@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # @jini-ai/plugins
2
+
3
+ ## 0.4.0 — 2026-10-02
4
+
5
+ ### BREAKING
6
+
7
+ - Private glue package retains behavior and public barrels while process/source-grep artifacts are archived or consolidated.
8
+ - Distribution includes runtime output, release documentation and required assets only. Process records and per-job neutrality checks are no longer part of the package surface.
9
+
10
+ ## Unreleased
11
+
12
+ - Publish the plugin host runtime at universal `./host` and Node `./host/node`, `./host/worker`,
13
+ `./host/sql`; keep `./glue` unchanged. Require host SDK/catalog, declaration, tier, executable
14
+ import/digest, archive and storage-table ports; preserve package layout, diagnostics and states.
15
+ - Remove private-package status and configure public npm publishing without a version bump.
16
+ Host dependencies are optional peers under the 2026-10-07 install-isolation decision.
17
+ Copied behavior tests and entry-purity coverage await coordinator verification.
18
+
19
+
20
+ ### Integration of extracted APIs
21
+
22
+ - Complete the universal `./glue` surface: manifest validation, capability gates, dispatch resolution, content lifecycle/event attachment and isolated tool registration. Host vocabulary, wired sites, dispatcher and delegates remain required inputs; no new runtime dependencies.
23
+ - **BREAKING:** Empty glue attachment options use `Record<string, never>`, rejecting scalar options. Public functions, constructors and host delegates use required/optional argument objects; existing names are retained. See `API.md` for examples. Verification remains pending.
24
+
25
+ - Add host-independent glue validation, capability gates, dispatch and attachment delegates at `./glue`, with required vocabulary and host ports. The host runtime is now publishable; verification remains pending (owner directive).
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Open Design contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # `@jini-ai/plugins`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The `./glue` subpath provides host-independent manifest validation, capability gates, dispatch and attachment delegates. The package is publishable with public npm access.
4
+
5
+ Supply `vocabulary` to `validateGlueManifest`, `vocabulary` and `coreDelegates` to `buildGlueCapabilityGate`, and `wiredCallSites` to dispatch. Host delegates use required/optional argument objects. Content lifecycle and event failures propagate; tool contributions are quarantined independently. `registerTools` must mount a module atomically or throw without leaving a partial mount.
6
+
7
+ `./glue` is a universal runtime entry with no runtime dependencies. Every public callable takes
8
+ a required argument object and accepts an optional settings object; empty settings use
9
+ `Record<string, never>`. See [API.md](https://github.com/AINSEP/Jini/blob/main/packages/plugins/API.md) for the full glue surface and host-port examples.
10
+
11
+ ## What used to be here
12
+
13
+ Support for the third-party **Agent Plugins** open standard (types, validators) plus this
14
+ package's bundled plugins (`ui-ux-design`, `create-the host-theme`) lived here under a `./agent-plugins`
15
+ subpath through 2026-08-17. On 2026-08-18 all of that moved out to its own package,
16
+ **`@jini-ai/agent-plugins`**, since there was no longer a second plugin format sharing this
17
+ namespace to disambiguate against. See that package's README for everything Agent-Plugins-related.
18
+
19
+ ## Plugin host runtime
20
+
21
+ - `./host` is universal: manifest validation, claim conflicts, activation, quarantine, hook composition,
22
+ declarative-enable orchestration and uninstall policy. It has no Node imports or code evaluation.
23
+ - `./host/node` owns discovery, bounded package reads, installation and snapshots, and the ordered
24
+ integrity → SDK compatibility → injected import → setup pipeline.
25
+ - `./host/worker` provides the Tier-2 protocol, proxy importer and worker call orchestration.
26
+ - `./host/sql` adapts `StorageKernel` using required `tables: { activations }`; it retains the existing
27
+ `plugin_activations` columns without assuming a host table name.
28
+
29
+ All functions use `(required, optional = {})`. Registry methods take objects. Existing error
30
+ constructors and plugin SDK callbacks retain their established ABI. Bind `PluginSdkBinding` (hook
31
+ ids, semantics, runtime SDK version, export validation and SDK assembly), `capabilityVocabulary`,
32
+ `declarativeContentTypes`, and the host's `coreOwnerName`. Node loading requires `importModule`,
33
+ `verifyDigest` and `tierPolicy`; installation additionally requires `archiveReader`. These inputs
34
+ have no executable or product-policy defaults. The import port matches Phase 13's
35
+ `{ plugin, modulePath } → { exported } | refusal` contract structurally, without an L4 dependency.
36
+
37
+ The application owns contained executable import and fresh snapshot selection, including Tier-2
38
+ worker execution. Tier-1 never imports code, Tier-2 requires `tierPolicy.execution: 'worker'`, and
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 Tovu adapter.
41
+ The content-type grammar and create/write implementation remain host ports.
42
+
43
+ ```ts
44
+ import { validateManifest } from '@jini-ai/plugins/host';
45
+ const result = validateManifest({
46
+ manifest, folderName, builtInIds,
47
+ pluginSdkBinding, capabilityVocabulary, declarativeContentTypes, coreOwnerName,
48
+ }, {});
49
+ ```
50
+
51
+ Host-only packages are optional peers so installing the dependency-free `./glue` domain does not
52
+ install them. Hosts using `./host` must install `semver` and `@jini-ai/core`; SQL hosts also install
53
+ `kysely` and `@jini-ai/db`.
54
+
55
+ Historical note — 2026-08-18: [DR-005 portable package boundaries](../../docs/decisions/DR-005-portable-package-boundaries.md)
56
+ kept the host format reserved until a real consumer justified its implementation. The 2026-10-07
57
+ p6 extraction implements that format under the approved CMS/Jini modular design Rev 3.
58
+
59
+ ## Design decisions
60
+
61
+ - [Attachment vocabulary and failure containment are separate decisions](docs/decisions/DR-001-category-specific-glue-containment.md).
@@ -0,0 +1,10 @@
1
+ import type { GlueContentLifecycleFilter, GlueFieldDecl, GlueHostPort } from "../ports.js";
2
+ export interface AttachGlueContentLifecycleRequired {
3
+ readonly moduleId: string;
4
+ readonly filter: GlueContentLifecycleFilter;
5
+ readonly declaredFields: readonly GlueFieldDecl[];
6
+ readonly hostPort: Pick<GlueHostPort, "attachContentLifecycleFilter">;
7
+ }
8
+ export type AttachGlueContentLifecycleOptional = Record<string, never>;
9
+ export declare function attachGlueContentLifecycle(required: AttachGlueContentLifecycleRequired, _optional?: AttachGlueContentLifecycleOptional): void;
10
+ //# sourceMappingURL=content-lifecycle.d.ts.map
@@ -0,0 +1,5 @@
1
+ export function attachGlueContentLifecycle(required, _optional = {}) {
2
+ const { moduleId, filter, declaredFields, hostPort } = required;
3
+ hostPort.attachContentLifecycleFilter({ moduleId, filter, declaredFields });
4
+ }
5
+ //# sourceMappingURL=content-lifecycle.js.map
@@ -0,0 +1,12 @@
1
+ import type { GlueHostPort } from "../ports.js";
2
+ export interface SubscribeGlueEventRequired {
3
+ readonly moduleId: string;
4
+ readonly eventName: string;
5
+ readonly handler: (required: {
6
+ payload: unknown;
7
+ }) => Promise<void> | void;
8
+ readonly hostPort: Pick<GlueHostPort, "subscribeEvent">;
9
+ }
10
+ export type SubscribeGlueEventOptional = Record<string, never>;
11
+ export declare function subscribeGlueEvent(required: SubscribeGlueEventRequired, _optional?: SubscribeGlueEventOptional): void;
12
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,5 @@
1
+ export function subscribeGlueEvent(required, _optional = {}) {
2
+ const { moduleId, eventName, handler, hostPort } = required;
3
+ hostPort.subscribeEvent({ moduleId, eventName, handler });
4
+ }
5
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1,23 @@
1
+ import type { GlueHostPort, GlueToolRegistration } from "../ports.js";
2
+ export interface GlueToolModuleContribution {
3
+ readonly moduleId: string;
4
+ readonly build: (required: Record<string, never>) => readonly GlueToolRegistration[];
5
+ }
6
+ export interface MergeGlueToolRegistrationsRequired {
7
+ readonly coreToolIds: readonly string[];
8
+ readonly glueModules: readonly GlueToolModuleContribution[];
9
+ readonly hostPort: Pick<GlueHostPort, "registerTools">;
10
+ }
11
+ export type MergeGlueToolRegistrationsOptional = Record<string, never>;
12
+ export type GlueToolQuarantineReason = "THROW" | "DUPLICATE_TOOL_ID";
13
+ export interface GlueToolQuarantineEntry {
14
+ readonly moduleId: string;
15
+ readonly reason: GlueToolQuarantineReason;
16
+ readonly detail: string;
17
+ }
18
+ export interface MergeGlueToolRegistrationsResult {
19
+ readonly registeredModuleIds: readonly string[];
20
+ readonly quarantined: readonly GlueToolQuarantineEntry[];
21
+ }
22
+ export declare function mergeGlueToolRegistrations(required: MergeGlueToolRegistrationsRequired, _optional?: MergeGlueToolRegistrationsOptional): MergeGlueToolRegistrationsResult;
23
+ //# sourceMappingURL=tool-registration.d.ts.map
@@ -0,0 +1,43 @@
1
+ export function mergeGlueToolRegistrations(required, _optional = {}) {
2
+ const { coreToolIds, glueModules, hostPort } = required;
3
+ const claimedToolIds = new Set(coreToolIds);
4
+ const registeredModuleIds = [];
5
+ const quarantined = [];
6
+ const quarantine = (moduleId, reason, detail) => {
7
+ quarantined.push({ moduleId, reason, detail });
8
+ };
9
+ const messageOf = (error) => (error instanceof Error ? error.message : String(error));
10
+ for (const module of glueModules) {
11
+ let registrations;
12
+ try {
13
+ registrations = module.build({});
14
+ }
15
+ catch (error) {
16
+ quarantine(module.moduleId, "THROW", `registration build failed: ${messageOf(error)}`);
17
+ continue;
18
+ }
19
+ const moduleToolIds = new Set();
20
+ const duplicate = registrations.find((registration) => {
21
+ if (claimedToolIds.has(registration.toolId) || moduleToolIds.has(registration.toolId))
22
+ return true;
23
+ moduleToolIds.add(registration.toolId);
24
+ return false;
25
+ });
26
+ if (duplicate) {
27
+ quarantine(module.moduleId, "DUPLICATE_TOOL_ID", `tool id '${duplicate.toolId}' is already registered by core or an earlier glue module`);
28
+ continue;
29
+ }
30
+ try {
31
+ hostPort.registerTools({ moduleId: module.moduleId, registrations });
32
+ }
33
+ catch (error) {
34
+ quarantine(module.moduleId, "THROW", `host port registration failed: ${messageOf(error)}`);
35
+ continue;
36
+ }
37
+ for (const registration of registrations)
38
+ claimedToolIds.add(registration.toolId);
39
+ registeredModuleIds.push(module.moduleId);
40
+ }
41
+ return { registeredModuleIds, quarantined };
42
+ }
43
+ //# sourceMappingURL=tool-registration.js.map
@@ -0,0 +1,20 @@
1
+ import type { GlueCapability } from './manifest.js';
2
+ export declare class GlueCapabilityDeniedError extends Error {
3
+ readonly moduleId: string;
4
+ readonly capability: GlueCapability;
5
+ constructor(required: {
6
+ moduleId: string;
7
+ capability: GlueCapability;
8
+ }, _optional?: Record<string, never>);
9
+ }
10
+ export type GlueCapabilityDelegate = (required: Readonly<Record<string, unknown>>, optional?: Readonly<Record<string, unknown>>) => unknown;
11
+ export interface BuildGlueCapabilityGateRequired {
12
+ readonly moduleId: string;
13
+ readonly vocabulary: readonly GlueCapability[];
14
+ readonly capabilities: readonly GlueCapability[];
15
+ readonly coreDelegates: Readonly<Record<GlueCapability, GlueCapabilityDelegate>>;
16
+ }
17
+ export type BuildGlueCapabilityGateOptional = Record<string, never>;
18
+ /** Grants and delegate references are snapshots; handles are frozen and denied slots stay callable. */
19
+ export declare function buildGlueCapabilityGate(required: BuildGlueCapabilityGateRequired, _optional?: BuildGlueCapabilityGateOptional): Readonly<Record<GlueCapability, GlueCapabilityDelegate>>;
20
+ //# sourceMappingURL=capability-gate.d.ts.map
@@ -0,0 +1,23 @@
1
+ export class GlueCapabilityDeniedError extends Error {
2
+ moduleId;
3
+ capability;
4
+ constructor(required, _optional = {}) {
5
+ super(`module '${required.moduleId}' invoked '${required.capability}' without declaring it in its manifest capabilities`);
6
+ this.name = 'GlueCapabilityDeniedError';
7
+ this.moduleId = required.moduleId;
8
+ this.capability = required.capability;
9
+ }
10
+ }
11
+ /** Grants and delegate references are snapshots; handles are frozen and denied slots stay callable. */
12
+ export function buildGlueCapabilityGate(required, _optional = {}) {
13
+ const granted = new Set(required.capabilities);
14
+ const handle = Object.create(null);
15
+ for (const capability of required.vocabulary) {
16
+ const delegate = Object.hasOwn(required.coreDelegates, capability) ? required.coreDelegates[capability] : undefined;
17
+ handle[capability] = granted.has(capability) && typeof delegate === 'function'
18
+ ? delegate
19
+ : (_required, _optional) => { throw new GlueCapabilityDeniedError({ moduleId: required.moduleId, capability }); };
20
+ }
21
+ return Object.freeze(handle);
22
+ }
23
+ //# sourceMappingURL=capability-gate.js.map
@@ -0,0 +1,20 @@
1
+ export type GlueDispatcherPort = (required: {
2
+ moduleId: string;
3
+ callSite: string;
4
+ payload: Readonly<Record<string, unknown>>;
5
+ }) => unknown;
6
+ /** Host delegates define what a wired call site does; unwired sites never silently dispatch. */
7
+ export declare function dispatchGlueAttachment(required: {
8
+ moduleId: string;
9
+ callSite: string;
10
+ payload: Readonly<Record<string, unknown>>;
11
+ wiredCallSites: readonly string[];
12
+ dispatch: GlueDispatcherPort;
13
+ }, _optional?: Record<string, never>): {
14
+ readonly wired: false;
15
+ readonly code: 'UNWIRED_CALL_SITE';
16
+ } | {
17
+ readonly wired: true;
18
+ readonly result: unknown;
19
+ };
20
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { resolveCallSiteDispatch } from './manifest.js';
2
+ /** Host delegates define what a wired call site does; unwired sites never silently dispatch. */
3
+ export function dispatchGlueAttachment(required, _optional = {}) {
4
+ const status = resolveCallSiteDispatch(required);
5
+ if (!status.wired)
6
+ return status;
7
+ return { wired: true, result: required.dispatch({ moduleId: required.moduleId, callSite: required.callSite, payload: required.payload }) };
8
+ }
9
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1,8 @@
1
+ export * from './manifest.js';
2
+ export * from './ports.js';
3
+ export * from './capability-gate.js';
4
+ export * from './dispatch.js';
5
+ export * from './attachment-points/content-lifecycle.js';
6
+ export * from './attachment-points/events.js';
7
+ export * from './attachment-points/tool-registration.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,8 @@
1
+ export * from './manifest.js';
2
+ export * from './ports.js';
3
+ export * from './capability-gate.js';
4
+ export * from './dispatch.js';
5
+ export * from './attachment-points/content-lifecycle.js';
6
+ export * from './attachment-points/events.js';
7
+ export * from './attachment-points/tool-registration.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,43 @@
1
+ /** Host-independent collect-all manifest validation; vocabularies are host inputs. */
2
+ export interface GlueVocabulary {
3
+ readonly capabilities: readonly string[];
4
+ readonly callSites: readonly string[];
5
+ }
6
+ export type GlueCallSite = string;
7
+ export type GlueCapability = string;
8
+ export interface GlueManifestAttachment {
9
+ readonly callSite: GlueCallSite;
10
+ readonly [payloadKey: string]: unknown;
11
+ }
12
+ export interface GlueManifest {
13
+ readonly id: string;
14
+ readonly version: string;
15
+ readonly sdkRange: string;
16
+ readonly capabilities: readonly GlueCapability[];
17
+ readonly attachments: readonly GlueManifestAttachment[];
18
+ }
19
+ export interface GlueManifestValidationError {
20
+ readonly code: string;
21
+ readonly file: string | null;
22
+ readonly message: string;
23
+ }
24
+ export interface ValidateGlueManifestRequired {
25
+ readonly manifest: unknown;
26
+ readonly vocabulary: GlueVocabulary;
27
+ }
28
+ export type ValidateGlueManifestOptional = Record<string, never>;
29
+ export interface ValidateGlueManifestResult {
30
+ readonly errors: readonly GlueManifestValidationError[];
31
+ }
32
+ export declare function validateGlueManifest(required: ValidateGlueManifestRequired, _optional?: ValidateGlueManifestOptional): ValidateGlueManifestResult;
33
+ export type GlueCallSiteDispatchStatus = {
34
+ readonly wired: true;
35
+ } | {
36
+ readonly wired: false;
37
+ readonly code: "UNWIRED_CALL_SITE";
38
+ };
39
+ export declare function resolveCallSiteDispatch({ callSite, wiredCallSites }: {
40
+ callSite: GlueCallSite;
41
+ wiredCallSites: readonly GlueCallSite[];
42
+ }, _optional?: Record<string, never>): GlueCallSiteDispatchStatus;
43
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1,106 @@
1
+ const REQUIRED_KEYS = ["id", "version", "sdkRange", "capabilities", "attachments"];
2
+ const ALLOWED_KEYS = new Set(REQUIRED_KEYS);
3
+ const ID_PATTERN = /^[a-z0-9-]+$/;
4
+ const MAX_ID_LENGTH = 50;
5
+ function malformed(message) {
6
+ return { code: "MANIFEST_MALFORMED", file: null, message };
7
+ }
8
+ function validateKeys(raw) {
9
+ const errors = [];
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;
21
+ }
22
+ function validateId(raw) {
23
+ const errors = [];
24
+ const id = typeof raw.id === "string" ? raw.id : undefined;
25
+ if (raw.id !== undefined && id === undefined) {
26
+ errors.push(malformed("'id' must be a string"));
27
+ }
28
+ if (id !== undefined && (!ID_PATTERN.test(id) || id.length < 1 || id.length > MAX_ID_LENGTH)) {
29
+ errors.push(malformed(`id '${id}' must match ${ID_PATTERN} and be 1-${MAX_ID_LENGTH} characters`));
30
+ }
31
+ return errors;
32
+ }
33
+ function validateVersionAndSdkRange(raw) {
34
+ const errors = [];
35
+ if (raw.version !== undefined && typeof raw.version !== "string") {
36
+ errors.push(malformed("'version' must be a string"));
37
+ }
38
+ if (raw.sdkRange !== undefined && typeof raw.sdkRange !== "string") {
39
+ errors.push(malformed("'sdkRange' must be a string"));
40
+ }
41
+ return errors;
42
+ }
43
+ function validateCapabilities(raw, vocabulary) {
44
+ const errors = [];
45
+ const capabilities = Array.isArray(raw.capabilities) ? raw.capabilities : [];
46
+ if (raw.capabilities !== undefined && !Array.isArray(raw.capabilities)) {
47
+ errors.push(malformed("'capabilities' must be an array"));
48
+ }
49
+ for (const capability of capabilities) {
50
+ if (typeof capability !== "string" || !vocabulary.capabilities.includes(capability)) {
51
+ errors.push({
52
+ code: "CAPABILITY_UNKNOWN",
53
+ file: null,
54
+ message: `capability '${String(capability)}' is outside the supplied capability vocabulary`,
55
+ });
56
+ }
57
+ }
58
+ return errors;
59
+ }
60
+ function validateAttachment(attachment, vocabulary) {
61
+ if (typeof attachment !== "object" || attachment === null || Array.isArray(attachment)) {
62
+ return [malformed("each 'attachments' entry must be an object")];
63
+ }
64
+ const callSite = attachment.callSite;
65
+ if (typeof callSite !== "string" || !vocabulary.callSites.includes(callSite)) {
66
+ return [
67
+ {
68
+ code: "CALL_SITE_UNKNOWN",
69
+ file: null,
70
+ message: `call site '${String(callSite)}' is outside the supplied call-site vocabulary`,
71
+ },
72
+ ];
73
+ }
74
+ return [];
75
+ }
76
+ function validateAttachments(raw, vocabulary) {
77
+ const errors = [];
78
+ const attachments = Array.isArray(raw.attachments) ? raw.attachments : [];
79
+ if (raw.attachments !== undefined && !Array.isArray(raw.attachments)) {
80
+ errors.push(malformed("'attachments' must be an array"));
81
+ }
82
+ for (const attachment of attachments) {
83
+ errors.push(...validateAttachment(attachment, vocabulary));
84
+ }
85
+ return errors;
86
+ }
87
+ export function validateGlueManifest(required, _optional = {}) {
88
+ const { manifest, vocabulary } = required;
89
+ if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
90
+ return { errors: [malformed("glue manifest must be a JSON object")] };
91
+ }
92
+ // Treat the input as a read-only bag of unknown values — never assigned back into.
93
+ const raw = manifest;
94
+ const errors = [
95
+ ...validateKeys(raw),
96
+ ...validateId(raw),
97
+ ...validateVersionAndSdkRange(raw),
98
+ ...validateCapabilities(raw, vocabulary),
99
+ ...validateAttachments(raw, vocabulary),
100
+ ];
101
+ return { errors };
102
+ }
103
+ export function resolveCallSiteDispatch({ callSite, wiredCallSites }, _optional = {}) {
104
+ return wiredCallSites.includes(callSite) ? { wired: true } : { wired: false, code: "UNWIRED_CALL_SITE" };
105
+ }
106
+ //# sourceMappingURL=manifest.js.map