@jini-ai/plugins 0.0.0-stage → 0.4.0

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 (76) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -0
  3. package/README.md +60 -2
  4. package/dist/glue/attachment-points/content-lifecycle.d.ts +10 -0
  5. package/dist/glue/attachment-points/content-lifecycle.js +5 -0
  6. package/dist/glue/attachment-points/events.d.ts +12 -0
  7. package/dist/glue/attachment-points/events.js +5 -0
  8. package/dist/glue/attachment-points/tool-registration.d.ts +23 -0
  9. package/dist/glue/attachment-points/tool-registration.js +43 -0
  10. package/dist/glue/capability-gate.d.ts +20 -0
  11. package/dist/glue/capability-gate.js +23 -0
  12. package/dist/glue/dispatch.d.ts +20 -0
  13. package/dist/glue/dispatch.js +9 -0
  14. package/dist/glue/index.d.ts +8 -0
  15. package/dist/glue/index.js +8 -0
  16. package/dist/glue/manifest.d.ts +43 -0
  17. package/dist/glue/manifest.js +106 -0
  18. package/dist/glue/ports.d.ts +60 -0
  19. package/dist/glue/ports.js +2 -0
  20. package/dist/host/activation.d.ts +118 -0
  21. package/dist/host/activation.js +104 -0
  22. package/dist/host/attach-loaded-plugin.d.ts +37 -0
  23. package/dist/host/attach-loaded-plugin.js +19 -0
  24. package/dist/host/capability-sdk.d.ts +74 -0
  25. package/dist/host/capability-sdk.js +58 -0
  26. package/dist/host/claim-conflicts.d.ts +101 -0
  27. package/dist/host/claim-conflicts.js +139 -0
  28. package/dist/host/declarative-enable.d.ts +43 -0
  29. package/dist/host/declarative-enable.js +73 -0
  30. package/dist/host/discovery-types.d.ts +52 -0
  31. package/dist/host/discovery-types.js +2 -0
  32. package/dist/host/errors.d.ts +20 -0
  33. package/dist/host/errors.js +22 -0
  34. package/dist/host/hook-registry.d.ts +113 -0
  35. package/dist/host/hook-registry.js +190 -0
  36. package/dist/host/index.d.ts +16 -0
  37. package/dist/host/index.js +16 -0
  38. package/dist/host/manifest.d.ts +149 -0
  39. package/dist/host/manifest.js +407 -0
  40. package/dist/host/node/discovery.d.ts +25 -0
  41. package/dist/host/node/discovery.js +217 -0
  42. package/dist/host/node/index.d.ts +7 -0
  43. package/dist/host/node/index.js +7 -0
  44. package/dist/host/node/install.d.ts +73 -0
  45. package/dist/host/node/install.js +301 -0
  46. package/dist/host/node/loader.d.ts +55 -0
  47. package/dist/host/node/loader.js +146 -0
  48. package/dist/host/node/module-snapshot.d.ts +25 -0
  49. package/dist/host/node/module-snapshot.js +53 -0
  50. package/dist/host/node/package-files.d.ts +52 -0
  51. package/dist/host/node/package-files.js +214 -0
  52. package/dist/host/plugin-claims.d.ts +113 -0
  53. package/dist/host/plugin-claims.js +134 -0
  54. package/dist/host/ports.d.ts +196 -0
  55. package/dist/host/ports.js +2 -0
  56. package/dist/host/quarantine.d.ts +19 -0
  57. package/dist/host/quarantine.js +28 -0
  58. package/dist/host/repo.memory.d.ts +27 -0
  59. package/dist/host/repo.memory.js +33 -0
  60. package/dist/host/sql/index.d.ts +4 -0
  61. package/dist/host/sql/index.js +4 -0
  62. package/dist/host/sql/repo.d.ts +38 -0
  63. package/dist/host/sql/repo.js +50 -0
  64. package/dist/host/sql/repo.rows.d.ts +28 -0
  65. package/dist/host/sql/repo.rows.js +28 -0
  66. package/dist/host/uninstall.d.ts +88 -0
  67. package/dist/host/uninstall.js +112 -0
  68. package/dist/host/worker/import-seam.d.ts +45 -0
  69. package/dist/host/worker/import-seam.js +52 -0
  70. package/dist/host/worker/index.d.ts +5 -0
  71. package/dist/host/worker/index.js +5 -0
  72. package/dist/host/worker/protocol.d.ts +62 -0
  73. package/dist/host/worker/protocol.js +31 -0
  74. package/dist/host/worker/run-call.d.ts +27 -0
  75. package/dist/host/worker/run-call.js +76 -0
  76. package/package.json +102 -3
@@ -0,0 +1,190 @@
1
+ import { PluginHookFailedError } from "./errors.js";
2
+ // The class lives in `contracts/core` so `features/post` can recognize it without importing this
3
+ // feature (see that file's header); re-exported so this module's importers are unchanged.
4
+ export { PluginHookFailedError };
5
+ /** Default recovery policy: tolerate two transient failures, quarantine on the third consecutive
6
+ * failure. Composition may inject a different positive integer per runtime instance. */
7
+ export const DEFAULT_PLUGIN_FAILURE_THRESHOLD = 3;
8
+ /** TB-01's rank per source, ADR-057 Decision 3's additive third stage: built-ins (0), then site
9
+ * plugins (1), then glue modules (2) — id-ascending within each rank (`compareTb01` below). */
10
+ const SOURCE_RANK = { "built-in": 0, site: 1, glue: 2 };
11
+ /**
12
+ * TB-01 comparator: built-ins before site plugins before glue modules, id-ascending within each
13
+ * group. Shared with `discovery.ts`'s own ordering rule for the `built-in`/`site` ranks (PLUGINS_LIST
14
+ * uses the same order) so those two never diverge; the `glue` rank has no discovery-time analogue
15
+ * since glue modules are never listed by `discovery.ts` (ADR-057 Decision 6 — a separate tier).
16
+ */
17
+ function compareTb01(a, b) {
18
+ const rankDiff = SOURCE_RANK[a[1].source] - SOURCE_RANK[b[1].source];
19
+ if (rankDiff !== 0)
20
+ return rankDiff;
21
+ return a[0].localeCompare(b[0]);
22
+ }
23
+ /** The four JSON-primitive field types BR-06's declared-field vocabulary supports. */
24
+ function matchesDeclaredType(value, type) {
25
+ switch (type) {
26
+ case "integer":
27
+ return typeof value === "number" && Number.isInteger(value);
28
+ case "number":
29
+ return typeof value === "number";
30
+ case "string":
31
+ return typeof value === "string";
32
+ case "boolean":
33
+ return typeof value === "boolean";
34
+ default:
35
+ return false;
36
+ }
37
+ }
38
+ /** Last dot-segment of a declared `ext.{pluginId}.{field}` path — the field name a returned patch
39
+ * key is checked against. */
40
+ function fieldNameOf(declaredPath) {
41
+ const segments = declaredPath.split(".");
42
+ return segments[segments.length - 1] ?? declaredPath;
43
+ }
44
+ /** Calls one plugin's filter, re-shaping a thrown error into the module's own
45
+ * `PluginHookFailedError` vocabulary — the ONE place `runBeforeSave`'s per-plugin work touches the
46
+ * plugin's own code directly. */
47
+ async function callPluginFilter(pluginId, filter, snapshot, ctx, beforeSaveHook) {
48
+ try {
49
+ return await filter(snapshot, ctx);
50
+ }
51
+ catch (error) {
52
+ throw new PluginHookFailedError(pluginId, `plugin '${pluginId}' ${beforeSaveHook} filter failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
53
+ }
54
+ }
55
+ /** BR-07/EC-10: a filter's return value must be a plain object, never an array or a primitive. */
56
+ function assertPatchShape(pluginId, patch) {
57
+ if (typeof patch !== "object" || patch === null || Array.isArray(patch)) {
58
+ throw new PluginHookFailedError(pluginId, `plugin '${pluginId}' returned a non-object ext patch from its beforeSave filter`);
59
+ }
60
+ }
61
+ /** BR-06: every key in a validated patch must match a field the plugin's own manifest declared,
62
+ * with a value matching that field's declared type — anything else is fail-closed, not dropped. */
63
+ function buildDeclaredPatch(pluginId, patch, declaredFields) {
64
+ const declaredByField = new Map(declaredFields.map((f) => [fieldNameOf(f.path), f]));
65
+ const pluginPatch = {};
66
+ for (const [field, value] of Object.entries(patch)) {
67
+ const decl = declaredByField.get(field);
68
+ if (!decl) {
69
+ throw new PluginHookFailedError(pluginId, `plugin '${pluginId}' returned undeclared ext field '${field}' (FIELD_PATH_INVALID)`);
70
+ }
71
+ if (!matchesDeclaredType(value, decl.type)) {
72
+ throw new PluginHookFailedError(pluginId, `plugin '${pluginId}' returned ext field '${field}' with a value not matching its declared type '${decl.type}' (FIELD_TYPE_MISMATCH)`);
73
+ }
74
+ pluginPatch[field] = value;
75
+ }
76
+ return pluginPatch;
77
+ }
78
+ /**
79
+ * One plugin's full contribution: builds its isolated entry snapshot (this plugin's own `ext`
80
+ * namespace overlaid with every earlier plugin's already-merged result, per TB-01's composition
81
+ * order), calls its filter, and validates the returned patch. Pulled out of `runBeforeSave`'s loop
82
+ * body because that loop's own job — ordering, failure bookkeeping, quarantine — is a different
83
+ * concern from what happens to any ONE plugin's filter call.
84
+ */
85
+ async function applyPluginFilter(pluginId, attachment, entry, mergedSoFar, beforeSaveHook) {
86
+ const snapshot = structuredClone({ ...entry, ext: { ...entry.ext, ...mergedSoFar } });
87
+ const ctx = { pluginId, workspaceId: entry.workspaceId };
88
+ const patch = await callPluginFilter(pluginId, attachment.filter, snapshot, ctx, beforeSaveHook);
89
+ assertPatchShape(pluginId, patch);
90
+ return buildDeclaredPatch(pluginId, patch, attachment.declaredFields);
91
+ }
92
+ /**
93
+ * Creates a fresh, empty hook registry (no plugins attached). Each process has exactly one
94
+ * long-lived instance, constructed once at composition-root time and shared between `loader.ts`
95
+ * (attach/detach) and `post.ts` (via `BeforeSaveHookPort`, `runBeforeSave` only).
96
+ *
97
+ * @complexity `attach`/`detach` are O(1) (Map operations). `runBeforeSave` is
98
+ * O(attached-plugin-count · own-declared-field-count) for merge/validation bookkeeping, plus each
99
+ * plugin's own filter cost (unbounded, plugin-defined — no latency budget exists, ADR scalability
100
+ * axis, a disclosed gap).
101
+ * @overallScore 100/100
102
+ */
103
+ export function createHookRegistry(required, options = {}) {
104
+ const beforeSaveHook = required.pluginSdkBinding.beforeSaveHook;
105
+ const failureThreshold = options.failureThreshold ?? DEFAULT_PLUGIN_FAILURE_THRESHOLD;
106
+ if (!Number.isInteger(failureThreshold) || failureThreshold < 1) {
107
+ throw new RangeError("plugin failure threshold must be a positive integer");
108
+ }
109
+ const attachments = new Map();
110
+ const consecutiveFailures = new Map();
111
+ function clearFailures(pluginId, workspaceId) {
112
+ if (workspaceId !== undefined) {
113
+ const workspaceFailures = consecutiveFailures.get(workspaceId);
114
+ workspaceFailures?.delete(pluginId);
115
+ if (workspaceFailures?.size === 0)
116
+ consecutiveFailures.delete(workspaceId);
117
+ return;
118
+ }
119
+ for (const [workspace, workspaceFailures] of consecutiveFailures) {
120
+ workspaceFailures.delete(pluginId);
121
+ if (workspaceFailures.size === 0)
122
+ consecutiveFailures.delete(workspace);
123
+ }
124
+ }
125
+ async function recordFailure(pluginId, workspaceId, failure) {
126
+ if (!options.onQuarantine)
127
+ return;
128
+ const workspaceFailures = consecutiveFailures.get(workspaceId) ?? new Map();
129
+ const next = (workspaceFailures.get(pluginId) ?? 0) + 1;
130
+ workspaceFailures.set(pluginId, next);
131
+ consecutiveFailures.set(workspaceId, workspaceFailures);
132
+ if (next < failureThreshold)
133
+ return;
134
+ // Recover the process first: the triggering save remains fail-closed, but all later saves see
135
+ // the attachment gone even while durable activation state is being recorded.
136
+ detach({ pluginId });
137
+ try {
138
+ await options.onQuarantine({
139
+ pluginId,
140
+ workspaceId,
141
+ consecutiveFailures: next,
142
+ reason: failure.message,
143
+ });
144
+ }
145
+ catch (error) {
146
+ throw new PluginHookFailedError(pluginId, `${failure.message}; automatic quarantine persistence failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
147
+ }
148
+ }
149
+ function attach({ pluginId, source, filter, declaredFields }, _optional = {}) {
150
+ clearFailures(pluginId);
151
+ attachments.set(pluginId, { source, filter, declaredFields });
152
+ }
153
+ function detach({ pluginId }, _optional = {}) {
154
+ attachments.delete(pluginId);
155
+ clearFailures(pluginId);
156
+ }
157
+ async function runBeforeSave({ entry }, _optional = {}) {
158
+ const ordered = [...attachments.entries()].sort(compareTb01);
159
+ const merged = {};
160
+ for (const [pluginId, attachment] of ordered) {
161
+ try {
162
+ merged[pluginId] = await applyPluginFilter(pluginId, attachment, entry, merged, beforeSaveHook);
163
+ clearFailures(pluginId, entry.workspaceId);
164
+ }
165
+ catch (error) {
166
+ const failure = error instanceof PluginHookFailedError
167
+ ? error
168
+ : new PluginHookFailedError(pluginId, `plugin '${pluginId}' beforeSave hook failed`, { cause: error });
169
+ await recordFailure(pluginId, entry.workspaceId, failure);
170
+ throw failure;
171
+ }
172
+ }
173
+ return merged;
174
+ }
175
+ async function previewBeforeSave({ pluginId, entry }, _optional = {}) {
176
+ const attachment = attachments.get(pluginId);
177
+ if (!attachment)
178
+ return null;
179
+ try {
180
+ return await applyPluginFilter(pluginId, attachment, entry, {}, beforeSaveHook);
181
+ }
182
+ catch (error) {
183
+ throw error instanceof PluginHookFailedError
184
+ ? error
185
+ : new PluginHookFailedError(pluginId, `plugin '${pluginId}' beforeSave hook failed`, { cause: error });
186
+ }
187
+ }
188
+ return { attach, detach, runBeforeSave, previewBeforeSave };
189
+ }
190
+ //# sourceMappingURL=hook-registry.js.map
@@ -0,0 +1,16 @@
1
+ /** Universal manifest, claims, activation and hook composition; never imports or evaluates a module. */
2
+ export * from './ports.js';
3
+ export * from './errors.js';
4
+ export * from './manifest.js';
5
+ export * from './discovery-types.js';
6
+ export * from './hook-registry.js';
7
+ export * from './attach-loaded-plugin.js';
8
+ export * from './plugin-claims.js';
9
+ export * from './claim-conflicts.js';
10
+ export * from './activation.js';
11
+ export * from './declarative-enable.js';
12
+ export * from './capability-sdk.js';
13
+ export * from './quarantine.js';
14
+ export * from './repo.memory.js';
15
+ export * from './uninstall.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /** Universal manifest, claims, activation and hook composition; never imports or evaluates a module. */
2
+ export * from './ports.js';
3
+ export * from './errors.js';
4
+ export * from './manifest.js';
5
+ export * from './discovery-types.js';
6
+ export * from './hook-registry.js';
7
+ export * from './attach-loaded-plugin.js';
8
+ export * from './plugin-claims.js';
9
+ export * from './claim-conflicts.js';
10
+ export * from './activation.js';
11
+ export * from './declarative-enable.js';
12
+ export * from './capability-sdk.js';
13
+ export * from './quarantine.js';
14
+ export * from './repo.memory.js';
15
+ export * from './uninstall.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @file `PluginManifest` type + `validateManifest()` — static, collect-all manifest validation
3
+ * (SPEC-005 REQ-01, BR-02/BR-03; ADR-024 `tier`, 1.1.1 fix).
4
+ *
5
+ * Purpose:
6
+ * Pure, no-I/O validation of an already-parsed `tovu.plugin.json` object against the v1 required-
7
+ * field set, id/folder match, capability vocabulary, hook vocabulary, and field-declaration rules.
8
+ * Consumed by both `discovery.ts` (list-time, every discovery pass) and `loader.ts` (enable-time
9
+ * re-validation, BR-05) — one validator, two call sites, never diverging (mirrors SPEC-004's theme
10
+ * validator shape, per feature.spec.md's own Article IV note).
11
+ *
12
+ * Division of labor (a TDD design decision, not itself a spec requirement): BR-02 step (1),
13
+ * "package-level (size, disallowed files, server/index.mjs presence)", requires a directory
14
+ * listing this function's contract deliberately does NOT take as input (Implementation Outline
15
+ * C-006: `{ manifest: unknown, folderName: string, builtInIds: string[] }` — no file-list
16
+ * parameter). Package-level filesystem checks are therefore `discovery.ts`'s responsibility
17
+ * (REQ-02/03's discovery step, which does read the filesystem); this function owns BR-02 steps
18
+ * (2)-(6) only: manifest / identity / capabilities / hooks / fields. `discovery.ts` merges both
19
+ * error sets into one `PluginDiscoveryRecord.errors[]` array before listing/enabling a plugin.
20
+ *
21
+ * Architectural role:
22
+ * TDD-certified implementation (implementation outline C-005/C-006). Signature and JSDoc are
23
+ * design-frozen; `validateManifest()` collects every BR-02 steps (2)-(6) violation (identity,
24
+ * engine/tier, capabilities, hooks, fields) rather than stopping at the first, returning them in
25
+ * `errors[]` — it never throws. Verified against `__tests__/unit/manifest.unit.test.ts`.
26
+ */
27
+ import type { HookPoints, ManifestHostPorts } from "./ports.js";
28
+ /** ADR-024 §1 trust-tier vocabulary (1.1.1 REQ-01 fix). Literal encoding reused verbatim from the
29
+ * existing, approved SPEC-032/ADR-023 precedent (`DataModuleDecl.pluginTier`). */
30
+ export type PluginTier = "tier-1" | "tier-2" | "tier-3";
31
+ /** REQ-04's exactly-three v1 capability vocabulary, as manifest-declared strings (validated
32
+ * against this set by `validateManifest`; `@tovu/sdk`'s `CONTENT_READ`/`CONTENT_EXTEND`/
33
+ * `HOOKS_ATTACH` constants are the same literal values, kept independent here so this module has
34
+ * no dependency on the SDK package per the Module Map). Sourced from `core/`'s
35
+ * `SharedExtensionCapability` — the sibling `site-glue` mechanism's own capability vocabulary
36
+ * declares this same three-member set as its first three members; both import the one shared
37
+ * declaration rather than each retyping the literals (2026-08-20 swarm-consensus synthesis,
38
+ * Result 1). */
39
+ export type PluginCapability = string;
40
+ /** REQ-06 field declaration — `ext.{pluginId}.{field}` (BR-06). `queryable` MUST be `false` in
41
+ * v1 (EC-04); a `true` value is a validation error (`QUERYABLE_UNSUPPORTED_V1`), not silently
42
+ * coerced. */
43
+ export interface PluginManifestFieldDecl {
44
+ readonly path: string;
45
+ readonly type: "string" | "integer" | "number" | "boolean";
46
+ readonly queryable: boolean;
47
+ /**
48
+ * Optional, human-readable, action-oriented description of what this field represents and how an
49
+ * agent should use it (2026-08-26 addition — `features/plugin-runtime/capability-tool-registrations.ts`
50
+ * is the sole consumer: it is folded into the indexed `search_tools` description for this plugin's
51
+ * capability-read tool when the plugin is enabled). Absent on every pre-existing manifest — this
52
+ * is additive, not a widened requirement, so no previously-valid manifest becomes invalid by
53
+ * omitting it; a plugin author who wants their capability to rank well against a real user query
54
+ * simply adds one.
55
+ */
56
+ readonly description?: string;
57
+ }
58
+ /** `tovu.plugin.json` — the ecosystem compatibility surface (state.spec.md §2, ADR-004). */
59
+ export interface PluginManifest {
60
+ readonly id: string;
61
+ readonly name: string;
62
+ readonly version: string;
63
+ readonly sdkRange: string;
64
+ readonly engine: number;
65
+ readonly tier: PluginTier;
66
+ readonly capabilities: readonly string[];
67
+ readonly hooks: readonly string[];
68
+ readonly fields: readonly PluginManifestFieldDecl[];
69
+ readonly integrity: Readonly<Record<string, string>>;
70
+ /** Parsed-and-stored, UNUSED in v1 (forward-compat, no behavior — state.spec.md §2). */
71
+ readonly adminSurfaces?: readonly unknown[] | null;
72
+ /** Content types the plugin declares (AW-7 Tier 1, 2026-10-04) — no longer unused: validated by
73
+ * `declarative-content-types.ts`, claimed by key (`plugin-claims.ts`), created at enable. */
74
+ readonly contentTypes?: readonly unknown[] | null;
75
+ readonly provenance?: {
76
+ readonly sourceUrl?: string;
77
+ readonly signature?: string;
78
+ } | null;
79
+ readonly dependencies?: Readonly<Record<string, string>> | null;
80
+ /**
81
+ * What this plugin says it provides, by name (2026-10-04, conflict detection — see
82
+ * `plugin-claims.ts` and `ADS-memory/specs/005-plugin-system/conflicts.spec.md`). Optional and
83
+ * additive: a manifest without it claims only what its other fields already imply (its hooks and,
84
+ * when it declares `fields`, its generated capability tool). Each entry is a CLAIM: two enabled
85
+ * plugins, or a plugin and core, naming the same thing is refused at enable time and quarantined
86
+ * at boot rather than silently letting one overwrite the other. Declaring a surface the runtime
87
+ * does not mount yet (settings, widgets, routes — ADR-025/`adminSurfaces` are still unwired) is
88
+ * still binding for conflicts, so a plugin cannot squat a name today that a future mount would
89
+ * then have to arbitrate.
90
+ */
91
+ readonly contributes?: PluginContributions | null;
92
+ }
93
+ /** `tovu.plugin.json`'s `contributes` block — every list optional, every entry a plain name. */
94
+ export interface PluginContributions {
95
+ /** `"METHOD /path"` or `"/path"` (every method). Parameter names do not distinguish routes. */
96
+ readonly routes?: readonly string[];
97
+ /** Agent tool ids. The generated prefixes `plugin_capability_`/`agent_plugin_` are reserved. */
98
+ readonly tools?: readonly string[];
99
+ /** Data-module tables — must sit in this plugin's own `p_{id}__` namespace (ADR-023 §5). */
100
+ readonly tables?: readonly string[];
101
+ readonly settings?: readonly string[];
102
+ readonly widgets?: readonly string[];
103
+ /** Permission ids this plugin DEFINES (not ones it merely requires). */
104
+ readonly permissions?: readonly string[];
105
+ }
106
+ /** One validation-vocabulary entry (errors.spec.md §3). `file` names the offending packaged file
107
+ * when applicable; `null` for manifest-level errors with no single implicated file. This is the
108
+ * shared shape used verbatim by both `PLUGINS_LIST.plugins[].errors[]` and
109
+ * `PLUGIN_INVALID.details.errors[]` (errors.spec.md §4 — "one validator, two surfaces"). */
110
+ export interface PluginValidationError {
111
+ readonly code: string;
112
+ readonly file: string | null;
113
+ readonly message: string;
114
+ }
115
+ export interface ValidateManifestRequired<H extends HookPoints = HookPoints> extends ManifestHostPorts<H> {
116
+ /** An already-parsed `tovu.plugin.json` value (unparseable JSON is `discovery.ts`'s concern —
117
+ * this function receives a JS value, never a file path or raw bytes). */
118
+ readonly manifest: unknown;
119
+ /** The install folder name this manifest was read from (EC-01: `id` must equal this). */
120
+ readonly folderName: string;
121
+ /** Every currently-registered built-in plugin id (DUP-01: a site plugin id equal to a built-in
122
+ * id is `SHADOWS_BUILT_IN`, not silently shadowed). */
123
+ readonly builtInIds: readonly string[];
124
+ }
125
+ export type ValidateManifestOptional = Record<string, never>;
126
+ export interface ValidateManifestResult {
127
+ /** Every applicable error, collected — NOT first-failure (BR-02). Empty when the manifest is
128
+ * statically valid (integrity/`sdkRange` are separate, load-pipeline-time checks, BR-01). */
129
+ readonly errors: readonly PluginValidationError[];
130
+ }
131
+ /** The owner id the claim system gives Tovu core (`plugin-claims.ts` re-exports it). Conflict
132
+ * detection never compares an owner with itself, so a plugin with this id would never conflict with
133
+ * core's reserved routes, tools or permissions — it is refused as an id instead. */
134
+ export declare const CORE_OWNER_ID = "core";
135
+ /** The `contributes` lists `validateContributes` accepts, in the order claims are derived. */
136
+ export declare const CONTRIBUTION_KEYS: readonly ["routes", "tools", "tables", "settings", "widgets", "permissions"];
137
+ /**
138
+ * Validates one already-parsed manifest against BR-02 steps (2)-(6), collecting every applicable
139
+ * error rather than stopping at the first (BR-02: "collect ALL statically-determinable errors").
140
+ * Pure — no I/O, no mutation of `manifest`.
141
+ *
142
+ * @throws Nothing — validation failures are reported via the returned `errors` array, never a
143
+ * thrown error (this function itself cannot fail; a malformed top-level shape, e.g. `manifest`
144
+ * being `null` or an array, is itself a `MANIFEST_MALFORMED` entry in the result, not a throw).
145
+ * @complexity O(fields.length + capabilities.length + hooks.length) — bounded by one manifest's
146
+ * own declared arrays, never by external/unbounded input.
147
+ */
148
+ export declare function validateManifest<H extends HookPoints>(required: ValidateManifestRequired<H>, _optional?: ValidateManifestOptional): ValidateManifestResult;
149
+ //# sourceMappingURL=manifest.d.ts.map