@jini-ai/agent-plugins 0.4.7 → 0.6.10
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 +24 -2
- package/README.md +46 -0
- package/dist/admin-surfaces/action-dispatcher.d.ts +37 -0
- package/dist/admin-surfaces/action-dispatcher.d.ts.map +1 -0
- package/dist/admin-surfaces/action-dispatcher.js +69 -0
- package/dist/admin-surfaces/action-dispatcher.js.map +1 -0
- package/dist/admin-surfaces/action-schema.d.ts +56 -0
- package/dist/admin-surfaces/action-schema.d.ts.map +1 -0
- package/dist/admin-surfaces/action-schema.js +167 -0
- package/dist/admin-surfaces/action-schema.js.map +1 -0
- package/dist/admin-surfaces/action-tools.d.ts +40 -0
- package/dist/admin-surfaces/action-tools.d.ts.map +1 -0
- package/dist/admin-surfaces/action-tools.js +52 -0
- package/dist/admin-surfaces/action-tools.js.map +1 -0
- package/dist/admin-surfaces/callback-field-inbox.d.ts +35 -0
- package/dist/admin-surfaces/callback-field-inbox.d.ts.map +1 -0
- package/dist/admin-surfaces/callback-field-inbox.js +53 -0
- package/dist/admin-surfaces/callback-field-inbox.js.map +1 -0
- package/dist/admin-surfaces/capability-declarations.d.ts +41 -0
- package/dist/admin-surfaces/capability-declarations.d.ts.map +1 -0
- package/dist/admin-surfaces/capability-declarations.js +102 -0
- package/dist/admin-surfaces/capability-declarations.js.map +1 -0
- package/dist/admin-surfaces/contribution.d.ts +49 -0
- package/dist/admin-surfaces/contribution.d.ts.map +1 -0
- package/dist/admin-surfaces/contribution.js +30 -0
- package/dist/admin-surfaces/contribution.js.map +1 -0
- package/dist/admin-surfaces/delivery-bindings.d.ts +76 -0
- package/dist/admin-surfaces/delivery-bindings.d.ts.map +1 -0
- package/dist/admin-surfaces/delivery-bindings.js +99 -0
- package/dist/admin-surfaces/delivery-bindings.js.map +1 -0
- package/dist/admin-surfaces/descriptor.d.ts +69 -0
- package/dist/admin-surfaces/descriptor.d.ts.map +1 -0
- package/dist/admin-surfaces/descriptor.js +196 -0
- package/dist/admin-surfaces/descriptor.js.map +1 -0
- package/dist/admin-surfaces/external-links.d.ts +45 -0
- package/dist/admin-surfaces/external-links.d.ts.map +1 -0
- package/dist/admin-surfaces/external-links.js +70 -0
- package/dist/admin-surfaces/external-links.js.map +1 -0
- package/dist/admin-surfaces/host-validator.d.ts +62 -0
- package/dist/admin-surfaces/host-validator.d.ts.map +1 -0
- package/dist/admin-surfaces/host-validator.js +87 -0
- package/dist/admin-surfaces/host-validator.js.map +1 -0
- package/dist/admin-surfaces/index.d.ts +23 -0
- package/dist/admin-surfaces/index.d.ts.map +1 -0
- package/dist/admin-surfaces/index.js +21 -0
- package/dist/admin-surfaces/index.js.map +1 -0
- package/dist/admin-surfaces/protocol.d.ts +103 -0
- package/dist/admin-surfaces/protocol.d.ts.map +1 -0
- package/dist/admin-surfaces/protocol.js +25 -0
- package/dist/admin-surfaces/protocol.js.map +1 -0
- package/dist/admin-surfaces/sandbox.d.ts +78 -0
- package/dist/admin-surfaces/sandbox.d.ts.map +1 -0
- package/dist/admin-surfaces/sandbox.js +92 -0
- package/dist/admin-surfaces/sandbox.js.map +1 -0
- package/dist/admin-surfaces/settings-value.d.ts +28 -0
- package/dist/admin-surfaces/settings-value.d.ts.map +1 -0
- package/dist/admin-surfaces/settings-value.js +45 -0
- package/dist/admin-surfaces/settings-value.js.map +1 -0
- package/dist/admin-surfaces/surface-capabilities.d.ts +167 -0
- package/dist/admin-surfaces/surface-capabilities.d.ts.map +1 -0
- package/dist/admin-surfaces/surface-capabilities.js +215 -0
- package/dist/admin-surfaces/surface-capabilities.js.map +1 -0
- package/dist/admin-surfaces/surface-client.d.ts +116 -0
- package/dist/admin-surfaces/surface-client.d.ts.map +1 -0
- package/dist/admin-surfaces/surface-client.js +219 -0
- package/dist/admin-surfaces/surface-client.js.map +1 -0
- package/dist/admin-surfaces/surface-handlers.d.ts +111 -0
- package/dist/admin-surfaces/surface-handlers.d.ts.map +1 -0
- package/dist/admin-surfaces/surface-handlers.js +172 -0
- package/dist/admin-surfaces/surface-handlers.js.map +1 -0
- package/dist/admin-surfaces/theme.d.ts +59 -0
- package/dist/admin-surfaces/theme.d.ts.map +1 -0
- package/dist/admin-surfaces/theme.js +57 -0
- package/dist/admin-surfaces/theme.js.map +1 -0
- package/dist/folder-zip-node.d.ts.map +1 -0
- package/dist/folder-zip-node.js +59 -49
- package/dist/folder-zip-node.js.map +1 -0
- package/dist/folder-zip.d.ts.map +1 -0
- package/dist/folder-zip.js +9 -7
- package/dist/folder-zip.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle/activation.d.ts.map +1 -0
- package/dist/lifecycle/activation.js.map +1 -0
- package/dist/lifecycle/automatic-use.d.ts +79 -0
- package/dist/lifecycle/automatic-use.d.ts.map +1 -0
- package/dist/lifecycle/automatic-use.js +165 -0
- package/dist/lifecycle/automatic-use.js.map +1 -0
- package/dist/lifecycle/bundled-digests.d.ts.map +1 -0
- package/dist/lifecycle/bundled-digests.js.map +1 -0
- package/dist/lifecycle/bundled-source-archive.d.ts.map +1 -0
- package/dist/lifecycle/bundled-source-archive.js.map +1 -0
- package/dist/lifecycle/capability-projection.d.ts.map +1 -0
- package/dist/lifecycle/capability-projection.js.map +1 -0
- package/dist/lifecycle/compatibility-metadata.d.ts +19 -0
- package/dist/lifecycle/compatibility-metadata.d.ts.map +1 -0
- package/dist/lifecycle/compatibility-metadata.js +45 -0
- package/dist/lifecycle/compatibility-metadata.js.map +1 -0
- package/dist/lifecycle/compatibility.d.ts +52 -0
- package/dist/lifecycle/compatibility.d.ts.map +1 -0
- package/dist/lifecycle/compatibility.js +60 -0
- package/dist/lifecycle/compatibility.js.map +1 -0
- package/dist/lifecycle/contribution-loader.d.ts.map +1 -0
- package/dist/lifecycle/contribution-loader.js.map +1 -0
- package/dist/lifecycle/fetch-archive.d.ts.map +1 -0
- package/dist/lifecycle/fetch-archive.js +26 -24
- package/dist/lifecycle/fetch-archive.js.map +1 -0
- package/dist/lifecycle/index.d.ts +14 -2
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +8 -1
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/lifecycle/install-errors.d.ts.map +1 -0
- package/dist/lifecycle/install-errors.js.map +1 -0
- package/dist/lifecycle/install-from-url.d.ts.map +1 -0
- package/dist/lifecycle/install-from-url.js.map +1 -0
- package/dist/lifecycle/install.d.ts.map +1 -0
- package/dist/lifecycle/install.js +7 -0
- package/dist/lifecycle/install.js.map +1 -0
- package/dist/lifecycle/installed-package-index.d.ts.map +1 -0
- package/dist/lifecycle/installed-package-index.js +41 -29
- package/dist/lifecycle/installed-package-index.js.map +1 -0
- package/dist/lifecycle/installed-package-roots.d.ts.map +1 -0
- package/dist/lifecycle/installed-package-roots.js +28 -20
- package/dist/lifecycle/installed-package-roots.js.map +1 -0
- package/dist/lifecycle/layout.d.ts.map +1 -0
- package/dist/lifecycle/layout.js.map +1 -0
- package/dist/lifecycle/manifest.d.ts +13 -0
- package/dist/lifecycle/manifest.d.ts.map +1 -0
- package/dist/lifecycle/manifest.js +115 -101
- package/dist/lifecycle/manifest.js.map +1 -0
- package/dist/lifecycle/mcp-provisioning.d.ts.map +1 -0
- package/dist/lifecycle/mcp-provisioning.js.map +1 -0
- package/dist/lifecycle/node.d.ts.map +1 -0
- package/dist/lifecycle/node.js.map +1 -0
- package/dist/lifecycle/package-paths.d.ts.map +1 -0
- package/dist/lifecycle/package-paths.js +3 -3
- package/dist/lifecycle/package-paths.js.map +1 -0
- package/dist/lifecycle/persistent-state.d.ts.map +1 -0
- package/dist/lifecycle/persistent-state.js.map +1 -0
- package/dist/lifecycle/ports.d.ts +1 -1
- package/dist/lifecycle/ports.d.ts.map +1 -0
- package/dist/lifecycle/ports.js.map +1 -0
- package/dist/lifecycle/provider-contribution.d.ts +65 -0
- package/dist/lifecycle/provider-contribution.d.ts.map +1 -0
- package/dist/lifecycle/provider-contribution.js +93 -0
- package/dist/lifecycle/provider-contribution.js.map +1 -0
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts.map +1 -0
- package/dist/lifecycle/resolve-agent-plugin-refs.js +15 -2
- package/dist/lifecycle/resolve-agent-plugin-refs.js.map +1 -0
- package/dist/lifecycle/retire-bundled.d.ts.map +1 -0
- package/dist/lifecycle/retire-bundled.js +20 -18
- package/dist/lifecycle/retire-bundled.js.map +1 -0
- package/dist/lifecycle/search.d.ts +6 -1
- package/dist/lifecycle/search.d.ts.map +1 -0
- package/dist/lifecycle/search.js +45 -7
- package/dist/lifecycle/search.js.map +1 -0
- package/dist/lifecycle/seed-bundled.d.ts.map +1 -0
- package/dist/lifecycle/seed-bundled.js.map +1 -0
- package/dist/lifecycle/set-enabled.d.ts +2 -1
- package/dist/lifecycle/set-enabled.d.ts.map +1 -0
- package/dist/lifecycle/set-enabled.js +52 -8
- package/dist/lifecycle/set-enabled.js.map +1 -0
- package/dist/lifecycle/skill-file-reader.d.ts.map +1 -0
- package/dist/lifecycle/skill-file-reader.js +85 -71
- package/dist/lifecycle/skill-file-reader.js.map +1 -0
- package/dist/lifecycle/tools/capabilities.d.ts +199 -0
- package/dist/lifecycle/tools/capabilities.d.ts.map +1 -0
- package/dist/lifecycle/tools/capabilities.js +213 -0
- package/dist/lifecycle/tools/capabilities.js.map +1 -0
- package/dist/lifecycle/tools/definition.d.ts +32 -0
- package/dist/lifecycle/tools/definition.d.ts.map +1 -0
- package/dist/lifecycle/tools/definition.js +33 -0
- package/dist/lifecycle/tools/definition.js.map +1 -0
- package/dist/lifecycle/tools/index.d.ts +10 -0
- package/dist/lifecycle/tools/index.d.ts.map +1 -0
- package/dist/lifecycle/tools/index.js +10 -0
- package/dist/lifecycle/tools/index.js.map +1 -0
- package/dist/lifecycle/tools/manifest.d.ts +33 -0
- package/dist/lifecycle/tools/manifest.d.ts.map +1 -0
- package/dist/lifecycle/tools/manifest.js +89 -0
- package/dist/lifecycle/tools/manifest.js.map +1 -0
- package/dist/lifecycle/tools/projection.d.ts +90 -0
- package/dist/lifecycle/tools/projection.d.ts.map +1 -0
- package/dist/lifecycle/tools/projection.js +283 -0
- package/dist/lifecycle/tools/projection.js.map +1 -0
- package/dist/lifecycle/trusted-plugin-files.d.ts.map +1 -0
- package/dist/lifecycle/trusted-plugin-files.js.map +1 -0
- package/dist/lifecycle/types.d.ts +2 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/lifecycle/types.js.map +1 -0
- package/dist/lifecycle/uninstall.d.ts +3 -1
- package/dist/lifecycle/uninstall.d.ts.map +1 -0
- package/dist/lifecycle/uninstall.js +51 -27
- package/dist/lifecycle/uninstall.js.map +1 -0
- package/dist/lifecycle/update-plan.d.ts +18 -0
- package/dist/lifecycle/update-plan.d.ts.map +1 -0
- package/dist/lifecycle/update-plan.js +22 -0
- package/dist/lifecycle/update-plan.js.map +1 -0
- package/dist/lifecycle/update-store.d.ts +71 -0
- package/dist/lifecycle/update-store.d.ts.map +1 -0
- package/dist/lifecycle/update-store.js +150 -0
- package/dist/lifecycle/update-store.js.map +1 -0
- package/dist/lifecycle/update.d.ts +55 -0
- package/dist/lifecycle/update.d.ts.map +1 -0
- package/dist/lifecycle/update.js +321 -0
- package/dist/lifecycle/update.js.map +1 -0
- package/dist/lifecycle/yauzl-archive-reader.d.ts.map +1 -0
- package/dist/lifecycle/yauzl-archive-reader.js.map +1 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js.map +1 -0
- package/package.json +39 -7
- package/ui-ux-design/plugin.json +7 -2
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The wire vocabulary shared by the host page, the host server and a plugin's admin surface:
|
|
3
|
+
* protocol constants and the message envelopes (init, action request, open-link request, response).
|
|
4
|
+
*
|
|
5
|
+
* Why a separate file: the host-side validator, the server-side dispatcher and the docs all name the
|
|
6
|
+
* same envelope, and it must stay one definition. The surface-side client (`./surface-client.ts`)
|
|
7
|
+
* deliberately repeats the constants instead of importing them so a plugin can copy that one file;
|
|
8
|
+
* the vertical-slice test proves both sides still agree.
|
|
9
|
+
*/
|
|
10
|
+
import type { AdminSurfaceTheme } from './theme.js';
|
|
11
|
+
/** Discriminates this protocol's messages from anything else posted to the same window. */
|
|
12
|
+
export declare const ADMIN_SURFACE_PROTOCOL = "jini.admin-surface";
|
|
13
|
+
export declare const ADMIN_SURFACE_PROTOCOL_VERSION = 1;
|
|
14
|
+
/** The ONLY sandbox token a surface frame gets. Adding `allow-same-origin` next to `allow-scripts`
|
|
15
|
+
* lets the frame remove its own sandbox, so it is never granted. */
|
|
16
|
+
export declare const ADMIN_SURFACE_SANDBOX = "allow-scripts";
|
|
17
|
+
/** A frame sandboxed without `allow-same-origin` has an opaque origin, which `MessageEvent.origin`
|
|
18
|
+
* serializes as the string "null". Every sandboxed frame shares it, so origin alone never identifies
|
|
19
|
+
* a mount: the per-mount nonce and the frame's window identity do. */
|
|
20
|
+
export declare const SANDBOXED_FRAME_ORIGIN = "null";
|
|
21
|
+
/** Short-lived data the host server issues for one surface render (e.g. a scoped access token plus
|
|
22
|
+
* public config). Never cached (see `adminSurfaceBootstrapHeaders`), refused once `expiresAt` passes. */
|
|
23
|
+
export interface AdminSurfaceBootstrap<D = unknown> {
|
|
24
|
+
readonly surfaceId: string;
|
|
25
|
+
readonly issuedAt: number;
|
|
26
|
+
readonly expiresAt: number;
|
|
27
|
+
readonly data: D;
|
|
28
|
+
}
|
|
29
|
+
/** Host page -> surface, once per mount, after the frame loads. Carries the mount nonce and, when
|
|
30
|
+
* the host shares them, its design tokens (`./theme.ts`; later changes arrive as `theme` messages). */
|
|
31
|
+
export interface AdminSurfaceInitMessage {
|
|
32
|
+
readonly protocol: typeof ADMIN_SURFACE_PROTOCOL;
|
|
33
|
+
readonly version: typeof ADMIN_SURFACE_PROTOCOL_VERSION;
|
|
34
|
+
readonly kind: 'init';
|
|
35
|
+
readonly mountId: string;
|
|
36
|
+
readonly bootstrap?: AdminSurfaceBootstrap;
|
|
37
|
+
readonly theme?: AdminSurfaceTheme;
|
|
38
|
+
}
|
|
39
|
+
/** Surface -> host page. `mountId` must echo the nonce from init. */
|
|
40
|
+
export interface AdminSurfaceActionRequest {
|
|
41
|
+
readonly protocol: typeof ADMIN_SURFACE_PROTOCOL;
|
|
42
|
+
readonly version: typeof ADMIN_SURFACE_PROTOCOL_VERSION;
|
|
43
|
+
readonly kind: 'action-request';
|
|
44
|
+
readonly mountId: string;
|
|
45
|
+
readonly requestId: string;
|
|
46
|
+
readonly action: string;
|
|
47
|
+
readonly payload: unknown;
|
|
48
|
+
}
|
|
49
|
+
/** Surface -> host page: asks the host to open `url` outside the sandbox (`./external-links.ts`).
|
|
50
|
+
* Answered with an `action-response` for `requestId`, like an action. */
|
|
51
|
+
export interface AdminSurfaceOpenLinkRequest {
|
|
52
|
+
readonly protocol: typeof ADMIN_SURFACE_PROTOCOL;
|
|
53
|
+
readonly version: typeof ADMIN_SURFACE_PROTOCOL_VERSION;
|
|
54
|
+
readonly kind: 'open-link';
|
|
55
|
+
readonly mountId: string;
|
|
56
|
+
readonly requestId: string;
|
|
57
|
+
readonly url: string;
|
|
58
|
+
}
|
|
59
|
+
/** Surface-safe failure: `message` is written for the person using the surface and never carries a
|
|
60
|
+
* handler's raw error text, a token or a submitted value. */
|
|
61
|
+
/** Surface -> host: the surface's content height in CSS pixels, so the host can size the frame to fit. */
|
|
62
|
+
export interface AdminSurfaceResizeMessage {
|
|
63
|
+
readonly protocol: typeof ADMIN_SURFACE_PROTOCOL;
|
|
64
|
+
readonly version: typeof ADMIN_SURFACE_PROTOCOL_VERSION;
|
|
65
|
+
readonly kind: 'resize';
|
|
66
|
+
readonly mountId: string;
|
|
67
|
+
readonly height: number;
|
|
68
|
+
}
|
|
69
|
+
export interface AdminSurfaceActionFailure {
|
|
70
|
+
readonly code: string;
|
|
71
|
+
readonly message: string;
|
|
72
|
+
readonly retryable: boolean;
|
|
73
|
+
}
|
|
74
|
+
export type AdminSurfaceActionOutcome = {
|
|
75
|
+
readonly ok: true;
|
|
76
|
+
readonly result: unknown;
|
|
77
|
+
} | {
|
|
78
|
+
readonly ok: false;
|
|
79
|
+
readonly error: AdminSurfaceActionFailure;
|
|
80
|
+
};
|
|
81
|
+
/** Host page -> surface, answering exactly one request. */
|
|
82
|
+
export type AdminSurfaceActionResponse = {
|
|
83
|
+
readonly protocol: typeof ADMIN_SURFACE_PROTOCOL;
|
|
84
|
+
readonly version: typeof ADMIN_SURFACE_PROTOCOL_VERSION;
|
|
85
|
+
readonly kind: 'action-response';
|
|
86
|
+
readonly mountId: string;
|
|
87
|
+
readonly requestId: string;
|
|
88
|
+
} & AdminSurfaceActionOutcome;
|
|
89
|
+
/** Builds the init envelope the host page posts into a freshly loaded frame.
|
|
90
|
+
* @complexity O(1). */
|
|
91
|
+
export declare function adminSurfaceInitMessage(required: {
|
|
92
|
+
readonly mountId: string;
|
|
93
|
+
}, optional?: {
|
|
94
|
+
readonly bootstrap?: AdminSurfaceBootstrap;
|
|
95
|
+
readonly theme?: AdminSurfaceTheme;
|
|
96
|
+
}): AdminSurfaceInitMessage;
|
|
97
|
+
/** Wraps a dispatcher outcome as the response to one validated request.
|
|
98
|
+
* @complexity O(1). */
|
|
99
|
+
export declare function adminSurfaceActionResponse(required: {
|
|
100
|
+
readonly request: Pick<AdminSurfaceActionRequest, 'mountId' | 'requestId'>;
|
|
101
|
+
readonly outcome: AdminSurfaceActionOutcome;
|
|
102
|
+
}, _optional?: Record<string, never>): AdminSurfaceActionResponse;
|
|
103
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/admin-surfaces/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,uBAAuB,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AACvB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAAO,GAAG,uBAAuB,CAK1M;AAED;uBACuB;AACvB,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,0BAA0B,CAGnP"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Discriminates this protocol's messages from anything else posted to the same window. */
|
|
2
|
+
export const ADMIN_SURFACE_PROTOCOL = 'jini.admin-surface';
|
|
3
|
+
export const ADMIN_SURFACE_PROTOCOL_VERSION = 1;
|
|
4
|
+
/** The ONLY sandbox token a surface frame gets. Adding `allow-same-origin` next to `allow-scripts`
|
|
5
|
+
* lets the frame remove its own sandbox, so it is never granted. */
|
|
6
|
+
export const ADMIN_SURFACE_SANDBOX = 'allow-scripts';
|
|
7
|
+
/** A frame sandboxed without `allow-same-origin` has an opaque origin, which `MessageEvent.origin`
|
|
8
|
+
* serializes as the string "null". Every sandboxed frame shares it, so origin alone never identifies
|
|
9
|
+
* a mount: the per-mount nonce and the frame's window identity do. */
|
|
10
|
+
export const SANDBOXED_FRAME_ORIGIN = 'null';
|
|
11
|
+
/** Builds the init envelope the host page posts into a freshly loaded frame.
|
|
12
|
+
* @complexity O(1). */
|
|
13
|
+
export function adminSurfaceInitMessage(required, optional = {}) {
|
|
14
|
+
return {
|
|
15
|
+
protocol: ADMIN_SURFACE_PROTOCOL, version: ADMIN_SURFACE_PROTOCOL_VERSION, kind: 'init', mountId: required.mountId,
|
|
16
|
+
...(optional.bootstrap ? { bootstrap: optional.bootstrap } : {}), ...(optional.theme ? { theme: optional.theme } : {}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Wraps a dispatcher outcome as the response to one validated request.
|
|
20
|
+
* @complexity O(1). */
|
|
21
|
+
export function adminSurfaceActionResponse(required, _optional = {}) {
|
|
22
|
+
const { mountId, requestId } = required.request;
|
|
23
|
+
return { protocol: ADMIN_SURFACE_PROTOCOL, version: ADMIN_SURFACE_PROTOCOL_VERSION, kind: 'action-response', mountId, requestId, ...required.outcome };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/admin-surfaces/protocol.ts"],"names":[],"mappings":"AAWA,2FAA2F;AAC3F,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAEhD;oEACoE;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAErD;;sEAEsE;AACtE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AA0E7C;uBACuB;AACvB,MAAM,UAAU,uBAAuB,CAAC,QAAsC,EAAE,WAA+F,EAAE;IAC/K,OAAO;QACL,QAAQ,EAAE,sBAAsB,EAAE,OAAO,EAAE,8BAA8B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO;QAClH,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvH,CAAC;AACJ,CAAC;AAED;uBACuB;AACvB,MAAM,UAAU,0BAA0B,CAAC,QAAqI,EAAE,YAAmC,EAAE;IACrN,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;IAChD,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,OAAO,EAAE,8BAA8B,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;AACzJ,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The isolation contract a host applies when it renders and serves an admin surface: the
|
|
3
|
+
* iframe attributes, the Content-Security-Policy and headers for each served surface file, the mount
|
|
4
|
+
* nonce, and the short-lived, never-cached bootstrap envelope.
|
|
5
|
+
*
|
|
6
|
+
* Why these are pure helpers instead of host code: every host must apply the SAME strict values, and
|
|
7
|
+
* the values are the security boundary (no same-origin, no inline script, no direct network access
|
|
8
|
+
* unless the descriptor declared and validation accepted an https origin). Hosts call these and only
|
|
9
|
+
* choose routes.
|
|
10
|
+
*/
|
|
11
|
+
import type { AdminSurfaceDescriptor } from './descriptor.js';
|
|
12
|
+
import { type AdminSurfaceBootstrap } from './protocol.js';
|
|
13
|
+
/**
|
|
14
|
+
* The attributes for the `<iframe>` that renders a surface. `sandbox` is exactly `allow-scripts`:
|
|
15
|
+
* the frame gets an opaque origin, so it cannot read the host's cookies, storage or DOM.
|
|
16
|
+
* @complexity O(1).
|
|
17
|
+
*/
|
|
18
|
+
export declare function adminSurfaceFrameAttributes(required: {
|
|
19
|
+
readonly src: string;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
}, _optional?: Record<string, never>): {
|
|
22
|
+
readonly src: string;
|
|
23
|
+
readonly title: string;
|
|
24
|
+
readonly sandbox: "allow-scripts";
|
|
25
|
+
readonly referrerPolicy: "no-referrer";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The CSP for every file of one surface. Starts from `default-src 'none'`; scripts, styles, images
|
|
29
|
+
* and fonts may come from the surface's own files; `connect-src` and `frame-src` are closed unless the
|
|
30
|
+
* descriptor declared validated https origins. The `sandbox` directive keeps the document sandboxed
|
|
31
|
+
* even when opened directly rather than through the host's iframe.
|
|
32
|
+
* @complexity O(c) declared CSP sources.
|
|
33
|
+
*/
|
|
34
|
+
export declare function adminSurfaceContentSecurityPolicy(required: {
|
|
35
|
+
readonly descriptor: Pick<AdminSurfaceDescriptor, 'csp'>;
|
|
36
|
+
}, _optional?: Record<string, never>): string;
|
|
37
|
+
/**
|
|
38
|
+
* Response headers for one served surface file. Script files carry `Access-Control-Allow-Origin: *`
|
|
39
|
+
* because a module script requested by an opaque-origin document is a cross-origin CORS fetch; the
|
|
40
|
+
* files are static plugin code fetched without credentials, so they must never contain secrets.
|
|
41
|
+
* @complexity O(c) declared CSP sources.
|
|
42
|
+
*/
|
|
43
|
+
export declare function adminSurfaceFileHeaders(required: {
|
|
44
|
+
readonly descriptor: Pick<AdminSurfaceDescriptor, 'csp'>;
|
|
45
|
+
readonly path: string;
|
|
46
|
+
}, _optional?: Record<string, never>): Readonly<Record<string, string>>;
|
|
47
|
+
/** One rendered surface: the nonce its messages must echo (they must also come from origin "null").
|
|
48
|
+
* @complexity O(1). */
|
|
49
|
+
export declare function createAdminSurfaceMount(required: {
|
|
50
|
+
readonly surfaceId: string;
|
|
51
|
+
}, optional?: {
|
|
52
|
+
readonly randomBytes?: (input: {
|
|
53
|
+
readonly length: number;
|
|
54
|
+
}) => Uint8Array;
|
|
55
|
+
}): {
|
|
56
|
+
surfaceId: string;
|
|
57
|
+
mountId: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The envelope a host server returns for one surface render. Its lifetime is fixed at
|
|
61
|
+
* {@link BOOTSTRAP_TTL_MS}, not caller-chosen: bootstrap data may include a short-lived access token.
|
|
62
|
+
* @complexity O(1).
|
|
63
|
+
*/
|
|
64
|
+
export declare function createAdminSurfaceBootstrap<D>(required: {
|
|
65
|
+
readonly surfaceId: string;
|
|
66
|
+
readonly data: D;
|
|
67
|
+
readonly nowMs: number;
|
|
68
|
+
}, _optional?: Record<string, never>): AdminSurfaceBootstrap<D>;
|
|
69
|
+
/** Headers for the bootstrap response: never stored by the browser or any intermediary cache.
|
|
70
|
+
* @complexity O(1). */
|
|
71
|
+
export declare function adminSurfaceBootstrapHeaders(_required?: Record<string, never>, _optional?: Record<string, never>): Readonly<Record<string, string>>;
|
|
72
|
+
/** True while the bootstrap may still be used.
|
|
73
|
+
* @complexity O(1). */
|
|
74
|
+
export declare function isAdminSurfaceBootstrapCurrent(required: {
|
|
75
|
+
readonly bootstrap: Pick<AdminSurfaceBootstrap, 'expiresAt'>;
|
|
76
|
+
readonly nowMs: number;
|
|
77
|
+
}, _optional?: Record<string, never>): boolean;
|
|
78
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/admin-surfaces/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAalF;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM;;;;;EAE5I;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;CAAE,EAAE,SAAS,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,qBAAqB,EAAE,WAAW,CAAC,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,OAAO,CAEjM"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ADMIN_SURFACE_SANDBOX } from './protocol.js';
|
|
2
|
+
/** Bootstrap data is meant to live for one render: one minute, fixed so no host can lengthen it. */
|
|
3
|
+
const BOOTSTRAP_TTL_MS = 60_000;
|
|
4
|
+
const CONTENT_TYPES = {
|
|
5
|
+
html: 'text/html; charset=utf-8',
|
|
6
|
+
mjs: 'text/javascript; charset=utf-8',
|
|
7
|
+
js: 'text/javascript; charset=utf-8',
|
|
8
|
+
css: 'text/css; charset=utf-8',
|
|
9
|
+
json: 'application/json; charset=utf-8',
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The attributes for the `<iframe>` that renders a surface. `sandbox` is exactly `allow-scripts`:
|
|
13
|
+
* the frame gets an opaque origin, so it cannot read the host's cookies, storage or DOM.
|
|
14
|
+
* @complexity O(1).
|
|
15
|
+
*/
|
|
16
|
+
export function adminSurfaceFrameAttributes(required, _optional = {}) {
|
|
17
|
+
return { src: required.src, title: required.title, sandbox: ADMIN_SURFACE_SANDBOX, referrerPolicy: 'no-referrer' };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The CSP for every file of one surface. Starts from `default-src 'none'`; scripts, styles, images
|
|
21
|
+
* and fonts may come from the surface's own files; `connect-src` and `frame-src` are closed unless the
|
|
22
|
+
* descriptor declared validated https origins. The `sandbox` directive keeps the document sandboxed
|
|
23
|
+
* even when opened directly rather than through the host's iframe.
|
|
24
|
+
* @complexity O(c) declared CSP sources.
|
|
25
|
+
*/
|
|
26
|
+
export function adminSurfaceContentSecurityPolicy(required, _optional = {}) {
|
|
27
|
+
const extra = (directive) => required.descriptor.csp[directive] ?? [];
|
|
28
|
+
const own = (directive) => [`'self'`, ...extra(directive)].join(' ');
|
|
29
|
+
const closed = (directive) => (extra(directive).length ? extra(directive).join(' ') : `'none'`);
|
|
30
|
+
return [
|
|
31
|
+
`default-src 'none'`,
|
|
32
|
+
`script-src ${own('script-src')}`,
|
|
33
|
+
`style-src ${own('style-src')}`,
|
|
34
|
+
`img-src ${own('img-src')}`,
|
|
35
|
+
`font-src ${own('font-src')}`,
|
|
36
|
+
`connect-src ${closed('connect-src')}`,
|
|
37
|
+
`frame-src ${closed('frame-src')}`,
|
|
38
|
+
`form-action 'none'`,
|
|
39
|
+
`base-uri 'none'`,
|
|
40
|
+
`frame-ancestors 'self'`,
|
|
41
|
+
`sandbox ${ADMIN_SURFACE_SANDBOX}`,
|
|
42
|
+
].join('; ');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Response headers for one served surface file. Script files carry `Access-Control-Allow-Origin: *`
|
|
46
|
+
* because a module script requested by an opaque-origin document is a cross-origin CORS fetch; the
|
|
47
|
+
* files are static plugin code fetched without credentials, so they must never contain secrets.
|
|
48
|
+
* @complexity O(c) declared CSP sources.
|
|
49
|
+
*/
|
|
50
|
+
export function adminSurfaceFileHeaders(required, _optional = {}) {
|
|
51
|
+
const extension = required.path.slice(required.path.lastIndexOf('.') + 1);
|
|
52
|
+
const script = extension === 'mjs' || extension === 'js';
|
|
53
|
+
return {
|
|
54
|
+
'Content-Type': CONTENT_TYPES[extension] ?? 'application/octet-stream',
|
|
55
|
+
'Content-Security-Policy': adminSurfaceContentSecurityPolicy({ descriptor: required.descriptor }),
|
|
56
|
+
'X-Content-Type-Options': 'nosniff',
|
|
57
|
+
'Referrer-Policy': 'no-referrer',
|
|
58
|
+
'Cache-Control': 'no-cache',
|
|
59
|
+
...(script ? { 'Access-Control-Allow-Origin': '*' } : {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** One rendered surface: the nonce its messages must echo (they must also come from origin "null").
|
|
63
|
+
* @complexity O(1). */
|
|
64
|
+
export function createAdminSurfaceMount(required, optional = {}) {
|
|
65
|
+
const randomBytes = optional.randomBytes ?? (({ length }) => globalThis.crypto.getRandomValues(new Uint8Array(length)));
|
|
66
|
+
const mountId = Array.from(randomBytes({ length: 16 }), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
67
|
+
return { surfaceId: required.surfaceId, mountId };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The envelope a host server returns for one surface render. Its lifetime is fixed at
|
|
71
|
+
* {@link BOOTSTRAP_TTL_MS}, not caller-chosen: bootstrap data may include a short-lived access token.
|
|
72
|
+
* @complexity O(1).
|
|
73
|
+
*/
|
|
74
|
+
export function createAdminSurfaceBootstrap(required, _optional = {}) {
|
|
75
|
+
return { surfaceId: required.surfaceId, issuedAt: required.nowMs, expiresAt: required.nowMs + BOOTSTRAP_TTL_MS, data: required.data };
|
|
76
|
+
}
|
|
77
|
+
/** Headers for the bootstrap response: never stored by the browser or any intermediary cache.
|
|
78
|
+
* @complexity O(1). */
|
|
79
|
+
export function adminSurfaceBootstrapHeaders(_required = {}, _optional = {}) {
|
|
80
|
+
return {
|
|
81
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
82
|
+
'Cache-Control': 'no-store',
|
|
83
|
+
Pragma: 'no-cache',
|
|
84
|
+
'X-Content-Type-Options': 'nosniff',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** True while the bootstrap may still be used.
|
|
88
|
+
* @complexity O(1). */
|
|
89
|
+
export function isAdminSurfaceBootstrapCurrent(required, _optional = {}) {
|
|
90
|
+
return required.nowMs < required.bootstrap.expiresAt;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../src/admin-surfaces/sandbox.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,qBAAqB,EAA8B,MAAM,eAAe,CAAC;AAElF,oGAAoG;AACpG,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C,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/G,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAI,QAAkF,EAAE,YAAmC,EAAE;IACtK,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,KAAK,GAAG,gBAAgB,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxI,CAAC;AAED;uBACuB;AACvB,MAAM,UAAU,4BAA4B,CAAC,YAAmC,EAAE,EAAE,YAAmC,EAAE;IACvH,OAAO;QACL,cAAc,EAAE,iCAAiC;QACjD,eAAe,EAAE,UAAU;QAC3B,MAAM,EAAE,UAAU;QAClB,wBAAwB,EAAE,SAAS;KACpC,CAAC;AACJ,CAAC;AAED;uBACuB;AACvB,MAAM,UAAU,8BAA8B,CAAC,QAAkG,EAAE,YAAmC,EAAE;IACtL,OAAO,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The one check every plugin-written settings value passes before a host stores it: plugin
|
|
3
|
+
* state (`./surface-capabilities.ts`) and a delivery binding's config (`./delivery-bindings.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Why it is shared: both are plugin-chosen JSON the host persists and later hands back (to the
|
|
6
|
+
* plugin's tools, or to the delivery adapter), so both need the same guarantees — plain JSON only,
|
|
7
|
+
* bounded depth and size, and never a token the plugin obtained — and must not drift apart.
|
|
8
|
+
*/
|
|
9
|
+
import { type AgentPluginCapabilityGate, type AgentPluginStateValue } from '../lifecycle/tools/capabilities.js';
|
|
10
|
+
export declare const ADMIN_SURFACE_STATE_LIMITS: Readonly<{
|
|
11
|
+
maxKeyLength: 128;
|
|
12
|
+
maxValueBytes: number;
|
|
13
|
+
maxDepth: 16;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const STATE_CREDENTIAL_MESSAGE = "The plugin tried to save a connection credential in its settings; nothing was saved.";
|
|
16
|
+
/**
|
|
17
|
+
* The value the host stores: serialized once, scanned and size-checked on that text, then parsed
|
|
18
|
+
* back, so what is stored is exactly what was checked (the plugin cannot change it afterwards).
|
|
19
|
+
* @param required.gate - The call's capability gate (its token memory drives the scan).
|
|
20
|
+
* @param required.value - The plugin's value, unchecked.
|
|
21
|
+
* @throws Error when the value is not plain JSON, is too large, or mentions an obtained token.
|
|
22
|
+
* @complexity O(n) in the serialized size.
|
|
23
|
+
*/
|
|
24
|
+
export declare function storedStateValue(required: {
|
|
25
|
+
readonly gate: AgentPluginCapabilityGate;
|
|
26
|
+
readonly value: unknown;
|
|
27
|
+
}, _optional?: Record<string, never>): AgentPluginStateValue;
|
|
28
|
+
//# sourceMappingURL=settings-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-value.d.ts","sourceRoot":"","sources":["../../src/admin-surfaces/settings-value.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAA+B,KAAK,yBAAyB,EAAE,KAAK,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE7I,eAAO,MAAM,0BAA0B;;;;EAAuG,CAAC;AAC/I,eAAO,MAAM,wBAAwB,yFAAyF,CAAC;AAe/H;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,qBAAqB,CAO9K"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The one check every plugin-written settings value passes before a host stores it: plugin
|
|
3
|
+
* state (`./surface-capabilities.ts`) and a delivery binding's config (`./delivery-bindings.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Why it is shared: both are plugin-chosen JSON the host persists and later hands back (to the
|
|
6
|
+
* plugin's tools, or to the delivery adapter), so both need the same guarantees — plain JSON only,
|
|
7
|
+
* bounded depth and size, and never a token the plugin obtained — and must not drift apart.
|
|
8
|
+
*/
|
|
9
|
+
import { PLUGIN_STATE_MAX_KEY_LENGTH } from '../lifecycle/tools/capabilities.js';
|
|
10
|
+
export const ADMIN_SURFACE_STATE_LIMITS = Object.freeze({ maxKeyLength: PLUGIN_STATE_MAX_KEY_LENGTH, maxValueBytes: 16 * 1024, maxDepth: 16 });
|
|
11
|
+
export const STATE_CREDENTIAL_MESSAGE = 'The plugin tried to save a connection credential in its settings; nothing was saved.';
|
|
12
|
+
function isStateScalar(value) {
|
|
13
|
+
return value === null || typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value));
|
|
14
|
+
}
|
|
15
|
+
/** True for plain JSON data only: no undefined, functions, NaN, class instances or deep nesting. @complexity O(n) nodes. */
|
|
16
|
+
function isStateValue(value, depth) {
|
|
17
|
+
if (isStateScalar(value))
|
|
18
|
+
return true;
|
|
19
|
+
if (typeof value !== 'object' || depth >= ADMIN_SURFACE_STATE_LIMITS.maxDepth)
|
|
20
|
+
return false;
|
|
21
|
+
if (Array.isArray(value))
|
|
22
|
+
return value.every((item) => isStateValue(item, depth + 1));
|
|
23
|
+
const prototype = Object.getPrototypeOf(value);
|
|
24
|
+
return (prototype === Object.prototype || prototype === null) && Object.values(value).every((item) => isStateValue(item, depth + 1));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The value the host stores: serialized once, scanned and size-checked on that text, then parsed
|
|
28
|
+
* back, so what is stored is exactly what was checked (the plugin cannot change it afterwards).
|
|
29
|
+
* @param required.gate - The call's capability gate (its token memory drives the scan).
|
|
30
|
+
* @param required.value - The plugin's value, unchecked.
|
|
31
|
+
* @throws Error when the value is not plain JSON, is too large, or mentions an obtained token.
|
|
32
|
+
* @complexity O(n) in the serialized size.
|
|
33
|
+
*/
|
|
34
|
+
export function storedStateValue(required, _optional = {}) {
|
|
35
|
+
const { gate, value } = required;
|
|
36
|
+
if (!isStateValue(value, 0))
|
|
37
|
+
throw new Error('A settings value must be plain JSON data (no undefined, functions, NaN or class instances).');
|
|
38
|
+
const text = JSON.stringify(value);
|
|
39
|
+
if (new TextEncoder().encode(text).byteLength > ADMIN_SURFACE_STATE_LIMITS.maxValueBytes)
|
|
40
|
+
throw new Error(`A settings value may be at most ${ADMIN_SURFACE_STATE_LIMITS.maxValueBytes} bytes of JSON.`);
|
|
41
|
+
if (gate.mentionsToken({ value: text }))
|
|
42
|
+
throw new Error(STATE_CREDENTIAL_MESSAGE);
|
|
43
|
+
return JSON.parse(text);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=settings-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-value.js","sourceRoot":"","sources":["../../src/admin-surfaces/settings-value.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,2BAA2B,EAA8D,MAAM,oCAAoC,CAAC;AAE7I,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,2BAA2B,EAAE,aAAa,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/I,MAAM,CAAC,MAAM,wBAAwB,GAAG,sFAAsF,CAAC;AAE/H,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,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,iBAAiB,CAAC,CAAC;IACxM,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACnF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAA0B,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The host capability ports a plugin's admin-surface handlers receive, and the per-call
|
|
3
|
+
* session that wraps them. Jini defines the shapes and the checks; the host implements the ports
|
|
4
|
+
* (connections backed by its API-connection service, state by its own store, public config by its
|
|
5
|
+
* own settings) and Jini never names a provider.
|
|
6
|
+
*
|
|
7
|
+
* Why surfaces get more than tools: account actions (connect, reconnect, switch account, disconnect)
|
|
8
|
+
* and saving a chosen resource are admin actions a person takes on a settings screen, so they exist
|
|
9
|
+
* here and never on the executable-tool port. Why every check sits here and not only in the host:
|
|
10
|
+
* the surfaces file is the shipped, digest-checked allowlist, so the session refuses anything the
|
|
11
|
+
* surface did not declare (a connection, a start parameter, a callback field, a config name) before
|
|
12
|
+
* the host sees it, and a host that answers with more than the port promises (a connection ref, raw
|
|
13
|
+
* scopes, undeclared callback fields) is cut back to the declared shape. Like the tool session it
|
|
14
|
+
* revokes everything once the plugin is disabled and withholds results and errors that mention a
|
|
15
|
+
* token the plugin obtained (in this call, an earlier one, or one of its tools); it also refuses to persist
|
|
16
|
+
* such a token in plugin state.
|
|
17
|
+
*/
|
|
18
|
+
import { type AgentPluginStateReader, type AgentPluginStateValue, type AgentPluginToolCapabilities, type AgentPluginToolCapabilityScope, type IssuedTokenMemory } from '../lifecycle/tools/capabilities.js';
|
|
19
|
+
import type { AdminSurfaceCapabilityDeclarations } from './capability-declarations.js';
|
|
20
|
+
import { type AdminSurfaceDeliveryBindings } from './delivery-bindings.js';
|
|
21
|
+
export { ADMIN_SURFACE_STATE_LIMITS, STATE_CREDENTIAL_MESSAGE } from './settings-value.js';
|
|
22
|
+
/** Mirrors the API-connection lifecycle (`ApiConnectionStatus`); only `connected` serves access tokens. */
|
|
23
|
+
export type AdminSurfaceConnectionState = 'connected' | 'reconnect-required' | 'revocation-pending' | 'disconnected';
|
|
24
|
+
/**
|
|
25
|
+
* The API-connection start intent each account action maps to (`ApiConnectionIntent` in
|
|
26
|
+
* `@jini-ai/integrations/api-connections`, mirrored because agent-plugins does not depend on it), so a
|
|
27
|
+
* host passes `ADMIN_SURFACE_ACTION_INTENTS[action]` straight to `start`. `reconnect` and `add-scopes`
|
|
28
|
+
* are a same-account `connect` with the scope sets the handler passes (`add-scopes` re-consents for
|
|
29
|
+
* more of them); `switch` stages another account.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ADMIN_SURFACE_ACTION_INTENTS: Readonly<{
|
|
32
|
+
readonly connect: "connect";
|
|
33
|
+
readonly reconnect: "connect";
|
|
34
|
+
readonly switch: "switch-account";
|
|
35
|
+
readonly 'add-scopes': "connect";
|
|
36
|
+
}>;
|
|
37
|
+
export type AdminSurfaceConnectionAction = keyof typeof ADMIN_SURFACE_ACTION_INTENTS;
|
|
38
|
+
/**
|
|
39
|
+
* The honest remote outcome of a disconnect, the same values as `ApiConnectionRemoteRevocation`:
|
|
40
|
+
* never `confirmed` unless the provider confirmed it.
|
|
41
|
+
*/
|
|
42
|
+
export type AdminSurfaceRevocationOutcome = 'confirmed' | 'pending' | 'not-needed';
|
|
43
|
+
/** Token-free status. Scope sets are the plugin's own ids, never raw provider scopes. */
|
|
44
|
+
export interface AdminSurfaceConnectionStatus {
|
|
45
|
+
readonly connectionId: string;
|
|
46
|
+
readonly status: AdminSurfaceConnectionState;
|
|
47
|
+
readonly accountLabel: string | null;
|
|
48
|
+
readonly grantedScopeSetIds: readonly string[];
|
|
49
|
+
/** The account a staged switch would move to, awaiting `confirmSwitch`. */
|
|
50
|
+
readonly pendingSwitchAccountLabel: string | null;
|
|
51
|
+
/** Why the latest sign-in did not complete and what to do next, as the HOST's own lowercase
|
|
52
|
+
* hyphenated codes (for example `access-denied` / `reconnect`), never provider text; `null` when
|
|
53
|
+
* the latest attempt succeeded or none is recorded. A value that is not a safe code becomes `null`. */
|
|
54
|
+
readonly lastSignInAttempt: AdminSurfaceSignInAttempt | null;
|
|
55
|
+
}
|
|
56
|
+
/** The outcome codes of a sign-in attempt that did not complete. */
|
|
57
|
+
export interface AdminSurfaceSignInAttempt {
|
|
58
|
+
readonly code: string;
|
|
59
|
+
readonly nextAction: string;
|
|
60
|
+
}
|
|
61
|
+
/** A sign-in the person opens (a button on hosted, the system browser on desktop). */
|
|
62
|
+
export interface AdminSurfaceAuthorizationStart {
|
|
63
|
+
readonly authorizationUrl: string;
|
|
64
|
+
/** Opaque id for `takeCallbackFields` once the sign-in completed: the connection service's attempt
|
|
65
|
+
* id, never the authorization `state`. */
|
|
66
|
+
readonly attemptId: string;
|
|
67
|
+
readonly expiresAt: string;
|
|
68
|
+
}
|
|
69
|
+
export interface AdminSurfaceConnections {
|
|
70
|
+
/** A fresh access token for one of the surface's declared connections; never a refresh token. */
|
|
71
|
+
getAccessToken(required: {
|
|
72
|
+
readonly connectionId: string;
|
|
73
|
+
}, optional?: Record<string, never>): Promise<string>;
|
|
74
|
+
status(required: {
|
|
75
|
+
readonly connectionId: string;
|
|
76
|
+
}, optional?: Record<string, never>): Promise<AdminSurfaceConnectionStatus>;
|
|
77
|
+
begin(required: {
|
|
78
|
+
readonly connectionId: string;
|
|
79
|
+
readonly action: AdminSurfaceConnectionAction;
|
|
80
|
+
}, optional?: {
|
|
81
|
+
readonly scopeSetIds?: readonly string[];
|
|
82
|
+
readonly startParams?: Readonly<Record<string, string>>;
|
|
83
|
+
}): Promise<AdminSurfaceAuthorizationStart>;
|
|
84
|
+
confirmSwitch(required: {
|
|
85
|
+
readonly connectionId: string;
|
|
86
|
+
}, optional?: Record<string, never>): Promise<AdminSurfaceConnectionStatus>;
|
|
87
|
+
cancelSwitch(required: {
|
|
88
|
+
readonly connectionId: string;
|
|
89
|
+
}, optional?: Record<string, never>): Promise<AdminSurfaceConnectionStatus>;
|
|
90
|
+
disconnect(required: {
|
|
91
|
+
readonly connectionId: string;
|
|
92
|
+
}, optional?: Record<string, never>): Promise<AdminSurfaceConnectionStatus & {
|
|
93
|
+
readonly revocation: AdminSurfaceRevocationOutcome;
|
|
94
|
+
}>;
|
|
95
|
+
/** The declared callback fields of a completed sign-in, once; `null` when absent, taken or not completed.
|
|
96
|
+
* Still untrusted: verify them through the provider's API before saving anything. */
|
|
97
|
+
takeCallbackFields(required: {
|
|
98
|
+
readonly connectionId: string;
|
|
99
|
+
readonly attemptId: string;
|
|
100
|
+
}, optional?: Record<string, never>): Promise<Readonly<Record<string, string>> | null>;
|
|
101
|
+
}
|
|
102
|
+
export type AdminSurfaceStateValue = AgentPluginStateValue;
|
|
103
|
+
/** Plugin- and workspace-scoped JSON values (the host keys them by the session's scope). The plugin's
|
|
104
|
+
* tools read the same store through the read-only `AgentPluginStateReader`; only surfaces write. */
|
|
105
|
+
export interface AdminSurfaceState extends AgentPluginStateReader {
|
|
106
|
+
set(required: {
|
|
107
|
+
readonly key: string;
|
|
108
|
+
readonly value: AdminSurfaceStateValue;
|
|
109
|
+
}, optional?: Record<string, never>): Promise<void>;
|
|
110
|
+
delete(required: {
|
|
111
|
+
readonly key: string;
|
|
112
|
+
}, optional?: Record<string, never>): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
/** Host-supplied public values (an app id, a browser key) for names the surface declares; `null` when unset. */
|
|
115
|
+
export interface AdminSurfacePublicConfig {
|
|
116
|
+
get(required: {
|
|
117
|
+
readonly name: string;
|
|
118
|
+
}, optional?: Record<string, never>): Promise<string | null>;
|
|
119
|
+
}
|
|
120
|
+
/** Only form identity and display text, never fields, recipients or submission data. */
|
|
121
|
+
export interface AdminSurfaceForm {
|
|
122
|
+
readonly slug: string;
|
|
123
|
+
readonly title: string;
|
|
124
|
+
}
|
|
125
|
+
/** Workspace-scoped discovery. The session returns at most 200 choices; titles are capped at 1024 characters. */
|
|
126
|
+
export interface AdminSurfaceForms {
|
|
127
|
+
list(required: Record<string, never>, optional?: Record<string, never>): Promise<readonly AdminSurfaceForm[]>;
|
|
128
|
+
}
|
|
129
|
+
export type AdminSurfaceCapabilities = Pick<AgentPluginToolCapabilities, 'http' | 'limiter' | 'artifacts'> & {
|
|
130
|
+
readonly connections: AdminSurfaceConnections;
|
|
131
|
+
readonly state: AdminSurfaceState;
|
|
132
|
+
readonly publicConfig: AdminSurfacePublicConfig;
|
|
133
|
+
/** The workspace's form-delivery bindings (`./delivery-bindings.ts`). Optional for the host; a handler
|
|
134
|
+
* gets it only when its surface declares `deliveryAdapters` and the host provides it. */
|
|
135
|
+
readonly deliveryBindings?: AdminSurfaceDeliveryBindings;
|
|
136
|
+
/** Absent unless both the host supplies it and this surface declares `forms: ["list"]`. */
|
|
137
|
+
readonly forms?: AdminSurfaceForms;
|
|
138
|
+
};
|
|
139
|
+
/** Host port: builds one call's capabilities for the loaded plugin, workspace and admin principal. */
|
|
140
|
+
export type AdminSurfaceCapabilitiesPort = (required: AgentPluginToolCapabilityScope, optional?: Record<string, never>) => AdminSurfaceCapabilities;
|
|
141
|
+
/**
|
|
142
|
+
* Opens the capability session for one admin-surface handler call.
|
|
143
|
+
* @param required.capabilities - The host's ports for this call (already scoped to plugin, workspace, principal).
|
|
144
|
+
* @param required.isLive - False once the plugin's surface handlers are revoked.
|
|
145
|
+
* @param required.declared - The surface's own capability declarations (the allowlists).
|
|
146
|
+
* @param required.issued - The plugin's token memory, shared by all its calls (tools included).
|
|
147
|
+
* @param optional.actorId - The signed-in admin; account actions are refused without one.
|
|
148
|
+
* @returns Wrapped capabilities plus the shared `release` (result) and `sanitize` (error) gates.
|
|
149
|
+
* @complexity O(1) to open; each check is bounded by the declared lists and the value caps.
|
|
150
|
+
*/
|
|
151
|
+
export declare function openAdminSurfaceCapabilitySession(required: {
|
|
152
|
+
readonly capabilities: AdminSurfaceCapabilities;
|
|
153
|
+
readonly isLive: () => boolean;
|
|
154
|
+
readonly declared: AdminSurfaceCapabilityDeclarations;
|
|
155
|
+
readonly issued: IssuedTokenMemory;
|
|
156
|
+
}, optional?: {
|
|
157
|
+
readonly actorId?: string;
|
|
158
|
+
}): {
|
|
159
|
+
capabilities: AdminSurfaceCapabilities;
|
|
160
|
+
release: <T>({ value }: {
|
|
161
|
+
readonly value: T;
|
|
162
|
+
}) => T;
|
|
163
|
+
sanitize: ({ error }: {
|
|
164
|
+
readonly error: unknown;
|
|
165
|
+
}) => unknown;
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=surface-capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface-capabilities.d.ts","sourceRoot":"","sources":["../../src/admin-surfaces/surface-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAE2B,KAAK,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,KAAK,2BAA2B,EAAE,KAAK,8BAA8B,EAC9J,KAAK,iBAAiB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,kCAAkC,EAAqC,MAAM,8BAA8B,CAAC;AAC1H,OAAO,EAAyB,KAAK,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAIlG,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE3F,2GAA2G;AAC3G,MAAM,MAAM,2BAA2B,GAAG,WAAW,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,cAAc,CAAC;AAErH;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B;;;;;EAE9B,CAAC;AACZ,MAAM,MAAM,4BAA4B,GAAG,MAAM,OAAO,4BAA4B,CAAC;AACrF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;AAEnF,yFAAyF;AACzF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC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