@jini-ai/agent-plugins 0.7.3-next.1 → 0.7.3-next.3

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 (233) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +22 -4
  3. package/calendly/README.md +29 -0
  4. package/calendly/mcp.json +1 -1
  5. package/cloudflare/lib/assets.mjs +1 -1
  6. package/cloudflare/lib/cms-forms.mjs +1 -1
  7. package/core/persistent-state.d.ts +4 -1
  8. package/core/persistent-state.js +55 -21
  9. package/dist/admin-surfaces/callback-field-inbox.d.ts +1 -6
  10. package/dist/admin-surfaces/connections/connections.d.ts +2 -6
  11. package/dist/admin-surfaces/connections/index.d.ts +3 -2
  12. package/dist/admin-surfaces/index.d.ts +3 -1
  13. package/dist/connect/access-token-tool.d.ts +1 -1
  14. package/dist/connect/access-token-tool.js +1 -1
  15. package/dist/connect/catalog.d.ts +26 -0
  16. package/dist/connect/catalog.js +42 -0
  17. package/dist/connect/connect-tool.d.ts +2 -294
  18. package/dist/connect/connect-tool.js +2 -53
  19. package/dist/connect/contracts.d.ts +257 -0
  20. package/dist/connect/contracts.js +2 -0
  21. package/dist/connect/credential-cards.d.ts +2 -0
  22. package/dist/connect/credential-cards.js +7 -4
  23. package/dist/connect/grant-signed-in-defaults.js +1 -1
  24. package/dist/connect/host-deps.d.ts +32 -0
  25. package/dist/connect/host-deps.js +35 -0
  26. package/dist/connect/import-access-token.js +1 -1
  27. package/dist/connect/index.d.ts +7 -2
  28. package/dist/connect/index.js +5 -2
  29. package/dist/connect/installed-plugin.d.ts +28 -0
  30. package/dist/connect/installed-plugin.js +19 -0
  31. package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
  32. package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
  33. package/dist/connect/plugin-host/index.d.ts +2 -2
  34. package/dist/connect/plugin-host/index.js +19 -10
  35. package/dist/connect/token-sign-in.d.ts +1 -14
  36. package/dist/connect/token-sign-in.js +4 -23
  37. package/dist/core/export-props.d.ts +10 -0
  38. package/dist/core/export-props.js +31 -0
  39. package/dist/core/folder-zip-error.d.ts +5 -0
  40. package/dist/core/folder-zip-error.js +8 -0
  41. package/dist/core/host-incompatible-error.d.ts +8 -0
  42. package/dist/core/host-incompatible-error.js +9 -0
  43. package/dist/core/identity-namespace.d.ts +27 -16
  44. package/dist/core/identity-namespace.js +25 -22
  45. package/dist/core/plugin-display-name.d.ts +7 -0
  46. package/dist/core/plugin-display-name.js +11 -0
  47. package/dist/core/provider-plugin-link.d.ts +7 -0
  48. package/dist/core/provider-plugin-link.js +5 -0
  49. package/dist/{connect → core}/token-map.d.ts +11 -1
  50. package/dist/{connect → core}/token-map.js +15 -0
  51. package/dist/core/token-sign-in-list.d.ts +18 -0
  52. package/dist/core/token-sign-in-list.js +23 -0
  53. package/dist/core/update-error.d.ts +8 -0
  54. package/dist/core/update-error.js +9 -0
  55. package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
  56. package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
  57. package/dist/ffmpeg-transcode/adapter.js +155 -0
  58. package/dist/folder-zip-node.d.ts +2 -1
  59. package/dist/folder-zip-node.js +6 -5
  60. package/dist/folder-zip.d.ts +0 -4
  61. package/dist/folder-zip.js +1 -7
  62. package/dist/index.d.ts +3 -1
  63. package/dist/lifecycle/activation.d.ts +39 -3
  64. package/dist/lifecycle/activation.js +467 -418
  65. package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
  66. package/dist/lifecycle/automatic-use-offer.js +52 -0
  67. package/dist/lifecycle/automatic-use.d.ts +33 -1
  68. package/dist/lifecycle/automatic-use.js +157 -38
  69. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  70. package/dist/lifecycle/capability-projection.d.ts +0 -1
  71. package/dist/lifecycle/capability-projection.js +92 -23
  72. package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
  73. package/dist/lifecycle/compatibility-metadata.js +6 -1
  74. package/dist/lifecycle/compatibility.d.ts +1 -8
  75. package/dist/lifecycle/compatibility.js +1 -8
  76. package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
  77. package/dist/lifecycle/exports.d.ts +2 -45
  78. package/dist/lifecycle/exports.js +1 -30
  79. package/dist/lifecycle/host-tools/identity.d.ts +5 -4
  80. package/dist/lifecycle/host-tools/identity.js +5 -5
  81. package/dist/lifecycle/host-tools/ports.d.ts +10 -1
  82. package/dist/lifecycle/host-tools/search-tool.d.ts +4 -2
  83. package/dist/lifecycle/host-tools/search-tool.js +19 -8
  84. package/dist/lifecycle/host-tools/skill-tool.js +1 -1
  85. package/dist/lifecycle/index.d.ts +20 -17
  86. package/dist/lifecycle/index.js +5 -4
  87. package/dist/lifecycle/install-from-url.d.ts +1 -2
  88. package/dist/lifecycle/install.d.ts +4 -34
  89. package/dist/lifecycle/install.js +3 -3
  90. package/dist/lifecycle/installed-package-index.d.ts +1 -1
  91. package/dist/lifecycle/installed-package-index.js +4 -4
  92. package/dist/lifecycle/layout.d.ts +21 -25
  93. package/dist/lifecycle/layout.js +79 -0
  94. package/dist/lifecycle/manifest.d.ts +10 -7
  95. package/dist/lifecycle/manifest.js +20 -15
  96. package/dist/lifecycle/mcp-provisioning.d.ts +1 -1
  97. package/dist/lifecycle/metadata.d.ts +6 -3
  98. package/dist/lifecycle/metadata.js +2 -1
  99. package/dist/lifecycle/package-paths.js +59 -56
  100. package/dist/lifecycle/persistent-state.d.ts +10 -1
  101. package/dist/lifecycle/persistent-state.js +4 -2
  102. package/dist/lifecycle/ports.d.ts +18 -6
  103. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -14
  104. package/dist/lifecycle/retire-bundled.d.ts +1 -1
  105. package/dist/lifecycle/search-projection.d.ts +3 -1
  106. package/dist/lifecycle/search-projection.js +7 -3
  107. package/dist/lifecycle/search.d.ts +1 -0
  108. package/dist/lifecycle/seed-bundled.d.ts +86 -1
  109. package/dist/lifecycle/seed-bundled.js +48 -84
  110. package/dist/lifecycle/set-enabled.d.ts +1 -13
  111. package/dist/lifecycle/set-enabled.js +11 -7
  112. package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
  113. package/dist/lifecycle/trusted-plugin-files.js +33 -30
  114. package/dist/lifecycle/types.d.ts +13 -34
  115. package/dist/lifecycle/uninstall.d.ts +1 -33
  116. package/dist/lifecycle/update-store.d.ts +0 -7
  117. package/dist/lifecycle/update-store.js +1 -8
  118. package/dist/lifecycle/update.d.ts +1 -1
  119. package/dist/lifecycle/update.js +60 -10
  120. package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
  121. package/dist/lifecycle/yauzl-archive-reader.js +11 -6
  122. package/dist/manifest.d.ts +4 -8
  123. package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
  124. package/dist/react/AgentPluginDetailsModal.js +29 -0
  125. package/dist/react/agent-plugin-install-port.d.ts +24 -0
  126. package/dist/react/agent-plugin-install-port.js +15 -0
  127. package/dist/react/installed-skills-composer-source.d.ts +60 -0
  128. package/dist/react/installed-skills-composer-source.js +111 -0
  129. package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
  130. package/dist/react/use-agent-plugins.hooks.js +128 -0
  131. package/dist/site/activation-effects.d.ts +17 -0
  132. package/dist/site/activation-effects.js +31 -0
  133. package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
  134. package/dist/site/admin-surfaces/capabilities.js +30 -0
  135. package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
  136. package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
  137. package/dist/site/admin-surfaces/forms.d.ts +28 -0
  138. package/dist/site/admin-surfaces/forms.js +29 -0
  139. package/dist/site/admin-surfaces/handlers.d.ts +61 -0
  140. package/dist/site/admin-surfaces/handlers.js +35 -0
  141. package/dist/site/admin-surfaces/public-config.d.ts +12 -0
  142. package/dist/site/admin-surfaces/public-config.js +28 -0
  143. package/dist/site/analytics-provider-registry.d.ts +87 -0
  144. package/dist/site/analytics-provider-registry.js +87 -0
  145. package/dist/site/archive-reader-abi.d.ts +35 -0
  146. package/dist/site/archive-reader-abi.js +25 -0
  147. package/dist/site/auth-schemes.d.ts +110 -0
  148. package/dist/site/auth-schemes.js +119 -0
  149. package/dist/site/automatic-agent-plugins.d.ts +200 -0
  150. package/dist/site/automatic-agent-plugins.js +277 -0
  151. package/dist/site/bundled-contribution-sources.d.ts +24 -0
  152. package/dist/site/bundled-contribution-sources.js +17 -0
  153. package/dist/site/bundled-id-upgrade.d.ts +115 -0
  154. package/dist/site/bundled-id-upgrade.js +169 -0
  155. package/dist/site/customize-tool.d.ts +39 -0
  156. package/dist/site/customize-tool.js +31 -0
  157. package/dist/site/deploy-split-activation.d.ts +28 -0
  158. package/dist/site/deploy-split-activation.js +21 -0
  159. package/dist/site/exports/diagnostics.d.ts +37 -0
  160. package/dist/site/exports/diagnostics.js +55 -0
  161. package/dist/site/exports/runtime.d.ts +54 -0
  162. package/dist/site/exports/runtime.js +196 -0
  163. package/dist/site/exports/source.d.ts +42 -0
  164. package/dist/site/exports/source.js +58 -0
  165. package/dist/site/host-plugin-guidance.d.ts +137 -0
  166. package/dist/site/host-plugin-guidance.js +223 -0
  167. package/dist/site/host-signals.d.ts +78 -0
  168. package/dist/site/host-signals.js +83 -0
  169. package/dist/site/install-tool.d.ts +69 -0
  170. package/dist/site/install-tool.js +192 -0
  171. package/dist/site/install-upload.d.ts +175 -0
  172. package/dist/site/install-upload.js +324 -0
  173. package/dist/site/memory-i18n.d.ts +5 -0
  174. package/dist/site/memory-i18n.js +176 -0
  175. package/dist/site/memory.d.ts +80 -0
  176. package/dist/site/memory.js +83 -0
  177. package/dist/site/plugin-memory.d.ts +80 -0
  178. package/dist/site/plugin-memory.js +86 -0
  179. package/dist/site/provider-plugin-link.d.ts +112 -0
  180. package/dist/site/provider-plugin-link.js +100 -0
  181. package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
  182. package/dist/site/retired-plugin-tool-aliases.js +41 -0
  183. package/dist/site/service-ports.d.ts +108 -0
  184. package/dist/site/service-ports.js +2 -0
  185. package/dist/site/set-enabled.d.ts +80 -0
  186. package/dist/site/set-enabled.js +42 -0
  187. package/dist/site/soon-lock.d.ts +83 -0
  188. package/dist/site/soon-lock.js +78 -0
  189. package/dist/site/supersession.d.ts +61 -0
  190. package/dist/site/supersession.js +122 -0
  191. package/dist/site/uninstall-tool.d.ts +136 -0
  192. package/dist/site/uninstall-tool.js +203 -0
  193. package/dist/site/update-effects.d.ts +47 -0
  194. package/dist/site/update-effects.js +49 -0
  195. package/ffmpeg-transcode/plugin.json +16 -0
  196. package/github/source-control/backup-push.mjs +66 -46
  197. package/github/source-control/commit-site.mjs +124 -67
  198. package/github/source-control/write-files.mjs +86 -53
  199. package/github-pages/targets/github-pages.mjs +294 -233
  200. package/google-workspace/form-destinations/mapping.mjs +15 -7
  201. package/google-workspace/form-destinations/sheets.mjs +4 -2
  202. package/google-workspace/plugin.json +1 -0
  203. package/kuinetic/CHANGELOG.md +4 -0
  204. package/kuinetic/plugin.json +4 -1
  205. package/kuinetic/skills/kuinetic/SKILL.md +1 -2
  206. package/package.json +297 -20
  207. package/persistent-state.d.ts +4 -1
  208. package/resend/adapters/resend.mjs +5 -2
  209. package/resend/plugin.json +1 -1
  210. package/s3-compatible/jini-deploy-targets.json +1 -1
  211. package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
  212. package/s3-compatible/targets/s3-compatible.mjs +3 -3
  213. package/site-import/plugin.json +3 -3
  214. package/site-import/skills/site-import/SKILL.md +62 -54
  215. package/site-import/skills/site-import/references/content-mapping.md +26 -20
  216. package/slide-design/plugin.json +1 -1
  217. package/slide-design/skills/slide-design/SKILL.md +8 -2
  218. package/ui-ux-design/CHANGELOG.md +6 -0
  219. package/ui-ux-design/plugin.json +1 -1
  220. package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
  221. package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
  222. package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
  223. package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
  224. package/vercel/NOTES.md +2 -1
  225. package/vercel/object-stores/vercel-blob.mjs +3 -4
  226. package/vercel/targets/vercel.mjs +425 -351
  227. package/core/commerce-server.d.ts +0 -2
  228. package/core/commerce-server.mjs +0 -2
  229. package/dist/admin-surfaces/connections/ports.d.ts +0 -110
  230. package/dist/admin-surfaces/connections/ports.js +0 -2
  231. /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
  232. /package/dist/{lifecycle → core}/install-errors.js +0 -0
  233. /package/dist/{lifecycle → core}/update-plan.js +0 -0
@@ -24,60 +24,31 @@ import path from "node:path";
24
24
  export class PackagePathViolation extends Error {
25
25
  constructor({ message }, optional = {}) { super(message, optional); }
26
26
  }
27
- function buildModule(ports) {
28
- const realpath = ports.filesystem.realpath.bind(ports.filesystem);
29
- /**
30
- * Rejects an absolute path, a NUL byte, a Windows drive prefix, or a lexical `..`/`.` segment —
31
- * BEFORE any filesystem call. This is the cheap majority of attempts; {@link assertContainedOnDisk}
32
- * catches the rest (an entry that is lexically clean but is, or passes through, a symlink).
33
- *
34
- * Backslashes are normalized to `/` rather than rejected: the spec models paths as POSIX-style
35
- * (`./`-prefixed), and an archive built on Windows may use them as its own separator without any
36
- * hostile intent — the traversal segments that actually matter (`..`, an absolute prefix) are
37
- * checked after normalization either way.
38
- *
39
- * @throws {PackagePathViolation} If the path is unsafe by construction, independent of any
40
- * filesystem state.
41
- * @complexity O(n) in the path's own length.
42
- */
43
- function normalizePackageEntryPath(rawEntryPath) {
44
- if (rawEntryPath.includes("\0")) {
45
- throw new PackagePathViolation({ message: `package entry path contains a NUL byte: '${rawEntryPath}'` });
46
- }
47
- const portable = rawEntryPath.replaceAll("\\", "/");
48
- if (path.posix.isAbsolute(portable) || /^[a-zA-Z]:/.test(portable)) {
49
- throw new PackagePathViolation({ message: `package entry path must be relative: '${rawEntryPath}'` });
50
- }
51
- const normalized = path.posix.normalize(portable);
52
- if (normalized === ".." || normalized.startsWith("../") || normalized === "." || normalized === "") {
53
- throw new PackagePathViolation({ message: `package entry path escapes the package root: '${rawEntryPath}'` });
54
- }
55
- return normalized;
56
- }
27
+ function createOnDiskPackagePathResolver({ realpath, normalizePackageEntryPath }) {
57
28
  /**
58
- * Resolves `entryPath` against `packageRoot` and asserts the REAL, symlink-resolved result is still
59
- * inside the REAL, symlink-resolved root — the spec's "filesystem-resolved" requirement, not a
60
- * string comparison.
61
- *
62
- * `packageRoot` is `realpath`'d fresh on every call rather than accepted pre-resolved from the
63
- * caller, so a root whose own directory entry is later replaced by a symlink between two calls
64
- * cannot smuggle a stale trusted root in.
65
- *
66
- * Handles the case extraction needs and a plain read doesn't: the target may not exist yet (mid-
67
- * extraction, before this entry's own write), in which case the deepest EXISTING ancestor is
68
- * `realpath`'d instead — so a symlinked PARENT directory planted by an earlier archive entry is
69
- * still caught even though the leaf hasn't been created yet.
70
- *
71
- * @param packageRoot - Absolute path to the package root (extraction destination, or an already-
72
- * installed package's root).
73
- * @param entryPath - A package-relative path, as found in an archive entry name or a caller's own
74
- * read request. Lexically validated internally via {@link normalizePackageEntryPath}.
75
- * @returns The resolved (lexical, not yet realpath'd) absolute destination — safe for the caller to
76
- * `open`/`mkdir`/`stat` against.
77
- * @throws {PackagePathViolation} If the path is lexically unsafe, or the filesystem-resolved result
78
- * (direct or via a symlinked ancestor) falls outside `packageRoot`.
79
- * @complexity O(d) in path depth — one `realpath` per unresolved ancestor in the worst case.
80
- */
29
+ * Resolves `entryPath` against `packageRoot` and asserts the REAL, symlink-resolved result is still
30
+ * inside the REAL, symlink-resolved root — the spec's "filesystem-resolved" requirement, not a
31
+ * string comparison.
32
+ *
33
+ * `packageRoot` is `realpath`'d fresh on every call rather than accepted pre-resolved from the
34
+ * caller, so a root whose own directory entry is later replaced by a symlink between two calls
35
+ * cannot smuggle a stale trusted root in.
36
+ *
37
+ * Handles the case extraction needs and a plain read doesn't: the target may not exist yet (mid-
38
+ * extraction, before this entry's own write), in which case the deepest EXISTING ancestor is
39
+ * `realpath`'d instead — so a symlinked PARENT directory planted by an earlier archive entry is
40
+ * still caught even though the leaf hasn't been created yet.
41
+ *
42
+ * @param packageRoot - Absolute path to the package root (extraction destination, or an already-
43
+ * installed package's root).
44
+ * @param entryPath - A package-relative path, as found in an archive entry name or a caller's own
45
+ * read request. Lexically validated internally via {@link normalizePackageEntryPath}.
46
+ * @returns The resolved (lexical, not yet realpath'd) absolute destination — safe for the caller to
47
+ * `open`/`mkdir`/`stat` against.
48
+ * @throws {PackagePathViolation} If the path is lexically unsafe, or the filesystem-resolved result
49
+ * (direct or via a symlinked ancestor) falls outside `packageRoot`.
50
+ * @complexity O(d) in path depth — one `realpath` per unresolved ancestor in the worst case.
51
+ */
81
52
  async function assertContainedOnDisk(packageRoot, entryPath) {
82
53
  const normalized = normalizePackageEntryPath(entryPath);
83
54
  const realRoot = await realpath(packageRoot);
@@ -102,8 +73,8 @@ function buildModule(ports) {
102
73
  return relative === "" || (!path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`));
103
74
  }
104
75
  /** Walks up from `candidate` until an existing ancestor is found, `realpath`s that ancestor, and
105
- * reattaches the non-existent tail — so a symlinked ancestor is caught even for a path whose leaf
106
- * (and possibly several parent segments) have not been created yet. */
76
+ * reattaches the non-existent tail — so a symlinked ancestor is caught even for a path whose leaf
77
+ * (and possibly several parent segments) have not been created yet. */
107
78
  async function realpathDeepestExistingAncestor(candidate) {
108
79
  let current = path.dirname(candidate);
109
80
  const tail = [path.basename(candidate)];
@@ -121,7 +92,39 @@ function buildModule(ports) {
121
92
  }
122
93
  }
123
94
  }
124
- return { normalizePackageEntryPath, assertContainedOnDisk };
95
+ return assertContainedOnDisk;
96
+ }
97
+ function buildModule(ports) {
98
+ const realpath = ports.filesystem.realpath.bind(ports.filesystem);
99
+ /**
100
+ * Rejects an absolute path, a NUL byte, a Windows drive prefix, or a lexical `..`/`.` segment —
101
+ * BEFORE any filesystem call. This is the cheap majority of attempts; {@link assertContainedOnDisk}
102
+ * catches the rest (an entry that is lexically clean but is, or passes through, a symlink).
103
+ *
104
+ * Backslashes are normalized to `/` rather than rejected: the spec models paths as POSIX-style
105
+ * (`./`-prefixed), and an archive built on Windows may use them as its own separator without any
106
+ * hostile intent — the traversal segments that actually matter (`..`, an absolute prefix) are
107
+ * checked after normalization either way.
108
+ *
109
+ * @throws {PackagePathViolation} If the path is unsafe by construction, independent of any
110
+ * filesystem state.
111
+ * @complexity O(n) in the path's own length.
112
+ */
113
+ function normalizePackageEntryPath(rawEntryPath) {
114
+ if (rawEntryPath.includes("\0")) {
115
+ throw new PackagePathViolation({ message: `package entry path contains a NUL byte: '${rawEntryPath}'` });
116
+ }
117
+ const portable = rawEntryPath.replaceAll("\\", "/");
118
+ if (path.posix.isAbsolute(portable) || /^[a-zA-Z]:/.test(portable)) {
119
+ throw new PackagePathViolation({ message: `package entry path must be relative: '${rawEntryPath}'` });
120
+ }
121
+ const normalized = path.posix.normalize(portable);
122
+ if (normalized === ".." || normalized.startsWith("../") || normalized === "." || normalized === "") {
123
+ throw new PackagePathViolation({ message: `package entry path escapes the package root: '${rawEntryPath}'` });
124
+ }
125
+ return normalized;
126
+ }
127
+ return { normalizePackageEntryPath, assertContainedOnDisk: createOnDiskPackagePathResolver({ realpath, normalizePackageEntryPath }) };
125
128
  }
126
129
  const instances = new WeakMap();
127
130
  /** Internal composition; one state/queue instance per injected host context. */
@@ -1,3 +1,4 @@
1
+ import { type WorkspaceMigrationOwnership } from '../../core/persistent-state.js';
1
2
  import type { AgentPluginLifecyclePorts } from './ports.js';
2
3
  /** Reuses the platform lock with injected effects, never age-stealing a living migration. */
3
4
  export declare function createPersistentStateModule(ports: AgentPluginLifecyclePorts, _optional?: Record<string, never>): {
@@ -5,6 +6,12 @@ export declare function createPersistentStateModule(ports: AgentPluginLifecycleP
5
6
  workspaceRoot: string;
6
7
  run(): Promise<T>;
7
8
  }, _optional?: {}) => Promise<T>;
9
+ withWorkspaceLock: <T>(required: {
10
+ workspaceRoot: string;
11
+ run(held: {
12
+ ownership: WorkspaceMigrationOwnership;
13
+ }): Promise<T>;
14
+ }, _optional?: {}) => Promise<T>;
8
15
  withPluginLock: <T>(required: {
9
16
  workspaceRoot: string;
10
17
  pluginId: string;
@@ -20,7 +27,9 @@ export declare function createPersistentStateModule(ports: AgentPluginLifecycleP
20
27
  }, optional?: {}) => Promise<string>;
21
28
  migrate: (required: {
22
29
  workspaceRoot: string;
23
- }, optional?: {}) => Promise<{
30
+ }, optional?: {
31
+ ownership?: WorkspaceMigrationOwnership;
32
+ }) => Promise<{
24
33
  complete: boolean;
25
34
  moved: number;
26
35
  }>;
@@ -1,5 +1,5 @@
1
1
  import { resolveAgentPluginLifecycleNamespace } from '../core/identity-namespace.js';
2
- import { createPluginMemory, migratePluginLayout, assertPluginStatePath, withPluginStateLock } from '../../core/persistent-state.js';
2
+ import { createPluginMemory, migratePluginLayout, assertPluginStatePath, withPluginStateLock, withWorkspaceMigrationLock } from '../../core/persistent-state.js';
3
3
  import path from 'node:path';
4
4
  import { createPackagePathsModule } from './package-paths.js';
5
5
  import { parseAgentPluginManifest } from './manifest.js';
@@ -18,12 +18,14 @@ export function createPersistentStateModule(ports, _optional = {}) {
18
18
  };
19
19
  return {
20
20
  withIdentityLock: (required, _optional = {}) => effects.withLock({ lockPath: path.join(required.workspaceRoot, '.publisher-identity.lock'), run: required.run }),
21
+ // Outermost lock of the workspace ordering; see `withWorkspaceMigrationLock`.
22
+ withWorkspaceLock: (required, _optional = {}) => withWorkspaceMigrationLock({ ...effects, ...required }),
21
23
  withPluginLock: (required, optional = {}) => withPluginStateLock({ ...effects, ...required }, optional),
22
24
  memory: (required, optional = {}) => createPluginMemory({ ...effects, ...required }, optional),
23
25
  assertOwnedPath: (required, optional = {}) => assertPluginStatePath({ ...effects, ...required }, optional),
24
26
  migrate: (required, optional = {}) => migratePluginLayout({ ...effects, ...required,
25
27
  parsePluginId: ({ value }) => {
26
- const parsed = parseAgentPluginManifest({ value }, { identityNamespace: resolveAgentPluginLifecycleNamespace({ value, extensionNamespace: ports.extensionNamespace }) });
28
+ const parsed = parseAgentPluginManifest({ value }, { identityNamespace: resolveAgentPluginLifecycleNamespace({ value, extensionNamespace: ports.extensionNamespace }, { legacyIdentity: ports.legacyIdentity }), legacyIdentity: ports.legacyIdentity });
27
29
  if (!parsed.ok)
28
30
  throw new Error(parsed.errors.join('; '));
29
31
  return parsed.manifest.name;
@@ -1,8 +1,9 @@
1
+ import type { WorkspaceMigrationOwnership } from '../../core/persistent-state.js';
1
2
  import type { Clock, IdGenerator } from "@jini-ai/core/primitives";
2
3
  import type { AtomicFileWriterPort, BootIdentity, FileLockPort } from "@jini-ai/core/contracts/runtime";
3
- import type { AgentPluginServerMetadataReader } from './manifest.js';
4
- import type { AgentPluginLayoutPort } from './layout.js';
5
- import type { AgentPluginDeliveryMode, InstalledAgentPlugin } from './types.js';
4
+ import type { AgentPluginServerMetadataReader, LegacyAgentPluginIdentity, LegacyMcpAliases } from './manifest.js';
5
+ import type { AgentPluginDeliveryMode } from './types.js';
6
+ import type { AgentPluginLayoutPort, InstalledAgentPlugin } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
6
7
  /** Native Node filesystem ABI, narrowed to the operations used by lifecycle.
7
8
  * Inject instrumented fs/promises effects directly; native handles are never rewrapped. */
8
9
  export type FilesystemPort = Pick<typeof import('node:fs/promises'), 'chmod' | 'mkdir' | 'mkdtemp' | 'open' | 'readdir' | 'readFile' | 'rename' | 'rm' | 'rmdir' | 'stat' | 'lstat' | 'realpath' | 'unlink'>;
@@ -14,6 +15,11 @@ export type AgentPluginClockPort = Clock & {
14
15
  sleep(required: {
15
16
  readonly ms: number;
16
17
  }): Promise<void>;
18
+ /** The pause between background recovery attempts. A host binds a wait that does not keep its process
19
+ * alive (an unref'd timer), so a retry never delays process exit; absent = `sleep`. */
20
+ sleepInBackground?(required: {
21
+ readonly ms: number;
22
+ }): Promise<void>;
17
23
  };
18
24
  export type AgentPluginIdsPort = IdGenerator & {
19
25
  random(): number;
@@ -102,10 +108,14 @@ export interface AgentPluginLifecyclePorts {
102
108
  readonly extensionNamespace: string;
103
109
  /** Host boot policy may migrate every workspace before seeding the requested workspace.
104
110
  * A failure refuses all publication; absent uses the owner's single-workspace migration. */
111
+ /** `ownership`, when present, proves the caller already holds this workspace's migration lock: run
112
+ * the migration under it (`migratePluginLayout`'s `ownership`), never acquire it again. */
105
113
  readonly migrateBeforeSeed?: ((required: {
106
114
  readonly layout: AgentPluginLayoutPort;
107
115
  readonly workspaceId: string;
108
- }, optional: Record<string, never>) => Promise<{
116
+ }, optional: {
117
+ readonly ownership?: WorkspaceMigrationOwnership;
118
+ }) => Promise<{
109
119
  readonly complete: boolean;
110
120
  }>) | undefined;
111
121
  /** Host-facing recovery instructions; the bundled refusal and its security gate remain owned here. */
@@ -113,12 +123,14 @@ export interface AgentPluginLifecyclePorts {
113
123
  readonly pluginId: string;
114
124
  }, optional: Record<string, never>) => string) | undefined;
115
125
  readonly readServerMetadata?: AgentPluginServerMetadataReader | undefined;
126
+ readonly legacyIdentity?: LegacyAgentPluginIdentity | undefined;
127
+ readonly legacyMcpAliases?: LegacyMcpAliases | undefined;
116
128
  readonly deliveryMode: AgentPluginDeliveryMode;
117
129
  readonly mcpProvisioning: AgentPluginMcpProvisioningPort;
118
130
  readonly fetch: AgentPluginFetchPort;
119
131
  readonly outboundGuard: AgentPluginOutboundGuardPort;
120
132
  }
121
133
  /** Application policy/effects are required; observers and metadata translators are optional. */
122
- export type AgentPluginLifecycleRequired = Omit<AgentPluginLifecyclePorts, 'onActivationChanged' | 'onEvent' | 'readServerMetadata' | 'migrateBeforeSeed' | 'formatBundledUninstallRecovery' | 'identityAdmission'>;
123
- export type AgentPluginLifecycleOptional = Pick<AgentPluginLifecyclePorts, 'onActivationChanged' | 'onEvent' | 'readServerMetadata' | 'migrateBeforeSeed' | 'formatBundledUninstallRecovery' | 'identityAdmission'>;
134
+ export type AgentPluginLifecycleRequired = Omit<AgentPluginLifecyclePorts, 'onActivationChanged' | 'onEvent' | 'readServerMetadata' | 'legacyMcpAliases' | 'legacyIdentity' | 'migrateBeforeSeed' | 'formatBundledUninstallRecovery' | 'identityAdmission'>;
135
+ export type AgentPluginLifecycleOptional = Pick<AgentPluginLifecyclePorts, 'onActivationChanged' | 'onEvent' | 'readServerMetadata' | 'legacyMcpAliases' | 'legacyIdentity' | 'migrateBeforeSeed' | 'formatBundledUninstallRecovery' | 'identityAdmission'>;
124
136
  //# sourceMappingURL=ports.d.ts.map
@@ -1,18 +1,6 @@
1
- import type { /**
2
- * How a pinned ref's content reaches the agent.
3
- *
4
- * - `inject` — the whole eponymous SKILL.md (~15KB for `ui-ux-design`) plus its readable supporting-file inventory
5
- * listed relative to the skill folder, in the run's prompt prefix. Today's shipped behaviour, and the default.
6
- * - `pointer` — ~400 bytes naming the exact tool call that returns that SAME SKILL.md, and nothing
7
- * else. The content is identical; only the delivery differs, which is what makes the two a
8
- * controlled comparison rather than two different experiments.
9
- *
10
- * Selected per-process by the host-supplied `deliveryMode` port. This is a MEASUREMENT AFFORDANCE, not a
11
- * migration flag: pointer and inject must coexist to compare delivery of identical content.
12
- * Selecting an unconditional mode requires the measurement result.
13
- */ AgentPluginDeliveryMode, InstalledAgentPlugin } from "./types.js";
14
- import type { AgentPluginWorkspaceLayout } from "./layout.js";
1
+ import type { AgentPluginDeliveryMode } from "./types.js";
15
2
  import type { AgentPluginLifecyclePorts } from "./ports.js";
3
+ import type { InstalledAgentPlugin, AgentPluginWorkspaceLayout } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
16
4
  /** A declared skill and a file relative to that skill's folder; omitted file means SKILL.md. */
17
5
  export interface AgentPluginSkillRequest {
18
6
  readonly skill?: string;
@@ -1,6 +1,6 @@
1
1
  import type { BundledAgentPluginEnableOutcome } from "./activation.js";
2
- import type { AgentPluginLayout } from "./layout.js";
3
2
  import type { AgentPluginLifecyclePorts } from "./ports.js";
3
+ import type { AgentPluginLayout } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
4
4
  /** What happened to the successor. `not-needed`: the retired plugin was off, so the successor was
5
5
  * left as it was. The other three are {@link BundledAgentPluginEnableOutcome}. */
6
6
  export type RetiredAgentPluginSuccessorOutcome = BundledAgentPluginEnableOutcome | "not-needed";
@@ -18,7 +18,9 @@ export interface AgentPluginDiscoveryPage {
18
18
  * @complexity O(1) bounded text work and shallow copy; no I/O or mutation.
19
19
  */
20
20
  export declare function agentVisiblePluginCandidate({ candidate }: {
21
- candidate: AgentPluginSearchCandidate;
21
+ candidate: AgentPluginSearchCandidate & {
22
+ readonly maturity?: string;
23
+ };
22
24
  }, _options?: {}): AgentPluginSearchCandidate;
23
25
  /** Page an already ordered catalog, bounding the complete serialized result, including JSON escaping.
24
26
  * @param required Ranked/listed candidates, a validated count window and the installed catalog size.
@@ -17,14 +17,18 @@ export function agentVisiblePluginCandidate({ candidate }, _options = {}) {
17
17
  return candidate;
18
18
  const purpose = shortDescription({ text: (candidate.summary ?? candidate.description ?? '').slice(0, 1024).replace(/\s+/g, ' ').trim() }, { maxBytes: 100 });
19
19
  const label = shortDescription({ text: (candidate.displayName ?? candidate.pluginId).slice(0, 1024).replace(/\s+/g, ' ').trim() }, { maxBytes: 80 });
20
- return { ...candidate, id: candidate.id ?? candidate.pluginId, enabled: false,
21
- description: `installed, off: ${label}: ${purpose} — read guidance; tools unavailable` };
20
+ // A Soon plugin is locked off, so it is described as coming soon: "installed, off" invites an enable offer.
21
+ const description = candidate.maturity === 'soon'
22
+ ? `coming soon: ${label}: ${purpose} — not ready yet; it cannot be turned on`
23
+ : `installed, off: ${label}: ${purpose} — read guidance; tools unavailable`;
24
+ return { ...candidate, id: candidate.id ?? candidate.pluginId, enabled: false, description };
22
25
  }
23
26
  /** Project one candidate without copying skills, keywords, credentials or host metadata. O(1). */
24
27
  function discoveryMatch({ candidate }, _options = {}) {
25
28
  if (!candidate.enabled) {
26
29
  const visible = agentVisiblePluginCandidate({ candidate });
27
- return { id: visible.id ?? visible.pluginId, pluginId: visible.pluginId, enabled: false, description: visible.description ?? '' };
30
+ return { id: visible.id ?? visible.pluginId, pluginId: visible.pluginId, enabled: false,
31
+ ...(candidate.maturity === 'soon' ? { maturity: 'soon' } : {}), description: visible.description ?? '' };
28
32
  }
29
33
  return { id: candidate.id ?? candidate.pluginId, pluginId: candidate.pluginId, enabled: candidate.enabled,
30
34
  ...(candidate.maturity ? { maturity: candidate.maturity } : {}),
@@ -75,6 +75,7 @@ export interface AgentPluginSearchCandidate {
75
75
  readonly id?: string | undefined;
76
76
  readonly provides?: readonly string[] | undefined;
77
77
  readonly requires?: readonly string[] | undefined;
78
+ readonly companions?: readonly string[] | undefined;
78
79
  /** Whether this workspace currently has the plugin enabled — reflects `activation.ts`'s
79
80
  * absent-means-active default, same as everywhere else this codebase reads activation state. */
80
81
  readonly enabled: boolean;
@@ -1,7 +1,87 @@
1
+ /**
2
+ * @file `seedBundledAgentPlugins()` — installs the Agent Plugins that ship WITH the host into a
3
+ * workspace's own package store, and records each one INACTIVE until an operator says otherwise
4
+ * (except the few core paths depend on, `BUNDLED_AGENT_PLUGINS_SEEDED_ENABLED`, which seed active).
5
+ *
6
+ * ---------------------------------------------------------------------------
7
+ * "Bundled but inactive", concretely
8
+ * ---------------------------------------------------------------------------
9
+ * Bundled: the package's real files are tracked in this repository under `content/agent-plugins/<id>/`
10
+ * and copied into `dist/` by `npm run build`, exactly like `content/themes/`. A fresh install has them
11
+ * without downloading anything.
12
+ *
13
+ * Inactive: seeding writes `{ enabled: false, origin: "bundled" }` into the workspace's activation
14
+ * record (`activation.ts`) BEFORE the package can be read by anything, and the two places that
15
+ * consume installed plugins both consult that record:
16
+ *
17
+ * - `tool-registrations.ts` — will not register its `agent_plugin_<id>` tool;
18
+ * - `resolve-agent-plugin-refs.ts` — refuses to inject it even if a composer chip pins it by id.
19
+ *
20
+ * (A third surface, `capability-source.ts`'s `capability_search` discovery, was gated here too
21
+ * until that tool pair was removed 2026-08-26 — see
22
+ * `ADS-memory/knowledge/2026-08-26-removed-capability-search.md`.)
23
+ *
24
+ * So "inactive" means genuinely unexecutable, not merely unadvertised: its skills never reach a
25
+ * prompt, and its tools and MCP servers are never registered.
26
+ *
27
+ * It does NOT mean hidden from the operator. The admin Agent Plugins screen lists every installed
28
+ * plugin, with an inactive one's switch shown off, so a bundled plugin can be found and turned on
29
+ * there (owner decision, 2026-09-13; before it, that screen's default tab listed only active ones).
30
+ * Listing only READS the activation record, so the "absent means active" hazard described below is
31
+ * unaffected.
32
+ *
33
+ * ---------------------------------------------------------------------------
34
+ * Why it runs on every boot
35
+ * ---------------------------------------------------------------------------
36
+ * Seeding is idempotent twice over: `installAgentPlugin` short-circuits when the content digest is
37
+ * already published, and `recordBundledAgentPluginIfAbsent` never overwrites an existing decision.
38
+ * Re-running it therefore costs one directory walk and one hash, and buys two things a one-shot
39
+ * first-run seed would not:
40
+ *
41
+ * 1. A product upgrade that ships a NEW bundled plugin, or a NEW VERSION of one, reaches existing
42
+ * workspaces without a migration step.
43
+ *
44
+ * The second half of that claim was FALSE IN EFFECT until 2026-09-18, and the correction is the
45
+ * reason `bundled-digests.ts` exists. The package store is content-addressed and nothing retires
46
+ * an entry, so a revised bundled plugin installs ALONGSIDE its predecessor rather than replacing
47
+ * it — after which both consumption surfaces refused the plugin outright as ambiguous
48
+ * (`resolve-agent-plugin-refs.ts`'s "refusing to guess which one to use",
49
+ * `tool-registrations.ts`'s `poisonedPluginIds`). An upgrade did reach the workspace; it also
50
+ * silently broke the plugin. What makes the claim true now is the ledger this function writes
51
+ * below: the seed RECORDS which digest this build published, so the read side has the build's own
52
+ * answer to "which one" instead of a guess. The superseded bytes stay on disk — see
53
+ * `bundled-digests.ts`'s header for why nothing is deleted, and this file's own report for what
54
+ * an operator still has to prune by hand.
55
+ * 2. Deleting `activations.json` re-creates the bundled plugin's DISABLED record. Without the
56
+ * re-run, deleting that file would silently promote every bundled plugin to active, because
57
+ * `isAgentPluginActive`'s "absent means active" default is what keeps operator-installed plugins
58
+ * working. The boot-time re-seed is what closes that direction.
59
+ *
60
+ * A file that is PRESENT but unreadable is a different case from a deleted one, and is not
61
+ * treated the same way (t91 F1.1, 2026-09-16): seeding refuses outright rather than install
62
+ * around the fault, and every bundled plugin comes back `failed` with the recovery text
63
+ * `activation.ts`'s `AgentPluginActivationsUnreadableError` gives — see this file's header,
64
+ * "Failure isolation" below, and `activation.ts`'s own header, "Writers never rewrite what they
65
+ * could not read".
66
+ *
67
+ * ---------------------------------------------------------------------------
68
+ * Failure isolation
69
+ * ---------------------------------------------------------------------------
70
+ * One unusable bundled package must never stop a workspace from booting or hide the others. Each is
71
+ * seeded independently and its failure is captured into the returned report, not thrown. The caller
72
+ * decides whether to log it; nothing here writes to the console, so this stays a pure-ish function
73
+ * a test can assert on directly.
74
+ *
75
+ * Architectural role:
76
+ * Composition over `bundled-source-archive.ts` (directory to archive), `install.ts`
77
+ * (`installAgentPlugin`, where every extraction guarantee lives), and `activation.ts` (the record).
78
+ * No guarantee of its own.
79
+ */
80
+ import type { WorkspaceMigrationOwnership } from '../../core/persistent-state.js';
1
81
  import type { PackAgentPluginDirectoryOptional } from "./bundled-source-archive.js";
2
- import type { AgentPluginLayout } from "./layout.js";
3
82
  import type { RetiredAgentPluginOutcome } from "./retire-bundled.js";
4
83
  import type { AgentPluginLifecyclePorts } from "./ports.js";
84
+ import type { AgentPluginLayout } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
5
85
  export type SeededAgentPluginOutcome = {
6
86
  readonly pluginId: string;
7
87
  readonly status: "seeded";
@@ -22,6 +102,11 @@ export type PackingForSource = (required: {
22
102
  }, optional?: Record<string, never>) => PackAgentPluginDirectoryOptional | Promise<PackAgentPluginDirectoryOptional>;
23
103
  export interface SeedBundledAgentPluginsOptional {
24
104
  readonly packing?: PackAgentPluginDirectoryOptional | PackingForSource;
105
+ /** The caller holds this workspace's migration lock; the nested migration runs under it. */
106
+ readonly ownership?: WorkspaceMigrationOwnership;
107
+ /** Bundled ids a maintenance step refused to clear (id -> plain-words reason). Each is reported
108
+ * failed with that reason and never reaches install, so no alternate path can admit it. */
109
+ readonly heldPluginIds?: ReadonlyMap<string, string>;
25
110
  }
26
111
  export interface SeedBundledAgentPluginsResult {
27
112
  /** Directory holding one subdirectory per bundled plugin. `deps.ts`'s `bundledAgentPluginsDir()`
@@ -1,85 +1,7 @@
1
- /**
2
- * @file `seedBundledAgentPlugins()` — installs the Agent Plugins that ship WITH the host into a
3
- * workspace's own package store, and records each one INACTIVE until an operator says otherwise
4
- * (except the few core paths depend on, `BUNDLED_AGENT_PLUGINS_SEEDED_ENABLED`, which seed active).
5
- *
6
- * ---------------------------------------------------------------------------
7
- * "Bundled but inactive", concretely
8
- * ---------------------------------------------------------------------------
9
- * Bundled: the package's real files are tracked in this repository under `content/agent-plugins/<id>/`
10
- * and copied into `dist/` by `npm run build`, exactly like `content/themes/`. A fresh install has them
11
- * without downloading anything.
12
- *
13
- * Inactive: seeding writes `{ enabled: false, origin: "bundled" }` into the workspace's activation
14
- * record (`activation.ts`) BEFORE the package can be read by anything, and the two places that
15
- * consume installed plugins both consult that record:
16
- *
17
- * - `tool-registrations.ts` — will not register its `agent_plugin_<id>` tool;
18
- * - `resolve-agent-plugin-refs.ts` — refuses to inject it even if a composer chip pins it by id.
19
- *
20
- * (A third surface, `capability-source.ts`'s `capability_search` discovery, was gated here too
21
- * until that tool pair was removed 2026-08-26 — see
22
- * `ADS-memory/knowledge/2026-08-26-removed-capability-search.md`.)
23
- *
24
- * So "inactive" means genuinely unexecutable, not merely unadvertised: its skills never reach a
25
- * prompt, and its tools and MCP servers are never registered.
26
- *
27
- * It does NOT mean hidden from the operator. The admin Agent Plugins screen lists every installed
28
- * plugin, with an inactive one's switch shown off, so a bundled plugin can be found and turned on
29
- * there (owner decision, 2026-09-13; before it, that screen's default tab listed only active ones).
30
- * Listing only READS the activation record, so the "absent means active" hazard described below is
31
- * unaffected.
32
- *
33
- * ---------------------------------------------------------------------------
34
- * Why it runs on every boot
35
- * ---------------------------------------------------------------------------
36
- * Seeding is idempotent twice over: `installAgentPlugin` short-circuits when the content digest is
37
- * already published, and `recordBundledAgentPluginIfAbsent` never overwrites an existing decision.
38
- * Re-running it therefore costs one directory walk and one hash, and buys two things a one-shot
39
- * first-run seed would not:
40
- *
41
- * 1. A product upgrade that ships a NEW bundled plugin, or a NEW VERSION of one, reaches existing
42
- * workspaces without a migration step.
43
- *
44
- * The second half of that claim was FALSE IN EFFECT until 2026-09-18, and the correction is the
45
- * reason `bundled-digests.ts` exists. The package store is content-addressed and nothing retires
46
- * an entry, so a revised bundled plugin installs ALONGSIDE its predecessor rather than replacing
47
- * it — after which both consumption surfaces refused the plugin outright as ambiguous
48
- * (`resolve-agent-plugin-refs.ts`'s "refusing to guess which one to use",
49
- * `tool-registrations.ts`'s `poisonedPluginIds`). An upgrade did reach the workspace; it also
50
- * silently broke the plugin. What makes the claim true now is the ledger this function writes
51
- * below: the seed RECORDS which digest this build published, so the read side has the build's own
52
- * answer to "which one" instead of a guess. The superseded bytes stay on disk — see
53
- * `bundled-digests.ts`'s header for why nothing is deleted, and this file's own report for what
54
- * an operator still has to prune by hand.
55
- * 2. Deleting `activations.json` re-creates the bundled plugin's DISABLED record. Without the
56
- * re-run, deleting that file would silently promote every bundled plugin to active, because
57
- * `isAgentPluginActive`'s "absent means active" default is what keeps operator-installed plugins
58
- * working. The boot-time re-seed is what closes that direction.
59
- *
60
- * A file that is PRESENT but unreadable is a different case from a deleted one, and is not
61
- * treated the same way (t91 F1.1, 2026-09-16): seeding refuses outright rather than install
62
- * around the fault, and every bundled plugin comes back `failed` with the recovery text
63
- * `activation.ts`'s `AgentPluginActivationsUnreadableError` gives — see this file's header,
64
- * "Failure isolation" below, and `activation.ts`'s own header, "Writers never rewrite what they
65
- * could not read".
66
- *
67
- * ---------------------------------------------------------------------------
68
- * Failure isolation
69
- * ---------------------------------------------------------------------------
70
- * One unusable bundled package must never stop a workspace from booting or hide the others. Each is
71
- * seeded independently and its failure is captured into the returned report, not thrown. The caller
72
- * decides whether to log it; nothing here writes to the console, so this stays a pure-ish function
73
- * a test can assert on directly.
74
- *
75
- * Architectural role:
76
- * Composition over `bundled-source-archive.ts` (directory to archive), `install.ts`
77
- * (`installAgentPlugin`, where every extraction guarantee lives), and `activation.ts` (the record).
78
- * No guarantee of its own.
79
- */
80
1
  import { createPersistentStateModule } from "./persistent-state.js";
81
2
  import path from "node:path";
82
3
  import { describeErrorForLog } from "@jini-ai/core";
4
+ import { AgentPluginInstallError } from "../core/install-errors.js";
83
5
  import { createActivationModule } from "./activation.js";
84
6
  import { createBundledDigestsModule } from "./bundled-digests.js";
85
7
  import { createBundledSourceArchiveModule } from "./bundled-source-archive.js";
@@ -110,18 +32,27 @@ import { createRetireBundledModule } from "./retire-bundled.js";
110
32
  // its ledger entry exist by now, and the retirement only has to decide whether to switch it on.
111
33
  // A successor whose seed FAILED has neither; `retire-bundled.ts` then keeps the retired plugin
112
34
  // rather than remove it in favour of a switch with no code behind it (its header, step 1a).
35
+ /**
36
+ * Runs the layout migration that must precede seeding: the host's hook when it supplies one, else
37
+ * the default persistent-state migration. A caller already holding the workspace migration lock
38
+ * passes its ownership so the nested migration runs under it instead of reacquiring the lock.
39
+ * @complexity O(1) here; the migration itself is O(installed plugins).
40
+ */
41
+ function migrateBeforeSeeding({ ports, layout, workspaceId }, held = {}) {
42
+ return ports.migrateBeforeSeed
43
+ ? ports.migrateBeforeSeed({ layout, workspaceId }, held)
44
+ : createPersistentStateModule(ports).migrate({ workspaceRoot: layout.forWorkspace({ workspaceId }).root }, held);
45
+ }
113
46
  async function seedBundledAgentPlugins({ ports, required }, optional = {}) {
114
47
  const { layout, workspaceId, sourceRoot } = required;
115
48
  const pluginDirNames = await listBundledPluginDirs({ ports, sourceRoot });
116
49
  try {
117
- const migration = ports.migrateBeforeSeed
118
- ? await ports.migrateBeforeSeed({ layout, workspaceId }, {})
119
- : await createPersistentStateModule(ports).migrate({ workspaceRoot: layout.forWorkspace({ workspaceId }).root });
50
+ const migration = await migrateBeforeSeeding({ ports, layout, workspaceId }, optional.ownership ? { ownership: optional.ownership } : {});
120
51
  if (!migration.complete)
121
52
  throw new Error('Legacy plugin layout migration has unfinished filesystem moves; see boot log');
122
53
  }
123
54
  catch (error) {
124
- const reason = describeErrorForLog({ err: error });
55
+ const reason = describeSeedFailure({ err: error });
125
56
  return { sourceRoot, outcomes: pluginDirNames.map(pluginId => ({ pluginId, status: 'failed', reason })), retirements: [] };
126
57
  }
127
58
  const refusal = await activationsRefusal({ ports, layout, workspaceId });
@@ -134,6 +65,11 @@ async function seedBundledAgentPlugins({ ports, required }, optional = {}) {
134
65
  }
135
66
  const outcomes = [];
136
67
  for (const dirName of pluginDirNames) {
68
+ const heldReason = optional.heldPluginIds?.get(dirName);
69
+ if (heldReason !== undefined) {
70
+ outcomes.push({ pluginId: dirName, status: "failed", reason: heldReason });
71
+ continue;
72
+ }
137
73
  outcomes.push(await seedOne({
138
74
  ports,
139
75
  args: { layout, workspaceId, sourceDir: path.join(sourceRoot, dirName), dirName },
@@ -204,10 +140,38 @@ async function seedOne({ ports, args }, { optional = {} } = {}) {
204
140
  return {
205
141
  pluginId: args.dirName,
206
142
  status: "failed",
207
- reason: describeErrorForLog({ err: error }),
143
+ reason: describeSeedFailure({ err: error }),
208
144
  };
209
145
  }
210
146
  }
147
+ /** Safe, fixed boot-log copy per install error code. `AgentPluginInstallError.message` is written for
148
+ * the installing caller and can embed a local path (`PUBLISH_FAILED` names the publish target), so the
149
+ * log carries this copy instead; `Record` makes a newly added code a compile error until it has copy. */
150
+ const SAFE_INSTALL_FAILURE_COPY = {
151
+ PLUGIN_ID_CONFLICT: "The plugin id is already installed from different contents.",
152
+ ARCHIVE_TOO_LARGE: "The plugin archive is too large.",
153
+ DIGEST_MISMATCH: "The plugin archive does not match its expected digest.",
154
+ TOO_MANY_ENTRIES: "The plugin archive has too many entries.",
155
+ UNSAFE_ENTRY_PATH: "The plugin archive has an unsafe entry path.",
156
+ SYMLINK_ENTRY_REJECTED: "The plugin archive contains a symbolic link.",
157
+ UNSUPPORTED_ENTRY_KIND: "The plugin archive contains an unsupported entry.",
158
+ DUPLICATE_ENTRY: "The plugin archive has a duplicate entry.",
159
+ FILE_TOO_LARGE: "The plugin archive has a file that is too large.",
160
+ DECOMPRESSION_BOMB: "The plugin archive expands beyond its safe limit.",
161
+ TOTAL_SIZE_EXCEEDED: "The plugin archive expands beyond its total size limit.",
162
+ MANIFEST_MISSING: "The plugin manifest is missing.",
163
+ MANIFEST_INVALID: "The plugin manifest is invalid.",
164
+ PUBLISH_FAILED: "The plugin package could not be published.",
165
+ };
166
+ /** The reason a bundled plugin failed to seed, for the boot log. An install error logs its code with
167
+ * fixed safe copy for that code (never its message, which can carry a local path); the core describer
168
+ * has no vocabulary for this class and would print a bare "Error". Everything else keeps the core
169
+ * describer's class-only line. @complexity O(1). */
170
+ function describeSeedFailure({ err }, _optional = {}) {
171
+ if (err instanceof AgentPluginInstallError)
172
+ return `${err.code}: ${SAFE_INSTALL_FAILURE_COPY[err.code] ?? "The plugin could not be installed."}`;
173
+ return describeErrorForLog({ err });
174
+ }
211
175
  /**
212
176
  * Lists the subdirectories of `sourceRoot` that actually look like Agent Plugin packages (they hold
213
177
  * a `plugin.json` at their own root, which is where `indexInstalledRoot` looks for it).
@@ -1,4 +1,5 @@
1
1
  import type { AgentPluginLifecyclePorts } from "./ports.js";
2
+ import type { SetAgentPluginEnabledInput, SetAgentPluginEnabledResult } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
2
3
  /**
3
4
  * The id named is not installed in this workspace. A distinct class rather than a bare `Error` so
4
5
  * each caller can map it to its own boundary's vocabulary — 404 `AGENT_PLUGIN_NOT_FOUND` at the
@@ -9,19 +10,6 @@ export declare class AgentPluginNotInstalledError extends Error {
9
10
  readonly pluginId: string;
10
11
  });
11
12
  }
12
- export interface SetAgentPluginEnabledInput {
13
- readonly workspaceId: string;
14
- readonly pluginId: string;
15
- readonly enabled: boolean;
16
- /** Recorded as the activation record's updatedBy. The authenticated principal, never a constant. */
17
- readonly actor: string;
18
- }
19
- export interface SetAgentPluginEnabledResult {
20
- readonly pluginId: string;
21
- /** As actually written and read back, not as requested. */
22
- readonly enabled: boolean;
23
- readonly warnings?: readonly string[];
24
- }
25
13
  /** Internal composition; one state/queue instance per injected host context. */
26
14
  export declare function createSetEnabledModule(ports: AgentPluginLifecyclePorts, _optional?: Record<string, never>): {
27
15
  setAgentPluginEnabled: (input: SetAgentPluginEnabledInput, optional?: {