@keystrokehq/cli 0.1.119 → 0.1.121

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as __require, t as __commonJSMin } from "./chunk-DiodbrVj.mjs";
3
- import { Br as custom, Dr as requiredDisplayTextSchema, Er as parseStoredRouteManifest, Fr as _function, Ir as _null, Kr as number, Nr as ZodType, Pr as _enum, Qr as union, Rr as array, Sr as normalizeCredentialList, Ur as lazy, Vr as discriminatedUnion, Wr as literal, Xr as record, Yr as preprocess, Zr as string, _r as credentialInputSchema, dn as PromptResponseSchema, fn as PublicModelsResponseSchema, hn as ROUTE_MANIFEST_REL_PATH, ni as toJSONSchema, qr as object, tt as DEFAULT_CLOUD_PLATFORM_ORIGIN, ut as FilePartSchema, zr as boolean$1 } from "./dist-Cv14W_rK.mjs";
4
- import "./dist-Dapwh1K9.mjs";
3
+ import { $r as number, Br as ZodType, Gr as array, Hr as _function, Jr as discriminatedUnion, Kr as boolean$1, Nr as parseStoredRouteManifest, Pr as requiredDisplayTextSchema, Ur as _null, Vr as _enum, Xr as lazy, Zr as literal, ai as union, bn as ROUTE_MANIFEST_REL_PATH, ei as object, fn as PromptResponseSchema, gn as PublicModelsResponseSchema, ii as string, kr as normalizeCredentialList, li as toJSONSchema, ni as preprocess, qr as custom, ri as record, tt as DEFAULT_CLOUD_PLATFORM_ORIGIN, ut as FilePartSchema, wr as credentialInputSchema } from "./dist-CPu6Uh2o.mjs";
4
+ import "./dist-_HOtlAw_.mjs";
5
5
  import "./chunk-BZUGFHVS-CPWRFwK8.mjs";
6
6
  import "./chunk-DLL7UR66-BUYgzxnR.mjs";
7
7
  import "./chunk-TN7HHBQW-CSB_R-XD.mjs";
@@ -2726,7 +2726,7 @@ function buildPgSchema$1(registry) {
2726
2726
  function buildSqliteSchema$1(registry) {
2727
2727
  return Object.fromEntries(Object.entries(registry).map(([name, { sqlite }]) => [name, sqlite]));
2728
2728
  }
2729
- const agents = pgTable("agents", {
2729
+ const agents$1 = pgTable("agents", {
2730
2730
  id: text("id").primaryKey(),
2731
2731
  projectId: text("project_id").notNull(),
2732
2732
  slug: text("slug").notNull(),
@@ -2743,7 +2743,7 @@ const agents = pgTable("agents", {
2743
2743
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2744
2744
  deletedAt: timestamp("deleted_at", { withTimezone: true })
2745
2745
  }, (table) => [uniqueIndex("agents_project_id_slug_idx").on(table.projectId, table.slug), uniqueIndex("agents_project_id_route_idx").on(table.projectId, table.route)]);
2746
- const agentsSqlite = sqliteTable("agents", {
2746
+ const agentsSqlite$1 = sqliteTable("agents", {
2747
2747
  id: text$1("id").primaryKey(),
2748
2748
  projectId: text$1("project_id").notNull(),
2749
2749
  slug: text$1("slug").notNull(),
@@ -2760,10 +2760,10 @@ const agentsSqlite = sqliteTable("agents", {
2760
2760
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2761
2761
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2762
2762
  }, (table) => [uniqueIndex$1("agents_project_id_slug_idx").on(table.projectId, table.slug), uniqueIndex$1("agents_project_id_route_idx").on(table.projectId, table.route)]);
2763
- const agentSessions = pgTable("agent_sessions", {
2763
+ const agentSessions$1 = pgTable("agent_sessions", {
2764
2764
  id: text("id").primaryKey(),
2765
2765
  projectId: text("project_id").notNull(),
2766
- agentId: text("agent_id").notNull().references(() => agents.id),
2766
+ agentId: text("agent_id").notNull().references(() => agents$1.id),
2767
2767
  sourceKind: text("source_kind").$type().notNull().default("api"),
2768
2768
  sourceId: text("source_id"),
2769
2769
  parentSpanId: text("parent_span_id"),
@@ -2776,10 +2776,10 @@ const agentSessions = pgTable("agent_sessions", {
2776
2776
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2777
2777
  deletedAt: timestamp("deleted_at", { withTimezone: true })
2778
2778
  }, (table) => [index("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
2779
- const agentSessionsSqlite = sqliteTable("agent_sessions", {
2779
+ const agentSessionsSqlite$1 = sqliteTable("agent_sessions", {
2780
2780
  id: text$1("id").primaryKey(),
2781
2781
  projectId: text$1("project_id").notNull(),
2782
- agentId: text$1("agent_id").notNull().references(() => agentsSqlite.id),
2782
+ agentId: text$1("agent_id").notNull().references(() => agentsSqlite$1.id),
2783
2783
  sourceKind: text$1("source_kind").$type().notNull().default("api"),
2784
2784
  sourceId: text$1("source_id"),
2785
2785
  parentSpanId: text$1("parent_span_id"),
@@ -2792,25 +2792,25 @@ const agentSessionsSqlite = sqliteTable("agent_sessions", {
2792
2792
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2793
2793
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2794
2794
  }, (table) => [index$1("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
2795
- const agentEvents = pgTable("agent_events", {
2795
+ const agentEvents$1 = pgTable("agent_events", {
2796
2796
  id: text("id").primaryKey(),
2797
- sessionId: text("session_id").notNull().references(() => agentSessions.id),
2797
+ sessionId: text("session_id").notNull().references(() => agentSessions$1.id),
2798
2798
  seq: integer("seq").notNull(),
2799
2799
  eventType: text("event_type").notNull(),
2800
2800
  payload: jsonb("payload").notNull(),
2801
2801
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
2802
2802
  deletedAt: timestamp("deleted_at", { withTimezone: true })
2803
2803
  }, (table) => [index("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
2804
- const agentEventsSqlite = sqliteTable("agent_events", {
2804
+ const agentEventsSqlite$1 = sqliteTable("agent_events", {
2805
2805
  id: text$1("id").primaryKey(),
2806
- sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite.id),
2806
+ sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite$1.id),
2807
2807
  seq: integer$1("seq").notNull(),
2808
2808
  eventType: text$1("event_type").notNull(),
2809
2809
  payload: text$1("payload", { mode: "json" }).notNull(),
2810
2810
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
2811
2811
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2812
2812
  }, (table) => [index$1("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
2813
- const triggers = pgTable("triggers", {
2813
+ const triggers$1 = pgTable("triggers", {
2814
2814
  id: text("id").primaryKey(),
2815
2815
  projectId: text("project_id").notNull(),
2816
2816
  slug: text("slug").notNull(),
@@ -2836,7 +2836,7 @@ const triggers = pgTable("triggers", {
2836
2836
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2837
2837
  deletedAt: timestamp("deleted_at", { withTimezone: true })
2838
2838
  }, (table) => [uniqueIndex("triggers_project_id_slug_idx").on(table.projectId, table.slug), index("triggers_next_run_at_enabled_idx").on(table.nextRunAt, table.enabled)]);
2839
- const triggersSqlite = sqliteTable("triggers", {
2839
+ const triggersSqlite$1 = sqliteTable("triggers", {
2840
2840
  id: text$1("id").primaryKey(),
2841
2841
  projectId: text$1("project_id").notNull(),
2842
2842
  slug: text$1("slug").notNull(),
@@ -2862,10 +2862,10 @@ const triggersSqlite = sqliteTable("triggers", {
2862
2862
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2863
2863
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2864
2864
  }, (table) => [uniqueIndex$1("triggers_project_id_slug_idx").on(table.projectId, table.slug), index$1("triggers_next_run_at_enabled_idx").on(table.nextRunAt, table.enabled)]);
2865
- const triggerAttachments = pgTable("trigger_attachments", {
2865
+ const triggerAttachments$1 = pgTable("trigger_attachments", {
2866
2866
  id: text("id").primaryKey(),
2867
2867
  projectId: text("project_id").notNull(),
2868
- triggerId: text("trigger_id").notNull().references(() => triggers.id),
2868
+ triggerId: text("trigger_id").notNull().references(() => triggers$1.id),
2869
2869
  slug: text("slug").notNull(),
2870
2870
  targetKind: text("target_kind").$type().notNull().default("workflow"),
2871
2871
  workflowSlug: text("workflow_slug"),
@@ -2876,10 +2876,10 @@ const triggerAttachments = pgTable("trigger_attachments", {
2876
2876
  disabledAt: timestamp("disabled_at", { withTimezone: true }),
2877
2877
  deletedAt: timestamp("deleted_at", { withTimezone: true })
2878
2878
  }, (table) => [uniqueIndex("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
2879
- const triggerAttachmentsSqlite = sqliteTable("trigger_attachments", {
2879
+ const triggerAttachmentsSqlite$1 = sqliteTable("trigger_attachments", {
2880
2880
  id: text$1("id").primaryKey(),
2881
2881
  projectId: text$1("project_id").notNull(),
2882
- triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite.id),
2882
+ triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite$1.id),
2883
2883
  slug: text$1("slug").notNull(),
2884
2884
  targetKind: text$1("target_kind").$type().notNull().default("workflow"),
2885
2885
  workflowSlug: text$1("workflow_slug"),
@@ -2890,10 +2890,10 @@ const triggerAttachmentsSqlite = sqliteTable("trigger_attachments", {
2890
2890
  disabledAt: integer$1("disabled_at", { mode: "timestamp_ms" }),
2891
2891
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2892
2892
  }, (table) => [uniqueIndex$1("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
2893
- const triggerRuns = pgTable("trigger_runs", {
2893
+ const triggerRuns$1 = pgTable("trigger_runs", {
2894
2894
  id: text("id").primaryKey(),
2895
2895
  projectId: text("project_id").notNull(),
2896
- triggerId: text("trigger_id").notNull().references(() => triggers.id),
2896
+ triggerId: text("trigger_id").notNull().references(() => triggers$1.id),
2897
2897
  sourcePath: text("source_path"),
2898
2898
  triggerType: text("trigger_type").$type().notNull(),
2899
2899
  outcome: text("outcome").$type().notNull().default("dispatched"),
@@ -2902,10 +2902,10 @@ const triggerRuns = pgTable("trigger_runs", {
2902
2902
  payload: jsonb("payload"),
2903
2903
  triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull()
2904
2904
  }, (table) => [index("trigger_runs_project_trigger_triggered_idx").on(table.projectId, table.triggerId, table.triggeredAt), index("trigger_runs_project_triggered_idx").on(table.projectId, table.triggeredAt)]);
2905
- const triggerRunsSqlite = sqliteTable("trigger_runs", {
2905
+ const triggerRunsSqlite$1 = sqliteTable("trigger_runs", {
2906
2906
  id: text$1("id").primaryKey(),
2907
2907
  projectId: text$1("project_id").notNull(),
2908
- triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite.id),
2908
+ triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite$1.id),
2909
2909
  sourcePath: text$1("source_path"),
2910
2910
  triggerType: text$1("trigger_type").$type().notNull(),
2911
2911
  outcome: text$1("outcome").$type().notNull().default("dispatched"),
@@ -2914,7 +2914,7 @@ const triggerRunsSqlite = sqliteTable("trigger_runs", {
2914
2914
  payload: text$1("payload", { mode: "json" }),
2915
2915
  triggeredAt: integer$1("triggered_at", { mode: "timestamp_ms" }).notNull()
2916
2916
  }, (table) => [index$1("trigger_runs_project_trigger_triggered_idx").on(table.projectId, table.triggerId, table.triggeredAt), index$1("trigger_runs_project_triggered_idx").on(table.projectId, table.triggeredAt)]);
2917
- const workflowSubscriptions = pgTable("workflow_subscriptions", {
2917
+ const workflowSubscriptions$1 = pgTable("workflow_subscriptions", {
2918
2918
  id: text("id").primaryKey(),
2919
2919
  projectId: text("project_id").notNull(),
2920
2920
  workflowSlug: text("workflow_slug").notNull(),
@@ -2923,7 +2923,7 @@ const workflowSubscriptions = pgTable("workflow_subscriptions", {
2923
2923
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
2924
2924
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
2925
2925
  }, (table) => [uniqueIndex("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
2926
- const workflowSubscriptionsSqlite = sqliteTable("workflow_subscriptions", {
2926
+ const workflowSubscriptionsSqlite$1 = sqliteTable("workflow_subscriptions", {
2927
2927
  id: text$1("id").primaryKey(),
2928
2928
  projectId: text$1("project_id").notNull(),
2929
2929
  workflowSlug: text$1("workflow_slug").notNull(),
@@ -2932,13 +2932,13 @@ const workflowSubscriptionsSqlite = sqliteTable("workflow_subscriptions", {
2932
2932
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
2933
2933
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
2934
2934
  }, (table) => [uniqueIndex$1("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
2935
- const workflowRuns = pgTable("workflow_runs", {
2935
+ const workflowRuns$1 = pgTable("workflow_runs", {
2936
2936
  id: text("id").primaryKey(),
2937
2937
  projectId: text("project_id").notNull(),
2938
2938
  workflowSlug: text("workflow_slug").notNull(),
2939
- attachmentId: text("attachment_id").references(() => triggerAttachments.id),
2940
- subscriptionId: text("subscription_id").references(() => workflowSubscriptions.id),
2941
- triggerRunId: text("trigger_run_id").references(() => triggerRuns.id),
2939
+ attachmentId: text("attachment_id").references(() => triggerAttachments$1.id),
2940
+ subscriptionId: text("subscription_id").references(() => workflowSubscriptions$1.id),
2941
+ triggerRunId: text("trigger_run_id").references(() => triggerRuns$1.id),
2942
2942
  parentWorkflowRunId: text("parent_workflow_run_id"),
2943
2943
  parentSpanId: text("parent_span_id"),
2944
2944
  sourceKind: text("source_kind").$type().notNull().default("api"),
@@ -2954,13 +2954,13 @@ const workflowRuns = pgTable("workflow_runs", {
2954
2954
  output: jsonb("output"),
2955
2955
  error: jsonb("error")
2956
2956
  }, (table) => [index("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt)]);
2957
- const workflowRunsSqlite = sqliteTable("workflow_runs", {
2957
+ const workflowRunsSqlite$1 = sqliteTable("workflow_runs", {
2958
2958
  id: text$1("id").primaryKey(),
2959
2959
  projectId: text$1("project_id").notNull(),
2960
2960
  workflowSlug: text$1("workflow_slug").notNull(),
2961
- attachmentId: text$1("attachment_id").references(() => triggerAttachmentsSqlite.id),
2962
- subscriptionId: text$1("subscription_id").references(() => workflowSubscriptionsSqlite.id),
2963
- triggerRunId: text$1("trigger_run_id").references(() => triggerRunsSqlite.id),
2961
+ attachmentId: text$1("attachment_id").references(() => triggerAttachmentsSqlite$1.id),
2962
+ subscriptionId: text$1("subscription_id").references(() => workflowSubscriptionsSqlite$1.id),
2963
+ triggerRunId: text$1("trigger_run_id").references(() => triggerRunsSqlite$1.id),
2964
2964
  parentWorkflowRunId: text$1("parent_workflow_run_id"),
2965
2965
  parentSpanId: text$1("parent_span_id"),
2966
2966
  sourceKind: text$1("source_kind").$type().notNull().default("api"),
@@ -2980,9 +2980,9 @@ const workflowRunsSqlite = sqliteTable("workflow_runs", {
2980
2980
  * Append-only durable execution log. One row per workflow lifecycle transition.
2981
2981
  * Replay reads these in `seq` order and short-circuits already-completed primitives.
2982
2982
  */
2983
- const workflowEvents = pgTable("workflow_events", {
2983
+ const workflowEvents$1 = pgTable("workflow_events", {
2984
2984
  id: text("id").primaryKey(),
2985
- runId: text("run_id").notNull().references(() => workflowRuns.id),
2985
+ runId: text("run_id").notNull().references(() => workflowRuns$1.id),
2986
2986
  projectId: text("project_id").notNull(),
2987
2987
  seq: integer("seq").notNull(),
2988
2988
  type: text("type").$type().notNull(),
@@ -2994,9 +2994,9 @@ const workflowEvents = pgTable("workflow_events", {
2994
2994
  index("workflow_events_run_id_type_idx").on(table.runId, table.type),
2995
2995
  index("workflow_events_correlation_id_idx").on(table.correlationId)
2996
2996
  ]);
2997
- const workflowEventsSqlite = sqliteTable("workflow_events", {
2997
+ const workflowEventsSqlite$1 = sqliteTable("workflow_events", {
2998
2998
  id: text$1("id").primaryKey(),
2999
- runId: text$1("run_id").notNull().references(() => workflowRunsSqlite.id),
2999
+ runId: text$1("run_id").notNull().references(() => workflowRunsSqlite$1.id),
3000
3000
  projectId: text$1("project_id").notNull(),
3001
3001
  seq: integer$1("seq").notNull(),
3002
3002
  type: text$1("type").$type().notNull(),
@@ -3008,9 +3008,9 @@ const workflowEventsSqlite = sqliteTable("workflow_events", {
3008
3008
  index$1("workflow_events_run_id_type_idx").on(table.runId, table.type),
3009
3009
  index$1("workflow_events_correlation_id_idx").on(table.correlationId)
3010
3010
  ]);
3011
- const workflowHooks = pgTable("workflow_hooks", {
3011
+ const workflowHooks$1 = pgTable("workflow_hooks", {
3012
3012
  hookId: text("hook_id").primaryKey(),
3013
- runId: text("run_id").notNull().references(() => workflowRuns.id),
3013
+ runId: text("run_id").notNull().references(() => workflowRuns$1.id),
3014
3014
  projectId: text("project_id").notNull(),
3015
3015
  token: text("token").notNull(),
3016
3016
  correlationId: text("correlation_id").notNull(),
@@ -3020,9 +3020,9 @@ const workflowHooks = pgTable("workflow_hooks", {
3020
3020
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3021
3021
  resumedAt: timestamp("resumed_at", { withTimezone: true })
3022
3022
  }, (table) => [uniqueIndex("workflow_hooks_token_unique").on(table.token), index("workflow_hooks_run_id_idx").on(table.runId)]);
3023
- const workflowHooksSqlite = sqliteTable("workflow_hooks", {
3023
+ const workflowHooksSqlite$1 = sqliteTable("workflow_hooks", {
3024
3024
  hookId: text$1("hook_id").primaryKey(),
3025
- runId: text$1("run_id").notNull().references(() => workflowRunsSqlite.id),
3025
+ runId: text$1("run_id").notNull().references(() => workflowRunsSqlite$1.id),
3026
3026
  projectId: text$1("project_id").notNull(),
3027
3027
  token: text$1("token").notNull(),
3028
3028
  correlationId: text$1("correlation_id").notNull(),
@@ -3032,7 +3032,7 @@ const workflowHooksSqlite = sqliteTable("workflow_hooks", {
3032
3032
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3033
3033
  resumedAt: integer$1("resumed_at", { mode: "timestamp_ms" })
3034
3034
  }, (table) => [uniqueIndex$1("workflow_hooks_token_unique").on(table.token), index$1("workflow_hooks_run_id_idx").on(table.runId)]);
3035
- const credentialInstances = pgTable("credential_instances", {
3035
+ const credentialInstances$1 = pgTable("credential_instances", {
3036
3036
  id: text("id").primaryKey(),
3037
3037
  projectId: text("project_id").notNull(),
3038
3038
  appSlug: text("app_slug").notNull(),
@@ -3052,7 +3052,7 @@ const credentialInstances = pgTable("credential_instances", {
3052
3052
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3053
3053
  lastUsedAt: timestamp("last_used_at", { withTimezone: true })
3054
3054
  }, (table) => [uniqueIndex("credential_instances_project_scope_slug_unique").on(table.projectId, table.scopeType, table.scopeId, table.slug), index("credential_instances_project_app_slug_scope_idx").on(table.projectId, table.appSlug, table.scopeType, table.scopeId)]);
3055
- const credentialInstancesSqlite = sqliteTable("credential_instances", {
3055
+ const credentialInstancesSqlite$1 = sqliteTable("credential_instances", {
3056
3056
  id: text$1("id").primaryKey(),
3057
3057
  projectId: text$1("project_id").notNull(),
3058
3058
  appSlug: text$1("app_slug").notNull(),
@@ -3072,7 +3072,7 @@ const credentialInstancesSqlite = sqliteTable("credential_instances", {
3072
3072
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3073
3073
  lastUsedAt: integer$1("last_used_at", { mode: "timestamp_ms" })
3074
3074
  }, (table) => [uniqueIndex$1("credential_instances_project_scope_slug_unique").on(table.projectId, table.scopeType, table.scopeId, table.slug), index$1("credential_instances_project_app_slug_scope_idx").on(table.projectId, table.appSlug, table.scopeType, table.scopeId)]);
3075
- const credentialAssignments = pgTable("credential_assignments", {
3075
+ const credentialAssignments$1 = pgTable("credential_assignments", {
3076
3076
  id: text("id").primaryKey(),
3077
3077
  projectId: text("project_id").notNull(),
3078
3078
  targetType: text("target_type").$type().notNull(),
@@ -3084,7 +3084,7 @@ const credentialAssignments = pgTable("credential_assignments", {
3084
3084
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3085
3085
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
3086
3086
  }, (table) => [uniqueIndex("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug)]);
3087
- const credentialAssignmentsSqlite = sqliteTable("credential_assignments", {
3087
+ const credentialAssignmentsSqlite$1 = sqliteTable("credential_assignments", {
3088
3088
  id: text$1("id").primaryKey(),
3089
3089
  projectId: text$1("project_id").notNull(),
3090
3090
  targetType: text$1("target_type").$type().notNull(),
@@ -3095,7 +3095,7 @@ const credentialAssignmentsSqlite = sqliteTable("credential_assignments", {
3095
3095
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3096
3096
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
3097
3097
  }, (table) => [uniqueIndex$1("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug)]);
3098
- const jobs = pgTable("jobs", {
3098
+ const jobs$1 = pgTable("jobs", {
3099
3099
  id: text("id").primaryKey(),
3100
3100
  projectId: text("project_id").notNull(),
3101
3101
  kind: text("kind").$type().notNull(),
@@ -3113,7 +3113,7 @@ const jobs = pgTable("jobs", {
3113
3113
  completedAt: timestamp("completed_at", { withTimezone: true }),
3114
3114
  error: jsonb("error")
3115
3115
  });
3116
- const jobsSqlite = sqliteTable("jobs", {
3116
+ const jobsSqlite$1 = sqliteTable("jobs", {
3117
3117
  id: text$1("id").primaryKey(),
3118
3118
  projectId: text$1("project_id").notNull(),
3119
3119
  kind: text$1("kind").$type().notNull(),
@@ -3131,7 +3131,7 @@ const jobsSqlite = sqliteTable("jobs", {
3131
3131
  completedAt: integer$1("completed_at", { mode: "timestamp_ms" }),
3132
3132
  error: text$1("error", { mode: "json" })
3133
3133
  });
3134
- const gatewayAttachments = pgTable("gateway_attachments", {
3134
+ const gatewayAttachments$1 = pgTable("gateway_attachments", {
3135
3135
  id: text("id").primaryKey(),
3136
3136
  projectId: text("project_id").notNull(),
3137
3137
  slug: text("slug").notNull(),
@@ -3145,7 +3145,7 @@ const gatewayAttachments = pgTable("gateway_attachments", {
3145
3145
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3146
3146
  deletedAt: timestamp("deleted_at", { withTimezone: true })
3147
3147
  }, (table) => [uniqueIndex("gateway_attachments_project_id_slug_idx").on(table.projectId, table.slug), uniqueIndex("gateway_attachments_project_platform_channel_active").on(table.projectId, table.platform, table.channelId).where(sql`${table.deletedAt} is null`)]);
3148
- const gatewayAttachmentsSqlite = sqliteTable("gateway_attachments", {
3148
+ const gatewayAttachmentsSqlite$1 = sqliteTable("gateway_attachments", {
3149
3149
  id: text$1("id").primaryKey(),
3150
3150
  projectId: text$1("project_id").notNull(),
3151
3151
  slug: text$1("slug").notNull(),
@@ -3159,23 +3159,23 @@ const gatewayAttachmentsSqlite = sqliteTable("gateway_attachments", {
3159
3159
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3160
3160
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
3161
3161
  }, (table) => [uniqueIndex$1("gateway_attachments_project_id_slug_idx").on(table.projectId, table.slug), uniqueIndex$1("gateway_attachments_project_platform_channel_active").on(table.projectId, table.platform, table.channelId).where(sql`${table.deletedAt} is null`)]);
3162
- const gatewayThreadSessions = pgTable("gateway_thread_sessions", {
3162
+ const gatewayThreadSessions$1 = pgTable("gateway_thread_sessions", {
3163
3163
  threadId: text("thread_id").primaryKey(),
3164
- agentId: text("agent_id").notNull().references(() => agents.id),
3165
- sessionId: text("session_id").notNull().references(() => agentSessions.id),
3166
- attachmentId: text("attachment_id").notNull().references(() => gatewayAttachments.id),
3164
+ agentId: text("agent_id").notNull().references(() => agents$1.id),
3165
+ sessionId: text("session_id").notNull().references(() => agentSessions$1.id),
3166
+ attachmentId: text("attachment_id").notNull().references(() => gatewayAttachments$1.id),
3167
3167
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3168
3168
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
3169
3169
  });
3170
- const gatewayThreadSessionsSqlite = sqliteTable("gateway_thread_sessions", {
3170
+ const gatewayThreadSessionsSqlite$1 = sqliteTable("gateway_thread_sessions", {
3171
3171
  threadId: text$1("thread_id").primaryKey(),
3172
- agentId: text$1("agent_id").notNull().references(() => agentsSqlite.id),
3173
- sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite.id),
3174
- attachmentId: text$1("attachment_id").notNull().references(() => gatewayAttachmentsSqlite.id),
3172
+ agentId: text$1("agent_id").notNull().references(() => agentsSqlite$1.id),
3173
+ sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite$1.id),
3174
+ attachmentId: text$1("attachment_id").notNull().references(() => gatewayAttachmentsSqlite$1.id),
3175
3175
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3176
3176
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
3177
3177
  });
3178
- const traceSpans = pgTable("trace_spans", {
3178
+ const traceSpans$1 = pgTable("trace_spans", {
3179
3179
  id: text("id").primaryKey(),
3180
3180
  traceId: text("trace_id").notNull(),
3181
3181
  parentSpanId: text("parent_span_id"),
@@ -3188,7 +3188,7 @@ const traceSpans = pgTable("trace_spans", {
3188
3188
  metadata: jsonb("metadata"),
3189
3189
  error: jsonb("error")
3190
3190
  }, (table) => [index("trace_spans_trace_id_started_at_idx").on(table.traceId, table.startedAt), index("trace_spans_ref_id_kind_started_at_idx").on(table.refId, table.kind, table.startedAt)]);
3191
- const traceSpansSqlite = sqliteTable("trace_spans", {
3191
+ const traceSpansSqlite$1 = sqliteTable("trace_spans", {
3192
3192
  id: text$1("id").primaryKey(),
3193
3193
  traceId: text$1("trace_id").notNull(),
3194
3194
  parentSpanId: text$1("parent_span_id"),
@@ -3201,10 +3201,10 @@ const traceSpansSqlite = sqliteTable("trace_spans", {
3201
3201
  metadata: text$1("metadata", { mode: "json" }),
3202
3202
  error: text$1("error", { mode: "json" })
3203
3203
  }, (table) => [index$1("trace_spans_trace_id_started_at_idx").on(table.traceId, table.startedAt), index$1("trace_spans_ref_id_kind_started_at_idx").on(table.refId, table.kind, table.startedAt)]);
3204
- const traceLogs = pgTable("trace_logs", {
3204
+ const traceLogs$1 = pgTable("trace_logs", {
3205
3205
  id: text("id").primaryKey(),
3206
3206
  traceId: text("trace_id").notNull(),
3207
- spanId: text("span_id").notNull().references(() => traceSpans.id),
3207
+ spanId: text("span_id").notNull().references(() => traceSpans$1.id),
3208
3208
  seq: integer("seq").notNull(),
3209
3209
  level: text("level").$type().notNull(),
3210
3210
  message: text("message").notNull(),
@@ -3212,10 +3212,10 @@ const traceLogs = pgTable("trace_logs", {
3212
3212
  source: text("source").$type().notNull(),
3213
3213
  createdAt: timestamp("created_at", { withTimezone: true }).notNull()
3214
3214
  }, (table) => [index("trace_logs_trace_id_seq_idx").on(table.traceId, table.seq), index("trace_logs_span_id_seq_idx").on(table.spanId, table.seq)]);
3215
- const traceLogsSqlite = sqliteTable("trace_logs", {
3215
+ const traceLogsSqlite$1 = sqliteTable("trace_logs", {
3216
3216
  id: text$1("id").primaryKey(),
3217
3217
  traceId: text$1("trace_id").notNull(),
3218
- spanId: text$1("span_id").notNull().references(() => traceSpansSqlite.id),
3218
+ spanId: text$1("span_id").notNull().references(() => traceSpansSqlite$1.id),
3219
3219
  seq: integer$1("seq").notNull(),
3220
3220
  level: text$1("level").$type().notNull(),
3221
3221
  message: text$1("message").notNull(),
@@ -3223,7 +3223,7 @@ const traceLogsSqlite = sqliteTable("trace_logs", {
3223
3223
  source: text$1("source").$type().notNull(),
3224
3224
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
3225
3225
  }, (table) => [index$1("trace_logs_trace_id_seq_idx").on(table.traceId, table.seq), index$1("trace_logs_span_id_seq_idx").on(table.spanId, table.seq)]);
3226
- const skills = pgTable("skills", {
3226
+ const skills$1 = pgTable("skills", {
3227
3227
  id: text("id").primaryKey(),
3228
3228
  projectId: text("project_id").notNull(),
3229
3229
  slug: text("slug").notNull(),
@@ -3234,7 +3234,7 @@ const skills = pgTable("skills", {
3234
3234
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3235
3235
  deletedAt: timestamp("deleted_at", { withTimezone: true })
3236
3236
  }, (table) => [uniqueIndex("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
3237
- const skillsSqlite = sqliteTable("skills", {
3237
+ const skillsSqlite$1 = sqliteTable("skills", {
3238
3238
  id: text$1("id").primaryKey(),
3239
3239
  projectId: text$1("project_id").notNull(),
3240
3240
  slug: text$1("slug").notNull(),
@@ -3245,7 +3245,7 @@ const skillsSqlite = sqliteTable("skills", {
3245
3245
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3246
3246
  deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
3247
3247
  }, (table) => [uniqueIndex$1("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
3248
- const workflows = pgTable("workflows", {
3248
+ const workflows$1 = pgTable("workflows", {
3249
3249
  id: text("id").primaryKey(),
3250
3250
  projectId: text("project_id").notNull(),
3251
3251
  slug: text("slug").notNull(),
@@ -3270,7 +3270,7 @@ const workflows = pgTable("workflows", {
3270
3270
  overviewStatus: text("overview_status").$type().notNull().default("idle"),
3271
3271
  overviewGeneratedAt: timestamp("overview_generated_at", { withTimezone: true })
3272
3272
  }, (table) => [uniqueIndex("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
3273
- const workflowsSqlite = sqliteTable("workflows", {
3273
+ const workflowsSqlite$1 = sqliteTable("workflows", {
3274
3274
  id: text$1("id").primaryKey(),
3275
3275
  projectId: text$1("project_id").notNull(),
3276
3276
  slug: text$1("slug").notNull(),
@@ -3295,7 +3295,7 @@ const workflowsSqlite = sqliteTable("workflows", {
3295
3295
  overviewStatus: text$1("overview_status").$type().notNull().default("idle"),
3296
3296
  overviewGeneratedAt: integer$1("overview_generated_at", { mode: "timestamp_ms" })
3297
3297
  }, (table) => [uniqueIndex$1("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
3298
- const resourceActivity = pgTable("resource_activity", {
3298
+ const resourceActivity$1 = pgTable("resource_activity", {
3299
3299
  id: text("id").primaryKey(),
3300
3300
  projectId: text("project_id").notNull(),
3301
3301
  userId: text("user_id").notNull(),
@@ -3303,7 +3303,7 @@ const resourceActivity = pgTable("resource_activity", {
3303
3303
  resourceId: text("resource_id").notNull(),
3304
3304
  lastOpenedAt: timestamp("last_opened_at", { withTimezone: true }).notNull()
3305
3305
  }, (table) => [uniqueIndex("resource_activity_project_user_kind_resource").on(table.projectId, table.userId, table.resourceKind, table.resourceId), index("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt)]);
3306
- const resourceActivitySqlite = sqliteTable("resource_activity", {
3306
+ const resourceActivitySqlite$1 = sqliteTable("resource_activity", {
3307
3307
  id: text$1("id").primaryKey(),
3308
3308
  projectId: text$1("project_id").notNull(),
3309
3309
  userId: text$1("user_id").notNull(),
@@ -3316,84 +3316,84 @@ const resourceActivitySqlite = sqliteTable("resource_activity", {
3316
3316
  */
3317
3317
  const tableRegistry$1 = {
3318
3318
  agents: {
3319
- pg: agents,
3320
- sqlite: agentsSqlite
3319
+ pg: agents$1,
3320
+ sqlite: agentsSqlite$1
3321
3321
  },
3322
3322
  agentSessions: {
3323
- pg: agentSessions,
3324
- sqlite: agentSessionsSqlite
3323
+ pg: agentSessions$1,
3324
+ sqlite: agentSessionsSqlite$1
3325
3325
  },
3326
3326
  agentEvents: {
3327
- pg: agentEvents,
3328
- sqlite: agentEventsSqlite
3327
+ pg: agentEvents$1,
3328
+ sqlite: agentEventsSqlite$1
3329
3329
  },
3330
3330
  triggers: {
3331
- pg: triggers,
3332
- sqlite: triggersSqlite
3331
+ pg: triggers$1,
3332
+ sqlite: triggersSqlite$1
3333
3333
  },
3334
3334
  triggerAttachments: {
3335
- pg: triggerAttachments,
3336
- sqlite: triggerAttachmentsSqlite
3335
+ pg: triggerAttachments$1,
3336
+ sqlite: triggerAttachmentsSqlite$1
3337
3337
  },
3338
3338
  triggerRuns: {
3339
- pg: triggerRuns,
3340
- sqlite: triggerRunsSqlite
3339
+ pg: triggerRuns$1,
3340
+ sqlite: triggerRunsSqlite$1
3341
3341
  },
3342
3342
  workflowRuns: {
3343
- pg: workflowRuns,
3344
- sqlite: workflowRunsSqlite
3343
+ pg: workflowRuns$1,
3344
+ sqlite: workflowRunsSqlite$1
3345
3345
  },
3346
3346
  workflowEvents: {
3347
- pg: workflowEvents,
3348
- sqlite: workflowEventsSqlite
3347
+ pg: workflowEvents$1,
3348
+ sqlite: workflowEventsSqlite$1
3349
3349
  },
3350
3350
  workflowHooks: {
3351
- pg: workflowHooks,
3352
- sqlite: workflowHooksSqlite
3351
+ pg: workflowHooks$1,
3352
+ sqlite: workflowHooksSqlite$1
3353
3353
  },
3354
3354
  credentialInstances: {
3355
- pg: credentialInstances,
3356
- sqlite: credentialInstancesSqlite
3355
+ pg: credentialInstances$1,
3356
+ sqlite: credentialInstancesSqlite$1
3357
3357
  },
3358
3358
  credentialAssignments: {
3359
- pg: credentialAssignments,
3360
- sqlite: credentialAssignmentsSqlite
3359
+ pg: credentialAssignments$1,
3360
+ sqlite: credentialAssignmentsSqlite$1
3361
3361
  },
3362
3362
  jobs: {
3363
- pg: jobs,
3364
- sqlite: jobsSqlite
3363
+ pg: jobs$1,
3364
+ sqlite: jobsSqlite$1
3365
3365
  },
3366
3366
  gatewayAttachments: {
3367
- pg: gatewayAttachments,
3368
- sqlite: gatewayAttachmentsSqlite
3367
+ pg: gatewayAttachments$1,
3368
+ sqlite: gatewayAttachmentsSqlite$1
3369
3369
  },
3370
3370
  gatewayThreadSessions: {
3371
- pg: gatewayThreadSessions,
3372
- sqlite: gatewayThreadSessionsSqlite
3371
+ pg: gatewayThreadSessions$1,
3372
+ sqlite: gatewayThreadSessionsSqlite$1
3373
3373
  },
3374
3374
  traceSpans: {
3375
- pg: traceSpans,
3376
- sqlite: traceSpansSqlite
3375
+ pg: traceSpans$1,
3376
+ sqlite: traceSpansSqlite$1
3377
3377
  },
3378
3378
  traceLogs: {
3379
- pg: traceLogs,
3380
- sqlite: traceLogsSqlite
3379
+ pg: traceLogs$1,
3380
+ sqlite: traceLogsSqlite$1
3381
3381
  },
3382
3382
  skills: {
3383
- pg: skills,
3384
- sqlite: skillsSqlite
3383
+ pg: skills$1,
3384
+ sqlite: skillsSqlite$1
3385
3385
  },
3386
3386
  workflows: {
3387
- pg: workflows,
3388
- sqlite: workflowsSqlite
3387
+ pg: workflows$1,
3388
+ sqlite: workflowsSqlite$1
3389
3389
  },
3390
3390
  workflowSubscriptions: {
3391
- pg: workflowSubscriptions,
3392
- sqlite: workflowSubscriptionsSqlite
3391
+ pg: workflowSubscriptions$1,
3392
+ sqlite: workflowSubscriptionsSqlite$1
3393
3393
  },
3394
3394
  resourceActivity: {
3395
- pg: resourceActivity,
3396
- sqlite: resourceActivitySqlite
3395
+ pg: resourceActivity$1,
3396
+ sqlite: resourceActivitySqlite$1
3397
3397
  }
3398
3398
  };
3399
3399
  buildPgSchema$1(tableRegistry$1);
@@ -13767,6 +13767,42 @@ const projectArtifactsSqlite = sqliteTable("project_artifacts", {
13767
13767
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
13768
13768
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13769
13769
  }, (table) => [index$1("project_artifacts_project_id_idx").on(table.projectId)]);
13770
+ const publishedForms = pgTable("published_forms", {
13771
+ id: text("id").primaryKey(),
13772
+ organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
13773
+ projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
13774
+ workflowSlug: text("workflow_slug").notNull(),
13775
+ token: text("token").notNull(),
13776
+ enabled: boolean("enabled").notNull().default(true),
13777
+ title: text("title"),
13778
+ description: text("description"),
13779
+ fieldConfig: jsonb("field_config").$type().notNull().default({}),
13780
+ createdByUserId: text("created_by_user_id").references(() => users.id, { onDelete: "set null" }),
13781
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
13782
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
13783
+ }, (table) => [
13784
+ uniqueIndex("published_forms_token_unique").on(table.token),
13785
+ uniqueIndex("published_forms_workflow_unique").on(table.organizationId, table.projectId, table.workflowSlug),
13786
+ index("published_forms_project_id_idx").on(table.projectId)
13787
+ ]);
13788
+ const publishedFormsSqlite = sqliteTable("published_forms", {
13789
+ id: text$1("id").primaryKey(),
13790
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
13791
+ projectId: text$1("project_id").notNull().references(() => projectsSqlite.id, { onDelete: "cascade" }),
13792
+ workflowSlug: text$1("workflow_slug").notNull(),
13793
+ token: text$1("token").notNull(),
13794
+ enabled: integer$1("enabled", { mode: "boolean" }).notNull().default(true),
13795
+ title: text$1("title"),
13796
+ description: text$1("description"),
13797
+ fieldConfig: text$1("field_config", { mode: "json" }).$type().notNull().default({}),
13798
+ createdByUserId: text$1("created_by_user_id").references(() => usersSqlite.id, { onDelete: "set null" }),
13799
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
13800
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13801
+ }, (table) => [
13802
+ uniqueIndex$1("published_forms_token_unique").on(table.token),
13803
+ uniqueIndex$1("published_forms_workflow_unique").on(table.organizationId, table.projectId, table.workflowSlug),
13804
+ index$1("published_forms_project_id_idx").on(table.projectId)
13805
+ ]);
13770
13806
  const projectUsers = pgTable("project_users", {
13771
13807
  projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
13772
13808
  userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
@@ -13989,113 +14025,899 @@ const managedServiceCredentialsSqlite = sqliteTable("managed_service_credentials
13989
14025
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
13990
14026
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13991
14027
  }, (table) => [uniqueIndex$1("managed_service_credentials_org_kind_provider_unique").on(table.organizationId, table.kind, table.provider), index$1("managed_service_credentials_org_kind_idx").on(table.organizationId, table.kind)]);
13992
- /**
13993
- * Platform control-plane tables — Postgres (hosted) or SQLite (local dev).
13994
- */
13995
- const tableRegistry = {
13996
- organizations: {
13997
- pg: organizations,
13998
- sqlite: organizationsSqlite
13999
- },
14000
- organizationUsers: {
14001
- pg: organizationUsers,
14002
- sqlite: organizationUsersSqlite
14003
- },
14004
- organizationInvitations: {
14005
- pg: organizationInvitations,
14006
- sqlite: organizationInvitationsSqlite
14007
- },
14008
- projects: {
14009
- pg: projects,
14010
- sqlite: projectsSqlite
14011
- },
14012
- projectUsers: {
14013
- pg: projectUsers,
14014
- sqlite: projectUsersSqlite
14015
- },
14016
- projectArtifacts: {
14017
- pg: projectArtifacts,
14018
- sqlite: projectArtifactsSqlite
14019
- },
14020
- users: {
14021
- pg: users,
14022
- sqlite: usersSqlite
14023
- },
14024
- authSessions: {
14025
- pg: authSessions,
14026
- sqlite: authSessionsSqlite
14027
- },
14028
- authAccounts: {
14029
- pg: authAccounts,
14030
- sqlite: authAccountsSqlite
14031
- },
14032
- authVerifications: {
14033
- pg: authVerifications,
14034
- sqlite: authVerificationsSqlite
14035
- },
14036
- authDeviceCodes: {
14037
- pg: authDeviceCodes,
14038
- sqlite: authDeviceCodesSqlite
14039
- },
14040
- authJwks: {
14041
- pg: authJwks,
14042
- sqlite: authJwksSqlite
14043
- },
14044
- authApiKeys: {
14045
- pg: authApiKeys,
14046
- sqlite: authApiKeysSqlite
14047
- },
14048
- apps: {
14049
- pg: apps,
14050
- sqlite: appsSqlite
14051
- },
14052
- oauthApps: {
14053
- pg: oauthApps,
14054
- sqlite: oauthAppsSqlite
14055
- },
14056
- oauthConnections: {
14057
- pg: oauthConnections,
14058
- sqlite: oauthConnectionsSqlite
14059
- },
14060
- mcpOauthClient: {
14061
- pg: mcpOauthClient,
14062
- sqlite: mcpOauthClientSqlite
14063
- },
14064
- mcpOauthAccessToken: {
14065
- pg: mcpOauthAccessToken,
14066
- sqlite: mcpOauthAccessTokenSqlite
14067
- },
14068
- mcpOauthConsent: {
14069
- pg: mcpOauthConsent,
14070
- sqlite: mcpOauthConsentSqlite
14071
- },
14072
- secretValues: {
14073
- pg: secretValues,
14074
- sqlite: secretValuesSqlite
14075
- },
14076
- organizationBilling: {
14077
- pg: organizationBilling,
14078
- sqlite: organizationBillingSqlite
14079
- },
14080
- billingEvents: {
14081
- pg: billingEvents,
14082
- sqlite: billingEventsSqlite
14083
- },
14084
- billingWallet: {
14085
- pg: billingWallet,
14086
- sqlite: billingWalletSqlite
14087
- },
14088
- billingLedger: {
14089
- pg: billingLedger,
14090
- sqlite: billingLedgerSqlite
14091
- },
14092
- usageEvents: {
14093
- pg: usageEvents,
14094
- sqlite: usageEventsSqlite
14095
- },
14096
- managedServiceCredentials: {
14097
- pg: managedServiceCredentials,
14098
- sqlite: managedServiceCredentialsSqlite
14028
+ const agents = pgTable("agents", {
14029
+ id: text("id").primaryKey(),
14030
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14031
+ projectId: text("project_id").notNull(),
14032
+ slug: text("slug").notNull(),
14033
+ name: text("name"),
14034
+ description: text("description"),
14035
+ route: text("route").notNull(),
14036
+ moduleFile: text("module_file").notNull(),
14037
+ model: text("model").notNull(),
14038
+ systemPrompt: text("system_prompt").notNull(),
14039
+ toolCount: integer("tool_count"),
14040
+ credentialCount: integer("credential_count"),
14041
+ appSlugs: jsonb("app_slugs").$type(),
14042
+ registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14043
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14044
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14045
+ }, (table) => [
14046
+ index("agents_organization_id_idx").on(table.organizationId),
14047
+ uniqueIndex("agents_project_id_slug_idx").on(table.projectId, table.slug),
14048
+ uniqueIndex("agents_project_id_route_idx").on(table.projectId, table.route)
14049
+ ]);
14050
+ const agentsSqlite = sqliteTable("agents", {
14051
+ id: text$1("id").primaryKey(),
14052
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14053
+ projectId: text$1("project_id").notNull(),
14054
+ slug: text$1("slug").notNull(),
14055
+ name: text$1("name"),
14056
+ description: text$1("description"),
14057
+ route: text$1("route").notNull(),
14058
+ moduleFile: text$1("module_file").notNull(),
14059
+ model: text$1("model").notNull(),
14060
+ systemPrompt: text$1("system_prompt").notNull(),
14061
+ toolCount: integer$1("tool_count"),
14062
+ credentialCount: integer$1("credential_count"),
14063
+ appSlugs: text$1("app_slugs", { mode: "json" }).$type(),
14064
+ registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
14065
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14066
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14067
+ }, (table) => [
14068
+ index$1("agents_organization_id_idx").on(table.organizationId),
14069
+ uniqueIndex$1("agents_project_id_slug_idx").on(table.projectId, table.slug),
14070
+ uniqueIndex$1("agents_project_id_route_idx").on(table.projectId, table.route)
14071
+ ]);
14072
+ const agentSessions = pgTable("agent_sessions", {
14073
+ id: text("id").primaryKey(),
14074
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14075
+ projectId: text("project_id").notNull(),
14076
+ agentId: text("agent_id").notNull().references(() => agents.id),
14077
+ sourceKind: text("source_kind").$type().notNull().default("api"),
14078
+ sourceId: text("source_id"),
14079
+ parentSpanId: text("parent_span_id"),
14080
+ ranByUserId: text("ran_by_user_id"),
14081
+ title: text("title"),
14082
+ canceledAt: timestamp("canceled_at", { withTimezone: true }),
14083
+ status: text("status").$type(),
14084
+ totalDurationMs: integer("total_duration_ms").notNull().default(0),
14085
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14086
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14087
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14088
+ }, (table) => [index("agent_sessions_organization_id_idx").on(table.organizationId), index("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
14089
+ const agentSessionsSqlite = sqliteTable("agent_sessions", {
14090
+ id: text$1("id").primaryKey(),
14091
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14092
+ projectId: text$1("project_id").notNull(),
14093
+ agentId: text$1("agent_id").notNull().references(() => agentsSqlite.id),
14094
+ sourceKind: text$1("source_kind").$type().notNull().default("api"),
14095
+ sourceId: text$1("source_id"),
14096
+ parentSpanId: text$1("parent_span_id"),
14097
+ ranByUserId: text$1("ran_by_user_id"),
14098
+ title: text$1("title"),
14099
+ canceledAt: integer$1("canceled_at", { mode: "timestamp_ms" }),
14100
+ status: text$1("status").$type(),
14101
+ totalDurationMs: integer$1("total_duration_ms").notNull().default(0),
14102
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14103
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14104
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14105
+ }, (table) => [index$1("agent_sessions_organization_id_idx").on(table.organizationId), index$1("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
14106
+ const agentEvents = pgTable("agent_events", {
14107
+ id: text("id").primaryKey(),
14108
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14109
+ sessionId: text("session_id").notNull().references(() => agentSessions.id),
14110
+ seq: integer("seq").notNull(),
14111
+ eventType: text("event_type").notNull(),
14112
+ payload: jsonb("payload").notNull(),
14113
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14114
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14115
+ }, (table) => [index("agent_events_organization_id_idx").on(table.organizationId), index("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
14116
+ const agentEventsSqlite = sqliteTable("agent_events", {
14117
+ id: text$1("id").primaryKey(),
14118
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14119
+ sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite.id),
14120
+ seq: integer$1("seq").notNull(),
14121
+ eventType: text$1("event_type").notNull(),
14122
+ payload: text$1("payload", { mode: "json" }).notNull(),
14123
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14124
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14125
+ }, (table) => [index$1("agent_events_organization_id_idx").on(table.organizationId), index$1("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
14126
+ const triggers = pgTable("triggers", {
14127
+ id: text("id").primaryKey(),
14128
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14129
+ projectId: text("project_id").notNull(),
14130
+ slug: text("slug").notNull(),
14131
+ kind: text("kind").$type().notNull(),
14132
+ name: text("name"),
14133
+ description: text("description"),
14134
+ moduleFile: text("module_file").notNull(),
14135
+ origin: text("origin").$type().notNull().default("project"),
14136
+ config: jsonb("config").$type(),
14137
+ state: jsonb("state").$type(),
14138
+ schedule: text("schedule"),
14139
+ nextRunAt: timestamp("next_run_at", { withTimezone: true }),
14140
+ enabled: integer("enabled").notNull().default(1),
14141
+ lifecycle: jsonb("lifecycle").$type(),
14142
+ createdBySessionId: text("created_by_session_id"),
14143
+ triggerHash: text("trigger_hash"),
14144
+ overviewMarkdown: text("overview_markdown"),
14145
+ overviewHash: text("overview_hash"),
14146
+ overviewModel: text("overview_model"),
14147
+ overviewStatus: text("overview_status").$type().notNull().default("idle"),
14148
+ overviewGeneratedAt: timestamp("overview_generated_at", { withTimezone: true }),
14149
+ registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14150
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14151
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14152
+ }, (table) => [
14153
+ index("triggers_organization_id_idx").on(table.organizationId),
14154
+ uniqueIndex("triggers_project_id_slug_idx").on(table.projectId, table.slug),
14155
+ index("triggers_next_run_at_enabled_idx").on(table.nextRunAt, table.enabled)
14156
+ ]);
14157
+ const triggersSqlite = sqliteTable("triggers", {
14158
+ id: text$1("id").primaryKey(),
14159
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14160
+ projectId: text$1("project_id").notNull(),
14161
+ slug: text$1("slug").notNull(),
14162
+ kind: text$1("kind").$type().notNull(),
14163
+ name: text$1("name"),
14164
+ description: text$1("description"),
14165
+ moduleFile: text$1("module_file").notNull(),
14166
+ origin: text$1("origin").$type().notNull().default("project"),
14167
+ config: text$1("config", { mode: "json" }).$type(),
14168
+ state: text$1("state", { mode: "json" }).$type(),
14169
+ schedule: text$1("schedule"),
14170
+ nextRunAt: integer$1("next_run_at", { mode: "timestamp_ms" }),
14171
+ enabled: integer$1("enabled").notNull().default(1),
14172
+ lifecycle: text$1("lifecycle", { mode: "json" }).$type(),
14173
+ createdBySessionId: text$1("created_by_session_id"),
14174
+ triggerHash: text$1("trigger_hash"),
14175
+ overviewMarkdown: text$1("overview_markdown"),
14176
+ overviewHash: text$1("overview_hash"),
14177
+ overviewModel: text$1("overview_model"),
14178
+ overviewStatus: text$1("overview_status").$type().notNull().default("idle"),
14179
+ overviewGeneratedAt: integer$1("overview_generated_at", { mode: "timestamp_ms" }),
14180
+ registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
14181
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14182
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14183
+ }, (table) => [
14184
+ index$1("triggers_organization_id_idx").on(table.organizationId),
14185
+ uniqueIndex$1("triggers_project_id_slug_idx").on(table.projectId, table.slug),
14186
+ index$1("triggers_next_run_at_enabled_idx").on(table.nextRunAt, table.enabled)
14187
+ ]);
14188
+ const triggerAttachments = pgTable("trigger_attachments", {
14189
+ id: text("id").primaryKey(),
14190
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14191
+ projectId: text("project_id").notNull(),
14192
+ triggerId: text("trigger_id").notNull().references(() => triggers.id),
14193
+ slug: text("slug").notNull(),
14194
+ targetKind: text("target_kind").$type().notNull().default("workflow"),
14195
+ workflowSlug: text("workflow_slug"),
14196
+ agentSlug: text("agent_slug"),
14197
+ prompt: text("prompt"),
14198
+ registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14199
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14200
+ disabledAt: timestamp("disabled_at", { withTimezone: true }),
14201
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14202
+ }, (table) => [index("trigger_attachments_organization_id_idx").on(table.organizationId), uniqueIndex("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
14203
+ const triggerAttachmentsSqlite = sqliteTable("trigger_attachments", {
14204
+ id: text$1("id").primaryKey(),
14205
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14206
+ projectId: text$1("project_id").notNull(),
14207
+ triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite.id),
14208
+ slug: text$1("slug").notNull(),
14209
+ targetKind: text$1("target_kind").$type().notNull().default("workflow"),
14210
+ workflowSlug: text$1("workflow_slug"),
14211
+ agentSlug: text$1("agent_slug"),
14212
+ prompt: text$1("prompt"),
14213
+ registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
14214
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14215
+ disabledAt: integer$1("disabled_at", { mode: "timestamp_ms" }),
14216
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14217
+ }, (table) => [index$1("trigger_attachments_organization_id_idx").on(table.organizationId), uniqueIndex$1("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
14218
+ const triggerRuns = pgTable("trigger_runs", {
14219
+ id: text("id").primaryKey(),
14220
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14221
+ projectId: text("project_id").notNull(),
14222
+ triggerId: text("trigger_id").notNull().references(() => triggers.id),
14223
+ sourcePath: text("source_path"),
14224
+ triggerType: text("trigger_type").$type().notNull(),
14225
+ outcome: text("outcome").$type().notNull().default("dispatched"),
14226
+ reason: text("reason").$type(),
14227
+ detail: text("detail"),
14228
+ payload: jsonb("payload"),
14229
+ triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull()
14230
+ }, (table) => [
14231
+ index("trigger_runs_organization_id_idx").on(table.organizationId),
14232
+ index("trigger_runs_project_trigger_triggered_idx").on(table.projectId, table.triggerId, table.triggeredAt),
14233
+ index("trigger_runs_project_triggered_idx").on(table.projectId, table.triggeredAt)
14234
+ ]);
14235
+ const triggerRunsSqlite = sqliteTable("trigger_runs", {
14236
+ id: text$1("id").primaryKey(),
14237
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14238
+ projectId: text$1("project_id").notNull(),
14239
+ triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite.id),
14240
+ sourcePath: text$1("source_path"),
14241
+ triggerType: text$1("trigger_type").$type().notNull(),
14242
+ outcome: text$1("outcome").$type().notNull().default("dispatched"),
14243
+ reason: text$1("reason").$type(),
14244
+ detail: text$1("detail"),
14245
+ payload: text$1("payload", { mode: "json" }),
14246
+ triggeredAt: integer$1("triggered_at", { mode: "timestamp_ms" }).notNull()
14247
+ }, (table) => [
14248
+ index$1("trigger_runs_organization_id_idx").on(table.organizationId),
14249
+ index$1("trigger_runs_project_trigger_triggered_idx").on(table.projectId, table.triggerId, table.triggeredAt),
14250
+ index$1("trigger_runs_project_triggered_idx").on(table.projectId, table.triggeredAt)
14251
+ ]);
14252
+ const workflowSubscriptions = pgTable("workflow_subscriptions", {
14253
+ id: text("id").primaryKey(),
14254
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14255
+ projectId: text("project_id").notNull(),
14256
+ workflowSlug: text("workflow_slug").notNull(),
14257
+ userId: text("user_id").notNull(),
14258
+ enabled: integer("enabled").notNull(),
14259
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14260
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
14261
+ }, (table) => [index("workflow_subscriptions_organization_id_idx").on(table.organizationId), uniqueIndex("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
14262
+ const workflowSubscriptionsSqlite = sqliteTable("workflow_subscriptions", {
14263
+ id: text$1("id").primaryKey(),
14264
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14265
+ projectId: text$1("project_id").notNull(),
14266
+ workflowSlug: text$1("workflow_slug").notNull(),
14267
+ userId: text$1("user_id").notNull(),
14268
+ enabled: integer$1("enabled", { mode: "boolean" }).notNull(),
14269
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14270
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
14271
+ }, (table) => [index$1("workflow_subscriptions_organization_id_idx").on(table.organizationId), uniqueIndex$1("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
14272
+ const workflowRuns = pgTable("workflow_runs", {
14273
+ id: text("id").primaryKey(),
14274
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14275
+ projectId: text("project_id").notNull(),
14276
+ workflowSlug: text("workflow_slug").notNull(),
14277
+ attachmentId: text("attachment_id").references(() => triggerAttachments.id),
14278
+ subscriptionId: text("subscription_id").references(() => workflowSubscriptions.id),
14279
+ triggerRunId: text("trigger_run_id").references(() => triggerRuns.id),
14280
+ parentWorkflowRunId: text("parent_workflow_run_id"),
14281
+ parentSpanId: text("parent_span_id"),
14282
+ sourceKind: text("source_kind").$type().notNull().default("api"),
14283
+ sourceId: text("source_id"),
14284
+ ranByUserId: text("ran_by_user_id"),
14285
+ credentialContext: jsonb("credential_context").$type(),
14286
+ status: text("status").$type().notNull(),
14287
+ trigger: text("trigger").$type().notNull(),
14288
+ triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull(),
14289
+ startedAt: timestamp("started_at", { withTimezone: true }),
14290
+ finishedAt: timestamp("finished_at", { withTimezone: true }),
14291
+ input: jsonb("input"),
14292
+ output: jsonb("output"),
14293
+ error: jsonb("error")
14294
+ }, (table) => [index("workflow_runs_organization_id_idx").on(table.organizationId), index("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt)]);
14295
+ const workflowRunsSqlite = sqliteTable("workflow_runs", {
14296
+ id: text$1("id").primaryKey(),
14297
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14298
+ projectId: text$1("project_id").notNull(),
14299
+ workflowSlug: text$1("workflow_slug").notNull(),
14300
+ attachmentId: text$1("attachment_id").references(() => triggerAttachmentsSqlite.id),
14301
+ subscriptionId: text$1("subscription_id").references(() => workflowSubscriptionsSqlite.id),
14302
+ triggerRunId: text$1("trigger_run_id").references(() => triggerRunsSqlite.id),
14303
+ parentWorkflowRunId: text$1("parent_workflow_run_id"),
14304
+ parentSpanId: text$1("parent_span_id"),
14305
+ sourceKind: text$1("source_kind").$type().notNull().default("api"),
14306
+ sourceId: text$1("source_id"),
14307
+ ranByUserId: text$1("ran_by_user_id"),
14308
+ credentialContext: text$1("credential_context", { mode: "json" }).$type(),
14309
+ status: text$1("status").$type().notNull(),
14310
+ trigger: text$1("trigger").$type().notNull(),
14311
+ triggeredAt: integer$1("triggered_at", { mode: "timestamp_ms" }).notNull(),
14312
+ startedAt: integer$1("started_at", { mode: "timestamp_ms" }),
14313
+ finishedAt: integer$1("finished_at", { mode: "timestamp_ms" }),
14314
+ input: text$1("input", { mode: "json" }),
14315
+ output: text$1("output", { mode: "json" }),
14316
+ error: text$1("error", { mode: "json" })
14317
+ }, (table) => [index$1("workflow_runs_organization_id_idx").on(table.organizationId), index$1("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt)]);
14318
+ /**
14319
+ * Append-only durable execution log. One row per workflow lifecycle transition.
14320
+ * Replay reads these in `seq` order and short-circuits already-completed primitives.
14321
+ */
14322
+ const workflowEvents = pgTable("workflow_events", {
14323
+ id: text("id").primaryKey(),
14324
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14325
+ runId: text("run_id").notNull().references(() => workflowRuns.id),
14326
+ projectId: text("project_id").notNull(),
14327
+ seq: integer("seq").notNull(),
14328
+ type: text("type").$type().notNull(),
14329
+ correlationId: text("correlation_id"),
14330
+ data: jsonb("data"),
14331
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
14332
+ }, (table) => [
14333
+ index("workflow_events_organization_id_idx").on(table.organizationId),
14334
+ uniqueIndex("workflow_events_run_id_seq_unique").on(table.runId, table.seq),
14335
+ index("workflow_events_run_id_type_idx").on(table.runId, table.type),
14336
+ index("workflow_events_correlation_id_idx").on(table.correlationId)
14337
+ ]);
14338
+ const workflowEventsSqlite = sqliteTable("workflow_events", {
14339
+ id: text$1("id").primaryKey(),
14340
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14341
+ runId: text$1("run_id").notNull().references(() => workflowRunsSqlite.id),
14342
+ projectId: text$1("project_id").notNull(),
14343
+ seq: integer$1("seq").notNull(),
14344
+ type: text$1("type").$type().notNull(),
14345
+ correlationId: text$1("correlation_id"),
14346
+ data: text$1("data", { mode: "json" }),
14347
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
14348
+ }, (table) => [
14349
+ index$1("workflow_events_organization_id_idx").on(table.organizationId),
14350
+ uniqueIndex$1("workflow_events_run_id_seq_unique").on(table.runId, table.seq),
14351
+ index$1("workflow_events_run_id_type_idx").on(table.runId, table.type),
14352
+ index$1("workflow_events_correlation_id_idx").on(table.correlationId)
14353
+ ]);
14354
+ const workflowHooks = pgTable("workflow_hooks", {
14355
+ hookId: text("hook_id").primaryKey(),
14356
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14357
+ runId: text("run_id").notNull().references(() => workflowRuns.id),
14358
+ projectId: text("project_id").notNull(),
14359
+ token: text("token").notNull(),
14360
+ correlationId: text("correlation_id").notNull(),
14361
+ status: text("status").$type().notNull(),
14362
+ schema: jsonb("schema"),
14363
+ payload: jsonb("payload"),
14364
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14365
+ resumedAt: timestamp("resumed_at", { withTimezone: true })
14366
+ }, (table) => [
14367
+ index("workflow_hooks_organization_id_idx").on(table.organizationId),
14368
+ uniqueIndex("workflow_hooks_token_unique").on(table.token),
14369
+ index("workflow_hooks_run_id_idx").on(table.runId)
14370
+ ]);
14371
+ const workflowHooksSqlite = sqliteTable("workflow_hooks", {
14372
+ hookId: text$1("hook_id").primaryKey(),
14373
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14374
+ runId: text$1("run_id").notNull().references(() => workflowRunsSqlite.id),
14375
+ projectId: text$1("project_id").notNull(),
14376
+ token: text$1("token").notNull(),
14377
+ correlationId: text$1("correlation_id").notNull(),
14378
+ status: text$1("status").$type().notNull(),
14379
+ schema: text$1("schema", { mode: "json" }),
14380
+ payload: text$1("payload", { mode: "json" }),
14381
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14382
+ resumedAt: integer$1("resumed_at", { mode: "timestamp_ms" })
14383
+ }, (table) => [
14384
+ index$1("workflow_hooks_organization_id_idx").on(table.organizationId),
14385
+ uniqueIndex$1("workflow_hooks_token_unique").on(table.token),
14386
+ index$1("workflow_hooks_run_id_idx").on(table.runId)
14387
+ ]);
14388
+ const credentialInstances = pgTable("credential_instances", {
14389
+ id: text("id").primaryKey(),
14390
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14391
+ projectId: text("project_id").notNull(),
14392
+ appSlug: text("app_slug").notNull(),
14393
+ slug: text("slug").notNull(),
14394
+ name: text("name"),
14395
+ scopeType: text("scope_type").$type().notNull(),
14396
+ scopeId: text("scope_id"),
14397
+ label: text("label"),
14398
+ isDefault: integer("is_default").notNull(),
14399
+ authKind: text("auth_kind").$type().notNull(),
14400
+ ciphertext: text("ciphertext"),
14401
+ connectionId: text("connection_id"),
14402
+ /** MCP entity id that owns connection_id when multiple scopes share one connection. */
14403
+ sharedConnectionId: text("shared_connection_id"),
14404
+ grantedScopes: jsonb("granted_scopes").$type(),
14405
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14406
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14407
+ lastUsedAt: timestamp("last_used_at", { withTimezone: true })
14408
+ }, (table) => [
14409
+ index("credential_instances_organization_id_idx").on(table.organizationId),
14410
+ uniqueIndex("credential_instances_project_scope_slug_unique").on(table.projectId, table.scopeType, table.scopeId, table.slug),
14411
+ index("credential_instances_project_app_slug_scope_idx").on(table.projectId, table.appSlug, table.scopeType, table.scopeId)
14412
+ ]);
14413
+ const credentialInstancesSqlite = sqliteTable("credential_instances", {
14414
+ id: text$1("id").primaryKey(),
14415
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14416
+ projectId: text$1("project_id").notNull(),
14417
+ appSlug: text$1("app_slug").notNull(),
14418
+ slug: text$1("slug").notNull(),
14419
+ name: text$1("name"),
14420
+ scopeType: text$1("scope_type").$type().notNull(),
14421
+ scopeId: text$1("scope_id"),
14422
+ label: text$1("label"),
14423
+ isDefault: integer$1("is_default", { mode: "boolean" }).notNull(),
14424
+ authKind: text$1("auth_kind").$type().notNull(),
14425
+ ciphertext: text$1("ciphertext"),
14426
+ connectionId: text$1("connection_id"),
14427
+ /** MCP entity id that owns connection_id when multiple scopes share one connection. */
14428
+ sharedConnectionId: text$1("shared_connection_id"),
14429
+ grantedScopes: text$1("granted_scopes", { mode: "json" }).$type(),
14430
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14431
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14432
+ lastUsedAt: integer$1("last_used_at", { mode: "timestamp_ms" })
14433
+ }, (table) => [
14434
+ index$1("credential_instances_organization_id_idx").on(table.organizationId),
14435
+ uniqueIndex$1("credential_instances_project_scope_slug_unique").on(table.projectId, table.scopeType, table.scopeId, table.slug),
14436
+ index$1("credential_instances_project_app_slug_scope_idx").on(table.projectId, table.appSlug, table.scopeType, table.scopeId)
14437
+ ]);
14438
+ const credentialAssignments = pgTable("credential_assignments", {
14439
+ id: text("id").primaryKey(),
14440
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14441
+ projectId: text("project_id").notNull(),
14442
+ targetType: text("target_type").$type().notNull(),
14443
+ targetKey: text("target_key").notNull(),
14444
+ /** '*' = wildcard; else runtime consumer id (step correlation id or tool slug). */
14445
+ consumerId: text("consumer_id").notNull(),
14446
+ credentialSlug: text("credential_slug").notNull(),
14447
+ instanceId: text("instance_id").notNull(),
14448
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14449
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
14450
+ }, (table) => [index("credential_assignments_organization_id_idx").on(table.organizationId), uniqueIndex("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug)]);
14451
+ const credentialAssignmentsSqlite = sqliteTable("credential_assignments", {
14452
+ id: text$1("id").primaryKey(),
14453
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14454
+ projectId: text$1("project_id").notNull(),
14455
+ targetType: text$1("target_type").$type().notNull(),
14456
+ targetKey: text$1("target_key").notNull(),
14457
+ consumerId: text$1("consumer_id").notNull(),
14458
+ credentialSlug: text$1("credential_slug").notNull(),
14459
+ instanceId: text$1("instance_id").notNull(),
14460
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14461
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
14462
+ }, (table) => [index$1("credential_assignments_organization_id_idx").on(table.organizationId), uniqueIndex$1("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug)]);
14463
+ const jobs = pgTable("jobs", {
14464
+ id: text("id").primaryKey(),
14465
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14466
+ projectId: text("project_id").notNull(),
14467
+ kind: text("kind").$type().notNull(),
14468
+ targetId: text("target_id").notNull(),
14469
+ runId: text("run_id").notNull(),
14470
+ trigger: text("trigger").$type().notNull(),
14471
+ payload: jsonb("payload"),
14472
+ parent: jsonb("parent").$type(),
14473
+ status: text("status").$type().notNull(),
14474
+ scheduledAt: timestamp("scheduled_at", { withTimezone: true }).notNull(),
14475
+ attempt: integer("attempt").notNull(),
14476
+ maxAttempts: integer("max_attempts").notNull(),
14477
+ leasedBy: text("leased_by"),
14478
+ leaseExpiresAt: timestamp("lease_expires_at", { withTimezone: true }),
14479
+ completedAt: timestamp("completed_at", { withTimezone: true }),
14480
+ error: jsonb("error")
14481
+ }, (table) => [index("jobs_organization_id_idx").on(table.organizationId)]);
14482
+ const jobsSqlite = sqliteTable("jobs", {
14483
+ id: text$1("id").primaryKey(),
14484
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14485
+ projectId: text$1("project_id").notNull(),
14486
+ kind: text$1("kind").$type().notNull(),
14487
+ targetId: text$1("target_id").notNull(),
14488
+ runId: text$1("run_id").notNull(),
14489
+ trigger: text$1("trigger").$type().notNull(),
14490
+ payload: text$1("payload", { mode: "json" }),
14491
+ parent: text$1("parent", { mode: "json" }).$type(),
14492
+ status: text$1("status").$type().notNull(),
14493
+ scheduledAt: integer$1("scheduled_at", { mode: "timestamp_ms" }).notNull(),
14494
+ attempt: integer$1("attempt").notNull(),
14495
+ maxAttempts: integer$1("max_attempts").notNull(),
14496
+ leasedBy: text$1("leased_by"),
14497
+ leaseExpiresAt: integer$1("lease_expires_at", { mode: "timestamp_ms" }),
14498
+ completedAt: integer$1("completed_at", { mode: "timestamp_ms" }),
14499
+ error: text$1("error", { mode: "json" })
14500
+ }, (table) => [index$1("jobs_organization_id_idx").on(table.organizationId)]);
14501
+ const gatewayAttachments = pgTable("gateway_attachments", {
14502
+ id: text("id").primaryKey(),
14503
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14504
+ projectId: text("project_id").notNull(),
14505
+ slug: text("slug").notNull(),
14506
+ agentSlug: text("agent_slug").notNull(),
14507
+ moduleFile: text("module_file"),
14508
+ platform: text("platform").notNull(),
14509
+ teamId: text("team_id"),
14510
+ channelId: text("channel_id").notNull(),
14511
+ source: jsonb("source").$type().notNull(),
14512
+ registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14513
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14514
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14515
+ }, (table) => [
14516
+ index("gateway_attachments_organization_id_idx").on(table.organizationId),
14517
+ uniqueIndex("gateway_attachments_project_id_slug_idx").on(table.projectId, table.slug),
14518
+ uniqueIndex("gateway_attachments_project_platform_channel_active").on(table.projectId, table.platform, table.channelId).where(sql`${table.deletedAt} is null`)
14519
+ ]);
14520
+ const gatewayAttachmentsSqlite = sqliteTable("gateway_attachments", {
14521
+ id: text$1("id").primaryKey(),
14522
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14523
+ projectId: text$1("project_id").notNull(),
14524
+ slug: text$1("slug").notNull(),
14525
+ agentSlug: text$1("agent_slug").notNull(),
14526
+ moduleFile: text$1("module_file"),
14527
+ platform: text$1("platform").notNull(),
14528
+ teamId: text$1("team_id"),
14529
+ channelId: text$1("channel_id").notNull(),
14530
+ source: text$1("source", { mode: "json" }).$type().notNull(),
14531
+ registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
14532
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14533
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14534
+ }, (table) => [
14535
+ index$1("gateway_attachments_organization_id_idx").on(table.organizationId),
14536
+ uniqueIndex$1("gateway_attachments_project_id_slug_idx").on(table.projectId, table.slug),
14537
+ uniqueIndex$1("gateway_attachments_project_platform_channel_active").on(table.projectId, table.platform, table.channelId).where(sql`${table.deletedAt} is null`)
14538
+ ]);
14539
+ const gatewayThreadSessions = pgTable("gateway_thread_sessions", {
14540
+ threadId: text("thread_id").primaryKey(),
14541
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14542
+ agentId: text("agent_id").notNull().references(() => agents.id),
14543
+ sessionId: text("session_id").notNull().references(() => agentSessions.id),
14544
+ attachmentId: text("attachment_id").notNull().references(() => gatewayAttachments.id),
14545
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14546
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
14547
+ }, (table) => [index("gateway_thread_sessions_organization_id_idx").on(table.organizationId)]);
14548
+ const gatewayThreadSessionsSqlite = sqliteTable("gateway_thread_sessions", {
14549
+ threadId: text$1("thread_id").primaryKey(),
14550
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14551
+ agentId: text$1("agent_id").notNull().references(() => agentsSqlite.id),
14552
+ sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite.id),
14553
+ attachmentId: text$1("attachment_id").notNull().references(() => gatewayAttachmentsSqlite.id),
14554
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
14555
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
14556
+ }, (table) => [index$1("gateway_thread_sessions_organization_id_idx").on(table.organizationId)]);
14557
+ const traceSpans = pgTable("trace_spans", {
14558
+ id: text("id").primaryKey(),
14559
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14560
+ traceId: text("trace_id").notNull(),
14561
+ parentSpanId: text("parent_span_id"),
14562
+ kind: text("kind").$type().notNull(),
14563
+ refId: text("ref_id").notNull(),
14564
+ name: text("name").notNull(),
14565
+ status: text("status").$type().notNull(),
14566
+ startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
14567
+ finishedAt: timestamp("finished_at", { withTimezone: true }),
14568
+ metadata: jsonb("metadata"),
14569
+ error: jsonb("error")
14570
+ }, (table) => [
14571
+ index("trace_spans_organization_id_idx").on(table.organizationId),
14572
+ index("trace_spans_trace_id_started_at_idx").on(table.traceId, table.startedAt),
14573
+ index("trace_spans_ref_id_kind_started_at_idx").on(table.refId, table.kind, table.startedAt)
14574
+ ]);
14575
+ const traceSpansSqlite = sqliteTable("trace_spans", {
14576
+ id: text$1("id").primaryKey(),
14577
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14578
+ traceId: text$1("trace_id").notNull(),
14579
+ parentSpanId: text$1("parent_span_id"),
14580
+ kind: text$1("kind").$type().notNull(),
14581
+ refId: text$1("ref_id").notNull(),
14582
+ name: text$1("name").notNull(),
14583
+ status: text$1("status").$type().notNull(),
14584
+ startedAt: integer$1("started_at", { mode: "timestamp_ms" }).notNull(),
14585
+ finishedAt: integer$1("finished_at", { mode: "timestamp_ms" }),
14586
+ metadata: text$1("metadata", { mode: "json" }),
14587
+ error: text$1("error", { mode: "json" })
14588
+ }, (table) => [
14589
+ index$1("trace_spans_organization_id_idx").on(table.organizationId),
14590
+ index$1("trace_spans_trace_id_started_at_idx").on(table.traceId, table.startedAt),
14591
+ index$1("trace_spans_ref_id_kind_started_at_idx").on(table.refId, table.kind, table.startedAt)
14592
+ ]);
14593
+ const traceLogs = pgTable("trace_logs", {
14594
+ id: text("id").primaryKey(),
14595
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14596
+ traceId: text("trace_id").notNull(),
14597
+ spanId: text("span_id").notNull().references(() => traceSpans.id),
14598
+ seq: integer("seq").notNull(),
14599
+ level: text("level").$type().notNull(),
14600
+ message: text("message").notNull(),
14601
+ data: jsonb("data"),
14602
+ source: text("source").$type().notNull(),
14603
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
14604
+ }, (table) => [
14605
+ index("trace_logs_organization_id_idx").on(table.organizationId),
14606
+ index("trace_logs_trace_id_seq_idx").on(table.traceId, table.seq),
14607
+ index("trace_logs_span_id_seq_idx").on(table.spanId, table.seq)
14608
+ ]);
14609
+ const traceLogsSqlite = sqliteTable("trace_logs", {
14610
+ id: text$1("id").primaryKey(),
14611
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14612
+ traceId: text$1("trace_id").notNull(),
14613
+ spanId: text$1("span_id").notNull().references(() => traceSpansSqlite.id),
14614
+ seq: integer$1("seq").notNull(),
14615
+ level: text$1("level").$type().notNull(),
14616
+ message: text$1("message").notNull(),
14617
+ data: text$1("data", { mode: "json" }),
14618
+ source: text$1("source").$type().notNull(),
14619
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
14620
+ }, (table) => [
14621
+ index$1("trace_logs_organization_id_idx").on(table.organizationId),
14622
+ index$1("trace_logs_trace_id_seq_idx").on(table.traceId, table.seq),
14623
+ index$1("trace_logs_span_id_seq_idx").on(table.spanId, table.seq)
14624
+ ]);
14625
+ const skills = pgTable("skills", {
14626
+ id: text("id").primaryKey(),
14627
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14628
+ projectId: text("project_id").notNull(),
14629
+ slug: text("slug").notNull(),
14630
+ name: text("name"),
14631
+ description: text("description"),
14632
+ moduleFile: text("module_file").notNull(),
14633
+ registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14634
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14635
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
14636
+ }, (table) => [index("skills_organization_id_idx").on(table.organizationId), uniqueIndex("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
14637
+ const skillsSqlite = sqliteTable("skills", {
14638
+ id: text$1("id").primaryKey(),
14639
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14640
+ projectId: text$1("project_id").notNull(),
14641
+ slug: text$1("slug").notNull(),
14642
+ name: text$1("name"),
14643
+ description: text$1("description"),
14644
+ moduleFile: text$1("module_file").notNull(),
14645
+ registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
14646
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14647
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
14648
+ }, (table) => [index$1("skills_organization_id_idx").on(table.organizationId), uniqueIndex$1("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
14649
+ const workflows = pgTable("workflows", {
14650
+ id: text("id").primaryKey(),
14651
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14652
+ projectId: text("project_id").notNull(),
14653
+ slug: text("slug").notNull(),
14654
+ name: text("name").notNull(),
14655
+ description: text("description").notNull(),
14656
+ moduleFile: text("module_file").notNull(),
14657
+ subscribable: integer("subscribable").notNull(),
14658
+ registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14659
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14660
+ deletedAt: timestamp("deleted_at", { withTimezone: true }),
14661
+ requestSchema: jsonb("request_schema").$type().notNull().default({}),
14662
+ runInputValues: jsonb("run_input_values").$type(),
14663
+ canvasAnnotationsJson: jsonb("canvas_annotations_json").$type(),
14664
+ canvasAnnotationsHash: text("canvas_annotations_hash"),
14665
+ canvasAnnotationsModel: text("canvas_annotations_model"),
14666
+ canvasAnnotationsStatus: text("canvas_annotations_status").$type().notNull().default("idle"),
14667
+ canvasAnnotationsGeneratedAt: timestamp("canvas_annotations_generated_at", { withTimezone: true }),
14668
+ overviewSummary: text("overview_summary"),
14669
+ overviewPhasesJson: jsonb("overview_phases_json").$type(),
14670
+ overviewHash: text("overview_hash"),
14671
+ overviewModel: text("overview_model"),
14672
+ overviewStatus: text("overview_status").$type().notNull().default("idle"),
14673
+ overviewGeneratedAt: timestamp("overview_generated_at", { withTimezone: true })
14674
+ }, (table) => [index("workflows_organization_id_idx").on(table.organizationId), uniqueIndex("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
14675
+ const workflowsSqlite = sqliteTable("workflows", {
14676
+ id: text$1("id").primaryKey(),
14677
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14678
+ projectId: text$1("project_id").notNull(),
14679
+ slug: text$1("slug").notNull(),
14680
+ name: text$1("name").notNull(),
14681
+ description: text$1("description").notNull(),
14682
+ moduleFile: text$1("module_file").notNull(),
14683
+ subscribable: integer$1("subscribable", { mode: "boolean" }).notNull(),
14684
+ registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
14685
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
14686
+ deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" }),
14687
+ requestSchema: text$1("request_schema", { mode: "json" }).$type().notNull().default({}),
14688
+ runInputValues: text$1("run_input_values", { mode: "json" }).$type(),
14689
+ canvasAnnotationsJson: text$1("canvas_annotations_json", { mode: "json" }).$type(),
14690
+ canvasAnnotationsHash: text$1("canvas_annotations_hash"),
14691
+ canvasAnnotationsModel: text$1("canvas_annotations_model"),
14692
+ canvasAnnotationsStatus: text$1("canvas_annotations_status").$type().notNull().default("idle"),
14693
+ canvasAnnotationsGeneratedAt: integer$1("canvas_annotations_generated_at", { mode: "timestamp_ms" }),
14694
+ overviewSummary: text$1("overview_summary"),
14695
+ overviewPhasesJson: text$1("overview_phases_json", { mode: "json" }).$type(),
14696
+ overviewHash: text$1("overview_hash"),
14697
+ overviewModel: text$1("overview_model"),
14698
+ overviewStatus: text$1("overview_status").$type().notNull().default("idle"),
14699
+ overviewGeneratedAt: integer$1("overview_generated_at", { mode: "timestamp_ms" })
14700
+ }, (table) => [index$1("workflows_organization_id_idx").on(table.organizationId), uniqueIndex$1("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
14701
+ const resourceActivity = pgTable("resource_activity", {
14702
+ id: text("id").primaryKey(),
14703
+ organizationId: text("organization_id").notNull().references(() => organizations.id),
14704
+ projectId: text("project_id").notNull(),
14705
+ userId: text("user_id").notNull(),
14706
+ resourceKind: text("resource_kind").notNull(),
14707
+ resourceId: text("resource_id").notNull(),
14708
+ lastOpenedAt: timestamp("last_opened_at", { withTimezone: true }).notNull()
14709
+ }, (table) => [
14710
+ index("resource_activity_organization_id_idx").on(table.organizationId),
14711
+ uniqueIndex("resource_activity_project_user_kind_resource").on(table.projectId, table.userId, table.resourceKind, table.resourceId),
14712
+ index("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt)
14713
+ ]);
14714
+ const resourceActivitySqlite = sqliteTable("resource_activity", {
14715
+ id: text$1("id").primaryKey(),
14716
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
14717
+ projectId: text$1("project_id").notNull(),
14718
+ userId: text$1("user_id").notNull(),
14719
+ resourceKind: text$1("resource_kind").notNull(),
14720
+ resourceId: text$1("resource_id").notNull(),
14721
+ lastOpenedAt: integer$1("last_opened_at", { mode: "timestamp_ms" }).notNull()
14722
+ }, (table) => [
14723
+ index$1("resource_activity_organization_id_idx").on(table.organizationId),
14724
+ uniqueIndex$1("resource_activity_project_user_kind_resource").on(table.projectId, table.userId, table.resourceKind, table.resourceId),
14725
+ index$1("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt)
14726
+ ]);
14727
+ /**
14728
+ * Platform control-plane tables — Postgres (hosted) or SQLite (local dev).
14729
+ *
14730
+ * Tenant (project-runtime) tables live under `./tables/tenant/` — staged here for
14731
+ * the single-db merge; `@keystrokehq/database` still owns the live runtime schema.
14732
+ */
14733
+ const tableRegistry = {
14734
+ organizations: {
14735
+ pg: organizations,
14736
+ sqlite: organizationsSqlite
14737
+ },
14738
+ organizationUsers: {
14739
+ pg: organizationUsers,
14740
+ sqlite: organizationUsersSqlite
14741
+ },
14742
+ organizationInvitations: {
14743
+ pg: organizationInvitations,
14744
+ sqlite: organizationInvitationsSqlite
14745
+ },
14746
+ projects: {
14747
+ pg: projects,
14748
+ sqlite: projectsSqlite
14749
+ },
14750
+ projectUsers: {
14751
+ pg: projectUsers,
14752
+ sqlite: projectUsersSqlite
14753
+ },
14754
+ projectArtifacts: {
14755
+ pg: projectArtifacts,
14756
+ sqlite: projectArtifactsSqlite
14757
+ },
14758
+ publishedForms: {
14759
+ pg: publishedForms,
14760
+ sqlite: publishedFormsSqlite
14761
+ },
14762
+ users: {
14763
+ pg: users,
14764
+ sqlite: usersSqlite
14765
+ },
14766
+ authSessions: {
14767
+ pg: authSessions,
14768
+ sqlite: authSessionsSqlite
14769
+ },
14770
+ authAccounts: {
14771
+ pg: authAccounts,
14772
+ sqlite: authAccountsSqlite
14773
+ },
14774
+ authVerifications: {
14775
+ pg: authVerifications,
14776
+ sqlite: authVerificationsSqlite
14777
+ },
14778
+ authDeviceCodes: {
14779
+ pg: authDeviceCodes,
14780
+ sqlite: authDeviceCodesSqlite
14781
+ },
14782
+ authJwks: {
14783
+ pg: authJwks,
14784
+ sqlite: authJwksSqlite
14785
+ },
14786
+ authApiKeys: {
14787
+ pg: authApiKeys,
14788
+ sqlite: authApiKeysSqlite
14789
+ },
14790
+ apps: {
14791
+ pg: apps,
14792
+ sqlite: appsSqlite
14793
+ },
14794
+ oauthApps: {
14795
+ pg: oauthApps,
14796
+ sqlite: oauthAppsSqlite
14797
+ },
14798
+ oauthConnections: {
14799
+ pg: oauthConnections,
14800
+ sqlite: oauthConnectionsSqlite
14801
+ },
14802
+ mcpOauthClient: {
14803
+ pg: mcpOauthClient,
14804
+ sqlite: mcpOauthClientSqlite
14805
+ },
14806
+ mcpOauthAccessToken: {
14807
+ pg: mcpOauthAccessToken,
14808
+ sqlite: mcpOauthAccessTokenSqlite
14809
+ },
14810
+ mcpOauthConsent: {
14811
+ pg: mcpOauthConsent,
14812
+ sqlite: mcpOauthConsentSqlite
14813
+ },
14814
+ secretValues: {
14815
+ pg: secretValues,
14816
+ sqlite: secretValuesSqlite
14817
+ },
14818
+ organizationBilling: {
14819
+ pg: organizationBilling,
14820
+ sqlite: organizationBillingSqlite
14821
+ },
14822
+ billingEvents: {
14823
+ pg: billingEvents,
14824
+ sqlite: billingEventsSqlite
14825
+ },
14826
+ billingWallet: {
14827
+ pg: billingWallet,
14828
+ sqlite: billingWalletSqlite
14829
+ },
14830
+ billingLedger: {
14831
+ pg: billingLedger,
14832
+ sqlite: billingLedgerSqlite
14833
+ },
14834
+ usageEvents: {
14835
+ pg: usageEvents,
14836
+ sqlite: usageEventsSqlite
14837
+ },
14838
+ managedServiceCredentials: {
14839
+ pg: managedServiceCredentials,
14840
+ sqlite: managedServiceCredentialsSqlite
14841
+ },
14842
+ agents: {
14843
+ pg: agents,
14844
+ sqlite: agentsSqlite
14845
+ },
14846
+ agentSessions: {
14847
+ pg: agentSessions,
14848
+ sqlite: agentSessionsSqlite
14849
+ },
14850
+ agentEvents: {
14851
+ pg: agentEvents,
14852
+ sqlite: agentEventsSqlite
14853
+ },
14854
+ triggers: {
14855
+ pg: triggers,
14856
+ sqlite: triggersSqlite
14857
+ },
14858
+ triggerAttachments: {
14859
+ pg: triggerAttachments,
14860
+ sqlite: triggerAttachmentsSqlite
14861
+ },
14862
+ triggerRuns: {
14863
+ pg: triggerRuns,
14864
+ sqlite: triggerRunsSqlite
14865
+ },
14866
+ workflowRuns: {
14867
+ pg: workflowRuns,
14868
+ sqlite: workflowRunsSqlite
14869
+ },
14870
+ workflowEvents: {
14871
+ pg: workflowEvents,
14872
+ sqlite: workflowEventsSqlite
14873
+ },
14874
+ workflowHooks: {
14875
+ pg: workflowHooks,
14876
+ sqlite: workflowHooksSqlite
14877
+ },
14878
+ credentialInstances: {
14879
+ pg: credentialInstances,
14880
+ sqlite: credentialInstancesSqlite
14881
+ },
14882
+ credentialAssignments: {
14883
+ pg: credentialAssignments,
14884
+ sqlite: credentialAssignmentsSqlite
14885
+ },
14886
+ jobs: {
14887
+ pg: jobs,
14888
+ sqlite: jobsSqlite
14889
+ },
14890
+ gatewayAttachments: {
14891
+ pg: gatewayAttachments,
14892
+ sqlite: gatewayAttachmentsSqlite
14893
+ },
14894
+ gatewayThreadSessions: {
14895
+ pg: gatewayThreadSessions,
14896
+ sqlite: gatewayThreadSessionsSqlite
14897
+ },
14898
+ traceSpans: {
14899
+ pg: traceSpans,
14900
+ sqlite: traceSpansSqlite
14901
+ },
14902
+ traceLogs: {
14903
+ pg: traceLogs,
14904
+ sqlite: traceLogsSqlite
14905
+ },
14906
+ skills: {
14907
+ pg: skills,
14908
+ sqlite: skillsSqlite
14909
+ },
14910
+ workflows: {
14911
+ pg: workflows,
14912
+ sqlite: workflowsSqlite
14913
+ },
14914
+ workflowSubscriptions: {
14915
+ pg: workflowSubscriptions,
14916
+ sqlite: workflowSubscriptionsSqlite
14917
+ },
14918
+ resourceActivity: {
14919
+ pg: resourceActivity,
14920
+ sqlite: resourceActivitySqlite
14099
14921
  }
14100
14922
  };
14101
14923
  buildPgSchema(tableRegistry);
@@ -31049,4 +31871,4 @@ async function emitStoredRouteManifestForProject(projectRoot) {
31049
31871
  //#endregion
31050
31872
  export { validatePollGroups as A, attachmentSlugFromRecord as B, pollRouteFromSourceSlug as C, validateAttachmentTargets as D, toStoredRouteManifest as E, webhookManifestAttachmentSchemasFromBindings as F, packAssetDirs as G, computeCallSiteIds as H, webhookMatchSchemaForBindings as I, entryIdFromFile as J, discoverEntries as K, webhookRouteFromEndpoint as L, validateTriggerAttachments as M, validateUniqueAttachmentSlugs as N, validateImportedTriggerAttachment as O, validateUniqueTriggerSourceSlugs as P, walkTypeScriptFiles as Q, workflowKeyForAttachment as R, pollGroupRouteFromId as S, serializeRouteManifest as T, diagnoseWorkflowSource as U, classifyCall as V, locateWorkflow as W, shouldSkipKeystrokeModuleFile as X, readKeystrokeIgnoreDirective as Y, validateUniqueModuleKeys as Z, importAgentDefinition as _, buildStoredRouteManifestForProject as a, persistStoredRouteManifest as b, collectAgentAppSlugs as c, discoverAgentEntries as d, discoverSkillManifestEntries as f, emitStoredRouteManifestForProject as g, discoverWorkflows as h, buildPollGroups as i, validateProjectModules as j, validateImportedWorkflowDefinition as k, collectAgentToolSlugs as l, discoverWorkflowEntries as m, agentManifestEntry as n, buildStoredRouteManifestFromContext as o, discoverTriggerAttachments as p, discoverModuleFileEntries as q, agentRouteFromKey as r, buildWebhookBindingsByRoute as s, agentKeyForAttachment as t, countAgentCredentials as u, importTriggerAttachments as v, schemaToJson as w, pollGroupId as x, importWorkflowDefinition as y, workflowRouteFromKey as z };
31051
31873
 
31052
- //# sourceMappingURL=dist-_VnO_w_x.mjs.map
31874
+ //# sourceMappingURL=dist-CPKiOMpO.mjs.map