@jini-ai/agent-plugins 0.7.3-next.2 → 0.7.4
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 +7 -0
- 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/credential-save-tool.js +2 -3
- 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 +159 -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 +17 -3
- package/dist/lifecycle/search-projection.js +8 -8
- package/dist/lifecycle/search.d.ts +1 -0
- package/dist/lifecycle/search.js +2 -2
- 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,137 @@
|
|
|
1
|
+
import type { AgentPluginDeliveryMode } from "../lifecycle/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* @file A host's overlay for portable Agent Plugins: the one formatter for
|
|
4
|
+
* `<overlaysDir>/<pluginId>/` (the host's overlay directory, always passed in as `overlaysDir`).
|
|
5
|
+
*
|
|
6
|
+
* A plugin's own payload (a Jini `@jini-ai/agent-plugins/<id>` subpath) describes jobs, not the host's tools.
|
|
7
|
+
* The host's rules for those jobs — which tool does what, which shapes to write — live in an overlay:
|
|
8
|
+
* an optional `GUIDANCE.md` placed before the plugin's guidance, and optional `host/<name>.md`
|
|
9
|
+
* supporting files a model reads by asking the plugin's own tool for `file: "host/<name>.md"`.
|
|
10
|
+
*
|
|
11
|
+
* Both delivery seams use this file and nothing else: the host's `agent_plugin_<id>` tool wrapper
|
|
12
|
+
* and its run-reference resolver. Both run AFTER the
|
|
13
|
+
* plugin's activation gate, so a disabled plugin never receives its overlay. This replaced reading
|
|
14
|
+
* host references through `fs_read_file` root `repo`, which site agents are refused
|
|
15
|
+
* and which a packaged build does not ship anyway.
|
|
16
|
+
*
|
|
17
|
+
* Lookup is by `pluginId` only; a caller never supplies a path. Reads are bounded at the same
|
|
18
|
+
* 256 KiB the plugin's own file reader uses.
|
|
19
|
+
*/
|
|
20
|
+
/** Same per-file cap as the plugin skill-file reader, so an overlay file is never the larger read. */
|
|
21
|
+
export declare const MAX_HOST_PLUGIN_FILE_BYTES: number;
|
|
22
|
+
/** The host answers `file` values with this prefix from the overlay; the plugin never sees them. */
|
|
23
|
+
export declare const HOST_PLUGIN_FILE_PREFIX = "host/";
|
|
24
|
+
/** A plugin's overlay: the guidance to put first, and its readable `host/` file names. */
|
|
25
|
+
export interface HostPluginGuidance {
|
|
26
|
+
readonly guidance?: string;
|
|
27
|
+
readonly files: string[];
|
|
28
|
+
}
|
|
29
|
+
/** True when a plugin tool `file` value names an overlay file rather than a plugin file. */
|
|
30
|
+
export declare function isHostPluginFileRequest(required: {
|
|
31
|
+
file: unknown;
|
|
32
|
+
}, _optional?: Record<string, never>): required is {
|
|
33
|
+
file: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Reads one plugin's overlay guidance and host-file names.
|
|
37
|
+
* @returns `{ files: [] }` when the plugin has no overlay (or an id that cannot name one).
|
|
38
|
+
* @throws A `GUIDANCE.md` over 256 KiB, not a file, or unreadable — host rules are never silently dropped.
|
|
39
|
+
* @complexity One stat, one bounded read, one readdir.
|
|
40
|
+
*/
|
|
41
|
+
export declare function readHostPluginGuidance(required: {
|
|
42
|
+
pluginId: string;
|
|
43
|
+
overlaysDir: string;
|
|
44
|
+
}, _optional?: Record<string, never>): Promise<HostPluginGuidance>;
|
|
45
|
+
/**
|
|
46
|
+
* Reads one `host/<name>.md` overlay file. Every refusal is a note naming the valid files, the same
|
|
47
|
+
* recovery shape the plugin's own file reader gives; a caller's unsafe value is never echoed.
|
|
48
|
+
* @complexity One stat, one bounded read, one readdir.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readHostPluginFile(required: {
|
|
51
|
+
pluginId: string;
|
|
52
|
+
file: string;
|
|
53
|
+
overlaysDir: string;
|
|
54
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
55
|
+
text: string;
|
|
56
|
+
} | {
|
|
57
|
+
note: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Removes a `"Bash"` item from every frontmatter `allowed-tools` list in delivered guidance. Body
|
|
61
|
+
* text, examples and every other tool stay byte-identical; source files are never changed.
|
|
62
|
+
* @complexity O(lines).
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeChatRefusedToolPermissions({ text }: {
|
|
65
|
+
text: string;
|
|
66
|
+
}, _optional?: Record<string, never>): string;
|
|
67
|
+
/** What the plugin tool's handler returned, as far as the overlay needs it. */
|
|
68
|
+
export interface PluginToolGuidance {
|
|
69
|
+
readonly pluginId: string;
|
|
70
|
+
readonly guidance: string;
|
|
71
|
+
readonly files?: readonly string[];
|
|
72
|
+
readonly note?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Seam 1, the `agent_plugin_<id>` tool response. `required.result` is the plugin handler's answer —
|
|
76
|
+
* for a `host/` request, the caller asked the handler WITHOUT `file`, so it is the skill's default.
|
|
77
|
+
* - `file` names a host file: the guidance becomes that file; a refused name keeps the skill's
|
|
78
|
+
* guidance with `GUIDANCE.md` first, plus a note.
|
|
79
|
+
* - otherwise: `GUIDANCE.md` goes before the plugin's guidance; `optional.notice` stays first.
|
|
80
|
+
* Host names are appended to `files` either way.
|
|
81
|
+
* @complexity Two overlay reads at most, plus O(guidance) text work.
|
|
82
|
+
*/
|
|
83
|
+
export declare function deliverHostPluginGuidance(required: {
|
|
84
|
+
result: PluginToolGuidance;
|
|
85
|
+
file?: string;
|
|
86
|
+
overlaysDir: string;
|
|
87
|
+
}, optional?: {
|
|
88
|
+
notice?: string;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
guidance: string;
|
|
91
|
+
files: string[];
|
|
92
|
+
note?: string;
|
|
93
|
+
}>;
|
|
94
|
+
/** A run-reference request, as the host's run-reference resolver receives it. */
|
|
95
|
+
export interface HostPluginRefOptions {
|
|
96
|
+
readonly deliveryMode?: AgentPluginDeliveryMode;
|
|
97
|
+
readonly allowInactiveGuidance?: boolean;
|
|
98
|
+
readonly skill?: string;
|
|
99
|
+
readonly file?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Splits a run-reference request: the owner receives everything except a `host/` file, which is
|
|
103
|
+
* the host's. Pointer delivery with nothing selected stays the owner's ~400-byte pointer; its tool call
|
|
104
|
+
* carries the overlay, so the guidance is not added twice.
|
|
105
|
+
* @complexity O(1).
|
|
106
|
+
*/
|
|
107
|
+
export declare function splitHostPluginRefRequest(required: {
|
|
108
|
+
options: HostPluginRefOptions;
|
|
109
|
+
defaultDeliveryMode: AgentPluginDeliveryMode;
|
|
110
|
+
}, _optional?: Record<string, never>): {
|
|
111
|
+
ownerOptions: HostPluginRefOptions;
|
|
112
|
+
overlay: {
|
|
113
|
+
includeGuidance: boolean;
|
|
114
|
+
file?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Seam 2, run references. For each pinned plugin: its `GUIDANCE.md` (unless `includeGuidance` is
|
|
119
|
+
* false — pointer delivery, whose tool call carries it) and, when `file` names a host file, that
|
|
120
|
+
* file framed with its plugin and name. A missing host file refuses the run, as the owner refuses a
|
|
121
|
+
* missing plugin file.
|
|
122
|
+
* @complexity O(refs) overlay reads.
|
|
123
|
+
*/
|
|
124
|
+
export declare function readHostPluginRefOverlays(required: {
|
|
125
|
+
pluginRefIds: readonly string[];
|
|
126
|
+
includeGuidance: boolean;
|
|
127
|
+
file?: string;
|
|
128
|
+
overlaysDir: string;
|
|
129
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
130
|
+
ok: true;
|
|
131
|
+
guidance: string[];
|
|
132
|
+
fileSections: string[];
|
|
133
|
+
} | {
|
|
134
|
+
ok: false;
|
|
135
|
+
reason: string;
|
|
136
|
+
}>;
|
|
137
|
+
//# sourceMappingURL=host-plugin-guidance.d.ts.map
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isNonArrayRecord } from "@jini-ai/core";
|
|
4
|
+
import { orFallbackSync } from "@jini-ai/core/errors/idioms";
|
|
5
|
+
import { load, FAILSAFE_SCHEMA } from "js-yaml";
|
|
6
|
+
/**
|
|
7
|
+
* @file A host's overlay for portable Agent Plugins: the one formatter for
|
|
8
|
+
* `<overlaysDir>/<pluginId>/` (the host's overlay directory, always passed in as `overlaysDir`).
|
|
9
|
+
*
|
|
10
|
+
* A plugin's own payload (a Jini `@jini-ai/agent-plugins/<id>` subpath) describes jobs, not the host's tools.
|
|
11
|
+
* The host's rules for those jobs — which tool does what, which shapes to write — live in an overlay:
|
|
12
|
+
* an optional `GUIDANCE.md` placed before the plugin's guidance, and optional `host/<name>.md`
|
|
13
|
+
* supporting files a model reads by asking the plugin's own tool for `file: "host/<name>.md"`.
|
|
14
|
+
*
|
|
15
|
+
* Both delivery seams use this file and nothing else: the host's `agent_plugin_<id>` tool wrapper
|
|
16
|
+
* and its run-reference resolver. Both run AFTER the
|
|
17
|
+
* plugin's activation gate, so a disabled plugin never receives its overlay. This replaced reading
|
|
18
|
+
* host references through `fs_read_file` root `repo`, which site agents are refused
|
|
19
|
+
* and which a packaged build does not ship anyway.
|
|
20
|
+
*
|
|
21
|
+
* Lookup is by `pluginId` only; a caller never supplies a path. Reads are bounded at the same
|
|
22
|
+
* 256 KiB the plugin's own file reader uses.
|
|
23
|
+
*/
|
|
24
|
+
/** Same per-file cap as the plugin skill-file reader, so an overlay file is never the larger read. */
|
|
25
|
+
export const MAX_HOST_PLUGIN_FILE_BYTES = 256 * 1024;
|
|
26
|
+
/** The host answers `file` values with this prefix from the overlay; the plugin never sees them. */
|
|
27
|
+
export const HOST_PLUGIN_FILE_PREFIX = "host/";
|
|
28
|
+
// One path segment each: no dot, slash or backslash can reach `path.join`, so no traversal and
|
|
29
|
+
// no absolute name. A host's overlay test can pin the same file rule.
|
|
30
|
+
const PLUGIN_ID_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
31
|
+
const HOST_FILE_PATTERN = /^host\/[a-z0-9-]+\.md$/;
|
|
32
|
+
const GUIDANCE_FILE = "GUIDANCE.md";
|
|
33
|
+
/** True when a plugin tool `file` value names an overlay file rather than a plugin file. */
|
|
34
|
+
export function isHostPluginFileRequest(required, _optional = {}) {
|
|
35
|
+
return typeof required.file === "string" && required.file.startsWith(HOST_PLUGIN_FILE_PREFIX);
|
|
36
|
+
}
|
|
37
|
+
/** `undefined` for absent files only; a directory or other non-file is a broken overlay and throws. */
|
|
38
|
+
async function readBoundedFile({ filePath }, _optional = {}) {
|
|
39
|
+
let size;
|
|
40
|
+
try {
|
|
41
|
+
const info = await stat(filePath);
|
|
42
|
+
if (!info.isFile())
|
|
43
|
+
throw new Error(`Agent Plugin overlay entry is not a file: ${path.basename(filePath)}`);
|
|
44
|
+
size = info.size;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error.code === "ENOENT")
|
|
48
|
+
return undefined;
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
if (size > MAX_HOST_PLUGIN_FILE_BYTES)
|
|
52
|
+
return { tooLarge: true };
|
|
53
|
+
return { text: await readFile(filePath, "utf8") };
|
|
54
|
+
}
|
|
55
|
+
/** Sorted `host/<name>.md` names; a missing `host/` folder lists none. O(entries log entries). */
|
|
56
|
+
async function listHostFiles({ pluginDir }, _optional = {}) {
|
|
57
|
+
try {
|
|
58
|
+
const entries = await readdir(path.join(pluginDir, "host"), { withFileTypes: true });
|
|
59
|
+
return entries.filter(entry => entry.isFile()).map(entry => `${HOST_PLUGIN_FILE_PREFIX}${entry.name}`)
|
|
60
|
+
.filter(name => HOST_FILE_PATTERN.test(name)).sort();
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error.code === "ENOENT")
|
|
64
|
+
return [];
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Reads one plugin's overlay guidance and host-file names.
|
|
70
|
+
* @returns `{ files: [] }` when the plugin has no overlay (or an id that cannot name one).
|
|
71
|
+
* @throws A `GUIDANCE.md` over 256 KiB, not a file, or unreadable — host rules are never silently dropped.
|
|
72
|
+
* @complexity One stat, one bounded read, one readdir.
|
|
73
|
+
*/
|
|
74
|
+
export async function readHostPluginGuidance(required, _optional = {}) {
|
|
75
|
+
if (!PLUGIN_ID_PATTERN.test(required.pluginId))
|
|
76
|
+
return { files: [] };
|
|
77
|
+
const pluginDir = path.join(required.overlaysDir, required.pluginId);
|
|
78
|
+
const guidance = await readBoundedFile({ filePath: path.join(pluginDir, GUIDANCE_FILE) });
|
|
79
|
+
if (guidance && "tooLarge" in guidance)
|
|
80
|
+
throw new Error(`Agent Plugin overlay ${required.pluginId}/${GUIDANCE_FILE} is over ${MAX_HOST_PLUGIN_FILE_BYTES} bytes`);
|
|
81
|
+
const files = await listHostFiles({ pluginDir });
|
|
82
|
+
return guidance ? { guidance: guidance.text, files } : { files };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Reads one `host/<name>.md` overlay file. Every refusal is a note naming the valid files, the same
|
|
86
|
+
* recovery shape the plugin's own file reader gives; a caller's unsafe value is never echoed.
|
|
87
|
+
* @complexity One stat, one bounded read, one readdir.
|
|
88
|
+
*/
|
|
89
|
+
export async function readHostPluginFile(required, _optional = {}) {
|
|
90
|
+
const pluginDir = path.join(required.overlaysDir, required.pluginId);
|
|
91
|
+
const valid = PLUGIN_ID_PATTERN.test(required.pluginId) ? await listHostFiles({ pluginDir }) : [];
|
|
92
|
+
const read = valid.includes(required.file) ? await readBoundedFile({ filePath: path.join(pluginDir, required.file) }) : undefined;
|
|
93
|
+
if (read && "text" in read)
|
|
94
|
+
return { text: read.text };
|
|
95
|
+
const label = HOST_FILE_PATTERN.test(required.file) ? ` '${required.file}'` : "";
|
|
96
|
+
const reason = read ? `is over ${MAX_HOST_PLUGIN_FILE_BYTES} bytes` : "is not available";
|
|
97
|
+
return { note: `Host file${label} ${reason} for the '${required.pluginId}' plugin. Valid host files: ${valid.join(", ") || "(none)"}.` };
|
|
98
|
+
}
|
|
99
|
+
// A host chat has no shell. The shared shadcn skill keeps `"Bash"` in `allowed-tools` for coding hosts;
|
|
100
|
+
// this removes that permission from what a chat host delivers.
|
|
101
|
+
const REFUSED_TOOL_ITEM = /^\s+-\s*["']?Bash["']?\s*$/;
|
|
102
|
+
/** A `---` opens frontmatter only around a YAML mapping, at the top of a text, after a blank
|
|
103
|
+
* line, or right after a run section's `<<AGENT_PLUGIN …>>` header. Markdown rules stay body text.
|
|
104
|
+
* Reuse the same failsafe YAML reader as platform/markdown/frontmatter; retain original bytes.
|
|
105
|
+
* @complexity O(candidate bytes). Candidates end at the next delimiter, so scans do not overlap. */
|
|
106
|
+
function opensFrontmatter({ lines, index }, _options = {}) {
|
|
107
|
+
const previous = lines[index - 1];
|
|
108
|
+
if (previous !== undefined && previous.trim() !== "" && !previous.startsWith("<<AGENT_PLUGIN"))
|
|
109
|
+
return false;
|
|
110
|
+
let end = index + 1;
|
|
111
|
+
while (end < lines.length && lines[end].trimEnd() !== "---")
|
|
112
|
+
end++;
|
|
113
|
+
if (end === lines.length)
|
|
114
|
+
return false;
|
|
115
|
+
return orFallbackSync({
|
|
116
|
+
work: () => isNonArrayRecord({ value: load(lines.slice(index + 1, end).join("\n"), { schema: FAILSAFE_SCHEMA }) }),
|
|
117
|
+
fallback: false,
|
|
118
|
+
step: "classify plugin guidance frontmatter",
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function nextFrontmatterState(required) {
|
|
122
|
+
const line = required.line.trimEnd();
|
|
123
|
+
if (required.state === "body")
|
|
124
|
+
return line === "---" && opensFrontmatter(required) ? "frontmatter" : "body";
|
|
125
|
+
if (line === "---")
|
|
126
|
+
return "body";
|
|
127
|
+
if (/^allowed-tools:$/.test(line))
|
|
128
|
+
return "allowedTools";
|
|
129
|
+
return required.state === "allowedTools" && /^\s+-\s/.test(line) ? "allowedTools" : "frontmatter";
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Removes a `"Bash"` item from every frontmatter `allowed-tools` list in delivered guidance. Body
|
|
133
|
+
* text, examples and every other tool stay byte-identical; source files are never changed.
|
|
134
|
+
* @complexity O(lines).
|
|
135
|
+
*/
|
|
136
|
+
export function removeChatRefusedToolPermissions({ text }, _optional = {}) {
|
|
137
|
+
const lines = text.split("\n");
|
|
138
|
+
let state = "body";
|
|
139
|
+
let fence;
|
|
140
|
+
return lines.filter((line, index) => {
|
|
141
|
+
const marker = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
142
|
+
if (state === "body" && marker) {
|
|
143
|
+
// Both capture groups are required by the pattern, so a match always carries them.
|
|
144
|
+
const markerFence = marker[1];
|
|
145
|
+
const markerSuffix = marker[2];
|
|
146
|
+
if (fence === undefined)
|
|
147
|
+
fence = markerFence;
|
|
148
|
+
else if (markerFence[0] === fence[0] && markerFence.length >= fence.length && markerSuffix.trim() === "")
|
|
149
|
+
fence = undefined;
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (fence !== undefined)
|
|
153
|
+
return true;
|
|
154
|
+
state = nextFrontmatterState({ state, line, lines, index });
|
|
155
|
+
return !(state === "allowedTools" && REFUSED_TOOL_ITEM.test(line));
|
|
156
|
+
}).join("\n");
|
|
157
|
+
}
|
|
158
|
+
/** Splits a leading notice (maturity) off the plugin's guidance so it can stay first. O(text). */
|
|
159
|
+
function splitNotice(required, optional) {
|
|
160
|
+
const { notice } = optional;
|
|
161
|
+
if (notice === undefined || !required.guidance.startsWith(`${notice}\n\n`))
|
|
162
|
+
return { body: required.guidance };
|
|
163
|
+
return { lead: notice, body: required.guidance.slice(notice.length + 2) };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Seam 1, the `agent_plugin_<id>` tool response. `required.result` is the plugin handler's answer —
|
|
167
|
+
* for a `host/` request, the caller asked the handler WITHOUT `file`, so it is the skill's default.
|
|
168
|
+
* - `file` names a host file: the guidance becomes that file; a refused name keeps the skill's
|
|
169
|
+
* guidance with `GUIDANCE.md` first, plus a note.
|
|
170
|
+
* - otherwise: `GUIDANCE.md` goes before the plugin's guidance; `optional.notice` stays first.
|
|
171
|
+
* Host names are appended to `files` either way.
|
|
172
|
+
* @complexity Two overlay reads at most, plus O(guidance) text work.
|
|
173
|
+
*/
|
|
174
|
+
export async function deliverHostPluginGuidance(required, optional = {}) {
|
|
175
|
+
const { result } = required;
|
|
176
|
+
const host = await readHostPluginGuidance({ pluginId: result.pluginId, overlaysDir: required.overlaysDir });
|
|
177
|
+
const files = [...(result.files ?? []), ...host.files];
|
|
178
|
+
const read = required.file === undefined ? undefined : await readHostPluginFile({ pluginId: result.pluginId, file: required.file, overlaysDir: required.overlaysDir });
|
|
179
|
+
const { lead, body } = splitNotice({ guidance: result.guidance }, optional);
|
|
180
|
+
const parts = read && "text" in read ? [lead, read.text] : [lead, host.guidance, body];
|
|
181
|
+
const guidance = parts.filter(Boolean).join("\n\n");
|
|
182
|
+
const note = [result.note, read && "note" in read ? read.note : undefined].filter(Boolean).join(" ");
|
|
183
|
+
return { guidance: removeChatRefusedToolPermissions({ text: guidance }), files, ...(note ? { note } : {}) };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Splits a run-reference request: the owner receives everything except a `host/` file, which is
|
|
187
|
+
* the host's. Pointer delivery with nothing selected stays the owner's ~400-byte pointer; its tool call
|
|
188
|
+
* carries the overlay, so the guidance is not added twice.
|
|
189
|
+
* @complexity O(1).
|
|
190
|
+
*/
|
|
191
|
+
export function splitHostPluginRefRequest(required, _optional = {}) {
|
|
192
|
+
const { options } = required;
|
|
193
|
+
const pointerOnly = (options.deliveryMode ?? required.defaultDeliveryMode) === "pointer" && options.skill === undefined && options.file === undefined;
|
|
194
|
+
const { file, ...ownerOptions } = options;
|
|
195
|
+
const request = { file };
|
|
196
|
+
if (!isHostPluginFileRequest(request))
|
|
197
|
+
return { ownerOptions: options, overlay: { includeGuidance: !pointerOnly } };
|
|
198
|
+
return { ownerOptions, overlay: { includeGuidance: !pointerOnly, file: request.file } };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Seam 2, run references. For each pinned plugin: its `GUIDANCE.md` (unless `includeGuidance` is
|
|
202
|
+
* false — pointer delivery, whose tool call carries it) and, when `file` names a host file, that
|
|
203
|
+
* file framed with its plugin and name. A missing host file refuses the run, as the owner refuses a
|
|
204
|
+
* missing plugin file.
|
|
205
|
+
* @complexity O(refs) overlay reads.
|
|
206
|
+
*/
|
|
207
|
+
export async function readHostPluginRefOverlays(required, _optional = {}) {
|
|
208
|
+
const guidance = [];
|
|
209
|
+
const fileSections = [];
|
|
210
|
+
for (const pluginId of required.pluginRefIds) {
|
|
211
|
+
const host = required.includeGuidance ? await readHostPluginGuidance({ pluginId, overlaysDir: required.overlaysDir }) : { files: [] };
|
|
212
|
+
if (host.guidance !== undefined)
|
|
213
|
+
guidance.push(host.guidance);
|
|
214
|
+
if (required.file === undefined)
|
|
215
|
+
continue;
|
|
216
|
+
const read = await readHostPluginFile({ pluginId, file: required.file, overlaysDir: required.overlaysDir });
|
|
217
|
+
if ("note" in read)
|
|
218
|
+
return { ok: false, reason: read.note };
|
|
219
|
+
fileSections.push(`Host file ${required.file} for Agent Plugin '${pluginId}':\n${read.text}`);
|
|
220
|
+
}
|
|
221
|
+
return { ok: true, guidance, fileSections };
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=host-plugin-guidance.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AgentPluginIdentityReadOptions } from "../core/identity-namespace.js";
|
|
2
|
+
import { type AgentPluginHostSignal } from "@jini-ai/agent-plugins/manifest";
|
|
3
|
+
import type { AgentPluginPathsPort } from "@jini-ai/agent-plugins/site/service-ports";
|
|
4
|
+
/**
|
|
5
|
+
* @file Host signals declared by shipped (bundled) agent plugins: a pure manifest parser, a hermetic
|
|
6
|
+
* bundled reader, and a resolver that binds those hints to the host's core security policy. The host
|
|
7
|
+
* injects its bundled-source policy (`sources`) and its policy functions (`evaluateHostSignals`,
|
|
8
|
+
* `selectCoreHostSignalDeclaration`, which own the security fallback); see `README.md` `## Wiring`.
|
|
9
|
+
*/
|
|
10
|
+
/** Validated host-signal hints from shipped plugin manifests (structurally the host's declaration type). */
|
|
11
|
+
export interface BundledHostSignalDeclaration {
|
|
12
|
+
readonly signals: readonly AgentPluginHostSignal[];
|
|
13
|
+
readonly deploymentAdvice?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The host's hermetic bundled-source policy: which packages under `sourceRoot` ship `filename`. */
|
|
16
|
+
export type BundledHostSignalSources = (required: {
|
|
17
|
+
readonly sourceRoot: string;
|
|
18
|
+
readonly filename: string;
|
|
19
|
+
}) => readonly {
|
|
20
|
+
readonly packageRoot: string;
|
|
21
|
+
}[];
|
|
22
|
+
/** The host's core policy functions; they own the security fallback, this module only supplies data. */
|
|
23
|
+
export interface HostSignalPolicyPorts<S> {
|
|
24
|
+
readonly evaluateHostSignals: (required: {
|
|
25
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
26
|
+
declaration: BundledHostSignalDeclaration;
|
|
27
|
+
}) => S;
|
|
28
|
+
readonly selectCoreHostSignalDeclaration: (required: {
|
|
29
|
+
declaration?: BundledHostSignalDeclaration;
|
|
30
|
+
}) => BundledHostSignalDeclaration;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read Jini's validated portable extension; malformed declarations contribute nothing.
|
|
34
|
+
* @param required Parsed JSON manifest, never executable plugin code.
|
|
35
|
+
* @returns Validated hints, or undefined for absent/invalid metadata. Never throws for JSON input.
|
|
36
|
+
* @complexity O(s) for s declared signals; no I/O.
|
|
37
|
+
* @example parseHostSignalDeclaration({ manifest: JSON.parse(text) }, optional);
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseHostSignalDeclaration({ manifest }: {
|
|
40
|
+
manifest: unknown;
|
|
41
|
+
}, optional?: Pick<AgentPluginIdentityReadOptions, "legacyIdentity">): BundledHostSignalDeclaration | undefined;
|
|
42
|
+
interface ReaderPorts {
|
|
43
|
+
readonly readText?: (file: string) => string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Read only manifests from the hermetic bundled source policy, independent of site activation.
|
|
47
|
+
* @param required Product-controlled content/agent-plugins root, never an installed package dir, and the
|
|
48
|
+
* host's bundled-source policy (`sources`).
|
|
49
|
+
* @param optional Text reader port for direct failure-path tests.
|
|
50
|
+
* @returns Validated unambiguous data. Absent/malformed packages contribute no declaration;
|
|
51
|
+
* the resolver applies the core security fallback rather than treating absent data as permission.
|
|
52
|
+
* @complexity O(p + s) for p plugin manifests and s signals; one synchronous read per manifest.
|
|
53
|
+
* @example readBundledHostSignalDeclaration({ sourceRoot, sources });
|
|
54
|
+
*/
|
|
55
|
+
export declare function readBundledHostSignalDeclaration(required: {
|
|
56
|
+
readonly sourceRoot: string;
|
|
57
|
+
readonly sources: BundledHostSignalSources;
|
|
58
|
+
}, optional?: ReaderPorts & Pick<AgentPluginIdentityReadOptions, "legacyIdentity">): BundledHostSignalDeclaration;
|
|
59
|
+
/**
|
|
60
|
+
* Bind the host's bundled-source fact to the pure evaluator; no plugin imports, DB or activation needed.
|
|
61
|
+
* @param required Environment snapshot, values are never logged or returned as diagnostic copy; plus the
|
|
62
|
+
* host's bundled-source policy and core policy functions.
|
|
63
|
+
* @param optional Declaration reader port; desktop may supply its payload in the required path fact.
|
|
64
|
+
* @returns Facts only; unavailable/incomplete/ambiguous security data uses the core HEAD fallback.
|
|
65
|
+
* Read failures never fail boot or disable the baseline hosted protections.
|
|
66
|
+
* @complexity O(p + s) as for the reader.
|
|
67
|
+
* @example resolveBundledHostSignals({ env, bundledSourceRoot, sources, evaluateHostSignals, selectCoreHostSignalDeclaration });
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveBundledHostSignals<S>(required: Pick<AgentPluginPathsPort, "bundledSourceRoot"> & HostSignalPolicyPorts<S> & {
|
|
70
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
71
|
+
readonly sources: BundledHostSignalSources;
|
|
72
|
+
}, optional?: Pick<AgentPluginIdentityReadOptions, "legacyIdentity"> & {
|
|
73
|
+
readDeclaration?: (required: {
|
|
74
|
+
readonly sourceRoot: string;
|
|
75
|
+
}) => BundledHostSignalDeclaration;
|
|
76
|
+
}): S;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=host-signals.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { readAgentPluginMetadata } from "@jini-ai/agent-plugins/manifest";
|
|
2
|
+
import { orFallbackSync } from "@jini-ai/core/errors/idioms";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
/**
|
|
6
|
+
* Read Jini's validated portable extension; malformed declarations contribute nothing.
|
|
7
|
+
* @param required Parsed JSON manifest, never executable plugin code.
|
|
8
|
+
* @returns Validated hints, or undefined for absent/invalid metadata. Never throws for JSON input.
|
|
9
|
+
* @complexity O(s) for s declared signals; no I/O.
|
|
10
|
+
* @example parseHostSignalDeclaration({ manifest: JSON.parse(text) }, optional);
|
|
11
|
+
*/
|
|
12
|
+
export function parseHostSignalDeclaration({ manifest }, optional = {}) {
|
|
13
|
+
const { metadata } = readAgentPluginMetadata({ value: manifest }, optional);
|
|
14
|
+
if (metadata.hostSignals === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
return { signals: metadata.hostSignals, ...(metadata.deploymentAdvice === undefined ? {} : { deploymentAdvice: metadata.deploymentAdvice }) };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Read only manifests from the hermetic bundled source policy, independent of site activation.
|
|
20
|
+
* @param required Product-controlled content/agent-plugins root, never an installed package dir, and the
|
|
21
|
+
* host's bundled-source policy (`sources`).
|
|
22
|
+
* @param optional Text reader port for direct failure-path tests.
|
|
23
|
+
* @returns Validated unambiguous data. Absent/malformed packages contribute no declaration;
|
|
24
|
+
* the resolver applies the core security fallback rather than treating absent data as permission.
|
|
25
|
+
* @complexity O(p + s) for p plugin manifests and s signals; one synchronous read per manifest.
|
|
26
|
+
* @example readBundledHostSignalDeclaration({ sourceRoot, sources });
|
|
27
|
+
*/
|
|
28
|
+
export function readBundledHostSignalDeclaration(required, optional = {}) {
|
|
29
|
+
// Preboot readers must not turn a missing bundled payload into a boot failure (phase 2 policy).
|
|
30
|
+
const sources = orFallbackSync({
|
|
31
|
+
work: () => required.sources({ sourceRoot: required.sourceRoot, filename: "plugin.json" }),
|
|
32
|
+
fallback: [],
|
|
33
|
+
step: "list bundled host signal manifests",
|
|
34
|
+
});
|
|
35
|
+
const declarations = sources.flatMap(source => {
|
|
36
|
+
return orFallbackSync({
|
|
37
|
+
work: () => {
|
|
38
|
+
const file = path.join(source.packageRoot, "plugin.json");
|
|
39
|
+
const text = optional.readText === undefined || optional.readText === null ? readManifestText({ file }) : optional.readText(file);
|
|
40
|
+
const declaration = parseHostSignalDeclaration({ manifest: JSON.parse(text) }, optional);
|
|
41
|
+
return declaration === undefined ? [] : [declaration];
|
|
42
|
+
},
|
|
43
|
+
fallback: [],
|
|
44
|
+
step: "read bundled host signal manifest",
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return combineDeclarations({ declarations });
|
|
48
|
+
}
|
|
49
|
+
/** Reject the whole ambiguous declaration so the resolver can retain the complete core fallback.
|
|
50
|
+
* @complexity O(s + p) for s signals and p declarations, with no I/O or input mutation. */
|
|
51
|
+
function combineDeclarations({ declarations }, _optional = {}) {
|
|
52
|
+
const signals = declarations.flatMap(declaration => declaration.signals);
|
|
53
|
+
const names = new Set(signals.map(signal => signal.env));
|
|
54
|
+
const advice = [...new Set(declarations.flatMap(declaration => declaration.deploymentAdvice === undefined ? [] : [declaration.deploymentAdvice]))];
|
|
55
|
+
if (names.size !== signals.length || advice.length > 1)
|
|
56
|
+
return { signals: [] };
|
|
57
|
+
return { signals, ...(advice.length === 1 ? { deploymentAdvice: advice[0] } : {}) };
|
|
58
|
+
}
|
|
59
|
+
/** Node's text-only manifest read; errors are caught at the bundled adapter boundary. */
|
|
60
|
+
function readManifestText({ file }, _optional = {}) { return readFileSync(file, "utf8"); }
|
|
61
|
+
/**
|
|
62
|
+
* Bind the host's bundled-source fact to the pure evaluator; no plugin imports, DB or activation needed.
|
|
63
|
+
* @param required Environment snapshot, values are never logged or returned as diagnostic copy; plus the
|
|
64
|
+
* host's bundled-source policy and core policy functions.
|
|
65
|
+
* @param optional Declaration reader port; desktop may supply its payload in the required path fact.
|
|
66
|
+
* @returns Facts only; unavailable/incomplete/ambiguous security data uses the core HEAD fallback.
|
|
67
|
+
* Read failures never fail boot or disable the baseline hosted protections.
|
|
68
|
+
* @complexity O(p + s) as for the reader.
|
|
69
|
+
* @example resolveBundledHostSignals({ env, bundledSourceRoot, sources, evaluateHostSignals, selectCoreHostSignalDeclaration });
|
|
70
|
+
*/
|
|
71
|
+
export function resolveBundledHostSignals(required, optional = {}) {
|
|
72
|
+
return orFallbackSync({
|
|
73
|
+
work: () => {
|
|
74
|
+
const sourceRoot = required.bundledSourceRoot;
|
|
75
|
+
const read = optional.readDeclaration ?? (({ sourceRoot: root }) => readBundledHostSignalDeclaration({ sourceRoot: root, sources: required.sources }, optional));
|
|
76
|
+
const declaration = required.selectCoreHostSignalDeclaration({ declaration: read({ sourceRoot }) });
|
|
77
|
+
return required.evaluateHostSignals({ env: required.env, declaration });
|
|
78
|
+
},
|
|
79
|
+
fallback: undefined,
|
|
80
|
+
step: "resolve bundled host signals",
|
|
81
|
+
}) ?? required.evaluateHostSignals({ env: required.env, declaration: required.selectCoreHostSignalDeclaration({}) });
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=host-signals.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createAgentPluginUpdateEffects, type UpdateMcpDeps } from "./update-effects.js";
|
|
2
|
+
import type { UpdateAgentPluginRequired } from "@jini-ai/agent-plugins/lifecycle";
|
|
3
|
+
import { buildDomainRegistrations, type AgentToolDefinition, type AgentToolSideEffect, type ToolRegistration, type ToolExecutionContext } from "@jini-ai/core";
|
|
4
|
+
import type { zipLocalFolder } from "@jini-ai/agent-plugins/folder-zip/node";
|
|
5
|
+
import type { ToolContributor } from "@jini-ai/core";
|
|
6
|
+
import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
|
|
7
|
+
import type { InstallAttachmentReader, PluginInstallSourcePort } from "@jini-ai/core/contracts/headless/plugin-install-source";
|
|
8
|
+
import type { createAgentPluginLifecycle } from "../lifecycle/index.js";
|
|
9
|
+
import { type InstallUploadedAgentPluginOptional, type bindAgentPluginUpload } from "./install-upload.js";
|
|
10
|
+
import type { AgentPluginLayout } from "@jini-ai/core/contracts/headless/plugin-host";
|
|
11
|
+
import type { listBundledAgentPluginServers } from "../connect/new-site-agent-plugin-tokens.js";
|
|
12
|
+
import type { prepareCustomizedAgentPluginArchive } from './customize-tool.js';
|
|
13
|
+
/** The assistant uses the same uploaded-package service as the Agent Plugins admin add tab.
|
|
14
|
+
* Customization prepares a new package and enters this same install flow, without replacement.
|
|
15
|
+
* No opt-in for this family: only bundled digests may run code. Preview verifies the full archive,
|
|
16
|
+
* install verifies the pinned bytes again, and every fresh/replacement install remains disabled. */
|
|
17
|
+
export type AgentPluginsInstallToolDeps<Layout extends AgentPluginLayout = AgentPluginLayout> = {
|
|
18
|
+
readonly pluginInstallSource: PluginInstallSourcePort;
|
|
19
|
+
readonly snapshotAgentPluginSettings?: UpdateAgentPluginRequired["snapshotSettings"];
|
|
20
|
+
readonly pluginHost?: import("@jini-ai/core/contracts/headless/plugin-host").PluginHostPort;
|
|
21
|
+
readonly workspaceId: string;
|
|
22
|
+
readonly authorize: AuthorizeFn;
|
|
23
|
+
readonly readInstallAttachment?: InstallAttachmentReader;
|
|
24
|
+
readonly agentPluginLayout: Layout;
|
|
25
|
+
readonly bundledAgentPluginsSourceRoot: string;
|
|
26
|
+
readonly catalog: readonly AgentToolDefinition[];
|
|
27
|
+
readonly catalogModule: string;
|
|
28
|
+
readonly toolMetadata: Parameters<typeof buildDomainRegistrations>[0]['metadata'];
|
|
29
|
+
readonly installPermission: string;
|
|
30
|
+
readonly zipLocalFolder: typeof zipLocalFolder;
|
|
31
|
+
readonly maxAgentPluginInstallArchiveBytes: () => number;
|
|
32
|
+
readonly listInstalledPlugins: ReturnType<typeof createAgentPluginLifecycle>['listInstalledPlugins'];
|
|
33
|
+
readonly seedBundledAgentPlugins: (input: Omit<Parameters<ReturnType<typeof createAgentPluginLifecycle>['seedBundledAgentPlugins']>[0], 'layout'> & {
|
|
34
|
+
layout: Layout;
|
|
35
|
+
}) => ReturnType<ReturnType<typeof createAgentPluginLifecycle>['seedBundledAgentPlugins']>;
|
|
36
|
+
readonly listBundledAgentPluginServers: (input: {
|
|
37
|
+
bundledSourceRoot: string;
|
|
38
|
+
}) => ReturnType<typeof listBundledAgentPluginServers>;
|
|
39
|
+
readonly agentPluginActivations: Pick<InstallUploadedAgentPluginOptional['lifecycle'], 'resolveAgentPluginActivation' | 'isAgentPluginRecordedAsBundled'>;
|
|
40
|
+
readonly uploadOptions: InstallUploadedAgentPluginOptional;
|
|
41
|
+
readonly resolveServers: Parameters<typeof createAgentPluginUpdateEffects>[0]['resolveServers'];
|
|
42
|
+
readonly provisionServers: Parameters<typeof createAgentPluginUpdateEffects>[0]['provisionServers'];
|
|
43
|
+
readonly prepareCustomizedAgentPluginArchive: (input: {
|
|
44
|
+
deps: AgentPluginsInstallToolDeps;
|
|
45
|
+
ctx: ToolExecutionContext;
|
|
46
|
+
}) => ReturnType<typeof prepareCustomizedAgentPluginArchive>;
|
|
47
|
+
} & Partial<UpdateMcpDeps>;
|
|
48
|
+
export declare const AGENT_PLUGINS_UPDATE_TOOL_ID = "agent_plugins_update";
|
|
49
|
+
export declare const AGENT_PLUGINS_INSTALL_TOOL_ID = "agent_plugins_install";
|
|
50
|
+
export declare const derivedRisk: ReadonlyMap<string, AgentToolSideEffect>;
|
|
51
|
+
export declare function bindAgentPluginsInstallTools<Layout extends AgentPluginLayout>(required: Pick<AgentPluginsInstallToolDeps<Layout>, 'catalog' | 'catalogModule' | 'toolMetadata' | 'installPermission' | 'zipLocalFolder' | 'maxAgentPluginInstallArchiveBytes' | 'listInstalledPlugins' | 'seedBundledAgentPlugins' | 'listBundledAgentPluginServers' | 'agentPluginActivations'> & {
|
|
52
|
+
sha256: InstallUploadedAgentPluginOptional['sha256'];
|
|
53
|
+
installUploadedAgentPlugin: ReturnType<typeof bindAgentPluginUpload>['installUploadedAgentPlugin'];
|
|
54
|
+
previewUploadedAgentPlugin: ReturnType<typeof bindAgentPluginUpload>['previewUploadedAgentPlugin'];
|
|
55
|
+
updateMcpEffects(input: {
|
|
56
|
+
deps: Pick<UpdateMcpDeps, 'workspaceId' | 'agentPluginLayout'> & Partial<UpdateMcpDeps>;
|
|
57
|
+
actor: string;
|
|
58
|
+
}): ReturnType<typeof createAgentPluginUpdateEffects>;
|
|
59
|
+
prepareCustomizedAgentPluginArchive(input: {
|
|
60
|
+
deps: Pick<AgentPluginsInstallToolDeps, 'workspaceId' | 'agentPluginLayout'>;
|
|
61
|
+
ctx: ToolExecutionContext;
|
|
62
|
+
}): ReturnType<typeof prepareCustomizedAgentPluginArchive>;
|
|
63
|
+
}, _optional?: {}): {
|
|
64
|
+
buildRegistrations: (input: Omit<AgentPluginsInstallToolDeps<Layout>, keyof typeof required | "uploadOptions" | "resolveServers" | "provisionServers">, _optional?: {}) => ToolRegistration[];
|
|
65
|
+
contributeAgentPluginsInstallTools: (input: Pick<AgentPluginsInstallToolDeps, "readInstallAttachment" | "pluginInstallSource">, _optional?: {}) => ToolContributor<Omit<Parameters<(input: Omit<AgentPluginsInstallToolDeps<Layout>, keyof typeof required | "uploadOptions" | "resolveServers" | "provisionServers">, _optional?: {}) => ToolRegistration[]>[0], "pluginInstallSource">, unknown>;
|
|
66
|
+
};
|
|
67
|
+
export declare function buildRegistrations(deps: AgentPluginsInstallToolDeps, _optional?: {}): ToolRegistration[];
|
|
68
|
+
export declare function contributeAgentPluginsInstallTools(required: Pick<AgentPluginsInstallToolDeps, 'readInstallAttachment' | 'pluginInstallSource'>, _optional?: {}): ToolContributor<Omit<Parameters<typeof buildRegistrations>[0], 'pluginInstallSource'>, unknown>;
|
|
69
|
+
//# sourceMappingURL=install-tool.d.ts.map
|