@jini-ai/plugins 0.7.1 → 0.7.3-next.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/README.md +1 -1
- package/dist/core/manifest-keys.d.ts +8 -0
- package/dist/core/manifest-keys.js +16 -0
- package/dist/glue/attachment-points/content-lifecycle.d.ts +6 -7
- package/dist/glue/attachment-points/content-lifecycle.js +1 -1
- package/dist/glue/capability-gate.d.ts +2 -2
- package/dist/glue/manifest.js +2 -12
- package/dist/host/activation.d.ts +4 -5
- package/dist/host/admin-response.d.ts +2 -3
- package/dist/host/attach-loaded-plugin.d.ts +4 -4
- package/dist/host/attach-loaded-plugin.js +2 -2
- package/dist/host/browser-providers.d.ts +1 -1
- package/dist/host/capability-sdk.d.ts +8 -7
- package/dist/host/capability-sdk.js +39 -31
- package/dist/host/capability-tools.d.ts +3 -3
- package/dist/host/capability-tools.js +249 -237
- package/dist/host/contributions.d.ts +7 -66
- package/dist/host/contributions.js +64 -51
- package/dist/host/declarative-content-types.d.ts +6 -6
- package/dist/host/declarative-content-types.js +141 -135
- package/dist/host/declarative-enable.js +1 -1
- package/dist/host/discovery-types.d.ts +3 -3
- package/dist/host/hook-registry.d.ts +9 -9
- package/dist/host/hook-registry.js +86 -76
- package/dist/host/index.d.ts +1 -2
- package/dist/host/index.js +1 -1
- package/dist/host/manifest-types.d.ts +6 -59
- package/dist/host/manifest.d.ts +6 -5
- package/dist/host/manifest.js +3 -39
- package/dist/host/node/discovery.d.ts +1 -1
- package/dist/host/node/discovery.js +4 -5
- package/dist/host/node/index.d.ts +3 -0
- package/dist/host/node/index.js +2 -0
- package/dist/host/node/install.js +2 -2
- package/dist/host/node/integrity-command.d.ts +8 -0
- package/dist/host/node/integrity-command.js +26 -0
- package/dist/host/node/invocation-binding.d.ts +1 -1
- package/dist/host/node/invocation-binding.js +1 -1
- package/dist/host/node/loader.d.ts +3 -2
- package/dist/host/node/loader.js +12 -12
- package/dist/host/node/module-snapshot.d.ts +20 -0
- package/dist/host/node/module-snapshot.js +31 -0
- package/dist/host/node/open-flags.d.ts +4 -1
- package/dist/host/node/open-flags.js +1 -1
- package/dist/host/node/package-files.js +1 -1
- package/dist/host/node/provider-artifact.d.ts +1 -2
- package/dist/host/node/runtime-contracts.d.ts +237 -0
- package/dist/host/node/runtime-contracts.js +2 -0
- package/dist/host/node/runtime-core.d.ts +1 -243
- package/dist/host/node/runtime-core.js +18 -114
- package/dist/host/node/runtime-load-target.d.ts +44 -0
- package/dist/host/node/runtime-load-target.js +45 -0
- package/dist/host/node/runtime-package-location.d.ts +45 -0
- package/dist/host/node/runtime-package-location.js +57 -0
- package/dist/host/node/source-drafts.d.ts +4 -2
- package/dist/host/node/source-drafts.js +107 -39
- package/dist/host/ports.d.ts +1 -38
- package/dist/host/provider-contributions.d.ts +2 -14
- package/dist/host/provider-contributions.js +1 -1
- package/dist/host/provider-host.d.ts +4 -19
- package/dist/host/provider-host.js +83 -71
- package/dist/host/provider-revision-watch.d.ts +36 -0
- package/dist/host/provider-revision-watch.js +52 -0
- package/dist/host/provider-setting-required.d.ts +1 -7
- package/dist/host/provider-setting-required.js +1 -18
- package/dist/host/provider-settings-migrations.d.ts +1 -1
- package/dist/host/repo.memory.d.ts +1 -1
- package/dist/host/repo.memory.js +1 -1
- package/dist/host/sql/repo.d.ts +4 -3
- package/dist/host/sql/repo.rows.js +2 -2
- package/dist/host/tool-contributions.d.ts +2 -1
- package/dist/host/tool-contributions.js +1 -0
- package/dist/host/tools/install.js +1 -0
- package/dist/host/tools/management.js +97 -83
- package/dist/host/uninstall.d.ts +1 -1
- package/dist/host/worker/import-seam.d.ts +2 -2
- package/dist/host/worker/protocol.d.ts +2 -2
- package/dist/host/worker/run-call.d.ts +2 -1
- package/dist/host/worker/run-call.js +2 -2
- package/dist/host/worker/start.js +1 -1
- package/package.json +7 -17
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ have no executable or product-policy defaults. The import port matches Phase 13'
|
|
|
37
37
|
The application owns contained executable import and fresh snapshot selection, including Tier-2
|
|
38
38
|
worker execution. Tier-1 never imports code, Tier-2 requires `tierPolicy.execution: 'worker'`, and
|
|
39
39
|
Tier-3 requires `tierPolicy.allowLoad` to allow it. Archive readers own ZIP parsing, zip-slip checks,
|
|
40
|
-
entry limits and bounded decompression; `readSitePluginArchive` remains the
|
|
40
|
+
entry limits and bounded decompression; `readSitePluginArchive` remains the host adapter.
|
|
41
41
|
The content-type grammar and create/write implementation remain host ports.
|
|
42
42
|
|
|
43
43
|
```ts
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Collect unknown and missing manifest keys in their existing validation order. */
|
|
2
|
+
export declare function collectManifestKeyErrors<ErrorType>({ raw, allowedKeys, requiredKeys, malformed }: {
|
|
3
|
+
raw: Readonly<Record<string, unknown>>;
|
|
4
|
+
allowedKeys: ReadonlySet<string>;
|
|
5
|
+
requiredKeys: readonly string[];
|
|
6
|
+
malformed: (message: string) => ErrorType;
|
|
7
|
+
}, _optional?: Record<string, never>): ErrorType[];
|
|
8
|
+
//# sourceMappingURL=manifest-keys.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Collect unknown and missing manifest keys in their existing validation order. */
|
|
2
|
+
export function collectManifestKeyErrors({ raw, allowedKeys, requiredKeys, malformed }, _optional = {}) {
|
|
3
|
+
const errors = [];
|
|
4
|
+
for (const key of Object.keys(raw)) {
|
|
5
|
+
if (!allowedKeys.has(key)) {
|
|
6
|
+
errors.push(malformed(`unknown manifest key '${key}'`));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
for (const key of requiredKeys) {
|
|
10
|
+
if (raw[key] === undefined) {
|
|
11
|
+
errors.push(malformed(`missing required manifest field '${key}'`));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return errors;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=manifest-keys.js.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file `attachGlueContentLifecycle()` — the content-lifecycle attachment point
|
|
3
|
-
* ADR-057 Decision 2's `content.entry.beforeSave` adapter row, Decision 2.1).
|
|
2
|
+
* @file `attachGlueContentLifecycle()` — the `content.entry.beforeSave` content-lifecycle attachment point.
|
|
4
3
|
*
|
|
5
4
|
* Purpose:
|
|
6
|
-
* The wired adapter for the one category that stays **fail-closed, unchanged**
|
|
7
|
-
* — data-mutation call sites are never fail-isolated
|
|
5
|
+
* The wired adapter for the one category that stays **fail-closed, unchanged**
|
|
6
|
+
* — data-mutation call sites are never fail-isolated. This module owns none of that containment
|
|
8
7
|
* logic itself: it delegates straight to {@link GlueHostPort.attachContentLifecycleFilter}, whose
|
|
9
8
|
* real, host-specific implementation is expected to attach the given filter to a live
|
|
10
9
|
* `hook-registry.ts` instance via `Jini/packages/plugins/src/host/node/loader.ts`'s `attachLoadedPlugin()` — the shared
|
|
11
|
-
* extraction
|
|
10
|
+
* extraction introduced for this attachment point, with the `"glue"` source. That composition (a real
|
|
12
11
|
* `HookRegistry` plus `attachLoadedPlugin`) is host-specific wiring and does not belong in this
|
|
13
12
|
* product-neutral module; see `__tests__/integration/content-lifecycle.integration.test.ts` for a
|
|
14
13
|
* worked example proving the two compose correctly end to end.
|
|
@@ -18,7 +17,7 @@
|
|
|
18
17
|
* *mechanism* this category relies on lives entirely behind the port, not in this file.
|
|
19
18
|
*
|
|
20
19
|
* Architectural role:
|
|
21
|
-
* Implementation Outline slice 2
|
|
20
|
+
* Implementation Outline slice 2. Depends on slice 1's frozen
|
|
22
21
|
* `manifest.ts`/`ports.ts` contracts.
|
|
23
22
|
*/
|
|
24
23
|
import type { GlueContentLifecycleFilter, GlueFieldDecl } from "../ports.js";
|
|
@@ -40,7 +39,7 @@ export interface AttachGlueContentLifecycleRequired<Filter = GlueContentLifecycl
|
|
|
40
39
|
export type AttachGlueContentLifecycleOptional = Record<string, never>;
|
|
41
40
|
/**
|
|
42
41
|
* Attaches one glue module's content-lifecycle filter via the host port. Pure delegation — this
|
|
43
|
-
* function adds no containment or validation of its own, matching
|
|
42
|
+
* function adds no containment or validation of its own, matching the explicit
|
|
44
43
|
* instruction that this category stays fail-closed and unchanged from `hook-registry.ts`'s existing
|
|
45
44
|
* discipline (a throw here is expected to propagate, not be caught).
|
|
46
45
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attaches one glue module's content-lifecycle filter via the host port. Pure delegation — this
|
|
3
|
-
* function adds no containment or validation of its own, matching
|
|
3
|
+
* function adds no containment or validation of its own, matching the explicit
|
|
4
4
|
* instruction that this category stays fail-closed and unchanged from `hook-registry.ts`'s existing
|
|
5
5
|
* discipline (a throw here is expected to propagate, not be caught).
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file `buildGlueCapabilityGate()` — capability-scoped delegate handle for `GlueCapability`
|
|
3
|
-
* (
|
|
3
|
+
* (`ESCALATE_SECURITY`).
|
|
4
4
|
*
|
|
5
5
|
* Purpose:
|
|
6
6
|
* Extends the sibling plugin mechanism's own `gate()` pattern (always-present, granted-delegates,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* zero I/O of its own — it is pure wiring between "is this granted" and "which closure runs."
|
|
23
23
|
*
|
|
24
24
|
* Architectural role:
|
|
25
|
-
* Design-frozen contract for the extension-glue-tier work (
|
|
25
|
+
* Design-frozen contract for the extension-glue-tier work (Implementation Outline slice
|
|
26
26
|
* 1). Depends on `./manifest`'s `GlueCapability` type and `core/`'s shared capability vocabulary
|
|
27
27
|
* — no host-specific dependency.
|
|
28
28
|
*/
|
package/dist/glue/manifest.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { collectManifestKeyErrors } from "../core/manifest-keys.js";
|
|
1
2
|
const REQUIRED_KEYS = ["id", "version", "sdkRange", "capabilities", "attachments"];
|
|
2
3
|
const ALLOWED_KEYS = new Set(REQUIRED_KEYS);
|
|
3
4
|
const ID_PATTERN = /^[a-z0-9-]+$/;
|
|
@@ -6,18 +7,7 @@ function malformed(message) {
|
|
|
6
7
|
return { code: "MANIFEST_MALFORMED", file: null, message };
|
|
7
8
|
}
|
|
8
9
|
function validateKeys(raw) {
|
|
9
|
-
|
|
10
|
-
for (const key of Object.keys(raw)) {
|
|
11
|
-
if (!ALLOWED_KEYS.has(key)) {
|
|
12
|
-
errors.push(malformed(`unknown manifest key '${key}'`));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
for (const key of REQUIRED_KEYS) {
|
|
16
|
-
if (raw[key] === undefined) {
|
|
17
|
-
errors.push(malformed(`missing required manifest field '${key}'`));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return errors;
|
|
10
|
+
return collectManifestKeyErrors({ raw, allowedKeys: ALLOWED_KEYS, requiredKeys: REQUIRED_KEYS, malformed });
|
|
21
11
|
}
|
|
22
12
|
function validateId(raw) {
|
|
23
13
|
const errors = [];
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file `setPluginEnabled()` / `getActivation()` — gateway-backed enable/disable feature functions
|
|
3
|
-
* (SPEC-005 REQ-07; BR-05; AC-02/AC-13; INV-03/INV-05).
|
|
4
3
|
*
|
|
5
4
|
* Purpose:
|
|
6
|
-
* Mirrors `src/
|
|
5
|
+
* Mirrors `packages/cms/src/presentation/presentation.ts`'s `setActiveTheme`/`getPresentationSettings`
|
|
7
6
|
* shape exactly (Module Map) — a plain feature function, validated and typed-error-throwing, that
|
|
8
|
-
* the ROUTE layer (
|
|
9
|
-
* `executeCommand` (mirrors
|
|
7
|
+
* the ROUTE layer (a host module, C-016) wraps in
|
|
8
|
+
* `executeCommand` (mirrors a host module's `executeCommand`-wrapped shape, per the
|
|
10
9
|
* ADR's API/Event Contract Summary) — NOT wrapped here. This function itself performs BR-05's
|
|
11
10
|
* three-step precondition evaluation and, on success, upserts the `PluginActivationRecord` and
|
|
12
11
|
* (on enable) invokes the injected load hook / (on disable) the injected unload hook — it does not
|
|
@@ -30,7 +29,7 @@ import type { PluginDiscoveryRecord } from "./discovery-types.js";
|
|
|
30
29
|
export interface PluginActivationRecord {
|
|
31
30
|
readonly pluginId: string;
|
|
32
31
|
readonly workspaceId: UUID;
|
|
33
|
-
/** The active (enabled) installed version — the "active pointer"
|
|
32
|
+
/** The active (enabled) installed version — the "active pointer". */
|
|
34
33
|
readonly version: string;
|
|
35
34
|
readonly enabled: boolean;
|
|
36
35
|
readonly updatedAt: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file `toAdminPluginResponse()` — DTO mapping for the admin plugin list / set-enabled wire shape
|
|
3
|
-
* (SPEC-005 REQ-10, api.spec.md §5; C-017).
|
|
4
3
|
*
|
|
5
4
|
* Purpose:
|
|
6
5
|
* Projects a `PluginDiscoveryRecord` plus its (possibly absent) `PluginActivationRecord` into the
|
|
@@ -29,8 +28,8 @@ export interface AdminPluginEnvelope {
|
|
|
29
28
|
readonly version: string;
|
|
30
29
|
readonly source: "built-in" | "site";
|
|
31
30
|
/** (1.1.2, REQ-10/REQ-18) Projected verbatim from `PluginDiscoveryRecord.tier`, itself projected
|
|
32
|
-
* verbatim from the plugin's already-required `PluginManifest.tier`
|
|
33
|
-
* same additive-field mechanism
|
|
31
|
+
* verbatim from the plugin's already-required `PluginManifest.tier` — the
|
|
32
|
+
* same additive-field mechanism described by the revision note ("mirroring how `enabled` is
|
|
34
33
|
* already projected"). Required at this wire-contract layer (api.spec.md §5 lists it as a plain,
|
|
35
34
|
* always-present field, consumed by REQ-18's per-row badge, AC-26).
|
|
36
35
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { BeforeSaveFilter } from "
|
|
1
|
+
import type { BeforeSaveFilter } from "@jini-ai/core/contracts/plugin-sdk";
|
|
2
2
|
import type { AttachmentSource, HookRegistry, HookRegistryFieldDecl } from "./hook-registry.js";
|
|
3
3
|
export interface AttachLoadedPluginRequired {
|
|
4
4
|
/** The plugin/glue-module id `hookRegistry.attach()` files this attachment under. */
|
|
5
5
|
readonly pluginId: string;
|
|
6
|
-
/** Who attached this filter — widened
|
|
6
|
+
/** Who attached this filter — widened to include `"glue"`, so Site Glue's
|
|
7
7
|
* content-lifecycle attachment point can call this function directly rather than forking it. */
|
|
8
8
|
readonly source: AttachmentSource;
|
|
9
9
|
/** The live registry this load's filter attaches to — one long-lived instance per process
|
|
@@ -20,9 +20,9 @@ export interface AttachLoadedPluginRequired {
|
|
|
20
20
|
}
|
|
21
21
|
export type AttachLoadedPluginOptional = Record<string, never>;
|
|
22
22
|
/**
|
|
23
|
-
* The real (not stub) extraction of `loadPlugin()`'s dead step (5)
|
|
23
|
+
* The real (not stub) extraction of `loadPlugin()`'s dead step (5). Attaches
|
|
24
24
|
* one already-obtained filter to the given hook registry under `(pluginId, source)`, widened beyond
|
|
25
|
-
* `loader.ts`'s original `"built-in" | "site"` scope to also accept `"glue"`. Before
|
|
25
|
+
* `loader.ts`'s original `"built-in" | "site"` scope to also accept `"glue"`. Before this extraction, no
|
|
26
26
|
* production code ever called `hookRegistry.attach()` at all (verified by grep, see `hook-registry.ts`'s
|
|
27
27
|
* corrected header) — Site Glue's content-lifecycle attachment point is this function's first real
|
|
28
28
|
* caller; a future fix to `loadPlugin()`'s own dead steps (4)-(5) is expected to call this same
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The real (not stub) extraction of `loadPlugin()`'s dead step (5)
|
|
2
|
+
* The real (not stub) extraction of `loadPlugin()`'s dead step (5). Attaches
|
|
3
3
|
* one already-obtained filter to the given hook registry under `(pluginId, source)`, widened beyond
|
|
4
|
-
* `loader.ts`'s original `"built-in" | "site"` scope to also accept `"glue"`. Before
|
|
4
|
+
* `loader.ts`'s original `"built-in" | "site"` scope to also accept `"glue"`. Before this extraction, no
|
|
5
5
|
* production code ever called `hookRegistry.attach()` at all (verified by grep, see `hook-registry.ts`'s
|
|
6
6
|
* corrected header) — Site Glue's content-lifecycle attachment point is this function's first real
|
|
7
7
|
* caller; a future fix to `loadPlugin()`'s own dead steps (4)-(5) is expected to call this same
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundled chart declarations only.
|
|
1
|
+
/** Bundled chart declarations only. Trust comes from composition, never the manifest. */
|
|
2
2
|
import type { BrowserProviderDeclaration, PluginValidationError } from './manifest-types.js';
|
|
3
3
|
export type { BrowserProviderDeclaration } from './manifest-types.js';
|
|
4
4
|
export interface BrowserProviderAsset {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file `buildCapabilityScopedSdk()` — builds the per-load `PluginSdk` handle
|
|
3
|
-
*
|
|
2
|
+
* @file `buildCapabilityScopedSdk()` — builds the per-load `PluginSdk` handle
|
|
3
|
+
* (`ESCALATE_SECURITY`).
|
|
4
4
|
*
|
|
5
5
|
* Purpose:
|
|
6
6
|
* REQ-04: "the SDK object handed to the plugin exposes ONLY the granted surface. A plugin
|
|
7
7
|
* invoking a surface it did not declare fails at the SDK boundary (`CAPABILITY_DENIED`)."
|
|
8
8
|
*
|
|
9
|
-
* **
|
|
9
|
+
* **Binding, ESCALATE_SECURITY:** a naive reading of the requirement could satisfy "exposes
|
|
10
10
|
* only the granted surface" by simply OMITTING ungranted properties (`sdk.content = granted ?
|
|
11
11
|
* {...} : undefined`). That is the wrong implementation — AC-05's contract requires a classified,
|
|
12
12
|
* catchable `CAPABILITY_DENIED` error, not a bare `TypeError` from calling a method on
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
* SYNCHRONOUSLY throws a typed `CapabilityDeniedError` naming the missing capability. Any
|
|
17
17
|
* deviation from "always present, never absent" requires a recorded
|
|
18
18
|
* `[CIC_DEVIATION_APPROVED]` entry — see
|
|
19
|
-
* `reports/pipeline/005-plugin-system/critical-internal-constraints.md
|
|
19
|
+
* `reports/pipeline/005-plugin-system/critical-internal-constraints.md`.
|
|
20
20
|
*
|
|
21
21
|
* Built fresh per plugin load (never a shared module-level singleton, ADR Decision item 2) — a
|
|
22
22
|
* new `PluginSdk` object is constructed for every `loadPlugin()` call, closing over that one
|
|
23
23
|
* plugin's own `pluginId` and granted capability set only.
|
|
24
24
|
*
|
|
25
25
|
* Architectural role:
|
|
26
|
-
* TDD-certified implementation
|
|
26
|
+
* TDD-certified implementation. Signature and JSDoc are
|
|
27
27
|
* design-frozen; `buildCapabilityScopedSdk()` returns fresh per-plugin delegates for granted
|
|
28
28
|
* capabilities and present, typed-denial stubs for every ungranted surface.
|
|
29
29
|
*/
|
|
30
|
-
import type {
|
|
30
|
+
import type { PluginSdkBinding } from "./ports.js";
|
|
31
|
+
import type { BeforeSaveFilter, ContentEntryDraft, PluginSdk, HookPoints } from "@jini-ai/core/contracts/plugin-sdk";
|
|
31
32
|
import type { PluginCapability } from "./manifest.js";
|
|
32
33
|
/** Thrown synchronously when a plugin invokes an SDK surface it did not declare a capability for
|
|
33
34
|
* (REQ-04, INV-02). Classified so `hook-registry.ts` can catch it specifically and map the
|
|
@@ -63,7 +64,7 @@ export interface BuildCapabilityScopedSdkRequired<H extends HookPoints = HookPoi
|
|
|
63
64
|
export type BuildCapabilityScopedSdkOptional = Record<string, never>;
|
|
64
65
|
/**
|
|
65
66
|
* Builds one plugin's capability-scoped `PluginSdk` handle. Every one of the three v1 surfaces is
|
|
66
|
-
* always present on the returned object
|
|
67
|
+
* always present on the returned object — granted surfaces delegate to `coreDeps`,
|
|
67
68
|
* ungranted surfaces are stubs that throw `CapabilityDeniedError` when invoked (never at build
|
|
68
69
|
* time — the stub itself is a normal, present function; only CALLING it throws).
|
|
69
70
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PLUGIN_PROVIDER_CAPABILITY } from '
|
|
1
|
+
import { PLUGIN_PROVIDER_CAPABILITY } from '@jini-ai/core/contracts/plugin-sdk';
|
|
2
2
|
/** Thrown synchronously when a plugin invokes an SDK surface it did not declare a capability for
|
|
3
3
|
* (REQ-04, INV-02). Classified so `hook-registry.ts` can catch it specifically and map the
|
|
4
4
|
* containing content operation to `PLUGIN_HOOK_FAILED` (BR-07), distinct from any other thrown
|
|
@@ -15,7 +15,7 @@ export class CapabilityDeniedError extends Error {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Builds one plugin's capability-scoped `PluginSdk` handle. Every one of the three v1 surfaces is
|
|
18
|
-
* always present on the returned object
|
|
18
|
+
* always present on the returned object — granted surfaces delegate to `coreDeps`,
|
|
19
19
|
* ungranted surfaces are stubs that throw `CapabilityDeniedError` when invoked (never at build
|
|
20
20
|
* time — the stub itself is a normal, present function; only CALLING it throws).
|
|
21
21
|
*
|
|
@@ -26,19 +26,7 @@ export class CapabilityDeniedError extends Error {
|
|
|
26
26
|
export function buildCapabilityScopedSdk(required, _optional = {}) {
|
|
27
27
|
const { pluginId, capabilities, coreDeps } = required;
|
|
28
28
|
const granted = new Set(capabilities);
|
|
29
|
-
|
|
30
|
-
* Wraps one capability-gated surface: returns `real` when `capability` is granted, otherwise a
|
|
31
|
-
* stub that synchronously throws `CapabilityDeniedError` when invoked. CIC U-003's binding
|
|
32
|
-
* property — every surface is always a present, callable function, never an absent property.
|
|
33
|
-
*/
|
|
34
|
-
function gate(capability, real) {
|
|
35
|
-
if (granted.has(capability)) {
|
|
36
|
-
return real;
|
|
37
|
-
}
|
|
38
|
-
return ((..._args) => {
|
|
39
|
-
throw new CapabilityDeniedError(pluginId, capability);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
29
|
+
const gate = createSdkCapabilityGate(pluginId, granted);
|
|
42
30
|
const sdk = {
|
|
43
31
|
providers: { register: gate(PLUGIN_PROVIDER_CAPABILITY, (input, options = {}) => {
|
|
44
32
|
if (!coreDeps.providers)
|
|
@@ -50,28 +38,14 @@ export function buildCapabilityScopedSdk(required, _optional = {}) {
|
|
|
50
38
|
extend: gate("content.extend", (field, value) => coreDeps.writeExtField(field, value)),
|
|
51
39
|
},
|
|
52
40
|
addFilter: gate("hooks.attach", (hookName, filter) => coreDeps.attachFilter(hookName, filter)),
|
|
53
|
-
|
|
54
|
-
if (!coreDeps.contributions)
|
|
55
|
-
throw new Error('plugin routes are not bound by this host');
|
|
56
|
-
coreDeps.contributions.routes.add(input, options);
|
|
57
|
-
}) },
|
|
58
|
-
tools: { add: gate("tools.register", (input, options = {}) => {
|
|
59
|
-
if (!coreDeps.contributions)
|
|
60
|
-
throw new Error('plugin tools are not bound by this host');
|
|
61
|
-
coreDeps.contributions.tools.add(input, options);
|
|
62
|
-
}) },
|
|
63
|
-
widgets: { add: gate("render.contribute", (input, options = {}) => {
|
|
64
|
-
if (!coreDeps.contributions)
|
|
65
|
-
throw new Error('plugin widgets are not bound by this host');
|
|
66
|
-
coreDeps.contributions.widgets.add(input, options);
|
|
67
|
-
}) },
|
|
41
|
+
...gatedContributionSurfaces(gate, coreDeps),
|
|
68
42
|
// V1 rationale retained: `ActionHookName`/`ContributionHookName` (@jini-ai/plugin-sdk hooks.ts) have no
|
|
69
43
|
// catalog members yet (hooks v2 plan §3.3 Waves 1/2 land in a later slice), so no name
|
|
70
44
|
// type-checks as an argument to either legacy surface. They remain present-but-unreachable,
|
|
71
45
|
// following the same "always present" contract as addFilter, gated on hooks.attach. There
|
|
72
46
|
// is still no action-hook coreDeps backing until a hook is cataloged. Explicit contribution
|
|
73
47
|
// records below now have real route/tool/widget owners and use those owners' capabilities.
|
|
74
|
-
// No action hooks are cataloged. Preserve
|
|
48
|
+
// No action hooks are cataloged. Preserve the callable denial boundary, but remove
|
|
75
49
|
// the silent no-op: a granted unsupported action fails explicitly until a real owner exists.
|
|
76
50
|
addAction: gate("hooks.attach", (..._args) => { throw new Error('no plugin action hooks are cataloged'); }),
|
|
77
51
|
addContribution: (input, options = {}) => {
|
|
@@ -97,4 +71,38 @@ export function buildCapabilityScopedSdk(required, _optional = {}) {
|
|
|
97
71
|
};
|
|
98
72
|
return required.pluginSdkBinding.buildSdk({ sdk });
|
|
99
73
|
}
|
|
74
|
+
function createSdkCapabilityGate(pluginId, granted) {
|
|
75
|
+
/**
|
|
76
|
+
* Wraps one capability-gated surface: returns `real` when `capability` is granted, otherwise a
|
|
77
|
+
* stub that synchronously throws `CapabilityDeniedError` when invoked. The binding
|
|
78
|
+
* property — every surface is always a present, callable function, never an absent property.
|
|
79
|
+
*/
|
|
80
|
+
return function gate(capability, real) {
|
|
81
|
+
if (granted.has(capability)) {
|
|
82
|
+
return real;
|
|
83
|
+
}
|
|
84
|
+
return ((..._args) => {
|
|
85
|
+
throw new CapabilityDeniedError(pluginId, capability);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function gatedContributionSurfaces(gate, coreDeps) {
|
|
90
|
+
return {
|
|
91
|
+
routes: { add: gate("http.route.register", (input, options = {}) => {
|
|
92
|
+
if (!coreDeps.contributions)
|
|
93
|
+
throw new Error('plugin routes are not bound by this host');
|
|
94
|
+
coreDeps.contributions.routes.add(input, options);
|
|
95
|
+
}) },
|
|
96
|
+
tools: { add: gate("tools.register", (input, options = {}) => {
|
|
97
|
+
if (!coreDeps.contributions)
|
|
98
|
+
throw new Error('plugin tools are not bound by this host');
|
|
99
|
+
coreDeps.contributions.tools.add(input, options);
|
|
100
|
+
}) },
|
|
101
|
+
widgets: { add: gate("render.contribute", (input, options = {}) => {
|
|
102
|
+
if (!coreDeps.contributions)
|
|
103
|
+
throw new Error('plugin widgets are not bound by this host');
|
|
104
|
+
coreDeps.contributions.widgets.add(input, options);
|
|
105
|
+
}) },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
100
108
|
//# sourceMappingURL=capability-sdk.js.map
|
|
@@ -6,7 +6,7 @@ import type { PluginDiscoveryRecord } from "./discovery-types.js";
|
|
|
6
6
|
import type { PluginManifestFieldDecl } from "./manifest-types.js";
|
|
7
7
|
/**
|
|
8
8
|
* @file Projects each ENABLED plugin-runtime plugin's own declared `fields[]` (manifest.ts,
|
|
9
|
-
*
|
|
9
|
+
* the manifest contract) into one real, `search_tools`-discoverable tool per plugin — the fix for the
|
|
10
10
|
* 2026-08-26 registration-gap audit (`ADS-memory/reports/2026-08-26-plugin-discoverability-audit.md`):
|
|
11
11
|
* a live, valid, tier-3 Word Count plugin was computing and storing a real per-post word count on
|
|
12
12
|
* every save, yet no agent-callable tool anywhere ever exposed it, so `search_tools` correctly
|
|
@@ -59,7 +59,7 @@ import type { PluginManifestFieldDecl } from "./manifest-types.js";
|
|
|
59
59
|
* ---------------------------------------------------------------------------
|
|
60
60
|
* Activation gate — the OPPOSITE default from Agent Plugins, and that is a real, disclosed decision
|
|
61
61
|
* ---------------------------------------------------------------------------
|
|
62
|
-
* `
|
|
62
|
+
* `packages/agent-plugins/src/lifecycle/activation.ts` treats an absent activation record as ACTIVE ("presence
|
|
63
63
|
* implies consent"). Plugin-runtime's own projection (`admin-response.ts`: `enabled: activation?.
|
|
64
64
|
* enabled ?? false`) is the opposite: absent means DISABLED. This loader follows plugin-runtime's own
|
|
65
65
|
* convention, not the Agent Plugins one it sits next to — a disabled plugin's `content.entry.
|
|
@@ -150,7 +150,7 @@ export interface PluginCapabilityToolText {
|
|
|
150
150
|
postId: string;
|
|
151
151
|
}, optional?: Record<string, never>) => string;
|
|
152
152
|
/** @agent-note Warning logged through `console.warn` when the per-call activation read throws and
|
|
153
|
-
* the call is denied. `detail` is
|
|
153
|
+
* the call is denied. `detail` is `describeErrorForLog` of the thrown value: its class and approved code, never its text. */
|
|
154
154
|
readonly activationReadDenied: (required: {
|
|
155
155
|
pluginId: string;
|
|
156
156
|
detail: string;
|