@sentry/junior 0.148.0 → 0.150.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 (84) hide show
  1. package/dist/{agent-hooks-VAUYT6PD.js → agent-hooks-SEOGOGKX.js} +10 -10
  2. package/dist/api/conversations/aggregate.d.ts +2 -0
  3. package/dist/api/conversations/create.d.ts +1 -1
  4. package/dist/api/conversations/pending-messages.d.ts +15 -0
  5. package/dist/api/people/shared.d.ts +2 -0
  6. package/dist/api/schema/conversation.d.ts +78 -4
  7. package/dist/api/schema.d.ts +2 -2
  8. package/dist/api/schema.js +7 -1
  9. package/dist/api.d.ts +1 -1
  10. package/dist/api.js +186 -35
  11. package/dist/app.js +152 -186
  12. package/dist/{catalog-runtime-WADOZVTB.js → catalog-runtime-HA7RIWYT.js} +5 -5
  13. package/dist/chat/agent/index.d.ts +5 -4
  14. package/dist/chat/agent/prompt.d.ts +8 -5
  15. package/dist/chat/agent/resume.d.ts +2 -2
  16. package/dist/chat/agent/tools.d.ts +4 -7
  17. package/dist/chat/agent/{request.d.ts → types.d.ts} +138 -129
  18. package/dist/chat/agent-dispatch/types.d.ts +2 -2
  19. package/dist/chat/agent-invocations/spawn.d.ts +2 -2
  20. package/dist/chat/api-turns/work.d.ts +6 -1
  21. package/dist/chat/app/services.d.ts +1 -1
  22. package/dist/chat/plugins/viewer.d.ts +4 -0
  23. package/dist/chat/runtime/agent-runner.d.ts +7 -5
  24. package/dist/chat/runtime/reply-executor.d.ts +0 -2
  25. package/dist/chat/runtime/slack-resume.d.ts +3 -3
  26. package/dist/chat/services/conversation-memory.d.ts +2 -2
  27. package/dist/chat/services/conversation-title.d.ts +20 -0
  28. package/dist/chat/slack/assistant-thread/title.d.ts +10 -27
  29. package/dist/chat/state/conversation.d.ts +1 -0
  30. package/dist/chat/task-execution/paused-turn.d.ts +2 -2
  31. package/dist/chat/tools/types.d.ts +1 -1
  32. package/dist/{chunk-QOWHHM3F.js → chunk-3GL327SC.js} +1 -1
  33. package/dist/{chunk-45LOR4PU.js → chunk-3JVUWLR7.js} +45 -1
  34. package/dist/{chunk-4GXJUYJV.js → chunk-3ZMKDHCT.js} +2 -2
  35. package/dist/{chunk-DUY5CDAM.js → chunk-4KAYAIBV.js} +1 -1
  36. package/dist/{chunk-ULAU5ZGU.js → chunk-4VH7KLGC.js} +106 -113
  37. package/dist/{chunk-V2FXMOEA.js → chunk-64K7GKRW.js} +2 -2
  38. package/dist/{chunk-2B3PT3V2.js → chunk-6PFDWAK2.js} +1 -1
  39. package/dist/{chunk-LNVEIJ2L.js → chunk-7D4GNUV2.js} +5 -5
  40. package/dist/{chunk-ZPL2RR7F.js → chunk-7GOP6VFJ.js} +40 -36
  41. package/dist/{chunk-HWQGBIH7.js → chunk-7NLW2NF5.js} +1 -1
  42. package/dist/{chunk-55F4QU2V.js → chunk-7QB2CKCW.js} +1 -1
  43. package/dist/{chunk-WCN4YSH7.js → chunk-DWETNV66.js} +6 -6
  44. package/dist/{chunk-D3WPMGEX.js → chunk-F5NMSEBL.js} +1 -1
  45. package/dist/{chunk-IL4EDBMV.js → chunk-FEFEIA3Z.js} +5 -5
  46. package/dist/{chunk-WOONT5ZP.js → chunk-H2RLIJ7G.js} +1 -1
  47. package/dist/{chunk-VRHTNBA6.js → chunk-ILYL6YFD.js} +3 -3
  48. package/dist/{chunk-VCYSOXON.js → chunk-IPGNWXA3.js} +545 -7
  49. package/dist/{chunk-LAZGHEYU.js → chunk-IZRSLANA.js} +1 -1
  50. package/dist/{chunk-EAI67NTM.js → chunk-JQXJ2E53.js} +1 -1
  51. package/dist/{chunk-HLPLT3NY.js → chunk-M5OZSVJI.js} +8 -4
  52. package/dist/{chunk-XJ42NBP5.js → chunk-MCNP7A7T.js} +8 -8
  53. package/dist/{chunk-OJCP3C3J.js → chunk-NCGVQXX5.js} +22 -26
  54. package/dist/{chunk-4AQZYNHM.js → chunk-NNOCRVQO.js} +2 -2
  55. package/dist/{chunk-GXYDVZKM.js → chunk-P43QM7JY.js} +5 -5
  56. package/dist/{chunk-EINWQFXI.js → chunk-QPIPYVGE.js} +5 -5
  57. package/dist/{chunk-GDFF3BQG.js → chunk-RF6J3DIO.js} +34 -36
  58. package/dist/{chunk-D6YX4NNN.js → chunk-SH6ZKJFZ.js} +4 -4
  59. package/dist/{chunk-LE5H7LMT.js → chunk-SHDREBGC.js} +1 -1
  60. package/dist/{chunk-VMNRXKAH.js → chunk-TZLYAO2J.js} +191 -134
  61. package/dist/{chunk-RRJV5UR5.js → chunk-UIMBNY6O.js} +11 -337
  62. package/dist/{chunk-ZCHIC2GM.js → chunk-UOFQEVR5.js} +15 -6
  63. package/dist/{chunk-7OEIXFC3.js → chunk-Y2VZ54CQ.js} +12 -12
  64. package/dist/{chunk-VY6W3T43.js → chunk-ZBOGYZ53.js} +4 -4
  65. package/dist/{chunk-POSZWRGL.js → chunk-ZUQT35YC.js} +1 -1
  66. package/dist/cli/chat.js +31 -32
  67. package/dist/cli/check.js +6 -6
  68. package/dist/cli/plugins.js +13 -13
  69. package/dist/cli/snapshot-create.js +9 -9
  70. package/dist/cli/upgrade.js +7 -7
  71. package/dist/{db-XUKZRFFK.js → db-HUW75QG7.js} +7 -7
  72. package/dist/instrumentation.js +4 -4
  73. package/dist/nitro.js +2 -2
  74. package/dist/{oauth-callback-server-LPZMMGFI.js → oauth-callback-server-DP7NIZPQ.js} +24 -25
  75. package/dist/{runner-DGKUTMPX.js → runner-AINV7K3M.js} +47 -45
  76. package/dist/{skills-P7YUFSXM.js → skills-PKS37E6B.js} +6 -6
  77. package/dist/spawn-NJCDEPPL.js +38 -0
  78. package/dist/{validation-S7U5M5NR.js → validation-PDC3MVMM.js} +6 -6
  79. package/dist/version.js +1 -1
  80. package/dist/{work-GAA7TVAD.js → work-KJLJRPXS.js} +17 -17
  81. package/dist/{worker-JXPJH3QB.js → worker-TYQ7YVIR.js} +11 -11
  82. package/package.json +5 -5
  83. package/dist/chunk-4EA2SFK2.js +0 -137
  84. package/dist/spawn-DSK3ZEVD.js +0 -38
@@ -7,7 +7,7 @@ import type { ToolRuntimeContext } from "@/chat/tools/types";
7
7
  import type { AnyToolDefinition } from "@/chat/tools/definition";
8
8
  import { type Actor } from "@/chat/actor";
9
9
  import type { PluginTurnContext } from "@/chat/plugins/prompt";
10
- import type { AgentRunInput, AgentRunInstructionActor, AgentRunRouting, AgentRunSteeringMessage } from "@/chat/agent/request";
10
+ import type { AgentInstruction, AgentInstructionActor, AgentRun, AgentSteeringMessage } from "@/chat/agent/types";
11
11
  export type UserContentPart = {
12
12
  type: "text";
13
13
  text: string;
@@ -38,7 +38,7 @@ export interface PromptAssembly {
38
38
  userContentParts: UserContentPart[];
39
39
  }
40
40
  /** Render the current actor's instruction without host-owned thread context. */
41
- export declare function buildUserTurnText(userInput: string, actor?: AgentRunInstructionActor): string;
41
+ export declare function buildUserTurnText(userInput: string, actor?: AgentInstructionActor): string;
42
42
  /** Render an explicitly selected skill as instructions for the current turn. */
43
43
  export declare function renderExplicitSkillInstructions(skill: Skill): string;
44
44
  /** Encode a non-image attachment as base64 XML for the prompt. */
@@ -50,13 +50,16 @@ export declare function encodeNonImageAttachmentForPrompt(attachment: {
50
50
  /** Redact image data from prompt content parts for observability. */
51
51
  export declare function toObservablePromptPart(part: UserContentPart): Record<string, unknown>;
52
52
  /** Build the prompt-facing user input, keeping router text aligned with Pi content. */
53
- export declare function buildPromptInput(input: AgentRunInput): PromptInput;
53
+ export declare function buildPromptInput(args: {
54
+ instruction: AgentInstruction;
55
+ history?: readonly import("@/chat/pi/messages").PiMessage[];
56
+ }): PromptInput;
54
57
  /**
55
58
  * Convert a mid-run user message into the Pi user message shape used for
56
59
  * steering injection and parked-conversation event-log appends, so both
57
60
  * paths store identical durable history.
58
61
  */
59
- export declare function buildSteeringPiMessage(message: AgentRunSteeringMessage): PiMessage;
62
+ export declare function buildSteeringPiMessage(message: AgentSteeringMessage): PiMessage;
60
63
  /** Assemble prompt history, instructions, and telemetry input for one slice. */
61
64
  export declare function assemblePrompt(args: {
62
65
  activeMcpCatalogs: ActiveMcpCatalogSummary[];
@@ -70,7 +73,7 @@ export declare function assemblePrompt(args: {
70
73
  explicitSkill: Skill | null;
71
74
  priorPiMessages?: PiMessage[];
72
75
  resumedFromSessionRecord: boolean;
73
- routing: AgentRunRouting;
76
+ run: Pick<AgentRun, "source" | "destination" | "dispatch" | "slackConversation">;
74
77
  spanContext: LogContext;
75
78
  turnId: string;
76
79
  toolGuidance: Array<{
@@ -12,7 +12,7 @@ import type { Actor } from "@/chat/actor";
12
12
  import { type AgentTurnSurface, type TurnCheckpoint } from "@/chat/task-execution/checkpoint";
13
13
  import { type AuthorizationPauseError } from "@/chat/services/auth-pause";
14
14
  import { type AgentTurnUsage } from "@/chat/usage";
15
- import { type AgentRunDurability } from "@/chat/agent/request";
15
+ import { type AgentDurability } from "@/chat/agent/types";
16
16
  import type { PluginTurnContext } from "@/chat/plugins/prompt";
17
17
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
18
18
  interface ResumeStateArgs {
@@ -20,7 +20,7 @@ interface ResumeStateArgs {
20
20
  destination: Destination;
21
21
  destinationVisibility?: ConversationPrivacy;
22
22
  dispatchId?: string;
23
- durability: AgentRunDurability;
23
+ durability: AgentDurability;
24
24
  recordActiveMcpProviders: () => Promise<void>;
25
25
  publishExternally: boolean;
26
26
  actor?: Actor;
@@ -25,7 +25,7 @@ import type { OAuthAuthorization } from "@/chat/oauth-authorization";
25
25
  import type { Actor } from "@/chat/actor";
26
26
  import type { AuthorizationPauseError } from "@/chat/services/auth-pause";
27
27
  import type { AgentTurnSurface } from "@/chat/task-execution/checkpoint";
28
- import { type AgentRunDurability, type AgentRunObservers, type AgentRunPolicy, type AgentRunRouting, type AgentRunState } from "@/chat/agent/request";
28
+ import { type AgentDurability, type AgentEvent, type AgentRun, type AgentRunState } from "@/chat/agent/types";
29
29
  import type { ResumeState } from "@/chat/agent/resume";
30
30
  interface ToolWiringArgs {
31
31
  abortAgent: () => void;
@@ -43,22 +43,19 @@ interface ToolWiringArgs {
43
43
  configurationValues: Record<string, unknown>;
44
44
  connectedMcpProviders: Set<string>;
45
45
  conversationPrivacy?: ConversationPrivacy;
46
- durability: AgentRunDurability;
46
+ durability: AgentDurability;
47
47
  authorization?: OAuthAuthorization;
48
48
  generatedFiles: FileUpload[];
49
49
  invokedSkill: SkillMetadata | null;
50
- observers: AgentRunObservers;
50
+ onEvent?: (event: AgentEvent) => void | Promise<void>;
51
51
  onFatalToolError(error: Error): void;
52
52
  onSandboxRefChanged: (sandboxRef: SandboxRef) => void;
53
- policy: AgentRunPolicy;
54
53
  preAgentPromptMessages: () => PiMessage[];
55
54
  priorPiMessages: PiMessage[] | undefined;
56
55
  recordConnectedMcpProvider: (provider: string) => Promise<void>;
57
56
  requestHandoff?: ToolRuntimeContext["handoff"];
58
57
  resume: ResumeState;
59
- routing: AgentRunRouting;
60
- conversationId: string;
61
- turnId: string;
58
+ run: AgentRun;
62
59
  skillSandbox: SkillSandbox;
63
60
  spanContext: LogContext;
64
61
  state: AgentRunState;
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Agent run request contract.
2
+ * Public agent-run launch contract.
3
3
  *
4
- * Groups the per-slice run request by the runtime role each field serves and
5
- * owns interpretation of the routing group: actor derivation, surface
6
- * inference, destination consistency checks, and session identifiers. Run
7
- * phases consume these groups directly; callers build them at runtime
8
- * boundaries.
4
+ * Providers build one flat `AgentRun` and call `AgentRunner.run`. Delivery and
5
+ * durability are capabilities that affect the run. `onEvent` is best-effort UI
6
+ * only. Stable composition binds stream, spawn, and tracing outside this type.
9
7
  */
10
8
  import type { Destination, ReplyAttribution, Source, SystemActor } from "@sentry/junior-plugin-api";
11
9
  import type { LocationConfigurationService } from "@/chat/configuration/types";
@@ -17,7 +15,6 @@ import type { SandboxRef } from "@/chat/sandbox/ref";
17
15
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
18
16
  import type { SandboxEgressSignalTransport } from "@/chat/sandbox/egress/signals";
19
17
  import type { OAuthAuthorization } from "@/chat/oauth-authorization";
20
- import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
21
18
  import type { SlackConversationContext } from "@/chat/slack/conversation-context";
22
19
  import type { ConversationPendingAuthState } from "@/chat/state/conversation";
23
20
  import type { ConversationMessageProvenance } from "@/chat/conversations/provenance";
@@ -27,26 +24,33 @@ import type { SlackActionToken } from "@/chat/slack/action-token";
27
24
  import type { TurnReasoningLevel } from "@/chat/reasoning-level";
28
25
  import type { ImageGenerateToolDeps, ViewImageToolDeps, WebFetchToolDeps, WebSearchToolDeps } from "@/chat/tools/types";
29
26
  import type { AssistantMessage } from "@earendil-works/pi-ai";
30
- export interface AgentRunAttachment {
27
+ /** One attachment the model may see for the current instruction. */
28
+ export type AgentAttachment = {
31
29
  data?: Buffer;
32
30
  mediaType: string;
33
31
  filename?: string;
34
32
  promptText?: string;
35
- }
36
- export interface AgentRunInstructionActor {
33
+ };
34
+ /** Instruction author metadata used for prompt labels and provenance. */
35
+ export type AgentInstructionActor = {
37
36
  authorId?: string;
38
37
  authorName?: string;
38
+ /**
39
+ * Slack message ts for the instruction when known.
40
+ * TODO: generalize to a provider-neutral message id once prompt attrs are neutral.
41
+ */
39
42
  slackTs?: string;
40
- }
41
- export interface AgentRunSteeringMessage {
42
- actor?: AgentRunInstructionActor;
43
+ };
44
+ /** One mid-turn steered user message drained from the durable mailbox. */
45
+ export type AgentSteeringMessage = {
46
+ actor?: AgentInstructionActor;
43
47
  /** Provenance of this queued/steered message, carrying its original author. */
44
48
  provenance: ConversationMessageProvenance;
45
49
  omittedImageAttachmentCount?: number;
46
50
  text: string;
47
51
  timestampMs?: number;
48
- userAttachments?: AgentRunAttachment[];
49
- }
52
+ attachments?: AgentAttachment[];
53
+ };
50
54
  /** Model-safe input for one asynchronously delegated child-agent task. */
51
55
  export type SpawnAgentInput = {
52
56
  name?: string;
@@ -62,155 +66,160 @@ export type SpawnAgent = (input: SpawnAgentInput, options: {
62
66
  signal?: AbortSignal;
63
67
  toolCallId: string;
64
68
  }) => Promise<SpawnAgentResult>;
65
- /** Carries the user-visible content and prior transcript for one agent-run slice. */
66
- export interface AgentRunInput {
67
- actor?: AgentRunInstructionActor;
68
- includeConversationContextWithPiMessages?: boolean;
69
- messageText: string;
70
- userAttachments?: AgentRunAttachment[];
69
+ /** Current user instruction for one agent-run slice. */
70
+ export type AgentInstruction = {
71
+ text: string;
72
+ attachments?: readonly AgentAttachment[];
71
73
  inboundAttachmentCount?: number;
72
74
  omittedImageAttachmentCount?: number;
73
- /** Durable Pi transcript for this conversation, excluding ephemeral turn context. */
74
- piMessages?: PiMessage[];
75
- conversationContext?: string;
76
- }
77
- /**
78
- * Identity and addressing for one run.
79
- *
80
- * Set `actor` first (who runs). Derive `credentialContext` with
81
- * `credentialContextForActor(actor, subject?)` unless a caller already bound
82
- * credentials (dispatch with delegated subject). They name the same principal
83
- * except when a system actor carries `credentialContext.subject` for delegated
84
- * user tokens.
85
- */
86
- export interface AgentRunRouting {
87
- /** Who this run executes as. Prefer always setting this. */
88
- actor?: Actor;
89
- /** Credential authority projected from actor (plus optional subject). */
90
- credentialContext?: CredentialContext;
91
- source: Source;
92
- slackConversation?: SlackConversationContext;
75
+ /** Host-owned turn context shown to the model near the instruction. */
76
+ context?: string;
77
+ actor?: AgentInstructionActor;
93
78
  /**
94
- * TODO: Move ephemeral Slack credentials into provider-owned turn context so
95
- * the Slack tool registry can consume them without extending core routing.
79
+ * When history is present, still include `context` in the prompt. Default is
80
+ * to omit conversation context once durable history already carries it.
96
81
  */
97
- slackActionToken?: SlackActionToken;
98
- destination: Destination;
99
- /** When true, also publish assistant output to the conversation destination. */
100
- publishExternally?: boolean;
101
- /** Confirmed visibility of the destination where this run is delivered. */
102
- destinationVisibility?: ConversationPrivacy;
103
- surface?: AgentTurnSurface;
104
- dispatch?: {
105
- actor?: SystemActor;
106
- id: string;
107
- metadata?: Record<string, string>;
108
- plugin?: string;
109
- replyAttribution?: ReplyAttribution;
110
- };
111
- toolChannelId?: string;
112
- }
82
+ includeConversationContextWithHistory?: boolean;
83
+ };
84
+ /** Dispatch identity carried on plugin-authored runs. */
85
+ export type AgentDispatch = {
86
+ actor?: SystemActor;
87
+ id: string;
88
+ metadata?: Record<string, string>;
89
+ plugin?: string;
90
+ replyAttribution?: ReplyAttribution;
91
+ };
113
92
  /** Optional agent capabilities that a run slice can turn off. */
114
93
  export declare const AGENT_RUN_FEATURES: readonly ["handoff", "interactive-auth", "subagents"];
115
- /** One optional agent capability controlled by run policy. */
116
- export type AgentRunFeature = (typeof AGENT_RUN_FEATURES)[number];
117
- /** Return whether one optional agent capability is disabled for this run. */
118
- export declare function isAgentRunFeatureDisabled(policy: Pick<AgentRunPolicy, "disabledFeatures"> | undefined, feature: AgentRunFeature): boolean;
119
- /** Carries execution limits and dependency overrides for one run slice. */
120
- export interface AgentRunPolicy {
121
- /**
122
- * Optional agent capabilities disabled for this run slice.
123
- * `interactive-auth` blocks pausing to send an OAuth link; missing credentials
124
- * hard-fail instead. Default is enabled when omitted.
125
- * TODO(#881, #883): child invocations currently disable interactive-auth, but
126
- * may later need a path to force the auth flow when a delegated tool requires
127
- * credentials the parent can already request.
128
- */
129
- disabledFeatures?: readonly AgentRunFeature[];
130
- /** Absolute wall-clock deadline for this host request, in milliseconds. */
131
- turnDeadlineAtMs?: number;
132
- /** Cancels provider work when the owning host request is abandoned. */
133
- signal?: AbortSignal;
134
- /** Explicit per-agent reasoning level. When set, adaptive routing is disabled. */
135
- reasoningLevel?: TurnReasoningLevel;
136
- configuration?: Record<string, unknown>;
137
- locationConfiguration?: LocationConfigurationService;
138
- skillDirs?: string[];
139
- /** Per-slice override for app-owned sandbox egress trace propagation. */
140
- sandboxTracePropagation?: SandboxEgressTracePropagationConfig;
141
- /** Per-slice sandbox egress signal storage override. */
142
- sandboxEgressSignals?: SandboxEgressSignalTransport;
143
- toolOverrides?: {
144
- imageGenerate?: ImageGenerateToolDeps;
145
- viewImage?: ViewImageToolDeps;
146
- webFetch?: WebFetchToolDeps;
147
- webSearch?: WebSearchToolDeps;
148
- };
149
- }
150
- /** Carries durable state snapshots already loaded by the caller. */
151
- export interface AgentRunState {
94
+ /** One optional agent capability controlled per run. */
95
+ export type AgentFeature = (typeof AGENT_RUN_FEATURES)[number];
96
+ /** Already-loaded resume state for this conversation. */
97
+ export type AgentRunState = {
152
98
  pendingAuth?: ConversationPendingAuthState;
153
99
  /** Persisted sandbox reuse state from prior slices of this conversation. */
154
100
  sandboxRef?: SandboxRef;
155
- }
156
- /**
157
- * Carries notification-only callbacks for streaming UI and status surfaces;
158
- * their failures never affect the run.
159
- */
160
- export interface AgentRunObservers {
161
- onToolInvocation?: (invocation: {
162
- params: Record<string, unknown>;
163
- toolCallId: string;
164
- toolName: string;
165
- }) => void | Promise<void>;
166
- onToolResult?: (result: ToolExecutionReport) => void | Promise<void>;
167
- onStatus?: (status: AssistantStatusSpec) => void | Promise<void>;
168
- }
101
+ };
169
102
  /**
170
103
  * Delivers completed tool-free assistant messages in model order.
171
104
  *
172
105
  * The runner must commit the preceding agent boundary before invoking this
173
106
  * port; the accepted reply transaction appends only this message.
174
107
  */
175
- export type AgentRunDelivery = (message: AssistantMessage) => void | Promise<void>;
108
+ export type AgentDelivery = (message: AssistantMessage) => void | Promise<void>;
176
109
  /** Resume the agent turn after a transient or ambiguous delivery failure. */
177
110
  export declare class RetryableDeliveryError extends Error {
178
111
  constructor(cause: unknown);
179
112
  }
180
- /** Carries durable-worker ports that commit or update resumable run state. */
181
- export interface AgentRunDurability {
113
+ /** Durable-worker ports that commit or update resumable run state. */
114
+ export type AgentDurability = {
182
115
  /** Schedule delegated work with authority bound by the active parent run. */
183
116
  spawnAgent?: SpawnAgent;
184
117
  onInputCommitted?: () => void | Promise<void>;
185
118
  /** Return true when the durable worker should pause at the next Pi boundary. */
186
119
  shouldYield?: () => boolean;
187
- drainSteeringMessages?: (accept: (messages: AgentRunSteeringMessage[]) => Promise<void>) => Promise<AgentRunSteeringMessage[]>;
120
+ drainSteeringMessages?: (accept: (messages: AgentSteeringMessage[]) => Promise<void>) => Promise<AgentSteeringMessage[]>;
188
121
  recordPendingAuth?: (pendingAuth: ConversationPendingAuthState | undefined) => void | Promise<void>;
189
122
  onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
190
- }
191
- /** Groups the per-slice run request by the runtime role each field serves. */
192
- export interface AgentRunRequest {
123
+ };
124
+ /** Best-effort progress events. Failures here never affect the run. */
125
+ export type AgentEvent = {
126
+ type: "status";
127
+ text: string;
128
+ } | {
129
+ type: "tool_started";
130
+ toolCallId: string;
131
+ toolName: string;
132
+ params: Record<string, unknown>;
133
+ } | {
134
+ type: "tool_finished";
135
+ report: ToolExecutionReport;
136
+ };
137
+ /** Resolved environment and optional per-run tool test overrides. */
138
+ export type AgentEnvironment = {
139
+ configuration?: Record<string, unknown>;
140
+ locationConfiguration?: LocationConfigurationService;
141
+ skillDirs?: string[];
142
+ /** Per-slice override for app-owned sandbox egress trace propagation. */
143
+ sandboxTracePropagation?: SandboxEgressTracePropagationConfig;
144
+ /** Per-slice sandbox egress signal storage override. */
145
+ sandboxEgressSignals?: SandboxEgressSignalTransport;
146
+ toolOverrides?: {
147
+ imageGenerate?: ImageGenerateToolDeps;
148
+ viewImage?: ViewImageToolDeps;
149
+ webFetch?: WebFetchToolDeps;
150
+ webSearch?: WebSearchToolDeps;
151
+ };
152
+ };
153
+ /**
154
+ * One provider-launched agent-run slice.
155
+ *
156
+ * Build identity, instruction, history, delivery, and durability here. Bind
157
+ * stable model/stream composition when creating the runner, not on each run.
158
+ */
159
+ export type AgentRun = {
193
160
  /** Durable conversation advanced by this run. */
194
161
  conversationId: string;
195
162
  /** Stable turn advanced across this run and any continuation runs. */
196
163
  turnId: string;
197
164
  /** Optional bounded-run identifier used only for observability. */
198
165
  runId?: string;
199
- input: AgentRunInput;
200
- routing: AgentRunRouting;
166
+ instruction: AgentInstruction;
167
+ /** Durable Pi transcript for this conversation, excluding ephemeral turn context. */
168
+ history?: readonly PiMessage[];
169
+ /**
170
+ * Who this run executes as. Prefer always setting this. Derive
171
+ * `credentialContext` with `credentialContextForActor(actor, subject?)`
172
+ * unless a caller already bound credentials.
173
+ */
174
+ actor?: Actor;
175
+ /** Credential authority projected from actor (plus optional subject). */
176
+ credentialContext?: CredentialContext;
177
+ source: Source;
178
+ destination: Destination;
179
+ /** When true, also publish assistant output to the conversation destination. */
180
+ publishExternally?: boolean;
181
+ /** Confirmed visibility of the destination where this run is delivered. */
182
+ destinationVisibility?: ConversationPrivacy;
183
+ surface?: AgentTurnSurface;
184
+ dispatch?: AgentDispatch;
185
+ /**
186
+ * TODO: Move ephemeral Slack credentials and conversation labels into
187
+ * provider-owned tool/prompt context so the shared run edge stays neutral.
188
+ */
189
+ slackConversation?: SlackConversationContext;
190
+ slackActionToken?: SlackActionToken;
191
+ toolChannelId?: string;
201
192
  /** Surface-owned OAuth state and private delivery capabilities. */
202
193
  authorization?: OAuthAuthorization;
203
- policy?: AgentRunPolicy;
194
+ /**
195
+ * Optional agent capabilities disabled for this run slice.
196
+ * `interactive-auth` blocks pausing to send an OAuth link; missing credentials
197
+ * hard-fail instead. Default is enabled when omitted.
198
+ * TODO(#881, #883): child invocations currently disable interactive-auth, but
199
+ * may later need a path to force the auth flow when a delegated tool requires
200
+ * credentials the parent can already request.
201
+ */
202
+ disabledFeatures?: readonly AgentFeature[];
203
+ /** Absolute wall-clock deadline for this host request, in milliseconds. */
204
+ deadlineAtMs?: number;
205
+ /** Cancels provider work when the owning host request is abandoned. */
206
+ signal?: AbortSignal;
207
+ /** Explicit per-agent reasoning level. When set, adaptive routing is disabled. */
208
+ reasoning?: TurnReasoningLevel;
209
+ environment?: AgentEnvironment;
204
210
  state?: AgentRunState;
205
- observers?: AgentRunObservers;
206
- delivery?: AgentRunDelivery;
207
- durability?: AgentRunDurability;
208
- }
209
- /** Resolve the explicit actor or the system credential actor for this run. */
210
- export declare function actorFromRouting(routing: AgentRunRouting): Actor | undefined;
211
+ /** Best-effort progress only. */
212
+ onEvent?: (event: AgentEvent) => void | Promise<void>;
213
+ delivery?: AgentDelivery;
214
+ durability?: AgentDurability;
215
+ };
216
+ /** Return whether one optional agent capability is disabled for this run. */
217
+ export declare function isAgentRunFeatureDisabled(disabledFeatures: readonly AgentFeature[] | undefined, feature: AgentFeature): boolean;
218
+ /** Resolve the explicit actor, dispatch actor, or credential actor for this run. */
219
+ export declare function actorFromRun(run: Pick<AgentRun, "actor" | "dispatch" | "credentialContext">): Actor | undefined;
211
220
  /** Reject contradictory provider coordinates before the run touches state. */
212
- export declare function assertRunRoutingConsistency(request: Pick<AgentRunRequest, "conversationId" | "routing">): void;
221
+ export declare function assertRunConsistency(run: Pick<AgentRun, "conversationId" | "source" | "destination" | "surface" | "publishExternally" | "actor" | "dispatch">): void;
213
222
  /** Route tool side effects to the tool channel when one overrides the destination. */
214
- export declare function toolInvocationDestination(routing: AgentRunRouting): Destination;
223
+ export declare function toolInvocationDestination(run: Pick<AgentRun, "destination" | "toolChannelId">): Destination;
215
224
  /** Infer the run surface when the caller did not state one. */
216
- export declare function surfaceFromRouting(routing: AgentRunRouting): AgentTurnSurface;
225
+ export declare function surfaceFromRun(run: Pick<AgentRun, "surface" | "source">): AgentTurnSurface;
@@ -1,6 +1,6 @@
1
1
  import type { DispatchOptions, DestinationVisibility, ReplyAttribution, Source, SlackDestination } from "@sentry/junior-plugin-api";
2
2
  import type { CredentialContext, CredentialSubject, CredentialSystemActor } from "@/chat/credentials/context";
3
- import type { AgentRunRouting } from "@/chat/agent/request";
3
+ import type { AgentDispatch } from "@/chat/agent/types";
4
4
  import type { AgentTurnSurface } from "@/chat/task-execution/checkpoint";
5
5
  import type { LocationConfigurationService } from "@/chat/configuration/types";
6
6
  export type DispatchStatus = "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
@@ -51,7 +51,7 @@ export interface DispatchTurnContext {
51
51
  locationConfiguration: LocationConfigurationService;
52
52
  credentialContext: CredentialContext;
53
53
  destinationVisibility: DestinationVisibility;
54
- dispatch: NonNullable<AgentRunRouting["dispatch"]>;
54
+ dispatch: AgentDispatch;
55
55
  skipProviderDefaultConfig: true;
56
56
  source: Source;
57
57
  surface: Extract<AgentTurnSurface, "api">;
@@ -1,6 +1,6 @@
1
1
  import type { StateAdapter } from "chat";
2
2
  import type { ConversationStore } from "@/chat/conversations/store";
3
- import type { AgentRunRequest, SpawnAgent } from "@/chat/agent/request";
3
+ import type { AgentRun, SpawnAgent } from "@/chat/agent/types";
4
4
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
5
5
  type SpawnOptions = {
6
6
  conversationStore?: ConversationStore;
@@ -8,5 +8,5 @@ type SpawnOptions = {
8
8
  state?: StateAdapter;
9
9
  };
10
10
  /** Bind one run's runtime-owned authority to the model-safe spawn capability. */
11
- export declare function bindSpawnAgent(request: AgentRunRequest, options: SpawnOptions): SpawnAgent | undefined;
11
+ export declare function bindSpawnAgent(run: AgentRun, options: SpawnOptions): SpawnAgent | undefined;
12
12
  export {};
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import type { StateAdapter } from "chat";
3
3
  import { type Destination } from "@sentry/junior-plugin-api";
4
+ import type { ConversationPrivacy } from "@/chat/conversation-privacy";
4
5
  import type { WebActor } from "@/chat/actor";
5
6
  import type { ConversationStore } from "@/chat/conversations/store";
6
7
  import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
@@ -28,12 +29,16 @@ export interface CreateApiConversationInput {
28
29
  message: string;
29
30
  /** Client-supplied idempotency key for the first message. */
30
31
  idempotencyKey: string;
32
+ /** New roots default public. Continues never rewrite visibility. */
33
+ visibility?: ConversationPrivacy;
31
34
  }
32
35
  export interface AppendApiConversationMessageInput {
33
36
  actor: WebActor;
34
37
  conversationId: string;
35
38
  message: string;
36
39
  idempotencyKey: string;
40
+ /** Applied only when this call creates the conversation root. */
41
+ rootVisibility?: ConversationPrivacy;
37
42
  }
38
43
  export interface ApiConversationMessageAccepted {
39
44
  conversationId: string;
@@ -68,7 +73,7 @@ export declare function buildApiTurnInboundMessage(args: {
68
73
  messageId: string;
69
74
  nowMs?: number;
70
75
  }): InboundMessage;
71
- /** Create a public root conversation and enqueue its first message. */
76
+ /** Create a dashboard root conversation and enqueue its first message. */
72
77
  export declare function createAndEnqueueApiConversation(input: CreateApiConversationInput, options: EnqueueOptions): Promise<ApiConversationMessageAccepted>;
73
78
  /** Append one API message to an existing conversation and wake the worker. */
74
79
  export declare function appendAndEnqueueApiConversationMessage(input: AppendApiConversationMessageInput, options: EnqueueOptions): Promise<ApiConversationMessageAccepted>;
@@ -14,7 +14,7 @@ export interface JuniorRuntimeServices {
14
14
  export interface JuniorRuntimeServiceOverrides {
15
15
  conversationMemory?: Partial<ConversationMemoryDeps>;
16
16
  contextCompactor?: Partial<ContextCompactorDeps>;
17
- replyExecutor?: Partial<Omit<ReplyExecutorServices, "generateThreadTitle">>;
17
+ replyExecutor?: Partial<ReplyExecutorServices>;
18
18
  subscribedReplyPolicy?: Partial<SubscribedReplyPolicyDeps>;
19
19
  sandbox?: {
20
20
  tracePropagation?: SandboxEgressTracePropagationConfig;
@@ -4,6 +4,10 @@ import type { JuniorDatabase } from "@/db/db";
4
4
  export declare function resolveViewerUserFromSql(db: JuniorDatabase, email: string): Promise<User | undefined>;
5
5
  /** Resolve or create the canonical user for one authenticated viewer. */
6
6
  export declare function resolveViewerUser(email: string): Promise<User | undefined>;
7
+ /** Update one canonical user's display name in SQL. */
8
+ export declare function updateViewerDisplayNameFromSql(db: JuniorDatabase, userId: string, displayName: string): Promise<User | undefined>;
9
+ /** Update one canonical user's display name. */
10
+ export declare function updateViewerDisplayName(userId: string, displayName: string): Promise<User | undefined>;
7
11
  /** Resolve the stored identity and linked user for one runtime actor. */
8
12
  export declare function readActorIdentityFromSql(db: JuniorDatabase, actor: Actor): Promise<{
9
13
  identity: Identity;
@@ -1,12 +1,14 @@
1
- import { type AgentRunRequest, type SpawnAgent } from "@/chat/agent/request";
1
+ import type { StreamFn } from "@earendil-works/pi-agent-core";
2
+ import { type AgentRun, type SpawnAgent } from "@/chat/agent/types";
2
3
  import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
3
4
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
4
5
  /** Run one agent-run slice behind runtime-owned orchestration boundaries. */
5
6
  export interface AgentRunner {
6
- run(request: AgentRunRequest): Promise<AgentRunOutcome>;
7
+ run(run: AgentRun): Promise<AgentRunOutcome>;
7
8
  }
8
- /** Adapt the Pi-facing agent-run executor behind the runtime-owned runner seam. */
9
- export declare function createAgentRunner(run: AgentRunner["run"], options?: {
10
- bindSpawnAgent?: (request: AgentRunRequest) => SpawnAgent | undefined;
9
+ /** Compose the agent executor with stable host dependencies. */
10
+ export declare function createAgentRunner(execute: (run: AgentRun, streamFn?: StreamFn) => Promise<AgentRunOutcome>, options?: {
11
+ bindSpawnAgent?: (run: AgentRun) => SpawnAgent | undefined;
12
+ streamFn?: StreamFn;
11
13
  tracePropagation?: SandboxEgressTracePropagationConfig;
12
14
  }): AgentRunner;
@@ -12,7 +12,6 @@ import { type Destination } from "@sentry/junior-plugin-api";
12
12
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
13
13
  import type { PreparedTurnState } from "@/chat/runtime/turn-preparation";
14
14
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnToolInvocation } from "@/chat/runtime/turn-input";
15
- import { type ConversationMemoryService } from "@/chat/services/conversation-memory";
16
15
  import type { ContextCompactor } from "@/chat/services/context-compaction";
17
16
  import { lookupSlackUser } from "@/chat/slack/user";
18
17
  import type { PausedTurnRequest } from "@/chat/task-execution/turn-wake";
@@ -21,7 +20,6 @@ import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispa
21
20
  export interface ReplyExecutorServices {
22
21
  agentRunner: AgentRunner;
23
22
  contextCompactor: ContextCompactor;
24
- generateThreadTitle: ConversationMemoryService["generateThreadTitle"];
25
23
  getPausedTurnRequest: (args: {
26
24
  conversationId: string;
27
25
  turnId: string;
@@ -1,4 +1,4 @@
1
- import { type AgentRunRequest } from "@/chat/agent/request";
1
+ import { type AgentRun } from "@/chat/agent/types";
2
2
  import type { AgentRunResult } from "@/chat/services/turn-result";
3
3
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
4
  import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
@@ -44,8 +44,8 @@ interface ResumeSlackTurnArgs {
44
44
  beforeStart?: () => Promise<ResumePreparedTurn | false | void>;
45
45
  replyTimeoutMs?: number;
46
46
  }
47
- type ResumeReplyContext = Omit<AgentRunRequest, "conversationId" | "turnId" | "runId" | "input" | "delivery"> & {
48
- input?: Omit<AgentRunRequest["input"], "messageText">;
47
+ type ResumeReplyContext = Omit<AgentRun, "conversationId" | "turnId" | "runId" | "instruction" | "delivery"> & {
48
+ instruction?: Omit<AgentRun["instruction"], "text">;
49
49
  };
50
50
  interface ResumePreparedTurn {
51
51
  messageText: string;
@@ -11,7 +11,6 @@ export interface ConversationMemoryService {
11
11
  actorId?: string;
12
12
  runId?: string;
13
13
  }) => Promise<void>;
14
- generateThreadTitle: (sourceText: string) => Promise<string>;
15
14
  }
16
15
  export declare function generateConversationId(prefix: "assistant" | "backfill" | "compaction" | "turn"): string;
17
16
  /** Normalize message boundaries without changing transcript formatting. */
@@ -23,6 +22,7 @@ export declare function upsertConversationMessage(conversation: ThreadConversati
23
22
  export declare function recordDeliveredAssistantMessage(args: {
24
23
  conversation: ThreadConversationState;
25
24
  sessionId: string;
25
+ source?: "web";
26
26
  text: string;
27
27
  userMessageId?: string;
28
28
  }): string;
@@ -39,7 +39,7 @@ export declare function buildConversationContext(conversation: ThreadConversatio
39
39
  }): string | undefined;
40
40
  /** Return the earliest human-authored message known for a thread. */
41
41
  export declare function getThreadTitleSourceMessage(conversation: ThreadConversationState): ConversationMessage | undefined;
42
- /** Build the service that owns durable conversation memory compaction and titles. */
42
+ /** Build the service that owns durable conversation memory compaction. */
43
43
  export declare function createConversationMemoryService(deps: ConversationMemoryDeps): ConversationMemoryService;
44
44
  export declare function isHumanConversationMessage(message: ConversationMessage): boolean;
45
45
  /** Return the native Slack timestamp for a persisted conversation message. */
@@ -0,0 +1,20 @@
1
+ import type { ConversationStore } from "@/chat/conversations/store";
2
+ import type { ThreadConversationState } from "@/chat/state/conversation";
3
+ /** Test-only: clear in-flight title work between cases. */
4
+ export declare function resetConversationTitleStateForTests(): void;
5
+ /**
6
+ * Fire-and-forget title work after durable human transcript writes.
7
+ * This is the only entry that starts generation.
8
+ */
9
+ export declare function scheduleConversationTitle(args: {
10
+ conversation: ThreadConversationState;
11
+ conversationId: string | undefined;
12
+ }): void;
13
+ /**
14
+ * Join in-flight generation when present, otherwise read the stored title.
15
+ * Does not start generation; providers use this only to project a title.
16
+ */
17
+ export declare function resolveConversationTitle(args: {
18
+ conversationId: string;
19
+ conversationStore?: Pick<ConversationStore, "get">;
20
+ }): Promise<string | undefined>;