@keystrokehq/cli 0.1.185 → 0.1.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-DiodbrVj.mjs";
3
- import { $a as number, Ba as ZodType, Ga as array, Ha as _function, Ja as discriminatedUnion, Ka as boolean$1, Mn as PROJECT_MANIFEST_REL_PATH, Qa as looseObject, Qt as ListBrainDocumentsQuerySchema, Ra as number$1, Ta as PublicModelsResponseSchema, Ua as _null, Va as _enum, Wa as any, Xa as lazy, Ya as intersection, Za as literal, _a as normalizeCredentialList, ao as union, co as datetime, eo as object, fr as PromptResponseSchema, g as BrainDocumentIdSchema, ga as getOpenApiJsonSchema, ha as credentialInputSchema, io as string, lo as safeParse$1, no as preprocess, nr as ProjectArtifactIndexSchema, oo as unknown, qa as custom, ra as parseStoredRouteManifest, ro as record, sa as zodToStoredJsonSchema, so as url, ta as parseProjectManifest, to as optional, uo as NEVER, va as requiredDisplayTextSchema, ya as DEFAULT_CLOUD_PLATFORM_ORIGIN, za as ZodIssueCode } from "./dist-BHaxjUlc.mjs";
3
+ import { $a as lazy, Fn as PROJECT_MANIFEST_REL_PATH, Ga as _function, Ha as ZodIssueCode, Ja as array, Ka as _null, Oa as PublicModelsResponseSchema, Qa as intersection, Sa as DEFAULT_CLOUD_PLATFORM_ORIGIN, Ua as ZodType, Va as number$1, Wa as _enum, Xa as custom, Ya as boolean$1, Za as discriminatedUnion, ao as preprocess, ar as ProjectArtifactIndexSchema, ba as normalizeCredentialList, co as union, do as datetime, eo as literal, fo as safeParse$1, hr as PromptResponseSchema, ia as parseProjectManifest, io as optional, lo as unknown, no as number, oa as parseStoredRouteManifest, oo as record, po as NEVER, qa as any, ro as object, so as string, tn as ListBrainDocumentsQuerySchema, to as looseObject, ua as zodToStoredJsonSchema, uo as url, va as credentialInputSchema, xa as requiredDisplayTextSchema, y as BrainDocumentIdSchema, ya as getOpenApiJsonSchema } from "./dist-CyMQwFFx.mjs";
4
4
  import "./chunk-4RUAZWKT-D60fyWAB.mjs";
5
5
  import "./chunk-SAI2SPQQ-CVRoDNs9.mjs";
6
6
  import "./chunk-WNH3HOQA-BCZUOjCJ.mjs";
@@ -25691,7 +25691,8 @@ const projectRepositoriesSqlite = sqliteTable("project_repositories", {
25691
25691
  ]);
25692
25692
  /**
25693
25693
  * Control-plane platform-agent conversation (org `/chat`).
25694
- * Durable history lives in `platform_agent_events`; Redis holds in-flight streams.
25694
+ * Durable history lives in `platform_agent_events` (V1) or message snapshots (V2);
25695
+ * Redis holds in-flight streams.
25695
25696
  */
25696
25697
  const platformAgentSessions = pgTable("platform_agent_sessions", {
25697
25698
  id: text$1("id").primaryKey(),
@@ -25701,6 +25702,8 @@ const platformAgentSessions = pgTable("platform_agent_sessions", {
25701
25702
  status: text$1("status").$type().notNull(),
25702
25703
  title: text$1("title"),
25703
25704
  model: text$1("model"),
25705
+ storageVersion: integer$1("storage_version").$type().notNull().default(1),
25706
+ activePromptId: text$1("active_prompt_id"),
25704
25707
  activeRunId: text$1("active_run_id"),
25705
25708
  lastDraftCommitSha: text$1("last_draft_commit_sha"),
25706
25709
  sandboxId: text$1("sandbox_id"),
@@ -25724,6 +25727,8 @@ const platformAgentSessionsSqlite = sqliteTable("platform_agent_sessions", {
25724
25727
  status: text("status").$type().notNull(),
25725
25728
  title: text("title"),
25726
25729
  model: text("model"),
25730
+ storageVersion: integer("storage_version").$type().notNull().default(1),
25731
+ activePromptId: text("active_prompt_id"),
25727
25732
  activeRunId: text("active_run_id"),
25728
25733
  lastDraftCommitSha: text("last_draft_commit_sha"),
25729
25734
  sandboxId: text("sandbox_id"),
@@ -25763,6 +25768,85 @@ const platformAgentEventsSqlite = sqliteTable("platform_agent_events", {
25763
25768
  deletedAt: integer("deleted_at", { mode: "timestamp_ms" })
25764
25769
  }, (table) => [index("platform_agent_events_organization_id_idx").on(table.organizationId), index("platform_agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
25765
25770
  /**
25771
+ * Immutable durable-pass message snapshots for platform-agent storageVersion ≥ 2.
25772
+ * Approval/suspension tables remain tenant-only until the platform agent exposes
25773
+ * those tool types.
25774
+ */
25775
+ const platformAgentMessages = pgTable("platform_agent_messages", {
25776
+ id: text$1("id").primaryKey(),
25777
+ organizationId: text$1("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
25778
+ sessionId: text$1("session_id").notNull().references(() => platformAgentSessions.id, { onDelete: "cascade" }),
25779
+ promptId: text$1("prompt_id"),
25780
+ role: text$1("role").$type().notNull(),
25781
+ parts: jsonb("parts").notNull(),
25782
+ durablePassIndex: integer$1("durable_pass_index"),
25783
+ ordinal: integer$1("ordinal").notNull(),
25784
+ legacyEventId: text$1("legacy_event_id"),
25785
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
25786
+ }, (table) => [index$1("platform_agent_messages_session_ordinal_idx").on(table.sessionId, table.ordinal), uniqueIndex$1("platform_agent_messages_session_ordinal_unique").on(table.sessionId, table.ordinal)]);
25787
+ const platformAgentMessagesSqlite = sqliteTable("platform_agent_messages", {
25788
+ id: text("id").primaryKey(),
25789
+ organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
25790
+ sessionId: text("session_id").notNull().references(() => platformAgentSessionsSqlite.id, { onDelete: "cascade" }),
25791
+ promptId: text("prompt_id"),
25792
+ role: text("role").$type().notNull(),
25793
+ parts: text("parts", { mode: "json" }).notNull(),
25794
+ durablePassIndex: integer("durable_pass_index"),
25795
+ ordinal: integer("ordinal").notNull(),
25796
+ legacyEventId: text("legacy_event_id"),
25797
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
25798
+ }, (table) => [index("platform_agent_messages_session_ordinal_idx").on(table.sessionId, table.ordinal), uniqueIndex("platform_agent_messages_session_ordinal_unique").on(table.sessionId, table.ordinal)]);
25799
+ const platformAgentContextCompactions = pgTable("platform_agent_context_compactions", {
25800
+ id: text$1("id").primaryKey(),
25801
+ organizationId: text$1("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
25802
+ sessionId: text$1("session_id").notNull().references(() => platformAgentSessions.id, { onDelete: "cascade" }),
25803
+ parentCheckpointId: text$1("parent_checkpoint_id"),
25804
+ promptId: text$1("prompt_id"),
25805
+ status: text$1("status").$type().notNull(),
25806
+ durable: boolean("durable").notNull().default(true),
25807
+ summary: text$1("summary").notNull(),
25808
+ structuredSummary: jsonb("structured_summary"),
25809
+ summarySchemaVersion: integer$1("summary_schema_version"),
25810
+ summaryPromptVersion: integer$1("summary_prompt_version"),
25811
+ compactedThroughOrdinal: integer$1("compacted_through_ordinal").notNull(),
25812
+ compactedThroughMessageId: text$1("compacted_through_message_id").notNull(),
25813
+ firstKeptMessageId: text$1("first_kept_message_id"),
25814
+ sourceRangeDigest: text$1("source_range_digest").notNull(),
25815
+ sourceModelId: text$1("source_model_id").notNull(),
25816
+ compactionModelId: text$1("compaction_model_id").notNull(),
25817
+ triggerReason: text$1("trigger_reason").$type().notNull(),
25818
+ estimatedBeforeTokens: integer$1("estimated_before_tokens"),
25819
+ actualBeforeTokens: integer$1("actual_before_tokens"),
25820
+ estimatedAfterTokens: integer$1("estimated_after_tokens"),
25821
+ usage: jsonb("usage"),
25822
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
25823
+ }, (table) => [index$1("platform_agent_context_compactions_session_status_idx").on(table.sessionId, table.status)]);
25824
+ const platformAgentContextCompactionsSqlite = sqliteTable("platform_agent_context_compactions", {
25825
+ id: text("id").primaryKey(),
25826
+ organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
25827
+ sessionId: text("session_id").notNull().references(() => platformAgentSessionsSqlite.id, { onDelete: "cascade" }),
25828
+ parentCheckpointId: text("parent_checkpoint_id"),
25829
+ promptId: text("prompt_id"),
25830
+ status: text("status").$type().notNull(),
25831
+ durable: integer("durable", { mode: "boolean" }).notNull().default(true),
25832
+ summary: text("summary").notNull(),
25833
+ structuredSummary: text("structured_summary", { mode: "json" }),
25834
+ summarySchemaVersion: integer("summary_schema_version"),
25835
+ summaryPromptVersion: integer("summary_prompt_version"),
25836
+ compactedThroughOrdinal: integer("compacted_through_ordinal").notNull(),
25837
+ compactedThroughMessageId: text("compacted_through_message_id").notNull(),
25838
+ firstKeptMessageId: text("first_kept_message_id"),
25839
+ sourceRangeDigest: text("source_range_digest").notNull(),
25840
+ sourceModelId: text("source_model_id").notNull(),
25841
+ compactionModelId: text("compaction_model_id").notNull(),
25842
+ triggerReason: text("trigger_reason").$type().notNull(),
25843
+ estimatedBeforeTokens: integer("estimated_before_tokens"),
25844
+ actualBeforeTokens: integer("actual_before_tokens"),
25845
+ estimatedAfterTokens: integer("estimated_after_tokens"),
25846
+ usage: text("usage", { mode: "json" }),
25847
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
25848
+ }, (table) => [index("platform_agent_context_compactions_session_status_idx").on(table.sessionId, table.status)]);
25849
+ /**
25766
25850
  * Per-project Modal filesystem snapshot for platform-agent cold boots.
25767
25851
  * One row per project; coalesce rebuilds via `build_status` + `build_started_at`.
25768
25852
  * When `recovery_state` is set, `modal_image_id` is the dirty recovery image
@@ -26230,7 +26314,16 @@ const agentSessions = pgTable("agent_sessions", {
26230
26314
  ranByUserId: text$1("ran_by_user_id"),
26231
26315
  title: text$1("title"),
26232
26316
  canceledAt: timestamp("canceled_at", { withTimezone: true }),
26317
+ cancelRequestedAt: timestamp("cancel_requested_at", { withTimezone: true }),
26233
26318
  status: text$1("status").$type(),
26319
+ activePromptId: text$1("active_prompt_id"),
26320
+ activeRunId: text$1("active_run_id"),
26321
+ activeSuspensionId: text$1("active_suspension_id"),
26322
+ executionGeneration: integer$1("execution_generation").notNull().default(0),
26323
+ headMessageId: text$1("head_message_id"),
26324
+ nextMessageOrdinal: integer$1("next_message_ordinal").notNull().default(1),
26325
+ forkedFromSessionId: text$1("forked_from_session_id"),
26326
+ forkedFromMessageId: text$1("forked_from_message_id"),
26234
26327
  totalDurationMs: integer$1("total_duration_ms").notNull().default(0),
26235
26328
  createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
26236
26329
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
@@ -26251,7 +26344,16 @@ const agentSessionsSqlite = sqliteTable("agent_sessions", {
26251
26344
  ranByUserId: text("ran_by_user_id"),
26252
26345
  title: text("title"),
26253
26346
  canceledAt: integer("canceled_at", { mode: "timestamp_ms" }),
26347
+ cancelRequestedAt: integer("cancel_requested_at", { mode: "timestamp_ms" }),
26254
26348
  status: text("status").$type(),
26349
+ activePromptId: text("active_prompt_id"),
26350
+ activeRunId: text("active_run_id"),
26351
+ activeSuspensionId: text("active_suspension_id"),
26352
+ executionGeneration: integer("execution_generation").notNull().default(0),
26353
+ headMessageId: text("head_message_id"),
26354
+ nextMessageOrdinal: integer("next_message_ordinal").notNull().default(1),
26355
+ forkedFromSessionId: text("forked_from_session_id"),
26356
+ forkedFromMessageId: text("forked_from_message_id"),
26255
26357
  totalDurationMs: integer("total_duration_ms").notNull().default(0),
26256
26358
  createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
26257
26359
  updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull(),
@@ -26281,6 +26383,234 @@ const agentEventsSqlite = sqliteTable("agent_events", {
26281
26383
  createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
26282
26384
  deletedAt: integer("deleted_at", { mode: "timestamp_ms" })
26283
26385
  }, (table) => [index("agent_events_organization_id_idx").on(table.organizationId), index("agent_events_session_event_seq_idx").on(table.sessionId, table.eventType, table.seq)]);
26386
+ const agentMessages = pgTable("agent_messages", {
26387
+ id: text$1("id").primaryKey(),
26388
+ organizationId: text$1("organization_id").notNull().references(() => organizations.id),
26389
+ sessionId: text$1("session_id").notNull().references(() => agentSessions.id),
26390
+ /** Prompt that produced this message; nullable for ambiguous legacy rows. */
26391
+ promptId: text$1("prompt_id"),
26392
+ role: text$1("role").$type().notNull(),
26393
+ /** AI SDK-compatible UIMessage parts / content snapshot. */
26394
+ parts: jsonb("parts").notNull(),
26395
+ /** Keystroke-owned stored UIMessage payload schema. */
26396
+ schemaVersion: integer$1("schema_version").notNull().default(1),
26397
+ /** Semantic ancestry; null only for the root message. */
26398
+ parentMessageId: text$1("parent_message_id"),
26399
+ /** Why this model boundary ended; null for user/system and migrated legacy rows. */
26400
+ finishReason: text$1("finish_reason").$type(),
26401
+ /** Per-session ordering; allocated under the active-prompt lock. */
26402
+ ordinal: integer$1("ordinal").notNull(),
26403
+ /** Legacy event identity when migrated from agent_events. */
26404
+ legacyEventId: text$1("legacy_event_id"),
26405
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
26406
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
26407
+ }, (table) => [
26408
+ index$1("agent_messages_organization_id_idx").on(table.organizationId),
26409
+ index$1("agent_messages_session_ordinal_idx").on(table.sessionId, table.ordinal),
26410
+ uniqueIndex$1("agent_messages_session_ordinal_unique").on(table.sessionId, table.ordinal),
26411
+ tenantOrganizationPolicy(table.organizationId)
26412
+ ]).enableRLS();
26413
+ const agentMessagesSqlite = sqliteTable("agent_messages", {
26414
+ id: text("id").primaryKey(),
26415
+ organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id),
26416
+ sessionId: text("session_id").notNull().references(() => agentSessionsSqlite.id),
26417
+ promptId: text("prompt_id"),
26418
+ role: text("role").$type().notNull(),
26419
+ parts: text("parts", { mode: "json" }).notNull(),
26420
+ schemaVersion: integer("schema_version").notNull().default(1),
26421
+ parentMessageId: text("parent_message_id"),
26422
+ finishReason: text("finish_reason").$type(),
26423
+ ordinal: integer("ordinal").notNull(),
26424
+ legacyEventId: text("legacy_event_id"),
26425
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
26426
+ deletedAt: integer("deleted_at", { mode: "timestamp_ms" })
26427
+ }, (table) => [
26428
+ index("agent_messages_organization_id_idx").on(table.organizationId),
26429
+ index("agent_messages_session_ordinal_idx").on(table.sessionId, table.ordinal),
26430
+ uniqueIndex("agent_messages_session_ordinal_unique").on(table.sessionId, table.ordinal)
26431
+ ]);
26432
+ const agentToolCalls = pgTable("agent_tool_calls", {
26433
+ id: text$1("id").primaryKey(),
26434
+ organizationId: text$1("organization_id").notNull().references(() => organizations.id),
26435
+ sessionId: text$1("session_id").notNull().references(() => agentSessions.id),
26436
+ toolCallId: text$1("tool_call_id").notNull(),
26437
+ assistantMessageId: text$1("assistant_message_id").references(() => agentMessages.id),
26438
+ promptId: text$1("prompt_id").notNull(),
26439
+ toolName: text$1("tool_name").notNull(),
26440
+ input: jsonb("input").notNull(),
26441
+ approvalRequired: boolean("approval_required").notNull().default(false),
26442
+ approvalId: text$1("approval_id"),
26443
+ approvalDecision: text$1("approval_decision").$type(),
26444
+ approvalReason: text$1("approval_reason"),
26445
+ approvalResponderId: text$1("approval_responder_id"),
26446
+ approvalRespondedAt: timestamp("approval_responded_at", { withTimezone: true }),
26447
+ status: text$1("status").$type().notNull(),
26448
+ childKind: text$1("child_kind").$type(),
26449
+ childRunId: text$1("child_run_id"),
26450
+ childTargetId: text$1("child_target_id"),
26451
+ childPayload: jsonb("child_payload"),
26452
+ executionGeneration: integer$1("execution_generation").notNull().default(0),
26453
+ startedAt: timestamp("started_at", { withTimezone: true }),
26454
+ result: jsonb("result"),
26455
+ error: jsonb("error"),
26456
+ suspensionId: text$1("suspension_id"),
26457
+ completedAt: timestamp("completed_at", { withTimezone: true }),
26458
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
26459
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
26460
+ }, (table) => [
26461
+ index$1("agent_tool_calls_organization_id_idx").on(table.organizationId),
26462
+ index$1("agent_tool_calls_session_status_idx").on(table.sessionId, table.status),
26463
+ index$1("agent_tool_calls_suspension_id_idx").on(table.suspensionId),
26464
+ uniqueIndex$1("agent_tool_calls_session_tool_call_unique").on(table.sessionId, table.toolCallId),
26465
+ uniqueIndex$1("agent_tool_calls_approval_id_unique").on(table.approvalId),
26466
+ tenantOrganizationPolicy(table.organizationId)
26467
+ ]).enableRLS();
26468
+ const agentToolCallsSqlite = sqliteTable("agent_tool_calls", {
26469
+ id: text("id").primaryKey(),
26470
+ organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id),
26471
+ sessionId: text("session_id").notNull().references(() => agentSessionsSqlite.id),
26472
+ toolCallId: text("tool_call_id").notNull(),
26473
+ assistantMessageId: text("assistant_message_id").references(() => agentMessagesSqlite.id),
26474
+ promptId: text("prompt_id").notNull(),
26475
+ toolName: text("tool_name").notNull(),
26476
+ input: text("input", { mode: "json" }).notNull(),
26477
+ approvalRequired: integer("approval_required", { mode: "boolean" }).notNull().default(false),
26478
+ approvalId: text("approval_id"),
26479
+ approvalDecision: text("approval_decision").$type(),
26480
+ approvalReason: text("approval_reason"),
26481
+ approvalResponderId: text("approval_responder_id"),
26482
+ approvalRespondedAt: integer("approval_responded_at", { mode: "timestamp_ms" }),
26483
+ status: text("status").$type().notNull(),
26484
+ childKind: text("child_kind").$type(),
26485
+ childRunId: text("child_run_id"),
26486
+ childTargetId: text("child_target_id"),
26487
+ childPayload: text("child_payload", { mode: "json" }),
26488
+ executionGeneration: integer("execution_generation").notNull().default(0),
26489
+ startedAt: integer("started_at", { mode: "timestamp_ms" }),
26490
+ result: text("result", { mode: "json" }),
26491
+ error: text("error", { mode: "json" }),
26492
+ suspensionId: text("suspension_id"),
26493
+ completedAt: integer("completed_at", { mode: "timestamp_ms" }),
26494
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
26495
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
26496
+ }, (table) => [
26497
+ index("agent_tool_calls_organization_id_idx").on(table.organizationId),
26498
+ index("agent_tool_calls_session_status_idx").on(table.sessionId, table.status),
26499
+ index("agent_tool_calls_suspension_id_idx").on(table.suspensionId),
26500
+ uniqueIndex("agent_tool_calls_session_tool_call_unique").on(table.sessionId, table.toolCallId),
26501
+ uniqueIndex("agent_tool_calls_approval_id_unique").on(table.approvalId)
26502
+ ]);
26503
+ const agentSuspensions = pgTable("agent_suspensions", {
26504
+ id: text$1("id").primaryKey(),
26505
+ organizationId: text$1("organization_id").notNull().references(() => organizations.id),
26506
+ sessionId: text$1("session_id").notNull().references(() => agentSessions.id),
26507
+ promptId: text$1("prompt_id").notNull(),
26508
+ /** Worker/run attempt that created the suspension. */
26509
+ runId: text$1("run_id").notNull(),
26510
+ status: text$1("status").$type().notNull(),
26511
+ reasonSummary: text$1("reason_summary"),
26512
+ /** Deterministic continuation job identity. */
26513
+ continuationId: text$1("continuation_id"),
26514
+ /** Safe queue envelope required to resume in a fresh worker. Never contains raw secrets. */
26515
+ continuationPayload: jsonb("continuation_payload"),
26516
+ executionGeneration: integer$1("execution_generation").notNull().default(0),
26517
+ continuationAttemptCount: integer$1("continuation_attempt_count").notNull().default(0),
26518
+ continuationLastAttemptAt: timestamp("continuation_last_attempt_at", { withTimezone: true }),
26519
+ continuationLastError: text$1("continuation_last_error"),
26520
+ continuationClaimedAt: timestamp("continuation_claimed_at", { withTimezone: true }),
26521
+ continuationClaimedBy: text$1("continuation_claimed_by"),
26522
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
26523
+ readyAt: timestamp("ready_at", { withTimezone: true }),
26524
+ completedAt: timestamp("completed_at", { withTimezone: true }),
26525
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
26526
+ }, (table) => [
26527
+ index$1("agent_suspensions_organization_id_idx").on(table.organizationId),
26528
+ index$1("agent_suspensions_session_status_idx").on(table.sessionId, table.status),
26529
+ uniqueIndex$1("agent_suspensions_continuation_id_unique").on(table.continuationId),
26530
+ tenantOrganizationPolicy(table.organizationId)
26531
+ ]).enableRLS();
26532
+ const agentSuspensionsSqlite = sqliteTable("agent_suspensions", {
26533
+ id: text("id").primaryKey(),
26534
+ organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id),
26535
+ sessionId: text("session_id").notNull().references(() => agentSessionsSqlite.id),
26536
+ promptId: text("prompt_id").notNull(),
26537
+ runId: text("run_id").notNull(),
26538
+ status: text("status").$type().notNull(),
26539
+ reasonSummary: text("reason_summary"),
26540
+ continuationId: text("continuation_id"),
26541
+ continuationPayload: text("continuation_payload", { mode: "json" }),
26542
+ executionGeneration: integer("execution_generation").notNull().default(0),
26543
+ continuationAttemptCount: integer("continuation_attempt_count").notNull().default(0),
26544
+ continuationLastAttemptAt: integer("continuation_last_attempt_at", { mode: "timestamp_ms" }),
26545
+ continuationLastError: text("continuation_last_error"),
26546
+ continuationClaimedAt: integer("continuation_claimed_at", { mode: "timestamp_ms" }),
26547
+ continuationClaimedBy: text("continuation_claimed_by"),
26548
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
26549
+ readyAt: integer("ready_at", { mode: "timestamp_ms" }),
26550
+ completedAt: integer("completed_at", { mode: "timestamp_ms" }),
26551
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
26552
+ }, (table) => [
26553
+ index("agent_suspensions_organization_id_idx").on(table.organizationId),
26554
+ index("agent_suspensions_session_status_idx").on(table.sessionId, table.status),
26555
+ uniqueIndex("agent_suspensions_continuation_id_unique").on(table.continuationId)
26556
+ ]);
26557
+ const agentContextCompactions = pgTable("agent_context_compactions", {
26558
+ id: text$1("id").primaryKey(),
26559
+ organizationId: text$1("organization_id").notNull().references(() => organizations.id),
26560
+ sessionId: text$1("session_id").notNull().references(() => agentSessions.id),
26561
+ parentCheckpointId: text$1("parent_checkpoint_id"),
26562
+ sourceHeadMessageId: text$1("source_head_message_id"),
26563
+ promptId: text$1("prompt_id"),
26564
+ status: text$1("status").$type().notNull(),
26565
+ durable: boolean("durable").notNull().default(true),
26566
+ summary: text$1("summary").notNull(),
26567
+ structuredSummary: jsonb("structured_summary"),
26568
+ summarySchemaVersion: integer$1("summary_schema_version"),
26569
+ summaryPromptVersion: integer$1("summary_prompt_version"),
26570
+ /** Highest source message ordinal included in the summary. */
26571
+ compactedThroughOrdinal: integer$1("compacted_through_ordinal").notNull(),
26572
+ compactedThroughMessageId: text$1("compacted_through_message_id").notNull(),
26573
+ firstKeptMessageId: text$1("first_kept_message_id"),
26574
+ sourceRangeDigest: text$1("source_range_digest").notNull(),
26575
+ sourceModelId: text$1("source_model_id").notNull(),
26576
+ compactionModelId: text$1("compaction_model_id").notNull(),
26577
+ triggerReason: text$1("trigger_reason").$type().notNull(),
26578
+ estimatedBeforeTokens: integer$1("estimated_before_tokens"),
26579
+ actualBeforeTokens: integer$1("actual_before_tokens"),
26580
+ estimatedAfterTokens: integer$1("estimated_after_tokens"),
26581
+ usage: jsonb("usage"),
26582
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
26583
+ }, (table) => [
26584
+ index$1("agent_context_compactions_organization_id_idx").on(table.organizationId),
26585
+ index$1("agent_context_compactions_session_status_idx").on(table.sessionId, table.status),
26586
+ tenantOrganizationPolicy(table.organizationId)
26587
+ ]).enableRLS();
26588
+ const agentContextCompactionsSqlite = sqliteTable("agent_context_compactions", {
26589
+ id: text("id").primaryKey(),
26590
+ organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id),
26591
+ sessionId: text("session_id").notNull().references(() => agentSessionsSqlite.id),
26592
+ parentCheckpointId: text("parent_checkpoint_id"),
26593
+ sourceHeadMessageId: text("source_head_message_id"),
26594
+ promptId: text("prompt_id"),
26595
+ status: text("status").$type().notNull(),
26596
+ durable: integer("durable", { mode: "boolean" }).notNull().default(true),
26597
+ summary: text("summary").notNull(),
26598
+ structuredSummary: text("structured_summary", { mode: "json" }),
26599
+ summarySchemaVersion: integer("summary_schema_version"),
26600
+ summaryPromptVersion: integer("summary_prompt_version"),
26601
+ compactedThroughOrdinal: integer("compacted_through_ordinal").notNull(),
26602
+ compactedThroughMessageId: text("compacted_through_message_id").notNull(),
26603
+ firstKeptMessageId: text("first_kept_message_id"),
26604
+ sourceRangeDigest: text("source_range_digest").notNull(),
26605
+ sourceModelId: text("source_model_id").notNull(),
26606
+ compactionModelId: text("compaction_model_id").notNull(),
26607
+ triggerReason: text("trigger_reason").$type().notNull(),
26608
+ estimatedBeforeTokens: integer("estimated_before_tokens"),
26609
+ actualBeforeTokens: integer("actual_before_tokens"),
26610
+ estimatedAfterTokens: integer("estimated_after_tokens"),
26611
+ usage: text("usage", { mode: "json" }),
26612
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
26613
+ }, (table) => [index("agent_context_compactions_organization_id_idx").on(table.organizationId), index("agent_context_compactions_session_status_idx").on(table.sessionId, table.status)]);
26284
26614
  const triggers = pgTable("triggers", {
26285
26615
  id: text$1("id").primaryKey(),
26286
26616
  organizationId: text$1("organization_id").notNull().references(() => organizations.id),
@@ -26646,6 +26976,7 @@ const jobs = pgTable("jobs", {
26646
26976
  kind: text$1("kind").$type().notNull(),
26647
26977
  targetId: text$1("target_id").notNull(),
26648
26978
  runId: text$1("run_id").notNull(),
26979
+ dedupeKey: text$1("dedupe_key"),
26649
26980
  trigger: text$1("trigger").$type().notNull(),
26650
26981
  payload: jsonb("payload"),
26651
26982
  parent: jsonb("parent").$type(),
@@ -26657,7 +26988,11 @@ const jobs = pgTable("jobs", {
26657
26988
  leaseExpiresAt: timestamp("lease_expires_at", { withTimezone: true }),
26658
26989
  completedAt: timestamp("completed_at", { withTimezone: true }),
26659
26990
  error: jsonb("error")
26660
- }, (table) => [index$1("jobs_organization_id_idx").on(table.organizationId), tenantOrganizationPolicy(table.organizationId)]).enableRLS();
26991
+ }, (table) => [
26992
+ index$1("jobs_organization_id_idx").on(table.organizationId),
26993
+ uniqueIndex$1("jobs_organization_dedupe_key_unique").on(table.organizationId, table.dedupeKey),
26994
+ tenantOrganizationPolicy(table.organizationId)
26995
+ ]).enableRLS();
26661
26996
  const jobsSqlite = sqliteTable("jobs", {
26662
26997
  id: text("id").primaryKey(),
26663
26998
  organizationId: text("organization_id").notNull().references(() => organizationsSqlite.id),
@@ -26665,6 +27000,7 @@ const jobsSqlite = sqliteTable("jobs", {
26665
27000
  kind: text("kind").$type().notNull(),
26666
27001
  targetId: text("target_id").notNull(),
26667
27002
  runId: text("run_id").notNull(),
27003
+ dedupeKey: text("dedupe_key"),
26668
27004
  trigger: text("trigger").$type().notNull(),
26669
27005
  payload: text("payload", { mode: "json" }),
26670
27006
  parent: text("parent", { mode: "json" }).$type(),
@@ -26676,7 +27012,7 @@ const jobsSqlite = sqliteTable("jobs", {
26676
27012
  leaseExpiresAt: integer("lease_expires_at", { mode: "timestamp_ms" }),
26677
27013
  completedAt: integer("completed_at", { mode: "timestamp_ms" }),
26678
27014
  error: text("error", { mode: "json" })
26679
- }, (table) => [index("jobs_organization_id_idx").on(table.organizationId)]);
27015
+ }, (table) => [index("jobs_organization_id_idx").on(table.organizationId), uniqueIndex("jobs_organization_dedupe_key_unique").on(table.organizationId, table.dedupeKey)]);
26680
27016
  const gatewayAttachments = pgTable("gateway_attachments", {
26681
27017
  id: text$1("id").primaryKey(),
26682
27018
  organizationId: text$1("organization_id").notNull().references(() => organizations.id),
@@ -27444,6 +27780,14 @@ const tableRegistry = {
27444
27780
  pg: platformAgentEvents,
27445
27781
  sqlite: platformAgentEventsSqlite
27446
27782
  },
27783
+ platformAgentMessages: {
27784
+ pg: platformAgentMessages,
27785
+ sqlite: platformAgentMessagesSqlite
27786
+ },
27787
+ platformAgentContextCompactions: {
27788
+ pg: platformAgentContextCompactions,
27789
+ sqlite: platformAgentContextCompactionsSqlite
27790
+ },
27447
27791
  platformAgentProjectSnapshots: {
27448
27792
  pg: platformAgentProjectSnapshots,
27449
27793
  sqlite: platformAgentProjectSnapshotsSqlite
@@ -27560,6 +27904,22 @@ const tableRegistry = {
27560
27904
  pg: agentEvents,
27561
27905
  sqlite: agentEventsSqlite
27562
27906
  },
27907
+ agentMessages: {
27908
+ pg: agentMessages,
27909
+ sqlite: agentMessagesSqlite
27910
+ },
27911
+ agentToolCalls: {
27912
+ pg: agentToolCalls,
27913
+ sqlite: agentToolCallsSqlite
27914
+ },
27915
+ agentSuspensions: {
27916
+ pg: agentSuspensions,
27917
+ sqlite: agentSuspensionsSqlite
27918
+ },
27919
+ agentContextCompactions: {
27920
+ pg: agentContextCompactions,
27921
+ sqlite: agentContextCompactionsSqlite
27922
+ },
27563
27923
  triggers: {
27564
27924
  pg: triggers,
27565
27925
  sqlite: triggersSqlite
@@ -46233,10 +46593,10 @@ function agentManifestEntry(agent, options) {
46233
46593
  };
46234
46594
  }
46235
46595
  function resolveActionFromModule(mod, filePath) {
46596
+ const actions = Object.values(mod).filter(isAction);
46597
+ if (actions.length > 1) throw new Error(`${filePath} exports multiple actions; use one action per file`);
46236
46598
  if (isAction(mod.default)) return mod.default;
46237
- const named = Object.values(mod).filter(isAction);
46238
- if (named.length === 1) return named[0];
46239
- if (named.length > 1) throw new Error(`${filePath} exports multiple actions; use one action per file`);
46599
+ if (actions.length === 1) return actions[0];
46240
46600
  throw new Error(`${filePath} must export defineAction(...) (default or single named export)`);
46241
46601
  }
46242
46602
  async function importActionDefinition(filePath, options) {
@@ -46600,6 +46960,7 @@ function serializeRouteManifest(manifest) {
46600
46960
  moduleFile: entry.moduleFile,
46601
46961
  requestSchema: schemaToJson(entry.request),
46602
46962
  responseSchema: schemaToJson(entry.response),
46963
+ agentSlugs: entry.agentSlugs ?? [],
46603
46964
  ...entry.flowGraph ? {
46604
46965
  flowGraph: entry.flowGraph,
46605
46966
  flowGraphSourceHash: entry.flowGraphSourceHash,
@@ -46836,7 +47197,8 @@ function splitStoredRouteManifest(input) {
46836
47197
  subscribable: entry.subscribable,
46837
47198
  moduleFile: entry.moduleFile,
46838
47199
  requestSchema: entry.requestSchema,
46839
- ...entry.responseSchema ? { responseSchema: entry.responseSchema } : {}
47200
+ ...entry.responseSchema ? { responseSchema: entry.responseSchema } : {},
47201
+ agentSlugs: entry.agentSlugs ?? []
46840
47202
  };
46841
47203
  const metaPath = workflowMetaShardRelPath(entry.slug);
46842
47204
  const metaJson = compactJson(meta);
@@ -47478,6 +47840,9 @@ function produceWorkflowFlowGraph(projectRoot, moduleFile, options) {
47478
47840
  return;
47479
47841
  }
47480
47842
  }
47843
+ function workflowAgentSlugs(flowGraph) {
47844
+ return [...new Set(flowGraph.nodes.flatMap((node) => node.nodeType === "step" && node.data.callKind === "agent" && node.data.slug ? [node.data.slug] : []))].sort();
47845
+ }
47481
47846
  /**
47482
47847
  * Resolve manifest moduleFile values to project-root-relative source paths.
47483
47848
  *
@@ -47614,20 +47979,24 @@ async function buildStoredRouteManifestForProject(projectRoot, options) {
47614
47979
  outputSchema: schemaToJson(action.definition.output)
47615
47980
  }));
47616
47981
  for (const entry of integration.entries) manifest.push(entry);
47617
- for (const { workflow, moduleFile } of resolvedWorkflows) manifest.push({
47618
- kind: "workflow",
47619
- slug: workflow.definition.slug,
47620
- name: workflow.definition.name,
47621
- description: workflow.definition.description,
47622
- subscribable: workflow.definition.subscription?.mode === "subscribable",
47623
- moduleFile,
47624
- request: workflow.definition.input,
47625
- response: workflow.definition.output,
47626
- ...produceWorkflowFlowGraph(projectRoot, moduleFile, {
47982
+ for (const { workflow, moduleFile } of resolvedWorkflows) {
47983
+ const flow = produceWorkflowFlowGraph(projectRoot, moduleFile, {
47627
47984
  slugRegistry,
47628
47985
  integrationRegistry: integration.registry
47629
- })
47630
- });
47986
+ });
47987
+ manifest.push({
47988
+ kind: "workflow",
47989
+ slug: workflow.definition.slug,
47990
+ name: workflow.definition.name,
47991
+ description: workflow.definition.description,
47992
+ subscribable: workflow.definition.subscription?.mode === "subscribable",
47993
+ moduleFile,
47994
+ request: workflow.definition.input,
47995
+ response: workflow.definition.output,
47996
+ agentSlugs: flow ? workflowAgentSlugs(flow.flowGraph) : [],
47997
+ ...flow
47998
+ });
47999
+ }
47631
48000
  const discoveredBySlug = new Map(attachments.map((attachment) => [attachment.slug, attachment]));
47632
48001
  const cronByTriggerSlug = /* @__PURE__ */ new Map();
47633
48002
  const pollByGroupId = /* @__PURE__ */ new Map();
@@ -47739,4 +48108,4 @@ async function emitStoredRouteManifestForProject(projectRoot) {
47739
48108
  //#endregion
47740
48109
  export { withMcpReadClient as $, serializeRouteManifest as A, validatePollGroups as B, isModularManifestEmitCacheHit as C, stopBrowserUseSession as Ct, pollRouteFromSourceSlug as D, event as Dt, pollGroupRouteFromId as E, configureTelemetry as Et, triggerManifestAttachments as F, webhookManifestAttachmentSchemasFromBindings as G, validateTriggerAttachments as H, tryReadProjectManifest as I, workflowKeyForAttachment as J, webhookMatchSchemaForBindings as K, validateAttachmentTargets as L, sha256File as M, splitStoredRouteManifest as N, projectActionsFingerprint as O, flushTelemetry as Ot, toStoredRouteManifest as P, assertPublicHttpUrl as Q, validateImportedTriggerAttachment as R, integrationPackagesFingerprint as S, runAgentBrowser as St, pollGroupId as T, captureException as Tt, validateUniqueAttachmentSlugs as U, validateProjectModules as V, validateUniqueTriggerSourceSlugs as W, attachmentSlugFromRecord as X, workflowRouteFromKey as Y, PublicHttpUrlError as Z, emitStoredRouteManifestForProject as _, defaultBrowserProfilesRoot as _t, buildPollGroups as a, classifyCall as at, importTriggerAttachments as b, resolveBrowserContext as bt, collectAgentAppSlugs as c, locateWorkflow as ct, countAgentCredentials as d, entryIdFromFile as dt, artifactIndexFromModules as et, discoverAgentEntries as f, readKeystrokeIgnoreDirective as ft, discoverWorkflows as g, agentBrowserProfilePath as gt, discoverWorkflowEntries as h, walkTypeScriptFiles as ht, agentRouteFromKey as i, packDirFromDisk as it, sha256Bytes as j, schemaToJson as k, shutdownTelemetry as kt, collectAgentToolSlugs as l, discoverEntries as lt, discoverTriggerAttachments as m, validateUniqueModuleKeys as mt, agentKeyForAttachment as n, moduleBlobRefsFromModules as nt, buildStoredRouteManifestForProject as o, computeCallSiteIds as ot, discoverSkillManifestEntries as p, shouldSkipKeystrokeModuleFile as pt, webhookRouteFromEndpoint as q, agentManifestEntry as r, mapInParallelBatches as rt, buildStoredRouteManifestFromContext as s, diagnoseWorkflowSource as st, actionsCatalogFingerprint as t, collectArtifactModules as tt, contentHashForModule as u, discoverModuleFileEntries as ut, hashDirectoryContents as v, deleteBrowserUseProfile as vt, persistModularRouteManifest as w, alias as wt, importWorkflowDefinition as x, resolveBrowserProvider as xt, importAgentDefinition as y, openCloudBrowserLogin as yt, validateImportedWorkflowDefinition as z };
47741
48110
 
47742
- //# sourceMappingURL=dist-aGL2P8SI.mjs.map
48111
+ //# sourceMappingURL=dist-vV8clzp6.mjs.map