@agent-native/core 0.198.3-nightly-20260930154911 → 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.
@@ -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,
@@ -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
  }
@@ -38,19 +38,19 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
38
38
  error: string;
39
39
  states?: undefined;
40
40
  } | {
41
- error?: undefined;
42
41
  states: {
43
42
  clientId: number;
44
43
  state: string;
45
44
  }[];
45
+ error?: undefined;
46
46
  }>>;
47
47
  export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
48
48
  error: string;
49
49
  users?: undefined;
50
50
  } | {
51
- error?: undefined;
52
51
  users: {
53
52
  clientId: number;
54
53
  lastSeen: number;
55
54
  }[];
55
+ error?: undefined;
56
56
  }>>;
@@ -8,8 +8,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
8
8
  state: string;
9
9
  }>>;
10
10
  export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
11
- ok?: undefined;
12
11
  error: string;
12
+ ok?: undefined;
13
13
  } | {
14
14
  error?: undefined;
15
15
  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();
@@ -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
  }
@@ -33,11 +33,11 @@ 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
39
  provider?: undefined;
39
40
  configured?: undefined;
40
- id?: undefined;
41
41
  } | {
42
42
  url: string;
43
43
  id: string;
@@ -45,10 +45,10 @@ declare const _default: import("../../action.js").ActionDefinition<{
45
45
  configured?: undefined;
46
46
  error?: undefined;
47
47
  } | {
48
+ id?: undefined;
48
49
  url?: undefined;
49
50
  provider?: undefined;
50
51
  error: string;
51
52
  configured: boolean;
52
- id?: undefined;
53
53
  }>;
54
54
  export default _default;
@@ -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;
@@ -16,6 +16,6 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
16
16
  } | {
17
17
  count?: undefined;
18
18
  updated?: undefined;
19
- error?: undefined;
20
19
  ok: boolean;
20
+ error?: undefined;
21
21
  }>>;
@@ -72,8 +72,8 @@ export declare const setWorkspaceAppDefaultVisibilityHandler: import("h3").Event
72
72
  }>>;
73
73
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
74
74
  success: boolean;
75
- name?: undefined;
76
75
  id?: undefined;
76
+ name?: undefined;
77
77
  role?: undefined;
78
78
  } | {
79
79
  success?: undefined;
@@ -312,5 +312,5 @@ export declare const setAppRoleHandler: import("h3").EventHandlerWithFetch<impor
312
312
  email: string;
313
313
  roles: any[];
314
314
  }>>;
315
- export { isFreeEmailProvider } from "./free-email-providers.js";
315
+ export { FREE_EMAIL_PROVIDER_DOMAINS, isFreeEmailProvider, } from "./free-email-providers.js";
316
316
  export { isOrgMember } from "./membership.js";
package/dist/org/index.js CHANGED
@@ -75,5 +75,5 @@ export const setWorkspaceAppDefaultVisibilityHandler = lazyFunction(loadOrgHandl
75
75
  export const setOrgVisualIdentityHandler = lazyFunction(loadOrgHandlers, "setOrgVisualIdentityHandler");
76
76
  export const listAppRolesHandler = lazyFunction(loadOrgAppRolesHandlers, "listAppRolesHandler");
77
77
  export const setAppRoleHandler = lazyFunction(loadOrgAppRolesHandlers, "setAppRoleHandler");
78
- export { isFreeEmailProvider } from "./free-email-providers.js";
78
+ export { FREE_EMAIL_PROVIDER_DOMAINS, isFreeEmailProvider, } from "./free-email-providers.js";
79
79
  export { isOrgMember } from "./membership.js";
@@ -75,10 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- message?: undefined;
79
78
  id?: undefined;
80
- deleted?: undefined;
79
+ message?: undefined;
81
80
  found?: undefined;
81
+ deleted?: undefined;
82
82
  providers: {
83
83
  id: string;
84
84
  label: string;
@@ -93,11 +93,11 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
93
93
  registered?: undefined;
94
94
  label?: undefined;
95
95
  } | {
96
- message?: undefined;
97
96
  id?: undefined;
97
+ message?: undefined;
98
98
  deleted?: undefined;
99
- count?: undefined;
100
99
  providers?: undefined;
100
+ count?: undefined;
101
101
  found: boolean;
102
102
  provider: import("../custom-registry.js").CustomProviderConfig;
103
103
  registered?: undefined;
@@ -105,8 +105,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
105
105
  } | {
106
106
  message?: undefined;
107
107
  deleted?: undefined;
108
- count?: undefined;
109
108
  providers?: undefined;
109
+ count?: undefined;
110
110
  provider?: undefined;
111
111
  found: boolean;
112
112
  id: string;
@@ -115,18 +115,18 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
115
115
  } | {
116
116
  message?: undefined;
117
117
  found?: undefined;
118
- count?: undefined;
119
118
  providers?: undefined;
119
+ count?: undefined;
120
120
  provider?: undefined;
121
121
  deleted: boolean;
122
122
  id: string;
123
123
  registered?: undefined;
124
124
  label?: undefined;
125
125
  } | {
126
- deleted?: undefined;
127
126
  found?: undefined;
128
- count?: undefined;
127
+ deleted?: undefined;
129
128
  providers?: undefined;
129
+ count?: undefined;
130
130
  provider?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
@@ -311,9 +311,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
311
311
  notes?: string | undefined;
312
312
  scope?: "org" | "user" | undefined;
313
313
  }, {
314
+ id?: undefined;
314
315
  provider?: undefined;
315
316
  deleted?: undefined;
316
- id?: undefined;
317
317
  message?: undefined;
318
318
  found?: undefined;
319
319
  providers: {
@@ -329,11 +329,11 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
329
329
  registered?: undefined;
330
330
  label?: undefined;
331
331
  } | {
332
- deleted?: undefined;
333
332
  id?: undefined;
333
+ deleted?: undefined;
334
+ count?: undefined;
334
335
  message?: undefined;
335
336
  providers?: undefined;
336
- count?: undefined;
337
337
  found: boolean;
338
338
  provider: import("../custom-registry.js").CustomProviderConfig;
339
339
  registered?: undefined;
@@ -341,19 +341,19 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
341
341
  } | {
342
342
  provider?: undefined;
343
343
  deleted?: undefined;
344
+ count?: undefined;
344
345
  message?: undefined;
345
346
  providers?: undefined;
346
- count?: undefined;
347
347
  found: boolean;
348
348
  id: string;
349
349
  registered?: undefined;
350
350
  label?: undefined;
351
351
  } | {
352
352
  provider?: undefined;
353
+ count?: undefined;
353
354
  message?: undefined;
354
355
  found?: undefined;
355
356
  providers?: undefined;
356
- count?: undefined;
357
357
  deleted: boolean;
358
358
  id: string;
359
359
  registered?: undefined;
@@ -361,9 +361,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
361
361
  } | {
362
362
  provider?: undefined;
363
363
  deleted?: undefined;
364
+ count?: undefined;
364
365
  found?: undefined;
365
366
  providers?: undefined;
366
- count?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -73,7 +73,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
73
73
  offset?: unknown;
74
74
  limit?: unknown;
75
75
  }, {
76
- deleted?: undefined;
77
76
  jobs: {
78
77
  id: string;
79
78
  name: string;
@@ -84,6 +83,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
84
83
  updatedAt: string;
85
84
  }[];
86
85
  total: number;
86
+ deleted?: undefined;
87
87
  jobId?: undefined;
88
88
  } | {
89
89
  jobs?: undefined;
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
91
91
  deleted: boolean;
92
92
  jobId: string;
93
93
  } | {
94
- deleted?: undefined;
95
94
  jobs?: undefined;
96
95
  total?: undefined;
96
+ deleted?: undefined;
97
97
  jobId?: undefined;
98
98
  hits: Record<string, unknown>[];
99
99
  offset: number;
@@ -55,39 +55,39 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
55
55
  } | {
56
56
  error: string;
57
57
  errorCode?: undefined;
58
- ok?: undefined;
59
58
  status?: undefined;
59
+ ok?: undefined;
60
60
  } | {
61
61
  error: string;
62
62
  errorCode: string;
63
- ok?: undefined;
64
63
  status?: undefined;
64
+ ok?: undefined;
65
65
  } | {
66
- error?: undefined;
67
66
  errorCode?: undefined;
68
67
  ok: boolean;
69
68
  status: string;
69
+ error?: undefined;
70
70
  } | {
71
- ok?: undefined;
72
71
  error: string;
73
72
  removed?: undefined;
73
+ ok?: undefined;
74
74
  } | {
75
- error?: undefined;
76
75
  ok: boolean;
77
76
  removed: boolean;
77
+ error?: undefined;
78
78
  }>>;
79
79
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
80
- ok?: undefined;
81
80
  error: string;
82
81
  note?: undefined;
82
+ ok?: undefined;
83
83
  } | {
84
- error?: undefined;
85
84
  ok: boolean;
86
85
  note?: undefined;
87
- } | {
88
86
  error?: undefined;
87
+ } | {
89
88
  ok: boolean;
90
89
  note: string;
90
+ error?: undefined;
91
91
  } | {
92
92
  note?: undefined;
93
93
  ok: boolean;
@@ -115,11 +115,11 @@ export declare function createAdHocSecretHandler(): import("h3").EventHandlerWit
115
115
  } | {
116
116
  error: string;
117
117
  } | {
118
- error?: undefined;
119
118
  ok: boolean;
120
119
  key: string;
121
- } | {
122
120
  error?: undefined;
121
+ } | {
123
122
  ok: boolean;
124
123
  removed: boolean;
124
+ error?: undefined;
125
125
  }>>;
@@ -9,16 +9,16 @@ export declare const AGENT_ENGINE_API_KEY_ACTION_NAME = "agent-engine-api-key";
9
9
  */
10
10
  export declare function createAgentEngineDisconnectHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
11
11
  error: string;
12
- scope?: undefined;
13
12
  ok?: undefined;
13
+ scope?: undefined;
14
14
  } | {
15
15
  ok: boolean;
16
16
  error: any;
17
17
  scope?: undefined;
18
18
  } | {
19
+ error?: undefined;
19
20
  ok: boolean;
20
21
  scope: "org" | "user";
21
- error?: undefined;
22
22
  }>>;
23
23
  export interface DefaultModelSelectionRequest {
24
24
  engine: string;
@@ -1,6 +1,6 @@
1
1
  export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
2
- ok?: undefined;
3
2
  error: string;
3
+ ok?: undefined;
4
4
  models?: undefined;
5
5
  } | {
6
6
  error?: undefined;
@@ -1,6 +1,6 @@
1
1
  import { and, eq, isNull, or, sql } from "drizzle-orm";
2
2
  import { drizzle as drizzleProxy } from "drizzle-orm/pg-proxy";
3
- import { withDbExec } from "../db/client.js";
3
+ import { getScopedDbExec, withDbExec } from "../db/client.js";
4
4
  import { evaluateFeatureFlagStrict } from "../feature-flags/store.js";
5
5
  import { CROSS_APP_ORG_FEDERATION_FLAG } from "../org/feature-flags.js";
6
6
  import { isMissingOrganizationTableError } from "../org/membership.js";
@@ -322,17 +322,18 @@ export async function resolveAccess(resourceType, resourceId, rawCtx = currentAc
322
322
  }
323
323
  async function resolveAccessImpl(resourceType, resourceId, rawCtx = currentAccess(), options = {}) {
324
324
  const registered = requireShareableResource(resourceType);
325
- const transaction = rawCtx.transaction;
325
+ const transaction = rawCtx.transaction ?? getScopedDbExec();
326
326
  const transactionDb = transaction
327
327
  ? drizzleProxy(async (query, params) => {
328
328
  const result = await transaction.execute({ sql: query, args: params });
329
329
  return { rows: result.rows.map((row) => Object.values(row)) };
330
330
  })
331
331
  : null;
332
+ const transactionCtx = transaction ? { ...rawCtx, transaction } : rawCtx;
332
333
  const reg = transactionDb
333
334
  ? { ...registered, getDb: () => transactionDb }
334
335
  : registered;
335
- const ctx = resolveRegisteredAccessContext(reg, rawCtx);
336
+ const ctx = resolveRegisteredAccessContext(reg, transactionCtx);
336
337
  const resource = await loadResourceForAccess(reg, resourceId, options);
337
338
  if (!resource)
338
339
  return null;
@@ -2208,12 +2208,20 @@ function ssrStubPlugin(packages) {
2208
2208
  load(id) {
2209
2209
  if (id !== STUB_ID)
2210
2210
  return null;
2211
- return ("const handler = { get(_, p) { " +
2211
+ return ("function makeStub() { return new Proxy(makeStub, resultHandler); } " +
2212
+ "const handler = { get(_, p) { " +
2212
2213
  "if (p === Symbol.toPrimitive) return () => ''; " +
2213
2214
  "if (p === 'then') return undefined; " +
2214
- "return new Proxy(() => {}, handler); " +
2215
+ "return new Proxy(makeStub, handler); " +
2215
2216
  "} };" +
2216
- "const stub = new Proxy(() => {}, handler);" +
2217
+ "const resultHandler = { get(_, p) { " +
2218
+ "if (p === Symbol.toPrimitive) return () => ''; " +
2219
+ "if (p === 'then') return (resolve) => { " +
2220
+ "if (typeof resolve === 'function') resolve(''); " +
2221
+ "return new Proxy(makeStub, resultHandler); }; " +
2222
+ "return new Proxy(makeStub, resultHandler); " +
2223
+ "} };" +
2224
+ "const stub = new Proxy(makeStub, handler);" +
2217
2225
  "export default stub;" +
2218
2226
  namedExports.map((name) => `export const ${name} = stub;`).join(""));
2219
2227
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.198.3-nightly-20260930154911",
3
+ "version": "0.198.3",
4
4
  "description": "The agentic application framework for building autonomous agents with intuitive UIs",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -659,8 +659,8 @@
659
659
  "yaml": "^2.9.0",
660
660
  "yjs": "^13.6.33",
661
661
  "zod": "^4.3.6",
662
- "@agent-native/agentkit": "^0.198.3-nightly-20260930154911",
663
- "@agent-native/recap-cli": "^0.5.52"
662
+ "@agent-native/agentkit": "^0.198.3",
663
+ "@agent-native/recap-cli": "^0.5.53"
664
664
  },
665
665
  "devDependencies": {
666
666
  "@ai-sdk/anthropic": "^3.0.71",
@@ -732,7 +732,7 @@
732
732
  "xlsx": "^0.18.5"
733
733
  },
734
734
  "peerDependencies": {
735
- "@agent-native/core-corpus": "0.198.3-nightly-20260930154911",
735
+ "@agent-native/core-corpus": ">=0.196.0",
736
736
  "@ai-sdk/anthropic": ">=3",
737
737
  "@ai-sdk/cohere": ">=3",
738
738
  "@ai-sdk/google": ">=3",