@mintlify/cli 4.0.1813 → 4.1.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.
Files changed (274) hide show
  1. package/dist/assets/export-scripts/README.classic.md +15 -0
  2. package/dist/assets/export-scripts/README.md +14 -0
  3. package/dist/assets/export-scripts/serve.js +114 -0
  4. package/dist/assets/export-scripts/start-docs.bat +10 -0
  5. package/dist/assets/export-scripts/start-docs.sh +9 -0
  6. package/dist/assets/og/Inter-Bold.ttf +0 -0
  7. package/dist/assets/og/Inter-Medium.ttf +0 -0
  8. package/dist/assets/og/Inter-Regular.ttf +0 -0
  9. package/dist/assets/og/Inter-SemiBold.ttf +0 -0
  10. package/dist/assets/og/PaperMono-Regular.ttf +0 -0
  11. package/dist/assets/og/index_bg.wasm +0 -0
  12. package/dist/assets/openChrome.applescript +94 -0
  13. package/dist/assets/socket.io/socket.io.esm.min.js +7 -0
  14. package/dist/assets/socket.io/socket.io.esm.min.js.map +1 -0
  15. package/dist/assets/socket.io/socket.io.js +4907 -0
  16. package/dist/assets/socket.io/socket.io.js.map +1 -0
  17. package/dist/assets/socket.io/socket.io.min.js +7 -0
  18. package/dist/assets/socket.io/socket.io.min.js.map +1 -0
  19. package/dist/assets/socket.io/socket.io.msgpack.min.js +7 -0
  20. package/dist/assets/socket.io/socket.io.msgpack.min.js.map +1 -0
  21. package/dist/assets/xdg-open +1066 -0
  22. package/dist/assets/yargs-locales/be.json +46 -0
  23. package/dist/assets/yargs-locales/cs.json +51 -0
  24. package/dist/assets/yargs-locales/de.json +46 -0
  25. package/dist/assets/yargs-locales/en.json +55 -0
  26. package/dist/assets/yargs-locales/es.json +46 -0
  27. package/dist/assets/yargs-locales/fi.json +49 -0
  28. package/dist/assets/yargs-locales/fr.json +53 -0
  29. package/dist/assets/yargs-locales/hi.json +49 -0
  30. package/dist/assets/yargs-locales/hu.json +46 -0
  31. package/dist/assets/yargs-locales/id.json +50 -0
  32. package/dist/assets/yargs-locales/it.json +46 -0
  33. package/dist/assets/yargs-locales/ja.json +51 -0
  34. package/dist/assets/yargs-locales/ko.json +49 -0
  35. package/dist/assets/yargs-locales/nb.json +44 -0
  36. package/dist/assets/yargs-locales/nl.json +49 -0
  37. package/dist/assets/yargs-locales/nn.json +44 -0
  38. package/dist/assets/yargs-locales/pirate.json +13 -0
  39. package/dist/assets/yargs-locales/pl.json +49 -0
  40. package/dist/assets/yargs-locales/pt.json +45 -0
  41. package/dist/assets/yargs-locales/pt_BR.json +48 -0
  42. package/dist/assets/yargs-locales/ru.json +51 -0
  43. package/dist/assets/yargs-locales/th.json +46 -0
  44. package/dist/assets/yargs-locales/tr.json +48 -0
  45. package/dist/assets/yargs-locales/uk_UA.json +51 -0
  46. package/dist/assets/yargs-locales/uz.json +52 -0
  47. package/dist/assets/yargs-locales/zh_CN.json +48 -0
  48. package/dist/assets/yargs-locales/zh_TW.json +51 -0
  49. package/dist/converter-d8O3xkdU.js +102 -0
  50. package/dist/devtools-CGNZQKFV.js +24 -0
  51. package/dist/index.js +8 -0
  52. package/dist/rolldown-runtime-CEAe2Uac.js +7 -0
  53. package/dist/schemas-CBsmCNpK.js +372 -0
  54. package/dist/start.js +2310 -0
  55. package/package.json +38 -31
  56. package/.oxlintrc.json +0 -5
  57. package/.prettierignore +0 -2
  58. package/.turbo/turbo-build.log +0 -1
  59. package/CONTRIBUTING.md +0 -45
  60. package/__test__/agent-auth.test.ts +0 -114
  61. package/__test__/agent-claim.test.ts +0 -164
  62. package/__test__/agent-credentials.test.ts +0 -149
  63. package/__test__/agent-deployment.test.ts +0 -106
  64. package/__test__/agent-setup-config.test.ts +0 -324
  65. package/__test__/agent-setup.test.ts +0 -207
  66. package/__test__/agent.test.ts +0 -64
  67. package/__test__/analytics/client.test.ts +0 -180
  68. package/__test__/analytics/dates.test.ts +0 -12
  69. package/__test__/analytics/filters.test.ts +0 -116
  70. package/__test__/analytics/format.test.ts +0 -137
  71. package/__test__/authenticatedFetch.test.ts +0 -182
  72. package/__test__/brokenLinks.test.ts +0 -283
  73. package/__test__/checkPort.test.ts +0 -92
  74. package/__test__/deploy-github-actions.test.ts +0 -202
  75. package/__test__/deploy-github-setup.test.ts +0 -240
  76. package/__test__/deploy-instructions.test.ts +0 -155
  77. package/__test__/deploy.test.ts +0 -202
  78. package/__test__/feedback.test.ts +0 -34
  79. package/__test__/foreignSyntax.test.ts +0 -73
  80. package/__test__/format.test.ts +0 -72
  81. package/__test__/helpers.test.ts +0 -52
  82. package/__test__/init.test.ts +0 -119
  83. package/__test__/instructions.test.ts +0 -53
  84. package/__test__/keyring.test.ts +0 -82
  85. package/__test__/mdxAccessibility.test.ts +0 -81
  86. package/__test__/migrate.test.ts +0 -186
  87. package/__test__/openApiCheck.test.ts +0 -185
  88. package/__test__/pathValidation.test.ts +0 -25
  89. package/__test__/resolveFiles.test.ts +0 -70
  90. package/__test__/sessionId.test.ts +0 -46
  91. package/__test__/signup.test.ts +0 -36
  92. package/__test__/update.test.ts +0 -117
  93. package/__test__/utils.ts +0 -25
  94. package/__test__/validateCommand.test.ts +0 -647
  95. package/__test__/validateEngine.test.ts +0 -245
  96. package/__test__/validateRules.test.ts +0 -1275
  97. package/__test__/welcome.test.ts +0 -15
  98. package/__test__/workflows/client.test.ts +0 -126
  99. package/bin/accessibility.js +0 -111
  100. package/bin/accessibilityCheck.js +0 -82
  101. package/bin/addDomain.js +0 -130
  102. package/bin/agent-auth.js +0 -104
  103. package/bin/agent-claim.js +0 -97
  104. package/bin/agent-credentials.js +0 -124
  105. package/bin/agent-deployment.js +0 -96
  106. package/bin/agent-http.js +0 -45
  107. package/bin/agent-setup-config.js +0 -141
  108. package/bin/agent-setup.js +0 -146
  109. package/bin/agent.js +0 -42
  110. package/bin/analytics/client.js +0 -60
  111. package/bin/analytics/dates.js +0 -6
  112. package/bin/analytics/filters.js +0 -27
  113. package/bin/analytics/format.js +0 -13
  114. package/bin/analytics/index.js +0 -496
  115. package/bin/analytics/output.js +0 -75
  116. package/bin/analytics/types.js +0 -1
  117. package/bin/authenticatedFetch.js +0 -46
  118. package/bin/brokenLinks.js +0 -122
  119. package/bin/callbackServer.js +0 -65
  120. package/bin/cli.js +0 -813
  121. package/bin/comingSoon.js +0 -26
  122. package/bin/config.js +0 -78
  123. package/bin/constants.js +0 -16
  124. package/bin/deploy-base.js +0 -20
  125. package/bin/deploy-github-actions.js +0 -102
  126. package/bin/deploy-github-setup.js +0 -165
  127. package/bin/deploy-instructions.js +0 -71
  128. package/bin/deploy.js +0 -123
  129. package/bin/feedback.js +0 -36
  130. package/bin/format.js +0 -121
  131. package/bin/helpers.js +0 -238
  132. package/bin/idToken.js +0 -14
  133. package/bin/index.js +0 -102
  134. package/bin/init.js +0 -182
  135. package/bin/instructions.js +0 -101
  136. package/bin/keyring.js +0 -78
  137. package/bin/login.js +0 -123
  138. package/bin/logout.js +0 -18
  139. package/bin/mdxAccessibility.js +0 -113
  140. package/bin/mdxLinter.js +0 -55
  141. package/bin/middlewares/subdomainMiddleware.js +0 -28
  142. package/bin/middlewares/telemetryMiddleware.js +0 -61
  143. package/bin/migrate.js +0 -54
  144. package/bin/og.js +0 -145
  145. package/bin/openApiCheck.js +0 -99
  146. package/bin/resolveFiles.js +0 -114
  147. package/bin/score/client.js +0 -40
  148. package/bin/score/index.js +0 -211
  149. package/bin/score/types.js +0 -1
  150. package/bin/signup.js +0 -118
  151. package/bin/start.js +0 -36
  152. package/bin/status.js +0 -106
  153. package/bin/telemetry/client.js +0 -53
  154. package/bin/telemetry/distinctId.js +0 -68
  155. package/bin/telemetry/sessionId.js +0 -36
  156. package/bin/telemetry/track.js +0 -149
  157. package/bin/templates.js +0 -127
  158. package/bin/tokenRefresh.js +0 -50
  159. package/bin/tsconfig.build.tsbuildinfo +0 -1
  160. package/bin/update.js +0 -65
  161. package/bin/validate/command.js +0 -127
  162. package/bin/validate/engine.js +0 -154
  163. package/bin/validate/files.js +0 -163
  164. package/bin/validate/mdx.js +0 -238
  165. package/bin/validate/output.js +0 -44
  166. package/bin/validate/report.js +0 -11
  167. package/bin/validate/rules/build.js +0 -102
  168. package/bin/validate/rules/content/duplicateH1.js +0 -57
  169. package/bin/validate/rules/content/foreignSyntax.js +0 -120
  170. package/bin/validate/rules/content/katex.js +0 -34
  171. package/bin/validate/rules/content/missingSnippet.js +0 -34
  172. package/bin/validate/rules/content/undefinedVariable.js +0 -13
  173. package/bin/validate/rules/content/unknownComponent.js +0 -121
  174. package/bin/validate/rules/content/voidTags.js +0 -38
  175. package/bin/validate/rules/index.js +0 -21
  176. package/bin/validate/rules/openapi.js +0 -50
  177. package/bin/validate/rules/parseError.js +0 -7
  178. package/bin/validate/site.js +0 -57
  179. package/bin/validate/types.js +0 -1
  180. package/bin/vendor/converter.js +0 -30882
  181. package/bin/welcome.js +0 -108
  182. package/bin/workflows/client.js +0 -34
  183. package/bin/workflows/index.js +0 -269
  184. package/bin/workflows/types.js +0 -11
  185. package/scripts/bundle-converter.mjs +0 -26
  186. package/scripts/generate-logo.mjs +0 -79
  187. package/src/accessibility.ts +0 -180
  188. package/src/accessibilityCheck.tsx +0 -150
  189. package/src/addDomain.tsx +0 -206
  190. package/src/agent-auth.ts +0 -119
  191. package/src/agent-claim.ts +0 -124
  192. package/src/agent-credentials.ts +0 -104
  193. package/src/agent-deployment.ts +0 -116
  194. package/src/agent-http.ts +0 -34
  195. package/src/agent-setup-config.ts +0 -144
  196. package/src/agent-setup.ts +0 -165
  197. package/src/agent.ts +0 -56
  198. package/src/analytics/client.ts +0 -153
  199. package/src/analytics/dates.ts +0 -6
  200. package/src/analytics/filters.ts +0 -50
  201. package/src/analytics/format.ts +0 -13
  202. package/src/analytics/index.tsx +0 -599
  203. package/src/analytics/output.ts +0 -99
  204. package/src/analytics/types.ts +0 -145
  205. package/src/authenticatedFetch.ts +0 -42
  206. package/src/brokenLinks.tsx +0 -152
  207. package/src/callbackServer.ts +0 -64
  208. package/src/cli.tsx +0 -1105
  209. package/src/comingSoon.tsx +0 -29
  210. package/src/config.ts +0 -75
  211. package/src/constants.ts +0 -28
  212. package/src/deploy-base.ts +0 -18
  213. package/src/deploy-github-actions.ts +0 -139
  214. package/src/deploy-github-setup.ts +0 -189
  215. package/src/deploy-instructions.ts +0 -76
  216. package/src/deploy.ts +0 -165
  217. package/src/feedback.tsx +0 -31
  218. package/src/format.tsx +0 -82
  219. package/src/helpers.tsx +0 -279
  220. package/src/idToken.ts +0 -17
  221. package/src/index.ts +0 -109
  222. package/src/init.tsx +0 -237
  223. package/src/instructions.ts +0 -99
  224. package/src/keyring.ts +0 -65
  225. package/src/login.tsx +0 -166
  226. package/src/logout.tsx +0 -8
  227. package/src/mdxAccessibility.ts +0 -134
  228. package/src/mdxLinter.tsx +0 -88
  229. package/src/middlewares/subdomainMiddleware.ts +0 -20
  230. package/src/middlewares/telemetryMiddleware.ts +0 -55
  231. package/src/migrate.ts +0 -76
  232. package/src/og.tsx +0 -185
  233. package/src/openApiCheck.tsx +0 -125
  234. package/src/resolveFiles.ts +0 -101
  235. package/src/score/client.ts +0 -36
  236. package/src/score/index.tsx +0 -205
  237. package/src/score/types.ts +0 -15
  238. package/src/signup.tsx +0 -172
  239. package/src/start.ts +0 -27
  240. package/src/status.tsx +0 -129
  241. package/src/telemetry/client.ts +0 -46
  242. package/src/telemetry/distinctId.ts +0 -70
  243. package/src/telemetry/sessionId.ts +0 -40
  244. package/src/telemetry/track.ts +0 -163
  245. package/src/templates.tsx +0 -143
  246. package/src/tokenRefresh.ts +0 -53
  247. package/src/update.tsx +0 -89
  248. package/src/validate/command.tsx +0 -135
  249. package/src/validate/engine.ts +0 -210
  250. package/src/validate/files.ts +0 -249
  251. package/src/validate/mdx.ts +0 -290
  252. package/src/validate/output.tsx +0 -76
  253. package/src/validate/report.ts +0 -40
  254. package/src/validate/rules/build.ts +0 -146
  255. package/src/validate/rules/content/duplicateH1.ts +0 -78
  256. package/src/validate/rules/content/foreignSyntax.ts +0 -144
  257. package/src/validate/rules/content/katex.ts +0 -33
  258. package/src/validate/rules/content/missingSnippet.ts +0 -36
  259. package/src/validate/rules/content/undefinedVariable.ts +0 -20
  260. package/src/validate/rules/content/unknownComponent.ts +0 -130
  261. package/src/validate/rules/content/voidTags.ts +0 -43
  262. package/src/validate/rules/index.ts +0 -23
  263. package/src/validate/rules/openapi.ts +0 -59
  264. package/src/validate/rules/parseError.ts +0 -9
  265. package/src/validate/site.ts +0 -53
  266. package/src/validate/types.ts +0 -102
  267. package/src/vendor/converter.ts +0 -1
  268. package/src/welcome.ts +0 -154
  269. package/src/workflows/client.ts +0 -39
  270. package/src/workflows/index.tsx +0 -287
  271. package/src/workflows/types.ts +0 -73
  272. package/tsconfig.build.json +0 -4
  273. package/tsconfig.json +0 -10
  274. package/vitest.config.ts +0 -9
@@ -1,124 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { createHash } from 'node:crypto';
22
- import fs from 'node:fs/promises';
23
- import path from 'node:path';
24
- import { z } from 'zod';
25
- import { CONFIG_DIR } from './constants.js';
26
- import { getKeytar } from './keyring.js';
27
- const service = 'mintlify-agent';
28
- const fallbackFile = () => path.join(CONFIG_DIR, 'agent-credentials.json');
29
- export const agentCredentialsSchema = z.object({
30
- registrationId: z.string().min(1),
31
- issuer: z.url(),
32
- assertion: z.string().min(1),
33
- claimToken: z.string().min(1),
34
- claimVerified: z.boolean().optional(),
35
- accessToken: z.string().min(1).optional(),
36
- accessTokenExpiresAt: z.number().optional(),
37
- });
38
- function projectAccount(apiUrl, directory) {
39
- return `project:${createHash('sha256')
40
- .update(JSON.stringify([new URL(apiUrl).origin, path.resolve(directory)]))
41
- .digest('hex')}`;
42
- }
43
- function registrationAccount(apiUrl, registrationId) {
44
- return `${new URL(apiUrl).origin}:${registrationId}`;
45
- }
46
- function readFallback() {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- try {
49
- return z
50
- .record(z.string(), z.string())
51
- .parse(JSON.parse(yield fs.readFile(fallbackFile(), 'utf-8')));
52
- }
53
- catch (_a) {
54
- return {};
55
- }
56
- });
57
- }
58
- function writeFallback(entries) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- yield fs.mkdir(CONFIG_DIR, { recursive: true });
61
- const temp = `${fallbackFile()}.${process.pid}.tmp`;
62
- yield fs.writeFile(temp, JSON.stringify(entries, null, 2), { mode: 0o600 });
63
- yield fs.chmod(temp, 0o600);
64
- yield fs.rename(temp, fallbackFile());
65
- });
66
- }
67
- function getSecret(account) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- let keyringError;
70
- try {
71
- const value = yield (yield getKeytar()).getPassword(service, account);
72
- if (value)
73
- return value;
74
- }
75
- catch (error) {
76
- keyringError = error;
77
- }
78
- const value = (yield readFallback())[account];
79
- if (value)
80
- return value;
81
- if (keyringError)
82
- throw keyringError;
83
- return null;
84
- });
85
- }
86
- function setSecret(account, value) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- try {
89
- yield (yield getKeytar()).setPassword(service, account, value);
90
- }
91
- catch (_a) {
92
- yield writeFallback(Object.assign(Object.assign({}, (yield readFallback())), { [account]: value }));
93
- yield getKeytar()
94
- .then((keytar) => keytar.deletePassword(service, account))
95
- .catch(() => { });
96
- return;
97
- }
98
- const _b = yield readFallback(), _c = account, stale = _b[_c], rest = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
99
- if (stale)
100
- yield writeFallback(rest).catch(() => { });
101
- });
102
- }
103
- export function loadAgentCredentials(apiUrl, directory) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- const registrationId = yield getSecret(projectAccount(apiUrl, directory));
106
- if (!registrationId)
107
- return null;
108
- const value = yield getSecret(registrationAccount(apiUrl, registrationId));
109
- if (!value)
110
- throw new Error('Saved agent credentials are missing. Use --new to create another site.');
111
- const credentials = agentCredentialsSchema.parse(JSON.parse(value));
112
- if (credentials.registrationId !== registrationId) {
113
- throw new Error('Saved agent credentials do not match this project.');
114
- }
115
- return credentials;
116
- });
117
- }
118
- export function saveAgentCredentials(apiUrl, directory, credentials) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const value = agentCredentialsSchema.parse(credentials);
121
- yield setSecret(registrationAccount(apiUrl, value.registrationId), JSON.stringify(value));
122
- yield setSecret(projectAccount(apiUrl, directory), value.registrationId);
123
- });
124
- }
@@ -1,96 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { setTimeout } from 'node:timers/promises';
11
- import { z } from 'zod';
12
- import { agentRequest, agentResponse } from './agent-http.js';
13
- const readySchema = z.object({
14
- status: z.literal('ready'),
15
- deploymentId: z.string().min(1),
16
- subdomain: z.string().min(1),
17
- remote: z.url(),
18
- branch: z.literal('main'),
19
- expiresAt: z.iso.datetime(),
20
- orgSlug: z.string().min(1).optional(),
21
- });
22
- const existingSchema = z.discriminatedUnion('status', [
23
- readySchema.extend({ code: z.literal('deployment_already_exists') }),
24
- z.object({
25
- status: z.literal('provisioning'),
26
- code: z.literal('deployment_already_exists'),
27
- deploymentId: z.string().optional(),
28
- subdomain: z.string().optional(),
29
- }),
30
- z.object({
31
- status: z.literal('expired'),
32
- code: z.enum(['deployment_already_exists', 'deployment_claim_expired']),
33
- deploymentId: z.string(),
34
- subdomain: z.string(),
35
- expiresAt: z.iso.datetime().optional(),
36
- }),
37
- ]);
38
- const writeTokenSchema = z.object({
39
- remote: z.url(),
40
- branch: z.literal('main'),
41
- token: z.string().min(1),
42
- tokenExpiresAt: z.iso.datetime(),
43
- });
44
- const trustedReposSchema = z.object({
45
- subdomain: z.string().min(1),
46
- trustedRepos: z.array(z.object({ repositoryId: z.string(), repository: z.string(), branch: z.string() })),
47
- });
48
- export function provisionAgentSite(apiUrl, accessToken, settings) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- for (let attempt = 0; attempt < 4; attempt++) {
51
- const response = yield agentRequest(`${apiUrl}/api/agent/deployments/provision`, {
52
- method: 'POST',
53
- headers: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },
54
- body: JSON.stringify(Object.assign(Object.assign({}, settings), { docsPath: '' })),
55
- });
56
- if (response.status !== 409) {
57
- return Object.assign(Object.assign({}, (yield agentResponse(response, readySchema))), { created: true });
58
- }
59
- const body = yield response.json().catch(() => null);
60
- const parsed = existingSchema.safeParse(body);
61
- if (!parsed.success)
62
- throw new Error('The deployment service returned an unexpected response.');
63
- if (parsed.data.status !== 'provisioning')
64
- return Object.assign(Object.assign({}, parsed.data), { created: false });
65
- if (attempt < 3)
66
- yield setTimeout(1000 * (attempt + 1));
67
- }
68
- throw new Error('Your site is still provisioning. Run the same command again.');
69
- });
70
- }
71
- export function getAgentWriteToken(apiUrl, accessToken) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- return agentResponse(yield agentRequest(`${apiUrl}/api/agent/deployments/token`, {
74
- method: 'POST',
75
- headers: { Authorization: `Bearer ${accessToken}` },
76
- }), writeTokenSchema);
77
- });
78
- }
79
- export function getGithubActionsWriteToken(apiUrl, oidcToken, subdomain) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- return agentResponse(yield agentRequest(`${apiUrl}/api/agent/deployments/github-actions/token`, {
82
- method: 'POST',
83
- headers: { Authorization: `Bearer ${oidcToken}`, 'Content-Type': 'application/json' },
84
- body: JSON.stringify({ subdomain }),
85
- }), writeTokenSchema);
86
- });
87
- }
88
- export function trustGithubRepo(apiUrl, accessToken, repo) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- return agentResponse(yield agentRequest(`${apiUrl}/api/agent/deployments/trusted-repos`, {
91
- method: 'POST',
92
- headers: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },
93
- body: JSON.stringify(repo),
94
- }), trustedReposSchema);
95
- });
96
- }
package/bin/agent-http.js DELETED
@@ -1,45 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { z } from 'zod';
11
- const errorSchema = z.object({ code: z.string().optional(), error: z.string().optional() });
12
- export class AgentApiError extends Error {
13
- constructor(status, code) {
14
- super(`Agent request failed (HTTP ${status}).${code ? ` Code: ${code}.` : ''}`);
15
- this.status = status;
16
- this.code = code;
17
- }
18
- }
19
- export function agentRequest(url, init) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- try {
22
- const timeout = AbortSignal.timeout(30000);
23
- const signal = (init === null || init === void 0 ? void 0 : init.signal) ? AbortSignal.any([init.signal, timeout]) : timeout;
24
- return yield fetch(url, Object.assign(Object.assign({}, init), { redirect: 'error', signal }));
25
- }
26
- catch (_a) {
27
- throw new Error('Could not reach the agent service. Retry the same command.');
28
- }
29
- });
30
- }
31
- export function agentResponse(response, schema) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- var _a, _b;
34
- const body = yield response.json().catch(() => null);
35
- if (!response.ok) {
36
- const error = errorSchema.safeParse(body);
37
- const code = error.success ? ((_a = error.data.code) !== null && _a !== void 0 ? _a : error.data.error) : undefined;
38
- throw new AgentApiError(response.status, (_b = code === null || code === void 0 ? void 0 : code.match(/^[a-z_]{1,80}$/)) === null || _b === void 0 ? void 0 : _b[0]);
39
- }
40
- const parsed = schema.safeParse(body);
41
- if (!parsed.success)
42
- throw new Error('The agent service returned an unexpected response.');
43
- return parsed.data;
44
- });
45
- }
@@ -1,141 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { applyEdits, modify, parse } from 'jsonc-parser';
11
- import { randomUUID } from 'node:crypto';
12
- import fs from 'node:fs/promises';
13
- import path from 'node:path';
14
- import { parse as parseToml } from 'smol-toml';
15
- export const ADMIN_MCP_NAME = 'mintlify-admin';
16
- export const ADMIN_MCP_URL = 'https://mcp.mintlify.com';
17
- function isRecord(value) {
18
- return typeof value === 'object' && value !== null && !Array.isArray(value);
19
- }
20
- function readConfig(file) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- try {
23
- return yield fs.readFile(file, 'utf8');
24
- }
25
- catch (error) {
26
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
27
- return undefined;
28
- throw error;
29
- }
30
- });
31
- }
32
- function configPath(agent, options) {
33
- var _a;
34
- const env = (_a = options.env) !== null && _a !== void 0 ? _a : process.env;
35
- if (agent === 'codex') {
36
- let directory = path.join(options.cwd, '.codex');
37
- if (options.global)
38
- directory = env.CODEX_HOME || path.join(options.homeDir, '.codex');
39
- return path.join(directory, 'config.toml');
40
- }
41
- if (agent === 'cursor') {
42
- const directory = options.global ? options.homeDir : options.cwd;
43
- return path.join(directory, '.cursor', 'mcp.json');
44
- }
45
- if (options.global) {
46
- if (env.CLAUDE_CONFIG_DIR) {
47
- throw new Error('CLAUDE_CONFIG_DIR is set. Configure Claude Code with: claude mcp add --scope user --transport http mintlify-admin https://mcp.mintlify.com');
48
- }
49
- return path.join(options.homeDir, '.claude.json');
50
- }
51
- return path.join(options.cwd, '.mcp.json');
52
- }
53
- export function prepareMcpConfig(agent, options) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- const requestedPath = configPath(agent, options);
56
- const file = yield fs.realpath(requestedPath).catch((error) => {
57
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
58
- return requestedPath;
59
- throw error;
60
- });
61
- const original = yield readConfig(file);
62
- const source = original !== null && original !== void 0 ? original : '';
63
- const key = agent === 'codex' ? 'mcp_servers' : 'mcpServers';
64
- let config;
65
- try {
66
- if (agent === 'codex') {
67
- config = parseToml(source);
68
- }
69
- else {
70
- const errors = [];
71
- config = parse(source || '{}', errors, { allowTrailingComma: true });
72
- if (errors.length > 0)
73
- throw new Error('Invalid JSON');
74
- }
75
- }
76
- catch (_a) {
77
- throw new Error(`Cannot parse ${file}. Fix its configuration before running setup.`);
78
- }
79
- if (!isRecord(config))
80
- throw new Error(`Expected an object in ${file}.`);
81
- const servers = config[key];
82
- if (servers !== undefined && !isRecord(servers)) {
83
- throw new Error(`Expected ${key} to be an object in ${file}.`);
84
- }
85
- const existing = servers === null || servers === void 0 ? void 0 : servers[ADMIN_MCP_NAME];
86
- if (existing !== undefined) {
87
- if (!isRecord(existing) || existing.url !== ADMIN_MCP_URL || existing.command !== undefined) {
88
- throw new Error(`${ADMIN_MCP_NAME} already has a different configuration in ${file}. Rename or remove that entry before running setup.`);
89
- }
90
- if (agent === 'claude-code' && existing.type !== 'http') {
91
- throw new Error(`Set type to "http" for ${ADMIN_MCP_NAME} in ${file} before running setup.`);
92
- }
93
- return { path: file, original, contents: undefined };
94
- }
95
- const newline = source.includes('\r\n') ? '\r\n' : '\n';
96
- let contents;
97
- if (agent === 'codex') {
98
- contents = `${source}${newline}[mcp_servers.${ADMIN_MCP_NAME}]${newline}url = "${ADMIN_MCP_URL}"${newline}`;
99
- try {
100
- parseToml(contents);
101
- }
102
- catch (_b) {
103
- throw new Error(`Cannot safely extend ${file}. Add a ${ADMIN_MCP_NAME} entry with url = "${ADMIN_MCP_URL}" to mcp_servers manually.`);
104
- }
105
- }
106
- else {
107
- const server = { url: ADMIN_MCP_URL };
108
- if (agent === 'claude-code')
109
- server.type = 'http';
110
- contents = applyEdits(source || '{}', modify(source || '{}', [key, ADMIN_MCP_NAME], server, {
111
- formattingOptions: { insertSpaces: true, tabSize: 2, eol: newline },
112
- }));
113
- if (!contents.endsWith(newline))
114
- contents += newline;
115
- }
116
- return { path: file, original, contents };
117
- });
118
- }
119
- export function writeMcpConfig(plan) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- if ((yield readConfig(plan.path)) !== plan.original) {
122
- throw new Error(`${plan.path} changed during setup. Run setup again to preserve those changes.`);
123
- }
124
- if (plan.contents === undefined)
125
- return;
126
- yield fs.mkdir(path.dirname(plan.path), { recursive: true, mode: 0o700 });
127
- let mode = 0o600;
128
- if (plan.original !== undefined)
129
- mode = (yield fs.stat(plan.path)).mode;
130
- const temporaryPath = `${plan.path}.${randomUUID()}.tmp`;
131
- try {
132
- yield fs.writeFile(temporaryPath, plan.contents, { mode, flag: 'wx' });
133
- if (plan.original !== undefined)
134
- yield fs.chmod(temporaryPath, mode);
135
- yield fs.rename(temporaryPath, plan.path);
136
- }
137
- finally {
138
- yield fs.rm(temporaryPath, { force: true });
139
- }
140
- });
141
- }
@@ -1,146 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { checkbox } from '@inquirer/prompts';
11
- import { spawn } from 'node:child_process';
12
- import { existsSync } from 'node:fs';
13
- import os from 'node:os';
14
- import path from 'node:path';
15
- import { stripVTControlCharacters } from 'node:util';
16
- import { ADMIN_MCP_NAME, ADMIN_MCP_URL, prepareMcpConfig, writeMcpConfig, } from './agent-setup-config.js';
17
- import { detectAgent } from './agent.js';
18
- export const SETUP_AGENTS = ['claude-code', 'codex', 'cursor'];
19
- const AGENT_LABELS = {
20
- 'claude-code': 'Claude Code',
21
- codex: 'Codex',
22
- cursor: 'Cursor',
23
- };
24
- function isSetupAgent(value) {
25
- return SETUP_AGENTS.some((agent) => agent === value);
26
- }
27
- function detectedAgents() {
28
- const homeDir = os.homedir();
29
- const current = detectAgent();
30
- return SETUP_AGENTS.filter((agent) => {
31
- if (agent === 'codex') {
32
- return (current === 'codex_cli' ||
33
- existsSync(process.env.CODEX_HOME || path.join(homeDir, '.codex')));
34
- }
35
- if (agent === 'claude-code') {
36
- return (current === 'claude_code' ||
37
- existsSync(process.env.CLAUDE_CONFIG_DIR || path.join(homeDir, '.claude')));
38
- }
39
- return (current === 'cursor' || current === 'cursor-cli' || existsSync(path.join(homeDir, '.cursor')));
40
- });
41
- }
42
- export function installSkills(agents, global) {
43
- const args = [
44
- '--yes',
45
- 'skills@1.7.4',
46
- 'add',
47
- 'https://mintlify.com/docs',
48
- '--agent',
49
- ...agents,
50
- '--yes',
51
- ];
52
- if (global)
53
- args.push('--global');
54
- return new Promise((resolve, reject) => {
55
- const child = spawn('npx', args, {
56
- stdio: ['ignore', 'pipe', 'pipe'],
57
- shell: process.platform === 'win32',
58
- });
59
- let output = '';
60
- const recordOutput = (chunk) => {
61
- output = (output + chunk.toString()).slice(-65536);
62
- };
63
- child.stdout.on('data', (chunk) => {
64
- recordOutput(chunk);
65
- process.stdout.write(chunk.toString());
66
- });
67
- child.stderr.on('data', (chunk) => {
68
- recordOutput(chunk);
69
- process.stderr.write(chunk.toString());
70
- });
71
- child.on('error', () => reject(new Error('Could not run npx. Install npm and run setup again.')));
72
- child.on('close', (code, signal) => {
73
- if (code !== 0 || /Failed to install\s+\d+/.test(stripVTControlCharacters(output))) {
74
- reject(new Error(`Skills installation failed (${signal !== null && signal !== void 0 ? signal : code}). Review the installer output and run setup again.`));
75
- }
76
- else {
77
- resolve();
78
- }
79
- });
80
- });
81
- }
82
- export function setupAgent(options) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- var _a;
85
- const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
86
- if (major < 22 || (major === 22 && minor < 20)) {
87
- throw new Error('mint agent setup requires Node.js 22.20 or later to install skills. Upgrade Node.js and try again.');
88
- }
89
- const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
90
- let agents = [];
91
- for (const agent of (_a = options.agents) !== null && _a !== void 0 ? _a : []) {
92
- if (!isSetupAgent(agent))
93
- throw new Error(`Unsupported agent: ${agent}`);
94
- if (!agents.includes(agent))
95
- agents.push(agent);
96
- }
97
- if (agents.length === 0) {
98
- const detected = detectedAgents();
99
- if (!interactive) {
100
- agents = detected;
101
- }
102
- else {
103
- agents = yield checkbox({
104
- message: 'Which agents should use Mintlify?',
105
- choices: SETUP_AGENTS.map((agent) => ({
106
- name: AGENT_LABELS[agent],
107
- value: agent,
108
- checked: detected.includes(agent),
109
- })),
110
- required: true,
111
- });
112
- }
113
- }
114
- if (agents.length === 0) {
115
- throw new Error('No supported agents detected. Pass --agent claude-code, codex, or cursor.');
116
- }
117
- const location = { cwd: process.cwd(), homeDir: os.homedir(), global: options.global };
118
- const plans = yield Promise.all(agents.map((agent) => prepareMcpConfig(agent, location)));
119
- const scope = options.global ? 'your user account' : 'this project';
120
- process.stdout.write(`Setting up Mintlify skills and Admin MCP for ${scope}.\n`);
121
- yield installSkills(agents, options.global);
122
- for (const plan of plans) {
123
- yield writeMcpConfig(plan);
124
- const action = plan.contents === undefined ? 'Already configured' : 'Configured';
125
- process.stdout.write(`${action}: ${plan.path}\n`);
126
- }
127
- process.stdout.write('\nAdmin MCP is configured. Complete OAuth sign-in to grant account and project access:\n');
128
- for (const agent of agents) {
129
- if (agent === 'codex') {
130
- let command = `codex mcp login ${ADMIN_MCP_NAME}`;
131
- if (!options.global) {
132
- const config = `mcp_servers.${ADMIN_MCP_NAME}.url='${ADMIN_MCP_URL}'`;
133
- command = `codex -c "${config}" mcp login ${ADMIN_MCP_NAME}`;
134
- }
135
- process.stdout.write(` Codex: run ${command}. Trust the project before using its MCP configuration.\n`);
136
- }
137
- else if (agent === 'claude-code') {
138
- process.stdout.write(` Claude Code: open /mcp and authenticate ${ADMIN_MCP_NAME}. Approve the project server if prompted.\n`);
139
- }
140
- else {
141
- process.stdout.write(` Cursor: open MCP settings and connect ${ADMIN_MCP_NAME}.\n`);
142
- }
143
- }
144
- process.stdout.write('Setup: https://mintlify.com/docs/ai/mintlify-mcp\n');
145
- });
146
- }
package/bin/agent.js DELETED
@@ -1,42 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- const set = (...names) => (env) => names.some((name) => Boolean(env[name]));
3
- const matches = (name, pattern) => (env) => { var _a; return pattern.test((_a = env[name]) !== null && _a !== void 0 ? _a : ''); };
4
- const noTTY = (check) => (env) => !process.stdout.isTTY && check(env);
5
- const AGENTS = [
6
- [
7
- 'cursor-cli',
8
- (env) => set('CURSOR_AGENT')(env) || env.CURSOR_EXTENSION_HOST_ROLE === 'agent-exec',
9
- ],
10
- ['kimi', set('KIMI_PLUGIN_ROOT')],
11
- ['grok', set('GROK_PLUGIN_ROOT', 'GROK_PLUGIN_DATA')],
12
- ['gemini_cli', set('GEMINI_CLI')],
13
- ['cline', set('CLINE_ACTIVE')],
14
- [
15
- 'codex_cli',
16
- set('CODEX_SANDBOX', 'CODEX_CI', 'CODEX_THREAD_ID', 'CODEX_SANDBOX_NETWORK_DISABLED'),
17
- ],
18
- ['antigravity', set('ANTIGRAVITY_AGENT', 'ANTIGRAVITY_CLI_ALIAS')],
19
- ['augment-cli', set('AUGMENT_AGENT')],
20
- ['open_code', (env) => set('OPENCODE')(env) || noTTY(set('OPENCODE_CLIENT'))(env)],
21
- ['goose', noTTY(set('GOOSE_PROVIDER'))],
22
- ['junie', set('JUNIE_DATA', 'JUNIE_SHIM_PATH')],
23
- ['pi', matches('PATH', /\.pi[\\/]agent/)],
24
- ['cowork', (env) => set('CLAUDE_CODE_IS_COWORK')(env) && set('CLAUDECODE', 'CLAUDE_CODE')(env)],
25
- ['claude_code', (env) => set('CLAUDECODE', 'CLAUDE_CODE')(env) || env.TERM_PROGRAM === 'claude'],
26
- ['github-copilot', noTTY(set('COPILOT_MODEL', 'COPILOT_ALLOW_ALL'))],
27
- ['openclaw', set('OPENCLAW_SHELL')],
28
- ['devin', (env) => matches('EDITOR', /devin/)(env) || existsSync('/opt/.devin')],
29
- ['replit', noTTY(set('REPL_ID'))],
30
- ['kiro', noTTY(matches('TERM_PROGRAM', /kiro/))],
31
- ['cursor', noTTY(set('CURSOR_TRACE_ID'))],
32
- ];
33
- export function detectAgent(env = process.env) {
34
- var _a, _b;
35
- const explicit = (_a = (env.AI_AGENT || env.AGENT)) === null || _a === void 0 ? void 0 : _a.trim();
36
- if (explicit)
37
- return explicit.toLowerCase();
38
- return (_b = AGENTS.find(([, check]) => check(env))) === null || _b === void 0 ? void 0 : _b[0];
39
- }
40
- export function isCI(env = process.env) {
41
- return Boolean(env.CI && env.CI !== 'false' && env.CI !== '0');
42
- }
@@ -1,60 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { authenticatedFetch } from '../authenticatedFetch.js';
11
- import { API_URL } from '../constants.js';
12
- function request(path_1) {
13
- return __awaiter(this, arguments, void 0, function* (path, params = {}) {
14
- const url = new URL(`${API_URL}/api/cli/analytics${path}`);
15
- for (const [key, value] of Object.entries(params)) {
16
- if (value !== undefined)
17
- url.searchParams.set(key, String(value));
18
- }
19
- const res = yield authenticatedFetch(url.toString(), {
20
- headers: { Accept: 'application/json' },
21
- });
22
- if (!res.ok) {
23
- const body = yield res.text().catch(() => '');
24
- throw new Error(`API error (${res.status}): ${body || res.statusText}`);
25
- }
26
- return res.json();
27
- });
28
- }
29
- export function getKpi(opts, subdomain) {
30
- return request('/kpi', Object.assign(Object.assign({}, opts), { subdomain }));
31
- }
32
- export function getFeedback(opts, subdomain) {
33
- return request('/feedback', Object.assign(Object.assign({}, opts), { subdomain }));
34
- }
35
- export function getFeedbackByPage(opts, subdomain) {
36
- return request('/feedback/by-page', Object.assign(Object.assign({}, opts), { subdomain }));
37
- }
38
- export function getConversations(opts, subdomain) {
39
- return request('/assistant', Object.assign(Object.assign({}, opts), { subdomain }));
40
- }
41
- export function getAssistantThread(threadId, subdomain) {
42
- return request(`/assistant/threads/${encodeURIComponent(threadId)}`, {
43
- subdomain,
44
- });
45
- }
46
- export function getSearches(opts, subdomain) {
47
- return request('/searches', Object.assign(Object.assign({}, opts), { subdomain }));
48
- }
49
- export function getViews(opts, subdomain) {
50
- return request('/views', Object.assign(Object.assign({}, opts), { subdomain }));
51
- }
52
- export function getVisitors(opts, subdomain) {
53
- return request('/visitors', Object.assign(Object.assign({}, opts), { subdomain }));
54
- }
55
- export function getBuckets(opts, subdomain) {
56
- return request('/conversations/buckets', Object.assign(Object.assign({}, opts), { subdomain }));
57
- }
58
- export function getBucketThreads(bucketId, opts, subdomain) {
59
- return request(`/conversations/buckets/${encodeURIComponent(bucketId)}`, Object.assign(Object.assign({}, opts), { subdomain }));
60
- }
@@ -1,6 +0,0 @@
1
- export function formatLocalDate(date) {
2
- const year = date.getFullYear();
3
- const month = String(date.getMonth() + 1).padStart(2, '0');
4
- const day = String(date.getDate()).padStart(2, '0');
5
- return `${year}-${month}-${day}`;
6
- }