@jini-ai/agent-plugins 0.6.22 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +13 -0
- package/calendly/exports/booking-calendar.css +7 -0
- package/calendly/exports/booking-calendar.html +5 -0
- package/calendly/mcp.json +10 -0
- package/calendly/plugin.json +47 -0
- package/calendly/skills/calendly/SKILL.md +27 -0
- package/charts-echarts/plugin.json +2 -2
- package/charts-recharts/plugin.json +2 -2
- package/cloudflare/lib/cms-forms.mjs +57 -0
- package/cloudflare/lib/forms.mjs +78 -18
- package/cloudflare/lib/target.mjs +17 -4
- package/cloudflare/plugin.json +2 -2
- package/cloudflare/skills/cloudflare/SKILL.md +4 -4
- package/cloudflare/skills/cloudflare/references/workers.md +4 -4
- package/cloudflare/worker/forms-receiver.mjs +81 -41
- package/cloudflare/worker/portable-validation.mjs +220 -0
- package/commerce/plugin.json +17 -0
- package/commerce/skills/commerce/SKILL.md +23 -0
- package/composio/mcp.json +1 -1
- package/composio/plugin.json +2 -2
- package/composio/skills/composio/SKILL.md +4 -4
- package/core/commerce-server.d.ts +2 -0
- package/core/commerce-server.mjs +2 -0
- package/dist/admin-surfaces/connections/connections.d.ts +35 -0
- package/dist/admin-surfaces/connections/connections.js +135 -0
- package/dist/admin-surfaces/connections/index.d.ts +3 -0
- package/dist/admin-surfaces/connections/index.js +2 -0
- package/dist/admin-surfaces/connections/ports.d.ts +110 -0
- package/dist/admin-surfaces/connections/ports.js +2 -0
- package/dist/admin-surfaces/index.d.ts +2 -0
- package/dist/admin-surfaces/index.js +1 -0
- package/dist/admin-surfaces/plugin-state-persistence.d.ts +27 -0
- package/dist/admin-surfaces/plugin-state-persistence.js +2 -0
- package/dist/admin-surfaces/plugin-state.d.ts +51 -0
- package/dist/admin-surfaces/plugin-state.js +106 -0
- package/dist/connect/access-token-tool.d.ts +240 -0
- package/dist/connect/access-token-tool.js +213 -0
- package/dist/connect/apply-connect-defaults.d.ts +91 -0
- package/dist/connect/apply-connect-defaults.js +113 -0
- package/dist/connect/apply-tool-renames.d.ts +72 -0
- package/dist/connect/apply-tool-renames.js +105 -0
- package/dist/connect/connect-card-ui.d.ts +143 -0
- package/dist/connect/connect-card-ui.js +106 -0
- package/dist/connect/connect-destination.d.ts +35 -0
- package/dist/connect/connect-destination.js +45 -0
- package/dist/connect/connect-sign-in-wait.d.ts +31 -0
- package/dist/connect/connect-sign-in-wait.js +21 -0
- package/dist/connect/connect-tool.d.ts +314 -0
- package/dist/connect/connect-tool.js +431 -0
- package/dist/connect/connection-status.d.ts +33 -0
- package/dist/connect/connection-status.js +63 -0
- package/dist/connect/credential-cards.d.ts +15 -0
- package/dist/connect/credential-cards.js +49 -0
- package/dist/connect/credential-save-tool.d.ts +45 -0
- package/dist/connect/credential-save-tool.js +156 -0
- package/dist/connect/enable-access.d.ts +67 -0
- package/dist/connect/enable-access.js +74 -0
- package/dist/connect/executable/approval.d.ts +58 -0
- package/dist/connect/executable/approval.js +40 -0
- package/dist/connect/executable/host-capabilities.d.ts +76 -0
- package/dist/connect/executable/host-capabilities.js +100 -0
- package/dist/connect/executable/index.d.ts +10 -0
- package/dist/connect/executable/index.js +9 -0
- package/dist/connect/executable/ports.d.ts +189 -0
- package/dist/connect/executable/ports.js +2 -0
- package/dist/connect/executable/register.d.ts +21 -0
- package/dist/connect/executable/register.js +125 -0
- package/dist/connect/federate-mcp.d.ts +190 -0
- package/dist/connect/federate-mcp.js +440 -0
- package/dist/connect/grant-signed-in-defaults.d.ts +96 -0
- package/dist/connect/grant-signed-in-defaults.js +100 -0
- package/dist/connect/import-access-token.d.ts +114 -0
- package/dist/connect/import-access-token.js +103 -0
- package/dist/connect/index.d.ts +19 -0
- package/dist/connect/index.js +19 -0
- package/dist/connect/plugin-credential-card.d.ts +46 -0
- package/dist/connect/plugin-credential-card.js +63 -0
- package/dist/connect/plugin-host/index.d.ts +203 -0
- package/dist/connect/plugin-host/index.js +153 -0
- package/dist/connect/ports.d.ts +74 -0
- package/dist/connect/ports.js +2 -0
- package/dist/connect/switch-on-saved-token.d.ts +48 -0
- package/dist/connect/switch-on-saved-token.js +20 -0
- package/dist/connect/token-sign-in.d.ts +51 -0
- package/dist/connect/token-sign-in.js +43 -0
- package/dist/core/identity-namespace.d.ts +39 -0
- package/dist/core/identity-namespace.js +61 -3
- package/dist/folder-zip-node.js +3 -1
- package/dist/lifecycle/automatic-use.d.ts +12 -7
- package/dist/lifecycle/automatic-use.js +37 -28
- package/dist/lifecycle/capability-projection.js +5 -1
- package/dist/lifecycle/contribution-loader.d.ts +2 -7
- package/dist/lifecycle/contribution-types.d.ts +8 -0
- package/dist/lifecycle/contribution-types.js +2 -0
- package/dist/lifecycle/credential-card-metadata.d.ts +23 -0
- package/dist/lifecycle/credential-card-metadata.js +184 -0
- package/dist/lifecycle/exports.d.ts +11 -0
- package/dist/lifecycle/exports.js +64 -3
- package/dist/lifecycle/host-tools/identity.d.ts +38 -0
- package/dist/lifecycle/host-tools/identity.js +58 -0
- package/dist/lifecycle/host-tools/index.d.ts +20 -0
- package/dist/lifecycle/host-tools/index.js +20 -0
- package/dist/lifecycle/host-tools/memory-tools.d.ts +22 -0
- package/dist/lifecycle/host-tools/memory-tools.js +63 -0
- package/dist/lifecycle/host-tools/ports.d.ts +121 -0
- package/dist/lifecycle/host-tools/ports.js +2 -0
- package/dist/lifecycle/host-tools/provider-status-tool.d.ts +88 -0
- package/dist/lifecycle/host-tools/provider-status-tool.js +45 -0
- package/dist/lifecycle/host-tools/search-tool.d.ts +74 -0
- package/dist/lifecycle/host-tools/search-tool.js +282 -0
- package/dist/lifecycle/host-tools/skill-tool.d.ts +219 -0
- package/dist/lifecycle/host-tools/skill-tool.js +482 -0
- package/dist/lifecycle/host-tools/write-note-tool.d.ts +22 -0
- package/dist/lifecycle/host-tools/write-note-tool.js +47 -0
- package/dist/lifecycle/index.d.ts +2 -1
- package/dist/lifecycle/install.js +2 -1
- package/dist/lifecycle/installed-package-index.js +5 -8
- package/dist/lifecycle/mail/adapter-descriptors.d.ts +78 -0
- package/dist/lifecycle/mail/adapter-descriptors.js +155 -0
- package/dist/lifecycle/mail/catalog.d.ts +116 -0
- package/dist/lifecycle/mail/catalog.js +72 -0
- package/dist/lifecycle/mail/configuration.d.ts +25 -0
- package/dist/lifecycle/mail/configuration.js +62 -0
- package/dist/lifecycle/mail/contribution.d.ts +89 -0
- package/dist/lifecycle/mail/contribution.js +115 -0
- package/dist/lifecycle/mail/host-mailer.d.ts +24 -0
- package/dist/lifecycle/mail/host-mailer.js +10 -0
- package/dist/lifecycle/mail/index.d.ts +16 -0
- package/dist/lifecycle/mail/index.js +16 -0
- package/dist/lifecycle/mail/selection.d.ts +40 -0
- package/dist/lifecycle/mail/selection.js +86 -0
- package/dist/lifecycle/manifest.d.ts +7 -2
- package/dist/lifecycle/manifest.js +32 -9
- package/dist/lifecycle/metadata.d.ts +31 -0
- package/dist/lifecycle/metadata.js +80 -0
- package/dist/lifecycle/persistent-state.js +2 -1
- package/dist/lifecycle/ports.d.ts +2 -0
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -1
- package/dist/lifecycle/resolve-agent-plugin-refs.js +14 -8
- package/dist/lifecycle/search-projection.d.ts +3 -4
- package/dist/lifecycle/search-projection.js +5 -7
- package/dist/lifecycle/search.js +3 -2
- package/fly/plugin.json +5 -5
- package/fly/skills/fly/SKILL.md +1 -1
- package/formspree/plugin.json +7 -0
- package/formspree/skills/formspree/SKILL.md +11 -0
- package/github/plugin.json +2 -2
- package/github/skills/github/SKILL.md +28 -28
- package/github/skills/github/references/actions.md +8 -8
- package/github/skills/github/references/auth-and-tokens.md +7 -7
- package/github/skills/github/references/repo-files.md +5 -5
- package/github/skills/github/references/site-backup.md +16 -16
- package/github/skills/github/references/source-control.md +17 -17
- package/github-pages/plugin.json +2 -2
- package/github-pages/skills/github-pages/SKILL.md +3 -3
- package/google-forms/plugin.json +7 -0
- package/google-forms/skills/google-forms/SKILL.md +15 -0
- package/google-login/plugin.json +3 -3
- package/google-login/skills/google-login/SKILL.md +17 -60
- package/google-workspace/plugin.json +6 -6
- package/google-workspace/skills/google-workspace/references/connection.md +1 -1
- package/google-workspace/skills/google-workspace/references/form-delivery.md +4 -4
- package/google-workspace/tovu-admin-surfaces.json +5 -5
- package/higgsfield-media/plugin.json +5 -5
- package/higgsfield-media/skills/higgsfield-media/SKILL.md +31 -33
- package/higgsfield-media/skills/higgsfield-media/references/failure-modes.md +7 -7
- package/higgsfield-media/skills/higgsfield-media/references/models-and-plan-gates.md +3 -3
- package/jev/plugin.json +2 -2
- package/langfuse/plugin.json +2 -2
- package/meilisearch/plugin.json +2 -2
- package/meilisearch/skills/meilisearch/SKILL.md +1 -1
- package/netlify/plugin.json +2 -2
- package/netlify/skills/netlify/SKILL.md +3 -3
- package/opentelemetry/plugin.json +2 -2
- package/opentelemetry/skills/opentelemetry/SKILL.md +7 -7
- package/package.json +92 -14
- package/posthog/plugin.json +2 -2
- package/posthog/skills/posthog/SKILL.md +7 -7
- package/railway/plugin.json +3 -3
- package/railway/skills/railway/SKILL.md +10 -11
- package/render/plugin.json +3 -3
- package/render/skills/render/SKILL.md +7 -8
- package/resend/NOTES.md +2 -2
- package/resend/mcp.json +1 -1
- package/resend/plugin.json +5 -5
- package/resend/skills/resend/SKILL.md +13 -13
- package/s3-compatible/plugin.json +2 -2
- package/s3-compatible/skills/s3-compatible/SKILL.md +4 -4
- package/sentry/plugin.json +2 -2
- package/sentry/skills/sentry/SKILL.md +7 -7
- package/shopify/plugin.json +2 -2
- package/site-compliance/plugin.json +2 -2
- package/site-compliance/skills/site-compliance/SKILL.md +3 -3
- package/site-compliance/skills/site-compliance/references/gdpr-eu-uk.md +1 -1
- package/site-import/plugin.json +2 -2
- package/slide-design/plugin.json +2 -2
- package/software-engineering/LICENSE +201 -0
- package/software-engineering/NOTICE +9 -0
- package/software-engineering/README.md +89 -0
- package/software-engineering/plugin.json +24 -0
- package/software-engineering/skills/software-engineering/SKILL.md +33 -0
- package/software-engineering/skills/software-engineering/references/debugging.md +54 -0
- package/software-engineering/skills/software-engineering/references/implementation.md +27 -0
- package/software-engineering/skills/software-engineering/references/planning.md +27 -0
- package/software-engineering/skills/software-engineering/references/prototyping.md +14 -0
- package/software-engineering/skills/software-engineering/references/security.md +47 -0
- package/software-engineering/skills/software-engineering/references/verification.md +53 -0
- package/stripe/plugin.json +2 -2
- package/supabase/mcp.json +4 -4
- package/supabase/plugin.json +3 -3
- package/supabase/skills/supabase/SKILL.md +8 -8
- package/supabase/skills/supabase/references/failure-modes.md +5 -5
- package/ui-ux-design/plugin.json +2 -2
- package/vercel/plugin.json +2 -2
- package/vercel/skills/vercel/SKILL.md +3 -3
- package/wordpress/plugin.json +2 -2
- package/wordpress/skills/wordpress/SKILL.md +3 -3
- package/wordpress/skills/wordpress/references/free-site-redirect.md +2 -2
- package/wordpress/skills/wordpress/references/subdomain.md +5 -5
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ADMIN_SURFACE_ACTION_INTENTS } from '../surface-capabilities.js';
|
|
2
|
+
function codeOf(error) {
|
|
3
|
+
const code = error?.code;
|
|
4
|
+
return typeof code === "string" ? code : "unknown";
|
|
5
|
+
}
|
|
6
|
+
/** Our own lowercase hyphenated codes pass; anything else (an upstream library's code) becomes one generic code. */
|
|
7
|
+
const SAFE_ATTEMPT_CODE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
8
|
+
function failedAttempt(error) {
|
|
9
|
+
const code = codeOf(error);
|
|
10
|
+
return { code: code.length <= 64 && SAFE_ATTEMPT_CODE.test(code) ? code : "sign-in-failed", nextAction: "reconnect" };
|
|
11
|
+
}
|
|
12
|
+
const NEVER_CONNECTED = { status: "disconnected", account: null, grantedScopes: [], pendingSwitch: null };
|
|
13
|
+
/** The plugin's declared scope sets whose scopes are all granted. @complexity O(s) hook calls. */
|
|
14
|
+
async function grantedScopeSets(host, connection, granted) {
|
|
15
|
+
const ids = [];
|
|
16
|
+
for (const id of connection.scopeSets) {
|
|
17
|
+
if ((await host.requestedScopes({ connection, scopeSetIds: [id] })).every((scope) => granted.includes(scope)))
|
|
18
|
+
ids.push(id);
|
|
19
|
+
}
|
|
20
|
+
return ids;
|
|
21
|
+
}
|
|
22
|
+
/** A staged switch's account while it can still be confirmed: after its expiry the confirm refuses, so no label. @complexity O(1). */
|
|
23
|
+
function liveStagedAccount(host, staged) {
|
|
24
|
+
return staged && Date.parse(staged.expiresAt) > host.nowMs() ? staged.account : null;
|
|
25
|
+
}
|
|
26
|
+
/** Token-free status; scope sets are the plugin's own ids, never raw provider scopes. */
|
|
27
|
+
async function statusFrom(host, connection, view, connectionRef) {
|
|
28
|
+
return {
|
|
29
|
+
connectionId: connection.descriptor.connectionId, status: view.status, accountLabel: view.account?.displayName ?? null,
|
|
30
|
+
grantedScopeSetIds: view.status === "connected" ? await grantedScopeSets(host, connection, view.grantedScopes) : [],
|
|
31
|
+
pendingSwitchAccountLabel: view.pendingSwitch?.displayName ?? null,
|
|
32
|
+
lastSignInAttempt: host.attempts.get(connectionRef) ?? null,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Builds the per-call connections port for one plugin, workspace and (for account actions) admin.
|
|
37
|
+
* @complexity Each call: one contribution load plus one record read or one service call.
|
|
38
|
+
*/
|
|
39
|
+
export function createAdminSurfaceConnections(required, _optional = {}) {
|
|
40
|
+
const { host, pluginId, workspaceId, principalId } = required;
|
|
41
|
+
async function resolve(connectionId) {
|
|
42
|
+
const connection = workspaceId === host.workspaceId ? (await host.listConnections({ pluginId })).find((candidate) => candidate.descriptor.connectionId === connectionId) : undefined;
|
|
43
|
+
if (!connection)
|
|
44
|
+
throw host.notAvailable();
|
|
45
|
+
return { connection, connectionRef: host.connectionKey({ workspaceId, pluginId, connectionId }) };
|
|
46
|
+
}
|
|
47
|
+
/** Account actions need the admin the route authenticated; Jini checks it too. */
|
|
48
|
+
async function forActor(connectionId) {
|
|
49
|
+
if (principalId === undefined)
|
|
50
|
+
throw host.notAvailable();
|
|
51
|
+
return { ...(await resolve(connectionId)), actorId: principalId };
|
|
52
|
+
}
|
|
53
|
+
/** An action's result view, its staged-switch label re-read from the record so an expired one never shows. */
|
|
54
|
+
async function viewAfterAction(connectionRef, view) {
|
|
55
|
+
return { ...view, pendingSwitch: liveStagedAccount(host, (await host.readRecord({ key: connectionRef }))?.staged) };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Desktop: deposit the callback fields once the loopback sign-in redeemed, and clear a failed
|
|
59
|
+
* attempt; a failure is kept (code and next action only) for `status` and logged by code only.
|
|
60
|
+
*/
|
|
61
|
+
function watchDesktopCompletion(connectionId, attemptId, completion) {
|
|
62
|
+
const connectionRef = host.connectionKey({ workspaceId, pluginId, connectionId });
|
|
63
|
+
void completion?.then((done) => {
|
|
64
|
+
if (!done)
|
|
65
|
+
return;
|
|
66
|
+
host.attempts.delete(connectionRef);
|
|
67
|
+
host.callbackInbox.deposit({ workspaceId, pluginId, connectionId, attemptId, fields: done.callbackFields });
|
|
68
|
+
},
|
|
69
|
+
// Error codes only: a desktop sign-in that failed after the browser opened.
|
|
70
|
+
(error) => {
|
|
71
|
+
host.attempts.set(connectionRef, failedAttempt(error));
|
|
72
|
+
console.warn(`[admin-surfaces] desktop sign-in for '${pluginId}' did not complete: ${codeOf(error)}`);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
async getAccessToken({ connectionId }) {
|
|
77
|
+
const { connectionRef } = await forActor(connectionId);
|
|
78
|
+
const pinned = host.pinnedTokenOptions?.({ signal: required.signal, connectionRef }) ?? {};
|
|
79
|
+
return host.getAccessToken({ workspaceId, pluginId, connectionRef }, pinned);
|
|
80
|
+
},
|
|
81
|
+
async status({ connectionId }) {
|
|
82
|
+
const { connection, connectionRef } = await resolve(connectionId);
|
|
83
|
+
if (host.sharedOAuth && await host.sharedOAuth.hasBinding(connection)) {
|
|
84
|
+
const shared = await host.sharedOAuth.getStatus(connection);
|
|
85
|
+
const account = shared?.account ?? null;
|
|
86
|
+
return statusFrom(host, connection, shared ? { ...shared, account, pendingSwitch: null } : NEVER_CONNECTED, connectionRef);
|
|
87
|
+
}
|
|
88
|
+
const record = await host.readRecord({ key: connectionRef });
|
|
89
|
+
return statusFrom(host, connection, record ? { ...record, pendingSwitch: liveStagedAccount(host, record.staged) } : NEVER_CONNECTED, connectionRef);
|
|
90
|
+
},
|
|
91
|
+
async begin({ connectionId, action }, optional = {}) {
|
|
92
|
+
const { connection, actorId } = await forActor(connectionId);
|
|
93
|
+
const shared = host.sharedOAuth && await host.sharedOAuth.hasBinding(connection);
|
|
94
|
+
if (shared && ADMIN_SURFACE_ACTION_INTENTS[action] === "switch-account")
|
|
95
|
+
throw host.notAvailable();
|
|
96
|
+
const start = await host.startSignIn({ connection, actorId, intent: ADMIN_SURFACE_ACTION_INTENTS[action], scopeSetIds: optional.scopeSetIds ?? [],
|
|
97
|
+
...(shared ? { destination: "shared" } : {}) }, {
|
|
98
|
+
...(optional.startParams === undefined ? {} : { startParams: optional.startParams }),
|
|
99
|
+
});
|
|
100
|
+
const issued = { authorizationUrl: start.authorizationUrl, attemptId: start.attemptId, expiresAt: start.expiresAt };
|
|
101
|
+
watchDesktopCompletion(connectionId, issued.attemptId, start.completion);
|
|
102
|
+
required.onSignInIssued?.({ ...issued, pluginId, connectionId });
|
|
103
|
+
return issued;
|
|
104
|
+
},
|
|
105
|
+
async confirmSwitch({ connectionId }) {
|
|
106
|
+
const { connection, connectionRef, actorId } = await forActor(connectionId);
|
|
107
|
+
if (host.sharedOAuth && await host.sharedOAuth.hasBinding(connection))
|
|
108
|
+
throw host.notAvailable();
|
|
109
|
+
const view = await host.service({ connection }).confirmSwitchAccount({ connectionRef, workspaceId, actorId });
|
|
110
|
+
return statusFrom(host, connection, await viewAfterAction(connectionRef, view), connectionRef);
|
|
111
|
+
},
|
|
112
|
+
async cancelSwitch({ connectionId }) {
|
|
113
|
+
const { connection, connectionRef } = await forActor(connectionId);
|
|
114
|
+
if (host.sharedOAuth && await host.sharedOAuth.hasBinding(connection))
|
|
115
|
+
throw host.notAvailable();
|
|
116
|
+
const view = await host.service({ connection }).cancelSwitchAccount({ connectionRef, workspaceId });
|
|
117
|
+
return statusFrom(host, connection, await viewAfterAction(connectionRef, view), connectionRef);
|
|
118
|
+
},
|
|
119
|
+
async disconnect({ connectionId }) {
|
|
120
|
+
const { connection, connectionRef } = await forActor(connectionId);
|
|
121
|
+
if (host.sharedOAuth && await host.sharedOAuth.hasBinding(connection)) {
|
|
122
|
+
await host.sharedOAuth.stopUsing(connection);
|
|
123
|
+
return { ...(await statusFrom(host, connection, NEVER_CONNECTED, connectionRef)), revocation: "not-needed" };
|
|
124
|
+
}
|
|
125
|
+
const outcome = await host.service({ connection }).disconnect({ connectionRef, workspaceId });
|
|
126
|
+
// Same vocabulary on both sides: the provider's outcome passes through unchanged.
|
|
127
|
+
return { ...(await statusFrom(host, connection, await viewAfterAction(connectionRef, outcome), connectionRef)), revocation: outcome.remoteRevocation };
|
|
128
|
+
},
|
|
129
|
+
async takeCallbackFields({ connectionId, attemptId }) {
|
|
130
|
+
await resolve(connectionId);
|
|
131
|
+
return host.callbackInbox.take({ workspaceId, pluginId, connectionId, attemptId });
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createAdminSurfaceConnections, type AdminSurfaceConnectionsDeps, type IssuedSignIn } from './connections.js';
|
|
2
|
+
export type { AdminSurfaceConnectionsHost, AdminSurfaceDeclaredConnection, AdminSurfaceConnectionAccount, AdminSurfaceStagedAccount, AdminSurfaceStatusView, AdminSurfaceConnectionRecord, AdminSurfaceAccountAction, AdminSurfaceDisconnected, AdminSurfaceSignInStart, AdminSurfaceSignInStarted, AdminSurfaceCallbackInbox } from './ports.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { AdminSurfaceAuthorizationStart, AdminSurfaceConnectionState, AdminSurfaceRevocationOutcome, AdminSurfaceSignInAttempt } from '../surface-capabilities.js';
|
|
2
|
+
import type { AdminSurfaceCallbackFieldKey } from '../callback-field-inbox.js';
|
|
3
|
+
/** The loaded connection stays opaque beyond the fields this domain actually reads. */
|
|
4
|
+
export interface AdminSurfaceDeclaredConnection {
|
|
5
|
+
readonly pluginId: string;
|
|
6
|
+
readonly descriptor: {
|
|
7
|
+
readonly connectionId: string;
|
|
8
|
+
};
|
|
9
|
+
readonly scopeSets: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export interface AdminSurfaceConnectionAccount {
|
|
12
|
+
readonly accountId: string;
|
|
13
|
+
readonly displayName: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AdminSurfaceStagedAccount {
|
|
16
|
+
readonly expiresAt: string;
|
|
17
|
+
readonly account: AdminSurfaceConnectionAccount;
|
|
18
|
+
}
|
|
19
|
+
export interface AdminSurfaceStatusView {
|
|
20
|
+
readonly status: AdminSurfaceConnectionState;
|
|
21
|
+
readonly account: AdminSurfaceConnectionAccount | null;
|
|
22
|
+
readonly grantedScopes: readonly string[];
|
|
23
|
+
readonly pendingSwitch: AdminSurfaceConnectionAccount | null;
|
|
24
|
+
}
|
|
25
|
+
export interface AdminSurfaceConnectionRecord extends Omit<AdminSurfaceStatusView, 'pendingSwitch'> {
|
|
26
|
+
readonly staged: AdminSurfaceStagedAccount | null;
|
|
27
|
+
}
|
|
28
|
+
export interface AdminSurfaceAccountAction {
|
|
29
|
+
readonly connectionRef: string;
|
|
30
|
+
readonly workspaceId: string;
|
|
31
|
+
readonly actorId: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AdminSurfaceDisconnected extends AdminSurfaceStatusView {
|
|
34
|
+
readonly remoteRevocation: AdminSurfaceRevocationOutcome;
|
|
35
|
+
}
|
|
36
|
+
export interface AdminSurfaceSignInStart<Connection extends AdminSurfaceDeclaredConnection> {
|
|
37
|
+
readonly connection: Connection;
|
|
38
|
+
readonly actorId: string;
|
|
39
|
+
readonly intent: 'connect' | 'switch-account';
|
|
40
|
+
readonly scopeSetIds: readonly string[];
|
|
41
|
+
readonly destination?: 'site' | 'shared' | undefined;
|
|
42
|
+
}
|
|
43
|
+
export interface AdminSurfaceSignInStarted extends AdminSurfaceAuthorizationStart {
|
|
44
|
+
readonly completion?: Promise<{
|
|
45
|
+
readonly callbackFields: Readonly<Record<string, string>>;
|
|
46
|
+
} | null>;
|
|
47
|
+
}
|
|
48
|
+
export interface AdminSurfaceCallbackInbox {
|
|
49
|
+
deposit(required: AdminSurfaceCallbackFieldKey & {
|
|
50
|
+
readonly fields: Readonly<Record<string, string>>;
|
|
51
|
+
}): void;
|
|
52
|
+
take(required: AdminSurfaceCallbackFieldKey): Readonly<Record<string, string>> | null;
|
|
53
|
+
}
|
|
54
|
+
/** @agent-note Fulfill from the one API connection host your tools and callback route already share. A second
|
|
55
|
+
* host loses callbacks. `pinnedTokenOptions` must read the same frozen accounts as the tool registrar. */
|
|
56
|
+
export interface AdminSurfaceConnectionsHost<Connection extends AdminSurfaceDeclaredConnection = AdminSurfaceDeclaredConnection> {
|
|
57
|
+
readonly workspaceId: string;
|
|
58
|
+
nowMs(): number;
|
|
59
|
+
connectionKey(required: {
|
|
60
|
+
workspaceId: string;
|
|
61
|
+
pluginId: string;
|
|
62
|
+
connectionId: string;
|
|
63
|
+
}): string;
|
|
64
|
+
listConnections(required: {
|
|
65
|
+
pluginId: string;
|
|
66
|
+
}): Promise<readonly Connection[]>;
|
|
67
|
+
requestedScopes(required: {
|
|
68
|
+
connection: Connection;
|
|
69
|
+
scopeSetIds: readonly string[];
|
|
70
|
+
}): Promise<readonly string[]>;
|
|
71
|
+
readRecord(required: {
|
|
72
|
+
key: string;
|
|
73
|
+
}): Promise<AdminSurfaceConnectionRecord | null>;
|
|
74
|
+
getAccessToken(required: {
|
|
75
|
+
workspaceId: string;
|
|
76
|
+
pluginId: string;
|
|
77
|
+
connectionRef: string;
|
|
78
|
+
}, optional?: {
|
|
79
|
+
expectedAccountId?: string;
|
|
80
|
+
}): Promise<string>;
|
|
81
|
+
startSignIn(required: AdminSurfaceSignInStart<Connection>, optional?: {
|
|
82
|
+
startParams?: Readonly<Record<string, string>>;
|
|
83
|
+
}): Promise<AdminSurfaceSignInStarted>;
|
|
84
|
+
service(required: {
|
|
85
|
+
connection: Connection;
|
|
86
|
+
}): {
|
|
87
|
+
confirmSwitchAccount(required: AdminSurfaceAccountAction): Promise<AdminSurfaceStatusView>;
|
|
88
|
+
cancelSwitchAccount(required: Omit<AdminSurfaceAccountAction, 'actorId'>): Promise<AdminSurfaceStatusView>;
|
|
89
|
+
disconnect(required: Omit<AdminSurfaceAccountAction, 'actorId'>): Promise<AdminSurfaceDisconnected>;
|
|
90
|
+
};
|
|
91
|
+
readonly attempts: {
|
|
92
|
+
get(ref: string): AdminSurfaceSignInAttempt | undefined;
|
|
93
|
+
set(ref: string, attempt: AdminSurfaceSignInAttempt): void;
|
|
94
|
+
delete(ref: string): void;
|
|
95
|
+
};
|
|
96
|
+
readonly callbackInbox: AdminSurfaceCallbackInbox;
|
|
97
|
+
readonly sharedOAuth?: {
|
|
98
|
+
hasBinding(connection: Connection): Promise<boolean>;
|
|
99
|
+
getStatus(connection: Connection): Promise<Omit<AdminSurfaceStatusView, 'pendingSwitch'> | null>;
|
|
100
|
+
stopUsing(connection: Connection): Promise<void>;
|
|
101
|
+
};
|
|
102
|
+
notAvailable(): Error;
|
|
103
|
+
pinnedTokenOptions?(required: {
|
|
104
|
+
signal?: AbortSignal | undefined;
|
|
105
|
+
connectionRef: string;
|
|
106
|
+
}): {
|
|
107
|
+
expectedAccountId?: string;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -20,4 +20,6 @@ export type { AdminSurfaceDeliveryBinding, AdminSurfaceDeliveryBindingDraft, Adm
|
|
|
20
20
|
export { openAdminSurfaceLink, type AdminSurfaceOpenLinkPort, type AdminSurfaceLinkVerdict } from './external-links.js';
|
|
21
21
|
export { createAdminSurfaceCallbackInbox, type AdminSurfaceCallbackFieldKey } from './callback-field-inbox.js';
|
|
22
22
|
export { buildAdminSurfaceActionTools, type AdminSurfaceToolSource, type AdminSurfaceToolContext } from './action-tools.js';
|
|
23
|
+
export type { AdminSurfacePluginStatePersistence } from './plugin-state-persistence.js';
|
|
24
|
+
export { createAgentPluginStateStore, PLUGIN_STATE_MAX_KEYS, type AgentPluginStateScope, type AgentPluginStateStore, type AgentPluginStateSummary } from './plugin-state.js';
|
|
23
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -18,4 +18,5 @@ export { ADMIN_SURFACE_ACTION_INTENTS, ADMIN_SURFACE_STATE_LIMITS, } from './sur
|
|
|
18
18
|
export { openAdminSurfaceLink } from './external-links.js';
|
|
19
19
|
export { createAdminSurfaceCallbackInbox } from './callback-field-inbox.js';
|
|
20
20
|
export { buildAdminSurfaceActionTools } from './action-tools.js';
|
|
21
|
+
export { createAgentPluginStateStore, PLUGIN_STATE_MAX_KEYS } from './plugin-state.js';
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { VaultContext, VaultIdentity, VaultMeta, VaultSummary } from '@jini-ai/core/contracts/vault';
|
|
2
|
+
/** @agent-note Back it with the same vault object as your API connection host; `format` and the row ids are saved; never change them. */
|
|
3
|
+
export interface AdminSurfacePluginStatePersistence {
|
|
4
|
+
readonly scope: VaultContext;
|
|
5
|
+
readonly format: string;
|
|
6
|
+
readonly vault: {
|
|
7
|
+
list(required: VaultContext): Promise<readonly VaultSummary[]>;
|
|
8
|
+
get(required: VaultIdentity): Promise<{
|
|
9
|
+
summary: VaultSummary;
|
|
10
|
+
payload: VaultMeta | null;
|
|
11
|
+
} | null>;
|
|
12
|
+
put(required: VaultIdentity & {
|
|
13
|
+
expectedRevision: number | null;
|
|
14
|
+
provider: null;
|
|
15
|
+
label: string;
|
|
16
|
+
meta: VaultMeta;
|
|
17
|
+
payload: VaultMeta;
|
|
18
|
+
}): Promise<VaultSummary>;
|
|
19
|
+
delete(required: VaultIdentity & {
|
|
20
|
+
expectedRevision: number;
|
|
21
|
+
}): Promise<boolean>;
|
|
22
|
+
};
|
|
23
|
+
isConflict(required: {
|
|
24
|
+
error: unknown;
|
|
25
|
+
}): boolean;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=plugin-state-persistence.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type AdminSurfaceState } from "./surface-capabilities.js";
|
|
2
|
+
import type { AdminSurfacePluginStatePersistence } from "./plugin-state-persistence.js";
|
|
3
|
+
import type { AgentPluginStateReader } from "../lifecycle/tools/capabilities.js";
|
|
4
|
+
/**
|
|
5
|
+
* @file A plugin's own settings ("state": which products are on, the chosen resource), one JSON
|
|
6
|
+
* value per key, scoped to one workspace and one plugin. The admin-surface port writes it; the
|
|
7
|
+
* plugin's tools and its form delivery only read it, so a setting a surface saves is what they honor.
|
|
8
|
+
*
|
|
9
|
+
* Why the api-connection vault rows: they already give per-workspace rows, revision-checked writes
|
|
10
|
+
* and exclusion from the exportable settings ledger, so plugin state needs no new table or vault
|
|
11
|
+
* kind (no migration). Values are not secret; Jini's surface session refuses a value that mentions
|
|
12
|
+
* a token the call obtained, and this store re-checks the size and key caps itself so a host path
|
|
13
|
+
* that skips the session cannot grow storage without bound.
|
|
14
|
+
*/
|
|
15
|
+
/** Keys one plugin may hold in one workspace; a new key past this is refused, existing keys still update. */
|
|
16
|
+
export declare const PLUGIN_STATE_MAX_KEYS = 128;
|
|
17
|
+
export interface AgentPluginStateScope {
|
|
18
|
+
readonly workspaceId: string;
|
|
19
|
+
readonly pluginId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentPluginStateStore {
|
|
22
|
+
/** Read-write view for the plugin's admin-surface handlers. */
|
|
23
|
+
forPlugin(required: AgentPluginStateScope, optional?: Record<string, never>): AdminSurfaceState;
|
|
24
|
+
/** Read-only view (`get` alone) for the plugin's tools and form delivery. */
|
|
25
|
+
readerFor(required: AgentPluginStateScope, optional?: Record<string, never>): AgentPluginStateReader;
|
|
26
|
+
/** Non-secret summary of the plugin's saved settings: each key with its vault revision, sorted by
|
|
27
|
+
* key, never a value. The Agent Plugin update journal records it as its settings snapshot, and that
|
|
28
|
+
* journal is a plaintext file on disk, so values must never reach it. */
|
|
29
|
+
describe(required: AgentPluginStateScope, optional?: Record<string, never>): Promise<AgentPluginStateSummary>;
|
|
30
|
+
}
|
|
31
|
+
export interface AgentPluginStateSummary {
|
|
32
|
+
readonly keys: readonly {
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly revision: number;
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates the workspace's plugin-state store over the api-connection vault.
|
|
39
|
+
* @param required.vault - The workspace's api-connection vault (`createApiConnectionVault`).
|
|
40
|
+
* @param required.workspaceId - The only workspace this store serves; any other scope is refused.
|
|
41
|
+
* @complexity get/delete O(1) vault calls; set O(r) in the workspace's api-connection rows (one
|
|
42
|
+
* summary listing); describe O(r log r).
|
|
43
|
+
*/
|
|
44
|
+
export declare function createAgentPluginStateStore(required: {
|
|
45
|
+
readonly persistence: AdminSurfacePluginStatePersistence;
|
|
46
|
+
readonly workspaceId: string;
|
|
47
|
+
readonly messages: {
|
|
48
|
+
readonly unavailable: string;
|
|
49
|
+
};
|
|
50
|
+
}, _optional?: Record<string, never>): AgentPluginStateStore;
|
|
51
|
+
//# sourceMappingURL=plugin-state.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ADMIN_SURFACE_STATE_LIMITS } from "./surface-capabilities.js";
|
|
2
|
+
/**
|
|
3
|
+
* @file A plugin's own settings ("state": which products are on, the chosen resource), one JSON
|
|
4
|
+
* value per key, scoped to one workspace and one plugin. The admin-surface port writes it; the
|
|
5
|
+
* plugin's tools and its form delivery only read it, so a setting a surface saves is what they honor.
|
|
6
|
+
*
|
|
7
|
+
* Why the api-connection vault rows: they already give per-workspace rows, revision-checked writes
|
|
8
|
+
* and exclusion from the exportable settings ledger, so plugin state needs no new table or vault
|
|
9
|
+
* kind (no migration). Values are not secret; Jini's surface session refuses a value that mentions
|
|
10
|
+
* a token the call obtained, and this store re-checks the size and key caps itself so a host path
|
|
11
|
+
* that skips the session cannot grow storage without bound.
|
|
12
|
+
*/
|
|
13
|
+
/** Keys one plugin may hold in one workspace; a new key past this is refused, existing keys still update. */
|
|
14
|
+
export const PLUGIN_STATE_MAX_KEYS = 128;
|
|
15
|
+
const KEY_PATTERN = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,${ADMIN_SURFACE_STATE_LIMITS.maxKeyLength - 1}}$`);
|
|
16
|
+
/** Plugin ids are lowercase hyphenated, so the `:` after one always ends it. */
|
|
17
|
+
const PLUGIN_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
18
|
+
const rowPrefix = (pluginId) => `plugin-state:${pluginId}:`;
|
|
19
|
+
function checkedKey(key) {
|
|
20
|
+
if (typeof key !== "string" || !KEY_PATTERN.test(key))
|
|
21
|
+
throw new Error("A plugin setting key must be 1-128 letters, digits, '.', '_', ':' or '-'.");
|
|
22
|
+
return key;
|
|
23
|
+
}
|
|
24
|
+
/** The value as stored: one JSON text, size-checked on that text. @complexity O(n) in its size. */
|
|
25
|
+
function checkedValue(value) {
|
|
26
|
+
const text = JSON.stringify(value);
|
|
27
|
+
if (text === undefined || new TextEncoder().encode(text).byteLength > ADMIN_SURFACE_STATE_LIMITS.maxValueBytes) {
|
|
28
|
+
throw new Error(`A plugin setting may be at most ${ADMIN_SURFACE_STATE_LIMITS.maxValueBytes} bytes of JSON.`);
|
|
29
|
+
}
|
|
30
|
+
return JSON.parse(text);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates the workspace's plugin-state store over the api-connection vault.
|
|
34
|
+
* @param required.vault - The workspace's api-connection vault (`createApiConnectionVault`).
|
|
35
|
+
* @param required.workspaceId - The only workspace this store serves; any other scope is refused.
|
|
36
|
+
* @complexity get/delete O(1) vault calls; set O(r) in the workspace's api-connection rows (one
|
|
37
|
+
* summary listing); describe O(r log r).
|
|
38
|
+
*/
|
|
39
|
+
export function createAgentPluginStateStore(required, _optional = {}) {
|
|
40
|
+
const { vault, scope, format } = required.persistence;
|
|
41
|
+
const isConflict = (error) => required.persistence.isConflict({ error });
|
|
42
|
+
/** This scope's row prefix; a foreign workspace or malformed plugin id never reaches the vault. */
|
|
43
|
+
function scopedPrefix(input) {
|
|
44
|
+
if (input.workspaceId !== required.workspaceId || !PLUGIN_ID_PATTERN.test(input.pluginId))
|
|
45
|
+
throw new Error(required.messages.unavailable);
|
|
46
|
+
return rowPrefix(input.pluginId);
|
|
47
|
+
}
|
|
48
|
+
/** The row id for this scope's key. */
|
|
49
|
+
function rowId(input, key) {
|
|
50
|
+
return `${scopedPrefix(input)}${checkedKey(key)}`;
|
|
51
|
+
}
|
|
52
|
+
/** Lists summaries only: `vault.list` opens no envelope, so no value is decrypted here.
|
|
53
|
+
* @complexity O(r log r) in the workspace's api-connection rows. */
|
|
54
|
+
async function describe(input) {
|
|
55
|
+
const prefix = scopedPrefix(input);
|
|
56
|
+
const keys = (await vault.list({ ...scope }))
|
|
57
|
+
.filter((row) => row.id.startsWith(prefix))
|
|
58
|
+
.map((row) => ({ key: row.id.slice(prefix.length), revision: row.revision }))
|
|
59
|
+
// Row ids are unique per plugin, so no two keys compare equal.
|
|
60
|
+
.sort((a, b) => (a.key < b.key ? -1 : 1));
|
|
61
|
+
return { keys };
|
|
62
|
+
}
|
|
63
|
+
/** The existing row's revision comes from the summary listing, which opens no envelope: a row sealed
|
|
64
|
+
* under a key this machine no longer has (a lost or re-minted store key) can still be overwritten,
|
|
65
|
+
* so the user re-enters the setting instead of being stuck behind an error. */
|
|
66
|
+
async function write(input, key, value) {
|
|
67
|
+
const id = rowId(input, key);
|
|
68
|
+
const stored = checkedValue(value);
|
|
69
|
+
const rows = await vault.list({ ...scope });
|
|
70
|
+
const existing = rows.find((row) => row.id === id);
|
|
71
|
+
if (!existing && rows.filter((row) => row.id.startsWith(rowPrefix(input.pluginId))).length >= PLUGIN_STATE_MAX_KEYS)
|
|
72
|
+
throw new Error(`A plugin may keep at most ${PLUGIN_STATE_MAX_KEYS} settings here. Remove one and retry.`);
|
|
73
|
+
await vault.put({ ...scope, id, expectedRevision: existing?.revision ?? null, provider: null, label: `Plugin settings ${id}`,
|
|
74
|
+
meta: { credentialFormat: format }, payload: { value: stored } })
|
|
75
|
+
.catch((error) => {
|
|
76
|
+
if (isConflict(error))
|
|
77
|
+
throw new Error("This setting changed while it was being saved. Reload the plugin's settings and retry.", { cause: error });
|
|
78
|
+
throw error;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function readerFor(input) {
|
|
82
|
+
return {
|
|
83
|
+
async get({ key }) {
|
|
84
|
+
const found = await vault.get({ ...scope, id: rowId(input, key) });
|
|
85
|
+
const value = found?.payload?.value;
|
|
86
|
+
return value === undefined ? null : value;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
readerFor,
|
|
92
|
+
describe,
|
|
93
|
+
forPlugin: (input) => ({
|
|
94
|
+
...readerFor(input),
|
|
95
|
+
set: ({ key, value }) => write(input, key, value),
|
|
96
|
+
async delete({ key }) {
|
|
97
|
+
const id = rowId(input, key);
|
|
98
|
+
const existing = await vault.get({ ...scope, id });
|
|
99
|
+
if (existing)
|
|
100
|
+
await vault.delete({ ...scope, id, expectedRevision: existing.summary.revision }).catch((error) => { if (!isConflict(error))
|
|
101
|
+
throw error; });
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=plugin-state.js.map
|