@sentry/junior 0.305.0 → 0.307.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/{adapter-context-BpvbUki8.js → adapter-context-B69WPn6b.js} +2 -2
  2. package/dist/{admin-CoDt35ny.js → admin-nCJXMgkp.js} +2 -2
  3. package/dist/{agent-runner-C5d6rY5g.js → agent-runner-DdFcxAxG.js} +463 -303
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +7 -8
  6. package/dist/api.d.ts +19 -4
  7. package/dist/api.js +437 -310
  8. package/dist/{app-Cs157Zc5.d.ts → app-EZur8cVC.d.ts} +12 -3
  9. package/dist/app.d.ts +2 -2
  10. package/dist/app.js +532 -439
  11. package/dist/background-compaction-queue-BhEe4UfU.js +231 -0
  12. package/dist/{briefs-BRdznF7c.js → briefs-Dl9lxi7J.js} +3 -3
  13. package/dist/{catalog-runtime-J52Tej47.js → catalog-runtime-OXrv2Ewn.js} +1 -1
  14. package/dist/cli/chat.d.ts +1 -1
  15. package/dist/cli/chat.js +17 -16
  16. package/dist/cli/check.js +58 -48
  17. package/dist/cli/main.js +3 -3
  18. package/dist/cli/plugins.d.ts +1 -1
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +5 -5
  21. package/dist/cli/upgrade.d.ts +2 -2
  22. package/dist/cli/upgrade.js +3 -8
  23. package/dist/{config-CBZp0udd.js → config-362yMSIz.js} +183 -49
  24. package/dist/{connections-BYmuJ6Vm.js → connections-BJv3EjmB.js} +10 -8
  25. package/dist/{continue-in-slack-Cvot6S38.js → continue-in-slack-CFEevC7z.js} +5 -5
  26. package/dist/{conversation-BOqdRtUx.js → conversation--f85g4zL.js} +132 -132
  27. package/dist/{conversation-feed-CgpgP7yi.js → conversation-feed-BNs9KiqC.js} +1 -1
  28. package/dist/{conversation-privacy-D2pOzBNl.js → conversation-privacy-Tjj5P2W6.js} +1 -1
  29. package/dist/{conversation-turn-CI8WDpnK.js → conversation-turn-DU0_WDAr.js} +26 -72
  30. package/dist/{credential-sync-COqnZ1Dx.js → credential-sync-D6aFARKE.js} +28 -27
  31. package/dist/{db-DU84dCVu.js → db-Bcbd9zQc.js} +226 -18
  32. package/dist/{db-zbN5ZV_o.d.ts → db-C41UgdBj.d.ts} +1 -1
  33. package/dist/{executor-CFyrgOu1.js → executor-DBMBrpNV.js} +137 -33
  34. package/dist/{history-m2-ceTTX.js → history-N7IVbUom.js} +5 -1
  35. package/dist/{install-CQ76CfRw.js → install-CgoAbzfF.js} +2 -2
  36. package/dist/instrumentation.js +2 -2
  37. package/dist/{lineage-DLd2UxVP.js → lineage-CsZDmz3e.js} +2 -2
  38. package/dist/{logging-BPNTQVFu.js → logging-CHCuQ5iz.js} +1 -1
  39. package/dist/{message-BWJLeQ5e.js → message-B8vCbZZB.js} +8 -8
  40. package/dist/{model-input-DoM9Ht-d.js → model-input-Xluiy-1W.js} +3 -3
  41. package/dist/nitro.d.ts +2 -2
  42. package/dist/nitro.js +3 -4
  43. package/dist/{oauth-callback-server-DeHbnAQl.js → oauth-callback-server-BUuNvfvu.js} +2 -2
  44. package/dist/{oauth-relay-DAmfVmJu.js → oauth-relay-DGAZzg9m.js} +1 -1
  45. package/dist/{plugins-B_0Cr0MO.d.ts → plugins-fBrz8PCV.d.ts} +2 -0
  46. package/dist/{projection-CcFBVFUo.js → projection-xPpvqexa.js} +13423 -11432
  47. package/dist/{prompt-C5LREK2p.js → prompt-D8u4jFs_.js} +15 -7
  48. package/dist/{registry-BjZZqKqi.js → registry-D20hG3r6.js} +19 -9
  49. package/dist/{resolve-CeJgXuH1.js → resolve-BhCySRCW.js} +3 -3
  50. package/dist/{result-icDrueyB.js → result-DddO63S9.js} +13 -11
  51. package/dist/{runner-nVfMkMMB.js → runner-DQR9vYce.js} +13 -15
  52. package/dist/{sandbox-egress-signals-H9vQ5qRf.js → sandbox-egress-signals-DFlNUOnK.js} +1 -1
  53. package/dist/{automation-CuA3yEcD.js → schedule-BG1tEbRF.js} +380 -8
  54. package/dist/{schema-CKcu-IK6.d.ts → schema-CRXcj4fj.d.ts} +420 -143
  55. package/dist/{schema-Bx0Mlo32.js → schema-D4jdesIu.js} +62 -8
  56. package/dist/{service-account-DU5865XA.js → service-account-Bv5QwrEq.js} +8 -6
  57. package/dist/{service-account-Dw06p3zm.js → service-account-CNfycv0z.js} +3 -3
  58. package/dist/{session-stop-uotLtp4g.js → session-stop-BDdwyZaa.js} +878 -171
  59. package/dist/{skills-Bex1EaO5.js → skills-63i1Bcv1.js} +32 -28
  60. package/dist/{slack-conversation-unfurl-EPG3riWF.js → slack-conversation-unfurl-DtpBUlUu.js} +10 -9
  61. package/dist/{spawn-CoD3vDuS.js → spawn-mwimEY9_.js} +6 -6
  62. package/dist/{state-nCR4Muhn.js → state-BBn9L6gC.js} +4 -4
  63. package/dist/{stop-BFVd0P0m.js → stop-Da-Ug7tg.js} +172 -239
  64. package/dist/{store-Ca6G962n.js → store-CdWg2r2L.js} +5 -5
  65. package/dist/{background-compaction-queue-BTqMIfTA.js → task-queue-BcjAYWyB.js} +164 -180
  66. package/dist/{task-runner-xsOPIxCZ.js → task-runner-CoXmMlsW.js} +13 -11
  67. package/dist/{thread-context-BOvZhsKK.js → thread-context-ZPGqOjW7.js} +8 -91
  68. package/dist/turn-session-routing-DFYak28Q.js +263 -0
  69. package/dist/{turn-user-message-BrhuyYrH.js → turn-user-message-B1S8nOnG.js} +3 -3
  70. package/dist/users-DDbENg-I.js +181 -0
  71. package/dist/{validation-BnY9K5WB.js → validation-fl21ps-k.js} +1 -1
  72. package/dist/{version-qROlRQGF.js → version-DCdMMx_0.js} +1 -1
  73. package/dist/version.js +1 -1
  74. package/dist/{viewer-CxUiOraX.js → viewer-DN_xzVKj.js} +3 -3
  75. package/dist/{warmup--Gkz7iB-.js → warmup-CxhEhm71.js} +842 -532
  76. package/dist/{web-message-id-lNodcCOI.js → web-message-id-BT8Mg8LL.js} +16 -1
  77. package/dist/{worker-DJ8d9fmD.js → worker-Btb1SB5h.js} +8 -7
  78. package/migrations/0114_plan_items.sql +22 -0
  79. package/migrations/0115_automation_creator_slack_index.sql +1 -0
  80. package/migrations/0116_conversation_event_search.sql +25 -0
  81. package/migrations/0117_automation_last_run.sql +46 -0
  82. package/migrations/0118_automation_last_run_index.sql +1 -0
  83. package/migrations/0119_money_micro_usd.sql +29 -0
  84. package/migrations/0120_conversation_cost_micro_usd.sql +8 -0
  85. package/migrations/meta/0114_snapshot.json +5203 -0
  86. package/migrations/meta/0115_snapshot.json +5225 -0
  87. package/migrations/meta/0116_snapshot.json +5388 -0
  88. package/migrations/meta/0117_snapshot.json +5413 -0
  89. package/migrations/meta/0118_snapshot.json +5428 -0
  90. package/migrations/meta/0119_snapshot.json +5441 -0
  91. package/migrations/meta/0120_snapshot.json +5441 -0
  92. package/migrations/meta/_journal.json +49 -0
  93. package/package.json +10 -9
  94. package/dist/queue-B2AAL3ym.js +0 -115
  95. package/dist/schedule-cP0AACm1.js +0 -344
  96. package/dist/secrets-DHaJ5TTn.js +0 -18
  97. package/dist/task-queue-BLPZU6kC.js +0 -89
  98. package/dist/turn-session-routing-2bW2qfeb.js +0 -1792
@@ -1,9 +1,10 @@
1
- import { h as logWarn, p as logException } from "./logging-BPNTQVFu.js";
1
+ import { h as logWarn, p as logException } from "./logging-CHCuQ5iz.js";
2
2
  import { _ as withScope } from "./sentry-CPbZjomA.js";
3
- import "./config-CBZp0udd.js";
3
+ import "./config-362yMSIz.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { sql } from "drizzle-orm";
6
- import { bigint, boolean, check, customType, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
6
+ import { bigint, boolean, check, customType, date, doublePrecision, foreignKey, index, integer, jsonb, pgSequence, pgTable, primaryKey, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
7
+ import { embeddingHalfvec, embeddingVector } from "@sentry/junior-plugin-api/embeddings";
7
8
  import { Pool as Pool$1, neon } from "@neondatabase/serverless";
8
9
  import { drizzle } from "drizzle-orm/neon-serverless";
9
10
  import { Agent } from "undici";
@@ -374,7 +375,7 @@ const CONVERSATION_METRICS = [
374
375
  "cached_input_tokens",
375
376
  "cache_creation_tokens",
376
377
  "reasoning_tokens",
377
- "cost_usd"
378
+ "cost_micro_usd"
378
379
  ];
379
380
  /**
380
381
  * One metric value for one Conversation Run. A Run is one Turn, so People
@@ -415,7 +416,8 @@ const juniorConversationBriefs = pgTable("junior_conversation_briefs", {
415
416
  content: jsonb("content").$type().notNull(),
416
417
  searchText: text("search_text").notNull(),
417
418
  modelId: text("model_id").notNull(),
418
- costUsd: doublePrecision("cost_usd"),
419
+ costMicroUsd: bigint("cost_micro_usd", { mode: "number" }),
420
+ legacyCostUsd: doublePrecision("cost_usd"),
419
421
  createdAt: timestamptz("created_at").defaultNow().notNull()
420
422
  }, (table) => [
421
423
  primaryKey({
@@ -433,21 +435,6 @@ const juniorConversationBriefs = pgTable("junior_conversation_briefs", {
433
435
  ]);
434
436
  // src/db/schema/conversation-embeddings.ts
435
437
  /**
436
- * pgvector column without a fixed size, so a change of embedding model needs
437
- * no migration. The dimensions column records the size of each row.
438
- */
439
- const vector = customType({
440
- dataType() {
441
- return "vector";
442
- },
443
- toDriver(value) {
444
- return JSON.stringify(value);
445
- },
446
- fromDriver(value) {
447
- return value.slice(1, -1).split(",").map(Number);
448
- }
449
- });
450
- /**
451
438
  * One embedding per Conversation, for semantic search. Its text is the latest
452
439
  * Brief. A derived index: the next Brief replaces the row, and deleting that
453
440
  * Brief row deletes it.
@@ -458,13 +445,68 @@ const juniorConversationEmbeddings = pgTable("junior_conversation_embeddings", {
458
445
  provider: text("provider").notNull(),
459
446
  model: text("model").notNull(),
460
447
  dimensions: integer("dimensions").notNull(),
461
- embedding: vector("embedding").notNull(),
448
+ embedding: embeddingVector("embedding").notNull(),
462
449
  createdAt: timestamptz("created_at").defaultNow().notNull()
463
450
  }, (table) => [foreignKey({
464
451
  name: "junior_conversation_embeddings_brief_fk",
465
452
  columns: [table.conversationId, table.briefVersion],
466
453
  foreignColumns: [juniorConversationBriefs.conversationId, juniorConversationBriefs.version]
467
454
  }).onDelete("cascade"), check("junior_conversation_embeddings_dimensions_check", sql`vector_dims(${table.embedding}) = ${table.dimensions}`)]);
455
+ // src/db/schema/conversation-event-embeddings.ts
456
+ /**
457
+ * One embedding per searchable Conversation event, for semantic search of the
458
+ * history of one Conversation. A derived index: a purge that deletes the
459
+ * event deletes its row, and a new embedding model replaces the row.
460
+ */
461
+ const juniorConversationEventEmbeddings = pgTable("junior_conversation_event_embeddings", {
462
+ conversationId: text("conversation_id").notNull(),
463
+ seq: integer("seq").notNull(),
464
+ provider: text("provider").notNull(),
465
+ model: text("model").notNull(),
466
+ dimensions: integer("dimensions").notNull(),
467
+ embedding: embeddingHalfvec("embedding").notNull(),
468
+ createdAt: timestamptz("created_at").defaultNow().notNull()
469
+ }, (table) => [
470
+ primaryKey({
471
+ name: "junior_conversation_event_embeddings_pk",
472
+ columns: [table.conversationId, table.seq]
473
+ }),
474
+ foreignKey({
475
+ name: "junior_conversation_event_embeddings_event_fk",
476
+ columns: [table.conversationId, table.seq],
477
+ foreignColumns: [juniorConversationEvents.conversationId, juniorConversationEvents.seq]
478
+ }).onDelete("cascade"),
479
+ check("junior_conversation_event_embeddings_dimensions_check", sql`vector_dims(${table.embedding}) = ${table.dimensions}`)
480
+ ]);
481
+ // src/db/schema/tsvector.ts
482
+ /** Postgres full-text lexemes. Queries read them only through SQL. */
483
+ const tsvector = customType({ dataType() {
484
+ return "tsvector";
485
+ } });
486
+ // src/db/schema/conversation-event-lexemes.ts
487
+ /**
488
+ * Stored full-text lexemes of one searchable Conversation event, for keyword
489
+ * search of the history of one Conversation. A derived index: a purge that
490
+ * deletes the event deletes its row. Events are immutable, so a row never
491
+ * changes.
492
+ */
493
+ const juniorConversationEventLexemes = pgTable("junior_conversation_event_lexemes", {
494
+ conversationId: text("conversation_id").notNull(),
495
+ seq: integer("seq").notNull(),
496
+ lexemes: tsvector("lexemes").notNull(),
497
+ createdAt: timestamptz("created_at").defaultNow().notNull()
498
+ }, (table) => [
499
+ primaryKey({
500
+ name: "junior_conversation_event_lexemes_pk",
501
+ columns: [table.conversationId, table.seq]
502
+ }),
503
+ foreignKey({
504
+ name: "junior_conversation_event_lexemes_event_fk",
505
+ columns: [table.conversationId, table.seq],
506
+ foreignColumns: [juniorConversationEvents.conversationId, juniorConversationEvents.seq]
507
+ }).onDelete("cascade"),
508
+ index("junior_conversation_event_lexemes_lexemes_idx").using("gin", table.lexemes)
509
+ ]);
468
510
  // src/db/schema/conversation-bindings.ts
469
511
  /** Provider conversation coordinates bound to Junior's opaque durable conversation id. */
470
512
  const juniorConversationBindings = pgTable("junior_conversation_bindings", {
@@ -598,7 +640,8 @@ const juniorStats = pgTable("junior_stats", {
598
640
  namespace: text("namespace").notNull(),
599
641
  metric: text("metric").notNull(),
600
642
  name: text("name").notNull(),
601
- count: integer("count").notNull().default(0)
643
+ count: bigint("value", { mode: "number" }).notNull().default(0),
644
+ legacyCount: integer("count").notNull().default(0)
602
645
  }, (table) => [primaryKey({
603
646
  name: "junior_stats_date_namespace_metric_name_pk",
604
647
  columns: [
@@ -638,6 +681,13 @@ const juniorAutomations = pgTable("junior_automations", {
638
681
  createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
639
682
  nextRunAtMs: bigint("next_run_at_ms", { mode: "number" }),
640
683
  runNowAtMs: bigint("run_now_at_ms", { mode: "number" }),
684
+ /**
685
+ * The latest run with an outcome. The list reads its end time and status
686
+ * to order by activity and to find failed last runs.
687
+ * `refreshAutomationLastRun` sets it after each run write. A purged run
688
+ * clears it.
689
+ */
690
+ lastRunId: text("last_run_id").references(() => juniorAutomationRuns.id, { onDelete: "set null" }),
641
691
  namespace: text("namespace"),
642
692
  identifier: text("identifier"),
643
693
  record: jsonb("record").$type().notNull()
@@ -649,6 +699,8 @@ const juniorAutomations = pgTable("junior_automations", {
649
699
  check("junior_automations_trigger_check", sql`(${table.kind} = 'scheduled' and ${table.namespace} is null and ${table.identifier} is null) or (${table.kind} = 'event' and ${table.namespace} is not null and ${table.nextRunAtMs} is null and ${table.runNowAtMs} is null and ${table.status} <> 'completed')`),
650
700
  index("junior_automations_team_idx").on(table.teamId, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`),
651
701
  index("junior_automations_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id),
702
+ index("junior_automations_creator_slack_idx").on(table.teamId, table.creatorSlackUserId).where(sql`${table.status} <> 'deleted'`),
703
+ index("junior_automations_last_run_idx").on(table.lastRunId),
652
704
  index("junior_automations_run_now_due_idx").on(table.runNowAtMs, table.createdAtMs, table.id).where(sql`${table.status} = 'active' AND ${table.runNowAtMs} IS NOT NULL`),
653
705
  index("junior_automations_next_run_due_idx").on(table.nextRunAtMs, table.createdAtMs, table.id).where(sql`${table.status} = 'active' AND ${table.nextRunAtMs} IS NOT NULL`),
654
706
  index("junior_automations_skill_idx").on(table.skill, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted' AND ${table.skill} IS NOT NULL`),
@@ -697,7 +749,8 @@ const juniorAutomationRuns = pgTable("junior_automation_runs", {
697
749
  startedAtMs: bigint("started_at_ms", { mode: "number" }),
698
750
  completedAtMs: bigint("completed_at_ms", { mode: "number" }),
699
751
  errorMessage: text("error_message"),
700
- resultMessageTs: text("result_message_ts")
752
+ resultMessageTs: text("result_message_ts"),
753
+ costMicroUsd: bigint("cost_micro_usd", { mode: "number" })
701
754
  }, (table) => [
702
755
  foreignKey({
703
756
  name: "junior_automation_runs_automation_version_fk",
@@ -784,6 +837,48 @@ const juniorReviewItemSlackCards = pgTable("junior_review_item_slack_cards", {
784
837
  channelId: text("channel_id").notNull(),
785
838
  messageTs: text("message_ts").notNull()
786
839
  }, (table) => [primaryKey({ columns: [table.itemId, table.conversationId] })]);
840
+ // src/db/schema/plan-items.ts
841
+ /**
842
+ * Gives each Plan item its id and each change its version. One sequence
843
+ * serves every Conversation, so history that a fork copies from its parent
844
+ * never shows a version that the fork's own plan reuses.
845
+ */
846
+ const juniorPlanItemVersionSeq = pgSequence("junior_plan_item_version_seq");
847
+ /**
848
+ * One Plan item: work that a Conversation has not finished. At most one
849
+ * assignee: a Conversation (the plan's own agent or one of its child agents)
850
+ * or a User. An item without one belongs to the plan's own agent.
851
+ * `changed_by_user_id` is set when a person made the latest change, and null
852
+ * when the plan's own agent did. Both User keys block deleting the User, as
853
+ * Conversation participants do: setting them null would turn a person's item
854
+ * into the agent's and hide an unseen change from `<plan-delta>`.
855
+ */
856
+ const juniorPlanItems = pgTable("junior_plan_items", {
857
+ conversationId: text("conversation_id").notNull(),
858
+ id: bigint("id", { mode: "number" }).notNull(),
859
+ title: text("title").notNull(),
860
+ notes: text("notes"),
861
+ status: text("status").$type().notNull(),
862
+ assigneeConversationId: text("assignee_conversation_id"),
863
+ assigneeUserId: text("assignee_user_id").references(() => juniorUsers.id),
864
+ version: bigint("version", { mode: "number" }).notNull(),
865
+ changedByUserId: text("changed_by_user_id").references(() => juniorUsers.id),
866
+ createdAt: timestamptz("created_at").notNull(),
867
+ updatedAt: timestamptz("updated_at").notNull()
868
+ }, (table) => [
869
+ primaryKey({
870
+ name: "junior_plan_items_pk",
871
+ columns: [table.conversationId, table.id]
872
+ }),
873
+ foreignKey({
874
+ name: "junior_plan_items_conversation_id_fk",
875
+ columns: [table.conversationId],
876
+ foreignColumns: [juniorConversations.conversationId]
877
+ }).onDelete("cascade"),
878
+ check("junior_plan_items_status_check", sql`${table.status} in ('pending', 'in_progress', 'blocked', 'done', 'cancelled')`),
879
+ check("junior_plan_items_assignee_check", sql`${table.assigneeConversationId} is null or ${table.assigneeUserId} is null`),
880
+ uniqueIndex("junior_plan_items_in_progress_uidx").on(table.conversationId, sql`coalesce(${table.assigneeConversationId}, ${table.assigneeUserId}, ${table.conversationId})`).where(sql`${table.status} = 'in_progress'`)
881
+ ]);
787
882
  // src/db/schema/push-subscriptions.ts
788
883
  /**
789
884
  * One browser Web Push subscription for one user. A user can have one row for
@@ -867,6 +962,8 @@ const juniorSqlSchema = {
867
962
  juniorConversationEvents,
868
963
  juniorConversationMetrics,
869
964
  juniorConversationEmbeddings,
965
+ juniorConversationEventEmbeddings,
966
+ juniorConversationEventLexemes,
870
967
  juniorConversationBriefs,
871
968
  juniorConversationBindings,
872
969
  juniorConversationParticipants,
@@ -879,6 +976,7 @@ const juniorSqlSchema = {
879
976
  juniorReviewItemConversations,
880
977
  juniorReviewItemSlackCards,
881
978
  juniorReviewItems,
979
+ juniorPlanItems,
882
980
  juniorPushSubscriptions,
883
981
  juniorSnapshots,
884
982
  juniorStats,
@@ -903,6 +1001,20 @@ function forwardInfoMessages(pool, onInfo) {
903
1001
  });
904
1002
  });
905
1003
  }
1004
+ // src/db/postgres-error.ts
1005
+ const MAX_CAUSE_DEPTH = 5;
1006
+ /**
1007
+ * Return whether a PostgreSQL failure, or an error that it wraps as `cause`,
1008
+ * has the requested SQLSTATE.
1009
+ */
1010
+ function isPostgresErrorCode(error, code) {
1011
+ let current = error;
1012
+ for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof current === "object" && current !== null; depth += 1) {
1013
+ if ("code" in current && current.code === code) return true;
1014
+ current = "cause" in current ? current.cause : void 0;
1015
+ }
1016
+ return false;
1017
+ }
906
1018
  // src/db/migrate.ts
907
1019
  const LOCK_TIMEOUT_MS = 5e3;
908
1020
  const LOCK_ATTEMPTS = 5;
@@ -931,14 +1043,6 @@ function concurrentIndexes(tag, statements) {
931
1043
  };
932
1044
  });
933
1045
  }
934
- function isLockTimeout(error) {
935
- let current = error;
936
- for (let depth = 0; current instanceof Error && depth < 5; depth += 1) {
937
- if ("code" in current && current.code === LOCK_NOT_AVAILABLE) return true;
938
- current = current.cause;
939
- }
940
- return false;
941
- }
942
1046
  /**
943
1047
  * Wait for the migration lock by polling `pg_try_advisory_lock`. A session
944
1048
  * blocked in `pg_advisory_lock` holds a snapshot, and `CREATE INDEX
@@ -953,7 +1057,7 @@ async function retryOnLockTimeout(tag, apply) {
953
1057
  await apply();
954
1058
  return;
955
1059
  } catch (error) {
956
- if (attempt >= LOCK_ATTEMPTS || !isLockTimeout(error)) throw error;
1060
+ if (attempt >= LOCK_ATTEMPTS || !isPostgresErrorCode(error, LOCK_NOT_AVAILABLE)) throw error;
957
1061
  logWarn("db.migration.lock_timeout", {
958
1062
  "app.db.migration.tag": tag,
959
1063
  "app.db.migration.attempt": attempt
@@ -1374,4 +1478,4 @@ function createJuniorSqlExecutor(args) {
1374
1478
  statementTimeoutMs
1375
1479
  });
1376
1480
  }
1377
- export { juniorAttachmentUploads as A, juniorConversationMetrics as C, juniorConversationAnnotations as D, juniorApiTokens as E, juniorUsers as F, juniorDestinations as I, juniorArtifacts as L, juniorMessageAttachments as M, juniorConversations as N, juniorCodeChanges as O, juniorIdentities as P, CONVERSATION_METRICS as S, juniorConversationEvents as T, juniorConversationReadPositions as _, juniorPushSubscriptions as a, juniorConversationEmbeddings as b, juniorReviewItemSlackCards as c, juniorAutomationVersions as d, juniorAutomations as f, juniorAgentInvocations as g, juniorAgentBindings as h, juniorWorkspaces as i, juniorAttachments as j, juniorCodeRepositories as k, juniorReviewItems as l, juniorLocationConfigurations as m, juniorSnapshots as n, juniorReviewItemAssignees as o, juniorStats as p, juniorWorkspaceRepos as r, juniorReviewItemConversations as s, createJuniorSqlExecutor as t, juniorAutomationRuns as u, juniorConversationParticipants as v, isUserInstruction as w, juniorConversationBriefs as x, juniorConversationBindings as y };
1481
+ export { juniorConversationEvents as A, juniorUsers as B, juniorConversationEventLexemes as C, CONVERSATION_METRICS as D, juniorConversationBriefs as E, juniorAttachmentUploads as F, juniorArtifacts as H, juniorAttachments as I, juniorMessageAttachments as L, juniorConversationAnnotations as M, juniorCodeChanges as N, juniorConversationMetrics as O, juniorCodeRepositories as P, juniorConversations as R, juniorConversationBindings as S, juniorConversationEmbeddings as T, juniorDestinations as V, juniorLocationConfigurations as _, juniorWorkspaces as a, juniorConversationReadPositions as b, juniorPlanItems as c, juniorReviewItemSlackCards as d, juniorReviewItems as f, juniorStats as g, juniorAutomations as h, juniorWorkspaceRepos as i, juniorApiTokens as j, isUserInstruction as k, juniorReviewItemAssignees as l, juniorAutomationVersions as m, isPostgresErrorCode as n, juniorPushSubscriptions as o, juniorAutomationRuns as p, juniorSnapshots as r, juniorPlanItemVersionSeq as s, createJuniorSqlExecutor as t, juniorReviewItemConversations as u, juniorAgentBindings as v, juniorConversationEventEmbeddings as w, juniorConversationParticipants as x, juniorAgentInvocations as y, juniorIdentities as z };
@@ -100,7 +100,11 @@ function encodeHistoryPayload(data) {
100
100
  model: message["model"],
101
101
  provider: message["provider"],
102
102
  usage: message["usage"],
103
- toolCallId: message["toolCallId"]
103
+ toolCallId: message["toolCallId"],
104
+ stopReason: message["stopReason"],
105
+ timestamp: message["timestamp"],
106
+ toolName: message["toolName"],
107
+ isError: message["isError"]
104
108
  }
105
109
  };
106
110
  }
@@ -1,5 +1,5 @@
1
- import { ao as SANDBOX_COMMAND_PATH, ho as runNonInteractiveCommand, lo as SANDBOX_WORKSPACE_ROOT } from "./projection-CcFBVFUo.js";
2
- import { E as withSpan, b as setSpanAttributes } from "./logging-BPNTQVFu.js";
1
+ import { Aa as SANDBOX_COMMAND_PATH, Fa as SANDBOX_WORKSPACE_ROOT, Va as runNonInteractiveCommand } from "./projection-xPpvqexa.js";
2
+ import { E as withSpan, b as setSpanAttributes } from "./logging-CHCuQ5iz.js";
3
3
  // src/chat/sandbox/resources.ts
4
4
  let configuredResources;
5
5
  function resourcesFromEnv() {
@@ -1,10 +1,10 @@
1
1
  import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON, s as getTraceData } from "./sentry-CPbZjomA.js";
2
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-D2pOzBNl.js";
2
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-Tjj5P2W6.js";
3
3
  import { n as isPushServiceHost } from "./push-endpoint-CO-nomUd.js";
4
4
  import { n as redactSandboxEgressProxyPath } from "./proxy-path-BHYoKZdq.js";
5
5
  import { n as promoteHttpRouteName, r as routeNameMiddleware, t as nameRequestRoute } from "./sentry-route-name-C6EIzAGP.js";
6
6
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
7
- import { B as getDeploymentServiceVersion, V as getDeploymentTelemetryAttributes } from "./logging-BPNTQVFu.js";
7
+ import { B as getDeploymentServiceVersion, V as getDeploymentTelemetryAttributes } from "./logging-CHCuQ5iz.js";
8
8
  import { performance } from "node:perf_hooks";
9
9
  import { subscribe, unsubscribe } from "node:diagnostics_channel";
10
10
  // src/chat/pi/gateway-request-timing.ts
@@ -1,5 +1,5 @@
1
- import { A as conversationKindFromRow, o as getDb } from "./db-DU84dCVu.js";
2
- import { N as juniorConversations } from "./executor-CFyrgOu1.js";
1
+ import { A as conversationKindFromRow, o as getDb } from "./db-Bcbd9zQc.js";
2
+ import { R as juniorConversations } from "./executor-DBMBrpNV.js";
3
3
  import { desc, eq, sql } from "drizzle-orm";
4
4
  // src/chat/conversations/lineage.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-CPbZjomA.js";
2
- import { t as JUNIOR_VERSION } from "./version-qROlRQGF.js";
2
+ import { t as JUNIOR_VERSION } from "./version-DCdMMx_0.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
@@ -1,12 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { M as toolInvocationDestination, j as actorFromRun } from "./agent-runner-C5d6rY5g.js";
3
- import { Cn as AgentMessagePausedError, Dn as PARENT_AGENT_TARGET, Gt as getLatestAgentInvocationForConversation, Ht as getActiveAgentInvocationForConversation, Tn as findChildAgentConversationId, bn as createAgentInvocationForMessage, fn as enqueueAgentInvocation, tn as readChildConversationSender, wn as AgentMessageTargetError } from "./warmup--Gkz7iB-.js";
4
- import { a as enqueueAgentMessageToParent } from "./result-icDrueyB.js";
5
- import { Kn as renderUntrustedTag, vo as canAccessConversation, xo as readConversationAccessFromSql } from "./projection-CcFBVFUo.js";
6
- import { n as botConfig } from "./config-CBZp0udd.js";
7
- import { P as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb } from "./db-DU84dCVu.js";
8
- import { L as postAutomatedTurnLimitNoticeForConversation, W as admitAutomatedTurn, k as EVENT_WAIT_MS } from "./session-stop-uotLtp4g.js";
9
- import { r as appendAndEnqueueInboundMessage } from "./store-Ca6G962n.js";
2
+ import { F as actorFromRun, I as toolInvocationDestination } from "./agent-runner-DdFcxAxG.js";
3
+ import { $t as readChildConversationSender, Bt as getActiveAgentInvocationForConversation, Cn as findChildAgentConversationId, Sn as AgentMessageTargetError, Tn as PARENT_AGENT_TARGET, Ut as getLatestAgentInvocationForConversation, un as enqueueAgentInvocation, vn as createAgentInvocationForMessage, xn as AgentMessagePausedError } from "./warmup-CxhEhm71.js";
4
+ import { a as enqueueAgentMessageToParent } from "./result-DddO63S9.js";
5
+ import { Wa as canAccessConversation, qa as readConversationAccessFromSql } from "./projection-xPpvqexa.js";
6
+ import { Z as renderUntrustedTag, n as botConfig } from "./config-362yMSIz.js";
7
+ import { P as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb } from "./db-Bcbd9zQc.js";
8
+ import { $ as postAutomatedTurnLimitNoticeForConversation, F as EVENT_WAIT_MS, ot as admitAutomatedTurn } from "./session-stop-BDdwyZaa.js";
9
+ import { r as appendAndEnqueueInboundMessage } from "./store-CdWg2r2L.js";
10
10
  // src/chat/agent-invocations/top-level-message.ts
11
11
  const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
12
12
  /** Event type of a message from another top-level agent. */
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { s as getSqlExecutor } from "./db-DU84dCVu.js";
3
- import { h as isVisionImageMediaType, m as detectImageMediaType } from "./web-message-id-lNodcCOI.js";
4
- import { Jo as readLiveAttachment } from "./projection-CcFBVFUo.js";
2
+ import { s as getSqlExecutor } from "./db-Bcbd9zQc.js";
3
+ import { h as isVisionImageMediaType, m as detectImageMediaType } from "./web-message-id-BT8Mg8LL.js";
4
+ import { bo as readLiveAttachment } from "./projection-xPpvqexa.js";
5
5
  // src/chat/attachments/model-input.ts
6
6
  var model_input_exports = /* @__PURE__ */ __exportAll({ loadInputAttachments: () => loadInputAttachments });
7
7
  /** Largest file that Slack and web send to the model in the prompt. */
package/dist/nitro.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
2
- import { i as JuniorDashboardOptions } from "./app-Cs157Zc5.js";
1
+ import { n as JuniorPluginSet } from "./plugins-fBrz8PCV.js";
2
+ import { i as JuniorDashboardOptions } from "./app-EZur8cVC.js";
3
3
  import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
4
4
  type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
5
5
  type SentryNitroOptions = NonNullable<Parameters<typeof withSentryConfig$1>[1]>;
package/dist/nitro.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-x4AvVhMj.js";
2
2
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-Bkk0XRo2.js";
3
- import { o as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as CACHE_WARMUP_QUEUE_TOPIC } from "./queue-B2AAL3ym.js";
4
- import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-BLPZU6kC.js";
5
- import { s as resolveConversationWorkQueueTopic, t as BACKGROUND_COMPACTION_QUEUE_TOPIC } from "./background-compaction-queue-BTqMIfTA.js";
6
- import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, B as getDeploymentServiceVersion, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE } from "./logging-BPNTQVFu.js";
3
+ import { a as CACHE_WARMUP_QUEUE_TOPIC, h as resolveConversationWorkQueueTopic, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./background-compaction-queue-BhEe4UfU.js";
4
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-BcjAYWyB.js";
5
+ import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, B as getDeploymentServiceVersion, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE } from "./logging-CHCuQ5iz.js";
7
6
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cv2ETe8Y.js";
8
7
  import path from "node:path";
9
8
  import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-COqnZ1Dx.js";
2
- import { Yn as createUserTokenStore } from "./projection-CcFBVFUo.js";
1
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-D6aFARKE.js";
2
+ import { bn as createUserTokenStore } from "./projection-xPpvqexa.js";
3
3
  import { createServer } from "node:http";
4
4
  // src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { t as readJuniorSecret } from "./secrets-DHaJ5TTn.js";
2
+ import { d as readJuniorSecret } from "./task-queue-BcjAYWyB.js";
3
3
  import * as z from "zod";
4
4
  import { randomBytes } from "node:crypto";
5
5
  import { SignJWT, jwtVerify } from "jose";
@@ -50,6 +50,7 @@ type PluginCredentialConfig = PluginCredentialConfigBase & {
50
50
  interface PluginManifestConfig {
51
51
  displayName?: string;
52
52
  description?: string;
53
+ reviewContext?: string | null;
53
54
  configKeys?: string[];
54
55
  domains?: string[] | null;
55
56
  apiHeaders?: Record<string, string | null> | null;
@@ -77,6 +78,7 @@ interface PluginManifestConfig {
77
78
  configKey?: string;
78
79
  commandFlags?: string[] | null;
79
80
  } | null;
81
+ toolsSendNoCredential?: boolean | null;
80
82
  }
81
83
  type JuniorPluginInput = PluginRegistration | string;
82
84
  interface JuniorPluginSetOptions {