anyformat-mcp 0.1.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.
Files changed (153) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  3. package/auth.d.mts +6 -0
  4. package/auth.d.mts.map +1 -0
  5. package/auth.d.ts +6 -0
  6. package/auth.d.ts.map +1 -0
  7. package/auth.js +37 -0
  8. package/auth.js.map +1 -0
  9. package/auth.mjs +32 -0
  10. package/auth.mjs.map +1 -0
  11. package/code-tool-paths.cjs +8 -0
  12. package/code-tool-paths.cjs.map +1 -0
  13. package/code-tool-paths.d.cts +2 -0
  14. package/code-tool-paths.d.cts.map +1 -0
  15. package/code-tool-types.d.mts +14 -0
  16. package/code-tool-types.d.mts.map +1 -0
  17. package/code-tool-types.d.ts +14 -0
  18. package/code-tool-types.d.ts.map +1 -0
  19. package/code-tool-types.js +4 -0
  20. package/code-tool-types.js.map +1 -0
  21. package/code-tool-types.mjs +3 -0
  22. package/code-tool-types.mjs.map +1 -0
  23. package/code-tool-worker.d.mts +5 -0
  24. package/code-tool-worker.d.mts.map +1 -0
  25. package/code-tool-worker.d.ts +5 -0
  26. package/code-tool-worker.d.ts.map +1 -0
  27. package/code-tool-worker.js +282 -0
  28. package/code-tool-worker.js.map +1 -0
  29. package/code-tool-worker.mjs +244 -0
  30. package/code-tool-worker.mjs.map +1 -0
  31. package/code-tool.d.mts +21 -0
  32. package/code-tool.d.mts.map +1 -0
  33. package/code-tool.d.ts +21 -0
  34. package/code-tool.d.ts.map +1 -0
  35. package/code-tool.js +335 -0
  36. package/code-tool.js.map +1 -0
  37. package/code-tool.mjs +299 -0
  38. package/code-tool.mjs.map +1 -0
  39. package/docs-search-tool.d.mts +59 -0
  40. package/docs-search-tool.d.mts.map +1 -0
  41. package/docs-search-tool.d.ts +59 -0
  42. package/docs-search-tool.d.ts.map +1 -0
  43. package/docs-search-tool.js +104 -0
  44. package/docs-search-tool.js.map +1 -0
  45. package/docs-search-tool.mjs +99 -0
  46. package/docs-search-tool.mjs.map +1 -0
  47. package/http.d.mts +12 -0
  48. package/http.d.mts.map +1 -0
  49. package/http.d.ts +12 -0
  50. package/http.d.ts.map +1 -0
  51. package/http.js +190 -0
  52. package/http.js.map +1 -0
  53. package/http.mjs +182 -0
  54. package/http.mjs.map +1 -0
  55. package/index.d.mts +3 -0
  56. package/index.d.mts.map +1 -0
  57. package/index.d.ts +3 -0
  58. package/index.d.ts.map +1 -0
  59. package/index.js +60 -0
  60. package/index.js.map +1 -0
  61. package/index.mjs +58 -0
  62. package/index.mjs.map +1 -0
  63. package/instructions.d.mts +5 -0
  64. package/instructions.d.mts.map +1 -0
  65. package/instructions.d.ts +5 -0
  66. package/instructions.d.ts.map +1 -0
  67. package/instructions.js +61 -0
  68. package/instructions.js.map +1 -0
  69. package/instructions.mjs +55 -0
  70. package/instructions.mjs.map +1 -0
  71. package/local-docs-search.d.mts +28 -0
  72. package/local-docs-search.d.mts.map +1 -0
  73. package/local-docs-search.d.ts +28 -0
  74. package/local-docs-search.d.ts.map +1 -0
  75. package/local-docs-search.js +731 -0
  76. package/local-docs-search.js.map +1 -0
  77. package/local-docs-search.mjs +691 -0
  78. package/local-docs-search.mjs.map +1 -0
  79. package/logger.d.mts +7 -0
  80. package/logger.d.mts.map +1 -0
  81. package/logger.d.ts +7 -0
  82. package/logger.d.ts.map +1 -0
  83. package/logger.js +29 -0
  84. package/logger.js.map +1 -0
  85. package/logger.mjs +22 -0
  86. package/logger.mjs.map +1 -0
  87. package/methods.d.mts +10 -0
  88. package/methods.d.mts.map +1 -0
  89. package/methods.d.ts +10 -0
  90. package/methods.d.ts.map +1 -0
  91. package/methods.js +161 -0
  92. package/methods.js.map +1 -0
  93. package/methods.mjs +157 -0
  94. package/methods.mjs.map +1 -0
  95. package/options.d.mts +23 -0
  96. package/options.d.mts.map +1 -0
  97. package/options.d.ts +23 -0
  98. package/options.d.ts.map +1 -0
  99. package/options.js +141 -0
  100. package/options.js.map +1 -0
  101. package/options.mjs +134 -0
  102. package/options.mjs.map +1 -0
  103. package/package.json +235 -0
  104. package/server.d.mts +38 -0
  105. package/server.d.mts.map +1 -0
  106. package/server.d.ts +38 -0
  107. package/server.d.ts.map +1 -0
  108. package/server.js +168 -0
  109. package/server.js.map +1 -0
  110. package/server.mjs +158 -0
  111. package/server.mjs.map +1 -0
  112. package/src/auth.ts +42 -0
  113. package/src/code-tool-paths.cts +5 -0
  114. package/src/code-tool-types.ts +17 -0
  115. package/src/code-tool-worker.ts +295 -0
  116. package/src/code-tool.ts +389 -0
  117. package/src/docs-search-tool.ts +138 -0
  118. package/src/http.ts +227 -0
  119. package/src/index.ts +67 -0
  120. package/src/instructions.ts +83 -0
  121. package/src/local-docs-search.ts +831 -0
  122. package/src/logger.ts +28 -0
  123. package/src/methods.ts +182 -0
  124. package/src/options.ts +185 -0
  125. package/src/server.ts +208 -0
  126. package/src/stdio.ts +17 -0
  127. package/src/tsconfig.json +11 -0
  128. package/src/types.ts +126 -0
  129. package/src/util.ts +25 -0
  130. package/stdio.d.mts +3 -0
  131. package/stdio.d.mts.map +1 -0
  132. package/stdio.d.ts +3 -0
  133. package/stdio.d.ts.map +1 -0
  134. package/stdio.js +18 -0
  135. package/stdio.js.map +1 -0
  136. package/stdio.mjs +14 -0
  137. package/stdio.mjs.map +1 -0
  138. package/types.d.mts +65 -0
  139. package/types.d.mts.map +1 -0
  140. package/types.d.ts +65 -0
  141. package/types.d.ts.map +1 -0
  142. package/types.js +58 -0
  143. package/types.js.map +1 -0
  144. package/types.mjs +53 -0
  145. package/types.mjs.map +1 -0
  146. package/util.d.mts +4 -0
  147. package/util.d.mts.map +1 -0
  148. package/util.d.ts +4 -0
  149. package/util.d.ts.map +1 -0
  150. package/util.js +30 -0
  151. package/util.js.map +1 -0
  152. package/util.mjs +24 -0
  153. package/util.mjs.map +1 -0
@@ -0,0 +1,731 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.LocalDocsSearch = void 0;
41
+ const minisearch_1 = __importDefault(require("minisearch"));
42
+ const fs = __importStar(require("node:fs/promises"));
43
+ const path = __importStar(require("node:path"));
44
+ const logger_1 = require("./logger.js");
45
+ const EMBEDDED_METHODS = [
46
+ {
47
+ name: 'check',
48
+ endpoint: '/health/',
49
+ httpMethod: 'get',
50
+ summary: 'Health Check',
51
+ description: 'Health check endpoint.\n\nReturns 200 OK if the service is running.\nNo authentication required.',
52
+ stainlessPath: '(resource) health > (method) check',
53
+ qualified: 'client.health.check',
54
+ response: 'object',
55
+ markdown: "## check\n\n`client.health.check(): object`\n\n**get** `/health/`\n\nHealth check endpoint.\n\nReturns 200 OK if the service is running.\nNo authentication required.\n\n### Returns\n\n- `object`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst response = await client.health.check();\n\nconsole.log(response);\n```",
56
+ perLanguage: {
57
+ http: {
58
+ example: 'curl https://api.anyformat.ai/health/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
59
+ },
60
+ python: {
61
+ method: 'health.check',
62
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.health.check()\nprint(response)',
63
+ },
64
+ typescript: {
65
+ method: 'client.health.check',
66
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.health.check();\n\nconsole.log(response);",
67
+ },
68
+ },
69
+ },
70
+ {
71
+ name: 'create',
72
+ endpoint: '/v2/webhooks/',
73
+ httpMethod: 'post',
74
+ summary: 'Create webhook',
75
+ description: 'Create a new webhook subscription.\n\nValidates URL (HTTPS only) and event types, then forwards to backend service.\nReturns the created webhook with generated secret.',
76
+ stainlessPath: '(resource) webhooks > (method) create',
77
+ qualified: 'client.webhooks.create',
78
+ params: ['url: string;', 'events?: string[];'],
79
+ response: '{ id: string; created_at: string; events: string[]; is_active: boolean; secret: string; url: string; }',
80
+ markdown: "## create\n\n`client.webhooks.create(url: string, events?: string[]): { id: string; created_at: string; events: string[]; is_active: boolean; secret: string; url: string; }`\n\n**post** `/v2/webhooks/`\n\nCreate a new webhook subscription.\n\nValidates URL (HTTPS only) and event types, then forwards to backend service.\nReturns the created webhook with generated secret.\n\n### Parameters\n\n- `url: string`\n\n- `events?: string[]`\n\n### Returns\n\n- `{ id: string; created_at: string; events: string[]; is_active: boolean; secret: string; url: string; }`\n Response schema for webhook subscription (includes secret)\n\n - `id: string`\n - `created_at: string`\n - `events: string[]`\n - `is_active: boolean`\n - `secret: string`\n - `url: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst webhook = await client.webhooks.create({ url: 'https://example.com' });\n\nconsole.log(webhook);\n```",
81
+ perLanguage: {
82
+ http: {
83
+ example: 'curl https://api.anyformat.ai/v2/webhooks/ \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY" \\\n -d \'{\n "url": "https://example.com"\n }\'',
84
+ },
85
+ python: {
86
+ method: 'webhooks.create',
87
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nwebhook = client.webhooks.create(\n url="https://example.com",\n)\nprint(webhook.id)',
88
+ },
89
+ typescript: {
90
+ method: 'client.webhooks.create',
91
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst webhook = await client.webhooks.create({ url: 'https://example.com' });\n\nconsole.log(webhook.id);",
92
+ },
93
+ },
94
+ },
95
+ {
96
+ name: 'list',
97
+ endpoint: '/v2/webhooks/',
98
+ httpMethod: 'get',
99
+ summary: 'List webhooks',
100
+ description: 'List all webhook subscriptions for the authenticated organization.\n\nReturns a list of webhooks (secrets are excluded in list view).',
101
+ stainlessPath: '(resource) webhooks > (method) list',
102
+ qualified: 'client.webhooks.list',
103
+ response: '{ id: string; created_at: string; events: string[]; is_active: boolean; url: string; }[]',
104
+ markdown: "## list\n\n`client.webhooks.list(): { id: string; created_at: string; events: string[]; is_active: boolean; url: string; }[]`\n\n**get** `/v2/webhooks/`\n\nList all webhook subscriptions for the authenticated organization.\n\nReturns a list of webhooks (secrets are excluded in list view).\n\n### Returns\n\n- `{ id: string; created_at: string; events: string[]; is_active: boolean; url: string; }[]`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst webhooks = await client.webhooks.list();\n\nconsole.log(webhooks);\n```",
105
+ perLanguage: {
106
+ http: {
107
+ example: 'curl https://api.anyformat.ai/v2/webhooks/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
108
+ },
109
+ python: {
110
+ method: 'webhooks.list',
111
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nwebhooks = client.webhooks.list()\nprint(webhooks)',
112
+ },
113
+ typescript: {
114
+ method: 'client.webhooks.list',
115
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst webhooks = await client.webhooks.list();\n\nconsole.log(webhooks);",
116
+ },
117
+ },
118
+ },
119
+ {
120
+ name: 'delete',
121
+ endpoint: '/v2/webhooks/{webhook_id}/',
122
+ httpMethod: 'delete',
123
+ summary: 'Delete webhook',
124
+ description: 'Delete a webhook subscription by ID.\n\nReturns 204 on success, 404 if webhook not found, 403 if unauthorized.',
125
+ stainlessPath: '(resource) webhooks > (method) delete',
126
+ qualified: 'client.webhooks.delete',
127
+ params: ['webhook_id: string;'],
128
+ markdown: "## delete\n\n`client.webhooks.delete(webhook_id: string): void`\n\n**delete** `/v2/webhooks/{webhook_id}/`\n\nDelete a webhook subscription by ID.\n\nReturns 204 on success, 404 if webhook not found, 403 if unauthorized.\n\n### Parameters\n\n- `webhook_id: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nawait client.webhooks.delete('webhook_id')\n```",
129
+ perLanguage: {
130
+ http: {
131
+ example: 'curl https://api.anyformat.ai/v2/webhooks/$WEBHOOK_ID/ \\\n -X DELETE \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
132
+ },
133
+ python: {
134
+ method: 'webhooks.delete',
135
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nclient.webhooks.delete(\n "webhook_id",\n)',
136
+ },
137
+ typescript: {
138
+ method: 'client.webhooks.delete',
139
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nawait client.webhooks.delete('webhook_id');",
140
+ },
141
+ },
142
+ },
143
+ {
144
+ name: 'list',
145
+ endpoint: '/v2/files/',
146
+ httpMethod: 'get',
147
+ summary: 'List file collections',
148
+ description: 'List file collections for a workflow.',
149
+ stainlessPath: '(resource) files > (method) list',
150
+ qualified: 'client.files.list',
151
+ params: ['page?: number;', 'page_size?: number;', 'workflow_id?: string;'],
152
+ response: '{ count: number; page: number; page_size: number; results: { id: string; status: string; created_at?: string; name?: string; updated_at?: string; }[]; }',
153
+ markdown: "## list\n\n`client.files.list(page?: number, page_size?: number, workflow_id?: string): { count: number; page: number; page_size: number; results: object[]; }`\n\n**get** `/v2/files/`\n\nList file collections for a workflow.\n\n### Parameters\n\n- `page?: number`\n\n- `page_size?: number`\n\n- `workflow_id?: string`\n\n### Returns\n\n- `{ count: number; page: number; page_size: number; results: { id: string; status: string; created_at?: string; name?: string; updated_at?: string; }[]; }`\n\n - `count: number`\n - `page: number`\n - `page_size: number`\n - `results: { id: string; status: string; created_at?: string; name?: string; updated_at?: string; }[]`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst files = await client.files.list();\n\nconsole.log(files);\n```",
154
+ perLanguage: {
155
+ http: {
156
+ example: 'curl https://api.anyformat.ai/v2/files/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
157
+ },
158
+ python: {
159
+ method: 'files.list',
160
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nfiles = client.files.list()\nprint(files.count)',
161
+ },
162
+ typescript: {
163
+ method: 'client.files.list',
164
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst files = await client.files.list();\n\nconsole.log(files.count);",
165
+ },
166
+ },
167
+ },
168
+ {
169
+ name: 'create',
170
+ endpoint: '/v2/files/',
171
+ httpMethod: 'post',
172
+ summary: 'Create file collection',
173
+ description: 'Upload files to a workflow, creating a file collection.',
174
+ stainlessPath: '(resource) files > (method) create',
175
+ qualified: 'client.files.create',
176
+ params: ['files: string[];', 'workflow_id: string;'],
177
+ response: '{ id: string; files: { filename: string; status: string; }[]; workflow_id: string; name?: string; }',
178
+ markdown: "## create\n\n`client.files.create(files: string[], workflow_id: string): { id: string; files: object[]; workflow_id: string; name?: string; }`\n\n**post** `/v2/files/`\n\nUpload files to a workflow, creating a file collection.\n\n### Parameters\n\n- `files: string[]`\n\n- `workflow_id: string`\n\n### Returns\n\n- `{ id: string; files: { filename: string; status: string; }[]; workflow_id: string; name?: string; }`\n Response from creating a file collection.\n\n - `id: string`\n - `files: { filename: string; status: string; }[]`\n - `workflow_id: string`\n - `name?: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst file = await client.files.create({ files: ['string'], workflow_id: 'workflow_id' });\n\nconsole.log(file);\n```",
179
+ perLanguage: {
180
+ http: {
181
+ example: 'curl https://api.anyformat.ai/v2/files/ \\\n -H \'Content-Type: multipart/form-data\' \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY" \\\n -F files=\'["string"]\' \\\n -F workflow_id=workflow_id',
182
+ },
183
+ python: {
184
+ method: 'files.create',
185
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nfile = client.files.create(\n files=["string"],\n workflow_id="workflow_id",\n)\nprint(file.id)',
186
+ },
187
+ typescript: {
188
+ method: 'client.files.create',
189
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst file = await client.files.create({ files: ['string'], workflow_id: 'workflow_id' });\n\nconsole.log(file.id);",
190
+ },
191
+ },
192
+ },
193
+ {
194
+ name: 'delete',
195
+ endpoint: '/v2/files/{collection_id}/',
196
+ httpMethod: 'delete',
197
+ summary: 'Delete file collection',
198
+ description: 'Delete a file collection and all its files.',
199
+ stainlessPath: '(resource) files > (method) delete',
200
+ qualified: 'client.files.delete',
201
+ params: ['collection_id: string;'],
202
+ markdown: "## delete\n\n`client.files.delete(collection_id: string): void`\n\n**delete** `/v2/files/{collection_id}/`\n\nDelete a file collection and all its files.\n\n### Parameters\n\n- `collection_id: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nawait client.files.delete('collection_id')\n```",
203
+ perLanguage: {
204
+ http: {
205
+ example: 'curl https://api.anyformat.ai/v2/files/$COLLECTION_ID/ \\\n -X DELETE \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
206
+ },
207
+ python: {
208
+ method: 'files.delete',
209
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nclient.files.delete(\n "collection_id",\n)',
210
+ },
211
+ typescript: {
212
+ method: 'client.files.delete',
213
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nawait client.files.delete('collection_id');",
214
+ },
215
+ },
216
+ },
217
+ {
218
+ name: 'get_extraction_results',
219
+ endpoint: '/v2/files/{collection_id}/extraction/',
220
+ httpMethod: 'get',
221
+ summary: 'Get extraction results',
222
+ description: 'Get extraction results for a file collection.\n\nReturns 412 if the extraction is not yet complete.',
223
+ stainlessPath: '(resource) files > (method) get_extraction_results',
224
+ qualified: 'client.files.getExtractionResults',
225
+ params: ['collection_id: string;'],
226
+ response: 'object',
227
+ markdown: "## get_extraction_results\n\n`client.files.getExtractionResults(collection_id: string): object`\n\n**get** `/v2/files/{collection_id}/extraction/`\n\nGet extraction results for a file collection.\n\nReturns 412 if the extraction is not yet complete.\n\n### Parameters\n\n- `collection_id: string`\n\n### Returns\n\n- `object`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst response = await client.files.getExtractionResults('collection_id');\n\nconsole.log(response);\n```",
228
+ perLanguage: {
229
+ http: {
230
+ example: 'curl https://api.anyformat.ai/v2/files/$COLLECTION_ID/extraction/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
231
+ },
232
+ python: {
233
+ method: 'files.get_extraction_results',
234
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.files.get_extraction_results(\n "collection_id",\n)\nprint(response)',
235
+ },
236
+ typescript: {
237
+ method: 'client.files.getExtractionResults',
238
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.files.getExtractionResults('collection_id');\n\nconsole.log(response);",
239
+ },
240
+ },
241
+ },
242
+ {
243
+ name: 'create',
244
+ endpoint: '/v2/workflows/',
245
+ httpMethod: 'post',
246
+ summary: 'Create workflow',
247
+ description: 'Create a new workflow.',
248
+ stainlessPath: '(resource) workflows > (method) create',
249
+ qualified: 'client.workflows.create',
250
+ response: '{ id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }',
251
+ markdown: "## create\n\n`client.workflows.create(): { id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }`\n\n**post** `/v2/workflows/`\n\nCreate a new workflow.\n\n### Returns\n\n- `{ id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }`\n Workflow detail — used for get, create, and list items.\n\n - `id: string`\n - `name: string`\n - `created_at?: string`\n - `description?: string`\n - `fields?: object[]`\n - `updated_at?: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst workflow = await client.workflows.create();\n\nconsole.log(workflow);\n```",
252
+ perLanguage: {
253
+ http: {
254
+ example: 'curl https://api.anyformat.ai/v2/workflows/ \\\n -X POST \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
255
+ },
256
+ python: {
257
+ method: 'workflows.create',
258
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nworkflow = client.workflows.create()\nprint(workflow.id)',
259
+ },
260
+ typescript: {
261
+ method: 'client.workflows.create',
262
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst workflow = await client.workflows.create();\n\nconsole.log(workflow.id);",
263
+ },
264
+ },
265
+ },
266
+ {
267
+ name: 'list',
268
+ endpoint: '/v2/workflows/',
269
+ httpMethod: 'get',
270
+ summary: 'List workflows',
271
+ description: 'List workflows with pagination.',
272
+ stainlessPath: '(resource) workflows > (method) list',
273
+ qualified: 'client.workflows.list',
274
+ params: [
275
+ 'order?: string;',
276
+ 'page?: number;',
277
+ 'page_size?: number;',
278
+ 'sort_by?: string;',
279
+ 'status?: string;',
280
+ ],
281
+ response: '{ count: number; page: number; page_size: number; results: { id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }[]; }',
282
+ markdown: "## list\n\n`client.workflows.list(order?: string, page?: number, page_size?: number, sort_by?: string, status?: string): { count: number; page: number; page_size: number; results: workflow[]; }`\n\n**get** `/v2/workflows/`\n\nList workflows with pagination.\n\n### Parameters\n\n- `order?: string`\n\n- `page?: number`\n\n- `page_size?: number`\n\n- `sort_by?: string`\n\n- `status?: string`\n\n### Returns\n\n- `{ count: number; page: number; page_size: number; results: { id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }[]; }`\n GET /workflows/ — paginated workflow list.\n\n - `count: number`\n - `page: number`\n - `page_size: number`\n - `results: { id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }[]`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst workflows = await client.workflows.list();\n\nconsole.log(workflows);\n```",
283
+ perLanguage: {
284
+ http: {
285
+ example: 'curl https://api.anyformat.ai/v2/workflows/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
286
+ },
287
+ python: {
288
+ method: 'workflows.list',
289
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nworkflows = client.workflows.list()\nprint(workflows.count)',
290
+ },
291
+ typescript: {
292
+ method: 'client.workflows.list',
293
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst workflows = await client.workflows.list();\n\nconsole.log(workflows.count);",
294
+ },
295
+ },
296
+ },
297
+ {
298
+ name: 'retrieve',
299
+ endpoint: '/v2/workflows/{workflow_id}/',
300
+ httpMethod: 'get',
301
+ summary: 'Get workflow',
302
+ description: 'Get workflow by ID.',
303
+ stainlessPath: '(resource) workflows > (method) retrieve',
304
+ qualified: 'client.workflows.retrieve',
305
+ params: ['workflow_id: string;'],
306
+ response: '{ id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }',
307
+ markdown: "## retrieve\n\n`client.workflows.retrieve(workflow_id: string): { id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }`\n\n**get** `/v2/workflows/{workflow_id}/`\n\nGet workflow by ID.\n\n### Parameters\n\n- `workflow_id: string`\n\n### Returns\n\n- `{ id: string; name: string; created_at?: string; description?: string; fields?: object[]; updated_at?: string; }`\n Workflow detail — used for get, create, and list items.\n\n - `id: string`\n - `name: string`\n - `created_at?: string`\n - `description?: string`\n - `fields?: object[]`\n - `updated_at?: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst workflow = await client.workflows.retrieve('workflow_id');\n\nconsole.log(workflow);\n```",
308
+ perLanguage: {
309
+ http: {
310
+ example: 'curl https://api.anyformat.ai/v2/workflows/$WORKFLOW_ID/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
311
+ },
312
+ python: {
313
+ method: 'workflows.retrieve',
314
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nworkflow = client.workflows.retrieve(\n "workflow_id",\n)\nprint(workflow.id)',
315
+ },
316
+ typescript: {
317
+ method: 'client.workflows.retrieve',
318
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst workflow = await client.workflows.retrieve('workflow_id');\n\nconsole.log(workflow.id);",
319
+ },
320
+ },
321
+ },
322
+ {
323
+ name: 'delete',
324
+ endpoint: '/v2/workflows/{workflow_id}/',
325
+ httpMethod: 'delete',
326
+ summary: 'Delete workflow',
327
+ description: 'Delete workflow by ID.',
328
+ stainlessPath: '(resource) workflows > (method) delete',
329
+ qualified: 'client.workflows.delete',
330
+ params: ['workflow_id: string;'],
331
+ markdown: "## delete\n\n`client.workflows.delete(workflow_id: string): void`\n\n**delete** `/v2/workflows/{workflow_id}/`\n\nDelete workflow by ID.\n\n### Parameters\n\n- `workflow_id: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nawait client.workflows.delete('workflow_id')\n```",
332
+ perLanguage: {
333
+ http: {
334
+ example: 'curl https://api.anyformat.ai/v2/workflows/$WORKFLOW_ID/ \\\n -X DELETE \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
335
+ },
336
+ python: {
337
+ method: 'workflows.delete',
338
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nclient.workflows.delete(\n "workflow_id",\n)',
339
+ },
340
+ typescript: {
341
+ method: 'client.workflows.delete',
342
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nawait client.workflows.delete('workflow_id');",
343
+ },
344
+ },
345
+ },
346
+ {
347
+ name: 'run',
348
+ endpoint: '/v2/workflows/{workflow_id}/run/',
349
+ httpMethod: 'post',
350
+ summary: 'Run workflow',
351
+ description: 'Execute workflow — returns collection UUID.',
352
+ stainlessPath: '(resource) workflows > (method) run',
353
+ qualified: 'client.workflows.run',
354
+ params: [
355
+ 'workflow_id: string;',
356
+ 'content_type?: string;',
357
+ 'file?: string;',
358
+ 'file_base64?: string;',
359
+ 'filename?: string;',
360
+ 'text?: string;',
361
+ ],
362
+ response: '{ id: string; status: string; workflow_id: string; }',
363
+ markdown: "## run\n\n`client.workflows.run(workflow_id: string, content_type?: string, file?: string, file_base64?: string, filename?: string, text?: string): { id: string; status: string; workflow_id: string; }`\n\n**post** `/v2/workflows/{workflow_id}/run/`\n\nExecute workflow — returns collection UUID.\n\n### Parameters\n\n- `workflow_id: string`\n\n- `content_type?: string`\n\n- `file?: string`\n\n- `file_base64?: string`\n\n- `filename?: string`\n\n- `text?: string`\n\n### Returns\n\n- `{ id: string; status: string; workflow_id: string; }`\n Response for workflow run endpoint (v2) — collection UUID as identifier.\n\n - `id: string`\n - `status: string`\n - `workflow_id: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst response = await client.workflows.run('workflow_id');\n\nconsole.log(response);\n```",
364
+ perLanguage: {
365
+ http: {
366
+ example: 'curl https://api.anyformat.ai/v2/workflows/$WORKFLOW_ID/run/ \\\n -X POST \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
367
+ },
368
+ python: {
369
+ method: 'workflows.run',
370
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.workflows.run(\n workflow_id="workflow_id",\n)\nprint(response.id)',
371
+ },
372
+ typescript: {
373
+ method: 'client.workflows.run',
374
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.workflows.run('workflow_id');\n\nconsole.log(response.id);",
375
+ },
376
+ },
377
+ },
378
+ {
379
+ name: 'upload',
380
+ endpoint: '/v2/workflows/{workflow_id}/upload/',
381
+ httpMethod: 'post',
382
+ summary: 'Upload file',
383
+ description: 'Upload file without executing workflow.',
384
+ stainlessPath: '(resource) workflows > (method) upload',
385
+ qualified: 'client.workflows.upload',
386
+ params: [
387
+ 'workflow_id: string;',
388
+ 'content_type?: string;',
389
+ 'file?: string;',
390
+ 'file_base64?: string;',
391
+ 'filename?: string;',
392
+ 'text?: string;',
393
+ ],
394
+ response: '{ status: string; filename?: string; }',
395
+ markdown: "## upload\n\n`client.workflows.upload(workflow_id: string, content_type?: string, file?: string, file_base64?: string, filename?: string, text?: string): { status: string; filename?: string; }`\n\n**post** `/v2/workflows/{workflow_id}/upload/`\n\nUpload file without executing workflow.\n\n### Parameters\n\n- `workflow_id: string`\n\n- `content_type?: string`\n\n- `file?: string`\n\n- `file_base64?: string`\n\n- `filename?: string`\n\n- `text?: string`\n\n### Returns\n\n- `{ status: string; filename?: string; }`\n POST /workflows/{id}/upload/ — upload confirmation.\n\n - `status: string`\n - `filename?: string`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst response = await client.workflows.upload('workflow_id');\n\nconsole.log(response);\n```",
396
+ perLanguage: {
397
+ http: {
398
+ example: 'curl https://api.anyformat.ai/v2/workflows/$WORKFLOW_ID/upload/ \\\n -X POST \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
399
+ },
400
+ python: {
401
+ method: 'workflows.upload',
402
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.workflows.upload(\n workflow_id="workflow_id",\n)\nprint(response.status)',
403
+ },
404
+ typescript: {
405
+ method: 'client.workflows.upload',
406
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.workflows.upload('workflow_id');\n\nconsole.log(response.status);",
407
+ },
408
+ },
409
+ },
410
+ {
411
+ name: 'results',
412
+ endpoint: '/v2/workflows/{workflow_id}/results/',
413
+ httpMethod: 'get',
414
+ summary: 'Get workflow results',
415
+ description: 'Get workflow results.',
416
+ stainlessPath: '(resource) workflows > (method) results',
417
+ qualified: 'client.workflows.results',
418
+ params: ['workflow_id: string;', 'as_lists?: string;', 'output_format?: string;'],
419
+ response: 'object',
420
+ markdown: "## results\n\n`client.workflows.results(workflow_id: string, as_lists?: string, output_format?: string): object`\n\n**get** `/v2/workflows/{workflow_id}/results/`\n\nGet workflow results.\n\n### Parameters\n\n- `workflow_id: string`\n\n- `as_lists?: string`\n\n- `output_format?: string`\n\n### Returns\n\n- `object`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst response = await client.workflows.results('workflow_id');\n\nconsole.log(response);\n```",
421
+ perLanguage: {
422
+ http: {
423
+ example: 'curl https://api.anyformat.ai/v2/workflows/$WORKFLOW_ID/results/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
424
+ },
425
+ python: {
426
+ method: 'workflows.results',
427
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.workflows.results(\n workflow_id="workflow_id",\n)\nprint(response)',
428
+ },
429
+ typescript: {
430
+ method: 'client.workflows.results',
431
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.workflows.results('workflow_id');\n\nconsole.log(response);",
432
+ },
433
+ },
434
+ },
435
+ {
436
+ name: 'list_runs',
437
+ endpoint: '/v2/workflows/{workflow_id}/runs/',
438
+ httpMethod: 'get',
439
+ summary: 'List workflow runs',
440
+ description: 'List extraction runs for a workflow, identified by collection UUID.',
441
+ stainlessPath: '(resource) workflows > (method) list_runs',
442
+ qualified: 'client.workflows.listRuns',
443
+ params: ['workflow_id: string;', 'page?: number;', 'page_size?: number;'],
444
+ response: '{ count: number; page: number; page_size: number; results: { id: string; status: string; created_at?: string; updated_at?: string; }[]; }',
445
+ markdown: "## list_runs\n\n`client.workflows.listRuns(workflow_id: string, page?: number, page_size?: number): { count: number; page: number; page_size: number; results: object[]; }`\n\n**get** `/v2/workflows/{workflow_id}/runs/`\n\nList extraction runs for a workflow, identified by collection UUID.\n\n### Parameters\n\n- `workflow_id: string`\n\n- `page?: number`\n\n- `page_size?: number`\n\n### Returns\n\n- `{ count: number; page: number; page_size: number; results: { id: string; status: string; created_at?: string; updated_at?: string; }[]; }`\n GET /workflows/{id}/runs/ — paginated run list.\n\n - `count: number`\n - `page: number`\n - `page_size: number`\n - `results: { id: string; status: string; created_at?: string; updated_at?: string; }[]`\n\n### Example\n\n```typescript\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat();\n\nconst response = await client.workflows.listRuns('workflow_id');\n\nconsole.log(response);\n```",
446
+ perLanguage: {
447
+ http: {
448
+ example: 'curl https://api.anyformat.ai/v2/workflows/$WORKFLOW_ID/runs/ \\\n -H "Authorization: Bearer $ANYFORMAT_API_KEY"',
449
+ },
450
+ python: {
451
+ method: 'workflows.list_runs',
452
+ example: 'import os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.workflows.list_runs(\n workflow_id="workflow_id",\n)\nprint(response.count)',
453
+ },
454
+ typescript: {
455
+ method: 'client.workflows.listRuns',
456
+ example: "import Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.workflows.listRuns('workflow_id');\n\nconsole.log(response.count);",
457
+ },
458
+ },
459
+ },
460
+ ];
461
+ const EMBEDDED_READMES = [
462
+ {
463
+ language: 'python',
464
+ content: '# Anyformat Python API library\n\n<!-- prettier-ignore -->\n[![PyPI version](https://img.shields.io/pypi/v/anyformat.svg?label=pypi%20(stable))](https://pypi.org/project/anyformat/)\n\nThe Anyformat Python library provides convenient access to the Anyformat REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Anyformat MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=anyformat-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImFueWZvcm1hdC1tY3AiXSwiZW52Ijp7IkFOWUZPUk1BVF9BUElfS0VZIjoiTXkgQVBJIEtleSJ9fQ)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22anyformat-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22anyformat-mcp%22%5D%2C%22env%22%3A%7B%22ANYFORMAT_API_KEY%22%3A%22My%20API%20Key%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\n The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install anyformat\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom anyformat import Anyformat\n\nclient = Anyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\n\nresponse = client.health.check()\n```\n\nWhile you can provide an `api_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `ANYFORMAT_API_KEY="My API Key"` to your `.env` file\nso that your API Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncAnyformat` instead of `Anyformat` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom anyformat import AsyncAnyformat\n\nclient = AsyncAnyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.health.check()\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install anyformat[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom anyformat import DefaultAioHttpClient\nfrom anyformat import AsyncAnyformat\n\nasync def main() -> None:\n async with AsyncAnyformat(\n api_key=os.environ.get("ANYFORMAT_API_KEY"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.health.check()\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `anyformat.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `anyformat.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `anyformat.APIError`.\n\n```python\nimport anyformat\nfrom anyformat import Anyformat\n\nclient = Anyformat()\n\ntry:\n client.health.check()\nexcept anyformat.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept anyformat.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept anyformat.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom anyformat import Anyformat\n\n# Configure the default for all requests:\nclient = Anyformat(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).health.check()\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom anyformat import Anyformat\n\n# Configure the default for all requests:\nclient = Anyformat(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = Anyformat(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).health.check()\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `ANYFORMAT_LOG` to `info`.\n\n```shell\n$ export ANYFORMAT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom anyformat import Anyformat\n\nclient = Anyformat()\nresponse = client.health.with_raw_response.check()\nprint(response.headers.get(\'X-My-Header\'))\n\nhealth = response.parse() # get the object that `health.check()` would have returned\nprint(health)\n```\n\nThese methods return an [`APIResponse`](https://github.com/anyformat-ai/anyformat-python/tree/main/src/anyformat/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/anyformat-ai/anyformat-python/tree/main/src/anyformat/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.health.with_streaming_response.check() as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom anyformat import Anyformat, DefaultHttpxClient\n\nclient = Anyformat(\n # Or use the `ANYFORMAT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom anyformat import Anyformat\n\nwith Anyformat() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/anyformat-ai/anyformat-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport anyformat\nprint(anyformat.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n',
465
+ },
466
+ {
467
+ language: 'typescript',
468
+ content: "# Anyformat TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/anyformat-ai.svg?label=npm%20(stable))](https://npmjs.org/package/anyformat-ai) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/anyformat-ai)\n\nThis library provides convenient access to the Anyformat REST API from server-side TypeScript or JavaScript.\n\n\n\nThe full API of this library can be found in [api.md](api.md).\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Anyformat MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=anyformat-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImFueWZvcm1hdC1tY3AiXSwiZW52Ijp7IkFOWUZPUk1BVF9BUElfS0VZIjoiTXkgQVBJIEtleSJ9fQ)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22anyformat-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22anyformat-mcp%22%5D%2C%22env%22%3A%7B%22ANYFORMAT_API_KEY%22%3A%22My%20API%20Key%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install anyformat-ai\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n<!-- prettier-ignore -->\n```js\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.health.check();\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n<!-- prettier-ignore -->\n```ts\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n apiKey: process.env['ANYFORMAT_API_KEY'], // This is the default and can be omitted\n});\n\nconst response: unknown = await client.health.check();\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n<!-- prettier-ignore -->\n```ts\nconst response = await client.health.check().catch(async (err) => {\n if (err instanceof Anyformat.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n});\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n<!-- prettier-ignore -->\n```js\n// Configure the default for all requests:\nconst client = new Anyformat({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.health.check({\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n<!-- prettier-ignore -->\n```ts\n// Configure the default for all requests:\nconst client = new Anyformat({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.health.check({\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n<!-- prettier-ignore -->\n```ts\nconst client = new Anyformat();\n\nconst response = await client.health.check().asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.health.check().withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `ANYFORMAT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport Anyformat from 'anyformat-ai';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new Anyformat({\n logger: logger.child({ name: 'Anyformat' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.health.check({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport Anyformat from 'anyformat-ai';\nimport fetch from 'my-fetch';\n\nconst client = new Anyformat({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n<img src=\"https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg\" align=\"top\" width=\"18\" height=\"21\"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>\n\n```ts\nimport Anyformat from 'anyformat-ai';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new Anyformat({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n<img src=\"https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg\" align=\"top\" width=\"18\" height=\"21\"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>\n\n```ts\nimport Anyformat from 'anyformat-ai';\n\nconst client = new Anyformat({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n<img src=\"https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg\" align=\"top\" width=\"18\" height=\"21\"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>\n\n```ts\nimport Anyformat from 'npm:anyformat-ai';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new Anyformat({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/anyformat-ai/anyformat-node/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n",
469
+ },
470
+ ];
471
+ const INDEX_OPTIONS = {
472
+ fields: [
473
+ 'name',
474
+ 'endpoint',
475
+ 'summary',
476
+ 'description',
477
+ 'qualified',
478
+ 'stainlessPath',
479
+ 'content',
480
+ 'sectionContext',
481
+ ],
482
+ storeFields: ['kind', '_original'],
483
+ searchOptions: {
484
+ prefix: true,
485
+ fuzzy: 0.1,
486
+ boost: {
487
+ name: 5,
488
+ stainlessPath: 3,
489
+ endpoint: 3,
490
+ qualified: 3,
491
+ summary: 2,
492
+ content: 1,
493
+ description: 1,
494
+ },
495
+ },
496
+ };
497
+ /**
498
+ * Self-contained local search engine backed by MiniSearch.
499
+ * Method data is embedded at SDK build time; prose documents
500
+ * can be loaded from an optional docs directory at runtime.
501
+ */
502
+ class LocalDocsSearch {
503
+ methodIndex;
504
+ proseIndex;
505
+ constructor() {
506
+ this.methodIndex = new minisearch_1.default(INDEX_OPTIONS);
507
+ this.proseIndex = new minisearch_1.default(INDEX_OPTIONS);
508
+ }
509
+ static async create(opts) {
510
+ const instance = new LocalDocsSearch();
511
+ instance.indexMethods(EMBEDDED_METHODS);
512
+ for (const readme of EMBEDDED_READMES) {
513
+ instance.indexProse(readme.content, `readme:${readme.language}`);
514
+ }
515
+ if (opts?.docsDir) {
516
+ await instance.loadDocsDirectory(opts.docsDir);
517
+ }
518
+ return instance;
519
+ }
520
+ search(props) {
521
+ const { query, language = 'typescript', detail = 'default', maxResults = 5, maxLength = 100_000 } = props;
522
+ const useMarkdown = detail === 'verbose' || detail === 'high';
523
+ // Search both indices and merge results by score.
524
+ // Filter prose hits so language-tagged content (READMEs and docs with
525
+ // frontmatter) only matches the requested language.
526
+ const methodHits = this.methodIndex
527
+ .search(query)
528
+ .map((hit) => ({ ...hit, _kind: 'http_method' }));
529
+ const proseHits = this.proseIndex
530
+ .search(query)
531
+ .filter((hit) => {
532
+ const source = hit['_original']?.source;
533
+ if (!source)
534
+ return true;
535
+ // Check for language-tagged sources: "readme:<lang>" or "lang:<lang>:<filename>"
536
+ let taggedLang;
537
+ if (source.startsWith('readme:'))
538
+ taggedLang = source.slice('readme:'.length);
539
+ else if (source.startsWith('lang:'))
540
+ taggedLang = source.split(':')[1];
541
+ if (!taggedLang)
542
+ return true;
543
+ return taggedLang === language || (language === 'javascript' && taggedLang === 'typescript');
544
+ })
545
+ .map((hit) => ({ ...hit, _kind: 'prose' }));
546
+ const merged = [...methodHits, ...proseHits].sort((a, b) => b.score - a.score);
547
+ const top = merged.slice(0, maxResults);
548
+ const fullResults = [];
549
+ for (const hit of top) {
550
+ const original = hit['_original'];
551
+ if (hit._kind === 'http_method') {
552
+ const m = original;
553
+ if (useMarkdown && m.markdown) {
554
+ fullResults.push(m.markdown);
555
+ }
556
+ else {
557
+ // Use per-language data when available, falling back to the
558
+ // top-level fields (which are TypeScript-specific in the
559
+ // legacy codepath).
560
+ const langData = m.perLanguage?.[language];
561
+ fullResults.push({
562
+ method: langData?.method ?? m.qualified,
563
+ summary: m.summary,
564
+ description: m.description,
565
+ endpoint: `${m.httpMethod.toUpperCase()} ${m.endpoint}`,
566
+ ...(langData?.example ? { example: langData.example } : {}),
567
+ ...(m.params ? { params: m.params } : {}),
568
+ ...(m.response ? { response: m.response } : {}),
569
+ });
570
+ }
571
+ }
572
+ else {
573
+ const c = original;
574
+ fullResults.push({
575
+ content: c.content,
576
+ ...(c.source ? { source: c.source } : {}),
577
+ });
578
+ }
579
+ }
580
+ let totalLength = 0;
581
+ const results = [];
582
+ for (const result of fullResults) {
583
+ const len = typeof result === 'string' ? result.length : JSON.stringify(result).length;
584
+ totalLength += len;
585
+ if (totalLength > maxLength)
586
+ break;
587
+ results.push(result);
588
+ }
589
+ if (results.length < fullResults.length) {
590
+ results.unshift(`Truncated; showing ${results.length} of ${fullResults.length} results.`);
591
+ }
592
+ return { results };
593
+ }
594
+ indexMethods(methods) {
595
+ const docs = methods.map((m, i) => ({
596
+ id: `method-${i}`,
597
+ kind: 'http_method',
598
+ name: m.name,
599
+ endpoint: m.endpoint,
600
+ summary: m.summary,
601
+ description: m.description,
602
+ qualified: m.qualified,
603
+ stainlessPath: m.stainlessPath,
604
+ _original: m,
605
+ }));
606
+ if (docs.length > 0) {
607
+ this.methodIndex.addAll(docs);
608
+ }
609
+ }
610
+ async loadDocsDirectory(docsDir) {
611
+ let entries;
612
+ try {
613
+ entries = await fs.readdir(docsDir, { withFileTypes: true });
614
+ }
615
+ catch (err) {
616
+ (0, logger_1.getLogger)().warn({ err, docsDir }, 'Could not read docs directory');
617
+ return;
618
+ }
619
+ const files = entries
620
+ .filter((e) => e.isFile())
621
+ .filter((e) => e.name.endsWith('.md') || e.name.endsWith('.markdown') || e.name.endsWith('.json'));
622
+ for (const file of files) {
623
+ try {
624
+ const filePath = path.join(docsDir, file.name);
625
+ const content = await fs.readFile(filePath, 'utf-8');
626
+ if (file.name.endsWith('.json')) {
627
+ const texts = extractTexts(JSON.parse(content));
628
+ if (texts.length > 0) {
629
+ this.indexProse(texts.join('\n\n'), file.name);
630
+ }
631
+ }
632
+ else {
633
+ // Parse optional YAML frontmatter for language tagging.
634
+ // Files with a "language" field in frontmatter will only
635
+ // surface in searches for that language.
636
+ //
637
+ // Example:
638
+ // ---
639
+ // language: python
640
+ // ---
641
+ // # Error handling in Python
642
+ // ...
643
+ const frontmatter = parseFrontmatter(content);
644
+ const source = frontmatter.language ? `lang:${frontmatter.language}:${file.name}` : file.name;
645
+ this.indexProse(content, source);
646
+ }
647
+ }
648
+ catch (err) {
649
+ (0, logger_1.getLogger)().warn({ err, file: file.name }, 'Failed to index docs file');
650
+ }
651
+ }
652
+ }
653
+ indexProse(markdown, source) {
654
+ const chunks = chunkMarkdown(markdown);
655
+ const baseId = this.proseIndex.documentCount;
656
+ const docs = chunks.map((chunk, i) => ({
657
+ id: `prose-${baseId + i}`,
658
+ kind: 'prose',
659
+ content: chunk.content,
660
+ ...(chunk.sectionContext != null ? { sectionContext: chunk.sectionContext } : {}),
661
+ _original: { ...chunk, source },
662
+ }));
663
+ if (docs.length > 0) {
664
+ this.proseIndex.addAll(docs);
665
+ }
666
+ }
667
+ }
668
+ exports.LocalDocsSearch = LocalDocsSearch;
669
+ /** Lightweight markdown chunker — splits on headers, chunks by word count. */
670
+ function chunkMarkdown(markdown) {
671
+ // Strip YAML frontmatter
672
+ const stripped = markdown.replace(/^---\n[\s\S]*?\n---\n?/, '');
673
+ const lines = stripped.split('\n');
674
+ const chunks = [];
675
+ const headers = [];
676
+ let current = [];
677
+ const flush = () => {
678
+ const text = current.join('\n').trim();
679
+ if (!text)
680
+ return;
681
+ const sectionContext = headers.length > 0 ? headers.join(' > ') : undefined;
682
+ // Split into ~200-word chunks
683
+ const words = text.split(/\s+/);
684
+ for (let i = 0; i < words.length; i += 200) {
685
+ const slice = words.slice(i, i + 200).join(' ');
686
+ if (slice) {
687
+ chunks.push({ content: slice, tag: 'p', ...(sectionContext != null ? { sectionContext } : {}) });
688
+ }
689
+ }
690
+ current = [];
691
+ };
692
+ for (const line of lines) {
693
+ const headerMatch = line.match(/^(#{1,6})\s+(.+)/);
694
+ if (headerMatch) {
695
+ flush();
696
+ const level = headerMatch[1].length;
697
+ const text = headerMatch[2].trim();
698
+ while (headers.length >= level)
699
+ headers.pop();
700
+ headers.push(text);
701
+ }
702
+ else {
703
+ current.push(line);
704
+ }
705
+ }
706
+ flush();
707
+ return chunks;
708
+ }
709
+ /** Recursively extracts string values from a JSON structure. */
710
+ function extractTexts(data, depth = 0) {
711
+ if (depth > 10)
712
+ return [];
713
+ if (typeof data === 'string')
714
+ return data.trim() ? [data] : [];
715
+ if (Array.isArray(data))
716
+ return data.flatMap((item) => extractTexts(item, depth + 1));
717
+ if (typeof data === 'object' && data !== null) {
718
+ return Object.values(data).flatMap((v) => extractTexts(v, depth + 1));
719
+ }
720
+ return [];
721
+ }
722
+ /** Parses YAML frontmatter from a markdown string, extracting the language field if present. */
723
+ function parseFrontmatter(markdown) {
724
+ const match = markdown.match(/^---\n([\s\S]*?)\n---/);
725
+ if (!match)
726
+ return {};
727
+ const body = match[1] ?? '';
728
+ const langMatch = body.match(/^language:\s*(.+)$/m);
729
+ return langMatch ? { language: langMatch[1].trim() } : {};
730
+ }
731
+ //# sourceMappingURL=local-docs-search.js.map