@capybara-hq/plugin-sdk 0.1.0-rc.9 → 0.1.0-rc.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +5 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extension-points/trigger-source.md +19 -0
- package/agent-docs/extensions.md +98 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/api/plugin-sdk.api.md +5983 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/agents-ctx.d.ts +116 -0
- package/dist/agents-ctx.js +22 -0
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +121 -13
- package/dist/cards.js +161 -19
- package/dist/channel.d.ts +133 -47
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +344 -31
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +18 -12
- package/dist/define-extension.js +18 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +348 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +286 -49
- package/dist/device-protocol.js +766 -89
- package/dist/device-provider.d.ts +820 -0
- package/dist/device-provider.js +432 -0
- package/dist/device-service.d.ts +204 -0
- package/dist/device-service.js +291 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +8 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +46 -9
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +185 -22
- package/dist/hooks.js +6 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/inbox.d.ts +103 -0
- package/dist/inbox.js +173 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +30 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +295 -77
- package/dist/model.js +249 -21
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +95 -25
- package/dist/permissions.js +175 -54
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +216 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +40 -12
- package/dist/theme-tokens.generated.js +36 -8
- package/dist/theme.d.ts +56 -10
- package/dist/theme.js +117 -23
- package/dist/tool.d.ts +242 -28
- package/dist/tool.js +135 -13
- package/dist/trigger-source.d.ts +35 -0
- package/dist/trigger-source.js +2 -0
- package/dist/triggers.d.ts +88 -0
- package/dist/triggers.js +71 -0
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +374 -0
- package/dist/ui-resolve.d.ts +2 -7
- package/dist/ui-resolve.js +7 -19
- package/dist/ui-slots.d.ts +27 -5
- package/dist/ui-slots.js +112 -19
- package/dist/ui.d.ts +203 -64
- package/dist/ui.js +117 -23
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +13 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/hooks.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { ContentBlock, ModelRequest, ModelUsage } from "./model.js";
|
|
1
|
+
import type { ContentBlock, ImageSize, ModelRequest, ModelUsage } from "./model.js";
|
|
2
2
|
/**
|
|
3
3
|
* Hook mount points a plugin can register on through `ctx.hooks.on` (from M7). The other names in
|
|
4
4
|
* `HOOK_MOUNT_POINTS` (`session.*`, `agent.preStep`) stay reserved: they validate in a manifest but
|
|
5
5
|
* cannot be registered yet.
|
|
6
6
|
*/
|
|
7
|
-
export declare const HOOKS_AVAILABLE: readonly ["model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report"];
|
|
7
|
+
export declare const HOOKS_AVAILABLE: readonly ["model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report", "org.member_removed", "agent.deleted", "org.deleted", "run.lifecycle"];
|
|
8
|
+
/** Lifecycle mount points: observe-only notices that something was removed. */
|
|
9
|
+
export declare const LIFECYCLE_HOOKS: readonly ["org.member_removed", "agent.deleted", "org.deleted"];
|
|
8
10
|
/** A mount point that `ctx.hooks.on` accepts. */
|
|
9
11
|
export type AvailableHook = (typeof HOOKS_AVAILABLE)[number];
|
|
10
12
|
/** Where a sub-agent was dispatched from: the parent conversation, its run and the `Agent` call. */
|
|
@@ -36,9 +38,13 @@ export interface HookScope {
|
|
|
36
38
|
* that summarizes earlier history before a step when the context grows too large, `title` is the call
|
|
37
39
|
* that writes a conversation's title after its first completed run (no run: `runId` is "", `step` 0,
|
|
38
40
|
* `attempt` 1), `web_fetch` is the call that extracts an answer from a fetched web page for the
|
|
39
|
-
* `WebFetch` tool
|
|
41
|
+
* `WebFetch` tool, `review` is the command-review classifier's call (`review` purpose, no run
|
|
42
|
+
* step; absent = no classifier), `suggestion` is the prompt suggestion side request after a
|
|
43
|
+
* completed web run (`runId` the run, `step` 0, `attempt` 1; a denial skips it and is recorded only
|
|
44
|
+
* in the audit log), `vision` is the call that reads an image for a model without vision, made by
|
|
45
|
+
* the `Read` tool (also for a pasted image, read by its `file_id`; the `vision` purpose's model).
|
|
40
46
|
*/
|
|
41
|
-
export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch";
|
|
47
|
+
export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch" | "review" | "image" | "vision" | "suggestion";
|
|
42
48
|
/**
|
|
43
49
|
* What a reported or requested model call was for: the {@link ModelCallPurpose} values, or
|
|
44
50
|
* `embedding` for an embedding call an extension made through `ctx.models` (`usage.report`, and
|
|
@@ -46,21 +52,23 @@ export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch";
|
|
|
46
52
|
*/
|
|
47
53
|
export type UsagePurpose = ModelCallPurpose | "embedding";
|
|
48
54
|
/**
|
|
49
|
-
* An image or
|
|
50
|
-
* attachment ids: each image
|
|
55
|
+
* An image, document or file of a `model.request` payload. Hook payloads never carry media bytes or
|
|
56
|
+
* attachment ids: each image / document / file block is replaced by this placeholder.
|
|
51
57
|
* `size` is the size of the bytes sent to the provider, in bytes (0 when unknown).
|
|
52
58
|
*/
|
|
53
59
|
export interface HookMediaPlaceholder {
|
|
54
60
|
type: "media_omitted";
|
|
55
|
-
kind: "image" | "document";
|
|
61
|
+
kind: "image" | "document" | "file";
|
|
56
62
|
mediaType: string;
|
|
57
63
|
size: number;
|
|
58
64
|
}
|
|
59
|
-
/** A content block of a `model.request` payload: image and
|
|
65
|
+
/** A content block of a `model.request` payload: image, document and file blocks become placeholders. */
|
|
60
66
|
export type HookContentBlock = Exclude<ContentBlock, {
|
|
61
67
|
type: "image";
|
|
62
68
|
} | {
|
|
63
69
|
type: "document";
|
|
70
|
+
} | {
|
|
71
|
+
type: "file";
|
|
64
72
|
}> | HookMediaPlaceholder;
|
|
65
73
|
/** A message of a `model.request` payload (see {@link HookContentBlock}). */
|
|
66
74
|
export type HookModelMessage = {
|
|
@@ -73,21 +81,26 @@ export type HookModelMessage = {
|
|
|
73
81
|
role: "system";
|
|
74
82
|
content: string;
|
|
75
83
|
};
|
|
76
|
-
/**
|
|
77
|
-
|
|
84
|
+
/**
|
|
85
|
+
* The request of a `model.request` payload: the request sent to the provider, without media bytes
|
|
86
|
+
* and without the transport option `cacheTtl`.
|
|
87
|
+
*/
|
|
88
|
+
export type HookModelRequest = Omit<ModelRequest, "messages" | "cacheTtl"> & {
|
|
78
89
|
messages: HookModelMessage[];
|
|
79
90
|
};
|
|
80
91
|
/**
|
|
81
92
|
* `model.request` of a chat model call (see {@link ModelRequestHookPayload}): once per attempt of a
|
|
82
93
|
* step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1),
|
|
83
94
|
* once for each conversation title call (`purpose: "title"`, `runId` "", `step` 0, `attempt` 1; a
|
|
84
|
-
* denial skips the title and is recorded only in the audit log)
|
|
85
|
-
* extraction call (`purpose: "web_fetch"`)
|
|
95
|
+
* denial skips the title and is recorded only in the audit log), once for each `WebFetch`
|
|
96
|
+
* extraction call (`purpose: "web_fetch"`) and once for each prompt suggestion call
|
|
97
|
+
* (`purpose: "suggestion"`, `step` 0, `attempt` 1; a denial skips the suggestion and is recorded
|
|
98
|
+
* only in the audit log) and once for each vision call (`purpose: "vision"`).
|
|
86
99
|
* `request` is the request as sent, except that images and documents are placeholders
|
|
87
100
|
* ({@link HookMediaPlaceholder}): no media bytes, no attachment ids.
|
|
88
101
|
*/
|
|
89
102
|
export interface ModelCallRequestHookPayload extends HookScope {
|
|
90
|
-
purpose: ModelCallPurpose
|
|
103
|
+
purpose: Exclude<ModelCallPurpose, "image">;
|
|
91
104
|
step: number;
|
|
92
105
|
attempt: number;
|
|
93
106
|
provider: string;
|
|
@@ -125,22 +138,82 @@ export interface EmbeddingRequestHookPayload {
|
|
|
125
138
|
runId?: undefined;
|
|
126
139
|
parent?: undefined;
|
|
127
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* `model.request` of an image generation call (`purpose: "image"`): once per `GenerateImage` tool
|
|
143
|
+
* call (conversation fields set) or `ctx.models.generateImage` call (`extension` and `imagePurpose`
|
|
144
|
+
* set, conversation fields absent). Reference images are placeholders: no bytes. A policy denial
|
|
145
|
+
* sends nothing and records no usage.
|
|
146
|
+
*/
|
|
147
|
+
export interface ImageRequestHookPayload {
|
|
148
|
+
purpose: "image";
|
|
149
|
+
orgId: string;
|
|
150
|
+
provider: string;
|
|
151
|
+
model: string;
|
|
152
|
+
prompt: string;
|
|
153
|
+
size: ImageSize;
|
|
154
|
+
n: number;
|
|
155
|
+
referenceImages: HookMediaPlaceholder[];
|
|
156
|
+
/** Conversation call: */
|
|
157
|
+
accountId?: string;
|
|
158
|
+
agentId?: string;
|
|
159
|
+
agentVersion?: number;
|
|
160
|
+
conversationId?: string;
|
|
161
|
+
runId?: string;
|
|
162
|
+
parent?: HookParentScope;
|
|
163
|
+
step?: number;
|
|
164
|
+
callId?: string;
|
|
165
|
+
/** Extension call: */
|
|
166
|
+
extension?: string;
|
|
167
|
+
imagePurpose?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* `model.response` of an image generation call: after it finished or failed. Same identity fields
|
|
171
|
+
* as {@link ImageRequestHookPayload}; images carry only their media type and byte size.
|
|
172
|
+
*/
|
|
173
|
+
export interface ImageResponseHookPayload {
|
|
174
|
+
purpose: "image";
|
|
175
|
+
orgId: string;
|
|
176
|
+
provider: string;
|
|
177
|
+
model: string;
|
|
178
|
+
accountId?: string;
|
|
179
|
+
agentId?: string;
|
|
180
|
+
agentVersion?: number;
|
|
181
|
+
conversationId?: string;
|
|
182
|
+
runId?: string;
|
|
183
|
+
parent?: HookParentScope;
|
|
184
|
+
step?: number;
|
|
185
|
+
callId?: string;
|
|
186
|
+
extension?: string;
|
|
187
|
+
imagePurpose?: string;
|
|
188
|
+
outcome: "ok" | "failed";
|
|
189
|
+
images: {
|
|
190
|
+
mediaType: string;
|
|
191
|
+
size: number;
|
|
192
|
+
}[];
|
|
193
|
+
revisedPrompt?: string;
|
|
194
|
+
usage: ModelUsage | null;
|
|
195
|
+
latencyMs: number;
|
|
196
|
+
errorCode?: string;
|
|
197
|
+
}
|
|
128
198
|
/**
|
|
129
199
|
* `model.request`: before a model call is sent. A policy hook may deny it. Either a chat model call
|
|
130
200
|
* ({@link ModelCallRequestHookPayload}: steps, compaction, titles, `WebFetch`) or an extension's
|
|
131
|
-
* embedding call ({@link EmbeddingRequestHookPayload}, `purpose: "embedding"`)
|
|
201
|
+
* embedding call ({@link EmbeddingRequestHookPayload}, `purpose: "embedding"`) or an image generation
|
|
202
|
+
* call ({@link ImageRequestHookPayload}, `purpose: "image"`); tell them apart by
|
|
132
203
|
* `purpose`. Handlers must accept the absent conversation fields of an embedding call (a policy
|
|
133
204
|
* hook that throws on one denies the call). Payloads carry no media bytes.
|
|
134
205
|
*/
|
|
135
|
-
export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload;
|
|
206
|
+
export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload | ImageRequestHookPayload;
|
|
136
207
|
/**
|
|
137
208
|
* `model.response`: after a sent model call finished or failed, with its usage when known (step
|
|
138
|
-
* attempts, compaction and
|
|
139
|
-
* stopped while the call was in flight), nor for a call that was never sent
|
|
140
|
-
* before sending), so a `model.request` can have no matching `model.response`.
|
|
209
|
+
* attempts, compaction, title and suggestion calls, see `purpose`). Not fired for a call the user
|
|
210
|
+
* aborted (the run was stopped while the call was in flight), nor for a call that was never sent
|
|
211
|
+
* (denied, or failed before sending), so a `model.request` can have no matching `model.response`.
|
|
212
|
+
* The mount's payload is this or, for an image generation call, an
|
|
213
|
+
* {@link ImageResponseHookPayload}.
|
|
141
214
|
*/
|
|
142
215
|
export interface ModelResponseHookPayload extends HookScope {
|
|
143
|
-
purpose: ModelCallPurpose
|
|
216
|
+
purpose: Exclude<ModelCallPurpose, "image">;
|
|
144
217
|
step: number;
|
|
145
218
|
attempt: number;
|
|
146
219
|
provider: string;
|
|
@@ -201,13 +274,99 @@ export interface UsageReportPayload {
|
|
|
201
274
|
usage: ModelUsage;
|
|
202
275
|
occurredAt: string;
|
|
203
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* `org.member_removed`: an account left the org (offboarding: removed by an admin, left on its own,
|
|
279
|
+
* or offboarded by a directory sync). Lifecycle hooks are delivered durably, after the removal
|
|
280
|
+
* committed, through a queue, at least once per plugin that declares the mount in
|
|
281
|
+
* `permissions.hooks`, whether or not the org has the plugin enabled and whether or not the org's
|
|
282
|
+
* effective config of the plugin is valid (`call.config` is the platform deployment config): they
|
|
283
|
+
* exist so a plugin can delete the data it holds. Handlers must be idempotent. The payload carries
|
|
284
|
+
* ids only.
|
|
285
|
+
*/
|
|
286
|
+
export interface OrgMemberRemovedPayload {
|
|
287
|
+
orgId: string;
|
|
288
|
+
accountId: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* `agent.deleted`: an agent was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
|
|
292
|
+
* least once, regardless of org enablement or config validity; ids only).
|
|
293
|
+
*/
|
|
294
|
+
export interface AgentDeletedPayload {
|
|
295
|
+
orgId: string;
|
|
296
|
+
agentId: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* `org.deleted`: an org was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
|
|
300
|
+
* least once, regardless of org enablement or config validity; ids only).
|
|
301
|
+
*/
|
|
302
|
+
export interface OrgDeletedPayload {
|
|
303
|
+
orgId: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* `run.lifecycle`: what happened to a run of a conversation that has a subject, or to directed work
|
|
307
|
+
* the kernel did not run (collaboration spec §4.8). Observe-only, delivered durably through a
|
|
308
|
+
* queue, at least once, after the change committed, and only to the plugin named by the
|
|
309
|
+
* conversation's subject `source` (for `offer_declined`, the plugin that emitted the event), when
|
|
310
|
+
* it declares `run.lifecycle` in `permissions.hooks` and the org has it enabled (checked when the
|
|
311
|
+
* change commits and again at delivery); `call.config` is the extension's effective config for the
|
|
312
|
+
* org. A handler that fails never affects the run. Handlers must be idempotent. The payload carries
|
|
313
|
+
* ids only. Compact runs (context compaction) are never reported.
|
|
314
|
+
*
|
|
315
|
+
* - `started`: a run of the conversation was created (queued).
|
|
316
|
+
* - `waiting`: the run suspended on a person (`waitingOn`: an `approval`, or `input`: a question
|
|
317
|
+
* or a connect card).
|
|
318
|
+
* - `resumed`: the person's wait cleared (answered, decided or timed out) and the run continues;
|
|
319
|
+
* one per wait, like `waiting`.
|
|
320
|
+
* - `finished`: the run completed. `failed`: it failed. `aborted`: a person or the kernel stopped
|
|
321
|
+
* it.
|
|
322
|
+
* - `offer_declined`: directed work was not run (`reason`): the person's rule is `off`, the person
|
|
323
|
+
* `declined` the offer, their acceptance automation is `paused`, the offer `expired` unanswered
|
|
324
|
+
* (seven days), or the event stayed `undelivered` (the kernel gave up routing it). No run and no
|
|
325
|
+
* conversation: `accountId` and `agentId` are the event's audience; `eventId` and `dedupeKey`
|
|
326
|
+
* name the event the decline is for, so a plugin can tell a stale decline (an older event of
|
|
327
|
+
* the subject) from one for its latest.
|
|
328
|
+
*/
|
|
329
|
+
export interface RunLifecyclePayload {
|
|
330
|
+
orgId: string;
|
|
331
|
+
/** The run's trigger account; for `offer_declined` the event's audience person. */
|
|
332
|
+
accountId: string;
|
|
333
|
+
agentId: string;
|
|
334
|
+
/** Absent for `offer_declined`. */
|
|
335
|
+
agentVersion?: number;
|
|
336
|
+
/** Absent for `offer_declined`. */
|
|
337
|
+
conversationId?: string;
|
|
338
|
+
/** Absent for `offer_declined`. */
|
|
339
|
+
runId?: string;
|
|
340
|
+
phase: "started" | "waiting" | "resumed" | "finished" | "failed" | "aborted" | "offer_declined";
|
|
341
|
+
/** The conversation's subject (or the directed event's subject). */
|
|
342
|
+
subject: {
|
|
343
|
+
kind: string;
|
|
344
|
+
id: string;
|
|
345
|
+
};
|
|
346
|
+
/** Set for `waiting` and `resumed`. */
|
|
347
|
+
waitingOn?: "approval" | "input";
|
|
348
|
+
/** Set for `offer_declined`. */
|
|
349
|
+
reason?: RunLifecycleDeclineReason;
|
|
350
|
+
/** Set for `offer_declined`: the kernel's id of the directed event that was not run. */
|
|
351
|
+
eventId?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Set for `offer_declined`: the `dedupeKey` the plugin gave that event in `ctx.triggers.emit`.
|
|
354
|
+
*/
|
|
355
|
+
dedupeKey?: string;
|
|
356
|
+
}
|
|
357
|
+
/** Why directed work was not run (`run.lifecycle` `offer_declined`). */
|
|
358
|
+
export type RunLifecycleDeclineReason = "declined" | "off" | "paused" | "expired" | "undelivered";
|
|
204
359
|
/** Payload type of each mount point. */
|
|
205
360
|
export interface HookPayloads {
|
|
206
361
|
"model.request": ModelRequestHookPayload;
|
|
207
|
-
"model.response": ModelResponseHookPayload;
|
|
362
|
+
"model.response": ModelResponseHookPayload | ImageResponseHookPayload;
|
|
208
363
|
"tool.preExecute": ToolPreHookPayload;
|
|
209
364
|
"tool.postExecute": ToolPostHookPayload;
|
|
210
365
|
"usage.report": UsageReportPayload;
|
|
366
|
+
"org.member_removed": OrgMemberRemovedPayload;
|
|
367
|
+
"agent.deleted": AgentDeletedPayload;
|
|
368
|
+
"org.deleted": OrgDeletedPayload;
|
|
369
|
+
"run.lifecycle": RunLifecyclePayload;
|
|
211
370
|
}
|
|
212
371
|
/**
|
|
213
372
|
* What a hook returns: nothing, or `{ deny: reason }`. A deny only takes effect for a `policy` hook
|
|
@@ -223,12 +382,16 @@ export type HookVerdict = void | {
|
|
|
223
382
|
* extension's effective deployment config for the payload's org (the platform's config with the
|
|
224
383
|
* org's copy applied to the overridable fields, or `ctx.config` while the org follows it); the
|
|
225
384
|
* kernel always passes it, and never calls a hook for an org where that config is not valid
|
|
226
|
-
* (observe hooks are skipped, policy hooks deny).
|
|
385
|
+
* (observe hooks are skipped, policy hooks deny). Lifecycle hooks ({@link LIFECYCLE_HOOKS}) are the
|
|
386
|
+
* exception: they get the platform deployment config and are always called.
|
|
227
387
|
*/
|
|
228
388
|
export type HookHandler<K extends AvailableHook> = (payload: HookPayloads[K], signal: AbortSignal, call?: HookCall) => Promise<HookVerdict> | HookVerdict;
|
|
229
389
|
/** The per-call context of a hook handler (see {@link HookHandler}). */
|
|
230
390
|
export interface HookCall {
|
|
231
|
-
/**
|
|
391
|
+
/**
|
|
392
|
+
* The extension's effective deployment config for the payload's org (lifecycle hooks: the
|
|
393
|
+
* platform deployment config).
|
|
394
|
+
*/
|
|
232
395
|
config: unknown;
|
|
233
396
|
}
|
|
234
397
|
/**
|
package/dist/hooks.js
CHANGED
|
@@ -9,6 +9,12 @@ export const HOOKS_AVAILABLE = [
|
|
|
9
9
|
"tool.preExecute",
|
|
10
10
|
"tool.postExecute",
|
|
11
11
|
"usage.report",
|
|
12
|
+
"org.member_removed",
|
|
13
|
+
"agent.deleted",
|
|
14
|
+
"org.deleted",
|
|
15
|
+
"run.lifecycle",
|
|
12
16
|
];
|
|
17
|
+
/** Lifecycle mount points: observe-only notices that something was removed. */
|
|
18
|
+
export const LIFECYCLE_HOOKS = ["org.member_removed", "agent.deleted", "org.deleted"];
|
|
13
19
|
/** Mount points where a `policy` hook may deny the call. */
|
|
14
20
|
export const POLICY_HOOKS = ["model.request", "tool.preExecute"];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { UiRole } from "./ui.js";
|
|
2
|
+
/**
|
|
3
|
+
* Who may call an extension route (declared per route in `permissions.http`, enforced by the
|
|
4
|
+
* kernel before the handler runs and before the body is read):
|
|
5
|
+
*
|
|
6
|
+
* - `public`: anyone; unsafe methods are rate-limited per client IP. Mounted at
|
|
7
|
+
* `/plugins/<name><path>`.
|
|
8
|
+
* - `embed`: the holder of an embed token (see `ctx.ui`); path under `/ui/`. Mounted at
|
|
9
|
+
* `/plugins/<name><path>`.
|
|
10
|
+
* - `member` / `admin`: an org member (admin: org admin and up) with a personal access token.
|
|
11
|
+
* Mounted at `/plugins/<name>/orgs/:orgId<path>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const HTTP_ACCESS: readonly ["public", "embed", "member", "admin"];
|
|
14
|
+
export type HttpAccess = (typeof HTTP_ACCESS)[number];
|
|
15
|
+
/** One entry of `permissions.http`. */
|
|
16
|
+
export interface HttpPermission {
|
|
17
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
18
|
+
path: string;
|
|
19
|
+
access: HttpAccess;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The caller the kernel resolved for a route, passed to the handler as its second argument.
|
|
23
|
+
* Trust only this (`caller.orgId`, never an org id in the body or query).
|
|
24
|
+
*/
|
|
25
|
+
export type RouteCaller = {
|
|
26
|
+
access: "public";
|
|
27
|
+
} | {
|
|
28
|
+
access: "embed";
|
|
29
|
+
scope: "org";
|
|
30
|
+
orgId: string;
|
|
31
|
+
accountId: string;
|
|
32
|
+
role: UiRole;
|
|
33
|
+
contribution: string;
|
|
34
|
+
conversationId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A skill file previewer's token (`OrgEmbedClaims.skillFile`): the skill, version and path;
|
|
37
|
+
* no conversation.
|
|
38
|
+
*/
|
|
39
|
+
skillFile?: {
|
|
40
|
+
skillId: string;
|
|
41
|
+
version: number;
|
|
42
|
+
path: string;
|
|
43
|
+
};
|
|
44
|
+
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
45
|
+
exp: number;
|
|
46
|
+
config: unknown;
|
|
47
|
+
} | {
|
|
48
|
+
access: "embed";
|
|
49
|
+
scope: "platform";
|
|
50
|
+
accountId: string;
|
|
51
|
+
role: "superAdmin";
|
|
52
|
+
contribution: string;
|
|
53
|
+
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
54
|
+
exp: number;
|
|
55
|
+
} | {
|
|
56
|
+
/** A share page's `file.preview` embed: no account, no role. */
|
|
57
|
+
access: "embed";
|
|
58
|
+
scope: "share";
|
|
59
|
+
orgId: string;
|
|
60
|
+
shareId: string;
|
|
61
|
+
contribution: string;
|
|
62
|
+
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
63
|
+
exp: number;
|
|
64
|
+
config: unknown;
|
|
65
|
+
} | {
|
|
66
|
+
access: "member" | "admin";
|
|
67
|
+
orgId: string;
|
|
68
|
+
accountId: string;
|
|
69
|
+
role: UiRole;
|
|
70
|
+
config: unknown;
|
|
71
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who may call an extension route (declared per route in `permissions.http`, enforced by the
|
|
3
|
+
* kernel before the handler runs and before the body is read):
|
|
4
|
+
*
|
|
5
|
+
* - `public`: anyone; unsafe methods are rate-limited per client IP. Mounted at
|
|
6
|
+
* `/plugins/<name><path>`.
|
|
7
|
+
* - `embed`: the holder of an embed token (see `ctx.ui`); path under `/ui/`. Mounted at
|
|
8
|
+
* `/plugins/<name><path>`.
|
|
9
|
+
* - `member` / `admin`: an org member (admin: org admin and up) with a personal access token.
|
|
10
|
+
* Mounted at `/plugins/<name>/orgs/:orgId<path>`.
|
|
11
|
+
*/
|
|
12
|
+
export const HTTP_ACCESS = ["public", "embed", "member", "admin"];
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* An external identity; login, channel inbound and directory all use the same (source, externalId)
|
|
3
|
+
* key.
|
|
4
|
+
*/
|
|
2
5
|
export interface ExternalIdentity {
|
|
3
6
|
/**
|
|
4
|
-
* `"
|
|
5
|
-
* `source === \`${
|
|
7
|
+
* `"<plugin name>:<tenant id>"`, must equal `tenantId`. On third-party login the kernel checks
|
|
8
|
+
* `source === \`${plugin name}:${tenantId}\``, and rejects a mismatch as an identity source
|
|
9
|
+
* error.
|
|
6
10
|
*/
|
|
7
11
|
source: string;
|
|
8
12
|
externalId: string;
|
|
@@ -12,24 +16,62 @@ export interface ExternalIdentity {
|
|
|
12
16
|
displayName: string;
|
|
13
17
|
avatarUrl?: string;
|
|
14
18
|
}
|
|
19
|
+
/** How an identity source describes its tenants to the admin console. */
|
|
20
|
+
export interface IdentitySourceTenant {
|
|
21
|
+
/** The field label in Chinese and English, e.g. the Slack workspace ID. */
|
|
22
|
+
label: {
|
|
23
|
+
zh: string;
|
|
24
|
+
en: string;
|
|
25
|
+
};
|
|
26
|
+
/** Where to find the tenant id. */
|
|
27
|
+
help?: {
|
|
28
|
+
zh: string;
|
|
29
|
+
en: string;
|
|
30
|
+
};
|
|
31
|
+
/** A regular expression (JavaScript syntax) a tenant id must match, e.g. `^T[A-Z0-9]+$`. */
|
|
32
|
+
pattern?: string;
|
|
33
|
+
/** An example tenant id shown as the placeholder. */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/** Tenant ids that may never be trusted for email merge (Google: `consumer`). */
|
|
36
|
+
neverTrusted?: string[];
|
|
37
|
+
}
|
|
15
38
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
39
|
+
* Checks a tenant id against a source's tenant declaration: `"empty"` for a blank id, `"pattern"`
|
|
40
|
+
* when it does not match the declared pattern (an invalid pattern counts as none),
|
|
41
|
+
* `"never_trusted"` when the source lists it in `neverTrusted`, else `"ok"`. The id is trimmed
|
|
42
|
+
* first. The kernel uses it before storing trusted tenants.
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateTenantId(decl: IdentitySourceTenant | undefined, id: string): "ok" | "pattern" | "never_trusted" | "empty";
|
|
45
|
+
/**
|
|
46
|
+
* Third-party login (`identity-source@1`). State, nonce and PKCE are all generated by the kernel
|
|
47
|
+
* and kept server-side:
|
|
48
|
+
* the plugin puts `codeChallenge` / `codeChallengeMethod` into the authorization URL
|
|
49
|
+
* (`code_challenge` / `code_challenge_method`),
|
|
50
|
+
* and passes `codeVerifier` (`code_verifier`) when exchanging the token at the callback. If the
|
|
51
|
+
* platform does not support PKCE, just ignore these fields.
|
|
19
52
|
*/
|
|
20
53
|
export interface IdentitySource {
|
|
21
54
|
label: {
|
|
22
55
|
zh: string;
|
|
23
56
|
en: string;
|
|
24
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* What a tenant is on this platform, so the admin console can label and check the trusted
|
|
60
|
+
* tenants of this source (a tenant id is the `<tenant>` of the source key `<plugin>:<tenant>`).
|
|
61
|
+
* Without it the console shows a plain tenant id field.
|
|
62
|
+
*/
|
|
63
|
+
tenant?: IdentitySourceTenant;
|
|
25
64
|
authorizeUrl(args: {
|
|
26
65
|
config: unknown;
|
|
27
66
|
redirectUri: string;
|
|
28
67
|
state: string;
|
|
29
68
|
nonce: string;
|
|
30
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* PKCE challenge (base64url(SHA-256(codeVerifier))); the kernel always provides it, old kernels
|
|
71
|
+
* do not.
|
|
72
|
+
*/
|
|
31
73
|
codeChallenge?: string;
|
|
32
|
-
/** PKCE challenge
|
|
74
|
+
/** The PKCE challenge algorithm; the kernel uses only `"S256"`. */
|
|
33
75
|
codeChallengeMethod?: "S256";
|
|
34
76
|
}): string;
|
|
35
77
|
callback(args: {
|
|
@@ -38,7 +80,26 @@ export interface IdentitySource {
|
|
|
38
80
|
query: Record<string, string>;
|
|
39
81
|
nonce: string;
|
|
40
82
|
signal: AbortSignal;
|
|
41
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* The PKCE verifier matching this flow's `codeChallenge`; the kernel always provides it, old
|
|
85
|
+
* kernels do not.
|
|
86
|
+
*/
|
|
42
87
|
codeVerifier?: string;
|
|
43
88
|
}): Promise<ExternalIdentity>;
|
|
44
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Thrown by an identity source's `callback` when it refuses the account on purpose (a hosted domain
|
|
92
|
+
* or tenant the platform does not allow, a consumer account where only organization accounts are
|
|
93
|
+
* allowed): the login page then says the account is not allowed (`sso.account_not_allowed`) instead
|
|
94
|
+
* of a provider error. The message is logged by the kernel and never shown to the person. Throw it
|
|
95
|
+
* only after the response itself was verified (ID token, nonce, PKCE); every other failure stays a
|
|
96
|
+
* plain error.
|
|
97
|
+
*/
|
|
98
|
+
export declare class IdentitySourceRefused extends Error {
|
|
99
|
+
constructor(message: string);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether `err` is an {@link IdentitySourceRefused}: any `Error` whose `name` is
|
|
103
|
+
* `"IdentitySourceRefused"`, so a plugin that bundles another copy of the SDK still matches.
|
|
104
|
+
*/
|
|
105
|
+
export declare function isIdentitySourceRefused(err: unknown): boolean;
|
package/dist/identity.js
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Checks a tenant id against a source's tenant declaration: `"empty"` for a blank id, `"pattern"`
|
|
3
|
+
* when it does not match the declared pattern (an invalid pattern counts as none),
|
|
4
|
+
* `"never_trusted"` when the source lists it in `neverTrusted`, else `"ok"`. The id is trimmed
|
|
5
|
+
* first. The kernel uses it before storing trusted tenants.
|
|
6
|
+
*/
|
|
7
|
+
export function validateTenantId(decl, id) {
|
|
8
|
+
const value = id.trim();
|
|
9
|
+
if (value === "")
|
|
10
|
+
return "empty";
|
|
11
|
+
if (decl?.pattern) {
|
|
12
|
+
let re;
|
|
13
|
+
try {
|
|
14
|
+
re = new RegExp(decl.pattern);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
re = undefined;
|
|
18
|
+
}
|
|
19
|
+
if (re && !re.test(value))
|
|
20
|
+
return "pattern";
|
|
21
|
+
}
|
|
22
|
+
if (decl?.neverTrusted?.includes(value))
|
|
23
|
+
return "never_trusted";
|
|
24
|
+
return "ok";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown by an identity source's `callback` when it refuses the account on purpose (a hosted domain
|
|
28
|
+
* or tenant the platform does not allow, a consumer account where only organization accounts are
|
|
29
|
+
* allowed): the login page then says the account is not allowed (`sso.account_not_allowed`) instead
|
|
30
|
+
* of a provider error. The message is logged by the kernel and never shown to the person. Throw it
|
|
31
|
+
* only after the response itself was verified (ID token, nonce, PKCE); every other failure stays a
|
|
32
|
+
* plain error.
|
|
33
|
+
*/
|
|
34
|
+
export class IdentitySourceRefused extends Error {
|
|
35
|
+
constructor(message) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = "IdentitySourceRefused";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether `err` is an {@link IdentitySourceRefused}: any `Error` whose `name` is
|
|
42
|
+
* `"IdentitySourceRefused"`, so a plugin that bundles another copy of the SDK still matches.
|
|
43
|
+
*/
|
|
44
|
+
export function isIdentitySourceRefused(err) {
|
|
45
|
+
return err instanceof Error && err.name === "IdentitySourceRefused";
|
|
46
|
+
}
|
package/dist/inbox.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { LocalizedName } from "./plugin-package.js";
|
|
2
|
+
import type { LocalizedText } from "./tool.js";
|
|
3
|
+
/**
|
|
4
|
+
* One button on an inbox item: clicking it calls `uiAction.actionId` of the extension's UI
|
|
5
|
+
* contribution `uiAction.contribution` (registered with `ctx.ui.action`) as the person who
|
|
6
|
+
* clicked, with `payload`, then resolves the item. The contribution must be one of an org-wide
|
|
7
|
+
* slot (such as `org.page`): the call carries no conversation or agent. The action must be
|
|
8
|
+
* idempotent: delivery is at least once (a click whose result was lost may be pressed again).
|
|
9
|
+
*/
|
|
10
|
+
export interface InboxAction {
|
|
11
|
+
/** Unique within the item ({@link INBOX_ID_RE}). */
|
|
12
|
+
id: string;
|
|
13
|
+
label: LocalizedName;
|
|
14
|
+
style?: "primary" | "danger";
|
|
15
|
+
uiAction: {
|
|
16
|
+
contribution: string;
|
|
17
|
+
actionId: string;
|
|
18
|
+
payload?: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** A personal inbox item an extension posts through `ctx.inbox.post`. */
|
|
22
|
+
export interface InboxPost {
|
|
23
|
+
orgId: string;
|
|
24
|
+
/** The one person the item is for: an active member of `orgId`. */
|
|
25
|
+
accountId: string;
|
|
26
|
+
/** What kind of item it is, for the extension ({@link INBOX_KIND_RE}). */
|
|
27
|
+
kind: string;
|
|
28
|
+
/**
|
|
29
|
+
* A single string shown as is, or `{ zh, en }` shown in the reader's language; each text at
|
|
30
|
+
* most {@link INBOX_LIMITS}.titleChars characters.
|
|
31
|
+
*/
|
|
32
|
+
title: LocalizedText;
|
|
33
|
+
/**
|
|
34
|
+
* A single string or `{ zh, en }`, like `title`; each text at most
|
|
35
|
+
* {@link INBOX_LIMITS}.bodyChars characters.
|
|
36
|
+
*/
|
|
37
|
+
body?: LocalizedText;
|
|
38
|
+
/**
|
|
39
|
+
* An in-app path opened from the item: an extension's item may only link to its own pages,
|
|
40
|
+
* `/p/<extension name>/...` (at most {@link INBOX_LIMITS}.linkChars characters).
|
|
41
|
+
*/
|
|
42
|
+
link?: string;
|
|
43
|
+
/** At most {@link INBOX_ACTIONS_MAX}. */
|
|
44
|
+
actions?: InboxAction[];
|
|
45
|
+
/**
|
|
46
|
+
* Seconds until the item expires and leaves the inbox (default
|
|
47
|
+
* {@link INBOX_LIMITS}.defaultExpirySeconds, at most {@link INBOX_LIMITS}.maxExpirySeconds).
|
|
48
|
+
*/
|
|
49
|
+
expiresInSeconds?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Idempotency key: while an item of this extension with the same key is open for the same
|
|
52
|
+
* person in the same org, a post returns that item instead of adding another.
|
|
53
|
+
*/
|
|
54
|
+
dedupeKey?: string;
|
|
55
|
+
}
|
|
56
|
+
/** `ctx.inbox` (requires `permissions.inbox`): personal inbox items. */
|
|
57
|
+
export interface InboxCtx {
|
|
58
|
+
/** Posts an item for one person (see {@link InboxPost}); the person's push settings apply. */
|
|
59
|
+
post(p: InboxPost): Promise<{
|
|
60
|
+
itemId: string;
|
|
61
|
+
}>;
|
|
62
|
+
/** Resolves an open item this extension posted (an item already closed is left as it is). */
|
|
63
|
+
resolve(args: {
|
|
64
|
+
orgId: string;
|
|
65
|
+
itemId: string;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export type InboxErrorCode = "invalid_item" | "org_disabled" | "not_found";
|
|
69
|
+
/** A {@link InboxCtx} call was refused. */
|
|
70
|
+
export declare class InboxError extends Error {
|
|
71
|
+
readonly code: InboxErrorCode;
|
|
72
|
+
constructor(code: InboxErrorCode, message: string, opts?: {
|
|
73
|
+
cause?: unknown;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** The most actions one inbox item carries. */
|
|
77
|
+
export declare const INBOX_ACTIONS_MAX = 3;
|
|
78
|
+
/** Limits of an inbox item. */
|
|
79
|
+
export declare const INBOX_LIMITS: {
|
|
80
|
+
readonly titleChars: 200;
|
|
81
|
+
readonly bodyChars: 2000;
|
|
82
|
+
readonly linkChars: 512;
|
|
83
|
+
readonly kindChars: 64;
|
|
84
|
+
readonly labelChars: 40;
|
|
85
|
+
readonly idChars: 64;
|
|
86
|
+
readonly dedupeKeyChars: 200;
|
|
87
|
+
/** UTF-8 bytes of one action's `payload` as JSON (as a UI button's). */
|
|
88
|
+
readonly payloadBytes: 2000;
|
|
89
|
+
readonly defaultExpirySeconds: number;
|
|
90
|
+
readonly maxExpirySeconds: number;
|
|
91
|
+
};
|
|
92
|
+
/** The shape of an item's `kind`: dotted lower-case words. */
|
|
93
|
+
export declare const INBOX_KIND_RE: RegExp;
|
|
94
|
+
/** The shape of an action id, a contribution id and a UI action id. */
|
|
95
|
+
export declare const INBOX_ID_RE: RegExp;
|
|
96
|
+
/**
|
|
97
|
+
* Checks a post before it is stored; returns error codes (empty = valid): `missing_<field>`,
|
|
98
|
+
* `<field>_too_long`, `title_invalid` / `body_invalid` (not a string or `{ zh, en }`),
|
|
99
|
+
* `kind_invalid`, `link_invalid` (not a path of the extension's own pages
|
|
100
|
+
* `/p/<plugin>/`), `too_many_actions`, `action_invalid`, `action_duplicate`, `payload_too_large`,
|
|
101
|
+
* `expiry_invalid`. `plugin` is the posting extension's name.
|
|
102
|
+
*/
|
|
103
|
+
export declare function validateInboxPost(p: InboxPost, plugin: string): string[];
|