@sentry/junior-plugin-api 0.75.0 → 0.76.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tasks.ts ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Public plugin background-task contracts.
3
+ *
4
+ * Plugins register small task handlers, while Junior core owns durable
5
+ * scheduling, queue delivery, retries, and the bounded run projection.
6
+ */
7
+ import { z } from "zod";
8
+ import type { PluginContext, PluginEmbedder, PluginModel } from "./context";
9
+ import { destinationSchema, requesterSchema, sourceSchema } from "./schemas";
10
+ import type { PluginState } from "./state";
11
+
12
+ /** One normalized transcript entry from the completed run exposed to plugin tasks. */
13
+ export const pluginRunTranscriptEntrySchema = z.discriminatedUnion("type", [
14
+ z
15
+ .object({
16
+ type: z.literal("message"),
17
+ role: z.enum(["user", "assistant"]),
18
+ text: z.string().min(1),
19
+ })
20
+ .strict(),
21
+ z
22
+ .object({
23
+ type: z.literal("toolResult"),
24
+ toolName: z.string().min(1),
25
+ isError: z.boolean(),
26
+ text: z.string().min(1).optional(),
27
+ })
28
+ .strict(),
29
+ ]);
30
+
31
+ /** Runtime-owned completed-run projection exposed to plugin tasks. */
32
+ export const pluginRunContextSchema = z
33
+ .object({
34
+ completedAtMs: z.number().finite(),
35
+ conversationId: z.string().min(1),
36
+ destination: destinationSchema,
37
+ requester: requesterSchema.optional(),
38
+ runId: z.string().min(1),
39
+ source: sourceSchema,
40
+ transcript: z.array(pluginRunTranscriptEntrySchema),
41
+ })
42
+ .strict();
43
+
44
+ export type PluginRunTranscriptEntry = z.output<
45
+ typeof pluginRunTranscriptEntrySchema
46
+ >;
47
+
48
+ export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
49
+
50
+ /** Runtime context passed to a plugin-owned background task. */
51
+ export interface PluginTaskContext extends PluginContext {
52
+ embedder: PluginEmbedder;
53
+ id: string;
54
+ model: PluginModel;
55
+ name: string;
56
+ run: {
57
+ load(): Promise<PluginRunContext>;
58
+ };
59
+ state: PluginState;
60
+ }
61
+
62
+ /** Plugin task handler registered by name in a plugin manifest module. */
63
+ export interface PluginTaskDefinition {
64
+ run(ctx: PluginTaskContext): Promise<void> | void;
65
+ }
66
+
67
+ /** Task handlers keyed by the plugin-owned task name. */
68
+ export type PluginTasks = Record<string, PluginTaskDefinition>;
package/src/tools.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type {
2
2
  PluginContext,
3
3
  LocalInvocationContext,
4
+ PluginEmbedder,
5
+ PluginModel,
4
6
  Requester,
5
7
  SlackInvocationContext,
6
8
  } from "./context";
@@ -62,10 +64,20 @@ export interface BeforeToolExecuteHookContext extends PluginContext {
62
64
  };
63
65
  }
64
66
 
67
+ export interface PluginToolExecuteOptions {
68
+ /**
69
+ * @deprecated Internal compatibility escape hatch for legacy tool bridges.
70
+ * Plugin tools should use typed input fields and runtime hook context instead.
71
+ */
72
+ experimental_context?: unknown;
73
+ /** Stable runtime tool-call id; durable create tools should derive idempotency keys from it. */
74
+ toolCallId?: string;
75
+ }
76
+
65
77
  export type PluginToolExecute<TInput = unknown> = {
66
78
  bivarianceHack(
67
79
  input: TInput,
68
- options: { experimental_context?: unknown },
80
+ options: PluginToolExecuteOptions,
69
81
  ): Promise<unknown> | unknown;
70
82
  }["bivarianceHack"];
71
83
 
@@ -111,6 +123,8 @@ interface BaseToolRegistrationHookContext extends PluginContext {
111
123
  * Do not parse as Slack unless the value starts with `slack:`.
112
124
  */
113
125
  conversationId?: string;
126
+ embedder: PluginEmbedder;
127
+ model: PluginModel;
114
128
  state: PluginState;
115
129
  userText?: string;
116
130
  }
@@ -1,13 +0,0 @@
1
- import type { PgDatabase } from "drizzle-orm/pg-core";
2
- import type { PgQueryResultHKT } from "drizzle-orm/pg-core/session";
3
- export type PluginDrizzleDatabase = PgDatabase<PgQueryResultHKT, Record<string, never>>;
4
- export interface PluginDb {
5
- delete: PluginDrizzleDatabase["delete"];
6
- execute(statement: string, params?: readonly unknown[]): Promise<void>;
7
- insert: PluginDrizzleDatabase["insert"];
8
- query<T = unknown>(statement: string, params?: readonly unknown[]): Promise<T[]>;
9
- select: PluginDrizzleDatabase["select"];
10
- transaction<T>(callback: (tx: PluginDb) => Promise<T>): Promise<T>;
11
- update: PluginDrizzleDatabase["update"];
12
- }
13
- export type PluginDatabaseConfig = Record<string, never>;
package/src/database.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { PgDatabase } from "drizzle-orm/pg-core";
2
- import type { PgQueryResultHKT } from "drizzle-orm/pg-core/session";
3
-
4
- export type PluginDrizzleDatabase = PgDatabase<
5
- PgQueryResultHKT,
6
- Record<string, never>
7
- >;
8
-
9
- export interface PluginDb {
10
- delete: PluginDrizzleDatabase["delete"];
11
- execute(statement: string, params?: readonly unknown[]): Promise<void>;
12
- insert: PluginDrizzleDatabase["insert"];
13
- query<T = unknown>(
14
- statement: string,
15
- params?: readonly unknown[],
16
- ): Promise<T[]>;
17
- select: PluginDrizzleDatabase["select"];
18
- transaction<T>(callback: (tx: PluginDb) => Promise<T>): Promise<T>;
19
- update: PluginDrizzleDatabase["update"];
20
- }
21
-
22
- export type PluginDatabaseConfig = Record<string, never>;