@jini-ai/agent-plugins 0.6.22 → 0.7.0
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.
- package/CHANGELOG.md +51 -0
- package/README.md +13 -0
- package/calendly/exports/booking-calendar.css +7 -0
- package/calendly/exports/booking-calendar.html +5 -0
- package/calendly/mcp.json +10 -0
- package/calendly/plugin.json +47 -0
- package/calendly/skills/calendly/SKILL.md +27 -0
- package/charts-echarts/plugin.json +2 -2
- package/charts-recharts/plugin.json +2 -2
- package/cloudflare/lib/cms-forms.mjs +57 -0
- package/cloudflare/lib/forms.mjs +78 -18
- package/cloudflare/lib/target.mjs +17 -4
- package/cloudflare/plugin.json +2 -2
- package/cloudflare/skills/cloudflare/SKILL.md +4 -4
- package/cloudflare/skills/cloudflare/references/workers.md +4 -4
- package/cloudflare/worker/forms-receiver.mjs +81 -41
- package/cloudflare/worker/portable-validation.mjs +220 -0
- package/commerce/plugin.json +17 -0
- package/commerce/skills/commerce/SKILL.md +23 -0
- package/composio/mcp.json +1 -1
- package/composio/plugin.json +2 -2
- package/composio/skills/composio/SKILL.md +4 -4
- package/core/commerce-server.d.ts +2 -0
- package/core/commerce-server.mjs +2 -0
- package/dist/admin-surfaces/connections/connections.d.ts +35 -0
- package/dist/admin-surfaces/connections/connections.js +135 -0
- package/dist/admin-surfaces/connections/index.d.ts +3 -0
- package/dist/admin-surfaces/connections/index.js +2 -0
- package/dist/admin-surfaces/connections/ports.d.ts +110 -0
- package/dist/admin-surfaces/connections/ports.js +2 -0
- package/dist/admin-surfaces/index.d.ts +2 -0
- package/dist/admin-surfaces/index.js +1 -0
- package/dist/admin-surfaces/plugin-state-persistence.d.ts +27 -0
- package/dist/admin-surfaces/plugin-state-persistence.js +2 -0
- package/dist/admin-surfaces/plugin-state.d.ts +51 -0
- package/dist/admin-surfaces/plugin-state.js +106 -0
- package/dist/connect/access-token-tool.d.ts +240 -0
- package/dist/connect/access-token-tool.js +213 -0
- package/dist/connect/apply-connect-defaults.d.ts +91 -0
- package/dist/connect/apply-connect-defaults.js +113 -0
- package/dist/connect/apply-tool-renames.d.ts +72 -0
- package/dist/connect/apply-tool-renames.js +105 -0
- package/dist/connect/connect-card-ui.d.ts +143 -0
- package/dist/connect/connect-card-ui.js +106 -0
- package/dist/connect/connect-destination.d.ts +35 -0
- package/dist/connect/connect-destination.js +45 -0
- package/dist/connect/connect-sign-in-wait.d.ts +31 -0
- package/dist/connect/connect-sign-in-wait.js +21 -0
- package/dist/connect/connect-tool.d.ts +314 -0
- package/dist/connect/connect-tool.js +431 -0
- package/dist/connect/connection-status.d.ts +33 -0
- package/dist/connect/connection-status.js +63 -0
- package/dist/connect/credential-cards.d.ts +15 -0
- package/dist/connect/credential-cards.js +49 -0
- package/dist/connect/credential-save-tool.d.ts +45 -0
- package/dist/connect/credential-save-tool.js +156 -0
- package/dist/connect/enable-access.d.ts +67 -0
- package/dist/connect/enable-access.js +74 -0
- package/dist/connect/executable/approval.d.ts +58 -0
- package/dist/connect/executable/approval.js +40 -0
- package/dist/connect/executable/host-capabilities.d.ts +76 -0
- package/dist/connect/executable/host-capabilities.js +100 -0
- package/dist/connect/executable/index.d.ts +10 -0
- package/dist/connect/executable/index.js +9 -0
- package/dist/connect/executable/ports.d.ts +189 -0
- package/dist/connect/executable/ports.js +2 -0
- package/dist/connect/executable/register.d.ts +21 -0
- package/dist/connect/executable/register.js +125 -0
- package/dist/connect/federate-mcp.d.ts +190 -0
- package/dist/connect/federate-mcp.js +440 -0
- package/dist/connect/grant-signed-in-defaults.d.ts +96 -0
- package/dist/connect/grant-signed-in-defaults.js +100 -0
- package/dist/connect/import-access-token.d.ts +114 -0
- package/dist/connect/import-access-token.js +103 -0
- package/dist/connect/index.d.ts +19 -0
- package/dist/connect/index.js +19 -0
- package/dist/connect/plugin-credential-card.d.ts +46 -0
- package/dist/connect/plugin-credential-card.js +63 -0
- package/dist/connect/plugin-host/index.d.ts +203 -0
- package/dist/connect/plugin-host/index.js +153 -0
- package/dist/connect/ports.d.ts +74 -0
- package/dist/connect/ports.js +2 -0
- package/dist/connect/switch-on-saved-token.d.ts +48 -0
- package/dist/connect/switch-on-saved-token.js +20 -0
- package/dist/connect/token-sign-in.d.ts +51 -0
- package/dist/connect/token-sign-in.js +43 -0
- package/dist/core/identity-namespace.d.ts +39 -0
- package/dist/core/identity-namespace.js +61 -3
- package/dist/folder-zip-node.js +3 -1
- package/dist/lifecycle/automatic-use.d.ts +12 -7
- package/dist/lifecycle/automatic-use.js +37 -28
- package/dist/lifecycle/capability-projection.js +5 -1
- package/dist/lifecycle/contribution-loader.d.ts +2 -7
- package/dist/lifecycle/contribution-types.d.ts +8 -0
- package/dist/lifecycle/contribution-types.js +2 -0
- package/dist/lifecycle/credential-card-metadata.d.ts +23 -0
- package/dist/lifecycle/credential-card-metadata.js +184 -0
- package/dist/lifecycle/exports.d.ts +11 -0
- package/dist/lifecycle/exports.js +64 -3
- package/dist/lifecycle/host-tools/identity.d.ts +38 -0
- package/dist/lifecycle/host-tools/identity.js +58 -0
- package/dist/lifecycle/host-tools/index.d.ts +20 -0
- package/dist/lifecycle/host-tools/index.js +20 -0
- package/dist/lifecycle/host-tools/memory-tools.d.ts +22 -0
- package/dist/lifecycle/host-tools/memory-tools.js +63 -0
- package/dist/lifecycle/host-tools/ports.d.ts +121 -0
- package/dist/lifecycle/host-tools/ports.js +2 -0
- package/dist/lifecycle/host-tools/provider-status-tool.d.ts +88 -0
- package/dist/lifecycle/host-tools/provider-status-tool.js +45 -0
- package/dist/lifecycle/host-tools/search-tool.d.ts +74 -0
- package/dist/lifecycle/host-tools/search-tool.js +282 -0
- package/dist/lifecycle/host-tools/skill-tool.d.ts +219 -0
- package/dist/lifecycle/host-tools/skill-tool.js +482 -0
- package/dist/lifecycle/host-tools/write-note-tool.d.ts +22 -0
- package/dist/lifecycle/host-tools/write-note-tool.js +47 -0
- package/dist/lifecycle/index.d.ts +2 -1
- package/dist/lifecycle/install.js +2 -1
- package/dist/lifecycle/installed-package-index.js +5 -8
- package/dist/lifecycle/mail/adapter-descriptors.d.ts +78 -0
- package/dist/lifecycle/mail/adapter-descriptors.js +155 -0
- package/dist/lifecycle/mail/catalog.d.ts +116 -0
- package/dist/lifecycle/mail/catalog.js +72 -0
- package/dist/lifecycle/mail/configuration.d.ts +25 -0
- package/dist/lifecycle/mail/configuration.js +62 -0
- package/dist/lifecycle/mail/contribution.d.ts +89 -0
- package/dist/lifecycle/mail/contribution.js +115 -0
- package/dist/lifecycle/mail/host-mailer.d.ts +24 -0
- package/dist/lifecycle/mail/host-mailer.js +10 -0
- package/dist/lifecycle/mail/index.d.ts +16 -0
- package/dist/lifecycle/mail/index.js +16 -0
- package/dist/lifecycle/mail/selection.d.ts +40 -0
- package/dist/lifecycle/mail/selection.js +86 -0
- package/dist/lifecycle/manifest.d.ts +7 -2
- package/dist/lifecycle/manifest.js +32 -9
- package/dist/lifecycle/metadata.d.ts +31 -0
- package/dist/lifecycle/metadata.js +80 -0
- package/dist/lifecycle/persistent-state.js +2 -1
- package/dist/lifecycle/ports.d.ts +2 -0
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -1
- package/dist/lifecycle/resolve-agent-plugin-refs.js +14 -8
- package/dist/lifecycle/search-projection.d.ts +3 -4
- package/dist/lifecycle/search-projection.js +5 -7
- package/dist/lifecycle/search.js +3 -2
- package/fly/plugin.json +5 -5
- package/fly/skills/fly/SKILL.md +1 -1
- package/formspree/plugin.json +7 -0
- package/formspree/skills/formspree/SKILL.md +11 -0
- package/github/plugin.json +2 -2
- package/github/skills/github/SKILL.md +28 -28
- package/github/skills/github/references/actions.md +8 -8
- package/github/skills/github/references/auth-and-tokens.md +7 -7
- package/github/skills/github/references/repo-files.md +5 -5
- package/github/skills/github/references/site-backup.md +16 -16
- package/github/skills/github/references/source-control.md +17 -17
- package/github-pages/plugin.json +2 -2
- package/github-pages/skills/github-pages/SKILL.md +3 -3
- package/google-forms/plugin.json +7 -0
- package/google-forms/skills/google-forms/SKILL.md +15 -0
- package/google-login/plugin.json +3 -3
- package/google-login/skills/google-login/SKILL.md +17 -60
- package/google-workspace/plugin.json +6 -6
- package/google-workspace/skills/google-workspace/references/connection.md +1 -1
- package/google-workspace/skills/google-workspace/references/form-delivery.md +4 -4
- package/google-workspace/tovu-admin-surfaces.json +5 -5
- package/higgsfield-media/plugin.json +5 -5
- package/higgsfield-media/skills/higgsfield-media/SKILL.md +31 -33
- package/higgsfield-media/skills/higgsfield-media/references/failure-modes.md +7 -7
- package/higgsfield-media/skills/higgsfield-media/references/models-and-plan-gates.md +3 -3
- package/jev/plugin.json +2 -2
- package/langfuse/plugin.json +2 -2
- package/meilisearch/plugin.json +2 -2
- package/meilisearch/skills/meilisearch/SKILL.md +1 -1
- package/netlify/plugin.json +2 -2
- package/netlify/skills/netlify/SKILL.md +3 -3
- package/opentelemetry/plugin.json +2 -2
- package/opentelemetry/skills/opentelemetry/SKILL.md +7 -7
- package/package.json +92 -14
- package/posthog/plugin.json +2 -2
- package/posthog/skills/posthog/SKILL.md +7 -7
- package/railway/plugin.json +3 -3
- package/railway/skills/railway/SKILL.md +10 -11
- package/render/plugin.json +3 -3
- package/render/skills/render/SKILL.md +7 -8
- package/resend/NOTES.md +2 -2
- package/resend/mcp.json +1 -1
- package/resend/plugin.json +5 -5
- package/resend/skills/resend/SKILL.md +13 -13
- package/s3-compatible/plugin.json +2 -2
- package/s3-compatible/skills/s3-compatible/SKILL.md +4 -4
- package/sentry/plugin.json +2 -2
- package/sentry/skills/sentry/SKILL.md +7 -7
- package/shopify/plugin.json +2 -2
- package/site-compliance/plugin.json +2 -2
- package/site-compliance/skills/site-compliance/SKILL.md +3 -3
- package/site-compliance/skills/site-compliance/references/gdpr-eu-uk.md +1 -1
- package/site-import/plugin.json +2 -2
- package/slide-design/plugin.json +2 -2
- package/software-engineering/LICENSE +201 -0
- package/software-engineering/NOTICE +9 -0
- package/software-engineering/README.md +89 -0
- package/software-engineering/plugin.json +24 -0
- package/software-engineering/skills/software-engineering/SKILL.md +33 -0
- package/software-engineering/skills/software-engineering/references/debugging.md +54 -0
- package/software-engineering/skills/software-engineering/references/implementation.md +27 -0
- package/software-engineering/skills/software-engineering/references/planning.md +27 -0
- package/software-engineering/skills/software-engineering/references/prototyping.md +14 -0
- package/software-engineering/skills/software-engineering/references/security.md +47 -0
- package/software-engineering/skills/software-engineering/references/verification.md +53 -0
- package/stripe/plugin.json +2 -2
- package/supabase/mcp.json +4 -4
- package/supabase/plugin.json +3 -3
- package/supabase/skills/supabase/SKILL.md +8 -8
- package/supabase/skills/supabase/references/failure-modes.md +5 -5
- package/ui-ux-design/plugin.json +2 -2
- package/vercel/plugin.json +2 -2
- package/vercel/skills/vercel/SKILL.md +3 -3
- package/wordpress/plugin.json +2 -2
- package/wordpress/skills/wordpress/SKILL.md +3 -3
- package/wordpress/skills/wordpress/references/free-site-redirect.md +2 -2
- package/wordpress/skills/wordpress/references/subdomain.md +5 -5
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { redactSecrets, ToolInputError } from '@jini-ai/core';
|
|
2
|
+
import { createPluginLookup, readPluginIdentity, assertPluginIdentityAvailable } from '@jini-ai/core/plugin-directory';
|
|
3
|
+
import { provisionAgentPluginMcpServers, resolveAgentPluginMcpServers } from '../federate-mcp.js';
|
|
4
|
+
import { recordAgentPluginAccessDeclined } from '../apply-connect-defaults.js';
|
|
5
|
+
import { previewAgentPluginEnableAccess } from '../enable-access.js';
|
|
6
|
+
/** Preserve best-effort diagnostics for background provisioning; an approved card must instead
|
|
7
|
+
* report a partial failure to its caller. O(s) in failed declared servers, no extra I/O.
|
|
8
|
+
*/
|
|
9
|
+
function reportProvisioningFailures({ pluginId, failed, approved, warn, messages }) {
|
|
10
|
+
for (const failure of failed)
|
|
11
|
+
warn(redactSecrets({ input: `Plugin '${pluginId}': MCP provisioning for server '${failure.serverKey}' failed — ${failure.reason}` }));
|
|
12
|
+
if (approved && failed.length)
|
|
13
|
+
throw new ToolInputError({ message: redactSecrets({ input: messages.provisioningFailed({ pluginId, failed }) }) });
|
|
14
|
+
}
|
|
15
|
+
/** An approved grant must carry the exact snapshot displayed by its host preview. */
|
|
16
|
+
function requireApprovedAccessKey(key, messages) {
|
|
17
|
+
if (!key)
|
|
18
|
+
throw new ToolInputError({ message: messages.approvedSnapshotMissing() });
|
|
19
|
+
return key;
|
|
20
|
+
}
|
|
21
|
+
/** Bind both plugin families to one workspace. Read manifests through the same installed-package
|
|
22
|
+
* index.
|
|
23
|
+
* @throws Unreadable activation (fail closed).
|
|
24
|
+
* Unreadable/invalid or ambiguous manifest metadata is omitted with a warning. Admission retains
|
|
25
|
+
* every valid revision identity, including revisions omitted from lookup, to prevent takeovers.
|
|
26
|
+
* @complexity O(p log p) per lookup, plus existing discovery/activation I/O for p installs.
|
|
27
|
+
*/
|
|
28
|
+
export function createPluginHost({ deps }, optional = {}) {
|
|
29
|
+
const { warn, lifecycle } = deps;
|
|
30
|
+
const listSiteProviders = async ({ forAdmission }, _options = {}) => {
|
|
31
|
+
const providers = [];
|
|
32
|
+
for (const record of await deps.discoverPlugins()) {
|
|
33
|
+
if (record.status !== 'valid' || !record.manifest) {
|
|
34
|
+
warn(`Plugin '${record.id}': invalid installed manifest omitted from metadata lookup.`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = readPluginIdentity({ manifest: record.manifest, name: record.id, namespace: deps.namespace });
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
warn(`Plugin '${record.id}': installed identity manifest is unreadable or invalid; omitted from metadata lookup.`);
|
|
43
|
+
}
|
|
44
|
+
if (parsed) {
|
|
45
|
+
const { warnings, ...identity } = parsed;
|
|
46
|
+
warnings.forEach(warn);
|
|
47
|
+
const activation = forAdmission ? null : await deps.getActivation({ workspaceId: deps.workspaceId, pluginId: record.id });
|
|
48
|
+
providers.push({ ...identity, version: record.version, enabled: activation?.enabled === true, family: 'site-runtime', localId: record.id });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return providers;
|
|
52
|
+
};
|
|
53
|
+
const resolveAgentProviders = async ({ agentProviders }, _options = {}) => {
|
|
54
|
+
const providers = [];
|
|
55
|
+
for (const [pluginId, revisions] of agentProviders) {
|
|
56
|
+
// Multiple digests are revisions of one install, not duplicate provider registrations.
|
|
57
|
+
// Without a recorded winner the existing lifecycle refuses to guess; discovery follows it
|
|
58
|
+
// by omitting this plugin, while unrelated lookup and installation remain available.
|
|
59
|
+
if (revisions.length !== 1) {
|
|
60
|
+
const declaredIds = new Set(revisions.map(provider => provider.id).filter(id => id !== `unknown/${pluginId}`));
|
|
61
|
+
warn(`Plugin '${pluginId}': ${declaredIds.size > 1 ? 'conflicting publisher identities' : 'ambiguous installed revisions'}; omitted from metadata lookup.`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
providers.push({ ...revisions[0], enabled: await lifecycle.isEnabled({ pluginId }) });
|
|
65
|
+
}
|
|
66
|
+
return providers;
|
|
67
|
+
};
|
|
68
|
+
const listAgentProviders = async ({ forAdmission }, _options = {}) => {
|
|
69
|
+
const providers = [];
|
|
70
|
+
const agentProviders = new Map();
|
|
71
|
+
// A legacy revision may acquire its first publisher identity at upgrade; old frozen
|
|
72
|
+
// digests can remain present from older installs until successful publication prunes them.
|
|
73
|
+
// Reuse that owner's selection; metadata lookup must not invent a newest-version policy.
|
|
74
|
+
const installed = await lifecycle.listInstalled();
|
|
75
|
+
const preferred = forAdmission ? installed : await lifecycle.preferInstalled({ installed });
|
|
76
|
+
const preferredKeys = new Set(preferred.map(plugin => `${plugin.pluginId}:${plugin.archiveDigest}`));
|
|
77
|
+
for (const plugin of installed) {
|
|
78
|
+
let parsed;
|
|
79
|
+
try {
|
|
80
|
+
parsed = await lifecycle.readIdentity({ plugin });
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
warn(`Plugin '${plugin.pluginId}': installed identity manifest is unreadable or invalid; omitted from metadata lookup.`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const { warnings, ...identity } = parsed;
|
|
87
|
+
warnings.forEach(warn);
|
|
88
|
+
const provider = { ...identity, version: plugin.version ?? null, enabled: false, family: 'agent-plugin', localId: plugin.pluginId };
|
|
89
|
+
if (forAdmission)
|
|
90
|
+
providers.push(provider);
|
|
91
|
+
else {
|
|
92
|
+
if (preferredKeys.has(`${plugin.pluginId}:${plugin.archiveDigest}`)) {
|
|
93
|
+
const revisions = agentProviders.get(plugin.pluginId) ?? [];
|
|
94
|
+
revisions.push(provider);
|
|
95
|
+
agentProviders.set(plugin.pluginId, revisions);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return providers.concat(await resolveAgentProviders({ agentProviders }));
|
|
100
|
+
};
|
|
101
|
+
const listProviders = async ({ forAdmission = false } = {}, _options = {}) => {
|
|
102
|
+
const providers = await listSiteProviders({ forAdmission });
|
|
103
|
+
return providers.concat(await listAgentProviders({ forAdmission }));
|
|
104
|
+
};
|
|
105
|
+
const lookup = createPluginLookup({ listPlugins: listProviders }, { warn });
|
|
106
|
+
const resolveServers = (pluginId) => (optional.resolveMcpServers ?? resolveAgentPluginMcpServers)({ agentPluginLayout: deps.agentPluginLayout, lifecycle: deps.installedMcp, workspaceId: deps.workspaceId, pluginId });
|
|
107
|
+
// Preview, provisioning grant and status share the host's composed pair (resolved once by the host).
|
|
108
|
+
const { mcp, mcpPorts } = deps;
|
|
109
|
+
const agentPlugins = {
|
|
110
|
+
inactivePluginIds: () => lifecycle.inactivePluginIds(),
|
|
111
|
+
previewEnableAccess: async ({ pluginId }) => previewAgentPluginEnableAccess({
|
|
112
|
+
workspaceId: deps.workspaceId, pluginId, repo: mcp.repo, ...mcpPorts, servers: await resolveServers(pluginId), classifyTrust: deps.classifyTrust, messages: deps.messages,
|
|
113
|
+
}),
|
|
114
|
+
recordDeclinedAccess: async ({ accessKey }) => recordAgentPluginAccessDeclined({ applyAccess: mcp.applyAccess, workspaceId: deps.workspaceId, accessKey, actorId: deps.declinedAccessActor }),
|
|
115
|
+
listInstalled: () => lifecycle.listInstalled(),
|
|
116
|
+
preferInstalled: input => lifecycle.preferInstalled(input),
|
|
117
|
+
assertWritable: () => lifecycle.assertWritable(),
|
|
118
|
+
setEnabled: input => lifecycle.setEnabled(input),
|
|
119
|
+
/** Provisioning must use the same two owners as the admin toggle. A failed connection never
|
|
120
|
+
* rolls back a successful activation; report fixed diagnostics without credential material. */
|
|
121
|
+
provisionMcp: async ({ pluginId, principalId }, execution = {}) => {
|
|
122
|
+
try {
|
|
123
|
+
const approvedEnable = execution.approvedEnable ? { principalId, accessKey: requireApprovedAccessKey(execution.approvedEnableKey, deps.messages) } : undefined;
|
|
124
|
+
const servers = await resolveServers(pluginId);
|
|
125
|
+
const result = await (optional.provisionMcpServers ?? provisionAgentPluginMcpServers)(mcp, { workspaceId: deps.workspaceId, pluginId, servers, principalId, classifyTrust: deps.classifyTrust, messages: deps.messages });
|
|
126
|
+
reportProvisioningFailures({ pluginId, failed: result.failed, approved: execution.approvedEnable === true, warn, messages: deps.messages });
|
|
127
|
+
// Same as the admin toggle: an account signed in while the plugin was off gets the plugin's
|
|
128
|
+
// declared tools now (bug 2026-11-04, the host's sign-in grant owner).
|
|
129
|
+
await deps.grantSignedInDefaults({
|
|
130
|
+
deps: { workspaceId: deps.workspaceId, agentPluginLayout: deps.agentPluginLayout, repo: mcp.repo, applyAccess: mcp.applyAccess, clock: deps.clock, ...mcpPorts,
|
|
131
|
+
notifyRosterChanged: () => mcp.notifyRosterChanged({}, {}), warn: message => warn(redactSecrets({ input: message })) },
|
|
132
|
+
pluginId,
|
|
133
|
+
servers,
|
|
134
|
+
}, { skipServerKeys: result.failed.map(failure => failure.serverKey), ...(approvedEnable ? { approvedEnable } : {}) });
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
138
|
+
if (execution.approvedEnable)
|
|
139
|
+
throw new ToolInputError({ message: redactSecrets({ input: deps.messages.approvedLoadFailed({ detail }) }) });
|
|
140
|
+
warn(redactSecrets({ input: `Plugin '${pluginId}': MCP provisioning could not run — ${detail}` }));
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
uninstall: input => lifecycle.uninstall(input),
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
...lookup,
|
|
147
|
+
withInstallIdentity: ({ candidate, run }) => deps.withLock({
|
|
148
|
+
run: async () => { assertPluginIdentityAvailable({ candidate, installed: await listProviders({ forAdmission: true }) }); return run(); },
|
|
149
|
+
}),
|
|
150
|
+
getHostCapability: ({ capability }) => capability === 'agent-plugin-lifecycle' ? agentPlugins : undefined
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Consumer-owned service boundaries. Composition binds concrete services and secret stores. */
|
|
2
|
+
import type { ExternalMcpAccessSnapshot, ExternalMcpApprovedAccess, ExternalMcpOAuthStatus, ExternalMcpServerRecord, ExternalMcpServerRepoPort, ExternalMcpServerView, SaveExternalMcpServerInput } from '@jini-ai/core/contracts/hosted-mcp';
|
|
3
|
+
import type { SealedSecret } from '@jini-ai/core/contracts/vault';
|
|
4
|
+
/** Roster persistence and safe classification; sealing/keyring dependencies stay in composition. */
|
|
5
|
+
/** @agent-note `Lowered` is the host's own tool-access change record type (opaque to this package). */
|
|
6
|
+
export interface AgentPluginMcpPort<Lowered = unknown> {
|
|
7
|
+
readonly repo: AgentPluginMcpRepo;
|
|
8
|
+
/** Atomically save exactly the approved source and previous grants through the store owner. */
|
|
9
|
+
applyAccess(input: ExternalMcpApprovedAccess, options?: Record<string, never>): Promise<void>;
|
|
10
|
+
saveServer(input: AgentPluginMcpSave, options?: Record<string, never>): Promise<AgentPluginMcpView>;
|
|
11
|
+
classifyError(input: {
|
|
12
|
+
error: unknown;
|
|
13
|
+
}, options?: Record<string, never>): "validation" | "unconfigured" | "other";
|
|
14
|
+
/** @agent-note `lowered` is the host's own tool-access change record (opaque here; this package only
|
|
15
|
+
* ever calls it with `{}` after provisioning settles). One roster notifier per host, shared by admin and chat enable. */
|
|
16
|
+
notifyRosterChanged(input: {
|
|
17
|
+
readonly lowered?: Lowered;
|
|
18
|
+
}, options?: Record<string, never>): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/** @agent-note These aliases name the canonical `@jini-ai/core/contracts/hosted-mcp` rows. Never copy the record,
|
|
21
|
+
* access snapshot or repository: adoption must retain the canonical store's whole saved row. */
|
|
22
|
+
export type AgentPluginMcpRecord = ExternalMcpServerRecord;
|
|
23
|
+
export type AgentPluginMcpSave = SaveExternalMcpServerInput;
|
|
24
|
+
/** @agent-note The host's token-hint shape stays opaque here (`unknown`); this package never reads it. */
|
|
25
|
+
export type AgentPluginMcpView = ExternalMcpServerView<unknown>;
|
|
26
|
+
export type AgentPluginMcpRepo = Pick<ExternalMcpServerRepoPort, 'findByServerId' | 'upsert' | 'deleteByServerId' | 'updateAccessIfCurrent'>;
|
|
27
|
+
export type AgentPluginMcpAccessSnapshot = ExternalMcpAccessSnapshot;
|
|
28
|
+
/** @agent-note A second host supplies all six projections together with the paired
|
|
29
|
+
* {@link AgentPluginMcpProjectionPorts.classifyError}; preview, provisioning, sign-in revalidation and
|
|
30
|
+
* status reads must all receive the SAME object, never a per-call default. */
|
|
31
|
+
export interface AgentPluginMcpProjections {
|
|
32
|
+
/** @agent-note The canonical saved representation of a row's admitted source. The snapshot must be
|
|
33
|
+
* JSON-serializable with a stable key order: approval revalidation compares JSON.stringify of the
|
|
34
|
+
* previewed and re-read snapshots byte-for-byte, so any reordering refuses a valid approval. */
|
|
35
|
+
readonly accessSnapshot: (required: {
|
|
36
|
+
record: AgentPluginMcpRecord;
|
|
37
|
+
}, optional?: Record<string, never>) => AgentPluginMcpAccessSnapshot;
|
|
38
|
+
/** @agent-note Canonical saved admission revision; same stability rule as `accessSnapshot`. */
|
|
39
|
+
readonly admissionRevision: (record: AgentPluginMcpRecord) => string;
|
|
40
|
+
/** @agent-note With `{ strict: true }` an unreadable stored list throws; it never reads as an empty
|
|
41
|
+
* or fresh grant, which would silently widen or drop an existing grant. */
|
|
42
|
+
readonly readToolGrants: (record: Pick<AgentPluginMcpAccessSnapshot, 'allowedToolNames' | 'writeAllowedToolNames'>, options?: {
|
|
43
|
+
strict?: boolean;
|
|
44
|
+
}) => {
|
|
45
|
+
allowedToolNames: string[];
|
|
46
|
+
writeAllowedToolNames: string[];
|
|
47
|
+
};
|
|
48
|
+
/** @agent-note Throws an error the paired `classifyError` reports as `'validation'`; its message is
|
|
49
|
+
* the public repair reason shown to the model, so it must never carry credential material. */
|
|
50
|
+
readonly validateToolNames: (required: {
|
|
51
|
+
names: readonly string[];
|
|
52
|
+
field: string;
|
|
53
|
+
}, optional?: Record<string, never>) => string[];
|
|
54
|
+
/** @agent-note Pure: no I/O, no cache, never opens sealed credential material (status reads stay token-free). */
|
|
55
|
+
readonly oauthStatus: (record: {
|
|
56
|
+
oauthStatus: string | null;
|
|
57
|
+
}) => ExternalMcpOAuthStatus;
|
|
58
|
+
/** @agent-note Pure: no I/O, no cache, never opens sealed credential material (status reads stay token-free). */
|
|
59
|
+
readonly hasStaticAccessToken: (record: {
|
|
60
|
+
authMode: string;
|
|
61
|
+
sealedOAuth: SealedSecret | null;
|
|
62
|
+
}) => boolean;
|
|
63
|
+
}
|
|
64
|
+
/** @agent-note Bound once per binding/factory and passed whole: a host never supplies one half. */
|
|
65
|
+
export interface AgentPluginMcpProjectionPorts {
|
|
66
|
+
readonly projections: AgentPluginMcpProjections;
|
|
67
|
+
/** @agent-note Paired with `projections.validateToolNames`: whatever it throws classifies as
|
|
68
|
+
* `'validation'`. Classification alone does not redact; consumers redact before model text. */
|
|
69
|
+
readonly classifyError: AgentPluginMcpPort['classifyError'];
|
|
70
|
+
}
|
|
71
|
+
/** New composition must fulfill the full contract. */
|
|
72
|
+
export interface AgentPluginMcpServicesPort<Lowered = unknown> extends Omit<AgentPluginMcpPort<Lowered>, 'classifyError'>, AgentPluginMcpProjectionPorts {
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AgentPluginMcpPort } from "./ports.js";
|
|
2
|
+
/**
|
|
3
|
+
* @file After an access token is saved onto a plugin's token-auth row, switches the plugin on the
|
|
4
|
+
* same way a first sign-in does (`apply-connect-defaults.ts`), so saving a token is the only step —
|
|
5
|
+
* unless an operator deliberately turned it off, in which case it stays off and the caller names the
|
|
6
|
+
* screen that turns it back on.
|
|
7
|
+
*
|
|
8
|
+
* Two callers: `agent_plugin_set_access_token` (`access-token-tool.ts`) and the token import
|
|
9
|
+
* (`import-access-token.ts`, boot env import and create-site onboarding). Added 2026-09-29: the
|
|
10
|
+
* tool used to end with "ask the operator to enable it in Settings", a manual step nothing required.
|
|
11
|
+
*
|
|
12
|
+
* "Deliberately off" is either:
|
|
13
|
+
* - a disabled Agent Plugins activation record that anyone other than the boot seeder wrote (the
|
|
14
|
+
* seeder's own disabled record is the default, not a decision — `activation.ts`'s same exception);
|
|
15
|
+
* - a row the operator already edited (tool lists filled) and left disabled — `apply-connect-defaults`
|
|
16
|
+
* never touches an edited row.
|
|
17
|
+
*/
|
|
18
|
+
export type SavedTokenSwitchOutcome = {
|
|
19
|
+
readonly state: "on";
|
|
20
|
+
} | {
|
|
21
|
+
readonly state: "plugin-off-by-operator";
|
|
22
|
+
} | {
|
|
23
|
+
readonly state: "connection-off-by-operator";
|
|
24
|
+
};
|
|
25
|
+
export interface SwitchOnSavedTokenDeps {
|
|
26
|
+
readonly workspaceId: string;
|
|
27
|
+
readonly mcp: Pick<AgentPluginMcpPort, "repo">;
|
|
28
|
+
/** @agent-note Host binding of the sign-in's own `onConnected` (`createApplyConnectDefaults` over the
|
|
29
|
+
* host's one MCP repo, projections and activation owner), so a saved token and a sign-in grant alike. */
|
|
30
|
+
readonly onConnected: (serverId: string) => Promise<void>;
|
|
31
|
+
/** @agent-note Host activation read: whether an operator (not the seeder) turned the plugin off. */
|
|
32
|
+
readonly isPluginOffByOperator: (pluginId: string) => Promise<boolean>;
|
|
33
|
+
/** @agent-note Host activation owner: switches the plugin's activation on unless an operator turned it
|
|
34
|
+
* off, through the host's one activation queue; false when an operator's "off" stopped it. */
|
|
35
|
+
readonly switchPluginOn: (pluginId: string) => Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Switches the plugin and its `connectionId` row on after a token was saved there, unless an
|
|
39
|
+
* operator turned either off. "on" means both the row and the plugin's own activation are on.
|
|
40
|
+
*
|
|
41
|
+
* @throws Whatever the activation read or write, the connect-defaults write, or the row read throws.
|
|
42
|
+
* @complexity Two activation reads, at most one connect-defaults apply and one activation write, one row read.
|
|
43
|
+
*/
|
|
44
|
+
export declare function switchOnSavedTokenConnection(deps: SwitchOnSavedTokenDeps, target: {
|
|
45
|
+
readonly pluginId: string;
|
|
46
|
+
readonly connectionId: string;
|
|
47
|
+
}): Promise<SavedTokenSwitchOutcome>;
|
|
48
|
+
//# sourceMappingURL=switch-on-saved-token.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switches the plugin and its `connectionId` row on after a token was saved there, unless an
|
|
3
|
+
* operator turned either off. "on" means both the row and the plugin's own activation are on.
|
|
4
|
+
*
|
|
5
|
+
* @throws Whatever the activation read or write, the connect-defaults write, or the row read throws.
|
|
6
|
+
* @complexity Two activation reads, at most one connect-defaults apply and one activation write, one row read.
|
|
7
|
+
*/
|
|
8
|
+
export async function switchOnSavedTokenConnection(deps, target) {
|
|
9
|
+
const isOff = deps.isPluginOffByOperator;
|
|
10
|
+
if (await isOff(target.pluginId))
|
|
11
|
+
return { state: "plugin-off-by-operator" };
|
|
12
|
+
const onConnected = deps.onConnected;
|
|
13
|
+
await onConnected(target.connectionId);
|
|
14
|
+
const row = await deps.mcp.repo.findByServerId({ workspaceId: deps.workspaceId, serverId: target.connectionId });
|
|
15
|
+
if (row?.enabled !== true)
|
|
16
|
+
return { state: "connection-off-by-operator" };
|
|
17
|
+
const switchPluginOn = deps.switchPluginOn;
|
|
18
|
+
return (await switchPluginOn(target.pluginId)) ? { state: "on" } : { state: "plugin-off-by-operator" };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=switch-on-saved-token.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type AgentPluginTokenCredentialsPort, type AgentPluginTokenValidator } from "./access-token-tool.js";
|
|
2
|
+
import { type ResolvedAgentPluginForConnect } from "./connect-tool.js";
|
|
3
|
+
import type { McpServerConfig } from "../lifecycle/manifest.js";
|
|
4
|
+
/**
|
|
5
|
+
* @file Which installed Agent Plugins can be connected with a pasted access token, and a check of one
|
|
6
|
+
* token before anything is saved — for create-site onboarding, which offers "connect <plugin> now"
|
|
7
|
+
* next to the site's name. Generic: a plugin qualifies by declaring `tokenAuth` on exactly one
|
|
8
|
+
* remote server in its `mcp.json`; the tokens page and the probe URL both come from there.
|
|
9
|
+
*/
|
|
10
|
+
/** One plugin the onboarding form can offer a token field for.
|
|
11
|
+
* @agent-note Safe display projection of your installed declaration; helpUrl is the plugin's
|
|
12
|
+
* declared human token page, never a saved token or a newly trusted endpoint. */
|
|
13
|
+
export interface TokenSignInPlugin {
|
|
14
|
+
readonly pluginId: string;
|
|
15
|
+
readonly displayName: string;
|
|
16
|
+
/** Where the person creates a token (the plugin's own `tokenAuth.helpUrl`). */
|
|
17
|
+
readonly helpUrl: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The installed plugins that take a pasted token, sorted by id.
|
|
21
|
+
* @complexity O(p·s) over installed plugins and their servers.
|
|
22
|
+
*/
|
|
23
|
+
export declare function listTokenSignInPlugins(required: {
|
|
24
|
+
readonly workspaceId: string;
|
|
25
|
+
/** @agent-note Second host: your installed-plugin read (declared servers per plugin id); no filesystem default here. */
|
|
26
|
+
readonly listPlugins: (workspaceId: string) => Promise<readonly {
|
|
27
|
+
readonly pluginId: string;
|
|
28
|
+
readonly servers: Readonly<Record<string, McpServerConfig>>;
|
|
29
|
+
}[]>;
|
|
30
|
+
}, _optional?: Record<string, never>): Promise<readonly TokenSignInPlugin[]>;
|
|
31
|
+
/** @agent-note The host validator/probe decides this bounded safe outcome. No token, response body
|
|
32
|
+
* or provider fault text is returned or persisted by the check. */
|
|
33
|
+
export type TokenCheckOutcome = "ok" | "invalid" | "refused" | "unavailable" | "unsupported";
|
|
34
|
+
/**
|
|
35
|
+
* Checks `token` against the plugin's declared probe URL (one GET; 401/403 refused). Never throws,
|
|
36
|
+
* never returns or logs the token. `unsupported`: the plugin is not installed or takes no token.
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkAgentPluginAccessToken(required: {
|
|
39
|
+
/** @agent-note Second host: `tokenValidator` is your token rule (R1, required); `resolveInstalledPlugin` your installed read. */
|
|
40
|
+
readonly deps: {
|
|
41
|
+
readonly workspaceId: string;
|
|
42
|
+
readonly credentials: Pick<AgentPluginTokenCredentialsPort, "probe">;
|
|
43
|
+
readonly resolveInstalledPlugin: (pluginId: string) => Promise<ResolvedAgentPluginForConnect | null>;
|
|
44
|
+
readonly tokenValidator: Pick<AgentPluginTokenValidator, "assertToken">;
|
|
45
|
+
};
|
|
46
|
+
readonly input: {
|
|
47
|
+
readonly pluginId: string;
|
|
48
|
+
readonly token: string;
|
|
49
|
+
};
|
|
50
|
+
}, _optional?: Record<string, never>): Promise<TokenCheckOutcome>;
|
|
51
|
+
//# sourceMappingURL=token-sign-in.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { probeToken } from "./access-token-tool.js";
|
|
2
|
+
import { titleCaseFromPluginId } from "./connect-tool.js";
|
|
3
|
+
/** The plugin's one token-auth declaration, or `null` for none or more than one (the same rule
|
|
4
|
+
* `agent_plugin_set_access_token` refuses on). */
|
|
5
|
+
function soleTokenAuth(servers) {
|
|
6
|
+
const declared = Object.values(servers).flatMap((config) => (config.type !== "stdio" && config.tokenAuth ? [config.tokenAuth] : []));
|
|
7
|
+
// Exactly one element was just checked, so `declared[0]` is present; the cast only narrows the
|
|
8
|
+
// index type (no fallback branch can ever run).
|
|
9
|
+
return declared.length === 1 ? declared[0] : null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The installed plugins that take a pasted token, sorted by id.
|
|
13
|
+
* @complexity O(p·s) over installed plugins and their servers.
|
|
14
|
+
*/
|
|
15
|
+
export async function listTokenSignInPlugins(required, _optional = {}) {
|
|
16
|
+
const plugins = await required.listPlugins(required.workspaceId);
|
|
17
|
+
return plugins
|
|
18
|
+
.flatMap(({ pluginId, servers }) => {
|
|
19
|
+
const auth = soleTokenAuth(servers);
|
|
20
|
+
return auth ? [{ pluginId, displayName: titleCaseFromPluginId({ pluginId }), helpUrl: auth.helpUrl }] : [];
|
|
21
|
+
})
|
|
22
|
+
.sort((a, b) => a.pluginId.localeCompare(b.pluginId));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks `token` against the plugin's declared probe URL (one GET; 401/403 refused). Never throws,
|
|
26
|
+
* never returns or logs the token. `unsupported`: the plugin is not installed or takes no token.
|
|
27
|
+
*/
|
|
28
|
+
export async function checkAgentPluginAccessToken(required, _optional = {}) {
|
|
29
|
+
const { deps, input } = required;
|
|
30
|
+
const resolvePlugin = deps.resolveInstalledPlugin;
|
|
31
|
+
let plugin;
|
|
32
|
+
try {
|
|
33
|
+
plugin = await resolvePlugin(input.pluginId);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return "unsupported";
|
|
37
|
+
}
|
|
38
|
+
const auth = plugin ? soleTokenAuth(plugin.servers) : null;
|
|
39
|
+
if (!auth)
|
|
40
|
+
return "unsupported";
|
|
41
|
+
return probeToken({ probeUrl: auth.probeUrl, token: input.token, credentials: deps.credentials, tokenValidator: deps.tokenValidator });
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=token-sign-in.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** Explicit unrelated namespaces retain their isolation; omitted names select portable metadata. */
|
|
2
|
+
export declare function isPortableAgentPluginNamespace({ namespace }: {
|
|
3
|
+
readonly namespace?: string | undefined;
|
|
4
|
+
}, _optional?: {}): boolean;
|
|
1
5
|
/** Selects the portable identity key without changing explicit host isolation.
|
|
2
6
|
* Legacy manifests remain readable only when no namespace was requested and `jini` is absent.
|
|
3
7
|
* A present malformed extension is left to the identity validator rather than bypassed.
|
|
@@ -9,4 +13,39 @@ export declare function resolveAgentPluginIdentityNamespace({ value }: {
|
|
|
9
13
|
}, { identityNamespace }?: {
|
|
10
14
|
readonly identityNamespace?: string;
|
|
11
15
|
}): string;
|
|
16
|
+
/** Existing installed copies remain readable through at least this date; removal requires an
|
|
17
|
+
* explicit release decision, never a clock-based refusal to load a plugin. */
|
|
18
|
+
export declare const legacyAgentPluginMetadataWarning = "Legacy extensions.tovu agent-plugin metadata is deprecated; compatibility is retained through at least 2027-05-06. Portable packages use extensions.jini and unprefixed MCP metadata.";
|
|
19
|
+
/** Select an extension without requiring a complete manifest, for preboot metadata readers.
|
|
20
|
+
* @complexity O(1); no I/O or mutation. */
|
|
21
|
+
export declare function readAgentPluginPortableExtension(required: {
|
|
22
|
+
readonly value: unknown;
|
|
23
|
+
}, optional?: {
|
|
24
|
+
readonly identityNamespace?: string;
|
|
25
|
+
}): Readonly<Record<string, unknown>> | undefined;
|
|
26
|
+
/** Diagnostics are returned to the host so it can choose its normal warning surface. */
|
|
27
|
+
export declare function readAgentPluginCompatibilityWarnings(required: {
|
|
28
|
+
readonly value: unknown;
|
|
29
|
+
}, optional?: {
|
|
30
|
+
readonly identityNamespace?: string;
|
|
31
|
+
}): readonly string[];
|
|
32
|
+
/** Lifecycle host names identify effects and packaging; portable metadata remains portable.
|
|
33
|
+
* A declared canonical key wins; explicit custom metadata keeps its isolation from legacy keys.
|
|
34
|
+
* A valid legacy object remains the fallback for hosts without their own declaration. */
|
|
35
|
+
export declare function resolveAgentPluginLifecycleNamespace({ value, extensionNamespace }: {
|
|
36
|
+
readonly value: unknown;
|
|
37
|
+
readonly extensionNamespace: string;
|
|
38
|
+
}, _optional?: {}): string;
|
|
39
|
+
/** Translate installed legacy MCP entries without granting read trust from transport data.
|
|
40
|
+
* Portable names take precedence even when malformed, leaving validation to the shared parser.
|
|
41
|
+
* @complexity O(k), bounded by the default-tools declaration. */
|
|
42
|
+
export declare function readCompatibleAgentPluginServerMetadata({ value, server }: {
|
|
43
|
+
readonly value: Readonly<Record<string, unknown>>;
|
|
44
|
+
readonly server: Readonly<Record<string, unknown>>;
|
|
45
|
+
}, _optional?: {}): Readonly<Record<string, unknown>>;
|
|
46
|
+
/** Whether compatibility aliases were read, for the MCP parser's returned diagnostics. */
|
|
47
|
+
export declare function hasLegacyAgentPluginServerMetadata({ value, server }: {
|
|
48
|
+
readonly value: Readonly<Record<string, unknown>>;
|
|
49
|
+
readonly server: Readonly<Record<string, unknown>>;
|
|
50
|
+
}, _optional?: {}): boolean;
|
|
12
51
|
//# sourceMappingURL=identity-namespace.d.ts.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
2
|
+
/** Explicit unrelated namespaces retain their isolation; omitted names select portable metadata. */
|
|
3
|
+
export function isPortableAgentPluginNamespace({ namespace }, _optional = {}) {
|
|
4
|
+
return namespace === undefined || namespace === 'jini' || namespace === 'tovu';
|
|
5
|
+
}
|
|
1
6
|
/** Selects the portable identity key without changing explicit host isolation.
|
|
2
7
|
* Legacy manifests remain readable only when no namespace was requested and `jini` is absent.
|
|
3
8
|
* A present malformed extension is left to the identity validator rather than bypassed.
|
|
@@ -5,16 +10,69 @@
|
|
|
5
10
|
* @complexity O(1) time and space; no I/O or manifest mutation.
|
|
6
11
|
*/
|
|
7
12
|
export function resolveAgentPluginIdentityNamespace({ value }, { identityNamespace } = {}) {
|
|
13
|
+
// The legacy key names the same portable metadata, so a declared canonical `jini` copy wins.
|
|
14
|
+
if (identityNamespace === 'tovu' && isObject(value) && isObject(value.extensions) && Object.hasOwn(value.extensions, 'jini'))
|
|
15
|
+
return 'jini';
|
|
8
16
|
if (identityNamespace !== undefined)
|
|
9
17
|
return identityNamespace;
|
|
10
|
-
if (
|
|
18
|
+
if (!isObject(value) || !isObject(value.extensions))
|
|
11
19
|
return 'jini';
|
|
12
20
|
const extensions = value.extensions;
|
|
13
|
-
if (typeof extensions !== 'object' || extensions === null || Array.isArray(extensions))
|
|
14
|
-
return 'jini';
|
|
15
21
|
if (Object.hasOwn(extensions, 'jini'))
|
|
16
22
|
return 'jini';
|
|
17
23
|
// Compatibility only: existing published manifests used this product's extension key.
|
|
18
24
|
return Object.hasOwn(extensions, 'tovu') ? 'tovu' : 'jini';
|
|
19
25
|
}
|
|
26
|
+
/** Existing installed copies remain readable through at least this date; removal requires an
|
|
27
|
+
* explicit release decision, never a clock-based refusal to load a plugin. */
|
|
28
|
+
export const legacyAgentPluginMetadataWarning = 'Legacy extensions.tovu agent-plugin metadata is deprecated; compatibility is retained through at least 2027-05-06. Portable packages use extensions.jini and unprefixed MCP metadata.';
|
|
29
|
+
/** Select an extension without requiring a complete manifest, for preboot metadata readers.
|
|
30
|
+
* @complexity O(1); no I/O or mutation. */
|
|
31
|
+
export function readAgentPluginPortableExtension(required, optional = {}) {
|
|
32
|
+
const namespace = resolveAgentPluginIdentityNamespace(required, optional);
|
|
33
|
+
const value = required.value;
|
|
34
|
+
if (!isObject(value) || !isObject(value.extensions) || !Object.hasOwn(value.extensions, namespace))
|
|
35
|
+
return undefined;
|
|
36
|
+
const extension = value.extensions[namespace];
|
|
37
|
+
return isObject(extension) ? extension : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Diagnostics are returned to the host so it can choose its normal warning surface. */
|
|
40
|
+
export function readAgentPluginCompatibilityWarnings(required, optional = {}) {
|
|
41
|
+
return isPortableAgentPluginNamespace({ namespace: optional.identityNamespace }) && resolveAgentPluginIdentityNamespace(required, optional) === 'tovu'
|
|
42
|
+
? [legacyAgentPluginMetadataWarning] : [];
|
|
43
|
+
}
|
|
44
|
+
/** Lifecycle host names identify effects and packaging; portable metadata remains portable.
|
|
45
|
+
* A declared canonical key wins; explicit custom metadata keeps its isolation from legacy keys.
|
|
46
|
+
* A valid legacy object remains the fallback for hosts without their own declaration. */
|
|
47
|
+
export function resolveAgentPluginLifecycleNamespace({ value, extensionNamespace }, _optional = {}) {
|
|
48
|
+
if (!isObject(value) || !isObject(value.extensions))
|
|
49
|
+
return extensionNamespace;
|
|
50
|
+
const extensions = value.extensions;
|
|
51
|
+
if (Object.hasOwn(extensions, 'jini'))
|
|
52
|
+
return 'jini';
|
|
53
|
+
if (!isPortableAgentPluginNamespace({ namespace: extensionNamespace }) && (Object.hasOwn(extensions, extensionNamespace) || !isObject(extensions.tovu)))
|
|
54
|
+
return extensionNamespace;
|
|
55
|
+
return Object.hasOwn(extensions, 'tovu') ? 'tovu' : extensionNamespace;
|
|
56
|
+
}
|
|
57
|
+
/** Translate installed legacy MCP entries without granting read trust from transport data.
|
|
58
|
+
* Portable names take precedence even when malformed, leaving validation to the shared parser.
|
|
59
|
+
* @complexity O(k), bounded by the default-tools declaration. */
|
|
60
|
+
export function readCompatibleAgentPluginServerMetadata({ value, server }, _optional = {}) {
|
|
61
|
+
return Object.fromEntries(['authMode', 'defaultTools', 'tokenAuth', 'renamedTools'].map(key => {
|
|
62
|
+
const legacyKey = `tovu${key[0].toUpperCase()}${key.slice(1)}`;
|
|
63
|
+
// Legacy adapters treated null aliases as absent; canonical null stays malformed.
|
|
64
|
+
const declared = value[key] !== undefined ? value[key] : value[legacyKey] ?? undefined;
|
|
65
|
+
const inline = server[key] !== undefined ? server[key] : server[legacyKey];
|
|
66
|
+
return [key, declared !== undefined ? declared : inlineMetadata({ key, value: inline })];
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
/** Whether compatibility aliases were read, for the MCP parser's returned diagnostics. */
|
|
70
|
+
export function hasLegacyAgentPluginServerMetadata({ value, server }, _optional = {}) {
|
|
71
|
+
return ['tovuAuthMode', 'tovuDefaultTools', 'tovuTokenAuth', 'tovuRenamedTools'].some(key => Object.hasOwn(value, key) || Object.hasOwn(server, key));
|
|
72
|
+
}
|
|
73
|
+
/** Transport declarations keep sign-in defaults, but reviewed reads require plugin.json metadata. */
|
|
74
|
+
function inlineMetadata({ key, value }) {
|
|
75
|
+
return key === 'defaultTools' && isObject(value)
|
|
76
|
+
? Object.fromEntries(Object.entries(value).filter(([name]) => name !== 'read')) : value;
|
|
77
|
+
}
|
|
20
78
|
//# sourceMappingURL=identity-namespace.js.map
|
package/dist/folder-zip-node.js
CHANGED
|
@@ -3,6 +3,7 @@ import { constants } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FOLDER_MAX_FILES, FOLDER_UNREADABLE, FolderZipError, zipFolderFiles } from "./folder-zip.js";
|
|
5
5
|
import { isAgentPluginName } from './core/plugin-name.js';
|
|
6
|
+
import { readAgentPluginPortableExtension } from './core/identity-namespace.js';
|
|
6
7
|
/** Code-unit order, independent of locale. */
|
|
7
8
|
function compareCodeUnits(a, b) {
|
|
8
9
|
if (a === b)
|
|
@@ -156,7 +157,8 @@ function customizeManifest({ text, name, identityNamespace }) {
|
|
|
156
157
|
if (!isPlainObject(manifest.extensions))
|
|
157
158
|
throw new FolderZipError('unreadable', 'plugin.json extensions must be an object.');
|
|
158
159
|
const localId = `local/${name}`;
|
|
159
|
-
|
|
160
|
+
// Creating the portable key must preserve the installed copy's capabilities and display copy.
|
|
161
|
+
manifest.extensions[identityNamespace] ??= identityNamespace === 'jini' ? { ...readAgentPluginPortableExtension({ value: manifest }) } : {};
|
|
160
162
|
sanitizeHostIdentities({ extensions: manifest.extensions, localId });
|
|
161
163
|
const host = manifest.extensions[identityNamespace];
|
|
162
164
|
if (isPlainObject(host))
|
|
@@ -9,6 +9,7 @@ export interface ChatAgentPluginState {
|
|
|
9
9
|
decision: {
|
|
10
10
|
selected: readonly string[];
|
|
11
11
|
asked?: boolean;
|
|
12
|
+
delivered?: readonly string[];
|
|
12
13
|
} | null;
|
|
13
14
|
excluded: readonly string[];
|
|
14
15
|
}
|
|
@@ -19,7 +20,7 @@ export interface AutomaticAgentPluginMatch {
|
|
|
19
20
|
}
|
|
20
21
|
/** Explicit loads report admission separately from guidance; only real delivery is `loaded`. */
|
|
21
22
|
export interface AutomaticAgentPluginLoadResult {
|
|
22
|
-
status: 'loaded' | 'installed-but-inactive' | 'excluded' | 'untrusted' | 'missing' | '
|
|
23
|
+
status: 'loaded' | 'installed-but-inactive' | 'excluded' | 'untrusted' | 'missing' | 'off' | 'cancelled' | 'unavailable';
|
|
23
24
|
/** Delivered content, or the resolver's safe refusal for an explicit skill/file request. */
|
|
24
25
|
guidance: string;
|
|
25
26
|
}
|
|
@@ -53,6 +54,13 @@ export interface AutomaticAgentPluginPorts {
|
|
|
53
54
|
}[];
|
|
54
55
|
}, options?: Record<string, never>): Promise<void>;
|
|
55
56
|
}
|
|
57
|
+
type PrepareInput = {
|
|
58
|
+
maxPromptArgBytes?: number;
|
|
59
|
+
query?: string;
|
|
60
|
+
capabilities?: readonly string[];
|
|
61
|
+
loaded?: readonly string[];
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
};
|
|
56
64
|
/** Validate the request's small browser state; malformed state means no previous decision.
|
|
57
65
|
* @returns A fresh state; no caller input is mutated. @complexity O(n) in saved identities.
|
|
58
66
|
*/
|
|
@@ -70,13 +78,9 @@ export declare function createAutomaticAgentPluginUse({ mode, state: initialStat
|
|
|
70
78
|
state?: ChatAgentPluginState | undefined;
|
|
71
79
|
ports: AutomaticAgentPluginPorts;
|
|
72
80
|
}, _options?: {}): {
|
|
81
|
+
guidanceIds: (_required: Record<string, never>, _options?: {}) => string[];
|
|
73
82
|
/** Suggest relevant metadata for a query; capability calls load only their providers. */
|
|
74
|
-
prepare: (input: {
|
|
75
|
-
query?: string;
|
|
76
|
-
capabilities?: readonly string[];
|
|
77
|
-
loaded?: readonly string[];
|
|
78
|
-
signal?: AbortSignal;
|
|
79
|
-
}, _options?: {}) => Promise<string>;
|
|
83
|
+
prepare: (input: PrepareInput, _options?: {}) => Promise<string>;
|
|
80
84
|
/** Resolve one active, permitted id and publish usage only after real guidance is read.
|
|
81
85
|
* Returns a concrete status and delivered content or a safe explicit-request refusal.
|
|
82
86
|
* @example await controller.load({ pluginId: 'my-plugin' });
|
|
@@ -86,4 +90,5 @@ export declare function createAutomaticAgentPluginUse({ mode, state: initialStat
|
|
|
86
90
|
signal?: AbortSignal;
|
|
87
91
|
} & AgentPluginSkillRequest, _options?: {}) => Promise<AutomaticAgentPluginLoadResult>;
|
|
88
92
|
};
|
|
93
|
+
export {};
|
|
89
94
|
//# sourceMappingURL=automatic-use.d.ts.map
|