@sentry/junior-plugin-api 0.225.0 → 0.227.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/README.md +3 -0
- package/dist/index.d.ts +219 -8
- package/dist/index.js +372 -266
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,127 @@
|
|
|
1
1
|
// src/object-annotations.ts
|
|
2
|
+
import { z as z2 } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/object-facts.ts
|
|
2
5
|
import { z } from "zod";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}).
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
var text = z.string().trim().min(1).max(160);
|
|
7
|
+
var count = z.number().int().nonnegative();
|
|
8
|
+
var objectFactsSchema = z.discriminatedUnion("type", [
|
|
9
|
+
// Code changes: keep lifecycle, review, and checks separate.
|
|
10
|
+
z.strictObject({
|
|
11
|
+
type: z.literal("code_change"),
|
|
12
|
+
author: text.optional(),
|
|
13
|
+
sourceBranch: text.optional(),
|
|
14
|
+
targetBranch: text.optional(),
|
|
15
|
+
reviewers: z.array(text).max(5).optional(),
|
|
16
|
+
review: z.enum(["required", "approved", "changes_requested"]).optional(),
|
|
17
|
+
checks: z.strictObject({ passed: count, failed: count, pending: count }).optional(),
|
|
18
|
+
mergeable: z.boolean().optional(),
|
|
19
|
+
changedFiles: count.optional(),
|
|
20
|
+
additions: count.optional(),
|
|
21
|
+
deletions: count.optional()
|
|
22
|
+
}),
|
|
23
|
+
// Tasks: ownership and priority first; planning context comes next.
|
|
24
|
+
z.strictObject({
|
|
25
|
+
type: z.literal("task"),
|
|
26
|
+
assignees: z.array(text).max(5).optional(),
|
|
27
|
+
priority: text.optional(),
|
|
28
|
+
project: text.optional(),
|
|
29
|
+
cycle: text.optional(),
|
|
30
|
+
dueDate: z.iso.date().optional(),
|
|
31
|
+
labels: z.array(text).max(5).optional()
|
|
32
|
+
}),
|
|
33
|
+
// Deployments remain Items. Never copy environment values or logs.
|
|
34
|
+
z.strictObject({
|
|
35
|
+
type: z.literal("deployment"),
|
|
36
|
+
project: text.optional(),
|
|
37
|
+
environment: text.optional(),
|
|
38
|
+
revision: text.optional(),
|
|
39
|
+
branch: text.optional()
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
function objectFactFields(facts) {
|
|
43
|
+
if (!facts) return [];
|
|
44
|
+
const fields = [];
|
|
45
|
+
const list = (values) => values?.length ? `${values.join(", ")}${values.length === 5 ? " (up to 5 shown)" : ""}` : void 0;
|
|
46
|
+
function add(key, label, value) {
|
|
47
|
+
if (value !== void 0 && value !== "")
|
|
48
|
+
fields.push({ key, label, value: String(value) });
|
|
49
|
+
}
|
|
50
|
+
switch (facts.type) {
|
|
51
|
+
case "code_change": {
|
|
52
|
+
const review = {
|
|
53
|
+
required: "Review required",
|
|
54
|
+
approved: "Approved",
|
|
55
|
+
changes_requested: "Changes requested"
|
|
56
|
+
};
|
|
57
|
+
add("review", "Review", facts.review && review[facts.review]);
|
|
58
|
+
const checks = facts.checks;
|
|
59
|
+
add(
|
|
60
|
+
"checks",
|
|
61
|
+
"Checks",
|
|
62
|
+
checks && `${checks.failed} failed \xB7 ${checks.pending} pending \xB7 ${checks.passed} passed`
|
|
63
|
+
);
|
|
64
|
+
add("author", "Author", facts.author);
|
|
65
|
+
add("reviewers", "Requested reviewers", list(facts.reviewers));
|
|
66
|
+
add(
|
|
67
|
+
"mergeable",
|
|
68
|
+
"Conflicts",
|
|
69
|
+
facts.mergeable === void 0 ? void 0 : facts.mergeable ? "No conflicts" : "Has conflicts"
|
|
70
|
+
);
|
|
71
|
+
add("sourceBranch", "From", facts.sourceBranch);
|
|
72
|
+
add("targetBranch", "Into", facts.targetBranch);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "task":
|
|
76
|
+
add(
|
|
77
|
+
"assignees",
|
|
78
|
+
"Assignees",
|
|
79
|
+
facts.assignees?.length === 0 ? "Unassigned" : list(facts.assignees)
|
|
80
|
+
);
|
|
81
|
+
add("priority", "Priority", facts.priority);
|
|
82
|
+
add("project", "Project", facts.project);
|
|
83
|
+
add("cycle", "Cycle", facts.cycle);
|
|
84
|
+
add("dueDate", "Due", facts.dueDate);
|
|
85
|
+
add("labels", "Labels", list(facts.labels));
|
|
86
|
+
break;
|
|
87
|
+
case "deployment":
|
|
88
|
+
add("environment", "Environment", facts.environment);
|
|
89
|
+
add("project", "Project", facts.project);
|
|
90
|
+
add("revision", "Revision", facts.revision);
|
|
91
|
+
add("branch", "Branch", facts.branch);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
return fields.slice(0, 4);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/object-annotations.ts
|
|
98
|
+
var objectAnnotationSchema = z2.object({
|
|
99
|
+
kind: z2.literal("object"),
|
|
100
|
+
key: z2.string().trim().min(1).max(256),
|
|
101
|
+
label: z2.string().trim().min(1).max(256),
|
|
102
|
+
objectType: z2.enum(["task", "code_change", "automation", "item"]),
|
|
103
|
+
title: z2.string().trim().min(1).max(512),
|
|
104
|
+
url: z2.url().max(2048).refine((value) => ["http:", "https:"].includes(new URL(value).protocol)).nullable(),
|
|
105
|
+
description: z2.string().max(4e3).optional(),
|
|
106
|
+
status: z2.string().trim().min(1).max(100).optional(),
|
|
107
|
+
trigger: z2.string().max(4e3).optional(),
|
|
108
|
+
warning: z2.string().max(1e3).optional(),
|
|
109
|
+
displayType: z2.string().trim().min(1).max(80).optional(),
|
|
110
|
+
sourceUpdatedAt: z2.iso.datetime({ offset: true }).optional(),
|
|
111
|
+
facts: objectFactsSchema.refine(
|
|
112
|
+
(facts) => new TextEncoder().encode(JSON.stringify(facts)).length <= 4096,
|
|
113
|
+
"Object facts must not exceed 4 KiB"
|
|
114
|
+
).optional()
|
|
115
|
+
}).strict().refine(
|
|
116
|
+
(annotation) => !annotation.facts || (annotation.facts.type === "deployment" ? annotation.objectType === "item" : annotation.facts.type === annotation.objectType),
|
|
117
|
+
"Object facts must match the object type"
|
|
118
|
+
);
|
|
119
|
+
var ownedObjectAnnotationSchema = objectAnnotationSchema.safeExtend({
|
|
120
|
+
plugin: z2.string().min(1)
|
|
17
121
|
});
|
|
18
122
|
|
|
19
123
|
// src/annotations.ts
|
|
20
|
-
import { z as
|
|
124
|
+
import { z as z3 } from "zod";
|
|
21
125
|
function usesHttpProtocol(value) {
|
|
22
126
|
try {
|
|
23
127
|
const protocol = new URL(value).protocol;
|
|
@@ -26,19 +130,19 @@ function usesHttpProtocol(value) {
|
|
|
26
130
|
return false;
|
|
27
131
|
}
|
|
28
132
|
}
|
|
29
|
-
var resourceLinkAnnotationSchema =
|
|
30
|
-
kind:
|
|
31
|
-
key:
|
|
32
|
-
label:
|
|
33
|
-
url:
|
|
34
|
-
description:
|
|
35
|
-
status:
|
|
133
|
+
var resourceLinkAnnotationSchema = z3.object({
|
|
134
|
+
kind: z3.literal("resource_link"),
|
|
135
|
+
key: z3.string().trim().min(1).max(256),
|
|
136
|
+
label: z3.string().trim().min(1).max(256),
|
|
137
|
+
url: z3.string().url().max(2048).refine(usesHttpProtocol, "URL must use HTTP or HTTPS."),
|
|
138
|
+
description: z3.string().trim().min(1).max(512).optional(),
|
|
139
|
+
status: z3.enum(["open", "draft", "closed", "merged", "warning"]).optional()
|
|
36
140
|
}).strict();
|
|
37
|
-
var conversationAnnotationInputSchema =
|
|
141
|
+
var conversationAnnotationInputSchema = z3.discriminatedUnion("kind", [
|
|
38
142
|
resourceLinkAnnotationSchema,
|
|
39
143
|
objectAnnotationSchema
|
|
40
144
|
]);
|
|
41
|
-
var conversationSidebarIconSchema =
|
|
145
|
+
var conversationSidebarIconSchema = z3.enum([
|
|
42
146
|
"circle-dot",
|
|
43
147
|
"circle-dashed",
|
|
44
148
|
"circle-x",
|
|
@@ -46,37 +150,37 @@ var conversationSidebarIconSchema = z2.enum([
|
|
|
46
150
|
"git-pull-request",
|
|
47
151
|
"triangle-alert"
|
|
48
152
|
]);
|
|
49
|
-
var conversationSidebarAnnotationSchema =
|
|
153
|
+
var conversationSidebarAnnotationSchema = z3.object({
|
|
50
154
|
icon: conversationSidebarIconSchema.optional(),
|
|
51
|
-
key:
|
|
52
|
-
label:
|
|
155
|
+
key: z3.string().trim().min(1).max(256),
|
|
156
|
+
label: z3.string().trim().min(1).max(256)
|
|
53
157
|
}).strict();
|
|
54
158
|
|
|
55
159
|
// src/code.ts
|
|
56
|
-
import { z as
|
|
57
|
-
var codeChangeStateSchema =
|
|
58
|
-
var codeChangeInputSchema =
|
|
59
|
-
closedAt:
|
|
60
|
-
conversationIds:
|
|
61
|
-
mergedAt:
|
|
62
|
-
number:
|
|
63
|
-
openedAt:
|
|
64
|
-
providerId:
|
|
65
|
-
repository:
|
|
66
|
-
name:
|
|
67
|
-
providerId:
|
|
68
|
-
url:
|
|
160
|
+
import { z as z4 } from "zod";
|
|
161
|
+
var codeChangeStateSchema = z4.enum(["closed", "merged", "open"]);
|
|
162
|
+
var codeChangeInputSchema = z4.object({
|
|
163
|
+
closedAt: z4.date().optional(),
|
|
164
|
+
conversationIds: z4.array(z4.string().min(1)).default([]),
|
|
165
|
+
mergedAt: z4.date().optional(),
|
|
166
|
+
number: z4.number().int().positive(),
|
|
167
|
+
openedAt: z4.date(),
|
|
168
|
+
providerId: z4.string().min(1),
|
|
169
|
+
repository: z4.object({
|
|
170
|
+
name: z4.string().min(1),
|
|
171
|
+
providerId: z4.string().min(1),
|
|
172
|
+
url: z4.string().url().optional()
|
|
69
173
|
}).strict(),
|
|
70
174
|
state: codeChangeStateSchema,
|
|
71
|
-
title:
|
|
72
|
-
updatedAt:
|
|
73
|
-
url:
|
|
175
|
+
title: z4.string().min(1).optional(),
|
|
176
|
+
updatedAt: z4.date(),
|
|
177
|
+
url: z4.string().url().optional()
|
|
74
178
|
}).strict();
|
|
75
179
|
|
|
76
180
|
// src/conversation-events.ts
|
|
77
|
-
import { z as
|
|
78
|
-
var conversationEventNameSchema =
|
|
79
|
-
var conversationEventIconSchema =
|
|
181
|
+
import { z as z5 } from "zod";
|
|
182
|
+
var conversationEventNameSchema = z5.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
183
|
+
var conversationEventIconSchema = z5.enum([
|
|
80
184
|
"activity",
|
|
81
185
|
"brain",
|
|
82
186
|
"calendar",
|
|
@@ -88,22 +192,22 @@ var conversationEventIconSchema = z4.enum([
|
|
|
88
192
|
"sparkles",
|
|
89
193
|
"warning"
|
|
90
194
|
]);
|
|
91
|
-
var conversationEventDetailSchema =
|
|
92
|
-
content:
|
|
93
|
-
description:
|
|
94
|
-
metadata:
|
|
95
|
-
title:
|
|
195
|
+
var conversationEventDetailSchema = z5.object({
|
|
196
|
+
content: z5.string().min(1).max(32 * 1024).optional(),
|
|
197
|
+
description: z5.string().trim().min(1).max(2e3).optional(),
|
|
198
|
+
metadata: z5.array(z5.string().trim().min(1).max(120)).max(8).optional(),
|
|
199
|
+
title: z5.string().trim().min(1).max(4e3)
|
|
96
200
|
}).strict();
|
|
97
|
-
var conversationEventPresentationSchema =
|
|
98
|
-
details:
|
|
201
|
+
var conversationEventPresentationSchema = z5.object({
|
|
202
|
+
details: z5.array(conversationEventDetailSchema).max(100).optional(),
|
|
99
203
|
icon: conversationEventIconSchema.optional(),
|
|
100
|
-
preview:
|
|
101
|
-
title:
|
|
204
|
+
preview: z5.string().trim().min(1).max(500).optional(),
|
|
205
|
+
title: z5.string().trim().min(1).max(120)
|
|
102
206
|
}).strict();
|
|
103
207
|
function defineConversationEvent(definition) {
|
|
104
|
-
const identity =
|
|
208
|
+
const identity = z5.object({
|
|
105
209
|
name: conversationEventNameSchema,
|
|
106
|
-
version:
|
|
210
|
+
version: z5.number().int().positive()
|
|
107
211
|
}).strict().parse({ name: definition.name, version: definition.version });
|
|
108
212
|
let eventDefinition;
|
|
109
213
|
const createEvent = (data) => ({
|
|
@@ -126,85 +230,85 @@ function defineConversationEvent(definition) {
|
|
|
126
230
|
}
|
|
127
231
|
|
|
128
232
|
// src/schemas.ts
|
|
129
|
-
import { z as
|
|
130
|
-
var slackTeamIdSchema =
|
|
131
|
-
var slackConversationIdSchema =
|
|
132
|
-
var localConversationIdSchema =
|
|
133
|
-
var actorUserIdSchema =
|
|
233
|
+
import { z as z6 } from "zod";
|
|
234
|
+
var slackTeamIdSchema = z6.string().regex(/^T[A-Z0-9]+$/);
|
|
235
|
+
var slackConversationIdSchema = z6.string().regex(/^(C|G|D)[A-Z0-9]+$/);
|
|
236
|
+
var localConversationIdSchema = z6.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/);
|
|
237
|
+
var actorUserIdSchema = z6.string().min(1).refine(
|
|
134
238
|
(value) => value === value.trim() && value.toLowerCase() !== "unknown"
|
|
135
239
|
);
|
|
136
240
|
var exactActorUserIdSchema = actorUserIdSchema;
|
|
137
|
-
var nonBlankStringSchema =
|
|
241
|
+
var nonBlankStringSchema = z6.string().refine((value) => value.trim().length > 0);
|
|
138
242
|
var exactNonBlankStringSchema = nonBlankStringSchema.refine(
|
|
139
243
|
(value) => value === value.trim()
|
|
140
244
|
);
|
|
141
|
-
var baseLocationSchema =
|
|
245
|
+
var baseLocationSchema = z6.object({
|
|
142
246
|
/** Stable SQL identity used by Location configuration and reporting. */
|
|
143
247
|
id: nonBlankStringSchema,
|
|
144
248
|
provider: exactNonBlankStringSchema
|
|
145
249
|
}).strict();
|
|
146
250
|
var slackLocationSchema = baseLocationSchema.extend({
|
|
147
|
-
provider:
|
|
251
|
+
provider: z6.literal("slack"),
|
|
148
252
|
teamId: slackTeamIdSchema,
|
|
149
253
|
channelId: slackConversationIdSchema,
|
|
150
254
|
threadTs: exactNonBlankStringSchema.optional()
|
|
151
255
|
}).strict();
|
|
152
|
-
var locationSchema =
|
|
256
|
+
var locationSchema = z6.discriminatedUnion("provider", [
|
|
153
257
|
slackLocationSchema
|
|
154
258
|
]);
|
|
155
|
-
var platformSchema =
|
|
156
|
-
var sourceVisibilitySchema =
|
|
157
|
-
var destinationVisibilitySchema =
|
|
158
|
-
var slackAddressSchema =
|
|
159
|
-
platform:
|
|
259
|
+
var platformSchema = z6.enum(["slack", "local"]);
|
|
260
|
+
var sourceVisibilitySchema = z6.enum(["public", "private"]);
|
|
261
|
+
var destinationVisibilitySchema = z6.enum(["public", "private"]);
|
|
262
|
+
var slackAddressSchema = z6.object({
|
|
263
|
+
platform: z6.literal("slack"),
|
|
160
264
|
teamId: slackTeamIdSchema,
|
|
161
265
|
channelId: slackConversationIdSchema,
|
|
162
266
|
threadTs: exactNonBlankStringSchema.optional()
|
|
163
267
|
}).strict();
|
|
164
268
|
var slackDestinationSchema = slackAddressSchema;
|
|
165
|
-
var localDestinationSchema =
|
|
166
|
-
platform:
|
|
269
|
+
var localDestinationSchema = z6.object({
|
|
270
|
+
platform: z6.literal("local"),
|
|
167
271
|
conversationId: localConversationIdSchema
|
|
168
272
|
}).strict();
|
|
169
|
-
var destinationSchema =
|
|
273
|
+
var destinationSchema = z6.discriminatedUnion("platform", [
|
|
170
274
|
slackDestinationSchema,
|
|
171
275
|
localDestinationSchema
|
|
172
276
|
]);
|
|
173
|
-
var taskOutcomeSchema =
|
|
174
|
-
action:
|
|
277
|
+
var taskOutcomeSchema = z6.object({
|
|
278
|
+
action: z6.literal("send_message"),
|
|
175
279
|
destination: slackDestinationSchema
|
|
176
280
|
}).strict();
|
|
177
|
-
var slackSourceSchema =
|
|
178
|
-
kind:
|
|
281
|
+
var slackSourceSchema = z6.object({
|
|
282
|
+
kind: z6.literal("slack"),
|
|
179
283
|
teamId: slackTeamIdSchema,
|
|
180
284
|
channelId: slackConversationIdSchema,
|
|
181
285
|
visibility: sourceVisibilitySchema,
|
|
182
286
|
messageTs: nonBlankStringSchema.optional(),
|
|
183
287
|
threadTs: nonBlankStringSchema.optional()
|
|
184
288
|
}).strict();
|
|
185
|
-
var localSourceSchema =
|
|
186
|
-
kind:
|
|
187
|
-
visibility:
|
|
289
|
+
var localSourceSchema = z6.object({
|
|
290
|
+
kind: z6.literal("local"),
|
|
291
|
+
visibility: z6.literal("private"),
|
|
188
292
|
conversationId: localConversationIdSchema
|
|
189
293
|
}).strict();
|
|
190
|
-
var webSourceSchema =
|
|
191
|
-
kind:
|
|
294
|
+
var webSourceSchema = z6.object({
|
|
295
|
+
kind: z6.literal("web"),
|
|
192
296
|
visibility: sourceVisibilitySchema,
|
|
193
297
|
// Web can continue any existing conversation id, including Slack roots.
|
|
194
298
|
conversationId: exactNonBlankStringSchema
|
|
195
299
|
}).strict();
|
|
196
|
-
var eventSourceSchema =
|
|
197
|
-
kind:
|
|
300
|
+
var eventSourceSchema = z6.object({
|
|
301
|
+
kind: z6.literal("event"),
|
|
198
302
|
eventKey: exactNonBlankStringSchema,
|
|
199
303
|
eventType: exactNonBlankStringSchema,
|
|
200
304
|
identifier: exactNonBlankStringSchema,
|
|
201
305
|
namespace: exactNonBlankStringSchema
|
|
202
306
|
}).strict();
|
|
203
|
-
var scheduledAutomationSourceSchema =
|
|
204
|
-
var eventAutomationSourceSchema =
|
|
205
|
-
var pluginDispatchSourceSchema =
|
|
206
|
-
var agentInvocationSourceSchema =
|
|
207
|
-
var currentSourceSchema =
|
|
307
|
+
var scheduledAutomationSourceSchema = z6.object({ kind: z6.literal("scheduled_automation") }).strict();
|
|
308
|
+
var eventAutomationSourceSchema = z6.object({ kind: z6.literal("event_automation") }).strict();
|
|
309
|
+
var pluginDispatchSourceSchema = z6.object({ kind: z6.literal("plugin_dispatch") }).strict();
|
|
310
|
+
var agentInvocationSourceSchema = z6.object({ kind: z6.literal("agent_invocation") }).strict();
|
|
311
|
+
var currentSourceSchema = z6.discriminatedUnion("kind", [
|
|
208
312
|
slackSourceSchema,
|
|
209
313
|
localSourceSchema,
|
|
210
314
|
webSourceSchema,
|
|
@@ -234,22 +338,22 @@ function normalizeStoredSource(value) {
|
|
|
234
338
|
const { location: _location, platform: kind, ...fields } = source;
|
|
235
339
|
return { ...fields, kind };
|
|
236
340
|
}
|
|
237
|
-
var sourceSchema =
|
|
341
|
+
var sourceSchema = z6.preprocess(
|
|
238
342
|
normalizeStoredSource,
|
|
239
343
|
currentSourceSchema
|
|
240
344
|
);
|
|
241
|
-
var pluginCredentialSubjectSchema =
|
|
345
|
+
var pluginCredentialSubjectSchema = z6.discriminatedUnion(
|
|
242
346
|
"allowedWhen",
|
|
243
347
|
[
|
|
244
|
-
|
|
245
|
-
type:
|
|
348
|
+
z6.object({
|
|
349
|
+
type: z6.literal("user"),
|
|
246
350
|
userId: exactActorUserIdSchema,
|
|
247
|
-
allowedWhen:
|
|
351
|
+
allowedWhen: z6.literal("private-direct-conversation")
|
|
248
352
|
}).strict(),
|
|
249
|
-
|
|
250
|
-
type:
|
|
353
|
+
z6.object({
|
|
354
|
+
type: z6.literal("user"),
|
|
251
355
|
userId: exactActorUserIdSchema,
|
|
252
|
-
allowedWhen:
|
|
356
|
+
allowedWhen: z6.literal("scheduled-automation"),
|
|
253
357
|
taskId: exactNonBlankStringSchema
|
|
254
358
|
}).strict()
|
|
255
359
|
]
|
|
@@ -260,30 +364,30 @@ var actorProfileSchema = {
|
|
|
260
364
|
userId: exactActorUserIdSchema,
|
|
261
365
|
userName: nonBlankStringSchema.optional()
|
|
262
366
|
};
|
|
263
|
-
var slackActorSchema =
|
|
367
|
+
var slackActorSchema = z6.object({
|
|
264
368
|
...actorProfileSchema,
|
|
265
|
-
platform:
|
|
369
|
+
platform: z6.literal("slack"),
|
|
266
370
|
teamId: slackTeamIdSchema
|
|
267
371
|
}).strict();
|
|
268
|
-
var localActorSchema =
|
|
372
|
+
var localActorSchema = z6.object({
|
|
269
373
|
...actorProfileSchema,
|
|
270
|
-
platform:
|
|
374
|
+
platform: z6.literal("local")
|
|
271
375
|
}).strict();
|
|
272
|
-
var webActorSchema =
|
|
376
|
+
var webActorSchema = z6.object({
|
|
273
377
|
...actorProfileSchema,
|
|
274
|
-
platform:
|
|
378
|
+
platform: z6.literal("web")
|
|
275
379
|
}).strict();
|
|
276
|
-
var systemActorSchema =
|
|
277
|
-
platform:
|
|
380
|
+
var systemActorSchema = z6.object({
|
|
381
|
+
platform: z6.literal("system"),
|
|
278
382
|
name: exactActorUserIdSchema
|
|
279
383
|
}).strict();
|
|
280
|
-
var actorSchema =
|
|
384
|
+
var actorSchema = z6.discriminatedUnion("platform", [
|
|
281
385
|
slackActorSchema,
|
|
282
386
|
localActorSchema,
|
|
283
387
|
webActorSchema,
|
|
284
388
|
systemActorSchema
|
|
285
389
|
]);
|
|
286
|
-
var identitySchema =
|
|
390
|
+
var identitySchema = z6.object({
|
|
287
391
|
displayName: nonBlankStringSchema.optional(),
|
|
288
392
|
handle: nonBlankStringSchema.optional(),
|
|
289
393
|
id: exactNonBlankStringSchema,
|
|
@@ -291,17 +395,17 @@ var identitySchema = z5.object({
|
|
|
291
395
|
providerSubjectId: exactNonBlankStringSchema,
|
|
292
396
|
providerTenantId: exactNonBlankStringSchema.optional()
|
|
293
397
|
}).strict();
|
|
294
|
-
var userSchema =
|
|
398
|
+
var userSchema = z6.object({
|
|
295
399
|
displayName: nonBlankStringSchema.optional(),
|
|
296
400
|
email: nonBlankStringSchema.max(320),
|
|
297
401
|
id: exactNonBlankStringSchema,
|
|
298
|
-
identities:
|
|
402
|
+
identities: z6.array(identitySchema).max(100)
|
|
299
403
|
}).strict();
|
|
300
|
-
var dispatchMetadataSchema =
|
|
404
|
+
var dispatchMetadataSchema = z6.record(z6.string(), z6.string()).superRefine((metadata, ctx) => {
|
|
301
405
|
const entries = Object.entries(metadata);
|
|
302
406
|
if (entries.length > 20) {
|
|
303
407
|
ctx.addIssue({
|
|
304
|
-
code:
|
|
408
|
+
code: z6.ZodIssueCode.custom,
|
|
305
409
|
message: "Dispatch metadata has too many keys"
|
|
306
410
|
});
|
|
307
411
|
return;
|
|
@@ -309,7 +413,7 @@ var dispatchMetadataSchema = z5.record(z5.string(), z5.string()).superRefine((me
|
|
|
309
413
|
for (const [key, value] of entries) {
|
|
310
414
|
if (!key.trim()) {
|
|
311
415
|
ctx.addIssue({
|
|
312
|
-
code:
|
|
416
|
+
code: z6.ZodIssueCode.custom,
|
|
313
417
|
message: "Dispatch metadata values must be strings",
|
|
314
418
|
path: [key]
|
|
315
419
|
});
|
|
@@ -317,44 +421,44 @@ var dispatchMetadataSchema = z5.record(z5.string(), z5.string()).superRefine((me
|
|
|
317
421
|
}
|
|
318
422
|
if (key.length > 128) {
|
|
319
423
|
ctx.addIssue({
|
|
320
|
-
code:
|
|
424
|
+
code: z6.ZodIssueCode.custom,
|
|
321
425
|
message: "Dispatch metadata key exceeds the maximum length",
|
|
322
426
|
path: [key]
|
|
323
427
|
});
|
|
324
428
|
}
|
|
325
429
|
if (/[\r\n]/.test(key)) {
|
|
326
430
|
ctx.addIssue({
|
|
327
|
-
code:
|
|
431
|
+
code: z6.ZodIssueCode.custom,
|
|
328
432
|
message: "Dispatch metadata keys must be single-line strings",
|
|
329
433
|
path: [key]
|
|
330
434
|
});
|
|
331
435
|
}
|
|
332
436
|
if (/[\r\n]/.test(value)) {
|
|
333
437
|
ctx.addIssue({
|
|
334
|
-
code:
|
|
438
|
+
code: z6.ZodIssueCode.custom,
|
|
335
439
|
message: "Dispatch metadata values must be single-line strings",
|
|
336
440
|
path: [key]
|
|
337
441
|
});
|
|
338
442
|
}
|
|
339
443
|
if (value.length > 512) {
|
|
340
444
|
ctx.addIssue({
|
|
341
|
-
code:
|
|
445
|
+
code: z6.ZodIssueCode.custom,
|
|
342
446
|
message: "Dispatch metadata value exceeds the maximum length",
|
|
343
447
|
path: [key]
|
|
344
448
|
});
|
|
345
449
|
}
|
|
346
450
|
}
|
|
347
451
|
});
|
|
348
|
-
var replyAttributionSchema =
|
|
349
|
-
label: exactNonBlankStringSchema.pipe(
|
|
350
|
-
detail: exactNonBlankStringSchema.pipe(
|
|
452
|
+
var replyAttributionSchema = z6.object({
|
|
453
|
+
label: exactNonBlankStringSchema.pipe(z6.string().max(48)).refine((value) => !/[\r\n]/.test(value)),
|
|
454
|
+
detail: exactNonBlankStringSchema.pipe(z6.string().max(128)).refine((value) => !/[\r\n]/.test(value)).optional()
|
|
351
455
|
}).strict();
|
|
352
|
-
var dispatchOptionsSchema =
|
|
353
|
-
idempotencyKey: nonBlankStringSchema.pipe(
|
|
456
|
+
var dispatchOptionsSchema = z6.object({
|
|
457
|
+
idempotencyKey: nonBlankStringSchema.pipe(z6.string().max(512)),
|
|
354
458
|
credentialSubject: pluginCredentialSubjectSchema.optional(),
|
|
355
459
|
destination: slackDestinationSchema,
|
|
356
460
|
destinationVisibility: destinationVisibilitySchema,
|
|
357
|
-
input: nonBlankStringSchema.pipe(
|
|
461
|
+
input: nonBlankStringSchema.pipe(z6.string().max(32e3)),
|
|
358
462
|
metadata: dispatchMetadataSchema.optional(),
|
|
359
463
|
replyAttribution: replyAttributionSchema.optional()
|
|
360
464
|
}).strict();
|
|
@@ -422,15 +526,15 @@ function isSlackDestination(destination) {
|
|
|
422
526
|
}
|
|
423
527
|
|
|
424
528
|
// src/prompt.ts
|
|
425
|
-
import { z as
|
|
426
|
-
var promptContextKindSchema =
|
|
427
|
-
var promptMessageSchema =
|
|
428
|
-
text:
|
|
529
|
+
import { z as z7 } from "zod";
|
|
530
|
+
var promptContextKindSchema = z7.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/);
|
|
531
|
+
var promptMessageSchema = z7.object({
|
|
532
|
+
text: z7.string().trim().min(1).max(8e3)
|
|
429
533
|
}).strict();
|
|
430
|
-
var promptContextSchema =
|
|
534
|
+
var promptContextSchema = z7.object({
|
|
431
535
|
kind: promptContextKindSchema,
|
|
432
|
-
version:
|
|
433
|
-
content:
|
|
536
|
+
version: z7.number().int().positive(),
|
|
537
|
+
content: z7.record(z7.string(), z7.unknown())
|
|
434
538
|
}).strict();
|
|
435
539
|
function definePromptContext(definition) {
|
|
436
540
|
const identity = promptContextSchema.pick({ kind: true, version: true }).parse({ kind: definition.kind, version: definition.version });
|
|
@@ -444,13 +548,13 @@ function definePromptContext(definition) {
|
|
|
444
548
|
}
|
|
445
549
|
|
|
446
550
|
// src/events.ts
|
|
447
|
-
import { z as
|
|
551
|
+
import { z as z8 } from "zod";
|
|
448
552
|
var EVENT_SUMMARY_MAX_LENGTH = 4e3;
|
|
449
553
|
var EVENT_TEXT_MAX_LENGTH = 8e3;
|
|
450
554
|
var EVENT_DATA_MAX_KEYS = 32;
|
|
451
555
|
var EVENT_DATA_MAX_JSON_BYTES = 4e3;
|
|
452
556
|
var EVENT_GUIDANCE_MAX_LENGTH = 1e3;
|
|
453
|
-
var eventDataSchema =
|
|
557
|
+
var eventDataSchema = z8.record(z8.string(), z8.unknown()).superRefine((value, context) => {
|
|
454
558
|
const keys = Object.keys(value);
|
|
455
559
|
if (keys.length > EVENT_DATA_MAX_KEYS) {
|
|
456
560
|
context.addIssue({
|
|
@@ -468,17 +572,17 @@ var eventDataSchema = z7.record(z7.string(), z7.unknown()).superRefine((value, c
|
|
|
468
572
|
});
|
|
469
573
|
}
|
|
470
574
|
});
|
|
471
|
-
var eventTypeSchema =
|
|
575
|
+
var eventTypeSchema = z8.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe(
|
|
472
576
|
"Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."
|
|
473
577
|
);
|
|
474
|
-
var resourceTypeSchema =
|
|
578
|
+
var resourceTypeSchema = z8.string().regex(/^[a-z][a-z0-9_]*$/).describe(
|
|
475
579
|
"Canonical plugin-defined resource type, such as issue or pull_request."
|
|
476
580
|
);
|
|
477
581
|
var EVENT_MATCH_FIELD_NAME = /^[a-z][a-zA-Z0-9]*$/;
|
|
478
|
-
var eventMatchFieldSchema =
|
|
479
|
-
kind:
|
|
480
|
-
description:
|
|
481
|
-
enum:
|
|
582
|
+
var eventMatchFieldSchema = z8.object({
|
|
583
|
+
kind: z8.enum(["boolean", "string", "number"]),
|
|
584
|
+
description: z8.string().trim().min(1).max(200),
|
|
585
|
+
enum: z8.array(z8.string().min(1)).min(1).optional()
|
|
482
586
|
}).strict().superRefine((field, context) => {
|
|
483
587
|
if (field.enum && field.kind !== "string") {
|
|
484
588
|
context.addIssue({
|
|
@@ -488,7 +592,7 @@ var eventMatchFieldSchema = z7.object({
|
|
|
488
592
|
});
|
|
489
593
|
}
|
|
490
594
|
});
|
|
491
|
-
var eventMatchFieldsSchema =
|
|
595
|
+
var eventMatchFieldsSchema = z8.record(z8.string().regex(EVENT_MATCH_FIELD_NAME), eventMatchFieldSchema).superRefine((fields, context) => {
|
|
492
596
|
if (Object.keys(fields).length > EVENT_DATA_MAX_KEYS) {
|
|
493
597
|
context.addIssue({
|
|
494
598
|
code: "custom",
|
|
@@ -496,13 +600,13 @@ var eventMatchFieldsSchema = z7.record(z7.string().regex(EVENT_MATCH_FIELD_NAME)
|
|
|
496
600
|
});
|
|
497
601
|
}
|
|
498
602
|
});
|
|
499
|
-
var eventMatchSchema =
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
603
|
+
var eventMatchSchema = z8.record(
|
|
604
|
+
z8.string().regex(EVENT_MATCH_FIELD_NAME),
|
|
605
|
+
z8.union([
|
|
606
|
+
z8.boolean(),
|
|
607
|
+
z8.number().finite(),
|
|
608
|
+
z8.string().min(1),
|
|
609
|
+
z8.array(z8.union([z8.number().finite(), z8.string().min(1)])).min(1)
|
|
506
610
|
])
|
|
507
611
|
).superRefine((match, context) => {
|
|
508
612
|
if (Object.keys(match).length > EVENT_DATA_MAX_KEYS) {
|
|
@@ -553,14 +657,14 @@ function eventMatches(match, data) {
|
|
|
553
657
|
}
|
|
554
658
|
return true;
|
|
555
659
|
}
|
|
556
|
-
var pluginEventTypeSchema =
|
|
660
|
+
var pluginEventTypeSchema = z8.object({
|
|
557
661
|
type: resourceTypeSchema,
|
|
558
|
-
supportedEvents:
|
|
559
|
-
suggestedEvents:
|
|
662
|
+
supportedEvents: z8.array(eventTypeSchema).min(1),
|
|
663
|
+
suggestedEvents: z8.array(eventTypeSchema).optional(),
|
|
560
664
|
matchFields: eventMatchFieldsSchema.optional(),
|
|
561
|
-
guidance:
|
|
665
|
+
guidance: z8.record(
|
|
562
666
|
eventTypeSchema,
|
|
563
|
-
|
|
667
|
+
z8.string().trim().min(1).max(EVENT_GUIDANCE_MAX_LENGTH)
|
|
564
668
|
).optional()
|
|
565
669
|
}).strict().superRefine((resourceType, context) => {
|
|
566
670
|
const supported = /* @__PURE__ */ new Set();
|
|
@@ -602,10 +706,10 @@ var pluginEventTypeSchema = z7.object({
|
|
|
602
706
|
suggested.add(eventType);
|
|
603
707
|
});
|
|
604
708
|
});
|
|
605
|
-
var pluginEventsSchema =
|
|
606
|
-
resourceTypes:
|
|
607
|
-
isEnabled:
|
|
608
|
-
normalizeIdentifier:
|
|
709
|
+
var pluginEventsSchema = z8.object({
|
|
710
|
+
resourceTypes: z8.array(pluginEventTypeSchema).min(1),
|
|
711
|
+
isEnabled: z8.function({ input: [], output: z8.boolean() }).optional(),
|
|
712
|
+
normalizeIdentifier: z8.function({ input: [z8.string()], output: z8.string() }).optional()
|
|
609
713
|
}).strict().superRefine((registration, context) => {
|
|
610
714
|
const seen = /* @__PURE__ */ new Set();
|
|
611
715
|
registration.resourceTypes.forEach((resourceType, index) => {
|
|
@@ -627,62 +731,62 @@ function normalizeEventIdentifier(registration, identifier) {
|
|
|
627
731
|
}
|
|
628
732
|
return normalized;
|
|
629
733
|
}
|
|
630
|
-
var subscribableResourceSchema =
|
|
631
|
-
identifier:
|
|
632
|
-
label:
|
|
633
|
-
namespace:
|
|
634
|
-
suggestedEvents:
|
|
635
|
-
supportedEvents:
|
|
734
|
+
var subscribableResourceSchema = z8.object({
|
|
735
|
+
identifier: z8.string().min(1),
|
|
736
|
+
label: z8.string().min(1),
|
|
737
|
+
namespace: z8.string().min(1),
|
|
738
|
+
suggestedEvents: z8.array(eventTypeSchema).optional(),
|
|
739
|
+
supportedEvents: z8.array(eventTypeSchema),
|
|
636
740
|
type: resourceTypeSchema
|
|
637
741
|
}).strict();
|
|
638
|
-
var watchResultSchema =
|
|
639
|
-
events:
|
|
640
|
-
id:
|
|
742
|
+
var watchResultSchema = z8.object({
|
|
743
|
+
events: z8.array(eventTypeSchema).min(1),
|
|
744
|
+
id: z8.string().min(1)
|
|
641
745
|
}).strict();
|
|
642
|
-
var eventInputSchema =
|
|
643
|
-
eventKey:
|
|
746
|
+
var eventInputSchema = z8.object({
|
|
747
|
+
eventKey: z8.string().min(1),
|
|
644
748
|
eventType: eventTypeSchema,
|
|
645
|
-
identifier:
|
|
646
|
-
occurredAtMs:
|
|
647
|
-
terminal:
|
|
648
|
-
trustedSummary:
|
|
749
|
+
identifier: z8.string().min(1),
|
|
750
|
+
occurredAtMs: z8.number().finite(),
|
|
751
|
+
terminal: z8.boolean().optional(),
|
|
752
|
+
trustedSummary: z8.string().min(1).transform((value) => value.slice(0, EVENT_SUMMARY_MAX_LENGTH)),
|
|
649
753
|
/** Trusted structured facts. Prefer ids and urls over long prose. */
|
|
650
754
|
data: eventDataSchema.optional(),
|
|
651
|
-
untrustedText:
|
|
755
|
+
untrustedText: z8.string().transform((value) => value.slice(0, EVENT_TEXT_MAX_LENGTH)).optional()
|
|
652
756
|
}).strict();
|
|
653
757
|
var eventSchema = eventInputSchema.extend({
|
|
654
|
-
namespace:
|
|
758
|
+
namespace: z8.string().min(1)
|
|
655
759
|
});
|
|
656
760
|
|
|
657
761
|
// src/tasks.ts
|
|
658
|
-
import { z as
|
|
659
|
-
var pluginRunTranscriptProvenanceSchema =
|
|
660
|
-
authority:
|
|
762
|
+
import { z as z9 } from "zod";
|
|
763
|
+
var pluginRunTranscriptProvenanceSchema = z9.object({
|
|
764
|
+
authority: z9.enum(["instruction", "context"]),
|
|
661
765
|
actor: actorSchema.optional()
|
|
662
766
|
}).strict();
|
|
663
|
-
var pluginRunTranscriptEntrySchema =
|
|
664
|
-
|
|
665
|
-
type:
|
|
666
|
-
role:
|
|
667
|
-
text:
|
|
767
|
+
var pluginRunTranscriptEntrySchema = z9.discriminatedUnion("type", [
|
|
768
|
+
z9.object({
|
|
769
|
+
type: z9.literal("message"),
|
|
770
|
+
role: z9.enum(["user", "assistant"]),
|
|
771
|
+
text: z9.string().min(1),
|
|
668
772
|
provenance: pluginRunTranscriptProvenanceSchema.optional(),
|
|
669
|
-
isRunActor:
|
|
773
|
+
isRunActor: z9.boolean().optional()
|
|
670
774
|
}).strict(),
|
|
671
|
-
|
|
672
|
-
type:
|
|
673
|
-
toolName:
|
|
674
|
-
isError:
|
|
675
|
-
text:
|
|
775
|
+
z9.object({
|
|
776
|
+
type: z9.literal("toolResult"),
|
|
777
|
+
toolName: z9.string().min(1),
|
|
778
|
+
isError: z9.boolean(),
|
|
779
|
+
text: z9.string().min(1).optional()
|
|
676
780
|
}).strict()
|
|
677
781
|
]);
|
|
678
|
-
var pluginRunContextSchema =
|
|
782
|
+
var pluginRunContextSchema = z9.object({
|
|
679
783
|
/** User linked to the Actor, when known. */
|
|
680
|
-
actorUserId:
|
|
681
|
-
completedAtMs:
|
|
682
|
-
conversationId:
|
|
784
|
+
actorUserId: z9.string().min(1).optional(),
|
|
785
|
+
completedAtMs: z9.number().finite(),
|
|
786
|
+
conversationId: z9.string().min(1),
|
|
683
787
|
destination: destinationSchema,
|
|
684
788
|
/** Location associated with this Conversation. */
|
|
685
|
-
locationId:
|
|
789
|
+
locationId: z9.string().min(1).optional(),
|
|
686
790
|
/**
|
|
687
791
|
* All distinct actors annotated on this run's committed instruction-authority
|
|
688
792
|
* messages, in first-seen order. Attribution provenance only, never an
|
|
@@ -691,45 +795,45 @@ var pluginRunContextSchema = z8.object({
|
|
|
691
795
|
* exceed the actors visible in the transcript slice. Usually `[run.actor]`;
|
|
692
796
|
* possibly empty for system runs with no human instructions.
|
|
693
797
|
*/
|
|
694
|
-
actors:
|
|
798
|
+
actors: z9.array(actorSchema),
|
|
695
799
|
/**
|
|
696
800
|
* The single actor this run executes as. Absent only for actor-less legacy
|
|
697
801
|
* system records, so authority-sensitive plugins must fail closed.
|
|
698
802
|
*/
|
|
699
803
|
actor: actorSchema.optional(),
|
|
700
|
-
runId:
|
|
804
|
+
runId: z9.string().min(1),
|
|
701
805
|
source: sourceSchema,
|
|
702
|
-
transcript:
|
|
806
|
+
transcript: z9.array(pluginRunTranscriptEntrySchema)
|
|
703
807
|
}).strict();
|
|
704
808
|
|
|
705
809
|
// src/tools.ts
|
|
706
|
-
import { z as
|
|
810
|
+
import { z as z10 } from "zod";
|
|
707
811
|
var PluginToolInputError = class extends Error {
|
|
708
812
|
constructor(message, options) {
|
|
709
813
|
super(message, options);
|
|
710
814
|
this.name = "PluginToolInputError";
|
|
711
815
|
}
|
|
712
816
|
};
|
|
713
|
-
var pluginToolContentSchema =
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
type:
|
|
717
|
-
data:
|
|
718
|
-
mimeType:
|
|
817
|
+
var pluginToolContentSchema = z10.discriminatedUnion("type", [
|
|
818
|
+
z10.object({ type: z10.literal("text"), text: z10.string() }).strict(),
|
|
819
|
+
z10.object({
|
|
820
|
+
type: z10.literal("image"),
|
|
821
|
+
data: z10.string(),
|
|
822
|
+
mimeType: z10.string()
|
|
719
823
|
}).strict()
|
|
720
824
|
]);
|
|
721
|
-
var pluginToolContinuationSchema =
|
|
722
|
-
arguments:
|
|
723
|
-
reason:
|
|
825
|
+
var pluginToolContinuationSchema = z10.object({
|
|
826
|
+
arguments: z10.record(z10.string(), z10.unknown()),
|
|
827
|
+
reason: z10.string().min(1).optional()
|
|
724
828
|
}).strict();
|
|
725
|
-
var pluginToolOutputSchema =
|
|
829
|
+
var pluginToolOutputSchema = z10.object({
|
|
726
830
|
/** Object results to save and show with the next reply. Omit for silent updates. */
|
|
727
|
-
objectAnnotations:
|
|
728
|
-
target:
|
|
729
|
-
truncated:
|
|
831
|
+
objectAnnotations: z10.array(objectAnnotationSchema).optional(),
|
|
832
|
+
target: z10.string().min(1).optional(),
|
|
833
|
+
truncated: z10.boolean().optional(),
|
|
730
834
|
continuation: pluginToolContinuationSchema.optional()
|
|
731
835
|
}).passthrough();
|
|
732
|
-
var toolApprovalModeSchema =
|
|
836
|
+
var toolApprovalModeSchema = z10.enum(["auto", "review", "approve"]);
|
|
733
837
|
var REQUIRED_TOOL_ANNOTATION_KEYS = [
|
|
734
838
|
"destructiveHint",
|
|
735
839
|
"idempotentHint",
|
|
@@ -765,7 +869,7 @@ function createZodTool(definition, helperName) {
|
|
|
765
869
|
let modelInputSchema;
|
|
766
870
|
let modelOutputSchema;
|
|
767
871
|
try {
|
|
768
|
-
modelInputSchema =
|
|
872
|
+
modelInputSchema = z10.toJSONSchema(inputSchema);
|
|
769
873
|
} catch (error) {
|
|
770
874
|
throw new TypeError(
|
|
771
875
|
`${helperName}() inputSchema must be representable as JSON Schema.`,
|
|
@@ -773,7 +877,7 @@ function createZodTool(definition, helperName) {
|
|
|
773
877
|
);
|
|
774
878
|
}
|
|
775
879
|
try {
|
|
776
|
-
modelOutputSchema =
|
|
880
|
+
modelOutputSchema = z10.toJSONSchema(outputSchema);
|
|
777
881
|
} catch (error) {
|
|
778
882
|
throw new TypeError(
|
|
779
883
|
`${helperName}() outputSchema must be representable as JSON Schema.`,
|
|
@@ -799,7 +903,7 @@ function createZodTool(definition, helperName) {
|
|
|
799
903
|
);
|
|
800
904
|
if (isPluginToolOutputEnvelope(result)) {
|
|
801
905
|
return {
|
|
802
|
-
content:
|
|
906
|
+
content: z10.array(pluginToolContentSchema).parse(result.content),
|
|
803
907
|
details: outputSchema.parse(result.details)
|
|
804
908
|
};
|
|
805
909
|
}
|
|
@@ -816,76 +920,76 @@ function definePluginTool(definition) {
|
|
|
816
920
|
}
|
|
817
921
|
|
|
818
922
|
// src/operations.ts
|
|
819
|
-
import { z as
|
|
820
|
-
var pluginApiRouteRequestContextSchema =
|
|
821
|
-
auth:
|
|
822
|
-
user:
|
|
823
|
-
email:
|
|
824
|
-
emailVerified:
|
|
825
|
-
name:
|
|
923
|
+
import { z as z11 } from "zod";
|
|
924
|
+
var pluginApiRouteRequestContextSchema = z11.object({
|
|
925
|
+
auth: z11.object({
|
|
926
|
+
user: z11.object({
|
|
927
|
+
email: z11.string().nullable().optional(),
|
|
928
|
+
emailVerified: z11.boolean().optional(),
|
|
929
|
+
name: z11.string().nullable().optional()
|
|
826
930
|
}).strict()
|
|
827
931
|
}).strict(),
|
|
828
932
|
pluginName: nonBlankStringSchema
|
|
829
933
|
}).strict();
|
|
830
934
|
|
|
831
935
|
// src/credentials.ts
|
|
832
|
-
import { z as
|
|
833
|
-
var pluginProviderNameSchema =
|
|
834
|
-
var pluginGrantNameSchema =
|
|
835
|
-
var pluginGrantAccessSchema =
|
|
836
|
-
|
|
837
|
-
|
|
936
|
+
import { z as z12 } from "zod";
|
|
937
|
+
var pluginProviderNameSchema = z12.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
938
|
+
var pluginGrantNameSchema = z12.string().regex(/^[a-z][a-z0-9.-]*$/);
|
|
939
|
+
var pluginGrantAccessSchema = z12.union([
|
|
940
|
+
z12.literal("read"),
|
|
941
|
+
z12.literal("write")
|
|
838
942
|
]);
|
|
839
|
-
var pluginAuthorizationSchema =
|
|
943
|
+
var pluginAuthorizationSchema = z12.object({
|
|
840
944
|
provider: pluginProviderNameSchema,
|
|
841
945
|
scope: nonBlankStringSchema.optional(),
|
|
842
|
-
type:
|
|
946
|
+
type: z12.literal("oauth")
|
|
843
947
|
}).strict();
|
|
844
|
-
var pluginProviderAccountSchema =
|
|
948
|
+
var pluginProviderAccountSchema = z12.object({
|
|
845
949
|
displayName: nonBlankStringSchema.optional(),
|
|
846
950
|
handle: nonBlankStringSchema.optional(),
|
|
847
951
|
id: nonBlankStringSchema,
|
|
848
952
|
label: nonBlankStringSchema.optional(),
|
|
849
953
|
url: nonBlankStringSchema.optional()
|
|
850
954
|
}).strict();
|
|
851
|
-
var pluginStoredTokensSchema =
|
|
955
|
+
var pluginStoredTokensSchema = z12.object({
|
|
852
956
|
account: pluginProviderAccountSchema.optional(),
|
|
853
957
|
accessToken: nonBlankStringSchema,
|
|
854
|
-
expiresAt:
|
|
958
|
+
expiresAt: z12.number().finite().optional(),
|
|
855
959
|
refreshToken: nonBlankStringSchema,
|
|
856
|
-
refreshTokenExpiresAt:
|
|
960
|
+
refreshTokenExpiresAt: z12.number().finite().optional(),
|
|
857
961
|
scope: nonBlankStringSchema.optional()
|
|
858
962
|
}).strict();
|
|
859
|
-
var pluginGrantSchema =
|
|
963
|
+
var pluginGrantSchema = z12.object({
|
|
860
964
|
access: pluginGrantAccessSchema,
|
|
861
965
|
leaseScope: nonBlankStringSchema.optional(),
|
|
862
966
|
name: pluginGrantNameSchema,
|
|
863
967
|
reason: nonBlankStringSchema.optional(),
|
|
864
|
-
requirements:
|
|
968
|
+
requirements: z12.array(nonBlankStringSchema).min(1).optional()
|
|
865
969
|
}).strict();
|
|
866
|
-
var pluginCredentialHeaderTransformSchema =
|
|
867
|
-
domain:
|
|
868
|
-
headers:
|
|
970
|
+
var pluginCredentialHeaderTransformSchema = z12.object({
|
|
971
|
+
domain: z12.string().min(1),
|
|
972
|
+
headers: z12.record(z12.string(), z12.string()).refine((headers) => Object.keys(headers).length > 0)
|
|
869
973
|
}).strict();
|
|
870
|
-
var pluginCredentialLeaseSchema =
|
|
974
|
+
var pluginCredentialLeaseSchema = z12.object({
|
|
871
975
|
account: pluginProviderAccountSchema.optional(),
|
|
872
976
|
authorization: pluginAuthorizationSchema.optional(),
|
|
873
|
-
expiresAt:
|
|
874
|
-
headerTransforms:
|
|
977
|
+
expiresAt: z12.string().refine((value) => Number.isFinite(Date.parse(value))),
|
|
978
|
+
headerTransforms: z12.array(pluginCredentialHeaderTransformSchema).min(1)
|
|
875
979
|
}).strict();
|
|
876
|
-
var pluginCredentialResultSchema =
|
|
877
|
-
|
|
980
|
+
var pluginCredentialResultSchema = z12.discriminatedUnion("type", [
|
|
981
|
+
z12.object({
|
|
878
982
|
lease: pluginCredentialLeaseSchema,
|
|
879
|
-
type:
|
|
983
|
+
type: z12.literal("lease")
|
|
880
984
|
}).strict(),
|
|
881
|
-
|
|
985
|
+
z12.object({
|
|
882
986
|
authorization: pluginAuthorizationSchema.optional(),
|
|
883
987
|
message: nonBlankStringSchema,
|
|
884
|
-
type:
|
|
988
|
+
type: z12.literal("needed")
|
|
885
989
|
}).strict(),
|
|
886
|
-
|
|
990
|
+
z12.object({
|
|
887
991
|
message: nonBlankStringSchema,
|
|
888
|
-
type:
|
|
992
|
+
type: z12.literal("unavailable")
|
|
889
993
|
}).strict()
|
|
890
994
|
]);
|
|
891
995
|
var EgressAuthRequired = class extends Error {
|
|
@@ -1021,44 +1125,44 @@ function defineJuniorPlugin(plugin) {
|
|
|
1021
1125
|
}
|
|
1022
1126
|
|
|
1023
1127
|
// src/user-pages.ts
|
|
1024
|
-
import { z as
|
|
1128
|
+
import { z as z13 } from "zod";
|
|
1025
1129
|
var userPageIdSchema = nonBlankStringSchema.max(64).regex(/^[a-z][a-z0-9-]*$/);
|
|
1026
1130
|
var userPageLabelSchema = nonBlankStringSchema.max(80);
|
|
1027
1131
|
var userPageDescriptionSchema = nonBlankStringSchema.max(500);
|
|
1028
|
-
var userPageNavigationSchema =
|
|
1029
|
-
var pluginUserPageMetricSchema =
|
|
1132
|
+
var userPageNavigationSchema = z13.enum(["primary", "profile"]);
|
|
1133
|
+
var pluginUserPageMetricSchema = z13.object({
|
|
1030
1134
|
detail: nonBlankStringSchema.max(500).optional(),
|
|
1031
1135
|
label: nonBlankStringSchema.max(80),
|
|
1032
|
-
tone:
|
|
1136
|
+
tone: z13.enum(["good", "neutral", "warning"]).optional(),
|
|
1033
1137
|
value: nonBlankStringSchema.max(120)
|
|
1034
1138
|
}).strict();
|
|
1035
|
-
var pluginUserPageMetadataSchema =
|
|
1139
|
+
var pluginUserPageMetadataSchema = z13.object({
|
|
1036
1140
|
label: nonBlankStringSchema.max(80),
|
|
1037
1141
|
value: nonBlankStringSchema.max(500)
|
|
1038
1142
|
}).strict();
|
|
1039
|
-
var pluginUserPageActionSchema =
|
|
1143
|
+
var pluginUserPageActionSchema = z13.object({
|
|
1040
1144
|
confirmation: nonBlankStringSchema.max(500).optional(),
|
|
1041
1145
|
href: nonBlankStringSchema.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),
|
|
1042
1146
|
label: nonBlankStringSchema.max(80),
|
|
1043
|
-
method:
|
|
1044
|
-
tone:
|
|
1147
|
+
method: z13.literal("DELETE"),
|
|
1148
|
+
tone: z13.enum(["danger", "neutral"]).optional()
|
|
1045
1149
|
}).strict();
|
|
1046
|
-
var pluginUserPageRecordSchema =
|
|
1047
|
-
actions:
|
|
1150
|
+
var pluginUserPageRecordSchema = z13.object({
|
|
1151
|
+
actions: z13.array(pluginUserPageActionSchema).max(4).optional(),
|
|
1048
1152
|
description: nonBlankStringSchema.max(1e3).optional(),
|
|
1049
1153
|
id: nonBlankStringSchema.max(128),
|
|
1050
|
-
metadata:
|
|
1154
|
+
metadata: z13.array(pluginUserPageMetadataSchema).max(8).optional(),
|
|
1051
1155
|
title: nonBlankStringSchema.max(4e3)
|
|
1052
1156
|
}).strict();
|
|
1053
|
-
var pluginUserPageContentSchema =
|
|
1157
|
+
var pluginUserPageContentSchema = z13.object({
|
|
1054
1158
|
emptyText: nonBlankStringSchema.max(500).optional(),
|
|
1055
|
-
metrics:
|
|
1159
|
+
metrics: z13.array(pluginUserPageMetricSchema).max(6).optional(),
|
|
1056
1160
|
nextCursor: nonBlankStringSchema.max(1e3).optional(),
|
|
1057
|
-
records:
|
|
1161
|
+
records: z13.array(pluginUserPageRecordSchema).max(100),
|
|
1058
1162
|
searchPlaceholder: nonBlankStringSchema.max(120).optional(),
|
|
1059
|
-
type:
|
|
1163
|
+
type: z13.literal("list")
|
|
1060
1164
|
}).strict();
|
|
1061
|
-
var pluginUserPageLinkSchema =
|
|
1165
|
+
var pluginUserPageLinkSchema = z13.object({
|
|
1062
1166
|
description: userPageDescriptionSchema,
|
|
1063
1167
|
id: userPageIdSchema,
|
|
1064
1168
|
label: userPageLabelSchema,
|
|
@@ -1066,14 +1170,14 @@ var pluginUserPageLinkSchema = z12.object({
|
|
|
1066
1170
|
pluginDisplayName: nonBlankStringSchema.max(200),
|
|
1067
1171
|
pluginName: nonBlankStringSchema.max(100)
|
|
1068
1172
|
}).strict();
|
|
1069
|
-
var pluginUserPageLinksSchema =
|
|
1173
|
+
var pluginUserPageLinksSchema = z13.array(pluginUserPageLinkSchema);
|
|
1070
1174
|
var pluginUserPageCursorSchema = nonBlankStringSchema.max(1e3).optional();
|
|
1071
1175
|
var pluginUserPageFilterSchema = nonBlankStringSchema.max(64).optional();
|
|
1072
|
-
var pluginUserPageQuerySchema =
|
|
1073
|
-
var pluginUserPageInputSchema =
|
|
1176
|
+
var pluginUserPageQuerySchema = z13.string().trim().max(200).optional();
|
|
1177
|
+
var pluginUserPageInputSchema = z13.object({
|
|
1074
1178
|
cursor: pluginUserPageCursorSchema,
|
|
1075
1179
|
filter: pluginUserPageFilterSchema,
|
|
1076
|
-
limit:
|
|
1180
|
+
limit: z13.number().int().min(1).max(50),
|
|
1077
1181
|
query: pluginUserPageQuerySchema
|
|
1078
1182
|
}).strict();
|
|
1079
1183
|
export {
|
|
@@ -1130,6 +1234,8 @@ export {
|
|
|
1130
1234
|
nonBlankStringSchema,
|
|
1131
1235
|
normalizeEventIdentifier,
|
|
1132
1236
|
objectAnnotationSchema,
|
|
1237
|
+
objectFactFields,
|
|
1238
|
+
objectFactsSchema,
|
|
1133
1239
|
ownedObjectAnnotationSchema,
|
|
1134
1240
|
platformSchema,
|
|
1135
1241
|
pluginApiRouteRequestContextSchema,
|