@jini-ai/agent-plugins 0.7.1 → 0.7.3-next.1
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 +4 -4
- package/NOTICE +2 -0
- package/README.md +11 -15
- package/calendly/plugin.json +3 -3
- package/cloudflare/lib/forms.mjs +9 -10
- package/cloudflare/lib/target.mjs +1 -1
- package/cloudflare/plugin.json +3 -3
- package/cloudflare/worker/forms-receiver.mjs +9 -9
- package/composio/plugin.json +3 -3
- package/core/persistent-state.js +227 -163
- package/dist/admin-surfaces/connections/connections.d.ts +11 -6
- package/dist/admin-surfaces/connections/connections.js +102 -85
- package/dist/admin-surfaces/node.d.ts +27 -0
- package/dist/admin-surfaces/node.js +32 -0
- package/dist/admin-surfaces/plugin-state.js +21 -18
- package/dist/admin-surfaces/surface-client.d.ts +4 -0
- package/dist/admin-surfaces/surface-client.js +124 -117
- package/dist/admin-surfaces/surface-handlers.js +21 -17
- package/dist/admin-surfaces/theme.d.ts +5 -1
- package/dist/admin-surfaces/theme.js +3 -3
- package/dist/connect/access-token-tool.d.ts +3 -1
- package/dist/connect/access-token-tool.js +3 -2
- package/dist/connect/apply-connect-defaults.js +2 -2
- package/dist/connect/apply-tool-renames.js +9 -8
- package/dist/connect/connect-tool.d.ts +2 -0
- package/dist/connect/connect-tool.js +3 -2
- package/dist/connect/credential-cards.js +3 -2
- package/dist/connect/credential-save-tool.d.ts +14 -11
- package/dist/connect/credential-save-tool.js +128 -121
- package/dist/connect/enable-access.d.ts +2 -2
- package/dist/connect/enable-access.js +6 -6
- package/dist/connect/executable/register.js +40 -34
- package/dist/connect/federate-mcp.d.ts +21 -11
- package/dist/connect/federate-mcp.js +28 -21
- package/dist/connect/grant-signed-in-defaults.js +3 -3
- package/dist/connect/import-access-token.js +2 -1
- package/dist/connect/index.d.ts +1 -0
- package/dist/connect/index.js +1 -0
- package/dist/connect/plugin-credential-card.js +2 -1
- package/dist/connect/plugin-host/index.d.ts +9 -5
- package/dist/connect/plugin-host/index.js +113 -100
- package/dist/connect/ports.d.ts +1 -1
- package/dist/connect/row-update.d.ts +22 -0
- package/dist/connect/row-update.js +18 -0
- package/dist/connect/switch-on-saved-token.d.ts +4 -2
- package/dist/connect/switch-on-saved-token.js +1 -1
- package/dist/connect/token-map.d.ts +44 -0
- package/dist/connect/token-map.js +49 -0
- package/dist/core/identity-namespace.js +5 -0
- package/dist/folder-zip.d.ts +3 -1
- package/dist/folder-zip.js +2 -2
- package/dist/lifecycle/activation.d.ts +4 -4
- package/dist/lifecycle/activation.js +4 -5
- package/dist/lifecycle/automatic-use.js +236 -210
- package/dist/lifecycle/bundled-digests.d.ts +75 -12
- package/dist/lifecycle/bundled-digests.js +213 -212
- package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
- package/dist/lifecycle/bundled-source-archive.js +263 -264
- package/dist/lifecycle/capability-projection.d.ts +1 -1
- package/dist/lifecycle/capability-projection.js +1 -1
- package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
- package/dist/lifecycle/credential-card-metadata.js +27 -3
- package/dist/lifecycle/exports.js +9 -4
- package/dist/lifecycle/fetch-archive.d.ts +1 -1
- package/dist/lifecycle/fetch-archive.js +1 -1
- package/dist/lifecycle/host-tools/identity.js +3 -2
- package/dist/lifecycle/host-tools/ports.d.ts +2 -0
- package/dist/lifecycle/host-tools/search-tool.js +8 -8
- package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
- package/dist/lifecycle/host-tools/skill-tool.js +16 -8
- package/dist/lifecycle/index.d.ts +118 -110
- package/dist/lifecycle/index.js +45 -12
- package/dist/lifecycle/install-errors.d.ts +1 -1
- package/dist/lifecycle/install-from-url.d.ts +1 -1
- package/dist/lifecycle/install-from-url.js +1 -1
- package/dist/lifecycle/install.d.ts +7 -2
- package/dist/lifecycle/install.js +414 -396
- package/dist/lifecycle/installed-package-index.js +45 -42
- package/dist/lifecycle/layout.d.ts +1 -1
- package/dist/lifecycle/layout.js +1 -1
- package/dist/lifecycle/mail/catalog.d.ts +8 -32
- package/dist/lifecycle/mail/catalog.js +25 -20
- package/dist/lifecycle/mail/contribution.d.ts +2 -2
- package/dist/lifecycle/mail/contribution.js +34 -34
- package/dist/lifecycle/mail/selection.js +6 -2
- package/dist/lifecycle/manifest.d.ts +3 -3
- package/dist/lifecycle/manifest.js +4 -4
- package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
- package/dist/lifecycle/mcp-provisioning.js +3 -3
- package/dist/lifecycle/package-paths.d.ts +1 -1
- package/dist/lifecycle/package-paths.js +1 -1
- package/dist/lifecycle/persistent-state.js +1 -2
- package/dist/lifecycle/ports.d.ts +5 -1
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
- package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
- package/dist/lifecycle/retire-bundled.d.ts +1 -52
- package/dist/lifecycle/retire-bundled.js +134 -84
- package/dist/lifecycle/search.d.ts +2 -1
- package/dist/lifecycle/search.js +1 -1
- package/dist/lifecycle/seed-bundled.d.ts +1 -1
- package/dist/lifecycle/seed-bundled.js +154 -155
- package/dist/lifecycle/set-enabled.d.ts +1 -1
- package/dist/lifecycle/set-enabled.js +1 -1
- package/dist/lifecycle/skill-file-reader.js +53 -50
- package/dist/lifecycle/tools/projection.d.ts +4 -7
- package/dist/lifecycle/tools/projection.js +109 -108
- package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
- package/dist/lifecycle/trusted-plugin-files.js +1 -1
- package/dist/lifecycle/uninstall.d.ts +1 -1
- package/dist/lifecycle/uninstall.js +237 -241
- package/dist/lifecycle/update-store.js +20 -17
- package/dist/lifecycle/update.js +287 -281
- package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
- package/dist/lifecycle/yauzl-archive-reader.js +8 -2
- package/dist/manifest.d.ts +11 -3
- package/dist/manifest.js +9 -9
- package/fly/jini-credential-schemes.json +11 -0
- package/fly/plugin.json +3 -4
- package/github/plugin.json +3 -3
- package/github/source-control/backup-push.mjs +11 -11
- package/github/source-control/commit-site.mjs +3 -3
- package/github/source-control/github.mjs +12 -6
- package/github/source-control/write-files.mjs +27 -28
- package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
- package/github-pages/plugin.json +3 -3
- package/github-pages/targets/github-pages.mjs +3 -3
- package/google-login/plugin.json +3 -3
- package/google-workspace/README.md +14 -14
- package/google-workspace/form-destinations/README.md +3 -3
- package/google-workspace/form-destinations/dedupe.mjs +1 -1
- package/google-workspace/form-destinations/mapping.mjs +8 -9
- package/google-workspace/form-destinations/sheets.mjs +1 -1
- package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
- package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
- package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
- package/google-workspace/lib/auth.mjs +2 -2
- package/google-workspace/lib/form-destination-settings.mjs +1 -1
- package/google-workspace/lib/picker-flow.mjs +2 -2
- package/google-workspace/lib/request-policy.mjs +1 -1
- package/google-workspace/lib/surface-actions.mjs +1 -1
- package/google-workspace/plugin.json +3 -3
- package/google-workspace/tools/sheets/README.md +3 -3
- package/google-workspace/tools/sheets-admin/README.md +3 -3
- package/google-workspace/ui/README.md +4 -4
- package/google-workspace/ui/connection-panel.mjs +51 -51
- package/google-workspace/ui/destination-panel.mjs +34 -34
- package/google-workspace/ui/dom.mjs +15 -16
- package/google-workspace/ui/picker-flow.mjs +2 -2
- package/google-workspace/ui/picker.mjs +19 -19
- package/google-workspace/ui/surface-client.mjs +96 -69
- package/higgsfield-media/plugin.json +3 -3
- package/jev/plugin.json +3 -3
- package/kuinetic/CHANGELOG.md +12 -0
- package/kuinetic/mcp.json +4 -0
- package/kuinetic/plugin.json +27 -0
- package/kuinetic/skills/kuinetic/SKILL.md +120 -0
- package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
- package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
- package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
- package/meilisearch/plugin.json +5 -5
- package/netlify/plugin.json +3 -3
- package/netlify/targets/netlify.mjs +14 -4
- package/opentelemetry/plugin.json +3 -3
- package/package.json +25 -20
- package/posthog/plugin.json +3 -3
- package/railway/plugin.json +3 -3
- package/render/plugin.json +3 -3
- package/resend/NOTES.md +2 -2
- package/resend/adapters/resend.mjs +1 -1
- package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
- package/resend/lib/domains.mjs +8 -8
- package/resend/plugin.json +3 -3
- package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
- package/s3-compatible/jini-object-stores.json +29 -0
- package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
- package/s3-compatible/plugin.json +3 -3
- package/s3-compatible/targets/s3-compatible.mjs +25 -25
- package/sentry/plugin.json +3 -3
- package/shadcn-ui/CHANGELOG.md +7 -0
- package/shadcn-ui/LICENSE +201 -0
- package/shadcn-ui/NOTICE +10 -0
- package/shadcn-ui/mcp.json +4 -0
- package/shadcn-ui/plugin.json +26 -0
- package/shopify/plugin.json +3 -3
- package/site-compliance/plugin.json +3 -3
- package/site-import/plugin.json +3 -3
- package/supabase/mcp.json +1 -4
- package/supabase/plugin.json +3 -3
- package/ui-ux-design/CHANGELOG.md +13 -0
- package/ui-ux-design/NOTICE +2 -0
- package/ui-ux-design/README.md +17 -7
- package/ui-ux-design/plugin.json +6 -3
- package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
- package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
- package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
- package/vercel/NOTES.md +1 -1
- package/vercel/object-stores/vercel-blob.mjs +12 -2
- package/vercel/plugin.json +3 -3
- package/vercel/targets/vercel.mjs +3 -3
- package/wordpress/plugin.json +3 -3
- package/dist/lifecycle/node.d.ts +0 -11
- package/dist/lifecycle/node.js +0 -38
- package/fly/tovu-credential-schemes.json +0 -11
- package/github/deployments/github.mjs +0 -415
- package/s3-compatible/tovu-object-stores.json +0 -29
- package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
- /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
- /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
- /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
- /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
- /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
- /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
- /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
- /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
- /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
- /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
- /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
- /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
- /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
- /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
- /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
- /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
- /package/vercel/{tovu-object-stores.json → jini-object-stores.json} +0 -0
|
@@ -68,233 +68,234 @@
|
|
|
68
68
|
/** Extracted from the host plugin lifecycle. Effects are supplied per host context. */
|
|
69
69
|
import path from "node:path";
|
|
70
70
|
export const BUNDLED_DIGESTS_FILENAME = "bundled-digests.json";
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
* @complexity One file read plus O(p) in the recorded plugin count.
|
|
90
|
-
*/
|
|
91
|
-
async function readBundledAgentPluginDigests(workspaceRoot) {
|
|
92
|
-
let raw;
|
|
93
|
-
try {
|
|
94
|
-
raw = await readFile(path.join(workspaceRoot, BUNDLED_DIGESTS_FILENAME), "utf8");
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
return EMPTY_LEDGER;
|
|
98
|
-
}
|
|
99
|
-
let parsed;
|
|
100
|
-
try {
|
|
101
|
-
parsed = JSON.parse(raw);
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return EMPTY_LEDGER;
|
|
105
|
-
}
|
|
106
|
-
return normalizeBundledDigests(parsed);
|
|
71
|
+
const SHA256_DIGEST_PATTERN = /^[a-f0-9]{64}$/;
|
|
72
|
+
const SAFE_PLUGIN_ID_PATTERN = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/;
|
|
73
|
+
const EMPTY_LEDGER = new Map();
|
|
74
|
+
/**
|
|
75
|
+
* Reads one workspace's bundled-digest ledger.
|
|
76
|
+
*
|
|
77
|
+
* @param workspaceRoot - `AgentPluginWorkspaceLayout.root`, never an instance-level path.
|
|
78
|
+
* @returns The recorded plugin-id -> digest map, or an EMPTY map for a missing, unreadable,
|
|
79
|
+
* malformed, or wrong-version file. Malformed INDIVIDUAL entries are skipped rather than discarding
|
|
80
|
+
* the whole ledger, matching `activation.ts`'s own per-entry discipline.
|
|
81
|
+
* @throws Nothing. An empty answer is always safe: it names no winner, so every ambiguity this
|
|
82
|
+
* module could have resolved simply stays the explicit error it already was.
|
|
83
|
+
* @complexity One file read plus O(p) in the recorded plugin count.
|
|
84
|
+
*/
|
|
85
|
+
async function readBundledAgentPluginDigests({ ports, workspaceRoot }) {
|
|
86
|
+
let raw;
|
|
87
|
+
try {
|
|
88
|
+
raw = await ports.filesystem.readFile(path.join(workspaceRoot, BUNDLED_DIGESTS_FILENAME), "utf8");
|
|
107
89
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* Pure, so the parsing rules are assertable without touching a filesystem.
|
|
111
|
-
*
|
|
112
|
-
* @complexity O(p) in the entry count.
|
|
113
|
-
*/
|
|
114
|
-
function normalizeBundledDigests(value) {
|
|
115
|
-
if (!isPlainObject(value) || value.schemaVersion !== 1 || !isPlainObject(value.plugins))
|
|
116
|
-
return EMPTY_LEDGER;
|
|
117
|
-
const digests = new Map();
|
|
118
|
-
for (const [pluginId, entry] of Object.entries(value.plugins)) {
|
|
119
|
-
const archiveDigest = SAFE_PLUGIN_ID_PATTERN.test(pluginId) && isPlainObject(entry) ? entry.archiveDigest : undefined;
|
|
120
|
-
if (typeof archiveDigest === "string" && SHA256_DIGEST_PATTERN.test(archiveDigest))
|
|
121
|
-
digests.set(pluginId, archiveDigest);
|
|
122
|
-
}
|
|
123
|
-
return digests;
|
|
90
|
+
catch {
|
|
91
|
+
return EMPTY_LEDGER;
|
|
124
92
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
* MERGED, not replaced, for failure isolation (the property `seed-bundled.ts`'s header names): a
|
|
130
|
-
* plugin that failed to seed this boot — an unreadable source directory, a transient I/O fault —
|
|
131
|
-
* must not lose the perfectly good entry an earlier boot wrote for it, which is what a wholesale
|
|
132
|
-
* rewrite of only this boot's successes would do.
|
|
133
|
-
*
|
|
134
|
-
* A plugin id seeded TWICE in one run under two different digests (two bundled source directories
|
|
135
|
-
* declaring the same manifest `name`) is dropped from the ledger entirely, prior entry included:
|
|
136
|
-
* the build itself is ambiguous about what it ships, so there is nothing authoritative to record and
|
|
137
|
-
* the explicit ambiguity refusal downstream is the correct outcome.
|
|
138
|
-
*
|
|
139
|
-
* @param seeded - One entry per successfully seeded plugin. An empty list writes nothing at all —
|
|
140
|
-
* not even an empty file — so a boot that seeded nothing cannot create a workspace directory or
|
|
141
|
-
* truncate an existing ledger.
|
|
142
|
-
* @throws {Error} Any filesystem fault from the write. The caller (`seed-bundled.ts`) captures it
|
|
143
|
-
* into its report rather than failing the boot.
|
|
144
|
-
* @complexity One file read and one atomic write, O(p) in the recorded plugin count.
|
|
145
|
-
*/
|
|
146
|
-
async function recordBundledAgentPluginDigests(required) {
|
|
147
|
-
if (required.seeded.length === 0)
|
|
148
|
-
return;
|
|
149
|
-
const existing = await readBundledAgentPluginDigests(required.workspaceRoot);
|
|
150
|
-
const merged = new Map(existing);
|
|
151
|
-
const seededAt = (required.now?.({}) ?? new Date(ports.clock.nowMs())).toISOString();
|
|
152
|
-
for (const [pluginId, archiveDigest] of resolveThisBootsDigests(required.seeded)) {
|
|
153
|
-
if (archiveDigest === undefined)
|
|
154
|
-
merged.delete(pluginId);
|
|
155
|
-
else
|
|
156
|
-
merged.set(pluginId, archiveDigest);
|
|
157
|
-
}
|
|
158
|
-
const plugins = Object.fromEntries([...merged].map(([pluginId, archiveDigest]) => [pluginId, { archiveDigest, seededAt }]));
|
|
159
|
-
await writeLedgerAtomically(required.workspaceRoot, plugins);
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = JSON.parse(raw);
|
|
160
96
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* same id under two different digests and therefore has no authoritative answer for it.
|
|
164
|
-
*
|
|
165
|
-
* Split out as a pure step so the "a self-contradictory build records NOTHING" rule is assertable
|
|
166
|
-
* without a filesystem, and so {@link recordBundledAgentPluginDigests} reads as merge-then-write.
|
|
167
|
-
*
|
|
168
|
-
* @complexity O(n) in the seeded-entry count.
|
|
169
|
-
*/
|
|
170
|
-
function resolveThisBootsDigests(seeded) {
|
|
171
|
-
const thisBoot = new Map();
|
|
172
|
-
for (const { pluginId, archiveDigest } of seeded) {
|
|
173
|
-
if (!SAFE_PLUGIN_ID_PATTERN.test(pluginId) || !SHA256_DIGEST_PATTERN.test(archiveDigest))
|
|
174
|
-
continue;
|
|
175
|
-
if (thisBoot.has(pluginId) && thisBoot.get(pluginId) !== archiveDigest)
|
|
176
|
-
thisBoot.set(pluginId, undefined);
|
|
177
|
-
else
|
|
178
|
-
thisBoot.set(pluginId, archiveDigest);
|
|
179
|
-
}
|
|
180
|
-
return thisBoot;
|
|
97
|
+
catch {
|
|
98
|
+
return EMPTY_LEDGER;
|
|
181
99
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
100
|
+
return normalizeBundledDigests(parsed);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validates an already-`JSON.parse`d ledger value, dropping anything that does not match the shape.
|
|
104
|
+
* Pure, so the parsing rules are assertable without touching a filesystem.
|
|
105
|
+
*
|
|
106
|
+
* @complexity O(p) in the entry count.
|
|
107
|
+
*/
|
|
108
|
+
function normalizeBundledDigests(value) {
|
|
109
|
+
if (!isPlainObject(value) || value.schemaVersion !== 1 || !isPlainObject(value.plugins))
|
|
110
|
+
return EMPTY_LEDGER;
|
|
111
|
+
const digests = new Map();
|
|
112
|
+
for (const [pluginId, entry] of Object.entries(value.plugins)) {
|
|
113
|
+
const archiveDigest = SAFE_PLUGIN_ID_PATTERN.test(pluginId) && isPlainObject(entry) ? entry.archiveDigest : undefined;
|
|
114
|
+
if (typeof archiveDigest === "string" && SHA256_DIGEST_PATTERN.test(archiveDigest))
|
|
115
|
+
digests.set(pluginId, archiveDigest);
|
|
116
|
+
}
|
|
117
|
+
return digests;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Records the digest this boot seeded for each bundled plugin, merged over whatever was already
|
|
121
|
+
* recorded.
|
|
122
|
+
*
|
|
123
|
+
* MERGED, not replaced, for failure isolation (the property `seed-bundled.ts`'s header names): a
|
|
124
|
+
* plugin that failed to seed this boot — an unreadable source directory, a transient I/O fault —
|
|
125
|
+
* must not lose the perfectly good entry an earlier boot wrote for it, which is what a wholesale
|
|
126
|
+
* rewrite of only this boot's successes would do.
|
|
127
|
+
*
|
|
128
|
+
* A plugin id seeded TWICE in one run under two different digests (two bundled source directories
|
|
129
|
+
* declaring the same manifest `name`) is dropped from the ledger entirely, prior entry included:
|
|
130
|
+
* the build itself is ambiguous about what it ships, so there is nothing authoritative to record and
|
|
131
|
+
* the explicit ambiguity refusal downstream is the correct outcome.
|
|
132
|
+
*
|
|
133
|
+
* @param seeded - One entry per successfully seeded plugin. An empty list writes nothing at all —
|
|
134
|
+
* not even an empty file — so a boot that seeded nothing cannot create a workspace directory or
|
|
135
|
+
* truncate an existing ledger.
|
|
136
|
+
* @throws {Error} Any filesystem fault from the write. The caller (`seed-bundled.ts`) captures it
|
|
137
|
+
* into its report rather than failing the boot.
|
|
138
|
+
* @complexity One file read and one atomic write, O(p) in the recorded plugin count.
|
|
139
|
+
*/
|
|
140
|
+
async function recordBundledAgentPluginDigests(ports, required) {
|
|
141
|
+
if (required.seeded.length === 0)
|
|
142
|
+
return;
|
|
143
|
+
const existing = await readBundledAgentPluginDigests({ ports, workspaceRoot: required.workspaceRoot });
|
|
144
|
+
const merged = new Map(existing);
|
|
145
|
+
const seededAt = (required.now?.({}) ?? new Date(ports.clock.nowMs())).toISOString();
|
|
146
|
+
for (const [pluginId, archiveDigest] of resolveThisBootsDigests(required.seeded)) {
|
|
147
|
+
if (archiveDigest === undefined)
|
|
148
|
+
merged.delete(pluginId);
|
|
149
|
+
else
|
|
150
|
+
merged.set(pluginId, archiveDigest);
|
|
151
|
+
}
|
|
152
|
+
const plugins = Object.fromEntries([...merged].map(([pluginId, archiveDigest]) => [pluginId, { archiveDigest, seededAt }]));
|
|
153
|
+
await writeLedgerAtomically({ ports, workspaceRoot: required.workspaceRoot, plugins });
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* This boot's verdict per plugin id: the digest it seeded, or `undefined` when the run seeded the
|
|
157
|
+
* same id under two different digests and therefore has no authoritative answer for it.
|
|
158
|
+
*
|
|
159
|
+
* Split out as a pure step so the "a self-contradictory build records NOTHING" rule is assertable
|
|
160
|
+
* without a filesystem, and so {@link recordBundledAgentPluginDigests} reads as merge-then-write.
|
|
161
|
+
*
|
|
162
|
+
* @complexity O(n) in the seeded-entry count.
|
|
163
|
+
*/
|
|
164
|
+
function resolveThisBootsDigests(seeded) {
|
|
165
|
+
const thisBoot = new Map();
|
|
166
|
+
for (const { pluginId, archiveDigest } of seeded) {
|
|
167
|
+
if (!SAFE_PLUGIN_ID_PATTERN.test(pluginId) || !SHA256_DIGEST_PATTERN.test(archiveDigest))
|
|
168
|
+
continue;
|
|
169
|
+
if (thisBoot.has(pluginId) && thisBoot.get(pluginId) !== archiveDigest)
|
|
170
|
+
thisBoot.set(pluginId, undefined);
|
|
171
|
+
else
|
|
172
|
+
thisBoot.set(pluginId, archiveDigest);
|
|
173
|
+
}
|
|
174
|
+
return thisBoot;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Drops one plugin id from the ledger — for `retire-bundled.ts`, once a retired bundled plugin's
|
|
178
|
+
* packages are gone and no build will ever seed it again.
|
|
179
|
+
*
|
|
180
|
+
* Every other entry is kept byte-for-byte, `seededAt` included: this rewrites the raw `plugins` bag
|
|
181
|
+
* rather than the normalized map, so it cannot lose a field a later schema adds. A missing,
|
|
182
|
+
* unreadable, malformed, or wrong-version ledger, or one with no entry for `pluginId`, writes
|
|
183
|
+
* nothing — there is nothing to drop, and a fail-closed reader already treats such a file as empty.
|
|
184
|
+
*
|
|
185
|
+
* @returns Whether an entry was removed.
|
|
186
|
+
* @throws {Error} Any filesystem fault from the write. `retire-bundled.ts` captures it into its report.
|
|
187
|
+
* @complexity One file read and at most one atomic write, O(p) in the recorded plugin count.
|
|
188
|
+
*/
|
|
189
|
+
async function removeBundledAgentPluginDigest(ports, required) {
|
|
190
|
+
let parsed;
|
|
191
|
+
try {
|
|
192
|
+
parsed = JSON.parse(await ports.filesystem.readFile(path.join(required.workspaceRoot, BUNDLED_DIGESTS_FILENAME), "utf8"));
|
|
211
193
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
194
|
+
catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (!isPlainObject(parsed) || parsed.schemaVersion !== 1 || !isPlainObject(parsed.plugins))
|
|
198
|
+
return false;
|
|
199
|
+
if (!Object.hasOwn(parsed.plugins, required.pluginId))
|
|
200
|
+
return false;
|
|
201
|
+
const remaining = { ...parsed.plugins };
|
|
202
|
+
delete remaining[required.pluginId];
|
|
203
|
+
await writeLedgerAtomically({ ports, workspaceRoot: required.workspaceRoot, plugins: remaining });
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
/** Temp-file-then-`rename`, so a reader never observes a half-written ledger and a crash mid-write
|
|
207
|
+
* leaves the previous one intact — the same durability shape `activation.ts`'s
|
|
208
|
+
* `writeActivationsAtomically` uses, minus its cross-process lock: this file has exactly one writer
|
|
209
|
+
* (the boot seeder, retirement included), and two concurrent boots of the SAME build write byte-identical content.
|
|
210
|
+
* @complexity One write and one rename. */
|
|
211
|
+
async function writeLedgerAtomically({ ports, workspaceRoot, plugins }) {
|
|
212
|
+
const finalPath = path.join(workspaceRoot, BUNDLED_DIGESTS_FILENAME);
|
|
213
|
+
const tempPath = `${finalPath}.tmp-${ports.process.pid}-${ports.ids.newId()}`;
|
|
214
|
+
try {
|
|
215
|
+
const handle = await ports.filesystem.open(tempPath, "wx", 0o600);
|
|
220
216
|
try {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
await handle.writeFile(`${JSON.stringify({ schemaVersion: 1, plugins }, null, 2)}\n`, "utf8");
|
|
224
|
-
await handle.sync();
|
|
225
|
-
}
|
|
226
|
-
finally {
|
|
227
|
-
await handle.close();
|
|
228
|
-
}
|
|
229
|
-
await rename(tempPath, finalPath);
|
|
217
|
+
await handle.writeFile(`${JSON.stringify({ schemaVersion: 1, plugins }, null, 2)}\n`, "utf8");
|
|
218
|
+
await handle.sync();
|
|
230
219
|
}
|
|
231
|
-
|
|
232
|
-
await
|
|
233
|
-
throw error;
|
|
220
|
+
finally {
|
|
221
|
+
await handle.close();
|
|
234
222
|
}
|
|
223
|
+
await ports.filesystem.rename(tempPath, finalPath);
|
|
235
224
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*
|
|
240
|
-
* An id is narrowed only when all three hold: it has more than one installed digest, the ledger
|
|
241
|
-
* records a digest for it, and exactly one of its installed digests is that recorded one. Anything
|
|
242
|
-
* else passes through untouched, so the caller's own ambiguity refusal still fires for every case
|
|
243
|
-
* this module has no authority over (this file's header, consequences 1 and 2).
|
|
244
|
-
*
|
|
245
|
-
* Applied at READ time by the surfaces that must pick one package per plugin id. Deliberately NOT
|
|
246
|
-
* folded into `listInstalledPlugins` itself: `uninstall.ts` needs to see EVERY digest of a plugin to
|
|
247
|
-
* remove them, and a filter hidden inside the shared walk would make superseded bytes unremovable.
|
|
248
|
-
*
|
|
249
|
-
* @returns A list in the input's own order, with superseded entries removed. The input is never
|
|
250
|
-
* mutated.
|
|
251
|
-
* @complexity O(n) in the installed-package count, over one O(n) pre-pass that counts digests per
|
|
252
|
-
* plugin id.
|
|
253
|
-
*/
|
|
254
|
-
function preferBundledAgentPluginDigests(installed, bundled) {
|
|
255
|
-
if (bundled.size === 0)
|
|
256
|
-
return installed;
|
|
257
|
-
const supersededIds = idsNarrowableToTheirBundledDigest(installed, bundled);
|
|
258
|
-
if (supersededIds.size === 0)
|
|
259
|
-
return installed;
|
|
260
|
-
return installed.filter((plugin) => !supersededIds.has(plugin.pluginId) || plugin.archiveDigest === bundled.get(plugin.pluginId));
|
|
225
|
+
catch (error) {
|
|
226
|
+
await ports.filesystem.rm(tempPath, { force: true });
|
|
227
|
+
throw error;
|
|
261
228
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Drops the SUPERSEDED installs of any bundled plugin id from a list of installed packages, leaving
|
|
232
|
+
* every other entry — and every other plugin id — exactly as it was.
|
|
233
|
+
*
|
|
234
|
+
* An id is narrowed only when all three hold: it has more than one installed digest, the ledger
|
|
235
|
+
* records a digest for it, and exactly one of its installed digests is that recorded one. Anything
|
|
236
|
+
* else passes through untouched, so the caller's own ambiguity refusal still fires for every case
|
|
237
|
+
* this module has no authority over (this file's header, consequences 1 and 2).
|
|
238
|
+
*
|
|
239
|
+
* Applied at READ time by the surfaces that must pick one package per plugin id. Deliberately NOT
|
|
240
|
+
* folded into `listInstalledPlugins` itself: `uninstall.ts` needs to see EVERY digest of a plugin to
|
|
241
|
+
* remove them, and a filter hidden inside the shared walk would make superseded bytes unremovable.
|
|
242
|
+
*
|
|
243
|
+
* @returns A list in the input's own order, with superseded entries removed. The input is never
|
|
244
|
+
* mutated.
|
|
245
|
+
* @complexity O(n) in the installed-package count, over one O(n) pre-pass that counts digests per
|
|
246
|
+
* plugin id.
|
|
247
|
+
*/
|
|
248
|
+
function preferBundledAgentPluginDigests(installed, bundled) {
|
|
249
|
+
if (bundled.size === 0)
|
|
250
|
+
return installed;
|
|
251
|
+
const supersededIds = idsNarrowableToTheirBundledDigest(installed, bundled);
|
|
252
|
+
if (supersededIds.size === 0)
|
|
253
|
+
return installed;
|
|
254
|
+
return installed.filter((plugin) => !supersededIds.has(plugin.pluginId) || plugin.archiveDigest === bundled.get(plugin.pluginId));
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The plugin ids whose installed digests the ledger can authoritatively narrow to one — every id
|
|
258
|
+
* that is installed under several digests, exactly one of which is the digest this build seeded.
|
|
259
|
+
*
|
|
260
|
+
* @complexity O(n) in the installed-package count.
|
|
261
|
+
*/
|
|
262
|
+
function idsNarrowableToTheirBundledDigest(installed, bundled) {
|
|
263
|
+
const digestsByPluginId = new Map();
|
|
264
|
+
for (const plugin of installed) {
|
|
265
|
+
const digests = digestsByPluginId.get(plugin.pluginId) ?? new Set();
|
|
266
|
+
digests.add(plugin.archiveDigest);
|
|
267
|
+
digestsByPluginId.set(plugin.pluginId, digests);
|
|
284
268
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
269
|
+
const narrowable = new Set();
|
|
270
|
+
for (const [pluginId, digests] of digestsByPluginId) {
|
|
271
|
+
if (digests.size < 2)
|
|
272
|
+
continue;
|
|
273
|
+
const bundledDigest = bundled.get(pluginId);
|
|
274
|
+
if (bundledDigest !== undefined && digests.has(bundledDigest))
|
|
275
|
+
narrowable.add(pluginId);
|
|
292
276
|
}
|
|
293
|
-
return
|
|
277
|
+
return narrowable;
|
|
278
|
+
}
|
|
279
|
+
/** Whether `value` is a plain (non-null, non-array) object — the shape both this file's JSON-adjacent
|
|
280
|
+
* values must have before their own fields are worth looking at. Duplicated from `activation.ts`'s
|
|
281
|
+
* private helper of the same name rather than widening that module's public surface, matching this
|
|
282
|
+
* codebase's own precedent for small private formatting/shape helpers (see `resolve-agent-plugin-
|
|
283
|
+
* refs.ts`'s note on `humanize()`). */
|
|
284
|
+
function isPlainObject(value) {
|
|
285
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
286
|
+
}
|
|
287
|
+
function buildModule(ports) {
|
|
288
|
+
return {
|
|
289
|
+
readBundledAgentPluginDigests: (workspaceRoot) => readBundledAgentPluginDigests({ ports, workspaceRoot }),
|
|
290
|
+
normalizeBundledDigests,
|
|
291
|
+
recordBundledAgentPluginDigests: (required) => recordBundledAgentPluginDigests(ports, required),
|
|
292
|
+
removeBundledAgentPluginDigest: (required) => removeBundledAgentPluginDigest(ports, required),
|
|
293
|
+
preferBundledAgentPluginDigests,
|
|
294
|
+
};
|
|
294
295
|
}
|
|
295
296
|
const instances = new WeakMap();
|
|
296
297
|
/** Internal composition; one state/queue instance per injected host context. */
|
|
297
|
-
export function createBundledDigestsModule(ports) {
|
|
298
|
+
export function createBundledDigestsModule(ports, _optional = {}) {
|
|
298
299
|
let instance = instances.get(ports);
|
|
299
300
|
if (!instance) {
|
|
300
301
|
instance = buildModule(ports);
|
|
@@ -38,7 +38,7 @@ export interface PackAgentPluginDirectoryOptional {
|
|
|
38
38
|
readonly digestEncoding?: 'bundled-v1' | 'canonical-files-v1';
|
|
39
39
|
}
|
|
40
40
|
/** Internal composition; one state/queue instance per injected host context. */
|
|
41
|
-
export declare function createBundledSourceArchiveModule(ports: AgentPluginLifecyclePorts): {
|
|
41
|
+
export declare function createBundledSourceArchiveModule(ports: AgentPluginLifecyclePorts, _optional?: Record<string, never>): {
|
|
42
42
|
packAgentPluginDirectory: (sourceDir: string, options?: PackAgentPluginDirectoryOptional) => Promise<PackedAgentPluginArchive>;
|
|
43
43
|
createBundledSourceArchiveReader: () => AgentPluginArchiveReaderPort;
|
|
44
44
|
};
|