@agent-native/core 0.209.2 → 0.209.3-nightly-20261016183441

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 (53) hide show
  1. package/dist/agent/context-xray/plugin.js +2 -6
  2. package/dist/agent/context-xray/schema-store.d.ts +1 -0
  3. package/dist/agent/context-xray/schema-store.js +7 -0
  4. package/dist/agent/harness/store.js +3 -0
  5. package/dist/agent/observational-memory/plugin.js +2 -6
  6. package/dist/agent/observational-memory/store.js +3 -0
  7. package/dist/agent/run-store.js +3 -0
  8. package/dist/agent/tool-approval-store.js +4 -0
  9. package/dist/automation/index.d.ts +1 -1
  10. package/dist/chat-threads/store.js +3 -0
  11. package/dist/db/migrations.d.ts +1 -0
  12. package/dist/db/migrations.js +1 -1
  13. package/dist/db/runtime-facts.d.ts +7 -0
  14. package/dist/db/runtime-facts.js +18 -0
  15. package/dist/db/schema-catalog.js +4 -1
  16. package/dist/db/store-ledger.test-helpers.d.ts +5 -0
  17. package/dist/db/store-ledger.test-helpers.js +19 -0
  18. package/dist/db/store-registry.d.ts +34 -0
  19. package/dist/db/store-registry.generated.js +9 -0
  20. package/dist/db/store-registry.js +230 -47
  21. package/dist/db/versioned-store-migrations.d.ts +14 -0
  22. package/dist/db/versioned-store-migrations.js +37 -0
  23. package/dist/db/widen-columns.js +5 -2
  24. package/dist/extensions/html-shell.js +67 -0
  25. package/dist/integrations/remote-devices-store.js +3 -0
  26. package/dist/jobs/run-history.d.ts +3 -2
  27. package/dist/jobs/run-history.js +5 -5
  28. package/dist/jobs/scheduler-health.d.ts +3 -2
  29. package/dist/jobs/scheduler-health.js +5 -5
  30. package/dist/oauth-tokens/store.js +3 -0
  31. package/dist/observability/routes.d.ts +7 -7
  32. package/dist/observability/store.js +4 -0
  33. package/dist/org/index.d.ts +1 -1
  34. package/dist/org/plugin.js +2 -4
  35. package/dist/org/schema-store.d.ts +1 -0
  36. package/dist/org/schema-store.js +13 -0
  37. package/dist/provider-api/actions/custom-provider-registration.d.ts +15 -15
  38. package/dist/provider-api/actions/provider-api.d.ts +16 -16
  39. package/dist/resources/handlers.d.ts +1 -1
  40. package/dist/resources/store.js +5 -2
  41. package/dist/secrets/routes.d.ts +10 -10
  42. package/dist/server/agent-engine-ollama-models-route.d.ts +2 -2
  43. package/dist/server/auth-plugin.js +2 -6
  44. package/dist/server/identity-sso-store.js +3 -0
  45. package/dist/server/release-migrations.js +0 -57
  46. package/dist/server/release-schema.js +10 -2
  47. package/dist/triggers/actions/manage-automation.d.ts +3 -3
  48. package/dist/triggers/event-queue.d.ts +4 -2
  49. package/dist/triggers/event-queue.js +38 -38
  50. package/dist/usage/alerts-store.js +3 -0
  51. package/dist/workspace-connections/groups.js +4 -0
  52. package/dist/workspace-connections/store.js +3 -0
  53. package/package.json +3 -3
@@ -1,8 +1,10 @@
1
1
  import { getDbExec } from "../db/client.js";
2
2
  import { ensureColumnExists, ensureTableExists } from "../db/ddl-guard.js";
3
3
  import { defineStore } from "../db/store-registry.js";
4
+ import { fromMigrationEntries } from "../db/versioned-store-migrations.js";
4
5
  import { widenIntColumnsToBigInt } from "../db/widen-columns.js";
5
6
  import { encryptSecretValue, decryptSecretValue, isEncryptedSecretValue, } from "../secrets/crypto.js";
7
+ import { OAUTH_TOKEN_MIGRATIONS, OAUTH_TOKEN_MIGRATIONS_TABLE, } from "./migrations.js";
6
8
  function serializeTokens(tokens) {
7
9
  return encryptSecretValue(JSON.stringify(tokens));
8
10
  }
@@ -79,6 +81,7 @@ export const oauthTokensStore = defineStore({
79
81
  await widenIntColumnsToBigInt("oauth_tokens", ["updated_at"], exec);
80
82
  },
81
83
  },
84
+ ...fromMigrationEntries(OAUTH_TOKEN_MIGRATIONS_TABLE, OAUTH_TOKEN_MIGRATIONS, { data: [4, 6] }),
82
85
  ],
83
86
  });
84
87
  export function ensureTable() {
@@ -27,43 +27,43 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
27
27
  thumbsUpRate: number;
28
28
  avgEvalScore: number;
29
29
  } | {
30
+ ok?: undefined;
30
31
  error: string;
31
32
  message: string;
32
33
  summary?: undefined;
33
34
  spans?: undefined;
34
- ok?: undefined;
35
35
  } | {
36
+ error?: undefined;
37
+ ok?: undefined;
36
38
  message?: undefined;
37
39
  summary: import("./types.js").TraceSummary;
38
40
  spans: import("./types.js").TraceSpan[];
41
+ } | {
39
42
  error?: undefined;
40
43
  ok?: undefined;
41
- } | {
42
44
  message?: undefined;
43
45
  summary?: undefined;
44
46
  spans?: undefined;
45
47
  traceMissing: true;
46
48
  id: string;
49
+ } | {
47
50
  error?: undefined;
48
51
  ok?: undefined;
49
- } | {
50
52
  message?: undefined;
51
53
  summary?: undefined;
52
54
  spans?: undefined;
53
55
  traceMissing?: undefined;
54
56
  id: string;
55
- error?: undefined;
56
- ok?: undefined;
57
57
  } | {
58
+ ok?: undefined;
58
59
  message?: undefined;
59
60
  summary?: undefined;
60
61
  spans?: undefined;
61
62
  error: any;
62
- ok?: undefined;
63
63
  } | {
64
+ error?: undefined;
64
65
  message?: undefined;
65
66
  summary?: undefined;
66
67
  spans?: undefined;
67
- error?: undefined;
68
68
  ok: boolean;
69
69
  }>>;
@@ -2,6 +2,8 @@ import { z } from "zod";
2
2
  import { getDbExec } from "../db/client.js";
3
3
  import { ensureTableExists, ensureColumnExists, ensureIndexExists, } from "../db/ddl-guard.js";
4
4
  import { defineStore } from "../db/store-registry.js";
5
+ import { fromMigrationEntries } from "../db/versioned-store-migrations.js";
6
+ import { OBSERVABILITY_MIGRATIONS, OBSERVABILITY_MIGRATIONS_TABLE, } from "./migrations.js";
5
7
  import { sanitizeToolErrorMessage, TOOL_ERROR_CAPTURE_METADATA_KEY, TOOL_ERROR_DETAIL_METADATA_KEY, } from "./trace-error.js";
6
8
  import { redactSensitiveFields } from "./trace-redaction.js";
7
9
  import { observabilityReviewThreadKey } from "./types.js";
@@ -118,6 +120,7 @@ function withUserFilter(baseWhere, baseArgs, userId, orgId) {
118
120
  }
119
121
  export const observabilityStore = defineStore({
120
122
  id: "observability",
123
+ after: ["chat_threads"],
121
124
  migrations: [
122
125
  {
123
126
  name: "baseline",
@@ -334,6 +337,7 @@ export const observabilityStore = defineStore({
334
337
  await ensureIndexExists("idx_experiment_results_exp", `CREATE INDEX IF NOT EXISTS idx_experiment_results_exp ON agent_experiment_results (experiment_id)`);
335
338
  },
336
339
  },
340
+ ...fromMigrationEntries(OBSERVABILITY_MIGRATIONS_TABLE, OBSERVABILITY_MIGRATIONS, { data: [1, 2, 3] }),
337
341
  ],
338
342
  });
339
343
  export function ensureObservabilityTables() {
@@ -161,9 +161,9 @@ export declare const getMyOrgHandler: import("h3").EventHandlerWithFetch<import(
161
161
  soloDeploymentAdmin: boolean;
162
162
  }>>;
163
163
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
164
+ name?: undefined;
164
165
  success: boolean;
165
166
  id?: undefined;
166
- name?: undefined;
167
167
  role?: undefined;
168
168
  } | {
169
169
  success?: undefined;
@@ -1,13 +1,12 @@
1
1
  import { defineEventHandler, setResponseStatus, getMethod, getRequestURL, } from "h3";
2
- import { runMigrations } from "../db/migrations.js";
3
2
  import { registerFeatureFlags } from "../feature-flags/registry.js";
4
3
  import { awaitBootstrap, getH3App, FRAMEWORK_PREFIX, markDefaultPluginProvided, } from "../server/framework-request-handler.js";
5
4
  import { listAppRolesHandler, setAppRoleHandler, getAppPermissionsHandler, setAppPermissionsHandler, resetAppPermissionHandler, } from "./app-roles-handlers.js";
6
5
  import { listSSOProvidersHandler, createSSOProviderHandler, verifySSOProviderHandler, deleteSSOProviderHandler, getSCIMHandler, createSCIMHandler, deleteSCIMHandler, } from "./enterprise-auth-handlers.js";
7
6
  import { CROSS_APP_ORG_FEDERATION_FLAG } from "./feature-flags.js";
8
7
  import { getMyOrgHandler, createOrgHandler, updateOrgHandler, deleteOrgHandler, switchOrgHandler, listMembersHandler, removeMemberHandler, retryPendingFederatedRemovalHandler, changeMemberRoleHandler, listInvitationsHandler, createInvitationHandler, acceptInvitationHandler, joinByDomainHandler, setDomainHandler, setWorkspaceUrlHandler, setRequiredAuthProviderHandler, revealA2ASecretHandler, setA2ASecretHandler, syncA2ASecretHandler, receiveA2ASecretHandler, setWorkspaceAppDefaultVisibilityHandler, setOrgVisualIdentityHandler, } from "./handlers.js";
9
- import { ORG_MIGRATIONS } from "./migrations.js";
10
8
  import { readWorkspacePrivateIconHandler, uploadWorkspacePrivateIconHandler, } from "./private-icon-handlers.js";
9
+ import { orgStore } from "./schema-store.js";
11
10
  const ORG_PREFIX = `${FRAMEWORK_PREFIX}/org`;
12
11
  async function workspaceIconUploadResponse(event) {
13
12
  try {
@@ -64,12 +63,11 @@ async function workspaceIconUploadResponse(event) {
64
63
  * POST /_agent-native/org/a2a-secret/receive — accept a peer's secret push (JWT-auth, no session)
65
64
  */
66
65
  export function createOrgPlugin() {
67
- const migrate = runMigrations(ORG_MIGRATIONS, { table: "_org_migrations" });
68
66
  return async (nitroApp) => {
69
67
  registerFeatureFlags([CROSS_APP_ORG_FEDERATION_FLAG]);
70
68
  markDefaultPluginProvided(nitroApp, "org");
71
69
  await awaitBootstrap(nitroApp);
72
- await migrate(nitroApp);
70
+ await orgStore.ready();
73
71
  const app = getH3App(nitroApp);
74
72
  app.use(`${ORG_PREFIX}/private-icons`, defineEventHandler(async (event) => {
75
73
  const tail = getRequestURL(event).pathname || "/";
@@ -0,0 +1 @@
1
+ export declare const orgStore: import("../db/store-registry.js").Store;
@@ -0,0 +1,13 @@
1
+ import { defineStore } from "../db/store-registry.js";
2
+ import { fromMigrationEntries } from "../db/versioned-store-migrations.js";
3
+ import { ORG_MIGRATIONS } from "./migrations.js";
4
+ export const orgStore = defineStore({
5
+ id: "org",
6
+ // Entries 1024 and 1032 touch the review-suggestion and audit tables; on main
7
+ // every store ran before this list, so keep that order at release.
8
+ after: ["audit", "review_suggestions"],
9
+ migrations: fromMigrationEntries("_org_migrations", ORG_MIGRATIONS, {
10
+ ranAtBoot: true,
11
+ data: [1009, 1018],
12
+ }),
13
+ });
@@ -75,9 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- id?: undefined;
79
78
  deleted?: undefined;
80
- message?: undefined;
79
+ id?: undefined;
80
+ provider?: undefined;
81
+ found?: undefined;
81
82
  providers: {
82
83
  id: string;
83
84
  label: string;
@@ -88,46 +89,45 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
88
89
  updatedAt: number;
89
90
  }[];
90
91
  count: number;
91
- provider?: undefined;
92
- found?: undefined;
93
92
  registered?: undefined;
94
93
  label?: undefined;
94
+ message?: undefined;
95
95
  } | {
96
- id?: undefined;
97
96
  deleted?: undefined;
98
- count?: undefined;
99
- message?: undefined;
97
+ id?: undefined;
100
98
  providers?: undefined;
99
+ count?: undefined;
101
100
  found: boolean;
102
101
  provider: import("../custom-registry.js").CustomProviderConfig;
103
102
  registered?: undefined;
104
103
  label?: undefined;
104
+ message?: undefined;
105
105
  } | {
106
106
  deleted?: undefined;
107
- count?: undefined;
108
- message?: undefined;
109
- providers?: undefined;
110
107
  provider?: undefined;
108
+ providers?: undefined;
109
+ count?: undefined;
111
110
  found: boolean;
112
111
  id: string;
113
112
  registered?: undefined;
114
113
  label?: undefined;
115
- } | {
116
- count?: undefined;
117
114
  message?: undefined;
118
- providers?: undefined;
115
+ } | {
119
116
  provider?: undefined;
120
117
  found?: undefined;
118
+ providers?: undefined;
119
+ count?: undefined;
121
120
  deleted: boolean;
122
121
  id: string;
123
122
  registered?: undefined;
124
123
  label?: undefined;
124
+ message?: undefined;
125
125
  } | {
126
126
  deleted?: undefined;
127
- count?: undefined;
128
- providers?: undefined;
129
127
  provider?: undefined;
130
128
  found?: undefined;
129
+ providers?: undefined;
130
+ count?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -316,7 +316,11 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
316
316
  notes?: string | undefined;
317
317
  scope?: "org" | "user" | undefined;
318
318
  }, {
319
+ provider?: undefined;
320
+ id?: undefined;
321
+ deleted?: undefined;
319
322
  message?: undefined;
323
+ found?: undefined;
320
324
  providers: {
321
325
  id: string;
322
326
  label: string;
@@ -327,48 +331,44 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
327
331
  updatedAt: number;
328
332
  }[];
329
333
  count: number;
330
- provider?: undefined;
331
- found?: undefined;
332
- deleted?: undefined;
333
334
  registered?: undefined;
334
- id?: undefined;
335
335
  label?: undefined;
336
336
  } | {
337
+ id?: undefined;
338
+ deleted?: undefined;
337
339
  message?: undefined;
338
- count?: undefined;
339
340
  providers?: undefined;
341
+ count?: undefined;
340
342
  found: boolean;
341
343
  provider: import("../custom-registry.js").CustomProviderConfig;
342
- deleted?: undefined;
343
344
  registered?: undefined;
344
- id?: undefined;
345
345
  label?: undefined;
346
346
  } | {
347
+ provider?: undefined;
348
+ deleted?: undefined;
347
349
  message?: undefined;
348
- count?: undefined;
349
350
  providers?: undefined;
350
- provider?: undefined;
351
+ count?: undefined;
351
352
  found: boolean;
352
353
  id: string;
353
- deleted?: undefined;
354
354
  registered?: undefined;
355
355
  label?: undefined;
356
356
  } | {
357
- message?: undefined;
358
- count?: undefined;
359
- providers?: undefined;
360
357
  provider?: undefined;
358
+ message?: undefined;
361
359
  found?: undefined;
360
+ providers?: undefined;
361
+ count?: undefined;
362
362
  deleted: boolean;
363
363
  id: string;
364
364
  registered?: undefined;
365
365
  label?: undefined;
366
366
  } | {
367
- count?: undefined;
368
- providers?: undefined;
369
367
  provider?: undefined;
370
- found?: undefined;
371
368
  deleted?: undefined;
369
+ found?: undefined;
370
+ providers?: undefined;
371
+ count?: undefined;
372
372
  registered: boolean;
373
373
  id: string;
374
374
  label: string;
@@ -39,8 +39,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
39
39
  error: string;
40
40
  }>;
41
41
  export declare function handleDeleteResource(event: any): Promise<{
42
- ok?: undefined;
43
42
  error: string;
43
+ ok?: undefined;
44
44
  } | {
45
45
  error?: undefined;
46
46
  ok: boolean;
@@ -3,6 +3,7 @@ import { getDbExec } from "../db/client.js";
3
3
  import { ensureColumnExists, ensureIndexExists, ensureTableExists, } from "../db/ddl-guard.js";
4
4
  import { isMigrationAuthorizedRuntime } from "../db/migration-runtime.js";
5
5
  import { retainRequestDbPoolScope } from "../db/request-pool-context.js";
6
+ import { isRecordingStoreMigration } from "../db/runtime-facts.js";
6
7
  import { defineStore } from "../db/store-registry.js";
7
8
  import { widenIntColumnsToBigInt } from "../db/widen-columns.js";
8
9
  import { noteJobFrontmatterWrite } from "../jobs/frontmatter-loss.js";
@@ -866,8 +867,9 @@ export const resourcesStore = defineStore({
866
867
  run: async () => {
867
868
  await ensureIndexExists("resources_visibility_expires_idx", `CREATE INDEX IF NOT EXISTS resources_visibility_expires_idx ON resources (visibility, expires_at)`).catch((err) => {
868
869
  // At release, fail so the ledger never records an index that was not built.
869
- if (isMigrationAuthorizedRuntime())
870
+ if (isMigrationAuthorizedRuntime() || isRecordingStoreMigration()) {
870
871
  throw err;
872
+ }
871
873
  // An index is an optimization, not a correctness requirement: a
872
874
  // concurrent creator or a permissions edge must not fail table init and
873
875
  // take the app down with it. The scan it avoids is slow, not wrong — but
@@ -889,8 +891,9 @@ export const resourcesStore = defineStore({
889
891
  // `CREATE INDEX CONCURRENTLY` without creating anything (see the matching
890
892
  // note in chat-threads/store.ts). A plain build is the form that lands.
891
893
  await ensureIndexExists("resources_path_pattern_idx", `CREATE INDEX IF NOT EXISTS resources_path_pattern_idx ON resources (path text_pattern_ops)`).catch((err) => {
892
- if (isMigrationAuthorizedRuntime())
894
+ if (isMigrationAuthorizedRuntime() || isRecordingStoreMigration()) {
893
895
  throw err;
896
+ }
894
897
  // coercion-ok: absence of an index degrades latency, never correctness
895
898
  console.warn("[resources] could not ensure resources_path_pattern_idx; prefix reads such as the jobs/ fingerprint will full-scan:", err?.message ?? err);
896
899
  });
@@ -57,39 +57,39 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
57
57
  } | {
58
58
  error: string;
59
59
  errorCode?: undefined;
60
- status?: undefined;
61
60
  ok?: undefined;
61
+ status?: undefined;
62
62
  } | {
63
63
  error: string;
64
64
  errorCode: string;
65
- status?: undefined;
66
65
  ok?: undefined;
66
+ status?: undefined;
67
67
  } | {
68
+ error?: undefined;
68
69
  errorCode?: undefined;
69
70
  ok: boolean;
70
71
  status: string;
71
- error?: undefined;
72
72
  } | {
73
+ ok?: undefined;
73
74
  error: string;
74
75
  removed?: undefined;
75
- ok?: undefined;
76
76
  } | {
77
+ error?: undefined;
77
78
  ok: boolean;
78
79
  removed: boolean;
79
- error?: undefined;
80
80
  }>>;
81
81
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
82
+ ok?: undefined;
82
83
  error: string;
83
84
  note?: undefined;
84
- ok?: undefined;
85
85
  } | {
86
+ error?: undefined;
86
87
  ok: boolean;
87
88
  note?: undefined;
88
- error?: undefined;
89
89
  } | {
90
+ error?: undefined;
90
91
  ok: boolean;
91
92
  note: string;
92
- error?: undefined;
93
93
  } | {
94
94
  note?: undefined;
95
95
  ok: boolean;
@@ -117,11 +117,11 @@ export declare function createAdHocSecretHandler(): import("h3").EventHandlerWit
117
117
  } | {
118
118
  error: string;
119
119
  } | {
120
+ error?: undefined;
120
121
  ok: boolean;
121
122
  key: string;
122
- error?: undefined;
123
123
  } | {
124
+ error?: undefined;
124
125
  ok: boolean;
125
126
  removed: boolean;
126
- error?: undefined;
127
127
  }>>;
@@ -1,9 +1,9 @@
1
1
  export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
2
2
  error: string;
3
- ok?: undefined;
4
3
  models?: undefined;
4
+ ok?: undefined;
5
5
  } | {
6
- error?: undefined;
7
6
  ok: boolean;
8
7
  models: string[];
8
+ error?: undefined;
9
9
  }>>;
@@ -1,12 +1,8 @@
1
- import { runMigrations } from "../db/migrations.js";
2
- import { ORG_MIGRATIONS } from "../org/migrations.js";
1
+ import { orgStore } from "../org/schema-store.js";
3
2
  import { authSessionHandler, autoMountAuth } from "./auth.js";
4
3
  import { runBetterAuthMigrations } from "./better-auth-migrations.js";
5
4
  import { FRAMEWORK_AUTH_EARLY_PATHS, getH3App, markDefaultPluginProvided, markFrameworkRoutesReadyBeforeBootstrap, trackPluginInit, } from "./framework-request-handler.js";
6
5
  export function createAuthPlugin(options) {
7
- const migrateOrgSchema = runMigrations(ORG_MIGRATIONS, {
8
- table: "_org_migrations",
9
- });
10
6
  return (nitroApp) => {
11
7
  markDefaultPluginProvided(nitroApp, "auth");
12
8
  const isByoa = Boolean(options?.getSession);
@@ -38,7 +34,7 @@ export function createAuthPlugin(options) {
38
34
  // transaction, where a missing table aborts the sign-up. The org
39
35
  // plugin migrates only after the whole bootstrap, too late for that.
40
36
  const mountPromise = runBetterAuthMigrations(nitroApp)
41
- .then(() => migrateOrgSchema(nitroApp))
37
+ .then(() => orgStore.ready())
42
38
  .then(() => autoMountAuth(app, options));
43
39
  markFrameworkRoutesReadyBeforeBootstrap(nitroApp, FRAMEWORK_AUTH_EARLY_PATHS);
44
40
  await mountPromise;
@@ -2,6 +2,8 @@ import { randomBytes } from "node:crypto";
2
2
  import { getDbExec, isConnectionError } from "../db/client.js";
3
3
  import { ensureTableExists } from "../db/ddl-guard.js";
4
4
  import { defineStore } from "../db/store-registry.js";
5
+ import { fromMigrationEntries } from "../db/versioned-store-migrations.js";
6
+ import { IDENTITY_SSO_MIGRATIONS } from "./identity-sso-migrations.js";
5
7
  const DESKTOP_SSO_USER_AGENT = /AgentNativeDesktop(?:SsoCanary)?\//i;
6
8
  const DESKTOP_SSO_CANARY_USER_AGENT = /AgentNativeDesktopSsoCanary\//i;
7
9
  export const CANONICAL_IDENTITY_SSO_HUB_URL = "https://dispatch.agent-native.com";
@@ -223,6 +225,7 @@ export const identitySsoStore = defineStore({
223
225
  await ensureTableExists("identity_sso_jti", buildIdentitySsoJtiCreateSql());
224
226
  },
225
227
  },
228
+ ...fromMigrationEntries("_identity_sso_migrations", IDENTITY_SSO_MIGRATIONS),
226
229
  ],
227
230
  });
228
231
  export function ensureTable() {
@@ -1,26 +1,9 @@
1
- import { CONTEXT_XRAY_MIGRATIONS } from "../agent/context-xray/migrations.js";
2
- import { AGENT_HARNESS_SESSION_MIGRATIONS, AGENT_HARNESS_SESSION_MIGRATIONS_TABLE, } from "../agent/harness/migrations.js";
3
- import { OBSERVATIONAL_MEMORY_MIGRATIONS } from "../agent/observational-memory/migrations.js";
4
- import { AGENT_RUN_MIGRATIONS, AGENT_RUN_MIGRATIONS_TABLE, } from "../agent/run-migrations.js";
5
- import { AGENT_TOOL_APPROVAL_MIGRATIONS, AGENT_TOOL_APPROVAL_MIGRATIONS_TABLE, } from "../agent/tool-approval-migrations.js";
6
1
  import { getAppConfig } from "../app-config/index.js";
7
- import { CHAT_THREAD_SCHEMA_MIGRATIONS, CHAT_THREAD_SCHEMA_MIGRATIONS_TABLE, } from "../chat-threads/schema-migrations.js";
8
2
  import { getDatabaseUrl } from "../db/client.js";
9
- import { runMigrations } from "../db/migrations.js";
10
3
  import { withStoreMigrationLock } from "../db/store-registry.js";
11
- import { REMOTE_DEVICE_MIGRATIONS, REMOTE_DEVICE_MIGRATIONS_TABLE, } from "../integrations/remote-device-migrations.js";
12
- import { runAutomationRunMigrations } from "../jobs/run-history.js";
13
- import { runAutomationSchedulerHealthMigrations } from "../jobs/scheduler-health.js";
14
- import { OAUTH_TOKEN_MIGRATIONS, OAUTH_TOKEN_MIGRATIONS_TABLE, } from "../oauth-tokens/migrations.js";
15
- import { OBSERVABILITY_MIGRATIONS, OBSERVABILITY_MIGRATIONS_TABLE, } from "../observability/migrations.js";
16
- import { ORG_MIGRATIONS } from "../org/migrations.js";
17
4
  import { ensureSharingAccessIndexes } from "../sharing/indexes.js";
18
- import { runAutomationTriggerEventMigrations } from "../triggers/event-queue.js";
19
- import { USAGE_ALERT_MIGRATIONS, USAGE_ALERT_MIGRATIONS_TABLE, } from "../usage/migrations.js";
20
- import { WORKSPACE_CONNECTIONS_MIGRATIONS, WORKSPACE_CONNECTIONS_MIGRATIONS_TABLE, } from "../workspace-connections/migrations.js";
21
5
  import { runBetterAuthMigrations } from "./better-auth-migrations.js";
22
6
  import { recordDatabaseIdentity } from "./database-identity.js";
23
- import { IDENTITY_SSO_MIGRATIONS } from "./identity-sso-migrations.js";
24
7
  import { runFrameworkSchemaEnsures } from "./release-schema.js";
25
8
  /**
26
9
  * A release deploy whose `DATABASE_URL` resolves to a local development
@@ -73,46 +56,6 @@ export async function runFrameworkReleaseMigrations(nitroApp) {
73
56
  await runFrameworkSchemaEnsures();
74
57
  await recordDatabaseIdentity();
75
58
  await runBetterAuthMigrations(nitroApp);
76
- await runMigrations(AGENT_TOOL_APPROVAL_MIGRATIONS, {
77
- table: AGENT_TOOL_APPROVAL_MIGRATIONS_TABLE,
78
- })(nitroApp);
79
- await runMigrations(OAUTH_TOKEN_MIGRATIONS, {
80
- table: OAUTH_TOKEN_MIGRATIONS_TABLE,
81
- })(nitroApp);
82
- await runMigrations(CHAT_THREAD_SCHEMA_MIGRATIONS, {
83
- table: CHAT_THREAD_SCHEMA_MIGRATIONS_TABLE,
84
- })(nitroApp);
85
- await runMigrations(OBSERVABILITY_MIGRATIONS, {
86
- table: OBSERVABILITY_MIGRATIONS_TABLE,
87
- })(nitroApp);
88
- await runMigrations(AGENT_RUN_MIGRATIONS, {
89
- table: AGENT_RUN_MIGRATIONS_TABLE,
90
- })(nitroApp);
91
- await runMigrations(AGENT_HARNESS_SESSION_MIGRATIONS, {
92
- table: AGENT_HARNESS_SESSION_MIGRATIONS_TABLE,
93
- })(nitroApp);
94
- await runMigrations(USAGE_ALERT_MIGRATIONS, {
95
- table: USAGE_ALERT_MIGRATIONS_TABLE,
96
- })(nitroApp);
97
- await runMigrations(ORG_MIGRATIONS, { table: "_org_migrations" })(nitroApp);
98
- await runMigrations(REMOTE_DEVICE_MIGRATIONS, {
99
- table: REMOTE_DEVICE_MIGRATIONS_TABLE,
100
- })(nitroApp);
101
- await runMigrations(IDENTITY_SSO_MIGRATIONS, {
102
- table: "_identity_sso_migrations",
103
- })(nitroApp);
104
- await runMigrations(CONTEXT_XRAY_MIGRATIONS, {
105
- table: "_context_xray_migrations",
106
- })(nitroApp);
107
- await runMigrations(OBSERVATIONAL_MEMORY_MIGRATIONS, {
108
- table: "_observational_memory_migrations",
109
- })(nitroApp);
110
- await runMigrations(WORKSPACE_CONNECTIONS_MIGRATIONS, {
111
- table: WORKSPACE_CONNECTIONS_MIGRATIONS_TABLE,
112
- })(nitroApp);
113
- await runAutomationRunMigrations(nitroApp);
114
- await runAutomationTriggerEventMigrations(nitroApp);
115
- await runAutomationSchedulerHealthMigrations(nitroApp);
116
59
  // Last, so the framework's own share and owner tables exist. An app's tables
117
60
  // are indexed by the release after the one that creates them.
118
61
  await ensureSharingAccessIndexes();
@@ -9,11 +9,16 @@
9
9
  */
10
10
  import { isMigrationAuthorizedRuntime } from "../db/migration-runtime.js";
11
11
  import { FRAMEWORK_STORES } from "../db/store-registry.generated.js";
12
- import { SchemaNotMigratedError, findUnappliedStoreMigrations, withStoreMigrationLock, } from "../db/store-registry.js";
12
+ import { SchemaNotMigratedError, findUnappliedStoreMigrations, orderStoresForRelease, withStoreMigrationLock, } from "../db/store-registry.js";
13
13
  const FRAMEWORK_SCHEMA_ENSURES = FRAMEWORK_STORES.map(([id, load]) => [id, () => load().then((store) => store.ready())]);
14
14
  export function frameworkSchemaEnsureNames() {
15
15
  return FRAMEWORK_SCHEMA_ENSURES.map(([name]) => name);
16
16
  }
17
+ /** Every registered store, loaded and ordered by its `after` dependencies. */
18
+ async function orderedFrameworkEnsures() {
19
+ const stores = await Promise.all(FRAMEWORK_STORES.map(([, load]) => load()));
20
+ return orderStoresForRelease(stores).map((store) => [store.id, () => store.ready()]);
21
+ }
17
22
  /**
18
23
  * Create every framework-owned table, in one pass, before the app serves
19
24
  * traffic. Callers must hold migration duty via `withMigrationRuntime`; without
@@ -31,8 +36,11 @@ export async function runFrameworkSchemaEnsures(ensures = FRAMEWORK_SCHEMA_ENSUR
31
36
  if (!isMigrationAuthorizedRuntime()) {
32
37
  throw new Error("runFrameworkSchemaEnsures must run inside withMigrationRuntime(); outside it no store is migrated.");
33
38
  }
39
+ const pass = ensures === FRAMEWORK_SCHEMA_ENSURES
40
+ ? await orderedFrameworkEnsures()
41
+ : ensures;
34
42
  await withStoreMigrationLock(async () => {
35
- for (const [name, run] of ensures) {
43
+ for (const [name, run] of pass) {
36
44
  try {
37
45
  await run();
38
46
  }
@@ -14,6 +14,7 @@ declare const _default: import("../../action.js").ActionDefinition<{
14
14
  executionCwd?: string;
15
15
  }, {
16
16
  deleted?: undefined;
17
+ enabled?: undefined;
17
18
  created: boolean;
18
19
  name: string;
19
20
  scope: "organization" | "personal";
@@ -24,25 +25,24 @@ declare const _default: import("../../action.js").ActionDefinition<{
24
25
  reasoningEffort: "auto" | "high" | "low" | "max" | "medium" | "minimal" | "none" | "xhigh";
25
26
  webhookPath: string;
26
27
  nextRun: string;
27
- enabled?: undefined;
28
28
  executionHostId?: undefined;
29
29
  executionEngine?: undefined;
30
30
  executionCwd?: undefined;
31
31
  } | {
32
+ enabled?: undefined;
33
+ nextRun?: undefined;
32
34
  created?: undefined;
33
35
  scope?: undefined;
34
36
  triggerType?: undefined;
35
37
  event?: undefined;
36
38
  deleted: boolean;
37
39
  name: string;
38
- enabled?: undefined;
39
40
  schedule?: undefined;
40
41
  timezone?: undefined;
41
42
  reasoningEffort?: undefined;
42
43
  executionHostId?: undefined;
43
44
  executionEngine?: undefined;
44
45
  executionCwd?: undefined;
45
- nextRun?: undefined;
46
46
  webhookPath?: undefined;
47
47
  } | {
48
48
  deleted?: undefined;
@@ -1,11 +1,13 @@
1
- import { type MigrationEntry } from "../db/migrations.js";
1
+ import type { MigrationEntry } from "../db/migrations.js";
2
2
  export declare const AUTOMATION_TRIGGER_EVENT_DEDUPE_RETENTION_MS: number;
3
3
  export declare const AUTOMATION_TRIGGER_EVENT_PURGE_BATCH_SIZE = 1000;
4
4
  export declare const AUTOMATION_TRIGGER_EVENT_EXPIRY_BATCH_SIZE = 1000;
5
5
  export declare const MAX_AUTOMATION_TRIGGER_EVENT_FAILURES = 8;
6
6
  declare const CLAIM_LEASE_MS: () => number;
7
7
  export declare const AUTOMATION_TRIGGER_EVENT_MIGRATIONS: MigrationEntry[];
8
- export declare function runAutomationTriggerEventMigrations(nitroApp: unknown): Promise<void>;
8
+ export declare const automationTriggerEventsStore: import("../db/store-registry.js").Store;
9
+ /** Kept for callers of the export; the store owns these migrations. */
10
+ export declare function runAutomationTriggerEventMigrations(_nitroApp?: unknown): Promise<void>;
9
11
  export declare function ensureAutomationTriggerEventQueue(): Promise<void>;
10
12
  export interface EnqueueAutomationTriggerEventInput {
11
13
  triggerId: string;