@sentry/junior-plugin-api 0.94.0 → 0.96.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.
package/dist/index.js CHANGED
@@ -261,7 +261,7 @@ function parsePluginToolInput(schema, args) {
261
261
  }
262
262
  return result.data;
263
263
  }
264
- function definePluginTool(definition) {
264
+ function createZodTool(definition, helperName) {
265
265
  const { inputSchema, outputSchema, prepareArguments, execute, ...tool } = definition;
266
266
  let modelInputSchema;
267
267
  let modelOutputSchema;
@@ -269,7 +269,7 @@ function definePluginTool(definition) {
269
269
  modelInputSchema = z5.toJSONSchema(inputSchema);
270
270
  } catch (error) {
271
271
  throw new TypeError(
272
- "definePluginTool() inputSchema must be representable as JSON Schema.",
272
+ `${helperName}() inputSchema must be representable as JSON Schema.`,
273
273
  { cause: error }
274
274
  );
275
275
  }
@@ -277,7 +277,7 @@ function definePluginTool(definition) {
277
277
  modelOutputSchema = z5.toJSONSchema(outputSchema);
278
278
  } catch (error) {
279
279
  throw new TypeError(
280
- "definePluginTool() outputSchema must be representable as JSON Schema.",
280
+ `${helperName}() outputSchema must be representable as JSON Schema.`,
281
281
  { cause: error }
282
282
  );
283
283
  }
@@ -302,6 +302,12 @@ function definePluginTool(definition) {
302
302
  } : {}
303
303
  };
304
304
  }
305
+ function zodTool(definition) {
306
+ return createZodTool(definition, "zodTool");
307
+ }
308
+ function definePluginTool(definition) {
309
+ return createZodTool(definition, "definePluginTool");
310
+ }
305
311
 
306
312
  // src/operations.ts
307
313
  import { z as z6 } from "zod";
@@ -471,5 +477,6 @@ export {
471
477
  sourceSchema,
472
478
  sourceTypeSchema,
473
479
  subscribableResourceSchema,
474
- systemActorSchema
480
+ systemActorSchema,
481
+ zodTool
475
482
  };
package/dist/tools.d.ts CHANGED
@@ -113,6 +113,11 @@ export interface PluginToolDefinition<TInput = unknown, TOutput = unknown> {
113
113
  executionMode?: unknown;
114
114
  inputSchema: unknown;
115
115
  outputSchema?: unknown;
116
+ /**
117
+ * Select result fields that are safe to retain in private traces.
118
+ * Returning `undefined` suppresses private result capture.
119
+ */
120
+ privateTraceResult?(result: TOutput): unknown;
116
121
  prepareArguments?: (args: unknown) => unknown;
117
122
  /**
118
123
  * @deprecated Put tool-selection and usage guidance directly in `description`
@@ -134,9 +139,9 @@ type ZodPluginToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema exte
134
139
  prepareArguments?: (args: unknown) => z.input<TInputSchema>;
135
140
  execute?: (input: z.output<TInputSchema>, options: PluginToolExecuteOptions) => Promise<z.input<TOutputSchema>> | z.input<TOutputSchema>;
136
141
  };
137
- /**
138
- * Define a plugin tool with Zod input parsing and the structured result contract.
139
- */
142
+ /** Define a plugin tool with Zod input parsing and validated structured results. */
143
+ export declare function zodTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodType<PluginToolResult>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>>;
144
+ /** Define a plugin tool with Zod input parsing and the structured result contract. */
140
145
  export declare function definePluginTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodType<PluginToolResult>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>>;
141
146
  export interface SlackToolRegistrationHookContext {
142
147
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.94.0",
3
+ "version": "0.96.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/tools.ts CHANGED
@@ -134,6 +134,11 @@ export interface PluginToolDefinition<TInput = unknown, TOutput = unknown> {
134
134
  executionMode?: unknown;
135
135
  inputSchema: unknown;
136
136
  outputSchema?: unknown;
137
+ /**
138
+ * Select result fields that are safe to retain in private traces.
139
+ * Returning `undefined` suppresses private result capture.
140
+ */
141
+ privateTraceResult?(result: TOutput): unknown;
137
142
  prepareArguments?: (args: unknown) => unknown;
138
143
  /**
139
144
  * @deprecated Put tool-selection and usage guidance directly in `description`
@@ -191,14 +196,12 @@ function parsePluginToolInput<TInputSchema extends ZodTypeAny>(
191
196
  return result.data;
192
197
  }
193
198
 
194
- /**
195
- * Define a plugin tool with Zod input parsing and the structured result contract.
196
- */
197
- export function definePluginTool<
199
+ function createZodTool<
198
200
  TInputSchema extends ZodTypeAny,
199
201
  TOutputSchema extends ZodType<PluginToolResult>,
200
202
  >(
201
203
  definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema>,
204
+ helperName: "definePluginTool" | "zodTool",
202
205
  ): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>> {
203
206
  const { inputSchema, outputSchema, prepareArguments, execute, ...tool } =
204
207
  definition;
@@ -208,7 +211,7 @@ export function definePluginTool<
208
211
  modelInputSchema = z.toJSONSchema(inputSchema);
209
212
  } catch (error) {
210
213
  throw new TypeError(
211
- "definePluginTool() inputSchema must be representable as JSON Schema.",
214
+ `${helperName}() inputSchema must be representable as JSON Schema.`,
212
215
  { cause: error },
213
216
  );
214
217
  }
@@ -216,7 +219,7 @@ export function definePluginTool<
216
219
  modelOutputSchema = z.toJSONSchema(outputSchema);
217
220
  } catch (error) {
218
221
  throw new TypeError(
219
- "definePluginTool() outputSchema must be representable as JSON Schema.",
222
+ `${helperName}() outputSchema must be representable as JSON Schema.`,
220
223
  { cause: error },
221
224
  );
222
225
  }
@@ -244,6 +247,26 @@ export function definePluginTool<
244
247
  };
245
248
  }
246
249
 
250
+ /** Define a plugin tool with Zod input parsing and validated structured results. */
251
+ export function zodTool<
252
+ TInputSchema extends ZodTypeAny,
253
+ TOutputSchema extends ZodType<PluginToolResult>,
254
+ >(
255
+ definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema>,
256
+ ): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>> {
257
+ return createZodTool(definition, "zodTool");
258
+ }
259
+
260
+ /** Define a plugin tool with Zod input parsing and the structured result contract. */
261
+ export function definePluginTool<
262
+ TInputSchema extends ZodTypeAny,
263
+ TOutputSchema extends ZodType<PluginToolResult>,
264
+ >(
265
+ definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema>,
266
+ ): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>> {
267
+ return createZodTool(definition, "definePluginTool");
268
+ }
269
+
247
270
  export interface SlackToolRegistrationHookContext {
248
271
  /**
249
272
  * Capabilities of the source Slack conversation exposed to this plugin.