@sentry/junior 0.74.1 → 0.76.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 (121) hide show
  1. package/README.md +1 -1
  2. package/bin/junior.mjs +4 -66
  3. package/dist/agent-hooks-ZOE7RIED.js +37 -0
  4. package/dist/api-reference.d.ts +3 -1
  5. package/dist/app.js +5516 -5422
  6. package/dist/build/copy-build-content.d.ts +1 -1
  7. package/dist/build/virtual-config.d.ts +2 -2
  8. package/dist/chat/agent-dispatch/context.d.ts +2 -3
  9. package/dist/chat/agent-dispatch/runner.d.ts +2 -0
  10. package/dist/chat/agent-dispatch/types.d.ts +2 -1
  11. package/dist/chat/config.d.ts +3 -0
  12. package/dist/chat/credentials/state-adapter-token-store.d.ts +2 -0
  13. package/dist/chat/credentials/subject.d.ts +3 -3
  14. package/dist/chat/credentials/user-token-store.d.ts +17 -12
  15. package/dist/chat/db.d.ts +8 -0
  16. package/dist/chat/mcp/auth-store.d.ts +2 -1
  17. package/dist/chat/mcp/oauth.d.ts +2 -1
  18. package/dist/chat/oauth-flow.d.ts +3 -1
  19. package/dist/chat/pi/client.d.ts +15 -7
  20. package/dist/chat/plugins/agent-hooks.d.ts +20 -13
  21. package/dist/chat/plugins/auth/oauth-request.d.ts +11 -7
  22. package/dist/chat/plugins/credential-hooks.d.ts +6 -6
  23. package/dist/chat/plugins/logging.d.ts +2 -2
  24. package/dist/chat/plugins/model.d.ts +9 -0
  25. package/dist/chat/plugins/package-discovery.d.ts +2 -1
  26. package/dist/chat/plugins/prompt.d.ts +5 -0
  27. package/dist/chat/plugins/registry.d.ts +4 -0
  28. package/dist/chat/plugins/state.d.ts +3 -5
  29. package/dist/chat/plugins/task-callback.d.ts +5 -0
  30. package/dist/chat/plugins/task-message.d.ts +23 -0
  31. package/dist/chat/plugins/task-queue.d.ts +5 -0
  32. package/dist/chat/plugins/task-runner.d.ts +12 -0
  33. package/dist/chat/plugins/task-signing.d.ts +31 -0
  34. package/dist/chat/plugins/types.d.ts +1 -0
  35. package/dist/chat/plugins/validation.d.ts +5 -0
  36. package/dist/chat/prompt.d.ts +15 -1
  37. package/dist/chat/requester.d.ts +6 -5
  38. package/dist/chat/respond-helpers.d.ts +2 -0
  39. package/dist/chat/respond.d.ts +13 -2
  40. package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
  41. package/dist/chat/runtime/reply-executor.d.ts +5 -1
  42. package/dist/chat/runtime/slack-resume.d.ts +10 -2
  43. package/dist/chat/runtime/slack-runtime.d.ts +6 -1
  44. package/dist/chat/sandbox/egress-credentials.d.ts +8 -8
  45. package/dist/chat/sandbox/sandbox.d.ts +2 -2
  46. package/dist/chat/sentry.d.ts +1 -0
  47. package/dist/chat/services/mcp-auth-orchestration.d.ts +2 -1
  48. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
  49. package/dist/chat/services/subscribed-decision.d.ts +2 -2
  50. package/dist/chat/services/turn-session-record.d.ts +11 -7
  51. package/dist/chat/sql/db.d.ts +3 -0
  52. package/dist/chat/sql/executor.d.ts +7 -0
  53. package/dist/chat/sql/neon.d.ts +2 -4
  54. package/dist/chat/sql/postgres.d.ts +6 -0
  55. package/dist/chat/state/turn-session.d.ts +8 -5
  56. package/dist/chat/task-execution/state.d.ts +7 -2
  57. package/dist/chat/task-execution/worker.d.ts +1 -1
  58. package/dist/chat/tools/agent-tools.d.ts +9 -2
  59. package/dist/chat/tools/slack/context.d.ts +2 -2
  60. package/dist/chat/tools/types.d.ts +7 -4
  61. package/dist/chat/vercel-queue-client.d.ts +3 -0
  62. package/dist/{chunk-YOHFWWBV.js → chunk-2ECJXSVQ.js} +5 -107
  63. package/dist/{chunk-OR6NQJ5E.js → chunk-4SCWV7TJ.js} +3 -3
  64. package/dist/chunk-4UO6FK4G.js +64 -0
  65. package/dist/chunk-56TBVRJG.js +115 -0
  66. package/dist/{chunk-3BYAPS6B.js → chunk-EJN6G5A2.js} +17 -11
  67. package/dist/{chunk-SQGMG7OD.js → chunk-HHDUKWVG.js} +508 -149
  68. package/dist/{chunk-6UP2Z2RZ.js → chunk-JBASI5VV.js} +7 -7
  69. package/dist/chunk-KNFROR7R.js +127 -0
  70. package/dist/{chunk-HYHKTFG2.js → chunk-KOIMO7S3.js} +186 -910
  71. package/dist/chunk-MLKGABMK.js +9 -0
  72. package/dist/chunk-NFTMTIP3.js +964 -0
  73. package/dist/chunk-NYKJ3KON.js +1082 -0
  74. package/dist/{chunk-SJHUF3DP.js → chunk-OJ53FYVG.js} +2 -10
  75. package/dist/{chunk-KVZL5NZS.js → chunk-Q3XNY442.js} +17 -7
  76. package/dist/{chunk-YRDS7VKO.js → chunk-Q6XFTRV5.js} +2 -2
  77. package/dist/chunk-R6Z5XWY3.js +1076 -0
  78. package/dist/chunk-RV5RYIJW.js +56 -0
  79. package/dist/chunk-SG5WAA7H.js +132 -0
  80. package/dist/chunk-ST6YNAXG.js +54 -0
  81. package/dist/{chunk-GM7HTXYC.js → chunk-T77LUIX3.js} +148 -151
  82. package/dist/{chunk-CYUI7JU5.js → chunk-VALUBQ7R.js} +22 -30
  83. package/dist/chunk-XBBC6W45.js +71 -0
  84. package/dist/chunk-Y2CM7HXH.js +111 -0
  85. package/dist/{chunk-F6HWCPOC.js → chunk-Y5OFBCBZ.js} +1 -1
  86. package/dist/{chunk-M4FLLXXD.js → chunk-Z4CIQ3EB.js} +5 -1
  87. package/dist/{chunk-7Q5YOUUT.js → chunk-ZLMBNBUG.js} +146 -52
  88. package/dist/{chunk-2LUZA3LY.js → chunk-ZQB37HUX.js} +11 -11
  89. package/dist/cli/chat.js +87 -8
  90. package/dist/cli/check.js +8 -7
  91. package/dist/cli/env.js +4 -53
  92. package/dist/cli/init.js +6 -1
  93. package/dist/cli/main.js +84 -0
  94. package/dist/cli/plugins.js +244 -0
  95. package/dist/cli/run.js +5 -52
  96. package/dist/cli/snapshot-warmup.js +12 -11
  97. package/dist/cli/upgrade.js +385 -26
  98. package/dist/db-7A7PFRGL.js +17 -0
  99. package/dist/deployment.d.ts +1 -0
  100. package/dist/handlers/sandbox-egress-route.d.ts +4 -0
  101. package/dist/handlers/slack-webhook.d.ts +4 -0
  102. package/dist/handlers/webhooks.d.ts +6 -13
  103. package/dist/instrumentation.js +14 -18
  104. package/dist/nitro.d.ts +1 -1
  105. package/dist/nitro.js +67 -101
  106. package/dist/plugin-module.d.ts +21 -0
  107. package/dist/plugins-PZMDS7AT.js +15 -0
  108. package/dist/plugins.d.ts +9 -5
  109. package/dist/registry-OIPAJU2O.js +46 -0
  110. package/dist/reporting/conversations.d.ts +3 -3
  111. package/dist/reporting.d.ts +6 -5
  112. package/dist/reporting.js +42 -28
  113. package/dist/{runner-27NP2TEO.js → runner-KPLNHDCV.js} +77 -19
  114. package/dist/sentry-4CP5NNQ5.js +31 -0
  115. package/dist/validation-SLA6IGF7.js +15 -0
  116. package/dist/vercel.js +1 -1
  117. package/package.json +14 -11
  118. package/dist/chat/conversations/configured.d.ts +0 -5
  119. package/dist/chat/conversations/state.d.ts +0 -4
  120. package/dist/chunk-2KG3PWR4.js +0 -17
  121. package/dist/chunk-JL2SLRAT.js +0 -1970
@@ -1,4 +1,4 @@
1
- /** Copy app directory and plugin manifests into the server output. */
1
+ /** Copy app and declared plugin package content into the server output. */
2
2
  export declare function copyAppAndPluginContent(cwd: string, serverRoot: string, packageNames?: unknown): void;
3
3
  /** Copy extra file patterns into server output for files the bundler cannot trace. */
4
4
  export declare function copyIncludedFiles(cwd: string, serverRoot: string, patterns?: unknown): void;
@@ -9,12 +9,12 @@ export interface RuntimePluginModule {
9
9
  export declare function renderVirtualConfig(options: {
10
10
  plugins?: PluginCatalogConfig;
11
11
  pluginModule?: RuntimePluginModule;
12
- pluginHookRegistrations?: string[];
12
+ pluginRuntimeRegistrations?: string[];
13
13
  }): string;
14
14
  /** Inject a virtual module so createApp() can read the plugin list at runtime. */
15
15
  export declare function injectVirtualConfig(nitro: Nitro, options?: {
16
16
  loadPluginSet?: () => Promise<JuniorPluginSet | undefined>;
17
17
  pluginModule?: RuntimePluginModule;
18
18
  plugins?: PluginCatalogConfig;
19
- pluginHookRegistrations?: string[];
19
+ pluginRuntimeRegistrations?: string[];
20
20
  }): void;
@@ -1,7 +1,6 @@
1
- import type { HeartbeatHookContext } from "@sentry/junior-plugin-api";
1
+ import type { HeartbeatHookContext, PluginRegistration } from "@sentry/junior-plugin-api";
2
2
  /** Build the plugin-scoped heartbeat context that gates durable dispatch access. */
3
3
  export declare function createHeartbeatContext(args: {
4
- legacyStatePrefixes?: string[];
5
4
  nowMs: number;
6
- plugin: string;
5
+ plugin: string | PluginRegistration;
7
6
  }): HeartbeatHookContext;
@@ -1,10 +1,12 @@
1
1
  import { generateAssistantReply as generateAssistantReplyImpl } from "@/chat/respond";
2
2
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress-tracing";
3
+ import { scheduleSessionCompletedPluginTasks } from "@/chat/plugins/task-runner";
3
4
  import { scheduleDispatchCallback } from "./signing";
4
5
  import type { DispatchCallback } from "./types";
5
6
  export interface AgentDispatchRunnerDeps {
6
7
  generateAssistantReply?: typeof generateAssistantReplyImpl;
7
8
  scheduleCallback?: typeof scheduleDispatchCallback;
9
+ scheduleSessionCompletedPluginTasks?: typeof scheduleSessionCompletedPluginTasks;
8
10
  tracePropagation?: SandboxEgressTracePropagationConfig;
9
11
  }
10
12
  /** Run one serverless slice for a core-owned agent dispatch. */
@@ -1,4 +1,4 @@
1
- import type { DispatchOptions, SlackDestination } from "@sentry/junior-plugin-api";
1
+ import type { DispatchOptions, Source, SlackDestination } from "@sentry/junior-plugin-api";
2
2
  import type { CredentialSubject, CredentialSystemActor } from "@/chat/credentials/context";
3
3
  export type DispatchStatus = "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
4
4
  export type SlackDispatchOptions = Omit<DispatchOptions, "destination"> & {
@@ -23,6 +23,7 @@ export interface DispatchRecord {
23
23
  metadata?: Record<string, string>;
24
24
  plugin: string;
25
25
  resultMessageTs?: string;
26
+ source: Source;
26
27
  status: DispatchStatus;
27
28
  updatedAtMs: number;
28
29
  version: number;
@@ -7,6 +7,7 @@ export type AdvisorThinkingLevel = (typeof ADVISOR_THINKING_LEVELS)[number];
7
7
  export declare const FUNCTION_TIMEOUT_BUFFER_SECONDS = 20;
8
8
  export interface BotConfig {
9
9
  advisor: AdvisorConfig;
10
+ embeddingModelId: string;
10
11
  fastModelId: string;
11
12
  loadingMessages: string[];
12
13
  modelId: string;
@@ -19,11 +20,13 @@ export interface AdvisorConfig {
19
20
  modelId: string;
20
21
  thinkingLevel: AdvisorThinkingLevel;
21
22
  }
23
+ export type SqlDriver = "neon" | "postgres";
22
24
  export interface ChatConfig {
23
25
  bot: BotConfig;
24
26
  functionMaxDurationSeconds: number;
25
27
  sql: {
26
28
  databaseUrl?: string;
29
+ driver: SqlDriver;
27
30
  };
28
31
  slack: {
29
32
  botToken?: string;
@@ -6,4 +6,6 @@ export declare class StateAdapterTokenStore implements UserTokenStore {
6
6
  get(userId: string, provider: string): Promise<StoredTokens | undefined>;
7
7
  set(userId: string, provider: string, tokens: StoredTokens): Promise<void>;
8
8
  delete(userId: string, provider: string): Promise<void>;
9
+ /** Wait for the per-slot refresh gate so rotated refresh tokens are used once. */
10
+ withRefresh<T>(userId: string, provider: string, callback: () => Promise<T>): Promise<T>;
9
11
  }
@@ -1,15 +1,15 @@
1
- import type { AgentPluginCredentialSubject } from "@sentry/junior-plugin-api";
1
+ import type { PluginCredentialSubject } from "@sentry/junior-plugin-api";
2
2
  import type { CredentialSubject } from "@/chat/credentials/context";
3
3
  /** Create a delegated user credential subject for a verified Slack DM turn. */
4
4
  export declare function createSlackDirectCredentialSubject(input: {
5
5
  channelId: string | undefined;
6
6
  teamId: string | undefined;
7
7
  userId: string | undefined;
8
- }): AgentPluginCredentialSubject | undefined;
8
+ }): PluginCredentialSubject | undefined;
9
9
  /** Bind a delegated user subject to the Slack DM destination being dispatched. */
10
10
  export declare function bindSlackDirectCredentialSubject(input: {
11
11
  channelId: string;
12
- subject: AgentPluginCredentialSubject;
12
+ subject: PluginCredentialSubject;
13
13
  teamId: string;
14
14
  }): CredentialSubject | undefined;
15
15
  /** Verify that a delegated subject was signed for the dispatch destination. */
@@ -1,17 +1,22 @@
1
- export interface StoredProviderAccount {
2
- id: string;
3
- label?: string;
4
- url?: string;
5
- }
6
- export interface StoredTokens {
7
- account?: StoredProviderAccount;
8
- accessToken: string;
9
- refreshToken: string;
10
- expiresAt?: number;
11
- scope?: string;
12
- }
1
+ import { type PluginProviderAccount, type PluginStoredTokens } from "@sentry/junior-plugin-api";
2
+ export declare const storedTokensSchema: import("zod").ZodObject<{
3
+ account: import("zod").ZodOptional<import("zod").ZodObject<{
4
+ id: import("zod").ZodString;
5
+ label: import("zod").ZodOptional<import("zod").ZodString>;
6
+ url: import("zod").ZodOptional<import("zod").ZodString>;
7
+ }, import("zod/v4/core").$strict>>;
8
+ accessToken: import("zod").ZodString;
9
+ expiresAt: import("zod").ZodOptional<import("zod").ZodNumber>;
10
+ refreshToken: import("zod").ZodString;
11
+ refreshTokenExpiresAt: import("zod").ZodOptional<import("zod").ZodNumber>;
12
+ scope: import("zod").ZodOptional<import("zod").ZodString>;
13
+ }, import("zod/v4/core").$strict>;
14
+ export type StoredProviderAccount = PluginProviderAccount;
15
+ export type StoredTokens = PluginStoredTokens;
13
16
  export interface UserTokenStore {
14
17
  get(userId: string, provider: string): Promise<StoredTokens | undefined>;
15
18
  set(userId: string, provider: string, tokens: StoredTokens): Promise<void>;
16
19
  delete(userId: string, provider: string): Promise<void>;
20
+ /** Run refresh-token rotation for one user/provider slot, or throw after a bounded wait. */
21
+ withRefresh<T>(userId: string, provider: string, callback: () => Promise<T>): Promise<T>;
17
22
  }
@@ -0,0 +1,8 @@
1
+ import type { ConversationStore } from "@/chat/conversations/store";
2
+ import type { JuniorDatabase } from "@/chat/sql/db";
3
+ /** Return the process Drizzle database. */
4
+ export declare function getDb(): JuniorDatabase;
5
+ /** Return the SQL-backed conversation store. */
6
+ export declare function getConversationStore(): ConversationStore;
7
+ /** Close the process SQL database when it has been opened. */
8
+ export declare function closeDb(): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import type { OAuthClientInformationMixed, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
2
2
  import type { OAuthDiscoveryState } from "@modelcontextprotocol/sdk/client/auth.js";
3
- import type { Destination } from "@sentry/junior-plugin-api";
3
+ import { type Destination, type Source } from "@sentry/junior-plugin-api";
4
4
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
5
5
  export interface McpAuthSessionState {
6
6
  authSessionId: string;
@@ -8,6 +8,7 @@ export interface McpAuthSessionState {
8
8
  userId: string;
9
9
  conversationId: string;
10
10
  destination?: Destination;
11
+ source?: Source;
11
12
  sessionId: string;
12
13
  userMessage: string;
13
14
  channelId?: string;
@@ -1,4 +1,4 @@
1
- import type { Destination } from "@sentry/junior-plugin-api";
1
+ import type { Destination, Source } from "@sentry/junior-plugin-api";
2
2
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
3
3
  import { type McpAuthSessionState } from "./auth-store";
4
4
  import { StateBackedMcpOAuthClientProvider } from "./oauth-provider";
@@ -7,6 +7,7 @@ export declare function createMcpOAuthClientProvider(input: {
7
7
  provider: string;
8
8
  conversationId: string;
9
9
  destination?: Destination;
10
+ source?: Source;
10
11
  sessionId: string;
11
12
  userId: string;
12
13
  userMessage: string;
@@ -1,4 +1,4 @@
1
- import type { Destination } from "@sentry/junior-plugin-api";
1
+ import { type Destination, type Source } from "@sentry/junior-plugin-api";
2
2
  import type { ChannelConfigurationService } from "@/chat/configuration/types";
3
3
  type PrivateDeliveryResult = "in_context" | "fallback_dm" | false;
4
4
  export type OAuthStatePayload = {
@@ -6,6 +6,7 @@ export type OAuthStatePayload = {
6
6
  provider: string;
7
7
  channelId?: string;
8
8
  destination?: Destination;
9
+ source?: Source;
9
10
  threadTs?: string;
10
11
  pendingMessage?: string;
11
12
  configuration?: Record<string, unknown>;
@@ -17,6 +18,7 @@ type OAuthFlowInput = {
17
18
  requesterId: string;
18
19
  channelId?: string;
19
20
  destination?: Destination;
21
+ source?: Source;
20
22
  threadTs?: string;
21
23
  userMessage?: string;
22
24
  channelConfiguration?: ChannelConfigurationService;
@@ -9,11 +9,8 @@ export declare const MISSING_GATEWAY_CREDENTIALS_ERROR = "Missing AI gateway cre
9
9
  * the bearer token string directly.
10
10
  */
11
11
  export declare function getGatewayApiKey(): string | undefined;
12
- /**
13
- * Let pi-ai read AI_GATEWAY_API_KEY from env itself and only override the
14
- * token when auth comes from VERCEL_OIDC_TOKEN.
15
- */
16
- export declare function getPiGatewayApiKeyOverride(): string | undefined;
12
+ /** Return the Gateway credential shape expected by Pi Agent getApiKey hooks. */
13
+ export declare function getPiGatewayApiKey(): string | undefined;
17
14
  /**
18
15
  * Look up a gateway model by id. Throws `Unknown AI Gateway model id: …` if
19
16
  * the id is not in pi-ai's registry — callers at the config boundary can use
@@ -35,7 +32,7 @@ export declare function completeText(params: {
35
32
  message: import("@earendil-works/pi-ai").AssistantMessage;
36
33
  text: string;
37
34
  }>;
38
- /** Execute a schema-constrained completion using the traced text path above. */
35
+ /** Execute a schema-constrained completion using the AI SDK structured output path. */
39
36
  export declare function completeObject<TSchema extends ZodTypeAny>(params: {
40
37
  modelId: string;
41
38
  schema: TSchema;
@@ -48,5 +45,16 @@ export declare function completeObject<TSchema extends ZodTypeAny>(params: {
48
45
  metadata?: Record<string, unknown>;
49
46
  }): Promise<{
50
47
  object: z.infer<TSchema>;
51
- text: string;
48
+ }>;
49
+ /** Generate text embeddings through the host-owned AI Gateway provider. */
50
+ export declare function embedTexts(params: {
51
+ modelId: string;
52
+ texts: string[];
53
+ signal?: AbortSignal;
54
+ metadata?: Record<string, unknown>;
55
+ }): Promise<{
56
+ dimensions: number;
57
+ model: string;
58
+ provider: string;
59
+ vectors: number[][];
52
60
  }>;
@@ -1,10 +1,11 @@
1
- import type { AgentPluginConversations, AgentPluginRoute, PluginOperationalReport, SlackConversationLink, JuniorPluginRegistration } from "@sentry/junior-plugin-api";
1
+ import type { PluginConversations, PluginRoute, PluginOperationalReport, SlackConversationLink, PluginRegistration } from "@sentry/junior-plugin-api";
2
+ import type { PluginPromptContributionContext } from "@/chat/plugins/prompt";
2
3
  import type { ToolDefinition } from "@/chat/tools/definition";
3
4
  import type { ToolRuntimeContext } from "@/chat/tools/types";
4
5
  import type { SandboxInstance } from "@/chat/sandbox/workspace";
5
6
  import type { Requester } from "@/chat/requester";
6
7
  /** Signal that a plugin intentionally denied a tool execution. */
7
- export declare class AgentPluginHookDeniedError extends Error {
8
+ export declare class PluginHookDeniedError extends Error {
8
9
  constructor(message: string);
9
10
  }
10
11
  export interface ToolHookInput {
@@ -15,28 +16,34 @@ export interface ToolHookResult {
15
16
  env: Record<string, string>;
16
17
  input: Record<string, unknown>;
17
18
  }
18
- export interface AgentPluginRouteRegistration extends AgentPluginRoute {
19
+ export interface PluginRouteRegistration extends PluginRoute {
19
20
  pluginName: string;
20
21
  }
21
- export interface AgentPluginHookRunner {
22
+ export interface PluginHookRunner {
22
23
  beforeToolExecute(input: ToolHookInput): Promise<ToolHookResult>;
23
24
  prepareSandbox(sandbox: SandboxInstance): Promise<void>;
24
25
  }
25
26
  /** Validate plugin identity before it can affect process-wide hooks. */
26
- export declare function validateAgentPlugins(plugins: JuniorPluginRegistration[]): void;
27
+ export declare function validatePlugins(plugins: PluginRegistration[]): void;
27
28
  /** Replace runtime hook plugins and return the previous list for rollback. */
28
- export declare function setAgentPlugins(plugins: JuniorPluginRegistration[]): JuniorPluginRegistration[];
29
+ export declare function setPlugins(nextPlugins: PluginRegistration[]): PluginRegistration[];
29
30
  /** Return the current runtime hook plugins without exposing mutable state. */
30
- export declare function getAgentPlugins(): JuniorPluginRegistration[];
31
+ export declare function getPlugins(): PluginRegistration[];
32
+ /** Collect stable plugin prompt contributions for the static system prompt. */
33
+ export declare function getPluginSystemPromptContributions(source: ToolRuntimeContext["source"]): Promise<PluginPromptContributionContext[]>;
34
+ /** Collect request-scoped plugin prompt contributions. */
35
+ export declare function getPluginUserPromptContributions(args: {
36
+ context: Pick<ToolRuntimeContext, "conversationId" | "destination" | "requester" | "source" | "userText">;
37
+ }): Promise<PluginPromptContributionContext[]>;
31
38
  /** Collect turn-scoped tools exposed by plugins. */
32
- export declare function getAgentPluginTools(context: ToolRuntimeContext): Record<string, ToolDefinition<any>>;
39
+ export declare function getPluginTools(context: ToolRuntimeContext): Record<string, ToolDefinition<any>>;
33
40
  /** Collect route handlers exposed by plugins for app-level mounting. */
34
- export declare function getAgentPluginRoutes(): AgentPluginRouteRegistration[];
41
+ export declare function getPluginRoutes(): PluginRouteRegistration[];
35
42
  /** Resolve the first plugin conversation URL for finalized Slack footers. */
36
- export declare function getAgentPluginSlackConversationLink(conversationId: string): SlackConversationLink | undefined;
43
+ export declare function getPluginSlackConversationLink(conversationId: string): SlackConversationLink | undefined;
37
44
  /** Collect read-only operational summaries exposed by plugins. */
38
- export declare function getAgentPluginOperationalReports(nowMs: number, conversations: AgentPluginConversations): Promise<PluginOperationalReport[]>;
45
+ export declare function getPluginOperationalReports(nowMs: number, conversations: PluginConversations): Promise<PluginOperationalReport[]>;
39
46
  /** Create one runner over runtime hook plugins registered by the app. */
40
- export declare function createAgentPluginHookRunner(input?: {
47
+ export declare function createPluginHookRunner(input?: {
41
48
  requester?: Requester;
42
- }): AgentPluginHookRunner;
49
+ }): PluginHookRunner;
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  type OAuthTokenRequestInput = {
2
3
  clientId: string;
3
4
  clientSecret: string;
@@ -5,16 +6,19 @@ type OAuthTokenRequestInput = {
5
6
  tokenAuthMethod?: "body" | "basic";
6
7
  tokenExtraHeaders?: Record<string, string>;
7
8
  };
9
+ declare const parsedOAuthTokenResponseSchema: z.ZodObject<{
10
+ accessToken: z.ZodString;
11
+ refreshToken: z.ZodString;
12
+ expiresAt: z.ZodOptional<z.ZodNumber>;
13
+ refreshTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
14
+ scope: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strict>;
16
+ export type OAuthTokenResponse = z.output<typeof parsedOAuthTokenResponseSchema>;
8
17
  export declare function buildOAuthTokenRequest(input: OAuthTokenRequestInput): {
9
18
  headers: Record<string, string>;
10
19
  body: BodyInit;
11
20
  };
12
- export declare function parseOAuthTokenResponse(data: Record<string, unknown>, requestedScope?: string, options?: {
21
+ export declare function parseOAuthTokenResponse(data: unknown, requestedScope?: string, options?: {
13
22
  treatEmptyScopeAsUnreported?: boolean;
14
- }): {
15
- accessToken: string;
16
- refreshToken: string;
17
- expiresAt?: number;
18
- scope?: string;
19
- };
23
+ }): OAuthTokenResponse;
20
24
  export {};
@@ -1,4 +1,4 @@
1
- import { type AgentPluginCredentialResult, type AgentPluginGrant, type AgentPluginProviderAccount } from "@sentry/junior-plugin-api";
1
+ import { type PluginCredentialResult, type PluginGrant, type PluginProviderAccount } from "@sentry/junior-plugin-api";
2
2
  import type { StoredTokens, UserTokenStore } from "@/chat/credentials/user-token-store";
3
3
  export interface EgressGrantInput {
4
4
  bodyText?: string;
@@ -7,9 +7,9 @@ export interface EgressGrantInput {
7
7
  upstreamUrl: URL;
8
8
  }
9
9
  /** Ask a plugin which grant an outbound request needs. */
10
- export declare function selectPluginGrant(input: EgressGrantInput): Promise<AgentPluginGrant | undefined>;
10
+ export declare function selectPluginGrant(input: EgressGrantInput): Promise<PluginGrant | undefined>;
11
11
  export interface EgressResponseInput {
12
- grant: AgentPluginGrant;
12
+ grant: PluginGrant;
13
13
  method: string;
14
14
  provider: string;
15
15
  response: {
@@ -40,7 +40,7 @@ export interface IssueCredentialInput {
40
40
  type: "user";
41
41
  userId: string;
42
42
  };
43
- grant: AgentPluginGrant;
43
+ grant: PluginGrant;
44
44
  provider: string;
45
45
  userTokenStore: UserTokenStore;
46
46
  }
@@ -48,6 +48,6 @@ export interface IssueCredentialInput {
48
48
  export declare function resolvePluginOAuthAccount(input: {
49
49
  provider: string;
50
50
  tokens: StoredTokens;
51
- }): Promise<AgentPluginProviderAccount | undefined>;
51
+ }): Promise<PluginProviderAccount | undefined>;
52
52
  /** Ask a plugin to issue headers or describe why the selected grant is unavailable. */
53
- export declare function issuePluginCredential(input: IssueCredentialInput): Promise<AgentPluginCredentialResult>;
53
+ export declare function issuePluginCredential(input: IssueCredentialInput): Promise<PluginCredentialResult>;
@@ -1,3 +1,3 @@
1
- import type { AgentPluginLogger } from "@sentry/junior-plugin-api";
1
+ import type { PluginLogger } from "@sentry/junior-plugin-api";
2
2
  /** Create the host logger exposed to plugin hooks. */
3
- export declare function createAgentPluginLogger(plugin: string): AgentPluginLogger;
3
+ export declare function createPluginLogger(plugin: string): PluginLogger;
@@ -0,0 +1,9 @@
1
+ import type { PluginEmbedder, PluginModel, PluginModelConfig } from "@sentry/junior-plugin-api";
2
+ /** Create the host-owned structured model capability exposed to plugins. */
3
+ export declare function createPluginModel(pluginName: string, options?: PluginModelConfig, runtime?: {
4
+ signal?: AbortSignal;
5
+ }): PluginModel;
6
+ /** Create the host-owned embedding capability exposed to prompt hooks. */
7
+ export declare function createPluginEmbedder(pluginName: string, runtime?: {
8
+ signal?: AbortSignal;
9
+ }): PluginEmbedder;
@@ -2,8 +2,9 @@ export interface InstalledPluginPackageContent {
2
2
  packageNames: string[];
3
3
  packages: {
4
4
  dir: string;
5
+ hasMigrationsDir: boolean;
5
6
  hasSkillsDir: boolean;
6
- name: string;
7
+ packageName: string;
7
8
  }[];
8
9
  manifestRoots: string[];
9
10
  skillRoots: string[];
@@ -0,0 +1,5 @@
1
+ export interface PluginPromptContributionContext {
2
+ id: string;
3
+ pluginName: string;
4
+ text: string;
5
+ }
@@ -10,6 +10,10 @@ export declare function getPluginPackageContent(): InstalledPluginPackageContent
10
10
  export declare function getPluginCatalogSignature(): string;
11
11
  export declare function getPluginCapabilityProviders(): CapabilityProviderDefinition[];
12
12
  export declare function getPluginProviders(): PluginDefinition[];
13
+ export declare function getPluginMigrationRoots(): {
14
+ dir: string;
15
+ pluginName: string;
16
+ }[];
13
17
  export declare function getPluginMcpProviders(): PluginDefinition[];
14
18
  export declare function getPluginRuntimeDependencies(): PluginRuntimeDependency[];
15
19
  export declare function getPluginRuntimePostinstall(): PluginRuntimePostinstallCommand[];
@@ -1,6 +1,4 @@
1
- import type { AgentPluginState } from "@sentry/junior-plugin-api";
2
- export interface PluginStateOptions {
3
- legacyStatePrefixes?: string[];
4
- }
1
+ import type { PluginState } from "@sentry/junior-plugin-api";
2
+ import type { StateAdapter } from "chat";
5
3
  /** Create a durable state namespace scoped to one plugin. */
6
- export declare function createPluginState(plugin: string, options?: PluginStateOptions): AgentPluginState;
4
+ export declare function createPluginState(plugin: string, adapter?: StateAdapter): PluginState;
@@ -0,0 +1,5 @@
1
+ export declare const PLUGIN_TASK_DEV_CONSUMER_GROUP = "junior_plugin_tasks_dev";
2
+ /** Create the Vercel Queue push callback for plugin background tasks. */
3
+ export declare function createVercelPluginTaskCallback(): (request: Request) => Promise<Response>;
4
+ /** Register the Vercel Queue local-dev consumer for plugin background tasks. */
5
+ export declare function registerVercelPluginTaskDevConsumer(): (() => void) | undefined;
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ export declare const pluginTaskParamsSchema: z.ZodObject<{
3
+ conversationId: z.ZodString;
4
+ sessionId: z.ZodString;
5
+ }, z.core.$strict>;
6
+ export type PluginTaskParams = z.output<typeof pluginTaskParamsSchema>;
7
+ export declare const pluginTaskQueueMessageSchema: z.ZodObject<{
8
+ name: z.ZodString;
9
+ params: z.ZodObject<{
10
+ conversationId: z.ZodString;
11
+ sessionId: z.ZodString;
12
+ }, z.core.$strict>;
13
+ plugin: z.ZodString;
14
+ }, z.core.$strict>;
15
+ export type PluginTaskQueueMessage = z.output<typeof pluginTaskQueueMessageSchema>;
16
+ /** Build the stable task id used for queue idempotency and tracing. */
17
+ export declare function pluginTaskId(args: {
18
+ name: string;
19
+ params: PluginTaskParams;
20
+ plugin: string;
21
+ }): string;
22
+ /** Parse the bounded queue payload accepted by the plugin task callback. */
23
+ export declare function parsePluginTaskQueueMessage(value: unknown): PluginTaskQueueMessage | undefined;
@@ -0,0 +1,5 @@
1
+ import { type PluginTaskQueueMessage } from "./task-message";
2
+ export declare const PLUGIN_TASK_QUEUE_TOPIC = "junior_plugin_tasks";
3
+ export declare const PLUGIN_TASK_QUEUE_RETENTION_SECONDS: number;
4
+ /** Send one plugin task wakeup through Vercel Queues. */
5
+ export declare function sendVercelPluginTask(message: PluginTaskQueueMessage): Promise<void>;
@@ -0,0 +1,12 @@
1
+ import { type PluginTaskParams, type PluginTaskQueueMessage } from "./task-message";
2
+ export interface ScheduleSessionCompletedPluginTasksOptions {
3
+ send?: (message: PluginTaskQueueMessage) => Promise<void>;
4
+ }
5
+ interface ProcessPluginTaskOptions {
6
+ signal?: AbortSignal;
7
+ }
8
+ /** Schedule all plugin tasks interested in a completed agent-run session. */
9
+ export declare function scheduleSessionCompletedPluginTasks(params: PluginTaskParams, options?: ScheduleSessionCompletedPluginTasksOptions): Promise<void>;
10
+ /** Execute one parsed plugin task request. */
11
+ export declare function processPluginTask(message: PluginTaskQueueMessage, options?: ProcessPluginTaskOptions): Promise<void>;
12
+ export {};
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { type PluginTaskQueueMessage } from "./task-message";
3
+ export declare const PLUGIN_TASK_QUEUE_SIGNATURE_MAX_SKEW_MS: number;
4
+ export type PluginTaskQueueRejectReason = "expired" | "malformed" | "signature_mismatch";
5
+ type VerificationResult = {
6
+ message: PluginTaskQueueMessage;
7
+ status: "verified";
8
+ } | {
9
+ reason: PluginTaskQueueRejectReason;
10
+ status: "rejected";
11
+ } | {
12
+ reason: "invalid_clock" | "missing_secret";
13
+ status: "unavailable";
14
+ };
15
+ declare const signedPluginTaskQueueMessageSchema: z.ZodObject<{
16
+ name: z.ZodString;
17
+ params: z.ZodObject<{
18
+ conversationId: z.ZodString;
19
+ sessionId: z.ZodString;
20
+ }, z.core.$strict>;
21
+ plugin: z.ZodString;
22
+ signature: z.ZodString;
23
+ signatureVersion: z.ZodLiteral<"v1">;
24
+ signedAtMs: z.ZodNumber;
25
+ }, z.core.$strict>;
26
+ type SignedPluginTaskQueueMessage = z.output<typeof signedPluginTaskQueueMessageSchema>;
27
+ /** Sign a plugin task payload before it crosses the public queue callback. */
28
+ export declare function signPluginTaskQueueMessage(message: PluginTaskQueueMessage, nowMs?: number): SignedPluginTaskQueueMessage;
29
+ /** Verify a plugin task payload from the public queue callback route. */
30
+ export declare function verifyPluginTaskQueueMessage(value: unknown, nowMs?: number): VerificationResult;
31
+ export {};
@@ -143,6 +143,7 @@ export interface PluginBrokerDeps {
143
143
  export interface PluginDefinition {
144
144
  manifest: PluginManifest;
145
145
  dir: string;
146
+ migrationsDir?: string;
146
147
  skillsDir?: string;
147
148
  }
148
149
  export interface InlinePluginManifestDefinition {
@@ -0,0 +1,5 @@
1
+ import type { PluginRegistration } from "@sentry/junior-plugin-api";
2
+ /** Validate hook registrations against the loaded plugin manifest catalog. */
3
+ export declare function validatePluginRegistrations(registrations: PluginRegistration[]): void;
4
+ /** Validate credential hook registrations against the loaded plugin manifests. */
5
+ export declare function validatePluginEgressCredentialHooks(registrations: PluginRegistration[]): void;
@@ -2,7 +2,8 @@ import type { SlackConversationContext } from "@/chat/slack/conversation-context
2
2
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
3
3
  import type { SkillMetadata, SkillInvocation } from "@/chat/skills";
4
4
  import type { ActiveMcpCatalogSummary } from "@/chat/tools/skill/mcp-tool-summary";
5
- import type { Source } from "@sentry/junior-plugin-api";
5
+ import type { PluginPromptContributionContext } from "@/chat/plugins/prompt";
6
+ import type { Destination, Source } from "@sentry/junior-plugin-api";
6
7
  export declare const JUNIOR_PERSONALITY: string;
7
8
  export declare const JUNIOR_WORLD: string | null;
8
9
  interface ToolPromptContext {
@@ -10,15 +11,28 @@ interface ToolPromptContext {
10
11
  promptGuidelines?: string[];
11
12
  promptSnippet?: string;
12
13
  }
14
+ /** Render plugin system prompt additions under a core-owned wrapper. */
15
+ export declare function buildPluginSystemPromptContributions(contributions: PluginPromptContributionContext[]): string | null;
13
16
  type TurnContextPromptInput = {
14
17
  availableSkills: SkillMetadata[];
15
18
  activeMcpCatalogs?: ActiveMcpCatalogSummary[];
16
19
  includeSessionContext?: boolean;
20
+ pluginPromptContributions?: PluginPromptContributionContext[];
17
21
  toolGuidance?: ToolPromptContext[];
18
22
  runtime?: {
19
23
  conversationId?: string;
20
24
  slackConversation?: SlackConversationContext;
21
25
  };
26
+ dispatch?: {
27
+ actor?: {
28
+ id: string;
29
+ type: string;
30
+ };
31
+ destination: Destination;
32
+ metadata?: Record<string, string>;
33
+ plugin?: string;
34
+ source: Source;
35
+ };
22
36
  invocation: SkillInvocation | null;
23
37
  requester?: {
24
38
  userName?: string;
@@ -2,8 +2,7 @@
2
2
  * Canonical requester identity.
3
3
  *
4
4
  * Runtime requesters are platform-scoped actors. Stored Slack requester parsing
5
- * remains explicit so legacy durable records can resume without repairing
6
- * malformed team or user ids.
5
+ * remains explicit so durable conversation metadata is not repaired on read.
7
6
  */
8
7
  import { z } from "zod";
9
8
  export declare const storedSlackRequesterSchema: z.ZodObject<{
@@ -34,6 +33,8 @@ export interface SlackRequesterProfile {
34
33
  userName?: string;
35
34
  }
36
35
  export type StoredSlackRequester = z.output<typeof storedSlackRequesterSchema>;
36
+ /** Parse a serialized runtime requester that crossed a durable boundary. */
37
+ export declare function parseRequester(value: unknown): Requester | undefined;
37
38
  interface RequesterInput {
38
39
  email?: string;
39
40
  fullName?: string;
@@ -58,9 +59,9 @@ export declare function createSlackRequester(teamId: string, userId: string, pro
58
59
  export declare function parseStoredSlackRequester(value: unknown): StoredSlackRequester | undefined;
59
60
  /** Convert a runtime Slack requester into its durable session shape. */
60
61
  export declare function toStoredSlackRequester(requester: SlackRequester): StoredSlackRequester;
61
- /** Rebuild a runtime requester from durable Slack requester state. */
62
- export declare function createRequesterFromStoredSlackRequester(args: {
63
- requester?: StoredSlackRequester;
62
+ /** Resolve a Slack resume requester from stored runtime identity and the active actor. */
63
+ export declare function createSlackResumeRequester(args: {
64
+ requester?: Requester;
64
65
  teamId: string;
65
66
  userId: string;
66
67
  }): SlackRequester;
@@ -59,6 +59,8 @@ export declare function isToolResultMessage(value: unknown): value is ToolResult
59
59
  export declare function normalizeToolNameFromResult(result: unknown): string | undefined;
60
60
  /** Check whether a tool result carries an error flag. */
61
61
  export declare function isToolResultError(result: unknown): boolean;
62
+ /** Extract tool names that completed successfully from raw Pi messages. */
63
+ export declare function getSuccessfulToolCalls(messages: readonly unknown[]): string[];
62
64
  /** Type guard for Pi SDK assistant messages. */
63
65
  export declare function isAssistantMessage(value: unknown): value is AssistantMessage;
64
66
  /** Extract role string from a raw Pi message. */