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

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 (235) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/NOTICE +2 -0
  3. package/README.md +11 -15
  4. package/calendly/plugin.json +3 -3
  5. package/cloudflare/lib/forms.mjs +9 -10
  6. package/cloudflare/lib/target.mjs +1 -1
  7. package/cloudflare/plugin.json +3 -3
  8. package/cloudflare/worker/forms-receiver.mjs +9 -9
  9. package/composio/plugin.json +3 -3
  10. package/core/persistent-state.js +227 -163
  11. package/dist/admin-surfaces/connections/connections.d.ts +11 -6
  12. package/dist/admin-surfaces/connections/connections.js +102 -85
  13. package/dist/admin-surfaces/node.d.ts +27 -0
  14. package/dist/admin-surfaces/node.js +32 -0
  15. package/dist/admin-surfaces/plugin-state.js +21 -18
  16. package/dist/admin-surfaces/surface-client.d.ts +4 -0
  17. package/dist/admin-surfaces/surface-client.js +124 -117
  18. package/dist/admin-surfaces/surface-handlers.js +21 -17
  19. package/dist/admin-surfaces/theme.d.ts +5 -1
  20. package/dist/admin-surfaces/theme.js +3 -3
  21. package/dist/connect/access-token-tool.d.ts +3 -1
  22. package/dist/connect/access-token-tool.js +3 -2
  23. package/dist/connect/apply-connect-defaults.js +2 -2
  24. package/dist/connect/apply-tool-renames.js +9 -8
  25. package/dist/connect/connect-tool.d.ts +2 -0
  26. package/dist/connect/connect-tool.js +3 -2
  27. package/dist/connect/credential-cards.js +3 -2
  28. package/dist/connect/credential-save-tool.d.ts +14 -11
  29. package/dist/connect/credential-save-tool.js +128 -121
  30. package/dist/connect/enable-access.d.ts +2 -2
  31. package/dist/connect/enable-access.js +6 -6
  32. package/dist/connect/executable/register.js +40 -34
  33. package/dist/connect/federate-mcp.d.ts +21 -11
  34. package/dist/connect/federate-mcp.js +28 -21
  35. package/dist/connect/grant-signed-in-defaults.js +3 -3
  36. package/dist/connect/import-access-token.js +2 -1
  37. package/dist/connect/index.d.ts +1 -0
  38. package/dist/connect/index.js +1 -0
  39. package/dist/connect/plugin-credential-card.js +2 -1
  40. package/dist/connect/plugin-host/index.d.ts +9 -5
  41. package/dist/connect/plugin-host/index.js +113 -100
  42. package/dist/connect/ports.d.ts +1 -1
  43. package/dist/connect/row-update.d.ts +22 -0
  44. package/dist/connect/row-update.js +18 -0
  45. package/dist/connect/switch-on-saved-token.d.ts +4 -2
  46. package/dist/connect/switch-on-saved-token.js +1 -1
  47. package/dist/connect/token-map.d.ts +44 -0
  48. package/dist/connect/token-map.js +49 -0
  49. package/dist/core/identity-namespace.js +5 -0
  50. package/dist/folder-zip.d.ts +3 -1
  51. package/dist/folder-zip.js +2 -2
  52. package/dist/lifecycle/activation.d.ts +4 -4
  53. package/dist/lifecycle/activation.js +4 -5
  54. package/dist/lifecycle/automatic-use.js +236 -210
  55. package/dist/lifecycle/bundled-digests.d.ts +75 -12
  56. package/dist/lifecycle/bundled-digests.js +213 -212
  57. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  58. package/dist/lifecycle/bundled-source-archive.js +263 -264
  59. package/dist/lifecycle/capability-projection.d.ts +1 -1
  60. package/dist/lifecycle/capability-projection.js +1 -1
  61. package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
  62. package/dist/lifecycle/credential-card-metadata.js +27 -3
  63. package/dist/lifecycle/exports.js +9 -4
  64. package/dist/lifecycle/fetch-archive.d.ts +1 -1
  65. package/dist/lifecycle/fetch-archive.js +1 -1
  66. package/dist/lifecycle/host-tools/identity.js +3 -2
  67. package/dist/lifecycle/host-tools/ports.d.ts +2 -0
  68. package/dist/lifecycle/host-tools/search-tool.js +8 -8
  69. package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
  70. package/dist/lifecycle/host-tools/skill-tool.js +16 -8
  71. package/dist/lifecycle/index.d.ts +118 -110
  72. package/dist/lifecycle/index.js +45 -12
  73. package/dist/lifecycle/install-errors.d.ts +1 -1
  74. package/dist/lifecycle/install-from-url.d.ts +1 -1
  75. package/dist/lifecycle/install-from-url.js +1 -1
  76. package/dist/lifecycle/install.d.ts +7 -2
  77. package/dist/lifecycle/install.js +414 -396
  78. package/dist/lifecycle/installed-package-index.js +45 -42
  79. package/dist/lifecycle/layout.d.ts +1 -1
  80. package/dist/lifecycle/layout.js +1 -1
  81. package/dist/lifecycle/mail/catalog.d.ts +8 -32
  82. package/dist/lifecycle/mail/catalog.js +25 -20
  83. package/dist/lifecycle/mail/contribution.d.ts +2 -2
  84. package/dist/lifecycle/mail/contribution.js +34 -34
  85. package/dist/lifecycle/mail/selection.js +6 -2
  86. package/dist/lifecycle/manifest.d.ts +3 -3
  87. package/dist/lifecycle/manifest.js +4 -4
  88. package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
  89. package/dist/lifecycle/mcp-provisioning.js +3 -3
  90. package/dist/lifecycle/package-paths.d.ts +1 -1
  91. package/dist/lifecycle/package-paths.js +1 -1
  92. package/dist/lifecycle/persistent-state.js +1 -2
  93. package/dist/lifecycle/ports.d.ts +5 -1
  94. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
  95. package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
  96. package/dist/lifecycle/retire-bundled.d.ts +1 -52
  97. package/dist/lifecycle/retire-bundled.js +134 -84
  98. package/dist/lifecycle/search.d.ts +2 -1
  99. package/dist/lifecycle/search.js +1 -1
  100. package/dist/lifecycle/seed-bundled.d.ts +1 -1
  101. package/dist/lifecycle/seed-bundled.js +154 -155
  102. package/dist/lifecycle/set-enabled.d.ts +1 -1
  103. package/dist/lifecycle/set-enabled.js +1 -1
  104. package/dist/lifecycle/skill-file-reader.js +53 -50
  105. package/dist/lifecycle/tools/projection.d.ts +4 -7
  106. package/dist/lifecycle/tools/projection.js +109 -108
  107. package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
  108. package/dist/lifecycle/trusted-plugin-files.js +1 -1
  109. package/dist/lifecycle/uninstall.d.ts +1 -1
  110. package/dist/lifecycle/uninstall.js +237 -241
  111. package/dist/lifecycle/update-store.js +20 -17
  112. package/dist/lifecycle/update.js +287 -281
  113. package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
  114. package/dist/lifecycle/yauzl-archive-reader.js +8 -2
  115. package/dist/manifest.d.ts +11 -3
  116. package/dist/manifest.js +9 -9
  117. package/fly/jini-credential-schemes.json +11 -0
  118. package/fly/plugin.json +3 -4
  119. package/github/plugin.json +3 -3
  120. package/github/source-control/backup-push.mjs +11 -11
  121. package/github/source-control/commit-site.mjs +3 -3
  122. package/github/source-control/github.mjs +12 -6
  123. package/github/source-control/write-files.mjs +27 -28
  124. package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
  125. package/github-pages/plugin.json +3 -3
  126. package/github-pages/targets/github-pages.mjs +3 -3
  127. package/google-login/plugin.json +3 -3
  128. package/google-workspace/README.md +14 -14
  129. package/google-workspace/form-destinations/README.md +3 -3
  130. package/google-workspace/form-destinations/dedupe.mjs +1 -1
  131. package/google-workspace/form-destinations/mapping.mjs +8 -9
  132. package/google-workspace/form-destinations/sheets.mjs +1 -1
  133. package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
  134. package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
  135. package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
  136. package/google-workspace/lib/auth.mjs +2 -2
  137. package/google-workspace/lib/form-destination-settings.mjs +1 -1
  138. package/google-workspace/lib/picker-flow.mjs +2 -2
  139. package/google-workspace/lib/request-policy.mjs +1 -1
  140. package/google-workspace/lib/surface-actions.mjs +1 -1
  141. package/google-workspace/plugin.json +3 -3
  142. package/google-workspace/tools/sheets/README.md +3 -3
  143. package/google-workspace/tools/sheets-admin/README.md +3 -3
  144. package/google-workspace/ui/README.md +4 -4
  145. package/google-workspace/ui/connection-panel.mjs +51 -51
  146. package/google-workspace/ui/destination-panel.mjs +34 -34
  147. package/google-workspace/ui/dom.mjs +15 -16
  148. package/google-workspace/ui/picker-flow.mjs +2 -2
  149. package/google-workspace/ui/picker.mjs +19 -19
  150. package/google-workspace/ui/surface-client.mjs +96 -69
  151. package/higgsfield-media/plugin.json +3 -3
  152. package/jev/plugin.json +3 -3
  153. package/kuinetic/CHANGELOG.md +12 -0
  154. package/kuinetic/mcp.json +4 -0
  155. package/kuinetic/plugin.json +27 -0
  156. package/kuinetic/skills/kuinetic/SKILL.md +120 -0
  157. package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
  158. package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
  159. package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
  160. package/meilisearch/plugin.json +5 -5
  161. package/netlify/plugin.json +3 -3
  162. package/netlify/targets/netlify.mjs +14 -4
  163. package/opentelemetry/plugin.json +3 -3
  164. package/package.json +25 -20
  165. package/posthog/plugin.json +3 -3
  166. package/railway/plugin.json +3 -3
  167. package/render/plugin.json +3 -3
  168. package/resend/NOTES.md +2 -2
  169. package/resend/adapters/resend.mjs +1 -1
  170. package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
  171. package/resend/lib/domains.mjs +8 -8
  172. package/resend/plugin.json +3 -3
  173. package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
  174. package/s3-compatible/jini-object-stores.json +29 -0
  175. package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
  176. package/s3-compatible/plugin.json +3 -3
  177. package/s3-compatible/targets/s3-compatible.mjs +25 -25
  178. package/sentry/plugin.json +3 -3
  179. package/shadcn-ui/CHANGELOG.md +7 -0
  180. package/shadcn-ui/LICENSE +201 -0
  181. package/shadcn-ui/NOTICE +10 -0
  182. package/shadcn-ui/mcp.json +4 -0
  183. package/shadcn-ui/plugin.json +26 -0
  184. package/shopify/plugin.json +3 -3
  185. package/site-compliance/plugin.json +3 -3
  186. package/site-import/plugin.json +3 -3
  187. package/supabase/mcp.json +1 -4
  188. package/supabase/plugin.json +3 -3
  189. package/ui-ux-design/CHANGELOG.md +13 -0
  190. package/ui-ux-design/NOTICE +2 -0
  191. package/ui-ux-design/README.md +17 -7
  192. package/ui-ux-design/plugin.json +6 -3
  193. package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
  194. package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
  195. package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
  196. package/vercel/NOTES.md +1 -1
  197. package/vercel/object-stores/vercel-blob.mjs +12 -2
  198. package/vercel/plugin.json +3 -3
  199. package/vercel/targets/vercel.mjs +3 -3
  200. package/wordpress/plugin.json +3 -3
  201. package/dist/lifecycle/node.d.ts +0 -11
  202. package/dist/lifecycle/node.js +0 -38
  203. package/fly/tovu-credential-schemes.json +0 -11
  204. package/github/deployments/github.mjs +0 -415
  205. package/s3-compatible/tovu-object-stores.json +0 -29
  206. package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
  207. /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
  208. /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  209. /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  210. /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  211. /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  212. /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  213. /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
  214. /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
  215. /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  216. /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
  217. /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
  218. /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  219. /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  220. /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  221. /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  222. /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  223. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
  224. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
  225. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
  226. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
  227. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
  228. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
  229. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
  230. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
  231. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
  232. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
  233. /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
  234. /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  235. /package/vercel/{tovu-object-stores.json → jini-object-stores.json} +0 -0
@@ -27,6 +27,44 @@ function ownersById({ contributions, toolIdFor }) {
27
27
  }
28
28
  return owners;
29
29
  }
30
+ function createExecutableRegistrationAdapter(required, { host, workspaceId, withExtensionApprovalPolicy, authorize, disclose, isAdminTool }) {
31
+ return (registration, owner) => {
32
+ const toolId = registration.descriptor.id;
33
+ // The contract asks the executor to confirm; the host's executor has no transport for that and would
34
+ // park forever, so the approval owner's card below confirms instead (never less friction).
35
+ const { requiresConfirmation: _parked, timeoutMs, ...descriptor } = registration.descriptor;
36
+ const asks = owner.effect !== 'read';
37
+ const gated = isAdminTool(toolId) ? { ...registration, policy: { ...registration.policy, authorize: async (ctx) => {
38
+ if (await registration.policy.authorize(ctx) !== 'allow')
39
+ return 'deny';
40
+ try {
41
+ await requireToolPermission({ authorize, workspaceId, principalId: ctx.principal.id, permission: host.adminSurfaces.permission });
42
+ return 'allow';
43
+ }
44
+ catch {
45
+ return 'deny';
46
+ }
47
+ } } } : registration;
48
+ const nonDestructiveEffect = asks ? 'mutates-durable-state' : 'none';
49
+ const sideEffects = owner.effect === 'destructive' ? 'deletes-durable-state' : nonDestructiveEffect;
50
+ const classified = withExtensionApprovalPolicy({ registration: { ...gated, descriptor: { ...descriptor, readOnly: !asks, sideEffects, ...(asks ? {} : { timeoutMs }) } }, family: APPROVAL_FAMILY_BY_EFFECT[owner.effect] });
51
+ // An admin action may be the one that signs a connection in, so its unconnected ones are left unbound.
52
+ const skipUnconnected = isAdminTool(toolId);
53
+ return asks ? required.applyApproval({ registration: classified }, { disclose: ({ ctx }) => disclose({ ctx, toolId, pluginId: owner.pluginId, workspaceId }, { skipUnconnected }) }) : classified;
54
+ };
55
+ }
56
+ function createExecutableScopeRefresh({ readOwners, registrations, scope, adapt }) {
57
+ return () => {
58
+ const owners = readOwners();
59
+ scope.replace({ registrations: registrations().map((registration) => {
60
+ const owner = owners.get(registration.descriptor.id);
61
+ // Both come from the same snapshots; refusing beats registering a tool with no approval family.
62
+ if (!owner)
63
+ throw new Error(`agent plugin tool '${registration.descriptor.id}' has no owning plugin, so its approval could not be classified`);
64
+ return adapt(registration, owner);
65
+ }) });
66
+ };
67
+ }
30
68
  /**
31
69
  * Loads this workspace's executable Agent Plugin tools and keeps them registered on `registry`.
32
70
  * @param required.registry - The core ToolRegistry the assistant executes from (a registration scope needs it).
@@ -65,41 +103,9 @@ export async function registerAgentPluginExecutableTools(required, _optional = {
65
103
  },
66
104
  metadata: { approval: required.readApproval },
67
105
  };
68
- const adapt = (registration, owner) => {
69
- const toolId = registration.descriptor.id;
70
- // The contract asks the executor to confirm; the host's executor has no transport for that and would
71
- // park forever, so the approval owner's card below confirms instead (never less friction).
72
- const { requiresConfirmation: _parked, timeoutMs, ...descriptor } = registration.descriptor;
73
- const asks = owner.effect !== 'read';
74
- const gated = adminToolIds.has(toolId) ? { ...registration, policy: { ...registration.policy, authorize: async (ctx) => {
75
- if (await registration.policy.authorize(ctx) !== 'allow')
76
- return 'deny';
77
- try {
78
- await requireToolPermission({ authorize, workspaceId, principalId: ctx.principal.id, permission: host.adminSurfaces.permission });
79
- return 'allow';
80
- }
81
- catch {
82
- return 'deny';
83
- }
84
- } } } : registration;
85
- const nonDestructiveEffect = asks ? 'mutates-durable-state' : 'none';
86
- const sideEffects = owner.effect === 'destructive' ? 'deletes-durable-state' : nonDestructiveEffect;
87
- const classified = withExtensionApprovalPolicy({ registration: { ...gated, descriptor: { ...descriptor, readOnly: !asks, sideEffects, ...(asks ? {} : { timeoutMs }) } }, family: APPROVAL_FAMILY_BY_EFFECT[owner.effect] });
88
- // An admin action may be the one that signs a connection in, so its unconnected ones are left unbound.
89
- const skipUnconnected = adminToolIds.has(toolId);
90
- return asks ? required.applyApproval({ registration: classified }, { disclose: ({ ctx }) => disclose({ ctx, toolId, pluginId: owner.pluginId, workspaceId }, { skipUnconnected }) }) : classified;
91
- };
106
+ const adapt = createExecutableRegistrationAdapter(required, { host, workspaceId, withExtensionApprovalPolicy, authorize, disclose, isAdminTool: toolId => adminToolIds.has(toolId) });
92
107
  const scope = createToolRegistrationScope({ registry });
93
- const refresh = () => {
94
- const owners = ownersById({ contributions, toolIdFor: pluginToolIdFor });
95
- scope.replace({ registrations: required.contributions.buildRegistrations(ports).map((registration) => {
96
- const owner = owners.get(registration.descriptor.id);
97
- // Both come from the same snapshots; refusing beats registering a tool with no approval family.
98
- if (!owner)
99
- throw new Error(`agent plugin tool '${registration.descriptor.id}' has no owning plugin, so its approval could not be classified`);
100
- return adapt(registration, owner);
101
- }) });
102
- };
108
+ const refresh = createExecutableScopeRefresh({ readOwners: () => ownersById({ contributions, toolIdFor: pluginToolIdFor }), registrations: () => required.contributions.buildRegistrations(ports), scope, adapt });
103
109
  refresh();
104
110
  const unsubscribe = contributions.subscribe({ onChanged: refresh });
105
111
  let disposed = false;
@@ -1,3 +1,4 @@
1
+ import { type Logger } from '@jini-ai/core/primitives';
1
2
  import type { AgentPluginMcpPort } from "./ports.js";
2
3
  import type { AgentPluginMcpProjectionPorts } from "./ports.js";
3
4
  import type { AgentPluginDefaultTools, McpServerConfig } from "../lifecycle/manifest.js";
@@ -23,7 +24,7 @@ export declare function deriveAgentPluginConnectionId({ serverKey }: {
23
24
  serverKey: string;
24
25
  }, _optional?: {}): string | null;
25
26
  /** One server this plugin declared that {@link planAgentPluginMcpFederation} will not attempt to
26
- * provision, and why — reported rather than silently dropped, matching `mcp-federation/trust.ts`'s
27
+ * provision, and why — reported rather than silently dropped, matching `packages/mcp/src/federation/trust.ts`'s
27
28
  * own "every refusal is reportable, never silent" discipline. */
28
29
  export interface SkippedAgentPluginMcpServer {
29
30
  readonly serverKey: string;
@@ -45,7 +46,9 @@ export interface AgentPluginMcpFederationMessages {
45
46
  }
46
47
  /** The host's plugin directory tree; only each workspace's root is read here. */
47
48
  export interface AgentPluginLayout {
48
- forWorkspace(workspaceId: string): {
49
+ forWorkspace(required: {
50
+ readonly workspaceId: string;
51
+ }, optional?: Record<string, never>): {
49
52
  readonly root: string;
50
53
  };
51
54
  }
@@ -76,7 +79,6 @@ export interface AgentPluginMcpFederationPlan {
76
79
  */
77
80
  export declare function planAgentPluginMcpFederation(input: {
78
81
  readonly servers: Readonly<Record<string, McpServerConfig>>;
79
- }, options: {
80
82
  /** The trust rule consulted after the stdio narrowing. The host passes the real
81
83
  * `classifyAgentPluginMcpServerTrust`; injectable so the drift guard above (a remote transport
82
84
  * reclassified as "requires-confirmation") stays verifiable while today's rule never trips it.
@@ -84,7 +86,7 @@ export declare function planAgentPluginMcpFederation(input: {
84
86
  * (object argument adapted to this positional shape); there is no default trust rule here. */
85
87
  readonly classifyTrust: AgentPluginMcpTrustClassifier;
86
88
  readonly messages: AgentPluginMcpFederationMessages;
87
- }): AgentPluginMcpFederationPlan;
89
+ }, _optional?: Record<string, never>): AgentPluginMcpFederationPlan;
88
90
  /**
89
91
  * Resolves one installed plugin's full, validated `mcp.json` server configs, given only its
90
92
  * `workspaceId`/`pluginId` — the pair a route naturally has, rather than the `packageRoot`
@@ -114,10 +116,13 @@ export declare function resolveAgentPluginMcpServers(input: {
114
116
  * @returns The matching defaults, or `null`.
115
117
  * @complexity O(s) time, O(1) space in declared servers.
116
118
  */
117
- export declare function findAgentPluginMcpServerDefaults(servers: Readonly<Record<string, McpServerConfig>>, row: {
118
- readonly serverId: string;
119
- readonly url: string | null;
120
- }): AgentPluginDefaultTools | null;
119
+ export declare function findAgentPluginMcpServerDefaults({ servers, row }: {
120
+ servers: Readonly<Record<string, McpServerConfig>>;
121
+ row: {
122
+ readonly serverId: string;
123
+ readonly url: string | null;
124
+ };
125
+ }, _optional?: Record<string, never>): AgentPluginDefaultTools | null;
121
126
  /**
122
127
  * Reads the bundled plugin's current manifest on every roster load. Only a build-seeded
123
128
  * digest supplies read trust; URL-only connections and arbitrary installed packages cannot.
@@ -159,6 +164,7 @@ export interface ProvisionAgentPluginMcpServersResult {
159
164
  * see {@link failed}. */
160
165
  readonly adopted: readonly string[];
161
166
  readonly skipped: readonly SkippedAgentPluginMcpServer[];
167
+ /** Safe caller-facing failure reasons; caught exceptions travel only through the report port. */
162
168
  readonly failed: readonly SkippedAgentPluginMcpServer[];
163
169
  }
164
170
  /** A stored JSON tool list that is null, blank, `[]`, or unreadable (the store reads those as `[]`).
@@ -174,17 +180,21 @@ export declare function isEmptyJsonList({ raw }: {
174
180
  * Rule 1 is enforced per server, right here: `deps.repo.findByServerId` runs BEFORE any write. A row
175
181
  * already at the derived id is NEVER passed through `saveExternalMcpServer` — it is either
176
182
  * recognized as this same plugin's earlier work (`alreadyProvisioned`), adopted byte-identical
177
- * except for `provisionedByPluginId` via a direct `repo.upsert` (`adopted`), or, when it belongs to a
183
+ * except for `provisionedByPluginId` via a direct conditional repo write (`adopted`), or, when it belongs to a
178
184
  * DIFFERENT plugin at a non-matching endpoint/transport/auth mode, refused as a genuine collision
179
185
  * (`failed`). See {@link adoptOrRecognizeExistingAgentPluginMcpServer}.
180
186
  *
181
187
  * Per-server failures (a store validation error, an unconfigured secret store, a refused collision,
182
- * or an adoption's upsert failing) are caught and reported rather than thrown, matching
188
+ * or an adoption's write failing) are caught and reported rather than thrown, matching
183
189
  * `readEnabledExternalMcpConfigs`'s own fail-open posture: one unwritable row must not stop every
184
190
  * other server in the same plugin, or the plugin's own activation, from succeeding.
185
191
  *
186
192
  * @complexity O(s) in the plugin's declared server count, each one an existence check plus at most
187
193
  * one create or adopt.
188
194
  */
189
- export declare function provisionAgentPluginMcpServers(deps: AgentPluginMcpProjectionPorts & Pick<AgentPluginMcpPort, "repo" | "saveServer"> & Partial<Pick<AgentPluginMcpPort, "notifyRosterChanged">>, input: ProvisionAgentPluginMcpServersInput): Promise<ProvisionAgentPluginMcpServersResult>;
195
+ export declare function provisionAgentPluginMcpServers({ deps, ...input }: {
196
+ deps: AgentPluginMcpProjectionPorts & Pick<AgentPluginMcpPort, "repo" | "saveServer"> & Partial<Pick<AgentPluginMcpPort, "notifyRosterChanged">>;
197
+ } & ProvisionAgentPluginMcpServersInput, { report }?: {
198
+ report?: Pick<Logger, 'warn'> | undefined;
199
+ }): Promise<ProvisionAgentPluginMcpServersResult>;
190
200
  //# sourceMappingURL=federate-mcp.d.ts.map
@@ -1,3 +1,6 @@
1
+ import { describeErrorForLog } from '@jini-ai/core';
2
+ import { createConsoleLogger } from '@jini-ai/core/primitives';
3
+ import { updateAgentPluginMcpRow } from "./row-update.js";
1
4
  /**
2
5
  * @file Phase 4 of the 2026-09-10 plugin-MCP-wiring work: PROVISIONS an activated Agent Plugin's
3
6
  * auto-admitted remote MCP servers as real rows in the SAME external-MCP store
@@ -33,7 +36,7 @@
33
36
  * .alreadyProvisioned}.
34
37
  * - anything else (`null`, or a DIFFERENT plugin's id) — an operator's own hand-configured
35
38
  * connection (with its earned OAuth tokens, allowlist, and write grants), or another plugin's
36
- * row. This is ADOPTION: `deps.repo.upsert({ ...existing, provisionedByPluginId: input.pluginId })`
39
+ * row. This is ADOPTION: `updateAgentPluginMcpRow` over `{ ...existing, provisionedByPluginId: input.pluginId }`
37
40
  * is called directly against the repo port — the raw record, spread, with only that one field
38
41
  * changed — never `saveExternalMcpServer`, which has no way to leave every other field
39
42
  * untouched while changing just this one (even its "tri-state" fields resolve a default the
@@ -92,7 +95,7 @@
92
95
  * What happens on plugin disable or uninstall: THE ROW SURVIVES
93
96
  * ---------------------------------------------------------------------------
94
97
  * Nothing in this file, and nothing this dispatch added to `set-enabled.ts` or
95
- * `features/agent-plugins/uninstall.ts`, ever deletes or disables a provisioned row when its plugin
98
+ * `packages/agent-plugins/src/lifecycle/uninstall.ts`, ever deletes or disables a provisioned row when its plugin
96
99
  * is turned off or removed. This is a deliberate position, not an oversight: a provisioned row may
97
100
  * already hold OAuth tokens the operator earned through a real browser sign-in, and deleting an
98
101
  * external MCP connection is UNRECOVERABLE in this app (`project_external_mcp_delete_is_unrecoverable`
@@ -127,7 +130,7 @@
127
130
  * server requires OAuth (Higgsfield's own `mcp.json` does) sets the `authMode` extension
128
131
  * (`manifest.ts`) to say so explicitly.
129
132
  */
130
- /** `mcp-federation/trust.ts`'s `CONNECTION_ID_PATTERN` caps a connection id at 40 characters. */
133
+ /** `packages/mcp/src/federation/trust.ts`'s `CONNECTION_ID_PATTERN` caps a connection id at 40 characters. */
131
134
  const MAX_CONNECTION_ID_LENGTH = 40;
132
135
  /**
133
136
  * Derives the `external_mcp_servers.serverId` one plugin-declared server maps to: its OWN declared
@@ -209,12 +212,12 @@ function classifyAgentPluginMcpServerForFederation(serverKey, config, classifyTr
209
212
  *
210
213
  * @complexity O(s) in the declared server count.
211
214
  */
212
- export function planAgentPluginMcpFederation(input, options) {
213
- const classifyTrust = options.classifyTrust;
215
+ export function planAgentPluginMcpFederation(input, _optional = {}) {
216
+ const classifyTrust = input.classifyTrust;
214
217
  const toUpsert = [];
215
218
  const skipped = [];
216
219
  for (const [serverKey, config] of Object.entries(input.servers)) {
217
- const result = classifyAgentPluginMcpServerForFederation(serverKey, config, classifyTrust, options.messages);
220
+ const result = classifyAgentPluginMcpServerForFederation(serverKey, config, classifyTrust, input.messages);
218
221
  if (result.kind === "upsert")
219
222
  toUpsert.push(result.planned);
220
223
  else
@@ -238,7 +241,7 @@ export function planAgentPluginMcpFederation(input, options) {
238
241
  * @complexity O(d) in installed-digest count, plus one `mcp.json` read.
239
242
  */
240
243
  export async function resolveAgentPluginMcpServers(input, _optional = {}) {
241
- const workspaceLayout = input.agentPluginLayout.forWorkspace(input.workspaceId);
244
+ const workspaceLayout = input.agentPluginLayout.forWorkspace({ workspaceId: input.workspaceId });
242
245
  // A bundled plugin that was upgraded in place has its superseded package dropped here, so the
243
246
  // servers this provisions come from the digest the running build published rather than whichever
244
247
  // one the directory walk happened to reach first (`bundled-digests.ts`).
@@ -260,7 +263,7 @@ export async function resolveAgentPluginMcpServers(input, _optional = {}) {
260
263
  * @returns The matching defaults, or `null`.
261
264
  * @complexity O(s) time, O(1) space in declared servers.
262
265
  */
263
- export function findAgentPluginMcpServerDefaults(servers, row) {
266
+ export function findAgentPluginMcpServerDefaults({ servers, row }, _optional = {}) {
264
267
  for (const [serverKey, config] of Object.entries(servers)) {
265
268
  if (config.type === "stdio" || deriveAgentPluginConnectionId({ serverKey }) !== row.serverId)
266
269
  continue;
@@ -276,7 +279,7 @@ export function findAgentPluginMcpServerDefaults(servers, row) {
276
279
  */
277
280
  export async function resolveAgentPluginReadOnlyRemoteNames(input, _optional = {}) {
278
281
  const servers = await resolveAgentPluginMcpServers({ ...input, bundledOnly: true });
279
- return new Set(findAgentPluginMcpServerDefaults(servers, input)?.read ?? []);
282
+ return new Set(findAgentPluginMcpServerDefaults({ servers, row: input })?.read ?? []);
280
283
  }
281
284
  /** Builds the ONE-TIME creation input for a planned server that rule 1's existence check already
282
285
  * confirmed has no row yet. Split out of {@link provisionAgentPluginMcpServers} purely to keep that
@@ -343,7 +346,7 @@ export function isEmptyJsonList({ raw }, _optional = {}) {
343
346
  * out of {@link provisionAgentPluginMcpServers} purely to keep that function's complexity under the
344
347
  * shop ceiling: the loop gets exactly one branch point per planned server instead of a nested
345
348
  * try/catch inline.
346
- * @complexity O(1) plus at most one `repo.upsert` for the adoption case. */
349
+ * @complexity O(1) plus at most one conditional write for the adoption case. */
347
350
  async function adoptOrRecognizeExistingAgentPluginMcpServer(deps, existing, planned, pluginId) {
348
351
  if (existing.provisionedByPluginId === pluginId) {
349
352
  return { kind: isStaleUntouchedProvisioning({ existing, planned, projections: deps.projections }) ? "stale" : "alreadyProvisioned" };
@@ -367,11 +370,11 @@ async function adoptOrRecognizeExistingAgentPluginMcpServer(deps, existing, plan
367
370
  }
368
371
  // Direct repo write, never `saveExternalMcpServer` — that function has no way to leave every
369
372
  // other field untouched while changing only this one (even its "tri-state" fields resolve a
370
- // default the caller must supply). Spreading `existing` and changing one property is the only
373
+ // default the caller must supply). Spreading the row just read and changing one property is the only
371
374
  // way to guarantee byte-identical preservation of the operator's url/transport/auth/allowlist/
372
- // write-grants/oauth state.
373
- await deps.repo.upsert({ ...existing, provisionedByPluginId: pluginId });
374
- return { kind: "adopted" };
375
+ // write-grants/oauth state; the write is conditional on that read's version (a missed write re-reads once).
376
+ const written = await updateAgentPluginMcpRow({ repo: deps.repo, key: existing, build: current => (current.provisionedByPluginId === existing.provisionedByPluginId ? { ...current, provisionedByPluginId: pluginId } : null) });
377
+ return written ? { kind: "adopted" } : { kind: "failed", reason: `connection id '${planned.connectionId}' changed owner or was removed while plugin '${pluginId}' was adopting it — nothing was changed` };
375
378
  }
376
379
  /**
377
380
  * Idempotently provisions one plugin's auto-admitted remote MCP servers into the external-MCP
@@ -381,20 +384,20 @@ async function adoptOrRecognizeExistingAgentPluginMcpServer(deps, existing, plan
381
384
  * Rule 1 is enforced per server, right here: `deps.repo.findByServerId` runs BEFORE any write. A row
382
385
  * already at the derived id is NEVER passed through `saveExternalMcpServer` — it is either
383
386
  * recognized as this same plugin's earlier work (`alreadyProvisioned`), adopted byte-identical
384
- * except for `provisionedByPluginId` via a direct `repo.upsert` (`adopted`), or, when it belongs to a
387
+ * except for `provisionedByPluginId` via a direct conditional repo write (`adopted`), or, when it belongs to a
385
388
  * DIFFERENT plugin at a non-matching endpoint/transport/auth mode, refused as a genuine collision
386
389
  * (`failed`). See {@link adoptOrRecognizeExistingAgentPluginMcpServer}.
387
390
  *
388
391
  * Per-server failures (a store validation error, an unconfigured secret store, a refused collision,
389
- * or an adoption's upsert failing) are caught and reported rather than thrown, matching
392
+ * or an adoption's write failing) are caught and reported rather than thrown, matching
390
393
  * `readEnabledExternalMcpConfigs`'s own fail-open posture: one unwritable row must not stop every
391
394
  * other server in the same plugin, or the plugin's own activation, from succeeding.
392
395
  *
393
396
  * @complexity O(s) in the plugin's declared server count, each one an existence check plus at most
394
397
  * one create or adopt.
395
398
  */
396
- export async function provisionAgentPluginMcpServers(deps, input) {
397
- const plan = planAgentPluginMcpFederation(input, { classifyTrust: input.classifyTrust, messages: input.messages });
399
+ export async function provisionAgentPluginMcpServers({ deps, ...input }, { report = createConsoleLogger({ prefix: '[agent-plugins]' }) } = {}) {
400
+ const plan = planAgentPluginMcpFederation(input);
398
401
  const provisioned = [];
399
402
  const alreadyProvisioned = [];
400
403
  const adopted = [];
@@ -403,7 +406,7 @@ export async function provisionAgentPluginMcpServers(deps, input) {
403
406
  // portable body never falls back to one host's projections; a host's legacy shim adds its pair).
404
407
  const bound = { repo: deps.repo, saveServer: (save) => deps.saveServer(save), projections: deps.projections, classifyError: deps.classifyError };
405
408
  for (const planned of plan.toUpsert) {
406
- const outcome = await provisionPlannedServer({ deps: bound, input, planned });
409
+ const outcome = await provisionPlannedServer({ deps: bound, input, planned, report });
407
410
  if (outcome.kind === "failed")
408
411
  failed.push({ serverKey: planned.serverKey, reason: outcome.reason });
409
412
  else if (outcome.kind === "provisioned")
@@ -420,7 +423,7 @@ export async function provisionAgentPluginMcpServers(deps, input) {
420
423
  }
421
424
  /** Execute one planned write, keeping lookup, adoption and replacement failures isolated. */
422
425
  async function provisionPlannedServer(required, _options = {}) {
423
- const { deps, input, planned } = required;
426
+ const { deps, input, planned, report } = required;
424
427
  try {
425
428
  const existing = await deps.repo.findByServerId({ workspaceId: input.workspaceId, serverId: planned.connectionId });
426
429
  if (existing) {
@@ -434,7 +437,11 @@ async function provisionPlannedServer(required, _options = {}) {
434
437
  return { kind: "provisioned" };
435
438
  }
436
439
  catch (err) {
437
- return { kind: "failed", reason: err instanceof Error ? err.message : String(err) };
440
+ const logger = report;
441
+ logger.warn({ message: `MCP provisioning write for server '${planned.serverKey}' of plugin '${input.pluginId}' failed.` }, { error: err });
442
+ // The caught error goes to `report` only; the answer text names the step and the error class,
443
+ // never the native message (it can carry credentials from the store).
444
+ return { kind: "failed", reason: `the MCP server row could not be saved (${describeErrorForLog({ err })})` };
438
445
  }
439
446
  }
440
447
  //# sourceMappingURL=federate-mcp.js.map
@@ -1,4 +1,4 @@
1
- import { ToolInputError, redactSecrets } from '@jini-ai/core';
1
+ import { ToolInputError, describeErrorForLog, redactSecrets } from '@jini-ai/core';
2
2
  import { createApplyConnectDefaults } from "./apply-connect-defaults.js";
3
3
  import { hasStoredAgentPluginCredential } from "./connect-tool.js";
4
4
  import { deriveAgentPluginConnectionId } from "./federate-mcp.js";
@@ -31,7 +31,7 @@ function grantFailure({ error, pluginId, connectionId, approved, warn, approvedF
31
31
  const detail = error instanceof Error ? error.message : String(error);
32
32
  if (approved)
33
33
  throw new ToolInputError({ message: redactSecrets({ input: approvedFailure({ connectionId, detail: detail.slice(0, 2000) }) }) });
34
- warn(`[agent-plugins] '${pluginId}': could not turn on the '${connectionId}' connection with the tools the plugin declares — ${detail}`);
34
+ warn(`[agent-plugins] '${pluginId}': could not turn on the '${connectionId}' connection with the tools the plugin declares — ${describeErrorForLog({ err: error })}`);
35
35
  }
36
36
  /**
37
37
  * Runs the sign-in grant on each of `pluginId`'s declared remote servers whose row this plugin
@@ -86,7 +86,7 @@ export async function grantDeclaredToolsAtBoot(required, _optional = {}) {
86
86
  activations = await deps.readActivations();
87
87
  }
88
88
  catch (error) {
89
- log.warn(`[agent-plugins] could not check signed-in plugin connections for their declared tools: ${error instanceof Error ? error.message : String(error)}`);
89
+ log.warn(`[agent-plugins] could not check signed-in plugin connections for their declared tools: ${describeErrorForLog({ err: error })}`);
90
90
  return;
91
91
  }
92
92
  for (const { pluginId, servers } of plugins) {
@@ -1,4 +1,5 @@
1
1
  import { resolveTarget, saveStaticAccessToken } from "./access-token-tool.js";
2
+ import { describeErrorForLog } from "@jini-ai/core";
2
3
  import { hasStoredAgentPluginCredential } from "./connect-tool.js";
3
4
  /**
4
5
  * Seals `token` onto `pluginId`'s token-auth row unless that row already has a credential, then
@@ -64,7 +65,7 @@ export async function importAgentPluginAccessTokensFromEnv(required, options = {
64
65
  plugins = await deps.listPlugins();
65
66
  }
66
67
  catch (err) {
67
- log.warn(`[agent-plugins] could not list plugins to import env tokens: ${err instanceof Error ? err.message : String(err)}`);
68
+ log.warn(`[agent-plugins] could not list plugins to import env tokens: ${describeErrorForLog({ err })}`);
68
69
  return;
69
70
  }
70
71
  for (const { pluginId, url, auth } of envDeclarations(plugins)) {
@@ -13,6 +13,7 @@ export * from './connect-sign-in-wait.js';
13
13
  export * from './connect-tool.js';
14
14
  export * from './access-token-tool.js';
15
15
  export * from './token-sign-in.js';
16
+ export * from './token-map.js';
16
17
  export * from './import-access-token.js';
17
18
  export * from './grant-signed-in-defaults.js';
18
19
  export * from './apply-tool-renames.js';
@@ -13,6 +13,7 @@ export * from './connect-sign-in-wait.js';
13
13
  export * from './connect-tool.js';
14
14
  export * from './access-token-tool.js';
15
15
  export * from './token-sign-in.js';
16
+ export * from './token-map.js';
16
17
  export * from './import-access-token.js';
17
18
  export * from './grant-signed-in-defaults.js';
18
19
  export * from './apply-tool-renames.js';
@@ -1,3 +1,4 @@
1
+ import { createConsoleLogger } from '@jini-ai/core/primitives';
1
2
  /** @agent-note Supply the same validation error constructor and field policy used by the host's credential store. */
2
3
  export function createPluginCredentialCardOperations({ cardErrors, assertFreeField }, _optional = {}) {
3
4
  /** Extract API inputs from the human card. Fixed destinations cannot be changed by form params.
@@ -56,7 +57,7 @@ export async function loadPluginCredentialCardsSafely({ loadCards, workspaceId }
56
57
  return await loadCards?.(workspaceId) ?? [];
57
58
  }
58
59
  catch {
59
- (options.warn ?? console.warn)("[plugin-credential-cards] Optional card lookup failed; using the default credential form.");
60
+ (options.warn ?? (message => createConsoleLogger({ prefix: '' }).warn({ message })))("[plugin-credential-cards] Optional card lookup failed; using the default credential form.");
60
61
  return [];
61
62
  }
62
63
  }
@@ -6,6 +6,7 @@
6
6
  * Discovery is metadata-only and fresh on each call so disable/uninstall cannot leave stale grants. */
7
7
  import type { Clock } from "@jini-ai/core/primitives";
8
8
  import { type AccessApprovalResource } from '@jini-ai/core';
9
+ import type { Logger } from '@jini-ai/core/primitives';
9
10
  import { readPluginIdentity, type PluginIdentityCandidate, type PluginLookupPort } from '@jini-ai/core/plugin-directory';
10
11
  import type { InstalledAgentPlugin } from '../../lifecycle/types.js';
11
12
  import type { SetAgentPluginEnabledInput, SetAgentPluginEnabledResult } from '../../lifecycle/set-enabled.js';
@@ -85,12 +86,13 @@ export interface PluginHostMessages extends AgentPluginEnableAccessMessages {
85
86
  * been provisioned or granted when this is thrown. */
86
87
  approvedSnapshotMissing(): string;
87
88
  /** @agent-note Product copy when an approved enable's provisioning/grant threw; `detail` is the
88
- * raw error message (unredacted) — the result is passed through `redactSecrets`. */
89
+ * safe error class/code summary — the result is passed through `redactSecrets`. */
89
90
  approvedLoadFailed(required: {
90
91
  detail: string;
91
92
  }): string;
92
93
  }
93
94
  export interface PluginHostDeps<UninstallInput, Layout extends AgentPluginLayoutInput = AgentPluginLayoutInput> {
95
+ readonly report?: Pick<Logger, 'warn'>;
94
96
  readonly workspaceId: string;
95
97
  readonly agentPluginLayout: Layout;
96
98
  readonly clock: Clock;
@@ -186,6 +188,11 @@ export interface PortablePluginHost<UninstallInput> extends PluginLookupPort {
186
188
  capability: 'agent-plugin-lifecycle';
187
189
  }): AgentPluginLifecycleCapability<UninstallInput> | undefined;
188
190
  }
191
+ /** Test seams: replace the MCP server resolver and the provisioning call. */
192
+ interface PluginHostOptional {
193
+ resolveMcpServers?: typeof resolveAgentPluginMcpServers;
194
+ provisionMcpServers?: typeof provisionAgentPluginMcpServers;
195
+ }
189
196
  /** Bind both plugin families to one workspace. Read manifests through the same installed-package
190
197
  * index.
191
198
  * @throws Unreadable activation (fail closed).
@@ -195,9 +202,6 @@ export interface PortablePluginHost<UninstallInput> extends PluginLookupPort {
195
202
  */
196
203
  export declare function createPluginHost<UninstallInput, Layout extends AgentPluginLayoutInput = AgentPluginLayoutInput>({ deps }: {
197
204
  deps: PluginHostDeps<UninstallInput, Layout>;
198
- }, optional?: {
199
- resolveMcpServers?: typeof resolveAgentPluginMcpServers;
200
- provisionMcpServers?: typeof provisionAgentPluginMcpServers;
201
- }): PortablePluginHost<UninstallInput>;
205
+ }, optional?: PluginHostOptional): PortablePluginHost<UninstallInput>;
202
206
  export {};
203
207
  //# sourceMappingURL=index.d.ts.map