@sentry/junior-plugin-api 0.93.0 → 0.95.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/credentials.d.ts +1 -0
- package/dist/index.js +12 -4
- package/dist/tools.d.ts +8 -3
- package/package.json +1 -1
- package/src/credentials.ts +1 -0
- package/src/tools.ts +29 -6
package/dist/credentials.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const pluginStoredTokensSchema: z.ZodObject<{
|
|
|
30
30
|
/** Runtime schema for a plugin-defined outbound credential grant. */
|
|
31
31
|
export declare const pluginGrantSchema: z.ZodObject<{
|
|
32
32
|
access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
33
|
+
leaseScope: z.ZodOptional<z.ZodString>;
|
|
33
34
|
name: z.ZodString;
|
|
34
35
|
reason: z.ZodOptional<z.ZodString>;
|
|
35
36
|
requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
package/dist/index.js
CHANGED
|
@@ -261,7 +261,7 @@ function parsePluginToolInput(schema, args) {
|
|
|
261
261
|
}
|
|
262
262
|
return result.data;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
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
|
-
|
|
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
|
-
|
|
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";
|
|
@@ -345,6 +351,7 @@ var pluginStoredTokensSchema = z7.object({
|
|
|
345
351
|
}).strict();
|
|
346
352
|
var pluginGrantSchema = z7.object({
|
|
347
353
|
access: pluginGrantAccessSchema,
|
|
354
|
+
leaseScope: nonBlankStringSchema.optional(),
|
|
348
355
|
name: pluginGrantNameSchema,
|
|
349
356
|
reason: nonBlankStringSchema.optional(),
|
|
350
357
|
requirements: z7.array(nonBlankStringSchema).min(1).optional()
|
|
@@ -470,5 +477,6 @@ export {
|
|
|
470
477
|
sourceSchema,
|
|
471
478
|
sourceTypeSchema,
|
|
472
479
|
subscribableResourceSchema,
|
|
473
|
-
systemActorSchema
|
|
480
|
+
systemActorSchema,
|
|
481
|
+
zodTool
|
|
474
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
|
-
|
|
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
package/src/credentials.ts
CHANGED
|
@@ -43,6 +43,7 @@ export const pluginStoredTokensSchema = z
|
|
|
43
43
|
export const pluginGrantSchema = z
|
|
44
44
|
.object({
|
|
45
45
|
access: pluginGrantAccessSchema,
|
|
46
|
+
leaseScope: nonBlankStringSchema.optional(),
|
|
46
47
|
name: pluginGrantNameSchema,
|
|
47
48
|
reason: nonBlankStringSchema.optional(),
|
|
48
49
|
requirements: z.array(nonBlankStringSchema).min(1).optional(),
|
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
|
-
|
|
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
|
-
|
|
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.
|