@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
@@ -1,4 +1,6 @@
1
- import { getActivePgliteTransactionClient, getRuntimeDatabaseUrl, isPgliteUrl, isConnectionError, getPgliteClient, loadPgliteDrizzle, pgliteDrizzleClient, pgPoolOptions, neonPoolOptions, guardNeonPool, withDbTimeout, retryOnConnectionError, dbOpTimeoutMs, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, assertHostedRuntimeDatabase, } from "./client.js";
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { sql } from "drizzle-orm";
3
+ import { annotateMissingTable, dbExecQueryBudget, getActivePgliteTransactionClient, getRuntimeDatabaseUrl, hasExplicitDbTimeout, isPgliteUrl, isConnectionError, getPgliteClient, loadPgliteDrizzle, pgliteDrizzleClient, pgPoolOptions, neonPoolOptions, guardNeonPool, withDbTimeout, retryOnConnectionError, dbOpTimeoutMs, sharedDbPool, toPostgresParams, withDbExec, onSharedDbPoolsClosed, onSharedDbPoolReplaced, postgresStatementTimeoutMs, assertHostedRuntimeDatabase, } from "./client.js";
2
4
  let _pgDrizzle;
3
5
  function getPgDrizzle() {
4
6
  if (!_pgDrizzle) {
@@ -25,6 +27,479 @@ function getNeonServerlessDrizzle() {
25
27
  }
26
28
  return _neonServerlessDrizzle;
27
29
  }
30
+ function drizzleRawQuery(text, params = []) {
31
+ const query = sql.raw(text);
32
+ query.toQuery = () => ({ sql: text, params });
33
+ return query;
34
+ }
35
+ function terminateNeonTransactionConnection(transaction) {
36
+ const client = transaction.session?.client;
37
+ const stream = client?.connection?.stream;
38
+ if (typeof client?.release === "function" &&
39
+ typeof stream?.destroy === "function") {
40
+ stream.destroy();
41
+ }
42
+ }
43
+ async function withTransactionStatementTimeout(transaction, run) {
44
+ const timeoutMs = dbOpTimeoutMs();
45
+ const statementTimeoutMs = postgresStatementTimeoutMs(timeoutMs);
46
+ const timeoutSql = `SELECT set_config('statement_timeout', CASE WHEN current_setting('statement_timeout')::interval <= interval '0' OR current_setting('statement_timeout')::interval > interval '${statementTimeoutMs}ms' THEN '${statementTimeoutMs}ms' ELSE current_setting('statement_timeout') END, true)`;
47
+ let timedOut = false;
48
+ let setupQuery;
49
+ try {
50
+ await withDbTimeout("query", () => (setupQuery = Promise.resolve(transaction.execute(drizzleRawQuery(timeoutSql)))), timeoutMs, () => {
51
+ timedOut = true;
52
+ terminateNeonTransactionConnection(transaction);
53
+ }, { sql: timeoutSql });
54
+ }
55
+ catch (err) {
56
+ if (timedOut && setupQuery)
57
+ await setupQuery.catch(() => { });
58
+ throw err;
59
+ }
60
+ return await run();
61
+ }
62
+ const activeDrizzleTransactionScope = new AsyncLocalStorage();
63
+ function createDrizzleTransactionQueryQueue(parent) {
64
+ return {
65
+ pending: Promise.resolve(),
66
+ parent,
67
+ active: true,
68
+ nestedTransactionActive: false,
69
+ };
70
+ }
71
+ function assertDrizzleTransactionQueryQueueActive(queue) {
72
+ for (let current = queue; current; current = current.parent) {
73
+ if (!current.active) {
74
+ throw new Error("Cannot use a database handle after its transaction has completed");
75
+ }
76
+ }
77
+ }
78
+ async function closeDrizzleTransactionQueryQueue(queue) {
79
+ queue.active = false;
80
+ await queue.pending;
81
+ }
82
+ function activeDrizzleTransactionScopeForQueue(queue) {
83
+ const activeScope = activeDrizzleTransactionScope.getStore();
84
+ if (!queue) {
85
+ if (activeScope)
86
+ assertDrizzleTransactionQueryQueueActive(activeScope.queue);
87
+ return activeScope;
88
+ }
89
+ assertDrizzleTransactionQueryQueueActive(queue);
90
+ for (let scope = activeScope; scope; scope = scope.parent) {
91
+ assertDrizzleTransactionQueryQueueActive(scope.queue);
92
+ for (let current = scope.queue; current; current = current.parent) {
93
+ if (current !== queue)
94
+ continue;
95
+ if (scope !== activeScope) {
96
+ throw new Error("Cannot use a database handle from an enclosing transaction while an independent transaction is active");
97
+ }
98
+ return scope;
99
+ }
100
+ }
101
+ return undefined;
102
+ }
103
+ function runInActiveDrizzleTransactionScope(scope, run) {
104
+ return activeDrizzleTransactionScope.run({ ...scope, parent: activeDrizzleTransactionScope.getStore() }, run);
105
+ }
106
+ function acquireDrizzleTransactionQuery(queue) {
107
+ const previous = queue.pending;
108
+ let release;
109
+ queue.pending = new Promise((resolve) => {
110
+ release = resolve;
111
+ });
112
+ return previous.then(() => release);
113
+ }
114
+ async function withDrizzleTransactionQuery(queue, run) {
115
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
116
+ const activeQueue = activeScope?.queue ?? queue;
117
+ if (!activeQueue)
118
+ return await run();
119
+ if (activeQueue.nestedTransactionActive) {
120
+ throw new Error("Cannot use a transaction handle while its nested transaction is active");
121
+ }
122
+ const release = await acquireDrizzleTransactionQuery(activeQueue);
123
+ try {
124
+ const currentQueue = activeDrizzleTransactionScopeForQueue(queue)?.queue ?? queue;
125
+ if (currentQueue?.nestedTransactionActive) {
126
+ throw new Error("Cannot use a transaction handle while its nested transaction is active");
127
+ }
128
+ return await run();
129
+ }
130
+ finally {
131
+ release();
132
+ }
133
+ }
134
+ function scopeDrizzlePreparedQuery(prepared, queue, sourceSession, prepareArgs) {
135
+ let hasToken = false;
136
+ let token;
137
+ const resolvePrepared = (target) => {
138
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
139
+ const session = activeScope?.transaction.session;
140
+ if (!session || session === sourceSession)
141
+ return target;
142
+ const rebound = session.prepareQuery(...prepareArgs);
143
+ if (hasToken)
144
+ rebound.setToken?.(token);
145
+ return rebound;
146
+ };
147
+ const scoped = new Proxy(prepared, {
148
+ get(target, prop) {
149
+ const value = Reflect.get(target, prop, target);
150
+ if (prop === "setToken" && typeof value === "function") {
151
+ return (nextToken) => {
152
+ hasToken = true;
153
+ token = nextToken;
154
+ value.call(target, nextToken);
155
+ return scoped;
156
+ };
157
+ }
158
+ if ((prop === "execute" || prop === "all" || prop === "values") &&
159
+ typeof value === "function") {
160
+ return (...args) => withDrizzleTransactionQuery(queue, () => {
161
+ const current = resolvePrepared(target);
162
+ return current[prop].apply(current, args);
163
+ });
164
+ }
165
+ return typeof value === "function" ? value.bind(target) : value;
166
+ },
167
+ });
168
+ return scoped;
169
+ }
170
+ function scopeDrizzleSessionQueries(session, queue) {
171
+ return new Proxy(session, {
172
+ get(target, prop, receiver) {
173
+ const value = Reflect.get(target, prop, target);
174
+ if (prop === "prepareQuery" && typeof value === "function") {
175
+ return (...args) => {
176
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
177
+ const queryQueue = queue ?? activeScope?.queue;
178
+ const querySession = activeScope?.transaction.session ?? target;
179
+ const prepared = querySession.prepareQuery(...args);
180
+ return scopeDrizzlePreparedQuery(prepared, queryQueue, querySession, args);
181
+ };
182
+ }
183
+ if ((prop === "query" || prop === "queryObjects") &&
184
+ typeof value === "function") {
185
+ return (...args) => withDrizzleTransactionQuery(queue, () => {
186
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
187
+ const querySession = activeScope?.transaction.session ?? target;
188
+ return querySession[prop].apply(querySession, args);
189
+ });
190
+ }
191
+ return typeof value === "function" ? value.bind(receiver) : value;
192
+ },
193
+ });
194
+ }
195
+ function scopeDrizzleRelationalPreparedQuery(prepared, getQuery, queue, prepareArgs, initialToken) {
196
+ let hasToken = initialToken !== undefined;
197
+ let token = initialToken?.value;
198
+ const scoped = new Proxy(prepared, {
199
+ get(target, prop) {
200
+ const value = Reflect.get(target, prop, target);
201
+ if (prop === "setToken" && typeof value === "function") {
202
+ return (nextToken) => {
203
+ hasToken = true;
204
+ token = nextToken;
205
+ value.call(target, nextToken);
206
+ return scoped;
207
+ };
208
+ }
209
+ if ((prop === "execute" || prop === "all" || prop === "values") &&
210
+ typeof value === "function") {
211
+ return (...args) => withDrizzleTransactionQuery(queue, () => {
212
+ const current = getQuery().prepare(...prepareArgs);
213
+ if (hasToken)
214
+ current.setToken?.(token);
215
+ return current[prop].apply(current, args);
216
+ });
217
+ }
218
+ return typeof value === "function" ? value.bind(target) : value;
219
+ },
220
+ });
221
+ return scoped;
222
+ }
223
+ function scopeDrizzleRelationalQuery(query, getQuery, queue, transactionSession) {
224
+ let hasToken = false;
225
+ let token;
226
+ const getScopedQuery = () => {
227
+ const current = getQuery();
228
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
229
+ if (transactionSession || activeScope) {
230
+ current.session =
231
+ activeScope?.transaction.session ??
232
+ transactionSession ??
233
+ current.session;
234
+ }
235
+ return current;
236
+ };
237
+ const execute = (...args) => withDrizzleTransactionQuery(queue, () => {
238
+ const current = getScopedQuery();
239
+ if (hasToken)
240
+ current.setToken?.(token);
241
+ return current.execute(...args);
242
+ });
243
+ const scoped = new Proxy(query, {
244
+ get(target, prop) {
245
+ const value = Reflect.get(target, prop, target);
246
+ if (prop === "setToken" && typeof value === "function") {
247
+ return (nextToken) => {
248
+ hasToken = true;
249
+ token = nextToken;
250
+ value.call(target, nextToken);
251
+ return scoped;
252
+ };
253
+ }
254
+ if (prop === "execute" && typeof value === "function")
255
+ return execute;
256
+ if (prop === "then" && typeof value === "function") {
257
+ return (onFulfilled, onRejected) => execute().then(onFulfilled, onRejected);
258
+ }
259
+ if (prop === "catch" && typeof value === "function") {
260
+ return (onRejected) => execute().catch(onRejected);
261
+ }
262
+ if (prop === "finally" && typeof value === "function") {
263
+ return (onFinally) => execute().finally(onFinally);
264
+ }
265
+ if (prop === "prepare" && typeof value === "function") {
266
+ return (...args) => {
267
+ const current = getScopedQuery();
268
+ return scopeDrizzleRelationalPreparedQuery(current.prepare(...args), getScopedQuery, queue, args, hasToken ? { value: token } : undefined);
269
+ };
270
+ }
271
+ return typeof value === "function" ? value.bind(target) : value;
272
+ },
273
+ });
274
+ return scoped;
275
+ }
276
+ function scopeDrizzleRelationalQueries(queries, transaction, queue) {
277
+ return new Proxy(queries, {
278
+ get(target, tableName) {
279
+ const builder = Reflect.get(target, tableName, target);
280
+ if (!builder || typeof builder !== "object")
281
+ return builder;
282
+ return new Proxy(builder, {
283
+ get(builderTarget, method) {
284
+ const value = Reflect.get(builderTarget, method, builderTarget);
285
+ if ((method !== "findFirst" && method !== "findMany") ||
286
+ typeof value !== "function") {
287
+ return typeof value === "function"
288
+ ? value.bind(builderTarget)
289
+ : value;
290
+ }
291
+ return (...args) => {
292
+ const getQuery = () => {
293
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
294
+ const activeTransaction = activeScope?.transaction ?? transaction;
295
+ return activeTransaction.query[tableName][method](...args);
296
+ };
297
+ return scopeDrizzleRelationalQuery(getQuery(), getQuery, queue);
298
+ };
299
+ },
300
+ });
301
+ },
302
+ });
303
+ }
304
+ function scopeDrizzleRootRelationalQueries(queries, queue, transactionSession) {
305
+ return new Proxy(queries, {
306
+ get(target, tableName) {
307
+ const builder = Reflect.get(target, tableName, target);
308
+ if (!builder || typeof builder !== "object")
309
+ return builder;
310
+ return new Proxy(builder, {
311
+ get(builderTarget, method) {
312
+ const value = Reflect.get(builderTarget, method, builderTarget);
313
+ if ((method !== "findFirst" && method !== "findMany") ||
314
+ typeof value !== "function") {
315
+ return typeof value === "function"
316
+ ? value.bind(builderTarget)
317
+ : value;
318
+ }
319
+ return (...args) => {
320
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
321
+ const queryQueue = queue ?? activeScope?.queue;
322
+ const querySession = activeScope?.transaction.session ?? transactionSession;
323
+ const getQuery = () => value.apply(builderTarget, args);
324
+ return scopeDrizzleRelationalQuery(getQuery(), getQuery, queryQueue, querySession);
325
+ };
326
+ },
327
+ });
328
+ },
329
+ });
330
+ }
331
+ async function withNestedDrizzleTransaction(transaction, queue, run) {
332
+ const activeScope = activeDrizzleTransactionScopeForQueue(queue);
333
+ const activeQueue = activeScope?.queue ?? queue;
334
+ const activeTransaction = activeScope?.transaction ?? transaction;
335
+ return await withDrizzleTransactionQuery(activeQueue, async () => {
336
+ activeQueue.nestedTransactionActive = true;
337
+ try {
338
+ return await activeTransaction.transaction(async (nested) => {
339
+ const nestedQueue = createDrizzleTransactionQueryQueue(activeQueue);
340
+ try {
341
+ await withTransactionStatementTimeout(nested, () => undefined);
342
+ return await runInActiveDrizzleTransactionScope({ queue: nestedQueue, transaction: nested }, () => run(nested, nestedQueue));
343
+ }
344
+ finally {
345
+ await closeDrizzleTransactionQueryQueue(nestedQueue);
346
+ }
347
+ });
348
+ }
349
+ finally {
350
+ activeQueue.nestedTransactionActive = false;
351
+ }
352
+ });
353
+ }
354
+ function drizzleTransactionExec(transaction, queryQueue = createDrizzleTransactionQueryQueue()) {
355
+ const executeStatement = async (statement, remainingMs, timedOut) => {
356
+ const query = typeof statement === "string" ? { sql: statement, args: [] } : statement;
357
+ const postgresSql = toPostgresParams(query.sql);
358
+ const args = (query.args ?? []).map((arg) => arg ?? null);
359
+ const prepared = drizzleRawQuery(postgresSql, args);
360
+ if (!hasExplicitDbTimeout(statement)) {
361
+ return await transaction.execute(prepared);
362
+ }
363
+ const currentTimeout = await transaction.execute(drizzleRawQuery("SELECT current_setting('statement_timeout') AS statement_timeout"));
364
+ const currentRows = Array.isArray(currentTimeout)
365
+ ? currentTimeout
366
+ : currentTimeout?.rows;
367
+ const previousTimeout = currentRows?.[0]?.statement_timeout;
368
+ if (typeof previousTimeout !== "string") {
369
+ throw new Error("Could not read the active statement timeout");
370
+ }
371
+ if (timedOut())
372
+ return undefined;
373
+ await transaction.execute(drizzleRawQuery(`SET LOCAL statement_timeout = ${postgresStatementTimeoutMs(remainingMs())}`));
374
+ const restoreTimeout = () => transaction.execute(drizzleRawQuery("SELECT set_config('statement_timeout', $1, true)", [
375
+ previousTimeout,
376
+ ]));
377
+ if (timedOut()) {
378
+ // Keep the transaction open until this reset finishes or rollback releases the local setting.
379
+ await restoreTimeout().catch(() => { });
380
+ return undefined;
381
+ }
382
+ let queryResult;
383
+ let queryError;
384
+ let queryFailed = false;
385
+ try {
386
+ queryResult = await transaction.execute(prepared);
387
+ }
388
+ catch (err) {
389
+ queryFailed = true;
390
+ queryError = err;
391
+ }
392
+ try {
393
+ await restoreTimeout();
394
+ }
395
+ catch (err) {
396
+ if (!queryFailed)
397
+ throw err;
398
+ }
399
+ if (queryFailed)
400
+ throw queryError;
401
+ return queryResult;
402
+ };
403
+ const execute = async (statement) => {
404
+ const query = typeof statement === "string" ? statement : statement.sql;
405
+ const { timeoutMs } = dbExecQueryBudget(statement);
406
+ const startedAt = Date.now();
407
+ const remainingMs = () => Math.max(1, timeoutMs - (Date.now() - startedAt));
408
+ let timedOut = false;
409
+ let started = false;
410
+ let inFlight;
411
+ let result;
412
+ try {
413
+ result = await withDbTimeout("query", () => {
414
+ inFlight = withDrizzleTransactionQuery(queryQueue, () => {
415
+ if (timedOut)
416
+ return Promise.resolve(undefined);
417
+ started = true;
418
+ return executeStatement(statement, remainingMs, () => timedOut);
419
+ });
420
+ return inFlight;
421
+ }, timeoutMs, () => {
422
+ timedOut = true;
423
+ if (started)
424
+ terminateNeonTransactionConnection(transaction);
425
+ }, { sql: query });
426
+ }
427
+ catch (err) {
428
+ // A caller can catch the timeout and continue, so drain any query already sent.
429
+ if (timedOut && started && inFlight)
430
+ await inFlight.catch(() => { });
431
+ throw annotateMissingTable(err, statement);
432
+ }
433
+ const rows = Array.isArray(result) ? result : result?.rows;
434
+ if (!Array.isArray(rows)) {
435
+ throw new Error("Drizzle transaction query returned no row array");
436
+ }
437
+ return {
438
+ rows,
439
+ rowsAffected: result.rowCount ?? result.count ?? result.affectedRows ?? rows.length,
440
+ };
441
+ };
442
+ const exec = {
443
+ execute,
444
+ };
445
+ exec.atomicBatch = async (statements) => {
446
+ const results = [];
447
+ for (const statement of statements)
448
+ results.push(await exec.execute(statement));
449
+ return results;
450
+ };
451
+ if (typeof transaction.transaction === "function") {
452
+ exec.transaction = (run) => withNestedDrizzleTransaction(transaction, queryQueue, (nested, queue) => {
453
+ const nestedExec = drizzleTransactionExec(nested, queue);
454
+ return withDbExec(nestedExec, () => run(nestedExec));
455
+ });
456
+ }
457
+ return exec;
458
+ }
459
+ function scopeDbExecToDrizzleTransactions(db, queryQueue) {
460
+ return new Proxy(db, {
461
+ get(target, prop, receiver) {
462
+ const value = Reflect.get(target, prop, target);
463
+ if (prop === "transaction" && typeof value === "function") {
464
+ return (run, ...args) => {
465
+ if (typeof run !== "function") {
466
+ return value.apply(target, [run, ...args]);
467
+ }
468
+ if (!queryQueue) {
469
+ if (activeDrizzleTransactionScopeForQueue()) {
470
+ throw new Error("Cannot start a root transaction while another transaction is active; use the transaction handle to create a savepoint");
471
+ }
472
+ const transactionQueue = createDrizzleTransactionQueryQueue();
473
+ return value.apply(target, [
474
+ async (transaction) => {
475
+ try {
476
+ return await withTransactionStatementTimeout(transaction, () => withDbExec(drizzleTransactionExec(transaction, transactionQueue), () => runInActiveDrizzleTransactionScope({ queue: transactionQueue, transaction }, () => run(scopeDbExecToDrizzleTransactions(transaction, transactionQueue)))));
477
+ }
478
+ finally {
479
+ await closeDrizzleTransactionQueryQueue(transactionQueue);
480
+ }
481
+ },
482
+ ...args,
483
+ ]);
484
+ }
485
+ return withNestedDrizzleTransaction(target, queryQueue, (transaction, nestedQueue) => withDbExec(drizzleTransactionExec(transaction, nestedQueue), () => run(scopeDbExecToDrizzleTransactions(transaction, nestedQueue))));
486
+ };
487
+ }
488
+ if (prop === "session" && value) {
489
+ const activeScope = activeDrizzleTransactionScopeForQueue(queryQueue);
490
+ return scopeDrizzleSessionQueries(value, queryQueue ?? activeScope?.queue);
491
+ }
492
+ if (prop === "query" && queryQueue && value) {
493
+ return scopeDrizzleRelationalQueries(value, target, queryQueue);
494
+ }
495
+ if (prop === "query" && value) {
496
+ const activeScope = activeDrizzleTransactionScopeForQueue();
497
+ return scopeDrizzleRootRelationalQueries(value, activeScope?.queue, activeScope?.transaction.session);
498
+ }
499
+ return typeof value === "function" ? value.bind(receiver) : value;
500
+ },
501
+ });
502
+ }
28
503
  /**
29
504
  * Returns true when a SQL string starts with a SELECT-class verb.
30
505
  * Used by the Neon resilience wrapper to decide retry safety:
@@ -235,7 +710,7 @@ export function createGetDb(schema) {
235
710
  const rawPool = sharedDbPool("neon", url, () => new Pool({ connectionString: url, ...neonPoolOptions() }));
236
711
  guardNeonPool(rawPool, url);
237
712
  const pool = buildResilientNeonPool(rawPool);
238
- _db = drizzle(pool, { schema });
713
+ _db = scopeDbExecToDrizzleTransactions(drizzle(pool, { schema }));
239
714
  return _db;
240
715
  });
241
716
  }
@@ -243,7 +718,7 @@ export function createGetDb(schema) {
243
718
  _dbReady = getPgDrizzle().then(({ drizzle, postgres }) => {
244
719
  resetOnPoolClose("postgres-js", url);
245
720
  const client = sharedDbPool("postgres-js", url, () => postgres(url, pgPoolOptions(url)));
246
- _db = drizzle(buildResilientPostgresJsClient(client), { schema });
721
+ _db = scopeDbExecToDrizzleTransactions(drizzle(buildResilientPostgresJsClient(client), { schema }));
247
722
  return _db;
248
723
  });
249
724
  }
@@ -18,6 +18,12 @@ import { collectImmutableAssetPaths, IMMUTABLE_ASSET_CACHE_HEADERS, } from "./im
18
18
  function workspaceFrameworkRoutePrefixEnv() {
19
19
  return (process.env.AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX?.trim() || "");
20
20
  }
21
+ function workspaceFrameworkRoutePrefixEnvSnippet() {
22
+ const frameworkRoutePrefix = workspaceFrameworkRoutePrefixEnv();
23
+ return frameworkRoutePrefix
24
+ ? ` processRef.env.AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX = ${JSON.stringify(frameworkRoutePrefix)};\n`
25
+ : " delete processRef.env.AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX;\n";
26
+ }
21
27
  function workspaceFrameworkRoutePrefix() {
22
28
  return normalizeFrameworkRoutePrefix(workspaceFrameworkRoutePrefixEnv() || undefined, "AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX");
23
29
  }
@@ -167,6 +173,7 @@ function buildOneApp(workspaceRoot, appsDir, app, preset, execFile, workspaceApp
167
173
  ? workspaceGatewayUrl
168
174
  : null);
169
175
  const workspaceOAuthUrl = workspaceOAuthOrigin(workspaceGatewayUrl);
176
+ const frameworkRoutePrefix = workspaceFrameworkRoutePrefixEnv();
170
177
  const env = {
171
178
  ...process.env,
172
179
  NITRO_PRESET: preset,
@@ -184,7 +191,6 @@ function buildOneApp(workspaceRoot, appsDir, app, preset, execFile, workspaceApp
184
191
  : {}),
185
192
  APP_BASE_PATH: `/${app}`,
186
193
  VITE_APP_BASE_PATH: `/${app}`,
187
- AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX: workspaceFrameworkRoutePrefixEnv(),
188
194
  AGENT_NATIVE_WORKSPACE_APP_AUDIENCE: workspaceAppAudience,
189
195
  AGENT_NATIVE_WORKSPACE_APP_PUBLIC_PATHS: JSON.stringify(workspaceAppRouteAccess.publicPaths),
190
196
  AGENT_NATIVE_WORKSPACE_APP_PROTECTED_PATHS: JSON.stringify(workspaceAppRouteAccess.protectedPaths),
@@ -206,6 +212,13 @@ function buildOneApp(workspaceRoot, appsDir, app, preset, execFile, workspaceApp
206
212
  : {}),
207
213
  [WORKSPACE_APPS_ENV_KEY]: JSON.stringify(workspaceApps),
208
214
  };
215
+ if (frameworkRoutePrefix) {
216
+ env.AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX =
217
+ frameworkRoutePrefix;
218
+ }
219
+ else {
220
+ delete env.AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX;
221
+ }
209
222
  if (preset === "netlify" && appUsesNetlifyUnpooledDatabaseUrl(appDir)) {
210
223
  env.DATABASE_URL =
211
224
  process.env.NETLIFY_DATABASE_URL_UNPOOLED ??
@@ -641,13 +654,13 @@ ${workspaceDirectoryEnvSnippet(workspaceApps)}
641
654
  VITE_AGENT_NATIVE_WORKSPACE_AUTH_MODE: ${JSON.stringify(workspaceAuthMode)},
642
655
  VITE_AGENT_NATIVE_WORKSPACE_APP_ID: ${JSON.stringify(app)},
643
656
  VITE_APP_BASE_PATH: basePath,
644
- AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX: ${JSON.stringify(workspaceFrameworkRoutePrefixEnv())},
645
657
  VITE_AGENT_NATIVE_WORKSPACE_APP_AUDIENCE: ${JSON.stringify(workspaceAppAudience)},
646
658
  VITE_AGENT_NATIVE_WORKSPACE_APP_PUBLIC_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.publicPaths))},
647
659
  VITE_AGENT_NATIVE_WORKSPACE_APP_PROTECTED_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.protectedPaths))},
648
660
  VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON: ${JSON.stringify(JSON.stringify(workspaceApps))},
649
661
  ${JSON.stringify(WORKSPACE_APPS_ENV_KEY)}: ${JSON.stringify(JSON.stringify(workspaceApps))},
650
662
  });
663
+ ${workspaceFrameworkRoutePrefixEnvSnippet()}
651
664
  }
652
665
 
653
666
  setBasePathEnv();
@@ -734,13 +747,13 @@ ${workspaceDirectoryEnvSnippet(workspaceApps)}
734
747
  VITE_AGENT_NATIVE_WORKSPACE_AUTH_MODE: ${JSON.stringify(workspaceAuthMode)},
735
748
  VITE_AGENT_NATIVE_WORKSPACE_APP_ID: ${JSON.stringify(app)},
736
749
  VITE_APP_BASE_PATH: basePath,
737
- AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX: ${JSON.stringify(workspaceFrameworkRoutePrefixEnv())},
738
750
  VITE_AGENT_NATIVE_WORKSPACE_APP_AUDIENCE: ${JSON.stringify(workspaceAppAudience)},
739
751
  VITE_AGENT_NATIVE_WORKSPACE_APP_PUBLIC_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.publicPaths))},
740
752
  VITE_AGENT_NATIVE_WORKSPACE_APP_PROTECTED_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.protectedPaths))},
741
753
  VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON: ${JSON.stringify(JSON.stringify(workspaceApps))},
742
754
  ${JSON.stringify(WORKSPACE_APPS_ENV_KEY)}: ${JSON.stringify(JSON.stringify(workspaceApps))},
743
755
  });
756
+ ${workspaceFrameworkRoutePrefixEnvSnippet()}
744
757
  }
745
758
 
746
759
  function enabled() {
@@ -865,13 +878,13 @@ ${workspaceDirectoryEnvSnippet(workspaceApps)}
865
878
  VITE_AGENT_NATIVE_WORKSPACE_AUTH_MODE: ${JSON.stringify(workspaceAuthMode)},
866
879
  VITE_AGENT_NATIVE_WORKSPACE_APP_ID: ${JSON.stringify(app)},
867
880
  VITE_APP_BASE_PATH: basePath,
868
- AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX: ${JSON.stringify(workspaceFrameworkRoutePrefixEnv())},
869
881
  VITE_AGENT_NATIVE_WORKSPACE_APP_AUDIENCE: ${JSON.stringify(workspaceAppAudience)},
870
882
  VITE_AGENT_NATIVE_WORKSPACE_APP_PUBLIC_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.publicPaths))},
871
883
  VITE_AGENT_NATIVE_WORKSPACE_APP_PROTECTED_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.protectedPaths))},
872
884
  VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON: ${JSON.stringify(JSON.stringify(workspaceApps))},
873
885
  ${JSON.stringify(WORKSPACE_APPS_ENV_KEY)}: ${JSON.stringify(JSON.stringify(workspaceApps))},
874
886
  });
887
+ ${workspaceFrameworkRoutePrefixEnvSnippet()}
875
888
  }
876
889
 
877
890
  setBasePathEnv();
@@ -928,13 +941,13 @@ ${workspaceDirectoryEnvSnippet(workspaceApps)}
928
941
  VITE_AGENT_NATIVE_WORKSPACE_AUTH_MODE: ${JSON.stringify(workspaceAuthMode)},
929
942
  VITE_AGENT_NATIVE_WORKSPACE_APP_ID: ${JSON.stringify(app)},
930
943
  VITE_APP_BASE_PATH: basePath,
931
- AGENT_NATIVE_CONFIG_RUNTIME_FRAMEWORK_ROUTE_PREFIX: ${JSON.stringify(workspaceFrameworkRoutePrefixEnv())},
932
944
  VITE_AGENT_NATIVE_WORKSPACE_APP_AUDIENCE: ${JSON.stringify(workspaceAppAudience)},
933
945
  VITE_AGENT_NATIVE_WORKSPACE_APP_PUBLIC_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.publicPaths))},
934
946
  VITE_AGENT_NATIVE_WORKSPACE_APP_PROTECTED_PATHS: ${JSON.stringify(JSON.stringify(workspaceAppRouteAccess.protectedPaths))},
935
947
  VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON: ${JSON.stringify(JSON.stringify(workspaceApps))},
936
948
  ${JSON.stringify(WORKSPACE_APPS_ENV_KEY)}: ${JSON.stringify(JSON.stringify(workspaceApps))},
937
949
  });
950
+ ${workspaceFrameworkRoutePrefixEnvSnippet()}
938
951
  }
939
952
 
940
953
  function normalizeBasePathArgs(args) {
@@ -33,9 +33,9 @@ declare const _default: import("../../action.js").ActionDefinition<{
33
33
  idempotencyKey: string;
34
34
  deleted: boolean;
35
35
  } | {
36
+ id?: undefined;
36
37
  error: string;
37
38
  url?: undefined;
38
- id?: undefined;
39
39
  provider?: undefined;
40
40
  configured?: undefined;
41
41
  } | {
@@ -45,8 +45,8 @@ declare const _default: import("../../action.js").ActionDefinition<{
45
45
  configured?: undefined;
46
46
  error?: undefined;
47
47
  } | {
48
- url?: undefined;
49
48
  id?: undefined;
49
+ url?: undefined;
50
50
  provider?: undefined;
51
51
  error: string;
52
52
  configured: boolean;
@@ -11,9 +11,9 @@ declare const _default: import("../../action.js").ActionDefinition<{
11
11
  enabled?: undefined;
12
12
  nextRun?: undefined;
13
13
  } | {
14
- deleted?: undefined;
15
14
  name: string;
16
15
  enabled: boolean;
17
16
  nextRun: string;
17
+ deleted?: undefined;
18
18
  }>;
19
19
  export default _default;
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
37
37
  revoke: "إلغاء",
38
38
  couldNotRevoke: "تعذر إلغاء الرمز.",
39
39
  authorizeDevice: "تخويل الجهاز",
40
+ organization: "المؤسسة",
41
+ invalidOrganization: "اختر مؤسسة أنت عضو فيها.",
40
42
  fullCatalogRequested: "يطلب هذا الجهاز الوصول إلى كتالوج الإجراءات الكامل.",
41
43
  createToken: "إنشاء رمز اتصال",
42
44
  authorizingDevice: "جارٍ تخويل الجهاز...",
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
37
37
  revoke: "Widerrufen",
38
38
  couldNotRevoke: "Token konnte nicht widerrufen werden.",
39
39
  authorizeDevice: "Gerät autorisieren",
40
+ organization: "Organisation",
41
+ invalidOrganization: "Wähle eine Organisation, der du angehörst.",
40
42
  fullCatalogRequested: "Dieses Gerät fordert Zugriff auf den vollständigen Aktionskatalog an.",
41
43
  createToken: "Verbindungstoken erstellen",
42
44
  authorizingDevice: "Gerät wird autorisiert...",
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
37
37
  revoke: "Revoke",
38
38
  couldNotRevoke: "Could not revoke token.",
39
39
  authorizeDevice: "Authorize device",
40
+ organization: "Organization",
41
+ invalidOrganization: "Choose an organization you belong to.",
40
42
  fullCatalogRequested: "This device is requesting access to the full action catalog.",
41
43
  createToken: "Create connection token",
42
44
  authorizingDevice: "Authorizing device...",
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
37
37
  revoke: "Revocar",
38
38
  couldNotRevoke: "No se pudo revocar el token.",
39
39
  authorizeDevice: "Autorizar dispositivo",
40
+ organization: "Organización",
41
+ invalidOrganization: "Elige una organización a la que pertenezcas.",
40
42
  fullCatalogRequested: "Este dispositivo solicita acceso al catálogo completo de acciones.",
41
43
  createToken: "Crear token de conexión",
42
44
  authorizingDevice: "Autorizando dispositivo...",