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