@jini-ai/plugins 0.6.15-rc.2 → 0.6.16

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 (123) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/glue/attachment-points/tool-registration.js +14 -8
  3. package/dist/host/browser-providers.js +8 -1
  4. package/dist/host/bundled-initialization.js +12 -11
  5. package/dist/host/claim-conflicts.js +3 -4
  6. package/dist/host/contributions.d.ts +3 -2
  7. package/dist/host/contributions.js +15 -9
  8. package/dist/host/declarative-enable.js +4 -2
  9. package/dist/host/hook-registry.js +4 -3
  10. package/dist/host/node/browser-provider-assets.js +3 -2
  11. package/dist/host/node/install.js +9 -6
  12. package/dist/host/node/package-files.js +12 -7
  13. package/dist/host/node/source-drafts.js +14 -4
  14. package/dist/host/plugin-claims.js +5 -1
  15. package/dist/host/provider-contributions.js +9 -9
  16. package/dist/host/provider-host.js +16 -9
  17. package/dist/host/provider-setting-required.js +12 -2
  18. package/dist/host/sql/repo.js +4 -1
  19. package/package.json +18 -12
  20. package/dist/glue/attachment-points/content-lifecycle.d.ts.map +0 -1
  21. package/dist/glue/attachment-points/content-lifecycle.js.map +0 -1
  22. package/dist/glue/attachment-points/events.d.ts.map +0 -1
  23. package/dist/glue/attachment-points/events.js.map +0 -1
  24. package/dist/glue/attachment-points/tool-registration.d.ts.map +0 -1
  25. package/dist/glue/attachment-points/tool-registration.js.map +0 -1
  26. package/dist/glue/capability-gate.d.ts.map +0 -1
  27. package/dist/glue/capability-gate.js.map +0 -1
  28. package/dist/glue/dispatch.d.ts.map +0 -1
  29. package/dist/glue/dispatch.js.map +0 -1
  30. package/dist/glue/index.d.ts.map +0 -1
  31. package/dist/glue/index.js.map +0 -1
  32. package/dist/glue/manifest.d.ts.map +0 -1
  33. package/dist/glue/manifest.js.map +0 -1
  34. package/dist/glue/ports.d.ts.map +0 -1
  35. package/dist/glue/ports.js.map +0 -1
  36. package/dist/host/activation.d.ts.map +0 -1
  37. package/dist/host/activation.js.map +0 -1
  38. package/dist/host/attach-loaded-plugin.d.ts.map +0 -1
  39. package/dist/host/attach-loaded-plugin.js.map +0 -1
  40. package/dist/host/browser-providers.d.ts.map +0 -1
  41. package/dist/host/browser-providers.js.map +0 -1
  42. package/dist/host/bundled-initialization.d.ts.map +0 -1
  43. package/dist/host/bundled-initialization.js.map +0 -1
  44. package/dist/host/capability-sdk.d.ts.map +0 -1
  45. package/dist/host/capability-sdk.js.map +0 -1
  46. package/dist/host/claim-conflicts.d.ts.map +0 -1
  47. package/dist/host/claim-conflicts.js.map +0 -1
  48. package/dist/host/contributions.d.ts.map +0 -1
  49. package/dist/host/contributions.js.map +0 -1
  50. package/dist/host/declarative-enable.d.ts.map +0 -1
  51. package/dist/host/declarative-enable.js.map +0 -1
  52. package/dist/host/discovery-types.d.ts.map +0 -1
  53. package/dist/host/discovery-types.js.map +0 -1
  54. package/dist/host/errors.d.ts.map +0 -1
  55. package/dist/host/errors.js.map +0 -1
  56. package/dist/host/hook-registry.d.ts.map +0 -1
  57. package/dist/host/hook-registry.js.map +0 -1
  58. package/dist/host/index.d.ts.map +0 -1
  59. package/dist/host/index.js.map +0 -1
  60. package/dist/host/manifest-types.d.ts.map +0 -1
  61. package/dist/host/manifest-types.js.map +0 -1
  62. package/dist/host/manifest.d.ts.map +0 -1
  63. package/dist/host/manifest.js.map +0 -1
  64. package/dist/host/node/browser-provider-assets.d.ts.map +0 -1
  65. package/dist/host/node/browser-provider-assets.js.map +0 -1
  66. package/dist/host/node/discovery.d.ts.map +0 -1
  67. package/dist/host/node/discovery.js.map +0 -1
  68. package/dist/host/node/index.d.ts.map +0 -1
  69. package/dist/host/node/index.js.map +0 -1
  70. package/dist/host/node/install.d.ts.map +0 -1
  71. package/dist/host/node/install.js.map +0 -1
  72. package/dist/host/node/loader.d.ts.map +0 -1
  73. package/dist/host/node/loader.js.map +0 -1
  74. package/dist/host/node/module-snapshot.d.ts.map +0 -1
  75. package/dist/host/node/module-snapshot.js.map +0 -1
  76. package/dist/host/node/open-flags.d.ts.map +0 -1
  77. package/dist/host/node/open-flags.js.map +0 -1
  78. package/dist/host/node/package-files.d.ts.map +0 -1
  79. package/dist/host/node/package-files.js.map +0 -1
  80. package/dist/host/node/provider-artifact.d.ts.map +0 -1
  81. package/dist/host/node/provider-artifact.js.map +0 -1
  82. package/dist/host/node/source-drafts.d.ts.map +0 -1
  83. package/dist/host/node/source-drafts.js.map +0 -1
  84. package/dist/host/plugin-claims.d.ts.map +0 -1
  85. package/dist/host/plugin-claims.js.map +0 -1
  86. package/dist/host/plugin-format.d.ts.map +0 -1
  87. package/dist/host/plugin-format.js.map +0 -1
  88. package/dist/host/ports.d.ts.map +0 -1
  89. package/dist/host/ports.js.map +0 -1
  90. package/dist/host/provider-config-source.d.ts.map +0 -1
  91. package/dist/host/provider-config-source.js.map +0 -1
  92. package/dist/host/provider-contributions.d.ts.map +0 -1
  93. package/dist/host/provider-contributions.js.map +0 -1
  94. package/dist/host/provider-host.d.ts.map +0 -1
  95. package/dist/host/provider-host.js.map +0 -1
  96. package/dist/host/provider-setting-required.d.ts.map +0 -1
  97. package/dist/host/provider-setting-required.js.map +0 -1
  98. package/dist/host/provider-settings-migrations.d.ts.map +0 -1
  99. package/dist/host/provider-settings-migrations.js.map +0 -1
  100. package/dist/host/quarantine.d.ts.map +0 -1
  101. package/dist/host/quarantine.js.map +0 -1
  102. package/dist/host/repo.memory.d.ts.map +0 -1
  103. package/dist/host/repo.memory.js.map +0 -1
  104. package/dist/host/source-policy.d.ts.map +0 -1
  105. package/dist/host/source-policy.js.map +0 -1
  106. package/dist/host/sql/index.d.ts.map +0 -1
  107. package/dist/host/sql/index.js.map +0 -1
  108. package/dist/host/sql/repo.d.ts.map +0 -1
  109. package/dist/host/sql/repo.js.map +0 -1
  110. package/dist/host/sql/repo.rows.d.ts.map +0 -1
  111. package/dist/host/sql/repo.rows.js.map +0 -1
  112. package/dist/host/tool-contributions.d.ts.map +0 -1
  113. package/dist/host/tool-contributions.js.map +0 -1
  114. package/dist/host/uninstall.d.ts.map +0 -1
  115. package/dist/host/uninstall.js.map +0 -1
  116. package/dist/host/worker/import-seam.d.ts.map +0 -1
  117. package/dist/host/worker/import-seam.js.map +0 -1
  118. package/dist/host/worker/index.d.ts.map +0 -1
  119. package/dist/host/worker/index.js.map +0 -1
  120. package/dist/host/worker/protocol.d.ts.map +0 -1
  121. package/dist/host/worker/protocol.js.map +0 -1
  122. package/dist/host/worker/run-call.d.ts.map +0 -1
  123. package/dist/host/worker/run-call.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @jini-ai/plugins
2
2
 
3
+ ## 0.6.15
4
+
5
+ ### Minor Changes
6
+
7
+ - Release standalone provider distributions and a metadata-only plugin catalog in the
8
+ fixed 0.6.15 release group. Hosts explicitly select @jini-ai/plugin-<id> packages
9
+ instead of the @jini-ai/provider-plugins aggregate; installing a package never
10
+ installs another plugin. Existing artifact IDs, contracts, integrity verification,
11
+ installers and loaders are preserved, including commerce Phase 1's Stripe API.
12
+
13
+ The aggregate becomes private build tooling. After rc.2 consumers migrate, deprecate
14
+ its last verified published version with the standalone mapping; keep old tarballs.
15
+ See docs/plugin-packages-migration.md for host migration and first publication.
16
+
3
17
  ## 0.6.13
4
18
 
5
19
  ### Patch Changes
@@ -7,14 +7,15 @@ export function mergeGlueToolRegistrations(required, _optional = {}) {
7
7
  quarantined.push({ moduleId, reason, detail });
8
8
  };
9
9
  const messageOf = (error) => (error instanceof Error ? error.message : String(error));
10
- for (const module of glueModules) {
10
+ // A module either registers all its tools or is quarantined with the reason; core ids and
11
+ // earlier modules' ids are never shadowed.
12
+ const registerModule = (module) => {
11
13
  let registrations;
12
14
  try {
13
15
  registrations = module.build({});
14
16
  }
15
17
  catch (error) {
16
- quarantine(module.moduleId, "THROW", `registration build failed: ${messageOf(error)}`);
17
- continue;
18
+ return { reason: "THROW", detail: `registration build failed: ${messageOf(error)}` };
18
19
  }
19
20
  const moduleToolIds = new Set();
20
21
  const duplicate = registrations.find((registration) => {
@@ -24,19 +25,24 @@ export function mergeGlueToolRegistrations(required, _optional = {}) {
24
25
  return false;
25
26
  });
26
27
  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;
28
+ return { reason: "DUPLICATE_TOOL_ID", detail: `tool id '${duplicate.toolId}' is already registered by core or an earlier glue module` };
29
29
  }
30
30
  try {
31
31
  hostPort.registerTools({ moduleId: module.moduleId, registrations });
32
32
  }
33
33
  catch (error) {
34
- quarantine(module.moduleId, "THROW", `host port registration failed: ${messageOf(error)}`);
35
- continue;
34
+ return { reason: "THROW", detail: `host port registration failed: ${messageOf(error)}` };
36
35
  }
37
36
  for (const registration of registrations)
38
37
  claimedToolIds.add(registration.toolId);
39
- registeredModuleIds.push(module.moduleId);
38
+ return undefined;
39
+ };
40
+ for (const module of glueModules) {
41
+ const failure = registerModule(module);
42
+ if (failure)
43
+ quarantine(module.moduleId, failure.reason, failure.detail);
44
+ else
45
+ registeredModuleIds.push(module.moduleId);
40
46
  }
41
47
  return { registeredModuleIds, quarantined };
42
48
  }
@@ -22,13 +22,20 @@ function validateBrowserProviderDeclaration({ provider, ids }, _options = {}) {
22
22
  errors.push('Chart kinds must be unique non-empty strings.');
23
23
  return errors;
24
24
  }
25
+ /** A plugin-relative `client/` file of the expected type whose bytes the integrity map covers. */
26
+ function isDigestCoveredClientAsset({ file, suffix, integrity }) {
27
+ if (typeof file !== 'string' || !file.startsWith('client/'))
28
+ return false;
29
+ const shapeValid = isPluginRelativePath({ path: file }) && suffix.test(file);
30
+ return shapeValid && /^sha256-[0-9a-f]{64}$/.test(String(integrity[file]));
31
+ }
25
32
  function validateBrowserProviderAssets({ provider, integrity }, _options = {}) {
26
33
  const errors = [];
27
34
  for (const [key, suffix] of [['javascript', /\.(?:m?js)$/], ['stylesheet', /\.css$/]]) {
28
35
  const file = provider[key];
29
36
  if (key === 'stylesheet' && file === undefined)
30
37
  continue;
31
- if (typeof file !== 'string' || !isPluginRelativePath({ path: file }) || !file.startsWith('client/') || !suffix.test(file) || !/^sha256-[0-9a-f]{64}$/.test(String(integrity[file])))
38
+ if (!isDigestCoveredClientAsset({ file, suffix, integrity }))
32
39
  errors.push(`Browser provider ${key} must name a digest-covered client asset.`);
33
40
  }
34
41
  return errors;
@@ -9,19 +9,20 @@ export async function initializeBundledPlugins({ deps, input }, _options = {}) {
9
9
  const enabled = [];
10
10
  const skipped = [];
11
11
  const failed = [];
12
+ // Already-activated and non-bundled ids are skipped; only a fresh bundled plugin is enabled.
13
+ const initializeOne = async (pluginId) => {
14
+ if (await deps.repo.getActivation({ workspaceId: input.workspaceId, pluginId }))
15
+ return 'skipped';
16
+ const bundled = deps.discovery.find((record) => record.id === pluginId && record.source === 'built-in');
17
+ if (!bundled)
18
+ return 'skipped';
19
+ await setPluginEnabled({ deps, input: { workspaceId: input.workspaceId, pluginId, enabled: true } });
20
+ return 'enabled';
21
+ };
12
22
  for (const pluginId of new Set(input.pluginIds)) {
13
23
  try {
14
- if (await deps.repo.getActivation({ workspaceId: input.workspaceId, pluginId })) {
15
- skipped.push(pluginId);
16
- continue;
17
- }
18
- const bundled = deps.discovery.find((record) => record.id === pluginId && record.source === 'built-in');
19
- if (!bundled) {
20
- skipped.push(pluginId);
21
- continue;
22
- }
23
- await setPluginEnabled({ deps, input: { workspaceId: input.workspaceId, pluginId, enabled: true } });
24
- enabled.push(pluginId);
24
+ const outcome = await initializeOne(pluginId);
25
+ (outcome === 'enabled' ? enabled : skipped).push(pluginId);
25
26
  }
26
27
  catch (error) {
27
28
  failed.push({ pluginId, error });
@@ -89,9 +89,10 @@ function slotsFor(claim, rules) {
89
89
  /** The first already-held slot a pending slot collides with, if any (rule 2: shared+shared never
90
90
  * collides; anything involving an exclusive claim does). */
91
91
  function findHolder(held, ownerId, pending) {
92
+ const bothShared = (each) => each.mode === "shared" && pending.claim.mode === "shared";
92
93
  return held.find((each) => each.ownerId !== ownerId &&
93
94
  each.kind === pending.claim.kind &&
94
- !(each.mode === "shared" && pending.claim.mode === "shared") &&
95
+ !bothShared(each) &&
95
96
  slotsOverlap(each.slot, pending.slot));
96
97
  }
97
98
  /** Every conflict one owner has against what is already held; one entry per distinct claim. */
@@ -99,9 +100,7 @@ function conflictsFor(held, owner, pending) {
99
100
  const conflicts = [];
100
101
  const reported = new Set();
101
102
  for (const each of pending) {
102
- if (reported.has(each.claim))
103
- continue;
104
- const holder = findHolder(held, owner.id, each);
103
+ const holder = reported.has(each.claim) ? undefined : findHolder(held, owner.id, each);
105
104
  if (!holder)
106
105
  continue;
107
106
  reported.add(each.claim);
@@ -1,6 +1,7 @@
1
1
  /** Executable contribution admission on the existing plugin loader, never a second loader.
2
2
  * Captures stay private until setup succeeds. A sealed generation cannot register from a timer.
3
- * Tier-3 currently runs with full in-process authority; TODO: hardened worker at this boundary. */
3
+ * Tier-3 currently runs with full in-process authority; a hardened worker at this boundary is
4
+ * still to come. */
4
5
  import { type PluginProviderContribution } from './provider-contributions.js';
5
6
  import type { PluginManifest } from './manifest-types.js';
6
7
  import type { PluginSdk } from './ports.js';
@@ -117,7 +118,7 @@ export interface PluginContributionRegistry {
117
118
  export declare function createPluginContributionRegistry(_required: Record<string, never>, _optional?: Record<string, never>): PluginContributionRegistry;
118
119
  /** Resolves only named public fragments, isolating failures and bounding the awaited work.
119
120
  * Validation is an injected host renderer port; plugins cannot substitute their own validator.
120
- * TODO: client enhancement JS waits for an ADR-025 owner amendment. */
121
+ * Client enhancement JS is still pending: it waits for an ADR-025 owner amendment. */
121
122
  export declare function renderPluginWidgetFragments(required: {
122
123
  registry: PluginContributionRegistry;
123
124
  names: readonly string[];
@@ -1,6 +1,7 @@
1
1
  /** Executable contribution admission on the existing plugin loader, never a second loader.
2
2
  * Captures stay private until setup succeeds. A sealed generation cannot register from a timer.
3
- * Tier-3 currently runs with full in-process authority; TODO: hardened worker at this boundary. */
3
+ * Tier-3 currently runs with full in-process authority; a hardened worker at this boundary is
4
+ * still to come. */
4
5
  import { PLUGIN_PROVIDER_CAPABILITY, isPluginProviderDeclaration } from './provider-contributions.js';
5
6
  import { createContributionRegistry } from '@jini-ai/core/contribution-registry';
6
7
  import { normalizeRoute, resolveClaimConflicts } from './claim-conflicts.js';
@@ -9,18 +10,26 @@ export const PLUGIN_CONTRIBUTION_CAPABILITIES = ['http.route.register', 'tools.r
9
10
  export function pluginToolIdFor(required, _optional = {}) {
10
11
  return `p_${required.pluginId.replace(/-/g, '_')}__${required.name}`;
11
12
  }
13
+ /** One route segment: a literal word (letters, digits, `_`, `-`) or an Express `:param`. */
14
+ const ROUTE_SEGMENT = String.raw `(?:[\w-]+|:[a-zA-Z]\w*)`;
15
+ const PLUGIN_ROUTE_PATH = new RegExp(String.raw `^/${ROUTE_SEGMENT}(?:/${ROUTE_SEGMENT})*/?$`);
12
16
  /** Relative route grammar intentionally excludes wildcard/regex routes: a handler cannot widen
13
17
  * its declared claim or leave /api/p/<id>. Express owns parameter matching. */
14
18
  export function validatePluginRoute(required, _optional = {}) {
15
19
  if (!/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(required.method))
16
20
  throw new Error('unsupported plugin route method');
17
- if (!/^\/(?:[a-zA-Z0-9_-]+|:[a-zA-Z][a-zA-Z0-9_]*)(?:\/(?:[a-zA-Z0-9_-]+|:[a-zA-Z][a-zA-Z0-9_]*))*\/?$/.test(required.path) && required.path !== '/')
21
+ if (!PLUGIN_ROUTE_PATH.test(required.path) && required.path !== '/')
18
22
  throw new Error('unsafe plugin route path');
19
23
  }
20
24
  /** Enforces the object-schema contract before and after plugin-controlled JSON serialization.
21
25
  * Throws a fixed admission error. O(1) time/space. */
26
+ function isObjectSchema(schema) {
27
+ if (!schema || typeof schema !== 'object' || Array.isArray(schema))
28
+ return false;
29
+ return 'type' in schema && schema.type === 'object';
30
+ }
22
31
  function requireObjectSchema({ schema }, _options = {}) {
23
- if (!schema || typeof schema !== 'object' || Array.isArray(schema) || !('type' in schema) || schema.type !== 'object')
32
+ if (!isObjectSchema(schema))
24
33
  throw new Error('plugin tool input schema must describe an object');
25
34
  return schema;
26
35
  }
@@ -55,7 +64,7 @@ export function createPluginContributionCapture(required, optional = {}) {
55
64
  if (!/^[a-z][a-z0-9_-]{0,63}$/.test(name) || !declarations?.includes(name))
56
65
  throw new Error(`undeclared plugin contribution '${name}'`);
57
66
  };
58
- const capture = {
67
+ return {
59
68
  providers: { register(value, _optional = {}) {
60
69
  check();
61
70
  if (manifest.tier !== 'tier-3' || !isPluginProviderDeclaration({ value }) || typeof value.factory !== 'function')
@@ -104,7 +113,6 @@ export function createPluginContributionCapture(required, optional = {}) {
104
113
  return Object.freeze({ pluginId: manifest.id, sdk, routes: Object.freeze([...routes]), tools: Object.freeze([...tools]), widgets: Object.freeze([...widgets]), providers: Object.freeze([...providers]) });
105
114
  },
106
115
  };
107
- return capture;
108
116
  }
109
117
  /** Reuses core's contribution owner and the existing conflict detector. Replacement and detach
110
118
  * rebuild a small plugin collection atomically; readers always see complete generations. */
@@ -150,7 +158,7 @@ export function createPluginContributionRegistry(_required, _optional = {}) {
150
158
  }
151
159
  /** Resolves only named public fragments, isolating failures and bounding the awaited work.
152
160
  * Validation is an injected host renderer port; plugins cannot substitute their own validator.
153
- * TODO: client enhancement JS waits for an ADR-025 owner amendment. */
161
+ * Client enhancement JS is still pending: it waits for an ADR-025 owner amendment. */
154
162
  export async function renderPluginWidgetFragments(required, optional = {}) {
155
163
  const names = [...new Set(required.names)];
156
164
  if (names.length > (optional.maxNames ?? 32))
@@ -161,9 +169,7 @@ export async function renderPluginWidgetFragments(required, optional = {}) {
161
169
  const fragments = Object.create(null);
162
170
  for (const snapshot of required.registry.list({})) {
163
171
  const selected = snapshot.widgets.filter(widget => names.includes(widget.name));
164
- if (!selected.length)
165
- continue;
166
- if (!await required.isEnabled({ pluginId: snapshot.pluginId }))
172
+ if (!selected.length || !await required.isEnabled({ pluginId: snapshot.pluginId }))
167
173
  continue;
168
174
  await Promise.all(selected.map(async (widget) => {
169
175
  let timer;
@@ -31,8 +31,10 @@ export async function enableDeclaredPlugin(required, optional = {}) {
31
31
  // ADR-024 §1: a Tier-1 plugin is zero executable code — the runtime never imports anything for it.
32
32
  const load = manifest.tier === "tier-1" ? async () => { } : loadCode;
33
33
  const { decls } = required.declarativeContentTypes.parse({ value: manifest.contentTypes });
34
- if (decls.length === 0)
35
- return load();
34
+ if (decls.length === 0) {
35
+ await load();
36
+ return;
37
+ }
36
38
  const ports = optional.contentTypes;
37
39
  if (!ports)
38
40
  throw new PluginInvalidError(`plugin '${pluginId}' declares content types, but this site cannot create them`);
@@ -22,9 +22,8 @@ function compareTb01(a, b) {
22
22
  }
23
23
  /** The four JSON-primitive field types BR-06's declared-field vocabulary supports. The switch is
24
24
  * exhaustive over `HookRegistryFieldDecl["type"]`, and `validateManifest` (`VALID_FIELD_TYPES`)
25
- * refuses any other declared type before a plugin can attach, so there is no `default` arm: a type
26
- * outside the union would fall through to `undefined`, which the only caller reads as a mismatch
27
- * (still fail-closed). */
25
+ * refuses any other declared type before a plugin can attach, so the `default` arm is unreachable;
26
+ * it returns false so a type outside the union still fails closed. */
28
27
  function matchesDeclaredType(value, type) {
29
28
  switch (type) {
30
29
  case "integer":
@@ -35,6 +34,8 @@ function matchesDeclaredType(value, type) {
35
34
  return typeof value === "string";
36
35
  case "boolean":
37
36
  return typeof value === "boolean";
37
+ default:
38
+ return false;
38
39
  }
39
40
  }
40
41
  /** Last dot-segment of a declared `ext.{pluginId}.{field}` path — the field name a returned patch
@@ -5,12 +5,13 @@ import { validateBrowserProviders } from '../browser-providers.js';
5
5
  /** Compare review-owned declarations with what the discovered manifest requests. Array order is
6
6
  * significant (capability preference); object key order is not. No self-declared trust field exists.
7
7
  */
8
+ /** Scalar fields an approval pins exactly; `kinds` is compared by value. */
9
+ const PINNED_PROVIDER_FIELDS = ['id', 'kind', 'contractVersion', 'javascript', 'stylesheet'];
8
10
  function matchesDeclaration(manifest, approval) {
9
11
  const requested = manifest.browserProviders ?? [];
10
12
  return requested.length === approval.browserProviders.length && requested.every((provider, index) => {
11
13
  const pinned = approval.browserProviders[index];
12
- return provider.id === pinned.id && provider.kind === pinned.kind && provider.contractVersion === pinned.contractVersion
13
- && provider.javascript === pinned.javascript && provider.stylesheet === pinned.stylesheet
14
+ return PINNED_PROVIDER_FIELDS.every((field) => provider[field] === pinned[field])
14
15
  && JSON.stringify(provider.kinds) === JSON.stringify(pinned.kinds);
15
16
  });
16
17
  }
@@ -106,7 +106,8 @@ async function snapshot(sourceDir, limits = {}) {
106
106
  async function walk(dir, prefix) {
107
107
  assertRealDirectory(await lstat(dir), "Package directories must not be symbolic links.");
108
108
  for (const name of (await readdir(dir)).sort()) {
109
- if (++entries > maxEntries)
109
+ entries += 1;
110
+ if (entries > maxEntries)
110
111
  fail("PLUGIN_PACKAGE_TOO_LARGE", "Package has too many entries.");
111
112
  const target = path.join(dir, name);
112
113
  const relative = prefix + name;
@@ -269,9 +270,8 @@ async function readInstalledIdentity(required) {
269
270
  async function assertSlotIdentityFree(required) {
270
271
  const { scan, localId, deps } = required;
271
272
  const slot = path.join(required.root, localId);
272
- for (const version of await scanSlotVersions({ scan, slot, localId, deps })) {
273
- if (!semver.valid(version))
274
- continue;
273
+ const versions = (await scanSlotVersions({ scan, slot, localId, deps })).filter((version) => semver.valid(version) !== null);
274
+ for (const version of versions) {
275
275
  const versionDir = path.join(slot, version);
276
276
  if (!(await isScannableVersion({ scan, versionDir, localId, deps })))
277
277
  continue;
@@ -316,8 +316,11 @@ async function latestInstalledVersion(required) {
316
316
  async function checkDestination(manifest, input, deps) {
317
317
  const root = path.resolve(deps.installDir);
318
318
  const scan = deps.identityFilesystem ?? { lstat, readdir, readFile };
319
- const entries = await scan.readdir(root).catch((e) => { if (e.code === "ENOENT")
320
- return []; throw e; });
319
+ const entries = await scan.readdir(root).catch((e) => {
320
+ if (e.code === "ENOENT")
321
+ return [];
322
+ throw e;
323
+ });
321
324
  const candidate = { ...identityOf(manifest, deps), family: "site-runtime", localId: manifest.id };
322
325
  assertIdentityFree(candidate, (deps.builtInManifests ?? []).map(builtIn => ({
323
326
  ...identityOf(builtIn, deps), family: "site-runtime", localId: builtIn.id, version: builtIn.version, enabled: false,
@@ -164,14 +164,17 @@ async function readDirectoryLevel(rootReal, relativeDir, state) {
164
164
  return [];
165
165
  }
166
166
  const subdirectories = [];
167
- for (const entry of entries.sort(byName)) {
168
- if (!admitEntry(state))
169
- break;
167
+ const sorted = entries.sort(byName);
168
+ // Stop at the first entry the limits refuse, or once visiting an entry truncated the walk.
169
+ let index = 0;
170
+ let open = true;
171
+ while (open && index < sorted.length && admitEntry(state)) {
172
+ const entry = sorted[index];
170
173
  const relativePath = relativeDir === "" ? entry.name : `${relativeDir}/${entry.name}`;
171
174
  if (await visitEntry(rootReal, relativePath, entry, state))
172
175
  subdirectories.push(relativePath);
173
- if (state.truncated)
174
- break;
176
+ index += 1;
177
+ open = !state.truncated;
175
178
  }
176
179
  return subdirectories;
177
180
  }
@@ -179,9 +182,11 @@ async function readDirectoryLevel(rootReal, relativeDir, state) {
179
182
  async function visitEntry(rootReal, relativePath, entry, state) {
180
183
  if (entry.isDirectory())
181
184
  return true;
182
- if (entry.isSymbolicLink())
185
+ if (entry.isSymbolicLink()) {
183
186
  state.files.push(omittedFile(relativePath, 0, "symlink"));
184
- else if (entry.isFile())
187
+ return false;
188
+ }
189
+ if (entry.isFile())
185
190
  await readFileEntry({ absolutePath: path.join(rootReal, relativePath), relativePath, state });
186
191
  return false;
187
192
  }
@@ -23,8 +23,17 @@ function safeId(id) {
23
23
  fail('PLUGIN_SOURCE_PATH_INVALID', 'Use a lowercase plugin id of at most 50 characters containing letters, numbers and hyphens.');
24
24
  }
25
25
  /** Reject both POSIX and Windows absolute/traversal syntax, even on a POSIX host. */
26
+ function isSafeDraftPath(file) {
27
+ if (typeof file !== 'string' || !file)
28
+ return false;
29
+ if (file.includes('\\') || file.includes('\0'))
30
+ return false;
31
+ if (path.posix.isAbsolute(file) || path.win32.isAbsolute(file))
32
+ return false;
33
+ return !file.split('/').some(part => !part || part === '.' || part === '..');
34
+ }
26
35
  function safeFile(file) {
27
- if (typeof file !== 'string' || !file || file.includes('\\') || file.includes('\0') || path.posix.isAbsolute(file) || path.win32.isAbsolute(file) || file.split('/').some(part => !part || part === '.' || part === '..')) {
36
+ if (!isSafeDraftPath(file)) {
28
37
  fail('PLUGIN_SOURCE_PATH_INVALID', 'File paths must be relative to the draft, without .., absolute paths or empty segments.');
29
38
  }
30
39
  }
@@ -142,7 +151,7 @@ export function createPluginSourceService(required, optional = {}) {
142
151
  await confined(root, root);
143
152
  if (options.createRoot)
144
153
  await mkdir(root, { recursive: true });
145
- else if (!await exists(root))
154
+ if (!options.createRoot && !await exists(root))
146
155
  fail('PLUGIN_SOURCE_DRAFT_MISSING', 'Create or open a plugin draft first.');
147
156
  try {
148
157
  return await withFileLock({ lockPath: root + '-source-lock', run: action }, { ...optional.lockPorts, timeoutMs: 100, staleMs: Infinity });
@@ -253,7 +262,7 @@ export function createPluginSourceService(required, optional = {}) {
253
262
  const plugin = await required.installer.install({ ...input, expectedDigest: preview.digest }, { versionAppend: true });
254
263
  // Host-owned, digest-bound provenance cannot be claimed by a manifest or written through
255
264
  // a draft path. Tier-3 has full server access by owner decision (2026-10-09), so this is an
256
- // assistant-tool boundary, not isolation from executing code. TODO: sandbox tier-3 later.
265
+ // assistant-tool boundary, not isolation from executing code. Sandboxing tier-3 is planned for later.
257
266
  await writeAtomic(root, marker(id, version), jsonBytes({ digest: plugin.digest }));
258
267
  return await reloadAndPrune(id, plugin, rollbackFrom ? { rollbackFrom } : {});
259
268
  }
@@ -308,7 +317,8 @@ export function createPluginSourceService(required, optional = {}) {
308
317
  read: ({ id, path: file }, _options = {}) => locked(id, () => read(id, file)),
309
318
  write: ({ id, path: file, content }, _options = {}) => locked(id, () => write(id, file, content)),
310
319
  edit: ({ id, path: file, oldString, newString, replaceAll }, _options = {}) => locked(id, async () => {
311
- if (typeof oldString !== 'string' || !oldString || typeof newString !== 'string' || (replaceAll !== undefined && typeof replaceAll !== 'boolean'))
320
+ const validReplaceAll = replaceAll === undefined || typeof replaceAll === 'boolean';
321
+ if (typeof oldString !== 'string' || !oldString || typeof newString !== 'string' || !validReplaceAll)
312
322
  fail('PLUGIN_SOURCE_INPUT_INVALID', 'Provide a nonempty oldString, a newString and optional boolean replaceAll.');
313
323
  const { content, bytes } = await read(id, file);
314
324
  const parts = content.split(oldString);
@@ -148,10 +148,14 @@ export function resolvePluginConflicts(required, optional = {}) {
148
148
  }
149
149
  return result;
150
150
  }
151
+ /** The core's own spelling of the claim, when it differs from the requested key. */
152
+ function heldKeyNote(conflict) {
153
+ return conflict.heldKey === conflict.key ? "" : ` ('${conflict.heldKey}')`;
154
+ }
151
155
  /** One conflict, in words: `tool 'x' is provided by plugin 'a' (A)` / `... is reserved by the host core ('/api/*')`. */
152
156
  function describeOne(conflict) {
153
157
  const holder = conflict.heldBy === CORE_OWNER_ID
154
- ? `is reserved by ${conflict.heldByName}${conflict.heldKey === conflict.key ? "" : ` ('${conflict.heldKey}')`}`
158
+ ? `is reserved by ${conflict.heldByName}${heldKeyNote(conflict)}`
155
159
  : `is provided by plugin '${conflict.heldBy}' (${conflict.heldByName})`;
156
160
  return `${conflict.kind} '${conflict.key}' ${holder}`;
157
161
  }
@@ -7,11 +7,12 @@ export function isPluginProviderDeclaration(required, _optional = {}) {
7
7
  if (!value || typeof value !== 'object' || Array.isArray(value))
8
8
  return false;
9
9
  const declaration = value;
10
- return typeof declaration.contract === 'string' && PROVIDER_ID_PATTERN.test(declaration.contract)
11
- && typeof declaration.id === 'string' && PROVIDER_ID_PATTERN.test(declaration.id)
12
- && declaration.contractVersion === 1;
10
+ return providerIdValid(declaration.contract) && providerIdValid(declaration.id) && declaration.contractVersion === 1;
13
11
  }
14
- const SETTING_NAME = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
12
+ function providerIdValid(value) {
13
+ return typeof value === 'string' && PROVIDER_ID_PATTERN.test(value);
14
+ }
15
+ const SETTING_NAME = /^[A-Za-z]\w{0,63}$/;
15
16
  function optionalOf(value, type) {
16
17
  return value === undefined || typeof value === type;
17
18
  }
@@ -39,9 +40,8 @@ function requiredUnlessValid(value) {
39
40
  if (!value || typeof value !== 'object' || Array.isArray(value))
40
41
  return false;
41
42
  const { field, equals, orPresent, headerNames } = value;
42
- return settingNameValid(field) && typeof equals === 'string'
43
- && (orPresent === undefined || settingNameValid(orPresent))
44
- && headerNamesValid({ headerNames, orPresent });
43
+ const orPresentValid = orPresent === undefined || settingNameValid(orPresent);
44
+ return settingNameValid(field) && typeof equals === 'string' && orPresentValid && headerNamesValid({ headerNames, orPresent });
45
45
  }
46
46
  /** A conditional requirement names public string choices, never executable plugin logic.
47
47
  * @complexity O(k) in declared choices; no effects. */
@@ -51,8 +51,8 @@ function requiredWhenValid(value) {
51
51
  if (!value || typeof value !== 'object' || Array.isArray(value))
52
52
  return false;
53
53
  const { field, in: choices } = value;
54
- return typeof field === 'string' && SETTING_NAME.test(field)
55
- && Array.isArray(choices) && choices.length > 0 && choices.every((choice) => typeof choice === 'string' && choice.trim() !== '');
54
+ const choicesValid = Array.isArray(choices) && choices.length > 0 && choices.every((choice) => typeof choice === 'string' && choice.trim() !== '');
55
+ return settingNameValid(field) && choicesValid;
56
56
  }
57
57
  const optionValid = (option) => {
58
58
  const { value, label } = (option ?? {});
@@ -30,26 +30,33 @@ function createResourceDisposer(required, _optional = {}) {
30
30
  let disposal;
31
31
  return () => {
32
32
  disposal ??= (async () => {
33
- let timer;
34
33
  const work = Promise.resolve().then(() => required.resource.dispose({}, {})).catch(error => {
35
34
  required.report({ phase: 'dispose', error });
36
35
  });
36
+ const deadline = startDeadline(required.timeoutMs, () => {
37
+ required.report({ phase: 'dispose_timeout', error: new PluginProviderError({ message: 'provider disposal timed out' }) });
38
+ });
37
39
  try {
38
- await Promise.race([work, new Promise(resolve => {
39
- timer = setTimeout(() => {
40
- required.report({ phase: 'dispose_timeout', error: new PluginProviderError({ message: 'provider disposal timed out' }) });
41
- resolve();
42
- }, required.timeoutMs);
43
- })]);
40
+ await Promise.race([work, deadline.elapsed]);
44
41
  }
45
42
  finally {
46
- if (timer !== undefined)
47
- clearTimeout(timer);
43
+ deadline.cancel();
48
44
  }
49
45
  })();
50
46
  return disposal;
51
47
  };
52
48
  }
49
+ /** Resolves (after calling `onElapsed`) once `ms` pass, unless cancelled first. */
50
+ function startDeadline(ms, onElapsed) {
51
+ let timer;
52
+ const elapsed = new Promise(resolve => {
53
+ timer = setTimeout(() => {
54
+ onElapsed();
55
+ resolve();
56
+ }, ms);
57
+ });
58
+ return { elapsed, cancel: () => clearTimeout(timer) };
59
+ }
53
60
  function timeoutOption(value, fallback, name) {
54
61
  const timeoutMs = value ?? fallback;
55
62
  if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1)
@@ -1,3 +1,4 @@
1
+ import { captureLineTail } from '@jini-ai/core/text';
1
2
  /** Evaluate the declared alternative without returning any setting or credential value. O(b) alternative text. */
2
3
  function requirementWaived({ condition, values }, _optional = {}) {
3
4
  if (!condition)
@@ -30,9 +31,18 @@ export function isProviderSettingRequired({ field, values }, _optional = {}) {
30
31
  /** Match only declared nonblank Name=Value headers; malformed lists never waive a requirement.
31
32
  * @complexity O(h * n) in header text and the manifest's small name allowlist. */
32
33
  export function hasProviderAuthHeader({ text, names }, _optional = {}) {
33
- const pairs = text.split(',').map(pair => /^([^=\s][^=]*?)\s*=\s*(.+)$/.exec(pair.trim()));
34
+ const pairs = text.split(',').map(pair => headerPair(pair.trim()));
34
35
  if (pairs.some(pair => !pair))
35
36
  return false;
36
- return pairs.some(pair => names.some(name => name.toLowerCase() === pair[1].toLowerCase()) && pair[2].trim() !== '');
37
+ return pairs.some(pair => names.some(name => name.toLowerCase() === pair[0].toLowerCase()) && pair[1].trim() !== '');
38
+ }
39
+ /** `[name, value]` exactly as /^([^=\s][^=]*?)\s*=\s*(.+)$/ captures them from a trimmed pair, but
40
+ * without that pattern's backtracking: the name runs to the first `=` (trailing spaces dropped). */
41
+ function headerPair(pair) {
42
+ const eq = pair.indexOf('=');
43
+ if (eq <= 0)
44
+ return null;
45
+ const value = captureLineTail({ rest: pair.slice(eq + 1) });
46
+ return value === null ? null : [pair.slice(0, eq).trimEnd(), value];
37
47
  }
38
48
  //# sourceMappingURL=provider-setting-required.js.map
@@ -24,7 +24,10 @@ export class SqlPluginActivationRepo {
24
24
  }
25
25
  async save(record, _optional = {}) {
26
26
  const row = toActivationRow({ record });
27
- const { workspace_id: _workspaceId, plugin_id: _pluginId, ...set } = row;
27
+ // The conflict key columns are never part of the update.
28
+ const set = { ...row };
29
+ delete set.workspace_id;
30
+ delete set.plugin_id;
28
31
  await this.kernel.run((db) => db
29
32
  .insertInto(this.tables.activations)
30
33
  .values(row)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/plugins",
3
- "version": "0.6.15-rc.2",
3
+ "version": "0.6.16",
4
4
  "description": "Host-independent extension glue and site-plugin runtime with injected SDK, trust, archive and storage ports.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,6 +25,12 @@
25
25
  "node:"
26
26
  ]
27
27
  }
28
+ },
29
+ "optionalPeers": {
30
+ "@jini-ai/platform": "opt-in: platform-backed adapters; import @jini-ai/plugins/host/node — Platform-backed adapters could not load @jini-ai/platform. Install @jini-ai/platform to enable this feature, or check its installed version and native binaries.",
31
+ "semver": "opt-in: plugin version compatibility; import @jini-ai/plugins/host — Plugin version compatibility could not load semver. Install semver to enable this feature, or check its installed version and native binaries.",
32
+ "kysely": "opt-in: sql storage adapters; import @jini-ai/plugins/host/sql — SQL storage adapters could not load kysely. Install kysely to enable this feature, or check its installed version and native binaries.",
33
+ "@jini-ai/db": "opt-in: database-backed adapters; import @jini-ai/plugins/host/sql — Database-backed adapters could not load @jini-ai/db. Install @jini-ai/db to enable this feature, or check its installed version and native binaries."
28
34
  }
29
35
  },
30
36
  "type": "module",
@@ -72,13 +78,21 @@
72
78
  "registry": "https://registry.npmjs.org"
73
79
  },
74
80
  "dependencies": {
75
- "@jini-ai/core": "^0.6.15-rc.2"
81
+ "@jini-ai/core": "^0.6.16"
76
82
  },
77
83
  "peerDependencies": {
78
- "@jini-ai/platform": "^0.6.15-rc.2",
84
+ "@jini-ai/platform": "^0.6.10",
85
+ "semver": "^7.6.2",
86
+ "kysely": "^0.29.6",
87
+ "@jini-ai/db": "^0.6.10"
88
+ },
89
+ "devDependencies": {
79
90
  "semver": "^7.6.2",
91
+ "@types/semver": "^7.5.8",
80
92
  "kysely": "^0.29.6",
81
- "@jini-ai/db": "^0.6.15-rc.2"
93
+ "@jini-ai/platform": "^0.6.16",
94
+ "@jini-ai/core": "^0.6.16",
95
+ "@jini-ai/db": "0.6.16"
82
96
  },
83
97
  "peerDependenciesMeta": {
84
98
  "@jini-ai/platform": {
@@ -94,14 +108,6 @@
94
108
  "optional": true
95
109
  }
96
110
  },
97
- "devDependencies": {
98
- "semver": "^7.6.2",
99
- "@types/semver": "^7.5.8",
100
- "kysely": "^0.29.6",
101
- "@jini-ai/platform": "^0.6.15-rc.2",
102
- "@jini-ai/db": "0.6.15-rc.2",
103
- "@jini-ai/core": "^0.6.15-rc.2"
104
- },
105
111
  "scripts": {
106
112
  "build": "tsc -p tsconfig.json",
107
113
  "typecheck": "tsc -p tsconfig.json --noEmit",
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/glue/attachment-points/content-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAC;AAE3F,MAAM,WAAW,kCAAkC,CAAC,MAAM,GAAG,0BAA0B;IACrF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC5B;;iDAE6C;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE;QAAE,4BAA4B,CAAC,QAAQ,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAA;SAAE,GAAG,IAAI,CAAA;KAAE,CAAC;CACrJ;AAED,MAAM,MAAM,kCAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEvE;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,GAAG,0BAA0B,EAC5E,QAAQ,EAAE,kCAAkC,CAAC,MAAM,CAAC,EACpD,SAAS,GAAE,kCAAuC,GACjD,IAAI,CAGN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-lifecycle.js","sourceRoot":"","sources":["../../../src/glue/attachment-points/content-lifecycle.ts"],"names":[],"mappings":"AAsCA;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAoD,EACpD,YAAgD,EAAE;IAElD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;IAChE,QAAQ,CAAC,4BAA4B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAC9E,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/glue/attachment-points/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3E,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;CACzD;AAED,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE/D,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,0BAA0B,EACpC,SAAS,GAAE,0BAA+B,GACzC,IAAI,CAGN"}