@keystrokehq/cli 0.1.120 → 0.1.122

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-B48EHpH2.mjs";
4
+ import "./dist-DlXOuU_e.mjs";
5
5
  import "./chunk-BZUGFHVS-CPWRFwK8.mjs";
6
6
  import "./chunk-DLL7UR66-BUYgzxnR.mjs";
7
7
  import "./chunk-TN7HHBQW-CSB_R-XD.mjs";
@@ -25,14 +25,14 @@ import { pathToFileURL } from "node:url";
25
25
  import { readdir, stat } from "node:fs/promises";
26
26
  import { createHash } from "node:crypto";
27
27
  import ts from "typescript";
28
- import { bigint, boolean, doublePrecision, index, integer, jsonb, pgEnum, pgTable, primaryKey, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
28
+ import { bigint, boolean, doublePrecision, index, integer, jsonb, pgEnum, pgPolicy, pgTable, primaryKey, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
29
29
  import { index as index$1, integer as integer$1, primaryKey as primaryKey$1, real, sqliteTable, text as text$1, uniqueIndex as uniqueIndex$1 } from "drizzle-orm/sqlite-core";
30
30
  import { sql } from "drizzle-orm";
31
- import "drizzle-orm/pg-proxy";
32
31
  import "better-sqlite3";
33
32
  import "drizzle-orm/better-sqlite3";
34
33
  import "drizzle-orm/migrator";
35
34
  import "drizzle-orm/better-sqlite3/migrator";
35
+ import "drizzle-orm/pg-proxy";
36
36
  //#region ../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/chunks/chunk-G5EVRAOO.js
37
37
  createRequire(import.meta.url);
38
38
  var p;
@@ -2684,807 +2684,37 @@ Object.freeze({
2684
2684
  ["unalias", ["unalias [-a] name [name ...]", `Remove each NAME from the list of defined aliases.
2685
2685
  Exit Status:
2686
2686
  Returns success unless a NAME is not an existing alias.`]],
2687
- ["unset", ["unset [-f] [-v] [-n] [name ...]", `Unset values and attributes of shell variables and functions.
2688
- For each NAME, remove the corresponding variable or function.
2689
-
2690
- Options:
2691
- -f treat each NAME as a shell function
2692
- -v treat each NAME as a shell variable
2693
- -n treat each NAME as a name reference and unset the variable itself
2694
- rather than the variable it references
2695
-
2696
- Without options, unset first tries to unset a variable, and if that fails,
2697
- tries to unset a function.
2698
- Exit Status:
2699
- Returns success unless an invalid option is given or a NAME is read-only.`]],
2700
- ["wait", ["wait [-fn] [id ...]", `Wait for job completion and return exit status.
2701
- Waits for each process identified by an ID, which may be a process ID or a
2702
- job specification, and reports its termination status.
2703
- Exit Status:
2704
- Returns the status of the last ID; fails if ID is invalid or an invalid
2705
- option is given.`]]
2706
- ]).keys()].sort();
2707
- new TextDecoder("utf-8", { fatal: !0 });
2708
- JSON.stringify({
2709
- messages: [],
2710
- results: [],
2711
- items: [],
2712
- data: {
2713
- messages: [],
2714
- items: [],
2715
- results: []
2716
- }
2717
- });
2718
- new AsyncLocalStorage();
2719
- new AsyncLocalStorage();
2720
- new AsyncLocalStorage();
2721
- new AsyncLocalStorage();
2722
- createRequire(import.meta.url);
2723
- function buildPgSchema$1(registry) {
2724
- return Object.fromEntries(Object.entries(registry).map(([name, { pg }]) => [name, pg]));
2725
- }
2726
- function buildSqliteSchema$1(registry) {
2727
- return Object.fromEntries(Object.entries(registry).map(([name, { sqlite }]) => [name, sqlite]));
2728
- }
2729
- const agents$1 = pgTable("agents", {
2730
- id: text("id").primaryKey(),
2731
- projectId: text("project_id").notNull(),
2732
- slug: text("slug").notNull(),
2733
- name: text("name"),
2734
- description: text("description"),
2735
- route: text("route").notNull(),
2736
- moduleFile: text("module_file").notNull(),
2737
- model: text("model").notNull(),
2738
- systemPrompt: text("system_prompt").notNull(),
2739
- toolCount: integer("tool_count"),
2740
- credentialCount: integer("credential_count"),
2741
- appSlugs: jsonb("app_slugs").$type(),
2742
- registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
2743
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2744
- deletedAt: timestamp("deleted_at", { withTimezone: true })
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$1 = sqliteTable("agents", {
2747
- id: text$1("id").primaryKey(),
2748
- projectId: text$1("project_id").notNull(),
2749
- slug: text$1("slug").notNull(),
2750
- name: text$1("name"),
2751
- description: text$1("description"),
2752
- route: text$1("route").notNull(),
2753
- moduleFile: text$1("module_file").notNull(),
2754
- model: text$1("model").notNull(),
2755
- systemPrompt: text$1("system_prompt").notNull(),
2756
- toolCount: integer$1("tool_count"),
2757
- credentialCount: integer$1("credential_count"),
2758
- appSlugs: text$1("app_slugs", { mode: "json" }).$type(),
2759
- registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
2760
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2761
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
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$1 = pgTable("agent_sessions", {
2764
- id: text("id").primaryKey(),
2765
- projectId: text("project_id").notNull(),
2766
- agentId: text("agent_id").notNull().references(() => agents$1.id),
2767
- sourceKind: text("source_kind").$type().notNull().default("api"),
2768
- sourceId: text("source_id"),
2769
- parentSpanId: text("parent_span_id"),
2770
- ranByUserId: text("ran_by_user_id"),
2771
- title: text("title"),
2772
- canceledAt: timestamp("canceled_at", { withTimezone: true }),
2773
- status: text("status").$type(),
2774
- totalDurationMs: integer("total_duration_ms").notNull().default(0),
2775
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
2776
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2777
- deletedAt: timestamp("deleted_at", { withTimezone: true })
2778
- }, (table) => [index("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
2779
- const agentSessionsSqlite$1 = sqliteTable("agent_sessions", {
2780
- id: text$1("id").primaryKey(),
2781
- projectId: text$1("project_id").notNull(),
2782
- agentId: text$1("agent_id").notNull().references(() => agentsSqlite$1.id),
2783
- sourceKind: text$1("source_kind").$type().notNull().default("api"),
2784
- sourceId: text$1("source_id"),
2785
- parentSpanId: text$1("parent_span_id"),
2786
- ranByUserId: text$1("ran_by_user_id"),
2787
- title: text$1("title"),
2788
- canceledAt: integer$1("canceled_at", { mode: "timestamp_ms" }),
2789
- status: text$1("status").$type(),
2790
- totalDurationMs: integer$1("total_duration_ms").notNull().default(0),
2791
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
2792
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2793
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2794
- }, (table) => [index$1("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
2795
- const agentEvents$1 = pgTable("agent_events", {
2796
- id: text("id").primaryKey(),
2797
- sessionId: text("session_id").notNull().references(() => agentSessions$1.id),
2798
- seq: integer("seq").notNull(),
2799
- eventType: text("event_type").notNull(),
2800
- payload: jsonb("payload").notNull(),
2801
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
2802
- deletedAt: timestamp("deleted_at", { withTimezone: true })
2803
- }, (table) => [index("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
2804
- const agentEventsSqlite$1 = sqliteTable("agent_events", {
2805
- id: text$1("id").primaryKey(),
2806
- sessionId: text$1("session_id").notNull().references(() => agentSessionsSqlite$1.id),
2807
- seq: integer$1("seq").notNull(),
2808
- eventType: text$1("event_type").notNull(),
2809
- payload: text$1("payload", { mode: "json" }).notNull(),
2810
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
2811
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2812
- }, (table) => [index$1("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
2813
- const triggers$1 = pgTable("triggers", {
2814
- id: text("id").primaryKey(),
2815
- projectId: text("project_id").notNull(),
2816
- slug: text("slug").notNull(),
2817
- kind: text("kind").$type().notNull(),
2818
- name: text("name"),
2819
- description: text("description"),
2820
- moduleFile: text("module_file").notNull(),
2821
- origin: text("origin").$type().notNull().default("project"),
2822
- config: jsonb("config").$type(),
2823
- state: jsonb("state").$type(),
2824
- schedule: text("schedule"),
2825
- nextRunAt: timestamp("next_run_at", { withTimezone: true }),
2826
- enabled: integer("enabled").notNull().default(1),
2827
- lifecycle: jsonb("lifecycle").$type(),
2828
- createdBySessionId: text("created_by_session_id"),
2829
- triggerHash: text("trigger_hash"),
2830
- overviewMarkdown: text("overview_markdown"),
2831
- overviewHash: text("overview_hash"),
2832
- overviewModel: text("overview_model"),
2833
- overviewStatus: text("overview_status").$type().notNull().default("idle"),
2834
- overviewGeneratedAt: timestamp("overview_generated_at", { withTimezone: true }),
2835
- registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
2836
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2837
- deletedAt: timestamp("deleted_at", { withTimezone: true })
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$1 = sqliteTable("triggers", {
2840
- id: text$1("id").primaryKey(),
2841
- projectId: text$1("project_id").notNull(),
2842
- slug: text$1("slug").notNull(),
2843
- kind: text$1("kind").$type().notNull(),
2844
- name: text$1("name"),
2845
- description: text$1("description"),
2846
- moduleFile: text$1("module_file").notNull(),
2847
- origin: text$1("origin").$type().notNull().default("project"),
2848
- config: text$1("config", { mode: "json" }).$type(),
2849
- state: text$1("state", { mode: "json" }).$type(),
2850
- schedule: text$1("schedule"),
2851
- nextRunAt: integer$1("next_run_at", { mode: "timestamp_ms" }),
2852
- enabled: integer$1("enabled").notNull().default(1),
2853
- lifecycle: text$1("lifecycle", { mode: "json" }).$type(),
2854
- createdBySessionId: text$1("created_by_session_id"),
2855
- triggerHash: text$1("trigger_hash"),
2856
- overviewMarkdown: text$1("overview_markdown"),
2857
- overviewHash: text$1("overview_hash"),
2858
- overviewModel: text$1("overview_model"),
2859
- overviewStatus: text$1("overview_status").$type().notNull().default("idle"),
2860
- overviewGeneratedAt: integer$1("overview_generated_at", { mode: "timestamp_ms" }),
2861
- registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
2862
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2863
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
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$1 = pgTable("trigger_attachments", {
2866
- id: text("id").primaryKey(),
2867
- projectId: text("project_id").notNull(),
2868
- triggerId: text("trigger_id").notNull().references(() => triggers$1.id),
2869
- slug: text("slug").notNull(),
2870
- targetKind: text("target_kind").$type().notNull().default("workflow"),
2871
- workflowSlug: text("workflow_slug"),
2872
- agentSlug: text("agent_slug"),
2873
- prompt: text("prompt"),
2874
- registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
2875
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
2876
- disabledAt: timestamp("disabled_at", { withTimezone: true }),
2877
- deletedAt: timestamp("deleted_at", { withTimezone: true })
2878
- }, (table) => [uniqueIndex("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
2879
- const triggerAttachmentsSqlite$1 = sqliteTable("trigger_attachments", {
2880
- id: text$1("id").primaryKey(),
2881
- projectId: text$1("project_id").notNull(),
2882
- triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite$1.id),
2883
- slug: text$1("slug").notNull(),
2884
- targetKind: text$1("target_kind").$type().notNull().default("workflow"),
2885
- workflowSlug: text$1("workflow_slug"),
2886
- agentSlug: text$1("agent_slug"),
2887
- prompt: text$1("prompt"),
2888
- registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
2889
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
2890
- disabledAt: integer$1("disabled_at", { mode: "timestamp_ms" }),
2891
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
2892
- }, (table) => [uniqueIndex$1("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
2893
- const triggerRuns$1 = pgTable("trigger_runs", {
2894
- id: text("id").primaryKey(),
2895
- projectId: text("project_id").notNull(),
2896
- triggerId: text("trigger_id").notNull().references(() => triggers$1.id),
2897
- sourcePath: text("source_path"),
2898
- triggerType: text("trigger_type").$type().notNull(),
2899
- outcome: text("outcome").$type().notNull().default("dispatched"),
2900
- reason: text("reason").$type(),
2901
- detail: text("detail"),
2902
- payload: jsonb("payload"),
2903
- triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull()
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$1 = sqliteTable("trigger_runs", {
2906
- id: text$1("id").primaryKey(),
2907
- projectId: text$1("project_id").notNull(),
2908
- triggerId: text$1("trigger_id").notNull().references(() => triggersSqlite$1.id),
2909
- sourcePath: text$1("source_path"),
2910
- triggerType: text$1("trigger_type").$type().notNull(),
2911
- outcome: text$1("outcome").$type().notNull().default("dispatched"),
2912
- reason: text$1("reason").$type(),
2913
- detail: text$1("detail"),
2914
- payload: text$1("payload", { mode: "json" }),
2915
- triggeredAt: integer$1("triggered_at", { mode: "timestamp_ms" }).notNull()
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$1 = pgTable("workflow_subscriptions", {
2918
- id: text("id").primaryKey(),
2919
- projectId: text("project_id").notNull(),
2920
- workflowSlug: text("workflow_slug").notNull(),
2921
- userId: text("user_id").notNull(),
2922
- enabled: integer("enabled").notNull(),
2923
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
2924
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
2925
- }, (table) => [uniqueIndex("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
2926
- const workflowSubscriptionsSqlite$1 = sqliteTable("workflow_subscriptions", {
2927
- id: text$1("id").primaryKey(),
2928
- projectId: text$1("project_id").notNull(),
2929
- workflowSlug: text$1("workflow_slug").notNull(),
2930
- userId: text$1("user_id").notNull(),
2931
- enabled: integer$1("enabled", { mode: "boolean" }).notNull(),
2932
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
2933
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
2934
- }, (table) => [uniqueIndex$1("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
2935
- const workflowRuns$1 = pgTable("workflow_runs", {
2936
- id: text("id").primaryKey(),
2937
- projectId: text("project_id").notNull(),
2938
- workflowSlug: text("workflow_slug").notNull(),
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
- parentWorkflowRunId: text("parent_workflow_run_id"),
2943
- parentSpanId: text("parent_span_id"),
2944
- sourceKind: text("source_kind").$type().notNull().default("api"),
2945
- sourceId: text("source_id"),
2946
- ranByUserId: text("ran_by_user_id"),
2947
- credentialContext: jsonb("credential_context").$type(),
2948
- status: text("status").$type().notNull(),
2949
- trigger: text("trigger").$type().notNull(),
2950
- triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull(),
2951
- startedAt: timestamp("started_at", { withTimezone: true }),
2952
- finishedAt: timestamp("finished_at", { withTimezone: true }),
2953
- input: jsonb("input"),
2954
- output: jsonb("output"),
2955
- error: jsonb("error")
2956
- }, (table) => [index("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt)]);
2957
- const workflowRunsSqlite$1 = sqliteTable("workflow_runs", {
2958
- id: text$1("id").primaryKey(),
2959
- projectId: text$1("project_id").notNull(),
2960
- workflowSlug: text$1("workflow_slug").notNull(),
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
- parentWorkflowRunId: text$1("parent_workflow_run_id"),
2965
- parentSpanId: text$1("parent_span_id"),
2966
- sourceKind: text$1("source_kind").$type().notNull().default("api"),
2967
- sourceId: text$1("source_id"),
2968
- ranByUserId: text$1("ran_by_user_id"),
2969
- credentialContext: text$1("credential_context", { mode: "json" }).$type(),
2970
- status: text$1("status").$type().notNull(),
2971
- trigger: text$1("trigger").$type().notNull(),
2972
- triggeredAt: integer$1("triggered_at", { mode: "timestamp_ms" }).notNull(),
2973
- startedAt: integer$1("started_at", { mode: "timestamp_ms" }),
2974
- finishedAt: integer$1("finished_at", { mode: "timestamp_ms" }),
2975
- input: text$1("input", { mode: "json" }),
2976
- output: text$1("output", { mode: "json" }),
2977
- error: text$1("error", { mode: "json" })
2978
- }, (table) => [index$1("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt)]);
2979
- /**
2980
- * Append-only durable execution log. One row per workflow lifecycle transition.
2981
- * Replay reads these in `seq` order and short-circuits already-completed primitives.
2982
- */
2983
- const workflowEvents$1 = pgTable("workflow_events", {
2984
- id: text("id").primaryKey(),
2985
- runId: text("run_id").notNull().references(() => workflowRuns$1.id),
2986
- projectId: text("project_id").notNull(),
2987
- seq: integer("seq").notNull(),
2988
- type: text("type").$type().notNull(),
2989
- correlationId: text("correlation_id"),
2990
- data: jsonb("data"),
2991
- createdAt: timestamp("created_at", { withTimezone: true }).notNull()
2992
- }, (table) => [
2993
- uniqueIndex("workflow_events_run_id_seq_unique").on(table.runId, table.seq),
2994
- index("workflow_events_run_id_type_idx").on(table.runId, table.type),
2995
- index("workflow_events_correlation_id_idx").on(table.correlationId)
2996
- ]);
2997
- const workflowEventsSqlite$1 = sqliteTable("workflow_events", {
2998
- id: text$1("id").primaryKey(),
2999
- runId: text$1("run_id").notNull().references(() => workflowRunsSqlite$1.id),
3000
- projectId: text$1("project_id").notNull(),
3001
- seq: integer$1("seq").notNull(),
3002
- type: text$1("type").$type().notNull(),
3003
- correlationId: text$1("correlation_id"),
3004
- data: text$1("data", { mode: "json" }),
3005
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
3006
- }, (table) => [
3007
- uniqueIndex$1("workflow_events_run_id_seq_unique").on(table.runId, table.seq),
3008
- index$1("workflow_events_run_id_type_idx").on(table.runId, table.type),
3009
- index$1("workflow_events_correlation_id_idx").on(table.correlationId)
3010
- ]);
3011
- const workflowHooks$1 = pgTable("workflow_hooks", {
3012
- hookId: text("hook_id").primaryKey(),
3013
- runId: text("run_id").notNull().references(() => workflowRuns$1.id),
3014
- projectId: text("project_id").notNull(),
3015
- token: text("token").notNull(),
3016
- correlationId: text("correlation_id").notNull(),
3017
- status: text("status").$type().notNull(),
3018
- schema: jsonb("schema"),
3019
- payload: jsonb("payload"),
3020
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3021
- resumedAt: timestamp("resumed_at", { withTimezone: true })
3022
- }, (table) => [uniqueIndex("workflow_hooks_token_unique").on(table.token), index("workflow_hooks_run_id_idx").on(table.runId)]);
3023
- const workflowHooksSqlite$1 = sqliteTable("workflow_hooks", {
3024
- hookId: text$1("hook_id").primaryKey(),
3025
- runId: text$1("run_id").notNull().references(() => workflowRunsSqlite$1.id),
3026
- projectId: text$1("project_id").notNull(),
3027
- token: text$1("token").notNull(),
3028
- correlationId: text$1("correlation_id").notNull(),
3029
- status: text$1("status").$type().notNull(),
3030
- schema: text$1("schema", { mode: "json" }),
3031
- payload: text$1("payload", { mode: "json" }),
3032
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3033
- resumedAt: integer$1("resumed_at", { mode: "timestamp_ms" })
3034
- }, (table) => [uniqueIndex$1("workflow_hooks_token_unique").on(table.token), index$1("workflow_hooks_run_id_idx").on(table.runId)]);
3035
- const credentialInstances$1 = pgTable("credential_instances", {
3036
- id: text("id").primaryKey(),
3037
- projectId: text("project_id").notNull(),
3038
- appSlug: text("app_slug").notNull(),
3039
- slug: text("slug").notNull(),
3040
- name: text("name"),
3041
- scopeType: text("scope_type").$type().notNull(),
3042
- scopeId: text("scope_id"),
3043
- label: text("label"),
3044
- isDefault: integer("is_default").notNull(),
3045
- authKind: text("auth_kind").$type().notNull(),
3046
- ciphertext: text("ciphertext"),
3047
- connectionId: text("connection_id"),
3048
- /** MCP entity id that owns connection_id when multiple scopes share one connection. */
3049
- sharedConnectionId: text("shared_connection_id"),
3050
- grantedScopes: jsonb("granted_scopes").$type(),
3051
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3052
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3053
- lastUsedAt: timestamp("last_used_at", { withTimezone: true })
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$1 = sqliteTable("credential_instances", {
3056
- id: text$1("id").primaryKey(),
3057
- projectId: text$1("project_id").notNull(),
3058
- appSlug: text$1("app_slug").notNull(),
3059
- slug: text$1("slug").notNull(),
3060
- name: text$1("name"),
3061
- scopeType: text$1("scope_type").$type().notNull(),
3062
- scopeId: text$1("scope_id"),
3063
- label: text$1("label"),
3064
- isDefault: integer$1("is_default", { mode: "boolean" }).notNull(),
3065
- authKind: text$1("auth_kind").$type().notNull(),
3066
- ciphertext: text$1("ciphertext"),
3067
- connectionId: text$1("connection_id"),
3068
- /** MCP entity id that owns connection_id when multiple scopes share one connection. */
3069
- sharedConnectionId: text$1("shared_connection_id"),
3070
- grantedScopes: text$1("granted_scopes", { mode: "json" }).$type(),
3071
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3072
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3073
- lastUsedAt: integer$1("last_used_at", { mode: "timestamp_ms" })
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$1 = pgTable("credential_assignments", {
3076
- id: text("id").primaryKey(),
3077
- projectId: text("project_id").notNull(),
3078
- targetType: text("target_type").$type().notNull(),
3079
- targetKey: text("target_key").notNull(),
3080
- /** '*' = wildcard; else runtime consumer id (step correlation id or tool slug). */
3081
- consumerId: text("consumer_id").notNull(),
3082
- credentialSlug: text("credential_slug").notNull(),
3083
- instanceId: text("instance_id").notNull(),
3084
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3085
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
3086
- }, (table) => [uniqueIndex("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug)]);
3087
- const credentialAssignmentsSqlite$1 = sqliteTable("credential_assignments", {
3088
- id: text$1("id").primaryKey(),
3089
- projectId: text$1("project_id").notNull(),
3090
- targetType: text$1("target_type").$type().notNull(),
3091
- targetKey: text$1("target_key").notNull(),
3092
- consumerId: text$1("consumer_id").notNull(),
3093
- credentialSlug: text$1("credential_slug").notNull(),
3094
- instanceId: text$1("instance_id").notNull(),
3095
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3096
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
3097
- }, (table) => [uniqueIndex$1("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug)]);
3098
- const jobs$1 = pgTable("jobs", {
3099
- id: text("id").primaryKey(),
3100
- projectId: text("project_id").notNull(),
3101
- kind: text("kind").$type().notNull(),
3102
- targetId: text("target_id").notNull(),
3103
- runId: text("run_id").notNull(),
3104
- trigger: text("trigger").$type().notNull(),
3105
- payload: jsonb("payload"),
3106
- parent: jsonb("parent").$type(),
3107
- status: text("status").$type().notNull(),
3108
- scheduledAt: timestamp("scheduled_at", { withTimezone: true }).notNull(),
3109
- attempt: integer("attempt").notNull(),
3110
- maxAttempts: integer("max_attempts").notNull(),
3111
- leasedBy: text("leased_by"),
3112
- leaseExpiresAt: timestamp("lease_expires_at", { withTimezone: true }),
3113
- completedAt: timestamp("completed_at", { withTimezone: true }),
3114
- error: jsonb("error")
3115
- });
3116
- const jobsSqlite$1 = sqliteTable("jobs", {
3117
- id: text$1("id").primaryKey(),
3118
- projectId: text$1("project_id").notNull(),
3119
- kind: text$1("kind").$type().notNull(),
3120
- targetId: text$1("target_id").notNull(),
3121
- runId: text$1("run_id").notNull(),
3122
- trigger: text$1("trigger").$type().notNull(),
3123
- payload: text$1("payload", { mode: "json" }),
3124
- parent: text$1("parent", { mode: "json" }).$type(),
3125
- status: text$1("status").$type().notNull(),
3126
- scheduledAt: integer$1("scheduled_at", { mode: "timestamp_ms" }).notNull(),
3127
- attempt: integer$1("attempt").notNull(),
3128
- maxAttempts: integer$1("max_attempts").notNull(),
3129
- leasedBy: text$1("leased_by"),
3130
- leaseExpiresAt: integer$1("lease_expires_at", { mode: "timestamp_ms" }),
3131
- completedAt: integer$1("completed_at", { mode: "timestamp_ms" }),
3132
- error: text$1("error", { mode: "json" })
3133
- });
3134
- const gatewayAttachments$1 = pgTable("gateway_attachments", {
3135
- id: text("id").primaryKey(),
3136
- projectId: text("project_id").notNull(),
3137
- slug: text("slug").notNull(),
3138
- agentSlug: text("agent_slug").notNull(),
3139
- moduleFile: text("module_file"),
3140
- platform: text("platform").notNull(),
3141
- teamId: text("team_id"),
3142
- channelId: text("channel_id").notNull(),
3143
- source: jsonb("source").$type().notNull(),
3144
- registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
3145
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3146
- deletedAt: timestamp("deleted_at", { withTimezone: true })
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$1 = sqliteTable("gateway_attachments", {
3149
- id: text$1("id").primaryKey(),
3150
- projectId: text$1("project_id").notNull(),
3151
- slug: text$1("slug").notNull(),
3152
- agentSlug: text$1("agent_slug").notNull(),
3153
- moduleFile: text$1("module_file"),
3154
- platform: text$1("platform").notNull(),
3155
- teamId: text$1("team_id"),
3156
- channelId: text$1("channel_id").notNull(),
3157
- source: text$1("source", { mode: "json" }).$type().notNull(),
3158
- registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
3159
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3160
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
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$1 = pgTable("gateway_thread_sessions", {
3163
- threadId: text("thread_id").primaryKey(),
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
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
3168
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
3169
- });
3170
- const gatewayThreadSessionsSqlite$1 = sqliteTable("gateway_thread_sessions", {
3171
- threadId: text$1("thread_id").primaryKey(),
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
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
3176
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
3177
- });
3178
- const traceSpans$1 = pgTable("trace_spans", {
3179
- id: text("id").primaryKey(),
3180
- traceId: text("trace_id").notNull(),
3181
- parentSpanId: text("parent_span_id"),
3182
- kind: text("kind").$type().notNull(),
3183
- refId: text("ref_id").notNull(),
3184
- name: text("name").notNull(),
3185
- status: text("status").$type().notNull(),
3186
- startedAt: timestamp("started_at", { withTimezone: true }).notNull(),
3187
- finishedAt: timestamp("finished_at", { withTimezone: true }),
3188
- metadata: jsonb("metadata"),
3189
- error: jsonb("error")
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$1 = sqliteTable("trace_spans", {
3192
- id: text$1("id").primaryKey(),
3193
- traceId: text$1("trace_id").notNull(),
3194
- parentSpanId: text$1("parent_span_id"),
3195
- kind: text$1("kind").$type().notNull(),
3196
- refId: text$1("ref_id").notNull(),
3197
- name: text$1("name").notNull(),
3198
- status: text$1("status").$type().notNull(),
3199
- startedAt: integer$1("started_at", { mode: "timestamp_ms" }).notNull(),
3200
- finishedAt: integer$1("finished_at", { mode: "timestamp_ms" }),
3201
- metadata: text$1("metadata", { mode: "json" }),
3202
- error: text$1("error", { mode: "json" })
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$1 = pgTable("trace_logs", {
3205
- id: text("id").primaryKey(),
3206
- traceId: text("trace_id").notNull(),
3207
- spanId: text("span_id").notNull().references(() => traceSpans$1.id),
3208
- seq: integer("seq").notNull(),
3209
- level: text("level").$type().notNull(),
3210
- message: text("message").notNull(),
3211
- data: jsonb("data"),
3212
- source: text("source").$type().notNull(),
3213
- createdAt: timestamp("created_at", { withTimezone: true }).notNull()
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$1 = sqliteTable("trace_logs", {
3216
- id: text$1("id").primaryKey(),
3217
- traceId: text$1("trace_id").notNull(),
3218
- spanId: text$1("span_id").notNull().references(() => traceSpansSqlite$1.id),
3219
- seq: integer$1("seq").notNull(),
3220
- level: text$1("level").$type().notNull(),
3221
- message: text$1("message").notNull(),
3222
- data: text$1("data", { mode: "json" }),
3223
- source: text$1("source").$type().notNull(),
3224
- createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
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$1 = pgTable("skills", {
3227
- id: text("id").primaryKey(),
3228
- projectId: text("project_id").notNull(),
3229
- slug: text("slug").notNull(),
3230
- name: text("name"),
3231
- description: text("description"),
3232
- moduleFile: text("module_file").notNull(),
3233
- registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
3234
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3235
- deletedAt: timestamp("deleted_at", { withTimezone: true })
3236
- }, (table) => [uniqueIndex("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
3237
- const skillsSqlite$1 = sqliteTable("skills", {
3238
- id: text$1("id").primaryKey(),
3239
- projectId: text$1("project_id").notNull(),
3240
- slug: text$1("slug").notNull(),
3241
- name: text$1("name"),
3242
- description: text$1("description"),
3243
- moduleFile: text$1("module_file").notNull(),
3244
- registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
3245
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3246
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" })
3247
- }, (table) => [uniqueIndex$1("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
3248
- const workflows$1 = pgTable("workflows", {
3249
- id: text("id").primaryKey(),
3250
- projectId: text("project_id").notNull(),
3251
- slug: text("slug").notNull(),
3252
- name: text("name").notNull(),
3253
- description: text("description").notNull(),
3254
- moduleFile: text("module_file").notNull(),
3255
- subscribable: integer("subscribable").notNull(),
3256
- registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
3257
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
3258
- deletedAt: timestamp("deleted_at", { withTimezone: true }),
3259
- requestSchema: jsonb("request_schema").$type().notNull().default({}),
3260
- runInputValues: jsonb("run_input_values").$type(),
3261
- canvasAnnotationsJson: jsonb("canvas_annotations_json").$type(),
3262
- canvasAnnotationsHash: text("canvas_annotations_hash"),
3263
- canvasAnnotationsModel: text("canvas_annotations_model"),
3264
- canvasAnnotationsStatus: text("canvas_annotations_status").$type().notNull().default("idle"),
3265
- canvasAnnotationsGeneratedAt: timestamp("canvas_annotations_generated_at", { withTimezone: true }),
3266
- overviewSummary: text("overview_summary"),
3267
- overviewPhasesJson: jsonb("overview_phases_json").$type(),
3268
- overviewHash: text("overview_hash"),
3269
- overviewModel: text("overview_model"),
3270
- overviewStatus: text("overview_status").$type().notNull().default("idle"),
3271
- overviewGeneratedAt: timestamp("overview_generated_at", { withTimezone: true })
3272
- }, (table) => [uniqueIndex("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
3273
- const workflowsSqlite$1 = sqliteTable("workflows", {
3274
- id: text$1("id").primaryKey(),
3275
- projectId: text$1("project_id").notNull(),
3276
- slug: text$1("slug").notNull(),
3277
- name: text$1("name").notNull(),
3278
- description: text$1("description").notNull(),
3279
- moduleFile: text$1("module_file").notNull(),
3280
- subscribable: integer$1("subscribable", { mode: "boolean" }).notNull(),
3281
- registeredAt: integer$1("registered_at", { mode: "timestamp_ms" }).notNull(),
3282
- updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull(),
3283
- deletedAt: integer$1("deleted_at", { mode: "timestamp_ms" }),
3284
- requestSchema: text$1("request_schema", { mode: "json" }).$type().notNull().default({}),
3285
- runInputValues: text$1("run_input_values", { mode: "json" }).$type(),
3286
- canvasAnnotationsJson: text$1("canvas_annotations_json", { mode: "json" }).$type(),
3287
- canvasAnnotationsHash: text$1("canvas_annotations_hash"),
3288
- canvasAnnotationsModel: text$1("canvas_annotations_model"),
3289
- canvasAnnotationsStatus: text$1("canvas_annotations_status").$type().notNull().default("idle"),
3290
- canvasAnnotationsGeneratedAt: integer$1("canvas_annotations_generated_at", { mode: "timestamp_ms" }),
3291
- overviewSummary: text$1("overview_summary"),
3292
- overviewPhasesJson: text$1("overview_phases_json", { mode: "json" }).$type(),
3293
- overviewHash: text$1("overview_hash"),
3294
- overviewModel: text$1("overview_model"),
3295
- overviewStatus: text$1("overview_status").$type().notNull().default("idle"),
3296
- overviewGeneratedAt: integer$1("overview_generated_at", { mode: "timestamp_ms" })
3297
- }, (table) => [uniqueIndex$1("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
3298
- const resourceActivity$1 = pgTable("resource_activity", {
3299
- id: text("id").primaryKey(),
3300
- projectId: text("project_id").notNull(),
3301
- userId: text("user_id").notNull(),
3302
- resourceKind: text("resource_kind").notNull(),
3303
- resourceId: text("resource_id").notNull(),
3304
- lastOpenedAt: timestamp("last_opened_at", { withTimezone: true }).notNull()
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$1 = sqliteTable("resource_activity", {
3307
- id: text$1("id").primaryKey(),
3308
- projectId: text$1("project_id").notNull(),
3309
- userId: text$1("user_id").notNull(),
3310
- resourceKind: text$1("resource_kind").notNull(),
3311
- resourceId: text$1("resource_id").notNull(),
3312
- lastOpenedAt: integer$1("last_opened_at", { mode: "timestamp_ms" }).notNull()
3313
- }, (table) => [uniqueIndex$1("resource_activity_project_user_kind_resource").on(table.projectId, table.userId, table.resourceKind, table.resourceId), index$1("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt)]);
3314
- /**
3315
- * Project server tables — Postgres (hosted) or SQLite (local dev).
3316
- */
3317
- const tableRegistry$1 = {
3318
- agents: {
3319
- pg: agents$1,
3320
- sqlite: agentsSqlite$1
3321
- },
3322
- agentSessions: {
3323
- pg: agentSessions$1,
3324
- sqlite: agentSessionsSqlite$1
3325
- },
3326
- agentEvents: {
3327
- pg: agentEvents$1,
3328
- sqlite: agentEventsSqlite$1
3329
- },
3330
- triggers: {
3331
- pg: triggers$1,
3332
- sqlite: triggersSqlite$1
3333
- },
3334
- triggerAttachments: {
3335
- pg: triggerAttachments$1,
3336
- sqlite: triggerAttachmentsSqlite$1
3337
- },
3338
- triggerRuns: {
3339
- pg: triggerRuns$1,
3340
- sqlite: triggerRunsSqlite$1
3341
- },
3342
- workflowRuns: {
3343
- pg: workflowRuns$1,
3344
- sqlite: workflowRunsSqlite$1
3345
- },
3346
- workflowEvents: {
3347
- pg: workflowEvents$1,
3348
- sqlite: workflowEventsSqlite$1
3349
- },
3350
- workflowHooks: {
3351
- pg: workflowHooks$1,
3352
- sqlite: workflowHooksSqlite$1
3353
- },
3354
- credentialInstances: {
3355
- pg: credentialInstances$1,
3356
- sqlite: credentialInstancesSqlite$1
3357
- },
3358
- credentialAssignments: {
3359
- pg: credentialAssignments$1,
3360
- sqlite: credentialAssignmentsSqlite$1
3361
- },
3362
- jobs: {
3363
- pg: jobs$1,
3364
- sqlite: jobsSqlite$1
3365
- },
3366
- gatewayAttachments: {
3367
- pg: gatewayAttachments$1,
3368
- sqlite: gatewayAttachmentsSqlite$1
3369
- },
3370
- gatewayThreadSessions: {
3371
- pg: gatewayThreadSessions$1,
3372
- sqlite: gatewayThreadSessionsSqlite$1
3373
- },
3374
- traceSpans: {
3375
- pg: traceSpans$1,
3376
- sqlite: traceSpansSqlite$1
3377
- },
3378
- traceLogs: {
3379
- pg: traceLogs$1,
3380
- sqlite: traceLogsSqlite$1
3381
- },
3382
- skills: {
3383
- pg: skills$1,
3384
- sqlite: skillsSqlite$1
3385
- },
3386
- workflows: {
3387
- pg: workflows$1,
3388
- sqlite: workflowsSqlite$1
3389
- },
3390
- workflowSubscriptions: {
3391
- pg: workflowSubscriptions$1,
3392
- sqlite: workflowSubscriptionsSqlite$1
3393
- },
3394
- resourceActivity: {
3395
- pg: resourceActivity$1,
3396
- sqlite: resourceActivitySqlite$1
2687
+ ["unset", ["unset [-f] [-v] [-n] [name ...]", `Unset values and attributes of shell variables and functions.
2688
+ For each NAME, remove the corresponding variable or function.
2689
+
2690
+ Options:
2691
+ -f treat each NAME as a shell function
2692
+ -v treat each NAME as a shell variable
2693
+ -n treat each NAME as a name reference and unset the variable itself
2694
+ rather than the variable it references
2695
+
2696
+ Without options, unset first tries to unset a variable, and if that fails,
2697
+ tries to unset a function.
2698
+ Exit Status:
2699
+ Returns success unless an invalid option is given or a NAME is read-only.`]],
2700
+ ["wait", ["wait [-fn] [id ...]", `Wait for job completion and return exit status.
2701
+ Waits for each process identified by an ID, which may be a process ID or a
2702
+ job specification, and reports its termination status.
2703
+ Exit Status:
2704
+ Returns the status of the last ID; fails if ID is invalid or an invalid
2705
+ option is given.`]]
2706
+ ]).keys()].sort();
2707
+ new TextDecoder("utf-8", { fatal: !0 });
2708
+ JSON.stringify({
2709
+ messages: [],
2710
+ results: [],
2711
+ items: [],
2712
+ data: {
2713
+ messages: [],
2714
+ items: [],
2715
+ results: []
3397
2716
  }
3398
- };
3399
- buildPgSchema$1(tableRegistry$1);
3400
- buildSqliteSchema$1(tableRegistry$1);
3401
- new AsyncLocalStorage();
3402
- const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
3403
- const AgentModelIdSchema = custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
3404
- const GatewayModelPricingSchema = object({
3405
- input: string().optional(),
3406
- output: string().optional(),
3407
- input_cache_read: string().optional(),
3408
- input_cache_write: string().optional()
3409
- });
3410
- object({
3411
- id: string().min(1),
3412
- name: string().optional(),
3413
- type: string().optional(),
3414
- context_window: number().int().positive().optional(),
3415
- max_tokens: number().int().positive().optional(),
3416
- tags: array(string()).optional(),
3417
- pricing: GatewayModelPricingSchema.optional()
3418
- });
3419
- const ThinkingLevelSchema = _enum([
3420
- "provider-default",
3421
- "none",
3422
- "minimal",
3423
- "low",
3424
- "medium",
3425
- "high",
3426
- "xhigh"
3427
- ]);
3428
- object({
3429
- systemPrompt: string(),
3430
- model: AgentModelIdSchema,
3431
- /**
3432
- * Optional model used only for context compaction. Same `vendor/model-id` form as
3433
- * `model`. When omitted, Keystroke uses {@link DEFAULT_COMPACTION_MODEL_ID}.
3434
- */
3435
- compactionModel: AgentModelIdSchema.optional(),
3436
- thinkingLevel: ThinkingLevelSchema.optional(),
3437
- /**
3438
- * Maximum tool-loop steps per prompt. When omitted, Keystroke uses
3439
- * {@link DEFAULT_MAX_STEPS}.
3440
- */
3441
- maxSteps: number().int().positive().optional()
3442
- });
3443
- [
3444
- "You compress long agent conversation history into a compact context summary.",
3445
- "Preserve durable facts, decisions, IDs, file paths, unresolved tasks, and recent tool outcomes.",
3446
- "Omit chit-chat, repeated tool dumps, and superseded drafts.",
3447
- "Write plain prose the primary agent can continue from. Do not call tools.",
3448
- "Respond with ONLY the summary text."
3449
- ].join("\n");
3450
- //#endregion
3451
- //#region ../../packages/action/dist/index.mjs
3452
- const zodSchema$3 = custom((v) => v instanceof ZodType, "must be a Zod schema");
3453
- /** Runtime validation for an unbranded action definition. */
3454
- const actionCoreSchema = object({
3455
- slug: string().trim().min(1),
3456
- name: requiredDisplayTextSchema,
3457
- description: requiredDisplayTextSchema,
3458
- input: zodSchema$3,
3459
- output: zodSchema$3,
3460
- credentials: array(credentialInputSchema).optional(),
3461
- run: _function()
3462
2717
  });
3463
- const ACTION$1 = Symbol.for("keystroke.action");
3464
- /**
3465
- * Validates brand + shape via `actionCoreSchema` so discovery and guards reject
3466
- * malformed definitions.
3467
- */
3468
- function isAction(value) {
3469
- if (typeof value !== "object" || value === null) return false;
3470
- if (!(ACTION$1 in value) || value[ACTION$1] !== true) return false;
3471
- return actionCoreSchema.safeParse(value).success;
3472
- }
3473
- function getActionCredentialRequirements(action) {
3474
- return action.credentials;
3475
- }
3476
- new AsyncLocalStorage();
3477
- new AsyncLocalStorage();
3478
- new AbortController().signal;
3479
- const REGISTRY_KEY$2 = Symbol.for("keystroke.workflowRunGetter");
3480
- function registry$1() {
3481
- const globalScope = globalThis;
3482
- if (!globalScope[REGISTRY_KEY$2]) globalScope[REGISTRY_KEY$2] = {};
3483
- return globalScope[REGISTRY_KEY$2];
3484
- }
3485
- function registerWorkflowRunGetter(fn) {
3486
- registry$1().getter = fn;
3487
- }
3488
2718
  //#endregion
3489
2719
  //#region ../../packages/platform-database/dist/mcp-oauth-SRTcHMWZ.mjs
3490
2720
  const users = pgTable("users", {
@@ -13440,6 +12670,7 @@ var require_Redis = /* @__PURE__ */ __commonJSMin(((exports) => {
13440
12670
  }
13441
12671
  exports.print = print;
13442
12672
  })))();
12673
+ new AsyncLocalStorage();
13443
12674
  createRequire(import.meta.url);
13444
12675
  function buildPgSchema(registry) {
13445
12676
  return Object.fromEntries(Object.entries(registry).map(([name, { pg }]) => [name, pg]));
@@ -13767,6 +12998,42 @@ const projectArtifactsSqlite = sqliteTable("project_artifacts", {
13767
12998
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
13768
12999
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13769
13000
  }, (table) => [index$1("project_artifacts_project_id_idx").on(table.projectId)]);
13001
+ const publishedForms = pgTable("published_forms", {
13002
+ id: text("id").primaryKey(),
13003
+ organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
13004
+ projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
13005
+ workflowSlug: text("workflow_slug").notNull(),
13006
+ token: text("token").notNull(),
13007
+ enabled: boolean("enabled").notNull().default(true),
13008
+ title: text("title"),
13009
+ description: text("description"),
13010
+ fieldConfig: jsonb("field_config").$type().notNull().default({}),
13011
+ createdByUserId: text("created_by_user_id").references(() => users.id, { onDelete: "set null" }),
13012
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
13013
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
13014
+ }, (table) => [
13015
+ uniqueIndex("published_forms_token_unique").on(table.token),
13016
+ uniqueIndex("published_forms_workflow_unique").on(table.organizationId, table.projectId, table.workflowSlug),
13017
+ index("published_forms_project_id_idx").on(table.projectId)
13018
+ ]);
13019
+ const publishedFormsSqlite = sqliteTable("published_forms", {
13020
+ id: text$1("id").primaryKey(),
13021
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
13022
+ projectId: text$1("project_id").notNull().references(() => projectsSqlite.id, { onDelete: "cascade" }),
13023
+ workflowSlug: text$1("workflow_slug").notNull(),
13024
+ token: text$1("token").notNull(),
13025
+ enabled: integer$1("enabled", { mode: "boolean" }).notNull().default(true),
13026
+ title: text$1("title"),
13027
+ description: text$1("description"),
13028
+ fieldConfig: text$1("field_config", { mode: "json" }).$type().notNull().default({}),
13029
+ createdByUserId: text$1("created_by_user_id").references(() => usersSqlite.id, { onDelete: "set null" }),
13030
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
13031
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13032
+ }, (table) => [
13033
+ uniqueIndex$1("published_forms_token_unique").on(table.token),
13034
+ uniqueIndex$1("published_forms_workflow_unique").on(table.organizationId, table.projectId, table.workflowSlug),
13035
+ index$1("published_forms_project_id_idx").on(table.projectId)
13036
+ ]);
13770
13037
  const projectUsers = pgTable("project_users", {
13771
13038
  projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
13772
13039
  userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
@@ -13989,6 +13256,23 @@ const managedServiceCredentialsSqlite = sqliteTable("managed_service_credentials
13989
13256
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull(),
13990
13257
  updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13991
13258
  }, (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)]);
13259
+ /**
13260
+ * Tenant isolation for public runtime tables.
13261
+ *
13262
+ * Organization identity comes from `keystroke.current_organization_id()`, which
13263
+ * verifies a short-lived signed claim set by trusted platform code via
13264
+ * `set_config('keystroke.org_claim', …, true)` for the current transaction.
13265
+ */
13266
+ function tenantOrganizationPolicy(organizationId) {
13267
+ const match = sql`${organizationId} = (SELECT keystroke.current_organization_id())`;
13268
+ return pgPolicy("tenant_organization_isolation", {
13269
+ as: "permissive",
13270
+ for: "all",
13271
+ to: "public",
13272
+ using: match,
13273
+ withCheck: match
13274
+ });
13275
+ }
13992
13276
  const agents = pgTable("agents", {
13993
13277
  id: text("id").primaryKey(),
13994
13278
  organizationId: text("organization_id").notNull().references(() => organizations.id),
@@ -14009,8 +13293,9 @@ const agents = pgTable("agents", {
14009
13293
  }, (table) => [
14010
13294
  index("agents_organization_id_idx").on(table.organizationId),
14011
13295
  uniqueIndex("agents_project_id_slug_idx").on(table.projectId, table.slug),
14012
- uniqueIndex("agents_project_id_route_idx").on(table.projectId, table.route)
14013
- ]);
13296
+ uniqueIndex("agents_project_id_route_idx").on(table.projectId, table.route),
13297
+ tenantOrganizationPolicy(table.organizationId)
13298
+ ]).enableRLS();
14014
13299
  const agentsSqlite = sqliteTable("agents", {
14015
13300
  id: text$1("id").primaryKey(),
14016
13301
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14049,7 +13334,11 @@ const agentSessions = pgTable("agent_sessions", {
14049
13334
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14050
13335
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14051
13336
  deletedAt: timestamp("deleted_at", { withTimezone: true })
14052
- }, (table) => [index("agent_sessions_organization_id_idx").on(table.organizationId), index("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt)]);
13337
+ }, (table) => [
13338
+ index("agent_sessions_organization_id_idx").on(table.organizationId),
13339
+ index("agent_sessions_agent_updated_idx").on(table.agentId, table.updatedAt),
13340
+ tenantOrganizationPolicy(table.organizationId)
13341
+ ]).enableRLS();
14053
13342
  const agentSessionsSqlite = sqliteTable("agent_sessions", {
14054
13343
  id: text$1("id").primaryKey(),
14055
13344
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14076,7 +13365,11 @@ const agentEvents = pgTable("agent_events", {
14076
13365
  payload: jsonb("payload").notNull(),
14077
13366
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14078
13367
  deletedAt: timestamp("deleted_at", { withTimezone: true })
14079
- }, (table) => [index("agent_events_organization_id_idx").on(table.organizationId), index("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
13368
+ }, (table) => [
13369
+ index("agent_events_organization_id_idx").on(table.organizationId),
13370
+ index("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq),
13371
+ tenantOrganizationPolicy(table.organizationId)
13372
+ ]).enableRLS();
14080
13373
  const agentEventsSqlite = sqliteTable("agent_events", {
14081
13374
  id: text$1("id").primaryKey(),
14082
13375
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14116,8 +13409,9 @@ const triggers = pgTable("triggers", {
14116
13409
  }, (table) => [
14117
13410
  index("triggers_organization_id_idx").on(table.organizationId),
14118
13411
  uniqueIndex("triggers_project_id_slug_idx").on(table.projectId, table.slug),
14119
- index("triggers_next_run_at_enabled_idx").on(table.nextRunAt, table.enabled)
14120
- ]);
13412
+ index("triggers_next_run_at_enabled_idx").on(table.nextRunAt, table.enabled),
13413
+ tenantOrganizationPolicy(table.organizationId)
13414
+ ]).enableRLS();
14121
13415
  const triggersSqlite = sqliteTable("triggers", {
14122
13416
  id: text$1("id").primaryKey(),
14123
13417
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14163,7 +13457,11 @@ const triggerAttachments = pgTable("trigger_attachments", {
14163
13457
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14164
13458
  disabledAt: timestamp("disabled_at", { withTimezone: true }),
14165
13459
  deletedAt: timestamp("deleted_at", { withTimezone: true })
14166
- }, (table) => [index("trigger_attachments_organization_id_idx").on(table.organizationId), uniqueIndex("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug)]);
13460
+ }, (table) => [
13461
+ index("trigger_attachments_organization_id_idx").on(table.organizationId),
13462
+ uniqueIndex("trigger_attachments_project_id_slug_idx").on(table.projectId, table.slug),
13463
+ tenantOrganizationPolicy(table.organizationId)
13464
+ ]).enableRLS();
14167
13465
  const triggerAttachmentsSqlite = sqliteTable("trigger_attachments", {
14168
13466
  id: text$1("id").primaryKey(),
14169
13467
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14194,8 +13492,9 @@ const triggerRuns = pgTable("trigger_runs", {
14194
13492
  }, (table) => [
14195
13493
  index("trigger_runs_organization_id_idx").on(table.organizationId),
14196
13494
  index("trigger_runs_project_trigger_triggered_idx").on(table.projectId, table.triggerId, table.triggeredAt),
14197
- index("trigger_runs_project_triggered_idx").on(table.projectId, table.triggeredAt)
14198
- ]);
13495
+ index("trigger_runs_project_triggered_idx").on(table.projectId, table.triggeredAt),
13496
+ tenantOrganizationPolicy(table.organizationId)
13497
+ ]).enableRLS();
14199
13498
  const triggerRunsSqlite = sqliteTable("trigger_runs", {
14200
13499
  id: text$1("id").primaryKey(),
14201
13500
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14222,7 +13521,11 @@ const workflowSubscriptions = pgTable("workflow_subscriptions", {
14222
13521
  enabled: integer("enabled").notNull(),
14223
13522
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14224
13523
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
14225
- }, (table) => [index("workflow_subscriptions_organization_id_idx").on(table.organizationId), uniqueIndex("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId)]);
13524
+ }, (table) => [
13525
+ index("workflow_subscriptions_organization_id_idx").on(table.organizationId),
13526
+ uniqueIndex("workflow_subscriptions_project_workflow_user").on(table.projectId, table.workflowSlug, table.userId),
13527
+ tenantOrganizationPolicy(table.organizationId)
13528
+ ]).enableRLS();
14226
13529
  const workflowSubscriptionsSqlite = sqliteTable("workflow_subscriptions", {
14227
13530
  id: text$1("id").primaryKey(),
14228
13531
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14255,7 +13558,11 @@ const workflowRuns = pgTable("workflow_runs", {
14255
13558
  input: jsonb("input"),
14256
13559
  output: jsonb("output"),
14257
13560
  error: jsonb("error")
14258
- }, (table) => [index("workflow_runs_organization_id_idx").on(table.organizationId), index("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt)]);
13561
+ }, (table) => [
13562
+ index("workflow_runs_organization_id_idx").on(table.organizationId),
13563
+ index("workflow_runs_project_workflow_triggered_idx").on(table.projectId, table.workflowSlug, table.triggeredAt),
13564
+ tenantOrganizationPolicy(table.organizationId)
13565
+ ]).enableRLS();
14259
13566
  const workflowRunsSqlite = sqliteTable("workflow_runs", {
14260
13567
  id: text$1("id").primaryKey(),
14261
13568
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14297,8 +13604,9 @@ const workflowEvents = pgTable("workflow_events", {
14297
13604
  index("workflow_events_organization_id_idx").on(table.organizationId),
14298
13605
  uniqueIndex("workflow_events_run_id_seq_unique").on(table.runId, table.seq),
14299
13606
  index("workflow_events_run_id_type_idx").on(table.runId, table.type),
14300
- index("workflow_events_correlation_id_idx").on(table.correlationId)
14301
- ]);
13607
+ index("workflow_events_correlation_id_idx").on(table.correlationId),
13608
+ tenantOrganizationPolicy(table.organizationId)
13609
+ ]).enableRLS();
14302
13610
  const workflowEventsSqlite = sqliteTable("workflow_events", {
14303
13611
  id: text$1("id").primaryKey(),
14304
13612
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14330,8 +13638,9 @@ const workflowHooks = pgTable("workflow_hooks", {
14330
13638
  }, (table) => [
14331
13639
  index("workflow_hooks_organization_id_idx").on(table.organizationId),
14332
13640
  uniqueIndex("workflow_hooks_token_unique").on(table.token),
14333
- index("workflow_hooks_run_id_idx").on(table.runId)
14334
- ]);
13641
+ index("workflow_hooks_run_id_idx").on(table.runId),
13642
+ tenantOrganizationPolicy(table.organizationId)
13643
+ ]).enableRLS();
14335
13644
  const workflowHooksSqlite = sqliteTable("workflow_hooks", {
14336
13645
  hookId: text$1("hook_id").primaryKey(),
14337
13646
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14372,8 +13681,9 @@ const credentialInstances = pgTable("credential_instances", {
14372
13681
  }, (table) => [
14373
13682
  index("credential_instances_organization_id_idx").on(table.organizationId),
14374
13683
  uniqueIndex("credential_instances_project_scope_slug_unique").on(table.projectId, table.scopeType, table.scopeId, table.slug),
14375
- index("credential_instances_project_app_slug_scope_idx").on(table.projectId, table.appSlug, table.scopeType, table.scopeId)
14376
- ]);
13684
+ index("credential_instances_project_app_slug_scope_idx").on(table.projectId, table.appSlug, table.scopeType, table.scopeId),
13685
+ tenantOrganizationPolicy(table.organizationId)
13686
+ ]).enableRLS();
14377
13687
  const credentialInstancesSqlite = sqliteTable("credential_instances", {
14378
13688
  id: text$1("id").primaryKey(),
14379
13689
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14411,7 +13721,11 @@ const credentialAssignments = pgTable("credential_assignments", {
14411
13721
  instanceId: text("instance_id").notNull(),
14412
13722
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14413
13723
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
14414
- }, (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)]);
13724
+ }, (table) => [
13725
+ index("credential_assignments_organization_id_idx").on(table.organizationId),
13726
+ uniqueIndex("credential_assignments_project_target_consumer_slug").on(table.projectId, table.targetType, table.targetKey, table.consumerId, table.credentialSlug),
13727
+ tenantOrganizationPolicy(table.organizationId)
13728
+ ]).enableRLS();
14415
13729
  const credentialAssignmentsSqlite = sqliteTable("credential_assignments", {
14416
13730
  id: text$1("id").primaryKey(),
14417
13731
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14442,7 +13756,7 @@ const jobs = pgTable("jobs", {
14442
13756
  leaseExpiresAt: timestamp("lease_expires_at", { withTimezone: true }),
14443
13757
  completedAt: timestamp("completed_at", { withTimezone: true }),
14444
13758
  error: jsonb("error")
14445
- }, (table) => [index("jobs_organization_id_idx").on(table.organizationId)]);
13759
+ }, (table) => [index("jobs_organization_id_idx").on(table.organizationId), tenantOrganizationPolicy(table.organizationId)]).enableRLS();
14446
13760
  const jobsSqlite = sqliteTable("jobs", {
14447
13761
  id: text$1("id").primaryKey(),
14448
13762
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14479,8 +13793,9 @@ const gatewayAttachments = pgTable("gateway_attachments", {
14479
13793
  }, (table) => [
14480
13794
  index("gateway_attachments_organization_id_idx").on(table.organizationId),
14481
13795
  uniqueIndex("gateway_attachments_project_id_slug_idx").on(table.projectId, table.slug),
14482
- uniqueIndex("gateway_attachments_project_platform_channel_active").on(table.projectId, table.platform, table.channelId).where(sql`${table.deletedAt} is null`)
14483
- ]);
13796
+ uniqueIndex("gateway_attachments_project_platform_channel_active").on(table.projectId, table.platform, table.channelId).where(sql`${table.deletedAt} is null`),
13797
+ tenantOrganizationPolicy(table.organizationId)
13798
+ ]).enableRLS();
14484
13799
  const gatewayAttachmentsSqlite = sqliteTable("gateway_attachments", {
14485
13800
  id: text$1("id").primaryKey(),
14486
13801
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14508,7 +13823,7 @@ const gatewayThreadSessions = pgTable("gateway_thread_sessions", {
14508
13823
  attachmentId: text("attachment_id").notNull().references(() => gatewayAttachments.id),
14509
13824
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
14510
13825
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
14511
- }, (table) => [index("gateway_thread_sessions_organization_id_idx").on(table.organizationId)]);
13826
+ }, (table) => [index("gateway_thread_sessions_organization_id_idx").on(table.organizationId), tenantOrganizationPolicy(table.organizationId)]).enableRLS();
14512
13827
  const gatewayThreadSessionsSqlite = sqliteTable("gateway_thread_sessions", {
14513
13828
  threadId: text$1("thread_id").primaryKey(),
14514
13829
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14534,8 +13849,9 @@ const traceSpans = pgTable("trace_spans", {
14534
13849
  }, (table) => [
14535
13850
  index("trace_spans_organization_id_idx").on(table.organizationId),
14536
13851
  index("trace_spans_trace_id_started_at_idx").on(table.traceId, table.startedAt),
14537
- index("trace_spans_ref_id_kind_started_at_idx").on(table.refId, table.kind, table.startedAt)
14538
- ]);
13852
+ index("trace_spans_ref_id_kind_started_at_idx").on(table.refId, table.kind, table.startedAt),
13853
+ tenantOrganizationPolicy(table.organizationId)
13854
+ ]).enableRLS();
14539
13855
  const traceSpansSqlite = sqliteTable("trace_spans", {
14540
13856
  id: text$1("id").primaryKey(),
14541
13857
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14568,8 +13884,9 @@ const traceLogs = pgTable("trace_logs", {
14568
13884
  }, (table) => [
14569
13885
  index("trace_logs_organization_id_idx").on(table.organizationId),
14570
13886
  index("trace_logs_trace_id_seq_idx").on(table.traceId, table.seq),
14571
- index("trace_logs_span_id_seq_idx").on(table.spanId, table.seq)
14572
- ]);
13887
+ index("trace_logs_span_id_seq_idx").on(table.spanId, table.seq),
13888
+ tenantOrganizationPolicy(table.organizationId)
13889
+ ]).enableRLS();
14573
13890
  const traceLogsSqlite = sqliteTable("trace_logs", {
14574
13891
  id: text$1("id").primaryKey(),
14575
13892
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14597,7 +13914,11 @@ const skills = pgTable("skills", {
14597
13914
  registeredAt: timestamp("registered_at", { withTimezone: true }).notNull(),
14598
13915
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
14599
13916
  deletedAt: timestamp("deleted_at", { withTimezone: true })
14600
- }, (table) => [index("skills_organization_id_idx").on(table.organizationId), uniqueIndex("skills_project_id_slug_idx").on(table.projectId, table.slug)]);
13917
+ }, (table) => [
13918
+ index("skills_organization_id_idx").on(table.organizationId),
13919
+ uniqueIndex("skills_project_id_slug_idx").on(table.projectId, table.slug),
13920
+ tenantOrganizationPolicy(table.organizationId)
13921
+ ]).enableRLS();
14601
13922
  const skillsSqlite = sqliteTable("skills", {
14602
13923
  id: text$1("id").primaryKey(),
14603
13924
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14635,7 +13956,11 @@ const workflows = pgTable("workflows", {
14635
13956
  overviewModel: text("overview_model"),
14636
13957
  overviewStatus: text("overview_status").$type().notNull().default("idle"),
14637
13958
  overviewGeneratedAt: timestamp("overview_generated_at", { withTimezone: true })
14638
- }, (table) => [index("workflows_organization_id_idx").on(table.organizationId), uniqueIndex("workflows_project_id_slug_idx").on(table.projectId, table.slug)]);
13959
+ }, (table) => [
13960
+ index("workflows_organization_id_idx").on(table.organizationId),
13961
+ uniqueIndex("workflows_project_id_slug_idx").on(table.projectId, table.slug),
13962
+ tenantOrganizationPolicy(table.organizationId)
13963
+ ]).enableRLS();
14639
13964
  const workflowsSqlite = sqliteTable("workflows", {
14640
13965
  id: text$1("id").primaryKey(),
14641
13966
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14673,8 +13998,9 @@ const resourceActivity = pgTable("resource_activity", {
14673
13998
  }, (table) => [
14674
13999
  index("resource_activity_organization_id_idx").on(table.organizationId),
14675
14000
  uniqueIndex("resource_activity_project_user_kind_resource").on(table.projectId, table.userId, table.resourceKind, table.resourceId),
14676
- index("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt)
14677
- ]);
14001
+ index("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt),
14002
+ tenantOrganizationPolicy(table.organizationId)
14003
+ ]).enableRLS();
14678
14004
  const resourceActivitySqlite = sqliteTable("resource_activity", {
14679
14005
  id: text$1("id").primaryKey(),
14680
14006
  organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -14691,8 +14017,8 @@ const resourceActivitySqlite = sqliteTable("resource_activity", {
14691
14017
  /**
14692
14018
  * Platform control-plane tables — Postgres (hosted) or SQLite (local dev).
14693
14019
  *
14694
- * Tenant (project-runtime) tables live under `./tables/tenant/` staged here for
14695
- * the single-db merge; `@keystrokehq/database` still owns the live runtime schema.
14020
+ * Tenant (project-runtime) tables live under `./tables/tenant/` in the public
14021
+ * schema with `organization_id` + RLS. Runtime queries live in `src/runtime/`.
14696
14022
  */
14697
14023
  const tableRegistry = {
14698
14024
  organizations: {
@@ -14719,6 +14045,10 @@ const tableRegistry = {
14719
14045
  pg: projectArtifacts,
14720
14046
  sqlite: projectArtifactsSqlite
14721
14047
  },
14048
+ publishedForms: {
14049
+ pg: publishedForms,
14050
+ sqlite: publishedFormsSqlite
14051
+ },
14722
14052
  users: {
14723
14053
  pg: users,
14724
14054
  sqlite: usersSqlite
@@ -14884,6 +14214,97 @@ buildPgSchema(tableRegistry);
14884
14214
  buildSqliteSchema(tableRegistry);
14885
14215
  new AsyncLocalStorage();
14886
14216
  new AsyncLocalStorage();
14217
+ new AsyncLocalStorage();
14218
+ new AsyncLocalStorage();
14219
+ createRequire(import.meta.url);
14220
+ new AsyncLocalStorage();
14221
+ const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
14222
+ const AgentModelIdSchema = custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
14223
+ const GatewayModelPricingSchema = object({
14224
+ input: string().optional(),
14225
+ output: string().optional(),
14226
+ input_cache_read: string().optional(),
14227
+ input_cache_write: string().optional()
14228
+ });
14229
+ object({
14230
+ id: string().min(1),
14231
+ name: string().optional(),
14232
+ type: string().optional(),
14233
+ context_window: number().int().positive().optional(),
14234
+ max_tokens: number().int().positive().optional(),
14235
+ tags: array(string()).optional(),
14236
+ pricing: GatewayModelPricingSchema.optional()
14237
+ });
14238
+ const ThinkingLevelSchema = _enum([
14239
+ "provider-default",
14240
+ "none",
14241
+ "minimal",
14242
+ "low",
14243
+ "medium",
14244
+ "high",
14245
+ "xhigh"
14246
+ ]);
14247
+ object({
14248
+ systemPrompt: string(),
14249
+ model: AgentModelIdSchema,
14250
+ /**
14251
+ * Optional model used only for context compaction. Same `vendor/model-id` form as
14252
+ * `model`. When omitted, Keystroke uses {@link DEFAULT_COMPACTION_MODEL_ID}.
14253
+ */
14254
+ compactionModel: AgentModelIdSchema.optional(),
14255
+ thinkingLevel: ThinkingLevelSchema.optional(),
14256
+ /**
14257
+ * Maximum tool-loop steps per prompt. When omitted, Keystroke uses
14258
+ * {@link DEFAULT_MAX_STEPS}.
14259
+ */
14260
+ maxSteps: number().int().positive().optional()
14261
+ });
14262
+ [
14263
+ "You compress long agent conversation history into a compact context summary.",
14264
+ "Preserve durable facts, decisions, IDs, file paths, unresolved tasks, and recent tool outcomes.",
14265
+ "Omit chit-chat, repeated tool dumps, and superseded drafts.",
14266
+ "Write plain prose the primary agent can continue from. Do not call tools.",
14267
+ "Respond with ONLY the summary text."
14268
+ ].join("\n");
14269
+ //#endregion
14270
+ //#region ../../packages/action/dist/index.mjs
14271
+ const zodSchema$3 = custom((v) => v instanceof ZodType, "must be a Zod schema");
14272
+ /** Runtime validation for an unbranded action definition. */
14273
+ const actionCoreSchema = object({
14274
+ slug: string().trim().min(1),
14275
+ name: requiredDisplayTextSchema,
14276
+ description: requiredDisplayTextSchema,
14277
+ input: zodSchema$3,
14278
+ output: zodSchema$3,
14279
+ credentials: array(credentialInputSchema).optional(),
14280
+ run: _function()
14281
+ });
14282
+ const ACTION$1 = Symbol.for("keystroke.action");
14283
+ /**
14284
+ * Validates brand + shape via `actionCoreSchema` so discovery and guards reject
14285
+ * malformed definitions.
14286
+ */
14287
+ function isAction(value) {
14288
+ if (typeof value !== "object" || value === null) return false;
14289
+ if (!(ACTION$1 in value) || value[ACTION$1] !== true) return false;
14290
+ return actionCoreSchema.safeParse(value).success;
14291
+ }
14292
+ function getActionCredentialRequirements(action) {
14293
+ return action.credentials;
14294
+ }
14295
+ new AsyncLocalStorage();
14296
+ new AsyncLocalStorage();
14297
+ new AbortController().signal;
14298
+ const REGISTRY_KEY$2 = Symbol.for("keystroke.workflowRunGetter");
14299
+ function registry$1() {
14300
+ const globalScope = globalThis;
14301
+ if (!globalScope[REGISTRY_KEY$2]) globalScope[REGISTRY_KEY$2] = {};
14302
+ return globalScope[REGISTRY_KEY$2];
14303
+ }
14304
+ function registerWorkflowRunGetter(fn) {
14305
+ registry$1().getter = fn;
14306
+ }
14307
+ new AsyncLocalStorage();
14887
14308
  //#endregion
14888
14309
  //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
14889
14310
  var require_identity = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -31831,4 +31252,4 @@ async function emitStoredRouteManifestForProject(projectRoot) {
31831
31252
  //#endregion
31832
31253
  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 };
31833
31254
 
31834
- //# sourceMappingURL=dist-DEf7Qj_S.mjs.map
31255
+ //# sourceMappingURL=dist-JgES5-HY.mjs.map