@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,161 @@
|
|
|
1
|
+
import { AdminSurfaceActionError } from "../../admin-surfaces/index.js";
|
|
2
|
+
import { ValueValidationFailedError } from "@jini-ai/core/settings";
|
|
3
|
+
const NOTHING_OWNED = { all: [], adapterIds: new Set(), refByConnectionId: new Map(), connectionIdByRef: new Map(), slugByFormId: new Map(), formIdBySlug: new Map() };
|
|
4
|
+
/** Names in messages come from plugin code: cut them so a message stays a message. */
|
|
5
|
+
const named = ({ value }, _optional = {}) => JSON.stringify(value.slice(0, 64));
|
|
6
|
+
function refusal({ code, message }, _optional = {}) {
|
|
7
|
+
return new AdminSurfaceActionError({ code, message });
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* This plugin's stored bindings: the adapter is one the plugin contributes and the ref one of the
|
|
11
|
+
* plugin's connections (a binding the plugin cannot name by connection id is not its to manage).
|
|
12
|
+
* @complexity O(b).
|
|
13
|
+
*/
|
|
14
|
+
function ownEntries(ownership) {
|
|
15
|
+
return ownership.all.flatMap((binding, index) => {
|
|
16
|
+
const connectionId = ownership.adapterIds.has(binding.adapterId) ? ownership.connectionIdByRef.get(binding.connectionRef) : undefined;
|
|
17
|
+
return connectionId === undefined ? [] : [{ binding, index, connectionId }];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The surface's view of a stored binding: connection id instead of ref, slugs instead of form ids
|
|
22
|
+
* (an id whose form is gone is left out).
|
|
23
|
+
* @complexity O(f) form ids.
|
|
24
|
+
*/
|
|
25
|
+
function toView({ ownership, binding, connectionId }, _optional = {}) {
|
|
26
|
+
// A stored binding without `formIds` delivers every form (the forms build's meaning); the port
|
|
27
|
+
// states that explicitly, so the plugin never has to infer it from a missing field.
|
|
28
|
+
const forms = binding.formIds === undefined ? { allForms: true } : { formIds: binding.formIds.flatMap((formId) => ownership.slugByFormId.get(formId) ?? []) };
|
|
29
|
+
return {
|
|
30
|
+
bindingId: binding.bindingId, adapterId: binding.adapterId, connectionId,
|
|
31
|
+
enabled: binding.enabled, ...forms,
|
|
32
|
+
// Stored config passed the binding owner's JSON validation and Jini's plain-JSON check on save.
|
|
33
|
+
config: binding.config,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Slugs → this site's form row ids. @throws AdminSurfaceActionError `form-not-found`. @complexity O(f). */
|
|
37
|
+
function storedFormIds(ownership, slugs) {
|
|
38
|
+
return slugs.map((slug) => {
|
|
39
|
+
const formId = ownership.formIdBySlug.get(slug);
|
|
40
|
+
if (formId === undefined)
|
|
41
|
+
throw refusal({ code: "form-not-found", message: `No form with the short name ${named({ value: slug })} exists on this site. Check the form's short name and save again.` });
|
|
42
|
+
return formId;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The binding to store for a draft the plugin owns.
|
|
47
|
+
* @throws AdminSurfaceActionError `adapter-not-owned`, `connection-not-declared` or `form-not-found`.
|
|
48
|
+
* @complexity O(f) form ids.
|
|
49
|
+
*/
|
|
50
|
+
function toStored({ ownership, draft, bindingId }, _optional = {}) {
|
|
51
|
+
if (!ownership.adapterIds.has(draft.adapterId))
|
|
52
|
+
throw refusal({ code: "adapter-not-owned", message: `This plugin does not provide the delivery adapter ${named({ value: draft.adapterId })} here, so it cannot save its bindings.` });
|
|
53
|
+
const connectionRef = ownership.refByConnectionId.get(draft.connectionId);
|
|
54
|
+
if (connectionRef === undefined)
|
|
55
|
+
throw refusal({ code: "connection-not-declared", message: `This plugin has no connection ${named({ value: draft.connectionId })} here. Reopen the plugin's settings from this site's admin and retry.` });
|
|
56
|
+
return {
|
|
57
|
+
bindingId, adapterId: draft.adapterId, connectionRef, enabled: draft.enabled,
|
|
58
|
+
// `allForms: true` is stored as no `formIds`, which the forms build reads as every form.
|
|
59
|
+
...(draft.allForms === true ? {} : { formIds: storedFormIds(ownership, draft.formIds) }),
|
|
60
|
+
config: { ...draft.config },
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `stored` keeping the form ids of `previous` this site's form list does not show (a trashed form):
|
|
65
|
+
* the plugin only ever saw the visible slugs, so a re-save must not drop a form that comes back.
|
|
66
|
+
* @complexity O(f) form ids.
|
|
67
|
+
*/
|
|
68
|
+
function keepHiddenFormIds({ ownership, stored, previous }, _optional = {}) {
|
|
69
|
+
if (stored.formIds === undefined || previous?.formIds === undefined)
|
|
70
|
+
return stored;
|
|
71
|
+
const formIds = stored.formIds;
|
|
72
|
+
const hidden = previous.formIds.filter((formId) => !ownership.slugByFormId.has(formId) && !formIds.includes(formId));
|
|
73
|
+
return hidden.length === 0 ? stored : { ...stored, formIds: [...formIds, ...hidden] };
|
|
74
|
+
}
|
|
75
|
+
/** The index of one of this plugin's stored bindings. @throws AdminSurfaceActionError `binding-not-found`. @complexity O(b). */
|
|
76
|
+
function ownIndex({ ownership, bindingId }, _optional = {}) {
|
|
77
|
+
const own = ownEntries(ownership).find((entry) => entry.binding.bindingId === bindingId);
|
|
78
|
+
if (own === undefined)
|
|
79
|
+
throw refusal({ code: "binding-not-found", message: `No delivery binding ${named({ value: bindingId })} belongs to this plugin here. List the bindings again and retry.` });
|
|
80
|
+
return own.index;
|
|
81
|
+
}
|
|
82
|
+
/** @complexity O(b + c + a + forms), four reads in parallel. */
|
|
83
|
+
async function readOwnership(required) {
|
|
84
|
+
const { pluginId, workspaceId } = required;
|
|
85
|
+
if (workspaceId !== required.siteWorkspaceId)
|
|
86
|
+
return NOTHING_OWNED;
|
|
87
|
+
const [all, adapterIds, connectionIds, forms] = await Promise.all([
|
|
88
|
+
required.bindings.read({ workspaceId }), required.contributedAdapterIds({ workspaceId, pluginId }),
|
|
89
|
+
required.declaredConnectionIds({ pluginId }), required.forms.list({ workspaceId }),
|
|
90
|
+
]);
|
|
91
|
+
const refs = connectionIds.map((connectionId) => [connectionId, required.deriveConnectionRef({ workspaceId, pluginId, connectionId })]);
|
|
92
|
+
return {
|
|
93
|
+
all, adapterIds: new Set(adapterIds),
|
|
94
|
+
refByConnectionId: new Map(refs), connectionIdByRef: new Map(refs.map(([connectionId, ref]) => [ref, connectionId])),
|
|
95
|
+
slugByFormId: new Map(forms.map((form) => [form.id, form.slug])), formIdBySlug: new Map(forms.map((form) => [form.slug, form.id])),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Merges against fresh ownership and writes through the binding owner; one conflict retries the
|
|
100
|
+
* whole ownership check, so a concurrent removal or ownership change cannot be undone.
|
|
101
|
+
* Validation keeps its people-facing message; a second conflict asks the panel to refresh.
|
|
102
|
+
* @complexity At most two ownership reads and guarded writes; O(b + f) merge time/space per try.
|
|
103
|
+
*/
|
|
104
|
+
async function updateBindings(required, input, optional = {}) {
|
|
105
|
+
const owned = await readOwnership(required);
|
|
106
|
+
const { value, result } = input.merge({ owned });
|
|
107
|
+
const { workspaceId } = required;
|
|
108
|
+
try {
|
|
109
|
+
await required.bindings.write({ workspaceId, callerPrincipalId: input.callerPrincipalId, value, expectedValue: owned.all });
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (required.bindings.isConflict({ error })) {
|
|
114
|
+
if (optional.retry !== false)
|
|
115
|
+
return updateBindings(required, input, { retry: false });
|
|
116
|
+
throw new AdminSurfaceActionError({ code: "delivery-binding-conflict", message: "Delivery settings changed in another panel. List the bindings again and retry your change." }, { cause: error });
|
|
117
|
+
}
|
|
118
|
+
if (!(error instanceof ValueValidationFailedError))
|
|
119
|
+
throw error;
|
|
120
|
+
throw new AdminSurfaceActionError({ code: "delivery-binding-invalid", message: error.message }, { cause: error });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Builds the per-call port for one plugin, workspace and signed-in admin.
|
|
125
|
+
* @param required.principalId - The admin the route authenticated; every call is refused without one,
|
|
126
|
+
* and every write is authorized for this principal by the settings chokepoint.
|
|
127
|
+
* @complexity Each call: one bindings read, one connection and one adapter listing, one forms list,
|
|
128
|
+
* then O(b + f); `save` and `remove` add one guarded settings write and retry once on conflict.
|
|
129
|
+
*/
|
|
130
|
+
export function createSurfaceDeliveryBindings(required, _optional = {}) {
|
|
131
|
+
const { principalId } = required;
|
|
132
|
+
function admin() {
|
|
133
|
+
if (principalId === undefined)
|
|
134
|
+
throw refusal({ code: "admin-required", message: "Delivery settings need a signed-in admin. Open the plugin's settings from this site's admin and retry." });
|
|
135
|
+
return principalId;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
async list() {
|
|
139
|
+
admin();
|
|
140
|
+
const owned = await readOwnership(required);
|
|
141
|
+
return ownEntries(owned).map((entry) => toView({ ownership: owned, binding: entry.binding, connectionId: entry.connectionId }));
|
|
142
|
+
},
|
|
143
|
+
async save(draft) {
|
|
144
|
+
const callerPrincipalId = admin();
|
|
145
|
+
const bindingId = draft.bindingId ?? required.newBindingId();
|
|
146
|
+
return updateBindings(required, { callerPrincipalId, merge: ({ owned }, _optional = {}) => {
|
|
147
|
+
const replaced = draft.bindingId === undefined ? owned.all.length : ownIndex({ ownership: owned, bindingId: draft.bindingId });
|
|
148
|
+
const stored = keepHiddenFormIds({ ownership: owned, stored: toStored({ ownership: owned, draft, bindingId }), previous: owned.all[replaced] });
|
|
149
|
+
return { value: [...owned.all.slice(0, replaced), stored, ...owned.all.slice(replaced + 1)], result: toView({ ownership: owned, binding: stored, connectionId: draft.connectionId }) };
|
|
150
|
+
} });
|
|
151
|
+
},
|
|
152
|
+
async remove({ bindingId }) {
|
|
153
|
+
const callerPrincipalId = admin();
|
|
154
|
+
return updateBindings(required, { callerPrincipalId, merge: ({ owned }, _optional = {}) => {
|
|
155
|
+
const index = ownIndex({ ownership: owned, bindingId });
|
|
156
|
+
return { value: owned.all.filter((_binding, at) => at !== index), result: undefined };
|
|
157
|
+
} });
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=delivery-bindings.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AdminSurfaceForms } from "../../admin-surfaces/index.js";
|
|
2
|
+
import type { SetValueRequired } from "@jini-ai/core/settings";
|
|
3
|
+
/**
|
|
4
|
+
* @file The surface forms reader reuses the definition repository behind the admin forms API.
|
|
5
|
+
* Plugin access is not forms access: the signed-in caller must also have `admin.forms.manage`.
|
|
6
|
+
* The repository hides trashed forms; only identities and names leave this adapter. Jini's
|
|
7
|
+
* capability session caps the choices and exposes the port only to a declaring surface.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Builds one call's forms reader, scoped by the authenticated host context, never by plugin input.
|
|
11
|
+
* Missing actors, foreign workspaces and denied permissions fail before the repository read.
|
|
12
|
+
* @complexity O(f) time/space for f workspace forms, one authorization and one existing list query.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSurfaceForms(required: {
|
|
15
|
+
readonly siteWorkspaceId: string;
|
|
16
|
+
readonly workspaceId: string;
|
|
17
|
+
readonly principalId?: string;
|
|
18
|
+
readonly authorize: SetValueRequired["deps"]["authorize"];
|
|
19
|
+
readonly forms: {
|
|
20
|
+
list(required: {
|
|
21
|
+
readonly workspaceId: string;
|
|
22
|
+
}): Promise<readonly {
|
|
23
|
+
readonly slug: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
}[]>;
|
|
26
|
+
};
|
|
27
|
+
}, _optional?: Record<string, never>): AdminSurfaceForms;
|
|
28
|
+
//# sourceMappingURL=forms.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AdminSurfaceActionError } from "../../admin-surfaces/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* @file The surface forms reader reuses the definition repository behind the admin forms API.
|
|
4
|
+
* Plugin access is not forms access: the signed-in caller must also have `admin.forms.manage`.
|
|
5
|
+
* The repository hides trashed forms; only identities and names leave this adapter. Jini's
|
|
6
|
+
* capability session caps the choices and exposes the port only to a declaring surface.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Builds one call's forms reader, scoped by the authenticated host context, never by plugin input.
|
|
10
|
+
* Missing actors, foreign workspaces and denied permissions fail before the repository read.
|
|
11
|
+
* @complexity O(f) time/space for f workspace forms, one authorization and one existing list query.
|
|
12
|
+
*/
|
|
13
|
+
export function createSurfaceForms(required, _optional = {}) {
|
|
14
|
+
return {
|
|
15
|
+
async list(_input, _options = {}) {
|
|
16
|
+
const { workspaceId, principalId } = required;
|
|
17
|
+
if (workspaceId !== required.siteWorkspaceId)
|
|
18
|
+
throw new AdminSurfaceActionError({ code: "workspace-not-found", message: "This workspace is not available here." });
|
|
19
|
+
if (principalId === undefined)
|
|
20
|
+
throw new AdminSurfaceActionError({ code: "admin-required", message: "Listing forms needs a signed-in admin." });
|
|
21
|
+
const result = await required.authorize({ principalId, workspaceId, permission: "admin.forms.manage", entityType: "form_definition" });
|
|
22
|
+
if (!result.allowed)
|
|
23
|
+
throw new AdminSurfaceActionError({ code: "forbidden", message: "You do not have permission to list this site's forms." });
|
|
24
|
+
const forms = await required.forms.list({ workspaceId });
|
|
25
|
+
return forms.map(({ slug, name }) => ({ slug, title: name }));
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=forms.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createAdminSurfaceHandlerHost, defineAdminSurfaceHandlerContribution, type AdminSurfaceCapabilitiesPort, type AdminSurfaceHostKind, type LoadedAdminSurfaceHandlers } from "../../admin-surfaces/index.js";
|
|
2
|
+
import type { IssuedTokenMemories } from "../../lifecycle/tools/index.js";
|
|
3
|
+
import type { IssuedSignInCollector } from "../../admin-surfaces/node.js";
|
|
4
|
+
/**
|
|
5
|
+
* @file Binds plugin-supplied admin-surface handler modules (Jini's G5b handler host) to this site as
|
|
6
|
+
* the admin routes' `AdminSurfaceHost` port. Nothing here names a provider.
|
|
7
|
+
*
|
|
8
|
+
* When the handlers are (re)loaded: once at boot, and again before every surface bootstrap. The
|
|
9
|
+
* admin frame always asks for its bootstrap when a surface opens, before any action, so a plugin
|
|
10
|
+
* enabled since the last load (by any writer: the admin toggle, an assistant tool, an install, in
|
|
11
|
+
* either process) gets its handlers on the next open without a restart or a cross-process signal.
|
|
12
|
+
* Disabling needs no reload to take effect: the surface routes admit only active plugins per
|
|
13
|
+
* request, and a later load drops the module and revokes the capabilities it kept.
|
|
14
|
+
*/
|
|
15
|
+
type AdminSurfaceHandlerContribution = ReturnType<typeof defineAdminSurfaceHandlerContribution>;
|
|
16
|
+
type AdminSurfaceHandlerHost = ReturnType<typeof createAdminSurfaceHandlerHost>;
|
|
17
|
+
/** The lifecycle's `loadPluginContributions`, narrowed to this contribution (as the executable-tool host does). */
|
|
18
|
+
export type LoadAdminSurfaceHandlers = (required: {
|
|
19
|
+
readonly workspaceId: string;
|
|
20
|
+
readonly definition: AdminSurfaceHandlerContribution;
|
|
21
|
+
}, optional: {
|
|
22
|
+
readonly orderByPluginId?: boolean;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
readonly items: readonly LoadedAdminSurfaceHandlers[];
|
|
25
|
+
readonly refusals: readonly string[];
|
|
26
|
+
}>;
|
|
27
|
+
/** The admin routes' surface host port (the host's `AdminSurfaceHost`), plus `refresh`. */
|
|
28
|
+
export interface AgentPluginAdminSurfaceHandlers {
|
|
29
|
+
handlersFor(required: Parameters<AdminSurfaceHandlerHost["handlersFor"]>[0], optional?: Record<string, never>): ReturnType<AdminSurfaceHandlerHost["handlersFor"]>;
|
|
30
|
+
bootstrapData(required: Parameters<AdminSurfaceHandlerHost["bootstrapData"]>[0], optional?: Record<string, never>): ReturnType<AdminSurfaceHandlerHost["bootstrapData"]>;
|
|
31
|
+
/** The sign-in links an action issued, for the host page to offer (absent: none are ever offered). */
|
|
32
|
+
readonly signIns?: Pick<IssuedSignInCollector, "collect">;
|
|
33
|
+
/** Loads the active plugins' handler modules and admits them; resolves to the refusal lines. */
|
|
34
|
+
refresh(required?: Record<string, never>, optional?: Record<string, never>): Promise<readonly string[]>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates the site's admin-surface handler host.
|
|
38
|
+
* @param required.workspaceId - The site's workspace; every load reads its active plugins.
|
|
39
|
+
* @param required.filename - The host's admin-surfaces contribution filename.
|
|
40
|
+
* @param required.loadContributions - The lifecycle owner's trusted contribution loader.
|
|
41
|
+
* @param required.capabilities - The admin-surface capability port (`capabilities.ts`: tool HTTP/limiter + connections, state, public config).
|
|
42
|
+
* @param required.issuedTokens - The site's one token memory, the SAME instance the tool projection has.
|
|
43
|
+
* @param required.hostKind - `'desktop'` or `'hosted'`, from the runtime the API connections use (one source of truth).
|
|
44
|
+
* @param required.log - Where refusal lines go; the host owns the sink and any log-line prefix.
|
|
45
|
+
* @param optional.signIns - The registry the connections port reports issued sign-ins to; the action route collects it.
|
|
46
|
+
* @returns The `AdminSurfaceHost` port plus `refresh`.
|
|
47
|
+
* @complexity `refresh` is one contribution load, O(p) active packages, plus O(s + a) admission.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createAgentPluginAdminSurfaceHandlers(required: {
|
|
50
|
+
readonly workspaceId: string;
|
|
51
|
+
readonly filename: string;
|
|
52
|
+
readonly loadContributions: LoadAdminSurfaceHandlers;
|
|
53
|
+
readonly capabilities: AdminSurfaceCapabilitiesPort;
|
|
54
|
+
readonly issuedTokens: IssuedTokenMemories;
|
|
55
|
+
readonly hostKind: AdminSurfaceHostKind;
|
|
56
|
+
readonly log: (line: string) => void;
|
|
57
|
+
}, optional?: {
|
|
58
|
+
readonly signIns?: IssuedSignInCollector;
|
|
59
|
+
}): AgentPluginAdminSurfaceHandlers;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createAdminSurfaceHandlerHost, defineAdminSurfaceHandlerContribution } from "../../admin-surfaces/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the site's admin-surface handler host.
|
|
4
|
+
* @param required.workspaceId - The site's workspace; every load reads its active plugins.
|
|
5
|
+
* @param required.filename - The host's admin-surfaces contribution filename.
|
|
6
|
+
* @param required.loadContributions - The lifecycle owner's trusted contribution loader.
|
|
7
|
+
* @param required.capabilities - The admin-surface capability port (`capabilities.ts`: tool HTTP/limiter + connections, state, public config).
|
|
8
|
+
* @param required.issuedTokens - The site's one token memory, the SAME instance the tool projection has.
|
|
9
|
+
* @param required.hostKind - `'desktop'` or `'hosted'`, from the runtime the API connections use (one source of truth).
|
|
10
|
+
* @param required.log - Where refusal lines go; the host owns the sink and any log-line prefix.
|
|
11
|
+
* @param optional.signIns - The registry the connections port reports issued sign-ins to; the action route collects it.
|
|
12
|
+
* @returns The `AdminSurfaceHost` port plus `refresh`.
|
|
13
|
+
* @complexity `refresh` is one contribution load, O(p) active packages, plus O(s + a) admission.
|
|
14
|
+
*/
|
|
15
|
+
export function createAgentPluginAdminSurfaceHandlers(required, optional = {}) {
|
|
16
|
+
const handlerContribution = defineAdminSurfaceHandlerContribution({ filename: required.filename });
|
|
17
|
+
const host = createAdminSurfaceHandlerHost({ capabilities: required.capabilities, issuedTokens: required.issuedTokens, hostKind: required.hostKind });
|
|
18
|
+
async function refresh() {
|
|
19
|
+
const load = await required.loadContributions({ workspaceId: required.workspaceId, definition: handlerContribution }, { orderByPluginId: true });
|
|
20
|
+
const { refusals } = host.sync({ loaded: load.items, refusals: load.refusals });
|
|
21
|
+
for (const line of refusals)
|
|
22
|
+
required.log(line);
|
|
23
|
+
return refusals;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
refresh,
|
|
27
|
+
...(optional.signIns === undefined ? {} : { signIns: optional.signIns }),
|
|
28
|
+
handlersFor: (input, _optional = {}) => host.handlersFor(input),
|
|
29
|
+
async bootstrapData(input, _optional = {}) {
|
|
30
|
+
await refresh();
|
|
31
|
+
return host.bootstrapData(input);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AdminSurfacePublicConfig } from "../../admin-surfaces/index.js";
|
|
2
|
+
export declare const PUBLIC_CONFIG_REFUSED_MESSAGE = "This setting is not public configuration, so a plugin surface cannot read it.";
|
|
3
|
+
/**
|
|
4
|
+
* @param required.env - The configuration the port reads (the process environment on a node host).
|
|
5
|
+
* @param required.publicNamePattern - The host's allow-list of public-config names (its own prefix and suffix shapes).
|
|
6
|
+
* @complexity O(1) per read.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAdminSurfacePublicConfig(required: {
|
|
9
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
10
|
+
readonly publicNamePattern: RegExp;
|
|
11
|
+
}, _optional?: Record<string, never>): AdminSurfacePublicConfig;
|
|
12
|
+
//# sourceMappingURL=public-config.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The `publicConfig` port for plugin admin-surface handlers: host settings a surface may see
|
|
3
|
+
* (a browser app id, a public browser key), read from the host's configuration by the names the
|
|
4
|
+
* surface declared. Values are placeholders the operator configures; unset reads as `null`.
|
|
5
|
+
*
|
|
6
|
+
* Why the host narrows names beyond the declaration check: the declaration only refuses
|
|
7
|
+
* secret-looking words, but this port reads the process environment, which also holds settings such
|
|
8
|
+
* as the site's encryption key or storage keys whose names contain none of them. So only names the
|
|
9
|
+
* host's `publicNamePattern` shapes like public plugin config are read (for example `…_APP_ID`,
|
|
10
|
+
* `…_CLIENT_ID`, `…_BROWSER_KEY` or `…_PUBLIC_KEY`), and never one with a secret word.
|
|
11
|
+
*/
|
|
12
|
+
const SECRET_WORDS = /SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|COOKIE|SESSION|SIGNING/;
|
|
13
|
+
export const PUBLIC_CONFIG_REFUSED_MESSAGE = "This setting is not public configuration, so a plugin surface cannot read it.";
|
|
14
|
+
/**
|
|
15
|
+
* @param required.env - The configuration the port reads (the process environment on a node host).
|
|
16
|
+
* @param required.publicNamePattern - The host's allow-list of public-config names (its own prefix and suffix shapes).
|
|
17
|
+
* @complexity O(1) per read.
|
|
18
|
+
*/
|
|
19
|
+
export function createAdminSurfacePublicConfig(required, _optional = {}) {
|
|
20
|
+
return {
|
|
21
|
+
async get({ name }) {
|
|
22
|
+
if (!required.publicNamePattern.test(name) || SECRET_WORDS.test(name))
|
|
23
|
+
throw new Error(PUBLIC_CONFIG_REFUSED_MESSAGE);
|
|
24
|
+
return required.env[name]?.trim() || null;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=public-config.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ProviderRegistry } from "@jini-ai/core/provider-registry";
|
|
2
|
+
import { type LoadedProviderContribution, type PluginContributionDefinition, type PluginContributionResult } from "@jini-ai/agent-plugins/lifecycle";
|
|
3
|
+
/**
|
|
4
|
+
* @file Loads the analytics providers Agent Plugins contribute: vendor FORWARDERS (Plausible /
|
|
5
|
+
* PostHog / GA4-style, selected per site by `core.analytics.sink`) and `beforeIngest` HOOKS. The
|
|
6
|
+
* generic seam that lets a plugin add a vendor without core naming one — same trust gate as mail
|
|
7
|
+
* adapters (`mail-adapter-registry.ts`): a module runs in this process, so it loads only from an
|
|
8
|
+
* ACTIVE plugin whose installed digest is a bundled one, from a contained `.mjs` path. A bad plugin
|
|
9
|
+
* drops only its own providers and every drop is a refusal line, never a throw.
|
|
10
|
+
*
|
|
11
|
+
* Manifests are data-only: `{ schemaVersion: 1, providers: [{ id, module, label? }] }`. A
|
|
12
|
+
* forwarder module's default export is an `AnalyticsForwarderModule` (it may declare its own
|
|
13
|
+
* `credentialLabel`); a hook module's default export has `beforeIngest({ hit })`.
|
|
14
|
+
*
|
|
15
|
+
* The host injects the analytics package's contracts, validators and forwarder-registry factory plus
|
|
16
|
+
* its own product-named manifest filenames (see `README.md` `## Wiring`), so this file names no vendor.
|
|
17
|
+
*/
|
|
18
|
+
export interface AnalyticsProviderDescriptor {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** Plugin-relative path of the `.mjs` module. */
|
|
21
|
+
readonly module: string;
|
|
22
|
+
readonly label?: string;
|
|
23
|
+
}
|
|
24
|
+
type ParseResult = {
|
|
25
|
+
readonly ok: true;
|
|
26
|
+
readonly descriptors: readonly AnalyticsProviderDescriptor[];
|
|
27
|
+
} | {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Parses an analytics provider manifest. Pure; unknown keys are ignored.
|
|
33
|
+
* @complexity O(p) declared providers.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseAnalyticsProvidersFile(required: {
|
|
36
|
+
readonly raw: string;
|
|
37
|
+
}, _optional?: Record<string, never>): ParseResult;
|
|
38
|
+
/** One injected provider kind (forwarders or hooks): the analytics package's contract and validator, the host's filename. */
|
|
39
|
+
export interface AnalyticsProviderKind<T> {
|
|
40
|
+
/** Registry contract this kind contributes to (the analytics package's contract constant). */
|
|
41
|
+
readonly contract: string;
|
|
42
|
+
/** The host-named file a plugin ships at its root to contribute this kind. */
|
|
43
|
+
readonly filename: string;
|
|
44
|
+
/** The module export as this kind's provider, or why not (the analytics package's validator). */
|
|
45
|
+
readonly validate: (required: {
|
|
46
|
+
readonly exported: unknown;
|
|
47
|
+
}) => T | string;
|
|
48
|
+
}
|
|
49
|
+
/** The host's contribution loader, bound to its lifecycle owner's trust gate. */
|
|
50
|
+
export type AnalyticsContributionLoader = <D, T>(input: {
|
|
51
|
+
readonly workspaceId: string;
|
|
52
|
+
readonly definition: PluginContributionDefinition<D, T>;
|
|
53
|
+
}, optional: {
|
|
54
|
+
readonly orderByPluginId: boolean;
|
|
55
|
+
}) => Promise<PluginContributionResult<T>>;
|
|
56
|
+
/** Every collaborator `loadAnalyticsProviders` needs; `F` is the forwarder module, `H` the hook. */
|
|
57
|
+
export interface AnalyticsProviderPorts<F, H> {
|
|
58
|
+
readonly forwarders: AnalyticsProviderKind<F>;
|
|
59
|
+
readonly hooks: AnalyticsProviderKind<H>;
|
|
60
|
+
/** A fresh keyed forwarder registry (the analytics package's factory). */
|
|
61
|
+
readonly createForwarderRegistry: () => ProviderRegistry<NoInfer<F>>;
|
|
62
|
+
}
|
|
63
|
+
/** The shared provider-contribution definition for one injected kind. @complexity O(1). */
|
|
64
|
+
export declare function analyticsProviderContribution<T>(required: {
|
|
65
|
+
readonly kind: AnalyticsProviderKind<T>;
|
|
66
|
+
readonly noun: string;
|
|
67
|
+
}, _optional?: Record<string, never>): PluginContributionDefinition<AnalyticsProviderDescriptor, LoadedProviderContribution<T>>;
|
|
68
|
+
export interface AnalyticsProviders<F, H> {
|
|
69
|
+
/** Keyed vendor forwarders; `core.analytics.sink` selects one per site. */
|
|
70
|
+
readonly forwarders: ProviderRegistry<F>;
|
|
71
|
+
/** `beforeIngest` handlers in a stable order (plugin id, then declaration order). */
|
|
72
|
+
readonly hooks: readonly H[];
|
|
73
|
+
/** Log-safe, one sentence per provider or plugin that was NOT loaded, and why. */
|
|
74
|
+
readonly refusals: readonly string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Builds this workspace's analytics providers from its installed Agent Plugins.
|
|
78
|
+
* @throws Nothing for a plugin-level fault; only a fault listing the package directory itself.
|
|
79
|
+
* @complexity O(p) installed plugins: two small reads plus one import per declared provider.
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadAnalyticsProviders<F, H>(required: {
|
|
82
|
+
readonly workspaceId: string;
|
|
83
|
+
readonly loadContributions: AnalyticsContributionLoader;
|
|
84
|
+
readonly analytics: AnalyticsProviderPorts<F, H>;
|
|
85
|
+
}, _optional?: Record<string, never>): Promise<AnalyticsProviders<F, H>>;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=analytics-provider-registry.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { contributeProviders, defineProviderContribution, } from "@jini-ai/agent-plugins/lifecycle";
|
|
3
|
+
const MAX_LABEL_LENGTH = 100;
|
|
4
|
+
function isPlainObject(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
/** One descriptor entry, or why it is invalid. The id grammar is the registry's (checked before import). @complexity O(1). */
|
|
8
|
+
function parseDescriptor({ entry, at }, _optional = {}) {
|
|
9
|
+
if (!isPlainObject(entry))
|
|
10
|
+
return `${at} must be an object`;
|
|
11
|
+
const { id, module, label } = entry;
|
|
12
|
+
if (typeof id !== "string")
|
|
13
|
+
return `${at}.id must be a string`;
|
|
14
|
+
if (!isRelativeModulePath(module))
|
|
15
|
+
return `${at}.module must be a relative path ending in .mjs`;
|
|
16
|
+
if (label === undefined)
|
|
17
|
+
return { id, module };
|
|
18
|
+
if (typeof label !== "string" || label.trim() === "" || label.length > MAX_LABEL_LENGTH)
|
|
19
|
+
return `${at}.label must be a non-empty string`;
|
|
20
|
+
return { id, module, label };
|
|
21
|
+
}
|
|
22
|
+
function isRelativeModulePath(module) {
|
|
23
|
+
return typeof module === "string" && module.endsWith(".mjs") && !path.posix.isAbsolute(module);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parses an analytics provider manifest. Pure; unknown keys are ignored.
|
|
27
|
+
* @complexity O(p) declared providers.
|
|
28
|
+
*/
|
|
29
|
+
export function parseAnalyticsProvidersFile(required, _optional = {}) {
|
|
30
|
+
let value;
|
|
31
|
+
try {
|
|
32
|
+
value = JSON.parse(required.raw);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return { ok: false, reason: "not valid JSON" };
|
|
36
|
+
}
|
|
37
|
+
if (!isPlainObject(value) || value.schemaVersion !== 1)
|
|
38
|
+
return { ok: false, reason: "schemaVersion must be 1" };
|
|
39
|
+
if (!Array.isArray(value.providers))
|
|
40
|
+
return { ok: false, reason: "providers must be an array" };
|
|
41
|
+
const descriptors = [];
|
|
42
|
+
for (const [index, entry] of value.providers.entries()) {
|
|
43
|
+
const result = parseDescriptor({ entry, at: `providers[${index}]` });
|
|
44
|
+
if (typeof result === "string")
|
|
45
|
+
return { ok: false, reason: result };
|
|
46
|
+
if (descriptors.some((seen) => seen.id === result.id))
|
|
47
|
+
return { ok: false, reason: `providers[${index}].id '${result.id}' is declared twice` };
|
|
48
|
+
descriptors.push(result);
|
|
49
|
+
}
|
|
50
|
+
return { ok: true, descriptors };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Per-plugin recovery: an unreadable manifest or a module that throws on import is that plugin's
|
|
54
|
+
* refusal line, so one broken plugin never discards the healthy forwarders and hooks beside it.
|
|
55
|
+
*/
|
|
56
|
+
const recovery = (required) => ({
|
|
57
|
+
onReadError: ({ plugin }) => [`analytics ${required.noun} from '${plugin.pluginId}' were not loaded: ${required.filename} could not be read`],
|
|
58
|
+
importErrorReason: "its module failed to load",
|
|
59
|
+
});
|
|
60
|
+
/** The shared provider-contribution definition for one injected kind. @complexity O(1). */
|
|
61
|
+
export function analyticsProviderContribution(required, _optional = {}) {
|
|
62
|
+
const { contract, filename, validate } = required.kind;
|
|
63
|
+
return defineProviderContribution({
|
|
64
|
+
contract, filename, parse: ({ raw }) => parseAnalyticsProvidersFile({ raw }),
|
|
65
|
+
validate: ({ exported }) => validate({ exported }),
|
|
66
|
+
}, recovery({ noun: required.noun, filename }));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Builds this workspace's analytics providers from its installed Agent Plugins.
|
|
70
|
+
* @throws Nothing for a plugin-level fault; only a fault listing the package directory itself.
|
|
71
|
+
* @complexity O(p) installed plugins: two small reads plus one import per declared provider.
|
|
72
|
+
*/
|
|
73
|
+
export async function loadAnalyticsProviders(required, _optional = {}) {
|
|
74
|
+
const { workspaceId, analytics } = required;
|
|
75
|
+
const [forwarderLoad, hookLoad] = await Promise.all([
|
|
76
|
+
required.loadContributions({ workspaceId, definition: analyticsProviderContribution({ kind: analytics.forwarders, noun: "forwarders" }) }, { orderByPluginId: true }),
|
|
77
|
+
required.loadContributions({ workspaceId, definition: analyticsProviderContribution({ kind: analytics.hooks, noun: "hooks" }) }, { orderByPluginId: true }),
|
|
78
|
+
]);
|
|
79
|
+
const forwarders = analytics.createForwarderRegistry();
|
|
80
|
+
const contributed = contributeProviders({ registry: forwarders, loaded: forwarderLoad });
|
|
81
|
+
return {
|
|
82
|
+
forwarders,
|
|
83
|
+
hooks: hookLoad.items.map((item) => item.definition.provider),
|
|
84
|
+
refusals: [...contributed.refusals, ...hookLoad.refusals],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=analytics-provider-registry.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AgentPluginArchiveEntry, AgentPluginArchiveReaderPort } from '../lifecycle/index.js';
|
|
2
|
+
export declare function toObjectArgArchiveReader({ reader }: {
|
|
3
|
+
reader: {
|
|
4
|
+
entries(required: {
|
|
5
|
+
archive: Uint8Array;
|
|
6
|
+
}): AsyncIterable<Exclude<AgentPluginArchiveEntry, {
|
|
7
|
+
kind: 'file';
|
|
8
|
+
}> | (Omit<Extract<AgentPluginArchiveEntry, {
|
|
9
|
+
kind: 'file';
|
|
10
|
+
}>, 'openReadStream'> & {
|
|
11
|
+
openReadStream(): AsyncIterable<Uint8Array>;
|
|
12
|
+
})>;
|
|
13
|
+
};
|
|
14
|
+
}, _optional?: {}): AgentPluginArchiveReaderPort;
|
|
15
|
+
export declare function toZeroArgArchiveReader({ reader }: {
|
|
16
|
+
reader: AgentPluginArchiveReaderPort;
|
|
17
|
+
}, _optional?: {}): {
|
|
18
|
+
entries({ archive }: {
|
|
19
|
+
archive: Uint8Array;
|
|
20
|
+
}): AsyncGenerator<{
|
|
21
|
+
readonly kind: "directory";
|
|
22
|
+
readonly entryPath: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "symlink" | "hardlink" | "device" | "fifo";
|
|
25
|
+
readonly entryPath: string;
|
|
26
|
+
readonly linkTarget?: string | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
openReadStream: () => AsyncIterable<Uint8Array<ArrayBufferLike>>;
|
|
29
|
+
kind: "file";
|
|
30
|
+
entryPath: string;
|
|
31
|
+
declaredSize?: (number) | undefined;
|
|
32
|
+
executable?: (boolean) | undefined;
|
|
33
|
+
}, void, unknown>;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=archive-reader-abi.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function toObjectArgArchiveReader({ reader }, _optional = {}) {
|
|
2
|
+
return {
|
|
3
|
+
async *entries({ archive }) {
|
|
4
|
+
for await (const entry of reader.entries({ archive })) {
|
|
5
|
+
if (entry.kind !== 'file')
|
|
6
|
+
yield entry;
|
|
7
|
+
else
|
|
8
|
+
yield { ...entry, openReadStream: (_required) => entry.openReadStream() };
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function toZeroArgArchiveReader({ reader }, _optional = {}) {
|
|
14
|
+
return {
|
|
15
|
+
async *entries({ archive }) {
|
|
16
|
+
for await (const entry of reader.entries({ archive })) {
|
|
17
|
+
if (entry.kind !== 'file')
|
|
18
|
+
yield entry;
|
|
19
|
+
else
|
|
20
|
+
yield { ...entry, openReadStream: () => entry.openReadStream({}) };
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=archive-reader-abi.js.map
|