@sentry/junior 0.267.0 → 0.269.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 (95) hide show
  1. package/README.md +2 -9
  2. package/dist/{actor-DZSokpwj.js → actor-CP9K2Idu.js} +2 -1
  3. package/dist/{adapter-BybMEezj.js → adapter-2-CG25be.js} +3 -51
  4. package/dist/{admin-DOs1_EiW.js → admin-DSs8S5Uy.js} +1 -1
  5. package/dist/{agent-invocations-CxKldAeB.js → agent-invocations-C1RNOCs8.js} +2 -0
  6. package/dist/{agent-runner-DgNATN4D.js → agent-runner-CrDrPUtY.js} +3411 -1640
  7. package/dist/api/schema.d.ts +2 -5630
  8. package/dist/api/schema.js +7 -7
  9. package/dist/api.d.ts +3 -1
  10. package/dist/api.js +268 -287
  11. package/dist/{app-DAB3fzyp.d.ts → app-BrMMzjYm.d.ts} +10 -3
  12. package/dist/app.d.ts +1 -1
  13. package/dist/app.js +371 -223
  14. package/dist/{automation-CmeFBSEh.js → automation-p87hg_AV.js} +74 -74
  15. package/dist/{briefs-CWKjka7v.js → briefs-PtODdLNu.js} +4 -4
  16. package/dist/{catalog-runtime-cMlAI5LY.js → catalog-runtime-BsoSmTM0.js} +1 -1
  17. package/dist/cli/chat.js +16 -26
  18. package/dist/cli/check.js +3 -3
  19. package/dist/cli/main.js +5 -3
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/snapshot-create.js +4 -4
  22. package/dist/cli/upgrade.d.ts +1 -1
  23. package/dist/cli/upgrade.js +3 -3
  24. package/dist/{client-BjgbMawj.js → client-Cqf4TboL.js} +20 -15
  25. package/dist/{config-CdB6yJj5.js → config-CPsE4T5L.js} +2 -2
  26. package/dist/{connections-RE_65jzK.js → connections-upFXLmhG.js} +10 -11
  27. package/dist/{conversation-DSo310Ps.js → conversation-CTpD_PGk.js} +7 -84
  28. package/dist/{conversation-privacy-BzgJC5k0.js → conversation-privacy-D6zJc8ff.js} +1 -1
  29. package/dist/{credential-sync-DhEGEpgq.js → credential-sync-CS_6IC-f.js} +30 -34
  30. package/dist/{credentialed-CIGwoLU2.js → credentialed-BU-OW7HP.js} +577 -74
  31. package/dist/{store-B8CABbmR.d.ts → db-BzOCzVb1.d.ts} +17 -7
  32. package/dist/{executor-VYrx_K4w.js → executor-CNS7ONt-.js} +78 -4
  33. package/dist/instrumentation.js +2 -2
  34. package/dist/{assistant-reply-CT7VcXQe.js → interruption-marker-g6Xup3Fk.js} +8 -2
  35. package/dist/{job-queue-C0BZSa7r.js → job-queue-DI-k-Bbk.js} +2 -2
  36. package/dist/{list-1XQP-o6K.js → list-CGoQdXTp.js} +429 -1401
  37. package/dist/locks-D-0h111u.js +48 -0
  38. package/dist/{logging-DuZ1A4ab.js → logging-n7knse-O.js} +1 -1
  39. package/dist/{history-C84mlAwO.js → media-85PDJxO_.js} +83 -1
  40. package/dist/{message-NKSbbnA6.js → message-BpaWd8TT.js} +4 -4
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +3 -3
  43. package/dist/{oauth-callback-server-qAHLPtml.js → oauth-callback-server-CpGmEw_i.js} +2 -2
  44. package/dist/{prompt-BW9jFsqZ.js → prompt-BlQB0QQt.js} +1 -1
  45. package/dist/{registry-FQutO926.js → registry-By36_xsm.js} +2 -2
  46. package/dist/reporting-schema-CZREhYc-.js +104 -0
  47. package/dist/reporting-window-CVarfId9.js +255 -0
  48. package/dist/{resolve-Bk4yeuHy.js → resolve-CUIBcdPd.js} +3 -3
  49. package/dist/{result-B9e9ATOU.js → result-BemsOMOO.js} +31 -12
  50. package/dist/{runner-C3S2ObH-.js → runner-BVok7PAA.js} +12 -11
  51. package/dist/{sandbox-egress-signals-DqpGzzMB.js → sandbox-egress-signals-BSUWQI95.js} +1 -1
  52. package/dist/{schema-X7Fj4fv1.js → schema-ChnFo5f2.js} +98 -6
  53. package/dist/schema-jK4-1u_H.d.ts +5927 -0
  54. package/dist/{service-account-Do30HUNv.js → service-account-DHvlLnZw.js} +4 -3
  55. package/dist/{service-account-BQasl-qq.js → service-account-hMmESDcr.js} +3 -3
  56. package/dist/{session-stop-DkOjt46_.js → session-stop-BQW_iFcd.js} +499 -23
  57. package/dist/{skills-CQHrwfOa.js → skills-DmJJIuLF.js} +2 -2
  58. package/dist/{spawn-BHuqN14f.js → spawn-ChCm46i-.js} +2 -2
  59. package/dist/{store-6EetVP-m.js → store-1DVhoKOL.js} +4 -4
  60. package/dist/{store-DvNZIsCr.js → store-DCo2n5iJ.js} +3 -3
  61. package/dist/{task-queue-B0DLgd2P.js → task-queue-HMC4QjFm.js} +3 -3
  62. package/dist/task-runner-cA6yjn_E.js +269 -0
  63. package/dist/{thread-state-DRmdJ2QN.js → thread-state-CHy8LS0C.js} +8 -18
  64. package/dist/{turn-failure-response-G11cs2gE.js → turn-failure-response-Dr7erLWs.js} +11 -16
  65. package/dist/{turn-lifecycle-OzLIwvi1.js → turn-lifecycle-bf2fIYi_.js} +1 -1
  66. package/dist/{tasks-0ilmuCux.js → turn-session-routing-BqO0qXLk.js} +959 -44
  67. package/dist/{validation-CxEmt1id.js → validation-DHR1ivfh.js} +1 -1
  68. package/dist/{version-Bapedn4A.js → version-CXCHLgWm.js} +1 -1
  69. package/dist/version.js +1 -1
  70. package/dist/{viewer-DrN3oC2X.js → viewer-DSbD6DF6.js} +503 -241
  71. package/dist/{work-DUQoNcqP.js → work-BE_qTYGi.js} +17 -36
  72. package/dist/{worker-D1l4Ugk0.js → worker-Cm9_sWXg.js} +15 -7
  73. package/migrations/0065_user_customization.sql +1 -0
  74. package/migrations/0066_review_items.sql +53 -0
  75. package/migrations/0067_review_item_dedupe_tenant.sql +2 -0
  76. package/migrations/0068_review_item_slack_cards.sql +10 -0
  77. package/migrations/0069_system_identity.sql +25 -0
  78. package/migrations/0070_review_item_foreign_keys.sql +5 -0
  79. package/migrations/AGENTS.md +17 -0
  80. package/migrations/meta/0065_snapshot.json +3511 -0
  81. package/migrations/meta/0066_snapshot.json +4099 -0
  82. package/migrations/meta/0067_snapshot.json +3921 -0
  83. package/migrations/meta/0068_snapshot.json +4176 -0
  84. package/migrations/meta/0069_snapshot.json +3979 -0
  85. package/migrations/meta/0070_snapshot.json +3997 -0
  86. package/migrations/meta/_journal.json +42 -0
  87. package/package.json +5 -5
  88. package/dist/db-Bg-zC3r5.d.ts +0 -5
  89. package/dist/history-BgI33Kie.d.ts +0 -78
  90. package/dist/images-CecjXAAz.js +0 -64
  91. package/dist/task-runner-B-PD_JOj.js +0 -1074
  92. package/dist/turn-session-routing-Dyut9l7Y.js +0 -76
  93. package/dist/user-input-request-BDFBdF8r.js +0 -116
  94. package/dist/web-message-id-CJSUiksE.js +0 -236
  95. package/migrations/README.md +0 -30
@@ -1,6 +1,10 @@
1
+ import "./schema-jK4-1u_H.js";
1
2
  import { z } from "zod";
2
3
  import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
4
+ import "drizzle-orm/pg-core";
3
5
  import "@earendil-works/pi-ai";
6
+ import "drizzle-orm/migrator";
7
+ import "drizzle-orm/pg-core/session";
4
8
  type ConversationPrivacy = "public" | "private";
5
9
  /** Validated Location associated with a Conversation. */
6
10
  type Location = z.output<typeof locationSchema>;
@@ -48,6 +52,11 @@ type Usage = z.output<typeof usageSchema>;
48
52
  type AgentTurnUsage = Usage;
49
53
  type ConversationSource = "api" | "internal" | "local" | "plugin" | "event" | "scheduler" | "slack" | "web";
50
54
  type ConversationStatus = "paused" | "failed" | "idle" | "pending" | "running";
55
+ /** Cumulative duration and usage that one Run reported. */
56
+ interface ConversationRunMetrics {
57
+ durationMs: number;
58
+ usage?: AgentTurnUsage;
59
+ }
51
60
  interface ConversationExecution {
52
61
  lastCheckpointAtMs?: number;
53
62
  lastEnqueuedAtMs?: number;
@@ -73,10 +82,9 @@ interface Conversation {
73
82
  createdAtMs: number;
74
83
  destination?: Destination;
75
84
  execution: ConversationExecution;
76
- executionMetrics?: {
77
- durationMs: number;
85
+ /** Metrics of the latest Run that wrote metrics. */
86
+ executionMetrics?: ConversationRunMetrics & {
78
87
  runId?: string;
79
- usage?: AgentTurnUsage;
80
88
  };
81
89
  lastActivityAtMs: number;
82
90
  /** Immutable parent Conversation. */
@@ -115,6 +123,11 @@ interface ConversationStore {
115
123
  get(args: {
116
124
  conversationId: string;
117
125
  }): Promise<Conversation | undefined>;
126
+ /** Read one Run's stored metrics, including a Run that is not the latest. */
127
+ getRunMetrics(args: {
128
+ conversationId: string;
129
+ runId: string;
130
+ }): Promise<ConversationRunMetrics | undefined>;
118
131
  /** Resolve the durable conversation bound to one provider conversation. */
119
132
  getConversationIdByProviderConversation(args: {
120
133
  provider: string;
@@ -180,10 +193,7 @@ interface ConversationStore {
180
193
  destination?: Destination;
181
194
  execution: ConversationExecution;
182
195
  lastActivityAtMs: number;
183
- metrics: {
184
- durationMs: number;
185
- usage?: AgentTurnUsage;
186
- } | null;
196
+ metrics: ConversationRunMetrics | null;
187
197
  actor?: StoredSlackActor;
188
198
  source?: ConversationSource;
189
199
  title?: string;
@@ -1,6 +1,6 @@
1
- import "./config-CdB6yJj5.js";
2
- import { p as logException } from "./logging-DuZ1A4ab.js";
3
- import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, f as timestamptz, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-CxKldAeB.js";
1
+ import "./config-CPsE4T5L.js";
2
+ import { p as logException } from "./logging-n7knse-O.js";
3
+ import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, f as timestamptz, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-C1RNOCs8.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { sql } from "drizzle-orm";
6
6
  import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, uniqueIndex, uuid } from "drizzle-orm/pg-core";
@@ -382,6 +382,76 @@ const juniorAutomationRuns = pgTable("junior_automation_runs", {
382
382
  index("junior_automation_runs_completed_idx").on(table.completedAtMs),
383
383
  index("junior_automation_runs_incomplete_idx").on(table.automationId, table.scheduledForMs).where(sql`${table.status} in ('pending', 'running')`)
384
384
  ]);
385
+ // src/db/schema/review-items.ts
386
+ /**
387
+ * One Review item: something that needs a person. See
388
+ * `chat/review-items/AGENTS.md`. An action item stores its `request`, and
389
+ * its `answer` after an assignee submits it. `closed_at` is set for `done`
390
+ * and `dismissed`. `closed_by_user_id` is null when an agent closed it.
391
+ */
392
+ const juniorReviewItems = pgTable("junior_review_items", {
393
+ id: text("id").primaryKey(),
394
+ kind: text("kind").$type().notNull(),
395
+ status: text("status").$type().notNull(),
396
+ /**
397
+ * `private` when the Conversation that added it is not public. A private
398
+ * item stays private and links only to that Conversation.
399
+ */
400
+ visibility: text("visibility").$type().notNull(),
401
+ title: text("title").notNull(),
402
+ body: text("body").notNull(),
403
+ request: jsonb("request").$type(),
404
+ answer: jsonb("answer").$type(),
405
+ assignedToEveryone: boolean("assigned_to_everyone").notNull().default(false),
406
+ dedupeKey: text("dedupe_key").notNull(),
407
+ subjectId: text("subject_id"),
408
+ subjectTitle: text("subject_title"),
409
+ subjectUrl: text("subject_url"),
410
+ /** Conversation of the agent that added the item. */
411
+ addedByConversationId: text("added_by_conversation_id").notNull().references(() => juniorConversations.conversationId, { onDelete: "cascade" }),
412
+ /**
413
+ * Provider tenant, such as a Slack workspace, of the Conversation that
414
+ * added the item. A public item is visible only inside it.
415
+ */
416
+ provider: text("provider"),
417
+ providerTenantId: text("provider_tenant_id"),
418
+ automationId: text("automation_id").references(() => juniorAutomations.id, { onDelete: "set null" }),
419
+ closedAt: timestamptz("closed_at"),
420
+ closedByUserId: text("closed_by_user_id").references(() => juniorUsers.id, { onDelete: "set null" }),
421
+ closeReason: text("close_reason"),
422
+ createdAt: timestamptz("created_at").notNull(),
423
+ updatedAt: timestamptz("updated_at").notNull()
424
+ }, (table) => [
425
+ check("junior_review_items_kind_check", sql`(${table.kind} = 'notice' and ${table.request} is null and ${table.answer} is null) or (${table.kind} = 'action' and ${table.request} is not null)`),
426
+ check("junior_review_items_status_check", sql`(${table.status} = 'open' and ${table.closedAt} is null) or (${table.status} in ('done', 'dismissed') and ${table.closedAt} is not null)`),
427
+ check("junior_review_items_tenant_check", sql`(${table.provider} is null) = (${table.providerTenantId} is null)`),
428
+ check("junior_review_items_visibility_check", sql`${table.visibility} = 'public' or not ${table.assignedToEveryone}`),
429
+ uniqueIndex("junior_review_items_open_dedupe_uidx").on(sql`coalesce(${table.provider}, '')`, sql`coalesce(${table.providerTenantId}, '')`, table.dedupeKey).where(sql`${table.status} = 'open'`),
430
+ index("junior_review_items_status_idx").on(table.status, table.updatedAt, table.id),
431
+ index("junior_review_items_subject_idx").on(table.subjectId, table.status),
432
+ index("junior_review_items_automation_idx").on(table.automationId, table.status)
433
+ ]);
434
+ /** The assigned Users of a Review item. Everyone is a flag on the item. */
435
+ const juniorReviewItemAssignees = pgTable("junior_review_item_assignees", {
436
+ itemId: text("item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
437
+ userId: text("user_id").notNull().references(() => juniorUsers.id, { onDelete: "cascade" })
438
+ }, (table) => [primaryKey({ columns: [table.itemId, table.userId] }), index("junior_review_item_assignees_user_idx").on(table.userId)]);
439
+ /** The Conversations linked to a Review item. */
440
+ const juniorReviewItemConversations = pgTable("junior_review_item_conversations", {
441
+ itemId: text("item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
442
+ conversationId: text("conversation_id").notNull().references(() => juniorConversations.conversationId, { onDelete: "cascade" })
443
+ }, (table) => [primaryKey({ columns: [table.itemId, table.conversationId] }), index("junior_review_item_conversations_conversation_idx").on(table.conversationId)]);
444
+ /**
445
+ * The Slack message that shows a Review item in one linked Slack thread.
446
+ * Junior updates it in place after each change.
447
+ */
448
+ const juniorReviewItemSlackCards = pgTable("junior_review_item_slack_cards", {
449
+ itemId: text("item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
450
+ conversationId: text("conversation_id").notNull().references(() => juniorConversations.conversationId, { onDelete: "cascade" }),
451
+ teamId: text("team_id").notNull(),
452
+ channelId: text("channel_id").notNull(),
453
+ messageTs: text("message_ts").notNull()
454
+ }, (table) => [primaryKey({ columns: [table.itemId, table.conversationId] })]);
385
455
  // src/db/schema/workspaces.ts
386
456
  /** Named recipe used to prepare a reusable Sandbox. */
387
457
  const juniorWorkspaces = pgTable("junior_workspaces", {
@@ -455,6 +525,10 @@ const juniorSqlSchema = {
455
525
  juniorLocationConfigurations,
456
526
  juniorDestinations,
457
527
  juniorIdentities,
528
+ juniorReviewItemAssignees,
529
+ juniorReviewItemConversations,
530
+ juniorReviewItemSlackCards,
531
+ juniorReviewItems,
458
532
  juniorSnapshots,
459
533
  juniorStats,
460
534
  juniorAutomationRuns,
@@ -709,4 +783,4 @@ function createJuniorSqlExecutor(args) {
709
783
  statementTimeoutMs
710
784
  });
711
785
  }
712
- export { juniorConversationAnnotations as _, juniorAutomationRuns as a, juniorAttachments as b, juniorStats as c, juniorConversationBindings as d, juniorConversationBriefs as f, juniorApiTokens as g, juniorConversationEvents as h, juniorWorkspaces as i, juniorLocationConfigurations as l, juniorConversationMetrics as m, juniorSnapshots as n, juniorAutomationVersions as o, CONVERSATION_METRICS as p, juniorWorkspaceRepos as r, juniorAutomations as s, createJuniorSqlExecutor as t, juniorConversationParticipants as u, juniorCodeChanges as v, juniorArtifacts as x, juniorCodeRepositories as y };
786
+ export { juniorCodeRepositories as C, juniorCodeChanges as S, juniorArtifacts as T, CONVERSATION_METRICS as _, juniorReviewItemAssignees as a, juniorApiTokens as b, juniorReviewItems as c, juniorAutomations as d, juniorStats as f, juniorConversationBriefs as g, juniorConversationBindings as h, juniorWorkspaces as i, juniorAutomationRuns as l, juniorConversationParticipants as m, juniorSnapshots as n, juniorReviewItemConversations as o, juniorLocationConfigurations as p, juniorWorkspaceRepos as r, juniorReviewItemSlackCards as s, createJuniorSqlExecutor as t, juniorAutomationVersions as u, juniorConversationMetrics as v, juniorAttachments as w, juniorConversationAnnotations as x, juniorConversationEvents as y };
@@ -1,6 +1,6 @@
1
- import { F as getDeploymentServiceVersion, I as getDeploymentTelemetryAttributes } from "./logging-DuZ1A4ab.js";
1
+ import { F as getDeploymentServiceVersion, I as getDeploymentTelemetryAttributes } from "./logging-n7knse-O.js";
2
2
  import { a as getClient, c as init, o as getGlobalScope } from "./sentry-MDkYAVPV.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-BzgJC5k0.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-D6zJc8ff.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
5
5
  // src/chat/sentry-payload-filter.ts
6
6
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { Fn as extractAssistantText } from "./tasks-0ilmuCux.js";
1
+ import { gr as extractAssistantText } from "./turn-session-routing-BqO0qXLk.js";
2
2
  // src/chat/no-reply.ts
3
3
  const NO_REPLY_MARKER = "[[NO_REPLY]]";
4
4
  /**
@@ -40,4 +40,10 @@ function getAssistantReplyText(message) {
40
40
  const decision = decideReply(message);
41
41
  return decision.kind === "deliver" ? decision.text : void 0;
42
42
  }
43
- export { isNoReplyMarker as a, NO_REPLY_MARKER as i, getAssistantReplyText as n, sanitizeAssistantText as r, decideReply as t };
43
+ // src/chat/interruption-marker.ts
44
+ const INTERRUPTED_MARKER = "\n\n[Response interrupted before completion]";
45
+ /** Return the marker added when a visible reply ended mid-execution. */
46
+ function getInterruptionMarker() {
47
+ return INTERRUPTED_MARKER;
48
+ }
49
+ export { NO_REPLY_MARKER as a, sanitizeAssistantText as i, decideReply as n, isNoReplyMarker as o, getAssistantReplyText as r, getInterruptionMarker as t };
@@ -1,5 +1,5 @@
1
- import { i as getChatConfig } from "./config-CdB6yJj5.js";
2
- import { E as withSpan, m as logInfo, p as logException } from "./logging-DuZ1A4ab.js";
1
+ import { i as getChatConfig } from "./config-CPsE4T5L.js";
2
+ import { E as withSpan, m as logInfo, p as logException } from "./logging-n7knse-O.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { z } from "zod";
5
5
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";