@capybara-hq/plugin-sdk 0.1.0-rc.83 → 0.1.0-rc.85
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/agent-docs/extension-points/model-provider.md +2 -0
- package/agent-docs/extension-points/trigger-source.md +17 -0
- package/agent-docs/extensions.md +1 -0
- package/dist/ctx.d.ts +6 -0
- package/dist/device-service.d.ts +20 -1
- package/dist/device-service.js +20 -1
- package/dist/extension-point.js +1 -0
- package/dist/hooks.d.ts +5 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/model.d.ts +65 -1
- package/dist/model.js +91 -0
- package/dist/permissions.d.ts +7 -0
- package/dist/permissions.js +16 -0
- package/dist/shell-capabilities.d.ts +5 -0
- package/dist/theme-tokens.generated.d.ts +7 -7
- package/dist/theme-tokens.generated.js +5 -5
- package/dist/trigger-source.d.ts +35 -0
- package/dist/trigger-source.js +2 -0
- package/dist/triggers.d.ts +72 -0
- package/dist/triggers.js +71 -0
- package/dist/ui-parts.d.ts +1 -1
- package/dist/ui-parts.js +0 -11
- package/package.json +1 -1
|
@@ -14,4 +14,6 @@ Map the kernel's messages and tools to the vendor API and stream the result. Do
|
|
|
14
14
|
|
|
15
15
|
Messages may carry an `image` or a `document` block, gated by `capabilities.vision` and `capabilities.documents`; the kernel replaces a block the model cannot take with an English placeholder and never sends the bytes. A `file` block is an attachment the model can only reference (an xlsx, say): the kernel resolves it to text before the request, so a provider never receives one. Resolve any block you do not recognize by skipping it. The `size` on an attachment block is display metadata (the UI chip, the reference line) and is never sent to a provider.
|
|
16
16
|
|
|
17
|
+
Declare each model's prompt cache in `ModelInfo.cache` (absent = mechanism `none`; it must pass `validateModelCache`): the `mechanism` (`explicit` breakpoints, `implicit` service caching, `none`), the lifetimes a request can choose in seconds (`ttlOptions`, ascending; empty when the service decides alone), `defaultTtl` (required and one of `ttlOptions` when `ttlOptions` is non-empty), `ttlIsMinimum`, `refreshOnHit` (true only if a hit refreshes the lifetime of every tier the kernel may select; the kernel selects only `defaultTtl` or the smallest option of at least 1800 s, so OpenAI GPT-5.6+ declares true: its 30m tier refreshes, its 12h tier does not and is never selected; when unconfirmed, declare false), `ttlClock`, `minTokens` and `guaranteed` (a hit on an unchanged prefix within the lifetime is expected, not best-effort). `ModelRequest.cacheTtl` is one of the model's `ttlOptions` (the kernel sends no other value): map it to the vendor's field (`cache_control.ttl`, `prompt_cache_options.ttl`), and ignore it for a model without options. When the vendor reports writes per lifetime tier, report them in `ModelUsage.cacheWriteByTtl` (`{ ttl, tokens }[]`, summing to `cacheWriteTokens`; `validateCacheWriteByTtl`).
|
|
18
|
+
|
|
17
19
|
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Authoring: extension point trigger-source
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `trigger-source` (a ref is `trigger-source@<major>`)
|
|
5
|
+
- Declares the events an extension emits and which people may see their subjects.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: TriggerSource (`trigger-source.ts`), with `ctx.triggers` (`triggers.ts`)
|
|
12
|
+
|
|
13
|
+
Declare the event types the extension emits in `permissions.triggers.emit` (lower-case dotted names such as `item.created`, at most 64) and implement `TriggerSource.events()` with one `TriggerEventDeclaration` per type: a name, whether the event is directed at one agent, and its facts (a type, a name and whether automations may filter on it). Emit with `ctx.triggers.emit(event)`; the result says whether the `dedupeKey` was already seen (`duplicate`). An event carries the org, the subject (kind, id, title, optional url), scalar or string-list facts, a summary of at most 4096 UTF-8 bytes for the agent, and optionally the cause (the tool call or the account) and an audience for directed events. `emit` throws `TriggerError`: `type_not_declared`, `invalid_event` or `org_disabled`.
|
|
14
|
+
|
|
15
|
+
`visible` answers which of the given accounts may see a subject; the kernel only wakes agents of accounts it lists, and a throw or a missing answer means nobody. `subjectLink` optionally gives people a link to the subject. Automation filters are conjunctions over facts: `eq` compares scalars, `in` matches a scalar fact against a list, `contains` matches a list fact against a scalar, and a missing fact never matches.
|
|
16
|
+
|
|
17
|
+
See `extensions` for the rules every extension follows.
|
package/agent-docs/extensions.md
CHANGED
|
@@ -128,6 +128,7 @@ look like `channel@1`: name and major version. The registered points:
|
|
|
128
128
|
| `file-preview` | multi | yes | Renders previews of files of given types: conversation files, shared files and skill files. |
|
|
129
129
|
| `web-search` | multi | yes | Searches the web for the WebSearch tool; each org picks a default provider. |
|
|
130
130
|
| `context` | multi | yes | Adds text to the model's context at run start in conversations of orgs that enable it. |
|
|
131
|
+
| `trigger-source` | multi | yes | Declares the events an extension emits and which people may see their subjects. |
|
|
131
132
|
| `web-fetch` | multi | yes | Fetches and extracts web pages for the WebFetch tool; each org picks a default provider. |
|
|
132
133
|
| `push-provider` | multi | no | Delivers push notifications to people's mobile apps through one channel (APNs, FCM, an aggregator). |
|
|
133
134
|
<!-- /generated -->
|
package/dist/ctx.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ExtensionNet } from "./net.js";
|
|
|
9
9
|
import type { SetupCheckDefinition } from "./setup-check.js";
|
|
10
10
|
import type { ObjectHead, PresignedUpload, PresignGetOptions } from "./storage.js";
|
|
11
11
|
import type { ToolCallContext, ToolHandler, ToolSpec, ToolWatcher } from "./tool.js";
|
|
12
|
+
import type { TriggersCtx } from "./triggers.js";
|
|
12
13
|
import type { EmbedClaims, UiActionArgs, UiActionResult, UiRenderArgs, UiView } from "./ui.js";
|
|
13
14
|
/** Logger interface. */
|
|
14
15
|
export interface Logger {
|
|
@@ -426,6 +427,11 @@ export interface ExtensionContext {
|
|
|
426
427
|
* see {@link DeviceAccessCtx}).
|
|
427
428
|
*/
|
|
428
429
|
deviceAccess: DeviceAccessCtx;
|
|
430
|
+
/**
|
|
431
|
+
* Emits events automations can react to (requires `permissions.triggers`, see
|
|
432
|
+
* {@link TriggersCtx}).
|
|
433
|
+
*/
|
|
434
|
+
triggers: TriggersCtx;
|
|
429
435
|
provide(extensionPoint: ExtensionPointRef, impl: unknown): void;
|
|
430
436
|
/**
|
|
431
437
|
* The lifecycle signal of this plugin instance: aborted when the instance is revoked (disabled,
|
package/dist/device-service.d.ts
CHANGED
|
@@ -101,7 +101,8 @@ export declare const DEVICE_SERVICE_WORKSPACE_ENV = "CAPYBARA_SERVICE_WORKSPACE"
|
|
|
101
101
|
* {@link DEVICE_SERVICE_INSTALL_SEAL} in it; from its next start on the directory is read only
|
|
102
102
|
* for the service, so nothing the service later runs (a compromised browser included) can
|
|
103
103
|
* replace what was installed. The provider empties it at every start that does not find it
|
|
104
|
-
* sealed under the service's current files (unsealed, or a plugin upgrade since
|
|
104
|
+
* sealed under the service's current files (unsealed, or a plugin upgrade since; under its
|
|
105
|
+
* {@link DEVICE_SERVICE_INSTALL_KEY_FILE} where the service ships one), so a service
|
|
105
106
|
* installs afresh while unsealed and never trusts what it finds there. The process that seals
|
|
106
107
|
* keeps its write access until it exits, so a service runs no untrusted input (no web page) while
|
|
107
108
|
* unsealed, seals only a complete install and then exits; the next start, reviewed again, runs it
|
|
@@ -110,6 +111,24 @@ export declare const DEVICE_SERVICE_WORKSPACE_ENV = "CAPYBARA_SERVICE_WORKSPACE"
|
|
|
110
111
|
export declare const DEVICE_SERVICE_INSTALL_ENV = "CAPYBARA_SERVICE_INSTALL";
|
|
111
112
|
/** The file that seals a service's install directory ({@link DEVICE_SERVICE_INSTALL_ENV}). */
|
|
112
113
|
export declare const DEVICE_SERVICE_INSTALL_SEAL = ".sealed";
|
|
114
|
+
/**
|
|
115
|
+
* A service file naming what its install directory holds ({@link DEVICE_SERVICE_INSTALL_ENV}): one
|
|
116
|
+
* line matching {@link DEVICE_SERVICE_INSTALL_KEY_RE}, such as the browser revision. capybara-device
|
|
117
|
+
* (the device-local provider's machine program, capybara-hq/plugins#311) keeps such installs in a
|
|
118
|
+
* machine-wide cache of the OS user and keys them by it instead of by the service's files, so a
|
|
119
|
+
* plugin upgrade that keeps the key reuses the sealed install, and so do the other devices of the
|
|
120
|
+
* same deployment (its URL's origin and path) on that machine. Services of other deployments,
|
|
121
|
+
* platforms or launch environments never see it. The provider still hands an unsealed install out
|
|
122
|
+
* empty and private to one start, publishes it only once the service exits sealed (every link
|
|
123
|
+
* inside it, no hard link, no special file) and verifies it before every reuse. It assumes the
|
|
124
|
+
* unsealed install is the service's own code running no untrusted input, as the seal does: a
|
|
125
|
+
* child that left its process group could still write through an open file after the digest
|
|
126
|
+
* (the next reuse's verification catches it). Absent (or malformed): the install is keyed by the
|
|
127
|
+
* files.
|
|
128
|
+
*/
|
|
129
|
+
export declare const DEVICE_SERVICE_INSTALL_KEY_FILE = "capybara-install-key";
|
|
130
|
+
/** What {@link DEVICE_SERVICE_INSTALL_KEY_FILE} holds: lower case, so it is one name on every file system. */
|
|
131
|
+
export declare const DEVICE_SERVICE_INSTALL_KEY_RE: RegExp;
|
|
113
132
|
/**
|
|
114
133
|
* Names the Mach service allowances the provider's sandbox gives the service (macOS: device-local
|
|
115
134
|
* sets it, a spec cannot). Its value {@link DEVICE_SERVICE_MACH_CHROMIUM} means the full Chromium
|
package/dist/device-service.js
CHANGED
|
@@ -119,7 +119,8 @@ export const DEVICE_SERVICE_WORKSPACE_ENV = "CAPYBARA_SERVICE_WORKSPACE";
|
|
|
119
119
|
* {@link DEVICE_SERVICE_INSTALL_SEAL} in it; from its next start on the directory is read only
|
|
120
120
|
* for the service, so nothing the service later runs (a compromised browser included) can
|
|
121
121
|
* replace what was installed. The provider empties it at every start that does not find it
|
|
122
|
-
* sealed under the service's current files (unsealed, or a plugin upgrade since
|
|
122
|
+
* sealed under the service's current files (unsealed, or a plugin upgrade since; under its
|
|
123
|
+
* {@link DEVICE_SERVICE_INSTALL_KEY_FILE} where the service ships one), so a service
|
|
123
124
|
* installs afresh while unsealed and never trusts what it finds there. The process that seals
|
|
124
125
|
* keeps its write access until it exits, so a service runs no untrusted input (no web page) while
|
|
125
126
|
* unsealed, seals only a complete install and then exits; the next start, reviewed again, runs it
|
|
@@ -128,6 +129,24 @@ export const DEVICE_SERVICE_WORKSPACE_ENV = "CAPYBARA_SERVICE_WORKSPACE";
|
|
|
128
129
|
export const DEVICE_SERVICE_INSTALL_ENV = "CAPYBARA_SERVICE_INSTALL";
|
|
129
130
|
/** The file that seals a service's install directory ({@link DEVICE_SERVICE_INSTALL_ENV}). */
|
|
130
131
|
export const DEVICE_SERVICE_INSTALL_SEAL = ".sealed";
|
|
132
|
+
/**
|
|
133
|
+
* A service file naming what its install directory holds ({@link DEVICE_SERVICE_INSTALL_ENV}): one
|
|
134
|
+
* line matching {@link DEVICE_SERVICE_INSTALL_KEY_RE}, such as the browser revision. capybara-device
|
|
135
|
+
* (the device-local provider's machine program, capybara-hq/plugins#311) keeps such installs in a
|
|
136
|
+
* machine-wide cache of the OS user and keys them by it instead of by the service's files, so a
|
|
137
|
+
* plugin upgrade that keeps the key reuses the sealed install, and so do the other devices of the
|
|
138
|
+
* same deployment (its URL's origin and path) on that machine. Services of other deployments,
|
|
139
|
+
* platforms or launch environments never see it. The provider still hands an unsealed install out
|
|
140
|
+
* empty and private to one start, publishes it only once the service exits sealed (every link
|
|
141
|
+
* inside it, no hard link, no special file) and verifies it before every reuse. It assumes the
|
|
142
|
+
* unsealed install is the service's own code running no untrusted input, as the seal does: a
|
|
143
|
+
* child that left its process group could still write through an open file after the digest
|
|
144
|
+
* (the next reuse's verification catches it). Absent (or malformed): the install is keyed by the
|
|
145
|
+
* files.
|
|
146
|
+
*/
|
|
147
|
+
export const DEVICE_SERVICE_INSTALL_KEY_FILE = "capybara-install-key";
|
|
148
|
+
/** What {@link DEVICE_SERVICE_INSTALL_KEY_FILE} holds: lower case, so it is one name on every file system. */
|
|
149
|
+
export const DEVICE_SERVICE_INSTALL_KEY_RE = /^[a-z0-9][a-z0-9._+-]{0,127}$/;
|
|
131
150
|
/**
|
|
132
151
|
* Names the Mach service allowances the provider's sandbox gives the service (macOS: device-local
|
|
133
152
|
* sets it, a spec cannot). Its value {@link DEVICE_SERVICE_MACH_CHROMIUM} means the full Chromium
|
package/dist/extension-point.js
CHANGED
|
@@ -21,6 +21,7 @@ export const EXTENSION_POINTS = {
|
|
|
21
21
|
"file-preview": info([1], "Renders previews of files of given types: conversation files, shared files and skill files.", "multi", false, true),
|
|
22
22
|
"web-search": info([1], "Searches the web for the WebSearch tool; each org picks a default provider.", "multi", true, true, "org-default"),
|
|
23
23
|
context: info([1], "Adds text to the model's context at run start in conversations of orgs that enable it.", "multi", true, true),
|
|
24
|
+
"trigger-source": info([1], "Declares the events an extension emits and which people may see their subjects.", "multi", true, true),
|
|
24
25
|
"web-fetch": info([1], "Fetches and extracts web pages for the WebFetch tool; each org picks a default provider.", "multi", true, true, "org-default"),
|
|
25
26
|
"push-provider": info([1], "Delivers push notifications to people's mobile apps through one channel (APNs, FCM, an aggregator).", "multi", true),
|
|
26
27
|
};
|
package/dist/hooks.d.ts
CHANGED
|
@@ -81,8 +81,11 @@ export type HookModelMessage = {
|
|
|
81
81
|
role: "system";
|
|
82
82
|
content: string;
|
|
83
83
|
};
|
|
84
|
-
/**
|
|
85
|
-
|
|
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"> & {
|
|
86
89
|
messages: HookModelMessage[];
|
|
87
90
|
};
|
|
88
91
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.0-rc.85";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
3
|
export * from "./avatar-presets.js";
|
|
4
4
|
export * from "./bootstrap.js";
|
|
@@ -54,6 +54,8 @@ export * from "./theme-readability.js";
|
|
|
54
54
|
export * from "./theme-tokens.generated.js";
|
|
55
55
|
export * from "./tool.js";
|
|
56
56
|
export * from "./tool-key.js";
|
|
57
|
+
export * from "./trigger-source.js";
|
|
58
|
+
export * from "./triggers.js";
|
|
57
59
|
export * from "./ui.js";
|
|
58
60
|
export * from "./ui-parts.js";
|
|
59
61
|
export * from "./ui-resolve.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export const SDK_VERSION = "0.1.0-rc.85";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
3
|
export * from "./avatar-presets.js";
|
|
4
4
|
export * from "./bootstrap.js";
|
|
@@ -54,6 +54,8 @@ export * from "./theme-readability.js";
|
|
|
54
54
|
export * from "./theme-tokens.generated.js";
|
|
55
55
|
export * from "./tool.js";
|
|
56
56
|
export * from "./tool-key.js";
|
|
57
|
+
export * from "./trigger-source.js";
|
|
58
|
+
export * from "./triggers.js";
|
|
57
59
|
export * from "./ui.js";
|
|
58
60
|
export * from "./ui-parts.js";
|
|
59
61
|
export * from "./ui-resolve.js";
|
package/dist/model.d.ts
CHANGED
|
@@ -42,6 +42,48 @@ export interface ModelImageGenerationInfo {
|
|
|
42
42
|
/** The media types the model returns. */
|
|
43
43
|
outputMediaTypes: ImageMediaType[];
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* explicit: the plugin places breakpoints and the lifetime is known; implicit: the service caches
|
|
47
|
+
* on its own (best-effort unless it declares a lifetime floor); none: no caching.
|
|
48
|
+
*/
|
|
49
|
+
export type ModelCacheMechanism = "explicit" | "implicit" | "none";
|
|
50
|
+
/** How a model's prompt cache behaves. Absent or `mechanism: "none"` = no caching. */
|
|
51
|
+
export interface ModelCacheInfo {
|
|
52
|
+
/** See {@link ModelCacheMechanism}. */
|
|
53
|
+
mechanism: ModelCacheMechanism;
|
|
54
|
+
/**
|
|
55
|
+
* Lifetimes a request can choose, in seconds ([300, 3600] Anthropic / Qwen4, [1800, 43200]
|
|
56
|
+
* OpenAI 5.6+, [300] Bailian); empty when the service decides alone. Ascending and unique.
|
|
57
|
+
*/
|
|
58
|
+
ttlOptions: number[];
|
|
59
|
+
/**
|
|
60
|
+
* The lifetime a request that names none gets (OpenAI 5.6+: 1800). Required, and one of
|
|
61
|
+
* `ttlOptions`, when `ttlOptions` is non-empty.
|
|
62
|
+
*/
|
|
63
|
+
defaultTtl?: number;
|
|
64
|
+
/** OpenAI: the lifetime is a floor, entries may live longer; Anthropic / Bailian: exact. */
|
|
65
|
+
ttlIsMinimum: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* True only if a hit restarts the lifetime of every tier the kernel may select. The kernel
|
|
68
|
+
* selects only `defaultTtl` or the smallest option of at least 1800 s, so OpenAI GPT-5.6+
|
|
69
|
+
* declares true (its 30m tier refreshes on a hit; its 12h tier does not, and the kernel never
|
|
70
|
+
* selects 43200). Anthropic and Bailian declare true. When unconfirmed, declare false.
|
|
71
|
+
*/
|
|
72
|
+
refreshOnHit: boolean;
|
|
73
|
+
/** When the lifetime starts counting; Anthropic: the request's start. */
|
|
74
|
+
ttlClock: "request_start" | "unknown";
|
|
75
|
+
/** Below this many prompt tokens nothing is cached. */
|
|
76
|
+
minTokens?: number;
|
|
77
|
+
/** A hit on an unchanged prefix within the lifetime is expected, not best-effort. */
|
|
78
|
+
guaranteed: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Checks a model's cache declaration: positive integer TTLs, `ttlOptions` ascending and unique,
|
|
82
|
+
* `defaultTtl` present and among the options when options exist, `none` with no options and no
|
|
83
|
+
* guarantee, a guarantee only with a known lifetime, `minTokens` a positive integer. Returns the
|
|
84
|
+
* first problem (naming the field), or `null` when valid.
|
|
85
|
+
*/
|
|
86
|
+
export declare function validateModelCache(cache: ModelCacheInfo | undefined): string | null;
|
|
45
87
|
export interface ModelInfo {
|
|
46
88
|
id: string;
|
|
47
89
|
displayName: string;
|
|
@@ -63,7 +105,6 @@ export interface ModelInfo {
|
|
|
63
105
|
tools: boolean;
|
|
64
106
|
vision: boolean;
|
|
65
107
|
reasoning: boolean;
|
|
66
|
-
caching: boolean;
|
|
67
108
|
midConversationSystem: boolean;
|
|
68
109
|
/**
|
|
69
110
|
* Whether `document` blocks are accepted (default false). Images are governed by `vision`. When
|
|
@@ -80,6 +121,8 @@ export interface ModelInfo {
|
|
|
80
121
|
* uses the config default.
|
|
81
122
|
*/
|
|
82
123
|
streamIdleTimeoutMs?: number;
|
|
124
|
+
/** The model's prompt cache (must pass `validateModelCache`). Absent = mechanism `none`. */
|
|
125
|
+
cache?: ModelCacheInfo;
|
|
83
126
|
/**
|
|
84
127
|
* The parameters this model supports (may be an empty array; must pass
|
|
85
128
|
* `assertValidDeclarations`). Effort is the standard `effort` knob declared here.
|
|
@@ -261,6 +304,12 @@ export interface ModelRequest {
|
|
|
261
304
|
* API.
|
|
262
305
|
*/
|
|
263
306
|
purpose?: ModelCallPurpose;
|
|
307
|
+
/**
|
|
308
|
+
* The prompt cache lifetime to ask for: seconds, one of the model's `ttlOptions` (the kernel
|
|
309
|
+
* only ever sends one of them); a plugin of a model without options ignores it; the plugin maps
|
|
310
|
+
* it to the vendor's field. Absent = the model's default.
|
|
311
|
+
*/
|
|
312
|
+
cacheTtl?: number;
|
|
264
313
|
}
|
|
265
314
|
export type StopReason = "end_turn" | "tool_use" | "max_tokens" | "refusal" | "other";
|
|
266
315
|
/**
|
|
@@ -284,7 +333,22 @@ export interface ModelUsage {
|
|
|
284
333
|
cacheWriteTokens: number;
|
|
285
334
|
/** Images produced (image generation calls). */
|
|
286
335
|
outputImages?: number;
|
|
336
|
+
/**
|
|
337
|
+
* Cache writes per lifetime tier: optional; sums to `cacheWriteTokens`; from the vendor's
|
|
338
|
+
* per-tier write counts.
|
|
339
|
+
*/
|
|
340
|
+
cacheWriteByTtl?: CacheWriteByTtl[];
|
|
341
|
+
}
|
|
342
|
+
/** Input tokens written to the prompt cache with one lifetime (`ttl`, seconds). */
|
|
343
|
+
export interface CacheWriteByTtl {
|
|
344
|
+
ttl: number;
|
|
345
|
+
tokens: number;
|
|
287
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Checks `usage.cacheWriteByTtl` when present: positive integer `ttl`s, each once; non-negative
|
|
349
|
+
* integer `tokens`; the tokens sum to `cacheWriteTokens`. Returns the first problem, or `null`.
|
|
350
|
+
*/
|
|
351
|
+
export declare function validateCacheWriteByTtl(usage: ModelUsage): string | null;
|
|
288
352
|
/**
|
|
289
353
|
* One event of a model stream. Tool call events are display only: a provider MAY emit
|
|
290
354
|
* `tool_call_start` when a tool call begins and `tool_call_delta` with raw input JSON fragments
|
package/dist/model.js
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
/** The aspect ratios a caller may ask for instead of an exact size. */
|
|
2
2
|
export const IMAGE_ASPECT_RATIOS = ["1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16"];
|
|
3
|
+
const isPositiveInt = (n) => typeof n === "number" && Number.isInteger(n) && n > 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks a model's cache declaration: positive integer TTLs, `ttlOptions` ascending and unique,
|
|
6
|
+
* `defaultTtl` present and among the options when options exist, `none` with no options and no
|
|
7
|
+
* guarantee, a guarantee only with a known lifetime, `minTokens` a positive integer. Returns the
|
|
8
|
+
* first problem (naming the field), or `null` when valid.
|
|
9
|
+
*/
|
|
10
|
+
export function validateModelCache(cache) {
|
|
11
|
+
if (cache === undefined)
|
|
12
|
+
return null;
|
|
13
|
+
if (typeof cache !== "object" || cache === null || Array.isArray(cache)) {
|
|
14
|
+
return "cache must be an object";
|
|
15
|
+
}
|
|
16
|
+
if (!["explicit", "implicit", "none"].includes(cache.mechanism)) {
|
|
17
|
+
return `cache.mechanism must be "explicit", "implicit" or "none"`;
|
|
18
|
+
}
|
|
19
|
+
if (!Array.isArray(cache.ttlOptions))
|
|
20
|
+
return "cache.ttlOptions must be an array";
|
|
21
|
+
for (const [i, ttl] of cache.ttlOptions.entries()) {
|
|
22
|
+
if (!isPositiveInt(ttl))
|
|
23
|
+
return `cache.ttlOptions[${i}] must be a positive integer (seconds)`;
|
|
24
|
+
const prev = cache.ttlOptions[i - 1];
|
|
25
|
+
if (i > 0 && prev !== undefined && ttl <= prev) {
|
|
26
|
+
return "cache.ttlOptions must be ascending and unique";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (cache.defaultTtl !== undefined) {
|
|
30
|
+
if (!isPositiveInt(cache.defaultTtl)) {
|
|
31
|
+
return "cache.defaultTtl must be a positive integer (seconds)";
|
|
32
|
+
}
|
|
33
|
+
if (cache.ttlOptions.length > 0 && !cache.ttlOptions.includes(cache.defaultTtl)) {
|
|
34
|
+
return "cache.defaultTtl must be one of cache.ttlOptions";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!["request_start", "unknown"].includes(cache.ttlClock)) {
|
|
38
|
+
return `cache.ttlClock must be "request_start" or "unknown"`;
|
|
39
|
+
}
|
|
40
|
+
for (const field of ["ttlIsMinimum", "refreshOnHit", "guaranteed"]) {
|
|
41
|
+
if (typeof cache[field] !== "boolean")
|
|
42
|
+
return `cache.${field} must be a boolean`;
|
|
43
|
+
}
|
|
44
|
+
if (cache.minTokens !== undefined && !isPositiveInt(cache.minTokens)) {
|
|
45
|
+
return "cache.minTokens must be a positive integer";
|
|
46
|
+
}
|
|
47
|
+
if (cache.mechanism === "none") {
|
|
48
|
+
if (cache.ttlOptions.length > 0)
|
|
49
|
+
return 'cache.mechanism "none" takes no ttlOptions';
|
|
50
|
+
if (cache.guaranteed)
|
|
51
|
+
return 'cache.guaranteed must be false with mechanism "none"';
|
|
52
|
+
}
|
|
53
|
+
if (cache.ttlOptions.length > 0 && cache.defaultTtl === undefined) {
|
|
54
|
+
return "cache.defaultTtl is required when cache.ttlOptions is non-empty";
|
|
55
|
+
}
|
|
56
|
+
if (cache.guaranteed && cache.ttlOptions.length === 0 && cache.defaultTtl === undefined) {
|
|
57
|
+
return "cache.guaranteed needs a known lifetime (ttlOptions or defaultTtl)";
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
3
61
|
/** Types accepted by image blocks. */
|
|
4
62
|
export const IMAGE_MEDIA_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
5
63
|
/** Types accepted by document blocks. */
|
|
@@ -134,6 +192,39 @@ export function validateMediaBlock(b) {
|
|
|
134
192
|
}
|
|
135
193
|
return errs;
|
|
136
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Checks `usage.cacheWriteByTtl` when present: positive integer `ttl`s, each once; non-negative
|
|
197
|
+
* integer `tokens`; the tokens sum to `cacheWriteTokens`. Returns the first problem, or `null`.
|
|
198
|
+
*/
|
|
199
|
+
export function validateCacheWriteByTtl(usage) {
|
|
200
|
+
if (typeof usage !== "object" || usage === null)
|
|
201
|
+
return "usage must be an object";
|
|
202
|
+
const tiers = usage.cacheWriteByTtl;
|
|
203
|
+
if (tiers === undefined)
|
|
204
|
+
return null;
|
|
205
|
+
if (!Array.isArray(tiers))
|
|
206
|
+
return "cacheWriteByTtl must be an array";
|
|
207
|
+
const seen = new Set();
|
|
208
|
+
let sum = 0;
|
|
209
|
+
for (const [i, tier] of tiers.entries()) {
|
|
210
|
+
if (typeof tier !== "object" || tier === null)
|
|
211
|
+
return `cacheWriteByTtl[${i}] must be an object`;
|
|
212
|
+
if (!isPositiveInt(tier.ttl)) {
|
|
213
|
+
return `cacheWriteByTtl[${i}].ttl must be a positive integer (seconds)`;
|
|
214
|
+
}
|
|
215
|
+
if (seen.has(tier.ttl))
|
|
216
|
+
return `cacheWriteByTtl has ttl ${tier.ttl} twice`;
|
|
217
|
+
seen.add(tier.ttl);
|
|
218
|
+
if (typeof tier.tokens !== "number" || !Number.isInteger(tier.tokens) || tier.tokens < 0) {
|
|
219
|
+
return `cacheWriteByTtl[${i}].tokens must be a non-negative integer`;
|
|
220
|
+
}
|
|
221
|
+
sum += tier.tokens;
|
|
222
|
+
}
|
|
223
|
+
if (sum !== usage.cacheWriteTokens) {
|
|
224
|
+
return `cacheWriteByTtl sums to ${sum}, not cacheWriteTokens ${usage.cacheWriteTokens}`;
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
137
228
|
const ALL_KINDS = new Set([
|
|
138
229
|
"rate_limited",
|
|
139
230
|
"overloaded",
|
package/dist/permissions.d.ts
CHANGED
|
@@ -76,6 +76,13 @@ export interface ExtensionPermissions {
|
|
|
76
76
|
deviceAccess?: {
|
|
77
77
|
services: string[];
|
|
78
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* `ctx.triggers`: the event types this extension may emit (at most {@link TRIGGER_MAX_TYPES},
|
|
81
|
+
* each matching {@link TRIGGER_TYPE_RE}). An emit of another type is refused.
|
|
82
|
+
*/
|
|
83
|
+
triggers?: {
|
|
84
|
+
emit: string[];
|
|
85
|
+
};
|
|
79
86
|
}
|
|
80
87
|
/** The most services `permissions.deviceAccess.services` may list. */
|
|
81
88
|
export declare const DEVICE_ACCESS_MAX_SERVICES = 4;
|
package/dist/permissions.js
CHANGED
|
@@ -3,6 +3,7 @@ import { DIAL_IN_PROTOCOL_RE } from "./dial-in.js";
|
|
|
3
3
|
import { POLICY_HOOKS } from "./hooks.js";
|
|
4
4
|
import { HTTP_ACCESS } from "./http-access.js";
|
|
5
5
|
import { SETUP_CHECK_ID_RE, SETUP_CHECK_LIMITS } from "./setup-check.js";
|
|
6
|
+
import { TRIGGER_MAX_TYPES, TRIGGER_TYPE_RE } from "./triggers.js";
|
|
6
7
|
import { UI_ICONS } from "./ui.js";
|
|
7
8
|
import { isCompactForm, parseSlotRef, uiSlot } from "./ui-slots.js";
|
|
8
9
|
/** The most services `permissions.deviceAccess.services` may list. */
|
|
@@ -50,6 +51,7 @@ const KEYS = new Set([
|
|
|
50
51
|
"setupChecks",
|
|
51
52
|
"dialIn",
|
|
52
53
|
"deviceAccess",
|
|
54
|
+
"triggers",
|
|
53
55
|
]);
|
|
54
56
|
const POLICY = new Set(POLICY_HOOKS);
|
|
55
57
|
const METHODS = new Set(["GET", "POST", "PUT", "DELETE"]);
|
|
@@ -235,6 +237,20 @@ export function validatePermissions(plugin, p, provides = []) {
|
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
239
|
}
|
|
240
|
+
if (p.triggers !== undefined) {
|
|
241
|
+
if (!isObj(p.triggers) || Object.keys(p.triggers).some((k) => k !== "emit")) {
|
|
242
|
+
errs.push("permissions.triggers must be { emit: string[] }");
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
const types = strList("permissions.triggers.emit", p.triggers.emit, errs);
|
|
246
|
+
if (types.length > TRIGGER_MAX_TYPES)
|
|
247
|
+
errs.push(`permissions.triggers.emit lists at most ${TRIGGER_MAX_TYPES} types`);
|
|
248
|
+
for (const t of types) {
|
|
249
|
+
if (!TRIGGER_TYPE_RE.test(t))
|
|
250
|
+
errs.push(`permissions.triggers.emit entry "${t}" must match ${TRIGGER_TYPE_RE}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
238
254
|
return errs;
|
|
239
255
|
}
|
|
240
256
|
const UI_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
@@ -31,6 +31,11 @@ export interface NotifyCapabilityV1 {
|
|
|
31
31
|
/** `openExternal@1`: open a URL in the system browser. */
|
|
32
32
|
export interface OpenExternalCapabilityV1 {
|
|
33
33
|
open(url: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* The shell's own URL scheme, the one in its `<scheme>://auth/callback` (optional): a browser
|
|
36
|
+
* handoff's done page links back into the app through `<scheme>://open?url=…`.
|
|
37
|
+
*/
|
|
38
|
+
readonly returnScheme?: string;
|
|
34
39
|
}
|
|
35
40
|
/** `signIn@1`: sign in through the system browser (desktop client spec §6.5). */
|
|
36
41
|
export interface SignInCapabilityV1 {
|
|
@@ -3,7 +3,7 @@ export declare const THEME_TOKENS: {
|
|
|
3
3
|
readonly color: {
|
|
4
4
|
readonly bg: {
|
|
5
5
|
readonly dark: "#0A0A0A";
|
|
6
|
-
readonly light: "#
|
|
6
|
+
readonly light: "#FDFDFC";
|
|
7
7
|
};
|
|
8
8
|
readonly panel: {
|
|
9
9
|
readonly dark: "#111110";
|
|
@@ -14,11 +14,11 @@ export declare const THEME_TOKENS: {
|
|
|
14
14
|
readonly light: "#FCFBF9";
|
|
15
15
|
};
|
|
16
16
|
readonly sidebar: {
|
|
17
|
-
readonly dark: "#
|
|
18
|
-
readonly light: "#
|
|
17
|
+
readonly dark: "#171716";
|
|
18
|
+
readonly light: "#EDECE7";
|
|
19
19
|
};
|
|
20
20
|
readonly "sidebar-active": {
|
|
21
|
-
readonly dark: "
|
|
21
|
+
readonly dark: "rgba(255,255,255,0.07)";
|
|
22
22
|
readonly light: "rgba(26,26,24,0.09)";
|
|
23
23
|
};
|
|
24
24
|
readonly raised: {
|
|
@@ -26,12 +26,12 @@ export declare const THEME_TOKENS: {
|
|
|
26
26
|
readonly light: "#FFFFFF";
|
|
27
27
|
};
|
|
28
28
|
readonly selected: {
|
|
29
|
-
readonly dark: "#
|
|
29
|
+
readonly dark: "#21211F";
|
|
30
30
|
readonly light: "rgba(26,26,24,0.07)";
|
|
31
31
|
};
|
|
32
32
|
readonly hover: {
|
|
33
|
-
readonly dark: "
|
|
34
|
-
readonly light: "rgba(26,26,24,0.
|
|
33
|
+
readonly dark: "rgba(255,255,255,0.04)";
|
|
34
|
+
readonly light: "rgba(26,26,24,0.045)";
|
|
35
35
|
};
|
|
36
36
|
readonly "line-soft": {
|
|
37
37
|
readonly dark: "#1C1C1A";
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
/** The built-in token values a theme overrides (design spec §2). */
|
|
4
4
|
export const THEME_TOKENS = {
|
|
5
5
|
color: {
|
|
6
|
-
"bg": { dark: "#0A0A0A", light: "#
|
|
6
|
+
"bg": { dark: "#0A0A0A", light: "#FDFDFC" },
|
|
7
7
|
"panel": { dark: "#111110", light: "#FFFFFF" },
|
|
8
8
|
"panel-2": { dark: "#0E0E0D", light: "#FCFBF9" },
|
|
9
|
-
"sidebar": { dark: "#
|
|
10
|
-
"sidebar-active": { dark: "
|
|
9
|
+
"sidebar": { dark: "#171716", light: "#EDECE7" },
|
|
10
|
+
"sidebar-active": { dark: "rgba(255,255,255,0.07)", light: "rgba(26,26,24,0.09)" },
|
|
11
11
|
"raised": { dark: "#141413", light: "#FFFFFF" },
|
|
12
|
-
"selected": { dark: "#
|
|
13
|
-
"hover": { dark: "
|
|
12
|
+
"selected": { dark: "#21211F", light: "rgba(26,26,24,0.07)" },
|
|
13
|
+
"hover": { dark: "rgba(255,255,255,0.04)", light: "rgba(26,26,24,0.045)" },
|
|
14
14
|
"line-soft": { dark: "#1C1C1A", light: "#E8E7E2" },
|
|
15
15
|
"line": { dark: "#2A2A28", light: "#D9D8D2" },
|
|
16
16
|
"line-strong": { dark: "#3A3A37", light: "#B5B5AE" },
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ExtensionPointRef } from "./extension-point.js";
|
|
2
|
+
import type { LocalizedName } from "./plugin-package.js";
|
|
3
|
+
import type { TriggerSubject } from "./triggers.js";
|
|
4
|
+
/** One fact of an event type: its value type and whether automations may filter on it. */
|
|
5
|
+
export interface TriggerFactDeclaration {
|
|
6
|
+
type: "string" | "number" | "boolean" | "string[]";
|
|
7
|
+
name: LocalizedName;
|
|
8
|
+
filterable: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** One event type an extension emits, shown when an org builds an automation. */
|
|
11
|
+
export interface TriggerEventDeclaration {
|
|
12
|
+
type: string;
|
|
13
|
+
name: LocalizedName;
|
|
14
|
+
/** Directed events wake one agent (`TriggerEvent.audience`) instead of every subscriber. */
|
|
15
|
+
directed: boolean;
|
|
16
|
+
facts: Record<string, TriggerFactDeclaration>;
|
|
17
|
+
}
|
|
18
|
+
/** What a `trigger-source@1` provider implements. */
|
|
19
|
+
export interface TriggerSource {
|
|
20
|
+
events(): TriggerEventDeclaration[];
|
|
21
|
+
/** Of `accountIds`, the accounts that may see `subject`. */
|
|
22
|
+
visible(args: {
|
|
23
|
+
orgId: string;
|
|
24
|
+
accountIds: string[];
|
|
25
|
+
subject: TriggerSubject;
|
|
26
|
+
config?: unknown;
|
|
27
|
+
}): Promise<string[]>;
|
|
28
|
+
/** A link a person can open for the subject, or null. */
|
|
29
|
+
subjectLink?(args: {
|
|
30
|
+
orgId: string;
|
|
31
|
+
subject: TriggerSubject;
|
|
32
|
+
}): Promise<string | null>;
|
|
33
|
+
}
|
|
34
|
+
/** Trigger source extension point ref. */
|
|
35
|
+
export declare const TRIGGER_SOURCE_EXTENSION_POINT: ExtensionPointRef;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ToolCallContext } from "./tool.js";
|
|
2
|
+
/** The value of one fact on a trigger event: filters compare facts, never free text. */
|
|
3
|
+
export type TriggerFactValue = string | number | boolean | string[];
|
|
4
|
+
/** What an event is about (a task, a document, ...). */
|
|
5
|
+
export interface TriggerSubject {
|
|
6
|
+
kind: string;
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Who caused an event: a tool call of the extension, or an account acting outside a call. */
|
|
12
|
+
export type TriggerCause = {
|
|
13
|
+
call: ToolCallContext;
|
|
14
|
+
} | {
|
|
15
|
+
accountId: string;
|
|
16
|
+
};
|
|
17
|
+
/** An event an extension emits through `ctx.triggers.emit`. */
|
|
18
|
+
export interface TriggerEvent {
|
|
19
|
+
orgId: string;
|
|
20
|
+
/** One of the types the extension declares in `permissions.triggers.emit`. */
|
|
21
|
+
type: string;
|
|
22
|
+
subject: TriggerSubject;
|
|
23
|
+
facts: Record<string, TriggerFactValue>;
|
|
24
|
+
/** Short text for the agent; at most {@link TRIGGER_SUMMARY_MAX_BYTES} UTF-8 bytes. */
|
|
25
|
+
summary: string;
|
|
26
|
+
/** Idempotency key: the same key for the same type and org emits once. */
|
|
27
|
+
dedupeKey: string;
|
|
28
|
+
cause?: TriggerCause;
|
|
29
|
+
/** A directed event: only this agent of this account is woken. */
|
|
30
|
+
audience?: {
|
|
31
|
+
accountId: string;
|
|
32
|
+
agentId: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface EventFilterClause {
|
|
36
|
+
fact: string;
|
|
37
|
+
op: "eq" | "in" | "contains";
|
|
38
|
+
value: TriggerFactValue;
|
|
39
|
+
}
|
|
40
|
+
/** A conjunction: every clause must match. An empty filter matches every event. */
|
|
41
|
+
export type EventFilter = EventFilterClause[];
|
|
42
|
+
/** `ctx.triggers` (requires `permissions.triggers`). */
|
|
43
|
+
export interface TriggersCtx {
|
|
44
|
+
emit(event: TriggerEvent): Promise<{
|
|
45
|
+
eventId: string;
|
|
46
|
+
duplicate: boolean;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export type TriggerErrorCode = "type_not_declared" | "invalid_event" | "org_disabled";
|
|
50
|
+
/** A {@link TriggersCtx} call was refused. */
|
|
51
|
+
export declare class TriggerError extends Error {
|
|
52
|
+
readonly code: TriggerErrorCode;
|
|
53
|
+
constructor(code: TriggerErrorCode, message: string, opts?: {
|
|
54
|
+
cause?: unknown;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export declare const TRIGGER_SUMMARY_MAX_BYTES = 4096;
|
|
58
|
+
/** The shape of a trigger event type name (also the entries of `permissions.triggers.emit`). */
|
|
59
|
+
export declare const TRIGGER_TYPE_RE: RegExp;
|
|
60
|
+
/** Most event types one extension may declare. */
|
|
61
|
+
export declare const TRIGGER_MAX_TYPES = 64;
|
|
62
|
+
/**
|
|
63
|
+
* Checks an event before it is stored; returns error codes (empty = valid): `type_not_declared`,
|
|
64
|
+
* `summary_too_long` (UTF-8 bytes), and `missing_<field>` for each empty required field.
|
|
65
|
+
*/
|
|
66
|
+
export declare function validateTriggerEvent(e: TriggerEvent, declared: readonly string[]): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Whether the facts satisfy every clause. A missing fact never matches. `eq` compares scalars (an
|
|
69
|
+
* array fact never matches); `in` takes an array value and matches a scalar fact contained in it;
|
|
70
|
+
* `contains` matches an array fact containing the scalar value.
|
|
71
|
+
*/
|
|
72
|
+
export declare function matchesFilter(filter: EventFilter, facts: Record<string, TriggerFactValue>): boolean;
|
package/dist/triggers.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** A {@link TriggersCtx} call was refused. */
|
|
2
|
+
export class TriggerError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message, opts) {
|
|
5
|
+
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
6
|
+
this.name = "TriggerError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const TRIGGER_SUMMARY_MAX_BYTES = 4096;
|
|
11
|
+
/** The shape of a trigger event type name (also the entries of `permissions.triggers.emit`). */
|
|
12
|
+
export const TRIGGER_TYPE_RE = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/;
|
|
13
|
+
/** Most event types one extension may declare. */
|
|
14
|
+
export const TRIGGER_MAX_TYPES = 64;
|
|
15
|
+
/**
|
|
16
|
+
* Checks an event before it is stored; returns error codes (empty = valid): `type_not_declared`,
|
|
17
|
+
* `summary_too_long` (UTF-8 bytes), and `missing_<field>` for each empty required field.
|
|
18
|
+
*/
|
|
19
|
+
export function validateTriggerEvent(e, declared) {
|
|
20
|
+
const errs = [];
|
|
21
|
+
const blank = (v) => typeof v !== "string" || v === "";
|
|
22
|
+
if (blank(e.orgId))
|
|
23
|
+
errs.push("missing_org_id");
|
|
24
|
+
if (blank(e.type))
|
|
25
|
+
errs.push("missing_type");
|
|
26
|
+
else if (!declared.includes(e.type))
|
|
27
|
+
errs.push("type_not_declared");
|
|
28
|
+
if (blank(e.subject?.kind))
|
|
29
|
+
errs.push("missing_subject_kind");
|
|
30
|
+
if (blank(e.subject?.id))
|
|
31
|
+
errs.push("missing_subject_id");
|
|
32
|
+
if (blank(e.subject?.title))
|
|
33
|
+
errs.push("missing_subject_title");
|
|
34
|
+
if (blank(e.dedupeKey))
|
|
35
|
+
errs.push("missing_dedupe_key");
|
|
36
|
+
if (typeof e.summary !== "string")
|
|
37
|
+
errs.push("missing_summary");
|
|
38
|
+
else if (new TextEncoder().encode(e.summary).length > TRIGGER_SUMMARY_MAX_BYTES)
|
|
39
|
+
errs.push("summary_too_long");
|
|
40
|
+
return errs;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether the facts satisfy every clause. A missing fact never matches. `eq` compares scalars (an
|
|
44
|
+
* array fact never matches); `in` takes an array value and matches a scalar fact contained in it;
|
|
45
|
+
* `contains` matches an array fact containing the scalar value.
|
|
46
|
+
*/
|
|
47
|
+
export function matchesFilter(filter, facts) {
|
|
48
|
+
return filter.every((c) => {
|
|
49
|
+
if (!Object.hasOwn(facts, c.fact))
|
|
50
|
+
return false;
|
|
51
|
+
const f = facts[c.fact];
|
|
52
|
+
if (f === undefined)
|
|
53
|
+
return false;
|
|
54
|
+
switch (c.op) {
|
|
55
|
+
case "eq":
|
|
56
|
+
return !Array.isArray(f) && !Array.isArray(c.value) && f === c.value;
|
|
57
|
+
case "in":
|
|
58
|
+
return (Array.isArray(c.value) &&
|
|
59
|
+
!Array.isArray(f) &&
|
|
60
|
+
typeof f === "string" &&
|
|
61
|
+
c.value.includes(f));
|
|
62
|
+
case "contains":
|
|
63
|
+
return (Array.isArray(f) &&
|
|
64
|
+
!Array.isArray(c.value) &&
|
|
65
|
+
typeof c.value === "string" &&
|
|
66
|
+
f.includes(c.value));
|
|
67
|
+
default:
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
package/dist/ui-parts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The ARIA / data states a part promises (client extensions spec §7.1). */
|
|
2
2
|
export type UiPartState = "aria-current" | "aria-selected" | "aria-expanded" | "aria-busy" | "aria-checked" | "aria-pressed" | "disabled";
|
|
3
3
|
/** Every part name of the catalog, in catalog order. */
|
|
4
|
-
export declare const UI_PART_NAMES: readonly ["shell", "sidebar", "sidebar.brand", "sidebar.item", "title-bar", "page-header", "thread", "message.user", "message.user.bubble", "message.assistant", "tool-row", "composer", "composer.box", "composer.options", "composer.send", "properties-panel", "section", "right-panel", "
|
|
4
|
+
export declare const UI_PART_NAMES: readonly ["shell", "sidebar", "sidebar.brand", "sidebar.item", "title-bar", "page-header", "thread", "message.user", "message.user.bubble", "message.assistant", "tool-row", "composer", "composer.box", "composer.options", "composer.send", "properties-panel", "section", "right-panel", "button", "button.primary", "card", "input", "dialog", "code-block", "menu", "segmented", "stat-card", "switch", "switch.knob", "org-avatar", "agent-chip", "image-placeholder"];
|
|
5
5
|
export type UiPartName = (typeof UI_PART_NAMES)[number];
|
|
6
6
|
/** One built-in element plugin CSS may select with `[data-cap-part~="<name>"]`. */
|
|
7
7
|
export interface UiPartSpec {
|
package/dist/ui-parts.js
CHANGED
|
@@ -18,7 +18,6 @@ export const UI_PART_NAMES = [
|
|
|
18
18
|
"properties-panel",
|
|
19
19
|
"section",
|
|
20
20
|
"right-panel",
|
|
21
|
-
"status-bar",
|
|
22
21
|
"button",
|
|
23
22
|
"button.primary",
|
|
24
23
|
"card",
|
|
@@ -221,16 +220,6 @@ export const UI_PARTS = [
|
|
|
221
220
|
zh: "占满高度的右侧窗格。",
|
|
222
221
|
},
|
|
223
222
|
},
|
|
224
|
-
{
|
|
225
|
-
name: "status-bar",
|
|
226
|
-
version: 1,
|
|
227
|
-
owner: ["packages/design/src/shell/status-bar.tsx"],
|
|
228
|
-
states: [],
|
|
229
|
-
description: {
|
|
230
|
-
en: "The status bar.",
|
|
231
|
-
zh: "状态栏。",
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
223
|
{
|
|
235
224
|
name: "button",
|
|
236
225
|
version: 1,
|