@sentry/junior 0.115.0 → 0.116.1

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 (111) hide show
  1. package/dist/{agent-hooks-4EUUXP2F.js → agent-hooks-GUAAS3XH.js} +9 -9
  2. package/dist/api/conversations/detail.d.ts +18 -0
  3. package/dist/api/conversations/event-page.d.ts +1 -1
  4. package/dist/api/conversations/events.d.ts +1 -1
  5. package/dist/api/people/profile.d.ts +2 -2
  6. package/dist/api/people/shared.d.ts +1 -1
  7. package/dist/api/personal-tokens/create.d.ts +11 -0
  8. package/dist/api/personal-tokens/list.d.ts +12 -0
  9. package/dist/api/personal-tokens/revoke.d.ts +5 -0
  10. package/dist/api/personal-tokens/routes.d.ts +4 -0
  11. package/dist/api/plugins.d.ts +0 -1
  12. package/dist/api/route.d.ts +1 -1
  13. package/dist/api/schema/conversation.d.ts +18 -0
  14. package/dist/api/schema/person.d.ts +3 -3
  15. package/dist/api/schema/personal-token.d.ts +38 -0
  16. package/dist/api/schema.d.ts +2 -0
  17. package/dist/api/schema.js +15 -3
  18. package/dist/api.d.ts +1 -0
  19. package/dist/api.js +179 -39
  20. package/dist/app.js +1035 -853
  21. package/dist/{catalog-runtime-Y32UEQLB.js → catalog-runtime-WMPC4J4U.js} +5 -5
  22. package/dist/chat/agent/request.d.ts +1 -0
  23. package/dist/chat/agent/resume.d.ts +1 -0
  24. package/dist/chat/agent/sandbox.d.ts +1 -0
  25. package/dist/chat/agent/tools.d.ts +1 -0
  26. package/dist/chat/agent-dispatch/context.d.ts +2 -0
  27. package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
  28. package/dist/chat/agent-dispatch/signing.d.ts +14 -5
  29. package/dist/chat/agent-dispatch/store.d.ts +36 -15
  30. package/dist/chat/agent-dispatch/types.d.ts +23 -10
  31. package/dist/chat/agent-dispatch/work.d.ts +58 -0
  32. package/dist/chat/app/factory.d.ts +12 -3
  33. package/dist/chat/conversations/history.d.ts +285 -290
  34. package/dist/chat/conversations/projection.d.ts +2 -2
  35. package/dist/chat/mcp/tool-manager.d.ts +2 -1
  36. package/dist/chat/pi/conversation-events.d.ts +6 -2
  37. package/dist/chat/plugins/annotations.d.ts +8 -0
  38. package/dist/chat/plugins/registry.d.ts +0 -3
  39. package/dist/chat/plugins/types.d.ts +0 -2
  40. package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
  41. package/dist/chat/runtime/reply-executor.d.ts +6 -1
  42. package/dist/chat/runtime/slack-resume.d.ts +5 -1
  43. package/dist/chat/runtime/turn-input.d.ts +3 -0
  44. package/dist/chat/sandbox/sandbox.d.ts +2 -1
  45. package/dist/chat/sandbox/session.d.ts +2 -11
  46. package/dist/chat/sandbox/workspace.d.ts +10 -2
  47. package/dist/chat/services/turn-session-record.d.ts +14 -1
  48. package/dist/chat/slack/dispatch-turn.d.ts +25 -0
  49. package/dist/chat/state/turn-session.d.ts +11 -0
  50. package/dist/chat/tool-support/text-range-result.d.ts +3 -0
  51. package/dist/chat/tool-support/zod-tool.d.ts +1 -0
  52. package/dist/chat/tools/definition.d.ts +3 -10
  53. package/dist/chat/tools/query-conversation-events.d.ts +68 -0
  54. package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
  55. package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
  56. package/dist/chat/tools/sandbox/grep.d.ts +2 -1
  57. package/dist/{chunk-6V762AB4.js → chunk-2YYPXQNQ.js} +1 -1
  58. package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
  59. package/dist/{chunk-67CVNDJ7.js → chunk-7CSVG54J.js} +1 -1
  60. package/dist/{chunk-HWCQRGLL.js → chunk-BFYVIOTS.js} +105 -37
  61. package/dist/{chunk-LYA2AB5G.js → chunk-CGXLCMWI.js} +8 -52
  62. package/dist/{chunk-SYJT7AKB.js → chunk-CY7NXM32.js} +1 -1
  63. package/dist/{chunk-2QG4MZQ7.js → chunk-DLLW5ITL.js} +2 -2
  64. package/dist/{chunk-NVUQSFWX.js → chunk-F3SWGSPG.js} +3 -15
  65. package/dist/{chunk-CWEZEPD4.js → chunk-FAEALXEH.js} +68 -2
  66. package/dist/{chunk-43RYMWJ2.js → chunk-GDAXWEIJ.js} +809 -213
  67. package/dist/{chunk-AGLQYELI.js → chunk-H35BDAUS.js} +170 -170
  68. package/dist/{chunk-YCLO7D7M.js → chunk-JPKGW6L6.js} +77 -26
  69. package/dist/{chunk-G5SX4UPR.js → chunk-KNCELO2M.js} +2 -2
  70. package/dist/{chunk-FHC4JUSF.js → chunk-N3C4XCRE.js} +1 -2
  71. package/dist/{chunk-6FKLPVF3.js → chunk-OY2PQQ4P.js} +1 -1
  72. package/dist/{chunk-6OPTF4BQ.js → chunk-PE44LDDQ.js} +0 -1
  73. package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
  74. package/dist/{chunk-CEYOL62C.js → chunk-RYFAVWP3.js} +120 -20
  75. package/dist/{chunk-G36V2YGB.js → chunk-TC4ZEM2D.js} +33 -1
  76. package/dist/{chunk-PVZHG2XZ.js → chunk-VBMMMVVQ.js} +112 -35
  77. package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
  78. package/dist/{chunk-TVE25LPW.js → chunk-WLT72MRP.js} +1 -1
  79. package/dist/{chunk-EW5MLKT5.js → chunk-XA3VLFPK.js} +1 -55
  80. package/dist/{chunk-RAVKCKXA.js → chunk-ZYHLNTC2.js} +20 -5
  81. package/dist/cli/chat.js +23 -23
  82. package/dist/cli/check.js +6 -6
  83. package/dist/cli/plugins.js +13 -13
  84. package/dist/cli/snapshot-warmup.js +8 -8
  85. package/dist/cli/upgrade.js +7 -7
  86. package/dist/db/schema/api-tokens.d.ts +160 -0
  87. package/dist/db/schema/conversation-annotations.d.ts +142 -0
  88. package/dist/db/schema.d.ts +305 -1
  89. package/dist/{db-KBSJHAZU.js → db-FH4R5ZQ4.js} +6 -6
  90. package/dist/handlers/agent-dispatch.d.ts +7 -3
  91. package/dist/instrumentation.js +2 -2
  92. package/dist/nitro.js +5 -5
  93. package/dist/{oauth-callback-server-EYRMJTCS.js → oauth-callback-server-C2SSJ3FQ.js} +18 -18
  94. package/dist/personal-tokens/store.d.ts +27 -0
  95. package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
  96. package/dist/reporting-schema.d.ts +0 -2
  97. package/dist/{runner-RQGZ5Z2S.js → runner-NAALFIXM.js} +12 -12
  98. package/dist/{skills-JJQIE3BT.js → skills-UN2JXYYF.js} +6 -6
  99. package/dist/{validation-MZ47PZP5.js → validation-EEF4ROHR.js} +6 -6
  100. package/dist/version.js +1 -1
  101. package/migrations/0008_sticky_rage.sql +14 -0
  102. package/migrations/0009_slippery_harrier.sql +12 -0
  103. package/migrations/0010_native_conversation_history.sql +142 -0
  104. package/migrations/meta/0008_snapshot.json +1076 -0
  105. package/migrations/meta/0009_snapshot.json +1146 -0
  106. package/migrations/meta/0010_snapshot.json +1190 -0
  107. package/migrations/meta/_journal.json +22 -1
  108. package/package.json +5 -6
  109. package/dist/chat/agent-dispatch/runner.d.ts +0 -13
  110. package/dist/chat/capabilities/catalog.d.ts +0 -16
  111. package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
@@ -33,7 +33,7 @@ export declare function loadTurnProjection(args: {
33
33
  /** Load MCP providers connected in the current agent-history version. */
34
34
  export declare function loadConnectedMcpProviders(args: ScopedConversation): Promise<string[]>;
35
35
  /**
36
- * Append newly stable agent steps. A shorter or changed prefix indicates
36
+ * Append newly stable native history items. A shorter or changed prefix indicates
37
37
  * that a caller persisted volatile Pi state; only compaction and handoff may
38
38
  * intentionally replace active model history.
39
39
  */
@@ -51,7 +51,7 @@ export declare function commitMessages(args: {
51
51
  }): Promise<{
52
52
  committedSeq: number;
53
53
  historyVersion: number;
54
- /** Event sequence for every projected agent step. */
54
+ /** Event sequence for every projected agent history item. */
55
55
  messageSeqs: number[];
56
56
  /** Normalized durable messages after volatile runtime context is removed. */
57
57
  messages: PiMessage[];
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
10
10
  import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
11
+ import type { ToolAnnotations } from "@sentry/junior-plugin-api";
11
12
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
12
13
  import type { SkillMetadata } from "@/chat/skills";
13
14
  import type { PluginDefinition } from "@/chat/plugins/types";
@@ -27,7 +28,7 @@ export interface ManagedMcpToolDescriptor {
27
28
  description: string;
28
29
  parameters: Record<string, unknown>;
29
30
  outputSchema?: Record<string, unknown>;
30
- annotations?: Record<string, unknown>;
31
+ annotations?: ToolAnnotations;
31
32
  provider: string;
32
33
  }
33
34
  type ActiveMcpSkill = Pick<SkillMetadata, "name" | "pluginProvider">;
@@ -5,7 +5,7 @@
5
5
  * stored messages into the active Pi context.
6
6
  */
7
7
  import type { ModelProfile } from "@/chat/model-profile";
8
- import type { ConversationEvent } from "@/chat/conversations/history";
8
+ import type { ConversationEvent, AgentHistoryItem } from "@/chat/conversations/history";
9
9
  import { type PiMessage } from "@/chat/pi/messages";
10
10
  import { type ConversationMessageProvenance } from "@/chat/conversations/provenance";
11
11
  /** Pi context projected from one Junior model-history version. */
@@ -19,10 +19,14 @@ export interface PiConversationProjection {
19
19
  export interface PiConversationEventProjection extends PiConversationProjection {
20
20
  seqs: number[];
21
21
  }
22
+ /** Translate one Pi message into Junior's native durable history item. */
23
+ export declare function historyItemFromPiMessage(message: PiMessage, provenance: ConversationMessageProvenance): AgentHistoryItem;
24
+ /** Translate one Junior-native history item into the Pi message it represents. */
25
+ export declare function piMessageFromHistoryItem(data: AgentHistoryItem): PiMessage;
22
26
  /**
23
27
  * Project ordered Junior events into Pi context.
24
28
  *
25
- * Compaction and handoff start with replacement history. Later agent-step
29
+ * Compaction and handoff start with replacement history. Later native history
26
30
  * events append after it.
27
31
  *
28
32
  * Host-only events are filtered, completed authorization becomes a synthetic
@@ -0,0 +1,8 @@
1
+ import { type ConversationAnnotation, type PluginAnnotations } from "@sentry/junior-plugin-api";
2
+ import type { JuniorDatabase } from "@/db/db";
3
+ export declare function createPluginAnnotations(args: {
4
+ conversationId: string;
5
+ db: JuniorDatabase;
6
+ plugin: string;
7
+ }): PluginAnnotations;
8
+ export declare function listConversationAnnotations(db: JuniorDatabase, conversationId: string): Promise<ConversationAnnotation[]>;
@@ -1,10 +1,8 @@
1
- import type { CapabilityProviderDefinition } from "@/chat/capabilities/catalog";
2
1
  import type { CredentialBroker } from "@/chat/credentials/broker";
3
2
  import { type InstalledPluginPackageContent } from "./package-discovery";
4
3
  import type { InlinePluginManifestDefinition, PluginBrokerDeps, PluginCatalogConfig, PluginDefinition, OAuthProviderConfig, PluginRuntimeDependency, PluginRuntimePostinstallCommand } from "./types";
5
4
  export interface PluginCatalogRuntime {
6
5
  createBroker(provider: string, deps: PluginBrokerDeps): CredentialBroker;
7
- getCapabilityProviders(): CapabilityProviderDefinition[];
8
6
  getDefinition(provider: string): PluginDefinition | undefined;
9
7
  getDisplayName(provider: string): string | undefined;
10
8
  getForSkillPath(skillPath: string): PluginDefinition | undefined;
@@ -20,7 +18,6 @@ export interface PluginCatalogRuntime {
20
18
  getRuntimePostinstall(): PluginRuntimePostinstallCommand[];
21
19
  getSignature(): string;
22
20
  getSkillRoots(): string[];
23
- isCapability(capability: string): boolean;
24
21
  isConfigKey(key: string): boolean;
25
22
  isProvider(provider: string): boolean;
26
23
  parseConfiguredInlineManifest(manifest: InlinePluginManifestDefinition["manifest"], dir: string): PluginDefinition["manifest"];
@@ -63,7 +63,6 @@ export interface PluginManifest {
63
63
  name: string;
64
64
  displayName: string;
65
65
  description: string;
66
- capabilities: string[];
67
66
  configKeys: string[];
68
67
  domains?: string[];
69
68
  apiHeaders?: Record<string, string>;
@@ -109,7 +108,6 @@ type PluginCredentialConfig = PluginCredentialConfigBase & {
109
108
  export interface PluginManifestConfig {
110
109
  displayName?: string;
111
110
  description?: string;
112
- capabilities?: string[];
113
111
  configKeys?: string[];
114
112
  domains?: string[] | null;
115
113
  apiHeaders?: Record<string, string | null> | null;
@@ -1,9 +1,13 @@
1
1
  import { resumeSlackTurn } from "@/chat/runtime/slack-resume";
2
2
  import { type AgentContinueRequest } from "@/chat/services/agent-continue";
3
3
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
+ import type { AgentRunRouting } from "@/chat/agent/request";
4
5
  /** Runtime ports for agent continuation scheduling. */
5
6
  export interface AgentContinueRunnerOptions {
6
7
  agentRunner: AgentRunner;
8
+ /** Exact persisted input ids accepted for a non-interactive continuation. */
9
+ inputMessageIds?: readonly string[];
10
+ routingContext?: Pick<AgentRunRouting, "actor" | "credentialContext" | "destinationVisibility" | "dispatch" | "surface">;
7
11
  resumeTurn?: typeof resumeSlackTurn;
8
12
  scheduleAgentContinue?: (request: AgentContinueRequest) => Promise<void>;
9
13
  scheduleSessionCompletedPluginTasks?: (params: {
@@ -17,6 +17,7 @@ import type { ContextCompactor } from "@/chat/services/context-compaction";
17
17
  import { lookupSlackUser } from "@/chat/slack/user";
18
18
  import type { AgentContinueRequest } from "@/chat/services/agent-continue";
19
19
  import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
20
+ import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
20
21
  export interface ReplyExecutorServices {
21
22
  agentRunner: AgentRunner;
22
23
  contextCompactor: ContextCompactor;
@@ -51,7 +52,7 @@ interface ReplyExecutorDeps {
51
52
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<PreparedTurnState>;
52
53
  services: ReplyExecutorServices;
53
54
  }
54
- /** Build the Slack reply handler that prepares state, runs Pi, and delivers replies. */
55
+ /** Build the shared reply handler that prepares, advances, and commits a turn. */
55
56
  export declare function createReplyToThread(deps: ReplyExecutorDeps): (thread: Thread, message: Message, options: {
56
57
  beforeFirstResponsePost?: () => Promise<void>;
57
58
  destination: Destination;
@@ -59,9 +60,13 @@ export declare function createReplyToThread(deps: ReplyExecutorDeps): (thread: T
59
60
  ack?: () => Promise<void>;
60
61
  onToolInvocation?: (invocation: TurnToolInvocation) => void;
61
62
  onTurnCompleted?: () => Promise<void>;
63
+ onTurnDeliveryAccepted?: (messageId?: string) => void;
64
+ onTurnOutcome?: (result: DispatchTurnResult) => void;
62
65
  onTurnStatePersisted?: () => Promise<void>;
63
66
  preparedState?: PreparedTurnState;
64
67
  queuedMessages?: QueuedTurnMessage[];
68
+ execution?: DispatchTurnContext;
69
+ skipBackfill?: boolean;
65
70
  drainSteeringMessages?: (accept: (messages: QueuedTurnMessage[]) => Promise<void>, context?: {
66
71
  conversationContext?: string;
67
72
  }) => Promise<QueuedTurnMessage[]>;
@@ -12,8 +12,10 @@ interface ResumeSlackTurnArgs {
12
12
  messageText: string;
13
13
  conversationId: string;
14
14
  turnId: string;
15
+ /** Active durable execution slice being resumed. */
16
+ sliceId?: number;
15
17
  channelId: string;
16
- threadTs: string;
18
+ threadTs?: string;
17
19
  messageTs?: SlackMessageTs;
18
20
  replyContext?: ResumeReplyContext;
19
21
  lockKey?: string;
@@ -41,6 +43,8 @@ type ResumeReplyContext = Omit<AgentRunRequest, "conversationId" | "turnId" | "r
41
43
  };
42
44
  interface ResumePreparedTurn {
43
45
  messageText: string;
46
+ /** Active durable execution slice being resumed. */
47
+ sliceId?: number;
44
48
  messageTs?: SlackMessageTs;
45
49
  inputMessageIds?: string[];
46
50
  initialStatus?: AssistantStatusSpec;
@@ -1,4 +1,5 @@
1
1
  import type { Message, Thread } from "chat";
2
+ import type { ChannelConfigurationService } from "@/chat/configuration/types";
2
3
  export interface TurnContext {
3
4
  channelId?: string;
4
5
  actorId?: string;
@@ -18,10 +19,12 @@ export interface QueuedTurnMessage extends TurnMessageText {
18
19
  message: Message;
19
20
  }
20
21
  export interface PrepareTurnStateInput {
22
+ channelConfiguration?: ChannelConfigurationService;
21
23
  context: TurnContext;
22
24
  explicitMention: boolean;
23
25
  message: Message;
24
26
  queuedMessages?: QueuedTurnMessage[];
27
+ skipBackfill?: boolean;
25
28
  text: TurnMessageText;
26
29
  thread: Thread;
27
30
  }
@@ -3,7 +3,7 @@ import type { SandboxEgressSignalTransport } from "@/chat/sandbox/egress/signals
3
3
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
4
4
  import type { CredentialContext } from "@/chat/credentials/context";
5
5
  import type { SandboxRef } from "@/chat/sandbox/ref";
6
- import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
6
+ import { type SandboxWorkspace } from "@/chat/sandbox/workspace";
7
7
  import type { SkillMetadata } from "@/chat/skills";
8
8
  export interface SandboxToolCall {
9
9
  toolName: string;
@@ -18,6 +18,7 @@ export interface SandboxAccess {
18
18
  readonly tools: SandboxTools;
19
19
  readonly workspace: SandboxWorkspace;
20
20
  sandboxRef(): SandboxRef | undefined;
21
+ close(): void;
21
22
  }
22
23
  export interface SandboxOptions {
23
24
  sandboxRef?: SandboxRef;
@@ -19,24 +19,15 @@ interface SandboxToolExecutors {
19
19
  aborted?: boolean;
20
20
  timedOut?: boolean;
21
21
  }>;
22
- readFile: (input: {
23
- path: string;
24
- }) => Promise<{
25
- content: string;
26
- }>;
27
- writeFile: (input: {
28
- path: string;
29
- content: string;
30
- }) => Promise<{
31
- success: boolean;
32
- }>;
33
22
  fs: SandboxFileSystem;
23
+ runCommand: SandboxSession["runCommand"];
34
24
  }
35
25
  interface SandboxRuntime {
36
26
  sandboxRef(): SandboxRef | undefined;
37
27
  acquire(): Promise<SandboxSession>;
38
28
  tools(): Promise<SandboxToolExecutors>;
39
29
  refreshNetworkPolicy(traceHeaders?: TracePropagationHeaders): Promise<void>;
30
+ close(): void;
40
31
  }
41
32
  interface SandboxRuntimeOptions {
42
33
  sandboxRef?: SandboxRef;
@@ -18,13 +18,21 @@ export interface SandboxFileStat {
18
18
  export interface SandboxFileSystem {
19
19
  readFile(filePath: string, options: {
20
20
  encoding: BufferEncoding;
21
+ signal?: AbortSignal;
21
22
  }): Promise<string>;
22
23
  writeFile(filePath: string, content: string, options?: {
23
24
  encoding?: BufferEncoding;
25
+ signal?: AbortSignal;
24
26
  }): Promise<void>;
25
- readdir(filePath: string): Promise<string[]>;
26
- stat(filePath: string): Promise<SandboxFileStat>;
27
+ readdir(filePath: string, options?: {
28
+ signal?: AbortSignal;
29
+ }): Promise<string[]>;
30
+ stat(filePath: string, options?: {
31
+ signal?: AbortSignal;
32
+ }): Promise<SandboxFileStat>;
27
33
  }
34
+ /** Bind one tool call's cancellation to every sandbox filesystem operation. */
35
+ export declare function bindSandboxFileSystem(fs: SandboxFileSystem, signal?: AbortSignal): SandboxFileSystem;
28
36
  export interface SandboxWorkspace {
29
37
  readFileToBuffer(input: {
30
38
  cwd?: string;
@@ -1,4 +1,4 @@
1
- import { type AgentTurnSessionRecord, type AgentTurnSurface } from "@/chat/state/turn-session";
1
+ import { type AgentDispatchOutcome, type AgentTurnSessionRecord, type AgentTurnSurface } from "@/chat/state/turn-session";
2
2
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
3
3
  import type { Destination, Actor, Source } from "@sentry/junior-plugin-api";
4
4
  import type { PiMessage } from "@/chat/pi/messages";
@@ -27,6 +27,7 @@ export declare function persistRunningSessionRecord(args: {
27
27
  channelName?: string;
28
28
  conversationId: string;
29
29
  destination?: Destination;
30
+ dispatchId?: string;
30
31
  source?: Source;
31
32
  sessionId: string;
32
33
  sliceId: number;
@@ -56,8 +57,13 @@ export declare function persistCompletedSessionRecord(args: {
56
57
  currentDurationMs?: number;
57
58
  currentUsage?: AgentTurnUsage;
58
59
  destination?: Destination;
60
+ dispatchId?: string;
61
+ dispatchOutcome?: AgentDispatchOutcome;
62
+ errorMessage?: string;
59
63
  /** Source-confirmed destination visibility from the current event's signal. */
60
64
  destinationVisibility?: ConversationPrivacy;
65
+ /** Provider-owned identifier returned after visible delivery is accepted. */
66
+ resultMessageId?: string;
61
67
  source?: Source;
62
68
  sessionId: string;
63
69
  /** Defaults to the latest stored slice when the deliverer does not know it. */
@@ -76,12 +82,16 @@ export declare function completeDeliveredTurn(args: {
76
82
  conversationId: string;
77
83
  destination: Destination;
78
84
  destinationVisibility?: ConversationPrivacy;
85
+ dispatchId?: string;
86
+ dispatchOutcome?: AgentDispatchOutcome;
87
+ errorMessage?: string;
79
88
  durationMs?: number;
80
89
  loadedSkillNames?: string[];
81
90
  messages: PiMessage[];
82
91
  modelId: string;
83
92
  actor?: Actor;
84
93
  reasoningLevel?: string;
94
+ resultMessageId?: string;
85
95
  sessionId: string;
86
96
  sliceId: number;
87
97
  source: Source;
@@ -101,6 +111,7 @@ export declare function persistAuthPauseSessionRecord(args: {
101
111
  currentDurationMs?: number;
102
112
  currentUsage?: AgentTurnUsage;
103
113
  destination?: Destination;
114
+ dispatchId?: string;
104
115
  source?: Source;
105
116
  messages: PiMessage[];
106
117
  loadedSkillNames?: string[];
@@ -119,6 +130,7 @@ interface ContinuationRecordInput {
119
130
  currentDurationMs?: number;
120
131
  currentUsage?: AgentTurnUsage;
121
132
  destination?: Destination;
133
+ dispatchId?: string;
122
134
  source?: Source;
123
135
  messages: PiMessage[];
124
136
  loadedSkillNames?: string[];
@@ -144,6 +156,7 @@ export declare function persistYieldSessionRecord(args: {
144
156
  currentDurationMs?: number;
145
157
  currentUsage?: AgentTurnUsage;
146
158
  destination?: Destination;
159
+ dispatchId?: string;
147
160
  source?: Source;
148
161
  messages: PiMessage[];
149
162
  loadedSkillNames?: string[];
@@ -0,0 +1,25 @@
1
+ import { Message, ThreadImpl } from "chat";
2
+ import type { SlackAdapter } from "@chat-adapter/slack";
3
+ import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
4
+ import type { DispatchRecord } from "@/chat/agent-dispatch/types";
5
+ interface DispatchReplyToThread {
6
+ (thread: ThreadImpl, message: Message, options: {
7
+ ack?: () => Promise<void>;
8
+ destination: DispatchRecord["destination"];
9
+ execution: DispatchTurnContext;
10
+ onTurnDeliveryAccepted?: (messageId?: string) => void;
11
+ onTurnOutcome?: (result: DispatchTurnResult) => void;
12
+ shouldYield?: () => boolean;
13
+ skipBackfill?: boolean;
14
+ }): Promise<void>;
15
+ }
16
+ /** Build the Slack provider adapter for plugin-dispatched conversation turns. */
17
+ export declare function createSlackDispatchTurnRunner(options: {
18
+ getChannelConfiguration: (channelId: string) => DispatchTurnContext["channelConfiguration"];
19
+ getSlackAdapter: () => SlackAdapter;
20
+ replyToThread: DispatchReplyToThread;
21
+ }): (dispatch: DispatchRecord, hooks: {
22
+ ack: () => Promise<void>;
23
+ shouldYield?: () => boolean;
24
+ }) => Promise<DispatchTurnResult>;
25
+ export {};
@@ -18,6 +18,7 @@ import type { ConversationStore } from "@/chat/conversations/store";
18
18
  export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
19
19
  export type AgentTurnSurface = "slack" | "api" | "scheduler" | "internal";
20
20
  export type AgentTurnResumeReason = "timeout" | "auth" | "yield" | "retry";
21
+ export type AgentDispatchOutcome = "blocked" | "completed" | "failed";
21
22
  export interface AgentTurnSessionRecord {
22
23
  channelName?: string;
23
24
  version: number;
@@ -25,6 +26,10 @@ export interface AgentTurnSessionRecord {
25
26
  cumulativeDurationMs: number;
26
27
  cumulativeUsage?: AgentTurnUsage;
27
28
  destination?: Destination;
29
+ dispatchId?: string;
30
+ dispatchOutcome?: AgentDispatchOutcome;
31
+ /** Provider-owned identifier returned after visible delivery is accepted. */
32
+ resultMessageId?: string;
28
33
  source?: Source;
29
34
  errorMessage?: string;
30
35
  lastProgressAtMs: number;
@@ -66,6 +71,9 @@ export declare function upsertAgentTurnSessionRecord(args: {
66
71
  cumulativeDurationMs?: number;
67
72
  cumulativeUsage?: AgentTurnUsage;
68
73
  destination?: Destination;
74
+ dispatchId?: string;
75
+ dispatchOutcome?: AgentDispatchOutcome;
76
+ resultMessageId?: string;
69
77
  /** Source-confirmed destination visibility from the current event's signal. */
70
78
  destinationVisibility?: ConversationPrivacy;
71
79
  source?: Source;
@@ -97,6 +105,9 @@ export declare function recordAgentTurnSessionSummary(args: {
97
105
  cumulativeDurationMs?: number;
98
106
  cumulativeUsage?: AgentTurnUsage;
99
107
  destination?: Destination;
108
+ dispatchId?: string;
109
+ dispatchOutcome?: AgentDispatchOutcome;
110
+ resultMessageId?: string;
100
111
  /**
101
112
  * Source-confirmed destination visibility from the current event's signal
102
113
  * (Slack `channel_type`). Leave unset when no live signal exists so an
@@ -13,8 +13,11 @@ interface TextRangeResult {
13
13
  path: string;
14
14
  start_line: number;
15
15
  total_lines: number;
16
+ truncation_reasons?: string[];
16
17
  };
17
18
  truncated: boolean;
19
+ character_limit_reached?: number;
20
+ line_truncated?: boolean;
18
21
  continuation?: {
19
22
  arguments: {
20
23
  offset: number;
@@ -3,6 +3,7 @@ import { type JuniorToolResult } from "@/chat/tool-support/structured-result";
3
3
  import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
4
4
  import type { AnyToolDefinition, JsonSchemaObject, ToolExecuteOptions } from "@/chat/tools/definition";
5
5
  type ZodToolDefinitionBase<TInputSchema extends ZodTypeAny> = Pick<AnyToolDefinition, "approvalMode" | "identity" | "source" | "description" | "exposure" | "annotations" | "promptSnippet" | "promptGuidelines" | "executionMode"> & {
6
+ describeProposal?(input: z.output<TInputSchema>): string;
6
7
  inputSchema: TInputSchema;
7
8
  prepareArguments?: (args: unknown) => z.input<TInputSchema>;
8
9
  };
@@ -1,7 +1,6 @@
1
- import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
2
1
  import { type Static, type TSchema } from "@sinclair/typebox";
3
2
  import type { ToolExecutionMode } from "@earendil-works/pi-agent-core";
4
- import type { ToolApprovalMode } from "@sentry/junior-plugin-api";
3
+ import type { ToolApprovalMetadata } from "@sentry/junior-plugin-api";
5
4
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
6
5
  /**
7
6
  * Tool definition boundary for Pi-facing agent tools.
@@ -17,9 +16,7 @@ export interface ToolExecuteOptions {
17
16
  conversationPrivacy?: ConversationPrivacy;
18
17
  toolCallId?: string;
19
18
  }
20
- interface BaseToolDefinition<TInput, TInputSchema extends ToolInputSchema> {
21
- /** Optional declared approval mode; omission delegates to core defaults. */
22
- approvalMode?: ToolApprovalMode;
19
+ interface BaseToolDefinition<TInput, TInputSchema extends ToolInputSchema> extends ToolApprovalMetadata<TInput> {
23
20
  /** Stable internal owner-qualified identity for plugin-contributed tools. */
24
21
  identity?: {
25
22
  id: string;
@@ -36,7 +33,6 @@ interface BaseToolDefinition<TInput, TInputSchema extends ToolInputSchema> {
36
33
  inputSchema: TInputSchema;
37
34
  outputSchema?: ToolInputSchema;
38
35
  privateTraceResult?(result: unknown): unknown;
39
- annotations?: ToolAnnotations;
40
36
  /**
41
37
  * @deprecated Put tool-selection and usage guidance directly in `description`
42
38
  * and parameter descriptions. Retained for plugin compatibility; may be
@@ -58,9 +54,7 @@ export interface ToolDefinition<TInputSchema extends TSchema = TSchema> extends
58
54
  /**
59
55
  * Schema-erased view for heterogeneous registries after Pi validates tool input.
60
56
  */
61
- export interface AnyToolDefinition {
62
- /** Optional declared approval mode; omission delegates to core defaults. */
63
- approvalMode?: ToolApprovalMode;
57
+ export interface AnyToolDefinition extends ToolApprovalMetadata {
64
58
  /** Stable internal owner-qualified identity for plugin-contributed tools. */
65
59
  identity?: {
66
60
  id: string;
@@ -77,7 +71,6 @@ export interface AnyToolDefinition {
77
71
  inputSchema: ToolInputSchema;
78
72
  outputSchema?: ToolInputSchema;
79
73
  privateTraceResult?(result: unknown): unknown;
80
- annotations?: ToolAnnotations;
81
74
  /**
82
75
  * @deprecated Put tool-selection and usage guidance directly in `description`
83
76
  * and parameter descriptions. Retained for plugin compatibility; may be
@@ -0,0 +1,68 @@
1
+ import { type KnownConversationEventType } from "@/chat/conversations/history";
2
+ import type { ToolRuntimeContext } from "@/chat/tools/types";
3
+ /** Create a deferred tool that returns a bounded raw conversation event page. */
4
+ export declare function createQueryConversationEventsTool(context: ToolRuntimeContext): Omit<import("./definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
5
+ inputSchema: import("./definition").JsonSchemaObject;
6
+ outputSchema: import("./definition").JsonSchemaObject;
7
+ prepareArguments(args: unknown): {
8
+ conversation_id: string;
9
+ after_seq?: number | null | undefined;
10
+ before_seq?: number | null | undefined;
11
+ limit?: number | null | undefined;
12
+ types?: ("message" | "handoff" | "user_message" | "assistant_message" | "tool_result" | "compaction" | "mcp_provider_connected" | "authorization_requested" | "authorization_completed" | "tool_execution_started" | "message_updated" | "message_handled" | "messages_summarized" | "turn_started" | "turn_routed" | "turn_completed" | "turn_failed" | "subagent_started" | "subagent_ended")[] | null | undefined;
13
+ };
14
+ execute?: ((input: unknown, options: import("./definition").ToolExecuteOptions) => {
15
+ [x: string]: unknown;
16
+ ok: boolean;
17
+ status: "error" | "success";
18
+ conversation_id: string;
19
+ events: {
20
+ seq: number;
21
+ history_version: number;
22
+ created_at: string;
23
+ data: Record<string, unknown>;
24
+ idempotency_key?: string | undefined;
25
+ }[];
26
+ has_older: boolean;
27
+ has_newer: boolean;
28
+ target?: string | undefined;
29
+ data?: unknown;
30
+ truncated?: boolean | undefined;
31
+ continuation?: {
32
+ arguments: Record<string, unknown>;
33
+ reason?: string | undefined;
34
+ } | undefined;
35
+ error?: string | {
36
+ kind: string;
37
+ message: string;
38
+ retryable?: boolean | undefined;
39
+ } | undefined;
40
+ } | Promise<{
41
+ [x: string]: unknown;
42
+ ok: boolean;
43
+ status: "error" | "success";
44
+ conversation_id: string;
45
+ events: {
46
+ seq: number;
47
+ history_version: number;
48
+ created_at: string;
49
+ data: Record<string, unknown>;
50
+ idempotency_key?: string | undefined;
51
+ }[];
52
+ has_older: boolean;
53
+ has_newer: boolean;
54
+ target?: string | undefined;
55
+ data?: unknown;
56
+ truncated?: boolean | undefined;
57
+ continuation?: {
58
+ arguments: Record<string, unknown>;
59
+ reason?: string | undefined;
60
+ } | undefined;
61
+ error?: string | {
62
+ kind: string;
63
+ message: string;
64
+ retryable?: boolean | undefined;
65
+ } | undefined;
66
+ }>) | undefined;
67
+ };
68
+ export type { KnownConversationEventType };
@@ -1,6 +1,8 @@
1
- import type { SandboxFileSystem } from "@/chat/sandbox/workspace";
1
+ import type { SandboxCommandInput, SandboxCommandResult, SandboxFileSystem } from "@/chat/sandbox/workspace";
2
2
  export type { SandboxFileSystem };
3
+ export type SandboxCommandRunner = (input: SandboxCommandInput) => Promise<SandboxCommandResult>;
3
4
  export declare const MAX_TEXT_CHARS = 60000;
5
+ export declare const RIPGREP_EXCLUDED_GLOBS: readonly ["!**/.git/**", "!**/node_modules/**"];
4
6
  export type TextSearchResultDetails = {
5
7
  ok: true;
6
8
  status?: "success";
@@ -47,6 +49,11 @@ export declare function missingPathSearchResult(params: {
47
49
  }): TextSearchToolResult;
48
50
  /** Keep sandbox filesystem tools scoped to the mounted workspace root. */
49
51
  export declare function resolveWorkspacePath(input: string | undefined, fallback?: string): string;
52
+ /** Anchor ripgrep paths and globs to the requested search root. */
53
+ export declare function getRipgrepSearchLocation(root: string, rootIsDirectory: boolean): {
54
+ cwd: string;
55
+ target: string;
56
+ };
50
57
  /** Share bounded workspace traversal across search tools so their skip rules stay aligned. */
51
58
  export declare function collectFiles(params: {
52
59
  fs: SandboxFileSystem;
@@ -1,4 +1,4 @@
1
- import { type SandboxFileSystem, type TextSearchResultDetails, type TextSearchToolResult } from "@/chat/tools/sandbox/file-utils";
1
+ import { type SandboxCommandRunner, type SandboxFileSystem, type TextSearchResultDetails, type TextSearchToolResult } from "@/chat/tools/sandbox/file-utils";
2
2
  import { type JuniorToolResultEnvelope } from "@/chat/tool-support/structured-result";
3
3
  interface FindFilesSuccessResult {
4
4
  content: JuniorToolResultEnvelope["content"];
@@ -19,6 +19,7 @@ export declare function findFiles(params: {
19
19
  limit?: unknown;
20
20
  path?: string;
21
21
  pattern: string;
22
+ runCommand?: SandboxCommandRunner;
22
23
  }): Promise<FindFilesResult>;
23
24
  /** Create the sandbox file discovery tool definition exposed to the agent. */
24
25
  export declare function createFindFilesTool(): Omit<import("../definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
@@ -1,4 +1,4 @@
1
- import { type SandboxFileSystem, type TextSearchResultDetails, type TextSearchToolResult } from "@/chat/tools/sandbox/file-utils";
1
+ import { type SandboxCommandRunner, type SandboxFileSystem, type TextSearchResultDetails, type TextSearchToolResult } from "@/chat/tools/sandbox/file-utils";
2
2
  interface GrepResultData {
3
3
  context: number;
4
4
  glob?: string;
@@ -33,6 +33,7 @@ export declare function grepFiles(params: {
33
33
  literal?: boolean;
34
34
  path?: string;
35
35
  pattern: string;
36
+ runCommand?: SandboxCommandRunner;
36
37
  }): Promise<GrepResult>;
37
38
  /** Create the sandbox grep tool definition exposed to the agent. */
38
39
  export declare function createGrepTool(): Omit<import("../definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-6FKLPVF3.js";
3
+ } from "./chunk-OY2PQQ4P.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createVercelQueueClient
3
- } from "./chunk-KNFROR7R.js";
3
+ } from "./chunk-5I6ORJUY.js";
4
4
 
5
5
  // src/chat/task-execution/queue-signing.ts
6
6
  import { createHmac, timingSafeEqual } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-SYJT7AKB.js";
3
+ } from "./chunk-CY7NXM32.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";