superceo 0.3.9 → 0.3.10

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.
package/dist/index.js CHANGED
@@ -682,7 +682,9 @@ var init_instance = __esm({
682
682
  instanceExperimentalSettingsSchema = z3.object({
683
683
  enableIsolatedWorkspaces: z3.boolean().default(false),
684
684
  autoRestartDevServerWhenIdle: z3.boolean().default(false),
685
- enableIssueGraphLivenessAutoRecovery: z3.boolean().default(false)
685
+ enableIssueGraphLivenessAutoRecovery: z3.boolean().default(false),
686
+ enableContentLanes: z3.boolean().default(false),
687
+ enableBigTerminal: z3.boolean().default(false)
686
688
  }).strict();
687
689
  patchInstanceExperimentalSettingsSchema = instanceExperimentalSettingsSchema.partial();
688
690
  instanceBackupSettingsSchema = z3.object({
@@ -774,7 +776,8 @@ var init_company = __esm({
774
776
  feedbackDataSharingTermsVersion: feedbackDataSharingTermsVersionSchema,
775
777
  brandColor: brandColorSchema,
776
778
  logoAssetId: logoAssetIdSchema,
777
- defaultCreatorAgentId: z5.string().uuid().nullable().optional()
779
+ defaultCreatorAgentId: z5.string().uuid().nullable().optional(),
780
+ metadata: z5.record(z5.unknown()).nullable().optional()
778
781
  });
779
782
  updateCompanyBrandingSchema = z5.object({
780
783
  name: z5.string().min(1).optional(),
@@ -4276,7 +4279,7 @@ var init_server = __esm({
4276
4279
  });
4277
4280
 
4278
4281
  // ../packages/db/dist/schema/companies.js
4279
- import { pgTable, uuid, text as text6, integer, timestamp, boolean, uniqueIndex } from "drizzle-orm/pg-core";
4282
+ import { pgTable, uuid, text as text6, integer, timestamp, boolean, jsonb, uniqueIndex } from "drizzle-orm/pg-core";
4280
4283
  var companies;
4281
4284
  var init_companies = __esm({
4282
4285
  "../packages/db/dist/schema/companies.js"() {
@@ -4299,6 +4302,7 @@ var init_companies = __esm({
4299
4302
  feedbackDataSharingTermsVersion: text6("feedback_data_sharing_terms_version"),
4300
4303
  brandColor: text6("brand_color"),
4301
4304
  defaultCreatorAgentId: uuid("default_creator_agent_id"),
4305
+ metadata: jsonb("metadata").$type(),
4302
4306
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
4303
4307
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
4304
4308
  }, (table) => ({
@@ -4308,7 +4312,7 @@ var init_companies = __esm({
4308
4312
  });
4309
4313
 
4310
4314
  // ../packages/db/dist/schema/agents.js
4311
- import { pgTable as pgTable2, uuid as uuid2, text as text7, integer as integer2, timestamp as timestamp2, jsonb, index } from "drizzle-orm/pg-core";
4315
+ import { pgTable as pgTable2, uuid as uuid2, text as text7, integer as integer2, timestamp as timestamp2, jsonb as jsonb2, index } from "drizzle-orm/pg-core";
4312
4316
  var agents;
4313
4317
  var init_agents = __esm({
4314
4318
  "../packages/db/dist/schema/agents.js"() {
@@ -4326,15 +4330,15 @@ var init_agents = __esm({
4326
4330
  reportsTo: uuid2("reports_to").references(() => agents.id),
4327
4331
  capabilities: text7("capabilities"),
4328
4332
  adapterType: text7("adapter_type").notNull().default("process"),
4329
- adapterConfig: jsonb("adapter_config").$type().notNull().default({}),
4330
- runtimeConfig: jsonb("runtime_config").$type().notNull().default({}),
4333
+ adapterConfig: jsonb2("adapter_config").$type().notNull().default({}),
4334
+ runtimeConfig: jsonb2("runtime_config").$type().notNull().default({}),
4331
4335
  budgetMonthlyCents: integer2("budget_monthly_cents").notNull().default(0),
4332
4336
  spentMonthlyCents: integer2("spent_monthly_cents").notNull().default(0),
4333
4337
  pauseReason: text7("pause_reason"),
4334
4338
  pausedAt: timestamp2("paused_at", { withTimezone: true }),
4335
- permissions: jsonb("permissions").$type().notNull().default({}),
4339
+ permissions: jsonb2("permissions").$type().notNull().default({}),
4336
4340
  lastHeartbeatAt: timestamp2("last_heartbeat_at", { withTimezone: true }),
4337
- metadata: jsonb("metadata").$type(),
4341
+ metadata: jsonb2("metadata").$type(),
4338
4342
  createdAt: timestamp2("created_at", { withTimezone: true }).notNull().defaultNow(),
4339
4343
  updatedAt: timestamp2("updated_at", { withTimezone: true }).notNull().defaultNow()
4340
4344
  }, (table) => ({
@@ -4446,7 +4450,7 @@ var init_auth = __esm({
4446
4450
  });
4447
4451
 
4448
4452
  // ../packages/db/dist/schema/instance_settings.js
4449
- import { pgTable as pgTable6, uuid as uuid5, text as text10, timestamp as timestamp6, jsonb as jsonb2, uniqueIndex as uniqueIndex4 } from "drizzle-orm/pg-core";
4453
+ import { pgTable as pgTable6, uuid as uuid5, text as text10, timestamp as timestamp6, jsonb as jsonb3, uniqueIndex as uniqueIndex4 } from "drizzle-orm/pg-core";
4450
4454
  var instanceSettings;
4451
4455
  var init_instance_settings = __esm({
4452
4456
  "../packages/db/dist/schema/instance_settings.js"() {
@@ -4454,11 +4458,11 @@ var init_instance_settings = __esm({
4454
4458
  instanceSettings = pgTable6("instance_settings", {
4455
4459
  id: uuid5("id").primaryKey().defaultRandom(),
4456
4460
  singletonKey: text10("singleton_key").notNull().default("default"),
4457
- general: jsonb2("general").$type().notNull().default({}),
4458
- experimental: jsonb2("experimental").$type().notNull().default({}),
4459
- backup: jsonb2("backup").$type().notNull().default({}),
4460
- updates: jsonb2("updates").$type().notNull().default({}),
4461
- localTools: jsonb2("local_tools").$type().notNull().default({}),
4461
+ general: jsonb3("general").$type().notNull().default({}),
4462
+ experimental: jsonb3("experimental").$type().notNull().default({}),
4463
+ backup: jsonb3("backup").$type().notNull().default({}),
4464
+ updates: jsonb3("updates").$type().notNull().default({}),
4465
+ localTools: jsonb3("local_tools").$type().notNull().default({}),
4462
4466
  createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow(),
4463
4467
  updatedAt: timestamp6("updated_at", { withTimezone: true }).notNull().defaultNow()
4464
4468
  }, (table) => ({
@@ -4567,7 +4571,7 @@ var init_company_memberships = __esm({
4567
4571
  });
4568
4572
 
4569
4573
  // ../packages/db/dist/schema/principal_permission_grants.js
4570
- import { pgTable as pgTable11, uuid as uuid10, text as text15, timestamp as timestamp11, jsonb as jsonb3, uniqueIndex as uniqueIndex8, index as index7 } from "drizzle-orm/pg-core";
4574
+ import { pgTable as pgTable11, uuid as uuid10, text as text15, timestamp as timestamp11, jsonb as jsonb4, uniqueIndex as uniqueIndex8, index as index7 } from "drizzle-orm/pg-core";
4571
4575
  var principalPermissionGrants;
4572
4576
  var init_principal_permission_grants = __esm({
4573
4577
  "../packages/db/dist/schema/principal_permission_grants.js"() {
@@ -4579,7 +4583,7 @@ var init_principal_permission_grants = __esm({
4579
4583
  principalType: text15("principal_type").notNull(),
4580
4584
  principalId: text15("principal_id").notNull(),
4581
4585
  permissionKey: text15("permission_key").notNull(),
4582
- scope: jsonb3("scope").$type(),
4586
+ scope: jsonb4("scope").$type(),
4583
4587
  grantedByUserId: text15("granted_by_user_id"),
4584
4588
  createdAt: timestamp11("created_at", { withTimezone: true }).notNull().defaultNow(),
4585
4589
  updatedAt: timestamp11("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -4591,7 +4595,7 @@ var init_principal_permission_grants = __esm({
4591
4595
  });
4592
4596
 
4593
4597
  // ../packages/db/dist/schema/invites.js
4594
- import { pgTable as pgTable12, uuid as uuid11, text as text16, timestamp as timestamp12, jsonb as jsonb4, index as index8, uniqueIndex as uniqueIndex9 } from "drizzle-orm/pg-core";
4598
+ import { pgTable as pgTable12, uuid as uuid11, text as text16, timestamp as timestamp12, jsonb as jsonb5, index as index8, uniqueIndex as uniqueIndex9 } from "drizzle-orm/pg-core";
4595
4599
  var invites;
4596
4600
  var init_invites = __esm({
4597
4601
  "../packages/db/dist/schema/invites.js"() {
@@ -4603,7 +4607,7 @@ var init_invites = __esm({
4603
4607
  inviteType: text16("invite_type").notNull().default("company_join"),
4604
4608
  tokenHash: text16("token_hash").notNull(),
4605
4609
  allowedJoinTypes: text16("allowed_join_types").notNull().default("both"),
4606
- defaultsPayload: jsonb4("defaults_payload").$type(),
4610
+ defaultsPayload: jsonb5("defaults_payload").$type(),
4607
4611
  expiresAt: timestamp12("expires_at", { withTimezone: true }).notNull(),
4608
4612
  invitedByUserId: text16("invited_by_user_id"),
4609
4613
  revokedAt: timestamp12("revoked_at", { withTimezone: true }),
@@ -4618,7 +4622,7 @@ var init_invites = __esm({
4618
4622
  });
4619
4623
 
4620
4624
  // ../packages/db/dist/schema/join_requests.js
4621
- import { pgTable as pgTable13, uuid as uuid12, text as text17, timestamp as timestamp13, jsonb as jsonb5, index as index9, uniqueIndex as uniqueIndex10 } from "drizzle-orm/pg-core";
4625
+ import { pgTable as pgTable13, uuid as uuid12, text as text17, timestamp as timestamp13, jsonb as jsonb6, index as index9, uniqueIndex as uniqueIndex10 } from "drizzle-orm/pg-core";
4622
4626
  var joinRequests;
4623
4627
  var init_join_requests = __esm({
4624
4628
  "../packages/db/dist/schema/join_requests.js"() {
@@ -4638,7 +4642,7 @@ var init_join_requests = __esm({
4638
4642
  agentName: text17("agent_name"),
4639
4643
  adapterType: text17("adapter_type"),
4640
4644
  capabilities: text17("capabilities"),
4641
- agentDefaultsPayload: jsonb5("agent_defaults_payload").$type(),
4645
+ agentDefaultsPayload: jsonb6("agent_defaults_payload").$type(),
4642
4646
  claimSecretHash: text17("claim_secret_hash"),
4643
4647
  claimSecretExpiresAt: timestamp13("claim_secret_expires_at", { withTimezone: true }),
4644
4648
  claimSecretConsumedAt: timestamp13("claim_secret_consumed_at", { withTimezone: true }),
@@ -4690,7 +4694,7 @@ var init_budget_policies = __esm({
4690
4694
  });
4691
4695
 
4692
4696
  // ../packages/db/dist/schema/approvals.js
4693
- import { pgTable as pgTable15, uuid as uuid14, text as text19, timestamp as timestamp15, jsonb as jsonb6, index as index11 } from "drizzle-orm/pg-core";
4697
+ import { pgTable as pgTable15, uuid as uuid14, text as text19, timestamp as timestamp15, jsonb as jsonb7, index as index11 } from "drizzle-orm/pg-core";
4694
4698
  var approvals;
4695
4699
  var init_approvals = __esm({
4696
4700
  "../packages/db/dist/schema/approvals.js"() {
@@ -4704,7 +4708,7 @@ var init_approvals = __esm({
4704
4708
  requestedByAgentId: uuid14("requested_by_agent_id").references(() => agents.id),
4705
4709
  requestedByUserId: text19("requested_by_user_id"),
4706
4710
  status: text19("status").notNull().default("pending"),
4707
- payload: jsonb6("payload").$type().notNull(),
4711
+ payload: jsonb7("payload").$type().notNull(),
4708
4712
  decisionNote: text19("decision_note"),
4709
4713
  decidedByUserId: text19("decided_by_user_id"),
4710
4714
  decidedAt: timestamp15("decided_at", { withTimezone: true }),
@@ -4753,7 +4757,7 @@ var init_budget_incidents = __esm({
4753
4757
  });
4754
4758
 
4755
4759
  // ../packages/db/dist/schema/agent_config_revisions.js
4756
- import { pgTable as pgTable17, uuid as uuid16, text as text21, timestamp as timestamp17, jsonb as jsonb7, index as index13 } from "drizzle-orm/pg-core";
4760
+ import { pgTable as pgTable17, uuid as uuid16, text as text21, timestamp as timestamp17, jsonb as jsonb8, index as index13 } from "drizzle-orm/pg-core";
4757
4761
  var agentConfigRevisions;
4758
4762
  var init_agent_config_revisions = __esm({
4759
4763
  "../packages/db/dist/schema/agent_config_revisions.js"() {
@@ -4768,9 +4772,9 @@ var init_agent_config_revisions = __esm({
4768
4772
  createdByUserId: text21("created_by_user_id"),
4769
4773
  source: text21("source").notNull().default("patch"),
4770
4774
  rolledBackFromRevisionId: uuid16("rolled_back_from_revision_id"),
4771
- changedKeys: jsonb7("changed_keys").$type().notNull().default([]),
4772
- beforeConfig: jsonb7("before_config").$type().notNull(),
4773
- afterConfig: jsonb7("after_config").$type().notNull(),
4775
+ changedKeys: jsonb8("changed_keys").$type().notNull().default([]),
4776
+ beforeConfig: jsonb8("before_config").$type().notNull(),
4777
+ afterConfig: jsonb8("after_config").$type().notNull(),
4774
4778
  createdAt: timestamp17("created_at", { withTimezone: true }).notNull().defaultNow()
4775
4779
  }, (table) => ({
4776
4780
  companyAgentCreatedIdx: index13("agent_config_revisions_company_agent_created_idx").on(table.companyId, table.agentId, table.createdAt),
@@ -4804,7 +4808,7 @@ var init_agent_api_keys = __esm({
4804
4808
  });
4805
4809
 
4806
4810
  // ../packages/db/dist/schema/agent_runtime_state.js
4807
- import { pgTable as pgTable19, uuid as uuid18, text as text23, timestamp as timestamp19, jsonb as jsonb8, bigint, index as index15 } from "drizzle-orm/pg-core";
4811
+ import { pgTable as pgTable19, uuid as uuid18, text as text23, timestamp as timestamp19, jsonb as jsonb9, bigint, index as index15 } from "drizzle-orm/pg-core";
4808
4812
  var agentRuntimeState;
4809
4813
  var init_agent_runtime_state = __esm({
4810
4814
  "../packages/db/dist/schema/agent_runtime_state.js"() {
@@ -4816,7 +4820,7 @@ var init_agent_runtime_state = __esm({
4816
4820
  companyId: uuid18("company_id").notNull().references(() => companies.id),
4817
4821
  adapterType: text23("adapter_type").notNull(),
4818
4822
  sessionId: text23("session_id"),
4819
- stateJson: jsonb8("state_json").$type().notNull().default({}),
4823
+ stateJson: jsonb9("state_json").$type().notNull().default({}),
4820
4824
  lastRunId: uuid18("last_run_id"),
4821
4825
  lastRunStatus: text23("last_run_status"),
4822
4826
  totalInputTokens: bigint("total_input_tokens", { mode: "number" }).notNull().default(0),
@@ -4834,7 +4838,7 @@ var init_agent_runtime_state = __esm({
4834
4838
  });
4835
4839
 
4836
4840
  // ../packages/db/dist/schema/agent_wakeup_requests.js
4837
- import { pgTable as pgTable20, uuid as uuid19, text as text24, timestamp as timestamp20, jsonb as jsonb9, integer as integer6, index as index16 } from "drizzle-orm/pg-core";
4841
+ import { pgTable as pgTable20, uuid as uuid19, text as text24, timestamp as timestamp20, jsonb as jsonb10, integer as integer6, index as index16 } from "drizzle-orm/pg-core";
4838
4842
  var agentWakeupRequests;
4839
4843
  var init_agent_wakeup_requests = __esm({
4840
4844
  "../packages/db/dist/schema/agent_wakeup_requests.js"() {
@@ -4848,7 +4852,7 @@ var init_agent_wakeup_requests = __esm({
4848
4852
  source: text24("source").notNull(),
4849
4853
  triggerDetail: text24("trigger_detail"),
4850
4854
  reason: text24("reason"),
4851
- payload: jsonb9("payload").$type(),
4855
+ payload: jsonb10("payload").$type(),
4852
4856
  status: text24("status").notNull().default("queued"),
4853
4857
  coalescedCount: integer6("coalesced_count").notNull().default(0),
4854
4858
  requestedByActorType: text24("requested_by_actor_type"),
@@ -4870,7 +4874,7 @@ var init_agent_wakeup_requests = __esm({
4870
4874
  });
4871
4875
 
4872
4876
  // ../packages/db/dist/schema/heartbeat_runs.js
4873
- import { pgTable as pgTable21, uuid as uuid20, text as text25, timestamp as timestamp21, jsonb as jsonb10, index as index17, integer as integer7, bigint as bigint2, boolean as boolean4 } from "drizzle-orm/pg-core";
4877
+ import { pgTable as pgTable21, uuid as uuid20, text as text25, timestamp as timestamp21, jsonb as jsonb11, index as index17, integer as integer7, bigint as bigint2, boolean as boolean4 } from "drizzle-orm/pg-core";
4874
4878
  var heartbeatRuns;
4875
4879
  var init_heartbeat_runs = __esm({
4876
4880
  "../packages/db/dist/schema/heartbeat_runs.js"() {
@@ -4891,8 +4895,8 @@ var init_heartbeat_runs = __esm({
4891
4895
  wakeupRequestId: uuid20("wakeup_request_id").references(() => agentWakeupRequests.id),
4892
4896
  exitCode: integer7("exit_code"),
4893
4897
  signal: text25("signal"),
4894
- usageJson: jsonb10("usage_json").$type(),
4895
- resultJson: jsonb10("result_json").$type(),
4898
+ usageJson: jsonb11("usage_json").$type(),
4899
+ resultJson: jsonb11("result_json").$type(),
4896
4900
  sessionIdBefore: text25("session_id_before"),
4897
4901
  sessionIdAfter: text25("session_id_after"),
4898
4902
  logStore: text25("log_store"),
@@ -4926,7 +4930,7 @@ var init_heartbeat_runs = __esm({
4926
4930
  continuationAttempt: integer7("continuation_attempt").notNull().default(0),
4927
4931
  lastUsefulActionAt: timestamp21("last_useful_action_at", { withTimezone: true }),
4928
4932
  nextAction: text25("next_action"),
4929
- contextSnapshot: jsonb10("context_snapshot").$type(),
4933
+ contextSnapshot: jsonb11("context_snapshot").$type(),
4930
4934
  promptChars: integer7("prompt_chars"),
4931
4935
  createdAt: timestamp21("created_at", { withTimezone: true }).notNull().defaultNow(),
4932
4936
  updatedAt: timestamp21("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -4940,7 +4944,7 @@ var init_heartbeat_runs = __esm({
4940
4944
  });
4941
4945
 
4942
4946
  // ../packages/db/dist/schema/agent_task_sessions.js
4943
- import { pgTable as pgTable22, uuid as uuid21, text as text26, timestamp as timestamp22, jsonb as jsonb11, index as index18, uniqueIndex as uniqueIndex12 } from "drizzle-orm/pg-core";
4947
+ import { pgTable as pgTable22, uuid as uuid21, text as text26, timestamp as timestamp22, jsonb as jsonb12, index as index18, uniqueIndex as uniqueIndex12 } from "drizzle-orm/pg-core";
4944
4948
  var agentTaskSessions;
4945
4949
  var init_agent_task_sessions = __esm({
4946
4950
  "../packages/db/dist/schema/agent_task_sessions.js"() {
@@ -4954,7 +4958,7 @@ var init_agent_task_sessions = __esm({
4954
4958
  agentId: uuid21("agent_id").notNull().references(() => agents.id),
4955
4959
  adapterType: text26("adapter_type").notNull(),
4956
4960
  taskKey: text26("task_key").notNull(),
4957
- sessionParamsJson: jsonb11("session_params_json").$type(),
4961
+ sessionParamsJson: jsonb12("session_params_json").$type(),
4958
4962
  sessionDisplayId: text26("session_display_id"),
4959
4963
  lastRunId: uuid21("last_run_id").references(() => heartbeatRuns.id),
4960
4964
  lastError: text26("last_error"),
@@ -4969,7 +4973,7 @@ var init_agent_task_sessions = __esm({
4969
4973
  });
4970
4974
 
4971
4975
  // ../packages/db/dist/schema/agent_memory.js
4972
- import { pgTable as pgTable23, uuid as uuid22, text as text27, timestamp as timestamp23, jsonb as jsonb12, uniqueIndex as uniqueIndex13, index as index19 } from "drizzle-orm/pg-core";
4976
+ import { pgTable as pgTable23, uuid as uuid22, text as text27, timestamp as timestamp23, jsonb as jsonb13, uniqueIndex as uniqueIndex13, index as index19 } from "drizzle-orm/pg-core";
4973
4977
  var agentMemory;
4974
4978
  var init_agent_memory = __esm({
4975
4979
  "../packages/db/dist/schema/agent_memory.js"() {
@@ -4981,7 +4985,7 @@ var init_agent_memory = __esm({
4981
4985
  agentId: uuid22("agent_id").notNull().references(() => agents.id, { onDelete: "cascade" }),
4982
4986
  companyId: uuid22("company_id").notNull().references(() => companies.id),
4983
4987
  key: text27("key").notNull(),
4984
- value: jsonb12("value").$type().notNull(),
4988
+ value: jsonb13("value").$type().notNull(),
4985
4989
  createdAt: timestamp23("created_at", { withTimezone: true }).notNull().defaultNow(),
4986
4990
  updatedAt: timestamp23("updated_at", { withTimezone: true }).notNull().defaultNow()
4987
4991
  }, (table) => ({
@@ -5017,7 +5021,7 @@ var init_goals = __esm({
5017
5021
  });
5018
5022
 
5019
5023
  // ../packages/db/dist/schema/projects.js
5020
- import { pgTable as pgTable25, uuid as uuid24, text as text29, timestamp as timestamp25, date, index as index21, jsonb as jsonb13 } from "drizzle-orm/pg-core";
5024
+ import { pgTable as pgTable25, uuid as uuid24, text as text29, timestamp as timestamp25, date, index as index21, jsonb as jsonb14 } from "drizzle-orm/pg-core";
5021
5025
  var projects;
5022
5026
  var init_projects = __esm({
5023
5027
  "../packages/db/dist/schema/projects.js"() {
@@ -5035,10 +5039,10 @@ var init_projects = __esm({
5035
5039
  leadAgentId: uuid24("lead_agent_id").references(() => agents.id),
5036
5040
  targetDate: date("target_date"),
5037
5041
  color: text29("color"),
5038
- env: jsonb13("env").$type(),
5042
+ env: jsonb14("env").$type(),
5039
5043
  pauseReason: text29("pause_reason"),
5040
5044
  pausedAt: timestamp25("paused_at", { withTimezone: true }),
5041
- executionWorkspacePolicy: jsonb13("execution_workspace_policy").$type(),
5045
+ executionWorkspacePolicy: jsonb14("execution_workspace_policy").$type(),
5042
5046
  archivedAt: timestamp25("archived_at", { withTimezone: true }),
5043
5047
  createdAt: timestamp25("created_at", { withTimezone: true }).notNull().defaultNow(),
5044
5048
  updatedAt: timestamp25("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -5049,7 +5053,7 @@ var init_projects = __esm({
5049
5053
  });
5050
5054
 
5051
5055
  // ../packages/db/dist/schema/project_workspaces.js
5052
- import { boolean as boolean5, index as index22, jsonb as jsonb14, pgTable as pgTable26, text as text30, timestamp as timestamp26, uniqueIndex as uniqueIndex14, uuid as uuid25 } from "drizzle-orm/pg-core";
5056
+ import { boolean as boolean5, index as index22, jsonb as jsonb15, pgTable as pgTable26, text as text30, timestamp as timestamp26, uniqueIndex as uniqueIndex14, uuid as uuid25 } from "drizzle-orm/pg-core";
5053
5057
  var projectWorkspaces;
5054
5058
  var init_project_workspaces = __esm({
5055
5059
  "../packages/db/dist/schema/project_workspaces.js"() {
@@ -5072,7 +5076,7 @@ var init_project_workspaces = __esm({
5072
5076
  remoteProvider: text30("remote_provider"),
5073
5077
  remoteWorkspaceRef: text30("remote_workspace_ref"),
5074
5078
  sharedWorkspaceKey: text30("shared_workspace_key"),
5075
- metadata: jsonb14("metadata").$type(),
5079
+ metadata: jsonb15("metadata").$type(),
5076
5080
  isPrimary: boolean5("is_primary").notNull().default(false),
5077
5081
  createdAt: timestamp26("created_at", { withTimezone: true }).notNull().defaultNow(),
5078
5082
  updatedAt: timestamp26("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -5088,7 +5092,7 @@ var init_project_workspaces = __esm({
5088
5092
 
5089
5093
  // ../packages/db/dist/schema/issues.js
5090
5094
  import { sql as sql2 } from "drizzle-orm";
5091
- import { pgTable as pgTable27, uuid as uuid26, text as text31, timestamp as timestamp27, integer as integer8, jsonb as jsonb15, index as index23, uniqueIndex as uniqueIndex15 } from "drizzle-orm/pg-core";
5095
+ import { pgTable as pgTable27, uuid as uuid26, text as text31, timestamp as timestamp27, integer as integer8, jsonb as jsonb16, index as index23, uniqueIndex as uniqueIndex15 } from "drizzle-orm/pg-core";
5092
5096
  var issues;
5093
5097
  var init_issues = __esm({
5094
5098
  "../packages/db/dist/schema/issues.js"() {
@@ -5127,12 +5131,12 @@ var init_issues = __esm({
5127
5131
  originFingerprint: text31("origin_fingerprint").notNull().default("default"),
5128
5132
  requestDepth: integer8("request_depth").notNull().default(0),
5129
5133
  billingCode: text31("billing_code"),
5130
- assigneeAdapterOverrides: jsonb15("assignee_adapter_overrides").$type(),
5131
- executionPolicy: jsonb15("execution_policy").$type(),
5132
- executionState: jsonb15("execution_state").$type(),
5134
+ assigneeAdapterOverrides: jsonb16("assignee_adapter_overrides").$type(),
5135
+ executionPolicy: jsonb16("execution_policy").$type(),
5136
+ executionState: jsonb16("execution_state").$type(),
5133
5137
  executionWorkspaceId: uuid26("execution_workspace_id").references(() => executionWorkspaces.id, { onDelete: "set null" }),
5134
5138
  executionWorkspacePreference: text31("execution_workspace_preference"),
5135
- executionWorkspaceSettings: jsonb15("execution_workspace_settings").$type(),
5139
+ executionWorkspaceSettings: jsonb16("execution_workspace_settings").$type(),
5136
5140
  startedAt: timestamp27("started_at", { withTimezone: true }),
5137
5141
  completedAt: timestamp27("completed_at", { withTimezone: true }),
5138
5142
  cancelledAt: timestamp27("cancelled_at", { withTimezone: true }),
@@ -5174,7 +5178,7 @@ var init_issues = __esm({
5174
5178
  });
5175
5179
 
5176
5180
  // ../packages/db/dist/schema/execution_workspaces.js
5177
- import { index as index24, jsonb as jsonb16, pgTable as pgTable28, text as text32, timestamp as timestamp28, uuid as uuid27 } from "drizzle-orm/pg-core";
5181
+ import { index as index24, jsonb as jsonb17, pgTable as pgTable28, text as text32, timestamp as timestamp28, uuid as uuid27 } from "drizzle-orm/pg-core";
5178
5182
  var executionWorkspaces;
5179
5183
  var init_execution_workspaces = __esm({
5180
5184
  "../packages/db/dist/schema/execution_workspaces.js"() {
@@ -5205,7 +5209,7 @@ var init_execution_workspaces = __esm({
5205
5209
  closedAt: timestamp28("closed_at", { withTimezone: true }),
5206
5210
  cleanupEligibleAt: timestamp28("cleanup_eligible_at", { withTimezone: true }),
5207
5211
  cleanupReason: text32("cleanup_reason"),
5208
- metadata: jsonb16("metadata").$type(),
5212
+ metadata: jsonb17("metadata").$type(),
5209
5213
  createdAt: timestamp28("created_at", { withTimezone: true }).notNull().defaultNow(),
5210
5214
  updatedAt: timestamp28("updated_at", { withTimezone: true }).notNull().defaultNow()
5211
5215
  }, (table) => ({
@@ -5219,7 +5223,7 @@ var init_execution_workspaces = __esm({
5219
5223
  });
5220
5224
 
5221
5225
  // ../packages/db/dist/schema/workspace_operations.js
5222
- import { bigint as bigint3, boolean as boolean6, index as index25, integer as integer9, jsonb as jsonb17, pgTable as pgTable29, text as text33, timestamp as timestamp29, uuid as uuid28 } from "drizzle-orm/pg-core";
5226
+ import { bigint as bigint3, boolean as boolean6, index as index25, integer as integer9, jsonb as jsonb18, pgTable as pgTable29, text as text33, timestamp as timestamp29, uuid as uuid28 } from "drizzle-orm/pg-core";
5223
5227
  var workspaceOperations;
5224
5228
  var init_workspace_operations = __esm({
5225
5229
  "../packages/db/dist/schema/workspace_operations.js"() {
@@ -5248,7 +5252,7 @@ var init_workspace_operations = __esm({
5248
5252
  logCompressed: boolean6("log_compressed").notNull().default(false),
5249
5253
  stdoutExcerpt: text33("stdout_excerpt"),
5250
5254
  stderrExcerpt: text33("stderr_excerpt"),
5251
- metadata: jsonb17("metadata").$type(),
5255
+ metadata: jsonb18("metadata").$type(),
5252
5256
  startedAt: timestamp29("started_at", { withTimezone: true }).notNull().defaultNow(),
5253
5257
  finishedAt: timestamp29("finished_at", { withTimezone: true }),
5254
5258
  createdAt: timestamp29("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -5261,7 +5265,7 @@ var init_workspace_operations = __esm({
5261
5265
  });
5262
5266
 
5263
5267
  // ../packages/db/dist/schema/workspace_runtime_services.js
5264
- import { index as index26, integer as integer10, jsonb as jsonb18, pgTable as pgTable30, text as text34, timestamp as timestamp30, uuid as uuid29 } from "drizzle-orm/pg-core";
5268
+ import { index as index26, integer as integer10, jsonb as jsonb19, pgTable as pgTable30, text as text34, timestamp as timestamp30, uuid as uuid29 } from "drizzle-orm/pg-core";
5265
5269
  var workspaceRuntimeServices;
5266
5270
  var init_workspace_runtime_services = __esm({
5267
5271
  "../packages/db/dist/schema/workspace_runtime_services.js"() {
@@ -5297,7 +5301,7 @@ var init_workspace_runtime_services = __esm({
5297
5301
  lastUsedAt: timestamp30("last_used_at", { withTimezone: true }).notNull().defaultNow(),
5298
5302
  startedAt: timestamp30("started_at", { withTimezone: true }).notNull().defaultNow(),
5299
5303
  stoppedAt: timestamp30("stopped_at", { withTimezone: true }),
5300
- stopPolicy: jsonb18("stop_policy").$type(),
5304
+ stopPolicy: jsonb19("stop_policy").$type(),
5301
5305
  healthStatus: text34("health_status").notNull().default("unknown"),
5302
5306
  createdAt: timestamp30("created_at", { withTimezone: true }).notNull().defaultNow(),
5303
5307
  updatedAt: timestamp30("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -5422,7 +5426,7 @@ var init_company_secrets = __esm({
5422
5426
  });
5423
5427
 
5424
5428
  // ../packages/db/dist/schema/routines.js
5425
- import { boolean as boolean7, index as index31, integer as integer12, jsonb as jsonb19, pgTable as pgTable35, text as text38, timestamp as timestamp35, uniqueIndex as uniqueIndex19, uuid as uuid34 } from "drizzle-orm/pg-core";
5429
+ import { boolean as boolean7, index as index31, integer as integer12, jsonb as jsonb20, pgTable as pgTable35, text as text38, timestamp as timestamp35, uniqueIndex as uniqueIndex19, uuid as uuid34 } from "drizzle-orm/pg-core";
5426
5430
  var routines, routineTriggers, routineRuns;
5427
5431
  var init_routines = __esm({
5428
5432
  "../packages/db/dist/schema/routines.js"() {
@@ -5446,7 +5450,7 @@ var init_routines = __esm({
5446
5450
  status: text38("status").notNull().default("active"),
5447
5451
  concurrencyPolicy: text38("concurrency_policy").notNull().default("coalesce_if_active"),
5448
5452
  catchUpPolicy: text38("catch_up_policy").notNull().default("skip_missed"),
5449
- variables: jsonb19("variables").$type().notNull().default([]),
5453
+ variables: jsonb20("variables").$type().notNull().default([]),
5450
5454
  createdByAgentId: uuid34("created_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
5451
5455
  createdByUserId: text38("created_by_user_id"),
5452
5456
  updatedByAgentId: uuid34("updated_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
@@ -5499,7 +5503,7 @@ var init_routines = __esm({
5499
5503
  status: text38("status").notNull().default("received"),
5500
5504
  triggeredAt: timestamp35("triggered_at", { withTimezone: true }).notNull().defaultNow(),
5501
5505
  idempotencyKey: text38("idempotency_key"),
5502
- triggerPayload: jsonb19("trigger_payload").$type(),
5506
+ triggerPayload: jsonb20("trigger_payload").$type(),
5503
5507
  linkedIssueId: uuid34("linked_issue_id").references(() => issues.id, { onDelete: "set null" }),
5504
5508
  coalescedIntoRunId: uuid34("coalesced_into_run_id"),
5505
5509
  failureReason: text38("failure_reason"),
@@ -5516,7 +5520,7 @@ var init_routines = __esm({
5516
5520
  });
5517
5521
 
5518
5522
  // ../packages/db/dist/schema/issue_work_products.js
5519
- import { boolean as boolean8, index as index32, jsonb as jsonb20, pgTable as pgTable36, text as text39, timestamp as timestamp36, uuid as uuid35 } from "drizzle-orm/pg-core";
5523
+ import { boolean as boolean8, index as index32, jsonb as jsonb21, pgTable as pgTable36, text as text39, timestamp as timestamp36, uuid as uuid35 } from "drizzle-orm/pg-core";
5520
5524
  var issueWorkProducts;
5521
5525
  var init_issue_work_products = __esm({
5522
5526
  "../packages/db/dist/schema/issue_work_products.js"() {
@@ -5544,7 +5548,7 @@ var init_issue_work_products = __esm({
5544
5548
  isPrimary: boolean8("is_primary").notNull().default(false),
5545
5549
  healthStatus: text39("health_status").notNull().default("unknown"),
5546
5550
  summary: text39("summary"),
5547
- metadata: jsonb20("metadata").$type(),
5551
+ metadata: jsonb21("metadata").$type(),
5548
5552
  createdByRunId: uuid35("created_by_run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
5549
5553
  createdAt: timestamp36("created_at", { withTimezone: true }).notNull().defaultNow(),
5550
5554
  updatedAt: timestamp36("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -5686,7 +5690,7 @@ var init_leads = __esm({
5686
5690
  });
5687
5691
 
5688
5692
  // ../packages/db/dist/schema/lead_activities.js
5689
- import { index as index37, jsonb as jsonb21, pgTable as pgTable41, text as text43, timestamp as timestamp41, uuid as uuid40 } from "drizzle-orm/pg-core";
5693
+ import { index as index37, jsonb as jsonb22, pgTable as pgTable41, text as text43, timestamp as timestamp41, uuid as uuid40 } from "drizzle-orm/pg-core";
5690
5694
  import { sql as sql6 } from "drizzle-orm";
5691
5695
  var leadActivities;
5692
5696
  var init_lead_activities = __esm({
@@ -5701,7 +5705,7 @@ var init_lead_activities = __esm({
5701
5705
  kind: text43("kind").notNull(),
5702
5706
  issueId: uuid40("issue_id").references(() => issues.id, { onDelete: "set null" }),
5703
5707
  agentId: uuid40("agent_id").references(() => agents.id, { onDelete: "set null" }),
5704
- metadata: jsonb21("metadata").$type().notNull().default(sql6`'{}'::jsonb`),
5708
+ metadata: jsonb22("metadata").$type().notNull().default(sql6`'{}'::jsonb`),
5705
5709
  occurredAt: timestamp41("occurred_at", { withTimezone: true }).notNull(),
5706
5710
  createdAt: timestamp41("created_at", { withTimezone: true }).notNull().defaultNow()
5707
5711
  }, (table) => ({
@@ -5735,7 +5739,7 @@ var init_lead_labels = __esm({
5735
5739
  });
5736
5740
 
5737
5741
  // ../packages/db/dist/schema/contents.js
5738
- import { index as index39, integer as integer13, jsonb as jsonb22, pgTable as pgTable43, text as text44, timestamp as timestamp43, uuid as uuid42 } from "drizzle-orm/pg-core";
5742
+ import { index as index39, integer as integer13, jsonb as jsonb23, pgTable as pgTable43, text as text44, timestamp as timestamp43, uuid as uuid42 } from "drizzle-orm/pg-core";
5739
5743
  import { sql as sql7 } from "drizzle-orm";
5740
5744
  var contents;
5741
5745
  var init_contents = __esm({
@@ -5755,12 +5759,12 @@ var init_contents = __esm({
5755
5759
  status: text44("status").notNull().default("drafted"),
5756
5760
  title: text44("title"),
5757
5761
  body: text44("body").notNull(),
5758
- media: jsonb22("media").$type().notNull().default(sql7`'[]'::jsonb`),
5762
+ media: jsonb23("media").$type().notNull().default(sql7`'[]'::jsonb`),
5759
5763
  scheduledAt: timestamp43("scheduled_at", { withTimezone: true }),
5760
5764
  postedAt: timestamp43("posted_at", { withTimezone: true }),
5761
5765
  publishedUrl: text44("published_url"),
5762
5766
  externalId: text44("external_id"),
5763
- externalMetadata: jsonb22("external_metadata").$type().notNull().default(sql7`'{}'::jsonb`),
5767
+ externalMetadata: jsonb23("external_metadata").$type().notNull().default(sql7`'{}'::jsonb`),
5764
5768
  publishMethod: text44("publish_method"),
5765
5769
  publishError: text44("publish_error"),
5766
5770
  publishAttempts: integer13("publish_attempts").notNull().default(0),
@@ -5793,7 +5797,7 @@ var init_contents = __esm({
5793
5797
  });
5794
5798
 
5795
5799
  // ../packages/db/dist/schema/content_activities.js
5796
- import { index as index40, jsonb as jsonb23, pgTable as pgTable44, text as text45, timestamp as timestamp44, uuid as uuid43 } from "drizzle-orm/pg-core";
5800
+ import { index as index40, jsonb as jsonb24, pgTable as pgTable44, text as text45, timestamp as timestamp44, uuid as uuid43 } from "drizzle-orm/pg-core";
5797
5801
  import { sql as sql8 } from "drizzle-orm";
5798
5802
  var contentActivities;
5799
5803
  var init_content_activities = __esm({
@@ -5808,7 +5812,7 @@ var init_content_activities = __esm({
5808
5812
  kind: text45("kind").notNull(),
5809
5813
  issueId: uuid43("issue_id").references(() => issues.id, { onDelete: "set null" }),
5810
5814
  agentId: uuid43("agent_id").references(() => agents.id, { onDelete: "set null" }),
5811
- metadata: jsonb23("metadata").$type().notNull().default(sql8`'{}'::jsonb`),
5815
+ metadata: jsonb24("metadata").$type().notNull().default(sql8`'{}'::jsonb`),
5812
5816
  occurredAt: timestamp44("occurred_at", { withTimezone: true }).notNull(),
5813
5817
  createdAt: timestamp44("created_at", { withTimezone: true }).notNull().defaultNow()
5814
5818
  }, (table) => ({
@@ -5842,7 +5846,7 @@ var init_content_labels = __esm({
5842
5846
  });
5843
5847
 
5844
5848
  // ../packages/db/dist/schema/content_analytics.js
5845
- import { boolean as boolean10, index as index42, integer as integer14, jsonb as jsonb24, pgTable as pgTable46, text as text46, timestamp as timestamp46, uniqueIndex as uniqueIndex23, uuid as uuid45 } from "drizzle-orm/pg-core";
5849
+ import { boolean as boolean10, index as index42, integer as integer14, jsonb as jsonb25, pgTable as pgTable46, text as text46, timestamp as timestamp46, uniqueIndex as uniqueIndex23, uuid as uuid45 } from "drizzle-orm/pg-core";
5846
5850
  var contentAnalyticsPlatformConfigs, contentAnalyticsSnapshots, contentAnalyticsFetchLogs;
5847
5851
  var init_content_analytics = __esm({
5848
5852
  "../packages/db/dist/schema/content_analytics.js"() {
@@ -5854,7 +5858,7 @@ var init_content_analytics = __esm({
5854
5858
  companyId: uuid45("company_id").notNull().references(() => companies.id, { onDelete: "cascade" }),
5855
5859
  platform: text46("platform").notNull(),
5856
5860
  providerKey: text46("provider_key").notNull(),
5857
- env: jsonb24("env").$type().notNull().default({}),
5861
+ env: jsonb25("env").$type().notNull().default({}),
5858
5862
  enabled: boolean10("enabled").notNull().default(true),
5859
5863
  lastTestAt: timestamp46("last_test_at", { withTimezone: true }),
5860
5864
  lastTestStatus: text46("last_test_status"),
@@ -5874,9 +5878,9 @@ var init_content_analytics = __esm({
5874
5878
  providerKey: text46("provider_key").notNull(),
5875
5879
  status: text46("status").notNull().default("idle"),
5876
5880
  fetchedAt: timestamp46("fetched_at", { withTimezone: true }),
5877
- metrics: jsonb24("metrics").$type().notNull().default({}),
5878
- raw: jsonb24("raw").$type().notNull().default({}),
5879
- meta: jsonb24("meta").$type().notNull().default({}),
5881
+ metrics: jsonb25("metrics").$type().notNull().default({}),
5882
+ raw: jsonb25("raw").$type().notNull().default({}),
5883
+ meta: jsonb25("meta").$type().notNull().default({}),
5880
5884
  createdAt: timestamp46("created_at", { withTimezone: true }).notNull().defaultNow(),
5881
5885
  updatedAt: timestamp46("updated_at", { withTimezone: true }).notNull().defaultNow()
5882
5886
  }, (table) => ({
@@ -5896,8 +5900,8 @@ var init_content_analytics = __esm({
5896
5900
  durationMs: integer14("duration_ms"),
5897
5901
  error: text46("error"),
5898
5902
  summary: text46("summary"),
5899
- requestMeta: jsonb24("request_meta").$type().notNull().default({}),
5900
- responseMeta: jsonb24("response_meta").$type().notNull().default({}),
5903
+ requestMeta: jsonb25("request_meta").$type().notNull().default({}),
5904
+ responseMeta: jsonb25("response_meta").$type().notNull().default({}),
5901
5905
  createdAt: timestamp46("created_at", { withTimezone: true }).notNull().defaultNow()
5902
5906
  }, (table) => ({
5903
5907
  contentIdx: index42("content_analytics_fetch_logs_content_idx").on(table.contentId, table.createdAt),
@@ -6000,7 +6004,7 @@ var init_issue_comments = __esm({
6000
6004
  });
6001
6005
 
6002
6006
  // ../packages/db/dist/schema/issue_tree_holds.js
6003
- import { index as index46, jsonb as jsonb25, pgTable as pgTable50, text as text50, timestamp as timestamp50, uuid as uuid49 } from "drizzle-orm/pg-core";
6007
+ import { index as index46, jsonb as jsonb26, pgTable as pgTable50, text as text50, timestamp as timestamp50, uuid as uuid49 } from "drizzle-orm/pg-core";
6004
6008
  var issueTreeHolds;
6005
6009
  var init_issue_tree_holds = __esm({
6006
6010
  "../packages/db/dist/schema/issue_tree_holds.js"() {
@@ -6016,7 +6020,7 @@ var init_issue_tree_holds = __esm({
6016
6020
  mode: text50("mode").notNull(),
6017
6021
  status: text50("status").notNull().default("active"),
6018
6022
  reason: text50("reason"),
6019
- releasePolicy: jsonb25("release_policy").$type(),
6023
+ releasePolicy: jsonb26("release_policy").$type(),
6020
6024
  createdByActorType: text50("created_by_actor_type").notNull().default("system"),
6021
6025
  createdByAgentId: uuid49("created_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
6022
6026
  createdByUserId: text50("created_by_user_id"),
@@ -6027,7 +6031,7 @@ var init_issue_tree_holds = __esm({
6027
6031
  releasedByUserId: text50("released_by_user_id"),
6028
6032
  releasedByRunId: uuid49("released_by_run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
6029
6033
  releaseReason: text50("release_reason"),
6030
- releaseMetadata: jsonb25("release_metadata").$type(),
6034
+ releaseMetadata: jsonb26("release_metadata").$type(),
6031
6035
  createdAt: timestamp50("created_at", { withTimezone: true }).notNull().defaultNow(),
6032
6036
  updatedAt: timestamp50("updated_at", { withTimezone: true }).notNull().defaultNow()
6033
6037
  }, (table) => ({
@@ -6151,7 +6155,7 @@ var init_inbox_dismissals = __esm({
6151
6155
  });
6152
6156
 
6153
6157
  // ../packages/db/dist/schema/feedback_votes.js
6154
- import { boolean as boolean13, index as index51, jsonb as jsonb26, pgTable as pgTable55, text as text55, timestamp as timestamp55, uniqueIndex as uniqueIndex27, uuid as uuid54 } from "drizzle-orm/pg-core";
6158
+ import { boolean as boolean13, index as index51, jsonb as jsonb27, pgTable as pgTable55, text as text55, timestamp as timestamp55, uniqueIndex as uniqueIndex27, uuid as uuid54 } from "drizzle-orm/pg-core";
6155
6159
  var feedbackVotes;
6156
6160
  var init_feedback_votes = __esm({
6157
6161
  "../packages/db/dist/schema/feedback_votes.js"() {
@@ -6170,7 +6174,7 @@ var init_feedback_votes = __esm({
6170
6174
  sharedWithLabs: boolean13("shared_with_labs").notNull().default(false),
6171
6175
  sharedAt: timestamp55("shared_at", { withTimezone: true }),
6172
6176
  consentVersion: text55("consent_version"),
6173
- redactionSummary: jsonb26("redaction_summary"),
6177
+ redactionSummary: jsonb27("redaction_summary"),
6174
6178
  createdAt: timestamp55("created_at", { withTimezone: true }).notNull().defaultNow(),
6175
6179
  updatedAt: timestamp55("updated_at", { withTimezone: true }).notNull().defaultNow()
6176
6180
  }, (table) => ({
@@ -6183,7 +6187,7 @@ var init_feedback_votes = __esm({
6183
6187
  });
6184
6188
 
6185
6189
  // ../packages/db/dist/schema/feedback_exports.js
6186
- import { index as index52, integer as integer16, jsonb as jsonb27, pgTable as pgTable56, text as text56, timestamp as timestamp56, uniqueIndex as uniqueIndex28, uuid as uuid55 } from "drizzle-orm/pg-core";
6190
+ import { index as index52, integer as integer16, jsonb as jsonb28, pgTable as pgTable56, text as text56, timestamp as timestamp56, uniqueIndex as uniqueIndex28, uuid as uuid55 } from "drizzle-orm/pg-core";
6187
6191
  var feedbackExports;
6188
6192
  var init_feedback_exports = __esm({
6189
6193
  "../packages/db/dist/schema/feedback_exports.js"() {
@@ -6210,9 +6214,9 @@ var init_feedback_exports = __esm({
6210
6214
  bundleVersion: text56("bundle_version").notNull().default("paperclip-feedback-bundle-v2"),
6211
6215
  payloadVersion: text56("payload_version").notNull().default("paperclip-feedback-v1"),
6212
6216
  payloadDigest: text56("payload_digest"),
6213
- payloadSnapshot: jsonb27("payload_snapshot"),
6214
- targetSummary: jsonb27("target_summary").notNull(),
6215
- redactionSummary: jsonb27("redaction_summary"),
6217
+ payloadSnapshot: jsonb28("payload_snapshot"),
6218
+ targetSummary: jsonb28("target_summary").notNull(),
6219
+ redactionSummary: jsonb28("redaction_summary"),
6216
6220
  attemptCount: integer16("attempt_count").notNull().default(0),
6217
6221
  lastAttemptedAt: timestamp56("last_attempted_at", { withTimezone: true }),
6218
6222
  exportedAt: timestamp56("exported_at", { withTimezone: true }),
@@ -6309,7 +6313,7 @@ var init_creators = __esm({
6309
6313
  });
6310
6314
 
6311
6315
  // ../packages/db/dist/schema/creator_accounts.js
6312
- import { pgTable as pgTable60, uuid as uuid59, text as text59, integer as integer17, timestamp as timestamp60, jsonb as jsonb28, index as index56, uniqueIndex as uniqueIndex31 } from "drizzle-orm/pg-core";
6316
+ import { pgTable as pgTable60, uuid as uuid59, text as text59, integer as integer17, timestamp as timestamp60, jsonb as jsonb29, index as index56, uniqueIndex as uniqueIndex31 } from "drizzle-orm/pg-core";
6313
6317
  import { sql as sql9 } from "drizzle-orm";
6314
6318
  var creatorAccounts;
6315
6319
  var init_creator_accounts = __esm({
@@ -6326,7 +6330,7 @@ var init_creator_accounts = __esm({
6326
6330
  followerCount: integer17("follower_count"),
6327
6331
  lastSeenAt: timestamp60("last_seen_at", { withTimezone: true }),
6328
6332
  lastScrapedAt: timestamp60("last_scraped_at", { withTimezone: true }),
6329
- metadata: jsonb28("metadata").$type().notNull().default(sql9`'{}'::jsonb`),
6333
+ metadata: jsonb29("metadata").$type().notNull().default(sql9`'{}'::jsonb`),
6330
6334
  createdAt: timestamp60("created_at", { withTimezone: true }).notNull().defaultNow(),
6331
6335
  updatedAt: timestamp60("updated_at", { withTimezone: true }).notNull().defaultNow()
6332
6336
  }, (table) => ({
@@ -6357,7 +6361,7 @@ var init_creator_companies = __esm({
6357
6361
  });
6358
6362
 
6359
6363
  // ../packages/db/dist/schema/creator_posts.js
6360
- import { pgTable as pgTable62, uuid as uuid61, text as text61, integer as integer18, bigint as bigint4, timestamp as timestamp62, jsonb as jsonb29, index as index58, uniqueIndex as uniqueIndex32 } from "drizzle-orm/pg-core";
6364
+ import { pgTable as pgTable62, uuid as uuid61, text as text61, integer as integer18, bigint as bigint4, timestamp as timestamp62, jsonb as jsonb30, index as index58, uniqueIndex as uniqueIndex32 } from "drizzle-orm/pg-core";
6361
6365
  import { sql as sql10 } from "drizzle-orm";
6362
6366
  var creatorPosts;
6363
6367
  var init_creator_posts = __esm({
@@ -6390,8 +6394,8 @@ var init_creator_posts = __esm({
6390
6394
  transcript: text61("transcript"),
6391
6395
  transcriptLanguage: text61("transcript_language"),
6392
6396
  transcriptSource: text61("transcript_source"),
6393
- transcriptSegments: jsonb29("transcript_segments").$type(),
6394
- metadata: jsonb29("metadata").$type().notNull().default(sql10`'{}'::jsonb`),
6397
+ transcriptSegments: jsonb30("transcript_segments").$type(),
6398
+ metadata: jsonb30("metadata").$type().notNull().default(sql10`'{}'::jsonb`),
6395
6399
  sourceIssueId: uuid61("source_issue_id").references(() => issues.id, { onDelete: "set null" }),
6396
6400
  processingState: text61("processing_state").notNull().default("idle"),
6397
6401
  processingError: text61("processing_error"),
@@ -6519,7 +6523,7 @@ var init_issue_documents = __esm({
6519
6523
  });
6520
6524
 
6521
6525
  // ../packages/db/dist/schema/heartbeat_run_events.js
6522
- import { pgTable as pgTable67, uuid as uuid66, text as text66, timestamp as timestamp67, integer as integer21, jsonb as jsonb30, index as index63, bigserial } from "drizzle-orm/pg-core";
6526
+ import { pgTable as pgTable67, uuid as uuid66, text as text66, timestamp as timestamp67, integer as integer21, jsonb as jsonb31, index as index63, bigserial } from "drizzle-orm/pg-core";
6523
6527
  var heartbeatRunEvents;
6524
6528
  var init_heartbeat_run_events = __esm({
6525
6529
  "../packages/db/dist/schema/heartbeat_run_events.js"() {
@@ -6538,7 +6542,7 @@ var init_heartbeat_run_events = __esm({
6538
6542
  level: text66("level"),
6539
6543
  color: text66("color"),
6540
6544
  message: text66("message"),
6541
- payload: jsonb30("payload").$type(),
6545
+ payload: jsonb31("payload").$type(),
6542
6546
  createdAt: timestamp67("created_at", { withTimezone: true }).notNull().defaultNow()
6543
6547
  }, (table) => ({
6544
6548
  runSeqIdx: index63("heartbeat_run_events_run_seq_idx").on(table.runId, table.seq),
@@ -6619,7 +6623,7 @@ var init_cost_events = __esm({
6619
6623
  });
6620
6624
 
6621
6625
  // ../packages/db/dist/schema/finance_events.js
6622
- import { pgTable as pgTable70, uuid as uuid69, text as text69, timestamp as timestamp70, integer as integer23, index as index66, boolean as boolean14, jsonb as jsonb31 } from "drizzle-orm/pg-core";
6626
+ import { pgTable as pgTable70, uuid as uuid69, text as text69, timestamp as timestamp70, integer as integer23, index as index66, boolean as boolean14, jsonb as jsonb32 } from "drizzle-orm/pg-core";
6623
6627
  var financeEvents;
6624
6628
  var init_finance_events = __esm({
6625
6629
  "../packages/db/dist/schema/finance_events.js"() {
@@ -6656,7 +6660,7 @@ var init_finance_events = __esm({
6656
6660
  currency: text69("currency").notNull().default("USD"),
6657
6661
  estimated: boolean14("estimated").notNull().default(false),
6658
6662
  externalInvoiceId: text69("external_invoice_id"),
6659
- metadataJson: jsonb31("metadata_json").$type(),
6663
+ metadataJson: jsonb32("metadata_json").$type(),
6660
6664
  occurredAt: timestamp70("occurred_at", { withTimezone: true }).notNull(),
6661
6665
  createdAt: timestamp70("created_at", { withTimezone: true }).notNull().defaultNow()
6662
6666
  }, (table) => ({
@@ -6697,7 +6701,7 @@ var init_approval_comments = __esm({
6697
6701
  });
6698
6702
 
6699
6703
  // ../packages/db/dist/schema/activity_log.js
6700
- import { pgTable as pgTable72, uuid as uuid71, text as text71, timestamp as timestamp72, jsonb as jsonb32, index as index68 } from "drizzle-orm/pg-core";
6704
+ import { pgTable as pgTable72, uuid as uuid71, text as text71, timestamp as timestamp72, jsonb as jsonb33, index as index68 } from "drizzle-orm/pg-core";
6701
6705
  var activityLog;
6702
6706
  var init_activity_log = __esm({
6703
6707
  "../packages/db/dist/schema/activity_log.js"() {
@@ -6715,7 +6719,7 @@ var init_activity_log = __esm({
6715
6719
  entityId: text71("entity_id").notNull(),
6716
6720
  agentId: uuid71("agent_id").references(() => agents.id),
6717
6721
  runId: uuid71("run_id").references(() => heartbeatRuns.id),
6718
- details: jsonb32("details").$type(),
6722
+ details: jsonb33("details").$type(),
6719
6723
  createdAt: timestamp72("created_at", { withTimezone: true }).notNull().defaultNow()
6720
6724
  }, (table) => ({
6721
6725
  companyCreatedIdx: index68("activity_log_company_created_idx").on(table.companyId, table.createdAt),
@@ -6726,7 +6730,7 @@ var init_activity_log = __esm({
6726
6730
  });
6727
6731
 
6728
6732
  // ../packages/db/dist/schema/company_secret_versions.js
6729
- import { pgTable as pgTable73, uuid as uuid72, text as text72, timestamp as timestamp73, integer as integer24, jsonb as jsonb33, index as index69, uniqueIndex as uniqueIndex35 } from "drizzle-orm/pg-core";
6733
+ import { pgTable as pgTable73, uuid as uuid72, text as text72, timestamp as timestamp73, integer as integer24, jsonb as jsonb34, index as index69, uniqueIndex as uniqueIndex35 } from "drizzle-orm/pg-core";
6730
6734
  var companySecretVersions;
6731
6735
  var init_company_secret_versions = __esm({
6732
6736
  "../packages/db/dist/schema/company_secret_versions.js"() {
@@ -6737,7 +6741,7 @@ var init_company_secret_versions = __esm({
6737
6741
  id: uuid72("id").primaryKey().defaultRandom(),
6738
6742
  secretId: uuid72("secret_id").notNull().references(() => companySecrets.id, { onDelete: "cascade" }),
6739
6743
  version: integer24("version").notNull(),
6740
- material: jsonb33("material").$type().notNull(),
6744
+ material: jsonb34("material").$type().notNull(),
6741
6745
  valueSha256: text72("value_sha256").notNull(),
6742
6746
  createdByAgentId: uuid72("created_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
6743
6747
  createdByUserId: text72("created_by_user_id"),
@@ -6752,7 +6756,7 @@ var init_company_secret_versions = __esm({
6752
6756
  });
6753
6757
 
6754
6758
  // ../packages/db/dist/schema/company_skills.js
6755
- import { pgTable as pgTable74, uuid as uuid73, text as text73, timestamp as timestamp74, jsonb as jsonb34, index as index70, uniqueIndex as uniqueIndex36 } from "drizzle-orm/pg-core";
6759
+ import { pgTable as pgTable74, uuid as uuid73, text as text73, timestamp as timestamp74, jsonb as jsonb35, index as index70, uniqueIndex as uniqueIndex36 } from "drizzle-orm/pg-core";
6756
6760
  var companySkills;
6757
6761
  var init_company_skills = __esm({
6758
6762
  "../packages/db/dist/schema/company_skills.js"() {
@@ -6771,8 +6775,8 @@ var init_company_skills = __esm({
6771
6775
  sourceRef: text73("source_ref"),
6772
6776
  trustLevel: text73("trust_level").notNull().default("markdown_only"),
6773
6777
  compatibility: text73("compatibility").notNull().default("compatible"),
6774
- fileInventory: jsonb34("file_inventory").$type().notNull().default([]),
6775
- metadata: jsonb34("metadata").$type(),
6778
+ fileInventory: jsonb35("file_inventory").$type().notNull().default([]),
6779
+ metadata: jsonb35("metadata").$type(),
6776
6780
  createdAt: timestamp74("created_at", { withTimezone: true }).notNull().defaultNow(),
6777
6781
  updatedAt: timestamp74("updated_at", { withTimezone: true }).notNull().defaultNow()
6778
6782
  }, (table) => ({
@@ -6783,7 +6787,7 @@ var init_company_skills = __esm({
6783
6787
  });
6784
6788
 
6785
6789
  // ../packages/db/dist/schema/plugins.js
6786
- import { pgTable as pgTable75, uuid as uuid74, text as text74, integer as integer25, timestamp as timestamp75, jsonb as jsonb35, index as index71, uniqueIndex as uniqueIndex37 } from "drizzle-orm/pg-core";
6790
+ import { pgTable as pgTable75, uuid as uuid74, text as text74, integer as integer25, timestamp as timestamp75, jsonb as jsonb36, index as index71, uniqueIndex as uniqueIndex37 } from "drizzle-orm/pg-core";
6787
6791
  var plugins;
6788
6792
  var init_plugins = __esm({
6789
6793
  "../packages/db/dist/schema/plugins.js"() {
@@ -6794,8 +6798,8 @@ var init_plugins = __esm({
6794
6798
  packageName: text74("package_name").notNull(),
6795
6799
  version: text74("version").notNull(),
6796
6800
  apiVersion: integer25("api_version").notNull().default(1),
6797
- categories: jsonb35("categories").$type().notNull().default([]),
6798
- manifestJson: jsonb35("manifest_json").$type().notNull(),
6801
+ categories: jsonb36("categories").$type().notNull().default([]),
6802
+ manifestJson: jsonb36("manifest_json").$type().notNull(),
6799
6803
  status: text74("status").$type().notNull().default("installed"),
6800
6804
  installOrder: integer25("install_order"),
6801
6805
  /** Resolved package path for local-path installs; used to find worker entrypoint. */
@@ -6811,7 +6815,7 @@ var init_plugins = __esm({
6811
6815
  });
6812
6816
 
6813
6817
  // ../packages/db/dist/schema/plugin_config.js
6814
- import { pgTable as pgTable76, uuid as uuid75, text as text75, timestamp as timestamp76, jsonb as jsonb36, uniqueIndex as uniqueIndex38 } from "drizzle-orm/pg-core";
6818
+ import { pgTable as pgTable76, uuid as uuid75, text as text75, timestamp as timestamp76, jsonb as jsonb37, uniqueIndex as uniqueIndex38 } from "drizzle-orm/pg-core";
6815
6819
  var pluginConfig;
6816
6820
  var init_plugin_config = __esm({
6817
6821
  "../packages/db/dist/schema/plugin_config.js"() {
@@ -6820,7 +6824,7 @@ var init_plugin_config = __esm({
6820
6824
  pluginConfig = pgTable76("plugin_config", {
6821
6825
  id: uuid75("id").primaryKey().defaultRandom(),
6822
6826
  pluginId: uuid75("plugin_id").notNull().references(() => plugins.id, { onDelete: "cascade" }),
6823
- configJson: jsonb36("config_json").$type().notNull().default({}),
6827
+ configJson: jsonb37("config_json").$type().notNull().default({}),
6824
6828
  lastError: text75("last_error"),
6825
6829
  createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
6826
6830
  updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -6831,7 +6835,7 @@ var init_plugin_config = __esm({
6831
6835
  });
6832
6836
 
6833
6837
  // ../packages/db/dist/schema/plugin_company_settings.js
6834
- import { pgTable as pgTable77, uuid as uuid76, text as text76, timestamp as timestamp77, jsonb as jsonb37, index as index72, uniqueIndex as uniqueIndex39, boolean as boolean15 } from "drizzle-orm/pg-core";
6838
+ import { pgTable as pgTable77, uuid as uuid76, text as text76, timestamp as timestamp77, jsonb as jsonb38, index as index72, uniqueIndex as uniqueIndex39, boolean as boolean15 } from "drizzle-orm/pg-core";
6835
6839
  var pluginCompanySettings;
6836
6840
  var init_plugin_company_settings = __esm({
6837
6841
  "../packages/db/dist/schema/plugin_company_settings.js"() {
@@ -6843,7 +6847,7 @@ var init_plugin_company_settings = __esm({
6843
6847
  companyId: uuid76("company_id").notNull().references(() => companies.id, { onDelete: "cascade" }),
6844
6848
  pluginId: uuid76("plugin_id").notNull().references(() => plugins.id, { onDelete: "cascade" }),
6845
6849
  enabled: boolean15("enabled").notNull().default(true),
6846
- settingsJson: jsonb37("settings_json").$type().notNull().default({}),
6850
+ settingsJson: jsonb38("settings_json").$type().notNull().default({}),
6847
6851
  lastError: text76("last_error"),
6848
6852
  createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
6849
6853
  updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -6856,7 +6860,7 @@ var init_plugin_company_settings = __esm({
6856
6860
  });
6857
6861
 
6858
6862
  // ../packages/db/dist/schema/plugin_state.js
6859
- import { pgTable as pgTable78, uuid as uuid77, text as text77, timestamp as timestamp78, jsonb as jsonb38, index as index73, unique as unique3 } from "drizzle-orm/pg-core";
6863
+ import { pgTable as pgTable78, uuid as uuid77, text as text77, timestamp as timestamp78, jsonb as jsonb39, index as index73, unique as unique3 } from "drizzle-orm/pg-core";
6860
6864
  var pluginState;
6861
6865
  var init_plugin_state = __esm({
6862
6866
  "../packages/db/dist/schema/plugin_state.js"() {
@@ -6881,7 +6885,7 @@ var init_plugin_state = __esm({
6881
6885
  /** The key identifying this state entry within the namespace. */
6882
6886
  stateKey: text77("state_key").notNull(),
6883
6887
  /** JSON-serializable value stored by the plugin. */
6884
- valueJson: jsonb38("value_json").notNull(),
6888
+ valueJson: jsonb39("value_json").notNull(),
6885
6889
  /** Timestamp of the most recent write. */
6886
6890
  updatedAt: timestamp78("updated_at", { withTimezone: true }).notNull().defaultNow()
6887
6891
  }, (table) => ({
@@ -6904,7 +6908,7 @@ var init_plugin_state = __esm({
6904
6908
  });
6905
6909
 
6906
6910
  // ../packages/db/dist/schema/plugin_entities.js
6907
- import { pgTable as pgTable79, uuid as uuid78, text as text78, timestamp as timestamp79, jsonb as jsonb39, index as index74, uniqueIndex as uniqueIndex40 } from "drizzle-orm/pg-core";
6911
+ import { pgTable as pgTable79, uuid as uuid78, text as text78, timestamp as timestamp79, jsonb as jsonb40, index as index74, uniqueIndex as uniqueIndex40 } from "drizzle-orm/pg-core";
6908
6912
  var pluginEntities;
6909
6913
  var init_plugin_entities = __esm({
6910
6914
  "../packages/db/dist/schema/plugin_entities.js"() {
@@ -6921,7 +6925,7 @@ var init_plugin_entities = __esm({
6921
6925
  // ID in the external system
6922
6926
  title: text78("title"),
6923
6927
  status: text78("status"),
6924
- data: jsonb39("data").$type().notNull().default({}),
6928
+ data: jsonb40("data").$type().notNull().default({}),
6925
6929
  createdAt: timestamp79("created_at", { withTimezone: true }).notNull().defaultNow(),
6926
6930
  updatedAt: timestamp79("updated_at", { withTimezone: true }).notNull().defaultNow()
6927
6931
  }, (table) => ({
@@ -6934,7 +6938,7 @@ var init_plugin_entities = __esm({
6934
6938
  });
6935
6939
 
6936
6940
  // ../packages/db/dist/schema/plugin_jobs.js
6937
- import { pgTable as pgTable80, uuid as uuid79, text as text79, integer as integer26, timestamp as timestamp80, jsonb as jsonb40, index as index75, uniqueIndex as uniqueIndex41 } from "drizzle-orm/pg-core";
6941
+ import { pgTable as pgTable80, uuid as uuid79, text as text79, integer as integer26, timestamp as timestamp80, jsonb as jsonb41, index as index75, uniqueIndex as uniqueIndex41 } from "drizzle-orm/pg-core";
6938
6942
  var pluginJobs, pluginJobRuns;
6939
6943
  var init_plugin_jobs = __esm({
6940
6944
  "../packages/db/dist/schema/plugin_jobs.js"() {
@@ -6976,7 +6980,7 @@ var init_plugin_jobs = __esm({
6976
6980
  /** Error message if `status === "failed"`. */
6977
6981
  error: text79("error"),
6978
6982
  /** Ordered list of log lines emitted during this run. */
6979
- logs: jsonb40("logs").$type().notNull().default([]),
6983
+ logs: jsonb41("logs").$type().notNull().default([]),
6980
6984
  startedAt: timestamp80("started_at", { withTimezone: true }),
6981
6985
  finishedAt: timestamp80("finished_at", { withTimezone: true }),
6982
6986
  createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -6989,7 +6993,7 @@ var init_plugin_jobs = __esm({
6989
6993
  });
6990
6994
 
6991
6995
  // ../packages/db/dist/schema/plugin_webhooks.js
6992
- import { pgTable as pgTable81, uuid as uuid80, text as text80, integer as integer27, timestamp as timestamp81, jsonb as jsonb41, index as index76 } from "drizzle-orm/pg-core";
6996
+ import { pgTable as pgTable81, uuid as uuid80, text as text80, integer as integer27, timestamp as timestamp81, jsonb as jsonb42, index as index76 } from "drizzle-orm/pg-core";
6993
6997
  var pluginWebhookDeliveries;
6994
6998
  var init_plugin_webhooks = __esm({
6995
6999
  "../packages/db/dist/schema/plugin_webhooks.js"() {
@@ -7010,9 +7014,9 @@ var init_plugin_webhooks = __esm({
7010
7014
  /** Error message if `status === "failed"`. */
7011
7015
  error: text80("error"),
7012
7016
  /** Raw JSON body of the inbound HTTP request. */
7013
- payload: jsonb41("payload").$type().notNull(),
7017
+ payload: jsonb42("payload").$type().notNull(),
7014
7018
  /** Relevant HTTP headers from the inbound request (e.g. signature headers). */
7015
- headers: jsonb41("headers").$type().notNull().default({}),
7019
+ headers: jsonb42("headers").$type().notNull().default({}),
7016
7020
  startedAt: timestamp81("started_at", { withTimezone: true }),
7017
7021
  finishedAt: timestamp81("finished_at", { withTimezone: true }),
7018
7022
  createdAt: timestamp81("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -7025,7 +7029,7 @@ var init_plugin_webhooks = __esm({
7025
7029
  });
7026
7030
 
7027
7031
  // ../packages/db/dist/schema/plugin_logs.js
7028
- import { pgTable as pgTable82, uuid as uuid81, text as text81, timestamp as timestamp82, jsonb as jsonb42, index as index77 } from "drizzle-orm/pg-core";
7032
+ import { pgTable as pgTable82, uuid as uuid81, text as text81, timestamp as timestamp82, jsonb as jsonb43, index as index77 } from "drizzle-orm/pg-core";
7029
7033
  var pluginLogs;
7030
7034
  var init_plugin_logs = __esm({
7031
7035
  "../packages/db/dist/schema/plugin_logs.js"() {
@@ -7036,7 +7040,7 @@ var init_plugin_logs = __esm({
7036
7040
  pluginId: uuid81("plugin_id").notNull().references(() => plugins.id, { onDelete: "cascade" }),
7037
7041
  level: text81("level").notNull().default("info"),
7038
7042
  message: text81("message").notNull(),
7039
- meta: jsonb42("meta").$type(),
7043
+ meta: jsonb43("meta").$type(),
7040
7044
  createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow()
7041
7045
  }, (table) => ({
7042
7046
  pluginTimeIdx: index77("plugin_logs_plugin_time_idx").on(table.pluginId, table.createdAt),
@@ -7046,7 +7050,7 @@ var init_plugin_logs = __esm({
7046
7050
  });
7047
7051
 
7048
7052
  // ../packages/db/dist/schema/chat.js
7049
- import { pgTable as pgTable83, uuid as uuid82, text as text82, timestamp as timestamp83, jsonb as jsonb43, index as index78 } from "drizzle-orm/pg-core";
7053
+ import { pgTable as pgTable83, uuid as uuid82, text as text82, timestamp as timestamp83, jsonb as jsonb44, index as index78 } from "drizzle-orm/pg-core";
7050
7054
  var chatSessions, chatMessages;
7051
7055
  var init_chat = __esm({
7052
7056
  "../packages/db/dist/schema/chat.js"() {
@@ -7076,10 +7080,10 @@ var init_chat = __esm({
7076
7080
  id: uuid82("id").primaryKey().defaultRandom(),
7077
7081
  sessionId: uuid82("session_id").notNull().references(() => chatSessions.id, { onDelete: "cascade" }),
7078
7082
  role: text82("role").notNull(),
7079
- content: jsonb43("content").$type().notNull(),
7080
- resolutions: jsonb43("resolutions").$type(),
7083
+ content: jsonb44("content").$type().notNull(),
7084
+ resolutions: jsonb44("resolutions").$type(),
7081
7085
  stopReason: text82("stop_reason"),
7082
- usage: jsonb43("usage").$type(),
7086
+ usage: jsonb44("usage").$type(),
7083
7087
  createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
7084
7088
  }, (table) => ({
7085
7089
  sessionCreatedIdx: index78("chat_messages_session_created_idx").on(table.sessionId, table.createdAt)
@@ -10995,12 +10999,17 @@ function actorMiddleware(db, opts) {
10995
10999
  next();
10996
11000
  return;
10997
11001
  }
11002
+ let resolvedRunId = runIdHeader || void 0;
11003
+ if (!resolvedRunId && claims.run_id && UUID_RE3.test(claims.run_id)) {
11004
+ const runRow = await db.select({ id: heartbeatRuns.id }).from(heartbeatRuns).where(eq3(heartbeatRuns.id, claims.run_id)).then((rows) => rows[0] ?? null);
11005
+ if (runRow) resolvedRunId = claims.run_id;
11006
+ }
10998
11007
  req.actor = {
10999
11008
  type: "agent",
11000
11009
  agentId: claims.sub,
11001
11010
  companyId: claims.company_id,
11002
11011
  keyId: void 0,
11003
- runId: runIdHeader || claims.run_id || void 0,
11012
+ runId: resolvedRunId,
11004
11013
  source: "agent_jwt"
11005
11014
  };
11006
11015
  next();
@@ -11023,6 +11032,7 @@ function actorMiddleware(db, opts) {
11023
11032
  next();
11024
11033
  };
11025
11034
  }
11035
+ var UUID_RE3;
11026
11036
  var init_auth2 = __esm({
11027
11037
  "../server/src/middleware/auth.ts"() {
11028
11038
  "use strict";
@@ -11030,6 +11040,7 @@ var init_auth2 = __esm({
11030
11040
  init_agent_auth_jwt();
11031
11041
  init_logger();
11032
11042
  init_board_auth();
11043
+ UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
11033
11044
  }
11034
11045
  });
11035
11046
 
@@ -11787,13 +11798,17 @@ function normalizeExperimentalSettings(raw) {
11787
11798
  return {
11788
11799
  enableIsolatedWorkspaces: parsed.data.enableIsolatedWorkspaces ?? false,
11789
11800
  autoRestartDevServerWhenIdle: parsed.data.autoRestartDevServerWhenIdle ?? false,
11790
- enableIssueGraphLivenessAutoRecovery: parsed.data.enableIssueGraphLivenessAutoRecovery ?? false
11801
+ enableIssueGraphLivenessAutoRecovery: parsed.data.enableIssueGraphLivenessAutoRecovery ?? false,
11802
+ enableContentLanes: parsed.data.enableContentLanes ?? false,
11803
+ enableBigTerminal: parsed.data.enableBigTerminal ?? false
11791
11804
  };
11792
11805
  }
11793
11806
  return {
11794
11807
  enableIsolatedWorkspaces: false,
11795
11808
  autoRestartDevServerWhenIdle: false,
11796
- enableIssueGraphLivenessAutoRecovery: false
11809
+ enableIssueGraphLivenessAutoRecovery: false,
11810
+ enableContentLanes: false,
11811
+ enableBigTerminal: false
11797
11812
  };
11798
11813
  }
11799
11814
  function normalizeLocalToolsConfig(raw) {
@@ -12040,6 +12055,7 @@ function companyService(db) {
12040
12055
  feedbackDataSharingTermsVersion: companies.feedbackDataSharingTermsVersion,
12041
12056
  brandColor: companies.brandColor,
12042
12057
  defaultCreatorAgentId: companies.defaultCreatorAgentId,
12058
+ metadata: companies.metadata,
12043
12059
  logoAssetId: companyLogos.assetId,
12044
12060
  createdAt: companies.createdAt,
12045
12061
  updatedAt: companies.updatedAt
@@ -53708,9 +53724,9 @@ function agentRoutes(db) {
53708
53724
  return;
53709
53725
  }
53710
53726
  assertCompanyAccess(req, agent.companyId);
53711
- const sessions = await heartbeat2.listTaskSessions(id);
53727
+ const sessions2 = await heartbeat2.listTaskSessions(id);
53712
53728
  res.json(
53713
- sessions.map((session) => ({
53729
+ sessions2.map((session) => ({
53714
53730
  ...session,
53715
53731
  sessionParamsJson: redactEventPayload(session.sessionParamsJson ?? null)
53716
53732
  }))
@@ -62990,6 +63006,7 @@ function contentService(db) {
62990
63006
  if (patch.externalId !== void 0) values.externalId = cleanNullable3(patch.externalId);
62991
63007
  if (patch.postedAt !== void 0) values.postedAt = toDate3(patch.postedAt);
62992
63008
  if (patch.externalMetadata !== void 0) values.externalMetadata = patch.externalMetadata;
63009
+ if (patch.publishError !== void 0) values.publishError = cleanNullable3(patch.publishError);
62993
63010
  if (patch.publishedUrl !== void 0 && patch.accountHandle === void 0 && !existing.accountHandle?.trim()) {
62994
63011
  const newUrl = cleanNullable3(patch.publishedUrl);
62995
63012
  if (newUrl) {
@@ -63375,8 +63392,8 @@ var init_content = __esm({
63375
63392
  ALLOWED_TRANSITIONS = {
63376
63393
  drafted: ["in_review", "cancelled"],
63377
63394
  in_review: ["approved", "drafted"],
63378
- approved: ["scheduled", "publishing", "cancelled", "drafted"],
63379
- scheduled: ["publishing", "approved", "cancelled"],
63395
+ approved: ["scheduled", "publishing", "cancelled", "drafted", "failed"],
63396
+ scheduled: ["publishing", "approved", "cancelled", "failed"],
63380
63397
  publishing: ["posted", "failed"],
63381
63398
  posted: ["failed"],
63382
63399
  failed: ["approved", "scheduled", "drafted"],
@@ -67246,7 +67263,7 @@ ${message}`);
67246
67263
  parts.push("Respond with JSON only.");
67247
67264
  if (toolUseEnabled) {
67248
67265
  const targetAgentId = options2?.targetAgentId ?? null;
67249
- const jwt = targetAgentId ? createLocalAgentJwt(targetAgentId, companyId, "claude_local", `chat-${randomUUID13()}`) : null;
67266
+ const jwt = targetAgentId ? createLocalAgentJwt(targetAgentId, companyId, "claude_local", randomUUID13()) : null;
67250
67267
  if (targetAgentId && !jwt) {
67251
67268
  toolUseFallbackReason = "agent_auth_unavailable";
67252
67269
  toolUseFallbackAdapterType = adapterType;
@@ -67825,8 +67842,8 @@ function chatRoutes(db, storageService, bridgeDeps) {
67825
67842
  router.get("/companies/:companyId/chat/sessions", async (req, res) => {
67826
67843
  const companyId = req.params.companyId;
67827
67844
  assertCompanyAccess(req, companyId);
67828
- const sessions = await sessionSvc.listSessions(companyId);
67829
- res.json(sessions);
67845
+ const sessions2 = await sessionSvc.listSessions(companyId);
67846
+ res.json(sessions2);
67830
67847
  });
67831
67848
  router.get("/companies/:companyId/chat/model-options", async (req, res) => {
67832
67849
  const companyId = req.params.companyId;
@@ -68838,6 +68855,145 @@ var init_instance_settings3 = __esm({
68838
68855
  }
68839
68856
  });
68840
68857
 
68858
+ // ../server/src/services/terminal-sessions.ts
68859
+ import { createRequire as createRequire3 } from "node:module";
68860
+ import crypto5 from "node:crypto";
68861
+ function getPty() {
68862
+ return require4("node-pty");
68863
+ }
68864
+ function createSession(opts = {}) {
68865
+ const nodePty = getPty();
68866
+ const shell = process.env.SHELL ?? "/bin/zsh";
68867
+ const cols = opts.cols ?? 80;
68868
+ const rows = opts.rows ?? 24;
68869
+ const sessionId = crypto5.randomUUID();
68870
+ const pty = nodePty.spawn(shell, [], {
68871
+ name: "xterm-256color",
68872
+ cols,
68873
+ rows,
68874
+ cwd: process.cwd(),
68875
+ env: process.env
68876
+ });
68877
+ const session = {
68878
+ pty,
68879
+ scrollback: Buffer.alloc(0),
68880
+ sockets: /* @__PURE__ */ new Set()
68881
+ };
68882
+ pty.onData((data) => {
68883
+ const chunk = Buffer.from(data, "utf8");
68884
+ const combined = Buffer.concat([session.scrollback, chunk]);
68885
+ session.scrollback = combined.length > SCROLLBACK_LIMIT ? combined.slice(combined.length - SCROLLBACK_LIMIT) : combined;
68886
+ for (const ws of session.sockets) {
68887
+ if (ws.readyState === 1) {
68888
+ ws.send(chunk);
68889
+ }
68890
+ }
68891
+ });
68892
+ sessions.set(sessionId, session);
68893
+ return sessionId;
68894
+ }
68895
+ function attach(sessionId, ws) {
68896
+ const session = sessions.get(sessionId);
68897
+ if (!session) return false;
68898
+ if (session.scrollback.length > 0) {
68899
+ ws.send(session.scrollback);
68900
+ }
68901
+ session.sockets.add(ws);
68902
+ ws.on("message", (data) => {
68903
+ try {
68904
+ const text84 = typeof data === "string" ? data : data.toString("utf8");
68905
+ const msg = JSON.parse(text84);
68906
+ if (msg.type === "resize" && typeof msg.cols === "number" && typeof msg.rows === "number") {
68907
+ session.pty.resize(msg.cols, msg.rows);
68908
+ return;
68909
+ }
68910
+ } catch {
68911
+ }
68912
+ const text83 = typeof data === "string" ? data : data.toString("utf8");
68913
+ session.pty.write(text83);
68914
+ });
68915
+ ws.on("close", () => {
68916
+ session.sockets.delete(ws);
68917
+ });
68918
+ ws.on("error", () => {
68919
+ session.sockets.delete(ws);
68920
+ });
68921
+ return true;
68922
+ }
68923
+ function kill(sessionId) {
68924
+ const session = sessions.get(sessionId);
68925
+ if (!session) return false;
68926
+ for (const ws of session.sockets) {
68927
+ try {
68928
+ ws.send(Buffer.from("\r\nSession closed.\r\n"));
68929
+ } catch {
68930
+ }
68931
+ }
68932
+ session.sockets.clear();
68933
+ session.pty.kill();
68934
+ sessions.delete(sessionId);
68935
+ return true;
68936
+ }
68937
+ function hasSession(sessionId) {
68938
+ return sessions.has(sessionId);
68939
+ }
68940
+ var require4, SCROLLBACK_LIMIT, sessions;
68941
+ var init_terminal_sessions = __esm({
68942
+ "../server/src/services/terminal-sessions.ts"() {
68943
+ "use strict";
68944
+ require4 = createRequire3(import.meta.url);
68945
+ SCROLLBACK_LIMIT = 256 * 1024;
68946
+ sessions = /* @__PURE__ */ new Map();
68947
+ }
68948
+ });
68949
+
68950
+ // ../server/src/routes/terminal.ts
68951
+ import { Router as Router28 } from "express";
68952
+ import { z as z34 } from "zod";
68953
+ function terminalRoutes() {
68954
+ const router = Router28();
68955
+ router.post("/terminal/sessions", (req, res) => {
68956
+ if (req.actor.type !== "board") {
68957
+ res.status(403).json({ error: "Board access required" });
68958
+ return;
68959
+ }
68960
+ const parsed = createSessionSchema2.safeParse(req.body);
68961
+ if (!parsed.success) {
68962
+ throw badRequest("Invalid request body");
68963
+ }
68964
+ const sessionId = createSession({ cols: parsed.data.cols, rows: parsed.data.rows });
68965
+ res.status(201).json({ sessionId });
68966
+ });
68967
+ router.delete("/terminal/sessions/:id", (req, res) => {
68968
+ if (req.actor.type !== "board") {
68969
+ res.status(403).json({ error: "Board access required" });
68970
+ return;
68971
+ }
68972
+ const { id } = req.params;
68973
+ if (!id) {
68974
+ throw badRequest("Missing session id");
68975
+ }
68976
+ const found = kill(id);
68977
+ if (!found) {
68978
+ throw notFound("Session not found");
68979
+ }
68980
+ res.status(204).send();
68981
+ });
68982
+ return router;
68983
+ }
68984
+ var createSessionSchema2;
68985
+ var init_terminal = __esm({
68986
+ "../server/src/routes/terminal.ts"() {
68987
+ "use strict";
68988
+ init_errors();
68989
+ init_terminal_sessions();
68990
+ createSessionSchema2 = z34.object({
68991
+ cols: z34.number().int().min(10).max(500).optional(),
68992
+ rows: z34.number().int().min(5).max(200).optional()
68993
+ });
68994
+ }
68995
+ });
68996
+
68841
68997
  // ../server/src/services/local-tool-install.ts
68842
68998
  import fs51 from "node:fs/promises";
68843
68999
  import os27 from "node:os";
@@ -68994,7 +69150,7 @@ var init_local_tool_install = __esm({
68994
69150
  });
68995
69151
 
68996
69152
  // ../server/src/routes/local-tools.ts
68997
- import { Router as Router28 } from "express";
69153
+ import { Router as Router29 } from "express";
68998
69154
  function assertCanManageInstanceSettings2(req) {
68999
69155
  if (req.actor.type !== "board") {
69000
69156
  throw forbidden("Board access required");
@@ -69005,7 +69161,7 @@ function assertCanManageInstanceSettings2(req) {
69005
69161
  throw forbidden("Instance admin access required");
69006
69162
  }
69007
69163
  function localToolsRoutes(db) {
69008
- const router = Router28();
69164
+ const router = Router29();
69009
69165
  const svc = instanceSettingsService(db);
69010
69166
  router.get("/instance/local-tools", async (req, res) => {
69011
69167
  if (req.actor.type !== "board") {
@@ -69102,9 +69258,9 @@ var init_local_tools2 = __esm({
69102
69258
  });
69103
69259
 
69104
69260
  // ../server/src/routes/license.ts
69105
- import { Router as Router29 } from "express";
69261
+ import { Router as Router30 } from "express";
69106
69262
  function licenseRoutes(db) {
69107
- const router = Router29();
69263
+ const router = Router30();
69108
69264
  router.post("/activate", async (req, res) => {
69109
69265
  const { license_key } = req.body;
69110
69266
  if (!license_key || typeof license_key !== "string" || !license_key.trim()) {
@@ -69159,13 +69315,13 @@ var init_license = __esm({
69159
69315
  });
69160
69316
 
69161
69317
  // ../server/src/routes/llms.ts
69162
- import { Router as Router30 } from "express";
69318
+ import { Router as Router31 } from "express";
69163
69319
  function hasCreatePermission(agent) {
69164
69320
  if (!agent.permissions || typeof agent.permissions !== "object") return false;
69165
69321
  return Boolean(agent.permissions.canCreateAgents);
69166
69322
  }
69167
69323
  function llmRoutes(db) {
69168
- const router = Router30();
69324
+ const router = Router31();
69169
69325
  const agentsSvc = agentService(db);
69170
69326
  async function assertCanRead(req) {
69171
69327
  if (req.actor.type === "board") return;
@@ -69242,7 +69398,7 @@ var init_llms = __esm({
69242
69398
  });
69243
69399
 
69244
69400
  // ../server/src/routes/assets.ts
69245
- import { Router as Router31 } from "express";
69401
+ import { Router as Router32 } from "express";
69246
69402
  import multer2 from "multer";
69247
69403
  import createDOMPurify from "dompurify";
69248
69404
  import { JSDOM } from "jsdom";
@@ -69303,7 +69459,7 @@ function sanitizeSvgBuffer(input) {
69303
69459
  }
69304
69460
  }
69305
69461
  function assetRoutes(db, storage) {
69306
- const router = Router31();
69462
+ const router = Router32();
69307
69463
  const svc = assetService(db);
69308
69464
  const assetUpload = multer2({
69309
69465
  storage: multer2.memoryStorage(),
@@ -69664,7 +69820,7 @@ import {
69664
69820
  import fs52 from "node:fs";
69665
69821
  import path62 from "node:path";
69666
69822
  import { fileURLToPath as fileURLToPath17 } from "node:url";
69667
- import { Router as Router32 } from "express";
69823
+ import { Router as Router33 } from "express";
69668
69824
  import { and as and54, eq as eq57, isNull as isNull16, desc as desc32 } from "drizzle-orm";
69669
69825
  function hashToken4(token) {
69670
69826
  return createHash20("sha256").update(token).digest("hex");
@@ -70744,7 +70900,7 @@ async function probeInviteResolutionTarget(url, timeoutMs) {
70744
70900
  }
70745
70901
  }
70746
70902
  function accessRoutes(db, opts) {
70747
- const router = Router32();
70903
+ const router = Router33();
70748
70904
  const access = accessService(db);
70749
70905
  const boardAuth = boardAuthService(db);
70750
70906
  const agents2 = agentService(db);
@@ -73954,11 +74110,11 @@ async function dispatchVoiceIntent(deps, input) {
73954
74110
  const chatSessionId = readNonEmpty(input.chatSessionId);
73955
74111
  const surface = input.surface ?? "voice";
73956
74112
  const correlationId = readNonEmpty(input.correlationId) ?? null;
73957
- const sessions = chatSessionService(db);
74113
+ const sessions2 = chatSessionService(db);
73958
74114
  const append = async (text83) => {
73959
74115
  if (!chatSessionId || !companyId) return;
73960
74116
  try {
73961
- await sessions.appendMessage(companyId, chatSessionId, {
74117
+ await sessions2.appendMessage(companyId, chatSessionId, {
73962
74118
  role: "system",
73963
74119
  content: [
73964
74120
  {
@@ -73996,7 +74152,7 @@ async function dispatchVoiceIntent(deps, input) {
73996
74152
  finish(text83, false);
73997
74153
  return;
73998
74154
  }
73999
- const jwt = createLocalAgentJwt(agentId, companyId, "claude_local", `${surface}-${randomUUID14()}`);
74155
+ const jwt = createLocalAgentJwt(agentId, companyId, "claude_local", randomUUID14());
74000
74156
  if (!jwt) {
74001
74157
  const text83 = "[paperclip: agent auth unavailable, try again after the call]";
74002
74158
  await append(text83);
@@ -74533,7 +74689,7 @@ var init_host_client_factory = __esm({
74533
74689
  });
74534
74690
 
74535
74691
  // ../packages/plugins/sdk/dist/index.js
74536
- import { z as z34 } from "zod";
74692
+ import { z as z35 } from "zod";
74537
74693
  var init_dist11 = __esm({
74538
74694
  "../packages/plugins/sdk/dist/index.js"() {
74539
74695
  "use strict";
@@ -74566,7 +74722,7 @@ function invalidSecretRef(secretRef) {
74566
74722
  return err;
74567
74723
  }
74568
74724
  function isUuid(value) {
74569
- return UUID_RE3.test(value);
74725
+ return UUID_RE4.test(value);
74570
74726
  }
74571
74727
  function collectSecretRefPaths(schema) {
74572
74728
  const paths = /* @__PURE__ */ new Set();
@@ -74730,14 +74886,14 @@ function createPluginSecretsHandler(options2) {
74730
74886
  }
74731
74887
  };
74732
74888
  }
74733
- var UUID_RE3, allowlistInvalidators;
74889
+ var UUID_RE4, allowlistInvalidators;
74734
74890
  var init_plugin_secrets_handler = __esm({
74735
74891
  "../server/src/services/plugin-secrets-handler.ts"() {
74736
74892
  "use strict";
74737
74893
  init_dist2();
74738
74894
  init_provider_registry();
74739
74895
  init_plugin_registry();
74740
- UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
74896
+ UUID_RE4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
74741
74897
  allowlistInvalidators = /* @__PURE__ */ new Map();
74742
74898
  }
74743
74899
  });
@@ -74906,7 +75062,7 @@ import { existsSync as existsSync10, readFileSync as readFileSync6 } from "node:
74906
75062
  import path64 from "node:path";
74907
75063
  import { randomUUID as randomUUID15 } from "node:crypto";
74908
75064
  import { fileURLToPath as fileURLToPath19 } from "node:url";
74909
- import { Router as Router33 } from "express";
75065
+ import { Router as Router34 } from "express";
74910
75066
  import { and as and58, desc as desc34, eq as eq61, gte as gte12 } from "drizzle-orm";
74911
75067
  function loadLocalBundledExamples() {
74912
75068
  const localFile = path64.resolve(REPO_ROOT, "server/local-bundled-plugin-examples.json");
@@ -74948,7 +75104,7 @@ async function resolvePlugin(registry, pluginId) {
74948
75104
  return registry.getByKey(pluginId);
74949
75105
  }
74950
75106
  function pluginRoutes(db, loader, jobDeps, webhookDeps, toolDeps, bridgeDeps) {
74951
- const router = Router33();
75107
+ const router = Router34();
74952
75108
  const registry = pluginRegistryService(db);
74953
75109
  const lifecycle = pluginLifecycleManager(db, {
74954
75110
  loader,
@@ -76404,7 +76560,7 @@ import fs53 from "node:fs";
76404
76560
  import { readFile as readFile6 } from "node:fs/promises";
76405
76561
  import path65 from "node:path";
76406
76562
  import { promisify as promisify10 } from "node:util";
76407
- import { Router as Router34 } from "express";
76563
+ import { Router as Router35 } from "express";
76408
76564
  function resolveAdapterPackageDir(record) {
76409
76565
  return record.localPath ? path65.resolve(record.localPath) : path65.resolve(getAdapterPluginsDir(), "node_modules", record.packageName);
76410
76566
  }
@@ -76460,7 +76616,7 @@ function registerWithSessionManagement(adapter) {
76460
76616
  registerServerAdapter(wrapped);
76461
76617
  }
76462
76618
  function adapterRoutes() {
76463
- const router = Router34();
76619
+ const router = Router35();
76464
76620
  router.get("/adapters", async (_req, res) => {
76465
76621
  assertBoard(_req);
76466
76622
  const registeredAdapters = listServerAdapters();
@@ -76789,10 +76945,10 @@ var init_adapters3 = __esm({
76789
76945
  });
76790
76946
 
76791
76947
  // ../server/src/routes/plugin-ui-static.ts
76792
- import { Router as Router35 } from "express";
76948
+ import { Router as Router36 } from "express";
76793
76949
  import path66 from "node:path";
76794
76950
  import fs54 from "node:fs";
76795
- import crypto5 from "node:crypto";
76951
+ import crypto6 from "node:crypto";
76796
76952
  function resolvePluginUiDir(localPluginDir, packageName, entrypointsUi, packagePath) {
76797
76953
  if (packagePath) {
76798
76954
  const resolvedPackagePath = path66.resolve(packagePath);
@@ -76825,11 +76981,11 @@ function resolvePluginUiDir(localPluginDir, packageName, entrypointsUi, packageP
76825
76981
  }
76826
76982
  function computeETag(size, mtimeMs) {
76827
76983
  const ETAG_VERSION = "v2";
76828
- const hash = crypto5.createHash("md5").update(`${ETAG_VERSION}:${size}-${mtimeMs}`).digest("hex").slice(0, 16);
76984
+ const hash = crypto6.createHash("md5").update(`${ETAG_VERSION}:${size}-${mtimeMs}`).digest("hex").slice(0, 16);
76829
76985
  return `"${hash}"`;
76830
76986
  }
76831
76987
  function pluginUiStaticRoutes(db, options2) {
76832
- const router = Router35();
76988
+ const router = Router36();
76833
76989
  const registry = pluginRegistryService(db);
76834
76990
  const log12 = logger.child({ service: "plugin-ui-static" });
76835
76991
  router.get("/_plugins/:pluginId/ui/*filePath", async (req, res) => {
@@ -79209,112 +79365,126 @@ function pluginChatHostBridge(db) {
79209
79365
  }));
79210
79366
  },
79211
79367
  async triage(input) {
79212
- const { companyId, message, history, sessionId, userMessageId, mode, surface, previousProposalFingerprints } = input;
79213
- const [session, general] = await Promise.all([
79214
- sessionId ? sessionSvc.getSession(companyId, sessionId) : Promise.resolve(null),
79215
- instanceSettings2.getGeneral()
79216
- ]);
79217
- if (sessionId && !session) {
79218
- throw new Error("session_not_found");
79219
- }
79220
- const adapterTypeForTriage = normalizeChatAdapterType(
79221
- session?.adapterType ?? general.defaultChatAdapterType ?? CHAT_TRIAGE_ADAPTER_TYPE2
79222
- );
79223
- const modelForTriage = session?.model ?? general.defaultChatModel ?? void 0;
79224
- let validatedModelForTriage;
79368
+ let deadlineTimer;
79369
+ const deadline = new Promise((_, reject) => {
79370
+ deadlineTimer = setTimeout(
79371
+ () => reject(new Error("triage_timeout")),
79372
+ TRIAGE_RPC_DEADLINE_MS
79373
+ );
79374
+ });
79225
79375
  try {
79226
- validatedModelForTriage = await validateChatModelSelection(adapterTypeForTriage, modelForTriage, {
79227
- allowFallback: true
79376
+ return await Promise.race([runTriage(), deadline]);
79377
+ } finally {
79378
+ if (deadlineTimer) clearTimeout(deadlineTimer);
79379
+ }
79380
+ async function runTriage() {
79381
+ const { companyId, message, history, sessionId, userMessageId, mode, surface, previousProposalFingerprints } = input;
79382
+ const [session, general] = await Promise.all([
79383
+ sessionId ? sessionSvc.getSession(companyId, sessionId) : Promise.resolve(null),
79384
+ instanceSettings2.getGeneral()
79385
+ ]);
79386
+ if (sessionId && !session) {
79387
+ throw new Error("session_not_found");
79388
+ }
79389
+ const adapterTypeForTriage = normalizeChatAdapterType(
79390
+ session?.adapterType ?? general.defaultChatAdapterType ?? CHAT_TRIAGE_ADAPTER_TYPE2
79391
+ );
79392
+ const modelForTriage = session?.model ?? general.defaultChatModel ?? void 0;
79393
+ let validatedModelForTriage;
79394
+ try {
79395
+ validatedModelForTriage = await validateChatModelSelection(adapterTypeForTriage, modelForTriage, {
79396
+ allowFallback: true
79397
+ });
79398
+ } catch {
79399
+ validatedModelForTriage = void 0;
79400
+ }
79401
+ const result = await triageSvc.triage(companyId, message, history ?? [], {
79402
+ model: validatedModelForTriage,
79403
+ targetAgentId: session?.targetAgentId ?? null,
79404
+ adapterType: adapterTypeForTriage,
79405
+ mode,
79406
+ surface,
79407
+ previousProposalFingerprints
79228
79408
  });
79229
- } catch {
79230
- validatedModelForTriage = void 0;
79231
- }
79232
- const result = await triageSvc.triage(companyId, message, history ?? [], {
79233
- model: validatedModelForTriage,
79234
- targetAgentId: session?.targetAgentId ?? null,
79235
- adapterType: adapterTypeForTriage,
79236
- mode,
79237
- surface,
79238
- previousProposalFingerprints
79239
- });
79240
- let continuationRunId = null;
79241
- let continuationScheduled = false;
79242
- if (result.continuation && sessionId && userMessageId) {
79243
- const continuationSession = await sessionSvc.getSession(companyId, sessionId);
79244
- const preferredAgentId = result.continuation.preferredAgentId ?? continuationSession?.targetAgentId ?? await db.select({ id: agents.id }).from(agents).where(
79245
- and61(
79246
- eq64(agents.companyId, companyId),
79247
- ne12(agents.status, "terminated"),
79248
- ne12(agents.status, "paused"),
79249
- ne12(agents.status, "pending_approval")
79250
- )
79251
- ).limit(1).then((rows) => rows[0]?.id ?? null);
79252
- if (continuationSession && preferredAgentId) {
79253
- try {
79254
- const wakeRun = await heartbeat2.wakeup(preferredAgentId, {
79255
- source: "on_demand",
79256
- triggerDetail: "manual",
79257
- reason: "chat_continuation",
79258
- idempotencyKey: `chat-continuation:${sessionId}:${userMessageId}`,
79259
- requestedByActorType: "user",
79260
- requestedByActorId: "chat_session",
79261
- payload: {
79262
- chatSessionId: sessionId,
79263
- chatUserMessageId: userMessageId,
79264
- chatContinuationReason: result.continuation.reason,
79265
- chatContinuationPrompt: result.continuation.followUpPrompt
79266
- },
79267
- contextSnapshot: {
79268
- wakeReason: "chat_continuation",
79269
- taskKey: `chat-session:${sessionId}`,
79270
- chatSessionId: sessionId,
79271
- chatUserMessageId: userMessageId,
79272
- chatContinuationReason: result.continuation.reason,
79273
- chatContinuationPrompt: result.continuation.followUpPrompt,
79274
- executionStage: {
79275
- kind: "chat_continuation",
79276
- sessionId,
79277
- userMessageId,
79278
- reason: result.continuation.reason,
79279
- followUpPrompt: result.continuation.followUpPrompt,
79280
- initialReply: result.reply
79409
+ let continuationRunId = null;
79410
+ let continuationScheduled = false;
79411
+ if (result.continuation && sessionId && userMessageId) {
79412
+ const continuationSession = await sessionSvc.getSession(companyId, sessionId);
79413
+ const preferredAgentId = result.continuation.preferredAgentId ?? continuationSession?.targetAgentId ?? await db.select({ id: agents.id }).from(agents).where(
79414
+ and61(
79415
+ eq64(agents.companyId, companyId),
79416
+ ne12(agents.status, "terminated"),
79417
+ ne12(agents.status, "paused"),
79418
+ ne12(agents.status, "pending_approval")
79419
+ )
79420
+ ).limit(1).then((rows) => rows[0]?.id ?? null);
79421
+ if (continuationSession && preferredAgentId) {
79422
+ try {
79423
+ const wakeRun = await heartbeat2.wakeup(preferredAgentId, {
79424
+ source: "on_demand",
79425
+ triggerDetail: "manual",
79426
+ reason: "chat_continuation",
79427
+ idempotencyKey: `chat-continuation:${sessionId}:${userMessageId}`,
79428
+ requestedByActorType: "user",
79429
+ requestedByActorId: "chat_session",
79430
+ payload: {
79431
+ chatSessionId: sessionId,
79432
+ chatUserMessageId: userMessageId,
79433
+ chatContinuationReason: result.continuation.reason,
79434
+ chatContinuationPrompt: result.continuation.followUpPrompt
79435
+ },
79436
+ contextSnapshot: {
79437
+ wakeReason: "chat_continuation",
79438
+ taskKey: `chat-session:${sessionId}`,
79439
+ chatSessionId: sessionId,
79440
+ chatUserMessageId: userMessageId,
79441
+ chatContinuationReason: result.continuation.reason,
79442
+ chatContinuationPrompt: result.continuation.followUpPrompt,
79443
+ executionStage: {
79444
+ kind: "chat_continuation",
79445
+ sessionId,
79446
+ userMessageId,
79447
+ reason: result.continuation.reason,
79448
+ followUpPrompt: result.continuation.followUpPrompt,
79449
+ initialReply: result.reply
79450
+ }
79281
79451
  }
79452
+ });
79453
+ if (wakeRun) {
79454
+ continuationRunId = wakeRun.id;
79455
+ continuationScheduled = true;
79456
+ await sessionSvc.setContinuationState(companyId, sessionId, {
79457
+ status: "queued",
79458
+ runId: wakeRun.id,
79459
+ error: null
79460
+ });
79282
79461
  }
79283
- });
79284
- if (wakeRun) {
79285
- continuationRunId = wakeRun.id;
79286
- continuationScheduled = true;
79462
+ } catch {
79463
+ continuationScheduled = false;
79287
79464
  await sessionSvc.setContinuationState(companyId, sessionId, {
79288
- status: "queued",
79289
- runId: wakeRun.id,
79290
- error: null
79465
+ status: "failed",
79466
+ runId: null,
79467
+ error: "Could not schedule deferred follow-up"
79291
79468
  });
79292
79469
  }
79293
- } catch {
79294
- continuationScheduled = false;
79470
+ } else if (continuationSession) {
79295
79471
  await sessionSvc.setContinuationState(companyId, sessionId, {
79296
79472
  status: "failed",
79297
79473
  runId: null,
79298
- error: "Could not schedule deferred follow-up"
79474
+ error: "No invokable agent available for deferred follow-up"
79299
79475
  });
79300
79476
  }
79301
- } else if (continuationSession) {
79302
- await sessionSvc.setContinuationState(companyId, sessionId, {
79303
- status: "failed",
79304
- runId: null,
79305
- error: "No invokable agent available for deferred follow-up"
79306
- });
79307
79477
  }
79478
+ return {
79479
+ ...result,
79480
+ continuationRunId,
79481
+ continuationScheduled
79482
+ };
79308
79483
  }
79309
- return {
79310
- ...result,
79311
- continuationRunId,
79312
- continuationScheduled
79313
- };
79314
79484
  }
79315
79485
  };
79316
79486
  }
79317
- var CHAT_TRIAGE_ADAPTER_TYPE2, CHAT_SAFE_ADAPTER_TYPES2, LEGACY_MODEL_ALIASES2;
79487
+ var CHAT_TRIAGE_ADAPTER_TYPE2, TRIAGE_RPC_DEADLINE_MS, CHAT_SAFE_ADAPTER_TYPES2, LEGACY_MODEL_ALIASES2;
79318
79488
  var init_plugin_chat_host_bridge = __esm({
79319
79489
  "../server/src/services/plugin-chat-host-bridge.ts"() {
79320
79490
  "use strict";
@@ -79326,6 +79496,7 @@ var init_plugin_chat_host_bridge = __esm({
79326
79496
  init_instance_settings2();
79327
79497
  init_issue_suggestions();
79328
79498
  CHAT_TRIAGE_ADAPTER_TYPE2 = process.env.PAPERCLIP_CHAT_TRIAGE_ADAPTER_TYPE ?? "claude_local";
79499
+ TRIAGE_RPC_DEADLINE_MS = 15e4;
79329
79500
  CHAT_SAFE_ADAPTER_TYPES2 = ["claude_local", "cursor", "codex_local", "gemini_local"];
79330
79501
  LEGACY_MODEL_ALIASES2 = {
79331
79502
  "claude-haiku-4-5": ["claude-haiku-4-5-20251001"],
@@ -80844,7 +81015,7 @@ var init_plugin_host_service_cleanup = __esm({
80844
81015
  });
80845
81016
 
80846
81017
  // ../server/src/app.ts
80847
- import express, { Router as Router36 } from "express";
81018
+ import express, { Router as Router37 } from "express";
80848
81019
  import path68 from "node:path";
80849
81020
  import fs55 from "node:fs";
80850
81021
  import { fileURLToPath as fileURLToPath20 } from "node:url";
@@ -80924,7 +81095,7 @@ async function createApp(db, opts) {
80924
81095
  app.all("/api/auth/{*authPath}", opts.betterAuthHandler);
80925
81096
  }
80926
81097
  app.use(llmRoutes(db));
80927
- const api = Router36();
81098
+ const api = Router37();
80928
81099
  api.use(boardMutationGuard());
80929
81100
  api.use(
80930
81101
  "/health",
@@ -80968,6 +81139,7 @@ async function createApp(db, opts) {
80968
81139
  api.use(sidebarBadgeRoutes(db));
80969
81140
  api.use(inboxDismissalRoutes(db));
80970
81141
  api.use(instanceSettingsRoutes(db));
81142
+ api.use(terminalRoutes());
80971
81143
  api.use(localToolsRoutes(db));
80972
81144
  api.use("/instance/license", licenseRoutes(db));
80973
81145
  const eventBus = createPluginEventBus();
@@ -81202,6 +81374,7 @@ var init_app = __esm({
81202
81374
  init_sidebar_badges2();
81203
81375
  init_inbox_dismissals3();
81204
81376
  init_instance_settings3();
81377
+ init_terminal();
81205
81378
  init_local_tools2();
81206
81379
  init_license();
81207
81380
  init_llms();
@@ -81236,7 +81409,7 @@ var init_app = __esm({
81236
81409
 
81237
81410
  // ../server/src/realtime/live-events-ws.ts
81238
81411
  import { createHash as createHash21 } from "node:crypto";
81239
- import { createRequire as createRequire3 } from "node:module";
81412
+ import { createRequire as createRequire4 } from "node:module";
81240
81413
  import { and as and64, eq as eq67, isNull as isNull18 } from "drizzle-orm";
81241
81414
  function hashToken5(token) {
81242
81415
  return createHash21("sha256").update(token).digest("hex");
@@ -81376,7 +81549,6 @@ function setupLiveEventsWebSocketServer(server, db, opts) {
81376
81549
  const url = new URL(req.url, "http://localhost");
81377
81550
  const companyId = parseCompanyId(url.pathname);
81378
81551
  if (!companyId) {
81379
- socket.destroy();
81380
81552
  return;
81381
81553
  }
81382
81554
  void authorizeUpgrade(db, req, companyId, url, {
@@ -81399,15 +81571,80 @@ function setupLiveEventsWebSocketServer(server, db, opts) {
81399
81571
  });
81400
81572
  return wss;
81401
81573
  }
81402
- var require4, WebSocket3, WebSocketServer;
81574
+ var require5, WebSocket3, WebSocketServer;
81403
81575
  var init_live_events_ws = __esm({
81404
81576
  "../server/src/realtime/live-events-ws.ts"() {
81405
81577
  "use strict";
81406
81578
  init_dist2();
81407
81579
  init_logger();
81408
81580
  init_live_events();
81409
- require4 = createRequire3(import.meta.url);
81410
- ({ WebSocket: WebSocket3, WebSocketServer } = require4("ws"));
81581
+ require5 = createRequire4(import.meta.url);
81582
+ ({ WebSocket: WebSocket3, WebSocketServer } = require5("ws"));
81583
+ }
81584
+ });
81585
+
81586
+ // ../server/src/realtime/terminal-ws.ts
81587
+ import { createRequire as createRequire5 } from "node:module";
81588
+ function parseSessionId(pathname) {
81589
+ const match = pathname.match(/^\/api\/terminal\/sessions\/([^/]+)\/stream$/);
81590
+ if (!match) return null;
81591
+ try {
81592
+ return decodeURIComponent(match[1] ?? "");
81593
+ } catch {
81594
+ return null;
81595
+ }
81596
+ }
81597
+ function rejectUpgrade2(socket, statusLine, message) {
81598
+ const safe = message.replace(/[\r\n]+/g, " ").trim();
81599
+ socket.write(`HTTP/1.1 ${statusLine}\r
81600
+ Connection: close\r
81601
+ Content-Type: text/plain\r
81602
+ \r
81603
+ ${safe}`);
81604
+ socket.destroy();
81605
+ }
81606
+ function setupTerminalWebSocketServer(server) {
81607
+ const wss = new WebSocketServer2({ noServer: true });
81608
+ wss.on("connection", (ws, req) => {
81609
+ if (!req.url) {
81610
+ ws.on("error", () => {
81611
+ });
81612
+ return;
81613
+ }
81614
+ const url = new URL(req.url, "http://localhost");
81615
+ const sessionId = parseSessionId(url.pathname);
81616
+ if (!sessionId) {
81617
+ return;
81618
+ }
81619
+ const ok = attach(sessionId, ws);
81620
+ if (!ok) {
81621
+ ws.send(Buffer.from("\r\nSession not found.\r\n"));
81622
+ }
81623
+ });
81624
+ server.on("upgrade", (req, socket, head) => {
81625
+ if (!req.url) return;
81626
+ const url = new URL(req.url, "http://localhost");
81627
+ const sessionId = parseSessionId(url.pathname);
81628
+ if (!sessionId) return;
81629
+ if (!hasSession(sessionId)) {
81630
+ rejectUpgrade2(socket, "404 Not Found", "session not found");
81631
+ return;
81632
+ }
81633
+ wss.handleUpgrade(req, socket, head, (ws) => {
81634
+ wss.emit("connection", ws, req);
81635
+ });
81636
+ });
81637
+ logger.info("Terminal WebSocket server ready");
81638
+ return wss;
81639
+ }
81640
+ var require6, WebSocketServer2;
81641
+ var init_terminal_ws = __esm({
81642
+ "../server/src/realtime/terminal-ws.ts"() {
81643
+ "use strict";
81644
+ init_terminal_sessions();
81645
+ init_logger();
81646
+ require6 = createRequire5(import.meta.url);
81647
+ ({ WebSocketServer: WebSocketServer2 } = require6("ws"));
81411
81648
  }
81412
81649
  });
81413
81650
 
@@ -82092,6 +82329,7 @@ async function startServer() {
82092
82329
  deploymentMode: config.deploymentMode,
82093
82330
  resolveSessionFromHeaders
82094
82331
  });
82332
+ setupTerminalWebSocketServer(server);
82095
82333
  void reconcilePersistedRuntimeServicesOnStartup(db).then((result) => {
82096
82334
  if (result.reconciled > 0) {
82097
82335
  logger.warn(
@@ -82263,6 +82501,7 @@ var init_src = __esm({
82263
82501
  init_config3();
82264
82502
  init_logger();
82265
82503
  init_live_events_ws();
82504
+ init_terminal_ws();
82266
82505
  init_services();
82267
82506
  init_backup_scheduler();
82268
82507
  init_feedback_share_client();