@serene-pub/sdk 0.6.0-pr-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 +202 -0
- package/NOTICE +17 -0
- package/README.md +368 -0
- package/dist/actions.d.ts +572 -0
- package/dist/actions.js +829 -0
- package/dist/annexFields.d.ts +234 -0
- package/dist/annexFields.js +413 -0
- package/dist/announce.d.ts +464 -0
- package/dist/announce.js +426 -0
- package/dist/attributes.d.ts +670 -0
- package/dist/attributes.js +904 -0
- package/dist/bands.d.ts +125 -0
- package/dist/bands.js +256 -0
- package/dist/builder.d.ts +683 -0
- package/dist/builder.js +677 -0
- package/dist/candidates.d.ts +109 -0
- package/dist/candidates.js +118 -0
- package/dist/capabilities.d.ts +744 -0
- package/dist/capabilities.js +679 -0
- package/dist/channels.d.ts +106 -0
- package/dist/channels.js +129 -0
- package/dist/clauses.d.ts +40 -0
- package/dist/clauses.js +43 -0
- package/dist/component.d.ts +33 -0
- package/dist/component.js +27 -0
- package/dist/componentBuild.d.ts +48 -0
- package/dist/componentBuild.js +84 -0
- package/dist/componentClient.d.ts +100 -0
- package/dist/componentClient.js +13 -0
- package/dist/componentImports.d.ts +51 -0
- package/dist/componentImports.js +106 -0
- package/dist/componentModule.d.ts +8 -0
- package/dist/componentModule.js +270 -0
- package/dist/componentWire.d.ts +130 -0
- package/dist/componentWire.js +280 -0
- package/dist/config.d.ts +295 -0
- package/dist/config.js +231 -0
- package/dist/connections.d.ts +89 -0
- package/dist/connections.js +131 -0
- package/dist/declarations.d.ts +290 -0
- package/dist/declarations.js +794 -0
- package/dist/descriptors.d.ts +1774 -0
- package/dist/descriptors.js +1329 -0
- package/dist/dev.d.ts +136 -0
- package/dist/dev.js +161 -0
- package/dist/document.d.ts +202 -0
- package/dist/document.js +312 -0
- package/dist/engines.d.ts +117 -0
- package/dist/engines.js +203 -0
- package/dist/eventMapLaws.d.ts +63 -0
- package/dist/eventMapLaws.js +128 -0
- package/dist/events.d.ts +554 -0
- package/dist/events.js +633 -0
- package/dist/executor.d.ts +771 -0
- package/dist/executor.js +1829 -0
- package/dist/extension.d.ts +448 -0
- package/dist/extension.js +315 -0
- package/dist/facets.d.ts +53 -0
- package/dist/facets.js +60 -0
- package/dist/foldedSections.d.ts +74 -0
- package/dist/foldedSections.js +161 -0
- package/dist/genres.d.ts +507 -0
- package/dist/genres.js +633 -0
- package/dist/guardedConnection.d.ts +138 -0
- package/dist/guardedConnection.js +341 -0
- package/dist/handlebarsReach.d.ts +122 -0
- package/dist/handlebarsReach.js +222 -0
- package/dist/hash.d.ts +146 -0
- package/dist/hash.js +166 -0
- package/dist/hookGrants.d.ts +47 -0
- package/dist/hookGrants.js +68 -0
- package/dist/hooks.d.ts +290 -0
- package/dist/hooks.js +113 -0
- package/dist/hostElements.d.ts +447 -0
- package/dist/hostElements.js +702 -0
- package/dist/i18n.d.ts +94 -0
- package/dist/i18n.js +123 -0
- package/dist/identity.d.ts +93 -0
- package/dist/identity.js +135 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +176 -0
- package/dist/layout.d.ts +194 -0
- package/dist/layout.js +40 -0
- package/dist/media.d.ts +202 -0
- package/dist/media.js +70 -0
- package/dist/messageBlocks.d.ts +487 -0
- package/dist/messageBlocks.js +683 -0
- package/dist/migration.d.ts +128 -0
- package/dist/migration.js +261 -0
- package/dist/names.d.ts +78 -0
- package/dist/names.js +136 -0
- package/dist/nodeInput.d.ts +399 -0
- package/dist/nodeInput.js +178 -0
- package/dist/participants.d.ts +291 -0
- package/dist/participants.js +252 -0
- package/dist/personGate.d.ts +62 -0
- package/dist/personGate.js +77 -0
- package/dist/pick.d.ts +84 -0
- package/dist/pick.js +103 -0
- package/dist/pluginHarness.d.ts +235 -0
- package/dist/pluginHarness.js +558 -0
- package/dist/pluginPermissions.d.ts +25 -0
- package/dist/pluginPermissions.js +97 -0
- package/dist/pluginRuleRef.d.ts +13 -0
- package/dist/pluginRuleRef.js +10 -0
- package/dist/predicates.d.ts +182 -0
- package/dist/predicates.js +249 -0
- package/dist/preview.d.ts +120 -0
- package/dist/preview.js +82 -0
- package/dist/promptBlocks.d.ts +130 -0
- package/dist/promptBlocks.js +197 -0
- package/dist/rankingDecisions.d.ts +60 -0
- package/dist/rankingDecisions.js +48 -0
- package/dist/receipt.d.ts +313 -0
- package/dist/receipt.js +60 -0
- package/dist/receiverRules.d.ts +24 -0
- package/dist/receiverRules.js +94 -0
- package/dist/refs.d.ts +117 -0
- package/dist/refs.js +137 -0
- package/dist/registry.d.ts +230 -0
- package/dist/registry.js +273 -0
- package/dist/review.d.ts +108 -0
- package/dist/review.js +97 -0
- package/dist/sampling.d.ts +152 -0
- package/dist/sampling.js +712 -0
- package/dist/scope.d.ts +65 -0
- package/dist/scope.js +128 -0
- package/dist/scripts.d.ts +243 -0
- package/dist/scripts.js +326 -0
- package/dist/sessionLayout.d.ts +339 -0
- package/dist/sessionLayout.js +503 -0
- package/dist/sessionSettings.d.ts +70 -0
- package/dist/sessionSettings.js +2 -0
- package/dist/settings.d.ts +501 -0
- package/dist/settings.js +604 -0
- package/dist/settingsSlot.d.ts +108 -0
- package/dist/settingsSlot.js +166 -0
- package/dist/shapes.d.ts +373 -0
- package/dist/shapes.js +408 -0
- package/dist/sheets.d.ts +165 -0
- package/dist/sheets.js +251 -0
- package/dist/statShapes.d.ts +96 -0
- package/dist/statShapes.js +112 -0
- package/dist/status.d.ts +103 -0
- package/dist/status.js +125 -0
- package/dist/storage.d.ts +145 -0
- package/dist/storage.js +33 -0
- package/dist/storyTime.d.ts +308 -0
- package/dist/storyTime.js +560 -0
- package/dist/surfaces.d.ts +501 -0
- package/dist/surfaces.js +292 -0
- package/dist/template.d.ts +312 -0
- package/dist/template.js +554 -0
- package/dist/templateCheck.d.ts +60 -0
- package/dist/templateCheck.js +516 -0
- package/dist/templateFit.d.ts +157 -0
- package/dist/templateFit.js +349 -0
- package/dist/templateIds.d.ts +138 -0
- package/dist/templateIds.js +144 -0
- package/dist/templateScopeAt.d.ts +131 -0
- package/dist/templateScopeAt.js +354 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.js +383 -0
- package/dist/tokenizers.d.ts +113 -0
- package/dist/tokenizers.js +184 -0
- package/dist/turnLock.d.ts +96 -0
- package/dist/turnLock.js +79 -0
- package/dist/turnOrder.d.ts +143 -0
- package/dist/turnOrder.js +128 -0
- package/dist/validate.d.ts +74 -0
- package/dist/validate.js +1399 -0
- package/dist/values.d.ts +212 -0
- package/dist/values.js +390 -0
- package/dist/variables.d.ts +493 -0
- package/dist/variables.js +662 -0
- package/dist/verdicts.d.ts +275 -0
- package/dist/verdicts.js +348 -0
- package/dist/widgetDecls.d.ts +88 -0
- package/dist/widgetDecls.js +119 -0
- package/dist/widgets.d.ts +1527 -0
- package/dist/widgets.js +208 -0
- package/dist/wire.d.ts +126 -0
- package/dist/wire.js +140 -0
- package/dist/worldinfo.d.ts +150 -0
- package/dist/worldinfo.js +212 -0
- package/host-elements.d.ts +914 -0
- package/package.json +67 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `defineExtension` — the one entry point a plugin author starts from (03, 09).
|
|
3
|
+
*
|
|
4
|
+
* Before this existed, the SDK could express a pipeline and nothing else. An author could
|
|
5
|
+
* build a spec but had nowhere to say *"this is my plugin, here are its lifecycle
|
|
6
|
+
* callbacks, its settings, its node definitions, its components, and the pipelines it
|
|
7
|
+
* ships."* That is the
|
|
8
|
+
* difference between authoring a pipeline and writing a plugin, and it is most of what
|
|
9
|
+
* "download the SDK" has to mean.
|
|
10
|
+
*
|
|
11
|
+
* Since D-1 it says the rest of it too — the **genres**, **surfaces**, **presets**,
|
|
12
|
+
* **configs**, **prompts** and declared **permissions** that were only sayable through
|
|
13
|
+
* `announce()`. One declaration, one build: `serene-pub build` emits a single manifest
|
|
14
|
+
* carrying both halves, and a package no longer has to choose which half of itself to
|
|
15
|
+
* ship. It is the one authoring entry: a package with no code at all declares itself
|
|
16
|
+
* here too — core's own catalog does — and `announcementOf()` compiles it to the
|
|
17
|
+
* announcement document a host syncs.
|
|
18
|
+
*
|
|
19
|
+
* Everything here is a **literal declaration**, because the compiler extracts it from the
|
|
20
|
+
* source without executing it (F6, 03 §3, 13/§30). A registration assembled at runtime is
|
|
21
|
+
* a lint error rather than a silent omission — the manifest has to be a complete statement
|
|
22
|
+
* of what a plugin can do, or the permission model is a guess.
|
|
23
|
+
*/
|
|
24
|
+
import type { WidgetDecl } from './layout.js';
|
|
25
|
+
import type { BuiltSpec } from './builder.js';
|
|
26
|
+
import type { Descriptor } from './descriptors.js';
|
|
27
|
+
import type { PluginSettings, SettingsSchema } from './settings.js';
|
|
28
|
+
import type { EventListener, LifecycleCallback, LifecycleMoment } from './hooks.js';
|
|
29
|
+
import type { Result } from './executor.js';
|
|
30
|
+
import { type TemplateSeed } from './templateIds.js';
|
|
31
|
+
import { type I18n } from './i18n.js';
|
|
32
|
+
import type { SpecDocument } from './document.js';
|
|
33
|
+
import { type SessionEventDecl } from './events.js';
|
|
34
|
+
import { type EventDeclarationInput, type StoredEventDeclaration, type ConfigDecl, type ConfigInput, type PresetDecl, type HookDeclaration, type PresetInput, type PromptDecl } from './announce.js';
|
|
35
|
+
import type { GenreDecl } from './genres.js';
|
|
36
|
+
import { type AnnexFieldDecl } from './annexFields.js';
|
|
37
|
+
import type { SurfacesDecl } from './surfaces.js';
|
|
38
|
+
import { type VariableDecl } from './variables.js';
|
|
39
|
+
import { type StoredSwapContribution, type SwapContribution } from './declarations.js';
|
|
40
|
+
/**
|
|
41
|
+
* The **handler** implementing a node definition (R-1). Data in, expected shape out; the executor is the only caller
|
|
42
|
+
* (01 §9). **Private** (the default) means only this extension's pipelines may use the
|
|
43
|
+
* node — not another package's, not one a person authors; **public** means any may, which
|
|
44
|
+
* is how peer composition happens — as a node on the spine, never a peer call mid-run
|
|
45
|
+
* (F10). The node's visibility is this, and only this (R62): the definition does not
|
|
46
|
+
* say `public` itself. Enforced at install, at publish and at the run.
|
|
47
|
+
* @experimental
|
|
48
|
+
*/
|
|
49
|
+
export interface HandlerDecl<D extends Descriptor<any, any, any> = Descriptor> {
|
|
50
|
+
readonly __decl: 'handler';
|
|
51
|
+
type: D;
|
|
52
|
+
visibility: 'private' | 'public';
|
|
53
|
+
handler: (input: any, ctx: any) => Result | Promise<Result>;
|
|
54
|
+
/**
|
|
55
|
+
* Always its own process. There is no in-process option, and that is a rule
|
|
56
|
+
* rather than a default.
|
|
57
|
+
*
|
|
58
|
+
* An extension hook running inside Serene Pub's process cannot be stopped —
|
|
59
|
+
* a runaway loop or a blocking call takes the whole application with it, and
|
|
60
|
+
* F36's promise that every hook invocation is bounded becomes unenforceable
|
|
61
|
+
* (13 §7h). It also shares the host's memory, so a crash is the host's crash
|
|
62
|
+
* and a leak is the host's leak.
|
|
63
|
+
*
|
|
64
|
+
* Kept as a field rather than dropped because the *value* still travels into
|
|
65
|
+
* the registry row, where install-time validation reads it without executing
|
|
66
|
+
* the plugin (F6). A manifest claiming anything else is refused there.
|
|
67
|
+
*/
|
|
68
|
+
runtime?: 'process';
|
|
69
|
+
}
|
|
70
|
+
/** @public */
|
|
71
|
+
export declare function handler<D extends Descriptor<any, any, any>>(definition: D | {
|
|
72
|
+
descriptor: D;
|
|
73
|
+
}, fn: HandlerDecl<D>['handler'], opts?: {
|
|
74
|
+
visibility?: 'private' | 'public';
|
|
75
|
+
}): HandlerDecl<D>;
|
|
76
|
+
/** @experimental */
|
|
77
|
+
export interface LifecycleCallbackDecl {
|
|
78
|
+
readonly __decl: 'lifecycle-callback';
|
|
79
|
+
moment: LifecycleMoment;
|
|
80
|
+
handler: LifecycleCallback;
|
|
81
|
+
timeoutMs?: number;
|
|
82
|
+
}
|
|
83
|
+
/** @experimental */
|
|
84
|
+
export declare const lifecycleCallback: (moment: LifecycleMoment, handler: LifecycleCallback, opts?: {
|
|
85
|
+
timeoutMs?: number;
|
|
86
|
+
}) => LifecycleCallbackDecl;
|
|
87
|
+
/**
|
|
88
|
+
* One subscription. **Many may register against one event** — several
|
|
89
|
+
* extensions, and several of one extension's listeners — so this is an entry in a
|
|
90
|
+
* list rather than a claim on a name.
|
|
91
|
+
*
|
|
92
|
+
* There is deliberately nothing here for ordering or for using your return
|
|
93
|
+
* value, and both absences are the same absence. Delivery is fire-and-forget
|
|
94
|
+
* (01 §9c, 11 §3): your return is dropped, and dispatch order is **declaration
|
|
95
|
+
* order** — the order you wrote your own subscriptions in, tie-broken across
|
|
96
|
+
* extensions by plugin id. A `priority` field would manufacture an ordering
|
|
97
|
+
* guarantee core does not give, and be a collision of its own the moment two
|
|
98
|
+
* extensions claimed the same number; a `kind: 'filter'` field would let one
|
|
99
|
+
* extension rewrite what the next one is told. Neither is a thing you can ask
|
|
100
|
+
* for, which is why neither is a thing you have to defend against.
|
|
101
|
+
* @experimental
|
|
102
|
+
*/
|
|
103
|
+
export interface EventListenerDecl {
|
|
104
|
+
readonly __decl: 'event-listener';
|
|
105
|
+
/** The event heard — a core event id, or a package's declared event (stored as its id). */
|
|
106
|
+
event: string;
|
|
107
|
+
handler: EventListener;
|
|
108
|
+
/**
|
|
109
|
+
* This subscription's own budget. Defaults to a small one, and is clamped by
|
|
110
|
+
* the host: an event's subscribers **share one budget** rather than each
|
|
111
|
+
* getting their own, so a long deadline here is a claim on how much of a
|
|
112
|
+
* shared ceiling you intend to spend, not a private allowance.
|
|
113
|
+
*/
|
|
114
|
+
timeoutMs?: number;
|
|
115
|
+
}
|
|
116
|
+
/** @public */
|
|
117
|
+
export declare const eventListener: (event: string | SessionEventDecl, handler: EventListener, opts?: {
|
|
118
|
+
timeoutMs?: number;
|
|
119
|
+
}) => EventListenerDecl;
|
|
120
|
+
/**
|
|
121
|
+
* The one unit of custom UI (§3.5, R25): a module the page's UI worker runs,
|
|
122
|
+
* placing elements from the host vocabulary (`SP_HOST_ELEMENTS`), which the
|
|
123
|
+
* host mirrors into the box it is mounted in. A {@link WidgetDecl} names one
|
|
124
|
+
* by `component`; a page mount point will name one the same way.
|
|
125
|
+
*
|
|
126
|
+
* It runs in a worker, never in the host's document: one worker per owner
|
|
127
|
+
* (core, or one plugin) per session page. Its only path to data is the
|
|
128
|
+
* component client's port; it imports only `COMPONENT_IMPORTS`.
|
|
129
|
+
* @experimental
|
|
130
|
+
*/
|
|
131
|
+
export interface ComponentDecl {
|
|
132
|
+
readonly __decl: 'component';
|
|
133
|
+
/** Unique within the package — a widget's `component` names it. */
|
|
134
|
+
slug: string;
|
|
135
|
+
/** What an admin sees it called — a string or a locale map (R-20). */
|
|
136
|
+
label: I18n;
|
|
137
|
+
/**
|
|
138
|
+
* The component's source — `.svelte`, `.ts` or `.js` — relative to the
|
|
139
|
+
* package root. `serene-pub build` compiles it into one module under
|
|
140
|
+
* `dist/plugin/components/`, and the manifest names that built file.
|
|
141
|
+
*/
|
|
142
|
+
entry: string;
|
|
143
|
+
/**
|
|
144
|
+
* Which adapter renders it (R35, R37): Svelte, compiled, and vanilla —
|
|
145
|
+
* plain DOM, which needs no compiler and proves the seam is not
|
|
146
|
+
* Svelte-shaped. Preact, and React on `preact/compat`, come after 1.0.
|
|
147
|
+
*/
|
|
148
|
+
framework: ComponentFramework;
|
|
149
|
+
/** Per-instance settings, delivered as a widget's are (`settings.v1`). */
|
|
150
|
+
settings?: SettingsSchema;
|
|
151
|
+
/**
|
|
152
|
+
* A clone records its upstream, so an update can be offered (R-fork):
|
|
153
|
+
* the upstream component's slug, its package's version, and — experimental
|
|
154
|
+
* (C6) — the `sourceHash` of the source it was cloned from (core's
|
|
155
|
+
* `dist/components/<slug>.source.json` carries it), so "the upstream
|
|
156
|
+
* changed since you cloned" is a hash comparison, not a version guess.
|
|
157
|
+
*/
|
|
158
|
+
basedOn?: {
|
|
159
|
+
component: string;
|
|
160
|
+
version: string;
|
|
161
|
+
sourceHash?: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/** The component frameworks SDK 1.0 ships (R35). The list grows; it never shrinks. @experimental */
|
|
165
|
+
export declare const COMPONENT_FRAMEWORKS: readonly ['svelte', 'vanilla'];
|
|
166
|
+
/** @experimental */
|
|
167
|
+
export type ComponentFramework = (typeof COMPONENT_FRAMEWORKS)[number];
|
|
168
|
+
/** @public */
|
|
169
|
+
export declare const component: (d: Omit<ComponentDecl, '__decl'>) => ComponentDecl;
|
|
170
|
+
/**
|
|
171
|
+
* The sandbox permissions a plugin declares, as against the ones the packager
|
|
172
|
+
* compiles from its calls. Two axes only: **storage**, a private row/file store
|
|
173
|
+
* with a quota, and **network**, an allowlist of hosts its Providers may reach.
|
|
174
|
+
*
|
|
175
|
+
* Nothing else belongs here. Resources and events are compiled — an event
|
|
176
|
+
* subscription is a call site the packager reads, so declaring one would let a
|
|
177
|
+
* manifest disagree with the code. A quota and a host cannot be read off a call
|
|
178
|
+
* site, which is the whole reason these two are declared.
|
|
179
|
+
* @experimental
|
|
180
|
+
*/
|
|
181
|
+
export interface DeclaredPermissions {
|
|
182
|
+
storage?: {
|
|
183
|
+
quotaBytes?: number;
|
|
184
|
+
};
|
|
185
|
+
network?: {
|
|
186
|
+
hosts?: string[];
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/** The quota band an author may ask for. An instance clamps into its own. @experimental */
|
|
190
|
+
export declare const MIN_STORAGE_QUOTA = 1024;
|
|
191
|
+
/** @experimental */
|
|
192
|
+
export declare const MAX_STORAGE_QUOTA: number;
|
|
193
|
+
/**
|
|
194
|
+
* What is wrong with a declared permission set, in the same words the CLI's
|
|
195
|
+
* sandbox-manifest compiler uses — a package that moves from a separate
|
|
196
|
+
* manifest to this field gets the same answer to the same mistake.
|
|
197
|
+
* @experimental
|
|
198
|
+
*/
|
|
199
|
+
export declare function permissionFindings(p: DeclaredPermissions | undefined): string[];
|
|
200
|
+
/**
|
|
201
|
+
* @experimental What the host hands a plugin's template engine for one
|
|
202
|
+
* render — data only; a render is a pure function of it.
|
|
203
|
+
*/
|
|
204
|
+
export interface TemplateEngineHookInput {
|
|
205
|
+
/** The template source, in this engine's language. */
|
|
206
|
+
template: string;
|
|
207
|
+
/** The variables the template renders against. */
|
|
208
|
+
variables: Record<string, unknown>;
|
|
209
|
+
/** The prompt format key the render is for, or `null` where none applies. */
|
|
210
|
+
promptFormat: string | null;
|
|
211
|
+
/**
|
|
212
|
+
* The completion template that format names, resolved — a prefix and a
|
|
213
|
+
* suffix per role — so an engine can wrap blocks the way core does.
|
|
214
|
+
* `null` where the caller had no row to resolve (a preview, an admin test).
|
|
215
|
+
*/
|
|
216
|
+
completionTemplate: Record<string, unknown> | null;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @experimental A plugin's template-engine render function: template and
|
|
220
|
+
* variables in, the rendered string out. Declared under
|
|
221
|
+
* `ExtensionDecl.templateEngines`, run in the sandbox as a task.
|
|
222
|
+
*/
|
|
223
|
+
export type TemplateEngineHook = (input: TemplateEngineHookInput) => string | Promise<string>;
|
|
224
|
+
/** @experimental */
|
|
225
|
+
export interface ExtensionDecl {
|
|
226
|
+
/** `vendor.plugin` — the owner segment of every id this plugin registers (F2). */
|
|
227
|
+
slug: string;
|
|
228
|
+
/** What the plugin is called where it is listed — a string or a locale map with `en` (R-20). */
|
|
229
|
+
name: I18n;
|
|
230
|
+
version: string;
|
|
231
|
+
description?: I18n;
|
|
232
|
+
/** Who publishes it, as the plugin list credits them. */
|
|
233
|
+
author?: string;
|
|
234
|
+
/** Where its source lives, when it is public. */
|
|
235
|
+
repo?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Supported SP range, separate from the SDK range (09) — npm-style
|
|
238
|
+
* (`{ 'serene-pub': '>=0.7 <0.8' }`). Version ranges and nothing else: a
|
|
239
|
+
* template engine this plugin ships is `templateEngines` (R1).
|
|
240
|
+
*/
|
|
241
|
+
engines?: {
|
|
242
|
+
'serene-pub'?: string;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Template engines this plugin ships, by engine id — each the function that
|
|
246
|
+
* renders a template in that language, run in the sandbox like every other
|
|
247
|
+
* hook (`{ 'acme.x:template/mustache@1': renderMustache }`).
|
|
248
|
+
*
|
|
249
|
+
* The id is `<slug>:template/<name>@<major>`, under this plugin's own
|
|
250
|
+
* namespace. The packager names each function's export and writes the map
|
|
251
|
+
* to the manifest's `templateEngines` as `{ '<engine id>': '<hook name>' }`;
|
|
252
|
+
* the host registers a forwarding renderer per entry. A render must be a
|
|
253
|
+
* pure function of its input — the host pins the clock and the RNG seed.
|
|
254
|
+
*/
|
|
255
|
+
templateEngines?: Record<string, TemplateEngineHook>;
|
|
256
|
+
settings?: PluginSettings<any>;
|
|
257
|
+
/**
|
|
258
|
+
* The code this plugin runs: node definitions with the handlers that
|
|
259
|
+
* implement them (`handler()`), lifecycle callbacks and event listeners.
|
|
260
|
+
*/
|
|
261
|
+
handlers?: Array<HandlerDecl<any> | LifecycleCallbackDecl | EventListenerDecl>;
|
|
262
|
+
/**
|
|
263
|
+
* The hooks this package defines — points where other authored code may
|
|
264
|
+
* run, by key (namespaced `<slug>:hook/<key>` in the announcement). Core
|
|
265
|
+
* declares its own here. A plugin's do not reach its manifest yet, so the
|
|
266
|
+
* packager refuses them until the manifest carries declared points.
|
|
267
|
+
*/
|
|
268
|
+
hooks?: Record<string, HookDeclaration>;
|
|
269
|
+
/**
|
|
270
|
+
* Events this package declares and who may record them: for each, the
|
|
271
|
+
* event (`defineSessionEvent(…)`), the genre it belongs to, and the
|
|
272
|
+
* subjects whose pipelines may record it — `{ spec, key }` picks, event
|
|
273
|
+
* ids of the genre, spec values, or `'any'`. A pipeline outside that list
|
|
274
|
+
* is refused when it records the event.
|
|
275
|
+
*/
|
|
276
|
+
events?: EventDeclarationInput[];
|
|
277
|
+
components?: ComponentDecl[];
|
|
278
|
+
/**
|
|
279
|
+
* The widgets this package offers (R71) — `widget({ … })` values, each
|
|
280
|
+
* naming one of `components` and optionally scoped to genres. A genre
|
|
281
|
+
* withholds any of them by value (`omitWidgets`); a session offers every
|
|
282
|
+
* widget scoped to its genre or to all. The instance knows each under this
|
|
283
|
+
* package's namespace (`<slug>:<id>`).
|
|
284
|
+
*/
|
|
285
|
+
widgets?: WidgetDecl[];
|
|
286
|
+
/**
|
|
287
|
+
* This package's **annex declaration** (ruling 2026-09-26): every key it
|
|
288
|
+
* keeps in its session annex document, declared once with `annexField()`
|
|
289
|
+
* — the shape its value must have, who may see it (`see`) and, when a
|
|
290
|
+
* person may set it, who (`act`). The single source of truth: your
|
|
291
|
+
* pipelines' `set-session-annex` steps may write only these keys, and the
|
|
292
|
+
* audience stored with a value is the field's `see`. A field with `act`
|
|
293
|
+
* is set from a widget with `invoke(annexFieldAction('<slug>', key), {
|
|
294
|
+
* payload: { value } })` — core's one pipeline writes it. A field only for
|
|
295
|
+
* one genre's sessions takes `genre`.
|
|
296
|
+
* @experimental
|
|
297
|
+
*/
|
|
298
|
+
annexFields?: AnnexFieldDecl[];
|
|
299
|
+
/**
|
|
300
|
+
* Context variables this package declares (`definePluginVariable()`
|
|
301
|
+
* values), for an instance to register. A variable a plugin defines exists
|
|
302
|
+
* only in the plugin's own process until it travels in the manifest — so a
|
|
303
|
+
* band whose variable an instance never heard of is refused at install.
|
|
304
|
+
*
|
|
305
|
+
* **You rarely list one here.** Every variable a band of your handlers'
|
|
306
|
+
* definitions declares (`Descriptor.bands`) is collected for you — a band
|
|
307
|
+
* is already a value holding its variable, and a list you had to keep in
|
|
308
|
+
* step with it would be the list that goes stale. Name a variable here
|
|
309
|
+
* when nothing's `bands` holds it: one a shipped layout or template renders
|
|
310
|
+
* on its own. Ids sit under this package's namespace (`<slug>:var/…`);
|
|
311
|
+
* `core:` and another package's namespace are refused.
|
|
312
|
+
*
|
|
313
|
+
* Additive: a package declaring none emits the manifest it did before.
|
|
314
|
+
* @experimental
|
|
315
|
+
*/
|
|
316
|
+
variables?: VariableDecl[];
|
|
317
|
+
/** Pipelines shipped with the plugin — built specs, or documents already compiled. Compiled at build time (F6). */
|
|
318
|
+
pipelines?: Array<BuiltSpec | SpecDocument>;
|
|
319
|
+
/**
|
|
320
|
+
* Genres this plugin declares (24 §3, D-1) — a genre is a package-level
|
|
321
|
+
* declaration like a pipeline, so it belongs where the package is declared.
|
|
322
|
+
*
|
|
323
|
+
* Before D-1 a genre could only be declared through `announce()`, and a
|
|
324
|
+
* package with both a genre and its own node definitions had to export two
|
|
325
|
+
* declarations and build only one of them: the artifact carried the genre
|
|
326
|
+
* and not the handlers, or the handlers and not the genre. Every genre
|
|
327
|
+
* plugin is that package.
|
|
328
|
+
*
|
|
329
|
+
* Ids sit under the plugin's slug on the same terms a definition id does —
|
|
330
|
+
* `showcase.battleship:genre/battleship`, never somebody else's namespace.
|
|
331
|
+
* Referencing another package's genre is done from a spec's input binding,
|
|
332
|
+
* which is a reference rather than a claim of ownership. And a genre needs
|
|
333
|
+
* exactly one create pipeline in `pipelines`, so the two fields are checked
|
|
334
|
+
* against each other rather than separately.
|
|
335
|
+
*/
|
|
336
|
+
genres?: GenreDecl[];
|
|
337
|
+
/**
|
|
338
|
+
* Frame surfaces this plugin ships (20 §12, 21 §7): documents an instance
|
|
339
|
+
* mounts in opaque-origin iframes. Declared, never discovered — an instance
|
|
340
|
+
* renders what the manifest says and `serene-pub ui` renders the same list,
|
|
341
|
+
* so a surface a modder previewed is a surface an instance will offer.
|
|
342
|
+
*
|
|
343
|
+
* Distinct from `components`, and the difference is a trust decision: a
|
|
344
|
+
* frame gets a document and a MessageChannel, a component gets the host's
|
|
345
|
+
* own DOM.
|
|
346
|
+
*/
|
|
347
|
+
surfaces?: SurfacesDecl;
|
|
348
|
+
/** Named configurations over this plugin's specs — typed deltas (24 §7), made by `config()`. */
|
|
349
|
+
configs?: ConfigInput<any>[];
|
|
350
|
+
/**
|
|
351
|
+
* Presets: which pipelines a session of a genre runs. Each binds spec
|
|
352
|
+
* values on the events their inlet locks answer.
|
|
353
|
+
*/
|
|
354
|
+
presets?: PresetInput[];
|
|
355
|
+
/** Authored prose for a node's prompts slot, shipped as rows (24 T6b). */
|
|
356
|
+
prompts?: PromptDecl[];
|
|
357
|
+
/**
|
|
358
|
+
* This plugin's definitions, offered on another package's swappable nodes —
|
|
359
|
+
* e.g. a turn strategy on chat's turn-order spec, node
|
|
360
|
+
* `decide.rules.strategy`. The node key is checked against a spec value
|
|
361
|
+
* here; the instance checks exposure and fit at install.
|
|
362
|
+
*/
|
|
363
|
+
swaps?: SwapContribution[];
|
|
364
|
+
/**
|
|
365
|
+
* What this plugin asks the sandbox for (12 §6): a storage quota, a network
|
|
366
|
+
* allowlist. **Declared, because nothing else can compile them** — the
|
|
367
|
+
* packager derives the rest of the permission list from what the code
|
|
368
|
+
* actually calls, but a quota is a number and a host is a name, and neither
|
|
369
|
+
* appears in a call site.
|
|
370
|
+
*
|
|
371
|
+
* A declaration is a request, never a grant: an instance clamps the quota
|
|
372
|
+
* into its own band, an administrator may deny any single entry, and until
|
|
373
|
+
* somebody has looked at it the plugin runs with the grant refused. A
|
|
374
|
+
* declaration also cannot subtract — what the static scan compiled from the
|
|
375
|
+
* code is in the manifest whether this field mentions it or not.
|
|
376
|
+
*
|
|
377
|
+
* Folded in here so a package declares its permissions in the one place it
|
|
378
|
+
* declares everything else. The separate `ManifestInput` the CLI's sandbox
|
|
379
|
+
* compiler accepts still works for a package that has not moved.
|
|
380
|
+
*/
|
|
381
|
+
permissions?: DeclaredPermissions;
|
|
382
|
+
/**
|
|
383
|
+
* Template rows shipped with the plugin — prompts, context templates and
|
|
384
|
+
* variable layouts, each under an owner-namespaced **template id** (R19).
|
|
385
|
+
*
|
|
386
|
+
* Beside `pipelines` because that is the gap: a plugin could ship a spec
|
|
387
|
+
* whose configuration points at a prompt, and had no way to ship the prompt.
|
|
388
|
+
* The instance projects these the way it projects a `preset()` — created on
|
|
389
|
+
* enable, immutable to users, **marked withdrawn rather than deleted** when
|
|
390
|
+
* the plugin goes, because a pipeline's stored configuration holds the row's
|
|
391
|
+
* id and deleting it would leave that configuration pointing at nothing the
|
|
392
|
+
* moment somebody switched an extension off.
|
|
393
|
+
*
|
|
394
|
+
* A new major of a template is a NEW entry under a new id; the old id keeps
|
|
395
|
+
* resolving to the row every spec pinned to it was written against.
|
|
396
|
+
*/
|
|
397
|
+
templates?: readonly TemplateSeed[];
|
|
398
|
+
/**
|
|
399
|
+
* Dependencies on **public handlers** other plugins expose. Definition-level pins
|
|
400
|
+
* only; runtime peer invocation is banned (F10, 01 §9b).
|
|
401
|
+
*/
|
|
402
|
+
peerTypes?: string[];
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* What `defineExtension()` returns: the declaration with every reference read
|
|
406
|
+
* down to its id — the shapes the packager writes into the manifest.
|
|
407
|
+
* @experimental
|
|
408
|
+
*/
|
|
409
|
+
export interface Extension extends Omit<ExtensionDecl, 'configs' | 'presets' | 'swaps' | 'events'> {
|
|
410
|
+
readonly __extension: true;
|
|
411
|
+
configs?: ConfigDecl[];
|
|
412
|
+
presets?: PresetDecl[];
|
|
413
|
+
swaps?: StoredSwapContribution[];
|
|
414
|
+
events?: StoredEventDeclaration[];
|
|
415
|
+
}
|
|
416
|
+
/** @experimental */
|
|
417
|
+
export declare class ExtensionError extends Error {
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Declare a plugin. Validated here rather than at install, because an error an author
|
|
421
|
+
* sees while writing costs a minute and the same error at install costs a support thread.
|
|
422
|
+
* @public
|
|
423
|
+
*/
|
|
424
|
+
export declare function defineExtension(d: ExtensionDecl): Extension;
|
|
425
|
+
/** @experimental */
|
|
426
|
+
export declare const handlersOf: (e: Extension) => HandlerDecl<any>[];
|
|
427
|
+
/** @experimental */
|
|
428
|
+
export declare const lifecycleCallbacksOf: (e: Extension) => LifecycleCallbackDecl[];
|
|
429
|
+
/** @experimental */
|
|
430
|
+
export declare const eventListenersOf: (e: Extension) => EventListenerDecl[];
|
|
431
|
+
/**
|
|
432
|
+
* Every variable a package declares, as its manifest carries them: the
|
|
433
|
+
* `variables` list first, then each variable a band of its handlers'
|
|
434
|
+
* definitions holds (`Descriptor.bands`) — a band is a value holding its
|
|
435
|
+
* variable, so the author never lists it twice. One entry per distinct
|
|
436
|
+
* declaration: the same variable reached twice (two definitions declaring
|
|
437
|
+
* one band) is one entry; one id with two different contents stays two, and
|
|
438
|
+
* `pluginVariableFindings` refuses it.
|
|
439
|
+
* @experimental
|
|
440
|
+
*/
|
|
441
|
+
export declare function variablesOf(e: Pick<ExtensionDecl, 'variables' | 'handlers'>): VariableDecl[];
|
|
442
|
+
/**
|
|
443
|
+
* The bindings map the executor wants, built from the declaration. So an author's tests
|
|
444
|
+
* run their real handlers rather than a hand-maintained parallel map that drifts.
|
|
445
|
+
* @experimental
|
|
446
|
+
*/
|
|
447
|
+
export declare function bindingsOf(e: Extension): Record<string, HandlerDecl<any>['handler']>;
|
|
448
|
+
//# sourceMappingURL=extension.d.ts.map
|