@zhama/tego-plugin-sdk 0.0.0-stage → 1.36.1
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/LICENSE +172 -0
- package/README.md +846 -2
- package/access-catalog.schema.json +304 -0
- package/access-fixtures/resolve.json +1359 -0
- package/bin/tego-plugin-pack.mjs +2 -0
- package/bin/tego-plugin.mjs +3 -0
- package/dist/access-drizzle.cjs +1 -0
- package/dist/access-drizzle.d.cts +726 -0
- package/dist/access-drizzle.d.ts +726 -0
- package/dist/access-drizzle.js +1 -0
- package/dist/access-hono.cjs +3 -0
- package/dist/access-hono.d.cts +108 -0
- package/dist/access-hono.d.ts +108 -0
- package/dist/access-hono.js +3 -0
- package/dist/access-implications.cjs +1 -0
- package/dist/access-implications.d.cts +25 -0
- package/dist/access-implications.d.ts +25 -0
- package/dist/access-implications.js +1 -0
- package/dist/access.cjs +26 -0
- package/dist/access.d.cts +884 -0
- package/dist/access.d.ts +884 -0
- package/dist/access.js +26 -0
- package/dist/catalog-CSSbrfEf.d.cts +361 -0
- package/dist/catalog-CSSbrfEf.d.ts +361 -0
- package/dist/chunk-3KUOBGJN.js +19 -0
- package/dist/chunk-3WA3M347.cjs +1 -0
- package/dist/chunk-5CU33JVY.js +1 -0
- package/dist/chunk-7K37PVGV.js +5 -0
- package/dist/chunk-7XHF3YSK.js +1 -0
- package/dist/chunk-AJY7ZHXK.cjs +3 -0
- package/dist/chunk-BN6TGHSB.cjs +1 -0
- package/dist/chunk-BTHXQWHT.js +1 -0
- package/dist/chunk-C2OCOPZQ.cjs +1 -0
- package/dist/chunk-IMAVYQ4U.cjs +4 -0
- package/dist/chunk-OP64Y4IN.cjs +1 -0
- package/dist/chunk-QKSPPMVN.js +1 -0
- package/dist/chunk-ROFUQLOZ.cjs +1 -0
- package/dist/chunk-SNUCO2MK.js +1 -0
- package/dist/chunk-THMWRUAT.cjs +19 -0
- package/dist/chunk-VMCGDDGP.js +3 -0
- package/dist/chunk-W7C357A6.cjs +5 -0
- package/dist/chunk-WLTASJF6.js +4 -0
- package/dist/egress.cjs +7 -0
- package/dist/egress.d.cts +9 -0
- package/dist/egress.d.ts +9 -0
- package/dist/egress.js +7 -0
- package/dist/frontend.cjs +2 -0
- package/dist/frontend.d.cts +353 -0
- package/dist/frontend.d.ts +353 -0
- package/dist/frontend.js +2 -0
- package/dist/gateway-signature.cjs +1 -0
- package/dist/gateway-signature.d.cts +112 -0
- package/dist/gateway-signature.d.ts +112 -0
- package/dist/gateway-signature.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +528 -0
- package/dist/index.d.ts +528 -0
- package/dist/index.js +1 -0
- package/dist/manifest-types-DQARCQJt.d.cts +627 -0
- package/dist/manifest-types-DQARCQJt.d.ts +627 -0
- package/dist/manifest.cjs +1 -0
- package/dist/manifest.d.cts +2824 -0
- package/dist/manifest.d.ts +2824 -0
- package/dist/manifest.js +1 -0
- package/dist/mcp-identity.cjs +2 -0
- package/dist/mcp-identity.d.cts +106 -0
- package/dist/mcp-identity.d.ts +106 -0
- package/dist/mcp-identity.js +2 -0
- package/dist/pack.cjs +1 -0
- package/dist/pack.d.cts +169 -0
- package/dist/pack.d.ts +169 -0
- package/dist/pack.js +1 -0
- package/dist/publish.cjs +1 -0
- package/dist/publish.d.cts +96 -0
- package/dist/publish.d.ts +96 -0
- package/dist/publish.js +1 -0
- package/dist/scaffold.cjs +523 -0
- package/dist/scaffold.d.cts +182 -0
- package/dist/scaffold.d.ts +182 -0
- package/dist/scaffold.js +523 -0
- package/dist/server-runtime.cjs +1 -0
- package/dist/server-runtime.d.cts +63 -0
- package/dist/server-runtime.d.ts +63 -0
- package/dist/server-runtime.js +1 -0
- package/dist/server.cjs +1 -0
- package/dist/server.d.cts +1808 -0
- package/dist/server.d.ts +1808 -0
- package/dist/server.js +1 -0
- package/dist/testing.cjs +2 -0
- package/dist/testing.d.cts +92 -0
- package/dist/testing.d.ts +92 -0
- package/dist/testing.js +2 -0
- package/dist/vite.cjs +1 -0
- package/dist/vite.d.cts +133 -0
- package/dist/vite.d.ts +133 -0
- package/dist/vite.js +1 -0
- package/package.json +160 -4
- package/sql/access.sql +73 -0
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,1808 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PluginUserContext } from './frontend.js';
|
|
3
|
+
|
|
4
|
+
/** Invitation requests never accept platform roles or tenant overrides. */
|
|
5
|
+
declare const accountInviteSchema: z.ZodEffects<z.ZodObject<{
|
|
6
|
+
requestId: z.ZodString;
|
|
7
|
+
organizationName: z.ZodString;
|
|
8
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
username: z.ZodOptional<z.ZodString>;
|
|
10
|
+
email: z.ZodOptional<z.ZodString>;
|
|
11
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
12
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strict", z.ZodTypeAny, {
|
|
14
|
+
requestId: string;
|
|
15
|
+
organizationName: string;
|
|
16
|
+
email?: string | undefined;
|
|
17
|
+
phone?: string | undefined;
|
|
18
|
+
username?: string | undefined;
|
|
19
|
+
userId?: string | undefined;
|
|
20
|
+
fullName?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
requestId: string;
|
|
23
|
+
organizationName: string;
|
|
24
|
+
email?: string | undefined;
|
|
25
|
+
phone?: string | undefined;
|
|
26
|
+
username?: string | undefined;
|
|
27
|
+
userId?: string | undefined;
|
|
28
|
+
fullName?: string | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
requestId: string;
|
|
31
|
+
organizationName: string;
|
|
32
|
+
email?: string | undefined;
|
|
33
|
+
phone?: string | undefined;
|
|
34
|
+
username?: string | undefined;
|
|
35
|
+
userId?: string | undefined;
|
|
36
|
+
fullName?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
requestId: string;
|
|
39
|
+
organizationName: string;
|
|
40
|
+
email?: string | undefined;
|
|
41
|
+
phone?: string | undefined;
|
|
42
|
+
username?: string | undefined;
|
|
43
|
+
userId?: string | undefined;
|
|
44
|
+
fullName?: string | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
/** Register immediately without sending email; existing passwords remain unchanged. */
|
|
47
|
+
declare const accountProvisionSchema: z.ZodEffects<z.ZodObject<{
|
|
48
|
+
requestId: z.ZodString;
|
|
49
|
+
organizationName: z.ZodString;
|
|
50
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
51
|
+
username: z.ZodOptional<z.ZodString>;
|
|
52
|
+
email: z.ZodOptional<z.ZodString>;
|
|
53
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
54
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
55
|
+
} & {
|
|
56
|
+
password: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, "strict", z.ZodTypeAny, {
|
|
58
|
+
requestId: string;
|
|
59
|
+
organizationName: string;
|
|
60
|
+
email?: string | undefined;
|
|
61
|
+
phone?: string | undefined;
|
|
62
|
+
password?: string | undefined;
|
|
63
|
+
username?: string | undefined;
|
|
64
|
+
userId?: string | undefined;
|
|
65
|
+
fullName?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
requestId: string;
|
|
68
|
+
organizationName: string;
|
|
69
|
+
email?: string | undefined;
|
|
70
|
+
phone?: string | undefined;
|
|
71
|
+
password?: string | undefined;
|
|
72
|
+
username?: string | undefined;
|
|
73
|
+
userId?: string | undefined;
|
|
74
|
+
fullName?: string | undefined;
|
|
75
|
+
}>, {
|
|
76
|
+
requestId: string;
|
|
77
|
+
organizationName: string;
|
|
78
|
+
email?: string | undefined;
|
|
79
|
+
phone?: string | undefined;
|
|
80
|
+
password?: string | undefined;
|
|
81
|
+
username?: string | undefined;
|
|
82
|
+
userId?: string | undefined;
|
|
83
|
+
fullName?: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
requestId: string;
|
|
86
|
+
organizationName: string;
|
|
87
|
+
email?: string | undefined;
|
|
88
|
+
phone?: string | undefined;
|
|
89
|
+
password?: string | undefined;
|
|
90
|
+
username?: string | undefined;
|
|
91
|
+
userId?: string | undefined;
|
|
92
|
+
fullName?: string | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
interface AccountProvisionResult {
|
|
95
|
+
id: string;
|
|
96
|
+
userId: string;
|
|
97
|
+
}
|
|
98
|
+
declare const accountInvitationSchema: z.ZodObject<{
|
|
99
|
+
invitationId: z.ZodString;
|
|
100
|
+
}, "strict", z.ZodTypeAny, {
|
|
101
|
+
invitationId: string;
|
|
102
|
+
}, {
|
|
103
|
+
invitationId: string;
|
|
104
|
+
}>;
|
|
105
|
+
interface AccountInvitation {
|
|
106
|
+
id: string;
|
|
107
|
+
userId: string;
|
|
108
|
+
status: 'pending' | 'accepted' | 'expired';
|
|
109
|
+
deliveryStatus: 'pending' | 'sent' | 'failed';
|
|
110
|
+
error: string;
|
|
111
|
+
expiresAt: string;
|
|
112
|
+
}
|
|
113
|
+
/** Reset ordinary platform accounts; tenant and privileged roles remain host-controlled. */
|
|
114
|
+
declare const accountPasswordResetSchema: z.ZodObject<{
|
|
115
|
+
userId: z.ZodString;
|
|
116
|
+
newPassword: z.ZodString;
|
|
117
|
+
}, "strict", z.ZodTypeAny, {
|
|
118
|
+
userId: string;
|
|
119
|
+
newPassword: string;
|
|
120
|
+
}, {
|
|
121
|
+
userId: string;
|
|
122
|
+
newPassword: string;
|
|
123
|
+
}>;
|
|
124
|
+
interface PluginAccountsApi {
|
|
125
|
+
/** Requires accounts.provision; platform administrator accounts are protected. */
|
|
126
|
+
resetPassword(input: z.input<typeof accountPasswordResetSchema>): Promise<{
|
|
127
|
+
userId: string;
|
|
128
|
+
}>;
|
|
129
|
+
provisionUser(input: z.input<typeof accountProvisionSchema>): Promise<AccountProvisionResult>;
|
|
130
|
+
inviteUser(input: z.input<typeof accountInviteSchema>): Promise<AccountInvitation>;
|
|
131
|
+
getInvitation(invitationId: string): Promise<AccountInvitation>;
|
|
132
|
+
resendInvitation(invitationId: string): Promise<AccountInvitation>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Host API 1.20. Only source text is accepted; the host renders in an isolated browser. */
|
|
136
|
+
declare const pluginDiagramSchema: z.ZodObject<{
|
|
137
|
+
kind: z.ZodEnum<["mermaid", "html"]>;
|
|
138
|
+
source: z.ZodString;
|
|
139
|
+
destinationKey: z.ZodString;
|
|
140
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
141
|
+
height: z.ZodDefault<z.ZodNumber>;
|
|
142
|
+
}, "strict", z.ZodTypeAny, {
|
|
143
|
+
kind: "html" | "mermaid";
|
|
144
|
+
width: number;
|
|
145
|
+
height: number;
|
|
146
|
+
source: string;
|
|
147
|
+
destinationKey: string;
|
|
148
|
+
}, {
|
|
149
|
+
kind: "html" | "mermaid";
|
|
150
|
+
source: string;
|
|
151
|
+
destinationKey: string;
|
|
152
|
+
width?: number | undefined;
|
|
153
|
+
height?: number | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
type PluginDiagramInput = z.input<typeof pluginDiagramSchema>;
|
|
156
|
+
interface PluginDiagramResult {
|
|
157
|
+
key: string;
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
size: number;
|
|
161
|
+
sha256: string;
|
|
162
|
+
renderer: string;
|
|
163
|
+
}
|
|
164
|
+
interface PluginDiagramsApi {
|
|
165
|
+
status(): Promise<{
|
|
166
|
+
ready: boolean;
|
|
167
|
+
reason?: string;
|
|
168
|
+
}>;
|
|
169
|
+
/** Requires diagrams.render. Canvas dimensions are maxima; unused bottom whitespace is removed. */
|
|
170
|
+
render(input: PluginDiagramInput): Promise<PluginDiagramResult>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** A principal names an identity, never an organization's display label. */
|
|
174
|
+
declare const directoryPrincipalSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
175
|
+
kind: z.ZodLiteral<"user">;
|
|
176
|
+
id: z.ZodString;
|
|
177
|
+
}, "strict", z.ZodTypeAny, {
|
|
178
|
+
id: string;
|
|
179
|
+
kind: "user";
|
|
180
|
+
}, {
|
|
181
|
+
id: string;
|
|
182
|
+
kind: "user";
|
|
183
|
+
}>, z.ZodObject<{
|
|
184
|
+
kind: z.ZodLiteral<"unit">;
|
|
185
|
+
id: z.ZodString;
|
|
186
|
+
includeDescendants: z.ZodDefault<z.ZodBoolean>;
|
|
187
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodEnum<["owner", "admin", "member", "viewer"]>, "many">>;
|
|
188
|
+
}, "strict", z.ZodTypeAny, {
|
|
189
|
+
id: string;
|
|
190
|
+
kind: "unit";
|
|
191
|
+
roles: ("admin" | "viewer" | "owner" | "member")[];
|
|
192
|
+
includeDescendants: boolean;
|
|
193
|
+
}, {
|
|
194
|
+
id: string;
|
|
195
|
+
kind: "unit";
|
|
196
|
+
roles?: ("admin" | "viewer" | "owner" | "member")[] | undefined;
|
|
197
|
+
includeDescendants?: boolean | undefined;
|
|
198
|
+
}>]>;
|
|
199
|
+
type DirectoryPrincipal = z.infer<typeof directoryPrincipalSchema>;
|
|
200
|
+
declare const directoryMatchSchema: z.ZodObject<{
|
|
201
|
+
userId: z.ZodString;
|
|
202
|
+
principals: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
203
|
+
kind: z.ZodLiteral<"user">;
|
|
204
|
+
id: z.ZodString;
|
|
205
|
+
}, "strict", z.ZodTypeAny, {
|
|
206
|
+
id: string;
|
|
207
|
+
kind: "user";
|
|
208
|
+
}, {
|
|
209
|
+
id: string;
|
|
210
|
+
kind: "user";
|
|
211
|
+
}>, z.ZodObject<{
|
|
212
|
+
kind: z.ZodLiteral<"unit">;
|
|
213
|
+
id: z.ZodString;
|
|
214
|
+
includeDescendants: z.ZodDefault<z.ZodBoolean>;
|
|
215
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodEnum<["owner", "admin", "member", "viewer"]>, "many">>;
|
|
216
|
+
}, "strict", z.ZodTypeAny, {
|
|
217
|
+
id: string;
|
|
218
|
+
kind: "unit";
|
|
219
|
+
roles: ("admin" | "viewer" | "owner" | "member")[];
|
|
220
|
+
includeDescendants: boolean;
|
|
221
|
+
}, {
|
|
222
|
+
id: string;
|
|
223
|
+
kind: "unit";
|
|
224
|
+
roles?: ("admin" | "viewer" | "owner" | "member")[] | undefined;
|
|
225
|
+
includeDescendants?: boolean | undefined;
|
|
226
|
+
}>]>, "many">;
|
|
227
|
+
}, "strict", z.ZodTypeAny, {
|
|
228
|
+
principals: ({
|
|
229
|
+
id: string;
|
|
230
|
+
kind: "user";
|
|
231
|
+
} | {
|
|
232
|
+
id: string;
|
|
233
|
+
kind: "unit";
|
|
234
|
+
roles: ("admin" | "viewer" | "owner" | "member")[];
|
|
235
|
+
includeDescendants: boolean;
|
|
236
|
+
})[];
|
|
237
|
+
userId: string;
|
|
238
|
+
}, {
|
|
239
|
+
principals: ({
|
|
240
|
+
id: string;
|
|
241
|
+
kind: "user";
|
|
242
|
+
} | {
|
|
243
|
+
id: string;
|
|
244
|
+
kind: "unit";
|
|
245
|
+
roles?: ("admin" | "viewer" | "owner" | "member")[] | undefined;
|
|
246
|
+
includeDescendants?: boolean | undefined;
|
|
247
|
+
})[];
|
|
248
|
+
userId: string;
|
|
249
|
+
}>;
|
|
250
|
+
declare const directoryIdentitySchema: z.ZodObject<{
|
|
251
|
+
userId: z.ZodString;
|
|
252
|
+
}, "strict", z.ZodTypeAny, {
|
|
253
|
+
userId: string;
|
|
254
|
+
}, {
|
|
255
|
+
userId: string;
|
|
256
|
+
}>;
|
|
257
|
+
declare const directoryValidateSchema: z.ZodObject<{
|
|
258
|
+
principals: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
259
|
+
kind: z.ZodLiteral<"user">;
|
|
260
|
+
id: z.ZodString;
|
|
261
|
+
}, "strict", z.ZodTypeAny, {
|
|
262
|
+
id: string;
|
|
263
|
+
kind: "user";
|
|
264
|
+
}, {
|
|
265
|
+
id: string;
|
|
266
|
+
kind: "user";
|
|
267
|
+
}>, z.ZodObject<{
|
|
268
|
+
kind: z.ZodLiteral<"unit">;
|
|
269
|
+
id: z.ZodString;
|
|
270
|
+
includeDescendants: z.ZodDefault<z.ZodBoolean>;
|
|
271
|
+
roles: z.ZodDefault<z.ZodArray<z.ZodEnum<["owner", "admin", "member", "viewer"]>, "many">>;
|
|
272
|
+
}, "strict", z.ZodTypeAny, {
|
|
273
|
+
id: string;
|
|
274
|
+
kind: "unit";
|
|
275
|
+
roles: ("admin" | "viewer" | "owner" | "member")[];
|
|
276
|
+
includeDescendants: boolean;
|
|
277
|
+
}, {
|
|
278
|
+
id: string;
|
|
279
|
+
kind: "unit";
|
|
280
|
+
roles?: ("admin" | "viewer" | "owner" | "member")[] | undefined;
|
|
281
|
+
includeDescendants?: boolean | undefined;
|
|
282
|
+
}>]>, "many">;
|
|
283
|
+
}, "strict", z.ZodTypeAny, {
|
|
284
|
+
principals: ({
|
|
285
|
+
id: string;
|
|
286
|
+
kind: "user";
|
|
287
|
+
} | {
|
|
288
|
+
id: string;
|
|
289
|
+
kind: "unit";
|
|
290
|
+
roles: ("admin" | "viewer" | "owner" | "member")[];
|
|
291
|
+
includeDescendants: boolean;
|
|
292
|
+
})[];
|
|
293
|
+
}, {
|
|
294
|
+
principals: ({
|
|
295
|
+
id: string;
|
|
296
|
+
kind: "user";
|
|
297
|
+
} | {
|
|
298
|
+
id: string;
|
|
299
|
+
kind: "unit";
|
|
300
|
+
roles?: ("admin" | "viewer" | "owner" | "member")[] | undefined;
|
|
301
|
+
includeDescendants?: boolean | undefined;
|
|
302
|
+
})[];
|
|
303
|
+
}>;
|
|
304
|
+
declare const directoryListSchema: z.ZodObject<{
|
|
305
|
+
kind: z.ZodEnum<["users", "units"]>;
|
|
306
|
+
search: z.ZodOptional<z.ZodString>;
|
|
307
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
308
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
309
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
310
|
+
}, "strict", z.ZodTypeAny, {
|
|
311
|
+
kind: "users" | "units";
|
|
312
|
+
limit: number;
|
|
313
|
+
offset: number;
|
|
314
|
+
search?: string | undefined;
|
|
315
|
+
ids?: string[] | undefined;
|
|
316
|
+
}, {
|
|
317
|
+
kind: "users" | "units";
|
|
318
|
+
search?: string | undefined;
|
|
319
|
+
limit?: number | undefined;
|
|
320
|
+
ids?: string[] | undefined;
|
|
321
|
+
offset?: number | undefined;
|
|
322
|
+
}>;
|
|
323
|
+
interface DirectoryEntry {
|
|
324
|
+
id: string;
|
|
325
|
+
displayName: string;
|
|
326
|
+
fullName?: string | null;
|
|
327
|
+
username?: string;
|
|
328
|
+
email?: string;
|
|
329
|
+
active: boolean;
|
|
330
|
+
parentId?: string | null;
|
|
331
|
+
unitType?: 'team' | 'department' | 'subcompany';
|
|
332
|
+
}
|
|
333
|
+
interface DirectoryMatch {
|
|
334
|
+
active: boolean;
|
|
335
|
+
/** Indexes into the request, preserving groups without flattening rules. */
|
|
336
|
+
matched: number[];
|
|
337
|
+
checkedAt: string;
|
|
338
|
+
}
|
|
339
|
+
interface DirectoryIdentity {
|
|
340
|
+
active: boolean;
|
|
341
|
+
roleNames: string[];
|
|
342
|
+
memberships: {
|
|
343
|
+
unitId: string;
|
|
344
|
+
ancestors: string[];
|
|
345
|
+
role: 'owner' | 'admin' | 'member' | 'viewer';
|
|
346
|
+
}[];
|
|
347
|
+
checkedAt: string;
|
|
348
|
+
}
|
|
349
|
+
interface PluginDirectoryApi {
|
|
350
|
+
identity(userId: string): Promise<DirectoryIdentity>;
|
|
351
|
+
validate(principals: DirectoryPrincipal[]): Promise<{
|
|
352
|
+
invalid: number[];
|
|
353
|
+
}>;
|
|
354
|
+
list(input: z.input<typeof directoryListSchema>): Promise<{
|
|
355
|
+
items: DirectoryEntry[];
|
|
356
|
+
hasMore: boolean;
|
|
357
|
+
}>;
|
|
358
|
+
/** Always reads live tenant membership; this is not a user impersonation API. */
|
|
359
|
+
match(input: z.input<typeof directoryMatchSchema>): Promise<DirectoryMatch>;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** An excerpt of existing platform knowledge, not a second knowledge store. */
|
|
363
|
+
declare const pluginKnowledgeReferenceSchema: z.ZodObject<{
|
|
364
|
+
knowledgeBaseId: z.ZodString;
|
|
365
|
+
documentId: z.ZodString;
|
|
366
|
+
paragraphId: z.ZodString;
|
|
367
|
+
/** Omit to preserve the authoritative paragraph; supplied excerpts must match exactly. */
|
|
368
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
369
|
+
/** Optional optimistic check when editing a previously verified source snapshot. */
|
|
370
|
+
expectedContentSha256: z.ZodOptional<z.ZodString>;
|
|
371
|
+
}, "strict", z.ZodTypeAny, {
|
|
372
|
+
documentId: string;
|
|
373
|
+
knowledgeBaseId: string;
|
|
374
|
+
paragraphId: string;
|
|
375
|
+
quote?: string | undefined;
|
|
376
|
+
expectedContentSha256?: string | undefined;
|
|
377
|
+
}, {
|
|
378
|
+
documentId: string;
|
|
379
|
+
knowledgeBaseId: string;
|
|
380
|
+
paragraphId: string;
|
|
381
|
+
quote?: string | undefined;
|
|
382
|
+
expectedContentSha256?: string | undefined;
|
|
383
|
+
}>;
|
|
384
|
+
declare const pluginKnowledgeVerifySchema: z.ZodObject<{
|
|
385
|
+
userId: z.ZodString;
|
|
386
|
+
avatarId: z.ZodString;
|
|
387
|
+
references: z.ZodArray<z.ZodObject<{
|
|
388
|
+
knowledgeBaseId: z.ZodString;
|
|
389
|
+
documentId: z.ZodString;
|
|
390
|
+
paragraphId: z.ZodString;
|
|
391
|
+
/** Omit to preserve the authoritative paragraph; supplied excerpts must match exactly. */
|
|
392
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
393
|
+
/** Optional optimistic check when editing a previously verified source snapshot. */
|
|
394
|
+
expectedContentSha256: z.ZodOptional<z.ZodString>;
|
|
395
|
+
}, "strict", z.ZodTypeAny, {
|
|
396
|
+
documentId: string;
|
|
397
|
+
knowledgeBaseId: string;
|
|
398
|
+
paragraphId: string;
|
|
399
|
+
quote?: string | undefined;
|
|
400
|
+
expectedContentSha256?: string | undefined;
|
|
401
|
+
}, {
|
|
402
|
+
documentId: string;
|
|
403
|
+
knowledgeBaseId: string;
|
|
404
|
+
paragraphId: string;
|
|
405
|
+
quote?: string | undefined;
|
|
406
|
+
expectedContentSha256?: string | undefined;
|
|
407
|
+
}>, "many">;
|
|
408
|
+
}, "strict", z.ZodTypeAny, {
|
|
409
|
+
avatarId: string;
|
|
410
|
+
userId: string;
|
|
411
|
+
references: {
|
|
412
|
+
documentId: string;
|
|
413
|
+
knowledgeBaseId: string;
|
|
414
|
+
paragraphId: string;
|
|
415
|
+
quote?: string | undefined;
|
|
416
|
+
expectedContentSha256?: string | undefined;
|
|
417
|
+
}[];
|
|
418
|
+
}, {
|
|
419
|
+
avatarId: string;
|
|
420
|
+
userId: string;
|
|
421
|
+
references: {
|
|
422
|
+
documentId: string;
|
|
423
|
+
knowledgeBaseId: string;
|
|
424
|
+
paragraphId: string;
|
|
425
|
+
quote?: string | undefined;
|
|
426
|
+
expectedContentSha256?: string | undefined;
|
|
427
|
+
}[];
|
|
428
|
+
}>;
|
|
429
|
+
type PluginKnowledgeReference = z.infer<typeof pluginKnowledgeReferenceSchema>;
|
|
430
|
+
interface VerifiedPluginKnowledgeReference extends PluginKnowledgeReference {
|
|
431
|
+
quote: string;
|
|
432
|
+
documentName: string;
|
|
433
|
+
title: string;
|
|
434
|
+
/** SHA-256 of the hydrated content snapshot; not a whole-document version. */
|
|
435
|
+
contentSha256: string;
|
|
436
|
+
verifiedAt: string;
|
|
437
|
+
}
|
|
438
|
+
declare const PLUGIN_COLLECTION_IMPORT_MAX = 50;
|
|
439
|
+
declare const collectionMetadataSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>;
|
|
440
|
+
declare const pluginCollectionEnsureSchema: z.ZodObject<{
|
|
441
|
+
key: z.ZodString;
|
|
442
|
+
name: z.ZodString;
|
|
443
|
+
accessMode: z.ZodOptional<z.ZodEnum<["private", "managed"]>>;
|
|
444
|
+
/** @deprecated Accepted for older clients; reads use ordinary knowledge ACL. */
|
|
445
|
+
policyScope: z.ZodOptional<z.ZodString>;
|
|
446
|
+
}, "strict", z.ZodTypeAny, {
|
|
447
|
+
key: string;
|
|
448
|
+
name: string;
|
|
449
|
+
accessMode?: "managed" | "private" | undefined;
|
|
450
|
+
policyScope?: string | undefined;
|
|
451
|
+
}, {
|
|
452
|
+
key: string;
|
|
453
|
+
name: string;
|
|
454
|
+
accessMode?: "managed" | "private" | undefined;
|
|
455
|
+
policyScope?: string | undefined;
|
|
456
|
+
}>;
|
|
457
|
+
declare const pluginCollectionPermissionsSchema: z.ZodObject<{
|
|
458
|
+
key: z.ZodString;
|
|
459
|
+
syncRevision: z.ZodOptional<z.ZodString>;
|
|
460
|
+
grants: z.ZodArray<z.ZodObject<{
|
|
461
|
+
subjectType: z.ZodEnum<["user", "team", "role", "tenant"]>;
|
|
462
|
+
subjectId: z.ZodString;
|
|
463
|
+
}, "strict", z.ZodTypeAny, {
|
|
464
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
465
|
+
subjectId: string;
|
|
466
|
+
}, {
|
|
467
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
468
|
+
subjectId: string;
|
|
469
|
+
}>, "many">;
|
|
470
|
+
}, "strict", z.ZodTypeAny, {
|
|
471
|
+
key: string;
|
|
472
|
+
grants: {
|
|
473
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
474
|
+
subjectId: string;
|
|
475
|
+
}[];
|
|
476
|
+
syncRevision?: string | undefined;
|
|
477
|
+
}, {
|
|
478
|
+
key: string;
|
|
479
|
+
grants: {
|
|
480
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
481
|
+
subjectId: string;
|
|
482
|
+
}[];
|
|
483
|
+
syncRevision?: string | undefined;
|
|
484
|
+
}>;
|
|
485
|
+
/** Move existing documents without re-embedding; retry with the same migrationId. */
|
|
486
|
+
declare const pluginCollectionMoveSchema: z.ZodEffects<z.ZodObject<{
|
|
487
|
+
migrationId: z.ZodString;
|
|
488
|
+
sourceKey: z.ZodString;
|
|
489
|
+
targetKey: z.ZodString;
|
|
490
|
+
syncRevision: z.ZodString;
|
|
491
|
+
externalIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
|
|
492
|
+
}, "strict", z.ZodTypeAny, {
|
|
493
|
+
syncRevision: string;
|
|
494
|
+
migrationId: string;
|
|
495
|
+
sourceKey: string;
|
|
496
|
+
targetKey: string;
|
|
497
|
+
externalIds: string[];
|
|
498
|
+
}, {
|
|
499
|
+
syncRevision: string;
|
|
500
|
+
migrationId: string;
|
|
501
|
+
sourceKey: string;
|
|
502
|
+
targetKey: string;
|
|
503
|
+
externalIds: string[];
|
|
504
|
+
}>, {
|
|
505
|
+
syncRevision: string;
|
|
506
|
+
migrationId: string;
|
|
507
|
+
sourceKey: string;
|
|
508
|
+
targetKey: string;
|
|
509
|
+
externalIds: string[];
|
|
510
|
+
}, {
|
|
511
|
+
syncRevision: string;
|
|
512
|
+
migrationId: string;
|
|
513
|
+
sourceKey: string;
|
|
514
|
+
targetKey: string;
|
|
515
|
+
externalIds: string[];
|
|
516
|
+
}>;
|
|
517
|
+
/** Suspend reads while a plugin synchronizes ordinary ACLs. */
|
|
518
|
+
declare const pluginCollectionAccessSchema: z.ZodEffects<z.ZodObject<{
|
|
519
|
+
key: z.ZodOptional<z.ZodString>;
|
|
520
|
+
/** Omit to inspect the identity snapshot without changing read access. */
|
|
521
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
522
|
+
syncRevision: z.ZodOptional<z.ZodString>;
|
|
523
|
+
/** Identity snapshot returned by access({enabled:false}); required to resume. */
|
|
524
|
+
identityRevision: z.ZodOptional<z.ZodString>;
|
|
525
|
+
}, "strict", z.ZodTypeAny, {
|
|
526
|
+
key?: string | undefined;
|
|
527
|
+
enabled?: boolean | undefined;
|
|
528
|
+
syncRevision?: string | undefined;
|
|
529
|
+
identityRevision?: string | undefined;
|
|
530
|
+
}, {
|
|
531
|
+
key?: string | undefined;
|
|
532
|
+
enabled?: boolean | undefined;
|
|
533
|
+
syncRevision?: string | undefined;
|
|
534
|
+
identityRevision?: string | undefined;
|
|
535
|
+
}>, {
|
|
536
|
+
key?: string | undefined;
|
|
537
|
+
enabled?: boolean | undefined;
|
|
538
|
+
syncRevision?: string | undefined;
|
|
539
|
+
identityRevision?: string | undefined;
|
|
540
|
+
}, {
|
|
541
|
+
key?: string | undefined;
|
|
542
|
+
enabled?: boolean | undefined;
|
|
543
|
+
syncRevision?: string | undefined;
|
|
544
|
+
identityRevision?: string | undefined;
|
|
545
|
+
}>;
|
|
546
|
+
declare const pluginCollectionImportSchema: z.ZodObject<{
|
|
547
|
+
key: z.ZodString;
|
|
548
|
+
syncRevision: z.ZodOptional<z.ZodString>;
|
|
549
|
+
documents: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
550
|
+
externalId: z.ZodString;
|
|
551
|
+
title: z.ZodString;
|
|
552
|
+
text: z.ZodString;
|
|
553
|
+
metadata: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
554
|
+
}, "strict", z.ZodTypeAny, {
|
|
555
|
+
title: string;
|
|
556
|
+
text: string;
|
|
557
|
+
externalId: string;
|
|
558
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
559
|
+
}, {
|
|
560
|
+
title: string;
|
|
561
|
+
text: string;
|
|
562
|
+
externalId: string;
|
|
563
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
564
|
+
}>, "many">, {
|
|
565
|
+
title: string;
|
|
566
|
+
text: string;
|
|
567
|
+
externalId: string;
|
|
568
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
569
|
+
}[], {
|
|
570
|
+
title: string;
|
|
571
|
+
text: string;
|
|
572
|
+
externalId: string;
|
|
573
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
574
|
+
}[]>;
|
|
575
|
+
}, "strict", z.ZodTypeAny, {
|
|
576
|
+
key: string;
|
|
577
|
+
documents: {
|
|
578
|
+
title: string;
|
|
579
|
+
text: string;
|
|
580
|
+
externalId: string;
|
|
581
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
582
|
+
}[];
|
|
583
|
+
syncRevision?: string | undefined;
|
|
584
|
+
}, {
|
|
585
|
+
key: string;
|
|
586
|
+
documents: {
|
|
587
|
+
title: string;
|
|
588
|
+
text: string;
|
|
589
|
+
externalId: string;
|
|
590
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
591
|
+
}[];
|
|
592
|
+
syncRevision?: string | undefined;
|
|
593
|
+
}>;
|
|
594
|
+
declare const pluginCollectionImportFilesSchema: z.ZodObject<{
|
|
595
|
+
key: z.ZodString;
|
|
596
|
+
syncRevision: z.ZodOptional<z.ZodString>;
|
|
597
|
+
documents: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
598
|
+
externalId: z.ZodString;
|
|
599
|
+
title: z.ZodString;
|
|
600
|
+
storageKey: z.ZodString;
|
|
601
|
+
fileName: z.ZodString;
|
|
602
|
+
contentSha256: z.ZodString;
|
|
603
|
+
metadata: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
604
|
+
}, "strict", z.ZodTypeAny, {
|
|
605
|
+
title: string;
|
|
606
|
+
externalId: string;
|
|
607
|
+
storageKey: string;
|
|
608
|
+
fileName: string;
|
|
609
|
+
contentSha256: string;
|
|
610
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
611
|
+
}, {
|
|
612
|
+
title: string;
|
|
613
|
+
externalId: string;
|
|
614
|
+
storageKey: string;
|
|
615
|
+
fileName: string;
|
|
616
|
+
contentSha256: string;
|
|
617
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
618
|
+
}>, "many">, {
|
|
619
|
+
title: string;
|
|
620
|
+
externalId: string;
|
|
621
|
+
storageKey: string;
|
|
622
|
+
fileName: string;
|
|
623
|
+
contentSha256: string;
|
|
624
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
625
|
+
}[], {
|
|
626
|
+
title: string;
|
|
627
|
+
externalId: string;
|
|
628
|
+
storageKey: string;
|
|
629
|
+
fileName: string;
|
|
630
|
+
contentSha256: string;
|
|
631
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
632
|
+
}[]>;
|
|
633
|
+
}, "strict", z.ZodTypeAny, {
|
|
634
|
+
key: string;
|
|
635
|
+
documents: {
|
|
636
|
+
title: string;
|
|
637
|
+
externalId: string;
|
|
638
|
+
storageKey: string;
|
|
639
|
+
fileName: string;
|
|
640
|
+
contentSha256: string;
|
|
641
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
642
|
+
}[];
|
|
643
|
+
syncRevision?: string | undefined;
|
|
644
|
+
}, {
|
|
645
|
+
key: string;
|
|
646
|
+
documents: {
|
|
647
|
+
title: string;
|
|
648
|
+
externalId: string;
|
|
649
|
+
storageKey: string;
|
|
650
|
+
fileName: string;
|
|
651
|
+
contentSha256: string;
|
|
652
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
653
|
+
}[];
|
|
654
|
+
syncRevision?: string | undefined;
|
|
655
|
+
}>;
|
|
656
|
+
declare const pluginCollectionStatusSchema: z.ZodObject<{
|
|
657
|
+
key: z.ZodString;
|
|
658
|
+
}, "strict", z.ZodTypeAny, {
|
|
659
|
+
key: string;
|
|
660
|
+
}, {
|
|
661
|
+
key: string;
|
|
662
|
+
}>;
|
|
663
|
+
declare const pluginCollectionDeleteSchema: z.ZodObject<{
|
|
664
|
+
key: z.ZodString;
|
|
665
|
+
}, "strict", z.ZodTypeAny, {
|
|
666
|
+
key: string;
|
|
667
|
+
}, {
|
|
668
|
+
key: string;
|
|
669
|
+
}>;
|
|
670
|
+
declare const pluginCollectionDocumentsStatusSchema: z.ZodObject<{
|
|
671
|
+
key: z.ZodString;
|
|
672
|
+
externalIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
673
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
674
|
+
}, "strict", z.ZodTypeAny, {
|
|
675
|
+
key: string;
|
|
676
|
+
offset?: number | undefined;
|
|
677
|
+
externalIds?: string[] | undefined;
|
|
678
|
+
}, {
|
|
679
|
+
key: string;
|
|
680
|
+
offset?: number | undefined;
|
|
681
|
+
externalIds?: string[] | undefined;
|
|
682
|
+
}>;
|
|
683
|
+
declare const PLUGIN_COLLECTION_CONTENT_PAGE_MAX = 100;
|
|
684
|
+
declare const pluginCollectionDocumentContentSchema: z.ZodObject<{
|
|
685
|
+
key: z.ZodString;
|
|
686
|
+
externalId: z.ZodString;
|
|
687
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
688
|
+
pageSize: z.ZodDefault<z.ZodNumber>;
|
|
689
|
+
}, "strict", z.ZodTypeAny, {
|
|
690
|
+
key: string;
|
|
691
|
+
page: number;
|
|
692
|
+
externalId: string;
|
|
693
|
+
pageSize: number;
|
|
694
|
+
}, {
|
|
695
|
+
key: string;
|
|
696
|
+
externalId: string;
|
|
697
|
+
page?: number | undefined;
|
|
698
|
+
pageSize?: number | undefined;
|
|
699
|
+
}>;
|
|
700
|
+
declare const pluginCollectionSearchSchema: z.ZodObject<{
|
|
701
|
+
key: z.ZodString;
|
|
702
|
+
query: z.ZodString;
|
|
703
|
+
topK: z.ZodDefault<z.ZodNumber>;
|
|
704
|
+
/** Equality per key; an array matches any of its values. */
|
|
705
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">]>>>;
|
|
706
|
+
}, "strict", z.ZodTypeAny, {
|
|
707
|
+
key: string;
|
|
708
|
+
query: string;
|
|
709
|
+
topK: number;
|
|
710
|
+
filter?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
711
|
+
}, {
|
|
712
|
+
key: string;
|
|
713
|
+
query: string;
|
|
714
|
+
filter?: Record<string, string | number | boolean | (string | number | boolean | null)[] | null> | undefined;
|
|
715
|
+
topK?: number | undefined;
|
|
716
|
+
}>;
|
|
717
|
+
declare const pluginCollectionRemoveSchema: z.ZodObject<{
|
|
718
|
+
key: z.ZodString;
|
|
719
|
+
externalIds: z.ZodArray<z.ZodString, "many">;
|
|
720
|
+
}, "strict", z.ZodTypeAny, {
|
|
721
|
+
key: string;
|
|
722
|
+
externalIds: string[];
|
|
723
|
+
}, {
|
|
724
|
+
key: string;
|
|
725
|
+
externalIds: string[];
|
|
726
|
+
}>;
|
|
727
|
+
type PluginCollectionMetadata = z.infer<typeof collectionMetadataSchema>;
|
|
728
|
+
type PluginCollectionStatus = 'empty' | 'indexing' | 'partial' | 'ready';
|
|
729
|
+
/** One paragraph of a document as the knowledge service split it. */
|
|
730
|
+
interface PluginCollectionParagraph {
|
|
731
|
+
title: string;
|
|
732
|
+
content: string;
|
|
733
|
+
/** 1-based reading order within the document. */
|
|
734
|
+
position: number;
|
|
735
|
+
/** Source pages, for PDFs; null when the format has no pages. */
|
|
736
|
+
pageStart: number | null;
|
|
737
|
+
pageEnd: number | null;
|
|
738
|
+
}
|
|
739
|
+
interface PluginCollectionsApi {
|
|
740
|
+
ensure(input: z.input<typeof pluginCollectionEnsureSchema>): Promise<{
|
|
741
|
+
collectionId: string;
|
|
742
|
+
status: 'ready';
|
|
743
|
+
}>;
|
|
744
|
+
/** Project a managed plugin's reader principals onto the host KB ACL. */
|
|
745
|
+
permissions(input: z.input<typeof pluginCollectionPermissionsSchema>): Promise<{
|
|
746
|
+
aclVersion: number;
|
|
747
|
+
}>;
|
|
748
|
+
move(input: z.input<typeof pluginCollectionMoveSchema>): Promise<{
|
|
749
|
+
moved: number;
|
|
750
|
+
documentIds: string[];
|
|
751
|
+
}>;
|
|
752
|
+
access(input: z.input<typeof pluginCollectionAccessSchema>): Promise<{
|
|
753
|
+
enabled: boolean;
|
|
754
|
+
identityRevision: string;
|
|
755
|
+
syncRevision: string;
|
|
756
|
+
validUntil: string | null;
|
|
757
|
+
}>;
|
|
758
|
+
import(input: z.input<typeof pluginCollectionImportSchema>): Promise<{
|
|
759
|
+
accepted: number;
|
|
760
|
+
taskId: string;
|
|
761
|
+
}>;
|
|
762
|
+
importFiles(input: z.input<typeof pluginCollectionImportFilesSchema>): Promise<{
|
|
763
|
+
accepted: number;
|
|
764
|
+
taskId: string;
|
|
765
|
+
}>;
|
|
766
|
+
status(input: z.input<typeof pluginCollectionStatusSchema>): Promise<{
|
|
767
|
+
status: PluginCollectionStatus;
|
|
768
|
+
documents: number;
|
|
769
|
+
pending: number;
|
|
770
|
+
failed: number;
|
|
771
|
+
updatedAt: string;
|
|
772
|
+
}>;
|
|
773
|
+
/** Permanently retire a collection key and its knowledge base. */
|
|
774
|
+
delete(input: z.input<typeof pluginCollectionDeleteSchema>): Promise<{
|
|
775
|
+
deleted: boolean;
|
|
776
|
+
}>;
|
|
777
|
+
documentsStatus(input: z.input<typeof pluginCollectionDocumentsStatusSchema>): Promise<{
|
|
778
|
+
hasMore?: boolean;
|
|
779
|
+
documents: Array<{
|
|
780
|
+
externalId: string;
|
|
781
|
+
state: 'processing' | 'ready' | 'failed' | 'cancelled';
|
|
782
|
+
contentSha256: string;
|
|
783
|
+
metadata: PluginCollectionMetadata;
|
|
784
|
+
}>;
|
|
785
|
+
}>;
|
|
786
|
+
/**
|
|
787
|
+
* The full parsed text of one ready document, in reading order, a page of
|
|
788
|
+
* paragraphs at a time. A document still indexing or failed is a 409.
|
|
789
|
+
*/
|
|
790
|
+
documentContent(input: z.input<typeof pluginCollectionDocumentContentSchema>): Promise<{
|
|
791
|
+
paragraphs: PluginCollectionParagraph[];
|
|
792
|
+
total: number;
|
|
793
|
+
page: number;
|
|
794
|
+
pageSize: number;
|
|
795
|
+
}>;
|
|
796
|
+
search(input: z.input<typeof pluginCollectionSearchSchema>): Promise<{
|
|
797
|
+
hits: Array<{
|
|
798
|
+
externalId: string;
|
|
799
|
+
documentId: string;
|
|
800
|
+
paragraphId: string;
|
|
801
|
+
score: number;
|
|
802
|
+
snippet: string;
|
|
803
|
+
metadata: PluginCollectionMetadata;
|
|
804
|
+
}>;
|
|
805
|
+
}>;
|
|
806
|
+
remove(input: z.input<typeof pluginCollectionRemoveSchema>): Promise<{
|
|
807
|
+
removed: number;
|
|
808
|
+
}>;
|
|
809
|
+
}
|
|
810
|
+
interface PluginKnowledgeApi {
|
|
811
|
+
/** Requires knowledge.read and this person's live work delegation to the employee. */
|
|
812
|
+
verify(input: z.infer<typeof pluginKnowledgeVerifySchema>): Promise<{
|
|
813
|
+
references: VerifiedPluginKnowledgeReference[];
|
|
814
|
+
}>;
|
|
815
|
+
/** Knowledge collections owned by this install. Requires knowledge.collections. */
|
|
816
|
+
collections?: PluginCollectionsApi;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
declare const pluginKnowledgeListInputSchema: z.ZodObject<{
|
|
820
|
+
actionProof: z.ZodString;
|
|
821
|
+
search: z.ZodOptional<z.ZodString>;
|
|
822
|
+
sourceDepartments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
823
|
+
externalId: z.ZodString;
|
|
824
|
+
path: z.ZodArray<z.ZodString, "many">;
|
|
825
|
+
sourceVersion: z.ZodString;
|
|
826
|
+
}, "strict", z.ZodTypeAny, {
|
|
827
|
+
path: string[];
|
|
828
|
+
externalId: string;
|
|
829
|
+
sourceVersion: string;
|
|
830
|
+
}, {
|
|
831
|
+
path: string[];
|
|
832
|
+
externalId: string;
|
|
833
|
+
sourceVersion: string;
|
|
834
|
+
}>, "many">>;
|
|
835
|
+
departmentExternalIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
836
|
+
sourceDocumentIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
837
|
+
}, "strict", z.ZodTypeAny, {
|
|
838
|
+
actionProof: string;
|
|
839
|
+
search?: string | undefined;
|
|
840
|
+
sourceDepartments?: {
|
|
841
|
+
path: string[];
|
|
842
|
+
externalId: string;
|
|
843
|
+
sourceVersion: string;
|
|
844
|
+
}[] | undefined;
|
|
845
|
+
departmentExternalIds?: string[] | undefined;
|
|
846
|
+
sourceDocumentIds?: string[] | undefined;
|
|
847
|
+
}, {
|
|
848
|
+
actionProof: string;
|
|
849
|
+
search?: string | undefined;
|
|
850
|
+
sourceDepartments?: {
|
|
851
|
+
path: string[];
|
|
852
|
+
externalId: string;
|
|
853
|
+
sourceVersion: string;
|
|
854
|
+
}[] | undefined;
|
|
855
|
+
departmentExternalIds?: string[] | undefined;
|
|
856
|
+
sourceDocumentIds?: string[] | undefined;
|
|
857
|
+
}>;
|
|
858
|
+
declare const pluginAdminActionSchema: z.ZodEnum<["knowledge.list", "knowledge.create.preview", "knowledge.create", "knowledge.document.prepare", "knowledge.document.preview", "knowledge.document.import", "knowledge.task.read"]>;
|
|
859
|
+
type PluginAdminAction = z.infer<typeof pluginAdminActionSchema>;
|
|
860
|
+
declare const pluginApprovalDigestSchema: z.ZodString;
|
|
861
|
+
declare const pluginAdminProofSchema: z.ZodObject<{
|
|
862
|
+
action: z.ZodEnum<["knowledge.list", "knowledge.create.preview", "knowledge.create", "knowledge.document.prepare", "knowledge.document.preview", "knowledge.document.import", "knowledge.task.read"]>;
|
|
863
|
+
digest: z.ZodString;
|
|
864
|
+
}, "strict", z.ZodTypeAny, {
|
|
865
|
+
action: "knowledge.list" | "knowledge.create.preview" | "knowledge.create" | "knowledge.document.prepare" | "knowledge.document.preview" | "knowledge.document.import" | "knowledge.task.read";
|
|
866
|
+
digest: string;
|
|
867
|
+
}, {
|
|
868
|
+
action: "knowledge.list" | "knowledge.create.preview" | "knowledge.create" | "knowledge.document.prepare" | "knowledge.document.preview" | "knowledge.document.import" | "knowledge.task.read";
|
|
869
|
+
digest: string;
|
|
870
|
+
}>;
|
|
871
|
+
declare const pluginKnowledgeBaseInputSchema: z.ZodObject<{
|
|
872
|
+
name: z.ZodString;
|
|
873
|
+
description: z.ZodOptional<z.ZodString>;
|
|
874
|
+
scope: z.ZodObject<{
|
|
875
|
+
type: z.ZodLiteral<"team">;
|
|
876
|
+
teamId: z.ZodString;
|
|
877
|
+
}, "strict", z.ZodTypeAny, {
|
|
878
|
+
type: "team";
|
|
879
|
+
teamId: string;
|
|
880
|
+
}, {
|
|
881
|
+
type: "team";
|
|
882
|
+
teamId: string;
|
|
883
|
+
}>;
|
|
884
|
+
grants: z.ZodArray<z.ZodObject<{
|
|
885
|
+
subjectType: z.ZodEnum<["user", "role", "team", "tenant"]>;
|
|
886
|
+
subjectId: z.ZodString;
|
|
887
|
+
permission: z.ZodEnum<["view", "use", "operate", "manage"]>;
|
|
888
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
889
|
+
}, "strict", z.ZodTypeAny, {
|
|
890
|
+
permission: "view" | "manage" | "use" | "operate";
|
|
891
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
892
|
+
subjectId: string;
|
|
893
|
+
expiresAt?: string | null | undefined;
|
|
894
|
+
}, {
|
|
895
|
+
permission: "view" | "manage" | "use" | "operate";
|
|
896
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
897
|
+
subjectId: string;
|
|
898
|
+
expiresAt?: string | null | undefined;
|
|
899
|
+
}>, "many">;
|
|
900
|
+
idempotencyKey: z.ZodString;
|
|
901
|
+
}, "strict", z.ZodTypeAny, {
|
|
902
|
+
scope: {
|
|
903
|
+
type: "team";
|
|
904
|
+
teamId: string;
|
|
905
|
+
};
|
|
906
|
+
name: string;
|
|
907
|
+
grants: {
|
|
908
|
+
permission: "view" | "manage" | "use" | "operate";
|
|
909
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
910
|
+
subjectId: string;
|
|
911
|
+
expiresAt?: string | null | undefined;
|
|
912
|
+
}[];
|
|
913
|
+
idempotencyKey: string;
|
|
914
|
+
description?: string | undefined;
|
|
915
|
+
}, {
|
|
916
|
+
scope: {
|
|
917
|
+
type: "team";
|
|
918
|
+
teamId: string;
|
|
919
|
+
};
|
|
920
|
+
name: string;
|
|
921
|
+
grants: {
|
|
922
|
+
permission: "view" | "manage" | "use" | "operate";
|
|
923
|
+
subjectType: "tenant" | "user" | "team" | "role";
|
|
924
|
+
subjectId: string;
|
|
925
|
+
expiresAt?: string | null | undefined;
|
|
926
|
+
}[];
|
|
927
|
+
idempotencyKey: string;
|
|
928
|
+
description?: string | undefined;
|
|
929
|
+
}>;
|
|
930
|
+
type PluginKnowledgeBaseInput = z.infer<typeof pluginKnowledgeBaseInputSchema>;
|
|
931
|
+
declare const pluginDocumentContentInputSchema: z.ZodObject<{
|
|
932
|
+
knowledgeBaseId: z.ZodString;
|
|
933
|
+
objectKey: z.ZodString;
|
|
934
|
+
fileName: z.ZodEffects<z.ZodString, string, string>;
|
|
935
|
+
sha256: z.ZodString;
|
|
936
|
+
}, "strict", z.ZodTypeAny, {
|
|
937
|
+
knowledgeBaseId: string;
|
|
938
|
+
fileName: string;
|
|
939
|
+
objectKey: string;
|
|
940
|
+
sha256: string;
|
|
941
|
+
}, {
|
|
942
|
+
knowledgeBaseId: string;
|
|
943
|
+
fileName: string;
|
|
944
|
+
objectKey: string;
|
|
945
|
+
sha256: string;
|
|
946
|
+
}>;
|
|
947
|
+
type PluginDocumentContentInput = z.infer<typeof pluginDocumentContentInputSchema>;
|
|
948
|
+
declare const pluginDocumentBatchItemSchema: z.ZodObject<{
|
|
949
|
+
knowledgeBaseId: z.ZodString;
|
|
950
|
+
objectKey: z.ZodString;
|
|
951
|
+
fileName: z.ZodEffects<z.ZodString, string, string>;
|
|
952
|
+
sha256: z.ZodString;
|
|
953
|
+
} & {
|
|
954
|
+
sourceDocumentId: z.ZodString;
|
|
955
|
+
sourceVersion: z.ZodString;
|
|
956
|
+
sourceDigest: z.ZodString;
|
|
957
|
+
attachmentDigest: z.ZodString;
|
|
958
|
+
contentType: z.ZodLiteral<"text/markdown">;
|
|
959
|
+
idempotencyKey: z.ZodString;
|
|
960
|
+
departmentExternalId: z.ZodString;
|
|
961
|
+
departmentPath: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
962
|
+
departmentSourceVersion: z.ZodOptional<z.ZodString>;
|
|
963
|
+
teamId: z.ZodString;
|
|
964
|
+
bindingRevision: z.ZodNumber;
|
|
965
|
+
departmentMappingDigest: z.ZodOptional<z.ZodString>;
|
|
966
|
+
baseAclVersion: z.ZodNumber;
|
|
967
|
+
}, "strict", z.ZodTypeAny, {
|
|
968
|
+
knowledgeBaseId: string;
|
|
969
|
+
fileName: string;
|
|
970
|
+
sourceVersion: string;
|
|
971
|
+
teamId: string;
|
|
972
|
+
idempotencyKey: string;
|
|
973
|
+
objectKey: string;
|
|
974
|
+
sha256: string;
|
|
975
|
+
sourceDocumentId: string;
|
|
976
|
+
sourceDigest: string;
|
|
977
|
+
attachmentDigest: string;
|
|
978
|
+
contentType: "text/markdown";
|
|
979
|
+
departmentExternalId: string;
|
|
980
|
+
bindingRevision: number;
|
|
981
|
+
baseAclVersion: number;
|
|
982
|
+
departmentPath?: string[] | undefined;
|
|
983
|
+
departmentSourceVersion?: string | undefined;
|
|
984
|
+
departmentMappingDigest?: string | undefined;
|
|
985
|
+
}, {
|
|
986
|
+
knowledgeBaseId: string;
|
|
987
|
+
fileName: string;
|
|
988
|
+
sourceVersion: string;
|
|
989
|
+
teamId: string;
|
|
990
|
+
idempotencyKey: string;
|
|
991
|
+
objectKey: string;
|
|
992
|
+
sha256: string;
|
|
993
|
+
sourceDocumentId: string;
|
|
994
|
+
sourceDigest: string;
|
|
995
|
+
attachmentDigest: string;
|
|
996
|
+
contentType: "text/markdown";
|
|
997
|
+
departmentExternalId: string;
|
|
998
|
+
bindingRevision: number;
|
|
999
|
+
baseAclVersion: number;
|
|
1000
|
+
departmentPath?: string[] | undefined;
|
|
1001
|
+
departmentSourceVersion?: string | undefined;
|
|
1002
|
+
departmentMappingDigest?: string | undefined;
|
|
1003
|
+
}>;
|
|
1004
|
+
type PluginDocumentBatchItem = z.infer<typeof pluginDocumentBatchItemSchema>;
|
|
1005
|
+
declare const pluginDocumentBatchInputSchema: z.ZodEffects<z.ZodObject<{
|
|
1006
|
+
ruleVersion: z.ZodNumber;
|
|
1007
|
+
items: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
1008
|
+
knowledgeBaseId: z.ZodString;
|
|
1009
|
+
objectKey: z.ZodString;
|
|
1010
|
+
fileName: z.ZodEffects<z.ZodString, string, string>;
|
|
1011
|
+
sha256: z.ZodString;
|
|
1012
|
+
} & {
|
|
1013
|
+
sourceDocumentId: z.ZodString;
|
|
1014
|
+
sourceVersion: z.ZodString;
|
|
1015
|
+
sourceDigest: z.ZodString;
|
|
1016
|
+
attachmentDigest: z.ZodString;
|
|
1017
|
+
contentType: z.ZodLiteral<"text/markdown">;
|
|
1018
|
+
idempotencyKey: z.ZodString;
|
|
1019
|
+
departmentExternalId: z.ZodString;
|
|
1020
|
+
departmentPath: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
1021
|
+
departmentSourceVersion: z.ZodOptional<z.ZodString>;
|
|
1022
|
+
teamId: z.ZodString;
|
|
1023
|
+
bindingRevision: z.ZodNumber;
|
|
1024
|
+
departmentMappingDigest: z.ZodOptional<z.ZodString>;
|
|
1025
|
+
baseAclVersion: z.ZodNumber;
|
|
1026
|
+
}, "strict", z.ZodTypeAny, {
|
|
1027
|
+
knowledgeBaseId: string;
|
|
1028
|
+
fileName: string;
|
|
1029
|
+
sourceVersion: string;
|
|
1030
|
+
teamId: string;
|
|
1031
|
+
idempotencyKey: string;
|
|
1032
|
+
objectKey: string;
|
|
1033
|
+
sha256: string;
|
|
1034
|
+
sourceDocumentId: string;
|
|
1035
|
+
sourceDigest: string;
|
|
1036
|
+
attachmentDigest: string;
|
|
1037
|
+
contentType: "text/markdown";
|
|
1038
|
+
departmentExternalId: string;
|
|
1039
|
+
bindingRevision: number;
|
|
1040
|
+
baseAclVersion: number;
|
|
1041
|
+
departmentPath?: string[] | undefined;
|
|
1042
|
+
departmentSourceVersion?: string | undefined;
|
|
1043
|
+
departmentMappingDigest?: string | undefined;
|
|
1044
|
+
}, {
|
|
1045
|
+
knowledgeBaseId: string;
|
|
1046
|
+
fileName: string;
|
|
1047
|
+
sourceVersion: string;
|
|
1048
|
+
teamId: string;
|
|
1049
|
+
idempotencyKey: string;
|
|
1050
|
+
objectKey: string;
|
|
1051
|
+
sha256: string;
|
|
1052
|
+
sourceDocumentId: string;
|
|
1053
|
+
sourceDigest: string;
|
|
1054
|
+
attachmentDigest: string;
|
|
1055
|
+
contentType: "text/markdown";
|
|
1056
|
+
departmentExternalId: string;
|
|
1057
|
+
bindingRevision: number;
|
|
1058
|
+
baseAclVersion: number;
|
|
1059
|
+
departmentPath?: string[] | undefined;
|
|
1060
|
+
departmentSourceVersion?: string | undefined;
|
|
1061
|
+
departmentMappingDigest?: string | undefined;
|
|
1062
|
+
}>, "many">, {
|
|
1063
|
+
knowledgeBaseId: string;
|
|
1064
|
+
fileName: string;
|
|
1065
|
+
sourceVersion: string;
|
|
1066
|
+
teamId: string;
|
|
1067
|
+
idempotencyKey: string;
|
|
1068
|
+
objectKey: string;
|
|
1069
|
+
sha256: string;
|
|
1070
|
+
sourceDocumentId: string;
|
|
1071
|
+
sourceDigest: string;
|
|
1072
|
+
attachmentDigest: string;
|
|
1073
|
+
contentType: "text/markdown";
|
|
1074
|
+
departmentExternalId: string;
|
|
1075
|
+
bindingRevision: number;
|
|
1076
|
+
baseAclVersion: number;
|
|
1077
|
+
departmentPath?: string[] | undefined;
|
|
1078
|
+
departmentSourceVersion?: string | undefined;
|
|
1079
|
+
departmentMappingDigest?: string | undefined;
|
|
1080
|
+
}[], {
|
|
1081
|
+
knowledgeBaseId: string;
|
|
1082
|
+
fileName: string;
|
|
1083
|
+
sourceVersion: string;
|
|
1084
|
+
teamId: string;
|
|
1085
|
+
idempotencyKey: string;
|
|
1086
|
+
objectKey: string;
|
|
1087
|
+
sha256: string;
|
|
1088
|
+
sourceDocumentId: string;
|
|
1089
|
+
sourceDigest: string;
|
|
1090
|
+
attachmentDigest: string;
|
|
1091
|
+
contentType: "text/markdown";
|
|
1092
|
+
departmentExternalId: string;
|
|
1093
|
+
bindingRevision: number;
|
|
1094
|
+
baseAclVersion: number;
|
|
1095
|
+
departmentPath?: string[] | undefined;
|
|
1096
|
+
departmentSourceVersion?: string | undefined;
|
|
1097
|
+
departmentMappingDigest?: string | undefined;
|
|
1098
|
+
}[]>;
|
|
1099
|
+
}, "strict", z.ZodTypeAny, {
|
|
1100
|
+
items: {
|
|
1101
|
+
knowledgeBaseId: string;
|
|
1102
|
+
fileName: string;
|
|
1103
|
+
sourceVersion: string;
|
|
1104
|
+
teamId: string;
|
|
1105
|
+
idempotencyKey: string;
|
|
1106
|
+
objectKey: string;
|
|
1107
|
+
sha256: string;
|
|
1108
|
+
sourceDocumentId: string;
|
|
1109
|
+
sourceDigest: string;
|
|
1110
|
+
attachmentDigest: string;
|
|
1111
|
+
contentType: "text/markdown";
|
|
1112
|
+
departmentExternalId: string;
|
|
1113
|
+
bindingRevision: number;
|
|
1114
|
+
baseAclVersion: number;
|
|
1115
|
+
departmentPath?: string[] | undefined;
|
|
1116
|
+
departmentSourceVersion?: string | undefined;
|
|
1117
|
+
departmentMappingDigest?: string | undefined;
|
|
1118
|
+
}[];
|
|
1119
|
+
ruleVersion: number;
|
|
1120
|
+
}, {
|
|
1121
|
+
items: {
|
|
1122
|
+
knowledgeBaseId: string;
|
|
1123
|
+
fileName: string;
|
|
1124
|
+
sourceVersion: string;
|
|
1125
|
+
teamId: string;
|
|
1126
|
+
idempotencyKey: string;
|
|
1127
|
+
objectKey: string;
|
|
1128
|
+
sha256: string;
|
|
1129
|
+
sourceDocumentId: string;
|
|
1130
|
+
sourceDigest: string;
|
|
1131
|
+
attachmentDigest: string;
|
|
1132
|
+
contentType: "text/markdown";
|
|
1133
|
+
departmentExternalId: string;
|
|
1134
|
+
bindingRevision: number;
|
|
1135
|
+
baseAclVersion: number;
|
|
1136
|
+
departmentPath?: string[] | undefined;
|
|
1137
|
+
departmentSourceVersion?: string | undefined;
|
|
1138
|
+
departmentMappingDigest?: string | undefined;
|
|
1139
|
+
}[];
|
|
1140
|
+
ruleVersion: number;
|
|
1141
|
+
}>, {
|
|
1142
|
+
items: {
|
|
1143
|
+
knowledgeBaseId: string;
|
|
1144
|
+
fileName: string;
|
|
1145
|
+
sourceVersion: string;
|
|
1146
|
+
teamId: string;
|
|
1147
|
+
idempotencyKey: string;
|
|
1148
|
+
objectKey: string;
|
|
1149
|
+
sha256: string;
|
|
1150
|
+
sourceDocumentId: string;
|
|
1151
|
+
sourceDigest: string;
|
|
1152
|
+
attachmentDigest: string;
|
|
1153
|
+
contentType: "text/markdown";
|
|
1154
|
+
departmentExternalId: string;
|
|
1155
|
+
bindingRevision: number;
|
|
1156
|
+
baseAclVersion: number;
|
|
1157
|
+
departmentPath?: string[] | undefined;
|
|
1158
|
+
departmentSourceVersion?: string | undefined;
|
|
1159
|
+
departmentMappingDigest?: string | undefined;
|
|
1160
|
+
}[];
|
|
1161
|
+
ruleVersion: number;
|
|
1162
|
+
}, {
|
|
1163
|
+
items: {
|
|
1164
|
+
knowledgeBaseId: string;
|
|
1165
|
+
fileName: string;
|
|
1166
|
+
sourceVersion: string;
|
|
1167
|
+
teamId: string;
|
|
1168
|
+
idempotencyKey: string;
|
|
1169
|
+
objectKey: string;
|
|
1170
|
+
sha256: string;
|
|
1171
|
+
sourceDocumentId: string;
|
|
1172
|
+
sourceDigest: string;
|
|
1173
|
+
attachmentDigest: string;
|
|
1174
|
+
contentType: "text/markdown";
|
|
1175
|
+
departmentExternalId: string;
|
|
1176
|
+
bindingRevision: number;
|
|
1177
|
+
baseAclVersion: number;
|
|
1178
|
+
departmentPath?: string[] | undefined;
|
|
1179
|
+
departmentSourceVersion?: string | undefined;
|
|
1180
|
+
departmentMappingDigest?: string | undefined;
|
|
1181
|
+
}[];
|
|
1182
|
+
ruleVersion: number;
|
|
1183
|
+
}>;
|
|
1184
|
+
type PluginDocumentBatchInput = z.infer<typeof pluginDocumentBatchInputSchema>;
|
|
1185
|
+
interface PluginApprovedRequest<T> {
|
|
1186
|
+
actionProof: string;
|
|
1187
|
+
approvedDigest: string;
|
|
1188
|
+
input: T;
|
|
1189
|
+
}
|
|
1190
|
+
declare const pluginApprovedSchema: <T extends z.ZodType>(input: T) => z.ZodObject<{
|
|
1191
|
+
actionProof: z.ZodString;
|
|
1192
|
+
approvedDigest: z.ZodString;
|
|
1193
|
+
input: T;
|
|
1194
|
+
}, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
1195
|
+
actionProof: z.ZodString;
|
|
1196
|
+
approvedDigest: z.ZodString;
|
|
1197
|
+
input: T;
|
|
1198
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
|
|
1199
|
+
actionProof: z.ZodString;
|
|
1200
|
+
approvedDigest: z.ZodString;
|
|
1201
|
+
input: T;
|
|
1202
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
1203
|
+
interface PluginDocumentPreviewItem {
|
|
1204
|
+
sourceDocumentId: string;
|
|
1205
|
+
action: 'create' | 'update' | 'move';
|
|
1206
|
+
knowledgeBaseId: string;
|
|
1207
|
+
previousKnowledgeBaseId?: string;
|
|
1208
|
+
documentId?: string;
|
|
1209
|
+
sha256: string;
|
|
1210
|
+
scope: {
|
|
1211
|
+
type: 'team';
|
|
1212
|
+
teamId: string;
|
|
1213
|
+
};
|
|
1214
|
+
aclVersion: number;
|
|
1215
|
+
inheritedGrants: PluginKnowledgeBaseInput['grants'];
|
|
1216
|
+
issues: string[];
|
|
1217
|
+
}
|
|
1218
|
+
interface PluginKnowledgeAdminApi {
|
|
1219
|
+
listManageableBases(input: {
|
|
1220
|
+
actionProof: string;
|
|
1221
|
+
search?: string;
|
|
1222
|
+
departmentExternalIds?: string[];
|
|
1223
|
+
sourceDepartments?: {
|
|
1224
|
+
externalId: string;
|
|
1225
|
+
path: string[];
|
|
1226
|
+
sourceVersion: string;
|
|
1227
|
+
}[];
|
|
1228
|
+
sourceDocumentIds?: string[];
|
|
1229
|
+
}): Promise<{
|
|
1230
|
+
departmentMatching?: 'path-v1';
|
|
1231
|
+
localDepartmentCount?: number;
|
|
1232
|
+
departments?: {
|
|
1233
|
+
externalId: string;
|
|
1234
|
+
teamId: string | null;
|
|
1235
|
+
mappingDigest: string | null;
|
|
1236
|
+
issue: string | null;
|
|
1237
|
+
}[];
|
|
1238
|
+
syncLocations?: {
|
|
1239
|
+
sourceDocumentId: string;
|
|
1240
|
+
knowledgeBaseId: string;
|
|
1241
|
+
name: string;
|
|
1242
|
+
documentId: string;
|
|
1243
|
+
}[];
|
|
1244
|
+
syncStates?: {
|
|
1245
|
+
sourceDocumentId: string;
|
|
1246
|
+
knowledgeBaseId: string;
|
|
1247
|
+
name?: string;
|
|
1248
|
+
status: string;
|
|
1249
|
+
error: string | null;
|
|
1250
|
+
}[];
|
|
1251
|
+
items: {
|
|
1252
|
+
id: string;
|
|
1253
|
+
name: string;
|
|
1254
|
+
status: string;
|
|
1255
|
+
scope: {
|
|
1256
|
+
type: 'team';
|
|
1257
|
+
teamId: string;
|
|
1258
|
+
};
|
|
1259
|
+
aclVersion: number;
|
|
1260
|
+
grants: PluginKnowledgeBaseInput['grants'];
|
|
1261
|
+
}[];
|
|
1262
|
+
}>;
|
|
1263
|
+
previewCreateBase(input: PluginApprovedRequest<PluginKnowledgeBaseInput>): Promise<{
|
|
1264
|
+
digest: string;
|
|
1265
|
+
valid: boolean;
|
|
1266
|
+
issues: string[];
|
|
1267
|
+
}>;
|
|
1268
|
+
createApprovedBase(input: PluginApprovedRequest<PluginKnowledgeBaseInput>): Promise<{
|
|
1269
|
+
id: string;
|
|
1270
|
+
status: string;
|
|
1271
|
+
}>;
|
|
1272
|
+
prepareDocumentContent(input: PluginApprovedRequest<PluginDocumentContentInput>): Promise<{
|
|
1273
|
+
text: string;
|
|
1274
|
+
sha256: string;
|
|
1275
|
+
}>;
|
|
1276
|
+
previewDocumentBatch(input: PluginApprovedRequest<PluginDocumentBatchInput>): Promise<{
|
|
1277
|
+
digest: string;
|
|
1278
|
+
inputDigest: string;
|
|
1279
|
+
valid: boolean;
|
|
1280
|
+
issues: string[];
|
|
1281
|
+
count: number;
|
|
1282
|
+
items: PluginDocumentPreviewItem[];
|
|
1283
|
+
summary: {
|
|
1284
|
+
create: number;
|
|
1285
|
+
update: number;
|
|
1286
|
+
move: number;
|
|
1287
|
+
};
|
|
1288
|
+
}>;
|
|
1289
|
+
stageApprovedDocumentBatch(input: PluginApprovedRequest<PluginDocumentBatchInput> & {
|
|
1290
|
+
taskId?: string;
|
|
1291
|
+
}): Promise<{
|
|
1292
|
+
taskId: string;
|
|
1293
|
+
status: 'queued';
|
|
1294
|
+
}>;
|
|
1295
|
+
getTask(input: {
|
|
1296
|
+
actionProof?: string;
|
|
1297
|
+
taskId: string;
|
|
1298
|
+
}): Promise<Record<string, unknown>>;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* What a plugin's backend part exports, and the capabilities the host lends it.
|
|
1303
|
+
*
|
|
1304
|
+
* The backend runs as its own process under a sandbox, never inside the API
|
|
1305
|
+
* process — that process holds every tenant's database credentials. Everything
|
|
1306
|
+
* it can reach arrives through {@link PluginHostApi}, so the capability list is
|
|
1307
|
+
* literally the blast radius.
|
|
1308
|
+
*/
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* How a backend learns who is calling.
|
|
1312
|
+
*
|
|
1313
|
+
* Declared here because both ends read it: the platform's gateway sets these
|
|
1314
|
+
* after it has authenticated the caller, and `serveBackend` parses them back
|
|
1315
|
+
* into a {@link PluginUserContext}. A copy on each side would be a contract
|
|
1316
|
+
* that can drift silently — the backend would simply see no user.
|
|
1317
|
+
*
|
|
1318
|
+
* There is deliberately no token among them. A plugin runs third-party code,
|
|
1319
|
+
* and the caller's token authorizes the whole platform API, so handing it over
|
|
1320
|
+
* would make every backend a place from which the user's account can be
|
|
1321
|
+
* driven. This is also why a plugin is told never to parse a token: there is
|
|
1322
|
+
* none to parse.
|
|
1323
|
+
*/
|
|
1324
|
+
declare const PLUGIN_CONTEXT_HEADERS: {
|
|
1325
|
+
readonly userId: "x-tego-plugin-user-id";
|
|
1326
|
+
readonly tenantId: "x-tego-plugin-tenant-id";
|
|
1327
|
+
/** JSON array, so a role name containing a separator cannot be mis-split. */
|
|
1328
|
+
readonly roles: "x-tego-plugin-roles";
|
|
1329
|
+
/**
|
|
1330
|
+
* Present only when a claw container is the caller. Without it a backend
|
|
1331
|
+
* cannot tell which of the tenant's avatars is asking — every container
|
|
1332
|
+
* authenticates on its own gateway token, and they all resolve to the
|
|
1333
|
+
* avatar owner's user id.
|
|
1334
|
+
*/
|
|
1335
|
+
readonly avatarId: "x-tego-plugin-avatar-id";
|
|
1336
|
+
readonly delegation: "x-tego-plugin-delegation";
|
|
1337
|
+
/**
|
|
1338
|
+
* Unix milliseconds at which the gateway signed the four above.
|
|
1339
|
+
*
|
|
1340
|
+
* Signed along with them, so it cannot be moved forward to extend the life
|
|
1341
|
+
* of a captured header set.
|
|
1342
|
+
*/
|
|
1343
|
+
readonly issuedAt: "x-tego-plugin-issued-at";
|
|
1344
|
+
/**
|
|
1345
|
+
* HMAC over the identity, keyed per install — see `gateway-signature`.
|
|
1346
|
+
*
|
|
1347
|
+
* Without it the identity is whatever the socket claims, which is only as
|
|
1348
|
+
* strong as the network the backend sits on.
|
|
1349
|
+
*/
|
|
1350
|
+
readonly signature: "x-tego-plugin-signature";
|
|
1351
|
+
/** `1` on an anonymous request to a declared public route; see below. */
|
|
1352
|
+
readonly public: "x-tego-plugin-public";
|
|
1353
|
+
readonly installId: "x-tego-plugin-install-id";
|
|
1354
|
+
readonly publicRoute: "x-tego-plugin-public-route";
|
|
1355
|
+
readonly clientIp: "x-tego-plugin-client-ip";
|
|
1356
|
+
};
|
|
1357
|
+
/**
|
|
1358
|
+
* An anonymous request to a route `parts.backend.publicRoutes` declares.
|
|
1359
|
+
*
|
|
1360
|
+
* Carries no identity and no permission. Whatever token the path holds (a QR
|
|
1361
|
+
* link's, say) is the plugin's to check; the platform only vouches that the
|
|
1362
|
+
* route was declared and the install is enabled.
|
|
1363
|
+
*/
|
|
1364
|
+
interface PluginPublicContext {
|
|
1365
|
+
tenantId: string;
|
|
1366
|
+
installId: string;
|
|
1367
|
+
avatarId?: string;
|
|
1368
|
+
/** The matched declaration, e.g. `POST /public/trainings/:token/sign`. */
|
|
1369
|
+
route: string;
|
|
1370
|
+
clientIp: string;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Parameterized SQL against the plugin's own Postgres schema.
|
|
1374
|
+
*
|
|
1375
|
+
* The connection uses a role granted DML on that schema and nothing else, with
|
|
1376
|
+
* `search_path` pinned to it. No ORM is imposed: a plugin can layer Drizzle or
|
|
1377
|
+
* Kysely on top, and inventing a query-builder RPC here would freeze one
|
|
1378
|
+
* opinion into the contract forever.
|
|
1379
|
+
*/
|
|
1380
|
+
interface PluginScopedDb {
|
|
1381
|
+
query<T = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<T[]>;
|
|
1382
|
+
/**
|
|
1383
|
+
* Runs `body` on a single connection, wrapped in `BEGIN` / `COMMIT`.
|
|
1384
|
+
*
|
|
1385
|
+
* `query` above takes a connection from the pool per call, so a `BEGIN` and
|
|
1386
|
+
* its `COMMIT` would land on different connections and neither would mean
|
|
1387
|
+
* anything. Without this, a plugin whose write has to be atomic across
|
|
1388
|
+
* tables has one option left: phrase the whole thing as a single statement
|
|
1389
|
+
* with data-modifying CTEs. That works, and it stops working as soon as the
|
|
1390
|
+
* write is conditional on the row it is about.
|
|
1391
|
+
*
|
|
1392
|
+
* Throwing from `body` rolls back and re-throws. The transaction holds a
|
|
1393
|
+
* connection for as long as `body` runs, so a body that awaits something
|
|
1394
|
+
* slow — an HTTP call, say — is holding one of a small number of them: the
|
|
1395
|
+
* host bounds that from the database side rather than trusting plugins.
|
|
1396
|
+
*/
|
|
1397
|
+
transaction<T>(body: (tx: PluginTransaction) => Promise<T>): Promise<T>;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* The one connection a {@link PluginScopedDb.transaction} body writes through.
|
|
1401
|
+
*
|
|
1402
|
+
* Deliberately without a nested `transaction`: Postgres has no nested
|
|
1403
|
+
* transactions, only savepoints, and a method that silently meant something
|
|
1404
|
+
* weaker than its name would be worse than its absence.
|
|
1405
|
+
*/
|
|
1406
|
+
interface PluginTransaction {
|
|
1407
|
+
query<T = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<T[]>;
|
|
1408
|
+
}
|
|
1409
|
+
/** Object storage confined to the plugin's own key prefix. */
|
|
1410
|
+
interface PluginManagedDownloadPolicy {
|
|
1411
|
+
subject: {
|
|
1412
|
+
kind: 'user';
|
|
1413
|
+
userId: string;
|
|
1414
|
+
} | {
|
|
1415
|
+
kind: 'public';
|
|
1416
|
+
grantId: string;
|
|
1417
|
+
};
|
|
1418
|
+
/** Optional domain ID used by CRM-style plugins; generic resources use resourceId. */
|
|
1419
|
+
customerId?: number;
|
|
1420
|
+
resourceType: string;
|
|
1421
|
+
resourceId: string;
|
|
1422
|
+
purpose: 'view' | 'export';
|
|
1423
|
+
}
|
|
1424
|
+
interface PluginScopedStorage {
|
|
1425
|
+
/** Host API 1.19; namespace-scoped transfers, requiring storage.transfer. */
|
|
1426
|
+
copy?(sourceKey: string, destinationKey: string): Promise<PluginObjectHead>;
|
|
1427
|
+
getStream?(key: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
1428
|
+
putStream?(key: string, body: ReadableStream<Uint8Array>, options: {
|
|
1429
|
+
sizeBytes: number;
|
|
1430
|
+
contentType?: string;
|
|
1431
|
+
}): Promise<void>;
|
|
1432
|
+
/** Up to 25 MB; larger objects go through {@link uploadPath}. */
|
|
1433
|
+
put(key: string, body: Uint8Array, contentType?: string): Promise<void>;
|
|
1434
|
+
/**
|
|
1435
|
+
* The object, or only its first `firstBytes` — enough to check a file
|
|
1436
|
+
* signature without pulling a large upload into this process.
|
|
1437
|
+
*/
|
|
1438
|
+
get(key: string, options?: {
|
|
1439
|
+
firstBytes?: number;
|
|
1440
|
+
}): Promise<Uint8Array | null>;
|
|
1441
|
+
/** Size and stored type, without reading the object. */
|
|
1442
|
+
head(key: string): Promise<PluginObjectHead | null>;
|
|
1443
|
+
delete(key: string): Promise<void>;
|
|
1444
|
+
/**
|
|
1445
|
+
* Short-lived download URL, for handing large objects to the browser.
|
|
1446
|
+
*
|
|
1447
|
+
* Absolute only when the platform knows its public address; prefer
|
|
1448
|
+
* {@link signedPath}, which the frontend resolves with `ctx.hostUrl`.
|
|
1449
|
+
*/
|
|
1450
|
+
signedUrl(key: string, ttlSeconds?: number): Promise<string>;
|
|
1451
|
+
/** The same download, as a path for the frontend's `ctx.hostUrl`. */
|
|
1452
|
+
signedPath(key: string, ttlSeconds?: number): Promise<string>;
|
|
1453
|
+
/** Rechecked at the fixed internal storage policy endpoint before every download. */
|
|
1454
|
+
managedPath(key: string, policy: PluginManagedDownloadPolicy, ttlSeconds?: number): Promise<string>;
|
|
1455
|
+
/**
|
|
1456
|
+
* A path the browser can PUT one object to, once — the way to store
|
|
1457
|
+
* something larger than `put` accepts. The body streams straight into
|
|
1458
|
+
* storage without passing through this backend; check it afterwards with
|
|
1459
|
+
* {@link head} and {@link get}'s `firstBytes`.
|
|
1460
|
+
*/
|
|
1461
|
+
uploadPath(key: string, options?: {
|
|
1462
|
+
maxBytes?: number;
|
|
1463
|
+
ttlSeconds?: number;
|
|
1464
|
+
}): Promise<PluginObjectUpload>;
|
|
1465
|
+
}
|
|
1466
|
+
interface PluginObjectHead {
|
|
1467
|
+
/** Opaque content version validator, when supported. Changes whenever the object bytes change. */
|
|
1468
|
+
versionTag?: string;
|
|
1469
|
+
size: number;
|
|
1470
|
+
contentType: string | null;
|
|
1471
|
+
}
|
|
1472
|
+
interface PluginObjectUpload {
|
|
1473
|
+
/** Resolve with the frontend's `ctx.hostUrl`, then PUT with Content-Length. */
|
|
1474
|
+
path: string;
|
|
1475
|
+
/** The ceiling the host granted: the request's, capped by the platform's. */
|
|
1476
|
+
maxBytes: number;
|
|
1477
|
+
/** Epoch milliseconds. */
|
|
1478
|
+
expiresAt: number;
|
|
1479
|
+
}
|
|
1480
|
+
interface PluginLogger {
|
|
1481
|
+
debug(message: string, fields?: Record<string, unknown>): void;
|
|
1482
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
1483
|
+
warn(message: string, fields?: Record<string, unknown>): void;
|
|
1484
|
+
error(message: string, fields?: Record<string, unknown>): void;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* There is deliberately no way to invoke a tool on a claw instance.
|
|
1488
|
+
*
|
|
1489
|
+
* Reaching claw means acting for a user, and this object belongs to the
|
|
1490
|
+
* container rather than to any one request — so it would need a second kind of
|
|
1491
|
+
* credential, minted per request and carried back. Nothing needs it yet: the
|
|
1492
|
+
* traffic runs the other way, with a plugin's claw part polling a queue its
|
|
1493
|
+
* backend writes. Adding it later is a token design, not a method.
|
|
1494
|
+
*/
|
|
1495
|
+
/**
|
|
1496
|
+
* The operator-supplied settings for this install's backend part.
|
|
1497
|
+
*
|
|
1498
|
+
* A snapshot plus a way to re-take it, rather than a promise per read. The
|
|
1499
|
+
* values arrive over the host API — which is how a secret stays out of the
|
|
1500
|
+
* container's environment, where `docker inspect` and every crash dump would
|
|
1501
|
+
* find it — and the runtime fetches them once before the backend accepts its
|
|
1502
|
+
* first request, so a handler can read them without awaiting anything.
|
|
1503
|
+
*
|
|
1504
|
+
* Only what `parts.backend.config` declares, with declared defaults applied.
|
|
1505
|
+
* The frontend's and claw's settings are stored separately and are not
|
|
1506
|
+
* reachable from here.
|
|
1507
|
+
*/
|
|
1508
|
+
interface PluginConfigAccess {
|
|
1509
|
+
/** The settings as of the last fetch. Never null once the backend is serving. */
|
|
1510
|
+
current(): Record<string, unknown>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Re-read them, for a plugin that wants a rotated credential without a
|
|
1513
|
+
* restart. There is no push channel: the platform cannot call into a plugin
|
|
1514
|
+
* backend, so noticing a change is the plugin's own business.
|
|
1515
|
+
*/
|
|
1516
|
+
refresh(): Promise<Record<string, unknown>>;
|
|
1517
|
+
}
|
|
1518
|
+
interface PluginHostApi {
|
|
1519
|
+
pluginId: string;
|
|
1520
|
+
/**
|
|
1521
|
+
* Host API 1.22; the tenant this install belongs to.
|
|
1522
|
+
*
|
|
1523
|
+
* An install serves exactly one tenant, but until now only a request's
|
|
1524
|
+
* `ctx` said which — so `start`, which runs before any request, could not
|
|
1525
|
+
* write a tenant-owned row.
|
|
1526
|
+
*/
|
|
1527
|
+
tenantId: string;
|
|
1528
|
+
db: PluginScopedDb;
|
|
1529
|
+
storage: PluginScopedStorage;
|
|
1530
|
+
log: PluginLogger;
|
|
1531
|
+
config: PluginConfigAccess;
|
|
1532
|
+
/** Requires the install's directory.read capability. */
|
|
1533
|
+
directory?: PluginDirectoryApi;
|
|
1534
|
+
/** Creates ordinary accounts only; requires accounts.provision. */
|
|
1535
|
+
accounts?: PluginAccountsApi;
|
|
1536
|
+
/** Verifies citations against the existing platform knowledge and its live ACL. */
|
|
1537
|
+
knowledge?: PluginKnowledgeApi;
|
|
1538
|
+
/** Host API 1.23; explicit administrator approval for ordinary team bases. */
|
|
1539
|
+
knowledgeAdmin?: PluginKnowledgeAdminApi;
|
|
1540
|
+
/** Host API 1.20; isolated HTML and Mermaid PNG rendering. */
|
|
1541
|
+
diagrams?: PluginDiagramsApi;
|
|
1542
|
+
sources?: {
|
|
1543
|
+
/** Revalidates source ownership and capture permission on the host. */
|
|
1544
|
+
read(id: string, actor: {
|
|
1545
|
+
userId: string;
|
|
1546
|
+
avatarId: string;
|
|
1547
|
+
metadataOnly?: boolean;
|
|
1548
|
+
}): Promise<{
|
|
1549
|
+
source: unknown;
|
|
1550
|
+
}>;
|
|
1551
|
+
};
|
|
1552
|
+
/**
|
|
1553
|
+
* A person's live work delegations, as the host holds them.
|
|
1554
|
+
*
|
|
1555
|
+
* A plugin that reassigns durable work between employees needs this: the
|
|
1556
|
+
* delegation is what makes an employee able to execute for that person, and
|
|
1557
|
+
* a handover to an employee they never delegated produces work nobody can
|
|
1558
|
+
* pick up. The plugin cannot answer that from its own tables — the grant
|
|
1559
|
+
* lives on the host and can be revoked there at any time.
|
|
1560
|
+
*/
|
|
1561
|
+
delegations?: {
|
|
1562
|
+
list(userId: string): Promise<{
|
|
1563
|
+
delegations: {
|
|
1564
|
+
avatarId: string;
|
|
1565
|
+
enabled: boolean;
|
|
1566
|
+
actions: string[];
|
|
1567
|
+
}[];
|
|
1568
|
+
}>;
|
|
1569
|
+
};
|
|
1570
|
+
events: {
|
|
1571
|
+
/**
|
|
1572
|
+
* Publishes into the tenant's event stream.
|
|
1573
|
+
*
|
|
1574
|
+
* The host prefixes the topic with `plugin.<pluginId>.`, so subscribers
|
|
1575
|
+
* see the namespaced name and a plugin cannot emit an event the platform's
|
|
1576
|
+
* own subscribers would mistake for one of theirs.
|
|
1577
|
+
*/
|
|
1578
|
+
publish(topic: string, payload: unknown): Promise<void>;
|
|
1579
|
+
};
|
|
1580
|
+
notifications: {
|
|
1581
|
+
/** Durable direct message, deduplicated per install, event key and recipient. */
|
|
1582
|
+
send(input: {
|
|
1583
|
+
recipientId: string;
|
|
1584
|
+
eventKey: string;
|
|
1585
|
+
title: string;
|
|
1586
|
+
body: string;
|
|
1587
|
+
path: string;
|
|
1588
|
+
priority?: 'normal' | 'urgent';
|
|
1589
|
+
}): Promise<{
|
|
1590
|
+
id: string;
|
|
1591
|
+
}>;
|
|
1592
|
+
};
|
|
1593
|
+
/** Host API 1.26; requires proactive.emit. */
|
|
1594
|
+
proactive?: {
|
|
1595
|
+
/**
|
|
1596
|
+
* Starts the user's event-triggered scheduled tasks listening for this
|
|
1597
|
+
* plugin's `eventType`.
|
|
1598
|
+
*
|
|
1599
|
+
* The host fixes the source to `plugin:<pluginId>`. Redelivering the same
|
|
1600
|
+
* `eventId` returns the runs it already queued, so retrying a failed call
|
|
1601
|
+
* is safe. An event nobody listens for answers no runs, not an error.
|
|
1602
|
+
*/
|
|
1603
|
+
emit(input: PluginProactiveEvent): Promise<PluginProactiveEmitResult>;
|
|
1604
|
+
};
|
|
1605
|
+
/** Host API 1.29; requires mail.send. */
|
|
1606
|
+
mail?: {
|
|
1607
|
+
/**
|
|
1608
|
+
* Sends one email from `userId`'s own connected Gmail or Outlook.
|
|
1609
|
+
*
|
|
1610
|
+
* The host picks the sender, appends an unsubscribe link and refuses
|
|
1611
|
+
* (without sending) when the person has not connected a mailbox, has not
|
|
1612
|
+
* allowed this plugin, the tenant turned sending off, the daily limit is
|
|
1613
|
+
* reached or the recipient unsubscribed.
|
|
1614
|
+
*
|
|
1615
|
+
* Providers have no idempotency key, so the promise is at most one email
|
|
1616
|
+
* per `idempotencyKey`: repeating a key returns the first outcome without
|
|
1617
|
+
* sending, and `unknown` means the mailbox may or may not have accepted
|
|
1618
|
+
* it. Only a `failed` key is sent again when repeated.
|
|
1619
|
+
*/
|
|
1620
|
+
send(input: PluginMailSendInput): Promise<PluginMailSendResult>;
|
|
1621
|
+
/** Whether `userId` can send through this plugin right now, and why not. */
|
|
1622
|
+
status(userId: string): Promise<PluginMailStatus>;
|
|
1623
|
+
/** Recipients who used the unsubscribe link on this plugin's mail, oldest first. */
|
|
1624
|
+
unsubscribes(input?: {
|
|
1625
|
+
after?: string;
|
|
1626
|
+
limit?: number;
|
|
1627
|
+
}): Promise<{
|
|
1628
|
+
items: PluginMailUnsubscribe[];
|
|
1629
|
+
next?: string;
|
|
1630
|
+
}>;
|
|
1631
|
+
};
|
|
1632
|
+
/** Host API 1.34; requires attention.request. */
|
|
1633
|
+
attention?: {
|
|
1634
|
+
/**
|
|
1635
|
+
* Asks a person to answer questions, approve or take over work on behalf
|
|
1636
|
+
* of `principalUserId` (the person the plugin acts for). The request shows
|
|
1637
|
+
* in the recipient's Messages and by push, under the tenant's attention
|
|
1638
|
+
* policy (who may be asked, rate limits). Same `dedupeKey` to the same
|
|
1639
|
+
* person returns the open request instead of a second one.
|
|
1640
|
+
*/
|
|
1641
|
+
request(input: PluginAttentionRequest): Promise<PluginAttentionReceipt>;
|
|
1642
|
+
/** The request as it stands now, including the response once answered. */
|
|
1643
|
+
get(itemId: string): Promise<PluginAttentionStatus>;
|
|
1644
|
+
/** Withdraws an open request; the recipient's alert is cleared. */
|
|
1645
|
+
cancel(itemId: string): Promise<PluginAttentionStatus>;
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
interface PluginAttentionQuestion {
|
|
1649
|
+
id: string;
|
|
1650
|
+
header: string;
|
|
1651
|
+
question: string;
|
|
1652
|
+
multiSelect?: boolean;
|
|
1653
|
+
isOther?: boolean;
|
|
1654
|
+
options?: {
|
|
1655
|
+
label: string;
|
|
1656
|
+
description?: string;
|
|
1657
|
+
}[];
|
|
1658
|
+
}
|
|
1659
|
+
interface PluginAttentionRequest {
|
|
1660
|
+
principalUserId: string;
|
|
1661
|
+
recipientUserId: string;
|
|
1662
|
+
kind: 'question' | 'approval' | 'handoff';
|
|
1663
|
+
title: string;
|
|
1664
|
+
context?: string;
|
|
1665
|
+
/** Required for `question`; not allowed otherwise. */
|
|
1666
|
+
questions?: PluginAttentionQuestion[];
|
|
1667
|
+
urgent?: boolean;
|
|
1668
|
+
deadlineHours?: number;
|
|
1669
|
+
dedupeKey?: string;
|
|
1670
|
+
/** The plugin's own record, echoed back in `get`. */
|
|
1671
|
+
recordRef?: string;
|
|
1672
|
+
}
|
|
1673
|
+
interface PluginAttentionReceipt {
|
|
1674
|
+
itemId: string;
|
|
1675
|
+
state: string;
|
|
1676
|
+
reused: boolean;
|
|
1677
|
+
deadlineAt: string;
|
|
1678
|
+
}
|
|
1679
|
+
interface PluginAttentionStatus {
|
|
1680
|
+
itemId: string;
|
|
1681
|
+
state: 'pending' | 'seen' | 'answered' | 'declined' | 'expired' | 'cancelled';
|
|
1682
|
+
recordRef: string | null;
|
|
1683
|
+
response: {
|
|
1684
|
+
kind: 'question';
|
|
1685
|
+
answers: Record<string, string[]>;
|
|
1686
|
+
note?: string;
|
|
1687
|
+
} | {
|
|
1688
|
+
kind: 'approval';
|
|
1689
|
+
decision: 'approve' | 'reject';
|
|
1690
|
+
note?: string;
|
|
1691
|
+
} | {
|
|
1692
|
+
kind: 'handoff';
|
|
1693
|
+
decision: 'accept';
|
|
1694
|
+
note?: string;
|
|
1695
|
+
} | null;
|
|
1696
|
+
declineReason: string | null;
|
|
1697
|
+
resolvedBy: string | null;
|
|
1698
|
+
resolvedAt: string | null;
|
|
1699
|
+
}
|
|
1700
|
+
interface PluginMailSendInput {
|
|
1701
|
+
userId: string;
|
|
1702
|
+
/** Up to 200 characters, no whitespace. */
|
|
1703
|
+
idempotencyKey: string;
|
|
1704
|
+
to: string;
|
|
1705
|
+
subject: string;
|
|
1706
|
+
/** Plain text; the host appends the unsubscribe line. */
|
|
1707
|
+
text: string;
|
|
1708
|
+
/** Echoed back with unsubscribes and sent as `X-Tego-Correlation`. */
|
|
1709
|
+
correlationId?: string;
|
|
1710
|
+
}
|
|
1711
|
+
type PluginMailRefusal = 'not_member' | 'not_connected' | 'connection_broken' | 'not_granted' | 'sending_disabled' | 'recipient_unsubscribed' | 'daily_limit' | 'unavailable';
|
|
1712
|
+
type PluginMailSendResult = {
|
|
1713
|
+
status: 'sent';
|
|
1714
|
+
/** Gmail only; Graph's sendMail returns no id. */
|
|
1715
|
+
providerMessageId?: string;
|
|
1716
|
+
threadId?: string;
|
|
1717
|
+
sentAt: number;
|
|
1718
|
+
duplicate: boolean;
|
|
1719
|
+
} | {
|
|
1720
|
+
status: 'failed';
|
|
1721
|
+
reason: 'provider_rejected' | 'rate_limited' | 'connection_broken';
|
|
1722
|
+
message: string;
|
|
1723
|
+
duplicate: boolean;
|
|
1724
|
+
} | {
|
|
1725
|
+
status: 'unknown';
|
|
1726
|
+
duplicate: boolean;
|
|
1727
|
+
} | {
|
|
1728
|
+
status: 'refused';
|
|
1729
|
+
reason: PluginMailRefusal;
|
|
1730
|
+
};
|
|
1731
|
+
interface PluginMailStatus {
|
|
1732
|
+
state: 'ready' | Exclude<PluginMailRefusal, 'recipient_unsubscribed' | 'daily_limit'>;
|
|
1733
|
+
provider?: 'google' | 'microsoft';
|
|
1734
|
+
email?: string;
|
|
1735
|
+
dailyLimit: number;
|
|
1736
|
+
sentToday: number;
|
|
1737
|
+
}
|
|
1738
|
+
interface PluginMailUnsubscribe {
|
|
1739
|
+
id: string;
|
|
1740
|
+
email: string;
|
|
1741
|
+
correlationId?: string;
|
|
1742
|
+
at: number;
|
|
1743
|
+
}
|
|
1744
|
+
interface PluginProactiveEvent {
|
|
1745
|
+
/** The person whose tasks may start; tasks of other people never match. */
|
|
1746
|
+
userId: string;
|
|
1747
|
+
/** Matched verbatim against the task's `eventType`; no whitespace, up to 160 characters. */
|
|
1748
|
+
eventType: string;
|
|
1749
|
+
/** Unique per event within this plugin; no whitespace, up to 100 characters. */
|
|
1750
|
+
eventId: string;
|
|
1751
|
+
occurredAtMs?: number;
|
|
1752
|
+
/**
|
|
1753
|
+
* Shown to the employee as untrusted external content. At most 16,000
|
|
1754
|
+
* characters once serialized.
|
|
1755
|
+
*/
|
|
1756
|
+
payload?: Record<string, unknown>;
|
|
1757
|
+
}
|
|
1758
|
+
interface PluginProactiveEmitResult {
|
|
1759
|
+
/** `plugin:<pluginId>`. */
|
|
1760
|
+
source: string;
|
|
1761
|
+
/**
|
|
1762
|
+
* One entry per matched task, plus one per employee the person can no
|
|
1763
|
+
* longer use (`access-denied`, no `jobId`). `already-running`: the task
|
|
1764
|
+
* was busy and this event did not queue a run — the plugin decides whether
|
|
1765
|
+
* to send the same event again later. `authority-inactive`: the
|
|
1766
|
+
* employee's schedule store cannot be queued from the platform.
|
|
1767
|
+
*/
|
|
1768
|
+
runs: Array<{
|
|
1769
|
+
jobId?: string;
|
|
1770
|
+
avatarId: string;
|
|
1771
|
+
accepted: boolean;
|
|
1772
|
+
runId?: string;
|
|
1773
|
+
reason?: 'already-running' | 'authority-inactive' | 'access-denied';
|
|
1774
|
+
}>;
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* The default export of a backend part's entry module.
|
|
1778
|
+
*
|
|
1779
|
+
* A web-standard `fetch` handler, so a plugin can hand the request straight to
|
|
1780
|
+
* Hono, which is what the platform itself runs.
|
|
1781
|
+
*
|
|
1782
|
+
* `ctx` is already authenticated: the host verified the caller at the gateway
|
|
1783
|
+
* and passes the resolved identity. A plugin must never parse a token itself —
|
|
1784
|
+
* two implementations of the permission model would eventually disagree.
|
|
1785
|
+
*/
|
|
1786
|
+
interface PluginBackendModule {
|
|
1787
|
+
/** Only receives verified POSTs at /api/internal/storage/authorize. */
|
|
1788
|
+
authorizeStorage?(request: Request, context: {
|
|
1789
|
+
installId: string;
|
|
1790
|
+
tenantId: string;
|
|
1791
|
+
issuedAt: string;
|
|
1792
|
+
bodyHash: string;
|
|
1793
|
+
}, host: PluginHostApi): Promise<Response>;
|
|
1794
|
+
/** Starts install-scoped background maintenance after database/config readiness. No user identity is implied. */
|
|
1795
|
+
start?(host: PluginHostApi): void | Promise<void>;
|
|
1796
|
+
/** Stops background maintenance and awaits in-flight work during graceful shutdown. */
|
|
1797
|
+
stop?(): void | Promise<void>;
|
|
1798
|
+
fetch(request: Request, ctx: PluginUserContext, host: PluginHostApi): Promise<Response>;
|
|
1799
|
+
/**
|
|
1800
|
+
* Handles public-route requests. Never receives a user request, and `fetch`
|
|
1801
|
+
* never receives a public one. Absent means public requests are answered 404.
|
|
1802
|
+
*/
|
|
1803
|
+
fetchPublic?(request: Request, ctx: PluginPublicContext, host: PluginHostApi): Promise<Response>;
|
|
1804
|
+
}
|
|
1805
|
+
/** Identity helper for inference. */
|
|
1806
|
+
declare function definePluginBackend(module: PluginBackendModule): PluginBackendModule;
|
|
1807
|
+
|
|
1808
|
+
export { type AccountInvitation, type AccountProvisionResult, type DirectoryEntry, type DirectoryIdentity, type DirectoryMatch, type DirectoryPrincipal, PLUGIN_COLLECTION_CONTENT_PAGE_MAX, PLUGIN_COLLECTION_IMPORT_MAX, PLUGIN_CONTEXT_HEADERS, type PluginAccountsApi, type PluginAdminAction, type PluginApprovedRequest, type PluginAttentionQuestion, type PluginAttentionReceipt, type PluginAttentionRequest, type PluginAttentionStatus, type PluginBackendModule, type PluginCollectionMetadata, type PluginCollectionParagraph, type PluginCollectionStatus, type PluginCollectionsApi, type PluginConfigAccess, type PluginDiagramInput, type PluginDiagramResult, type PluginDiagramsApi, type PluginDirectoryApi, type PluginDocumentBatchInput, type PluginDocumentBatchItem, type PluginDocumentContentInput, type PluginDocumentPreviewItem, type PluginHostApi, type PluginKnowledgeAdminApi, type PluginKnowledgeApi, type PluginKnowledgeBaseInput, type PluginKnowledgeReference, type PluginLogger, type PluginMailRefusal, type PluginMailSendInput, type PluginMailSendResult, type PluginMailStatus, type PluginMailUnsubscribe, type PluginManagedDownloadPolicy, type PluginObjectHead, type PluginObjectUpload, type PluginProactiveEmitResult, type PluginProactiveEvent, type PluginPublicContext, type PluginScopedDb, type PluginScopedStorage, type PluginTransaction, PluginUserContext, type VerifiedPluginKnowledgeReference, accountInvitationSchema, accountInviteSchema, accountPasswordResetSchema, accountProvisionSchema, definePluginBackend, directoryIdentitySchema, directoryListSchema, directoryMatchSchema, directoryPrincipalSchema, directoryValidateSchema, pluginAdminActionSchema, pluginAdminProofSchema, pluginApprovalDigestSchema, pluginApprovedSchema, pluginCollectionAccessSchema, pluginCollectionDeleteSchema, pluginCollectionDocumentContentSchema, pluginCollectionDocumentsStatusSchema, pluginCollectionEnsureSchema, pluginCollectionImportFilesSchema, pluginCollectionImportSchema, pluginCollectionMoveSchema, pluginCollectionPermissionsSchema, pluginCollectionRemoveSchema, pluginCollectionSearchSchema, pluginCollectionStatusSchema, pluginDiagramSchema, pluginDocumentBatchInputSchema, pluginDocumentBatchItemSchema, pluginDocumentContentInputSchema, pluginKnowledgeBaseInputSchema, pluginKnowledgeListInputSchema, pluginKnowledgeReferenceSchema, pluginKnowledgeVerifySchema };
|