@sentry/junior-plugin-api 0.227.0 → 0.228.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 +95 -15
- package/dist/index.js +366 -269
- package/package.json +3 -2
- package/src/object-icons.LICENSE +21 -0
- package/LICENSE +0 -201
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/object-annotations.ts
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z3 } from "zod";
|
|
3
3
|
|
|
4
4
|
// src/object-facts.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -30,7 +30,7 @@ var objectFactsSchema = z.discriminatedUnion("type", [
|
|
|
30
30
|
dueDate: z.iso.date().optional(),
|
|
31
31
|
labels: z.array(text).max(5).optional()
|
|
32
32
|
}),
|
|
33
|
-
// Deployments
|
|
33
|
+
// Deployments: never copy environment values or logs.
|
|
34
34
|
z.strictObject({
|
|
35
35
|
type: z.literal("deployment"),
|
|
36
36
|
project: text.optional(),
|
|
@@ -94,34 +94,123 @@ function objectFactFields(facts) {
|
|
|
94
94
|
return fields.slice(0, 4);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
// src/object-presentation.ts
|
|
98
|
+
import { z as z2 } from "zod";
|
|
99
|
+
var objectTypeSchema = z2.enum([
|
|
100
|
+
"task",
|
|
101
|
+
"code_change",
|
|
102
|
+
"automation",
|
|
103
|
+
"deployment",
|
|
104
|
+
"item"
|
|
105
|
+
]);
|
|
106
|
+
var objectTypeLabels = {
|
|
107
|
+
task: "Ticket",
|
|
108
|
+
code_change: "Code change",
|
|
109
|
+
automation: "Automation",
|
|
110
|
+
deployment: "Deployment",
|
|
111
|
+
item: "Item"
|
|
112
|
+
};
|
|
113
|
+
function objectPresentation(object) {
|
|
114
|
+
const type = object.objectType === "item" && object.facts?.type === "deployment" ? "deployment" : object.objectType;
|
|
115
|
+
const status = object.status?.toLowerCase();
|
|
116
|
+
let icon = {
|
|
117
|
+
task: "issue-opened",
|
|
118
|
+
code_change: "git-pull-request",
|
|
119
|
+
automation: "workflow",
|
|
120
|
+
deployment: "rocket",
|
|
121
|
+
item: "package"
|
|
122
|
+
}[type];
|
|
123
|
+
let tone = type === "automation" ? "info" : "neutral";
|
|
124
|
+
if (type === "code_change") {
|
|
125
|
+
if (status === "draft") icon = "git-pull-request-draft";
|
|
126
|
+
if (status === "closed") {
|
|
127
|
+
icon = "git-pull-request-closed";
|
|
128
|
+
tone = "danger";
|
|
129
|
+
}
|
|
130
|
+
if (status === "merged") {
|
|
131
|
+
icon = "git-merge";
|
|
132
|
+
tone = "accent";
|
|
133
|
+
}
|
|
134
|
+
if (status === "open") tone = "success";
|
|
135
|
+
} else if (type === "task") {
|
|
136
|
+
if (status === "closed") {
|
|
137
|
+
icon = "issue-closed";
|
|
138
|
+
tone = "accent";
|
|
139
|
+
}
|
|
140
|
+
if (status === "open") tone = "success";
|
|
141
|
+
} else if (type === "deployment") {
|
|
142
|
+
if (status === "ready" || status === "succeeded") tone = "success";
|
|
143
|
+
if (status === "error" || status === "failed") tone = "danger";
|
|
144
|
+
if (status === "building" || status === "in_progress") tone = "info";
|
|
145
|
+
}
|
|
146
|
+
if (status === "warning" || status === "blocked") tone = "warning";
|
|
147
|
+
return { icon, tone, label: objectTypeLabels[type] };
|
|
148
|
+
}
|
|
149
|
+
function objectIconPath(icon) {
|
|
150
|
+
return `/_junior/dashboard/object-icons/v1/${icon}.png`;
|
|
151
|
+
}
|
|
152
|
+
|
|
97
153
|
// src/object-annotations.ts
|
|
98
|
-
var objectAnnotationSchema =
|
|
99
|
-
kind:
|
|
100
|
-
key:
|
|
101
|
-
label:
|
|
102
|
-
objectType:
|
|
103
|
-
title:
|
|
104
|
-
url:
|
|
105
|
-
description:
|
|
106
|
-
status:
|
|
107
|
-
trigger:
|
|
108
|
-
warning:
|
|
109
|
-
displayType:
|
|
110
|
-
sourceUpdatedAt:
|
|
154
|
+
var objectAnnotationSchema = z3.object({
|
|
155
|
+
kind: z3.literal("object"),
|
|
156
|
+
key: z3.string().trim().min(1).max(256),
|
|
157
|
+
label: z3.string().trim().min(1).max(256),
|
|
158
|
+
objectType: objectTypeSchema,
|
|
159
|
+
title: z3.string().trim().min(1).max(512),
|
|
160
|
+
url: z3.url().max(2048).refine((value) => ["http:", "https:"].includes(new URL(value).protocol)).nullable(),
|
|
161
|
+
description: z3.string().max(4e3).optional(),
|
|
162
|
+
status: z3.string().trim().min(1).max(100).optional(),
|
|
163
|
+
trigger: z3.string().max(4e3).optional(),
|
|
164
|
+
warning: z3.string().max(1e3).optional(),
|
|
165
|
+
displayType: z3.string().trim().min(1).max(80).optional(),
|
|
166
|
+
sourceUpdatedAt: z3.iso.datetime({ offset: true }).optional(),
|
|
111
167
|
facts: objectFactsSchema.refine(
|
|
112
168
|
(facts) => new TextEncoder().encode(JSON.stringify(facts)).length <= 4096,
|
|
113
169
|
"Object facts must not exceed 4 KiB"
|
|
114
170
|
).optional()
|
|
115
171
|
}).strict().refine(
|
|
116
|
-
(annotation) => !annotation.facts || (annotation.facts.type === "deployment" ? annotation.objectType === "item" : annotation.facts.type === annotation.objectType),
|
|
172
|
+
(annotation) => !annotation.facts || (annotation.facts.type === "deployment" ? annotation.objectType === "deployment" || annotation.objectType === "item" : annotation.facts.type === annotation.objectType),
|
|
117
173
|
"Object facts must match the object type"
|
|
118
174
|
);
|
|
119
175
|
var ownedObjectAnnotationSchema = objectAnnotationSchema.safeExtend({
|
|
120
|
-
plugin:
|
|
176
|
+
plugin: z3.string().min(1)
|
|
121
177
|
});
|
|
122
178
|
|
|
179
|
+
// src/object-icons.ts
|
|
180
|
+
var objectIconPaths = {
|
|
181
|
+
"issue-opened": [
|
|
182
|
+
"M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z",
|
|
183
|
+
"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"
|
|
184
|
+
],
|
|
185
|
+
"issue-closed": [
|
|
186
|
+
"M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z",
|
|
187
|
+
"M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z"
|
|
188
|
+
],
|
|
189
|
+
"git-pull-request": [
|
|
190
|
+
"M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"
|
|
191
|
+
],
|
|
192
|
+
"git-pull-request-draft": [
|
|
193
|
+
"M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z"
|
|
194
|
+
],
|
|
195
|
+
"git-pull-request-closed": [
|
|
196
|
+
"M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"
|
|
197
|
+
],
|
|
198
|
+
"git-merge": [
|
|
199
|
+
"M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z"
|
|
200
|
+
],
|
|
201
|
+
workflow: [
|
|
202
|
+
"M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"
|
|
203
|
+
],
|
|
204
|
+
rocket: [
|
|
205
|
+
"M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"
|
|
206
|
+
],
|
|
207
|
+
package: [
|
|
208
|
+
"m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"
|
|
209
|
+
]
|
|
210
|
+
};
|
|
211
|
+
|
|
123
212
|
// src/annotations.ts
|
|
124
|
-
import { z as
|
|
213
|
+
import { z as z4 } from "zod";
|
|
125
214
|
function usesHttpProtocol(value) {
|
|
126
215
|
try {
|
|
127
216
|
const protocol = new URL(value).protocol;
|
|
@@ -130,19 +219,20 @@ function usesHttpProtocol(value) {
|
|
|
130
219
|
return false;
|
|
131
220
|
}
|
|
132
221
|
}
|
|
133
|
-
var resourceLinkAnnotationSchema =
|
|
134
|
-
kind:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
222
|
+
var resourceLinkAnnotationSchema = z4.object({
|
|
223
|
+
kind: z4.literal("resource_link"),
|
|
224
|
+
objectType: objectTypeSchema.optional(),
|
|
225
|
+
key: z4.string().trim().min(1).max(256),
|
|
226
|
+
label: z4.string().trim().min(1).max(256),
|
|
227
|
+
url: z4.string().url().max(2048).refine(usesHttpProtocol, "URL must use HTTP or HTTPS."),
|
|
228
|
+
description: z4.string().trim().min(1).max(512).optional(),
|
|
229
|
+
status: z4.enum(["open", "draft", "closed", "merged", "warning"]).optional()
|
|
140
230
|
}).strict();
|
|
141
|
-
var conversationAnnotationInputSchema =
|
|
231
|
+
var conversationAnnotationInputSchema = z4.discriminatedUnion("kind", [
|
|
142
232
|
resourceLinkAnnotationSchema,
|
|
143
233
|
objectAnnotationSchema
|
|
144
234
|
]);
|
|
145
|
-
var conversationSidebarIconSchema =
|
|
235
|
+
var conversationSidebarIconSchema = z4.enum([
|
|
146
236
|
"circle-dot",
|
|
147
237
|
"circle-dashed",
|
|
148
238
|
"circle-x",
|
|
@@ -150,37 +240,39 @@ var conversationSidebarIconSchema = z3.enum([
|
|
|
150
240
|
"git-pull-request",
|
|
151
241
|
"triangle-alert"
|
|
152
242
|
]);
|
|
153
|
-
var conversationSidebarAnnotationSchema =
|
|
243
|
+
var conversationSidebarAnnotationSchema = z4.object({
|
|
154
244
|
icon: conversationSidebarIconSchema.optional(),
|
|
155
|
-
|
|
156
|
-
|
|
245
|
+
objectType: objectTypeSchema.optional(),
|
|
246
|
+
status: z4.string().trim().min(1).max(100).optional(),
|
|
247
|
+
key: z4.string().trim().min(1).max(256),
|
|
248
|
+
label: z4.string().trim().min(1).max(256)
|
|
157
249
|
}).strict();
|
|
158
250
|
|
|
159
251
|
// src/code.ts
|
|
160
|
-
import { z as
|
|
161
|
-
var codeChangeStateSchema =
|
|
162
|
-
var codeChangeInputSchema =
|
|
163
|
-
closedAt:
|
|
164
|
-
conversationIds:
|
|
165
|
-
mergedAt:
|
|
166
|
-
number:
|
|
167
|
-
openedAt:
|
|
168
|
-
providerId:
|
|
169
|
-
repository:
|
|
170
|
-
name:
|
|
171
|
-
providerId:
|
|
172
|
-
url:
|
|
252
|
+
import { z as z5 } from "zod";
|
|
253
|
+
var codeChangeStateSchema = z5.enum(["closed", "merged", "open"]);
|
|
254
|
+
var codeChangeInputSchema = z5.object({
|
|
255
|
+
closedAt: z5.date().optional(),
|
|
256
|
+
conversationIds: z5.array(z5.string().min(1)).default([]),
|
|
257
|
+
mergedAt: z5.date().optional(),
|
|
258
|
+
number: z5.number().int().positive(),
|
|
259
|
+
openedAt: z5.date(),
|
|
260
|
+
providerId: z5.string().min(1),
|
|
261
|
+
repository: z5.object({
|
|
262
|
+
name: z5.string().min(1),
|
|
263
|
+
providerId: z5.string().min(1),
|
|
264
|
+
url: z5.string().url().optional()
|
|
173
265
|
}).strict(),
|
|
174
266
|
state: codeChangeStateSchema,
|
|
175
|
-
title:
|
|
176
|
-
updatedAt:
|
|
177
|
-
url:
|
|
267
|
+
title: z5.string().min(1).optional(),
|
|
268
|
+
updatedAt: z5.date(),
|
|
269
|
+
url: z5.string().url().optional()
|
|
178
270
|
}).strict();
|
|
179
271
|
|
|
180
272
|
// src/conversation-events.ts
|
|
181
|
-
import { z as
|
|
182
|
-
var conversationEventNameSchema =
|
|
183
|
-
var conversationEventIconSchema =
|
|
273
|
+
import { z as z6 } from "zod";
|
|
274
|
+
var conversationEventNameSchema = z6.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
275
|
+
var conversationEventIconSchema = z6.enum([
|
|
184
276
|
"activity",
|
|
185
277
|
"brain",
|
|
186
278
|
"calendar",
|
|
@@ -192,22 +284,22 @@ var conversationEventIconSchema = z5.enum([
|
|
|
192
284
|
"sparkles",
|
|
193
285
|
"warning"
|
|
194
286
|
]);
|
|
195
|
-
var conversationEventDetailSchema =
|
|
196
|
-
content:
|
|
197
|
-
description:
|
|
198
|
-
metadata:
|
|
199
|
-
title:
|
|
287
|
+
var conversationEventDetailSchema = z6.object({
|
|
288
|
+
content: z6.string().min(1).max(32 * 1024).optional(),
|
|
289
|
+
description: z6.string().trim().min(1).max(2e3).optional(),
|
|
290
|
+
metadata: z6.array(z6.string().trim().min(1).max(120)).max(8).optional(),
|
|
291
|
+
title: z6.string().trim().min(1).max(4e3)
|
|
200
292
|
}).strict();
|
|
201
|
-
var conversationEventPresentationSchema =
|
|
202
|
-
details:
|
|
293
|
+
var conversationEventPresentationSchema = z6.object({
|
|
294
|
+
details: z6.array(conversationEventDetailSchema).max(100).optional(),
|
|
203
295
|
icon: conversationEventIconSchema.optional(),
|
|
204
|
-
preview:
|
|
205
|
-
title:
|
|
296
|
+
preview: z6.string().trim().min(1).max(500).optional(),
|
|
297
|
+
title: z6.string().trim().min(1).max(120)
|
|
206
298
|
}).strict();
|
|
207
299
|
function defineConversationEvent(definition) {
|
|
208
|
-
const identity =
|
|
300
|
+
const identity = z6.object({
|
|
209
301
|
name: conversationEventNameSchema,
|
|
210
|
-
version:
|
|
302
|
+
version: z6.number().int().positive()
|
|
211
303
|
}).strict().parse({ name: definition.name, version: definition.version });
|
|
212
304
|
let eventDefinition;
|
|
213
305
|
const createEvent = (data) => ({
|
|
@@ -230,85 +322,85 @@ function defineConversationEvent(definition) {
|
|
|
230
322
|
}
|
|
231
323
|
|
|
232
324
|
// src/schemas.ts
|
|
233
|
-
import { z as
|
|
234
|
-
var slackTeamIdSchema =
|
|
235
|
-
var slackConversationIdSchema =
|
|
236
|
-
var localConversationIdSchema =
|
|
237
|
-
var actorUserIdSchema =
|
|
325
|
+
import { z as z7 } from "zod";
|
|
326
|
+
var slackTeamIdSchema = z7.string().regex(/^T[A-Z0-9]+$/);
|
|
327
|
+
var slackConversationIdSchema = z7.string().regex(/^(C|G|D)[A-Z0-9]+$/);
|
|
328
|
+
var localConversationIdSchema = z7.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/);
|
|
329
|
+
var actorUserIdSchema = z7.string().min(1).refine(
|
|
238
330
|
(value) => value === value.trim() && value.toLowerCase() !== "unknown"
|
|
239
331
|
);
|
|
240
332
|
var exactActorUserIdSchema = actorUserIdSchema;
|
|
241
|
-
var nonBlankStringSchema =
|
|
333
|
+
var nonBlankStringSchema = z7.string().refine((value) => value.trim().length > 0);
|
|
242
334
|
var exactNonBlankStringSchema = nonBlankStringSchema.refine(
|
|
243
335
|
(value) => value === value.trim()
|
|
244
336
|
);
|
|
245
|
-
var baseLocationSchema =
|
|
337
|
+
var baseLocationSchema = z7.object({
|
|
246
338
|
/** Stable SQL identity used by Location configuration and reporting. */
|
|
247
339
|
id: nonBlankStringSchema,
|
|
248
340
|
provider: exactNonBlankStringSchema
|
|
249
341
|
}).strict();
|
|
250
342
|
var slackLocationSchema = baseLocationSchema.extend({
|
|
251
|
-
provider:
|
|
343
|
+
provider: z7.literal("slack"),
|
|
252
344
|
teamId: slackTeamIdSchema,
|
|
253
345
|
channelId: slackConversationIdSchema,
|
|
254
346
|
threadTs: exactNonBlankStringSchema.optional()
|
|
255
347
|
}).strict();
|
|
256
|
-
var locationSchema =
|
|
348
|
+
var locationSchema = z7.discriminatedUnion("provider", [
|
|
257
349
|
slackLocationSchema
|
|
258
350
|
]);
|
|
259
|
-
var platformSchema =
|
|
260
|
-
var sourceVisibilitySchema =
|
|
261
|
-
var destinationVisibilitySchema =
|
|
262
|
-
var slackAddressSchema =
|
|
263
|
-
platform:
|
|
351
|
+
var platformSchema = z7.enum(["slack", "local"]);
|
|
352
|
+
var sourceVisibilitySchema = z7.enum(["public", "private"]);
|
|
353
|
+
var destinationVisibilitySchema = z7.enum(["public", "private"]);
|
|
354
|
+
var slackAddressSchema = z7.object({
|
|
355
|
+
platform: z7.literal("slack"),
|
|
264
356
|
teamId: slackTeamIdSchema,
|
|
265
357
|
channelId: slackConversationIdSchema,
|
|
266
358
|
threadTs: exactNonBlankStringSchema.optional()
|
|
267
359
|
}).strict();
|
|
268
360
|
var slackDestinationSchema = slackAddressSchema;
|
|
269
|
-
var localDestinationSchema =
|
|
270
|
-
platform:
|
|
361
|
+
var localDestinationSchema = z7.object({
|
|
362
|
+
platform: z7.literal("local"),
|
|
271
363
|
conversationId: localConversationIdSchema
|
|
272
364
|
}).strict();
|
|
273
|
-
var destinationSchema =
|
|
365
|
+
var destinationSchema = z7.discriminatedUnion("platform", [
|
|
274
366
|
slackDestinationSchema,
|
|
275
367
|
localDestinationSchema
|
|
276
368
|
]);
|
|
277
|
-
var taskOutcomeSchema =
|
|
278
|
-
action:
|
|
369
|
+
var taskOutcomeSchema = z7.object({
|
|
370
|
+
action: z7.literal("send_message"),
|
|
279
371
|
destination: slackDestinationSchema
|
|
280
372
|
}).strict();
|
|
281
|
-
var slackSourceSchema =
|
|
282
|
-
kind:
|
|
373
|
+
var slackSourceSchema = z7.object({
|
|
374
|
+
kind: z7.literal("slack"),
|
|
283
375
|
teamId: slackTeamIdSchema,
|
|
284
376
|
channelId: slackConversationIdSchema,
|
|
285
377
|
visibility: sourceVisibilitySchema,
|
|
286
378
|
messageTs: nonBlankStringSchema.optional(),
|
|
287
379
|
threadTs: nonBlankStringSchema.optional()
|
|
288
380
|
}).strict();
|
|
289
|
-
var localSourceSchema =
|
|
290
|
-
kind:
|
|
291
|
-
visibility:
|
|
381
|
+
var localSourceSchema = z7.object({
|
|
382
|
+
kind: z7.literal("local"),
|
|
383
|
+
visibility: z7.literal("private"),
|
|
292
384
|
conversationId: localConversationIdSchema
|
|
293
385
|
}).strict();
|
|
294
|
-
var webSourceSchema =
|
|
295
|
-
kind:
|
|
386
|
+
var webSourceSchema = z7.object({
|
|
387
|
+
kind: z7.literal("web"),
|
|
296
388
|
visibility: sourceVisibilitySchema,
|
|
297
389
|
// Web can continue any existing conversation id, including Slack roots.
|
|
298
390
|
conversationId: exactNonBlankStringSchema
|
|
299
391
|
}).strict();
|
|
300
|
-
var eventSourceSchema =
|
|
301
|
-
kind:
|
|
392
|
+
var eventSourceSchema = z7.object({
|
|
393
|
+
kind: z7.literal("event"),
|
|
302
394
|
eventKey: exactNonBlankStringSchema,
|
|
303
395
|
eventType: exactNonBlankStringSchema,
|
|
304
396
|
identifier: exactNonBlankStringSchema,
|
|
305
397
|
namespace: exactNonBlankStringSchema
|
|
306
398
|
}).strict();
|
|
307
|
-
var scheduledAutomationSourceSchema =
|
|
308
|
-
var eventAutomationSourceSchema =
|
|
309
|
-
var pluginDispatchSourceSchema =
|
|
310
|
-
var agentInvocationSourceSchema =
|
|
311
|
-
var currentSourceSchema =
|
|
399
|
+
var scheduledAutomationSourceSchema = z7.object({ kind: z7.literal("scheduled_automation") }).strict();
|
|
400
|
+
var eventAutomationSourceSchema = z7.object({ kind: z7.literal("event_automation") }).strict();
|
|
401
|
+
var pluginDispatchSourceSchema = z7.object({ kind: z7.literal("plugin_dispatch") }).strict();
|
|
402
|
+
var agentInvocationSourceSchema = z7.object({ kind: z7.literal("agent_invocation") }).strict();
|
|
403
|
+
var currentSourceSchema = z7.discriminatedUnion("kind", [
|
|
312
404
|
slackSourceSchema,
|
|
313
405
|
localSourceSchema,
|
|
314
406
|
webSourceSchema,
|
|
@@ -338,22 +430,22 @@ function normalizeStoredSource(value) {
|
|
|
338
430
|
const { location: _location, platform: kind, ...fields } = source;
|
|
339
431
|
return { ...fields, kind };
|
|
340
432
|
}
|
|
341
|
-
var sourceSchema =
|
|
433
|
+
var sourceSchema = z7.preprocess(
|
|
342
434
|
normalizeStoredSource,
|
|
343
435
|
currentSourceSchema
|
|
344
436
|
);
|
|
345
|
-
var pluginCredentialSubjectSchema =
|
|
437
|
+
var pluginCredentialSubjectSchema = z7.discriminatedUnion(
|
|
346
438
|
"allowedWhen",
|
|
347
439
|
[
|
|
348
|
-
|
|
349
|
-
type:
|
|
440
|
+
z7.object({
|
|
441
|
+
type: z7.literal("user"),
|
|
350
442
|
userId: exactActorUserIdSchema,
|
|
351
|
-
allowedWhen:
|
|
443
|
+
allowedWhen: z7.literal("private-direct-conversation")
|
|
352
444
|
}).strict(),
|
|
353
|
-
|
|
354
|
-
type:
|
|
445
|
+
z7.object({
|
|
446
|
+
type: z7.literal("user"),
|
|
355
447
|
userId: exactActorUserIdSchema,
|
|
356
|
-
allowedWhen:
|
|
448
|
+
allowedWhen: z7.literal("scheduled-automation"),
|
|
357
449
|
taskId: exactNonBlankStringSchema
|
|
358
450
|
}).strict()
|
|
359
451
|
]
|
|
@@ -364,30 +456,30 @@ var actorProfileSchema = {
|
|
|
364
456
|
userId: exactActorUserIdSchema,
|
|
365
457
|
userName: nonBlankStringSchema.optional()
|
|
366
458
|
};
|
|
367
|
-
var slackActorSchema =
|
|
459
|
+
var slackActorSchema = z7.object({
|
|
368
460
|
...actorProfileSchema,
|
|
369
|
-
platform:
|
|
461
|
+
platform: z7.literal("slack"),
|
|
370
462
|
teamId: slackTeamIdSchema
|
|
371
463
|
}).strict();
|
|
372
|
-
var localActorSchema =
|
|
464
|
+
var localActorSchema = z7.object({
|
|
373
465
|
...actorProfileSchema,
|
|
374
|
-
platform:
|
|
466
|
+
platform: z7.literal("local")
|
|
375
467
|
}).strict();
|
|
376
|
-
var webActorSchema =
|
|
468
|
+
var webActorSchema = z7.object({
|
|
377
469
|
...actorProfileSchema,
|
|
378
|
-
platform:
|
|
470
|
+
platform: z7.literal("web")
|
|
379
471
|
}).strict();
|
|
380
|
-
var systemActorSchema =
|
|
381
|
-
platform:
|
|
472
|
+
var systemActorSchema = z7.object({
|
|
473
|
+
platform: z7.literal("system"),
|
|
382
474
|
name: exactActorUserIdSchema
|
|
383
475
|
}).strict();
|
|
384
|
-
var actorSchema =
|
|
476
|
+
var actorSchema = z7.discriminatedUnion("platform", [
|
|
385
477
|
slackActorSchema,
|
|
386
478
|
localActorSchema,
|
|
387
479
|
webActorSchema,
|
|
388
480
|
systemActorSchema
|
|
389
481
|
]);
|
|
390
|
-
var identitySchema =
|
|
482
|
+
var identitySchema = z7.object({
|
|
391
483
|
displayName: nonBlankStringSchema.optional(),
|
|
392
484
|
handle: nonBlankStringSchema.optional(),
|
|
393
485
|
id: exactNonBlankStringSchema,
|
|
@@ -395,17 +487,17 @@ var identitySchema = z6.object({
|
|
|
395
487
|
providerSubjectId: exactNonBlankStringSchema,
|
|
396
488
|
providerTenantId: exactNonBlankStringSchema.optional()
|
|
397
489
|
}).strict();
|
|
398
|
-
var userSchema =
|
|
490
|
+
var userSchema = z7.object({
|
|
399
491
|
displayName: nonBlankStringSchema.optional(),
|
|
400
492
|
email: nonBlankStringSchema.max(320),
|
|
401
493
|
id: exactNonBlankStringSchema,
|
|
402
|
-
identities:
|
|
494
|
+
identities: z7.array(identitySchema).max(100)
|
|
403
495
|
}).strict();
|
|
404
|
-
var dispatchMetadataSchema =
|
|
496
|
+
var dispatchMetadataSchema = z7.record(z7.string(), z7.string()).superRefine((metadata, ctx) => {
|
|
405
497
|
const entries = Object.entries(metadata);
|
|
406
498
|
if (entries.length > 20) {
|
|
407
499
|
ctx.addIssue({
|
|
408
|
-
code:
|
|
500
|
+
code: z7.ZodIssueCode.custom,
|
|
409
501
|
message: "Dispatch metadata has too many keys"
|
|
410
502
|
});
|
|
411
503
|
return;
|
|
@@ -413,7 +505,7 @@ var dispatchMetadataSchema = z6.record(z6.string(), z6.string()).superRefine((me
|
|
|
413
505
|
for (const [key, value] of entries) {
|
|
414
506
|
if (!key.trim()) {
|
|
415
507
|
ctx.addIssue({
|
|
416
|
-
code:
|
|
508
|
+
code: z7.ZodIssueCode.custom,
|
|
417
509
|
message: "Dispatch metadata values must be strings",
|
|
418
510
|
path: [key]
|
|
419
511
|
});
|
|
@@ -421,44 +513,44 @@ var dispatchMetadataSchema = z6.record(z6.string(), z6.string()).superRefine((me
|
|
|
421
513
|
}
|
|
422
514
|
if (key.length > 128) {
|
|
423
515
|
ctx.addIssue({
|
|
424
|
-
code:
|
|
516
|
+
code: z7.ZodIssueCode.custom,
|
|
425
517
|
message: "Dispatch metadata key exceeds the maximum length",
|
|
426
518
|
path: [key]
|
|
427
519
|
});
|
|
428
520
|
}
|
|
429
521
|
if (/[\r\n]/.test(key)) {
|
|
430
522
|
ctx.addIssue({
|
|
431
|
-
code:
|
|
523
|
+
code: z7.ZodIssueCode.custom,
|
|
432
524
|
message: "Dispatch metadata keys must be single-line strings",
|
|
433
525
|
path: [key]
|
|
434
526
|
});
|
|
435
527
|
}
|
|
436
528
|
if (/[\r\n]/.test(value)) {
|
|
437
529
|
ctx.addIssue({
|
|
438
|
-
code:
|
|
530
|
+
code: z7.ZodIssueCode.custom,
|
|
439
531
|
message: "Dispatch metadata values must be single-line strings",
|
|
440
532
|
path: [key]
|
|
441
533
|
});
|
|
442
534
|
}
|
|
443
535
|
if (value.length > 512) {
|
|
444
536
|
ctx.addIssue({
|
|
445
|
-
code:
|
|
537
|
+
code: z7.ZodIssueCode.custom,
|
|
446
538
|
message: "Dispatch metadata value exceeds the maximum length",
|
|
447
539
|
path: [key]
|
|
448
540
|
});
|
|
449
541
|
}
|
|
450
542
|
}
|
|
451
543
|
});
|
|
452
|
-
var replyAttributionSchema =
|
|
453
|
-
label: exactNonBlankStringSchema.pipe(
|
|
454
|
-
detail: exactNonBlankStringSchema.pipe(
|
|
544
|
+
var replyAttributionSchema = z7.object({
|
|
545
|
+
label: exactNonBlankStringSchema.pipe(z7.string().max(48)).refine((value) => !/[\r\n]/.test(value)),
|
|
546
|
+
detail: exactNonBlankStringSchema.pipe(z7.string().max(128)).refine((value) => !/[\r\n]/.test(value)).optional()
|
|
455
547
|
}).strict();
|
|
456
|
-
var dispatchOptionsSchema =
|
|
457
|
-
idempotencyKey: nonBlankStringSchema.pipe(
|
|
548
|
+
var dispatchOptionsSchema = z7.object({
|
|
549
|
+
idempotencyKey: nonBlankStringSchema.pipe(z7.string().max(512)),
|
|
458
550
|
credentialSubject: pluginCredentialSubjectSchema.optional(),
|
|
459
551
|
destination: slackDestinationSchema,
|
|
460
552
|
destinationVisibility: destinationVisibilitySchema,
|
|
461
|
-
input: nonBlankStringSchema.pipe(
|
|
553
|
+
input: nonBlankStringSchema.pipe(z7.string().max(32e3)),
|
|
462
554
|
metadata: dispatchMetadataSchema.optional(),
|
|
463
555
|
replyAttribution: replyAttributionSchema.optional()
|
|
464
556
|
}).strict();
|
|
@@ -526,15 +618,15 @@ function isSlackDestination(destination) {
|
|
|
526
618
|
}
|
|
527
619
|
|
|
528
620
|
// src/prompt.ts
|
|
529
|
-
import { z as
|
|
530
|
-
var promptContextKindSchema =
|
|
531
|
-
var promptMessageSchema =
|
|
532
|
-
text:
|
|
621
|
+
import { z as z8 } from "zod";
|
|
622
|
+
var promptContextKindSchema = z8.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/);
|
|
623
|
+
var promptMessageSchema = z8.object({
|
|
624
|
+
text: z8.string().trim().min(1).max(8e3)
|
|
533
625
|
}).strict();
|
|
534
|
-
var promptContextSchema =
|
|
626
|
+
var promptContextSchema = z8.object({
|
|
535
627
|
kind: promptContextKindSchema,
|
|
536
|
-
version:
|
|
537
|
-
content:
|
|
628
|
+
version: z8.number().int().positive(),
|
|
629
|
+
content: z8.record(z8.string(), z8.unknown())
|
|
538
630
|
}).strict();
|
|
539
631
|
function definePromptContext(definition) {
|
|
540
632
|
const identity = promptContextSchema.pick({ kind: true, version: true }).parse({ kind: definition.kind, version: definition.version });
|
|
@@ -548,13 +640,13 @@ function definePromptContext(definition) {
|
|
|
548
640
|
}
|
|
549
641
|
|
|
550
642
|
// src/events.ts
|
|
551
|
-
import { z as
|
|
643
|
+
import { z as z9 } from "zod";
|
|
552
644
|
var EVENT_SUMMARY_MAX_LENGTH = 4e3;
|
|
553
645
|
var EVENT_TEXT_MAX_LENGTH = 8e3;
|
|
554
646
|
var EVENT_DATA_MAX_KEYS = 32;
|
|
555
647
|
var EVENT_DATA_MAX_JSON_BYTES = 4e3;
|
|
556
648
|
var EVENT_GUIDANCE_MAX_LENGTH = 1e3;
|
|
557
|
-
var eventDataSchema =
|
|
649
|
+
var eventDataSchema = z9.record(z9.string(), z9.unknown()).superRefine((value, context) => {
|
|
558
650
|
const keys = Object.keys(value);
|
|
559
651
|
if (keys.length > EVENT_DATA_MAX_KEYS) {
|
|
560
652
|
context.addIssue({
|
|
@@ -572,17 +664,17 @@ var eventDataSchema = z8.record(z8.string(), z8.unknown()).superRefine((value, c
|
|
|
572
664
|
});
|
|
573
665
|
}
|
|
574
666
|
});
|
|
575
|
-
var eventTypeSchema =
|
|
667
|
+
var eventTypeSchema = z9.string().regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+$/).describe(
|
|
576
668
|
"Canonical dotted event type, such as issue.closed or pull_request.review.changes_requested."
|
|
577
669
|
);
|
|
578
|
-
var resourceTypeSchema =
|
|
670
|
+
var resourceTypeSchema = z9.string().regex(/^[a-z][a-z0-9_]*$/).describe(
|
|
579
671
|
"Canonical plugin-defined resource type, such as issue or pull_request."
|
|
580
672
|
);
|
|
581
673
|
var EVENT_MATCH_FIELD_NAME = /^[a-z][a-zA-Z0-9]*$/;
|
|
582
|
-
var eventMatchFieldSchema =
|
|
583
|
-
kind:
|
|
584
|
-
description:
|
|
585
|
-
enum:
|
|
674
|
+
var eventMatchFieldSchema = z9.object({
|
|
675
|
+
kind: z9.enum(["boolean", "string", "number"]),
|
|
676
|
+
description: z9.string().trim().min(1).max(200),
|
|
677
|
+
enum: z9.array(z9.string().min(1)).min(1).optional()
|
|
586
678
|
}).strict().superRefine((field, context) => {
|
|
587
679
|
if (field.enum && field.kind !== "string") {
|
|
588
680
|
context.addIssue({
|
|
@@ -592,7 +684,7 @@ var eventMatchFieldSchema = z8.object({
|
|
|
592
684
|
});
|
|
593
685
|
}
|
|
594
686
|
});
|
|
595
|
-
var eventMatchFieldsSchema =
|
|
687
|
+
var eventMatchFieldsSchema = z9.record(z9.string().regex(EVENT_MATCH_FIELD_NAME), eventMatchFieldSchema).superRefine((fields, context) => {
|
|
596
688
|
if (Object.keys(fields).length > EVENT_DATA_MAX_KEYS) {
|
|
597
689
|
context.addIssue({
|
|
598
690
|
code: "custom",
|
|
@@ -600,13 +692,13 @@ var eventMatchFieldsSchema = z8.record(z8.string().regex(EVENT_MATCH_FIELD_NAME)
|
|
|
600
692
|
});
|
|
601
693
|
}
|
|
602
694
|
});
|
|
603
|
-
var eventMatchSchema =
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
695
|
+
var eventMatchSchema = z9.record(
|
|
696
|
+
z9.string().regex(EVENT_MATCH_FIELD_NAME),
|
|
697
|
+
z9.union([
|
|
698
|
+
z9.boolean(),
|
|
699
|
+
z9.number().finite(),
|
|
700
|
+
z9.string().min(1),
|
|
701
|
+
z9.array(z9.union([z9.number().finite(), z9.string().min(1)])).min(1)
|
|
610
702
|
])
|
|
611
703
|
).superRefine((match, context) => {
|
|
612
704
|
if (Object.keys(match).length > EVENT_DATA_MAX_KEYS) {
|
|
@@ -657,14 +749,14 @@ function eventMatches(match, data) {
|
|
|
657
749
|
}
|
|
658
750
|
return true;
|
|
659
751
|
}
|
|
660
|
-
var pluginEventTypeSchema =
|
|
752
|
+
var pluginEventTypeSchema = z9.object({
|
|
661
753
|
type: resourceTypeSchema,
|
|
662
|
-
supportedEvents:
|
|
663
|
-
suggestedEvents:
|
|
754
|
+
supportedEvents: z9.array(eventTypeSchema).min(1),
|
|
755
|
+
suggestedEvents: z9.array(eventTypeSchema).optional(),
|
|
664
756
|
matchFields: eventMatchFieldsSchema.optional(),
|
|
665
|
-
guidance:
|
|
757
|
+
guidance: z9.record(
|
|
666
758
|
eventTypeSchema,
|
|
667
|
-
|
|
759
|
+
z9.string().trim().min(1).max(EVENT_GUIDANCE_MAX_LENGTH)
|
|
668
760
|
).optional()
|
|
669
761
|
}).strict().superRefine((resourceType, context) => {
|
|
670
762
|
const supported = /* @__PURE__ */ new Set();
|
|
@@ -706,10 +798,10 @@ var pluginEventTypeSchema = z8.object({
|
|
|
706
798
|
suggested.add(eventType);
|
|
707
799
|
});
|
|
708
800
|
});
|
|
709
|
-
var pluginEventsSchema =
|
|
710
|
-
resourceTypes:
|
|
711
|
-
isEnabled:
|
|
712
|
-
normalizeIdentifier:
|
|
801
|
+
var pluginEventsSchema = z9.object({
|
|
802
|
+
resourceTypes: z9.array(pluginEventTypeSchema).min(1),
|
|
803
|
+
isEnabled: z9.function({ input: [], output: z9.boolean() }).optional(),
|
|
804
|
+
normalizeIdentifier: z9.function({ input: [z9.string()], output: z9.string() }).optional()
|
|
713
805
|
}).strict().superRefine((registration, context) => {
|
|
714
806
|
const seen = /* @__PURE__ */ new Set();
|
|
715
807
|
registration.resourceTypes.forEach((resourceType, index) => {
|
|
@@ -731,62 +823,63 @@ function normalizeEventIdentifier(registration, identifier) {
|
|
|
731
823
|
}
|
|
732
824
|
return normalized;
|
|
733
825
|
}
|
|
734
|
-
var subscribableResourceSchema =
|
|
735
|
-
identifier:
|
|
736
|
-
label:
|
|
737
|
-
namespace:
|
|
738
|
-
suggestedEvents:
|
|
739
|
-
supportedEvents:
|
|
826
|
+
var subscribableResourceSchema = z9.object({
|
|
827
|
+
identifier: z9.string().min(1),
|
|
828
|
+
label: z9.string().min(1),
|
|
829
|
+
namespace: z9.string().min(1),
|
|
830
|
+
suggestedEvents: z9.array(eventTypeSchema).optional(),
|
|
831
|
+
supportedEvents: z9.array(eventTypeSchema),
|
|
740
832
|
type: resourceTypeSchema
|
|
741
833
|
}).strict();
|
|
742
|
-
var watchResultSchema =
|
|
743
|
-
events:
|
|
744
|
-
id:
|
|
834
|
+
var watchResultSchema = z9.object({
|
|
835
|
+
events: z9.array(eventTypeSchema).min(1),
|
|
836
|
+
id: z9.string().min(1)
|
|
745
837
|
}).strict();
|
|
746
|
-
var eventInputSchema =
|
|
747
|
-
|
|
838
|
+
var eventInputSchema = z9.object({
|
|
839
|
+
objectType: objectTypeSchema.optional(),
|
|
840
|
+
eventKey: z9.string().min(1),
|
|
748
841
|
eventType: eventTypeSchema,
|
|
749
|
-
identifier:
|
|
750
|
-
occurredAtMs:
|
|
751
|
-
terminal:
|
|
752
|
-
trustedSummary:
|
|
842
|
+
identifier: z9.string().min(1),
|
|
843
|
+
occurredAtMs: z9.number().finite(),
|
|
844
|
+
terminal: z9.boolean().optional(),
|
|
845
|
+
trustedSummary: z9.string().min(1).transform((value) => value.slice(0, EVENT_SUMMARY_MAX_LENGTH)),
|
|
753
846
|
/** Trusted structured facts. Prefer ids and urls over long prose. */
|
|
754
847
|
data: eventDataSchema.optional(),
|
|
755
|
-
untrustedText:
|
|
848
|
+
untrustedText: z9.string().transform((value) => value.slice(0, EVENT_TEXT_MAX_LENGTH)).optional()
|
|
756
849
|
}).strict();
|
|
757
850
|
var eventSchema = eventInputSchema.extend({
|
|
758
|
-
namespace:
|
|
851
|
+
namespace: z9.string().min(1)
|
|
759
852
|
});
|
|
760
853
|
|
|
761
854
|
// src/tasks.ts
|
|
762
|
-
import { z as
|
|
763
|
-
var pluginRunTranscriptProvenanceSchema =
|
|
764
|
-
authority:
|
|
855
|
+
import { z as z10 } from "zod";
|
|
856
|
+
var pluginRunTranscriptProvenanceSchema = z10.object({
|
|
857
|
+
authority: z10.enum(["instruction", "context"]),
|
|
765
858
|
actor: actorSchema.optional()
|
|
766
859
|
}).strict();
|
|
767
|
-
var pluginRunTranscriptEntrySchema =
|
|
768
|
-
|
|
769
|
-
type:
|
|
770
|
-
role:
|
|
771
|
-
text:
|
|
860
|
+
var pluginRunTranscriptEntrySchema = z10.discriminatedUnion("type", [
|
|
861
|
+
z10.object({
|
|
862
|
+
type: z10.literal("message"),
|
|
863
|
+
role: z10.enum(["user", "assistant"]),
|
|
864
|
+
text: z10.string().min(1),
|
|
772
865
|
provenance: pluginRunTranscriptProvenanceSchema.optional(),
|
|
773
|
-
isRunActor:
|
|
866
|
+
isRunActor: z10.boolean().optional()
|
|
774
867
|
}).strict(),
|
|
775
|
-
|
|
776
|
-
type:
|
|
777
|
-
toolName:
|
|
778
|
-
isError:
|
|
779
|
-
text:
|
|
868
|
+
z10.object({
|
|
869
|
+
type: z10.literal("toolResult"),
|
|
870
|
+
toolName: z10.string().min(1),
|
|
871
|
+
isError: z10.boolean(),
|
|
872
|
+
text: z10.string().min(1).optional()
|
|
780
873
|
}).strict()
|
|
781
874
|
]);
|
|
782
|
-
var pluginRunContextSchema =
|
|
875
|
+
var pluginRunContextSchema = z10.object({
|
|
783
876
|
/** User linked to the Actor, when known. */
|
|
784
|
-
actorUserId:
|
|
785
|
-
completedAtMs:
|
|
786
|
-
conversationId:
|
|
877
|
+
actorUserId: z10.string().min(1).optional(),
|
|
878
|
+
completedAtMs: z10.number().finite(),
|
|
879
|
+
conversationId: z10.string().min(1),
|
|
787
880
|
destination: destinationSchema,
|
|
788
881
|
/** Location associated with this Conversation. */
|
|
789
|
-
locationId:
|
|
882
|
+
locationId: z10.string().min(1).optional(),
|
|
790
883
|
/**
|
|
791
884
|
* All distinct actors annotated on this run's committed instruction-authority
|
|
792
885
|
* messages, in first-seen order. Attribution provenance only, never an
|
|
@@ -795,45 +888,45 @@ var pluginRunContextSchema = z9.object({
|
|
|
795
888
|
* exceed the actors visible in the transcript slice. Usually `[run.actor]`;
|
|
796
889
|
* possibly empty for system runs with no human instructions.
|
|
797
890
|
*/
|
|
798
|
-
actors:
|
|
891
|
+
actors: z10.array(actorSchema),
|
|
799
892
|
/**
|
|
800
893
|
* The single actor this run executes as. Absent only for actor-less legacy
|
|
801
894
|
* system records, so authority-sensitive plugins must fail closed.
|
|
802
895
|
*/
|
|
803
896
|
actor: actorSchema.optional(),
|
|
804
|
-
runId:
|
|
897
|
+
runId: z10.string().min(1),
|
|
805
898
|
source: sourceSchema,
|
|
806
|
-
transcript:
|
|
899
|
+
transcript: z10.array(pluginRunTranscriptEntrySchema)
|
|
807
900
|
}).strict();
|
|
808
901
|
|
|
809
902
|
// src/tools.ts
|
|
810
|
-
import { z as
|
|
903
|
+
import { z as z11 } from "zod";
|
|
811
904
|
var PluginToolInputError = class extends Error {
|
|
812
905
|
constructor(message, options) {
|
|
813
906
|
super(message, options);
|
|
814
907
|
this.name = "PluginToolInputError";
|
|
815
908
|
}
|
|
816
909
|
};
|
|
817
|
-
var pluginToolContentSchema =
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
type:
|
|
821
|
-
data:
|
|
822
|
-
mimeType:
|
|
910
|
+
var pluginToolContentSchema = z11.discriminatedUnion("type", [
|
|
911
|
+
z11.object({ type: z11.literal("text"), text: z11.string() }).strict(),
|
|
912
|
+
z11.object({
|
|
913
|
+
type: z11.literal("image"),
|
|
914
|
+
data: z11.string(),
|
|
915
|
+
mimeType: z11.string()
|
|
823
916
|
}).strict()
|
|
824
917
|
]);
|
|
825
|
-
var pluginToolContinuationSchema =
|
|
826
|
-
arguments:
|
|
827
|
-
reason:
|
|
918
|
+
var pluginToolContinuationSchema = z11.object({
|
|
919
|
+
arguments: z11.record(z11.string(), z11.unknown()),
|
|
920
|
+
reason: z11.string().min(1).optional()
|
|
828
921
|
}).strict();
|
|
829
|
-
var pluginToolOutputSchema =
|
|
922
|
+
var pluginToolOutputSchema = z11.object({
|
|
830
923
|
/** Object results to save and show with the next reply. Omit for silent updates. */
|
|
831
|
-
objectAnnotations:
|
|
832
|
-
target:
|
|
833
|
-
truncated:
|
|
924
|
+
objectAnnotations: z11.array(objectAnnotationSchema).optional(),
|
|
925
|
+
target: z11.string().min(1).optional(),
|
|
926
|
+
truncated: z11.boolean().optional(),
|
|
834
927
|
continuation: pluginToolContinuationSchema.optional()
|
|
835
928
|
}).passthrough();
|
|
836
|
-
var toolApprovalModeSchema =
|
|
929
|
+
var toolApprovalModeSchema = z11.enum(["auto", "review", "approve"]);
|
|
837
930
|
var REQUIRED_TOOL_ANNOTATION_KEYS = [
|
|
838
931
|
"destructiveHint",
|
|
839
932
|
"idempotentHint",
|
|
@@ -869,7 +962,7 @@ function createZodTool(definition, helperName) {
|
|
|
869
962
|
let modelInputSchema;
|
|
870
963
|
let modelOutputSchema;
|
|
871
964
|
try {
|
|
872
|
-
modelInputSchema =
|
|
965
|
+
modelInputSchema = z11.toJSONSchema(inputSchema);
|
|
873
966
|
} catch (error) {
|
|
874
967
|
throw new TypeError(
|
|
875
968
|
`${helperName}() inputSchema must be representable as JSON Schema.`,
|
|
@@ -877,7 +970,7 @@ function createZodTool(definition, helperName) {
|
|
|
877
970
|
);
|
|
878
971
|
}
|
|
879
972
|
try {
|
|
880
|
-
modelOutputSchema =
|
|
973
|
+
modelOutputSchema = z11.toJSONSchema(outputSchema);
|
|
881
974
|
} catch (error) {
|
|
882
975
|
throw new TypeError(
|
|
883
976
|
`${helperName}() outputSchema must be representable as JSON Schema.`,
|
|
@@ -903,7 +996,7 @@ function createZodTool(definition, helperName) {
|
|
|
903
996
|
);
|
|
904
997
|
if (isPluginToolOutputEnvelope(result)) {
|
|
905
998
|
return {
|
|
906
|
-
content:
|
|
999
|
+
content: z11.array(pluginToolContentSchema).parse(result.content),
|
|
907
1000
|
details: outputSchema.parse(result.details)
|
|
908
1001
|
};
|
|
909
1002
|
}
|
|
@@ -920,76 +1013,76 @@ function definePluginTool(definition) {
|
|
|
920
1013
|
}
|
|
921
1014
|
|
|
922
1015
|
// src/operations.ts
|
|
923
|
-
import { z as
|
|
924
|
-
var pluginApiRouteRequestContextSchema =
|
|
925
|
-
auth:
|
|
926
|
-
user:
|
|
927
|
-
email:
|
|
928
|
-
emailVerified:
|
|
929
|
-
name:
|
|
1016
|
+
import { z as z12 } from "zod";
|
|
1017
|
+
var pluginApiRouteRequestContextSchema = z12.object({
|
|
1018
|
+
auth: z12.object({
|
|
1019
|
+
user: z12.object({
|
|
1020
|
+
email: z12.string().nullable().optional(),
|
|
1021
|
+
emailVerified: z12.boolean().optional(),
|
|
1022
|
+
name: z12.string().nullable().optional()
|
|
930
1023
|
}).strict()
|
|
931
1024
|
}).strict(),
|
|
932
1025
|
pluginName: nonBlankStringSchema
|
|
933
1026
|
}).strict();
|
|
934
1027
|
|
|
935
1028
|
// src/credentials.ts
|
|
936
|
-
import { z as
|
|
937
|
-
var pluginProviderNameSchema =
|
|
938
|
-
var pluginGrantNameSchema =
|
|
939
|
-
var pluginGrantAccessSchema =
|
|
940
|
-
|
|
941
|
-
|
|
1029
|
+
import { z as z13 } from "zod";
|
|
1030
|
+
var pluginProviderNameSchema = z13.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
1031
|
+
var pluginGrantNameSchema = z13.string().regex(/^[a-z][a-z0-9.-]*$/);
|
|
1032
|
+
var pluginGrantAccessSchema = z13.union([
|
|
1033
|
+
z13.literal("read"),
|
|
1034
|
+
z13.literal("write")
|
|
942
1035
|
]);
|
|
943
|
-
var pluginAuthorizationSchema =
|
|
1036
|
+
var pluginAuthorizationSchema = z13.object({
|
|
944
1037
|
provider: pluginProviderNameSchema,
|
|
945
1038
|
scope: nonBlankStringSchema.optional(),
|
|
946
|
-
type:
|
|
1039
|
+
type: z13.literal("oauth")
|
|
947
1040
|
}).strict();
|
|
948
|
-
var pluginProviderAccountSchema =
|
|
1041
|
+
var pluginProviderAccountSchema = z13.object({
|
|
949
1042
|
displayName: nonBlankStringSchema.optional(),
|
|
950
1043
|
handle: nonBlankStringSchema.optional(),
|
|
951
1044
|
id: nonBlankStringSchema,
|
|
952
1045
|
label: nonBlankStringSchema.optional(),
|
|
953
1046
|
url: nonBlankStringSchema.optional()
|
|
954
1047
|
}).strict();
|
|
955
|
-
var pluginStoredTokensSchema =
|
|
1048
|
+
var pluginStoredTokensSchema = z13.object({
|
|
956
1049
|
account: pluginProviderAccountSchema.optional(),
|
|
957
1050
|
accessToken: nonBlankStringSchema,
|
|
958
|
-
expiresAt:
|
|
1051
|
+
expiresAt: z13.number().finite().optional(),
|
|
959
1052
|
refreshToken: nonBlankStringSchema,
|
|
960
|
-
refreshTokenExpiresAt:
|
|
1053
|
+
refreshTokenExpiresAt: z13.number().finite().optional(),
|
|
961
1054
|
scope: nonBlankStringSchema.optional()
|
|
962
1055
|
}).strict();
|
|
963
|
-
var pluginGrantSchema =
|
|
1056
|
+
var pluginGrantSchema = z13.object({
|
|
964
1057
|
access: pluginGrantAccessSchema,
|
|
965
1058
|
leaseScope: nonBlankStringSchema.optional(),
|
|
966
1059
|
name: pluginGrantNameSchema,
|
|
967
1060
|
reason: nonBlankStringSchema.optional(),
|
|
968
|
-
requirements:
|
|
1061
|
+
requirements: z13.array(nonBlankStringSchema).min(1).optional()
|
|
969
1062
|
}).strict();
|
|
970
|
-
var pluginCredentialHeaderTransformSchema =
|
|
971
|
-
domain:
|
|
972
|
-
headers:
|
|
1063
|
+
var pluginCredentialHeaderTransformSchema = z13.object({
|
|
1064
|
+
domain: z13.string().min(1),
|
|
1065
|
+
headers: z13.record(z13.string(), z13.string()).refine((headers) => Object.keys(headers).length > 0)
|
|
973
1066
|
}).strict();
|
|
974
|
-
var pluginCredentialLeaseSchema =
|
|
1067
|
+
var pluginCredentialLeaseSchema = z13.object({
|
|
975
1068
|
account: pluginProviderAccountSchema.optional(),
|
|
976
1069
|
authorization: pluginAuthorizationSchema.optional(),
|
|
977
|
-
expiresAt:
|
|
978
|
-
headerTransforms:
|
|
1070
|
+
expiresAt: z13.string().refine((value) => Number.isFinite(Date.parse(value))),
|
|
1071
|
+
headerTransforms: z13.array(pluginCredentialHeaderTransformSchema).min(1)
|
|
979
1072
|
}).strict();
|
|
980
|
-
var pluginCredentialResultSchema =
|
|
981
|
-
|
|
1073
|
+
var pluginCredentialResultSchema = z13.discriminatedUnion("type", [
|
|
1074
|
+
z13.object({
|
|
982
1075
|
lease: pluginCredentialLeaseSchema,
|
|
983
|
-
type:
|
|
1076
|
+
type: z13.literal("lease")
|
|
984
1077
|
}).strict(),
|
|
985
|
-
|
|
1078
|
+
z13.object({
|
|
986
1079
|
authorization: pluginAuthorizationSchema.optional(),
|
|
987
1080
|
message: nonBlankStringSchema,
|
|
988
|
-
type:
|
|
1081
|
+
type: z13.literal("needed")
|
|
989
1082
|
}).strict(),
|
|
990
|
-
|
|
1083
|
+
z13.object({
|
|
991
1084
|
message: nonBlankStringSchema,
|
|
992
|
-
type:
|
|
1085
|
+
type: z13.literal("unavailable")
|
|
993
1086
|
}).strict()
|
|
994
1087
|
]);
|
|
995
1088
|
var EgressAuthRequired = class extends Error {
|
|
@@ -1125,44 +1218,44 @@ function defineJuniorPlugin(plugin) {
|
|
|
1125
1218
|
}
|
|
1126
1219
|
|
|
1127
1220
|
// src/user-pages.ts
|
|
1128
|
-
import { z as
|
|
1221
|
+
import { z as z14 } from "zod";
|
|
1129
1222
|
var userPageIdSchema = nonBlankStringSchema.max(64).regex(/^[a-z][a-z0-9-]*$/);
|
|
1130
1223
|
var userPageLabelSchema = nonBlankStringSchema.max(80);
|
|
1131
1224
|
var userPageDescriptionSchema = nonBlankStringSchema.max(500);
|
|
1132
|
-
var userPageNavigationSchema =
|
|
1133
|
-
var pluginUserPageMetricSchema =
|
|
1225
|
+
var userPageNavigationSchema = z14.enum(["primary", "profile"]);
|
|
1226
|
+
var pluginUserPageMetricSchema = z14.object({
|
|
1134
1227
|
detail: nonBlankStringSchema.max(500).optional(),
|
|
1135
1228
|
label: nonBlankStringSchema.max(80),
|
|
1136
|
-
tone:
|
|
1229
|
+
tone: z14.enum(["good", "neutral", "warning"]).optional(),
|
|
1137
1230
|
value: nonBlankStringSchema.max(120)
|
|
1138
1231
|
}).strict();
|
|
1139
|
-
var pluginUserPageMetadataSchema =
|
|
1232
|
+
var pluginUserPageMetadataSchema = z14.object({
|
|
1140
1233
|
label: nonBlankStringSchema.max(80),
|
|
1141
1234
|
value: nonBlankStringSchema.max(500)
|
|
1142
1235
|
}).strict();
|
|
1143
|
-
var pluginUserPageActionSchema =
|
|
1236
|
+
var pluginUserPageActionSchema = z14.object({
|
|
1144
1237
|
confirmation: nonBlankStringSchema.max(500).optional(),
|
|
1145
1238
|
href: nonBlankStringSchema.max(500).regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),
|
|
1146
1239
|
label: nonBlankStringSchema.max(80),
|
|
1147
|
-
method:
|
|
1148
|
-
tone:
|
|
1240
|
+
method: z14.literal("DELETE"),
|
|
1241
|
+
tone: z14.enum(["danger", "neutral"]).optional()
|
|
1149
1242
|
}).strict();
|
|
1150
|
-
var pluginUserPageRecordSchema =
|
|
1151
|
-
actions:
|
|
1243
|
+
var pluginUserPageRecordSchema = z14.object({
|
|
1244
|
+
actions: z14.array(pluginUserPageActionSchema).max(4).optional(),
|
|
1152
1245
|
description: nonBlankStringSchema.max(1e3).optional(),
|
|
1153
1246
|
id: nonBlankStringSchema.max(128),
|
|
1154
|
-
metadata:
|
|
1247
|
+
metadata: z14.array(pluginUserPageMetadataSchema).max(8).optional(),
|
|
1155
1248
|
title: nonBlankStringSchema.max(4e3)
|
|
1156
1249
|
}).strict();
|
|
1157
|
-
var pluginUserPageContentSchema =
|
|
1250
|
+
var pluginUserPageContentSchema = z14.object({
|
|
1158
1251
|
emptyText: nonBlankStringSchema.max(500).optional(),
|
|
1159
|
-
metrics:
|
|
1252
|
+
metrics: z14.array(pluginUserPageMetricSchema).max(6).optional(),
|
|
1160
1253
|
nextCursor: nonBlankStringSchema.max(1e3).optional(),
|
|
1161
|
-
records:
|
|
1254
|
+
records: z14.array(pluginUserPageRecordSchema).max(100),
|
|
1162
1255
|
searchPlaceholder: nonBlankStringSchema.max(120).optional(),
|
|
1163
|
-
type:
|
|
1256
|
+
type: z14.literal("list")
|
|
1164
1257
|
}).strict();
|
|
1165
|
-
var pluginUserPageLinkSchema =
|
|
1258
|
+
var pluginUserPageLinkSchema = z14.object({
|
|
1166
1259
|
description: userPageDescriptionSchema,
|
|
1167
1260
|
id: userPageIdSchema,
|
|
1168
1261
|
label: userPageLabelSchema,
|
|
@@ -1170,14 +1263,14 @@ var pluginUserPageLinkSchema = z13.object({
|
|
|
1170
1263
|
pluginDisplayName: nonBlankStringSchema.max(200),
|
|
1171
1264
|
pluginName: nonBlankStringSchema.max(100)
|
|
1172
1265
|
}).strict();
|
|
1173
|
-
var pluginUserPageLinksSchema =
|
|
1266
|
+
var pluginUserPageLinksSchema = z14.array(pluginUserPageLinkSchema);
|
|
1174
1267
|
var pluginUserPageCursorSchema = nonBlankStringSchema.max(1e3).optional();
|
|
1175
1268
|
var pluginUserPageFilterSchema = nonBlankStringSchema.max(64).optional();
|
|
1176
|
-
var pluginUserPageQuerySchema =
|
|
1177
|
-
var pluginUserPageInputSchema =
|
|
1269
|
+
var pluginUserPageQuerySchema = z14.string().trim().max(200).optional();
|
|
1270
|
+
var pluginUserPageInputSchema = z14.object({
|
|
1178
1271
|
cursor: pluginUserPageCursorSchema,
|
|
1179
1272
|
filter: pluginUserPageFilterSchema,
|
|
1180
|
-
limit:
|
|
1273
|
+
limit: z14.number().int().min(1).max(50),
|
|
1181
1274
|
query: pluginUserPageQuerySchema
|
|
1182
1275
|
}).strict();
|
|
1183
1276
|
export {
|
|
@@ -1236,6 +1329,10 @@ export {
|
|
|
1236
1329
|
objectAnnotationSchema,
|
|
1237
1330
|
objectFactFields,
|
|
1238
1331
|
objectFactsSchema,
|
|
1332
|
+
objectIconPath,
|
|
1333
|
+
objectIconPaths,
|
|
1334
|
+
objectPresentation,
|
|
1335
|
+
objectTypeSchema,
|
|
1239
1336
|
ownedObjectAnnotationSchema,
|
|
1240
1337
|
platformSchema,
|
|
1241
1338
|
pluginApiRouteRequestContextSchema,
|