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