@jini-ai/agent-plugins 0.7.3-next.2 → 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 (231) hide show
  1. package/README.md +22 -4
  2. package/calendly/README.md +29 -0
  3. package/calendly/mcp.json +1 -1
  4. package/cloudflare/lib/assets.mjs +1 -1
  5. package/cloudflare/lib/cms-forms.mjs +1 -1
  6. package/core/persistent-state.d.ts +4 -1
  7. package/core/persistent-state.js +55 -21
  8. package/dist/admin-surfaces/callback-field-inbox.d.ts +1 -6
  9. package/dist/admin-surfaces/connections/connections.d.ts +2 -6
  10. package/dist/admin-surfaces/connections/index.d.ts +3 -2
  11. package/dist/admin-surfaces/index.d.ts +3 -1
  12. package/dist/connect/access-token-tool.d.ts +1 -1
  13. package/dist/connect/access-token-tool.js +1 -1
  14. package/dist/connect/catalog.d.ts +26 -0
  15. package/dist/connect/catalog.js +42 -0
  16. package/dist/connect/connect-tool.d.ts +2 -294
  17. package/dist/connect/connect-tool.js +2 -53
  18. package/dist/connect/contracts.d.ts +257 -0
  19. package/dist/connect/contracts.js +2 -0
  20. package/dist/connect/credential-cards.d.ts +2 -0
  21. package/dist/connect/credential-cards.js +7 -4
  22. package/dist/connect/grant-signed-in-defaults.js +1 -1
  23. package/dist/connect/host-deps.d.ts +32 -0
  24. package/dist/connect/host-deps.js +35 -0
  25. package/dist/connect/import-access-token.js +1 -1
  26. package/dist/connect/index.d.ts +7 -2
  27. package/dist/connect/index.js +5 -2
  28. package/dist/connect/installed-plugin.d.ts +28 -0
  29. package/dist/connect/installed-plugin.js +19 -0
  30. package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
  31. package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
  32. package/dist/connect/plugin-host/index.d.ts +1 -2
  33. package/dist/connect/plugin-host/index.js +18 -9
  34. package/dist/connect/token-sign-in.d.ts +1 -14
  35. package/dist/connect/token-sign-in.js +4 -23
  36. package/dist/core/export-props.d.ts +10 -0
  37. package/dist/core/export-props.js +31 -0
  38. package/dist/core/folder-zip-error.d.ts +5 -0
  39. package/dist/core/folder-zip-error.js +8 -0
  40. package/dist/core/host-incompatible-error.d.ts +8 -0
  41. package/dist/core/host-incompatible-error.js +9 -0
  42. package/dist/core/identity-namespace.d.ts +27 -16
  43. package/dist/core/identity-namespace.js +25 -22
  44. package/dist/core/plugin-display-name.d.ts +7 -0
  45. package/dist/core/plugin-display-name.js +11 -0
  46. package/dist/core/provider-plugin-link.d.ts +7 -0
  47. package/dist/core/provider-plugin-link.js +5 -0
  48. package/dist/{connect → core}/token-map.d.ts +11 -1
  49. package/dist/{connect → core}/token-map.js +15 -0
  50. package/dist/core/token-sign-in-list.d.ts +18 -0
  51. package/dist/core/token-sign-in-list.js +23 -0
  52. package/dist/core/update-error.d.ts +8 -0
  53. package/dist/core/update-error.js +9 -0
  54. package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
  55. package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
  56. package/dist/ffmpeg-transcode/adapter.js +155 -0
  57. package/dist/folder-zip-node.d.ts +2 -1
  58. package/dist/folder-zip-node.js +6 -5
  59. package/dist/folder-zip.d.ts +0 -4
  60. package/dist/folder-zip.js +1 -7
  61. package/dist/index.d.ts +3 -1
  62. package/dist/lifecycle/activation.d.ts +39 -3
  63. package/dist/lifecycle/activation.js +467 -418
  64. package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
  65. package/dist/lifecycle/automatic-use-offer.js +52 -0
  66. package/dist/lifecycle/automatic-use.d.ts +33 -1
  67. package/dist/lifecycle/automatic-use.js +157 -38
  68. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  69. package/dist/lifecycle/capability-projection.d.ts +0 -1
  70. package/dist/lifecycle/capability-projection.js +92 -23
  71. package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
  72. package/dist/lifecycle/compatibility-metadata.js +6 -1
  73. package/dist/lifecycle/compatibility.d.ts +1 -8
  74. package/dist/lifecycle/compatibility.js +1 -8
  75. package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
  76. package/dist/lifecycle/exports.d.ts +2 -45
  77. package/dist/lifecycle/exports.js +1 -30
  78. package/dist/lifecycle/host-tools/identity.d.ts +5 -4
  79. package/dist/lifecycle/host-tools/identity.js +5 -5
  80. package/dist/lifecycle/host-tools/ports.d.ts +10 -1
  81. package/dist/lifecycle/host-tools/search-tool.js +18 -8
  82. package/dist/lifecycle/host-tools/skill-tool.js +1 -1
  83. package/dist/lifecycle/index.d.ts +20 -17
  84. package/dist/lifecycle/index.js +5 -4
  85. package/dist/lifecycle/install-from-url.d.ts +1 -2
  86. package/dist/lifecycle/install.d.ts +4 -34
  87. package/dist/lifecycle/install.js +3 -3
  88. package/dist/lifecycle/installed-package-index.d.ts +1 -1
  89. package/dist/lifecycle/installed-package-index.js +4 -4
  90. package/dist/lifecycle/layout.d.ts +21 -25
  91. package/dist/lifecycle/layout.js +79 -0
  92. package/dist/lifecycle/manifest.d.ts +10 -7
  93. package/dist/lifecycle/manifest.js +20 -15
  94. package/dist/lifecycle/mcp-provisioning.d.ts +1 -1
  95. package/dist/lifecycle/metadata.d.ts +6 -3
  96. package/dist/lifecycle/metadata.js +2 -1
  97. package/dist/lifecycle/package-paths.js +59 -56
  98. package/dist/lifecycle/persistent-state.d.ts +10 -1
  99. package/dist/lifecycle/persistent-state.js +4 -2
  100. package/dist/lifecycle/ports.d.ts +18 -6
  101. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -14
  102. package/dist/lifecycle/retire-bundled.d.ts +1 -1
  103. package/dist/lifecycle/search-projection.d.ts +3 -1
  104. package/dist/lifecycle/search-projection.js +7 -3
  105. package/dist/lifecycle/search.d.ts +1 -0
  106. package/dist/lifecycle/seed-bundled.d.ts +86 -1
  107. package/dist/lifecycle/seed-bundled.js +48 -84
  108. package/dist/lifecycle/set-enabled.d.ts +1 -13
  109. package/dist/lifecycle/set-enabled.js +11 -7
  110. package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
  111. package/dist/lifecycle/trusted-plugin-files.js +33 -30
  112. package/dist/lifecycle/types.d.ts +13 -34
  113. package/dist/lifecycle/uninstall.d.ts +1 -33
  114. package/dist/lifecycle/update-store.d.ts +0 -7
  115. package/dist/lifecycle/update-store.js +1 -8
  116. package/dist/lifecycle/update.d.ts +1 -1
  117. package/dist/lifecycle/update.js +60 -10
  118. package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
  119. package/dist/lifecycle/yauzl-archive-reader.js +11 -6
  120. package/dist/manifest.d.ts +4 -8
  121. package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
  122. package/dist/react/AgentPluginDetailsModal.js +29 -0
  123. package/dist/react/agent-plugin-install-port.d.ts +24 -0
  124. package/dist/react/agent-plugin-install-port.js +15 -0
  125. package/dist/react/installed-skills-composer-source.d.ts +60 -0
  126. package/dist/react/installed-skills-composer-source.js +111 -0
  127. package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
  128. package/dist/react/use-agent-plugins.hooks.js +128 -0
  129. package/dist/site/activation-effects.d.ts +17 -0
  130. package/dist/site/activation-effects.js +31 -0
  131. package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
  132. package/dist/site/admin-surfaces/capabilities.js +30 -0
  133. package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
  134. package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
  135. package/dist/site/admin-surfaces/forms.d.ts +28 -0
  136. package/dist/site/admin-surfaces/forms.js +29 -0
  137. package/dist/site/admin-surfaces/handlers.d.ts +61 -0
  138. package/dist/site/admin-surfaces/handlers.js +35 -0
  139. package/dist/site/admin-surfaces/public-config.d.ts +12 -0
  140. package/dist/site/admin-surfaces/public-config.js +28 -0
  141. package/dist/site/analytics-provider-registry.d.ts +87 -0
  142. package/dist/site/analytics-provider-registry.js +87 -0
  143. package/dist/site/archive-reader-abi.d.ts +35 -0
  144. package/dist/site/archive-reader-abi.js +25 -0
  145. package/dist/site/auth-schemes.d.ts +110 -0
  146. package/dist/site/auth-schemes.js +119 -0
  147. package/dist/site/automatic-agent-plugins.d.ts +200 -0
  148. package/dist/site/automatic-agent-plugins.js +277 -0
  149. package/dist/site/bundled-contribution-sources.d.ts +24 -0
  150. package/dist/site/bundled-contribution-sources.js +17 -0
  151. package/dist/site/bundled-id-upgrade.d.ts +115 -0
  152. package/dist/site/bundled-id-upgrade.js +169 -0
  153. package/dist/site/customize-tool.d.ts +39 -0
  154. package/dist/site/customize-tool.js +31 -0
  155. package/dist/site/deploy-split-activation.d.ts +28 -0
  156. package/dist/site/deploy-split-activation.js +21 -0
  157. package/dist/site/exports/diagnostics.d.ts +37 -0
  158. package/dist/site/exports/diagnostics.js +55 -0
  159. package/dist/site/exports/runtime.d.ts +54 -0
  160. package/dist/site/exports/runtime.js +196 -0
  161. package/dist/site/exports/source.d.ts +42 -0
  162. package/dist/site/exports/source.js +58 -0
  163. package/dist/site/host-plugin-guidance.d.ts +137 -0
  164. package/dist/site/host-plugin-guidance.js +223 -0
  165. package/dist/site/host-signals.d.ts +78 -0
  166. package/dist/site/host-signals.js +83 -0
  167. package/dist/site/install-tool.d.ts +69 -0
  168. package/dist/site/install-tool.js +192 -0
  169. package/dist/site/install-upload.d.ts +175 -0
  170. package/dist/site/install-upload.js +324 -0
  171. package/dist/site/memory-i18n.d.ts +5 -0
  172. package/dist/site/memory-i18n.js +176 -0
  173. package/dist/site/memory.d.ts +80 -0
  174. package/dist/site/memory.js +83 -0
  175. package/dist/site/plugin-memory.d.ts +80 -0
  176. package/dist/site/plugin-memory.js +86 -0
  177. package/dist/site/provider-plugin-link.d.ts +112 -0
  178. package/dist/site/provider-plugin-link.js +100 -0
  179. package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
  180. package/dist/site/retired-plugin-tool-aliases.js +41 -0
  181. package/dist/site/service-ports.d.ts +108 -0
  182. package/dist/site/service-ports.js +2 -0
  183. package/dist/site/set-enabled.d.ts +80 -0
  184. package/dist/site/set-enabled.js +42 -0
  185. package/dist/site/soon-lock.d.ts +83 -0
  186. package/dist/site/soon-lock.js +78 -0
  187. package/dist/site/supersession.d.ts +61 -0
  188. package/dist/site/supersession.js +122 -0
  189. package/dist/site/uninstall-tool.d.ts +136 -0
  190. package/dist/site/uninstall-tool.js +203 -0
  191. package/dist/site/update-effects.d.ts +47 -0
  192. package/dist/site/update-effects.js +49 -0
  193. package/ffmpeg-transcode/plugin.json +16 -0
  194. package/github/source-control/backup-push.mjs +66 -46
  195. package/github/source-control/commit-site.mjs +112 -65
  196. package/github/source-control/write-files.mjs +86 -53
  197. package/github-pages/targets/github-pages.mjs +294 -233
  198. package/google-workspace/form-destinations/mapping.mjs +15 -7
  199. package/google-workspace/form-destinations/sheets.mjs +4 -2
  200. package/google-workspace/plugin.json +1 -0
  201. package/kuinetic/CHANGELOG.md +4 -0
  202. package/kuinetic/plugin.json +4 -1
  203. package/kuinetic/skills/kuinetic/SKILL.md +1 -2
  204. package/package.json +295 -18
  205. package/persistent-state.d.ts +4 -1
  206. package/resend/adapters/resend.mjs +5 -2
  207. package/resend/plugin.json +1 -1
  208. package/s3-compatible/jini-deploy-targets.json +1 -1
  209. package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
  210. package/s3-compatible/targets/s3-compatible.mjs +3 -3
  211. package/site-import/plugin.json +3 -3
  212. package/site-import/skills/site-import/SKILL.md +62 -54
  213. package/site-import/skills/site-import/references/content-mapping.md +26 -20
  214. package/slide-design/plugin.json +1 -1
  215. package/slide-design/skills/slide-design/SKILL.md +8 -2
  216. package/ui-ux-design/CHANGELOG.md +6 -0
  217. package/ui-ux-design/plugin.json +1 -1
  218. package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
  219. package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
  220. package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
  221. package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
  222. package/vercel/NOTES.md +2 -1
  223. package/vercel/object-stores/vercel-blob.mjs +3 -4
  224. package/vercel/targets/vercel.mjs +425 -351
  225. package/core/commerce-server.d.ts +0 -2
  226. package/core/commerce-server.mjs +0 -2
  227. package/dist/admin-surfaces/connections/ports.d.ts +0 -110
  228. package/dist/admin-surfaces/connections/ports.js +0 -2
  229. /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
  230. /package/dist/{lifecycle → core}/install-errors.js +0 -0
  231. /package/dist/{lifecycle → core}/update-plan.js +0 -0
package/README.md CHANGED
@@ -203,10 +203,12 @@ Create and retain one lifecycle per host context:
203
203
  ```ts
204
204
  import { createAgentPluginLifecycle, createAgentPluginLayout } from '@jini-ai/agent-plugins/lifecycle';
205
205
  import { createNodeAgentPluginEffects } from '@jini-ai/node-adapters/agent-plugins';
206
+ import { writeJsonFileAtomicAsync } from '@jini-ai/platform/fs';
207
+ import { readBootIdentity, withFileLock } from '@jini-ai/platform/fs/file-lock';
206
208
 
207
209
  const layout = createAgentPluginLayout({ root: pluginRoot });
208
210
  const lifecycle = createAgentPluginLifecycle({
209
- ...createNodeAgentPluginEffects({}),
211
+ ...createNodeAgentPluginEffects({ withFileLock, writeJsonFileAtomicAsync, readBootIdentity }),
210
212
  layout,
211
213
  productName,
212
214
  extensionNamespace,
@@ -236,8 +238,8 @@ when adopting the package. Prefer pinned hashes for remote installations; trust-
236
238
  is an explicit choice in `installAgentPluginFromUrl`.
237
239
 
238
240
  Filesystem effects use native `node:fs/promises` signatures and native FileHandles. Inject
239
- instrumented native effects directly through `filesystem`; `createNodeAgentPluginEffects({})`
240
- provides the default. Clocks extend core `Clock` with `monotonicMs()` and `sleep({ ms })`;
241
+ instrumented native effects directly through `filesystem`; `createNodeAgentPluginEffects({ withFileLock, writeJsonFileAtomicAsync, readBootIdentity })`
242
+ (the platform functions, injected) provides the default. Clocks extend core `Clock` with `monotonicMs()` and `sleep({ ms })`;
241
243
  IDs extend core `IdGenerator` with `random()`.
242
244
 
243
245
  Generic locks are imported directly from `@jini-ai/platform/fs/file-lock`. Lifecycle activation
@@ -271,7 +273,7 @@ See [integration-extraction.md](integration-extraction.md) for the reconciliatio
271
273
  rewire ledger and verification commands. All verification is deferred by owner directive.
272
274
 
273
275
  For a host that needs only activation, use `createAgentPluginActivations` with
274
- `createNodeAgentPluginEffects({})` instead of supplying unused network/provisioning
276
+ `createNodeAgentPluginEffects({ withFileLock, writeJsonFileAtomicAsync, readBootIdentity })` instead of supplying unused network/provisioning
275
277
  ports. Retain one returned object for the process lifetime. See `API.md` for the
276
278
  object-shaped reads, filters and optional legacy metadata reader.
277
279
 
@@ -327,3 +329,19 @@ for writes and destructive actions. Set discovery `readOnly`/`sideEffects` from
327
329
  the effect. Sync after activation changes: absent actions are withdrawn and held
328
330
  handlers are revoked. A host may collect its issued sign-in URLs around dispatch;
329
331
  return those URLs for the assistant to show. This adapter never opens a browser.
332
+
333
+ ## Wiring
334
+
335
+ The lifecycle value contracts (`InstalledAgentPlugin`, `SetAgentPluginEnabledInput`/`Result`, the
336
+ layout, uninstall and archive-reader ports, `PluginManifestAuthor`, `AgentPluginExport*`) are declared
337
+ in `@jini-ai/core/contracts/site/agent-plugins-lifecycle` and `./agent-plugins-manifest`. This package
338
+ imports them from core and keeps the runtime; `./lifecycle` and `./manifest` still re-export the names
339
+ as deprecated types until the next major. Hosts import them from core.
340
+
341
+ **Create-form tokens** (`tokensForCreate` from `./connect`). A host's create-site form collects
342
+ `{ [pluginId]: typed value }` from its own fields (offered services come from the host's inventory)
343
+ and calls `tokensForCreate({ values })`; `undefined` means "send the create input unchanged". The
344
+ host's create-form hook owns the inputs, the bridge and the copy; the receiving side validates with
345
+ `parsePluginTokenMap` and the host's limits.
346
+
347
+ MCP trust admission: hosts bind the lifecycle owner's `classifyAgentPluginMcpServerTrust({ server })` into the planners' positional `classifyTrust` callback (`stdio` always `requires-confirmation`) and read installed skills/`mcp.json` through `readInstalledSkillMarkdown`/`readInstalledMcpServers`/`readInstalledMcpServerIds`; metadata warnings arrive on `onEvent` as `agent-plugin-metadata-warning`.
@@ -0,0 +1,29 @@
1
+ # Calendly plugin
2
+
3
+ Shows a Calendly booking calendar on a site page. A public Calendly link is all it needs; the
4
+ optional Calendly sign-in only lets the assistant look up event types.
5
+
6
+ ## The `booking-calendar` export needs a `url`, by design
7
+
8
+ `exports/booking-calendar.html` renders `{{props.url}}` twice (the iframe `src` and the fallback
9
+ link) and gives it no default. That is intentional, not a gap:
10
+
11
+ - The fragment grammar has **no conditionals and no default values**. A template cannot say "use
12
+ this link unless the author gave none".
13
+ - `url` is `required` in the manifest's `props` schema, so the host refuses a marker without it.
14
+ Even if a marker slipped past schema validation, `fillPluginExportTemplate` throws
15
+ `unknown plugin export slot` for a slot with no value. A missing slot never leaks `{{props.url}}`
16
+ into the page.
17
+ - A refused export is isolated to that one occurrence: `resolvePluginExportEmbeds` keeps the
18
+ author's own fallback markup inside the marker, and the rest of the page renders normally.
19
+ The page author sees their fallback, not a broken frame and not a failed page.
20
+
21
+ Pinned by `packages/cms/src/widgets/__tests__/plugin-export.unit.test.ts` (a missing slot throws
22
+ `unknown plugin export slot`; an unresolved export keeps the authored fallback and the next
23
+ occurrence still renders).
24
+
25
+ ## Do not put a note in the template itself
26
+
27
+ The fragment keeps HTML comments. A `<!-- ... -->` added to `booking-calendar.html` is copied
28
+ into every published page that uses the calendar (checked against `fillPluginExportTemplate`).
29
+ Comments that mention `{{` or `}}` are refused outright. Keep design notes here instead.
package/calendly/mcp.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "calendly": {
5
5
  "type": "streamable-http",
6
6
  "url": "https://mcp.calendly.com",
7
- "tovuAuthMode": "oauth"
7
+ "authMode": "oauth"
8
8
  }
9
9
  }
10
10
  }
@@ -8,7 +8,7 @@ import { refusal } from './api.mjs';
8
8
  * dedup key (the direct-upload protocol needs a stable 32-hex-char key per
9
9
  * file, not a specific algorithm). Swapped from the OD origin's
10
10
  * `blake3-wasm` to Node's built-in `crypto` so this package carries no
11
- * native/WASM dependency — see `source-map.md`.
11
+ * native/WASM dependency.
12
12
  */
13
13
  export function assetHash({ file, data }, _options = {}) {
14
14
  const extension = file.includes('.') ? file.slice(file.lastIndexOf('.') + 1) : '';
@@ -47,7 +47,7 @@ function readSubmissionEvidence({ value }, _optional = {}) {
47
47
  function assertEvidenceHeader({ evidence }) {
48
48
  if (evidence.version !== 1 || typeof evidence.schemaHash !== "string" || !/^[a-f0-9]{64}$/.test(evidence.schemaHash))
49
49
  throw new TypeError("Invalid form submission evidence hash.");
50
- if (typeof evidence.capturedAt !== "string" || !["native", "cloudflare"].includes(String(evidence.source)))
50
+ if (typeof evidence.capturedAt !== "string" || typeof evidence.source !== "string" || !["native", "cloudflare"].includes(evidence.source))
51
51
  throw new TypeError("Invalid form submission evidence provenance.");
52
52
  if (evidence.html !== void 0 && typeof evidence.html !== "string")
53
53
  throw new TypeError("Invalid form submission evidence HTML.");
@@ -18,7 +18,10 @@ export interface PluginMemory {
18
18
  }
19
19
  export function pluginStatePaths(required: { workspaceRoot: string; pluginId: string }, optional?: {}): PluginStatePaths;
20
20
  export function createPluginMemory(required: PluginStateEffects & { workspaceRoot: string; pluginId: string }, optional?: { limits?: Partial<typeof DEFAULT_PLUGIN_MEMORY_LIMITS> }): PluginMemory;
21
- export function migratePluginLayout(required: PluginStateEffects & { workspaceRoot: string; parsePluginId(required: { value: unknown }): string; onEvent?(required: { event: string; message: string }): void }, optional?: {}): Promise<{ complete: boolean; moved: number }>;
21
+ /** Proof that a caller holds one canonical workspace's layout-migration lock; honoured only while held. */
22
+ export interface WorkspaceMigrationOwnership { readonly workspaceRoot: string; readonly lockPath: string; isHeld(): boolean; }
23
+ export function withWorkspaceMigrationLock<T>(required: Pick<PluginStateEffects, 'filesystem' | 'withLock'> & { workspaceRoot: string; run(held: { ownership: WorkspaceMigrationOwnership }): Promise<T> }, optional?: {}): Promise<T>;
24
+ export function migratePluginLayout(required: PluginStateEffects & { workspaceRoot: string; parsePluginId(required: { value: unknown }): string; onEvent?(required: { event: string; message: string }): void }, optional?: { ownership?: WorkspaceMigrationOwnership }): Promise<{ complete: boolean; moved: number }>;
22
25
 
23
26
  export function assertPluginStatePath(required: Pick<PluginStateEffects, "filesystem" | "contain"> & { workspaceRoot: string; entryPath: string }, optional?: {}): Promise<string>;
24
27
 
@@ -298,27 +298,61 @@ async function finishPluginLayoutMigration({ fs, workspaceRoot, marker, emit },
298
298
  emit('migration-complete', workspaceRoot);
299
299
  }
300
300
 
301
- /** Interrupted moves are resumable; refused legacy entries are kept in quarantine and reported. */
302
- export async function migratePluginLayout({ filesystem: fs, contain, workspaceRoot, parsePluginId, withLock, onEvent }, _optional = {}) {
301
+ const LAYOUT_MARKER = '.agent-plugin-layout-migrated';
302
+
303
+ /** Containment returns canonical paths; relative moves must use the same root (e.g. /var -> /private/var). */
304
+ async function canonicalWorkspaceRoot(fs, workspaceRoot) {
303
305
  await fs.mkdir(workspaceRoot, { recursive: true, mode: 0o700 });
304
- // Containment returns canonical paths; relative moves must use the same root (e.g. /var -> /private/var).
305
- workspaceRoot = await fs.realpath(workspaceRoot);
306
- const marker = path.join(workspaceRoot, '.agent-plugin-layout-migrated');
307
- const emit = (event, message) => onEvent?.({ event, message });
308
- return withLock({ lockPath: `${marker}.lock`, run: async () => {
309
- await assertPluginStatePath({ filesystem: fs, contain, workspaceRoot, entryPath: path.basename(marker) });
310
- try { if (JSON.parse(await fs.readFile(marker, 'utf8')).layoutVersion === 2) return { complete: true, moved: 0 }; }
311
- catch (error) { if (code(error) !== 'ENOENT') emit('migration-marker-invalid', String(error)); }
312
- const progress = { complete: true, moved: 0 };
313
- const context = { fs, contain, workspaceRoot, parsePluginId, withLock, emit };
314
- const operations = createLegacyMigrationOperations(context, progress);
315
- const oldPackages = path.join(workspaceRoot, 'packages', 'sha256');
316
- await migrateLegacyPackages({ ...context, oldPackages }, operations, progress);
317
- await migrateLegacyStateBuckets(context, operations, progress);
318
- await prepareMigratedPluginRoots(context, operations, progress);
319
- if (progress.complete) {
320
- await finishPluginLayoutMigration({ fs, workspaceRoot, marker, emit }, oldPackages);
321
- }
322
- return { complete: progress.complete, moved: progress.moved };
306
+ return fs.realpath(workspaceRoot);
307
+ }
308
+
309
+ /**
310
+ * Holds one workspace's layout-migration lock across a caller's whole window. Lock order is
311
+ * workspace migration lock first, then per-plugin state locks; nothing inside the window may take
312
+ * this lock again. `run` receives explicit ownership to pass into a nested migration so that
313
+ * migration runs under this lock instead of reacquiring it (which would wait on itself).
314
+ * The ownership is scoped to this canonical workspace root and stops being honoured on release.
315
+ */
316
+ export async function withWorkspaceMigrationLock({ filesystem: fs, workspaceRoot, withLock, run }, _optional = {}) {
317
+ const root = await canonicalWorkspaceRoot(fs, workspaceRoot);
318
+ const lockPath = path.join(root, `${LAYOUT_MARKER}.lock`);
319
+ let held = false;
320
+ const ownership = Object.freeze({ workspaceRoot: root, lockPath, isHeld: () => held });
321
+ return withLock({ lockPath, run: async () => {
322
+ held = true;
323
+ try { return await run({ ownership }); } finally { held = false; }
323
324
  } });
324
325
  }
326
+
327
+ async function runPluginLayoutMigration({ fs, contain, workspaceRoot, parsePluginId, withLock, emit }) {
328
+ const marker = path.join(workspaceRoot, LAYOUT_MARKER);
329
+ await assertPluginStatePath({ filesystem: fs, contain, workspaceRoot, entryPath: path.basename(marker) });
330
+ try { if (JSON.parse(await fs.readFile(marker, 'utf8')).layoutVersion === 2) return { complete: true, moved: 0 }; }
331
+ catch (error) { if (code(error) !== 'ENOENT') emit('migration-marker-invalid', String(error)); }
332
+ const progress = { complete: true, moved: 0 };
333
+ const context = { fs, contain, workspaceRoot, parsePluginId, withLock, emit };
334
+ const operations = createLegacyMigrationOperations(context, progress);
335
+ const oldPackages = path.join(workspaceRoot, 'packages', 'sha256');
336
+ await migrateLegacyPackages({ ...context, oldPackages }, operations, progress);
337
+ await migrateLegacyStateBuckets(context, operations, progress);
338
+ await prepareMigratedPluginRoots(context, operations, progress);
339
+ if (progress.complete) {
340
+ await finishPluginLayoutMigration({ fs, workspaceRoot, marker, emit }, oldPackages);
341
+ }
342
+ return { complete: progress.complete, moved: progress.moved };
343
+ }
344
+
345
+ /** Interrupted moves are resumable; refused legacy entries are kept in quarantine and reported.
346
+ * A direct call takes the workspace migration lock. A caller already holding it passes its
347
+ * `ownership` (from {@link withWorkspaceMigrationLock}); the migration then runs under that lock and
348
+ * never acquires it again. Ownership of another workspace, or one already released, is refused. */
349
+ export async function migratePluginLayout({ filesystem: fs, contain, workspaceRoot, parsePluginId, withLock, onEvent }, { ownership } = {}) {
350
+ const root = await canonicalWorkspaceRoot(fs, workspaceRoot);
351
+ const emit = (event, message) => onEvent?.({ event, message });
352
+ const context = { fs, contain, workspaceRoot: root, parsePluginId, withLock, emit };
353
+ if (ownership === undefined) {
354
+ return withLock({ lockPath: path.join(root, `${LAYOUT_MARKER}.lock`), run: () => runPluginLayoutMigration(context) });
355
+ }
356
+ if (ownership.workspaceRoot !== root || !ownership.isHeld()) throw new Error('The passed migration ownership does not hold this workspace\'s lock');
357
+ return runPluginLayoutMigration(context);
358
+ }
@@ -11,12 +11,7 @@
11
11
  * sign-in cannot grow memory. It is in-process: a host that completes sign-ins on another process
12
12
  * implements the same two methods over its own store.
13
13
  */
14
- export interface AdminSurfaceCallbackFieldKey {
15
- readonly workspaceId: string;
16
- readonly pluginId: string;
17
- readonly connectionId: string;
18
- readonly attemptId: string;
19
- }
14
+ import type { AdminSurfaceCallbackFieldKey } from "@jini-ai/core/contracts/site/admin-surfaces-connections";
20
15
  /**
21
16
  * @param required.now - Clock in epoch milliseconds (injected so expiry is testable).
22
17
  * @returns `deposit` (host callback route, after a successful completion) and `take` (consume-once).
@@ -1,5 +1,5 @@
1
- import { type AdminSurfaceAuthorizationStart, type AdminSurfaceConnections } from '../surface-capabilities.js';
2
- import type { AdminSurfaceConnectionsHost, AdminSurfaceDeclaredConnection } from './ports.js';
1
+ import { type AdminSurfaceConnections } from '../surface-capabilities.js';
2
+ import type { AdminSurfaceConnectionsHost, AdminSurfaceDeclaredConnection, IssuedSignIn } from '@jini-ai/core/contracts/site/admin-surfaces-connections';
3
3
  import { type Logger } from '@jini-ai/core/primitives';
4
4
  /**
5
5
  * @file The host's `connections` port for plugin admin-surface handlers (Jini's `AdminSurfaceConnections`):
@@ -15,10 +15,6 @@ import { type Logger } from '@jini-ai/core/primitives';
15
15
  * provider confirmed. A sign-in's `attemptId` is the service's own random id; the OAuth `state`
16
16
  * never reaches the plugin.
17
17
  */
18
- export interface IssuedSignIn extends AdminSurfaceAuthorizationStart {
19
- readonly pluginId: string;
20
- readonly connectionId: string;
21
- }
22
18
  export interface AdminSurfaceConnectionsDeps<Connection extends AdminSurfaceDeclaredConnection> {
23
19
  readonly host: AdminSurfaceConnectionsHost<Connection>;
24
20
  readonly report?: Pick<Logger, 'warn'>;
@@ -1,3 +1,4 @@
1
- export { createAdminSurfaceConnections, type AdminSurfaceConnectionsDeps, type IssuedSignIn } from './connections.js';
2
- export type { AdminSurfaceConnectionsHost, AdminSurfaceDeclaredConnection, AdminSurfaceConnectionAccount, AdminSurfaceStagedAccount, AdminSurfaceStatusView, AdminSurfaceConnectionRecord, AdminSurfaceAccountAction, AdminSurfaceDisconnected, AdminSurfaceSignInStart, AdminSurfaceSignInStarted, AdminSurfaceCallbackInbox } from './ports.js';
1
+ export { createAdminSurfaceConnections, type AdminSurfaceConnectionsDeps } from './connections.js';
2
+ /** Deprecated re-export: import these from `@jini-ai/core/contracts/site/admin-surfaces-connections`; removed at the next major. */
3
+ export type { IssuedSignIn, AdminSurfaceConnectionsHost, AdminSurfaceDeclaredConnection, AdminSurfaceConnectionAccount, AdminSurfaceStagedAccount, AdminSurfaceStatusView, AdminSurfaceConnectionRecord, AdminSurfaceAccountAction, AdminSurfaceDisconnected, AdminSurfaceSignInStart, AdminSurfaceSignInStarted, AdminSurfaceCallbackInbox } from "@jini-ai/core/contracts/site/admin-surfaces-connections";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -18,7 +18,9 @@ export type { AdminSurfaceConnectionDeclaration, AdminSurfaceCapabilityDeclarati
18
18
  export { ADMIN_SURFACE_ACTION_INTENTS, ADMIN_SURFACE_STATE_LIMITS, type AdminSurfaceConnectionState, type AdminSurfaceConnectionAction, type AdminSurfaceRevocationOutcome, type AdminSurfaceConnectionStatus, type AdminSurfaceSignInAttempt, type AdminSurfaceAuthorizationStart, type AdminSurfaceConnections, type AdminSurfaceStateValue, type AdminSurfaceState, type AdminSurfacePublicConfig, type AdminSurfaceForm, type AdminSurfaceForms, type AdminSurfaceCapabilities, type AdminSurfaceCapabilitiesPort, } from './surface-capabilities.js';
19
19
  export type { AdminSurfaceDeliveryBinding, AdminSurfaceDeliveryBindingDraft, AdminSurfaceDeliveryBindingForms, AdminSurfaceDeliveryBindings, } from './delivery-bindings.js';
20
20
  export { openAdminSurfaceLink, type AdminSurfaceOpenLinkPort, type AdminSurfaceLinkVerdict } from './external-links.js';
21
- export { createAdminSurfaceCallbackInbox, type AdminSurfaceCallbackFieldKey } from './callback-field-inbox.js';
21
+ export { createAdminSurfaceCallbackInbox } from './callback-field-inbox.js';
22
+ /** Deprecated re-export: import these from `@jini-ai/core/contracts/site/admin-surfaces-connections`; removed at the next major. */
23
+ export type { AdminSurfaceCallbackFieldKey } from "@jini-ai/core/contracts/site/admin-surfaces-connections";
22
24
  export { buildAdminSurfaceActionTools, type AdminSurfaceToolSource, type AdminSurfaceToolContext } from './action-tools.js';
23
25
  export type { AdminSurfacePluginStatePersistence } from './plugin-state-persistence.js';
24
26
  export { createAgentPluginStateStore, PLUGIN_STATE_MAX_KEYS, type AgentPluginStateScope, type AgentPluginStateStore, type AgentPluginStateSummary } from './plugin-state.js';
@@ -9,7 +9,7 @@ import type { AgentPluginMcpPort, AgentPluginMcpRecord, AgentPluginMcpProjection
9
9
  import type { SavedTokenSwitchOutcome } from "./switch-on-saved-token.js";
10
10
  import type { AgentPluginTokenAuth, RemoteMcpServerConfig } from "../lifecycle/manifest.js";
11
11
  import { type AgentPluginAccessTokenFormMessages, type AgentPluginCardIdentity } from "./connect-card-ui.js";
12
- import { type ResolvedAgentPluginForConnect } from "./connect-tool.js";
12
+ import type { ResolvedAgentPluginForConnect } from "./installed-plugin.js";
13
13
  /**
14
14
  * @file `agent_plugin_set_access_token` — the generic access-token fallback for an Agent Plugin whose
15
15
  * remote server declares `tokenAuth { helpUrl, probeUrl }` in its `mcp.json` (`manifest.ts`).
@@ -3,7 +3,7 @@ import {} from "@jini-ai/core/primitives";
3
3
  import { requireInputRecord, ToolInputError } from "@jini-ai/core";
4
4
  import { deriveAgentPluginConnectionId, provisionAgentPluginMcpServers } from "./federate-mcp.js";
5
5
  import { buildAgentPluginAccessTokenFormWithPorts, buildAgentPluginAccessTokenOutcomeWithPorts, resolveAgentPluginCardIdentity, } from "./connect-card-ui.js";
6
- import { titleCaseFromPluginId } from "./connect-tool.js";
6
+ import { titleCaseFromPluginId } from "../core/plugin-display-name.js";
7
7
  /** Plain-language messages from errors.spec.md. None ever carries a token or a vendor body. */
8
8
  const MESSAGES = {
9
9
  tokenInvalid: "The server rejected this token.",
@@ -0,0 +1,26 @@
1
+ import type { DerivedRiskByToolId, AgentToolDefinition } from '@jini-ai/core';
2
+ import type { AgentPluginMcpRecord, AgentPluginMcpProjections } from './ports.js';
3
+ /** This tool's one-entry catalog, built from host copy (tool id, permission, description and the
4
+ * pluginId schema text are product vocabulary).
5
+ * @agent-note Second host: pass your own tool id/permission/description bytes; the schema shape is fixed. */
6
+ export declare function agentPluginConnectAgentToolCatalogFor(required: {
7
+ toolId: string;
8
+ permission: string;
9
+ description: string;
10
+ pluginIdDescription: string;
11
+ }, _optional?: Record<string, never>): AgentToolDefinition[];
12
+ /** @agent-note Second host: key by your own tool id. */
13
+ export declare function agentPluginConnectDerivedRiskFor(required: {
14
+ toolId: string;
15
+ }, _optional?: Record<string, never>): DerivedRiskByToolId;
16
+ /** Whether a plugin's row already holds a credential: a finished sign-in, or a saved access token
17
+ * (`static_env` with the token sealed in `sealedOAuth` — what `agent_plugin_set_access_token`, the
18
+ * old env var's boot import, and create-site onboarding all write; `sealedEnv` is a stdio row's env
19
+ * block and never holds it). Such a row needs no sign-in, and a token import must never overwrite it.
20
+ * @agent-note Pass the canonical store's SAME pure projection pair; this check performs no I/O,
21
+ * opens no sealed material and must not replace an existing credential with a fresh grant. */
22
+ export declare function hasStoredAgentPluginCredential(required: {
23
+ row: Pick<AgentPluginMcpRecord, "authMode" | "sealedOAuth" | "oauthStatus">;
24
+ projections: AgentPluginMcpProjections;
25
+ }, _optional?: Record<string, never>): boolean;
26
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1,42 @@
1
+ /** This tool's one-entry catalog, built from host copy (tool id, permission, description and the
2
+ * pluginId schema text are product vocabulary).
3
+ * @agent-note Second host: pass your own tool id/permission/description bytes; the schema shape is fixed. */
4
+ export function agentPluginConnectAgentToolCatalogFor(required, _optional = {}) {
5
+ return [
6
+ {
7
+ name: required.toolId,
8
+ description: required.description,
9
+ sideEffects: "mutates-durable-state",
10
+ authorization: { permission: required.permission },
11
+ inputSchema: {
12
+ type: "object",
13
+ additionalProperties: false,
14
+ required: ["pluginId"],
15
+ properties: {
16
+ pluginId: {
17
+ type: "string",
18
+ minLength: 1,
19
+ description: required.pluginIdDescription,
20
+ },
21
+ },
22
+ },
23
+ },
24
+ ];
25
+ }
26
+ /** @agent-note Second host: key by your own tool id. */
27
+ export function agentPluginConnectDerivedRiskFor(required, _optional = {}) {
28
+ return new Map([
29
+ [required.toolId, "mutates-durable-state"],
30
+ ]);
31
+ }
32
+ /** Whether a plugin's row already holds a credential: a finished sign-in, or a saved access token
33
+ * (`static_env` with the token sealed in `sealedOAuth` — what `agent_plugin_set_access_token`, the
34
+ * old env var's boot import, and create-site onboarding all write; `sealedEnv` is a stdio row's env
35
+ * block and never holds it). Such a row needs no sign-in, and a token import must never overwrite it.
36
+ * @agent-note Pass the canonical store's SAME pure projection pair; this check performs no I/O,
37
+ * opens no sealed material and must not replace an existing credential with a fresh grant. */
38
+ export function hasStoredAgentPluginCredential(required, _optional = {}) {
39
+ const { row, projections } = required;
40
+ return projections.oauthStatus(row) === "connected" || projections.hasStaticAccessToken(row);
41
+ }
42
+ //# sourceMappingURL=catalog.js.map