@jini-ai/agent-plugins 0.7.2 → 0.7.3-next.2

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.
Files changed (236) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/NOTICE +2 -0
  3. package/README.md +11 -15
  4. package/calendly/plugin.json +3 -3
  5. package/cloudflare/lib/forms.mjs +9 -10
  6. package/cloudflare/lib/target.mjs +1 -1
  7. package/cloudflare/plugin.json +3 -3
  8. package/cloudflare/worker/forms-receiver.mjs +9 -9
  9. package/composio/plugin.json +3 -3
  10. package/core/persistent-state.js +227 -163
  11. package/dist/admin-surfaces/connections/connections.d.ts +11 -6
  12. package/dist/admin-surfaces/connections/connections.js +102 -85
  13. package/dist/admin-surfaces/node.d.ts +27 -0
  14. package/dist/admin-surfaces/node.js +32 -0
  15. package/dist/admin-surfaces/plugin-state.js +21 -18
  16. package/dist/admin-surfaces/surface-client.d.ts +4 -0
  17. package/dist/admin-surfaces/surface-client.js +124 -117
  18. package/dist/admin-surfaces/surface-handlers.js +21 -17
  19. package/dist/admin-surfaces/theme.d.ts +5 -1
  20. package/dist/admin-surfaces/theme.js +3 -3
  21. package/dist/connect/access-token-tool.d.ts +3 -1
  22. package/dist/connect/access-token-tool.js +3 -2
  23. package/dist/connect/apply-connect-defaults.js +2 -2
  24. package/dist/connect/apply-tool-renames.js +9 -8
  25. package/dist/connect/connect-tool.d.ts +2 -0
  26. package/dist/connect/connect-tool.js +3 -2
  27. package/dist/connect/credential-cards.js +3 -2
  28. package/dist/connect/credential-save-tool.d.ts +14 -11
  29. package/dist/connect/credential-save-tool.js +128 -121
  30. package/dist/connect/enable-access.d.ts +2 -2
  31. package/dist/connect/enable-access.js +6 -6
  32. package/dist/connect/executable/register.js +40 -34
  33. package/dist/connect/federate-mcp.d.ts +21 -11
  34. package/dist/connect/federate-mcp.js +28 -21
  35. package/dist/connect/grant-signed-in-defaults.js +3 -3
  36. package/dist/connect/import-access-token.js +2 -1
  37. package/dist/connect/index.d.ts +1 -0
  38. package/dist/connect/index.js +1 -0
  39. package/dist/connect/plugin-credential-card.js +2 -1
  40. package/dist/connect/plugin-host/index.d.ts +10 -5
  41. package/dist/connect/plugin-host/index.js +113 -100
  42. package/dist/connect/ports.d.ts +1 -1
  43. package/dist/connect/row-update.d.ts +22 -0
  44. package/dist/connect/row-update.js +18 -0
  45. package/dist/connect/switch-on-saved-token.d.ts +4 -2
  46. package/dist/connect/switch-on-saved-token.js +1 -1
  47. package/dist/connect/token-map.d.ts +44 -0
  48. package/dist/connect/token-map.js +49 -0
  49. package/dist/core/identity-namespace.js +5 -0
  50. package/dist/folder-zip.d.ts +3 -1
  51. package/dist/folder-zip.js +2 -2
  52. package/dist/lifecycle/activation.d.ts +4 -4
  53. package/dist/lifecycle/activation.js +4 -5
  54. package/dist/lifecycle/automatic-use.js +236 -210
  55. package/dist/lifecycle/bundled-digests.d.ts +75 -12
  56. package/dist/lifecycle/bundled-digests.js +213 -212
  57. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  58. package/dist/lifecycle/bundled-source-archive.js +263 -264
  59. package/dist/lifecycle/capability-projection.d.ts +1 -1
  60. package/dist/lifecycle/capability-projection.js +1 -1
  61. package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
  62. package/dist/lifecycle/credential-card-metadata.js +27 -3
  63. package/dist/lifecycle/exports.js +9 -4
  64. package/dist/lifecycle/fetch-archive.d.ts +1 -1
  65. package/dist/lifecycle/fetch-archive.js +1 -1
  66. package/dist/lifecycle/host-tools/identity.js +3 -2
  67. package/dist/lifecycle/host-tools/ports.d.ts +2 -0
  68. package/dist/lifecycle/host-tools/search-tool.d.ts +4 -2
  69. package/dist/lifecycle/host-tools/search-tool.js +9 -8
  70. package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
  71. package/dist/lifecycle/host-tools/skill-tool.js +16 -8
  72. package/dist/lifecycle/index.d.ts +118 -110
  73. package/dist/lifecycle/index.js +45 -12
  74. package/dist/lifecycle/install-errors.d.ts +1 -1
  75. package/dist/lifecycle/install-from-url.d.ts +1 -1
  76. package/dist/lifecycle/install-from-url.js +1 -1
  77. package/dist/lifecycle/install.d.ts +7 -2
  78. package/dist/lifecycle/install.js +414 -396
  79. package/dist/lifecycle/installed-package-index.js +45 -42
  80. package/dist/lifecycle/layout.d.ts +1 -1
  81. package/dist/lifecycle/layout.js +1 -1
  82. package/dist/lifecycle/mail/catalog.d.ts +8 -32
  83. package/dist/lifecycle/mail/catalog.js +25 -20
  84. package/dist/lifecycle/mail/contribution.d.ts +2 -2
  85. package/dist/lifecycle/mail/contribution.js +34 -34
  86. package/dist/lifecycle/mail/selection.js +6 -2
  87. package/dist/lifecycle/manifest.d.ts +3 -3
  88. package/dist/lifecycle/manifest.js +4 -4
  89. package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
  90. package/dist/lifecycle/mcp-provisioning.js +3 -3
  91. package/dist/lifecycle/package-paths.d.ts +1 -1
  92. package/dist/lifecycle/package-paths.js +1 -1
  93. package/dist/lifecycle/persistent-state.js +1 -2
  94. package/dist/lifecycle/ports.d.ts +5 -1
  95. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
  96. package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
  97. package/dist/lifecycle/retire-bundled.d.ts +1 -52
  98. package/dist/lifecycle/retire-bundled.js +134 -84
  99. package/dist/lifecycle/search.d.ts +2 -1
  100. package/dist/lifecycle/search.js +1 -1
  101. package/dist/lifecycle/seed-bundled.d.ts +1 -1
  102. package/dist/lifecycle/seed-bundled.js +154 -155
  103. package/dist/lifecycle/set-enabled.d.ts +1 -1
  104. package/dist/lifecycle/set-enabled.js +1 -1
  105. package/dist/lifecycle/skill-file-reader.js +53 -50
  106. package/dist/lifecycle/tools/projection.d.ts +4 -7
  107. package/dist/lifecycle/tools/projection.js +109 -108
  108. package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
  109. package/dist/lifecycle/trusted-plugin-files.js +1 -1
  110. package/dist/lifecycle/uninstall.d.ts +1 -1
  111. package/dist/lifecycle/uninstall.js +237 -241
  112. package/dist/lifecycle/update-store.js +20 -17
  113. package/dist/lifecycle/update.js +287 -281
  114. package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
  115. package/dist/lifecycle/yauzl-archive-reader.js +8 -2
  116. package/dist/manifest.d.ts +11 -3
  117. package/dist/manifest.js +9 -9
  118. package/fly/jini-credential-schemes.json +11 -0
  119. package/fly/plugin.json +3 -4
  120. package/github/plugin.json +3 -3
  121. package/github/source-control/backup-push.mjs +11 -11
  122. package/github/source-control/commit-site.mjs +23 -13
  123. package/github/source-control/github.mjs +12 -6
  124. package/github/source-control/write-files.mjs +27 -28
  125. package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
  126. package/github-pages/plugin.json +3 -3
  127. package/github-pages/targets/github-pages.mjs +3 -3
  128. package/google-login/plugin.json +3 -3
  129. package/google-workspace/README.md +14 -14
  130. package/google-workspace/form-destinations/README.md +3 -3
  131. package/google-workspace/form-destinations/dedupe.mjs +1 -1
  132. package/google-workspace/form-destinations/mapping.mjs +8 -9
  133. package/google-workspace/form-destinations/sheets.mjs +1 -1
  134. package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
  135. package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
  136. package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
  137. package/google-workspace/lib/auth.mjs +2 -2
  138. package/google-workspace/lib/form-destination-settings.mjs +1 -1
  139. package/google-workspace/lib/picker-flow.mjs +2 -2
  140. package/google-workspace/lib/request-policy.mjs +1 -1
  141. package/google-workspace/lib/surface-actions.mjs +1 -1
  142. package/google-workspace/plugin.json +3 -3
  143. package/google-workspace/tools/sheets/README.md +3 -3
  144. package/google-workspace/tools/sheets-admin/README.md +3 -3
  145. package/google-workspace/ui/README.md +4 -4
  146. package/google-workspace/ui/connection-panel.mjs +51 -51
  147. package/google-workspace/ui/destination-panel.mjs +34 -34
  148. package/google-workspace/ui/dom.mjs +15 -16
  149. package/google-workspace/ui/picker-flow.mjs +2 -2
  150. package/google-workspace/ui/picker.mjs +19 -19
  151. package/google-workspace/ui/surface-client.mjs +96 -69
  152. package/higgsfield-media/plugin.json +3 -3
  153. package/jev/plugin.json +3 -3
  154. package/kuinetic/CHANGELOG.md +12 -0
  155. package/kuinetic/mcp.json +4 -0
  156. package/kuinetic/plugin.json +27 -0
  157. package/kuinetic/skills/kuinetic/SKILL.md +120 -0
  158. package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
  159. package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
  160. package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
  161. package/meilisearch/plugin.json +5 -5
  162. package/netlify/plugin.json +3 -3
  163. package/netlify/targets/netlify.mjs +14 -4
  164. package/opentelemetry/plugin.json +3 -3
  165. package/package.json +27 -22
  166. package/posthog/plugin.json +3 -3
  167. package/railway/plugin.json +3 -3
  168. package/render/plugin.json +3 -3
  169. package/resend/NOTES.md +2 -2
  170. package/resend/adapters/resend.mjs +1 -1
  171. package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
  172. package/resend/lib/domains.mjs +8 -8
  173. package/resend/plugin.json +3 -3
  174. package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
  175. package/s3-compatible/jini-object-stores.json +29 -0
  176. package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
  177. package/s3-compatible/plugin.json +3 -3
  178. package/s3-compatible/targets/s3-compatible.mjs +25 -25
  179. package/sentry/plugin.json +3 -3
  180. package/shadcn-ui/CHANGELOG.md +7 -0
  181. package/shadcn-ui/LICENSE +201 -0
  182. package/shadcn-ui/NOTICE +10 -0
  183. package/shadcn-ui/mcp.json +4 -0
  184. package/shadcn-ui/plugin.json +26 -0
  185. package/shopify/plugin.json +3 -3
  186. package/site-compliance/plugin.json +3 -3
  187. package/site-import/plugin.json +3 -3
  188. package/supabase/mcp.json +1 -4
  189. package/supabase/plugin.json +3 -3
  190. package/ui-ux-design/CHANGELOG.md +13 -0
  191. package/ui-ux-design/NOTICE +2 -0
  192. package/ui-ux-design/README.md +17 -7
  193. package/ui-ux-design/plugin.json +6 -3
  194. package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
  195. package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
  196. package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
  197. package/vercel/NOTES.md +1 -1
  198. package/vercel/object-stores/vercel-blob.mjs +12 -2
  199. package/vercel/plugin.json +3 -3
  200. package/vercel/targets/vercel.mjs +3 -3
  201. package/wordpress/plugin.json +3 -3
  202. package/dist/lifecycle/node.d.ts +0 -11
  203. package/dist/lifecycle/node.js +0 -38
  204. package/fly/tovu-credential-schemes.json +0 -11
  205. package/github/deployments/github.mjs +0 -415
  206. package/s3-compatible/tovu-object-stores.json +0 -29
  207. package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
  208. /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
  209. /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  210. /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  211. /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  212. /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  213. /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  214. /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
  215. /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
  216. /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  217. /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
  218. /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
  219. /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  220. /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  221. /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  222. /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  223. /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  224. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
  225. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
  226. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
  227. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
  228. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
  229. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
  230. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
  231. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
  232. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
  233. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
  234. /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
  235. /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  236. /package/vercel/{tovu-object-stores.json → jini-object-stores.json} +0 -0
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "vercel",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description": "Publishes the site's static export to Vercel with the workspace's own saved token. Ships the host code itself (a host loads it only because that host chose to ship this plugin) and the know-how an agent needs: where to get a token, the optional team, Deployment Protection, and what each failure means in plain words.",
6
- "author": "Tovu",
6
+ "author": "Jini",
7
7
  "license": "Apache-2.0",
8
8
  "extensions": {
9
9
  "jini": {
10
10
  "displayName": "Vercel",
11
11
  "summary": "Puts your website online on Vercel. The assistant shows you a preview first.",
12
- "id": "tovu/vercel",
12
+ "id": "jini/vercel",
13
13
  "provides": [
14
14
  "deploy-target:vercel"
15
15
  ],
@@ -9,7 +9,7 @@
9
9
  * from the host kit the host injects (see {@link bindVercel}),
10
10
  * bound once per target by {@link bindVercel}: an installed plugin has no npm dependencies.
11
11
  * - `responseHeaders` (the host's security header set) is rendered into a root `vercel.json` here,
12
- * which the first host (Tovu) used to add in its core.
12
+ * which the first host used to add in its core.
13
13
  * - Files are uploaded one per request to `POST /v2/files` (by SHA-1) and the deployment references
14
14
  * them as `{ file, sha, size }`, the way Vercel's CLI does (2026-10-11). The devops source sent every
15
15
  * file inline, base64, in the one `/v13/deployments` body, which Vercel refuses past 10 MB
@@ -34,7 +34,7 @@ const VERCEL_CONFIG_FILE = "vercel.json";
34
34
 
35
35
  /**
36
36
  * Renders a header set as a `vercel.json` with one catch-all header rule. Byte-identical to what
37
- * the first host (Tovu) rendered in its core before this moved here.
37
+ * the first host rendered in its core before this moved here.
38
38
  *
39
39
  * @param {Readonly<Record<string, string>>} headers
40
40
  * @returns {string}
@@ -86,7 +86,7 @@ function vercelFileManifest(files) {
86
86
  * @returns The target class (constructed with `{ token, teamId?, teamSlug? }`, as in devops) and the
87
87
  * protected-response detector.
88
88
  */
89
- export function bindVercel(kit) {
89
+ export function bindVercel(kit, _optional = {}) {
90
90
  const { fetch: fetchWithTimeout, timeouts: FETCH_TIMEOUT_MS, sleep, DeployError, checkDeploymentUrl, normalizeDeploymentUrl, waitForReachableDeploymentUrl, safeProjectLabel, assertNotRedirected, redirectGuardInit } = kit;
91
91
  const VERCEL_TARGET_ID = 'vercel';
92
92
  const VERCEL_API = 'https://api.vercel.com';
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "wordpress",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description": "Guides publishing a site through an existing host, connecting an owned subdomain, or redirecting a free WordPress.com address. Uses existing hosting, DNS and page-reading tools. Includes WordPress.com dashboard steps and marks unconfirmed redirect pricing and host URL eligibility for dashboard confirmation.",
6
- "author": "Tovu",
6
+ "author": "Jini",
7
7
  "license": "Apache-2.0",
8
8
  "extensions": {
9
9
  "jini": {
10
10
  "maturity": "soon",
11
- "id": "tovu/wordpress",
11
+ "id": "jini/wordpress",
12
12
  "displayName": "WordPress",
13
13
  "summary": "Connect your own subdomain to your published site, or explore redirecting your free WordPress.com address.",
14
14
  "provides": [
@@ -1,11 +0,0 @@
1
- import type { AgentPluginClockPort, AgentPluginIdsPort, AgentPluginProcessPort, FilesystemPort } from './ports.js';
2
- /** Opt-in native effects. Layout, fetch, guard, namespace and provisioning remain host-owned. */
3
- export declare function createNodeAgentPluginEffects(_required: Record<string, never>, optional?: {
4
- readonly filesystem?: FilesystemPort;
5
- }): {
6
- filesystem: FilesystemPort;
7
- clock: AgentPluginClockPort;
8
- ids: AgentPluginIdsPort;
9
- process: AgentPluginProcessPort;
10
- };
11
- //# sourceMappingURL=node.d.ts.map
@@ -1,38 +0,0 @@
1
- import * as nativeFilesystem from 'node:fs/promises';
2
- import { randomInt, randomUUID } from 'node:crypto';
3
- import os from 'node:os';
4
- import { performance } from 'node:perf_hooks';
5
- import { setTimeout } from 'node:timers/promises';
6
- import { readBootIdentity } from '@jini-ai/platform/fs/file-lock';
7
- /** Granularity of the uniform [0, 1) value: crypto.randomInt's largest exclusive bound (2^48 - 1). */
8
- const RANDOM_RESOLUTION = 2 ** 48 - 1;
9
- /** Opt-in native effects. Layout, fetch, guard, namespace and provisioning remain host-owned. */
10
- export function createNodeAgentPluginEffects(_required, optional = {}) {
11
- return {
12
- filesystem: optional.filesystem ?? nativeFilesystem,
13
- clock: {
14
- nowMs: () => Date.now(),
15
- monotonicMs: () => performance.now(),
16
- sleep: ({ ms }) => setTimeout(ms),
17
- },
18
- ids: { newId: () => randomUUID(), random: () => randomInt(RANDOM_RESOLUTION) / RANDOM_RESOLUTION },
19
- process: {
20
- pid: process.pid,
21
- platform: process.platform,
22
- hostname: () => os.hostname(),
23
- bootIdentity: () => readBootIdentity({}),
24
- isAlive: ({ pid }) => {
25
- if (!Number.isSafeInteger(pid) || pid <= 0)
26
- return false;
27
- try {
28
- process.kill(pid, 0);
29
- return true;
30
- }
31
- catch (error) {
32
- return !(typeof error === 'object' && error !== null && 'code' in error && error.code === 'ESRCH');
33
- }
34
- },
35
- },
36
- };
37
- }
38
- //# sourceMappingURL=node.js.map
@@ -1,11 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "schemes": [
4
- {
5
- "id": "fly-io",
6
- "prefix": "FlyV1",
7
- "scheme": "FlyV1",
8
- "note": "Fly.io tokens (e.g. FlyV1fm2_..., a macaroon) carry their own Authorization scheme word. Verified live 2026-09-03 against https://api.machines.dev/v1/apps/tovu/machines with two independently generated tokens: 'Authorization: Bearer FlyV1fm2_...' (whole token) returned 401 {\"error\":\"Authenticate: token validation error\"}; 'Authorization: FlyV1 fm2_...' (FlyV1 moved to the scheme, remainder as the value) returned 200 with real machine data. Both tokens behaved identically, so it is a scheme problem, not scope or expiry. The 401's WWW-Authenticate header (Basic realm=\"api.machines.dev\") does not name the real scheme, so it cannot be derived from the server's challenge and must be declared here."
9
- }
10
- ]
11
- }
@@ -1,415 +0,0 @@
1
- import { createSign } from "node:crypto";
2
-
3
- /**
4
- * @file The first-party `github` deployment provider — GitHub App installation auth over the
5
- * guarded ADR-038 `HttpClientPort`.
6
- *
7
- * Why a GitHub App and not `gh` or a stored PAT (ADS deployments debate, all three rounds, 5/5):
8
- * a PAT is a long-lived, human-scoped credential with no per-workspace or per-repository boundary
9
- * in a multi-tenant process; `gh` inherits whatever credential is on the host's global config and
10
- * bypasses the guarded HTTP client entirely. A GitHub App installation token is narrowable to one
11
- * repository and one permission (`deployments: write`) at mint time, and expires in exactly one
12
- * hour regardless of caller-supplied TTL — verified against
13
- * docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app. The App JWT
14
- * used to mint it must be RS256 with `exp` no more than ten minutes past `iat` — verified against
15
- * docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.
16
- *
17
- * `EgressPolicy` cannot pin a host — see the host deployment port's file header. `sendPinned` below is this
18
- * file's answer: the ONLY function allowed to call `http.send`, and it refuses anything whose
19
- * resolved origin is not exactly `https://api.github.com`, so a malformed URL template (or a
20
- * future workspace-supplied GitHub Enterprise base URL, if that is ever added) fails closed instead
21
- * of silently reaching an arbitrary host.
22
- */
23
-
24
- export const GITHUB_DEPLOYMENT_PROVIDER_ID = "github";
25
-
26
- const GITHUB_API_ORIGIN = "https://api.github.com";
27
- const API_VERSION = "2022-11-28";
28
- const DEFAULT_TIMEOUT_MS = 10_000;
29
-
30
- /** GitHub App JWTs: `exp` MUST be no more than 10 minutes past `iat` (verified — see file header).
31
- * 9 minutes leaves margin against clock drift between signing and GitHub's verification. */
32
- const APP_JWT_TTL_SECONDS = 9 * 60;
33
- /** GitHub's own guidance is to back-date `iat` by up to 60s to tolerate clock skew between this
34
- * process and GitHub's clock (verified — see file header). */
35
- const APP_JWT_CLOCK_SKEW_SECONDS = 60;
36
-
37
- function fail(
38
- code,
39
- message,
40
- optional = {}
41
- ) {
42
- return {
43
- code,
44
- message,
45
- retryable: optional.retryable ?? false,
46
- ...(optional.providerStatus === undefined ? {} : { providerStatus: optional.providerStatus }),
47
- };
48
- }
49
-
50
- /**
51
- * Reads and validates `target.config`'s three required GitHub-specific fields.
52
- *
53
- * @complexity O(1).
54
- */
55
- function readGitHubTargetConfig(target) {
56
- const { owner, repo, environmentName } = target.config;
57
- if (typeof owner !== "string" || owner.length === 0) return null;
58
- if (typeof repo !== "string" || repo.length === 0) return null;
59
- if (typeof environmentName !== "string" || environmentName.length === 0) return null;
60
- return { owner, repo, environmentName };
61
- }
62
-
63
- /**
64
- * The origin pin. This is the ONLY call site for `http.send` in this file — every outbound request
65
- * (minting a token, creating a deployment, polling statuses) is routed through it. See the file
66
- * header for why this check cannot be delegated to `EgressPolicy`.
67
- *
68
- * Exported so this guard can be tested directly (see `../__tests__/deployments-provider.test.mjs`'s "sendPinned
69
- * refuses..." case) — every current call site builds its URL through `githubApiUrl()`, which
70
- * already can only resolve under `GITHUB_API_ORIGIN`, so an adapter-level test alone cannot prove
71
- * this check is load-bearing (confirmed by a mutation check: disabling it did not fail any
72
- * adapter-level test). This function is the actual safety boundary for a future call site that
73
- * builds a URL a different way — e.g. a workspace-supplied GitHub Enterprise base URL, if that is
74
- * ever added — so it must be proven correct on its own.
75
- *
76
- * @complexity O(1) beyond the underlying `http.send` call.
77
- */
78
- export async function sendPinned(http, request) {
79
- const url = new URL(request.url);
80
- if (url.origin !== GITHUB_API_ORIGIN) {
81
- throw new Error(
82
- `github deployment adapter refused to send to '${url.origin}' — pinned to ${GITHUB_API_ORIGIN} only`
83
- );
84
- }
85
- return http.send(request);
86
- }
87
-
88
- /** Builds a same-origin URL from a path. Every caller-influenced path segment (owner, repo,
89
- * installation id, provider run ref) MUST already be `encodeURIComponent`-encoded before reaching
90
- * this function — encoding is what stops a value like `../../app/installations/1` from being
91
- * interpreted as a literal dot-segment and resolving outside the intended endpoint: RFC 3986
92
- * dot-segment removal only recognizes literal, unencoded `..` between `/` characters, never a
93
- * percent-encoded `%2E%2E`. */
94
- function githubApiUrl(path) {
95
- return new URL(path, GITHUB_API_ORIGIN).toString();
96
- }
97
-
98
- function githubHeaders(token) {
99
- return {
100
- accept: "application/vnd.github+json",
101
- authorization: `Bearer ${token}`,
102
- "user-agent": "Tovu-CMS",
103
- "x-github-api-version": API_VERSION,
104
- };
105
- }
106
-
107
- function base64url(input) {
108
- return Buffer.from(input).toString("base64url");
109
- }
110
-
111
- /**
112
- * Signs a GitHub App JWT locally. The private key never leaves this process.
113
- *
114
- * @complexity O(1) (one RSA signature over a short, fixed-shape payload).
115
- */
116
- function signGitHubAppJwt(input) {
117
- const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
118
- const payload = base64url(JSON.stringify({ iat: input.issuedAt, exp: input.expiresAt, iss: input.appId }));
119
- const signature = createSign("RSA-SHA256")
120
- .update(`${header}.${payload}`)
121
- .sign(input.privateKeyPem)
122
- .toString("base64url");
123
- return `${header}.${payload}.${signature}`;
124
- }
125
-
126
- function sanitizeMessage(value) {
127
- if (typeof value !== "string") return null;
128
- return value.replace(/[\r\n\0]/g, " ").slice(0, 500);
129
- }
130
-
131
- /**
132
- * Mints a short-lived App JWT, exchanges it for an installation access token narrowed to exactly
133
- * this installation's `deployments: write` permission. Minted fresh on every call rather than
134
- * cached: simpler and correct, at the cost of one extra round trip per deploy action — acceptable
135
- * given deploy actions are infrequent, not a hot path.
136
- *
137
- * @complexity One outbound HTTP request, hard-bounded by `DEFAULT_TIMEOUT_MS`.
138
- */
139
- async function mintInstallationToken(
140
- http,
141
- credentials,
142
- nowMs
143
- ) {
144
- const now = Math.floor(nowMs() / 1000);
145
- const jwt = signGitHubAppJwt({
146
- appId: credentials.appId,
147
- privateKeyPem: credentials.privateKeyPem,
148
- issuedAt: now - APP_JWT_CLOCK_SKEW_SECONDS,
149
- expiresAt: now + APP_JWT_TTL_SECONDS,
150
- });
151
-
152
- let response;
153
- try {
154
- response = await sendPinned(http, {
155
- method: "POST",
156
- url: githubApiUrl(`/app/installations/${encodeURIComponent(credentials.installationId)}/access_tokens`),
157
- headers: { ...githubHeaders(jwt), "content-type": "application/json" },
158
- body: JSON.stringify({ permissions: { deployments: "write" } }),
159
- timeoutMs: DEFAULT_TIMEOUT_MS,
160
- });
161
- } catch (err) {
162
- return { ok: false, error: fail("TRANSPORT_ERROR", err instanceof Error ? err.message : String(err), { retryable: true }) };
163
- }
164
-
165
- if (response.status >= 400) {
166
- return {
167
- ok: false,
168
- error: fail("PROVIDER_ERROR", `GitHub installation token exchange failed: ${response.status}`, {
169
- providerStatus: response.status,
170
- retryable: response.status >= 500,
171
- }),
172
- };
173
- }
174
-
175
- let body;
176
- try {
177
- body = JSON.parse(response.bodyText);
178
- } catch {
179
- return { ok: false, error: fail("PROVIDER_RESPONSE_INVALID", "GitHub returned invalid JSON minting an installation token") };
180
- }
181
- // Token formats are opaque; do not assume a fixed prefix or length.
182
- if (typeof body.token !== "string" || body.token.length === 0) {
183
- return { ok: false, error: fail("PROVIDER_RESPONSE_INVALID", "GitHub returned an empty installation token") };
184
- }
185
- return { ok: true, token: body.token };
186
- }
187
-
188
- function requireCredentials(
189
- credentials
190
- ) {
191
- const { appId, installationId, privateKeyPem } = credentials;
192
- if (!appId || !installationId || !privateKeyPem) return null;
193
- return { appId, installationId, privateKeyPem };
194
- }
195
-
196
- /**
197
- * Sends the `POST .../deployments` call and validates its response — split out of `startRun` so
198
- * the pre-checks (target config, release shape, credentials) and the HTTP round-trip each carry
199
- * only their own branches. `release` is the two fields already narrowed out of
200
- * `input.release` by `startRun`'s own `kind !== "git-revision"` guard.
201
- */
202
- async function createGitHubDeployment(
203
- ctx,
204
- token,
205
- config,
206
- release
207
- ) {
208
- let response;
209
- try {
210
- response = await sendPinned(ctx.httpClient, {
211
- method: "POST",
212
- url: githubApiUrl(`/repos/${encodeURIComponent(config.owner)}/${encodeURIComponent(config.repo)}/deployments`),
213
- headers: { ...githubHeaders(token), "content-type": "application/json" },
214
- body: JSON.stringify({
215
- ref: release.commitSha,
216
- environment: config.environmentName,
217
- description: `Tovu deployment of release ${release.releaseId}`,
218
- auto_merge: false,
219
- required_contexts: [],
220
- transient_environment: false,
221
- production_environment: config.environmentName === "production",
222
- }),
223
- timeoutMs: DEFAULT_TIMEOUT_MS,
224
- });
225
- } catch (err) {
226
- return { ok: false, error: fail("TRANSPORT_ERROR", err instanceof Error ? err.message : String(err), { retryable: true }) };
227
- }
228
-
229
- if (response.status >= 400) {
230
- return {
231
- ok: false,
232
- error: fail("PROVIDER_ERROR", `GitHub deployment create failed: ${response.status}`, {
233
- providerStatus: response.status,
234
- retryable: response.status >= 500,
235
- }),
236
- };
237
- }
238
-
239
- let body;
240
- try {
241
- body = JSON.parse(response.bodyText);
242
- } catch {
243
- return { ok: false, error: fail("PROVIDER_RESPONSE_INVALID", "GitHub returned invalid JSON creating a deployment") };
244
- }
245
- if (!Number.isSafeInteger(body.id) || (body.id) <= 0) {
246
- return { ok: false, error: fail("PROVIDER_RESPONSE_INVALID", "GitHub returned an invalid deployment id") };
247
- }
248
-
249
- return { ok: true, providerRunRef: String(body.id), reconciliation: "callback" };
250
- }
251
-
252
- /**
253
- * Creates a GitHub Deployment for an existing commit. Does NOT wait for (or fabricate) evidence
254
- * that a build or deploy has started — GitHub's own docs state it does not access or deploy to the
255
- * target servers itself; creating a deployment only dispatches a `deployment` event to whatever is
256
- * listening.
257
- *
258
- * @complexity Two outbound HTTP requests (mint token, create deployment), each hard-bounded by
259
- * `DEFAULT_TIMEOUT_MS`.
260
- */
261
- async function startRun(input, ctx) {
262
- const config = readGitHubTargetConfig(input.target);
263
- if (!config) {
264
- return { ok: false, error: fail("INVALID_TARGET_CONFIG", "github target is missing owner/repo/environmentName") };
265
- }
266
- if (input.release.source.kind !== "git-revision") {
267
- // The honesty constraint, enforced at the one place it can be: this adapter promotes an
268
- // EXISTING commit. It cannot manufacture one from an "external-artifact" release — the host's CLI
269
- // has no build or export command.
270
- return {
271
- ok: false,
272
- error: fail("INVALID_RELEASE", "github deployment target requires a git-revision release (commit sha), not an external artifact"),
273
- };
274
- }
275
- const credentials = requireCredentials(ctx.credentials);
276
- if (!credentials) {
277
- return { ok: false, error: fail("NO_CREDENTIALS_CONFIGURED", "github deployment target is missing appId/installationId/privateKeyPem") };
278
- }
279
-
280
- const token = await mintInstallationToken(ctx.httpClient, credentials, ctx.now);
281
- if (!token.ok) return { ok: false, error: token.error };
282
-
283
- return createGitHubDeployment(ctx, token.token, config, {
284
- commitSha: input.release.source.commitSha,
285
- releaseId: input.release.id,
286
- });
287
- }
288
-
289
- /**
290
- * GitHub's real deployment-status `state` enum has SEVEN values — `error`, `failure`, `inactive`,
291
- * `in_progress`, `queued`, `pending`, `success` — verified against
292
- * docs.github.com/en/rest/deployments/statuses. Every value is handled explicitly here; an
293
- * unrecognized future value falls to `"running"` (never a terminal state), so it can never be
294
- * mistaken for success or a permanent failure.
295
- *
296
- * GitHub never fires a `deployment_status` WEBHOOK for `inactive` (verified against
297
- * docs.github.com/en/webhooks/webhook-events-and-payloads#deployment_status) — so this mapping is
298
- * the only place `inactive` is ever observed, and only via `pollRun`, never a callback.
299
- *
300
- * @complexity O(1).
301
- */
302
- export function mapGitHubDeploymentStatus(status) {
303
- const providerStatusId = String(status.id);
304
- const message = sanitizeMessage(status.description);
305
- switch (status.state) {
306
- case "success":
307
- return { status: "succeeded", providerStatusId, message };
308
- case "failure":
309
- case "error":
310
- return { status: "failed", providerStatusId, message };
311
- case "inactive":
312
- return { status: "cancelled", providerStatusId, message };
313
- case "in_progress":
314
- return { status: "running", providerStatusId, message };
315
- case "queued":
316
- case "pending":
317
- return { status: "queued", providerStatusId, message };
318
- default:
319
- return { status: "running", providerStatusId, message };
320
- }
321
- }
322
-
323
- /**
324
- * Sends the `GET .../statuses` call and resolves the latest status from it — split out of
325
- * `pollRun` for the same "pre-checks vs. HTTP round-trip" reason as `createGitHubDeployment`. Does
326
- * NOT assume the response is newest-first — GitHub's docs describe pagination for this endpoint but
327
- * state no response order (verified against docs.github.com/en/rest/deployments/statuses). Status
328
- * ids are assigned monotonically, so the correct status is the one with the greatest `id`,
329
- * independent of array position.
330
- */
331
- async function pollGitHubDeploymentStatuses(
332
- ctx,
333
- token,
334
- config,
335
- providerRunRef
336
- ) {
337
- let response;
338
- try {
339
- response = await sendPinned(ctx.httpClient, {
340
- method: "GET",
341
- url: githubApiUrl(
342
- `/repos/${encodeURIComponent(config.owner)}/${encodeURIComponent(config.repo)}/deployments/` +
343
- `${encodeURIComponent(providerRunRef)}/statuses?per_page=100`
344
- ),
345
- headers: githubHeaders(token),
346
- timeoutMs: DEFAULT_TIMEOUT_MS,
347
- });
348
- } catch (err) {
349
- return { ok: false, error: fail("TRANSPORT_ERROR", err instanceof Error ? err.message : String(err), { retryable: true }) };
350
- }
351
-
352
- if (response.status >= 400) {
353
- return {
354
- ok: false,
355
- error: fail("PROVIDER_ERROR", `GitHub deployment status poll failed: ${response.status}`, {
356
- providerStatus: response.status,
357
- retryable: response.status >= 500,
358
- }),
359
- };
360
- }
361
-
362
- let statuses;
363
- try {
364
- const parsed = JSON.parse(response.bodyText);
365
- if (!Array.isArray(parsed)) throw new Error("not an array");
366
- statuses = parsed;
367
- } catch {
368
- return { ok: false, error: fail("PROVIDER_RESPONSE_INVALID", "GitHub returned a malformed statuses response") };
369
- }
370
-
371
- if (statuses.length === 0) {
372
- return { ok: true, update: { status: "queued", providerStatusId: null, message: null } };
373
- }
374
-
375
- const latest = statuses.reduce((best, candidate) => (candidate.id > best.id ? candidate : best));
376
- return { ok: true, update: mapGitHubDeploymentStatus(latest) };
377
- }
378
-
379
- /**
380
- * Polls the latest deployment status.
381
- *
382
- * @complexity One outbound HTTP request (plus the token mint) and a single linear scan over the
383
- * returned statuses (bounded by `per_page=100`), each hard-bounded by `DEFAULT_TIMEOUT_MS`.
384
- */
385
- async function pollRun(input, ctx) {
386
- const config = readGitHubTargetConfig(input.target);
387
- if (!config) {
388
- return { ok: false, error: fail("INVALID_TARGET_CONFIG", "github target is missing owner/repo/environmentName") };
389
- }
390
- if (!/^[1-9]\d*$/.test(input.providerRunRef)) {
391
- return { ok: false, error: fail("INVALID_TARGET_CONFIG", "providerRunRef is not a github deployment id") };
392
- }
393
- const credentials = requireCredentials(ctx.credentials);
394
- if (!credentials) {
395
- return { ok: false, error: fail("NO_CREDENTIALS_CONFIGURED", "github deployment target is missing appId/installationId/privateKeyPem") };
396
- }
397
-
398
- const token = await mintInstallationToken(ctx.httpClient, credentials, ctx.now);
399
- if (!token.ok) return { ok: false, error: token.error };
400
-
401
- return pollGitHubDeploymentStatuses(ctx, token.token, config, input.providerRunRef);
402
- }
403
-
404
- /**
405
- * Builds the `github` deployment provider adapter. Stateless — safe to construct once and reuse
406
- * across requests; all per-call state lives in the `ctx` passed to each method.
407
- */
408
- export function createGitHubDeploymentProvider() {
409
- return {
410
- id: GITHUB_DEPLOYMENT_PROVIDER_ID,
411
- credentialKeys: ["appId", "installationId", "privateKeyPem"],
412
- startRun,
413
- pollRun,
414
- };
415
- }
@@ -1,29 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "providers": [
4
- {
5
- "id": "s3_compatible",
6
- "label": "S3-compatible storage",
7
- "module": "object-stores/s3-compatible.mjs",
8
- "env": {
9
- "selector": "s3",
10
- "settings": {
11
- "bucket": "TOVU_S3_BUCKET",
12
- "keyPrefix": "TOVU_S3_KEY_PREFIX"
13
- },
14
- "credentialFields": {
15
- "accessKeyId": "TOVU_S3_ACCESS_KEY_ID",
16
- "region": "TOVU_S3_REGION",
17
- "endpoint": "TOVU_S3_ENDPOINT"
18
- },
19
- "secret": "TOVU_S3_SECRET_ACCESS_KEY",
20
- "required": [
21
- "TOVU_S3_BUCKET",
22
- "TOVU_S3_REGION",
23
- "TOVU_S3_ACCESS_KEY_ID",
24
- "TOVU_S3_SECRET_ACCESS_KEY"
25
- ]
26
- }
27
- }
28
- ]
29
- }