@jini-ai/agent-plugins 0.7.3-next.2 → 0.7.3-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/calendly/README.md +29 -0
- package/calendly/mcp.json +1 -1
- package/cloudflare/lib/assets.mjs +1 -1
- package/cloudflare/lib/cms-forms.mjs +1 -1
- package/core/persistent-state.d.ts +4 -1
- package/core/persistent-state.js +55 -21
- package/dist/admin-surfaces/callback-field-inbox.d.ts +1 -6
- package/dist/admin-surfaces/connections/connections.d.ts +2 -6
- package/dist/admin-surfaces/connections/index.d.ts +3 -2
- package/dist/admin-surfaces/index.d.ts +3 -1
- package/dist/connect/access-token-tool.d.ts +1 -1
- package/dist/connect/access-token-tool.js +1 -1
- package/dist/connect/catalog.d.ts +26 -0
- package/dist/connect/catalog.js +42 -0
- package/dist/connect/connect-tool.d.ts +2 -294
- package/dist/connect/connect-tool.js +2 -53
- package/dist/connect/contracts.d.ts +257 -0
- package/dist/connect/contracts.js +2 -0
- package/dist/connect/credential-cards.d.ts +2 -0
- package/dist/connect/credential-cards.js +7 -4
- package/dist/connect/grant-signed-in-defaults.js +1 -1
- package/dist/connect/host-deps.d.ts +32 -0
- package/dist/connect/host-deps.js +35 -0
- package/dist/connect/import-access-token.js +1 -1
- package/dist/connect/index.d.ts +7 -2
- package/dist/connect/index.js +5 -2
- package/dist/connect/installed-plugin.d.ts +28 -0
- package/dist/connect/installed-plugin.js +19 -0
- package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
- package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
- package/dist/connect/plugin-host/index.d.ts +1 -2
- package/dist/connect/plugin-host/index.js +18 -9
- package/dist/connect/token-sign-in.d.ts +1 -14
- package/dist/connect/token-sign-in.js +4 -23
- package/dist/core/export-props.d.ts +10 -0
- package/dist/core/export-props.js +31 -0
- package/dist/core/folder-zip-error.d.ts +5 -0
- package/dist/core/folder-zip-error.js +8 -0
- package/dist/core/host-incompatible-error.d.ts +8 -0
- package/dist/core/host-incompatible-error.js +9 -0
- package/dist/core/identity-namespace.d.ts +27 -16
- package/dist/core/identity-namespace.js +25 -22
- package/dist/core/plugin-display-name.d.ts +7 -0
- package/dist/core/plugin-display-name.js +11 -0
- package/dist/core/provider-plugin-link.d.ts +7 -0
- package/dist/core/provider-plugin-link.js +5 -0
- package/dist/{connect → core}/token-map.d.ts +11 -1
- package/dist/{connect → core}/token-map.js +15 -0
- package/dist/core/token-sign-in-list.d.ts +18 -0
- package/dist/core/token-sign-in-list.js +23 -0
- package/dist/core/update-error.d.ts +8 -0
- package/dist/core/update-error.js +9 -0
- package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
- package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
- package/dist/ffmpeg-transcode/adapter.js +155 -0
- package/dist/folder-zip-node.d.ts +2 -1
- package/dist/folder-zip-node.js +6 -5
- package/dist/folder-zip.d.ts +0 -4
- package/dist/folder-zip.js +1 -7
- package/dist/index.d.ts +3 -1
- package/dist/lifecycle/activation.d.ts +39 -3
- package/dist/lifecycle/activation.js +467 -418
- package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
- package/dist/lifecycle/automatic-use-offer.js +52 -0
- package/dist/lifecycle/automatic-use.d.ts +33 -1
- package/dist/lifecycle/automatic-use.js +157 -38
- package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
- package/dist/lifecycle/capability-projection.d.ts +0 -1
- package/dist/lifecycle/capability-projection.js +92 -23
- package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
- package/dist/lifecycle/compatibility-metadata.js +6 -1
- package/dist/lifecycle/compatibility.d.ts +1 -8
- package/dist/lifecycle/compatibility.js +1 -8
- package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
- package/dist/lifecycle/exports.d.ts +2 -45
- package/dist/lifecycle/exports.js +1 -30
- package/dist/lifecycle/host-tools/identity.d.ts +5 -4
- package/dist/lifecycle/host-tools/identity.js +5 -5
- package/dist/lifecycle/host-tools/ports.d.ts +10 -1
- package/dist/lifecycle/host-tools/search-tool.js +18 -8
- package/dist/lifecycle/host-tools/skill-tool.js +1 -1
- package/dist/lifecycle/index.d.ts +20 -17
- package/dist/lifecycle/index.js +5 -4
- package/dist/lifecycle/install-from-url.d.ts +1 -2
- package/dist/lifecycle/install.d.ts +4 -34
- package/dist/lifecycle/install.js +3 -3
- package/dist/lifecycle/installed-package-index.d.ts +1 -1
- package/dist/lifecycle/installed-package-index.js +4 -4
- package/dist/lifecycle/layout.d.ts +21 -25
- package/dist/lifecycle/layout.js +79 -0
- package/dist/lifecycle/manifest.d.ts +10 -7
- package/dist/lifecycle/manifest.js +20 -15
- package/dist/lifecycle/mcp-provisioning.d.ts +1 -1
- package/dist/lifecycle/metadata.d.ts +6 -3
- package/dist/lifecycle/metadata.js +2 -1
- package/dist/lifecycle/package-paths.js +59 -56
- package/dist/lifecycle/persistent-state.d.ts +10 -1
- package/dist/lifecycle/persistent-state.js +4 -2
- package/dist/lifecycle/ports.d.ts +18 -6
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -14
- package/dist/lifecycle/retire-bundled.d.ts +1 -1
- package/dist/lifecycle/search-projection.d.ts +3 -1
- package/dist/lifecycle/search-projection.js +7 -3
- package/dist/lifecycle/search.d.ts +1 -0
- package/dist/lifecycle/seed-bundled.d.ts +86 -1
- package/dist/lifecycle/seed-bundled.js +48 -84
- package/dist/lifecycle/set-enabled.d.ts +1 -13
- package/dist/lifecycle/set-enabled.js +11 -7
- package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
- package/dist/lifecycle/trusted-plugin-files.js +33 -30
- package/dist/lifecycle/types.d.ts +13 -34
- package/dist/lifecycle/uninstall.d.ts +1 -33
- package/dist/lifecycle/update-store.d.ts +0 -7
- package/dist/lifecycle/update-store.js +1 -8
- package/dist/lifecycle/update.d.ts +1 -1
- package/dist/lifecycle/update.js +60 -10
- package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
- package/dist/lifecycle/yauzl-archive-reader.js +11 -6
- package/dist/manifest.d.ts +4 -8
- package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
- package/dist/react/AgentPluginDetailsModal.js +29 -0
- package/dist/react/agent-plugin-install-port.d.ts +24 -0
- package/dist/react/agent-plugin-install-port.js +15 -0
- package/dist/react/installed-skills-composer-source.d.ts +60 -0
- package/dist/react/installed-skills-composer-source.js +111 -0
- package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
- package/dist/react/use-agent-plugins.hooks.js +128 -0
- package/dist/site/activation-effects.d.ts +17 -0
- package/dist/site/activation-effects.js +31 -0
- package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
- package/dist/site/admin-surfaces/capabilities.js +30 -0
- package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
- package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
- package/dist/site/admin-surfaces/forms.d.ts +28 -0
- package/dist/site/admin-surfaces/forms.js +29 -0
- package/dist/site/admin-surfaces/handlers.d.ts +61 -0
- package/dist/site/admin-surfaces/handlers.js +35 -0
- package/dist/site/admin-surfaces/public-config.d.ts +12 -0
- package/dist/site/admin-surfaces/public-config.js +28 -0
- package/dist/site/analytics-provider-registry.d.ts +87 -0
- package/dist/site/analytics-provider-registry.js +87 -0
- package/dist/site/archive-reader-abi.d.ts +35 -0
- package/dist/site/archive-reader-abi.js +25 -0
- package/dist/site/auth-schemes.d.ts +110 -0
- package/dist/site/auth-schemes.js +119 -0
- package/dist/site/automatic-agent-plugins.d.ts +200 -0
- package/dist/site/automatic-agent-plugins.js +277 -0
- package/dist/site/bundled-contribution-sources.d.ts +24 -0
- package/dist/site/bundled-contribution-sources.js +17 -0
- package/dist/site/bundled-id-upgrade.d.ts +115 -0
- package/dist/site/bundled-id-upgrade.js +169 -0
- package/dist/site/customize-tool.d.ts +39 -0
- package/dist/site/customize-tool.js +31 -0
- package/dist/site/deploy-split-activation.d.ts +28 -0
- package/dist/site/deploy-split-activation.js +21 -0
- package/dist/site/exports/diagnostics.d.ts +37 -0
- package/dist/site/exports/diagnostics.js +55 -0
- package/dist/site/exports/runtime.d.ts +54 -0
- package/dist/site/exports/runtime.js +196 -0
- package/dist/site/exports/source.d.ts +42 -0
- package/dist/site/exports/source.js +58 -0
- package/dist/site/host-plugin-guidance.d.ts +137 -0
- package/dist/site/host-plugin-guidance.js +223 -0
- package/dist/site/host-signals.d.ts +78 -0
- package/dist/site/host-signals.js +83 -0
- package/dist/site/install-tool.d.ts +69 -0
- package/dist/site/install-tool.js +192 -0
- package/dist/site/install-upload.d.ts +175 -0
- package/dist/site/install-upload.js +324 -0
- package/dist/site/memory-i18n.d.ts +5 -0
- package/dist/site/memory-i18n.js +176 -0
- package/dist/site/memory.d.ts +80 -0
- package/dist/site/memory.js +83 -0
- package/dist/site/plugin-memory.d.ts +80 -0
- package/dist/site/plugin-memory.js +86 -0
- package/dist/site/provider-plugin-link.d.ts +112 -0
- package/dist/site/provider-plugin-link.js +100 -0
- package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
- package/dist/site/retired-plugin-tool-aliases.js +41 -0
- package/dist/site/service-ports.d.ts +108 -0
- package/dist/site/service-ports.js +2 -0
- package/dist/site/set-enabled.d.ts +80 -0
- package/dist/site/set-enabled.js +42 -0
- package/dist/site/soon-lock.d.ts +83 -0
- package/dist/site/soon-lock.js +78 -0
- package/dist/site/supersession.d.ts +61 -0
- package/dist/site/supersession.js +122 -0
- package/dist/site/uninstall-tool.d.ts +136 -0
- package/dist/site/uninstall-tool.js +203 -0
- package/dist/site/update-effects.d.ts +47 -0
- package/dist/site/update-effects.js +49 -0
- package/ffmpeg-transcode/plugin.json +16 -0
- package/github/source-control/backup-push.mjs +66 -46
- package/github/source-control/commit-site.mjs +112 -65
- package/github/source-control/write-files.mjs +86 -53
- package/github-pages/targets/github-pages.mjs +294 -233
- package/google-workspace/form-destinations/mapping.mjs +15 -7
- package/google-workspace/form-destinations/sheets.mjs +4 -2
- package/google-workspace/plugin.json +1 -0
- package/kuinetic/CHANGELOG.md +4 -0
- package/kuinetic/plugin.json +4 -1
- package/kuinetic/skills/kuinetic/SKILL.md +1 -2
- package/package.json +295 -18
- package/persistent-state.d.ts +4 -1
- package/resend/adapters/resend.mjs +5 -2
- package/resend/plugin.json +1 -1
- package/s3-compatible/jini-deploy-targets.json +1 -1
- package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
- package/s3-compatible/targets/s3-compatible.mjs +3 -3
- package/site-import/plugin.json +3 -3
- package/site-import/skills/site-import/SKILL.md +62 -54
- package/site-import/skills/site-import/references/content-mapping.md +26 -20
- package/slide-design/plugin.json +1 -1
- package/slide-design/skills/slide-design/SKILL.md +8 -2
- package/ui-ux-design/CHANGELOG.md +6 -0
- package/ui-ux-design/plugin.json +1 -1
- package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
- package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
- package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
- package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
- package/vercel/NOTES.md +2 -1
- package/vercel/object-stores/vercel-blob.mjs +3 -4
- package/vercel/targets/vercel.mjs +425 -351
- package/core/commerce-server.d.ts +0 -2
- package/core/commerce-server.mjs +0 -2
- package/dist/admin-surfaces/connections/ports.d.ts +0 -110
- package/dist/admin-surfaces/connections/ports.js +0 -2
- /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
- /package/dist/{lifecycle → core}/install-errors.js +0 -0
- /package/dist/{lifecycle → core}/update-plan.js +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { adaptLegacyAuthorize } from "@jini-ai/core";
|
|
2
|
+
import { requireToolPermission } from "@jini-ai/core";
|
|
3
|
+
import { ToolInputError } from "@jini-ai/core";
|
|
4
|
+
import { AgentPluginActivationsBusyError, AgentPluginActivationsUnreadableError } from "../lifecycle/index.js";
|
|
5
|
+
import { AgentPluginUpdateError } from "../core/update-error.js";
|
|
6
|
+
import { FileLockTimeoutError } from "@jini-ai/core/contracts/runtime";
|
|
7
|
+
import { AgentPluginChangedSincePreviewError, AgentPluginNotFoundError, AgentPluginNotUninstallableError, } from "../lifecycle/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Re-classifies `uninstallAgentPlugin`'s own domain errors into `ToolInputError` on their way to the
|
|
10
|
+
* model, and passes every other rejection through untouched.
|
|
11
|
+
*
|
|
12
|
+
* Same reasoning as `features/post/tool-registrations.ts`'s `toModelFacingUpdateError`: an unknown
|
|
13
|
+
* `pluginId` and a bundled-plugin refusal are both exactly "the CALLER's input was the problem, and a
|
|
14
|
+
* different input (a real installed id; a different tool call to disable instead) resolves it" — the
|
|
15
|
+
* honest classification, not a trick to defeat `@jini-ai/daemon`'s redaction. Neither message carries
|
|
16
|
+
* anything beyond the plugin id the caller already sent and, for the bundled case, the name of the
|
|
17
|
+
* tool to call instead — nothing internal leaks.
|
|
18
|
+
*/
|
|
19
|
+
function toModelFacingUninstallError({ error }, _optional = {}) {
|
|
20
|
+
if (error instanceof AgentPluginNotFoundError || error instanceof AgentPluginNotUninstallableError) {
|
|
21
|
+
return new ToolInputError({ message: error.message });
|
|
22
|
+
}
|
|
23
|
+
return error;
|
|
24
|
+
}
|
|
25
|
+
/** An interrupted update of this plugin is still waiting for boot recovery (`PLUGIN_UPDATE_PENDING`),
|
|
26
|
+
* or its recovery record is unreadable: removing it now would let recovery resurrect the old revision.
|
|
27
|
+
* Nothing was removed, so this is the same ADR-055 Decision 6 result as the refusals below.
|
|
28
|
+
* @complexity O(1). */
|
|
29
|
+
function updateJournalRefusedResult(required, _optional = {}) {
|
|
30
|
+
const { pluginId, error, copy } = required;
|
|
31
|
+
return {
|
|
32
|
+
uninstalled: false,
|
|
33
|
+
cancelled: false,
|
|
34
|
+
pluginId,
|
|
35
|
+
restartRequired: false,
|
|
36
|
+
reason: "update-pending",
|
|
37
|
+
code: error.code,
|
|
38
|
+
note: `Nothing was removed: an interrupted update of '${pluginId}' is still waiting to be recovered, so it was NOT ` +
|
|
39
|
+
`uninstalled. ${updateJournalNextStep({ error, copy })}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Only a pending update recovers at start. Any other journal refusal (an unreadable record, an
|
|
43
|
+
* unsafe recorded path) survives a restart, so telling the user to restart would loop them.
|
|
44
|
+
* @complexity O(1). */
|
|
45
|
+
function updateJournalNextStep({ error, copy }, _optional = {}) {
|
|
46
|
+
return error.code === "PLUGIN_UPDATE_PENDING"
|
|
47
|
+
? `Tell the user to restart ${copy.productName} (recovery runs at start) and then try again.`
|
|
48
|
+
: `Its update recovery record needs manual repair (${error.code}); restarting ${copy.productName} will not fix it. Tell the user an operator has to repair it first.`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The model-facing outcome of an `uninstall.ts` rejection: a RESULT when this workspace's activation record could
|
|
52
|
+
* not be read, or could not be locked, otherwise `toModelFacingUninstallError`'s classification, thrown.
|
|
53
|
+
*
|
|
54
|
+
* An unreadable or busy activations.json is not the caller's input and not an internal bug the model should see
|
|
55
|
+
* redacted (t91 §7.1/R2): nothing was removed, and there is a concrete next step, so this is the ADR-055 Decision 6
|
|
56
|
+
* not-removed result `plugins_set_enabled`'s `activationsUnreadableResult`/`activationsBusyResult` already return
|
|
57
|
+
* for the sibling family. The error's message names the host path (and, for Busy, the lock file), so it goes to the
|
|
58
|
+
* server log only — through the host's `reportRefusal`, which owns how it is logged; `note` is fixed, path-free text.
|
|
59
|
+
*
|
|
60
|
+
* @throws The re-classified error for every other rejection.
|
|
61
|
+
* @complexity O(1).
|
|
62
|
+
*/
|
|
63
|
+
function uninstallRefusedResult({ pluginId, error, copy, report }, _optional = {}) {
|
|
64
|
+
if (error instanceof AgentPluginUpdateError)
|
|
65
|
+
return updateJournalRefusedResult({ pluginId, error, copy });
|
|
66
|
+
if (error instanceof AgentPluginActivationsBusyError) {
|
|
67
|
+
report({ pluginId, reason: "activations-busy", error });
|
|
68
|
+
return {
|
|
69
|
+
uninstalled: false,
|
|
70
|
+
cancelled: false,
|
|
71
|
+
pluginId,
|
|
72
|
+
restartRequired: false,
|
|
73
|
+
reason: "activations-busy",
|
|
74
|
+
note: `Nothing was removed: another ${copy.productName} process was writing this workspace's Agent Plugin activation record at the ` +
|
|
75
|
+
`same moment, so '${pluginId}' was NOT uninstalled. Tell the user nothing was changed and to try again in a ` +
|
|
76
|
+
"moment; if it keeps happening, the server log names the lock file.",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (error instanceof FileLockTimeoutError) {
|
|
80
|
+
// Layout B (2026-10-04) added a second lock in front of the activations one: the per-plugin state
|
|
81
|
+
// lock (`staging/.plugin-state-<id>.lock`) every install/update/uninstall/memory write of this
|
|
82
|
+
// plugin takes. A timeout means the lock was never acquired, so the uninstall body never ran — or,
|
|
83
|
+
// for an inner lock, `uninstall.ts` already put every staged tree back (a failed put-back throws a
|
|
84
|
+
// different error). Same ADR-055 Decision 6 not-removed RESULT as a busy activations record; the
|
|
85
|
+
// message names the lock path, so it goes to the server log only (via the host's reporter).
|
|
86
|
+
report({ pluginId, reason: "plugin-busy", error });
|
|
87
|
+
return {
|
|
88
|
+
uninstalled: false,
|
|
89
|
+
cancelled: false,
|
|
90
|
+
pluginId,
|
|
91
|
+
restartRequired: false,
|
|
92
|
+
reason: "plugin-busy",
|
|
93
|
+
note: `Nothing was removed: another ${copy.productName} process was installing, updating or writing memory for '${pluginId}' at the ` +
|
|
94
|
+
"same moment, so it was NOT uninstalled. Tell the user nothing was changed and to try again in a moment; if it " +
|
|
95
|
+
"keeps happening, the server log names the lock file.",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (!(error instanceof AgentPluginActivationsUnreadableError))
|
|
99
|
+
throw toModelFacingUninstallError({ error });
|
|
100
|
+
report({ pluginId, reason: "activations-unreadable", error });
|
|
101
|
+
return {
|
|
102
|
+
uninstalled: false,
|
|
103
|
+
cancelled: false,
|
|
104
|
+
pluginId,
|
|
105
|
+
restartRequired: false,
|
|
106
|
+
reason: "activations-unreadable",
|
|
107
|
+
note: `Nothing was removed: this workspace's Agent Plugin activation record could not be read, so whether '${pluginId}' is ` +
|
|
108
|
+
`bundled with ${copy.productName} cannot be established and it was NOT uninstalled. Tell the user an operator has to repair ` +
|
|
109
|
+
"activations.json first (the server log names the file and the fault); until then every Agent Plugin tool call in " +
|
|
110
|
+
"this workspace is refused.",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** The preview a dialog may show, or the not-removed result to return instead of raising one.
|
|
114
|
+
* @complexity O(1) beyond `previewAgentPluginUninstall`. */
|
|
115
|
+
async function previewOrRefusal(request, { preview, copy, report }) {
|
|
116
|
+
try {
|
|
117
|
+
return { preview: await preview(request) };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return { refusal: uninstallRefusedResult({ pluginId: request.pluginId, error, copy, report }) };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Fails closed when no interactive transport exists: removing bytes and merely mentioning
|
|
124
|
+
// that we could not ask would make consent decorative. The shared owner closes cards on abort;
|
|
125
|
+
// a cancelled run must not leave a dialog holding a call nobody is listening to.
|
|
126
|
+
// The exchange uses the host's merged uninstall id, the ONE id both families redeem through, not a family
|
|
127
|
+
// specific id. ADR-055 Decision 6: a no-answer is a RESULT, not an exception — nothing was
|
|
128
|
+
// removed either way, and the model is still alive to say so.
|
|
129
|
+
/**
|
|
130
|
+
* The post-confirmation half: uninstalls exactly what the human was shown. If the installed archives changed while
|
|
131
|
+
* the dialog was open, that is a not-removed RESULT — the same union member `expired`/`abandoned` use — not a
|
|
132
|
+
* `ToolInputError`: the caller's input was fine, what is installed moved. Every other refusal goes through
|
|
133
|
+
* `uninstallRefusedResult`, like the preview's.
|
|
134
|
+
* @complexity O(1) beyond `uninstallAgentPlugin`.
|
|
135
|
+
*/
|
|
136
|
+
async function uninstallConfirmedAgentPlugin({ request, preview, copy, report }, { deleteMemory = false, uninstall }) {
|
|
137
|
+
try {
|
|
138
|
+
const result = await uninstall(request, { confirmedPreview: preview, deleteMemory });
|
|
139
|
+
return {
|
|
140
|
+
uninstalled: true,
|
|
141
|
+
cancelled: false,
|
|
142
|
+
pluginId: result.pluginId,
|
|
143
|
+
removedDigests: result.removedDigests,
|
|
144
|
+
restartRequired: true,
|
|
145
|
+
note: "Uninstalled. Its files and activation record are gone, new runs no longer load it, and its own agent_plugin_<id> " +
|
|
146
|
+
"tool stops running immediately — every call is refused from now on, with no restart needed. That tool does stay " +
|
|
147
|
+
`LISTED in this already-running daemon until ${copy.productName} restarts, so tell the user it may still appear in tool listings ` +
|
|
148
|
+
"until then, and that calling it will simply be denied. Uninstalling does NOT remove any external MCP server " +
|
|
149
|
+
"connection the plugin set up: if an operator turned one on, its mcp__<server>__* tools keep working until that " +
|
|
150
|
+
`connection is disabled or deleted under ${copy.externalMcpSettingsPath}.`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error instanceof AgentPluginChangedSincePreviewError) {
|
|
155
|
+
return {
|
|
156
|
+
uninstalled: false,
|
|
157
|
+
cancelled: false,
|
|
158
|
+
pluginId: request.pluginId,
|
|
159
|
+
restartRequired: false,
|
|
160
|
+
reason: "changed-since-confirmation",
|
|
161
|
+
note: `'${request.pluginId}' changed after the user was asked: the installed archives are no longer the ones the confirmation showed. ` +
|
|
162
|
+
`Nothing was removed. Call ${copy.uninstallToolName} again with family 'agent-plugin' so the user can review and confirm what is installed now.`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return uninstallRefusedResult({ pluginId: request.pluginId, error, copy, report });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Runs the Agent Plugin branch of `plugins_uninstall` end to end: permission, preview-or-refusal,
|
|
170
|
+
* confirm, write. `plugin-runtime/tool-registrations.ts`'s handler calls this directly when
|
|
171
|
+
* `family === "agent-plugin"` — see this file's header for why the permission check lives here rather
|
|
172
|
+
* than being hoisted above the family branch (unlike `plugins_set_enabled`'s single pre-branch check):
|
|
173
|
+
* this mirrors the deleted standalone tool's own order exactly, permission then preview then confirm
|
|
174
|
+
* then write, with nothing shared between the two families' checks to hoist.
|
|
175
|
+
*
|
|
176
|
+
* Order is load-bearing, same as the site-runtime branch: parse -> authorize -> preview (so an unknown
|
|
177
|
+
* or bundled id, or an unreadable/busy activations.json, is refused or returned as a not-removed
|
|
178
|
+
* result before any human is asked anything) -> confirm -> re-check and write only if the plugin is
|
|
179
|
+
* still what the dialog showed (t91 F2.2).
|
|
180
|
+
*
|
|
181
|
+
* @complexity O(1) beyond `previewAgentPluginUninstall`/`uninstallAgentPlugin`.
|
|
182
|
+
*/
|
|
183
|
+
export async function runAgentPluginUninstall({ routeDeps, surfaces, ctx, pluginId }, optional = {}) {
|
|
184
|
+
ctx = { ...ctx, input: structuredClone(ctx.input), principal: { ...ctx.principal }, run: { ...ctx.run } };
|
|
185
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }), workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: "admin.plugins.enable" }, { entityType: "agent-plugin", entityId: pluginId });
|
|
186
|
+
const request = { layout: routeDeps.agentPluginLayout, workspaceId: routeDeps.workspaceId, pluginId };
|
|
187
|
+
const host = routeDeps.uninstallHost;
|
|
188
|
+
const previewed = await previewOrRefusal(request, { preview: host.previewAgentPluginUninstall, copy: host.copy, report: host.reportRefusal });
|
|
189
|
+
if ("refusal" in previewed)
|
|
190
|
+
return previewed.refusal;
|
|
191
|
+
const locale = await routeDeps.preferences.locale({ workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id });
|
|
192
|
+
return host.approvalToolHandler({ surfaces,
|
|
193
|
+
prepare: async () => previewed.preview,
|
|
194
|
+
describe: ({ prepared }) => host.describeApproval({ preview: prepared }, { locale }),
|
|
195
|
+
run: async ({ ctx: approvedCtx, prepared, choice }) => {
|
|
196
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }), workspaceId: routeDeps.workspaceId, principalId: approvedCtx.principal.id, permission: "admin.plugins.enable" }, { entityType: "agent-plugin", entityId: pluginId });
|
|
197
|
+
if (approvedCtx.signal.aborted)
|
|
198
|
+
return { uninstalled: false, ...host.notConfirmedResult({ confirmed: false, reason: "abandoned" }) };
|
|
199
|
+
return uninstallConfirmedAgentPlugin({ request, preview: prepared, copy: host.copy, report: host.reportRefusal }, { deleteMemory: choice === "delete-memory", uninstall: routeDeps.uninstallAgentPlugin ?? host.uninstallAgentPlugin });
|
|
200
|
+
},
|
|
201
|
+
}, { flag: "uninstalled", declined: ({ reason }) => ({ uninstalled: false, pluginId, restartRequired: false, ...host.notConfirmedResult({ confirmed: false, reason }) }) })(ctx, optional);
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=uninstall-tool.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AgentPluginMcpProvisioningPort } from '@jini-ai/agent-plugins/lifecycle';
|
|
2
|
+
import type { provisionAgentPluginMcpServers, resolveAgentPluginMcpServers } from '../connect/federate-mcp.js';
|
|
3
|
+
import type { AgentPluginLayout } from "@jini-ai/core/contracts/headless/plugin-host";
|
|
4
|
+
type ProvisionDeps = import('./service-ports.js').AgentPluginMcpContext & Pick<import('./service-ports.js').AgentPluginMcpPort, 'repo' | 'saveServer'> & Partial<Pick<import('./service-ports.js').AgentPluginMcpPort, 'notifyRosterChanged'>>;
|
|
5
|
+
export type UpdateMcpDeps = {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
agentPluginLayout: AgentPluginLayout;
|
|
8
|
+
mcp: ProvisionDeps;
|
|
9
|
+
/** Announces the changed roster so live runtimes reload; the composition root binds
|
|
10
|
+
* `notifyExternalMcpRosterChanged`. A port rather than a value import: a feature module may not
|
|
11
|
+
* value-import `the assistant layer` (`domain-no-direct-tool-registration.boundary.test.ts`), the
|
|
12
|
+
* same seam `apply-tool-renames.ts` uses. */
|
|
13
|
+
notifyExternalMcpRosterChanged: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/** What a host hands over: the scope always, the MCP store and roster ports only when it bound them. */
|
|
16
|
+
export type UpdateMcpHostDeps = Pick<UpdateMcpDeps, "workspaceId" | "agentPluginLayout"> & Partial<UpdateMcpDeps>;
|
|
17
|
+
/** Update provisioning uses the existing MCP owner and roster reload. It must succeed before
|
|
18
|
+
* the update commits; existing credentials and reviewed permissions stay with that owner.
|
|
19
|
+
* @complexity O(s), candidate MCP servers. Running MCP requests may fail during roster reload.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createAgentPluginUpdateEffects({ deps, actor, resolveServers, provisionServers }: {
|
|
22
|
+
deps: UpdateMcpDeps;
|
|
23
|
+
actor: string;
|
|
24
|
+
resolveServers(input: Omit<Parameters<typeof resolveAgentPluginMcpServers>[0], 'lifecycle'>): ReturnType<typeof resolveAgentPluginMcpServers>;
|
|
25
|
+
provisionServers(deps: ProvisionDeps, input: Omit<Parameters<typeof provisionAgentPluginMcpServers>[0], 'deps' | 'classifyTrust' | 'messages'>): ReturnType<typeof provisionAgentPluginMcpServers>;
|
|
26
|
+
}, _optional?: {}): AgentPluginMcpProvisioningPort;
|
|
27
|
+
/** The update's MCP deps from what the host bound. A missing one is a host wiring fault, not the
|
|
28
|
+
* caller's, so this throws a plain error (redacted to the model and to HTTP clients).
|
|
29
|
+
* @complexity O(1). */
|
|
30
|
+
export declare function requireUpdateMcpDeps({ deps }: {
|
|
31
|
+
deps: UpdateMcpHostDeps;
|
|
32
|
+
}, _optional?: Record<string, never>): UpdateMcpDeps;
|
|
33
|
+
/**
|
|
34
|
+
* The composed lifecycle's MCP port, used by boot recovery to re-provision a restored revision's
|
|
35
|
+
* servers. The lifecycle is bound before the external-MCP store exists in the composition root, so
|
|
36
|
+
* the deps are read when recovery calls, not when this is built. Without this binding recovery
|
|
37
|
+
* still restores the bytes but leaves the plugin switched off (Jini's degraded outcome).
|
|
38
|
+
* @complexity O(1) to build; each call as {@link createAgentPluginUpdateEffects}.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createDeferredAgentPluginUpdateEffects({ resolveDeps, actor, resolveServers, provisionServers }: {
|
|
41
|
+
resolveDeps: () => UpdateMcpHostDeps;
|
|
42
|
+
actor: string;
|
|
43
|
+
resolveServers: Parameters<typeof createAgentPluginUpdateEffects>[0]['resolveServers'];
|
|
44
|
+
provisionServers: Parameters<typeof createAgentPluginUpdateEffects>[0]['provisionServers'];
|
|
45
|
+
}, _optional?: {}): AgentPluginMcpProvisioningPort;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=update-effects.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AgentPluginUpdateError } from '../core/update-error.js';
|
|
2
|
+
/** Update provisioning uses the existing MCP owner and roster reload. It must succeed before
|
|
3
|
+
* the update commits; existing credentials and reviewed permissions stay with that owner.
|
|
4
|
+
* @complexity O(s), candidate MCP servers. Running MCP requests may fail during roster reload.
|
|
5
|
+
*/
|
|
6
|
+
export function createAgentPluginUpdateEffects({ deps, actor, resolveServers, provisionServers }, _optional = {}) {
|
|
7
|
+
const unsupported = async () => { throw new Error('Use the shared activation/removal owner.'); };
|
|
8
|
+
return {
|
|
9
|
+
provision: async ({ workspaceId, installed }) => {
|
|
10
|
+
const servers = await resolveServers({ agentPluginLayout: deps.agentPluginLayout, workspaceId, pluginId: installed.pluginId });
|
|
11
|
+
const result = await provisionServers(deps.mcp, { workspaceId, pluginId: installed.pluginId, servers, principalId: actor });
|
|
12
|
+
// A named refusal, so the route answers 409 with this code rather than a redacted 500. The lifecycle
|
|
13
|
+
// owner rolls the update back before it rethrows this, so the message can say so.
|
|
14
|
+
if (result.failed.length)
|
|
15
|
+
throw new AgentPluginUpdateError({ code: 'PLUGIN_MCP_PROVISION_FAILED', message: 'The new version\'s MCP servers could not be set up; the previous version was restored.' });
|
|
16
|
+
},
|
|
17
|
+
notifyRosterChanged: async () => deps.notifyExternalMcpRosterChanged(),
|
|
18
|
+
setEnabled: unsupported,
|
|
19
|
+
remove: unsupported,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** The update's MCP deps from what the host bound. A missing one is a host wiring fault, not the
|
|
23
|
+
* caller's, so this throws a plain error (redacted to the model and to HTTP clients).
|
|
24
|
+
* @complexity O(1). */
|
|
25
|
+
export function requireUpdateMcpDeps({ deps }, _optional = {}) {
|
|
26
|
+
const { workspaceId, agentPluginLayout, mcp, notifyExternalMcpRosterChanged } = deps;
|
|
27
|
+
const unbound = () => new Error("Agent Plugin update is unavailable: the host did not bind its MCP provisioning.");
|
|
28
|
+
if (!mcp?.repo || !mcp.saveServer || !notifyExternalMcpRosterChanged)
|
|
29
|
+
throw unbound();
|
|
30
|
+
return { workspaceId, agentPluginLayout, mcp, notifyExternalMcpRosterChanged };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The composed lifecycle's MCP port, used by boot recovery to re-provision a restored revision's
|
|
34
|
+
* servers. The lifecycle is bound before the external-MCP store exists in the composition root, so
|
|
35
|
+
* the deps are read when recovery calls, not when this is built. Without this binding recovery
|
|
36
|
+
* still restores the bytes but leaves the plugin switched off (Jini's degraded outcome).
|
|
37
|
+
* @complexity O(1) to build; each call as {@link createAgentPluginUpdateEffects}.
|
|
38
|
+
*/
|
|
39
|
+
export function createDeferredAgentPluginUpdateEffects({ resolveDeps, actor, resolveServers, provisionServers }, _optional = {}) {
|
|
40
|
+
const effects = () => createAgentPluginUpdateEffects({ deps: requireUpdateMcpDeps({ deps: resolveDeps() }), actor, resolveServers, provisionServers });
|
|
41
|
+
return {
|
|
42
|
+
// Async so a host missing a dep rejects the call (a failed provision) instead of throwing synchronously.
|
|
43
|
+
provision: async (input) => effects().provision(input),
|
|
44
|
+
notifyRosterChanged: async (input) => effects().notifyRosterChanged(input),
|
|
45
|
+
setEnabled: async (input) => effects().setEnabled(input),
|
|
46
|
+
remove: async (input) => effects().remove(input),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=update-effects.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "ffmpeg-transcode",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Converts videos to a web-safe MP4 on the host computer with a local ffmpeg program. Local ffmpeg is required and is not bundled or installed by this plugin; without it, conversion is refused in plain words.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"extensions": {
|
|
8
|
+
"jini": {
|
|
9
|
+
"id": "jini/ffmpeg-transcode",
|
|
10
|
+
"displayName": "FFmpeg transcode",
|
|
11
|
+
"summary": "Converts videos to a web-safe MP4 on this computer, using the ffmpeg already installed here.",
|
|
12
|
+
"provides": ["media-transcode"]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"keywords": ["ffmpeg", "video", "transcode"]
|
|
16
|
+
}
|
|
@@ -79,45 +79,24 @@ function treeEntry(entry) {
|
|
|
79
79
|
return "text" in entry ? { path: entry.path, mode: "100644", type: "blob", content: entry.text } : { path: entry.path, mode: "100644", type: "blob", sha: entry.blobSha };
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/** @param {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"which would be exposed to everyone who can read that repository. Back up only to a private repository.",
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** @param {Target} target */
|
|
101
|
-
async function checkRepository(target) {
|
|
102
|
-
const name = `${target.owner}/${target.repo}`;
|
|
103
|
-
const repoJson = await git.getJson(target, repoPathOf(target), "GitHub repository lookup failed");
|
|
104
|
-
if (!repoJson.ok) return repoJson;
|
|
105
|
-
if (!repoJson.found) {
|
|
106
|
-
return { ok: false, code: "repo-not-found", message: `repository ${name} was not found, or this credential cannot see it` };
|
|
107
|
-
}
|
|
108
|
-
const json = repoJson.json;
|
|
109
|
-
const privacy = checkBackupPrivacy({ json, name });
|
|
110
|
-
if (privacy) return privacy;
|
|
111
|
-
const permissions = json.permissions;
|
|
112
|
-
if (typeof permissions === "object" && permissions !== null && permissions.push === false) {
|
|
113
|
-
return { ok: false, code: "no-push-permission", message: `this credential can read ${name} but cannot push to it` };
|
|
114
|
-
}
|
|
115
|
-
const defaultBranch = extractStringField({ value: json, field: "default_branch" });
|
|
116
|
-
const htmlUrl = extractStringField({ value: json, field: "html_url" });
|
|
117
|
-
if (!defaultBranch || !htmlUrl) return { ok: false, code: PROVIDER_ERROR, message: "GitHub repository lookup response did not include a default branch or URL" };
|
|
118
|
-
return { ok: true, defaultBranch, htmlUrl };
|
|
82
|
+
/** @param {{ json: any, name: string }} required */
|
|
83
|
+
function checkBackupPrivacy({ json, name }, _options = {}) {
|
|
84
|
+
const fallbackVisibility = json.private === true ? "private" : "public";
|
|
85
|
+
const visibility = typeof json.visibility === "string" ? json.visibility : fallbackVisibility;
|
|
86
|
+
if (json.private !== true || visibility !== "private") {
|
|
87
|
+
return {
|
|
88
|
+
ok: false,
|
|
89
|
+
code: "repo-not-private",
|
|
90
|
+
message:
|
|
91
|
+
`repository ${name} is ${visibility}. A site backup contains the whole database — members, form submissions, admin accounts — ` +
|
|
92
|
+
"which would be exposed to everyone who can read that repository. Back up only to a private repository.",
|
|
93
|
+
};
|
|
119
94
|
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
120
97
|
|
|
98
|
+
/** @param {GitDataClient} git */
|
|
99
|
+
function createBackupBranchReader(git) {
|
|
121
100
|
/** GitHub answers 409 for the ref of an EMPTY repository. @param {Target} target @param {string} branch */
|
|
122
101
|
async function readBranchTip(target, branch) {
|
|
123
102
|
const name = `${target.owner}/${target.repo}`;
|
|
@@ -138,13 +117,41 @@ export function createBackupPusher(git, _optional = {}) {
|
|
|
138
117
|
|
|
139
118
|
/** @param {{ target: Target, parentCommitSha: string }} required */
|
|
140
119
|
async function readBackupParentTree({ target, parentCommitSha }, _options = {}) {
|
|
141
|
-
const commitJson = await git.getJson(target, `${repoPathOf(target)}/git/commits/${enc(parentCommitSha)}`, "GitHub parent-commit lookup failed");
|
|
120
|
+
const commitJson = await git.getJson(target, `${repoPathOf(target)}/git/commits/${enc({ value: parentCommitSha })}`, "GitHub parent-commit lookup failed");
|
|
142
121
|
if (!commitJson.ok) return commitJson;
|
|
143
122
|
const baseTreeSha = commitJson.found ? extractStringField({ value: commitJson.json.tree, field: "sha" }) : "";
|
|
144
123
|
if (!baseTreeSha) return { ok: false, code: PROVIDER_ERROR, message: "GitHub parent-commit lookup did not return a tree sha" };
|
|
145
124
|
return { ok: true, parentCommitSha, baseTreeSha };
|
|
146
125
|
}
|
|
147
126
|
|
|
127
|
+
return readBranchTip;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** @param {GitDataClient} git */
|
|
131
|
+
function createBackupRepositoryInspector(git) {
|
|
132
|
+
const readBranchTip = createBackupBranchReader(git);
|
|
133
|
+
|
|
134
|
+
/** @param {Target} target */
|
|
135
|
+
async function checkRepository(target) {
|
|
136
|
+
const name = `${target.owner}/${target.repo}`;
|
|
137
|
+
const repoJson = await git.getJson(target, repoPathOf(target), "GitHub repository lookup failed");
|
|
138
|
+
if (!repoJson.ok) return repoJson;
|
|
139
|
+
if (!repoJson.found) {
|
|
140
|
+
return { ok: false, code: "repo-not-found", message: `repository ${name} was not found, or this credential cannot see it` };
|
|
141
|
+
}
|
|
142
|
+
const json = repoJson.json;
|
|
143
|
+
const privacy = checkBackupPrivacy({ json, name });
|
|
144
|
+
if (privacy) return privacy;
|
|
145
|
+
const permissions = json.permissions;
|
|
146
|
+
if (typeof permissions === "object" && permissions !== null && permissions.push === false) {
|
|
147
|
+
return { ok: false, code: "no-push-permission", message: `this credential can read ${name} but cannot push to it` };
|
|
148
|
+
}
|
|
149
|
+
const defaultBranch = extractStringField({ value: json, field: "default_branch" });
|
|
150
|
+
const htmlUrl = extractStringField({ value: json, field: "html_url" });
|
|
151
|
+
if (!defaultBranch || !htmlUrl) return { ok: false, code: PROVIDER_ERROR, message: "GitHub repository lookup response did not include a default branch or URL" };
|
|
152
|
+
return { ok: true, defaultBranch, htmlUrl };
|
|
153
|
+
}
|
|
154
|
+
|
|
148
155
|
/** @param {Target & { branch?: string, folder: string }} input */
|
|
149
156
|
async function inspectBackupRepository(input) {
|
|
150
157
|
const repo = await checkRepository(input);
|
|
@@ -154,7 +161,7 @@ export function createBackupPusher(git, _optional = {}) {
|
|
|
154
161
|
const tip = await readBranchTip(input, branch);
|
|
155
162
|
if (!tip.ok) return tip;
|
|
156
163
|
|
|
157
|
-
const folderJson = await git.getJson(input, `${repoPathOf(input)}/contents/${encPath({ path: input.folder })}?ref=${enc(branch)}`, "GitHub folder lookup failed");
|
|
164
|
+
const folderJson = await git.getJson(input, `${repoPathOf(input)}/contents/${encPath({ path: input.folder })}?ref=${enc({ value: branch })}`, "GitHub folder lookup failed");
|
|
158
165
|
if (!folderJson.ok) return folderJson;
|
|
159
166
|
if (folderJson.found && !Array.isArray(folderJson.json)) {
|
|
160
167
|
return { ok: false, code: "folder-is-file", message: `'${input.folder}' exists on branch '${branch}' but is not a folder — refusing to replace it` };
|
|
@@ -162,14 +169,11 @@ export function createBackupPusher(git, _optional = {}) {
|
|
|
162
169
|
return { ok: true, state: { branch, parentCommitSha: tip.parentCommitSha, baseTreeSha: tip.baseTreeSha, htmlUrl: repo.htmlUrl, folderExists: folderJson.found } };
|
|
163
170
|
}
|
|
164
171
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const result = await git.createBlob(target, file.content);
|
|
168
|
-
if (!result.ok) return result;
|
|
169
|
-
const sha256 = createHash("sha256").update(file.content).digest("hex");
|
|
170
|
-
return { ok: true, blob: { path: file.path, blobSha: result.sha, bytes: file.content.byteLength, sha256 } };
|
|
171
|
-
}
|
|
172
|
+
return inspectBackupRepository;
|
|
173
|
+
}
|
|
172
174
|
|
|
175
|
+
/** @param {GitDataClient} git */
|
|
176
|
+
function createBackupFolderWriter(git) {
|
|
173
177
|
/**
|
|
174
178
|
* The backup folder's tree, built over chained requests: each one adds a chunk of entries on top of
|
|
175
179
|
* the previous one's tree (`base_tree`), the first starting empty, so the folder still REPLACES
|
|
@@ -195,6 +199,22 @@ export function createBackupPusher(git, _optional = {}) {
|
|
|
195
199
|
return { ok: true, sha: /** @type {string} */ (folderTreeSha) };
|
|
196
200
|
}
|
|
197
201
|
|
|
202
|
+
return createFolderTree;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** @param {GitDataClient} git */
|
|
206
|
+
export function createBackupPusher(git, _optional = {}) {
|
|
207
|
+
const inspectBackupRepository = createBackupRepositoryInspector(git);
|
|
208
|
+
const createFolderTree = createBackupFolderWriter(git);
|
|
209
|
+
|
|
210
|
+
/** @param {Target} target @param {{ path: string, content: Uint8Array }} file */
|
|
211
|
+
async function uploadBackupBlob(target, file) {
|
|
212
|
+
const result = await git.createBlob(target, file.content);
|
|
213
|
+
if (!result.ok) return result;
|
|
214
|
+
const sha256 = createHash("sha256").update(file.content).digest("hex");
|
|
215
|
+
return { ok: true, blob: { path: file.path, blobSha: result.sha, bytes: file.content.byteLength, sha256 } };
|
|
216
|
+
}
|
|
217
|
+
|
|
198
218
|
/**
|
|
199
219
|
* @param {Target & { branch: string, folder: string, commitMessage: string, parentCommitSha: string,
|
|
200
220
|
* baseTreeSha: string, htmlUrl: string, entries: readonly (UploadedBackupBlob | InlineBackupText)[] }} input
|