@jini-ai/agent-plugins 0.7.3-next.2 → 0.7.4

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 (234) hide show
  1. package/CHANGELOG.md +7 -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/credential-save-tool.js +2 -3
  24. package/dist/connect/grant-signed-in-defaults.js +1 -1
  25. package/dist/connect/host-deps.d.ts +32 -0
  26. package/dist/connect/host-deps.js +35 -0
  27. package/dist/connect/import-access-token.js +1 -1
  28. package/dist/connect/index.d.ts +7 -2
  29. package/dist/connect/index.js +5 -2
  30. package/dist/connect/installed-plugin.d.ts +28 -0
  31. package/dist/connect/installed-plugin.js +19 -0
  32. package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
  33. package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
  34. package/dist/connect/plugin-host/index.d.ts +1 -2
  35. package/dist/connect/plugin-host/index.js +18 -9
  36. package/dist/connect/token-sign-in.d.ts +1 -14
  37. package/dist/connect/token-sign-in.js +4 -23
  38. package/dist/core/export-props.d.ts +10 -0
  39. package/dist/core/export-props.js +31 -0
  40. package/dist/core/folder-zip-error.d.ts +5 -0
  41. package/dist/core/folder-zip-error.js +8 -0
  42. package/dist/core/host-incompatible-error.d.ts +8 -0
  43. package/dist/core/host-incompatible-error.js +9 -0
  44. package/dist/core/identity-namespace.d.ts +27 -16
  45. package/dist/core/identity-namespace.js +25 -22
  46. package/dist/core/plugin-display-name.d.ts +7 -0
  47. package/dist/core/plugin-display-name.js +11 -0
  48. package/dist/core/provider-plugin-link.d.ts +7 -0
  49. package/dist/core/provider-plugin-link.js +5 -0
  50. package/dist/{connect → core}/token-map.d.ts +11 -1
  51. package/dist/{connect → core}/token-map.js +15 -0
  52. package/dist/core/token-sign-in-list.d.ts +18 -0
  53. package/dist/core/token-sign-in-list.js +23 -0
  54. package/dist/core/update-error.d.ts +8 -0
  55. package/dist/core/update-error.js +9 -0
  56. package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
  57. package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
  58. package/dist/ffmpeg-transcode/adapter.js +155 -0
  59. package/dist/folder-zip-node.d.ts +2 -1
  60. package/dist/folder-zip-node.js +6 -5
  61. package/dist/folder-zip.d.ts +0 -4
  62. package/dist/folder-zip.js +1 -7
  63. package/dist/index.d.ts +3 -1
  64. package/dist/lifecycle/activation.d.ts +39 -3
  65. package/dist/lifecycle/activation.js +467 -418
  66. package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
  67. package/dist/lifecycle/automatic-use-offer.js +52 -0
  68. package/dist/lifecycle/automatic-use.d.ts +33 -1
  69. package/dist/lifecycle/automatic-use.js +159 -38
  70. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  71. package/dist/lifecycle/capability-projection.d.ts +0 -1
  72. package/dist/lifecycle/capability-projection.js +92 -23
  73. package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
  74. package/dist/lifecycle/compatibility-metadata.js +6 -1
  75. package/dist/lifecycle/compatibility.d.ts +1 -8
  76. package/dist/lifecycle/compatibility.js +1 -8
  77. package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
  78. package/dist/lifecycle/exports.d.ts +2 -45
  79. package/dist/lifecycle/exports.js +1 -30
  80. package/dist/lifecycle/host-tools/identity.d.ts +5 -4
  81. package/dist/lifecycle/host-tools/identity.js +5 -5
  82. package/dist/lifecycle/host-tools/ports.d.ts +10 -1
  83. package/dist/lifecycle/host-tools/search-tool.js +18 -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 +17 -3
  106. package/dist/lifecycle/search-projection.js +8 -8
  107. package/dist/lifecycle/search.d.ts +1 -0
  108. package/dist/lifecycle/search.js +2 -2
  109. package/dist/lifecycle/seed-bundled.d.ts +86 -1
  110. package/dist/lifecycle/seed-bundled.js +48 -84
  111. package/dist/lifecycle/set-enabled.d.ts +1 -13
  112. package/dist/lifecycle/set-enabled.js +11 -7
  113. package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
  114. package/dist/lifecycle/trusted-plugin-files.js +33 -30
  115. package/dist/lifecycle/types.d.ts +13 -34
  116. package/dist/lifecycle/uninstall.d.ts +1 -33
  117. package/dist/lifecycle/update-store.d.ts +0 -7
  118. package/dist/lifecycle/update-store.js +1 -8
  119. package/dist/lifecycle/update.d.ts +1 -1
  120. package/dist/lifecycle/update.js +60 -10
  121. package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
  122. package/dist/lifecycle/yauzl-archive-reader.js +11 -6
  123. package/dist/manifest.d.ts +4 -8
  124. package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
  125. package/dist/react/AgentPluginDetailsModal.js +29 -0
  126. package/dist/react/agent-plugin-install-port.d.ts +24 -0
  127. package/dist/react/agent-plugin-install-port.js +15 -0
  128. package/dist/react/installed-skills-composer-source.d.ts +60 -0
  129. package/dist/react/installed-skills-composer-source.js +111 -0
  130. package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
  131. package/dist/react/use-agent-plugins.hooks.js +128 -0
  132. package/dist/site/activation-effects.d.ts +17 -0
  133. package/dist/site/activation-effects.js +31 -0
  134. package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
  135. package/dist/site/admin-surfaces/capabilities.js +30 -0
  136. package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
  137. package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
  138. package/dist/site/admin-surfaces/forms.d.ts +28 -0
  139. package/dist/site/admin-surfaces/forms.js +29 -0
  140. package/dist/site/admin-surfaces/handlers.d.ts +61 -0
  141. package/dist/site/admin-surfaces/handlers.js +35 -0
  142. package/dist/site/admin-surfaces/public-config.d.ts +12 -0
  143. package/dist/site/admin-surfaces/public-config.js +28 -0
  144. package/dist/site/analytics-provider-registry.d.ts +87 -0
  145. package/dist/site/analytics-provider-registry.js +87 -0
  146. package/dist/site/archive-reader-abi.d.ts +35 -0
  147. package/dist/site/archive-reader-abi.js +25 -0
  148. package/dist/site/auth-schemes.d.ts +110 -0
  149. package/dist/site/auth-schemes.js +119 -0
  150. package/dist/site/automatic-agent-plugins.d.ts +200 -0
  151. package/dist/site/automatic-agent-plugins.js +277 -0
  152. package/dist/site/bundled-contribution-sources.d.ts +24 -0
  153. package/dist/site/bundled-contribution-sources.js +17 -0
  154. package/dist/site/bundled-id-upgrade.d.ts +115 -0
  155. package/dist/site/bundled-id-upgrade.js +169 -0
  156. package/dist/site/customize-tool.d.ts +39 -0
  157. package/dist/site/customize-tool.js +31 -0
  158. package/dist/site/deploy-split-activation.d.ts +28 -0
  159. package/dist/site/deploy-split-activation.js +21 -0
  160. package/dist/site/exports/diagnostics.d.ts +37 -0
  161. package/dist/site/exports/diagnostics.js +55 -0
  162. package/dist/site/exports/runtime.d.ts +54 -0
  163. package/dist/site/exports/runtime.js +196 -0
  164. package/dist/site/exports/source.d.ts +42 -0
  165. package/dist/site/exports/source.js +58 -0
  166. package/dist/site/host-plugin-guidance.d.ts +137 -0
  167. package/dist/site/host-plugin-guidance.js +223 -0
  168. package/dist/site/host-signals.d.ts +78 -0
  169. package/dist/site/host-signals.js +83 -0
  170. package/dist/site/install-tool.d.ts +69 -0
  171. package/dist/site/install-tool.js +192 -0
  172. package/dist/site/install-upload.d.ts +175 -0
  173. package/dist/site/install-upload.js +324 -0
  174. package/dist/site/memory-i18n.d.ts +5 -0
  175. package/dist/site/memory-i18n.js +176 -0
  176. package/dist/site/memory.d.ts +80 -0
  177. package/dist/site/memory.js +83 -0
  178. package/dist/site/plugin-memory.d.ts +80 -0
  179. package/dist/site/plugin-memory.js +86 -0
  180. package/dist/site/provider-plugin-link.d.ts +112 -0
  181. package/dist/site/provider-plugin-link.js +100 -0
  182. package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
  183. package/dist/site/retired-plugin-tool-aliases.js +41 -0
  184. package/dist/site/service-ports.d.ts +108 -0
  185. package/dist/site/service-ports.js +2 -0
  186. package/dist/site/set-enabled.d.ts +80 -0
  187. package/dist/site/set-enabled.js +42 -0
  188. package/dist/site/soon-lock.d.ts +83 -0
  189. package/dist/site/soon-lock.js +78 -0
  190. package/dist/site/supersession.d.ts +61 -0
  191. package/dist/site/supersession.js +122 -0
  192. package/dist/site/uninstall-tool.d.ts +136 -0
  193. package/dist/site/uninstall-tool.js +203 -0
  194. package/dist/site/update-effects.d.ts +47 -0
  195. package/dist/site/update-effects.js +49 -0
  196. package/ffmpeg-transcode/plugin.json +16 -0
  197. package/github/source-control/backup-push.mjs +66 -46
  198. package/github/source-control/commit-site.mjs +112 -65
  199. package/github/source-control/write-files.mjs +86 -53
  200. package/github-pages/targets/github-pages.mjs +294 -233
  201. package/google-workspace/form-destinations/mapping.mjs +15 -7
  202. package/google-workspace/form-destinations/sheets.mjs +4 -2
  203. package/google-workspace/plugin.json +1 -0
  204. package/kuinetic/CHANGELOG.md +4 -0
  205. package/kuinetic/plugin.json +4 -1
  206. package/kuinetic/skills/kuinetic/SKILL.md +1 -2
  207. package/package.json +295 -18
  208. package/persistent-state.d.ts +4 -1
  209. package/resend/adapters/resend.mjs +5 -2
  210. package/resend/plugin.json +1 -1
  211. package/s3-compatible/jini-deploy-targets.json +1 -1
  212. package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
  213. package/s3-compatible/targets/s3-compatible.mjs +3 -3
  214. package/site-import/plugin.json +3 -3
  215. package/site-import/skills/site-import/SKILL.md +62 -54
  216. package/site-import/skills/site-import/references/content-mapping.md +26 -20
  217. package/slide-design/plugin.json +1 -1
  218. package/slide-design/skills/slide-design/SKILL.md +8 -2
  219. package/ui-ux-design/CHANGELOG.md +6 -0
  220. package/ui-ux-design/plugin.json +1 -1
  221. package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
  222. package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
  223. package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
  224. package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
  225. package/vercel/NOTES.md +2 -1
  226. package/vercel/object-stores/vercel-blob.mjs +3 -4
  227. package/vercel/targets/vercel.mjs +425 -351
  228. package/core/commerce-server.d.ts +0 -2
  229. package/core/commerce-server.mjs +0 -2
  230. package/dist/admin-surfaces/connections/ports.d.ts +0 -110
  231. package/dist/admin-surfaces/connections/ports.js +0 -2
  232. /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
  233. /package/dist/{lifecycle → core}/install-errors.js +0 -0
  234. /package/dist/{lifecycle → core}/update-plan.js +0 -0
@@ -1,7 +1,8 @@
1
- export * from './update-plan.js';
2
- export { AgentPluginUpdateError } from './update-store.js';
1
+ export * from '../core/update-plan.js';
2
+ export { AgentPluginUpdateError } from '../core/update-error.js';
3
3
  import { createUpdateModule } from './update.js';
4
4
  export * from './compatibility.js';
5
+ export { AgentPluginHostIncompatibleError } from '../core/host-incompatible-error.js';
5
6
  export * from './automatic-use.js';
6
7
  export * from './bundled-file-policy.js';
7
8
  import { createPersistentStateModule } from "./persistent-state.js";
@@ -31,7 +32,7 @@ export * from './contribution-loader.js';
31
32
  export * from './provider-contribution.js';
32
33
  export { createAgentPluginActivations, ACTIVATIONS_FILENAME, ACTIVATIONS_LOCK_FILENAME, AgentPluginActivationsBusyError, AgentPluginActivationsUnreadableError } from './activation.js';
33
34
  export { BUNDLED_DIGESTS_FILENAME } from './bundled-digests.js';
34
- export { AgentPluginInstallError } from './install.js';
35
+ export { AgentPluginInstallError } from '../core/install-errors.js';
35
36
  export { PackagePathViolation } from './package-paths.js';
36
37
  export { AgentPluginNotInstalledError } from './set-enabled.js';
37
38
  export { AgentPluginNotFoundError, AgentPluginNotUninstallableError, AgentPluginChangedSincePreviewError } from './uninstall.js';
@@ -104,7 +105,7 @@ function lifecycleInstallFacade(context, modules) {
104
105
  preferBundledAgentPluginDigests: (input) => digests.preferBundledAgentPluginDigests(input.installed, input.bundled),
105
106
  normalizePackageEntryPath: (input) => paths.normalizePackageEntryPath(input.rawEntryPath),
106
107
  assertContainedOnDisk: (input) => paths.assertContainedOnDisk(input.packageRoot, input.entryPath),
107
- classifyAgentPluginMcpServerTrust: (input) => capabilities.classifyAgentPluginMcpServerTrust(input.server),
108
+ classifyAgentPluginMcpServerTrust: (input, _optional = {}) => capabilities.classifyAgentPluginMcpServerTrust(input.server),
108
109
  readInstalledSkillMarkdown: (input) => capabilities.readInstalledSkillMarkdown(input.packageRoot, input.skillPath),
109
110
  readInstalledSkillFile: capabilities.readInstalledSkillFile,
110
111
  readInstalledMcpServerIds: (input) => capabilities.readInstalledMcpServerIds(input.packageRoot),
@@ -31,9 +31,8 @@
31
31
  * difference is entirely in whether the digest came from somewhere other than the bytes.
32
32
  */
33
33
  import { type FetchAgentPluginArchiveOptional } from "./fetch-archive.js";
34
- import { type AgentPluginArchiveReaderPort, type InstalledAgentPlugin } from "./install.js";
35
34
  import type { AgentPluginLifecyclePorts } from "./ports.js";
36
- import type { AgentPluginLayout } from "./layout.js";
35
+ import type { AgentPluginArchiveReaderPort, InstalledAgentPlugin, AgentPluginLayout } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
37
36
  /**
38
37
  * See this module's header for why this is a union rather than an optional `expectedSha256`.
39
38
  */
@@ -1,38 +1,8 @@
1
- import type { AgentPluginLayout } from "./layout.js";
2
1
  import type { AgentPluginLifecyclePorts } from "./ports.js";
3
- import type { InstalledAgentPlugin } from "./types.js";
4
- export type { InstalledAgentPlugin, InstalledAgentPluginSkill } from "./types.js";
5
- export { AgentPluginInstallError } from "./install-errors.js";
6
- export type { AgentPluginInstallErrorCode } from "./install-errors.js";
7
- /** One archive entry. A symlink is modeled as its OWN kind rather than folded into "file" — the
8
- * zip-slip research this module's header cites is explicit that the symlink-entry vector is
9
- * distinct from the lexical-traversal one, and the two need independent tests and independent
10
- * handling (see the "symlink entries are rejected outright" rule below). */
11
- export type AgentPluginArchiveEntry = {
12
- readonly kind: "file";
13
- readonly entryPath: string;
14
- /** The archive format's own claimed size. Never trusted alone — see `DECOMPRESSION_BOMB`. */
15
- readonly declaredSize?: (number) | undefined;
16
- readonly executable?: (boolean) | undefined;
17
- readonly openReadStream: (required: Record<string, never>) => AsyncIterable<Uint8Array>;
18
- } | {
19
- readonly kind: "directory";
20
- readonly entryPath: string;
21
- } | {
22
- readonly kind: "symlink" | "hardlink" | "device" | "fifo";
23
- readonly entryPath: string;
24
- readonly linkTarget?: string | undefined;
25
- };
26
- /**
27
- * `entries` must be a pure function of the archive bytes: an install iterates it twice, once to
28
- * check entry-count limits from metadata alone and once to extract.
29
- */
30
- /** `entries` is a pure function of archive bytes: metadata preflight and extraction iterate it twice. */
31
- export interface AgentPluginArchiveReaderPort {
32
- entries(required: {
33
- readonly archive: Uint8Array;
34
- }): AsyncIterable<AgentPluginArchiveEntry>;
35
- }
2
+ import type { AgentPluginLayout, InstalledAgentPlugin } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
3
+ import type { AgentPluginArchiveReaderPort } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
4
+ export { AgentPluginInstallError } from "../core/install-errors.js";
5
+ export type { AgentPluginInstallErrorCode } from "../core/install-errors.js";
36
6
  export interface InstallAgentPluginRequired {
37
7
  readonly archive: Uint8Array;
38
8
  /** Lowercase hex SHA-256 the caller expects `archive` to hash to — a real marketplace flow would
@@ -1,7 +1,7 @@
1
1
  import { resolveAgentPluginLifecycleNamespace } from '../core/identity-namespace.js';
2
2
  import { listInstalledPackageRoots } from "./installed-package-roots.js";
3
3
  import { createUninstallModule } from "./uninstall.js";
4
- import { AgentPluginInstallError } from "./install-errors.js";
4
+ import { AgentPluginInstallError } from "../core/install-errors.js";
5
5
  import { createInstalledPackageIndex } from "./installed-package-index.js";
6
6
  import { readPluginIdentity, assertPluginIdentityAvailable } from "@jini-ai/core/plugin-directory";
7
7
  /**
@@ -71,7 +71,7 @@ import { constants } from "node:fs";
71
71
  import path from "node:path";
72
72
  import { PackagePathViolation } from "./package-paths.js";
73
73
  import { createPackagePathsModule } from "./package-paths.js";
74
- export { AgentPluginInstallError } from "./install-errors.js";
74
+ export { AgentPluginInstallError } from "../core/install-errors.js";
75
75
  const LIMITS = {
76
76
  maxArchiveBytes: 32 * 1024 * 1024,
77
77
  maxEntries: 4096,
@@ -93,7 +93,7 @@ async function assertIdentityAvailable({ ports, workspaceRoot, candidate }) {
93
93
  let identity;
94
94
  try {
95
95
  raw = JSON.parse(await ports.filesystem.readFile(manifestPath, 'utf8'));
96
- identity = readPluginIdentity({ manifest: raw, name: root.localId, namespace: resolveAgentPluginLifecycleNamespace({ value: raw, extensionNamespace: ports.extensionNamespace }) });
96
+ identity = readPluginIdentity({ manifest: raw, name: root.localId, namespace: resolveAgentPluginLifecycleNamespace({ value: raw, extensionNamespace: ports.extensionNamespace }, { legacyIdentity: ports.legacyIdentity }) });
97
97
  }
98
98
  catch {
99
99
  // A damaged unrelated install must not block fresh installs or bundled seeding.
@@ -1,5 +1,5 @@
1
1
  import type { AgentPluginLifecyclePorts } from "./ports.js";
2
- import type { InstalledAgentPlugin } from "./types.js";
2
+ import type { InstalledAgentPlugin } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
3
3
  /** Indexes manifests and files with the same injected effects used by installation and resolution.
4
4
  * @complexity O(f) reads/walk work for f package files; no mutation or executable imports. */
5
5
  export declare function createInstalledPackageIndex(required: {
@@ -1,12 +1,12 @@
1
1
  import { resolveAgentPluginLifecycleNamespace } from '../core/identity-namespace.js';
2
2
  /** Read-side owner of installed package metadata; never constructs a mutation lifecycle. */
3
3
  import path from "node:path";
4
- import { AgentPluginInstallError } from "./install-errors.js";
4
+ import { AgentPluginInstallError } from "../core/install-errors.js";
5
5
  import { parseAgentPluginManifest as parseAgentPluginManifestValue } from "./manifest.js";
6
6
  /** Keep undeclared metadata absent, including for older packages. No extra manifest read. */
7
7
  function indexedMetadata({ manifest }, _optional = {}) {
8
- const { requires, hostRange, exports, renamedFrom } = manifest;
9
- return Object.fromEntries(Object.entries({ requires, hostRange, exports, renamedFrom }).filter(([, value]) => value !== undefined));
8
+ const { requires, companions, hostRange, exports, renamedFrom } = manifest;
9
+ return Object.fromEntries(Object.entries({ requires, companions, hostRange, exports, renamedFrom }).filter(([, value]) => value !== undefined));
10
10
  }
11
11
  /** Cosmetic fields are trimmed and capped rather than invalidating the package. The cap stops
12
12
  * a hostile package flooding an admin row. Malformed values fall back because these fields are
@@ -18,7 +18,7 @@ function readDisplayText(required, _optional = {}) {
18
18
  return text ? { [required.key]: text.slice(0, required.maxLength) } : {};
19
19
  }
20
20
  function createInstalledManifestReader(ports, readFile) {
21
- const parseAgentPluginManifest = (value) => parseAgentPluginManifestValue({ value }, { identityNamespace: resolveAgentPluginLifecycleNamespace({ value, extensionNamespace: ports.extensionNamespace }) });
21
+ const parseAgentPluginManifest = (value) => parseAgentPluginManifestValue({ value }, { identityNamespace: resolveAgentPluginLifecycleNamespace({ value, extensionNamespace: ports.extensionNamespace }, { legacyIdentity: ports.legacyIdentity }), legacyIdentity: ports.legacyIdentity });
22
22
  /** Reads and validates `packageRoot`'s `plugin.json`, refusing a missing, unparseable or invalid one. */
23
23
  return async function readInstalledManifest({ packageRoot }) {
24
24
  let manifestRaw;
@@ -1,30 +1,26 @@
1
- export interface AgentPluginWorkspaceLayout {
2
- readonly root: string;
3
- readonly packages: string;
4
- readonly staging: string;
5
- pluginRootDir(required: {
6
- readonly pluginId: string;
7
- }, optional?: Record<string, never>): string;
8
- pluginPackagesDir(required: {
9
- readonly pluginId: string;
10
- }, optional?: Record<string, never>): string;
11
- pluginMemoryDir(required: {
12
- readonly pluginId: string;
13
- readonly kind: 'learned' | 'notes';
14
- }, optional?: Record<string, never>): string;
15
- pluginDataDir(required: {
16
- readonly pluginId: string;
17
- }): string;
18
- }
19
- export interface AgentPluginLayoutPort {
20
- readonly root: string;
21
- forWorkspace(required: {
22
- readonly workspaceId: string;
23
- }): AgentPluginWorkspaceLayout;
24
- }
25
- export type AgentPluginLayout = AgentPluginLayoutPort;
1
+ import type { AgentPluginLayoutPort } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
26
2
  /** Explicit root only; site-root and environment resolution belong to the consumer. */
27
3
  export declare function createAgentPluginLayout(required: {
28
4
  readonly root: string;
29
5
  }, _optional?: Record<string, never>): AgentPluginLayoutPort;
6
+ import type { AgentPluginLayout } from '@jini-ai/core/contracts/headless/plugin-host';
7
+ export declare function createAgentPluginSiteLayout(required: {
8
+ siteDir: string;
9
+ rootOverride: string | undefined;
10
+ diagnostics: {
11
+ rootOverride(input: {
12
+ rootOverride: string;
13
+ }): Error;
14
+ workspaceId(input: {
15
+ workspaceId: string;
16
+ }): Error;
17
+ pluginId(input: {
18
+ pluginId: string;
19
+ }): Error;
20
+ pluginDataId(input: {
21
+ pluginId: string;
22
+ }): Error;
23
+ memoryKind(): Error;
24
+ };
25
+ }, _optional?: {}): AgentPluginLayout;
30
26
  //# sourceMappingURL=layout.d.ts.map
@@ -35,4 +35,83 @@ function assertSafeSegment(value) {
35
35
  throw new Error(`'${value}' is not a safe plugin/workspace id`);
36
36
  }
37
37
  }
38
+ /**
39
+ * @file Pure filesystem layout computation for installed Agent Plugins; callers perform I/O.
40
+ *
41
+ * The owner requires workspace isolation. A shared content-addressed package directory would
42
+ * leak another tenant's installs: public archive digests are precomputable and stat-able even
43
+ * when bytes are frozen. A per-workspace tree enforces isolation by construction rather than
44
+ * relying on every future reader to check activation records. It also avoids cross-workspace
45
+ * refcounts and prevents uninstalling one workspace's plugin from deleting another's bytes.
46
+ * Plugin archives are hostile third-party input; per-workspace extraction costs are bounded by
47
+ * the lifecycle owner's archive/expanded-byte limits. Content deduplication stays within a workspace.
48
+ * Writable PLUGIN_DATA belongs to the same workspace tree.
49
+ *
50
+ * Installed plugins are site data: they must travel with the site and survive upgrades.
51
+ */
52
+ /**
53
+ * One safe, indivisible path segment: lowercase alphanumerics in `-`/`.`-separated runs, with no
54
+ * leading, trailing, or doubled separator. Matches the Agent Plugins spec's own `name` grammar
55
+ * (§5.5), and — by construction — cannot be `.`, `..`, empty, or contain a `/`, `\`, or whitespace,
56
+ * which is the entire property this module needs before using a caller-supplied string in a
57
+ * `path.join`.
58
+ *
59
+ * Workspace IDs are safe path segments, not necessarily UUIDs: the site's real ID can be
60
+ * `workspace-local`. The check must prevent splitting or escaping a path while accepting that ID.
61
+ *
62
+ * Deliberately NOT relaxed further: `_`, uppercase (normalized before this is applied, never
63
+ * accepted raw), and any Unicode remain rejected, because each would let two distinct ids collide
64
+ * onto one directory on a case-insensitive or normalizing filesystem.
65
+ */
66
+ const SAFE_ID_SEGMENT_PATTERN = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/;
67
+ /** Bounds the segment so a caller cannot drive a pathological path length. Applied to both ids. */
68
+ const MAX_ID_SEGMENT_LENGTH = 64;
69
+ export function createAgentPluginSiteLayout(required, _optional = {}) {
70
+ const override = required.rootOverride;
71
+ if (override !== undefined && !path.isAbsolute(override)) {
72
+ throw required.diagnostics.rootOverride({ rootOverride: override });
73
+ }
74
+ const root = path.resolve(override ?? path.join(required.siteDir, "agent-plugins"));
75
+ const workspacesDir = path.join(root, "ws");
76
+ return {
77
+ root,
78
+ workspacesDir,
79
+ forWorkspace({ workspaceId }, _optional = {}) {
80
+ // Normalize BEFORE validating, not after: the pattern is deliberately lowercase-only (see its
81
+ // own doc), so validating the raw string would reject an uppercase id that the old UUID rule
82
+ // accepted — and the normalized value is the one that actually becomes the path segment, so it
83
+ // is the only value worth asserting about.
84
+ const normalizedWorkspaceId = workspaceId.toLowerCase();
85
+ if (!SAFE_ID_SEGMENT_PATTERN.test(normalizedWorkspaceId) || normalizedWorkspaceId.length > MAX_ID_SEGMENT_LENGTH) {
86
+ // Quotes the RAW input, not the normalized one, so the message names what the caller passed.
87
+ throw required.diagnostics.workspaceId({ workspaceId });
88
+ }
89
+ const workspaceRoot = path.join(workspacesDir, normalizedWorkspaceId);
90
+ const pluginRootDir = ({ pluginId }, _optional = {}) => {
91
+ if (!SAFE_ID_SEGMENT_PATTERN.test(pluginId) || pluginId.length > MAX_ID_SEGMENT_LENGTH) {
92
+ throw required.diagnostics.pluginId({ pluginId });
93
+ }
94
+ return pluginStatePaths({ workspaceRoot, pluginId }).root;
95
+ };
96
+ return {
97
+ root: workspaceRoot,
98
+ pluginRootDir,
99
+ pluginPackagesDir: ({ pluginId }, _optional = {}) => path.join(pluginRootDir({ pluginId }), "package", "sha256"),
100
+ pluginMemoryDir: ({ pluginId, kind }, _optional = {}) => {
101
+ if (kind !== "learned" && kind !== "notes")
102
+ throw required.diagnostics.memoryKind();
103
+ return path.join(pluginRootDir({ pluginId }), "memory", kind);
104
+ },
105
+ packages: path.join(workspaceRoot, "packages", "sha256"),
106
+ staging: path.join(workspaceRoot, "staging"),
107
+ pluginDataDir({ pluginId }, _optional = {}) {
108
+ if (!SAFE_ID_SEGMENT_PATTERN.test(pluginId) || pluginId.length > MAX_ID_SEGMENT_LENGTH) {
109
+ throw required.diagnostics.pluginDataId({ pluginId });
110
+ }
111
+ return path.join(pluginRootDir({ pluginId }), "data");
112
+ },
113
+ };
114
+ },
115
+ };
116
+ }
38
117
  //# sourceMappingURL=layout.js.map
@@ -1,14 +1,16 @@
1
- export { resolveAgentPluginIdentityNamespace, readAgentPluginPortableExtension, readAgentPluginCompatibilityWarnings, legacyAgentPluginMetadataWarning } from '../core/identity-namespace.js';
1
+ import { type AgentPluginIdentityReadOptions, type LegacyMcpAliases } from '../core/identity-namespace.js';
2
+ import type { AgentPluginExportMetadata, PluginManifestAuthor } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
3
+ export { type AgentPluginIdentityReadOptions, type LegacyAgentPluginIdentity, type LegacyMcpAliases, resolveAgentPluginIdentityNamespace, readAgentPluginPortableExtension, readAgentPluginCompatibilityWarnings } from '../core/identity-namespace.js';
2
4
  import { type AgentPluginMetadata } from './metadata.js';
3
5
  export * from './metadata.js';
4
6
  export * from './credential-card-metadata.js';
5
7
  export { isAgentPluginName } from '../core/plugin-name.js';
6
- import { type AgentPluginExportMetadata } from './exports.js';
7
8
  export * from './exports.js';
8
9
  export { validatePluginManifest, validateMcpManifest } from '../manifest.js';
9
10
  export type { PluginManifest, McpManifest, McpServerEntry } from '../manifest.js';
10
- import type { PluginManifestAuthor } from '../manifest.js';
11
- export type { PluginManifestAuthor } from '../manifest.js';
11
+ /** Deprecated re-export: import these from `@jini-ai/core/contracts/site/agent-plugins-lifecycle` and `-manifest`; removed at the next major. */
12
+ export type { AgentPluginExportMetadata, PluginManifestAuthor } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
13
+ export type { AgentPluginExport, AgentPluginExportConsent, AgentPluginExportExternalHosts, AgentPluginExportStaticMode } from "@jini-ai/core/contracts/site/agent-plugins-manifest";
12
14
  /** Agent Plugins 1.0.0/1.1.0 parsing, with application metadata confined to an explicit namespace. */
13
15
  export type AgentPluginServerMetadataReader = (required: {
14
16
  readonly serverId: string;
@@ -28,6 +30,7 @@ export interface AgentPluginManifest extends AgentPluginExportMetadata, AgentPlu
28
30
  readonly provides?: readonly string[] | undefined;
29
31
  /** `extensions.<ns>.requires`: advisory capability ids other active plugins should provide. */
30
32
  readonly requires?: readonly string[] | undefined;
33
+ readonly companions?: readonly string[] | undefined;
31
34
  /** `extensions.<ns>.hostRange`: semver range over AGENT_PLUGIN_CONTRACT_VERSION; a malformed value is stored as `<invalid>`. */
32
35
  readonly hostRange?: string | undefined;
33
36
  }
@@ -50,9 +53,7 @@ export type ParseAgentPluginManifestResult = {
50
53
  */
51
54
  export declare function parseAgentPluginManifest({ value }: {
52
55
  readonly value: unknown;
53
- }, optional?: {
54
- readonly identityNamespace?: string;
55
- }): ParseAgentPluginManifestResult;
56
+ }, optional?: AgentPluginIdentityReadOptions): ParseAgentPluginManifestResult;
56
57
  /**
57
58
  * The three closed transport variants `mcp.schema.json` 1.0.0/1.1.0 defines. See this file's header for
58
59
  * the verified field shape of each.
@@ -161,6 +162,8 @@ export declare function parseAgentPluginMcpConfig({ value, extensionNamespace }:
161
162
  }, optional?: {
162
163
  readonly pluginManifest?: unknown;
163
164
  readonly readServerMetadata?: AgentPluginServerMetadataReader | undefined;
165
+ readonly legacyMcpAliases?: LegacyMcpAliases | undefined;
166
+ readonly legacyIdentity?: AgentPluginIdentityReadOptions["legacyIdentity"];
164
167
  }): ParseAgentPluginMcpConfigResult;
165
168
  /** Typed extension reader: unknown namespaces have no semantics until a host supplies a reader. */
166
169
  export declare function readAgentPluginExtension<T>(required: {
@@ -37,7 +37,7 @@
37
37
  * spec-defined field — the host is the client the spec defers that decision to. This module accepts
38
38
  * portable metadata in `plugin.json`'s `extensions.jini.mcpServers[serverId]`, with an explicit
39
39
  * namespace option for custom clients. Legacy auth and sign-in defaults in MCP entries remain
40
- * readable automatically, but those cannot supply operator read trust. Custom clients can use
40
+ * readable with host-bound aliases, but those cannot supply operator read trust. Custom clients can use
41
41
  * readServerMetadata to translate their own fields before the same validators run.
42
42
  * `authMode: "oauth" | "none"` selects client auth; absent defaults to "none".
43
43
  * `defaultTools: { allow?, write?, read? }` names sign-in grants and reviewed read tools.
@@ -56,8 +56,8 @@
56
56
  * caller that reads the file and hands the parsed value here.
57
57
  */
58
58
  import { isAgentPluginName, MAX_NAME_LENGTH } from '../core/plugin-name.js';
59
- import { resolveAgentPluginIdentityNamespace, readCompatibleAgentPluginServerMetadata, hasLegacyAgentPluginServerMetadata, legacyAgentPluginMetadataWarning, readAgentPluginCompatibilityWarnings, isPortableAgentPluginNamespace } from '../core/identity-namespace.js';
60
- export { resolveAgentPluginIdentityNamespace, readAgentPluginPortableExtension, readAgentPluginCompatibilityWarnings, legacyAgentPluginMetadataWarning } from '../core/identity-namespace.js';
59
+ import { resolveAgentPluginIdentityNamespace, readCompatibleAgentPluginServerMetadata, hasLegacyAgentPluginServerMetadata, readAgentPluginCompatibilityWarnings, isPortableAgentPluginNamespace } from '../core/identity-namespace.js';
60
+ export { resolveAgentPluginIdentityNamespace, readAgentPluginPortableExtension, readAgentPluginCompatibilityWarnings } from '../core/identity-namespace.js';
61
61
  import { readAgentPluginMetadata } from './metadata.js';
62
62
  export * from './metadata.js';
63
63
  export * from './credential-card-metadata.js';
@@ -415,8 +415,8 @@ function collectMcpConfigErrors({ raw }, { pluginManifest } = {}) {
415
415
  return errors;
416
416
  }
417
417
  /** The per-server metadata `plugin.json` declares under `extensionNamespace`, or `{}` when it declares none. */
418
- function readExtensionServers({ pluginManifest, extensionNamespace }) {
419
- const manifest = parseAgentPluginManifest({ value: pluginManifest }, { identityNamespace: extensionNamespace });
418
+ function readExtensionServers({ pluginManifest, extensionNamespace }, optional = {}) {
419
+ const manifest = parseAgentPluginManifest({ value: pluginManifest }, { identityNamespace: extensionNamespace, ...optional });
420
420
  if (!manifest.ok)
421
421
  return {};
422
422
  return readAgentPluginExtension({ manifest: manifest.manifest, namespace: extensionNamespace, read: ({ value }) => isJsonObject(value.mcpServers) ? value.mcpServers : {} }) ?? {};
@@ -442,27 +442,32 @@ export function parseAgentPluginMcpConfig({ value, extensionNamespace }, optiona
442
442
  }
443
443
  /** Valid transports are independent siblings; a malformed declaration never hides their ids. */
444
444
  function parseMcpServers({ raw, extensionNamespace }, optional) {
445
- const namespace = resolveAgentPluginIdentityNamespace({ value: optional.pluginManifest }, extensionNamespace === undefined ? {} : { identityNamespace: extensionNamespace });
446
- const extensionServers = readExtensionServers({ pluginManifest: optional.pluginManifest, extensionNamespace: namespace });
445
+ const namespace = resolveAgentPluginIdentityNamespace({ value: optional.pluginManifest }, { identityNamespace: extensionNamespace, legacyIdentity: optional.legacyIdentity });
446
+ const extensionServers = readExtensionServers({ pluginManifest: optional.pluginManifest, extensionNamespace: namespace }, optional);
447
447
  const entries = Object.entries(raw.mcpServers);
448
448
  const servers = Object.create(null);
449
- const warnings = [...readAgentPluginCompatibilityWarnings({ value: optional.pluginManifest }, { identityNamespace: namespace })];
450
- const portable = isPortableAgentPluginNamespace({ namespace: extensionNamespace });
451
- const readServerMetadata = optional.readServerMetadata ?? (portable ? readCompatibleAgentPluginServerMetadata : undefined);
449
+ const warnings = [...readAgentPluginCompatibilityWarnings({ value: optional.pluginManifest }, { identityNamespace: namespace, legacyIdentity: optional.legacyIdentity })];
450
+ const portable = isPortableAgentPluginNamespace({ namespace: extensionNamespace }, optional);
451
+ const readServerMetadata = selectMcpServerMetadataReader({ portable }, optional);
452
452
  for (const [serverId, rawServer] of entries) {
453
453
  const extension = Object.hasOwn(extensionServers, serverId) ? extensionServers[serverId] : undefined;
454
- collectLegacyServerWarning({ rawServer, extension, portable, warnings });
454
+ collectLegacyServerWarning({ rawServer, extension, portable, warnings, legacyMcpAliases: optional.legacyMcpAliases });
455
455
  const parsed = parseDeclaredServer({ serverId, rawServer, extension }, { readServerMetadata });
456
456
  if (parsed)
457
457
  servers[serverId] = parsed;
458
458
  }
459
459
  return { ok: true, config: { serverIds: entries.map(([serverId]) => serverId), servers }, ...(warnings.length ? { warnings: [...new Set(warnings)] } : {}) };
460
460
  }
461
- function collectLegacyServerWarning({ rawServer, extension, portable, warnings }) {
462
- if (!portable || !isJsonObject(rawServer))
461
+ function selectMcpServerMetadataReader({ portable }, options) {
462
+ return options.readServerMetadata ?? (portable
463
+ ? required => readCompatibleAgentPluginServerMetadata(required, { legacyMcpAliases: options.legacyMcpAliases })
464
+ : undefined);
465
+ }
466
+ function collectLegacyServerWarning({ rawServer, extension, portable, warnings, legacyMcpAliases }) {
467
+ if (!portable || !isJsonObject(rawServer) || !legacyMcpAliases)
463
468
  return;
464
- if (hasLegacyAgentPluginServerMetadata({ value: isJsonObject(extension) ? extension : {}, server: rawServer }))
465
- warnings.push(legacyAgentPluginMetadataWarning);
469
+ if (hasLegacyAgentPluginServerMetadata({ value: isJsonObject(extension) ? extension : {}, server: rawServer }, { legacyMcpAliases }))
470
+ warnings.push(legacyMcpAliases.warning);
466
471
  }
467
472
  /** Typed extension reader: unknown namespaces have no semantics until a host supplies a reader. */
468
473
  export function readAgentPluginExtension(required, _optional = {}) {
@@ -1,5 +1,5 @@
1
1
  import type { AgentPluginMcpProvisioningPort } from './ports.js';
2
- import type { InstalledAgentPlugin } from './install.js';
2
+ import type { InstalledAgentPlugin } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
3
3
  /** A host performs MCP federation. Notify only after its durable provisioning step succeeds. */
4
4
  export declare function provisionAgentPluginMcp(required: {
5
5
  readonly mcpProvisioning: AgentPluginMcpProvisioningPort;
@@ -1,3 +1,6 @@
1
+ /** Portable advisory metadata. Invalid declarations warn and contribute nothing; parsing never
2
+ * executes a plugin or turns presentation copy into an authorization decision. */
3
+ import { type AgentPluginIdentityReadOptions } from '../core/identity-namespace.js';
1
4
  export interface AgentPluginHostSignal {
2
5
  readonly env: string;
3
6
  readonly facts: {
@@ -11,6 +14,8 @@ export interface AgentPluginMetadata {
11
14
  readonly displayName?: string;
12
15
  readonly summary?: string;
13
16
  readonly vendorAliases?: readonly string[];
17
+ /** Prefix the host puts on this plugin's client-setting names (upper-case letters, digits, underscores, ending in `_`). The host's own default applies when absent. */
18
+ readonly clientNamespace?: string;
14
19
  readonly toolKeywords?: Readonly<Record<string, string>>;
15
20
  readonly hostSignals?: readonly AgentPluginHostSignal[];
16
21
  readonly deploymentAdvice?: string;
@@ -22,9 +27,7 @@ export interface AgentPluginMetadata {
22
27
  * @returns Typed advisory fields and host-visible diagnostics. @complexity O(k + s) metadata keys/signals. */
23
28
  export declare function readAgentPluginMetadata(required: {
24
29
  readonly value: unknown;
25
- }, optional?: {
26
- readonly identityNamespace?: string;
27
- }): {
30
+ }, optional?: AgentPluginIdentityReadOptions): {
28
31
  readonly metadata: AgentPluginMetadata;
29
32
  readonly warnings: readonly string[];
30
33
  };
@@ -4,6 +4,7 @@ import { readAgentPluginPortableExtension, readAgentPluginCompatibilityWarnings
4
4
  const object = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
5
5
  const text = (value) => typeof value === 'string' && value.trim().length > 0 && value.length <= 2048 && !/[\x00-\x1f\x7f]/.test(value);
6
6
  const texts = (value) => Array.isArray(value) && value.every(text);
7
+ const namespaceText = (value) => typeof value === 'string' && /^[A-Z][A-Z0-9_]*_$/.test(value);
7
8
  const textMap = (value) => object(value) && Object.values(value).every(text);
8
9
  /** Only declared boolean facts and a finite positive safe proxy-hop count can be host hints. */
9
10
  function validFacts(value) {
@@ -26,7 +27,7 @@ export function readAgentPluginMetadata(required, optional = {}) {
26
27
  const extension = readAgentPluginPortableExtension(required, optional) ?? {};
27
28
  const warnings = [...readAgentPluginCompatibilityWarnings(required, optional)];
28
29
  const metadata = {};
29
- for (const [key, check] of Object.entries({ vendorAliases: texts, card: textMap })) {
30
+ for (const [key, check] of Object.entries({ vendorAliases: texts, card: textMap, clientNamespace: namespaceText })) {
30
31
  if (extension[key] === undefined)
31
32
  continue;
32
33
  if (check(extension[key]))
@@ -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
  }>;