@jini-ai/agent-plugins 0.7.3-next.2 → 0.7.3-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/calendly/README.md +29 -0
- package/calendly/mcp.json +1 -1
- package/cloudflare/lib/assets.mjs +1 -1
- package/cloudflare/lib/cms-forms.mjs +1 -1
- package/core/persistent-state.d.ts +4 -1
- package/core/persistent-state.js +55 -21
- package/dist/admin-surfaces/callback-field-inbox.d.ts +1 -6
- package/dist/admin-surfaces/connections/connections.d.ts +2 -6
- package/dist/admin-surfaces/connections/index.d.ts +3 -2
- package/dist/admin-surfaces/index.d.ts +3 -1
- package/dist/connect/access-token-tool.d.ts +1 -1
- package/dist/connect/access-token-tool.js +1 -1
- package/dist/connect/catalog.d.ts +26 -0
- package/dist/connect/catalog.js +42 -0
- package/dist/connect/connect-tool.d.ts +2 -294
- package/dist/connect/connect-tool.js +2 -53
- package/dist/connect/contracts.d.ts +257 -0
- package/dist/connect/contracts.js +2 -0
- package/dist/connect/credential-cards.d.ts +2 -0
- package/dist/connect/credential-cards.js +7 -4
- package/dist/connect/grant-signed-in-defaults.js +1 -1
- package/dist/connect/host-deps.d.ts +32 -0
- package/dist/connect/host-deps.js +35 -0
- package/dist/connect/import-access-token.js +1 -1
- package/dist/connect/index.d.ts +7 -2
- package/dist/connect/index.js +5 -2
- package/dist/connect/installed-plugin.d.ts +28 -0
- package/dist/connect/installed-plugin.js +19 -0
- package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
- package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
- package/dist/connect/plugin-host/index.d.ts +1 -2
- package/dist/connect/plugin-host/index.js +18 -9
- package/dist/connect/token-sign-in.d.ts +1 -14
- package/dist/connect/token-sign-in.js +4 -23
- package/dist/core/export-props.d.ts +10 -0
- package/dist/core/export-props.js +31 -0
- package/dist/core/folder-zip-error.d.ts +5 -0
- package/dist/core/folder-zip-error.js +8 -0
- package/dist/core/host-incompatible-error.d.ts +8 -0
- package/dist/core/host-incompatible-error.js +9 -0
- package/dist/core/identity-namespace.d.ts +27 -16
- package/dist/core/identity-namespace.js +25 -22
- package/dist/core/plugin-display-name.d.ts +7 -0
- package/dist/core/plugin-display-name.js +11 -0
- package/dist/core/provider-plugin-link.d.ts +7 -0
- package/dist/core/provider-plugin-link.js +5 -0
- package/dist/{connect → core}/token-map.d.ts +11 -1
- package/dist/{connect → core}/token-map.js +15 -0
- package/dist/core/token-sign-in-list.d.ts +18 -0
- package/dist/core/token-sign-in-list.js +23 -0
- package/dist/core/update-error.d.ts +8 -0
- package/dist/core/update-error.js +9 -0
- package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
- package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
- package/dist/ffmpeg-transcode/adapter.js +155 -0
- package/dist/folder-zip-node.d.ts +2 -1
- package/dist/folder-zip-node.js +6 -5
- package/dist/folder-zip.d.ts +0 -4
- package/dist/folder-zip.js +1 -7
- package/dist/index.d.ts +3 -1
- package/dist/lifecycle/activation.d.ts +39 -3
- package/dist/lifecycle/activation.js +467 -418
- package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
- package/dist/lifecycle/automatic-use-offer.js +52 -0
- package/dist/lifecycle/automatic-use.d.ts +33 -1
- package/dist/lifecycle/automatic-use.js +157 -38
- package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
- package/dist/lifecycle/capability-projection.d.ts +0 -1
- package/dist/lifecycle/capability-projection.js +92 -23
- package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
- package/dist/lifecycle/compatibility-metadata.js +6 -1
- package/dist/lifecycle/compatibility.d.ts +1 -8
- package/dist/lifecycle/compatibility.js +1 -8
- package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
- package/dist/lifecycle/exports.d.ts +2 -45
- package/dist/lifecycle/exports.js +1 -30
- package/dist/lifecycle/host-tools/identity.d.ts +5 -4
- package/dist/lifecycle/host-tools/identity.js +5 -5
- package/dist/lifecycle/host-tools/ports.d.ts +10 -1
- package/dist/lifecycle/host-tools/search-tool.js +18 -8
- package/dist/lifecycle/host-tools/skill-tool.js +1 -1
- package/dist/lifecycle/index.d.ts +20 -17
- package/dist/lifecycle/index.js +5 -4
- package/dist/lifecycle/install-from-url.d.ts +1 -2
- package/dist/lifecycle/install.d.ts +4 -34
- package/dist/lifecycle/install.js +3 -3
- package/dist/lifecycle/installed-package-index.d.ts +1 -1
- package/dist/lifecycle/installed-package-index.js +4 -4
- package/dist/lifecycle/layout.d.ts +21 -25
- package/dist/lifecycle/layout.js +79 -0
- package/dist/lifecycle/manifest.d.ts +10 -7
- package/dist/lifecycle/manifest.js +20 -15
- package/dist/lifecycle/mcp-provisioning.d.ts +1 -1
- package/dist/lifecycle/metadata.d.ts +6 -3
- package/dist/lifecycle/metadata.js +2 -1
- package/dist/lifecycle/package-paths.js +59 -56
- package/dist/lifecycle/persistent-state.d.ts +10 -1
- package/dist/lifecycle/persistent-state.js +4 -2
- package/dist/lifecycle/ports.d.ts +18 -6
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -14
- package/dist/lifecycle/retire-bundled.d.ts +1 -1
- package/dist/lifecycle/search-projection.d.ts +3 -1
- package/dist/lifecycle/search-projection.js +7 -3
- package/dist/lifecycle/search.d.ts +1 -0
- package/dist/lifecycle/seed-bundled.d.ts +86 -1
- package/dist/lifecycle/seed-bundled.js +48 -84
- package/dist/lifecycle/set-enabled.d.ts +1 -13
- package/dist/lifecycle/set-enabled.js +11 -7
- package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
- package/dist/lifecycle/trusted-plugin-files.js +33 -30
- package/dist/lifecycle/types.d.ts +13 -34
- package/dist/lifecycle/uninstall.d.ts +1 -33
- package/dist/lifecycle/update-store.d.ts +0 -7
- package/dist/lifecycle/update-store.js +1 -8
- package/dist/lifecycle/update.d.ts +1 -1
- package/dist/lifecycle/update.js +60 -10
- package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
- package/dist/lifecycle/yauzl-archive-reader.js +11 -6
- package/dist/manifest.d.ts +4 -8
- package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
- package/dist/react/AgentPluginDetailsModal.js +29 -0
- package/dist/react/agent-plugin-install-port.d.ts +24 -0
- package/dist/react/agent-plugin-install-port.js +15 -0
- package/dist/react/installed-skills-composer-source.d.ts +60 -0
- package/dist/react/installed-skills-composer-source.js +111 -0
- package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
- package/dist/react/use-agent-plugins.hooks.js +128 -0
- package/dist/site/activation-effects.d.ts +17 -0
- package/dist/site/activation-effects.js +31 -0
- package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
- package/dist/site/admin-surfaces/capabilities.js +30 -0
- package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
- package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
- package/dist/site/admin-surfaces/forms.d.ts +28 -0
- package/dist/site/admin-surfaces/forms.js +29 -0
- package/dist/site/admin-surfaces/handlers.d.ts +61 -0
- package/dist/site/admin-surfaces/handlers.js +35 -0
- package/dist/site/admin-surfaces/public-config.d.ts +12 -0
- package/dist/site/admin-surfaces/public-config.js +28 -0
- package/dist/site/analytics-provider-registry.d.ts +87 -0
- package/dist/site/analytics-provider-registry.js +87 -0
- package/dist/site/archive-reader-abi.d.ts +35 -0
- package/dist/site/archive-reader-abi.js +25 -0
- package/dist/site/auth-schemes.d.ts +110 -0
- package/dist/site/auth-schemes.js +119 -0
- package/dist/site/automatic-agent-plugins.d.ts +200 -0
- package/dist/site/automatic-agent-plugins.js +277 -0
- package/dist/site/bundled-contribution-sources.d.ts +24 -0
- package/dist/site/bundled-contribution-sources.js +17 -0
- package/dist/site/bundled-id-upgrade.d.ts +115 -0
- package/dist/site/bundled-id-upgrade.js +169 -0
- package/dist/site/customize-tool.d.ts +39 -0
- package/dist/site/customize-tool.js +31 -0
- package/dist/site/deploy-split-activation.d.ts +28 -0
- package/dist/site/deploy-split-activation.js +21 -0
- package/dist/site/exports/diagnostics.d.ts +37 -0
- package/dist/site/exports/diagnostics.js +55 -0
- package/dist/site/exports/runtime.d.ts +54 -0
- package/dist/site/exports/runtime.js +196 -0
- package/dist/site/exports/source.d.ts +42 -0
- package/dist/site/exports/source.js +58 -0
- package/dist/site/host-plugin-guidance.d.ts +137 -0
- package/dist/site/host-plugin-guidance.js +223 -0
- package/dist/site/host-signals.d.ts +78 -0
- package/dist/site/host-signals.js +83 -0
- package/dist/site/install-tool.d.ts +69 -0
- package/dist/site/install-tool.js +192 -0
- package/dist/site/install-upload.d.ts +175 -0
- package/dist/site/install-upload.js +324 -0
- package/dist/site/memory-i18n.d.ts +5 -0
- package/dist/site/memory-i18n.js +176 -0
- package/dist/site/memory.d.ts +80 -0
- package/dist/site/memory.js +83 -0
- package/dist/site/plugin-memory.d.ts +80 -0
- package/dist/site/plugin-memory.js +86 -0
- package/dist/site/provider-plugin-link.d.ts +112 -0
- package/dist/site/provider-plugin-link.js +100 -0
- package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
- package/dist/site/retired-plugin-tool-aliases.js +41 -0
- package/dist/site/service-ports.d.ts +108 -0
- package/dist/site/service-ports.js +2 -0
- package/dist/site/set-enabled.d.ts +80 -0
- package/dist/site/set-enabled.js +42 -0
- package/dist/site/soon-lock.d.ts +83 -0
- package/dist/site/soon-lock.js +78 -0
- package/dist/site/supersession.d.ts +61 -0
- package/dist/site/supersession.js +122 -0
- package/dist/site/uninstall-tool.d.ts +136 -0
- package/dist/site/uninstall-tool.js +203 -0
- package/dist/site/update-effects.d.ts +47 -0
- package/dist/site/update-effects.js +49 -0
- package/ffmpeg-transcode/plugin.json +16 -0
- package/github/source-control/backup-push.mjs +66 -46
- package/github/source-control/commit-site.mjs +112 -65
- package/github/source-control/write-files.mjs +86 -53
- package/github-pages/targets/github-pages.mjs +294 -233
- package/google-workspace/form-destinations/mapping.mjs +15 -7
- package/google-workspace/form-destinations/sheets.mjs +4 -2
- package/google-workspace/plugin.json +1 -0
- package/kuinetic/CHANGELOG.md +4 -0
- package/kuinetic/plugin.json +4 -1
- package/kuinetic/skills/kuinetic/SKILL.md +1 -2
- package/package.json +295 -18
- package/persistent-state.d.ts +4 -1
- package/resend/adapters/resend.mjs +5 -2
- package/resend/plugin.json +1 -1
- package/s3-compatible/jini-deploy-targets.json +1 -1
- package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
- package/s3-compatible/targets/s3-compatible.mjs +3 -3
- package/site-import/plugin.json +3 -3
- package/site-import/skills/site-import/SKILL.md +62 -54
- package/site-import/skills/site-import/references/content-mapping.md +26 -20
- package/slide-design/plugin.json +1 -1
- package/slide-design/skills/slide-design/SKILL.md +8 -2
- package/ui-ux-design/CHANGELOG.md +6 -0
- package/ui-ux-design/plugin.json +1 -1
- package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
- package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
- package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
- package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
- package/vercel/NOTES.md +2 -1
- package/vercel/object-stores/vercel-blob.mjs +3 -4
- package/vercel/targets/vercel.mjs +425 -351
- package/core/commerce-server.d.ts +0 -2
- package/core/commerce-server.mjs +0 -2
- package/dist/admin-surfaces/connections/ports.d.ts +0 -110
- package/dist/admin-surfaces/connections/ports.js +0 -2
- /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
- /package/dist/{lifecycle → core}/install-errors.js +0 -0
- /package/dist/{lifecycle → core}/update-plan.js +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { isAbortError } from '@jini-ai/core/text';
|
|
2
|
+
const INSTALLED_SKILLS_GROUP_ID = "installed-skills";
|
|
3
|
+
const INSTALLED_SKILLS_GROUP_LABEL = "Installed Skills";
|
|
4
|
+
/** See this file's own module doc: the one prefix guaranteed not to collide with the bundled
|
|
5
|
+
* catalog's `skill:` entries. */
|
|
6
|
+
const INSTALLED_SKILL_ID_PREFIX = "installed-skill:";
|
|
7
|
+
function skillsSnapshotFromBody({ body, cached, etag }, _options = {}) {
|
|
8
|
+
if (!Array.isArray(body.skills))
|
|
9
|
+
throw new TypeError("Installed skills response must contain a skills array");
|
|
10
|
+
if (cached?.etag && etag === cached.etag)
|
|
11
|
+
return cached;
|
|
12
|
+
return { etag, capabilities: body.skills.filter(isInstalledSkillSummary).filter(s => s.enabled !== false).map(toCapability) };
|
|
13
|
+
}
|
|
14
|
+
/** Reuse authenticated transport and translate only its 304 error into the exact cached snapshot.
|
|
15
|
+
* Invalid bodies and failures throw, so they never become successful cache entries.
|
|
16
|
+
* @complexity O(n) time/space for n summaries; one request, no guidance bodies cached.
|
|
17
|
+
*/
|
|
18
|
+
async function readSkillsSnapshot({ request, path, isNotModified, cached }, _options = {}) {
|
|
19
|
+
let etag;
|
|
20
|
+
try {
|
|
21
|
+
const body = await request({ path, method: "GET" }, {
|
|
22
|
+
headers: cached?.etag ? { "If-None-Match": cached.etag } : {},
|
|
23
|
+
onOk: ({ response }, _optional = {}) => { etag = response.headers?.get("ETag") ?? undefined; },
|
|
24
|
+
});
|
|
25
|
+
return skillsSnapshotFromBody({ body, cached, etag });
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (isNotModified(error) && cached)
|
|
29
|
+
return cached;
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function isInstalledSkillSummary(value) {
|
|
34
|
+
if (typeof value !== "object" || value === null)
|
|
35
|
+
return false;
|
|
36
|
+
const summary = value;
|
|
37
|
+
return typeof summary.toolId === "string" && typeof summary.name === "string" && typeof summary.description === "string";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Turns one wire summary into a discoverable, actionable composer row.
|
|
41
|
+
*
|
|
42
|
+
* `insertText: ""`, not omitted: an absent `insertText` on the slash-trigger path falls back to
|
|
43
|
+
* `label`, typing the skill's bare name into the draft with no instruction to act on it — the
|
|
44
|
+
* exact trap `composer-capabilities.ts` documents fixing on 2026-08-21. The `resolve` binding
|
|
45
|
+
* below loads the agent guidance behind the chip.
|
|
46
|
+
*/
|
|
47
|
+
function toCapability(summary) {
|
|
48
|
+
return {
|
|
49
|
+
groupId: INSTALLED_SKILLS_GROUP_ID,
|
|
50
|
+
groupLabel: INSTALLED_SKILLS_GROUP_LABEL,
|
|
51
|
+
item: {
|
|
52
|
+
id: `${INSTALLED_SKILL_ID_PREFIX}${summary.toolId}`,
|
|
53
|
+
label: summary.name,
|
|
54
|
+
description: summary.description,
|
|
55
|
+
kind: "skill",
|
|
56
|
+
keywords: ["skill", summary.name],
|
|
57
|
+
insertText: "",
|
|
58
|
+
},
|
|
59
|
+
resolve: () => ({ kind: "installed-skill", toolId: summary.toolId }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Builds a {@link ComposerCapabilitySource} backed by the installed-Skills route.
|
|
64
|
+
*
|
|
65
|
+
* Degrades to an empty list on ANY failure — non-2xx, network error, or a body that isn't the
|
|
66
|
+
* expected `{skills: [...]}` shape — rather than throwing. Load-bearing, not defensive polish
|
|
67
|
+
* (INV-001): `projectComposerCapabilities` awaits every source's `list()` through one
|
|
68
|
+
* `Promise.all`, so a single REJECTING source takes the WHOLE projection down with it, including
|
|
69
|
+
* the bundled catalog's always-available `/search` and `/mcp` rows. A workspace with zero
|
|
70
|
+
* installed skills, an unauthorized session, or a route that 500s on a duplicate-frontmatter-name
|
|
71
|
+
* conflict must cost this one capability — never the rest of the composer.
|
|
72
|
+
*
|
|
73
|
+
* @param _input - No required inputs; defaults preserve the existing no-argument callers.
|
|
74
|
+
* @param options.request - Authenticated request port, replaceable for direct failure-path tests.
|
|
75
|
+
* @returns A source whose list uses its cache; reload conditionally revalidates. Force supersedes
|
|
76
|
+
* pending work but still sends the validator. Failures resolve to the last good list (else empty); aborts are silent.
|
|
77
|
+
* @example createInstalledSkillsComposerCapabilitySource().list();
|
|
78
|
+
* @complexity Cached reads O(1); revalidation O(n) time/space for n installed skills, one request.
|
|
79
|
+
*/
|
|
80
|
+
export function createInstalledSkillsComposerCapabilitySource({ request, path, isNotModified, reportFailure }, _optional = {}) {
|
|
81
|
+
let cached;
|
|
82
|
+
let pending;
|
|
83
|
+
let generation = 0;
|
|
84
|
+
/** Revalidate once per pending request; force prevents pre-event work from publishing a cache. */
|
|
85
|
+
const reload = (_required = {}, { force = false } = {}) => {
|
|
86
|
+
if (pending && !force)
|
|
87
|
+
return pending;
|
|
88
|
+
generation += 1;
|
|
89
|
+
const current = generation;
|
|
90
|
+
pending = readSkillsSnapshot({ request, path, isNotModified, cached }).then(snapshot => {
|
|
91
|
+
if (current === generation)
|
|
92
|
+
cached = snapshot;
|
|
93
|
+
return snapshot.capabilities;
|
|
94
|
+
}).catch(error => {
|
|
95
|
+
// Leaving the page cancels the shared transport; it does not mean skill enumeration failed.
|
|
96
|
+
// Every failure costs this capability alone: Promise.all must retain the bundled catalog.
|
|
97
|
+
// A failed 60 s revalidation keeps the last good list rather than blanking typed skills.
|
|
98
|
+
if (!isAbortError({ error }))
|
|
99
|
+
reportFailure("[installed-skills-composer-source] installed-skills enumeration failed; falling back to the bundled catalog only", error);
|
|
100
|
+
return cached?.capabilities ?? [];
|
|
101
|
+
}).finally(() => { if (current === generation)
|
|
102
|
+
pending = undefined; });
|
|
103
|
+
return pending;
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
id: "installed-skills",
|
|
107
|
+
list: () => cached ? Promise.resolve(cached.capabilities) : reload(),
|
|
108
|
+
reload,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=installed-skills-composer-source.js.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { AdminHttpError } from "@jini-ai/core/admin-runtime";
|
|
2
|
+
import type { AdminSurfaceAction } from "@jini-ai/core/contracts/site/agent-plugins-admin-surfaces";
|
|
3
|
+
import type { FetchQueryAdapter } from "@jini-ai/core/fetch";
|
|
4
|
+
import { type Translate } from '@jini-ai/core/text';
|
|
5
|
+
/**
|
|
6
|
+
* @file State for the Agent Plugins screen, so `AgentPlugins.tsx` is only markup — same split as
|
|
7
|
+
* this directory's own `use-plugins.hooks.ts` (`Plugins.tsx`'s hook).
|
|
8
|
+
*
|
|
9
|
+
* REWRITTEN 2026-09-09: this hook used to return the static, checked-in `BUNDLED_AGENT_PLUGINS`
|
|
10
|
+
* constant with no I/O at all (the module's own prior header said so explicitly: "a port would be
|
|
11
|
+
* ceremony with nothing to inject"). That premise is gone — `AGENT_PLUGINS_LIST`
|
|
12
|
+
* (`server/inbound/admin-http/routes/agent-plugins/list.ts`) now exists, so this hook has a real
|
|
13
|
+
* host boundary to inject, and gets the same `port` (`AgentPluginsPort`) / `useX(dependencies)` /
|
|
14
|
+
* `useWiredX()` split `use-plugins.hooks.ts` already uses for this feature's sibling screen.
|
|
15
|
+
*
|
|
16
|
+
* EXTENDED 2026-09-09 (visual redesign): `onToggleEnabled` wires the row's enable/disable switch to
|
|
17
|
+
* `AGENT_PLUGIN_SET_ENABLED`. That is a real activation write — `resolveAgentPluginRefs()` refuses a
|
|
18
|
+
* run pinning a disabled plugin — so the switch's rendered position must always be server truth,
|
|
19
|
+
* never an optimistic guess. See {@link useAgentPlugins}'s own `@tradeoffs`.
|
|
20
|
+
*
|
|
21
|
+
* `describeApiError` here is the shared default from `lib/api.ts`, not this feature's
|
|
22
|
+
* `rules.ts` override — that override's `PLUGIN_NOT_FOUND`/`PLUGIN_INVALID`/`PLUGIN_INCOMPATIBLE`
|
|
23
|
+
* codes belong to the `.host-plugin` enable/disable route this screen does not call. This screen's
|
|
24
|
+
* own route answers `AGENT_PLUGIN_NOT_FOUND`/`VALIDATION_ERROR`, neither of which that override
|
|
25
|
+
* knows, so the shared default (which surfaces the server's own message) is the better fit.
|
|
26
|
+
*
|
|
27
|
+
* `t` (standing i18n rule, 2026-08-11): resolved from `useAdminLocale()` in `useWiredAgentPlugins`
|
|
28
|
+
* and returned as a bound `t`, rather than `AgentPlugins.tsx` calling `useAdminLocale()`/
|
|
29
|
+
* `translatePlugins` directly.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* HTTP presentation projection; installation paths/digests never enter the browser.
|
|
33
|
+
* Restated from the plugin lifecycle's `InstalledAgentPlugin` (only the fields the screen reads) so admin owns its
|
|
34
|
+
* plugin-list port; `__tests__/installed-plugin-fit.typecheck.ts` fails to compile when the lifecycle's types drift.
|
|
35
|
+
*/
|
|
36
|
+
interface AgentPluginSummary {
|
|
37
|
+
readonly pluginId: string;
|
|
38
|
+
readonly version: string | null;
|
|
39
|
+
readonly description: string | null;
|
|
40
|
+
readonly keywords: readonly string[];
|
|
41
|
+
readonly skills: readonly {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly summary: string;
|
|
44
|
+
}[];
|
|
45
|
+
readonly mcpServerIds: readonly string[];
|
|
46
|
+
readonly enabled: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** One row of `GET .../agent-plugins` as the host's screen reads it: {@link AgentPluginSummary} plus the optional
|
|
49
|
+
* host-owned lifecycle/account fields. `version`/`description` are nullable, not optional-absent: the wire always
|
|
50
|
+
* sends the key, `null` when the package's own manifest carries none. Agent Plugins (agent-plugins.org packages) are
|
|
51
|
+
* a DIFFERENT family from the site/runtime plugins `AdminPlugin` describes. */
|
|
52
|
+
export interface AgentPluginListRow extends AgentPluginSummary {
|
|
53
|
+
/** Account state is independent of activation; absent for plugins with no sign-in. */
|
|
54
|
+
connectionStatus?: "connected" | "disconnected" | "pending" | "needs_reauth";
|
|
55
|
+
/** Host maturity; absent means normal. */
|
|
56
|
+
maturity?: "untested" | "soon";
|
|
57
|
+
/** The provider plugin (Plugins screen) whose switch this plugin follows; it has no switch of its own. */
|
|
58
|
+
providerPlugin?: string;
|
|
59
|
+
provides?: string[];
|
|
60
|
+
origin?: "bundled" | "operator-installed";
|
|
61
|
+
hostOk?: boolean;
|
|
62
|
+
missingRequires?: string[];
|
|
63
|
+
requiredBy?: string[];
|
|
64
|
+
archiveDigest?: string;
|
|
65
|
+
/** `plugin.json`'s `extensions.jini.displayName`; `null` (or absent, from a server predating the
|
|
66
|
+
* field) means title-case `pluginId` instead. */
|
|
67
|
+
displayName?: string | null;
|
|
68
|
+
/** `plugin.json`'s `extensions.jini.summary` — the plain-language explainer the row shows in place
|
|
69
|
+
* of `description` (which is written for the assistant); `null`/absent means show `description`. */
|
|
70
|
+
summary?: string | null;
|
|
71
|
+
keywords: string[];
|
|
72
|
+
skills: Array<{
|
|
73
|
+
name: string;
|
|
74
|
+
summary: string;
|
|
75
|
+
}>;
|
|
76
|
+
mcpServerIds: string[];
|
|
77
|
+
}
|
|
78
|
+
/** The minimal shape `AgentPluginDetailsModal` actually reads (`plugin.id`/`plugin.displayName`) —
|
|
79
|
+
* see that component's own narrowed prop type. Kept here, not re-exported from the deleted
|
|
80
|
+
* `agent-plugin-catalog.ts`, since nothing about it is bundle-specific anymore: any installed
|
|
81
|
+
* plugin's id plus a human-readable label is enough to open the inspector. */
|
|
82
|
+
export interface InspectedAgentPlugin {
|
|
83
|
+
readonly maturity?: AgentPluginListRow["maturity"];
|
|
84
|
+
readonly id: string;
|
|
85
|
+
readonly displayName: string;
|
|
86
|
+
/** Set by the row's "Manage" button: the screens it already listed, so the modal opens on the first. */
|
|
87
|
+
readonly surfaces?: readonly {
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly title: string;
|
|
90
|
+
readonly src: string;
|
|
91
|
+
readonly actions: readonly AdminSurfaceAction[];
|
|
92
|
+
readonly linkOrigins?: readonly string[];
|
|
93
|
+
}[];
|
|
94
|
+
}
|
|
95
|
+
export interface AgentPluginsDependencies {
|
|
96
|
+
useFetchQuery: FetchQueryAdapter["useFetchQuery"];
|
|
97
|
+
useFetchMutation: FetchQueryAdapter["useFetchMutation"];
|
|
98
|
+
useCachedLoader: FetchQueryAdapter["useCachedLoader"];
|
|
99
|
+
useInvalidate: FetchQueryAdapter["useInvalidate"];
|
|
100
|
+
useContentRefreshSubscription: (required: {
|
|
101
|
+
resource: string;
|
|
102
|
+
onRefresh: () => void;
|
|
103
|
+
}, optional?: {}) => void;
|
|
104
|
+
resource: string;
|
|
105
|
+
toggleRefusalKeys: Readonly<Record<string, string>>;
|
|
106
|
+
translatePlugins: (required: {
|
|
107
|
+
locale: string;
|
|
108
|
+
key: string;
|
|
109
|
+
}) => string;
|
|
110
|
+
describeApiError: (required: {
|
|
111
|
+
e: unknown;
|
|
112
|
+
fallback: string;
|
|
113
|
+
}) => string;
|
|
114
|
+
isApiError: (error: unknown) => error is AdminHttpError;
|
|
115
|
+
port: {
|
|
116
|
+
listAgentPlugins(): Promise<{
|
|
117
|
+
agentPlugins: AgentPluginListRow[];
|
|
118
|
+
}>;
|
|
119
|
+
setAgentPluginEnabled(required: {
|
|
120
|
+
pluginId: string;
|
|
121
|
+
input: {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
};
|
|
124
|
+
}, optional?: Record<string, never>): Promise<{
|
|
125
|
+
agentPlugin: AgentPluginListRow;
|
|
126
|
+
}>;
|
|
127
|
+
getAgentPluginFiles(required: {
|
|
128
|
+
pluginId: string;
|
|
129
|
+
}, optional?: Record<string, never>): Promise<{
|
|
130
|
+
readonly pluginId: string;
|
|
131
|
+
readonly files: readonly {
|
|
132
|
+
readonly relativePath: string;
|
|
133
|
+
readonly sizeBytes: number;
|
|
134
|
+
readonly content: string | null;
|
|
135
|
+
readonly omitted: null | "binary" | "too-large" | "symlink" | "unreadable";
|
|
136
|
+
}[];
|
|
137
|
+
readonly truncated: boolean;
|
|
138
|
+
readonly limits: {
|
|
139
|
+
readonly maxFiles: number;
|
|
140
|
+
readonly maxEntries: number;
|
|
141
|
+
readonly maxFileBytes: number;
|
|
142
|
+
readonly maxTotalBytes: number;
|
|
143
|
+
};
|
|
144
|
+
}>;
|
|
145
|
+
};
|
|
146
|
+
locale: string;
|
|
147
|
+
t: Translate;
|
|
148
|
+
}
|
|
149
|
+
export interface AgentPluginsController {
|
|
150
|
+
/** `null` until the initial load settles — the caller renders a loading state. */
|
|
151
|
+
agentPlugins: AgentPluginListRow[] | null;
|
|
152
|
+
error: string | null;
|
|
153
|
+
/** The last failed toggle's message, or `null`. Separate from `error` (which means "the list
|
|
154
|
+
* itself could not load"), so a refused toggle does not blank the list the operator is reading. */
|
|
155
|
+
toggleError: string | null;
|
|
156
|
+
/** Plugin ids with an enable/disable request in flight right now. A `Set` rather than the sibling
|
|
157
|
+
* screen's single `rowSavingId` — see {@link useAgentPlugins}'s `@tradeoffs`. */
|
|
158
|
+
togglingIds: ReadonlySet<string>;
|
|
159
|
+
/** Flips one plugin's activation and replaces that row with the server's answer. */
|
|
160
|
+
onToggleEnabled: (plugin: AgentPluginListRow) => Promise<void>;
|
|
161
|
+
/** Adds (or replaces) the row the "Add a plugin" upload answered with, so no list re-fetch. */
|
|
162
|
+
onInstalled: (plugin: AgentPluginListRow) => void;
|
|
163
|
+
/** Plugin ids whose row detail panel (skills, MCP servers) is open. */
|
|
164
|
+
expandedIds: ReadonlySet<string>;
|
|
165
|
+
/** Opens or closes one row's detail panel. */
|
|
166
|
+
onToggleExpanded: (required: {
|
|
167
|
+
pluginId: string;
|
|
168
|
+
}, optional?: Record<string, never>) => void;
|
|
169
|
+
/** The plugin currently open in the read-only package inspector, or `null` when it's closed. */
|
|
170
|
+
inspectedPlugin: InspectedAgentPlugin | null;
|
|
171
|
+
/** Opens the inspector for `plugin`. */
|
|
172
|
+
inspectPlugin: (plugin: InspectedAgentPlugin) => void;
|
|
173
|
+
/** Closes the inspector. */
|
|
174
|
+
closeInspector: () => void;
|
|
175
|
+
/** Bound translator — `AgentPlugins.tsx`'s only source of UI copy; see this file's own header. */
|
|
176
|
+
t: Translate;
|
|
177
|
+
/** The raw resolved locale — exposed only because `AgentPlugins.tsx` passes it straight through
|
|
178
|
+
* to `I18nProvider`'s own `initialLocale`, not because anything here needs it beyond `t`. Same
|
|
179
|
+
* reasoning as `use-plugins.hooks.ts`'s own `locale` field. */
|
|
180
|
+
locale: string;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Loads the real installed Agent Plugins for this workspace on mount, and toggles one
|
|
184
|
+
* plugin's activation at a time per row.
|
|
185
|
+
*
|
|
186
|
+
* @complexity One GET on mount, one PATCH per toggle, and GETs after invalidation (toggle,
|
|
187
|
+
* install/uninstall, explicit reload or shared-query refresh). The PATCH response also replaces
|
|
188
|
+
* its row in the shared cache; successful mutations invalidate the list for reconciliation.
|
|
189
|
+
* @tradeoffs No optimistic flip. The switch shows only what the server has confirmed, so a refused
|
|
190
|
+
* or failed toggle can never leave the operator looking at an "on" switch for a plugin that will
|
|
191
|
+
* refuse the next run. The cost is one round-trip of visible latency, which the row's own
|
|
192
|
+
* in-flight state covers.
|
|
193
|
+
*
|
|
194
|
+
* Row replacement reads the shared cache through `loader.peek()` rather than closing over the
|
|
195
|
+
* array this render saw. Two rows toggled in quick succession settle independently, and a
|
|
196
|
+
* settlement holding a stale array would otherwise revert the other row's newer answer.
|
|
197
|
+
*/
|
|
198
|
+
export declare function useAgentPlugins({ port, locale, t, useFetchQuery, useFetchMutation, useCachedLoader, useInvalidate, useContentRefreshSubscription, resource, toggleRefusalKeys, translatePlugins, describeApiError, isApiError }: AgentPluginsDependencies, _optional?: Record<string, never>): AgentPluginsController;
|
|
199
|
+
/**
|
|
200
|
+
* Binds the real `/api/.../agent-plugins` client and the real `useAdminLocale()` — see
|
|
201
|
+
* `agent-plugins-dependencies.hooks.ts`.
|
|
202
|
+
*
|
|
203
|
+
* The zero-argument-dependencies half of the `useX(dependencies)` / `useWiredX()` pair, so
|
|
204
|
+
* `AgentPlugins.tsx` composes this and a test composes {@link useAgentPlugins} with
|
|
205
|
+
* `createFakeAgentPluginsPort`.
|
|
206
|
+
*/
|
|
207
|
+
export declare function useWiredAgentPlugins({ useAdminLocaleHook, ...deps }: Omit<AgentPluginsDependencies, "locale" | "t"> & {
|
|
208
|
+
useAdminLocaleHook: () => string;
|
|
209
|
+
}, _optional?: {}): AgentPluginsController;
|
|
210
|
+
export {};
|
|
211
|
+
//# sourceMappingURL=use-agent-plugins.hooks.d.ts.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import {} from '@jini-ai/core/text';
|
|
3
|
+
/** Adds or removes one id, returning a new `Set` — so React sees an identity change. */
|
|
4
|
+
function withId({ ids, pluginId, present }, _optional = {}) {
|
|
5
|
+
const next = new Set(ids);
|
|
6
|
+
if (present)
|
|
7
|
+
next.add(pluginId);
|
|
8
|
+
else
|
|
9
|
+
next.delete(pluginId);
|
|
10
|
+
return next;
|
|
11
|
+
}
|
|
12
|
+
/** `plugin` in place of the row with its id, keeping the list's order (an update must not move its
|
|
13
|
+
* row to the end), or appended when it is new. @complexity O(n) in row count. */
|
|
14
|
+
function withRow(required, _optional = {}) {
|
|
15
|
+
const { rows, plugin } = required;
|
|
16
|
+
const current = rows ?? [];
|
|
17
|
+
return current.some((entry) => entry.pluginId === plugin.pluginId)
|
|
18
|
+
? current.map((entry) => (entry.pluginId === plugin.pluginId ? plugin : entry))
|
|
19
|
+
: [...current, plugin];
|
|
20
|
+
}
|
|
21
|
+
/** `plugin` in place of the row with its id, or `null` when no list is cached yet. A toggle never
|
|
22
|
+
* appends, and with nothing cached there is nothing on screen to update: writing `[]` there would
|
|
23
|
+
* win over the list read the toggle's own invalidation just started (`replace` beats an older
|
|
24
|
+
* in-flight read) and leave the screen on an empty list. @complexity O(n) in row count. */
|
|
25
|
+
function withToggledRow(required, _optional = {}) {
|
|
26
|
+
const { rows, plugin } = required;
|
|
27
|
+
return rows ? rows.map((entry) => (entry.pluginId === plugin.pluginId ? plugin : entry)) : null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Loads the real installed Agent Plugins for this workspace on mount, and toggles one
|
|
31
|
+
* plugin's activation at a time per row.
|
|
32
|
+
*
|
|
33
|
+
* @complexity One GET on mount, one PATCH per toggle, and GETs after invalidation (toggle,
|
|
34
|
+
* install/uninstall, explicit reload or shared-query refresh). The PATCH response also replaces
|
|
35
|
+
* its row in the shared cache; successful mutations invalidate the list for reconciliation.
|
|
36
|
+
* @tradeoffs No optimistic flip. The switch shows only what the server has confirmed, so a refused
|
|
37
|
+
* or failed toggle can never leave the operator looking at an "on" switch for a plugin that will
|
|
38
|
+
* refuse the next run. The cost is one round-trip of visible latency, which the row's own
|
|
39
|
+
* in-flight state covers.
|
|
40
|
+
*
|
|
41
|
+
* Row replacement reads the shared cache through `loader.peek()` rather than closing over the
|
|
42
|
+
* array this render saw. Two rows toggled in quick succession settle independently, and a
|
|
43
|
+
* settlement holding a stale array would otherwise revert the other row's newer answer.
|
|
44
|
+
*/
|
|
45
|
+
export function useAgentPlugins({ port, locale, t, useFetchQuery, useFetchMutation, useCachedLoader, useInvalidate, useContentRefreshSubscription, resource, toggleRefusalKeys, translatePlugins, describeApiError, isApiError }, _optional = {}) {
|
|
46
|
+
const key = useMemo(() => ["agent-plugins", "list"], []);
|
|
47
|
+
const fetchList = useCallback(async () => {
|
|
48
|
+
try {
|
|
49
|
+
return (await port.listAgentPlugins()).agentPlugins;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(describeApiError({ e: error, fallback: translatePlugins({ locale, key: "failed to load agent plugins" }) }));
|
|
53
|
+
}
|
|
54
|
+
}, [port, locale, describeApiError, translatePlugins]);
|
|
55
|
+
const query = useFetchQuery({ key, fetch: fetchList }, { staleTime: 0, refetchOnWindowFocus: true });
|
|
56
|
+
const loader = useCachedLoader({ key, fetch: fetchList }, { staleTime: 0 });
|
|
57
|
+
const agentPlugins = query.data ?? null;
|
|
58
|
+
const setAgentPlugins = ({ update }, _optional = {}) => {
|
|
59
|
+
const next = update(loader.peek() ?? null);
|
|
60
|
+
if (next)
|
|
61
|
+
loader.replace({ value: next });
|
|
62
|
+
};
|
|
63
|
+
const invalidate = useInvalidate();
|
|
64
|
+
const toggle = useFetchMutation({ run: ({ input }) => port.setAgentPluginEnabled({ pluginId: input.pluginId, input: { enabled: !input.enabled } }) }, { invalidates: [["agent-plugins"]] });
|
|
65
|
+
const error = query.error?.message ?? null;
|
|
66
|
+
const [toggleError, setToggleError] = useState(null);
|
|
67
|
+
const [togglingIds, setTogglingIds] = useState(new Set());
|
|
68
|
+
const [expandedIds, setExpandedIds] = useState(new Set());
|
|
69
|
+
const [inspectedPlugin, setInspectedPlugin] = useState(null);
|
|
70
|
+
const reload = useCallback(async () => { invalidate({ key: ["agent-plugins"] }); }, [invalidate]);
|
|
71
|
+
// A completed assistant install/uninstall must update both tabs without a remount. The shared
|
|
72
|
+
// generation guard prevents a slow earlier read resurrecting the just-removed package.
|
|
73
|
+
useContentRefreshSubscription({ resource, onRefresh: () => { void reload(); } });
|
|
74
|
+
async function onToggleEnabled(plugin) {
|
|
75
|
+
// A second activation of this row's own switch while its request is outstanding is a no-op —
|
|
76
|
+
// the same client-side single-flight discipline `usePlugins` uses, applied per row.
|
|
77
|
+
if (togglingIds.has(plugin.pluginId))
|
|
78
|
+
return;
|
|
79
|
+
setTogglingIds((ids) => withId({ ids, pluginId: plugin.pluginId, present: true }));
|
|
80
|
+
setToggleError(null);
|
|
81
|
+
try {
|
|
82
|
+
const { agentPlugin } = await toggle.mutate({ input: plugin });
|
|
83
|
+
setAgentPlugins({ update: (current) => withToggledRow({ rows: current, plugin: agentPlugin }) });
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
// Lifecycle refusals by name (409), in the operator's language rather than the server's English.
|
|
87
|
+
const known = isApiError(e) && e.code ? toggleRefusalKeys[e.code] : undefined;
|
|
88
|
+
setToggleError(known ? translatePlugins({ locale, key: known })
|
|
89
|
+
: describeApiError({ e, fallback: translatePlugins({ locale: locale, key: "failed to update agent plugin" }) }));
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
setTogglingIds((ids) => withId({ ids, pluginId: plugin.pluginId, present: false }));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
agentPlugins,
|
|
97
|
+
error,
|
|
98
|
+
toggleError,
|
|
99
|
+
togglingIds,
|
|
100
|
+
onToggleEnabled,
|
|
101
|
+
onInstalled: (plugin) => {
|
|
102
|
+
// The install response is newer than any pending list read. Keep its row until a later
|
|
103
|
+
// refresh starts rather than letting an earlier snapshot hide the completed install.
|
|
104
|
+
setAgentPlugins({ update: (current) => withRow({ rows: current, plugin }) });
|
|
105
|
+
},
|
|
106
|
+
expandedIds,
|
|
107
|
+
onToggleExpanded: ({ pluginId }, _optional = {}) => setExpandedIds((ids) => withId({ ids, pluginId, present: !ids.has(pluginId) })),
|
|
108
|
+
inspectedPlugin,
|
|
109
|
+
inspectPlugin: setInspectedPlugin,
|
|
110
|
+
closeInspector: () => setInspectedPlugin(null),
|
|
111
|
+
t,
|
|
112
|
+
locale,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Binds the real `/api/.../agent-plugins` client and the real `useAdminLocale()` — see
|
|
117
|
+
* `agent-plugins-dependencies.hooks.ts`.
|
|
118
|
+
*
|
|
119
|
+
* The zero-argument-dependencies half of the `useX(dependencies)` / `useWiredX()` pair, so
|
|
120
|
+
* `AgentPlugins.tsx` composes this and a test composes {@link useAgentPlugins} with
|
|
121
|
+
* `createFakeAgentPluginsPort`.
|
|
122
|
+
*/
|
|
123
|
+
export function useWiredAgentPlugins({ useAdminLocaleHook, ...deps }, _optional = {}) {
|
|
124
|
+
const locale = useAdminLocaleHook();
|
|
125
|
+
const t = (key) => deps.translatePlugins({ locale: locale, key: key });
|
|
126
|
+
return useAgentPlugins({ ...deps, locale, t });
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=use-agent-plugins.hooks.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The lifecycle owner's fail-closed activation resolution, bound by the host. */
|
|
2
|
+
export type ResolveAgentPluginActivation = (required: {
|
|
3
|
+
workspaceRoot: string;
|
|
4
|
+
pluginId: string;
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
readonly verdict: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** Bind Jini's versioned point reader to the activation owner's atomic file writes.
|
|
9
|
+
* @returns A scoped callback with one stat per hot call; file contents are read only on change.
|
|
10
|
+
* @throws Filesystem errors except a genuinely absent activation file (the lifecycle default).
|
|
11
|
+
* @complexity O(1) metadata per call, O(a) activation-file read on cache miss for a bytes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAgentPluginEnabledReader({ workspaceRoot, resolveAgentPluginActivation }: {
|
|
14
|
+
workspaceRoot: string;
|
|
15
|
+
resolveAgentPluginActivation: ResolveAgentPluginActivation;
|
|
16
|
+
}, _options?: {}): (pluginId: string) => Promise<boolean>;
|
|
17
|
+
//# sourceMappingURL=activation-effects.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Revision-checked "is this Agent Plugin enabled" reads over the activation owner's atomic file.
|
|
2
|
+
* The host injects its lifecycle owner's `resolveAgentPluginActivation`, so every in-process writer
|
|
3
|
+
* keeps sharing that owner's activation queue.
|
|
4
|
+
*/
|
|
5
|
+
import { stat } from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { ACTIVATIONS_FILENAME, createVersionedPluginActivationReader } from "@jini-ai/agent-plugins/lifecycle";
|
|
8
|
+
/** Bind Jini's versioned point reader to the activation owner's atomic file writes.
|
|
9
|
+
* @returns A scoped callback with one stat per hot call; file contents are read only on change.
|
|
10
|
+
* @throws Filesystem errors except a genuinely absent activation file (the lifecycle default).
|
|
11
|
+
* @complexity O(1) metadata per call, O(a) activation-file read on cache miss for a bytes.
|
|
12
|
+
*/
|
|
13
|
+
export function createAgentPluginEnabledReader({ workspaceRoot, resolveAgentPluginActivation }, _options = {}) {
|
|
14
|
+
const reader = createVersionedPluginActivationReader({ ports: {
|
|
15
|
+
revision: async () => {
|
|
16
|
+
try {
|
|
17
|
+
const info = await stat(path.join(workspaceRoot, ACTIVATIONS_FILENAME), { bigint: true });
|
|
18
|
+
return `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === "ENOENT")
|
|
22
|
+
return "absent";
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
// Only an active verdict enables; missing activation records retain the lifecycle default.
|
|
27
|
+
resolve: async ({ pluginId }) => (await resolveAgentPluginActivation({ workspaceRoot, pluginId })).verdict === "active",
|
|
28
|
+
} });
|
|
29
|
+
return pluginId => reader.isEnabled({ pluginId });
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=activation-effects.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AdminSurfaceCapabilitiesPort, AdminSurfaceConnections, AdminSurfaceDeliveryBindings, AdminSurfaceForms, AdminSurfacePublicConfig, AdminSurfaceState } from "../../admin-surfaces/index.js";
|
|
2
|
+
import type { AgentPluginToolCapabilitiesPort, AgentPluginToolCapabilityScope } from "../../lifecycle/tools/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* @file The host's `AdminSurfaceCapabilitiesPort`: what a plugin's admin-surface handlers get per call.
|
|
5
|
+
* `http`, `limiter` and `artifacts` are the executable-tool ports (same guarded client, same
|
|
6
|
+
* per-plugin budgets); `connections`, `state`, `publicConfig` and (when the site binds form
|
|
7
|
+
* delivery) `deliveryBindings` and `forms` are surface-only and come from the composition root, each already
|
|
8
|
+
* scoped to the call's plugin, workspace and admin. Nothing here names a provider.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @param optional.deliveryBindingsFor - The site's form-delivery bindings port per call scope
|
|
12
|
+
* (`delivery-bindings.ts`); absent, no surface gets `deliveryBindings`.
|
|
13
|
+
* @param optional.formsFor - The permission-checked workspace form reader; Jini exposes it only
|
|
14
|
+
* to surfaces declaring `forms: ["list"]`.
|
|
15
|
+
* @complexity O(1) per call; each port is built lazily by its factory.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createAdminSurfaceCapabilities(required: {
|
|
18
|
+
readonly tools: AgentPluginToolCapabilitiesPort;
|
|
19
|
+
readonly connectionsFor: (scope: AgentPluginToolCapabilityScope) => AdminSurfaceConnections;
|
|
20
|
+
readonly stateFor: (scope: {
|
|
21
|
+
readonly workspaceId: string;
|
|
22
|
+
readonly pluginId: string;
|
|
23
|
+
}) => AdminSurfaceState;
|
|
24
|
+
readonly publicConfig: AdminSurfacePublicConfig;
|
|
25
|
+
}, optional?: {
|
|
26
|
+
readonly deliveryBindingsFor?: (scope: AgentPluginToolCapabilityScope) => AdminSurfaceDeliveryBindings;
|
|
27
|
+
readonly formsFor?: (scope: AgentPluginToolCapabilityScope) => AdminSurfaceForms;
|
|
28
|
+
}): AdminSurfaceCapabilitiesPort;
|
|
29
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The host's `AdminSurfaceCapabilitiesPort`: what a plugin's admin-surface handlers get per call.
|
|
3
|
+
* `http`, `limiter` and `artifacts` are the executable-tool ports (same guarded client, same
|
|
4
|
+
* per-plugin budgets); `connections`, `state`, `publicConfig` and (when the site binds form
|
|
5
|
+
* delivery) `deliveryBindings` and `forms` are surface-only and come from the composition root, each already
|
|
6
|
+
* scoped to the call's plugin, workspace and admin. Nothing here names a provider.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @param optional.deliveryBindingsFor - The site's form-delivery bindings port per call scope
|
|
10
|
+
* (`delivery-bindings.ts`); absent, no surface gets `deliveryBindings`.
|
|
11
|
+
* @param optional.formsFor - The permission-checked workspace form reader; Jini exposes it only
|
|
12
|
+
* to surfaces declaring `forms: ["list"]`.
|
|
13
|
+
* @complexity O(1) per call; each port is built lazily by its factory.
|
|
14
|
+
*/
|
|
15
|
+
export function createAdminSurfaceCapabilities(required, optional = {}) {
|
|
16
|
+
return (scope) => {
|
|
17
|
+
const { http, limiter, artifacts } = required.tools(scope);
|
|
18
|
+
return {
|
|
19
|
+
// Absent stays absent: this site has no artifact store, and a stub would hide that from the plugin.
|
|
20
|
+
http, limiter, ...(artifacts === undefined ? {} : { artifacts }),
|
|
21
|
+
connections: required.connectionsFor(scope),
|
|
22
|
+
state: required.stateFor({ workspaceId: scope.workspaceId, pluginId: scope.pluginId }),
|
|
23
|
+
publicConfig: required.publicConfig,
|
|
24
|
+
// Jini hands it on only to a surface that declares `deliveryAdapters`.
|
|
25
|
+
...(optional.deliveryBindingsFor === undefined ? {} : { deliveryBindings: optional.deliveryBindingsFor(scope) }),
|
|
26
|
+
...(optional.formsFor === undefined ? {} : { forms: optional.formsFor(scope) }),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type AdminSurfaceDeliveryBindings } from "../../admin-surfaces/index.js";
|
|
2
|
+
import type { FormDeliveryBinding } from "@jini-ai/core/contracts/site/cms-forms";
|
|
3
|
+
/**
|
|
4
|
+
* @file The host's `deliveryBindings` port for plugin admin-surface handlers (Jini's
|
|
5
|
+
* `AdminSurfaceDeliveryBindings`): a plugin's destination screen lists, saves and removes the
|
|
6
|
+
* site's form-delivery bindings for the adapters THIS plugin contributes, so an admin no longer
|
|
7
|
+
* copies a destination's config by hand.
|
|
8
|
+
*
|
|
9
|
+
* Why the host re-checks what Jini's session already checked: the session knows only the surface's
|
|
10
|
+
* declared adapter and connection ids; only the host knows which adapters the calling plugin really
|
|
11
|
+
* contributes (`jini-form-destinations.json`) and which connections it declares in this workspace.
|
|
12
|
+
* And the session's ownership check is a separate `list` before the `save`/`remove`, so ownership is
|
|
13
|
+
* re-read here inside the write itself (another writer may have changed the setting in between).
|
|
14
|
+
*
|
|
15
|
+
* Bindings are written through the forms build's binding owner (`core.forms/deliveryBindings`, via
|
|
16
|
+
* the settings chokepoint), with the signed-in admin as the caller: the same validation and the same
|
|
17
|
+
* `settings.workspace.write` authorization every other writer gets. No second store. The plugin
|
|
18
|
+
* sees its own connection id, never the stored connection ref, and names forms by slug (the only
|
|
19
|
+
* form identity a destination ever receives: the frozen job carries `form.slug`); the stored binding
|
|
20
|
+
* keeps the forms' row ids, which is what delivery planning matches.
|
|
21
|
+
*/
|
|
22
|
+
/** Read and write of the site's `core.forms/deliveryBindings` list (the forms build owns both). */
|
|
23
|
+
export interface FormDeliveryBindingsStore {
|
|
24
|
+
isConflict(required: {
|
|
25
|
+
readonly error: unknown;
|
|
26
|
+
}, optional?: Record<string, never>): boolean;
|
|
27
|
+
read(required: {
|
|
28
|
+
readonly workspaceId: string;
|
|
29
|
+
}): Promise<readonly FormDeliveryBinding[]>;
|
|
30
|
+
/** Atomically refuses a stale expectedValue with FormDeliveryBindingsConflictError. */
|
|
31
|
+
write(required: {
|
|
32
|
+
readonly workspaceId: string;
|
|
33
|
+
readonly callerPrincipalId: string;
|
|
34
|
+
readonly value: readonly FormDeliveryBinding[];
|
|
35
|
+
readonly expectedValue: readonly FormDeliveryBinding[];
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export interface SurfaceDeliveryBindingsDeps {
|
|
39
|
+
/** The one workspace this site serves; any other scope owns nothing here. */
|
|
40
|
+
readonly siteWorkspaceId: string;
|
|
41
|
+
/** Connection ids the plugin declares in this workspace (active plugins only). */
|
|
42
|
+
readonly declaredConnectionIds: (required: {
|
|
43
|
+
readonly pluginId: string;
|
|
44
|
+
}) => Promise<readonly string[]>;
|
|
45
|
+
/** Form-destination adapter ids the plugin contributes in the workspace (active plugins only). */
|
|
46
|
+
readonly contributedAdapterIds: (required: {
|
|
47
|
+
readonly workspaceId: string;
|
|
48
|
+
readonly pluginId: string;
|
|
49
|
+
}) => Promise<readonly string[]>;
|
|
50
|
+
readonly forms: {
|
|
51
|
+
list(required: {
|
|
52
|
+
readonly workspaceId: string;
|
|
53
|
+
}): Promise<readonly {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly slug: string;
|
|
56
|
+
}[]>;
|
|
57
|
+
};
|
|
58
|
+
readonly bindings: FormDeliveryBindingsStore;
|
|
59
|
+
readonly newBindingId: () => string;
|
|
60
|
+
/** The stored connection ref of one plugin connection (the host binds its api-connection key deriver). */
|
|
61
|
+
readonly deriveConnectionRef: (required: {
|
|
62
|
+
readonly workspaceId: string;
|
|
63
|
+
readonly pluginId: string;
|
|
64
|
+
readonly connectionId: string;
|
|
65
|
+
}) => string;
|
|
66
|
+
}
|
|
67
|
+
type BindingScope = SurfaceDeliveryBindingsDeps & {
|
|
68
|
+
readonly pluginId: string;
|
|
69
|
+
readonly workspaceId: string;
|
|
70
|
+
readonly principalId?: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Builds the per-call port for one plugin, workspace and signed-in admin.
|
|
74
|
+
* @param required.principalId - The admin the route authenticated; every call is refused without one,
|
|
75
|
+
* and every write is authorized for this principal by the settings chokepoint.
|
|
76
|
+
* @complexity Each call: one bindings read, one connection and one adapter listing, one forms list,
|
|
77
|
+
* then O(b + f); `save` and `remove` add one guarded settings write and retry once on conflict.
|
|
78
|
+
*/
|
|
79
|
+
export declare function createSurfaceDeliveryBindings(required: BindingScope, _optional?: Record<string, never>): AdminSurfaceDeliveryBindings;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=delivery-bindings.d.ts.map
|