@sentry/junior 0.184.0 → 0.186.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 (129) hide show
  1. package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-4B3Z4WRK.js} +13 -11
  2. package/dist/api/acp/schema.d.ts +20 -2
  3. package/dist/api/code/overview.d.ts +39 -0
  4. package/dist/api/locations/detail.d.ts +1 -1
  5. package/dist/api/people/code.d.ts +22 -0
  6. package/dist/api/schema/code.d.ts +46 -0
  7. package/dist/api/schema/conversation.d.ts +108 -20
  8. package/dist/api/schema/location.d.ts +1 -1
  9. package/dist/api/schema/person.d.ts +1 -1
  10. package/dist/api/schema.d.ts +4 -4
  11. package/dist/api/schema.js +12 -1
  12. package/dist/api.js +368 -78
  13. package/dist/app.js +1412 -538
  14. package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AFJCAOHC.js} +4 -4
  15. package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
  16. package/dist/chat/api-turns/cancellation.d.ts +3 -5
  17. package/dist/chat/api-turns/mailbox-input.d.ts +7 -0
  18. package/dist/chat/api-turns/routing.d.ts +18 -3
  19. package/dist/chat/api-turns/work.d.ts +4 -9
  20. package/dist/chat/app/conversation-work.d.ts +1 -1
  21. package/dist/chat/app/factory.d.ts +4 -0
  22. package/dist/chat/app/services.d.ts +4 -3
  23. package/dist/chat/conversations/history.d.ts +83 -9
  24. package/dist/chat/conversations/turn-lifecycle.d.ts +6 -3
  25. package/dist/chat/providers/slack/input.d.ts +32 -0
  26. package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
  27. package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
  28. package/dist/chat/providers/slack/runtime.d.ts +1 -12
  29. package/dist/chat/providers/slack/turn.d.ts +10 -25
  30. package/dist/chat/resource-events/actor.d.ts +7 -2
  31. package/dist/chat/resource-events/app-publisher.d.ts +18 -0
  32. package/dist/chat/resource-events/catalog.d.ts +19 -0
  33. package/dist/chat/resource-events/ingest.d.ts +0 -1
  34. package/dist/chat/resource-events/notification.d.ts +28 -3
  35. package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
  36. package/dist/chat/resource-events/store.d.ts +2 -14
  37. package/dist/chat/resource-events/tool-support.d.ts +0 -5
  38. package/dist/chat/resource-events/workspace.d.ts +7 -3
  39. package/dist/chat/runtime/turn-execution.d.ts +7 -2
  40. package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
  41. package/dist/chat/sandbox/egress/session.d.ts +10 -11
  42. package/dist/chat/sandbox/errors.d.ts +1 -1
  43. package/dist/chat/sandbox/ref.d.ts +1 -1
  44. package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
  45. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
  46. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  47. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  48. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  49. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  50. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  51. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  52. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  53. package/dist/chat/sentry-links.d.ts +2 -0
  54. package/dist/chat/services/provider-retry.d.ts +2 -0
  55. package/dist/chat/services/turn-failure-response.d.ts +4 -0
  56. package/dist/chat/services/turn-session-routing.d.ts +20 -5
  57. package/dist/chat/task-execution/paused-turn.d.ts +0 -2
  58. package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
  59. package/dist/chat/task-execution/slack-work.d.ts +0 -21
  60. package/dist/chat/task-execution/state.d.ts +2 -2
  61. package/dist/chat/task-execution/store.d.ts +1 -1
  62. package/dist/chat/task-execution/turn-wake.d.ts +12 -0
  63. package/dist/chat/tool-support/action-review.d.ts +1 -1
  64. package/dist/chat/tools/event-tasks.d.ts +1 -1
  65. package/dist/chat/tools/resource-events.d.ts +2 -2
  66. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  67. package/dist/chat/tools/types.d.ts +1 -1
  68. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  69. package/dist/{chunk-Z3QAXJR7.js → chunk-2IBDVE62.js} +12 -9
  70. package/dist/{chunk-4RONS3WR.js → chunk-2U7EPTRZ.js} +11 -5
  71. package/dist/{chunk-3S7ULUWW.js → chunk-3CVEE6LA.js} +1 -1
  72. package/dist/{chunk-IZDYYYGP.js → chunk-43LODHJM.js} +24 -384
  73. package/dist/{chunk-LHXIZLFF.js → chunk-64WF2GQ3.js} +1 -1
  74. package/dist/{chunk-YKX6MTLU.js → chunk-7EOWT62G.js} +1 -1
  75. package/dist/{chunk-UBOIHNTH.js → chunk-7EU4YSZ4.js} +362 -188
  76. package/dist/{chunk-UF6BUA5W.js → chunk-ACGWTJ74.js} +3 -3
  77. package/dist/{chunk-6UDPINOX.js → chunk-AD64YMEC.js} +19 -44
  78. package/dist/{chunk-MLSQX2EX.js → chunk-BRKB5R7P.js} +1 -1
  79. package/dist/{chunk-E57WPXWY.js → chunk-CM6RTYSO.js} +5 -5
  80. package/dist/{chunk-MAPJFUMV.js → chunk-CV5CPRVG.js} +3 -3
  81. package/dist/chunk-D4YV5TDV.js +45 -0
  82. package/dist/{chunk-HIPUIPJM.js → chunk-DHYZ4VKG.js} +383 -254
  83. package/dist/{chunk-DUKIDPF6.js → chunk-DOP3FIQC.js} +1 -1
  84. package/dist/{chunk-BT53RIGJ.js → chunk-EWRPUXE3.js} +12 -50
  85. package/dist/{chunk-BHYRYYLY.js → chunk-FFYDRLXW.js} +1 -1
  86. package/dist/chunk-GFBR4S3Q.js +406 -0
  87. package/dist/chunk-GQMQCY7H.js +58 -0
  88. package/dist/{chunk-JNO2GUDS.js → chunk-GSB3NTNS.js} +926 -1856
  89. package/dist/{chunk-2ZQPVX7C.js → chunk-H7X2G2KS.js} +25 -12
  90. package/dist/{chunk-WQFEWULF.js → chunk-HKFLRIBD.js} +2 -2
  91. package/dist/{chunk-SHJK75Z2.js → chunk-HWXP6RHG.js} +38 -4
  92. package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
  93. package/dist/{chunk-4CNDGK25.js → chunk-JFPY6XFF.js} +911 -993
  94. package/dist/{chunk-6WGC3SO4.js → chunk-MCLWOBPN.js} +80 -18
  95. package/dist/{chunk-PJPRXO2T.js → chunk-NRMAOGRS.js} +1 -1
  96. package/dist/{chunk-ACPDVEJO.js → chunk-O6GQO7VP.js} +201 -218
  97. package/dist/{chunk-M5YWNMTE.js → chunk-OZG7E22Y.js} +24 -6
  98. package/dist/{chunk-WVIA7V3M.js → chunk-PFAZSRGR.js} +29 -1
  99. package/dist/{chunk-LCP4EDKR.js → chunk-PZZOGHVR.js} +14 -4
  100. package/dist/{chunk-QABCY33S.js → chunk-QBL2AVFF.js} +2 -2
  101. package/dist/{chunk-FKEZZMXS.js → chunk-QU3URVWG.js} +9 -94
  102. package/dist/{chunk-M3QYTBQ6.js → chunk-STOCCPWH.js} +11 -2
  103. package/dist/{chunk-K7VDC2QW.js → chunk-TXLBLGNQ.js} +6 -6
  104. package/dist/{chunk-JA43DV4Y.js → chunk-VOGOTEW7.js} +1 -1
  105. package/dist/{chunk-HUXFMDBZ.js → chunk-VQIWBJOP.js} +1 -1
  106. package/dist/{chunk-JM2COLGC.js → chunk-VQZYIVYN.js} +6 -6
  107. package/dist/{chunk-BCHYQS4B.js → chunk-VXL2LBPK.js} +1 -1
  108. package/dist/{chunk-6VOYP4M6.js → chunk-YXSBZRP7.js} +1 -1
  109. package/dist/cli/chat.js +35 -33
  110. package/dist/cli/check.js +5 -5
  111. package/dist/cli/plugins.js +14 -12
  112. package/dist/cli/snapshot-create.js +10 -9
  113. package/dist/cli/upgrade.js +7 -6
  114. package/dist/{db-MA52H62H.js → db-7XL4UPAE.js} +8 -6
  115. package/dist/instrumentation.js +3 -3
  116. package/dist/nitro.js +7 -6
  117. package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-RAOYHWDI.js} +30 -27
  118. package/dist/{runner-4IXUAQNK.js → runner-KMPBWRPM.js} +24 -19
  119. package/dist/{skills-X3DY7AXO.js → skills-IPCALGLQ.js} +5 -5
  120. package/dist/spawn-OSOWTMBG.js +41 -0
  121. package/dist/task-runner-IQNBA3RY.js +34 -0
  122. package/dist/{validation-Z6JXSTJS.js → validation-BSRCCX6N.js} +5 -5
  123. package/dist/version.js +1 -1
  124. package/dist/{work-OKWRFBDW.js → work-T6UFTOJY.js} +24 -19
  125. package/dist/worker-L35OG7VA.js +24 -0
  126. package/package.json +5 -5
  127. package/dist/spawn-43WGS6CH.js +0 -37
  128. package/dist/task-runner-VDRKITPV.js +0 -32
  129. package/dist/worker-B236AE72.js +0 -22
@@ -1,39 +1,24 @@
1
1
  /**
2
- * Add Slack provider behavior around one native agent Turn.
2
+ * Add Slack behavior around one Turn.
3
3
  *
4
- * This module prepares Slack input and owns Slack status, delivery, and saved
5
- * Slack state. Native execution concerns that remain here must move behind a
6
- * provider-neutral runtime contract. Agent execution stays behind
7
- * `AgentRunner`.
4
+ * This module owns Slack status, delivery, and state.
5
+ * It calls `executeTurn` to run and finish the Turn.
8
6
  */
9
7
  import type { Message, Thread } from "chat";
10
8
  import type { SlackAdapter } from "@chat-adapter/slack";
11
9
  import { type Destination } from "@sentry/junior-plugin-api";
12
- import type { AgentRunner } from "@/chat/runtime/agent-runner";
10
+ import { type ExecuteTurn } from "@/chat/runtime/turn-execution";
13
11
  import type { PreparedTurnState } from "@/chat/runtime/turn-preparation";
14
12
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnToolInvocation } from "@/chat/runtime/turn-input";
15
13
  import type { ContextCompactor } from "@/chat/services/context-compaction";
16
- import { lookupSlackUser } from "@/chat/slack/user";
17
- import type { PausedTurnRequest } from "@/chat/task-execution/turn-wake";
18
- import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
14
+ import type { PausedTurns } from "@/chat/task-execution/turn-wake";
15
+ import { type ScheduleSessionCompletedPluginTasksOptions } from "@/chat/plugins/task-runner";
19
16
  import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
20
- export interface SlackTurnServices {
21
- agentRunner: AgentRunner;
22
- contextCompactor: ContextCompactor;
23
- getPausedTurnRequest: (args: {
24
- conversationId: string;
25
- turnId: string;
26
- }) => Promise<PausedTurnRequest | undefined>;
27
- lookupSlackUser: typeof lookupSlackUser;
28
- turnLifecycle: ConversationTurnLifecycle;
29
- wakePausedTurn: (request: PausedTurnRequest) => Promise<void>;
30
- scheduleSessionCompletedPluginTasks: (params: {
31
- conversationId: string;
32
- sessionId: string;
33
- }) => Promise<void>;
34
- }
35
17
  interface SlackTurnDeps {
18
+ contextCompactor: ContextCompactor;
19
+ executeTurn: ExecuteTurn;
36
20
  getSlackAdapter: () => SlackAdapter;
21
+ pausedTurns: PausedTurns;
37
22
  resolveUserAttachments: (attachments: Message["attachments"] | undefined, context: {
38
23
  threadId?: string;
39
24
  actorId?: string;
@@ -48,7 +33,7 @@ interface SlackTurnDeps {
48
33
  promptText?: string;
49
34
  }>>;
50
35
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<PreparedTurnState>;
51
- services: SlackTurnServices;
36
+ sendPluginTask?: ScheduleSessionCompletedPluginTasksOptions["send"];
52
37
  }
53
38
  /** Build the Slack caller that prepares input and delivers output for a Turn. */
54
39
  export declare function createSlackTurn(deps: SlackTurnDeps): (thread: Thread, message: Message, options: {
@@ -1,5 +1,10 @@
1
- /** Synthetic Slack author id stamped on resource-event mailbox messages. */
2
- export declare const RESOURCE_EVENT_SLACK_AUTHOR_ID = "UJRNEVENT";
1
+ /**
2
+ * Synthetic author id stamped on resource-event mailbox messages.
3
+ *
4
+ * Kept stable so provider adapters and conversation history can recognize the
5
+ * same system input for resource-event turns.
6
+ */
7
+ export declare const RESOURCE_EVENT_AUTHOR_ID = "UJRNEVENT";
3
8
  /** System execution actor for every resource-event turn. */
4
9
  export declare const RESOURCE_EVENT_SYSTEM_ACTOR: {
5
10
  readonly platform: "system";
@@ -0,0 +1,18 @@
1
+ import type { ResourceEvent } from "@sentry/junior-plugin-api";
2
+ import type { StateAdapter } from "chat";
3
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
4
+ export type ResourceEventAppPublisher = {
5
+ neededMatchKeys(input: {
6
+ eventTypes: string[];
7
+ identifiers: string[];
8
+ namespace: string;
9
+ }): Promise<string[]>;
10
+ publish(event: ResourceEvent): Promise<void>;
11
+ };
12
+ /** Build the core resource-event publisher used by plugin routes. */
13
+ export declare function createResourceEventAppPublisher(args: {
14
+ conversationWork: () => {
15
+ queue?: ConversationWorkQueue;
16
+ state?: StateAdapter;
17
+ };
18
+ }): ResourceEventAppPublisher;
@@ -2,6 +2,25 @@ import { type PluginResourceEvents, type ResourceEventMatch, type ResourceEventM
2
2
  import { z } from "zod";
3
3
  type ResourceEventRegistration = Pick<PluginResourceEvents, "resourceTypes" | "normalizeIdentifier">;
4
4
  export type ResourceEventCatalog = Readonly<Record<string, ResourceEventRegistration>>;
5
+ /** Core-owned resource-event namespace. Not a plugin publisher. */
6
+ export declare const CORE_RESOURCE_EVENT_NAMESPACE = "junior";
7
+ /** True when the catalog has any enabled registration. */
8
+ export declare function hasResourceEventCatalogEntries(catalog: ResourceEventCatalog): boolean;
9
+ /**
10
+ * True when at least one plugin namespace is enabled.
11
+ *
12
+ * Core Workspace snapshot events stay in the catalog for search and temporary
13
+ * watches. Durable event tasks still require a plugin publisher.
14
+ */
15
+ export declare function hasPluginResourceEventCatalogEntries(catalog: ResourceEventCatalog): boolean;
16
+ /**
17
+ * Catalog entries that durable event tasks may select.
18
+ *
19
+ * Core Workspace snapshot events only wake temporary watches. Snapshot finish
20
+ * does not run event-task ingest, so those namespaces stay out of create/update
21
+ * schemas and trigger availability.
22
+ */
23
+ export declare function pluginResourceEventCatalog(catalog: ResourceEventCatalog): ResourceEventCatalog;
5
24
  /** Build the model-facing namespace enum from enabled resource event plugins. */
6
25
  export declare function eventNamespaceSchema(catalog: ResourceEventCatalog): z.ZodString | z.ZodEnum<{
7
26
  [x: string]: string;
@@ -5,7 +5,6 @@ export declare function ingestResourceEvent(input: unknown, options: {
5
5
  nowMs?: number;
6
6
  queue: ConversationWorkQueue;
7
7
  state?: StateAdapter;
8
- teamId: string;
9
8
  }): Promise<{
10
9
  enqueued: number;
11
10
  }>;
@@ -1,5 +1,5 @@
1
1
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
2
- import { appendAndEnqueueInboundMessage } from "@/chat/task-execution/store";
2
+ import { appendAndEnqueueInboundMessage, type AppendAndEnqueueInboundMessageResult, type InboundMessage } from "@/chat/task-execution/store";
3
3
  import type { ResourceEventSubscription } from "@/chat/resource-events/store";
4
4
  export interface ResourceEventNotification {
5
5
  eventKey: string;
@@ -19,10 +19,35 @@ export interface ResourceEventNotification {
19
19
  * contract. Stable delivery rules live in runtime and docs, not this prompt.
20
20
  */
21
21
  export declare function renderResourceEventNotificationText(subscription: Pick<ResourceEventSubscription, "intent" | "label" | "resourceType">, event: Pick<ResourceEventNotification, "namespace" | "eventType" | "trustedSummary" | "data" | "untrustedText">): string;
22
- /** Enqueue a resource event as normal conversation mailbox input. */
22
+ /** Resource-event identity stamped on plain mailbox input. */
23
+ export type ResourceEventMailboxMetadata = {
24
+ kind: "resource_event";
25
+ resourceEvent: {
26
+ eventKey: string;
27
+ eventType: string;
28
+ namespace: string;
29
+ identifier: string;
30
+ subscriptionId: string;
31
+ };
32
+ } & Record<string, unknown>;
33
+ /** Whether mailbox metadata is a plain resource-event wake. */
34
+ export declare function isResourceEventMailboxMetadata(value: unknown): value is ResourceEventMailboxMetadata;
35
+ /** Build plain conversation mailbox input for one matched watch. */
36
+ export declare function createResourceEventInboundMessage(input: {
37
+ event: ResourceEventNotification;
38
+ subscription: Pick<ResourceEventSubscription, "conversationId" | "id">;
39
+ text: string;
40
+ receivedAtMs?: number;
41
+ }): InboundMessage;
42
+ /**
43
+ * Enqueue a resource event as normal conversation mailbox input.
44
+ *
45
+ * The watch only names the conversation. Destination stays on the conversation
46
+ * and is applied when the worker runs.
47
+ */
23
48
  export declare function enqueueResourceEventNotification(args: {
24
49
  event: ResourceEventNotification;
25
50
  queue: ConversationWorkQueue;
26
51
  subscription: ResourceEventSubscription;
27
52
  state?: Parameters<typeof appendAndEnqueueInboundMessage>[0]["state"];
28
- }): Promise<Awaited<ReturnType<typeof appendAndEnqueueInboundMessage>>>;
53
+ }): Promise<AppendAndEnqueueInboundMessageResult>;
@@ -1,3 +1,8 @@
1
- import type { ResourceEventCatalog } from "@/chat/resource-events/catalog";
2
- /** Read enabled plugin resource-event registrations as one core catalog. */
1
+ import { type ResourceEventCatalog } from "@/chat/resource-events/catalog";
2
+ /**
3
+ * Enabled resource-event registrations for search, guidance, and tool schemas.
4
+ *
5
+ * Includes core Workspace snapshot events under the `junior` namespace, plus
6
+ * every enabled plugin registration. Plugins may not use the `junior` namespace.
7
+ */
3
8
  export declare function getResourceEventCatalog(): ResourceEventCatalog;
@@ -1,17 +1,9 @@
1
1
  import type { StateAdapter } from "chat";
2
- import { type Destination, type ResourceEventData, type ResourceEventMatch } from "@sentry/junior-plugin-api";
2
+ import { type ResourceEventData, type ResourceEventMatch } from "@sentry/junior-plugin-api";
3
3
  import { z } from "zod";
4
4
  declare const subscriptionSchema: z.ZodObject<{
5
5
  conversationId: z.ZodString;
6
6
  createdAtMs: z.ZodNumber;
7
- destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
- platform: z.ZodLiteral<"slack">;
9
- teamId: z.ZodString;
10
- channelId: z.ZodString;
11
- }, z.core.$strict>, z.ZodObject<{
12
- platform: z.ZodLiteral<"local">;
13
- conversationId: z.ZodString;
14
- }, z.core.$strict>], "platform">;
15
7
  events: z.ZodArray<z.ZodString>;
16
8
  expiresAtMs: z.ZodNumber;
17
9
  id: z.ZodString;
@@ -23,15 +15,14 @@ declare const subscriptionSchema: z.ZodObject<{
23
15
  resourceType: z.ZodString;
24
16
  status: z.ZodEnum<{
25
17
  completed: "completed";
26
- active: "active";
27
18
  cancelled: "cancelled";
19
+ active: "active";
28
20
  }>;
29
21
  updatedAtMs: z.ZodNumber;
30
22
  }, z.core.$strict>;
31
23
  export type ResourceEventSubscription = z.output<typeof subscriptionSchema>;
32
24
  export interface CreateResourceEventSubscriptionInput {
33
25
  conversationId: string;
34
- destination: Destination;
35
26
  events: string[];
36
27
  expiresAtMs: number;
37
28
  intent: string;
@@ -75,7 +66,6 @@ export declare function collectResourceEventMatchKeys(input: {
75
66
  namespace: string;
76
67
  nowMs?: number;
77
68
  state?: StateAdapter;
78
- teamId: string;
79
69
  }): Promise<string[]>;
80
70
  /** Find active subscriptions interested in a normalized resource event. */
81
71
  export declare function findMatchingResourceEventSubscriptions(input: {
@@ -85,7 +75,6 @@ export declare function findMatchingResourceEventSubscriptions(input: {
85
75
  namespace: string;
86
76
  identifier: string;
87
77
  state?: StateAdapter;
88
- teamId: string;
89
78
  }): Promise<ResourceEventSubscription[]>;
90
79
  /** Recheck and deliver a matched subscription while holding its status lock. */
91
80
  export declare function deliverResourceEventSubscription(input: {
@@ -97,7 +86,6 @@ export declare function deliverResourceEventSubscription(input: {
97
86
  identifier: string;
98
87
  state?: StateAdapter;
99
88
  subscription: ResourceEventSubscription;
100
- teamId: string;
101
89
  terminal?: boolean;
102
90
  waitDeadlineMs?: number;
103
91
  }): Promise<boolean>;
@@ -1,4 +1,3 @@
1
- import type { ToolRuntimeContext } from "@/chat/tools/types";
2
1
  /** Default lifetime for temporary resource subscriptions. */
3
2
  export declare const RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS: number;
4
3
  /** Hard upper bound for temporary resource subscriptions. */
@@ -8,7 +7,3 @@ export declare const RESOURCE_WATCH_TOOL_SOURCE: {
8
7
  id: string;
9
8
  description: string;
10
9
  };
11
- /** Require the Slack thread identity that owns a resource watch. */
12
- export declare function requireResourceWatchConversation(context: ToolRuntimeContext): string;
13
- /** Return whether the current runtime can safely manage conversation watches. */
14
- export declare function canUseResourceEventSubscriptionTools(context: ToolRuntimeContext): boolean;
@@ -1,4 +1,8 @@
1
- /** Return whether provider events can be bound to one Slack workspace. */
2
- export declare function canRouteResourceEvents(): boolean;
3
- /** Resolve and cache the Slack workspace owned by this app instance. */
1
+ /**
2
+ * Resolve the single-bot Slack team id for event-task indexing.
3
+ *
4
+ * Resource watches do not use this. Event tasks still key by destination team
5
+ * until that store is conversation-owned. Resource-event delivery itself is
6
+ * not gated on Slack.
7
+ */
4
8
  export declare function createResourceEventTeamIdResolver(): () => Promise<string | undefined>;
@@ -1,14 +1,16 @@
1
1
  import type { AgentRun } from "@/chat/agent/types";
2
2
  import type { CompleteConversationTurnInput, FailConversationTurnInput } from "@/chat/conversations/turn-lifecycle";
3
3
  import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
4
- import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
+ import { type AgentRunner } from "@/chat/runtime/agent-runner";
5
5
  import type { AgentRunResult } from "@/chat/services/turn-result";
6
6
  type SavedTurnResult = {
7
7
  finishedAtMs?: number;
8
8
  outcome: CompleteConversationTurnInput["outcome"];
9
9
  } | {
10
+ eventId?: string;
10
11
  finishedAtMs?: number;
11
12
  failureCode: FailConversationTurnInput["failureCode"];
13
+ failureReason?: FailConversationTurnInput["failureReason"];
12
14
  outcome: "failed";
13
15
  };
14
16
  type TurnExecutionOutcome = Exclude<AgentRunOutcome, {
@@ -25,6 +27,9 @@ export declare class AgentRunError extends Error {
25
27
  *
26
28
  * A paused Run, or a Run waiting for authorization, leaves the Turn open. A
27
29
  * save error also leaves the Turn open so the worker can retry or recover it.
30
+ * A timeout aborts the Run before this function reports the failure.
28
31
  */
29
- export declare function executeTurn(agentRunner: AgentRunner, run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>): Promise<TurnExecutionOutcome>;
32
+ export declare function executeTurn(agentRunner: AgentRunner, run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>, timeoutMs?: number): Promise<TurnExecutionOutcome>;
33
+ /** Run the agent and finish a Turn after its caller saves the result. */
34
+ export type ExecuteTurn = (run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>, timeoutMs?: number) => Promise<TurnExecutionOutcome>;
30
35
  export {};
@@ -49,11 +49,12 @@ export declare function selectSandboxEgressGrant(input: {
49
49
  */
50
50
  export declare function authorizationForSandboxEgressGrant(provider: string, selection: SandboxEgressGrantSelection): PluginAuthorization | undefined;
51
51
  /**
52
- * Return cached or newly issued credential header transforms for a selected grant.
52
+ * Return credential header transforms for a selected grant.
53
53
  *
54
- * Leases are cached per actor/context/grant, validated against provider-owned
55
- * domains, and reused only while both the provider lease and sandbox context are
56
- * still valid.
54
+ * Only shared installation grants are remembered on the host. User and other
55
+ * grants always issue from the live credential source so a saved login change
56
+ * cannot leave stale auth headers in place. The sandbox context only authorizes
57
+ * the request.
57
58
  */
58
59
  export declare function sandboxEgressCredentialLease(provider: string, selection: SandboxEgressGrantSelection, context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease>;
59
60
  /** Return whether a credential lease can modify requests to the target host. */
@@ -22,18 +22,17 @@ export declare function createSandboxEgressCredentialToken(input: {
22
22
  */
23
23
  export declare function parseSandboxEgressCredentialToken(token: string | undefined): SandboxEgressCredentialContext | undefined;
24
24
  /**
25
- * Cache credential header transforms for one actor, VM, context token, and grant.
25
+ * Remember auth headers for a shared installation grant.
26
26
  *
27
- * The cache TTL is capped by both the provider lease expiry and the signed
28
- * context expiry so a stale sandbox URL cannot keep using old credentials.
29
- */
30
- export declare function setSandboxEgressCredentialLease(context: SandboxEgressCredentialContext, lease: SandboxEgressCredentialLease): Promise<void>;
31
- /**
32
- * Load cached credential header transforms for the exact actor/context/grant.
33
- */
34
- export declare function getSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease | undefined>;
35
- /** Clear a cached lease after the upstream provider rejects its auth headers. */
36
- export declare function clearSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], context: SandboxEgressCredentialContext): Promise<void>;
27
+ * User and other grants are ignored here. TTL follows the provider expiry.
28
+ * Sandbox context expiry still decides whether a request may use the headers;
29
+ * it does not shorten a shared installation grant for other sandboxes.
30
+ */
31
+ export declare function setSandboxEgressCredentialLease(_context: SandboxEgressCredentialContext, lease: SandboxEgressCredentialLease): Promise<void>;
32
+ /** Load remembered auth headers for a shared installation grant. */
33
+ export declare function getSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], _context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease | undefined>;
34
+ /** Drop remembered installation headers after the upstream rejects them. */
35
+ export declare function clearSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], _context: SandboxEgressCredentialContext): Promise<void>;
37
36
  /**
38
37
  * Record that credential issuance needs user authorization for this command.
39
38
  *
@@ -12,7 +12,7 @@ export declare function isAbortError(error: unknown): boolean;
12
12
  export declare function isSandboxApiTransientError(error: unknown): boolean;
13
13
  /** Detect interrupted command streams where no reliable exit status is available. */
14
14
  export declare function isSandboxCommandStreamInterruptedError(error: unknown): boolean;
15
- /** Wrap raw sandbox setup failures into one stable user-facing error contract. */
15
+ /** Wrap setup failures. Keep WorkspaceSnapshotNotReadyError as-is. */
16
16
  export declare function wrapSandboxSetupError(error: unknown): Error;
17
17
  /** Record span data and throw one stable sandbox operation error. */
18
18
  export declare function throwSandboxOperationError(action: string, error: unknown, includeMissingPath?: boolean): never;
@@ -1,4 +1,4 @@
1
- /** Durable opaque handle used to reopen a conversation's sandbox. */
1
+ /** Sandbox this conversation is using. Reopen by `id`; only switchWorkspace replaces it. */
2
2
  export interface SandboxRef {
3
3
  id: string;
4
4
  profileHash?: string;
@@ -1,8 +1,15 @@
1
- import type { ResourceEvent, SubscribableResource } from "@sentry/junior-plugin-api";
1
+ import type { PluginResourceEvents, ResourceEvent, SubscribableResource } from "@sentry/junior-plugin-api";
2
2
  export declare const WORKSPACE_SNAPSHOT_NAMESPACE = "junior";
3
3
  export declare const WORKSPACE_SNAPSHOT_RESOURCE_TYPE = "workspace_snapshot";
4
4
  export declare const WORKSPACE_SNAPSHOT_READY_EVENT = "workspace_snapshot.ready";
5
5
  export declare const WORKSPACE_SNAPSHOT_FAILED_EVENT = "workspace_snapshot.failed";
6
+ /**
7
+ * Core catalog entry for Workspace snapshot ready and failed events.
8
+ *
9
+ * Uses the same registration shape as plugins so search, guidance, and tool
10
+ * schemas treat these events like any other resource type.
11
+ */
12
+ export declare function workspaceSnapshotResourceEvents(): PluginResourceEvents;
6
13
  /** Describe the events that report when a snapshot build ends. */
7
14
  export declare function workspaceSnapshotWatch(input: {
8
15
  workspaceId: string;
@@ -1,6 +1,11 @@
1
1
  /** Report that a Workspace snapshot is not ready to use. */
2
2
  export declare class WorkspaceSnapshotNotReadyError extends Error {
3
+ readonly workspaceName: string;
3
4
  constructor(workspaceName: string);
4
5
  }
5
- /** Check an error and its causes for a snapshot that is not ready. */
6
+ /** Return WorkspaceSnapshotNotReadyError from this error or its causes. */
7
+ export declare function getWorkspaceSnapshotNotReadyError(error: unknown): WorkspaceSnapshotNotReadyError | undefined;
8
+ /** True when this error or a cause is WorkspaceSnapshotNotReadyError. */
6
9
  export declare function isWorkspaceSnapshotNotReadyError(error: unknown): boolean;
10
+ /** User message when a Workspace sandbox is still preparing. */
11
+ export declare function workspaceSnapshotNotReadyUserMessage(error: WorkspaceSnapshotNotReadyError): string;
@@ -34,8 +34,8 @@ declare const compactTaskResultSchema: z.ZodObject<{
34
34
  }, z.core.$strict>;
35
35
  conversation_access: z.ZodObject<{
36
36
  audience: z.ZodEnum<{
37
- channel: "channel";
38
37
  direct: "direct";
38
+ channel: "channel";
39
39
  group: "group";
40
40
  }>;
41
41
  visibility: z.ZodEnum<{
@@ -79,8 +79,8 @@ export declare const scheduleTaskToolResultSchema: z.ZodObject<{
79
79
  }, z.core.$strict>;
80
80
  conversation_access: z.ZodObject<{
81
81
  audience: z.ZodEnum<{
82
- channel: "channel";
83
82
  direct: "direct";
83
+ channel: "channel";
84
84
  group: "group";
85
85
  }>;
86
86
  visibility: z.ZodEnum<{
@@ -124,8 +124,8 @@ export declare const scheduleListToolResultSchema: z.ZodObject<{
124
124
  }, z.core.$strict>;
125
125
  conversation_access: z.ZodObject<{
126
126
  audience: z.ZodEnum<{
127
- channel: "channel";
128
127
  direct: "direct";
128
+ channel: "channel";
129
129
  group: "group";
130
130
  }>;
131
131
  visibility: z.ZodEnum<{
@@ -178,7 +178,7 @@ export declare function scheduleTaskToolResult(target: string, task: CompactTask
178
178
  channel_id: string;
179
179
  };
180
180
  conversation_access: {
181
- audience: "channel" | "direct" | "group";
181
+ audience: "direct" | "channel" | "group";
182
182
  visibility: "private" | "public";
183
183
  };
184
184
  credential_mode: "system" | "creator";
@@ -208,7 +208,7 @@ export declare function scheduleListToolResult(args: {
208
208
  channel_id: string;
209
209
  };
210
210
  conversation_access: {
211
- audience: "channel" | "direct" | "group";
211
+ audience: "direct" | "channel" | "group";
212
212
  visibility: "private" | "public";
213
213
  };
214
214
  credential_mode: "system" | "creator";
@@ -47,7 +47,7 @@ export declare function createSlackScheduleCreateTaskTool(context: SchedulerTool
47
47
  channel_id: string;
48
48
  };
49
49
  conversation_access: {
50
- audience: "channel" | "direct" | "group";
50
+ audience: "direct" | "channel" | "group";
51
51
  visibility: "private" | "public";
52
52
  };
53
53
  credential_mode: "system" | "creator";
@@ -77,7 +77,7 @@ export declare function createSlackScheduleCreateTaskTool(context: SchedulerTool
77
77
  channel_id: string;
78
78
  };
79
79
  conversation_access: {
80
- audience: "channel" | "direct" | "group";
80
+ audience: "direct" | "channel" | "group";
81
81
  visibility: "private" | "public";
82
82
  };
83
83
  credential_mode: "system" | "creator";
@@ -22,7 +22,7 @@ export declare function createSlackScheduleDeleteTaskTool(context: SchedulerTool
22
22
  channel_id: string;
23
23
  };
24
24
  conversation_access: {
25
- audience: "channel" | "direct" | "group";
25
+ audience: "direct" | "channel" | "group";
26
26
  visibility: "private" | "public";
27
27
  };
28
28
  credential_mode: "system" | "creator";
@@ -52,7 +52,7 @@ export declare function createSlackScheduleDeleteTaskTool(context: SchedulerTool
52
52
  channel_id: string;
53
53
  };
54
54
  conversation_access: {
55
- audience: "channel" | "direct" | "group";
55
+ audience: "direct" | "channel" | "group";
56
56
  visibility: "private" | "public";
57
57
  };
58
58
  credential_mode: "system" | "creator";
@@ -23,7 +23,7 @@ export declare function createSlackScheduleListTasksTool(context: SchedulerToolC
23
23
  channel_id: string;
24
24
  };
25
25
  conversation_access: {
26
- audience: "channel" | "direct" | "group";
26
+ audience: "direct" | "channel" | "group";
27
27
  visibility: "private" | "public";
28
28
  };
29
29
  credential_mode: "system" | "creator";
@@ -53,7 +53,7 @@ export declare function createSlackScheduleListTasksTool(context: SchedulerToolC
53
53
  channel_id: string;
54
54
  };
55
55
  conversation_access: {
56
- audience: "channel" | "direct" | "group";
56
+ audience: "direct" | "channel" | "group";
57
57
  visibility: "private" | "public";
58
58
  };
59
59
  credential_mode: "system" | "creator";
@@ -22,7 +22,7 @@ export declare function createSlackScheduleRunTaskNowTool(context: SchedulerTool
22
22
  channel_id: string;
23
23
  };
24
24
  conversation_access: {
25
- audience: "channel" | "direct" | "group";
25
+ audience: "direct" | "channel" | "group";
26
26
  visibility: "private" | "public";
27
27
  };
28
28
  credential_mode: "system" | "creator";
@@ -52,7 +52,7 @@ export declare function createSlackScheduleRunTaskNowTool(context: SchedulerTool
52
52
  channel_id: string;
53
53
  };
54
54
  conversation_access: {
55
- audience: "channel" | "direct" | "group";
55
+ audience: "direct" | "channel" | "group";
56
56
  visibility: "private" | "public";
57
57
  };
58
58
  credential_mode: "system" | "creator";
@@ -49,7 +49,7 @@ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerTool
49
49
  channel_id: string;
50
50
  };
51
51
  conversation_access: {
52
- audience: "channel" | "direct" | "group";
52
+ audience: "direct" | "channel" | "group";
53
53
  visibility: "private" | "public";
54
54
  };
55
55
  credential_mode: "system" | "creator";
@@ -79,7 +79,7 @@ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerTool
79
79
  channel_id: string;
80
80
  };
81
81
  conversation_access: {
82
- audience: "channel" | "direct" | "group";
82
+ audience: "direct" | "channel" | "group";
83
83
  visibility: "private" | "public";
84
84
  };
85
85
  credential_mode: "system" | "creator";
@@ -25,8 +25,8 @@ export declare const scheduledTaskSchema: z.ZodObject<{
25
25
  id: z.ZodString;
26
26
  conversationAccess: z.ZodObject<{
27
27
  audience: z.ZodEnum<{
28
- channel: "channel";
29
28
  direct: "direct";
29
+ channel: "channel";
30
30
  group: "group";
31
31
  }>;
32
32
  visibility: z.ZodEnum<{
@@ -1,4 +1,6 @@
1
1
  /** Build a Sentry conversation URL only when the runtime has enough Sentry config. */
2
2
  export declare function buildSentryConversationUrl(conversationId: string): string | undefined;
3
+ /** Build a Sentry event URL only when the runtime has enough Sentry config. */
4
+ export declare function buildSentryEventUrl(eventId: string): string | undefined;
3
5
  /** Build a Sentry trace URL only when the runtime has enough Sentry config. */
4
6
  export declare function buildSentryTraceUrl(traceId: string): string | undefined;
@@ -1,5 +1,6 @@
1
1
  import { type AssistantMessage } from "@earendil-works/pi-ai";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
+ import { type ProviderError } from "@/chat/services/provider-error";
3
4
  /** Apply Junior's retry budget to a retryable Pi assistant failure. */
4
5
  export declare function nextProviderRetry(args: {
5
6
  attempt: number;
@@ -8,4 +9,5 @@ export declare function nextProviderRetry(args: {
8
9
  }): {
9
10
  delayMs: number;
10
11
  messages: PiMessage[];
12
+ providerError: ProviderError;
11
13
  } | undefined;
@@ -1,12 +1,16 @@
1
+ import type { ConversationTurnFailureReason } from "@/chat/conversations/history";
1
2
  import type { AgentRunResult } from "@/chat/services/turn-result";
2
3
  type LogException = (error: unknown, eventName: string, attributes?: Record<string, unknown>) => string | undefined;
3
4
  /** Require captured turn failures to carry a real Sentry event reference. */
4
5
  export declare function requireTurnFailureEventId(eventId: string | undefined, eventName: string): string;
6
+ /** Return a fixed reason label for a failed model turn. */
7
+ export declare function getTurnFailureReason(reply: AgentRunResult): ConversationTurnFailureReason | undefined;
5
8
  /** Keep failed-turn Sentry captures and completion spans on the same keys. */
6
9
  export declare function getAgentTurnDiagnosticsAttributes(reply: AgentRunResult): Record<string, unknown>;
7
10
  /** Sanitized failure fallback plus its optional captured event ID. */
8
11
  export interface FinalizedTurnFailure {
9
12
  eventId?: string;
13
+ failureReason?: ConversationTurnFailureReason;
10
14
  reply: AgentRunResult;
11
15
  }
12
16
  /** Enforce one captured failure response and return its structured correlation. */
@@ -1,18 +1,33 @@
1
1
  /**
2
- * Load turn-session routing from durable conversation metadata.
2
+ * Load destination and session source from the conversation record.
3
3
  *
4
- * SQL owns destination and session source. Resume paths query those columns
5
- * directly — no redis fallback and no derived rebuild of missing fields.
4
+ * Destination is set once on the root conversation. Child conversations
5
+ * inherit through parent lineage. Later turns and mailbox wakes use that
6
+ * same destination so tools stay consistent for the whole conversation.
6
7
  */
7
8
  import type { Destination, Source } from "@sentry/junior-plugin-api";
8
9
  import type { ConversationStore } from "@/chat/conversations/store";
9
10
  export interface TurnSessionRouting {
10
11
  destination: Destination;
11
12
  locationId?: string;
12
- source: Source;
13
+ /** Present when the conversation already stores a session source. */
14
+ source?: Source;
13
15
  }
16
+ /** Full turn routing: destination plus a completed session source. */
17
+ export type RequiredTurnSessionRouting = TurnSessionRouting & {
18
+ source: Source;
19
+ };
20
+ /**
21
+ * Resolve the conversation's destination and session source.
22
+ *
23
+ * Walks parent lineage when the conversation has no destination of its own.
24
+ */
25
+ export declare function resolveConversationRouting(args: {
26
+ conversationId: string;
27
+ conversationStore?: ConversationStore;
28
+ }): Promise<TurnSessionRouting | undefined>;
14
29
  /** Require conversation destination and session source from SQL. */
15
30
  export declare function resolveTurnSessionRouting(args: {
16
31
  conversationId: string;
17
32
  conversationStore?: ConversationStore;
18
- }): Promise<TurnSessionRouting>;
33
+ }): Promise<RequiredTurnSessionRouting>;