@sentry/junior-plugin-api 0.197.0 → 0.199.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 +2021 -19
- package/package.json +4 -5
- package/dist/annotations.d.ts +0 -75
- package/dist/cli.d.ts +0 -39
- package/dist/code.d.ts +0 -37
- package/dist/context.d.ts +0 -158
- package/dist/conversation-events.d.ts +0 -80
- package/dist/credentials.d.ts +0 -184
- package/dist/dispatch.d.ts +0 -16
- package/dist/egress-policy.d.ts +0 -9
- package/dist/hooks.d.ts +0 -43
- package/dist/manifest.d.ts +0 -76
- package/dist/operations.d.ts +0 -153
- package/dist/prompt.d.ts +0 -56
- package/dist/registration.d.ts +0 -28
- package/dist/resource-events.d.ts +0 -128
- package/dist/schemas.d.ts +0 -261
- package/dist/state.d.ts +0 -10
- package/dist/tasks.d.ts +0 -250
- package/dist/tools.d.ts +0 -351
- package/dist/user-pages.d.ts +0 -97
- package/src/annotations.ts +0 -78
- package/src/cli.ts +0 -54
- package/src/code.ts +0 -37
- package/src/context.ts +0 -241
- package/src/conversation-events.ts +0 -136
- package/src/credentials.ts +0 -221
- package/src/dispatch.ts +0 -31
- package/src/egress-policy.ts +0 -15
- package/src/hooks.ts +0 -118
- package/src/index.ts +0 -29
- package/src/manifest.ts +0 -89
- package/src/operations.ts +0 -199
- package/src/prompt.ts +0 -99
- package/src/registration.ts +0 -173
- package/src/resource-events.ts +0 -320
- package/src/schemas.ts +0 -348
- package/src/state.ts +0 -15
- package/src/tasks.ts +0 -105
- package/src/tools.ts +0 -579
- package/src/user-pages.ts +0 -130
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,2021 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { z, ZodTypeAny } from 'zod';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
|
|
4
|
+
/** Exact non-blank actor user id that rejects the sentinel "unknown". */
|
|
5
|
+
declare const actorUserIdSchema: z.ZodString;
|
|
6
|
+
declare const nonBlankStringSchema: z.ZodString;
|
|
7
|
+
/** Complete Slack Location associated with a Conversation. */
|
|
8
|
+
declare const slackLocationSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
provider: z.ZodLiteral<"slack">;
|
|
11
|
+
teamId: z.ZodString;
|
|
12
|
+
channelId: z.ZodString;
|
|
13
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
/** Complete Location types supported by Junior. */
|
|
16
|
+
declare const locationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
provider: z.ZodLiteral<"slack">;
|
|
19
|
+
teamId: z.ZodString;
|
|
20
|
+
channelId: z.ZodString;
|
|
21
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strict>], "provider">;
|
|
23
|
+
/** Runtime platform names supported by plugin public contracts. */
|
|
24
|
+
declare const platformSchema: z.ZodEnum<{
|
|
25
|
+
slack: "slack";
|
|
26
|
+
local: "local";
|
|
27
|
+
}>;
|
|
28
|
+
/** Runtime source visibility visible to plugins. */
|
|
29
|
+
declare const sourceVisibilitySchema: z.ZodEnum<{
|
|
30
|
+
public: "public";
|
|
31
|
+
private: "private";
|
|
32
|
+
}>;
|
|
33
|
+
/** Provider-neutral visibility of a routed destination. */
|
|
34
|
+
declare const destinationVisibilitySchema: z.ZodEnum<{
|
|
35
|
+
public: "public";
|
|
36
|
+
private: "private";
|
|
37
|
+
}>;
|
|
38
|
+
/** Runtime-owned Slack address for routing future work or side effects. */
|
|
39
|
+
declare const slackDestinationSchema: z.ZodObject<{
|
|
40
|
+
platform: z.ZodLiteral<"slack">;
|
|
41
|
+
teamId: z.ZodString;
|
|
42
|
+
channelId: z.ZodString;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
/** Runtime-owned local CLI conversation address. */
|
|
45
|
+
declare const localDestinationSchema: z.ZodObject<{
|
|
46
|
+
platform: z.ZodLiteral<"local">;
|
|
47
|
+
conversationId: z.ZodString;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
/** Runtime-owned provider-neutral address for routing future work or side effects. */
|
|
50
|
+
declare const destinationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
51
|
+
platform: z.ZodLiteral<"slack">;
|
|
52
|
+
teamId: z.ZodString;
|
|
53
|
+
channelId: z.ZodString;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
platform: z.ZodLiteral<"local">;
|
|
56
|
+
conversationId: z.ZodString;
|
|
57
|
+
}, z.core.$strict>], "platform">;
|
|
58
|
+
/** Runtime-owned Slack input Source. */
|
|
59
|
+
declare const slackSourceSchema: z.ZodObject<{
|
|
60
|
+
kind: z.ZodLiteral<"slack">;
|
|
61
|
+
teamId: z.ZodString;
|
|
62
|
+
channelId: z.ZodString;
|
|
63
|
+
visibility: z.ZodEnum<{
|
|
64
|
+
public: "public";
|
|
65
|
+
private: "private";
|
|
66
|
+
}>;
|
|
67
|
+
messageTs: z.ZodOptional<z.ZodString>;
|
|
68
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
/** Runtime-owned local CLI input Source. */
|
|
71
|
+
declare const localSourceSchema: z.ZodObject<{
|
|
72
|
+
kind: z.ZodLiteral<"local">;
|
|
73
|
+
visibility: z.ZodLiteral<"private">;
|
|
74
|
+
conversationId: z.ZodString;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
/** Runtime-owned dashboard input Source. */
|
|
77
|
+
declare const webSourceSchema: z.ZodObject<{
|
|
78
|
+
kind: z.ZodLiteral<"web">;
|
|
79
|
+
visibility: z.ZodEnum<{
|
|
80
|
+
public: "public";
|
|
81
|
+
private: "private";
|
|
82
|
+
}>;
|
|
83
|
+
conversationId: z.ZodString;
|
|
84
|
+
}, z.core.$strict>;
|
|
85
|
+
/** Runtime-owned Resource event input Source. */
|
|
86
|
+
declare const resourceEventSourceSchema: z.ZodObject<{
|
|
87
|
+
kind: z.ZodLiteral<"resource_event">;
|
|
88
|
+
eventKey: z.ZodString;
|
|
89
|
+
eventType: z.ZodString;
|
|
90
|
+
identifier: z.ZodString;
|
|
91
|
+
namespace: z.ZodString;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
/** Runtime-owned Scheduled task input Source. */
|
|
94
|
+
declare const scheduledTaskSourceSchema: z.ZodObject<{
|
|
95
|
+
kind: z.ZodLiteral<"scheduled_task">;
|
|
96
|
+
}, z.core.$strict>;
|
|
97
|
+
/** Runtime-owned Event task input Source. */
|
|
98
|
+
declare const eventTaskSourceSchema: z.ZodObject<{
|
|
99
|
+
kind: z.ZodLiteral<"event_task">;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
/** Runtime-owned Plugin dispatch input Source. */
|
|
102
|
+
declare const pluginDispatchSourceSchema: z.ZodObject<{
|
|
103
|
+
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
/** Runtime-owned Agent invocation input Source. */
|
|
106
|
+
declare const agentInvocationSourceSchema: z.ZodObject<{
|
|
107
|
+
kind: z.ZodLiteral<"agent_invocation">;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
/** Runtime-owned input Source. Stored `platform` and Location fields normalize on read. */
|
|
110
|
+
declare const sourceSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
111
|
+
kind: z.ZodLiteral<"slack">;
|
|
112
|
+
teamId: z.ZodString;
|
|
113
|
+
channelId: z.ZodString;
|
|
114
|
+
visibility: z.ZodEnum<{
|
|
115
|
+
public: "public";
|
|
116
|
+
private: "private";
|
|
117
|
+
}>;
|
|
118
|
+
messageTs: z.ZodOptional<z.ZodString>;
|
|
119
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
kind: z.ZodLiteral<"local">;
|
|
122
|
+
visibility: z.ZodLiteral<"private">;
|
|
123
|
+
conversationId: z.ZodString;
|
|
124
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
125
|
+
kind: z.ZodLiteral<"web">;
|
|
126
|
+
visibility: z.ZodEnum<{
|
|
127
|
+
public: "public";
|
|
128
|
+
private: "private";
|
|
129
|
+
}>;
|
|
130
|
+
conversationId: z.ZodString;
|
|
131
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
132
|
+
kind: z.ZodLiteral<"resource_event">;
|
|
133
|
+
eventKey: z.ZodString;
|
|
134
|
+
eventType: z.ZodString;
|
|
135
|
+
identifier: z.ZodString;
|
|
136
|
+
namespace: z.ZodString;
|
|
137
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
138
|
+
kind: z.ZodLiteral<"scheduled_task">;
|
|
139
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
140
|
+
kind: z.ZodLiteral<"event_task">;
|
|
141
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
142
|
+
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
143
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
144
|
+
kind: z.ZodLiteral<"agent_invocation">;
|
|
145
|
+
}, z.core.$strict>], "kind">, unknown>;
|
|
146
|
+
/** Stable user credential subject shape accepted from plugins. */
|
|
147
|
+
declare const pluginCredentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
148
|
+
type: z.ZodLiteral<"user">;
|
|
149
|
+
userId: z.ZodString;
|
|
150
|
+
allowedWhen: z.ZodLiteral<"private-direct-conversation">;
|
|
151
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
152
|
+
type: z.ZodLiteral<"user">;
|
|
153
|
+
userId: z.ZodString;
|
|
154
|
+
allowedWhen: z.ZodLiteral<"scheduled-task">;
|
|
155
|
+
taskId: z.ZodString;
|
|
156
|
+
}, z.core.$strict>], "allowedWhen">;
|
|
157
|
+
declare const slackActorSchema: z.ZodObject<{
|
|
158
|
+
platform: z.ZodLiteral<"slack">;
|
|
159
|
+
teamId: z.ZodString;
|
|
160
|
+
email: z.ZodOptional<z.ZodString>;
|
|
161
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
162
|
+
userId: z.ZodString;
|
|
163
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
164
|
+
}, z.core.$strict>;
|
|
165
|
+
declare const localActorSchema: z.ZodObject<{
|
|
166
|
+
platform: z.ZodLiteral<"local">;
|
|
167
|
+
email: z.ZodOptional<z.ZodString>;
|
|
168
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
169
|
+
userId: z.ZodString;
|
|
170
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, z.core.$strict>;
|
|
172
|
+
declare const webActorSchema: z.ZodObject<{
|
|
173
|
+
platform: z.ZodLiteral<"web">;
|
|
174
|
+
email: z.ZodOptional<z.ZodString>;
|
|
175
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
176
|
+
userId: z.ZodString;
|
|
177
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
178
|
+
}, z.core.$strict>;
|
|
179
|
+
declare const systemActorSchema: z.ZodObject<{
|
|
180
|
+
platform: z.ZodLiteral<"system">;
|
|
181
|
+
name: z.ZodString;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
/** Runtime-provided actor identity visible to plugin hooks. */
|
|
184
|
+
declare const actorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
185
|
+
platform: z.ZodLiteral<"slack">;
|
|
186
|
+
teamId: z.ZodString;
|
|
187
|
+
email: z.ZodOptional<z.ZodString>;
|
|
188
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
189
|
+
userId: z.ZodString;
|
|
190
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
191
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
192
|
+
platform: z.ZodLiteral<"local">;
|
|
193
|
+
email: z.ZodOptional<z.ZodString>;
|
|
194
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
195
|
+
userId: z.ZodString;
|
|
196
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
197
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
198
|
+
platform: z.ZodLiteral<"web">;
|
|
199
|
+
email: z.ZodOptional<z.ZodString>;
|
|
200
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
201
|
+
userId: z.ZodString;
|
|
202
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
203
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
204
|
+
platform: z.ZodLiteral<"system">;
|
|
205
|
+
name: z.ZodString;
|
|
206
|
+
}, z.core.$strict>], "platform">;
|
|
207
|
+
/** Core-owned provider account linked to a user when verified. */
|
|
208
|
+
declare const identitySchema: z.ZodObject<{
|
|
209
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
210
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
211
|
+
id: z.ZodString;
|
|
212
|
+
provider: z.ZodString;
|
|
213
|
+
providerSubjectId: z.ZodString;
|
|
214
|
+
providerTenantId: z.ZodOptional<z.ZodString>;
|
|
215
|
+
}, z.core.$strict>;
|
|
216
|
+
/** Core-owned person with every linked provider identity. */
|
|
217
|
+
declare const userSchema: z.ZodObject<{
|
|
218
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
219
|
+
email: z.ZodString;
|
|
220
|
+
id: z.ZodString;
|
|
221
|
+
identities: z.ZodArray<z.ZodObject<{
|
|
222
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
223
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
224
|
+
id: z.ZodString;
|
|
225
|
+
provider: z.ZodString;
|
|
226
|
+
providerSubjectId: z.ZodString;
|
|
227
|
+
providerTenantId: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, z.core.$strict>>;
|
|
229
|
+
}, z.core.$strict>;
|
|
230
|
+
/** Compact destination-visible context explaining what produced a reply. */
|
|
231
|
+
declare const replyAttributionSchema: z.ZodObject<{
|
|
232
|
+
label: z.ZodPipe<z.ZodString, z.ZodString>;
|
|
233
|
+
detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
/** Plugin dispatch request accepted by Junior core. */
|
|
236
|
+
declare const dispatchOptionsSchema: z.ZodObject<{
|
|
237
|
+
idempotencyKey: z.ZodPipe<z.ZodString, z.ZodString>;
|
|
238
|
+
credentialSubject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
239
|
+
type: z.ZodLiteral<"user">;
|
|
240
|
+
userId: z.ZodString;
|
|
241
|
+
allowedWhen: z.ZodLiteral<"private-direct-conversation">;
|
|
242
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
243
|
+
type: z.ZodLiteral<"user">;
|
|
244
|
+
userId: z.ZodString;
|
|
245
|
+
allowedWhen: z.ZodLiteral<"scheduled-task">;
|
|
246
|
+
taskId: z.ZodString;
|
|
247
|
+
}, z.core.$strict>], "allowedWhen">>;
|
|
248
|
+
destination: z.ZodObject<{
|
|
249
|
+
platform: z.ZodLiteral<"slack">;
|
|
250
|
+
teamId: z.ZodString;
|
|
251
|
+
channelId: z.ZodString;
|
|
252
|
+
}, z.core.$strict>;
|
|
253
|
+
destinationVisibility: z.ZodEnum<{
|
|
254
|
+
public: "public";
|
|
255
|
+
private: "private";
|
|
256
|
+
}>;
|
|
257
|
+
input: z.ZodPipe<z.ZodString, z.ZodString>;
|
|
258
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
259
|
+
replyAttribution: z.ZodOptional<z.ZodObject<{
|
|
260
|
+
label: z.ZodPipe<z.ZodString, z.ZodString>;
|
|
261
|
+
detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
|
|
262
|
+
}, z.core.$strict>>;
|
|
263
|
+
}, z.core.$strict>;
|
|
264
|
+
|
|
265
|
+
/** Runtime platform name without source or destination coordinates. */
|
|
266
|
+
type Platform = z.output<typeof platformSchema>;
|
|
267
|
+
type Actor = z.output<typeof actorSchema>;
|
|
268
|
+
type SlackActor = z.output<typeof slackActorSchema>;
|
|
269
|
+
type LocalActor = z.output<typeof localActorSchema>;
|
|
270
|
+
type WebActor = z.output<typeof webActorSchema>;
|
|
271
|
+
type SystemActor = z.output<typeof systemActorSchema>;
|
|
272
|
+
type Identity = z.output<typeof identitySchema>;
|
|
273
|
+
type User = z.output<typeof userSchema>;
|
|
274
|
+
type Source = z.output<typeof sourceSchema>;
|
|
275
|
+
/** Validated Location associated with a Conversation. */
|
|
276
|
+
type Location = z.output<typeof locationSchema>;
|
|
277
|
+
/** Complete Slack Location associated with a Conversation. */
|
|
278
|
+
type SlackLocation = z.output<typeof slackLocationSchema>;
|
|
279
|
+
type SlackSource = Extract<Source, {
|
|
280
|
+
kind: "slack";
|
|
281
|
+
}>;
|
|
282
|
+
type LocalSource = Extract<Source, {
|
|
283
|
+
kind: "local";
|
|
284
|
+
}>;
|
|
285
|
+
type WebSource = Extract<Source, {
|
|
286
|
+
kind: "web";
|
|
287
|
+
}>;
|
|
288
|
+
type ResourceEventSource = Extract<Source, {
|
|
289
|
+
kind: "resource_event";
|
|
290
|
+
}>;
|
|
291
|
+
type ScheduledTaskSource = Extract<Source, {
|
|
292
|
+
kind: "scheduled_task";
|
|
293
|
+
}>;
|
|
294
|
+
type EventTaskSource = Extract<Source, {
|
|
295
|
+
kind: "event_task";
|
|
296
|
+
}>;
|
|
297
|
+
type PluginDispatchSource = Extract<Source, {
|
|
298
|
+
kind: "plugin_dispatch";
|
|
299
|
+
}>;
|
|
300
|
+
type AgentInvocationSource = Extract<Source, {
|
|
301
|
+
kind: "agent_invocation";
|
|
302
|
+
}>;
|
|
303
|
+
type SourceVisibility = z.output<typeof sourceVisibilitySchema>;
|
|
304
|
+
type Destination = z.output<typeof destinationSchema>;
|
|
305
|
+
type SlackDestination = Extract<Destination, {
|
|
306
|
+
platform: "slack";
|
|
307
|
+
}>;
|
|
308
|
+
type LocalDestination = Extract<Destination, {
|
|
309
|
+
platform: "local";
|
|
310
|
+
}>;
|
|
311
|
+
interface PluginMetadata {
|
|
312
|
+
name: string;
|
|
313
|
+
}
|
|
314
|
+
interface PluginLogger {
|
|
315
|
+
error(message: string, metadata?: Record<string, unknown>): void;
|
|
316
|
+
info(message: string, metadata?: Record<string, unknown>): void;
|
|
317
|
+
warn(message: string, metadata?: Record<string, unknown>): void;
|
|
318
|
+
}
|
|
319
|
+
interface PluginModel {
|
|
320
|
+
/** Run a host-owned structured model call without exposing provider credentials. */
|
|
321
|
+
completeObject<TSchema extends ZodTypeAny>(input: {
|
|
322
|
+
maxTokens?: number;
|
|
323
|
+
prompt: string;
|
|
324
|
+
schema: TSchema;
|
|
325
|
+
system?: string;
|
|
326
|
+
}): Promise<{
|
|
327
|
+
/** Best-effort estimated provider cost for this completion. */
|
|
328
|
+
costUsd?: number;
|
|
329
|
+
object: z.infer<TSchema>;
|
|
330
|
+
}>;
|
|
331
|
+
}
|
|
332
|
+
interface PluginEmbedder {
|
|
333
|
+
/** Embed plugin-owned text for derived retrieval without exposing provider credentials. */
|
|
334
|
+
embedTexts(input: {
|
|
335
|
+
texts: string[];
|
|
336
|
+
}): Promise<{
|
|
337
|
+
/** Best-effort estimated provider cost for this embedding call. */
|
|
338
|
+
costUsd?: number;
|
|
339
|
+
dimensions: number;
|
|
340
|
+
model: string;
|
|
341
|
+
provider: string;
|
|
342
|
+
vectors: number[][];
|
|
343
|
+
}>;
|
|
344
|
+
}
|
|
345
|
+
interface PluginContext {
|
|
346
|
+
/** Shared Drizzle database connection for plugin runtime code. */
|
|
347
|
+
db: unknown;
|
|
348
|
+
log: PluginLogger;
|
|
349
|
+
plugin: PluginMetadata;
|
|
350
|
+
}
|
|
351
|
+
interface BaseInvocationContext {
|
|
352
|
+
/**
|
|
353
|
+
* Opaque Junior conversation/session identity for this invocation.
|
|
354
|
+
* Interactive Slack turns use `slack:{channelId}:{threadTs}`.
|
|
355
|
+
*/
|
|
356
|
+
conversationId?: string;
|
|
357
|
+
/** Location associated with this Conversation. */
|
|
358
|
+
locationId?: string;
|
|
359
|
+
}
|
|
360
|
+
interface SlackInvocationContext extends BaseInvocationContext {
|
|
361
|
+
/** Runtime-owned default outbound destination for this invocation. */
|
|
362
|
+
destination: SlackDestination;
|
|
363
|
+
actor?: SlackActor;
|
|
364
|
+
/** Runtime-owned source where the invocation came from. */
|
|
365
|
+
source: SlackSource;
|
|
366
|
+
}
|
|
367
|
+
interface LocalInvocationContext extends BaseInvocationContext {
|
|
368
|
+
/** Runtime-owned default outbound destination for this invocation. */
|
|
369
|
+
destination: LocalDestination;
|
|
370
|
+
actor?: LocalActor;
|
|
371
|
+
/** Runtime-owned source where the invocation came from. */
|
|
372
|
+
source: LocalSource;
|
|
373
|
+
}
|
|
374
|
+
interface WebInvocationContext extends BaseInvocationContext {
|
|
375
|
+
/** Existing conversation destination used for location and tool context. */
|
|
376
|
+
destination: Destination;
|
|
377
|
+
actor?: WebActor;
|
|
378
|
+
/** Runtime-owned dashboard/web source for this invocation. */
|
|
379
|
+
source: WebSource;
|
|
380
|
+
}
|
|
381
|
+
interface ResourceEventInvocationContext extends BaseInvocationContext {
|
|
382
|
+
/** Existing conversation destination used for tool context. */
|
|
383
|
+
destination: Destination;
|
|
384
|
+
actor?: Actor;
|
|
385
|
+
/** Runtime-owned Resource event Source for this invocation. */
|
|
386
|
+
source: ResourceEventSource;
|
|
387
|
+
}
|
|
388
|
+
type InvocationContext = LocalInvocationContext | SlackInvocationContext | WebInvocationContext | (BaseInvocationContext & {
|
|
389
|
+
destination: Destination;
|
|
390
|
+
actor?: Actor;
|
|
391
|
+
source: AgentInvocationSource | EventTaskSource | PluginDispatchSource | ResourceEventSource | ScheduledTaskSource;
|
|
392
|
+
});
|
|
393
|
+
/** Build a normalized Slack source from runtime-owned Slack coordinates. */
|
|
394
|
+
declare function createSlackSource(input: {
|
|
395
|
+
channelId: string;
|
|
396
|
+
messageTs?: string;
|
|
397
|
+
teamId: string;
|
|
398
|
+
threadTs?: string;
|
|
399
|
+
/** Runtime-normalized source visibility. */
|
|
400
|
+
visibility: SourceVisibility;
|
|
401
|
+
}): SlackSource;
|
|
402
|
+
/** Build a normalized local source from a local conversation id. */
|
|
403
|
+
declare function createLocalSource(conversationId: string): LocalSource;
|
|
404
|
+
/** Build a normalized web/dashboard source from a conversation id. */
|
|
405
|
+
declare function createWebSource(conversationId: string, visibility?: SourceVisibility): WebSource;
|
|
406
|
+
/** Build a normalized Resource event Source from one matched event. */
|
|
407
|
+
declare function createResourceEventSource(input: {
|
|
408
|
+
eventKey: string;
|
|
409
|
+
eventType: string;
|
|
410
|
+
identifier: string;
|
|
411
|
+
namespace: string;
|
|
412
|
+
}): ResourceEventSource;
|
|
413
|
+
/** Return whether a source is private to a person or restricted group. */
|
|
414
|
+
declare function isPrivateSource(source: Source): boolean;
|
|
415
|
+
/** Return the stable source identity used for idempotency and attribution. */
|
|
416
|
+
declare function getSourceKey(source: Source): string | undefined;
|
|
417
|
+
/** Narrow a runtime destination to the Slack-specific address shape. */
|
|
418
|
+
declare function isSlackDestination(destination: Destination | undefined): destination is SlackDestination;
|
|
419
|
+
|
|
420
|
+
declare const resourceLinkAnnotationSchema: z.ZodObject<{
|
|
421
|
+
kind: z.ZodLiteral<"resource_link">;
|
|
422
|
+
key: z.ZodString;
|
|
423
|
+
label: z.ZodString;
|
|
424
|
+
url: z.ZodString;
|
|
425
|
+
description: z.ZodOptional<z.ZodString>;
|
|
426
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
427
|
+
open: "open";
|
|
428
|
+
draft: "draft";
|
|
429
|
+
closed: "closed";
|
|
430
|
+
merged: "merged";
|
|
431
|
+
warning: "warning";
|
|
432
|
+
}>>;
|
|
433
|
+
}, z.core.$strict>;
|
|
434
|
+
/** Core-known annotation shapes that plugins may attach to a conversation. */
|
|
435
|
+
declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
436
|
+
kind: z.ZodLiteral<"resource_link">;
|
|
437
|
+
key: z.ZodString;
|
|
438
|
+
label: z.ZodString;
|
|
439
|
+
url: z.ZodString;
|
|
440
|
+
description: z.ZodOptional<z.ZodString>;
|
|
441
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
442
|
+
open: "open";
|
|
443
|
+
draft: "draft";
|
|
444
|
+
closed: "closed";
|
|
445
|
+
merged: "merged";
|
|
446
|
+
warning: "warning";
|
|
447
|
+
}>>;
|
|
448
|
+
}, z.core.$strict>], "kind">;
|
|
449
|
+
type ConversationAnnotationInput = z.output<typeof conversationAnnotationInputSchema>;
|
|
450
|
+
type ConversationAnnotation = ConversationAnnotationInput & {
|
|
451
|
+
plugin: string;
|
|
452
|
+
createdAt: string;
|
|
453
|
+
updatedAt: string;
|
|
454
|
+
};
|
|
455
|
+
interface PluginAnnotations {
|
|
456
|
+
upsert(annotation: ConversationAnnotationInput): Promise<void>;
|
|
457
|
+
remove(kind: ConversationAnnotationInput["kind"], key: string): Promise<void>;
|
|
458
|
+
list(): Promise<ConversationAnnotation[]>;
|
|
459
|
+
}
|
|
460
|
+
interface PluginConversationAnnotations {
|
|
461
|
+
forConversation(conversationId: string): PluginAnnotations;
|
|
462
|
+
}
|
|
463
|
+
declare const conversationSidebarIconSchema: z.ZodEnum<{
|
|
464
|
+
"circle-dot": "circle-dot";
|
|
465
|
+
"circle-dashed": "circle-dashed";
|
|
466
|
+
"circle-x": "circle-x";
|
|
467
|
+
"git-merge": "git-merge";
|
|
468
|
+
"git-pull-request": "git-pull-request";
|
|
469
|
+
"triangle-alert": "triangle-alert";
|
|
470
|
+
}>;
|
|
471
|
+
declare const conversationSidebarAnnotationSchema: z.ZodObject<{
|
|
472
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
473
|
+
"circle-dot": "circle-dot";
|
|
474
|
+
"circle-dashed": "circle-dashed";
|
|
475
|
+
"circle-x": "circle-x";
|
|
476
|
+
"git-merge": "git-merge";
|
|
477
|
+
"git-pull-request": "git-pull-request";
|
|
478
|
+
"triangle-alert": "triangle-alert";
|
|
479
|
+
}>>;
|
|
480
|
+
key: z.ZodString;
|
|
481
|
+
label: z.ZodString;
|
|
482
|
+
}, z.core.$strict>;
|
|
483
|
+
type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
|
|
484
|
+
interface ConversationSidebarHookContext extends PluginContext {
|
|
485
|
+
/** Stored annotations owned by this plugin, keyed by candidate conversation. */
|
|
486
|
+
annotationsByConversationId: Record<string, ConversationAnnotation[]>;
|
|
487
|
+
conversationIds: string[];
|
|
488
|
+
}
|
|
489
|
+
interface ConversationSidebarResult {
|
|
490
|
+
/** Sidebar annotations in display order. Put the newest annotation first. */
|
|
491
|
+
annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
declare const codeChangeStateSchema: z.ZodEnum<{
|
|
495
|
+
open: "open";
|
|
496
|
+
closed: "closed";
|
|
497
|
+
merged: "merged";
|
|
498
|
+
}>;
|
|
499
|
+
type CodeChangeState = z.output<typeof codeChangeStateSchema>;
|
|
500
|
+
declare const codeChangeInputSchema: z.ZodObject<{
|
|
501
|
+
closedAt: z.ZodOptional<z.ZodDate>;
|
|
502
|
+
conversationIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
503
|
+
mergedAt: z.ZodOptional<z.ZodDate>;
|
|
504
|
+
number: z.ZodNumber;
|
|
505
|
+
openedAt: z.ZodDate;
|
|
506
|
+
providerId: z.ZodString;
|
|
507
|
+
repository: z.ZodObject<{
|
|
508
|
+
name: z.ZodString;
|
|
509
|
+
providerId: z.ZodString;
|
|
510
|
+
url: z.ZodOptional<z.ZodString>;
|
|
511
|
+
}, z.core.$strict>;
|
|
512
|
+
state: z.ZodEnum<{
|
|
513
|
+
open: "open";
|
|
514
|
+
closed: "closed";
|
|
515
|
+
merged: "merged";
|
|
516
|
+
}>;
|
|
517
|
+
title: z.ZodOptional<z.ZodString>;
|
|
518
|
+
updatedAt: z.ZodDate;
|
|
519
|
+
url: z.ZodOptional<z.ZodString>;
|
|
520
|
+
}, z.core.$strict>;
|
|
521
|
+
type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
|
|
522
|
+
/** Write code changes from a plugin to Junior's code records. */
|
|
523
|
+
interface CodeChangePublisher {
|
|
524
|
+
associateConversations(input: {
|
|
525
|
+
conversationIds: string[];
|
|
526
|
+
providerId: string;
|
|
527
|
+
}): Promise<void>;
|
|
528
|
+
record(input: CodeChangeInput): Promise<void>;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
declare const conversationEventIconSchema: z.ZodEnum<{
|
|
532
|
+
check: "check";
|
|
533
|
+
key: "key";
|
|
534
|
+
link: "link";
|
|
535
|
+
warning: "warning";
|
|
536
|
+
activity: "activity";
|
|
537
|
+
brain: "brain";
|
|
538
|
+
calendar: "calendar";
|
|
539
|
+
database: "database";
|
|
540
|
+
info: "info";
|
|
541
|
+
sparkles: "sparkles";
|
|
542
|
+
}>;
|
|
543
|
+
/** Safe, core-rendered presentation for one plugin conversation event. */
|
|
544
|
+
declare const conversationEventPresentationSchema: z.ZodObject<{
|
|
545
|
+
details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
546
|
+
content: z.ZodOptional<z.ZodString>;
|
|
547
|
+
description: z.ZodOptional<z.ZodString>;
|
|
548
|
+
metadata: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
549
|
+
title: z.ZodString;
|
|
550
|
+
}, z.core.$strict>>>;
|
|
551
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
552
|
+
check: "check";
|
|
553
|
+
key: "key";
|
|
554
|
+
link: "link";
|
|
555
|
+
warning: "warning";
|
|
556
|
+
activity: "activity";
|
|
557
|
+
brain: "brain";
|
|
558
|
+
calendar: "calendar";
|
|
559
|
+
database: "database";
|
|
560
|
+
info: "info";
|
|
561
|
+
sparkles: "sparkles";
|
|
562
|
+
}>>;
|
|
563
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
564
|
+
title: z.ZodString;
|
|
565
|
+
}, z.core.$strict>;
|
|
566
|
+
type ConversationEventPresentation = z.output<typeof conversationEventPresentationSchema>;
|
|
567
|
+
/** One validated plugin event value waiting for conversation-bound emission. */
|
|
568
|
+
interface PluginConversationEventValue {
|
|
569
|
+
readonly data: Record<string, unknown>;
|
|
570
|
+
readonly definition: PluginConversationEventDefinition;
|
|
571
|
+
}
|
|
572
|
+
/** Registered schema and optional transcript presentation for one event version. */
|
|
573
|
+
interface PluginConversationEventDefinition {
|
|
574
|
+
readonly eventName: string;
|
|
575
|
+
readonly version: number;
|
|
576
|
+
parse(data: unknown): Record<string, unknown>;
|
|
577
|
+
renderEvent(data: Record<string, unknown>): ConversationEventPresentation | undefined;
|
|
578
|
+
}
|
|
579
|
+
/** Typed factory returned while authoring one plugin conversation event. */
|
|
580
|
+
interface DefinedConversationEvent<TInput> extends PluginConversationEventDefinition {
|
|
581
|
+
(data: TInput): PluginConversationEventValue;
|
|
582
|
+
}
|
|
583
|
+
/** Define one typed, versioned plugin-owned conversation event. */
|
|
584
|
+
declare function defineConversationEvent<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
|
|
585
|
+
name: string;
|
|
586
|
+
version: number;
|
|
587
|
+
schema: TSchema;
|
|
588
|
+
renderEvent(event: z.output<TSchema>): z.input<typeof conversationEventPresentationSchema> | undefined;
|
|
589
|
+
}): DefinedConversationEvent<z.input<TSchema>>;
|
|
590
|
+
/** Conversation-bound event writer supplied by Junior core. */
|
|
591
|
+
interface PluginConversationEvents {
|
|
592
|
+
emit(event: PluginConversationEventValue): Promise<void>;
|
|
593
|
+
}
|
|
594
|
+
interface PluginConversationEventCostDay {
|
|
595
|
+
costUsd: number;
|
|
596
|
+
date: string;
|
|
597
|
+
events: number;
|
|
598
|
+
}
|
|
599
|
+
/** Read aggregate costs for events owned by the current plugin namespace. */
|
|
600
|
+
interface PluginConversationEventStats {
|
|
601
|
+
costsByDay(input: {
|
|
602
|
+
days: 7 | 30 | 90;
|
|
603
|
+
eventName: string;
|
|
604
|
+
}): Promise<PluginConversationEventCostDay[]>;
|
|
605
|
+
costsByHour(input: {
|
|
606
|
+
eventName: string;
|
|
607
|
+
hours?: number;
|
|
608
|
+
}): Promise<PluginConversationEventCostDay[]>;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
interface PluginState {
|
|
612
|
+
delete(key: string): Promise<void>;
|
|
613
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
614
|
+
set(key: string, value: unknown, ttlMs?: number): Promise<void>;
|
|
615
|
+
setIfNotExists(key: string, value: unknown, ttlMs?: number): Promise<boolean>;
|
|
616
|
+
withLock<T>(key: string, ttlMs: number, callback: () => Promise<T>): Promise<T>;
|
|
617
|
+
}
|
|
618
|
+
interface PluginReadState {
|
|
619
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
declare const promptMessageSchema: z.ZodObject<{
|
|
623
|
+
text: z.ZodString;
|
|
624
|
+
}, z.core.$strict>;
|
|
625
|
+
/** Small plugin-owned prompt text block rendered by Junior core. */
|
|
626
|
+
type PromptMessage = z.output<typeof promptMessageSchema>;
|
|
627
|
+
declare const promptContextSchema: z.ZodObject<{
|
|
628
|
+
kind: z.ZodString;
|
|
629
|
+
version: z.ZodNumber;
|
|
630
|
+
content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
631
|
+
}, z.core.$strict>;
|
|
632
|
+
/** Structured plugin context retained alongside its model-visible rendering. */
|
|
633
|
+
type PromptContext = z.output<typeof promptContextSchema>;
|
|
634
|
+
/** Runtime contribution produced from one validated plugin context value. */
|
|
635
|
+
interface PromptContextContribution {
|
|
636
|
+
context: PromptContext;
|
|
637
|
+
renderPrompt(): string;
|
|
638
|
+
}
|
|
639
|
+
/** Define one typed, versioned plugin context contribution. */
|
|
640
|
+
declare function definePromptContext<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
|
|
641
|
+
kind: string;
|
|
642
|
+
version: number;
|
|
643
|
+
schema: TSchema;
|
|
644
|
+
renderPrompt(content: z.output<TSchema>): string;
|
|
645
|
+
}): (content: z.input<TSchema>) => PromptContextContribution;
|
|
646
|
+
/** One request-scoped plugin contribution to the model-visible user prompt. */
|
|
647
|
+
type UserPromptContribution = PromptMessage | PromptContextContribution;
|
|
648
|
+
/** Stable platform context for plugin system prompt guidance. */
|
|
649
|
+
type SystemPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
650
|
+
platform: Platform;
|
|
651
|
+
};
|
|
652
|
+
/** Runtime facts available while building plugin user prompt context. */
|
|
653
|
+
type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
654
|
+
conversationId?: string;
|
|
655
|
+
destination: Destination;
|
|
656
|
+
embedder: PluginEmbedder;
|
|
657
|
+
/** Conversation-bound event writer when the prompt belongs to a durable turn. */
|
|
658
|
+
events?: PluginConversationEvents;
|
|
659
|
+
model: PluginModel;
|
|
660
|
+
/** Location associated with this Conversation. */
|
|
661
|
+
locationId?: string;
|
|
662
|
+
actor?: Actor;
|
|
663
|
+
source: Source;
|
|
664
|
+
state: PluginState;
|
|
665
|
+
text: string;
|
|
666
|
+
users: {
|
|
667
|
+
/** Resolve the current Actor's Identity and User. */
|
|
668
|
+
resolveActor(): Promise<{
|
|
669
|
+
identity: Identity;
|
|
670
|
+
user?: User;
|
|
671
|
+
} | undefined>;
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
type DestinationVisibility = z.output<typeof destinationVisibilitySchema>;
|
|
676
|
+
type DispatchOptions = z.output<typeof dispatchOptionsSchema>;
|
|
677
|
+
/** Compact destination-visible context explaining what produced a reply. */
|
|
678
|
+
type ReplyAttribution = z.output<typeof replyAttributionSchema>;
|
|
679
|
+
interface DispatchResult {
|
|
680
|
+
id: string;
|
|
681
|
+
status: "created" | "already_exists";
|
|
682
|
+
}
|
|
683
|
+
interface Dispatch {
|
|
684
|
+
errorMessage?: string;
|
|
685
|
+
id: string;
|
|
686
|
+
resultMessageTs?: string;
|
|
687
|
+
status: "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
declare const RESOURCE_EVENT_SUMMARY_MAX_LENGTH = 4000;
|
|
691
|
+
declare const RESOURCE_EVENT_TEXT_MAX_LENGTH = 8000;
|
|
692
|
+
declare const RESOURCE_EVENT_DATA_MAX_KEYS = 32;
|
|
693
|
+
declare const RESOURCE_EVENT_DATA_MAX_JSON_BYTES = 4000;
|
|
694
|
+
declare const RESOURCE_EVENT_GUIDANCE_MAX_LENGTH = 1000;
|
|
695
|
+
/** Small trusted data from the plugin. The agent should not look these up again. */
|
|
696
|
+
declare const resourceEventDataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
697
|
+
/** Canonical dotted event type published and selected across plugins. */
|
|
698
|
+
declare const resourceEventTypeSchema: z.ZodString;
|
|
699
|
+
declare const resourceTypeSchema: z.ZodString;
|
|
700
|
+
/** One exact value a watch or event task may require on trusted event data. */
|
|
701
|
+
declare const resourceEventMatchFieldSchema: z.ZodObject<{
|
|
702
|
+
kind: z.ZodEnum<{
|
|
703
|
+
string: "string";
|
|
704
|
+
number: "number";
|
|
705
|
+
boolean: "boolean";
|
|
706
|
+
}>;
|
|
707
|
+
description: z.ZodString;
|
|
708
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
709
|
+
}, z.core.$strict>;
|
|
710
|
+
declare const resourceEventMatchFieldsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
711
|
+
kind: z.ZodEnum<{
|
|
712
|
+
string: "string";
|
|
713
|
+
number: "number";
|
|
714
|
+
boolean: "boolean";
|
|
715
|
+
}>;
|
|
716
|
+
description: z.ZodString;
|
|
717
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
718
|
+
}, z.core.$strict>>;
|
|
719
|
+
/** Exact trusted values required before a watch or event task runs. */
|
|
720
|
+
declare const resourceEventMatchSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>;
|
|
721
|
+
type ResourceEventMatch = z.output<typeof resourceEventMatchSchema>;
|
|
722
|
+
type ResourceEventMatchFields = z.output<typeof resourceEventMatchFieldsSchema>;
|
|
723
|
+
/** Stable JSON for one match object. List order does not matter. */
|
|
724
|
+
declare function stableResourceEventMatchKey(match: ResourceEventMatch | undefined): string;
|
|
725
|
+
/** Return whether trusted event data matches one exact match object. */
|
|
726
|
+
declare function resourceEventMatches(match: ResourceEventMatch | undefined, data: ResourceEventData | undefined): boolean;
|
|
727
|
+
declare const pluginResourceEventTypeSchema: z.ZodObject<{
|
|
728
|
+
type: z.ZodString;
|
|
729
|
+
supportedEvents: z.ZodArray<z.ZodString>;
|
|
730
|
+
suggestedEvents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
731
|
+
matchFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
732
|
+
kind: z.ZodEnum<{
|
|
733
|
+
string: "string";
|
|
734
|
+
number: "number";
|
|
735
|
+
boolean: "boolean";
|
|
736
|
+
}>;
|
|
737
|
+
description: z.ZodString;
|
|
738
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
739
|
+
}, z.core.$strict>>>;
|
|
740
|
+
guidance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
741
|
+
}, z.core.$strict>;
|
|
742
|
+
declare const pluginResourceEventsSchema: z.ZodObject<{
|
|
743
|
+
resourceTypes: z.ZodArray<z.ZodObject<{
|
|
744
|
+
type: z.ZodString;
|
|
745
|
+
supportedEvents: z.ZodArray<z.ZodString>;
|
|
746
|
+
suggestedEvents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
747
|
+
matchFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
748
|
+
kind: z.ZodEnum<{
|
|
749
|
+
string: "string";
|
|
750
|
+
number: "number";
|
|
751
|
+
boolean: "boolean";
|
|
752
|
+
}>;
|
|
753
|
+
description: z.ZodString;
|
|
754
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
755
|
+
}, z.core.$strict>>>;
|
|
756
|
+
guidance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
757
|
+
}, z.core.$strict>>;
|
|
758
|
+
isEnabled: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodBoolean>>;
|
|
759
|
+
normalizeIdentifier: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodString>>;
|
|
760
|
+
}, z.core.$strict>;
|
|
761
|
+
type PluginResourceEventType = z.output<typeof pluginResourceEventTypeSchema>;
|
|
762
|
+
type PluginResourceEvents = z.output<typeof pluginResourceEventsSchema>;
|
|
763
|
+
/** Apply a plugin's identifier convention at resource-event boundaries. */
|
|
764
|
+
declare function normalizeResourceEventIdentifier(registration: Pick<PluginResourceEvents, "normalizeIdentifier"> | undefined, identifier: string): string;
|
|
765
|
+
declare const subscribableResourceSchema: z.ZodObject<{
|
|
766
|
+
identifier: z.ZodString;
|
|
767
|
+
label: z.ZodString;
|
|
768
|
+
namespace: z.ZodString;
|
|
769
|
+
suggestedEvents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
770
|
+
supportedEvents: z.ZodArray<z.ZodString>;
|
|
771
|
+
type: z.ZodString;
|
|
772
|
+
}, z.core.$strict>;
|
|
773
|
+
type SubscribableResource = z.output<typeof subscribableResourceSchema>;
|
|
774
|
+
/** Result returned after a temporary resource subscription is created. */
|
|
775
|
+
declare const resourceEventSubscriptionResultSchema: z.ZodObject<{
|
|
776
|
+
events: z.ZodArray<z.ZodString>;
|
|
777
|
+
id: z.ZodString;
|
|
778
|
+
}, z.core.$strict>;
|
|
779
|
+
type ResourceEventSubscriptionResult = z.output<typeof resourceEventSubscriptionResultSchema>;
|
|
780
|
+
declare const resourceEventInputSchema: z.ZodObject<{
|
|
781
|
+
eventKey: z.ZodString;
|
|
782
|
+
eventType: z.ZodString;
|
|
783
|
+
identifier: z.ZodString;
|
|
784
|
+
occurredAtMs: z.ZodNumber;
|
|
785
|
+
terminal: z.ZodOptional<z.ZodBoolean>;
|
|
786
|
+
trustedSummary: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
787
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
788
|
+
untrustedText: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
789
|
+
}, z.core.$strict>;
|
|
790
|
+
type ResourceEventData = z.output<typeof resourceEventDataSchema>;
|
|
791
|
+
type ResourceEventInput = z.output<typeof resourceEventInputSchema>;
|
|
792
|
+
declare const resourceEventSchema: z.ZodObject<{
|
|
793
|
+
eventKey: z.ZodString;
|
|
794
|
+
eventType: z.ZodString;
|
|
795
|
+
identifier: z.ZodString;
|
|
796
|
+
occurredAtMs: z.ZodNumber;
|
|
797
|
+
terminal: z.ZodOptional<z.ZodBoolean>;
|
|
798
|
+
trustedSummary: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
799
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
800
|
+
untrustedText: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
801
|
+
namespace: z.ZodString;
|
|
802
|
+
}, z.core.$strict>;
|
|
803
|
+
type ResourceEvent = z.output<typeof resourceEventSchema>;
|
|
804
|
+
interface ResourceEventPublisher {
|
|
805
|
+
/** Publish one normalized event under the owning plugin's namespace. */
|
|
806
|
+
publish(event: ResourceEventInput): Promise<void>;
|
|
807
|
+
/**
|
|
808
|
+
* Return match keys used by active watches or event tasks for these
|
|
809
|
+
* identifiers and event types. Plugins use this to load optional trusted
|
|
810
|
+
* data only when a filter needs it.
|
|
811
|
+
*/
|
|
812
|
+
neededMatchKeys?(input: {
|
|
813
|
+
eventTypes: string[];
|
|
814
|
+
identifiers: string[];
|
|
815
|
+
}): Promise<string[]>;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Public plugin background-task contracts.
|
|
820
|
+
*
|
|
821
|
+
* Plugins register small task handlers. Junior core owns scheduling, delivery,
|
|
822
|
+
* retries, and the bounded run projection.
|
|
823
|
+
*/
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Runtime-owned provenance for a transcript message: whether it is a durable
|
|
827
|
+
* instruction or ambient context, plus the actor identity when known. Missing
|
|
828
|
+
* provenance on an entry means unattributed context.
|
|
829
|
+
*/
|
|
830
|
+
declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
|
|
831
|
+
authority: z.ZodEnum<{
|
|
832
|
+
instruction: "instruction";
|
|
833
|
+
context: "context";
|
|
834
|
+
}>;
|
|
835
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
836
|
+
platform: z.ZodLiteral<"slack">;
|
|
837
|
+
teamId: z.ZodString;
|
|
838
|
+
email: z.ZodOptional<z.ZodString>;
|
|
839
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
840
|
+
userId: z.ZodString;
|
|
841
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
842
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
843
|
+
platform: z.ZodLiteral<"local">;
|
|
844
|
+
email: z.ZodOptional<z.ZodString>;
|
|
845
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
846
|
+
userId: z.ZodString;
|
|
847
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
848
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
849
|
+
platform: z.ZodLiteral<"web">;
|
|
850
|
+
email: z.ZodOptional<z.ZodString>;
|
|
851
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
852
|
+
userId: z.ZodString;
|
|
853
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
854
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
855
|
+
platform: z.ZodLiteral<"system">;
|
|
856
|
+
name: z.ZodString;
|
|
857
|
+
}, z.core.$strict>], "platform">>;
|
|
858
|
+
}, z.core.$strict>;
|
|
859
|
+
/** One normalized transcript entry from the completed run exposed to plugin tasks. */
|
|
860
|
+
declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
861
|
+
type: z.ZodLiteral<"message">;
|
|
862
|
+
role: z.ZodEnum<{
|
|
863
|
+
user: "user";
|
|
864
|
+
assistant: "assistant";
|
|
865
|
+
}>;
|
|
866
|
+
text: z.ZodString;
|
|
867
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
868
|
+
authority: z.ZodEnum<{
|
|
869
|
+
instruction: "instruction";
|
|
870
|
+
context: "context";
|
|
871
|
+
}>;
|
|
872
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
873
|
+
platform: z.ZodLiteral<"slack">;
|
|
874
|
+
teamId: z.ZodString;
|
|
875
|
+
email: z.ZodOptional<z.ZodString>;
|
|
876
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
877
|
+
userId: z.ZodString;
|
|
878
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
879
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
880
|
+
platform: z.ZodLiteral<"local">;
|
|
881
|
+
email: z.ZodOptional<z.ZodString>;
|
|
882
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
883
|
+
userId: z.ZodString;
|
|
884
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
885
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
886
|
+
platform: z.ZodLiteral<"web">;
|
|
887
|
+
email: z.ZodOptional<z.ZodString>;
|
|
888
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
889
|
+
userId: z.ZodString;
|
|
890
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
891
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
892
|
+
platform: z.ZodLiteral<"system">;
|
|
893
|
+
name: z.ZodString;
|
|
894
|
+
}, z.core.$strict>], "platform">>;
|
|
895
|
+
}, z.core.$strict>>;
|
|
896
|
+
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
897
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
898
|
+
type: z.ZodLiteral<"toolResult">;
|
|
899
|
+
toolName: z.ZodString;
|
|
900
|
+
isError: z.ZodBoolean;
|
|
901
|
+
text: z.ZodOptional<z.ZodString>;
|
|
902
|
+
}, z.core.$strict>], "type">;
|
|
903
|
+
type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
|
|
904
|
+
/** Runtime-owned completed-run projection exposed to plugin tasks. */
|
|
905
|
+
declare const pluginRunContextSchema: z.ZodObject<{
|
|
906
|
+
actorUserId: z.ZodOptional<z.ZodString>;
|
|
907
|
+
completedAtMs: z.ZodNumber;
|
|
908
|
+
conversationId: z.ZodString;
|
|
909
|
+
destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
910
|
+
platform: z.ZodLiteral<"slack">;
|
|
911
|
+
teamId: z.ZodString;
|
|
912
|
+
channelId: z.ZodString;
|
|
913
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
914
|
+
platform: z.ZodLiteral<"local">;
|
|
915
|
+
conversationId: z.ZodString;
|
|
916
|
+
}, z.core.$strict>], "platform">;
|
|
917
|
+
locationId: z.ZodOptional<z.ZodString>;
|
|
918
|
+
actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
919
|
+
platform: z.ZodLiteral<"slack">;
|
|
920
|
+
teamId: z.ZodString;
|
|
921
|
+
email: z.ZodOptional<z.ZodString>;
|
|
922
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
923
|
+
userId: z.ZodString;
|
|
924
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
925
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
926
|
+
platform: z.ZodLiteral<"local">;
|
|
927
|
+
email: z.ZodOptional<z.ZodString>;
|
|
928
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
929
|
+
userId: z.ZodString;
|
|
930
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
931
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
932
|
+
platform: z.ZodLiteral<"web">;
|
|
933
|
+
email: z.ZodOptional<z.ZodString>;
|
|
934
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
935
|
+
userId: z.ZodString;
|
|
936
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
937
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
938
|
+
platform: z.ZodLiteral<"system">;
|
|
939
|
+
name: z.ZodString;
|
|
940
|
+
}, z.core.$strict>], "platform">>;
|
|
941
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
942
|
+
platform: z.ZodLiteral<"slack">;
|
|
943
|
+
teamId: z.ZodString;
|
|
944
|
+
email: z.ZodOptional<z.ZodString>;
|
|
945
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
946
|
+
userId: z.ZodString;
|
|
947
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
948
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
949
|
+
platform: z.ZodLiteral<"local">;
|
|
950
|
+
email: z.ZodOptional<z.ZodString>;
|
|
951
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
952
|
+
userId: z.ZodString;
|
|
953
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
954
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
955
|
+
platform: z.ZodLiteral<"web">;
|
|
956
|
+
email: z.ZodOptional<z.ZodString>;
|
|
957
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
958
|
+
userId: z.ZodString;
|
|
959
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
960
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
961
|
+
platform: z.ZodLiteral<"system">;
|
|
962
|
+
name: z.ZodString;
|
|
963
|
+
}, z.core.$strict>], "platform">>;
|
|
964
|
+
runId: z.ZodString;
|
|
965
|
+
source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
966
|
+
kind: z.ZodLiteral<"slack">;
|
|
967
|
+
teamId: z.ZodString;
|
|
968
|
+
channelId: z.ZodString;
|
|
969
|
+
visibility: z.ZodEnum<{
|
|
970
|
+
public: "public";
|
|
971
|
+
private: "private";
|
|
972
|
+
}>;
|
|
973
|
+
messageTs: z.ZodOptional<z.ZodString>;
|
|
974
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
975
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
976
|
+
kind: z.ZodLiteral<"local">;
|
|
977
|
+
visibility: z.ZodLiteral<"private">;
|
|
978
|
+
conversationId: z.ZodString;
|
|
979
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
980
|
+
kind: z.ZodLiteral<"web">;
|
|
981
|
+
visibility: z.ZodEnum<{
|
|
982
|
+
public: "public";
|
|
983
|
+
private: "private";
|
|
984
|
+
}>;
|
|
985
|
+
conversationId: z.ZodString;
|
|
986
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
987
|
+
kind: z.ZodLiteral<"resource_event">;
|
|
988
|
+
eventKey: z.ZodString;
|
|
989
|
+
eventType: z.ZodString;
|
|
990
|
+
identifier: z.ZodString;
|
|
991
|
+
namespace: z.ZodString;
|
|
992
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
993
|
+
kind: z.ZodLiteral<"scheduled_task">;
|
|
994
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
995
|
+
kind: z.ZodLiteral<"event_task">;
|
|
996
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
997
|
+
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
998
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
999
|
+
kind: z.ZodLiteral<"agent_invocation">;
|
|
1000
|
+
}, z.core.$strict>], "kind">, unknown>;
|
|
1001
|
+
transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1002
|
+
type: z.ZodLiteral<"message">;
|
|
1003
|
+
role: z.ZodEnum<{
|
|
1004
|
+
user: "user";
|
|
1005
|
+
assistant: "assistant";
|
|
1006
|
+
}>;
|
|
1007
|
+
text: z.ZodString;
|
|
1008
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
1009
|
+
authority: z.ZodEnum<{
|
|
1010
|
+
instruction: "instruction";
|
|
1011
|
+
context: "context";
|
|
1012
|
+
}>;
|
|
1013
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1014
|
+
platform: z.ZodLiteral<"slack">;
|
|
1015
|
+
teamId: z.ZodString;
|
|
1016
|
+
email: z.ZodOptional<z.ZodString>;
|
|
1017
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
1018
|
+
userId: z.ZodString;
|
|
1019
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
1020
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1021
|
+
platform: z.ZodLiteral<"local">;
|
|
1022
|
+
email: z.ZodOptional<z.ZodString>;
|
|
1023
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
1024
|
+
userId: z.ZodString;
|
|
1025
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
1026
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1027
|
+
platform: z.ZodLiteral<"web">;
|
|
1028
|
+
email: z.ZodOptional<z.ZodString>;
|
|
1029
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
1030
|
+
userId: z.ZodString;
|
|
1031
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
1032
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1033
|
+
platform: z.ZodLiteral<"system">;
|
|
1034
|
+
name: z.ZodString;
|
|
1035
|
+
}, z.core.$strict>], "platform">>;
|
|
1036
|
+
}, z.core.$strict>>;
|
|
1037
|
+
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
1038
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1039
|
+
type: z.ZodLiteral<"toolResult">;
|
|
1040
|
+
toolName: z.ZodString;
|
|
1041
|
+
isError: z.ZodBoolean;
|
|
1042
|
+
text: z.ZodOptional<z.ZodString>;
|
|
1043
|
+
}, z.core.$strict>], "type">>;
|
|
1044
|
+
}, z.core.$strict>;
|
|
1045
|
+
type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
|
|
1046
|
+
type PluginRunContext = z.output<typeof pluginRunContextSchema>;
|
|
1047
|
+
/** Runtime context passed to a plugin-owned background task. */
|
|
1048
|
+
interface PluginTaskContext extends PluginContext {
|
|
1049
|
+
embedder: PluginEmbedder;
|
|
1050
|
+
events: PluginConversationEvents;
|
|
1051
|
+
id: string;
|
|
1052
|
+
model: PluginModel;
|
|
1053
|
+
name: string;
|
|
1054
|
+
run: {
|
|
1055
|
+
load(): Promise<PluginRunContext>;
|
|
1056
|
+
};
|
|
1057
|
+
state: PluginState;
|
|
1058
|
+
}
|
|
1059
|
+
/** Plugin task handler registered by name in a plugin manifest module. */
|
|
1060
|
+
interface PluginTaskDefinition {
|
|
1061
|
+
run(ctx: PluginTaskContext): Promise<void> | void;
|
|
1062
|
+
}
|
|
1063
|
+
/** Task handlers keyed by the plugin-owned task name. */
|
|
1064
|
+
type PluginTasks = Record<string, PluginTaskDefinition>;
|
|
1065
|
+
|
|
1066
|
+
declare const pluginGrantAccessSchema: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
1067
|
+
/** Runtime schema for provider authorization a plugin may request. */
|
|
1068
|
+
declare const pluginAuthorizationSchema: z.ZodObject<{
|
|
1069
|
+
provider: z.ZodString;
|
|
1070
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
1071
|
+
type: z.ZodLiteral<"oauth">;
|
|
1072
|
+
}, z.core.$strict>;
|
|
1073
|
+
/** Runtime schema for a provider account attached to stored OAuth tokens. */
|
|
1074
|
+
declare const pluginProviderAccountSchema: z.ZodObject<{
|
|
1075
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
1076
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
1077
|
+
id: z.ZodString;
|
|
1078
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1079
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1080
|
+
}, z.core.$strict>;
|
|
1081
|
+
/** Runtime schema for OAuth tokens stored by the host for plugin credentials. */
|
|
1082
|
+
declare const pluginStoredTokensSchema: z.ZodObject<{
|
|
1083
|
+
account: z.ZodOptional<z.ZodObject<{
|
|
1084
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
1085
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
1086
|
+
id: z.ZodString;
|
|
1087
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1088
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1089
|
+
}, z.core.$strict>>;
|
|
1090
|
+
accessToken: z.ZodString;
|
|
1091
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
1092
|
+
refreshToken: z.ZodString;
|
|
1093
|
+
refreshTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
|
|
1094
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
1095
|
+
}, z.core.$strict>;
|
|
1096
|
+
/** Runtime schema for a plugin-defined outbound credential grant. */
|
|
1097
|
+
declare const pluginGrantSchema: z.ZodObject<{
|
|
1098
|
+
access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
1099
|
+
leaseScope: z.ZodOptional<z.ZodString>;
|
|
1100
|
+
name: z.ZodString;
|
|
1101
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1102
|
+
requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1103
|
+
}, z.core.$strict>;
|
|
1104
|
+
/** Runtime schema for plugin-issued header mutations. */
|
|
1105
|
+
declare const pluginCredentialHeaderTransformSchema: z.ZodObject<{
|
|
1106
|
+
domain: z.ZodString;
|
|
1107
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1108
|
+
}, z.core.$strict>;
|
|
1109
|
+
/** Runtime schema for a short-lived plugin-issued credential lease. */
|
|
1110
|
+
declare const pluginCredentialLeaseSchema: z.ZodObject<{
|
|
1111
|
+
account: z.ZodOptional<z.ZodObject<{
|
|
1112
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
1113
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
1114
|
+
id: z.ZodString;
|
|
1115
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1116
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1117
|
+
}, z.core.$strict>>;
|
|
1118
|
+
authorization: z.ZodOptional<z.ZodObject<{
|
|
1119
|
+
provider: z.ZodString;
|
|
1120
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
1121
|
+
type: z.ZodLiteral<"oauth">;
|
|
1122
|
+
}, z.core.$strict>>;
|
|
1123
|
+
expiresAt: z.ZodString;
|
|
1124
|
+
headerTransforms: z.ZodArray<z.ZodObject<{
|
|
1125
|
+
domain: z.ZodString;
|
|
1126
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1127
|
+
}, z.core.$strict>>;
|
|
1128
|
+
}, z.core.$strict>;
|
|
1129
|
+
/** Runtime schema for the result returned by a plugin credential hook. */
|
|
1130
|
+
declare const pluginCredentialResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1131
|
+
lease: z.ZodObject<{
|
|
1132
|
+
account: z.ZodOptional<z.ZodObject<{
|
|
1133
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
1134
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
1135
|
+
id: z.ZodString;
|
|
1136
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1137
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1138
|
+
}, z.core.$strict>>;
|
|
1139
|
+
authorization: z.ZodOptional<z.ZodObject<{
|
|
1140
|
+
provider: z.ZodString;
|
|
1141
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
1142
|
+
type: z.ZodLiteral<"oauth">;
|
|
1143
|
+
}, z.core.$strict>>;
|
|
1144
|
+
expiresAt: z.ZodString;
|
|
1145
|
+
headerTransforms: z.ZodArray<z.ZodObject<{
|
|
1146
|
+
domain: z.ZodString;
|
|
1147
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
1148
|
+
}, z.core.$strict>>;
|
|
1149
|
+
}, z.core.$strict>;
|
|
1150
|
+
type: z.ZodLiteral<"lease">;
|
|
1151
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1152
|
+
authorization: z.ZodOptional<z.ZodObject<{
|
|
1153
|
+
provider: z.ZodString;
|
|
1154
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
1155
|
+
type: z.ZodLiteral<"oauth">;
|
|
1156
|
+
}, z.core.$strict>>;
|
|
1157
|
+
message: z.ZodString;
|
|
1158
|
+
type: z.ZodLiteral<"needed">;
|
|
1159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1160
|
+
message: z.ZodString;
|
|
1161
|
+
type: z.ZodLiteral<"unavailable">;
|
|
1162
|
+
}, z.core.$strict>], "type">;
|
|
1163
|
+
type PluginCredentialSubject = z.output<typeof pluginCredentialSubjectSchema>;
|
|
1164
|
+
type PluginGrantAccess = z.output<typeof pluginGrantAccessSchema>;
|
|
1165
|
+
/** Provider authorization Junior can start when a plugin-owned grant is missing. */
|
|
1166
|
+
type PluginAuthorization = z.output<typeof pluginAuthorizationSchema>;
|
|
1167
|
+
/** Interrupt sandbox egress so Junior can start provider authorization. */
|
|
1168
|
+
declare class EgressAuthRequired extends Error {
|
|
1169
|
+
authorization?: PluginAuthorization;
|
|
1170
|
+
constructor(message: string, options?: {
|
|
1171
|
+
authorization?: PluginAuthorization;
|
|
1172
|
+
cause?: unknown;
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
/** Deny provider egress before Junior issues credentials for a disallowed operation. */
|
|
1176
|
+
declare class EgressPolicyDenied extends Error {
|
|
1177
|
+
constructor(message: string, options?: {
|
|
1178
|
+
cause?: unknown;
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
/** Provider account identity resolved by a plugin OAuth hook. */
|
|
1182
|
+
type PluginProviderAccount = z.output<typeof pluginProviderAccountSchema>;
|
|
1183
|
+
/** Plugin-defined grant required before Junior can forward one outbound request. */
|
|
1184
|
+
type PluginGrant = z.output<typeof pluginGrantSchema>;
|
|
1185
|
+
/** Request details available while selecting the grant for sandbox egress. */
|
|
1186
|
+
interface PluginEgressRequest {
|
|
1187
|
+
/** Capped request body text when the host exposes it for provider-specific grant classification. */
|
|
1188
|
+
bodyText?: string;
|
|
1189
|
+
method: string;
|
|
1190
|
+
/** Plugin-declared operation this request performs, used for grant classification and diagnostics. */
|
|
1191
|
+
operation?: string;
|
|
1192
|
+
url: string;
|
|
1193
|
+
}
|
|
1194
|
+
interface EgressHookContext extends PluginContext {
|
|
1195
|
+
request: PluginEgressRequest;
|
|
1196
|
+
}
|
|
1197
|
+
interface PluginEgressResponse {
|
|
1198
|
+
/** Snapshot of upstream response headers; mutations do not affect pass-through. */
|
|
1199
|
+
headers: Headers;
|
|
1200
|
+
readText(maxBytes: number): Promise<string | undefined>;
|
|
1201
|
+
status: number;
|
|
1202
|
+
}
|
|
1203
|
+
interface EgressResponseHookContext extends PluginContext {
|
|
1204
|
+
grant: PluginGrant;
|
|
1205
|
+
permissionDenied(message: string): void;
|
|
1206
|
+
request: Omit<PluginEgressRequest, "bodyText">;
|
|
1207
|
+
response: PluginEgressResponse;
|
|
1208
|
+
}
|
|
1209
|
+
/** Header mutations a plugin-issued credential lease may apply to owned domains. */
|
|
1210
|
+
type PluginCredentialHeaderTransform = z.output<typeof pluginCredentialHeaderTransformSchema>;
|
|
1211
|
+
/** Short-lived credential headers issued by a plugin for a selected grant. */
|
|
1212
|
+
type PluginCredentialLease = z.output<typeof pluginCredentialLeaseSchema>;
|
|
1213
|
+
type PluginCredentialResult = z.output<typeof pluginCredentialResultSchema>;
|
|
1214
|
+
type PluginCredentialActor = {
|
|
1215
|
+
platform: "system";
|
|
1216
|
+
name: string;
|
|
1217
|
+
} | {
|
|
1218
|
+
type: "user";
|
|
1219
|
+
userId: string;
|
|
1220
|
+
};
|
|
1221
|
+
interface PluginResolvedCredentialUser {
|
|
1222
|
+
type: "user";
|
|
1223
|
+
userId: string;
|
|
1224
|
+
}
|
|
1225
|
+
type PluginStoredTokens = z.output<typeof pluginStoredTokensSchema>;
|
|
1226
|
+
interface PluginUserTokenSlot {
|
|
1227
|
+
get(): Promise<PluginStoredTokens | undefined>;
|
|
1228
|
+
set(tokens: PluginStoredTokens): Promise<void>;
|
|
1229
|
+
/** Run token refresh work after the host has serialized this user/provider slot, or throw after a bounded wait. */
|
|
1230
|
+
withRefresh<T>(callback: () => Promise<T>): Promise<T>;
|
|
1231
|
+
userId: string;
|
|
1232
|
+
}
|
|
1233
|
+
interface PluginTokenStore {
|
|
1234
|
+
credentialSubject?: PluginUserTokenSlot;
|
|
1235
|
+
currentUser?: PluginUserTokenSlot;
|
|
1236
|
+
}
|
|
1237
|
+
interface ResolveOAuthAccountHookContext extends PluginContext {
|
|
1238
|
+
tokens: PluginStoredTokens;
|
|
1239
|
+
}
|
|
1240
|
+
interface IssueCredentialHookContext extends PluginContext {
|
|
1241
|
+
actor: PluginCredentialActor;
|
|
1242
|
+
credentialSubject?: PluginResolvedCredentialUser;
|
|
1243
|
+
grant: PluginGrant;
|
|
1244
|
+
tokens: PluginTokenStore;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
interface HeartbeatHookContext extends PluginContext {
|
|
1248
|
+
agent: {
|
|
1249
|
+
dispatch(options: DispatchOptions): Promise<DispatchResult>;
|
|
1250
|
+
get(id: string): Promise<Dispatch | undefined>;
|
|
1251
|
+
};
|
|
1252
|
+
nowMs: number;
|
|
1253
|
+
state: PluginState;
|
|
1254
|
+
}
|
|
1255
|
+
interface HeartbeatResult {
|
|
1256
|
+
dispatchCount?: number;
|
|
1257
|
+
}
|
|
1258
|
+
interface UnfinishedWorkHookContext extends PluginContext {
|
|
1259
|
+
/** Bounded conversation candidates selected by the host. */
|
|
1260
|
+
conversationIds: string[];
|
|
1261
|
+
}
|
|
1262
|
+
interface UnfinishedWorkResult {
|
|
1263
|
+
/** Candidate conversations that have plugin-owned work to finish. */
|
|
1264
|
+
conversationIds: string[];
|
|
1265
|
+
/**
|
|
1266
|
+
* Candidate conversations that have any associated plugin-owned work,
|
|
1267
|
+
* finished or unfinished. Omit when the plugin cannot distinguish assignment.
|
|
1268
|
+
*
|
|
1269
|
+
* The host uses this with unfinished work and finish times to set feed
|
|
1270
|
+
* `isPriority`. Finished assigned work stays out of Priority unless the
|
|
1271
|
+
* conversation has activity after the finish time.
|
|
1272
|
+
*/
|
|
1273
|
+
assignedConversationIds?: string[];
|
|
1274
|
+
/**
|
|
1275
|
+
* Latest time when all known work finished, keyed by conversation id.
|
|
1276
|
+
* ISO-8601 timestamps. Used with conversation activity to decide whether
|
|
1277
|
+
* finished work still belongs in Priority.
|
|
1278
|
+
*/
|
|
1279
|
+
finishedWorkAtByConversationId?: Record<string, string>;
|
|
1280
|
+
}
|
|
1281
|
+
type PluginOperationalTone = "danger" | "good" | "neutral" | "warning";
|
|
1282
|
+
interface PluginOperationalMetric {
|
|
1283
|
+
label: string;
|
|
1284
|
+
tone?: PluginOperationalTone;
|
|
1285
|
+
value: string;
|
|
1286
|
+
}
|
|
1287
|
+
interface PluginOperationalField {
|
|
1288
|
+
key: string;
|
|
1289
|
+
label: string;
|
|
1290
|
+
}
|
|
1291
|
+
interface PluginOperationalRecord {
|
|
1292
|
+
id: string;
|
|
1293
|
+
tone?: PluginOperationalTone;
|
|
1294
|
+
values: Record<string, string>;
|
|
1295
|
+
}
|
|
1296
|
+
interface PluginOperationalRecordSet {
|
|
1297
|
+
fields?: PluginOperationalField[];
|
|
1298
|
+
emptyText?: string;
|
|
1299
|
+
records?: PluginOperationalRecord[];
|
|
1300
|
+
title: string;
|
|
1301
|
+
}
|
|
1302
|
+
interface PluginOperationalChartSeries {
|
|
1303
|
+
format?: "usd";
|
|
1304
|
+
key: string;
|
|
1305
|
+
label: string;
|
|
1306
|
+
tone?: PluginOperationalTone;
|
|
1307
|
+
}
|
|
1308
|
+
interface PluginOperationalChartCategory {
|
|
1309
|
+
id: string;
|
|
1310
|
+
label: string;
|
|
1311
|
+
values: Record<string, number>;
|
|
1312
|
+
}
|
|
1313
|
+
interface PluginOperationalBarChartWidget {
|
|
1314
|
+
categories: PluginOperationalChartCategory[];
|
|
1315
|
+
description?: string;
|
|
1316
|
+
emptyText?: string;
|
|
1317
|
+
id: string;
|
|
1318
|
+
series: PluginOperationalChartSeries[];
|
|
1319
|
+
timeRangeDays?: Array<1 | 7 | 30 | 90>;
|
|
1320
|
+
title: string;
|
|
1321
|
+
type: "bar_chart";
|
|
1322
|
+
}
|
|
1323
|
+
interface PluginOperationalReportContent {
|
|
1324
|
+
generatedAt?: string;
|
|
1325
|
+
metrics?: PluginOperationalMetric[];
|
|
1326
|
+
recordSets?: PluginOperationalRecordSet[];
|
|
1327
|
+
title?: string;
|
|
1328
|
+
widgets?: PluginOperationalBarChartWidget[];
|
|
1329
|
+
}
|
|
1330
|
+
interface PluginOperationalReport extends PluginOperationalReportContent {
|
|
1331
|
+
pluginName: string;
|
|
1332
|
+
}
|
|
1333
|
+
interface OperationalReportHookContext extends PluginContext {
|
|
1334
|
+
eventStats: PluginConversationEventStats;
|
|
1335
|
+
nowMs: number;
|
|
1336
|
+
state: PluginReadState;
|
|
1337
|
+
}
|
|
1338
|
+
/** Read-only context for one person-scoped plugin report on a profile page. */
|
|
1339
|
+
interface ProfileReportHookContext extends PluginContext {
|
|
1340
|
+
nowMs: number;
|
|
1341
|
+
state: PluginReadState;
|
|
1342
|
+
/** Canonical user for the profile being viewed. */
|
|
1343
|
+
subject: User;
|
|
1344
|
+
/** Canonical user for the authenticated viewer. */
|
|
1345
|
+
viewer: User;
|
|
1346
|
+
}
|
|
1347
|
+
type PluginRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
|
|
1348
|
+
type PluginRouteHandler = {
|
|
1349
|
+
bivarianceHack(request: Request): Promise<Response> | Response;
|
|
1350
|
+
}["bivarianceHack"];
|
|
1351
|
+
interface PluginRoute {
|
|
1352
|
+
handler: PluginRouteHandler;
|
|
1353
|
+
method?: PluginRouteMethod | PluginRouteMethod[];
|
|
1354
|
+
path: string;
|
|
1355
|
+
}
|
|
1356
|
+
/** Fetch-compatible plugin HTTP app mounted by Junior. */
|
|
1357
|
+
type PluginRouteApp = {
|
|
1358
|
+
fetch(request: Request, context?: PluginApiRouteRequestContext): Promise<Response> | Response;
|
|
1359
|
+
};
|
|
1360
|
+
interface RouteRegistrationHookContext extends PluginContext {
|
|
1361
|
+
annotations: PluginConversationAnnotations;
|
|
1362
|
+
/** Provider-neutral write boundary for Junior's native code index. */
|
|
1363
|
+
codeChanges: CodeChangePublisher;
|
|
1364
|
+
/** Core-owned delivery boundary for provider webhook events. */
|
|
1365
|
+
resourceEvents: ResourceEventPublisher;
|
|
1366
|
+
}
|
|
1367
|
+
interface ApiRouteRegistrationHookContext extends PluginContext {
|
|
1368
|
+
eventStats: PluginConversationEventStats;
|
|
1369
|
+
users: {
|
|
1370
|
+
/** Resolve or create the canonical user for one verified email. */
|
|
1371
|
+
resolve(email: string): Promise<User | undefined>;
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
/** Per-request context Junior passes to authenticated plugin product API routes. */
|
|
1375
|
+
declare const pluginApiRouteRequestContextSchema: z.ZodObject<{
|
|
1376
|
+
auth: z.ZodObject<{
|
|
1377
|
+
user: z.ZodObject<{
|
|
1378
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1379
|
+
emailVerified: z.ZodOptional<z.ZodBoolean>;
|
|
1380
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1381
|
+
}, z.core.$strict>;
|
|
1382
|
+
}, z.core.$strict>;
|
|
1383
|
+
pluginName: z.ZodString;
|
|
1384
|
+
}, z.core.$strict>;
|
|
1385
|
+
type PluginApiRouteRequestContext = z.output<typeof pluginApiRouteRequestContextSchema>;
|
|
1386
|
+
interface SlackConversationLink {
|
|
1387
|
+
url: string;
|
|
1388
|
+
}
|
|
1389
|
+
interface SlackConversationLinkHookContext extends PluginContext {
|
|
1390
|
+
conversationId: string;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
interface PluginEnv {
|
|
1394
|
+
get(key: string): string | undefined;
|
|
1395
|
+
set(key: string, value: string): void;
|
|
1396
|
+
}
|
|
1397
|
+
interface PluginDecision {
|
|
1398
|
+
deny(message: string): void;
|
|
1399
|
+
replaceInput(input: Record<string, unknown>): void;
|
|
1400
|
+
}
|
|
1401
|
+
/** Thrown when a plugin tool rejects invalid model or user input. */
|
|
1402
|
+
declare class PluginToolInputError extends Error {
|
|
1403
|
+
constructor(message: string, options?: {
|
|
1404
|
+
cause?: unknown;
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
interface PluginSandbox {
|
|
1408
|
+
juniorRoot: string;
|
|
1409
|
+
root: string;
|
|
1410
|
+
readFile(path: string): Promise<Uint8Array | null>;
|
|
1411
|
+
run(input: {
|
|
1412
|
+
args?: string[];
|
|
1413
|
+
cmd: string;
|
|
1414
|
+
cwd?: string;
|
|
1415
|
+
env?: Record<string, string>;
|
|
1416
|
+
signal?: AbortSignal;
|
|
1417
|
+
sudo?: boolean;
|
|
1418
|
+
}): Promise<{
|
|
1419
|
+
exitCode: number;
|
|
1420
|
+
stderr: string;
|
|
1421
|
+
stdout: string;
|
|
1422
|
+
}>;
|
|
1423
|
+
writeFile(input: {
|
|
1424
|
+
content: string | Uint8Array;
|
|
1425
|
+
mode?: number;
|
|
1426
|
+
path: string;
|
|
1427
|
+
}): Promise<void>;
|
|
1428
|
+
}
|
|
1429
|
+
interface PluginEgress {
|
|
1430
|
+
/**
|
|
1431
|
+
* Fetch a provider URL with host-owned credentials.
|
|
1432
|
+
*
|
|
1433
|
+
* The runtime selects and injects credentials for `provider`; plugin code
|
|
1434
|
+
* owns the request shape and response handling. `operation` names the
|
|
1435
|
+
* provider action for grant selection and diagnostics.
|
|
1436
|
+
*/
|
|
1437
|
+
fetch(input: {
|
|
1438
|
+
operation: string;
|
|
1439
|
+
provider: string;
|
|
1440
|
+
request: Request;
|
|
1441
|
+
}): Promise<Response>;
|
|
1442
|
+
}
|
|
1443
|
+
declare const pluginToolContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1444
|
+
type: z.ZodLiteral<"text">;
|
|
1445
|
+
text: z.ZodString;
|
|
1446
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1447
|
+
type: z.ZodLiteral<"image">;
|
|
1448
|
+
data: z.ZodString;
|
|
1449
|
+
mimeType: z.ZodString;
|
|
1450
|
+
}, z.core.$strict>], "type">;
|
|
1451
|
+
/** Model-visible content returned by a plugin tool. */
|
|
1452
|
+
type PluginToolContent = z.output<typeof pluginToolContentSchema>;
|
|
1453
|
+
/** Pi-native projection with model-facing content and canonical runtime details. */
|
|
1454
|
+
interface PluginToolOutputEnvelope<TDetails = unknown> {
|
|
1455
|
+
content: PluginToolContent[];
|
|
1456
|
+
details: TDetails;
|
|
1457
|
+
}
|
|
1458
|
+
type PluginMcpContent = PluginToolContent;
|
|
1459
|
+
/** Successful raw provider result returned to a plugin-owned wrapper tool. */
|
|
1460
|
+
type PluginMcpToolSuccess = {
|
|
1461
|
+
content: PluginMcpContent[];
|
|
1462
|
+
status: "success";
|
|
1463
|
+
structuredContent?: unknown;
|
|
1464
|
+
};
|
|
1465
|
+
/** Handled provider authorization pause with no provider result to consume. */
|
|
1466
|
+
type PluginMcpAuthorizationPending = {
|
|
1467
|
+
status: "authorization_pending";
|
|
1468
|
+
};
|
|
1469
|
+
/** Definitive provider rejection; transport and session failures still throw. */
|
|
1470
|
+
type PluginMcpToolError = {
|
|
1471
|
+
message: string;
|
|
1472
|
+
status: "error";
|
|
1473
|
+
};
|
|
1474
|
+
type PluginMcpToolResult = PluginMcpAuthorizationPending | PluginMcpToolError | PluginMcpToolSuccess;
|
|
1475
|
+
/** Access to this plugin's hosted MCP provider without exposing credentials. */
|
|
1476
|
+
interface PluginMcp {
|
|
1477
|
+
/**
|
|
1478
|
+
* Call a provider tool declared in `wrappedTools`.
|
|
1479
|
+
*
|
|
1480
|
+
* The host activates the provider when needed. Successful calls return the
|
|
1481
|
+
* provider's original content, provider rejections return an error result,
|
|
1482
|
+
* and authorization pauses return no tool content. Transport failures throw.
|
|
1483
|
+
*/
|
|
1484
|
+
callTool(input: {
|
|
1485
|
+
arguments?: Record<string, unknown>;
|
|
1486
|
+
name: string;
|
|
1487
|
+
toolCallId?: string;
|
|
1488
|
+
}): Promise<PluginMcpToolResult>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Activate the provider before wrapper-owned state changes.
|
|
1491
|
+
*
|
|
1492
|
+
* Ordinary wrappers can call `callTool` directly. Durable mutation wrappers
|
|
1493
|
+
* may prepare first so an initial authorization pause happens before they
|
|
1494
|
+
* record pending work.
|
|
1495
|
+
*/
|
|
1496
|
+
prepare(): Promise<"authorization_pending" | "ready">;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Provider-owned, repeatable repository preparation for a Workspace Sandbox.
|
|
1500
|
+
* Implementations should refresh complete checkouts and replace missing or
|
|
1501
|
+
* partial ones.
|
|
1502
|
+
*/
|
|
1503
|
+
interface WorkspacePrepareHookContext extends PluginContext {
|
|
1504
|
+
repos: Array<{
|
|
1505
|
+
path: string;
|
|
1506
|
+
repo: string;
|
|
1507
|
+
}>;
|
|
1508
|
+
sandbox: PluginSandbox;
|
|
1509
|
+
}
|
|
1510
|
+
interface SandboxPrepareHookContext extends PluginContext {
|
|
1511
|
+
actor?: Actor;
|
|
1512
|
+
sandbox: PluginSandbox;
|
|
1513
|
+
}
|
|
1514
|
+
interface BeforeToolExecuteHookContext extends PluginContext {
|
|
1515
|
+
decision: PluginDecision;
|
|
1516
|
+
env: PluginEnv;
|
|
1517
|
+
actor?: Actor;
|
|
1518
|
+
/** All actors who contributed instructions to the run so far; see `multi-actor-runs.md`. */
|
|
1519
|
+
actors?: Actor[];
|
|
1520
|
+
tool: {
|
|
1521
|
+
input: Record<string, unknown>;
|
|
1522
|
+
name: string;
|
|
1523
|
+
};
|
|
1524
|
+
/**
|
|
1525
|
+
* Resolve the current actor's stored identity and linked user.
|
|
1526
|
+
* Same contract as tool registration; used for commit attribution.
|
|
1527
|
+
*/
|
|
1528
|
+
users: {
|
|
1529
|
+
resolveActor(): Promise<{
|
|
1530
|
+
identity: Identity;
|
|
1531
|
+
user?: User;
|
|
1532
|
+
} | undefined>;
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Context for post-success MCP tool processing.
|
|
1537
|
+
*
|
|
1538
|
+
* Runs after a hosted MCP tool succeeds on the model-facing path. Use for
|
|
1539
|
+
* junior-owned side effects such as conversation annotations without replacing
|
|
1540
|
+
* the provider tool contract.
|
|
1541
|
+
*/
|
|
1542
|
+
interface AfterMcpToolHookContext extends PluginContext {
|
|
1543
|
+
/**
|
|
1544
|
+
* Opaque Junior conversation/session identity for this turn.
|
|
1545
|
+
* Interactive Slack turns use `slack:{channelId}:{threadTs}`.
|
|
1546
|
+
*/
|
|
1547
|
+
conversationId?: string;
|
|
1548
|
+
annotations?: PluginAnnotations;
|
|
1549
|
+
result: {
|
|
1550
|
+
structuredContent?: unknown;
|
|
1551
|
+
};
|
|
1552
|
+
tool: {
|
|
1553
|
+
arguments: Record<string, unknown>;
|
|
1554
|
+
/** Provider-local MCP tool name, for example `save_issue`. */
|
|
1555
|
+
name: string;
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
interface PluginToolExecuteOptions {
|
|
1559
|
+
/**
|
|
1560
|
+
* @deprecated Internal compatibility escape hatch for legacy tool bridges.
|
|
1561
|
+
* Plugin tools should use typed input fields and runtime hook context instead.
|
|
1562
|
+
*/
|
|
1563
|
+
experimental_context?: unknown;
|
|
1564
|
+
/** Abort when the owning agent tool call is cancelled or times out. */
|
|
1565
|
+
signal?: AbortSignal;
|
|
1566
|
+
/** Stable runtime tool-call id; durable create tools should derive idempotency keys from it. */
|
|
1567
|
+
toolCallId?: string;
|
|
1568
|
+
}
|
|
1569
|
+
declare const pluginToolContinuationSchema: z.ZodObject<{
|
|
1570
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1571
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1572
|
+
}, z.core.$strict>;
|
|
1573
|
+
/** Shared optional fields for canonical plugin tool outputs. */
|
|
1574
|
+
declare const pluginToolOutputSchema: z.ZodObject<{
|
|
1575
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1576
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
1577
|
+
continuation: z.ZodOptional<z.ZodObject<{
|
|
1578
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1579
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1580
|
+
}, z.core.$strict>>;
|
|
1581
|
+
}, z.core.$loose>;
|
|
1582
|
+
type PluginToolOutput = z.output<typeof pluginToolOutputSchema>;
|
|
1583
|
+
type PluginToolExecute<TInput = unknown, TOutput = unknown> = {
|
|
1584
|
+
bivarianceHack(input: TInput, options: PluginToolExecuteOptions): Promise<TOutput> | TOutput;
|
|
1585
|
+
}["bivarianceHack"];
|
|
1586
|
+
/**
|
|
1587
|
+
* Tool-declared approval mode.
|
|
1588
|
+
*
|
|
1589
|
+
* `auto` delegates to core policy, `review` enters Guardian review, and
|
|
1590
|
+
* `approve` permits execution without review. Plugin tool helpers normalize
|
|
1591
|
+
* omission to `auto`.
|
|
1592
|
+
*
|
|
1593
|
+
* Core resolves the effective mode immediately before execution.
|
|
1594
|
+
*/
|
|
1595
|
+
declare const toolApprovalModeSchema: z.ZodEnum<{
|
|
1596
|
+
auto: "auto";
|
|
1597
|
+
review: "review";
|
|
1598
|
+
approve: "approve";
|
|
1599
|
+
}>;
|
|
1600
|
+
type ToolApprovalMode = z.output<typeof toolApprovalModeSchema>;
|
|
1601
|
+
/**
|
|
1602
|
+
* Reviewer signals describing a tool's side-effect behavior.
|
|
1603
|
+
*
|
|
1604
|
+
* These hints follow the MCP tool annotation contract. Guardian may use
|
|
1605
|
+
* them as signals, but they never grant authority or override deterministic
|
|
1606
|
+
* authorization.
|
|
1607
|
+
*/
|
|
1608
|
+
interface ToolAnnotations {
|
|
1609
|
+
[key: string]: unknown;
|
|
1610
|
+
destructiveHint?: boolean;
|
|
1611
|
+
idempotentHint?: boolean;
|
|
1612
|
+
openWorldHint?: boolean;
|
|
1613
|
+
readOnlyHint?: boolean;
|
|
1614
|
+
title?: string;
|
|
1615
|
+
}
|
|
1616
|
+
declare const REQUIRED_TOOL_ANNOTATION_KEYS: readonly ["destructiveHint", "idempotentHint", "openWorldHint", "readOnlyHint"];
|
|
1617
|
+
type RequiredToolAnnotationKey = (typeof REQUIRED_TOOL_ANNOTATION_KEYS)[number];
|
|
1618
|
+
/** Return behavioral annotation keys that a tool did not declare. */
|
|
1619
|
+
declare function missingToolAnnotationKeys(annotations: ToolAnnotations | undefined): RequiredToolAnnotationKey[];
|
|
1620
|
+
/**
|
|
1621
|
+
* Canonical approval metadata declared by core and plugin tools.
|
|
1622
|
+
*/
|
|
1623
|
+
interface ToolApprovalMetadata<TInput = unknown> {
|
|
1624
|
+
/** Optional declared approval mode; the owning tool boundary selects defaults. */
|
|
1625
|
+
approvalMode?: ToolApprovalMode;
|
|
1626
|
+
annotations?: ToolAnnotations;
|
|
1627
|
+
/**
|
|
1628
|
+
* Describe the reviewed semantic action for the review request.
|
|
1629
|
+
*
|
|
1630
|
+
* Core owns authoritative tool, actor, source, destination, conversation,
|
|
1631
|
+
* credential, and input data. This description adds domain-specific context
|
|
1632
|
+
* only and is never an authorization grant.
|
|
1633
|
+
*/
|
|
1634
|
+
describeProposal?(input: TInput): string;
|
|
1635
|
+
}
|
|
1636
|
+
interface PluginToolDefinition<TInput = unknown, TOutput = unknown, TExecuteOutput = TOutput> extends ToolApprovalMetadata<TInput> {
|
|
1637
|
+
description: string;
|
|
1638
|
+
executionMode?: unknown;
|
|
1639
|
+
inputSchema: unknown;
|
|
1640
|
+
outputSchema?: unknown;
|
|
1641
|
+
/**
|
|
1642
|
+
* Select result fields that are safe to retain in private traces.
|
|
1643
|
+
* Returning `undefined` suppresses private result capture.
|
|
1644
|
+
*/
|
|
1645
|
+
privateTraceResult?(result: TOutput): unknown;
|
|
1646
|
+
prepareArguments?: (args: unknown) => TInput;
|
|
1647
|
+
/**
|
|
1648
|
+
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
1649
|
+
* and parameter descriptions. Retained for compatibility; may be removed in a
|
|
1650
|
+
* future major version.
|
|
1651
|
+
*/
|
|
1652
|
+
promptGuidelines?: string[];
|
|
1653
|
+
/**
|
|
1654
|
+
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
1655
|
+
* and parameter descriptions. Retained for compatibility; may be removed in a
|
|
1656
|
+
* future major version.
|
|
1657
|
+
*/
|
|
1658
|
+
promptSnippet?: string;
|
|
1659
|
+
execute?: PluginToolExecute<TInput, TExecuteOutput>;
|
|
1660
|
+
}
|
|
1661
|
+
type ZodPluginToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>> = Omit<PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>>, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
1662
|
+
inputSchema: TInputSchema;
|
|
1663
|
+
outputSchema: TOutputSchema;
|
|
1664
|
+
prepareArguments?: (args: unknown) => z.input<TInputSchema>;
|
|
1665
|
+
execute?: (input: z.output<TInputSchema>, options: PluginToolExecuteOptions) => Promise<TExecuteResult> | TExecuteResult;
|
|
1666
|
+
};
|
|
1667
|
+
type ParsedPluginToolExecuteResult<TOutputSchema extends ZodTypeAny, TResult> = TResult extends PluginToolOutputEnvelope<unknown> ? PluginToolOutputEnvelope<z.output<TOutputSchema>> : z.output<TOutputSchema>;
|
|
1668
|
+
/** Define a plugin tool with Zod input parsing and validated structured results. */
|
|
1669
|
+
declare function zodTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema, TExecuteResult>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>, ParsedPluginToolExecuteResult<TOutputSchema, TExecuteResult>>;
|
|
1670
|
+
/** Define a plugin tool with Zod input parsing and the structured result contract. */
|
|
1671
|
+
declare function definePluginTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema, TExecuteResult>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>, ParsedPluginToolExecuteResult<TOutputSchema, TExecuteResult>>;
|
|
1672
|
+
interface SlackToolRegistrationHookContext {
|
|
1673
|
+
/**
|
|
1674
|
+
* What Slack tools can do in the Conversation Location.
|
|
1675
|
+
* Computed from Location, not from Source or Destination.
|
|
1676
|
+
*/
|
|
1677
|
+
channelCapabilities: {
|
|
1678
|
+
canAddReactions: boolean;
|
|
1679
|
+
canCreateCanvas: boolean;
|
|
1680
|
+
canPostToChannel: boolean;
|
|
1681
|
+
};
|
|
1682
|
+
/** Host-owned link to this conversation, preferring the dashboard when enabled. */
|
|
1683
|
+
conversationLink?: SlackConversationLink;
|
|
1684
|
+
credentialSubject?: Extract<PluginCredentialSubject, {
|
|
1685
|
+
allowedWhen: "private-direct-conversation";
|
|
1686
|
+
}>;
|
|
1687
|
+
}
|
|
1688
|
+
interface PluginResourceEventToolContext {
|
|
1689
|
+
/** Whether this invocation can create a working resource subscription. */
|
|
1690
|
+
canSubscribe: boolean;
|
|
1691
|
+
/** Create a temporary resource subscription for the current conversation. */
|
|
1692
|
+
subscribe(input: {
|
|
1693
|
+
events: string[];
|
|
1694
|
+
intent: string;
|
|
1695
|
+
resource: SubscribableResource;
|
|
1696
|
+
}): Promise<ResourceEventSubscriptionResult>;
|
|
1697
|
+
}
|
|
1698
|
+
interface PluginWorkspaceToolContext {
|
|
1699
|
+
/** Find named Workspaces that include one provider repository. */
|
|
1700
|
+
findByRepository(input: {
|
|
1701
|
+
provider: string;
|
|
1702
|
+
repo: string;
|
|
1703
|
+
}): Promise<string[]>;
|
|
1704
|
+
}
|
|
1705
|
+
interface BaseToolRegistrationHookContext extends PluginContext {
|
|
1706
|
+
/**
|
|
1707
|
+
* Opaque Junior conversation/session identity for this turn.
|
|
1708
|
+
* Interactive Slack turns use `slack:{channelId}:{threadTs}`.
|
|
1709
|
+
* Scheduled/web turns use an internal id such as `agent-dispatch:{id}`.
|
|
1710
|
+
* Do not parse as Slack unless the value starts with `slack:`.
|
|
1711
|
+
*/
|
|
1712
|
+
conversationId?: string;
|
|
1713
|
+
annotations?: PluginAnnotations;
|
|
1714
|
+
embedder: PluginEmbedder;
|
|
1715
|
+
egress: PluginEgress;
|
|
1716
|
+
mcp?: PluginMcp;
|
|
1717
|
+
model: PluginModel;
|
|
1718
|
+
resourceEvents: PluginResourceEventToolContext;
|
|
1719
|
+
/** Sandbox filesystem and command capability for plugin-owned workspace tools. */
|
|
1720
|
+
sandbox: PluginSandbox;
|
|
1721
|
+
state: PluginState;
|
|
1722
|
+
users: {
|
|
1723
|
+
/** Resolve the current actor's stored identity and linked user. */
|
|
1724
|
+
resolveActor(): Promise<{
|
|
1725
|
+
identity: Identity;
|
|
1726
|
+
user?: User;
|
|
1727
|
+
} | undefined>;
|
|
1728
|
+
};
|
|
1729
|
+
userText?: string;
|
|
1730
|
+
workspaces: PluginWorkspaceToolContext;
|
|
1731
|
+
}
|
|
1732
|
+
type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
|
|
1733
|
+
/** Slack tool details when the Conversation has a Slack Location. */
|
|
1734
|
+
slack?: SlackToolRegistrationHookContext;
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Deny provider egress when a plugin policy does not allow the request.
|
|
1739
|
+
*
|
|
1740
|
+
* Call from a plugin `grantForEgress` hook before returning a write grant.
|
|
1741
|
+
*/
|
|
1742
|
+
declare function enforceEgressPolicy(input: {
|
|
1743
|
+
allowed: boolean;
|
|
1744
|
+
denialMessage: string;
|
|
1745
|
+
}): void;
|
|
1746
|
+
|
|
1747
|
+
/** Input for a pure Markdown rewrite before destination delivery formatting. */
|
|
1748
|
+
interface FormatMarkdownHookContext {
|
|
1749
|
+
text: string;
|
|
1750
|
+
}
|
|
1751
|
+
interface PluginHooks {
|
|
1752
|
+
conversationSidebar?(ctx: ConversationSidebarHookContext): Promise<ConversationSidebarResult> | ConversationSidebarResult;
|
|
1753
|
+
systemPrompt?(ctx: SystemPromptContext): Promise<PromptMessage[]> | PromptMessage[];
|
|
1754
|
+
userPrompt?(ctx: UserPromptContext): Promise<UserPromptContribution[] | undefined> | UserPromptContribution[] | undefined;
|
|
1755
|
+
beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
|
|
1756
|
+
/**
|
|
1757
|
+
* Run after a successful hosted MCP tool call.
|
|
1758
|
+
*
|
|
1759
|
+
* Prefer this for junior-owned side effects such as conversation annotations.
|
|
1760
|
+
* Do not use it to invent a parallel tool contract for the provider tool.
|
|
1761
|
+
*/
|
|
1762
|
+
afterMcpTool?(ctx: AfterMcpToolHookContext): Promise<void> | void;
|
|
1763
|
+
grantForEgress?(ctx: EgressHookContext): Promise<PluginGrant | undefined> | PluginGrant | undefined;
|
|
1764
|
+
heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
|
|
1765
|
+
unfinishedWork?(ctx: UnfinishedWorkHookContext): Promise<UnfinishedWorkResult> | UnfinishedWorkResult;
|
|
1766
|
+
issueCredential?(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult> | PluginCredentialResult;
|
|
1767
|
+
onEgressResponse?(ctx: EgressResponseHookContext): Promise<void> | void;
|
|
1768
|
+
operationalReport?(ctx: OperationalReportHookContext): Promise<PluginOperationalReportContent | undefined> | PluginOperationalReportContent | undefined;
|
|
1769
|
+
/**
|
|
1770
|
+
* Return one person-scoped operational report for a profile page.
|
|
1771
|
+
* Omit or return undefined when the plugin has nothing to show for the subject.
|
|
1772
|
+
*/
|
|
1773
|
+
profileReport?(ctx: ProfileReportHookContext): Promise<PluginOperationalReportContent | undefined> | PluginOperationalReportContent | undefined;
|
|
1774
|
+
/** Return plugin-owned product API routes mounted under Junior's authenticated plugin namespace. */
|
|
1775
|
+
apiRoutes?(ctx: ApiRouteRegistrationHookContext): PluginRouteApp | undefined;
|
|
1776
|
+
resolveOAuthAccount?(ctx: ResolveOAuthAccountHookContext): Promise<PluginProviderAccount | undefined> | PluginProviderAccount | undefined;
|
|
1777
|
+
routes?(ctx: RouteRegistrationHookContext): PluginRoute[];
|
|
1778
|
+
sandboxPrepare?(ctx: SandboxPrepareHookContext): Promise<void> | void;
|
|
1779
|
+
workspacePrepare?(ctx: WorkspacePrepareHookContext): Promise<void> | void;
|
|
1780
|
+
slackConversationLink?(ctx: SlackConversationLinkHookContext): SlackConversationLink | undefined;
|
|
1781
|
+
/** Pure Markdown rewrite. Emit ordinary Markdown only. */
|
|
1782
|
+
formatMarkdown?(ctx: FormatMarkdownHookContext): string;
|
|
1783
|
+
tools?(ctx: ToolRegistrationHookContext): Record<string, PluginToolDefinition>;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* Public Commander-based CLI contract for plugin-owned admin commands.
|
|
1788
|
+
* Junior owns the root command, plugin namespaces, context injection, and exit
|
|
1789
|
+
* normalization; plugins only configure subcommands under their namespace.
|
|
1790
|
+
*/
|
|
1791
|
+
|
|
1792
|
+
interface PluginCliIo {
|
|
1793
|
+
writeError(text: string): Promise<void> | void;
|
|
1794
|
+
writeOutput(text: string): Promise<void> | void;
|
|
1795
|
+
}
|
|
1796
|
+
interface PluginCliActionCommand {
|
|
1797
|
+
name: string;
|
|
1798
|
+
summary: string;
|
|
1799
|
+
}
|
|
1800
|
+
/** Host/admin context exposed to plugin-owned CLI command actions. */
|
|
1801
|
+
interface PluginCliActionContext extends Pick<PluginContext, "db" | "log" | "plugin"> {
|
|
1802
|
+
command: PluginCliActionCommand;
|
|
1803
|
+
io: PluginCliIo;
|
|
1804
|
+
}
|
|
1805
|
+
/** Plugin action callback wrapped by the Junior host for context and exit codes. */
|
|
1806
|
+
type PluginCliActionHandler<Args extends unknown[] = unknown[]> = (ctx: PluginCliActionContext, ...args: Args) => Promise<number | void> | number | void;
|
|
1807
|
+
interface PluginCliHost {
|
|
1808
|
+
/** Wrap a Commander action so Junior can inject context and normalize exits. */
|
|
1809
|
+
action<Args extends unknown[]>(handler: PluginCliActionHandler<Args>): (...args: Args) => Promise<void>;
|
|
1810
|
+
}
|
|
1811
|
+
/** Plugin-owned top-level CLI command registration. */
|
|
1812
|
+
interface PluginCliCommandDefinition {
|
|
1813
|
+
/** Configure subcommands under the host-created top-level namespace. */
|
|
1814
|
+
configure(command: Command, junior: PluginCliHost): void;
|
|
1815
|
+
/** Unique host-level command namespace owned by this plugin. */
|
|
1816
|
+
name: string;
|
|
1817
|
+
/** One-line summary used in generated command help. */
|
|
1818
|
+
summary: string;
|
|
1819
|
+
}
|
|
1820
|
+
/** Plugin-owned CLI command catalog. */
|
|
1821
|
+
interface PluginCliDefinition {
|
|
1822
|
+
commands: PluginCliCommandDefinition[];
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
interface PluginOAuthConfig {
|
|
1826
|
+
authorizeEndpoint: string;
|
|
1827
|
+
authorizeParams?: Record<string, string>;
|
|
1828
|
+
clientIdEnv: string;
|
|
1829
|
+
clientSecretEnv: string;
|
|
1830
|
+
scope?: string;
|
|
1831
|
+
/**
|
|
1832
|
+
* Treat a provider token response with `scope: ""` like an omitted scope and
|
|
1833
|
+
* fall back to the requested scope string when storing the token.
|
|
1834
|
+
*/
|
|
1835
|
+
treatEmptyScopeAsUnreported?: boolean;
|
|
1836
|
+
tokenAuthMethod?: "body" | "basic";
|
|
1837
|
+
tokenEndpoint: string;
|
|
1838
|
+
tokenExtraHeaders?: Record<string, string>;
|
|
1839
|
+
}
|
|
1840
|
+
interface PluginOAuthBearerCredentials {
|
|
1841
|
+
apiHeaders?: Record<string, string>;
|
|
1842
|
+
authTokenEnv: string;
|
|
1843
|
+
authTokenPlaceholder?: string;
|
|
1844
|
+
domains: string[];
|
|
1845
|
+
type: "oauth-bearer";
|
|
1846
|
+
}
|
|
1847
|
+
type PluginCredentials = PluginOAuthBearerCredentials;
|
|
1848
|
+
interface PluginNpmRuntimeDependency {
|
|
1849
|
+
package: string;
|
|
1850
|
+
type: "npm";
|
|
1851
|
+
version: string;
|
|
1852
|
+
}
|
|
1853
|
+
interface PluginSystemRuntimeDependency {
|
|
1854
|
+
package: string;
|
|
1855
|
+
type: "system";
|
|
1856
|
+
}
|
|
1857
|
+
interface PluginSystemRuntimeDependencyFromUrl {
|
|
1858
|
+
sha256: string;
|
|
1859
|
+
type: "system";
|
|
1860
|
+
url: string;
|
|
1861
|
+
}
|
|
1862
|
+
type PluginRuntimeDependency = PluginNpmRuntimeDependency | PluginSystemRuntimeDependency | PluginSystemRuntimeDependencyFromUrl;
|
|
1863
|
+
interface PluginRuntimePostinstallCommand {
|
|
1864
|
+
args?: string[];
|
|
1865
|
+
cmd: string;
|
|
1866
|
+
sudo?: boolean;
|
|
1867
|
+
}
|
|
1868
|
+
interface PluginMcpConfig {
|
|
1869
|
+
/** Provider tools exposed directly to the model. */
|
|
1870
|
+
allowedTools?: string[];
|
|
1871
|
+
headers?: Record<string, string>;
|
|
1872
|
+
transport: "http";
|
|
1873
|
+
url: string;
|
|
1874
|
+
/** Provider tools hidden from the model and callable only by plugin-owned wrapper tools. */
|
|
1875
|
+
wrappedTools?: string[];
|
|
1876
|
+
}
|
|
1877
|
+
interface PluginEnvVarDeclaration {
|
|
1878
|
+
default?: string;
|
|
1879
|
+
exposeToCommandEnv?: boolean;
|
|
1880
|
+
}
|
|
1881
|
+
interface PluginManifest {
|
|
1882
|
+
apiHeaders?: Record<string, string>;
|
|
1883
|
+
commandEnv?: Record<string, string>;
|
|
1884
|
+
configKeys?: string[];
|
|
1885
|
+
credentials?: PluginCredentials;
|
|
1886
|
+
description: string;
|
|
1887
|
+
displayName: string;
|
|
1888
|
+
domains?: string[];
|
|
1889
|
+
envVars?: Record<string, PluginEnvVarDeclaration>;
|
|
1890
|
+
mcp?: PluginMcpConfig;
|
|
1891
|
+
name: string;
|
|
1892
|
+
oauth?: PluginOAuthConfig;
|
|
1893
|
+
runtimeDependencies?: PluginRuntimeDependency[];
|
|
1894
|
+
runtimePostinstall?: PluginRuntimePostinstallCommand[];
|
|
1895
|
+
target?: {
|
|
1896
|
+
commandFlags?: string[];
|
|
1897
|
+
configKey: string;
|
|
1898
|
+
type: string;
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
/**
|
|
1903
|
+
* Core-rendered plugin user pages.
|
|
1904
|
+
*
|
|
1905
|
+
* Plugins own bounded data projection; Junior owns viewer authorization,
|
|
1906
|
+
* routing, response validation, and browser rendering.
|
|
1907
|
+
*/
|
|
1908
|
+
|
|
1909
|
+
/** Bounded list content returned by a plugin-owned user page. */
|
|
1910
|
+
declare const pluginUserPageContentSchema: z.ZodObject<{
|
|
1911
|
+
emptyText: z.ZodOptional<z.ZodString>;
|
|
1912
|
+
metrics: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1913
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
1914
|
+
label: z.ZodString;
|
|
1915
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
1916
|
+
warning: "warning";
|
|
1917
|
+
good: "good";
|
|
1918
|
+
neutral: "neutral";
|
|
1919
|
+
}>>;
|
|
1920
|
+
value: z.ZodString;
|
|
1921
|
+
}, z.core.$strict>>>;
|
|
1922
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
1923
|
+
records: z.ZodArray<z.ZodObject<{
|
|
1924
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1925
|
+
confirmation: z.ZodOptional<z.ZodString>;
|
|
1926
|
+
href: z.ZodString;
|
|
1927
|
+
label: z.ZodString;
|
|
1928
|
+
method: z.ZodLiteral<"DELETE">;
|
|
1929
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
1930
|
+
danger: "danger";
|
|
1931
|
+
neutral: "neutral";
|
|
1932
|
+
}>>;
|
|
1933
|
+
}, z.core.$strict>>>;
|
|
1934
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1935
|
+
id: z.ZodString;
|
|
1936
|
+
metadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1937
|
+
label: z.ZodString;
|
|
1938
|
+
value: z.ZodString;
|
|
1939
|
+
}, z.core.$strict>>>;
|
|
1940
|
+
title: z.ZodString;
|
|
1941
|
+
}, z.core.$strict>>;
|
|
1942
|
+
searchPlaceholder: z.ZodOptional<z.ZodString>;
|
|
1943
|
+
type: z.ZodLiteral<"list">;
|
|
1944
|
+
}, z.core.$strict>;
|
|
1945
|
+
/** Validated content for the current core-rendered list page type. */
|
|
1946
|
+
type PluginUserPageContent = z.output<typeof pluginUserPageContentSchema>;
|
|
1947
|
+
declare const pluginUserPageLinkSchema: z.ZodObject<{
|
|
1948
|
+
description: z.ZodString;
|
|
1949
|
+
id: z.ZodString;
|
|
1950
|
+
label: z.ZodString;
|
|
1951
|
+
navigation: z.ZodEnum<{
|
|
1952
|
+
primary: "primary";
|
|
1953
|
+
profile: "profile";
|
|
1954
|
+
}>;
|
|
1955
|
+
pluginDisplayName: z.ZodString;
|
|
1956
|
+
pluginName: z.ZodString;
|
|
1957
|
+
}, z.core.$strict>;
|
|
1958
|
+
declare const pluginUserPageLinksSchema: z.ZodArray<z.ZodObject<{
|
|
1959
|
+
description: z.ZodString;
|
|
1960
|
+
id: z.ZodString;
|
|
1961
|
+
label: z.ZodString;
|
|
1962
|
+
navigation: z.ZodEnum<{
|
|
1963
|
+
primary: "primary";
|
|
1964
|
+
profile: "profile";
|
|
1965
|
+
}>;
|
|
1966
|
+
pluginDisplayName: z.ZodString;
|
|
1967
|
+
pluginName: z.ZodString;
|
|
1968
|
+
}, z.core.$strict>>;
|
|
1969
|
+
/** Safe navigation metadata for one registered plugin user page. */
|
|
1970
|
+
type PluginUserPageLink = z.output<typeof pluginUserPageLinkSchema>;
|
|
1971
|
+
/** Optional cursor token for one plugin user page reader. */
|
|
1972
|
+
declare const pluginUserPageCursorSchema: z.ZodOptional<z.ZodString>;
|
|
1973
|
+
/** Optional filter token for one plugin user page reader. */
|
|
1974
|
+
declare const pluginUserPageFilterSchema: z.ZodOptional<z.ZodString>;
|
|
1975
|
+
/** Optional free-text query for one plugin user page reader. */
|
|
1976
|
+
declare const pluginUserPageQuerySchema: z.ZodOptional<z.ZodString>;
|
|
1977
|
+
/** Validated query state passed to one plugin user page reader. */
|
|
1978
|
+
declare const pluginUserPageInputSchema: z.ZodObject<{
|
|
1979
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
1980
|
+
filter: z.ZodOptional<z.ZodString>;
|
|
1981
|
+
limit: z.ZodNumber;
|
|
1982
|
+
query: z.ZodOptional<z.ZodString>;
|
|
1983
|
+
}, z.core.$strict>;
|
|
1984
|
+
type PluginUserPageInput = z.output<typeof pluginUserPageInputSchema>;
|
|
1985
|
+
/** Trusted host context supplied while reading one plugin user page. */
|
|
1986
|
+
interface PluginUserPageContext extends PluginContext {
|
|
1987
|
+
viewer: User;
|
|
1988
|
+
}
|
|
1989
|
+
/** Navigation metadata and reader for one core-rendered plugin user page. */
|
|
1990
|
+
interface PluginUserPageDefinition {
|
|
1991
|
+
description: string;
|
|
1992
|
+
id: string;
|
|
1993
|
+
label: string;
|
|
1994
|
+
/** Dashboard navigation surface where this page is linked. */
|
|
1995
|
+
navigation?: "primary" | "profile";
|
|
1996
|
+
read(ctx: PluginUserPageContext, input: PluginUserPageInput): Promise<PluginUserPageContent> | PluginUserPageContent;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
interface PluginModelConfig {
|
|
2000
|
+
/** Host model family used when no explicit structured model id is configured. */
|
|
2001
|
+
structuredModel?: "default" | "fast";
|
|
2002
|
+
/** Host model id used for this plugin's structured model calls. */
|
|
2003
|
+
structuredModelId?: string;
|
|
2004
|
+
}
|
|
2005
|
+
type PluginRegistrationInput = {
|
|
2006
|
+
cli?: PluginCliDefinition;
|
|
2007
|
+
conversationEvents?: PluginConversationEventDefinition[];
|
|
2008
|
+
hooks?: PluginHooks;
|
|
2009
|
+
manifest: PluginManifest;
|
|
2010
|
+
model?: PluginModelConfig;
|
|
2011
|
+
packageName?: string;
|
|
2012
|
+
resourceEvents?: PluginResourceEvents;
|
|
2013
|
+
tasks?: PluginTasks;
|
|
2014
|
+
userPages?: PluginUserPageDefinition[];
|
|
2015
|
+
};
|
|
2016
|
+
interface PluginRegistration extends PluginRegistrationInput {
|
|
2017
|
+
}
|
|
2018
|
+
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
2019
|
+
declare function defineJuniorPlugin(plugin: PluginRegistrationInput): PluginRegistration;
|
|
2020
|
+
|
|
2021
|
+
export { type Actor, type AfterMcpToolHookContext, type AgentInvocationSource, type ApiRouteRegistrationHookContext, type BeforeToolExecuteHookContext, type CodeChangeInput, type CodeChangePublisher, type CodeChangeState, type ConversationAnnotation, type ConversationAnnotationInput, type ConversationEventPresentation, type ConversationSidebarAnnotation, type ConversationSidebarHookContext, type ConversationSidebarResult, type DefinedConversationEvent, type Destination, type DestinationVisibility, type Dispatch, type DispatchOptions, type DispatchResult, EgressAuthRequired, type EgressHookContext, EgressPolicyDenied, type EgressResponseHookContext, type EventTaskSource, type FormatMarkdownHookContext, type HeartbeatHookContext, type HeartbeatResult, type Identity, type InvocationContext, type IssueCredentialHookContext, type LocalActor, type LocalDestination, type LocalInvocationContext, type LocalSource, type Location, type OperationalReportHookContext, type Platform, type PluginAnnotations, type PluginApiRouteRequestContext, type PluginAuthorization, type PluginCliActionCommand, type PluginCliActionContext, type PluginCliActionHandler, type PluginCliCommandDefinition, type PluginCliDefinition, type PluginCliHost, type PluginCliIo, type PluginContext, type PluginConversationAnnotations, type PluginConversationEventCostDay, type PluginConversationEventDefinition, type PluginConversationEventStats, type PluginConversationEventValue, type PluginConversationEvents, type PluginCredentialActor, type PluginCredentialHeaderTransform, type PluginCredentialLease, type PluginCredentialResult, type PluginCredentialSubject, type PluginCredentials, type PluginDecision, type PluginDispatchSource, type PluginEgress, type PluginEgressRequest, type PluginEgressResponse, type PluginEmbedder, type PluginEnv, type PluginEnvVarDeclaration, type PluginGrant, type PluginGrantAccess, type PluginHooks, type PluginLogger, type PluginManifest, type PluginMcp, type PluginMcpAuthorizationPending, type PluginMcpConfig, type PluginMcpContent, type PluginMcpToolError, type PluginMcpToolResult, type PluginMcpToolSuccess, type PluginMetadata, type PluginModel, type PluginModelConfig, type PluginNpmRuntimeDependency, type PluginOAuthBearerCredentials, type PluginOAuthConfig, type PluginOperationalBarChartWidget, type PluginOperationalChartCategory, type PluginOperationalChartSeries, type PluginOperationalField, type PluginOperationalMetric, type PluginOperationalRecord, type PluginOperationalRecordSet, type PluginOperationalReport, type PluginOperationalReportContent, type PluginOperationalTone, type PluginProviderAccount, type PluginReadState, type PluginRegistration, type PluginRegistrationInput, type PluginResolvedCredentialUser, type PluginResourceEventToolContext, type PluginResourceEventType, type PluginResourceEvents, type PluginRoute, type PluginRouteApp, type PluginRouteHandler, type PluginRouteMethod, type PluginRunContext, type PluginRunTranscriptEntry, type PluginRunTranscriptProvenance, type PluginRuntimeDependency, type PluginRuntimePostinstallCommand, type PluginSandbox, type PluginState, type PluginStoredTokens, type PluginSystemRuntimeDependency, type PluginSystemRuntimeDependencyFromUrl, type PluginTaskContext, type PluginTaskDefinition, type PluginTasks, type PluginTokenStore, type PluginToolContent, type PluginToolDefinition, type PluginToolExecute, type PluginToolExecuteOptions, PluginToolInputError, type PluginToolOutput, type PluginToolOutputEnvelope, type PluginUserPageContent, type PluginUserPageContext, type PluginUserPageDefinition, type PluginUserPageInput, type PluginUserPageLink, type PluginUserTokenSlot, type PluginWorkspaceToolContext, type ProfileReportHookContext, type PromptContext, type PromptContextContribution, type PromptMessage, REQUIRED_TOOL_ANNOTATION_KEYS, RESOURCE_EVENT_DATA_MAX_JSON_BYTES, RESOURCE_EVENT_DATA_MAX_KEYS, RESOURCE_EVENT_GUIDANCE_MAX_LENGTH, RESOURCE_EVENT_SUMMARY_MAX_LENGTH, RESOURCE_EVENT_TEXT_MAX_LENGTH, type ReplyAttribution, type RequiredToolAnnotationKey, type ResolveOAuthAccountHookContext, type ResourceEvent, type ResourceEventData, type ResourceEventInput, type ResourceEventInvocationContext, type ResourceEventMatch, type ResourceEventMatchFields, type ResourceEventPublisher, type ResourceEventSource, type ResourceEventSubscriptionResult, type RouteRegistrationHookContext, type SandboxPrepareHookContext, type ScheduledTaskSource, type SlackActor, type SlackConversationLink, type SlackConversationLinkHookContext, type SlackDestination, type SlackInvocationContext, type SlackLocation, type SlackSource, type SlackToolRegistrationHookContext, type Source, type SourceVisibility, type SubscribableResource, type SystemActor, type SystemPromptContext, type ToolAnnotations, type ToolApprovalMetadata, type ToolApprovalMode, type ToolRegistrationHookContext, type UnfinishedWorkHookContext, type UnfinishedWorkResult, type User, type UserPromptContext, type UserPromptContribution, type WebActor, type WebInvocationContext, type WebSource, type WorkspacePrepareHookContext, actorSchema, actorUserIdSchema, agentInvocationSourceSchema, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createLocalSource, createResourceEventSource, createSlackSource, createWebSource, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventTaskSourceSchema, getSourceKey, identitySchema, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, missingToolAnnotationKeys, nonBlankStringSchema, normalizeResourceEventIdentifier, platformSchema, pluginApiRouteRequestContextSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginGrantSchema, pluginProviderAccountSchema, pluginResourceEventTypeSchema, pluginResourceEventsSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, replyAttributionSchema, resourceEventDataSchema, resourceEventInputSchema, resourceEventMatchFieldSchema, resourceEventMatchFieldsSchema, resourceEventMatchSchema, resourceEventMatches, resourceEventSchema, resourceEventSourceSchema, resourceEventSubscriptionResultSchema, resourceEventTypeSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledTaskSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableResourceEventMatchKey, subscribableResourceSchema, systemActorSchema, toolApprovalModeSchema, userSchema, webActorSchema, webSourceSchema, zodTool };
|