@sentry/junior 0.108.0 → 0.110.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 (109) hide show
  1. package/dist/{agent-hooks-NU5HK3PS.js → agent-hooks-ELT4ODFF.js} +12 -13
  2. package/dist/api/conversations/access.d.ts +9 -0
  3. package/dist/api/conversations/aggregate.d.ts +12 -1
  4. package/dist/api/conversations/archive.d.ts +3 -5
  5. package/dist/api/conversations/detail.d.ts +156 -7
  6. package/dist/api/conversations/events.d.ts +2 -2
  7. package/dist/api/conversations/list.d.ts +57 -6
  8. package/dist/api/conversations/projection.d.ts +6 -7
  9. package/dist/api/conversations/reporting.d.ts +10 -4
  10. package/dist/api/conversations/routes.d.ts +2 -1
  11. package/dist/api/conversations/shared.d.ts +1 -1
  12. package/dist/api/conversations/stats.d.ts +37 -6
  13. package/dist/api/conversations/stats.query.d.ts +1 -1
  14. package/dist/api/conversations/usage.d.ts +9 -0
  15. package/dist/api/http.d.ts +7 -0
  16. package/dist/api/locations/detail.d.ts +102 -6
  17. package/dist/api/locations/list.d.ts +43 -5
  18. package/dist/api/locations/query.d.ts +4 -2
  19. package/dist/api/locations/routes.d.ts +2 -1
  20. package/dist/api/people/list.d.ts +28 -6
  21. package/dist/api/people/list.query.d.ts +1 -1
  22. package/dist/api/people/profile.d.ts +96 -7
  23. package/dist/api/people/profile.query.d.ts +4 -2
  24. package/dist/api/people/routes.d.ts +2 -1
  25. package/dist/api/people/shared.d.ts +1219 -2
  26. package/dist/api/route.d.ts +18 -4
  27. package/dist/api/schema/common.d.ts +6 -0
  28. package/dist/api/{conversations/schema.d.ts → schema/conversation.d.ts} +88 -9
  29. package/dist/api/{locations/schema.d.ts → schema/location.d.ts} +5 -0
  30. package/dist/api/{people/schema.d.ts → schema/person.d.ts} +37 -45
  31. package/dist/api/schema.d.ts +8 -22
  32. package/dist/api/schema.js +10 -2
  33. package/dist/api.d.ts +5 -1
  34. package/dist/api.js +838 -369
  35. package/dist/app.d.ts +1 -0
  36. package/dist/app.js +1564 -486
  37. package/dist/catalog-runtime-4GI22PXK.js +16 -0
  38. package/dist/chat/agent/resume.d.ts +11 -12
  39. package/dist/chat/conversations/history.d.ts +3 -0
  40. package/dist/chat/conversations/sql/privacy.d.ts +3 -15
  41. package/dist/chat/conversations/sql/store.d.ts +0 -7
  42. package/dist/chat/log-context.d.ts +40 -0
  43. package/dist/chat/logging.d.ts +3 -26
  44. package/dist/chat/pi/messages.d.ts +2 -2
  45. package/dist/chat/pi/sql-model-usage.d.ts +4 -1
  46. package/dist/chat/runtime/slack-resume.d.ts +2 -2
  47. package/dist/chat/services/auth-pause.d.ts +4 -0
  48. package/dist/chat/services/context-compaction.d.ts +1 -0
  49. package/dist/chat/services/turn-session-record.d.ts +0 -2
  50. package/dist/chat/slack/reply.d.ts +7 -19
  51. package/dist/chat/state/conversation.d.ts +1 -0
  52. package/dist/chat/task-execution/queue-signing.d.ts +10 -8
  53. package/dist/chat/task-execution/queue.d.ts +9 -7
  54. package/dist/chat/task-execution/slack-work.d.ts +6 -6
  55. package/dist/{chunk-UD6THJ2I.js → chunk-2T7TIEXI.js} +197 -12
  56. package/dist/{chunk-CEA3A3UA.js → chunk-2ZTTXTSZ.js} +24 -1
  57. package/dist/{chunk-XKB7LGIW.js → chunk-3S7YYHBI.js} +3 -139
  58. package/dist/chunk-3TV7OEHL.js +10 -0
  59. package/dist/{chunk-A5CO2EHL.js → chunk-3UBQI73J.js} +11 -15
  60. package/dist/{chunk-7FBGKXPE.js → chunk-42WRQLJ6.js} +10 -33
  61. package/dist/{chunk-TE4QHJH4.js → chunk-4QU44P7Q.js} +135 -595
  62. package/dist/{chunk-RT5BUHR5.js → chunk-6Y5L4BOM.js} +3 -5
  63. package/dist/{chunk-VIXFG2VC.js → chunk-C4MZ3GP5.js} +1 -2
  64. package/dist/{chunk-3RGQLX2F.js → chunk-C5XAFTHY.js} +1011 -29
  65. package/dist/{chunk-PUAMO4PI.js → chunk-FPK7XY3F.js} +139 -99
  66. package/dist/{chunk-H3QYZL7K.js → chunk-GK47NBDE.js} +28 -3
  67. package/dist/{chunk-O24R4DCK.js → chunk-IYKPU7H6.js} +94 -56
  68. package/dist/chunk-JQFJO5WH.js +477 -0
  69. package/dist/{chunk-VH6KWKG2.js → chunk-L5XQPJ7T.js} +3 -3
  70. package/dist/{chunk-2XXEKR44.js → chunk-MIAKQNYX.js} +43 -31
  71. package/dist/{chunk-KPMPQ6AA.js → chunk-RHHRKSPI.js} +249 -223
  72. package/dist/{chunk-YT72TOEK.js → chunk-SBOBTS27.js} +2 -2
  73. package/dist/{chunk-B5I5LMSP.js → chunk-W6RJZG7F.js} +5 -7
  74. package/dist/chunk-W75ZPAGG.js +44 -0
  75. package/dist/{chunk-SS67LUOK.js → chunk-WNOVRQ67.js} +6 -7
  76. package/dist/{chunk-YIPD3L6L.js → chunk-Y3H2DN6F.js} +8 -10
  77. package/dist/{chunk-DY7TRYB5.js → chunk-Y5FK3CNG.js} +1 -1
  78. package/dist/chunk-ZKIOWEFL.js +125 -0
  79. package/dist/cli/chat.js +23 -24
  80. package/dist/cli/check.js +9 -7
  81. package/dist/cli/plugins.js +16 -17
  82. package/dist/cli/snapshot-warmup.js +11 -10
  83. package/dist/cli/upgrade.js +314 -3505
  84. package/dist/db/db.d.ts +1 -1
  85. package/dist/db/schema/conversations.d.ts +17 -0
  86. package/dist/db/schema.d.ts +17 -0
  87. package/dist/{db-AMRBAT5D.js → db-Y6W6CWWW.js} +8 -7
  88. package/dist/instrumentation.js +4 -3
  89. package/dist/nitro.js +4 -4
  90. package/dist/reporting-schema.d.ts +46 -0
  91. package/dist/{runner-TQH5GAJ4.js → runner-BBFV5GLR.js} +17 -21
  92. package/dist/{skills-ITNHBARB.js → skills-AR4AF32L.js} +8 -6
  93. package/dist/{validation-AGQ46ZGV.js → validation-FBIEPTC2.js} +8 -6
  94. package/dist/version.d.ts +2 -0
  95. package/dist/version.js +7 -0
  96. package/migrations/0006_drop_legacy_conversation_messages.sql +1 -0
  97. package/migrations/0007_thick_sugar_man.sql +23 -0
  98. package/migrations/README.md +12 -9
  99. package/migrations/meta/0006_snapshot.json +948 -0
  100. package/migrations/meta/0007_snapshot.json +1013 -0
  101. package/migrations/meta/_journal.json +14 -0
  102. package/package.json +9 -5
  103. package/dist/catalog-runtime-FOFNPR3P.js +0 -14
  104. package/dist/chunk-AHJR2IFF.js +0 -115
  105. package/dist/chunk-B7PUBQQM.js +0 -53
  106. package/dist/chunk-G3E7SCME.js +0 -28
  107. package/dist/chunk-J3B3FPP2.js +0 -1061
  108. package/dist/chunk-OB42YVAE.js +0 -16
  109. package/dist/chunk-TWINAEZQ.js +0 -1283
@@ -0,0 +1,16 @@
1
+ import {
2
+ pluginCatalogRuntime
3
+ } from "./chunk-3TV7OEHL.js";
4
+ import "./chunk-Y3H2DN6F.js";
5
+ import "./chunk-C4MZ3GP5.js";
6
+ import "./chunk-IYKPU7H6.js";
7
+ import "./chunk-42WRQLJ6.js";
8
+ import "./chunk-6GWA276C.js";
9
+ import "./chunk-B3IT5END.js";
10
+ import "./chunk-3V7OFJZC.js";
11
+ import "./chunk-W75ZPAGG.js";
12
+ import "./chunk-ZKIOWEFL.js";
13
+ import "./chunk-MLKGABMK.js";
14
+ export {
15
+ pluginCatalogRuntime
16
+ };
@@ -15,6 +15,7 @@ import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
15
15
  import type { AgentTurnSurface } from "@/chat/state/turn-session";
16
16
  import type { Actor } from "@/chat/actor";
17
17
  import { loadTurnSessionRecord, persistRunningSessionRecord } from "@/chat/services/turn-session-record";
18
+ import { type AuthorizationPauseError } from "@/chat/services/auth-pause";
18
19
  import { type AgentTurnUsage } from "@/chat/usage";
19
20
  import { type AgentRunDurability } from "@/chat/agent/request";
20
21
  type LoadedSessionRecordState = Awaited<ReturnType<typeof loadTurnSessionRecord>>;
@@ -36,15 +37,14 @@ interface ResumeStateArgs {
36
37
  startedAtMs: number;
37
38
  surface: AgentTurnSurface;
38
39
  }
39
- interface ExpectedEndingTranslation {
40
- outcome?: AgentRunOutcome;
41
- }
40
+ type AuthPauseOutcome = Extract<AgentRunOutcome, {
41
+ status: "awaiting_auth";
42
+ }>;
42
43
  /** Create the run's resume state: checkpoints, snapshots, and ending translation. */
43
44
  export declare function createResumeState(args: ResumeStateArgs): {
44
45
  readonly inputCommitted: boolean;
45
46
  readonly beforeMessageCount: number;
46
47
  readonly timedOut: boolean;
47
- readonly cooperativeYieldError: CooperativeTurnYieldError | undefined;
48
48
  setTurnStartMessageIndex(index: number | undefined): void;
49
49
  setBeforeMessageCount(count: number): void;
50
50
  /** Adopt an already committed epoch replacement as every resume baseline. */
@@ -55,16 +55,15 @@ export declare function createResumeState(args: ResumeStateArgs): {
55
55
  commitInput(): Promise<void>;
56
56
  persistSafeBoundary(messages: PiMessage[], trailingMessageProvenance?: ConversationMessageProvenance[]): Promise<boolean>;
57
57
  requireDurableInputCheckpoint(messages: PiMessage[], trailingMessageProvenance?: ConversationMessageProvenance[]): Promise<boolean>;
58
- yieldAtSafeBoundaryIfDue(currentMessages: PiMessage[]): void;
59
- /**
60
- * Persist the continuation for an expected run ending and translate it
61
- * into an outcome; returns no outcome for genuine errors so the caller's
62
- * error guards run.
63
- */
64
- translateExpectedEnding(args2: {
58
+ /** Prepare a cooperative yield at the current durable boundary. */
59
+ prepareYieldIfDue(currentMessages: PiMessage[]): CooperativeTurnYieldError | undefined;
60
+ /** Persist an auth pause; only a durable pause may return `awaiting_auth`. */
61
+ parkForAuth(pause: AuthorizationPauseError, currentUsage?: AgentTurnUsage): Promise<AuthPauseOutcome>;
62
+ /** Persist a yield, retry, or timeout as a suspended run. */
63
+ translateSuspension(ending: {
65
64
  currentUsage?: AgentTurnUsage;
66
65
  error: unknown;
67
- }): Promise<ExpectedEndingTranslation>;
66
+ }): Promise<AgentRunOutcome | undefined>;
68
67
  };
69
68
  export type ResumeState = ReturnType<typeof createResumeState>;
70
69
  export {};
@@ -25,6 +25,7 @@ export declare const historyReplacementSchema: z.ZodObject<{
25
25
  type: z.ZodLiteral<"handoff">;
26
26
  modelProfile: z.ZodString;
27
27
  modelId: z.ZodString;
28
+ reasoningLevel: z.ZodOptional<z.ZodString>;
28
29
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
29
30
  replacementHistory: z.ZodArray<z.ZodObject<{
30
31
  message: z.ZodPipe<z.ZodObject<{
@@ -237,6 +238,7 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
237
238
  type: z.ZodLiteral<"handoff">;
238
239
  modelProfile: z.ZodString;
239
240
  modelId: z.ZodString;
241
+ reasoningLevel: z.ZodOptional<z.ZodString>;
240
242
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
241
243
  replacementHistory: z.ZodArray<z.ZodObject<{
242
244
  message: z.ZodPipe<z.ZodObject<{
@@ -479,6 +481,7 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
479
481
  type: z.ZodLiteral<"handoff">;
480
482
  modelProfile: z.ZodString;
481
483
  modelId: z.ZodString;
484
+ reasoningLevel: z.ZodOptional<z.ZodString>;
482
485
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
483
486
  replacementHistory: z.ZodArray<z.ZodObject<{
484
487
  message: z.ZodPipe<z.ZodObject<{
@@ -1,27 +1,15 @@
1
1
  import type { JuniorSqlDatabase } from "@/db/db";
2
- import { juniorConversationEvents } from "@/db/schema";
3
2
  import type { JuniorDestinationVisibility } from "@/db/schema/destinations";
4
3
  /** Root conversation identity and its normalized destination visibility. */
5
4
  export interface RootConversationVisibility {
6
5
  rootConversationId: string;
7
6
  visibility: JuniorDestinationVisibility | null;
8
7
  }
9
- type ConversationEventPrivacySnapshot = RootConversationVisibility & {
10
- events: Array<typeof juniorConversationEvents.$inferSelect>;
11
- };
12
- /**
13
- * Read selected event rows and their root privacy authority in one SQL snapshot.
14
- */
15
- export declare function readConversationEventPrivacySnapshot(executor: JuniorSqlDatabase, args: {
16
- conversationId: string;
17
- eventTypes: readonly string[];
18
- }): Promise<ConversationEventPrivacySnapshot | undefined>;
19
8
  /**
20
9
  * Resolve a conversation's privacy authority from its persisted root.
21
10
  *
22
- * Parent links are immutable after insertion. Missing, cyclic, or over-depth
23
- * lineage fails closed, while the root destination is locked so callers that
24
- * keep the transaction open receive a stable visibility decision.
11
+ * Missing or structurally invalid root metadata fails closed. The root
12
+ * destination is locked so callers that keep the transaction open receive a
13
+ * stable visibility decision.
25
14
  */
26
15
  export declare function resolveRootVisibility(executor: JuniorSqlDatabase, conversationId: string): Promise<RootConversationVisibility>;
27
- export {};
@@ -38,13 +38,6 @@ export declare class SqlStore implements ConversationStore {
38
38
  updatedAtMs: number;
39
39
  visibility?: ConversationPrivacy;
40
40
  }): Promise<void>;
41
- /** Copy one conversation record and retained metrics into SQL during backfill. */
42
- backfillConversation(sourceConversation: Conversation, metrics?: {
43
- durationMs: number;
44
- executionDurationMs: number;
45
- executionUsage?: AgentTurnUsage;
46
- usage?: AgentTurnUsage;
47
- }): Promise<void>;
48
41
  listByActivity(args?: {
49
42
  limit?: number;
50
43
  offset?: number;
@@ -0,0 +1,40 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ export type LogAttributeValue = string | number | boolean | string[];
3
+ export type LogAttributes = Record<string, LogAttributeValue>;
4
+ /** Provider-neutral correlation data inherited by logs and spans in an operation. */
5
+ export interface LogContext {
6
+ conversationId?: string;
7
+ platform?: string;
8
+ requestId?: string;
9
+ messageConversationId?: string;
10
+ destinationName?: string;
11
+ userId?: string;
12
+ userName?: string;
13
+ userEmail?: string;
14
+ runId?: string;
15
+ actorType?: string;
16
+ actorId?: string;
17
+ assistantUserName?: string;
18
+ modelId?: string;
19
+ skillName?: string;
20
+ httpMethod?: string;
21
+ httpPath?: string;
22
+ urlFull?: string;
23
+ userAgent?: string;
24
+ }
25
+ /** Async attribute domain consumed directly by LogTape. */
26
+ export declare const logContextStorage: AsyncLocalStorage<LogAttributes>;
27
+ /** Convert provider-neutral domain context to stable telemetry attributes. */
28
+ export declare function logContextToAttributes(context: LogContext): LogAttributes;
29
+ /** Run an operation with merged context, restoring its parent on completion. */
30
+ export declare function runWithLogContext<T>(context: LogContext, attributes: LogAttributes, callback: () => T): T;
31
+ /** Run an operation with raw attributes, restoring its parent on completion. */
32
+ export declare function runWithLogAttributes<T>(attributes: LogAttributes, callback: () => T): T;
33
+ /** Merge raw attributes into the current scoped operation. */
34
+ export declare function updateLogAttributes(attributes: LogAttributes): void;
35
+ /** Merge context and attributes into the current scoped operation. */
36
+ export declare function updateLogContext(context: LogContext, attributes: LogAttributes): void;
37
+ /** Read the typed context bound to the current operation. */
38
+ export declare function getBoundLogContext(): LogContext;
39
+ /** Read the attributes bound to the current operation. */
40
+ export declare function getBoundLogAttributes(): LogAttributes;
@@ -1,9 +1,8 @@
1
1
  import type { Logger as ChatSdkLogger } from "chat";
2
+ import { type LogAttributes, type LogContext } from "@/chat/log-context";
2
3
  import * as Sentry from "@/chat/sentry";
3
4
  import type { AgentTurnUsage } from "@/chat/usage";
4
- type Primitive = string | number | boolean;
5
- type AttributeValue = Primitive | string[];
6
- export type LogAttributes = Record<string, AttributeValue>;
5
+ export type { LogAttributes, LogContext } from "@/chat/log-context";
7
6
  export type LogLevel = "debug" | "info" | "warn" | "error";
8
7
  export interface EmittedLogRecord {
9
8
  attributes: LogAttributes;
@@ -11,26 +10,6 @@ export interface EmittedLogRecord {
11
10
  eventName: string;
12
11
  level: LogLevel;
13
12
  }
14
- export interface LogContext {
15
- conversationId?: string;
16
- platform?: string;
17
- requestId?: string;
18
- slackThreadId?: string;
19
- slackUserId?: string;
20
- slackUserName?: string;
21
- slackUserEmail?: string;
22
- slackChannelId?: string;
23
- runId?: string;
24
- actorType?: string;
25
- actorId?: string;
26
- assistantUserName?: string;
27
- modelId?: string;
28
- skillName?: string;
29
- httpMethod?: string;
30
- httpPath?: string;
31
- urlFull?: string;
32
- userAgent?: string;
33
- }
34
13
  export type TracePropagationHeaders = Partial<Record<"baggage" | "sentry-trace" | "traceparent", string>>;
35
14
  interface SentryUserIdentity {
36
15
  id: string | number;
@@ -51,7 +30,6 @@ export declare const log: {
51
30
  /** Create a Chat SDK logger that routes records through Junior's logging backend. */
52
31
  export declare function createChatSdkLogger(): ChatSdkLogger;
53
32
  export declare function withLogContext<T>(context: LogContext, callback: () => Promise<T>): Promise<T>;
54
- export declare function setLogContext(context: LogContext): void;
55
33
  export declare function getLogContextAttributes(): LogAttributes;
56
34
  /** Return inherited log context filtered to attributes valid for the span operation. */
57
35
  export declare function getLogContextAttributesForSpan(op: string): LogAttributes;
@@ -75,7 +53,7 @@ export declare function logWarn(eventName: string, context?: LogContext, attribu
75
53
  export declare function logError(eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): void;
76
54
  /** Log an error with exception capture; returns the Sentry event ID if available. */
77
55
  export declare function logException(error: unknown, eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string): string | undefined;
78
- /** Set log context and Sentry scope metadata for the current request. */
56
+ /** Add context to the current operation and Sentry scope. */
79
57
  export declare function setTags(context?: LogContext): void;
80
58
  /** Create a LogContext from an incoming HTTP request. */
81
59
  export declare function createRequestContext(request: Request, context?: Partial<LogContext>): LogContext;
@@ -107,4 +85,3 @@ export declare function serializeGenAiAttribute(value: unknown, maxChars?: numbe
107
85
  export declare function extractGenAiUsageSummary(...sources: unknown[]): AgentTurnUsage;
108
86
  /** Extract GenAI token and estimated USD cost attributes for tracing. */
109
87
  export declare function extractGenAiUsageAttributes(...sources: unknown[]): Partial<Record<"gen_ai.usage.input_tokens" | "gen_ai.usage.output_tokens" | "gen_ai.usage.cache_read.input_tokens" | "gen_ai.usage.cache_creation.input_tokens" | "gen_ai.usage.reasoning.output_tokens", number> & Partial<Record<"app.cost.input_usd" | "app.cost.output_usd" | "app.cost.cache_read_usd" | "app.cost.cache_write_usd" | "app.cost.total_usd", number>>>;
110
- export {};
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  /** Permissive schema for durable Pi SDK messages whose content shape may evolve. */
3
3
  export declare const piMessageSchema: z.ZodPipe<z.ZodObject<{
4
4
  role: z.ZodString;
5
- }, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").BashExecutionMessage | import("@earendil-works/pi-agent-core").CustomMessage<unknown> | import("@earendil-works/pi-agent-core").BranchSummaryMessage | import("@earendil-works/pi-agent-core").CompactionSummaryMessage, {
5
+ }, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").CustomMessage<unknown> | import("@earendil-works/pi-agent-core").BashExecutionMessage | import("@earendil-works/pi-agent-core").BranchSummaryMessage | import("@earendil-works/pi-agent-core").CompactionSummaryMessage, {
6
6
  [x: string]: unknown;
7
7
  role: string;
8
8
  }>>;
@@ -12,7 +12,7 @@ export type PiMessage = z.output<typeof piMessageSchema>;
12
12
  export declare const piContentMessageSchema: z.ZodPipe<z.ZodObject<{
13
13
  content: z.ZodArray<z.ZodUnknown>;
14
14
  role: z.ZodString;
15
- }, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").BashExecutionMessage | import("@earendil-works/pi-agent-core").CustomMessage<unknown> | import("@earendil-works/pi-agent-core").BranchSummaryMessage | import("@earendil-works/pi-agent-core").CompactionSummaryMessage, {
15
+ }, z.core.$loose>, z.ZodTransform<import("@earendil-works/pi-ai").AssistantMessage | import("@earendil-works/pi-ai").UserMessage | import("@earendil-works/pi-ai").ToolResultMessage<any> | import("@earendil-works/pi-agent-core").CustomMessage<unknown> | import("@earendil-works/pi-agent-core").BashExecutionMessage | import("@earendil-works/pi-agent-core").BranchSummaryMessage | import("@earendil-works/pi-agent-core").CompactionSummaryMessage, {
16
16
  [x: string]: unknown;
17
17
  content: unknown[];
18
18
  role: string;
@@ -4,7 +4,10 @@ import { type AgentTurnUsage } from "@/chat/usage";
4
4
  * Aggregate real assistant calls by provider/model in SQL. Replayed history is
5
5
  * not another call; its tokens appear in the next call's input usage.
6
6
  */
7
- export declare function readConversationModelUsageFromSql(executor: JuniorSqlDatabase, conversationId: string): Promise<Array<{
7
+ export declare function readConversationModelUsageFromSql(executor: JuniorSqlDatabase, options: {
8
+ conversationId: string;
9
+ includeDescendants?: boolean;
10
+ }): Promise<Array<{
8
11
  modelId: string;
9
12
  usage: AgentTurnUsage;
10
13
  }>>;
@@ -26,7 +26,7 @@ interface ResumeSlackTurnArgs {
26
26
  conversationId: string;
27
27
  sessionId: string;
28
28
  }) => Promise<void>;
29
- onSuccess?: (reply: AgentRunResult) => Promise<void>;
29
+ commitResult?: (result: AgentRunResult) => Promise<void>;
30
30
  onFailure?: (error: unknown) => Promise<void>;
31
31
  onAuthPause?: (pause: {
32
32
  providerDisplayName: string;
@@ -45,7 +45,7 @@ interface ResumePreparedTurn {
45
45
  inputMessageIds?: string[];
46
46
  initialStatus?: AssistantStatusSpec;
47
47
  replyContext: ResumeReplyContext;
48
- onSuccess?: (reply: AgentRunResult) => Promise<void>;
48
+ commitResult?: (result: AgentRunResult) => Promise<void>;
49
49
  onFailure?: (error: unknown) => Promise<void>;
50
50
  onAuthPause?: (pause: {
51
51
  providerDisplayName: string;
@@ -12,6 +12,10 @@ export declare class AuthorizationPauseError extends Error {
12
12
  readonly providerDisplayName: string;
13
13
  constructor(kind: AuthorizationPauseKind, provider: string, providerDisplayName: string, disposition: AuthorizationPauseDisposition);
14
14
  }
15
+ /** Error indicating an authorization pause could not be made durable. */
16
+ export declare class AuthPausePersistenceError extends Error {
17
+ constructor(conversationId: string, turnId: string, cause?: unknown);
18
+ }
15
19
  /** Error indicating this turn cannot start an external authorization flow. */
16
20
  export declare class AuthorizationFlowDisabledError extends Error {
17
21
  readonly kind: AuthorizationPauseKind;
@@ -38,6 +38,7 @@ interface HandoffContextArgs {
38
38
  target: {
39
39
  modelId: string;
40
40
  modelProfile: ModelProfile;
41
+ reasoningLevel?: string;
41
42
  };
42
43
  }
43
44
  /** Build retained user messages for a compacted Pi replacement history. */
@@ -64,7 +64,6 @@ export declare function persistCompletedSessionRecord(args: {
64
64
  sliceId?: number;
65
65
  allMessages: PiMessage[];
66
66
  loadedSkillNames?: string[];
67
- logContext: SessionRecordLogContext;
68
67
  modelId: string;
69
68
  actor?: Actor;
70
69
  reasoningLevel?: string;
@@ -79,7 +78,6 @@ export declare function completeDeliveredTurn(args: {
79
78
  destinationVisibility?: ConversationPrivacy;
80
79
  durationMs?: number;
81
80
  loadedSkillNames?: string[];
82
- logContext: SessionRecordLogContext;
83
81
  messages: PiMessage[];
84
82
  modelId: string;
85
83
  actor?: Actor;
@@ -1,24 +1,12 @@
1
- import { type SlackReplyFooter } from "@/chat/slack/footer";
2
- export type PlannedSlackReplyStage = "thread_reply" | "thread_reply_continuation";
3
- export interface PlannedSlackReplyPost {
4
- stage: PlannedSlackReplyStage;
5
- text: string;
6
- }
7
- /** Plan the Slack posts for one completed assistant message. */
8
- export declare function planSlackAssistantMessagePosts(text: string): PlannedSlackReplyPost[];
9
1
  /**
10
- * Deliver planned Slack reply posts over raw Slack Web API calls for resume and
11
- * callback handlers that do not have a Chat SDK thread object.
2
+ * Send one destination-visible Slack reply.
3
+ *
4
+ * Chunks oversized text, builds the conversation footer from
5
+ * `conversationId`, and posts through the shared Slack outbound boundary.
12
6
  */
13
- export declare function postSlackApiReplyPosts(args: {
14
- beforePost?: () => Promise<void>;
15
- footer?: SlackReplyFooter;
7
+ export declare function sendSlackReply(args: {
16
8
  channelId: string;
17
- onPostError?: (context: {
18
- error: unknown;
19
- messageTs?: string;
20
- stage: PlannedSlackReplyStage;
21
- }) => Promise<void> | void;
9
+ conversationId: string;
10
+ text: string;
22
11
  threadTs?: string;
23
- posts: PlannedSlackReplyPost[];
24
12
  }): Promise<string | undefined>;
@@ -7,6 +7,7 @@ export interface ConversationAuthor {
7
7
  }
8
8
  export interface ConversationMessageMeta {
9
9
  attachmentCount?: number;
10
+ eventType?: string;
10
11
  explicitMention?: boolean;
11
12
  imageAttachmentCount?: number;
12
13
  imageFileIds?: string[];
@@ -1,11 +1,13 @@
1
- import type { ConversationQueueMessage } from "./queue";
2
- declare const CONVERSATION_WORK_QUEUE_SIGNATURE_VERSION = "v1";
1
+ import { z } from "zod";
2
+ import { type ConversationQueueMessage } from "./queue";
3
3
  export declare const CONVERSATION_WORK_QUEUE_SIGNATURE_MAX_SKEW_MS: number;
4
- interface SignedConversationQueueMessage extends ConversationQueueMessage {
5
- signature: string;
6
- signatureVersion: typeof CONVERSATION_WORK_QUEUE_SIGNATURE_VERSION;
7
- signedAtMs: number;
8
- }
4
+ declare const signedConversationQueueMessageSchema: z.ZodObject<{
5
+ conversationId: z.ZodString;
6
+ signature: z.ZodString;
7
+ signatureVersion: z.ZodLiteral<"v2">;
8
+ signedAtMs: z.ZodNumber;
9
+ }, z.core.$strict>;
10
+ type SignedConversationQueueMessage = z.output<typeof signedConversationQueueMessageSchema>;
9
11
  export type ConversationQueueMessageVerificationResult = {
10
12
  message: ConversationQueueMessage;
11
13
  status: "verified";
@@ -18,7 +20,7 @@ export type ConversationQueueMessageVerificationResult = {
18
20
  };
19
21
  /** Sign a conversation queue payload before it crosses the public callback route. */
20
22
  export declare function signConversationQueueMessage(message: ConversationQueueMessage, nowMs?: number): SignedConversationQueueMessage;
21
- /** Explain whether a queue payload is verified, rejected, or temporarily unverifiable. */
23
+ /** Explain whether a queue payload is verified, rejected, or unavailable. */
22
24
  export declare function verifyConversationQueueMessage(value: unknown, nowMs?: number): ConversationQueueMessageVerificationResult;
23
25
  /** Verify a signed conversation queue payload from the Vercel Queue callback. */
24
26
  export declare function verifySignedConversationQueueMessage(value: unknown, nowMs?: number): ConversationQueueMessage | undefined;
@@ -1,9 +1,11 @@
1
- import type { Destination } from "@sentry/junior-plugin-api";
2
- export interface ConversationQueueMessage {
3
- conversationId: string;
4
- destination: Destination;
5
- }
6
- export type ConversationQueueMessageRejectReason = "destination_mismatch" | "expired" | "invalid_record" | "malformed" | "signature_mismatch";
1
+ import { z } from "zod";
2
+ /** Validate the conversation work hint sent through Vercel Queue. */
3
+ export declare const conversationQueueMessageSchema: z.ZodObject<{
4
+ conversationId: z.ZodString;
5
+ }, z.core.$strict>;
6
+ /** Conversation work hint accepted by the queue callback and worker. */
7
+ export type ConversationQueueMessage = z.output<typeof conversationQueueMessageSchema>;
8
+ export type ConversationQueueMessageRejectReason = "expired" | "invalid_record" | "malformed" | "signature_mismatch";
7
9
  export declare class ConversationQueueMessageRejectedError extends Error {
8
10
  conversationId?: string;
9
11
  reason: ConversationQueueMessageRejectReason;
@@ -11,7 +13,7 @@ export declare class ConversationQueueMessageRejectedError extends Error {
11
13
  conversationId?: string;
12
14
  });
13
15
  }
14
- /** Return whether a queue payload was permanently rejected at the message boundary. */
16
+ /** Return whether an error means the queue message was permanently rejected. */
15
17
  export declare function isConversationQueueMessageRejectedError(error: unknown): error is ConversationQueueMessageRejectedError;
16
18
  export interface ConversationQueueSendOptions {
17
19
  delayMs?: number;
@@ -22,8 +22,8 @@ declare const slackConversationMessageMetadataSchema: z.ZodUnion<readonly [z.Zod
22
22
  _type: z.ZodLiteral<"chat:Message">;
23
23
  attachments: z.ZodArray<z.ZodObject<{
24
24
  type: z.ZodEnum<{
25
- image: "image";
26
25
  file: "file";
26
+ image: "image";
27
27
  audio: "audio";
28
28
  video: "video";
29
29
  }>;
@@ -71,17 +71,17 @@ declare const slackConversationMessageMetadataSchema: z.ZodUnion<readonly [z.Zod
71
71
  adapterName: z.ZodLiteral<"slack">;
72
72
  channelId: z.ZodString;
73
73
  channelVisibility: z.ZodOptional<z.ZodEnum<{
74
- private: "private";
75
74
  unknown: "unknown";
76
75
  external: "external";
76
+ private: "private";
77
77
  workspace: "workspace";
78
78
  }>>;
79
79
  currentMessage: z.ZodOptional<z.ZodObject<{
80
80
  _type: z.ZodLiteral<"chat:Message">;
81
81
  attachments: z.ZodArray<z.ZodObject<{
82
82
  type: z.ZodEnum<{
83
- image: "image";
84
83
  file: "file";
84
+ image: "image";
85
85
  audio: "audio";
86
86
  video: "video";
87
87
  }>;
@@ -132,8 +132,8 @@ declare const slackConversationMessageMetadataSchema: z.ZodUnion<readonly [z.Zod
132
132
  _type: z.ZodLiteral<"chat:Message">;
133
133
  attachments: z.ZodArray<z.ZodObject<{
134
134
  type: z.ZodEnum<{
135
- image: "image";
136
135
  file: "file";
136
+ image: "image";
137
137
  audio: "audio";
138
138
  video: "video";
139
139
  }>;
@@ -181,17 +181,17 @@ declare const slackConversationMessageMetadataSchema: z.ZodUnion<readonly [z.Zod
181
181
  adapterName: z.ZodLiteral<"slack">;
182
182
  channelId: z.ZodString;
183
183
  channelVisibility: z.ZodOptional<z.ZodEnum<{
184
- private: "private";
185
184
  unknown: "unknown";
186
185
  external: "external";
186
+ private: "private";
187
187
  workspace: "workspace";
188
188
  }>>;
189
189
  currentMessage: z.ZodOptional<z.ZodObject<{
190
190
  _type: z.ZodLiteral<"chat:Message">;
191
191
  attachments: z.ZodArray<z.ZodObject<{
192
192
  type: z.ZodEnum<{
193
- image: "image";
194
193
  file: "file";
194
+ image: "image";
195
195
  audio: "audio";
196
196
  video: "video";
197
197
  }>;