@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.
Files changed (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
@@ -0,0 +1,290 @@
1
+ /**
2
+ * The three kinds of extension callable and their injected surfaces (01 §9, F10, F32).
3
+ *
4
+ * A **hook** is a declared point where authored code may run (NOMENCLATURE §12); the
5
+ * three callables are named for what they are (R-1, ruled 2026-09-14): a **handler**
6
+ * implements a node definition, a **lifecycle callback** answers a core moment, an
7
+ * **event listener** answers a core event. 01's *pipeline hook* / *lifecycle hook* /
8
+ * *event hook* are the same three under the old word; the code moved 2026-09-16 (U3).
9
+ *
10
+ * The rules are enforced by *what is in the object*, not by a document someone reads.
11
+ * A capability that isn't on the surface cannot be called, which is why these are
12
+ * types rather than a checklist.
13
+ */
14
+ import type { Result } from './executor.js';
15
+ import type { ExtensionStorage } from './storage.js';
16
+ /**
17
+ * Log severities.
18
+ *
19
+ * Was `'info' | 'warn'`, which left an extension no way to say a thing had
20
+ * actually failed — so failures were logged as warnings and became invisible in
21
+ * exactly the situation a log exists for. `debug` is the other half of the same
22
+ * problem: without it, authors log at `info` and users get noise.
23
+ * @experimental
24
+ */
25
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
26
+ /**
27
+ * Data in, expected shape out; the executor is the only caller. Private = only the
28
+ * owning extension's specs may pin it. Public = any spec may, which is how peer
29
+ * composition happens — as a node on the spine, never a peer call mid-run (F10).
30
+ *
31
+ * Both are enumerated in the manifest. Listing private ones costs nothing and the
32
+ * manifest is already the audit surface, since permissions are compiled from SDK
33
+ * usage (13 §7c).
34
+ * @experimental
35
+ */
36
+ export interface HandlerRules {
37
+ kind: 'pipeline';
38
+ definitionId: string;
39
+ visibility: 'private' | 'public';
40
+ }
41
+ /**
42
+ * `ctx.fetch` is **permissioned**, and unlike everything else on a hook surface
43
+ * it can be absent at runtime even though the type says it is there.
44
+ *
45
+ * The manifest must declare a host allowlist — `permissions.network.hosts`, each
46
+ * entry an exact host, a `*.suffix` / bare `*` wildcard, optionally pinned to a
47
+ * `:port` — and the packager refuses a `network` declaration with no hosts. Install
48
+ * stores that declaration; an **admin reviews it host by host** and can deny any
49
+ * single one without killing the rest, so the allowlist the host enforces is the
50
+ * *effective* grant (declared − denied), never the manifest. A hook that declared
51
+ * nothing, or whose hosts were all denied, gets a `ctx.fetch` that refuses every
52
+ * call — the capability is never ambient.
53
+ *
54
+ * The host, not the guest, enforces: http(s) only; the host must match the
55
+ * allowlist and (for a bare host or wildcard) use a default web port; redirects
56
+ * are followed by the host and **re-checked at every hop**; a name that resolves
57
+ * to a loopback/private/link-local address is refused unless an admin allowlisted
58
+ * that IP literal or `localhost` outright; and no request may *start* after
59
+ * `ctx.signal` fires. Every refusal throws — none of them come back as a response.
60
+ *
61
+ * Two further facts an author needs before reaching for it:
62
+ * - **It is async**, and therefore SES-only. A plugin pinned to the QuickJS
63
+ * backend gets a `ctx.fetch` that throws "network (fetch) requires the SES
64
+ * backend", the same way a WebAssembly plugin is SES-only.
65
+ * - **It is not a way to call a model.** Model work belongs to a Provider node,
66
+ * which is what gets it a receipt, a budget and the review gate; see
67
+ * `SCHEDULED_WORK_PATH` and the forbidden list below.
68
+ */
69
+ /**
70
+ * Request options for `ctx.fetch` — the JSON-serializable subset of `RequestInit`
71
+ * the host actually reads, and deliberately not `RequestInit` itself: the options
72
+ * cross the sandbox boundary as JSON, so a `Headers`, a `Blob`, a `FormData`, a
73
+ * stream or an `AbortSignal` cannot make the trip. A field not named here is
74
+ * dropped in transit rather than honoured, which is why they are not typed as
75
+ * accepted.
76
+ * @experimental
77
+ */
78
+ export interface HookFetchInit {
79
+ /** HTTP method. Defaults to GET. */
80
+ method?: string;
81
+ /** Headers as a plain object. Dropped on a cross-origin redirect hop, so an
82
+ * `Authorization` header never rides to a host the author did not address. */
83
+ headers?: Record<string, string>;
84
+ /** Body, sent as text. */
85
+ body?: string;
86
+ }
87
+ /**
88
+ * What `ctx.fetch` resolves to: the response flattened to plain data.
89
+ *
90
+ * **Not** a web `Response` — nothing live crosses the sandbox boundary, so there
91
+ * is no `.json()`, no `.text()`, no body stream and no `Headers` instance. The
92
+ * body has already been read for you.
93
+ * @experimental
94
+ */
95
+ export interface HookFetchResponse {
96
+ status: number;
97
+ /** `status` in 200–299, precomputed the way `Response.ok` is. */
98
+ ok: boolean;
99
+ /** Response headers flattened to a plain object, names lower-cased. */
100
+ headers: Record<string, string>;
101
+ /** The whole response body, already read as text. Parse it yourself. */
102
+ body: string;
103
+ }
104
+ /**
105
+ * What arrives as an event listener's **first argument**.
106
+ *
107
+ * An envelope rather than the bare payload, because one exported hook may be
108
+ * subscribed to more than one event — the manifest's `eventHooks` is a list of
109
+ * subscriptions, not a map — so a hook that could not tell which occurrence it
110
+ * was answering would need one export per event to find out.
111
+ * @experimental
112
+ */
113
+ export interface EventListenerInput<T = unknown> {
114
+ /** The event that fired, exactly as the subscription pinned it. */
115
+ event: string;
116
+ /**
117
+ * The occurrence, snapshotted at emit time (11 §3) — a hook never reads live
118
+ * state through this.
119
+ *
120
+ * Read-only in the sense that matters: mutating it, or returning something
121
+ * else in its place, changes nothing for the subscribers after you and
122
+ * nothing for the action that emitted it. An event states what happened.
123
+ */
124
+ payload: T;
125
+ }
126
+ /**
127
+ * What an event listener finds on `ctx`: exactly the members the grant table
128
+ * (`hookGrants.ts`) gives the `event` kind — the base four and storage. No
129
+ * network: `ctx.fetch` is an oracle's alone, and a listener that needs the
130
+ * network asks an oracle to do it as a node.
131
+ * @experimental
132
+ */
133
+ export interface EventListenerSurface {
134
+ /** A deterministic stream per call. `Math.random` is frozen in the SES
135
+ * sandbox, so this is the only randomness a listener has. */
136
+ random(): number;
137
+ /** The fan-out's pinned clock: every listener of one occurrence reads the
138
+ * same instant. Use it instead of `Date.now()`. */
139
+ now(): number;
140
+ log(level: LogLevel, message: string, detail?: unknown): void;
141
+ /** The extension's own rows and files — query, write, delete, and ask how
142
+ * much room is left. See storage.ts for why all four are needed. */
143
+ storage: ExtensionStorage;
144
+ signal: AbortSignal;
145
+ }
146
+ /**
147
+ * What a lifecycle callback finds on `ctx`: exactly the members the grant table
148
+ * (`hookGrants.ts`) gives the `lifecycle` kind — the base four and storage, the
149
+ * same as an event listener's.
150
+ *
151
+ * Absent, and for one reason: a lifecycle callback may not call a Provider and
152
+ * may not trigger a pipeline, so **scheduled model work subscribes to
153
+ * `core:event/schedule-tick@1` instead** — which gets it a receipt, a budget and
154
+ * the review gate, and puts it on the consent screen. A lifecycle callback doing
155
+ * that work would have had none of the four.
156
+ * @experimental
157
+ */
158
+ export interface LifecycleCallbackSurface {
159
+ /** A deterministic stream per call — see {@link EventListenerSurface.random}. */
160
+ random(): number;
161
+ /** The call's pinned clock — see {@link EventListenerSurface.now}. */
162
+ now(): number;
163
+ log(level: LogLevel, message: string, detail?: unknown): void;
164
+ /** The extension's own rows and files. */
165
+ storage: ExtensionStorage;
166
+ signal: AbortSignal;
167
+ }
168
+ /**
169
+ * The moments a lifecycle callback may be registered against:
170
+ *
171
+ * - `startup` — at boot, before the ready-gate opens.
172
+ * - `load` — declared, and not called yet (INTEGRATING.md §5c, Gaps).
173
+ * - `enable` — after the plugin is switched on.
174
+ * - `disable` — before it is switched off. Bounded; a failure never stops the switch.
175
+ * - `update` — once, after a reinstall replaced its bundle, on the new bundle's
176
+ * first run. Its input is {@link LifecycleUpdateInput}.
177
+ * - `uninstall` — before its rows and files are removed. Bounded.
178
+ * - `shutdown` — during the app's graceful shutdown. Bounded; never holds up exit.
179
+ *
180
+ * Every moment runs with the lifecycle grants and the lifecycle timeout, and a
181
+ * callback that throws or overruns is logged and recorded, never fatal.
182
+ *
183
+ * `sidecarSpawn` and `scheduled` were declared here once and never called.
184
+ * They are gone until something needs them, and the plugin compiler refuses a
185
+ * callback that names either one (`E_LIFECYCLE_MOMENT_UNSUPPORTED`). Scheduled
186
+ * work subscribes to `core:event/schedule-tick@1` ({@link SCHEDULED_WORK_PATH}).
187
+ * @experimental
188
+ */
189
+ export declare const LIFECYCLE_MOMENTS: readonly ['load', 'startup', 'shutdown', 'enable', 'disable', 'update',
190
+ /**
191
+ * The extension is being removed. Its last chance to clean up.
192
+ *
193
+ * Without this there was no such chance, and combined with a storage API
194
+ * that had no delete, an uninstalled extension's data was immortal — the
195
+ * same orphan problem the media cleanup tool exists to solve, one layer up.
196
+ *
197
+ * Best-effort by construction: the host removes the extension's namespace
198
+ * afterwards regardless, so a hook that throws, hangs or was never
199
+ * registered costs nothing. It exists for the work core *cannot* do on an
200
+ * extension's behalf — retiring a sidecar's external state, revoking a
201
+ * token it issued — not for deleting its own rows.
202
+ */
203
+ 'uninstall'];
204
+ /** One of {@link LIFECYCLE_MOMENTS}. @experimental */
205
+ export type LifecycleMoment = (typeof LIFECYCLE_MOMENTS)[number];
206
+ /**
207
+ * What the `update` moment's callback is sent: the version its bundle replaced
208
+ * and the version now running. Every other moment is sent an empty object.
209
+ * @experimental
210
+ */
211
+ export interface LifecycleUpdateInput {
212
+ previousVersion: string;
213
+ version: string;
214
+ }
215
+ /**
216
+ * A subscriber to a core event: **`(input, ctx)`**, like every other hook.
217
+ *
218
+ * `input` is the envelope above and `ctx` is the surface — the two arguments
219
+ * both sandboxes have always called a hook with. It was typed for a while as
220
+ * taking the surface alone, with the occurrence read back off it through a
221
+ * `readEvent()` method no runtime ever endowed; an author who followed that
222
+ * type called a function that was not there.
223
+ *
224
+ * ## Many hooks may register against one event
225
+ *
226
+ * A subscription is one entry in the manifest's `eventHooks` list, so several
227
+ * extensions — and several of one extension's hooks — can answer the same
228
+ * occurrence. Three things follow, and an author should know all three:
229
+ *
230
+ * - **You are isolated.** Throwing, overrunning or being stopped costs you
231
+ * your own call and nothing else: no sibling's result changes, no sibling's
232
+ * storage rolls back with yours, and the action that caused the event still
233
+ * succeeds (01 §9c).
234
+ * - **You cannot rely on order, and you cannot rely on being alone.** Dispatch
235
+ * order is **declaration order** — the order you wrote your own
236
+ * subscriptions in, tie-broken across extensions by plugin id — so a bug
237
+ * reproduces, but nothing about completion order is promised (11 §3). There
238
+ * is no `priority` to raise: it would promise a sequencing core declines to
239
+ * give, and be its own collision the moment two extensions claimed one
240
+ * number.
241
+ * - **Your return is ignored.** Delivery is fire-and-forget, so there is no
242
+ * opt-in that would let your return rewrite what a sibling — or the action
243
+ * that emitted the event — is given. Transforming a value is what a script
244
+ * chain and a pipeline node hook are for.
245
+ *
246
+ * Returning `halt(reason)` is the normal way to say "not applicable to me", and
247
+ * is a success rather than a failure (11 §3).
248
+ * @experimental
249
+ */
250
+ export type EventListener = (input: EventListenerInput, ctx: EventListenerSurface) => Result | Promise<Result>;
251
+ /**
252
+ * A core-invoked lifecycle callback: **`(input, ctx)`**, like every other callable.
253
+ *
254
+ * `ctx` is the surface above — argument **1**, not argument 0. This was typed
255
+ * for a while as taking the surface alone, while both sandboxes called it
256
+ * `__fn(__input, ctx)` exactly as they call every other hook; an author who
257
+ * followed the type read `storage` and `log` off the input envelope and found
258
+ * neither. The same defect `EventListener` carried, fixed the same way and in the
259
+ * same direction — towards what the runtimes have always done.
260
+ *
261
+ * `input` is typed `unknown` because it depends on the moment: `update` is sent
262
+ * a {@link LifecycleUpdateInput}, and every other moment an empty object. The
263
+ * moment itself is not in it — a hook is registered *against* a moment, so it
264
+ * already knows which one it is. Deliberately not given a shape it does not
265
+ * have; that is the mistake this signature exists to undo.
266
+ * @experimental
267
+ */
268
+ export type LifecycleCallback = (input: unknown, ctx: LifecycleCallbackSurface) => Result | Promise<Result>;
269
+ /**
270
+ * F32, checked rather than documented. The probe reads the surface an implementation
271
+ * actually hands out — a regression that adds `callProvider` back fails here instead
272
+ * of shipping.
273
+ * @experimental
274
+ */
275
+ export declare function assertHookSurface(kind: 'event' | 'lifecycle', surface: object): {
276
+ ok: true;
277
+ } | {
278
+ ok: false;
279
+ found: string[];
280
+ };
281
+ /**
282
+ * The scheduled-work path, stated as code so it is discoverable from the SDK rather
283
+ * than only from 13 §7c.
284
+ * @experimental
285
+ */
286
+ export declare const SCHEDULED_WORK_PATH: {
287
+ readonly instead: 'core:event/schedule-tick@1';
288
+ readonly because: string;
289
+ };
290
+ //# sourceMappingURL=hooks.d.ts.map
package/dist/hooks.js ADDED
@@ -0,0 +1,113 @@
1
+ /**
2
+ * The three kinds of extension callable and their injected surfaces (01 §9, F10, F32).
3
+ *
4
+ * A **hook** is a declared point where authored code may run (NOMENCLATURE §12); the
5
+ * three callables are named for what they are (R-1, ruled 2026-09-14): a **handler**
6
+ * implements a node definition, a **lifecycle callback** answers a core moment, an
7
+ * **event listener** answers a core event. 01's *pipeline hook* / *lifecycle hook* /
8
+ * *event hook* are the same three under the old word; the code moved 2026-09-16 (U3).
9
+ *
10
+ * The rules are enforced by *what is in the object*, not by a document someone reads.
11
+ * A capability that isn't on the surface cannot be called, which is why these are
12
+ * types rather than a checklist.
13
+ */
14
+ /**
15
+ * The moments a lifecycle callback may be registered against:
16
+ *
17
+ * - `startup` — at boot, before the ready-gate opens.
18
+ * - `load` — declared, and not called yet (INTEGRATING.md §5c, Gaps).
19
+ * - `enable` — after the plugin is switched on.
20
+ * - `disable` — before it is switched off. Bounded; a failure never stops the switch.
21
+ * - `update` — once, after a reinstall replaced its bundle, on the new bundle's
22
+ * first run. Its input is {@link LifecycleUpdateInput}.
23
+ * - `uninstall` — before its rows and files are removed. Bounded.
24
+ * - `shutdown` — during the app's graceful shutdown. Bounded; never holds up exit.
25
+ *
26
+ * Every moment runs with the lifecycle grants and the lifecycle timeout, and a
27
+ * callback that throws or overruns is logged and recorded, never fatal.
28
+ *
29
+ * `sidecarSpawn` and `scheduled` were declared here once and never called.
30
+ * They are gone until something needs them, and the plugin compiler refuses a
31
+ * callback that names either one (`E_LIFECYCLE_MOMENT_UNSUPPORTED`). Scheduled
32
+ * work subscribes to `core:event/schedule-tick@1` ({@link SCHEDULED_WORK_PATH}).
33
+ * @experimental
34
+ */
35
+ export const LIFECYCLE_MOMENTS = [
36
+ 'load',
37
+ 'startup',
38
+ 'shutdown',
39
+ 'enable',
40
+ 'disable',
41
+ 'update',
42
+ /**
43
+ * The extension is being removed. Its last chance to clean up.
44
+ *
45
+ * Without this there was no such chance, and combined with a storage API
46
+ * that had no delete, an uninstalled extension's data was immortal — the
47
+ * same orphan problem the media cleanup tool exists to solve, one layer up.
48
+ *
49
+ * Best-effort by construction: the host removes the extension's namespace
50
+ * afterwards regardless, so a hook that throws, hangs or was never
51
+ * registered costs nothing. It exists for the work core *cannot* do on an
52
+ * extension's behalf — retiring a sidecar's external state, revoking a
53
+ * token it issued — not for deleting its own rows.
54
+ */
55
+ 'uninstall',
56
+ ];
57
+ // ── Conformance probes (03 §9) ──────────────────────────────────────────────
58
+ /**
59
+ * Capability names no hook surface may carry, whatever the kind.
60
+ *
61
+ * Every one of these is a **handle back into the executor** — a way for a hook to
62
+ * make core do work on its behalf rather than being the work core invoked. Only
63
+ * handlers reach oracles, and they do it by *being* a node the executor
64
+ * invokes, never by holding a handle; a hook that could call, trigger, run or emit
65
+ * would have opted itself out of the receipt, the budget and the review gate that
66
+ * being a node buys.
67
+ *
68
+ * That is the line, and it is narrower than "a hook may not reach outside itself".
69
+ * `fetch` was on this list and is not any more: host-scoped network access is a
70
+ * manifest-declared, admin-deniable grant with a consent surface (see
71
+ * `HookFetchInit` and the docblock above it), so it is metered by the permission
72
+ * model rather than by being kept off the surface. It buys no Provider access —
73
+ * a hook that fetches a model API directly is still outside the receipt, and the
74
+ * grant an admin reads is what says so.
75
+ */
76
+ // Member NAMES a surface must not hand out — not kind words, so `provider`
77
+ // is right here after the U3 rename (`oracle` is the kind; a surface member
78
+ // called `provider` would still be a model door and is still forbidden).
79
+ const FORBIDDEN_ON_ANY_HOOK = [
80
+ 'callProvider',
81
+ 'call',
82
+ 'provider',
83
+ 'trigger',
84
+ 'run',
85
+ 'emit',
86
+ ];
87
+ /**
88
+ * F32, checked rather than documented. The probe reads the surface an implementation
89
+ * actually hands out — a regression that adds `callProvider` back fails here instead
90
+ * of shipping.
91
+ * @experimental
92
+ */
93
+ export function assertHookSurface(kind, surface) {
94
+ const keys = new Set(Object.keys(surface));
95
+ const found = FORBIDDEN_ON_ANY_HOOK.filter((k) => keys.has(k));
96
+ // Kind-specific, so it cannot live in the list above: a lifecycle callback runs
97
+ // at core's own moments (boot, enable, uninstall), where a write to core's
98
+ // tables would be a migration nobody reviewed (13 §7c).
99
+ if (kind === 'lifecycle' && keys.has('writeCore'))
100
+ found.push('writeCore');
101
+ return found.length ? { ok: false, found } : { ok: true };
102
+ }
103
+ /**
104
+ * The scheduled-work path, stated as code so it is discoverable from the SDK rather
105
+ * than only from 13 §7c.
106
+ * @experimental
107
+ */
108
+ export const SCHEDULED_WORK_PATH = {
109
+ instead: 'core:event/schedule-tick@1',
110
+ because: 'a hook calling a Provider would opt out of the receipt, the budget and the review gate, ' +
111
+ 'and would not appear on the consent screen a user reads (F32, 11 §4)',
112
+ };
113
+ //# sourceMappingURL=hooks.js.map