@tool-bridge/server 0.21.1 → 0.23.0

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 (178) hide show
  1. package/dist/admin.js +170 -0
  2. package/dist/airtable-VMQVXLHK.js +790 -0
  3. package/dist/{alt_text_generator_ai-W7O34SNG.js → alt_text_generator_ai-FTWY4RU4.js} +12 -11
  4. package/dist/{amap-VOX4T2AW.js → amap-OK5VBHYC.js} +221 -220
  5. package/dist/anthropic-S67AZFZ3.js +203 -0
  6. package/dist/apify-ZE6MYQI3.js +248 -0
  7. package/dist/brave_search-TG2M2KOD.js +302 -0
  8. package/dist/chunk-2JNAI4OC.js +161 -0
  9. package/dist/{chunk-KMTT3I6D.js → chunk-4XJPN3DY.js} +19392 -26136
  10. package/dist/chunk-5ICRY3VU.js +8432 -0
  11. package/dist/chunk-7CTWGTDU.js +302 -0
  12. package/dist/chunk-BADVCN6K.js +378 -0
  13. package/dist/{chunk-XYBU3WZH.js → chunk-TDAWLMDE.js} +3 -3
  14. package/dist/chunk-U7PTOA3U.js +7320 -0
  15. package/dist/{chunk-E6JCVKW6.js → chunk-VWRUGUSU.js} +3 -3
  16. package/dist/{chunk-ATK45BXV.js → chunk-WJHG6OK7.js} +4 -2
  17. package/dist/circleci-3L3WJVSK.js +389 -0
  18. package/dist/clerk-EZPF2V7T.js +1019 -0
  19. package/dist/cohere-U27DPO64.js +185 -0
  20. package/dist/{confluence-B3EWPZVE.js → confluence-G2KL6ERH.js} +105 -104
  21. package/dist/{convertapi-EUWSQYPF.js → convertapi-L4CLJ2M3.js} +32 -31
  22. package/dist/{currencyapi-KVTIK3GL.js → currencyapi-YPYXG7YY.js} +71 -71
  23. package/dist/deepseek-6HT6WF3M.js +210 -0
  24. package/dist/docker_hub-LPE3PCVB.js +933 -0
  25. package/dist/dropbox-V56ABHTA.js +1305 -0
  26. package/dist/dub-6OKQ7MHT.js +680 -0
  27. package/dist/e2b-JS2U2QFU.js +278 -0
  28. package/dist/exa-DPWVYXSP.js +332 -0
  29. package/dist/{fal_ai-23E7JPNT.js → fal_ai-DK6Y27ZF.js} +81 -80
  30. package/dist/{feishu-7QRIDUV6.js → feishu-K7EGSRF3.js} +528 -572
  31. package/dist/{feishu_custom_bot-TJ4K7QNJ.js → feishu_custom_bot-2JUGFYNG.js} +57 -53
  32. package/dist/figma-FT5I7ITD.js +777 -0
  33. package/dist/firehydrant-EIKLKHX2.js +563 -0
  34. package/dist/{fixer-BWON27UO.js → fixer-U5QXIAKD.js} +34 -33
  35. package/dist/fly-T3JYFZ2M.js +469 -0
  36. package/dist/{front-QCGXYEDJ.js → front-D72MGVOR.js} +104 -104
  37. package/dist/geocodio-BOTD5TI5.js +213 -0
  38. package/dist/ghost-KYP7SZGB.js +338 -0
  39. package/dist/github-AGMZT3VY.js +5421 -0
  40. package/dist/gmail-BLJNJOBG.js +1887 -0
  41. package/dist/googlecalendar-GTHWNCF6.js +2524 -0
  42. package/dist/{googledocs-BUHL4J2H.js → googledocs-6EEDMEBQ.js} +341 -340
  43. package/dist/{grafana-GLU2DWF2.js → grafana-GMW6EKSQ.js} +221 -220
  44. package/dist/graphhopper-6OLGBDGB.js +325 -0
  45. package/dist/index.d.ts +1132 -332
  46. package/dist/index.js +31 -14
  47. package/dist/{ip2proxy-EZ64Y4ZH.js → ip2proxy-4QN42E6T.js} +28 -27
  48. package/dist/ipgeolocation_io-SK4XKDA2.js +315 -0
  49. package/dist/ipqualityscore-6ANBPXKT.js +279 -0
  50. package/dist/{jina_ai-EFBHTBXL.js → jina_ai-IHPSVRM5.js} +23 -23
  51. package/dist/{jira-HQSHAA5K.js → jira-46KKM4LC.js} +118 -117
  52. package/dist/langsmith-JZA345I5.js +593 -0
  53. package/dist/lemlist-43IV7DK6.js +289 -0
  54. package/dist/{linear-K7RYFYAD.js → linear-5LFH7XNL.js} +327 -326
  55. package/dist/logsnag-5RMYAHIL.js +150 -0
  56. package/dist/main.js +57 -280
  57. package/dist/{mattermost-S2BRCWLQ.js → mattermost-XFL6SHGG.js} +59 -58
  58. package/dist/mem0-NYO4DTP6.js +544 -0
  59. package/dist/memos-37MPQOLV.js +744 -0
  60. package/dist/{metabase-MMSEPCOF.js → metabase-KYBKZFMG.js} +90 -89
  61. package/dist/mistral_ai-6PL3K4PM.js +1196 -0
  62. package/dist/{mother_duck-H7PCQNZ2.js → mother_duck-2NH7W5M5.js} +94 -93
  63. package/dist/ngrok-UO6CDYCA.js +356 -0
  64. package/dist/{notes-PFMKRO33.js → notes-I3P32WP4.js} +11 -9
  65. package/dist/notion-BEAJFUOE.js +940 -0
  66. package/dist/open_exchange_rates-CMF62JB4.js +215 -0
  67. package/dist/openai-IHOMKVND.js +800 -0
  68. package/dist/opengraph_io-ZQ2FGLHX.js +362 -0
  69. package/dist/openrouter-HXLW3NR5.js +441 -0
  70. package/dist/outline-ELCP4NEU.js +599 -0
  71. package/dist/paddle-O77LALVN.js +454 -0
  72. package/dist/perplexity-JCU654QV.js +220 -0
  73. package/dist/pinecone-W5W4LRKL.js +571 -0
  74. package/dist/{pipedrive-Y2O7QGFF.js → pipedrive-ITMJLLPZ.js} +99 -98
  75. package/dist/polar-R33XU4L3.js +395 -0
  76. package/dist/posthog-JVNTOLTV.js +3464 -0
  77. package/dist/postmark-6SBG7HWV.js +427 -0
  78. package/dist/{prerender-MENYM2TY.js → prerender-GPNKTNFC.js} +31 -30
  79. package/dist/{pubmed-GOXUVVH5.js → pubmed-UP6ZEEIH.js} +239 -238
  80. package/dist/{railway-V2SID4WV.js → railway-KWEWXHTY.js} +118 -117
  81. package/dist/readwise-BLATSMC3.js +470 -0
  82. package/dist/render-QYRVIXII.js +461 -0
  83. package/dist/{replicate-756MXPYX.js → replicate-JYTWH4NF.js} +81 -80
  84. package/dist/{resend-ZKH3BTBI.js → resend-L5N75SZM.js} +20 -16
  85. package/dist/rootly-MHCPEQ26.js +336 -0
  86. package/dist/{scrapfly-NSRHFDIQ.js → scrapfly-PTPGYSJM.js} +62 -61
  87. package/dist/{scrapingbee-OQHLAVEY.js → scrapingbee-JN6UH5PY.js} +56 -56
  88. package/dist/{screenshot_fyi-DVWG3AXC.js → screenshot_fyi-4QRVSV55.js} +16 -16
  89. package/dist/semantic_scholar-LRSWA2GE.js +611 -0
  90. package/dist/{sentry-546MNDJG.js → sentry-2G6PF5W6.js} +208 -207
  91. package/dist/{shodan-C3OON3Z3.js → shodan-WKKPP5C6.js} +62 -61
  92. package/dist/shopify-64YDK5T2.js +610 -0
  93. package/dist/stripe-QAIGGOTF.js +585 -0
  94. package/dist/{supabase-U2SL4D63.js → supabase-WHTGR6ND.js} +245 -244
  95. package/dist/tavily-QIXCDDWO.js +326 -0
  96. package/dist/telegram-E6G7CWI6.js +1767 -0
  97. package/dist/{telnyx-CXQ4EZUX.js → telnyx-ZDVVS7PK.js} +57 -56
  98. package/dist/todoist-DMYF3G7J.js +664 -0
  99. package/dist/trello-HY2RYIRP.js +1080 -0
  100. package/dist/turso-HAQWMGRP.js +416 -0
  101. package/dist/{twilio-4PDBJKWX.js → twilio-MLXYPHJE.js} +70 -69
  102. package/dist/umami-DZHBLPVG.js +389 -0
  103. package/dist/unsplash-GS2OPXKE.js +351 -0
  104. package/dist/{upstash_redis-G4LQBYHA.js → upstash_redis-XMXWTNAJ.js} +51 -50
  105. package/dist/uptimerobot-TF5WRZ4G.js +483 -0
  106. package/dist/v2ex-2BVXAPDF.js +667 -0
  107. package/dist/vercel-YMJGQYJE.js +1076 -0
  108. package/dist/{wolfram_alpha_api-3G4PUJWB.js → wolfram_alpha_api-I56SXWFZ.js} +36 -35
  109. package/dist/wordpress-R7TDFZ2P.js +812 -0
  110. package/dist/workos-HDNHWVMS.js +664 -0
  111. package/dist/zhihu-LX6AGGDS.js +254 -0
  112. package/package.json +18 -9
  113. package/dist/airtable-LLZDFN7M.js +0 -789
  114. package/dist/anthropic-G23NN3X5.js +0 -202
  115. package/dist/apify-Y3SS734K.js +0 -247
  116. package/dist/brave_search-ZC7OAPSZ.js +0 -301
  117. package/dist/chunk-R6P4XAE5.js +0 -248
  118. package/dist/chunk-U7B6DS2O.js +0 -977
  119. package/dist/chunk-UZM2RXZH.js +0 -23436
  120. package/dist/circleci-3BAX5FCG.js +0 -388
  121. package/dist/clerk-6LEM6TNU.js +0 -1019
  122. package/dist/cloudflare_dns-KINYTJUD.js +0 -588
  123. package/dist/cohere-XCJ5AJ6B.js +0 -185
  124. package/dist/deepseek-PC5YGNC5.js +0 -209
  125. package/dist/docker_hub-C3MA5FU6.js +0 -932
  126. package/dist/dropbox-XBV7Z2IR.js +0 -1304
  127. package/dist/dub-LDOFG3HC.js +0 -679
  128. package/dist/e2b-JMCPSVBW.js +0 -277
  129. package/dist/exa-RAK7O7RD.js +0 -331
  130. package/dist/figma-E6IX5DTH.js +0 -773
  131. package/dist/firehydrant-ZBLPQREE.js +0 -562
  132. package/dist/fly-ZH3HFCZJ.js +0 -468
  133. package/dist/geocodio-YGNI7DA4.js +0 -212
  134. package/dist/ghost-EVSGKH2Q.js +0 -337
  135. package/dist/github-MA2BGRCJ.js +0 -5420
  136. package/dist/gmail-E5E6AADE.js +0 -1886
  137. package/dist/googlecalendar-BTLFPXTD.js +0 -2523
  138. package/dist/graphhopper-WSMB3TCD.js +0 -324
  139. package/dist/ipgeolocation_io-AA7HAS22.js +0 -315
  140. package/dist/ipqualityscore-BHJXVTJT.js +0 -277
  141. package/dist/langsmith-5W6SCT6F.js +0 -592
  142. package/dist/lemlist-HJWH6UMK.js +0 -288
  143. package/dist/logsnag-4KFOHL37.js +0 -150
  144. package/dist/mem0-CAW43CIC.js +0 -543
  145. package/dist/memos-TWEGPKFM.js +0 -740
  146. package/dist/mistral_ai-64BGZQHP.js +0 -1195
  147. package/dist/ngrok-GQCUGZKJ.js +0 -356
  148. package/dist/notion-DQWZWP4N.js +0 -936
  149. package/dist/open_exchange_rates-QMMD735E.js +0 -214
  150. package/dist/openai-W6PX32NZ.js +0 -799
  151. package/dist/opengraph_io-HNDBXYNW.js +0 -361
  152. package/dist/openrouter-JJYMEAUL.js +0 -437
  153. package/dist/outline-MCBNQZYY.js +0 -595
  154. package/dist/paddle-D2SKLUDN.js +0 -453
  155. package/dist/perplexity-XIFMKUAE.js +0 -219
  156. package/dist/pinecone-HUFTALV2.js +0 -570
  157. package/dist/polar-TYTOMOSR.js +0 -394
  158. package/dist/posthog-43JAR3VW.js +0 -3463
  159. package/dist/postmark-KL2QJYSG.js +0 -426
  160. package/dist/readwise-CI4GIMMJ.js +0 -469
  161. package/dist/render-SUBJ6YRZ.js +0 -460
  162. package/dist/rootly-CD2LJHPI.js +0 -336
  163. package/dist/semantic_scholar-T4A252KW.js +0 -610
  164. package/dist/shopify-Y2HN2MCQ.js +0 -609
  165. package/dist/stripe-VE3CD3AY.js +0 -584
  166. package/dist/tavily-KCZHK6HE.js +0 -326
  167. package/dist/telegram-3URFBCMY.js +0 -1766
  168. package/dist/todoist-HNPWNYTD.js +0 -663
  169. package/dist/trello-3W2MIXRP.js +0 -1079
  170. package/dist/turso-2EQF7C2Z.js +0 -415
  171. package/dist/umami-5REN7TGP.js +0 -388
  172. package/dist/unsplash-EIXL424F.js +0 -350
  173. package/dist/uptimerobot-KNJ3EYLY.js +0 -482
  174. package/dist/v2ex-RHJ234PZ.js +0 -666
  175. package/dist/vercel-AS6NCIC7.js +0 -1075
  176. package/dist/wordpress-KNDAAUV7.js +0 -811
  177. package/dist/workos-R6UITSJ7.js +0 -663
  178. package/dist/zhihu-AGK4HILK.js +0 -253
@@ -1,799 +0,0 @@
1
- import {
2
- bytesToBase64,
3
- readBoundedResponseBytes
4
- } from "./chunk-LMLX3DJF.js";
5
- import {
6
- createAuthedClient
7
- } from "./chunk-XYBU3WZH.js";
8
- import "./chunk-E6JCVKW6.js";
9
- import {
10
- trimmedText
11
- } from "./chunk-JXHMDBAY.js";
12
- import {
13
- createProviderPlugin,
14
- requireApiKey,
15
- upstreamError
16
- } from "./chunk-ATK45BXV.js";
17
- import {
18
- assertPublicHttpUrl,
19
- guardedFetch
20
- } from "./chunk-U7B6DS2O.js";
21
- import {
22
- TBError,
23
- external_exports
24
- } from "./chunk-UZM2RXZH.js";
25
- import "./chunk-U67V476Y.js";
26
-
27
- // ../plugins/src/openai/api.ts
28
- var SERVICE = "openai";
29
- var API_BASE = "https://api.openai.com/v1";
30
- var AUDIO_SOURCE_MAX_BYTES = 25 * 1024 * 1024;
31
- var AUDIO_SOURCE_FETCH_TIMEOUT_MS = 3e4;
32
- function normalizedContentType(value, fallback) {
33
- if (value === null || value === "") return fallback;
34
- return value.split(";", 1)[0]?.trim() || fallback;
35
- }
36
- function stripPadding(value) {
37
- let end = value.length;
38
- while (end > 0 && value[end - 1] === "=") end -= 1;
39
- return value.slice(0, end);
40
- }
41
- function decodeBase64Content(value, fieldName) {
42
- try {
43
- const binary = atob(value);
44
- if (binary.length === 0) throw new Error("empty");
45
- const bytes = new Uint8Array(binary.length);
46
- for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
47
- if (stripPadding(bytesToBase64(bytes)) !== stripPadding(value)) throw new Error("mismatch");
48
- return bytes;
49
- } catch {
50
- throw new TBError("invalid_argument", `${fieldName} must be valid base64`);
51
- }
52
- }
53
- function assertAudioSourceSize(byteLength, fieldName) {
54
- if (byteLength > AUDIO_SOURCE_MAX_BYTES) {
55
- throw new TBError("invalid_argument", `${fieldName} exceeds ${AUDIO_SOURCE_MAX_BYTES} bytes`);
56
- }
57
- }
58
- function baseHeaders(apiKey) {
59
- return { accept: "application/json", authorization: `Bearer ${apiKey}` };
60
- }
61
- function jsonHeaders(apiKey) {
62
- return { ...baseHeaders(apiKey), "content-type": "application/json" };
63
- }
64
- async function errorMessage(response) {
65
- const fallback = `openai request failed with ${response.status}`;
66
- const body = await response.text().catch(() => "");
67
- try {
68
- const payload = JSON.parse(body);
69
- const message = payload.error?.message ?? payload.message;
70
- if (typeof message === "string" && message !== "") return message;
71
- } catch {
72
- }
73
- return body.trim() || fallback;
74
- }
75
- async function rawRequest(ctx, input) {
76
- const apiKey = requireApiKey(ctx, SERVICE);
77
- let body;
78
- let headers;
79
- if (input.body instanceof FormData) {
80
- body = input.body;
81
- headers = input.headers ?? baseHeaders(apiKey);
82
- } else if (input.body !== void 0) {
83
- body = JSON.stringify(input.body);
84
- headers = input.headers ?? jsonHeaders(apiKey);
85
- } else {
86
- headers = input.headers ?? baseHeaders(apiKey);
87
- }
88
- const method = input.method ?? "GET";
89
- let response;
90
- try {
91
- response = await guardedFetch(`${API_BASE}${input.path}`, { method, headers, body });
92
- } catch (error) {
93
- const message = error instanceof Error ? error.message : "unknown network error";
94
- throw upstreamError(502, `openai ${method} ${input.path} failed before receiving response: ${message}`);
95
- }
96
- if (!response.ok) throw upstreamError(response.status, await errorMessage(response));
97
- return response;
98
- }
99
- function errorMessageFromContext(context) {
100
- const fallback = `openai request failed with ${context.status}`;
101
- const payload = context.data;
102
- const message = payload !== null && typeof payload === "object" ? payload.error?.message ?? payload.message : void 0;
103
- if (typeof message === "string" && message !== "") return message;
104
- return context.rawText?.trim() || fallback;
105
- }
106
- var http = createAuthedClient({
107
- baseUrl: `${API_BASE}/`,
108
- service: SERVICE,
109
- auth: { kind: "bearer" },
110
- headers: { accept: "application/json" },
111
- // 提取不 trim 且兜底回显 rawText 原文,标准键序提取表达不了,整段覆写。
112
- mapError: (context) => upstreamError(context.status, errorMessageFromContext(context)),
113
- mapTransportError: ({ message }) => upstreamError(
114
- 502,
115
- `openai request failed before receiving response: ${message ?? "unknown network error"}`
116
- )
117
- });
118
- async function jsonRequest(ctx, input) {
119
- if (input.body instanceof FormData) {
120
- throw new TBError("internal", "openai jsonRequest cannot send multipart data");
121
- }
122
- const result = await http.request(ctx, {
123
- path: input.path,
124
- method: input.method ?? "GET",
125
- headers: input.headers,
126
- ...input.body === void 0 ? {} : { json: input.body },
127
- invalidJsonMessage: "OpenAI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
128
- });
129
- return result.data;
130
- }
131
- function assertStreamingDisabled(input) {
132
- if (input.stream === true) {
133
- throw new TBError("invalid_argument", "stream=true is not supported by connector actions");
134
- }
135
- }
136
- function appendQueryValue(url, key, value) {
137
- if (value === void 0 || value === null) return;
138
- if (Array.isArray(value)) {
139
- for (const item of value) appendQueryValue(url, key, item);
140
- return;
141
- }
142
- if (typeof value === "object") {
143
- url.searchParams.append(key, JSON.stringify(value));
144
- return;
145
- }
146
- url.searchParams.append(key, String(value));
147
- }
148
- function withQuery(path, query) {
149
- const url = new URL(path, API_BASE);
150
- for (const [key, value] of Object.entries(query)) appendQueryValue(url, key, value);
151
- return `${url.pathname}${url.search}`;
152
- }
153
- async function readBoundedBytes(response, fieldName) {
154
- return readBoundedResponseBytes(response, {
155
- maxBytes: AUDIO_SOURCE_MAX_BYTES,
156
- tooLarge: () => new TBError(
157
- "invalid_argument",
158
- `${fieldName} exceeds ${AUDIO_SOURCE_MAX_BYTES} bytes`
159
- )
160
- });
161
- }
162
- async function fetchAudioSource(url) {
163
- try {
164
- assertPublicHttpUrl(url);
165
- } catch (error) {
166
- throw new TBError("invalid_argument", `file.url ${error instanceof Error ? error.message : "\u4E0D\u53EF\u7528"}`);
167
- }
168
- let response;
169
- try {
170
- response = await guardedFetch(url, { signal: AbortSignal.timeout(AUDIO_SOURCE_FETCH_TIMEOUT_MS) });
171
- } catch (error) {
172
- if (error instanceof Error && error.name === "TimeoutError") {
173
- throw upstreamError(504, "failed to fetch audio source: request timed out");
174
- }
175
- const message = error instanceof Error ? error.message : "unknown network error";
176
- throw upstreamError(502, `failed to fetch audio source: ${message}`);
177
- }
178
- if (!response.ok) throw upstreamError(502, `failed to fetch audio source: ${response.status}`);
179
- return response;
180
- }
181
- async function resolveAudioUploadSource(input) {
182
- const file = input.file;
183
- const fileUrl = trimmedText(file.url);
184
- const contentBase64 = trimmedText(file.content_base64);
185
- const mimeType = trimmedText(file.mimetype);
186
- if (fileUrl === void 0 && contentBase64 === void 0) {
187
- throw new TBError("invalid_argument", "file.url or file.content_base64 is required");
188
- }
189
- if (fileUrl !== void 0 && contentBase64 !== void 0) {
190
- throw new TBError("invalid_argument", "provide only one of file.url or file.content_base64");
191
- }
192
- if (fileUrl !== void 0) {
193
- const response = await fetchAudioSource(fileUrl);
194
- return {
195
- bytes: await readBoundedBytes(response, "file.url"),
196
- fileName: file.name,
197
- mimeType: normalizedContentType(response.headers.get("content-type"), mimeType ?? "application/octet-stream")
198
- };
199
- }
200
- const bytes = decodeBase64Content(contentBase64, "file.content_base64");
201
- assertAudioSourceSize(bytes.byteLength, "file.content_base64");
202
- return { bytes, fileName: file.name, mimeType: mimeType ?? "application/octet-stream" };
203
- }
204
- function appendMultipartField(formData, key, value) {
205
- if (value === void 0 || value === null) return;
206
- if (typeof value === "string") {
207
- formData.append(key, value);
208
- return;
209
- }
210
- if (typeof value === "number" || typeof value === "boolean") {
211
- formData.append(key, String(value));
212
- return;
213
- }
214
- formData.append(key, JSON.stringify(value));
215
- }
216
- async function buildAudioFormData(input, arrayFieldMap = {}) {
217
- const source = await resolveAudioUploadSource(input);
218
- const formData = new FormData();
219
- formData.set("file", new File([source.bytes], source.fileName, { type: source.mimeType }));
220
- for (const [key, value] of Object.entries(input)) {
221
- if (key === "file" || value === void 0 || value === null) continue;
222
- if (Array.isArray(value)) {
223
- const targetKey = arrayFieldMap[key] ?? key;
224
- for (const item of value) appendMultipartField(formData, targetKey, item);
225
- continue;
226
- }
227
- appendMultipartField(formData, key, value);
228
- }
229
- return formData;
230
- }
231
- async function readJsonOrTextResponse(response) {
232
- if (normalizedContentType(response.headers.get("content-type"), "") === "application/json") {
233
- return response.json();
234
- }
235
- return { text: await response.text() };
236
- }
237
- function inferSpeechContentType(responseFormat) {
238
- switch (responseFormat) {
239
- case "wav":
240
- return "audio/wav";
241
- case "opus":
242
- return "audio/opus";
243
- case "aac":
244
- return "audio/aac";
245
- case "flac":
246
- return "audio/flac";
247
- case "pcm":
248
- return "audio/pcm";
249
- default:
250
- return "audio/mpeg";
251
- }
252
- }
253
- async function listModels(_input, ctx) {
254
- return jsonRequest(ctx, { path: "/models" });
255
- }
256
- async function getModel(input, ctx) {
257
- return jsonRequest(ctx, { path: `/models/${encodeURIComponent(input.model)}` });
258
- }
259
- async function createResponse(input, ctx) {
260
- assertStreamingDisabled(input);
261
- return jsonRequest(ctx, { method: "POST", path: "/responses", body: input });
262
- }
263
- async function getResponse(input, ctx) {
264
- return jsonRequest(ctx, {
265
- path: withQuery(`/responses/${encodeURIComponent(input.response_id)}`, { include: input.include })
266
- });
267
- }
268
- async function listInputItems(input, ctx) {
269
- return jsonRequest(ctx, {
270
- path: withQuery(`/responses/${encodeURIComponent(input.response_id)}/input_items`, {
271
- after: input.after,
272
- include: input.include,
273
- limit: input.limit,
274
- order: input.order
275
- })
276
- });
277
- }
278
- async function getInputTokenCounts(input, ctx) {
279
- return jsonRequest(ctx, { method: "POST", path: "/responses/input_tokens", body: input });
280
- }
281
- async function createEmbeddings(input, ctx) {
282
- return jsonRequest(ctx, { method: "POST", path: "/embeddings", body: input });
283
- }
284
- async function createModeration(input, ctx) {
285
- return jsonRequest(ctx, { method: "POST", path: "/moderations", body: input });
286
- }
287
- async function createImage(input, ctx) {
288
- assertStreamingDisabled(input);
289
- return jsonRequest(ctx, { method: "POST", path: "/images/generations", body: input });
290
- }
291
- async function createSpeech(input, ctx) {
292
- if (input.stream_format === "sse") {
293
- throw new TBError("invalid_argument", "stream_format=sse is not supported by connector actions");
294
- }
295
- const response = await rawRequest(ctx, {
296
- method: "POST",
297
- path: "/audio/speech",
298
- body: input,
299
- // 语音接口回的是音频字节,accept 必须放开,否则上游会按 JSON 协商拒绝。
300
- headers: { ...jsonHeaders(requireApiKey(ctx, SERVICE)), accept: "*/*" }
301
- });
302
- return {
303
- content_base64: bytesToBase64(new Uint8Array(await response.arrayBuffer())),
304
- content_type: normalizedContentType(
305
- response.headers.get("content-type"),
306
- inferSpeechContentType(input.response_format)
307
- )
308
- };
309
- }
310
- async function createAudioTranscription(input, ctx) {
311
- assertStreamingDisabled(input);
312
- const response = await rawRequest(ctx, {
313
- method: "POST",
314
- path: "/audio/transcriptions",
315
- body: await buildAudioFormData(input, {
316
- include: "include[]",
317
- timestamp_granularities: "timestamp_granularities[]"
318
- })
319
- });
320
- return readJsonOrTextResponse(response);
321
- }
322
- async function createAudioTranslation(input, ctx) {
323
- const response = await rawRequest(ctx, {
324
- method: "POST",
325
- path: "/audio/translations",
326
- body: await buildAudioFormData(input)
327
- });
328
- return readJsonOrTextResponse(response);
329
- }
330
- async function createBatch(input, ctx) {
331
- return jsonRequest(ctx, { method: "POST", path: "/batches", body: input });
332
- }
333
- async function getBatch(input, ctx) {
334
- return jsonRequest(ctx, { path: `/batches/${encodeURIComponent(input.batch_id)}` });
335
- }
336
- async function cancelBatch(input, ctx) {
337
- return jsonRequest(ctx, { method: "POST", path: `/batches/${encodeURIComponent(input.batch_id)}/cancel` });
338
- }
339
-
340
- // ../plugins/src/openai/schema.ts
341
- var listModelsInput = external_exports.looseObject({}).describe("No input parameters are required for this action.");
342
- var listModelsOutput = external_exports.looseObject({
343
- object: external_exports.string().describe("The top-level object type."),
344
- data: external_exports.array(external_exports.looseObject({
345
- id: external_exports.string().describe("The model identifier."),
346
- object: external_exports.string().describe("The object type returned by the API."),
347
- created: external_exports.int().describe("The Unix timestamp when the model was created."),
348
- owned_by: external_exports.string().describe("The organization or user that owns the model."),
349
- root: external_exports.string().describe("The root model identifier for a derived model.").optional(),
350
- parent: external_exports.string().describe("The immediate parent model identifier, if any.").nullable().optional(),
351
- permission: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The permission entries returned for the model.").optional()
352
- }).describe("An OpenAI model entry.")).describe("The list of available models.")
353
- }).describe("The response payload for listing OpenAI models.");
354
- var getModelInput = external_exports.looseObject({
355
- model: external_exports.string().describe("The exact model identifier to retrieve.")
356
- }).describe("The input payload for retrieving a single OpenAI model.");
357
- var getModelOutput = external_exports.looseObject({
358
- id: external_exports.string().describe("The model identifier."),
359
- object: external_exports.string().describe("The object type returned by the API."),
360
- created: external_exports.int().describe("The Unix timestamp when the model was created."),
361
- owned_by: external_exports.string().describe("The organization or user that owns the model."),
362
- root: external_exports.string().describe("The root model identifier for a derived model.").optional(),
363
- parent: external_exports.string().describe("The immediate parent model identifier, if any.").nullable().optional(),
364
- permission: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The permission entries returned for the model.").optional()
365
- }).describe("An OpenAI model entry.");
366
- var createResponseInput = external_exports.looseObject({
367
- model: external_exports.string().describe("The model to use for the response."),
368
- input: external_exports.union([external_exports.string().describe("A plain text prompt."), external_exports.array(external_exports.strictObject({
369
- role: external_exports.enum(["system", "user", "assistant", "developer"]).describe("The role of the message author."),
370
- content: external_exports.union([external_exports.string().describe("Plain text content for a simple message."), external_exports.array(external_exports.union([external_exports.strictObject({
371
- type: external_exports.literal("input_text").describe("The content type. Must be input_text."),
372
- text: external_exports.string().describe("The text content sent to the model.")
373
- }).describe("A text content block for a response input message."), external_exports.strictObject({
374
- type: external_exports.literal("input_image").describe("The content type. Must be input_image."),
375
- image_url: external_exports.string().describe("A remote image URL or a data URL containing the image bytes."),
376
- detail: external_exports.enum(["auto", "low", "high", "original"]).describe("The requested image detail level.").optional()
377
- }).describe("An image content block for a response input message."), external_exports.strictObject({
378
- type: external_exports.literal("input_file").describe("The content type. Must be input_file."),
379
- file_id: external_exports.string().describe("The uploaded file ID to reference.").optional(),
380
- file_data: external_exports.string().describe("The inline file data encoded as base64 or supplied as a data URL.").optional(),
381
- filename: external_exports.string().describe("The filename to report for inline file data.").optional()
382
- }).describe("A file content block for a response input message.")])).min(1).describe("Structured multimodal content blocks.")])
383
- }).describe("A message in the Responses API input array.")).min(1).describe("An ordered array of conversation messages.")]),
384
- instructions: external_exports.string().describe("A top-level instruction string applied before the input.").optional(),
385
- max_output_tokens: external_exports.int().min(1).describe("The maximum number of output tokens to generate.").optional(),
386
- metadata: external_exports.record(external_exports.string(), external_exports.string().describe("Metadata field value.")).describe("String metadata fields attached to the request.").optional(),
387
- previous_response_id: external_exports.string().describe("The ID of a previous response to continue from.").optional(),
388
- store: external_exports.boolean().describe("Whether the response may be stored by the upstream platform.").optional(),
389
- temperature: external_exports.number().min(0).max(2).describe("The sampling temperature.").optional(),
390
- text: external_exports.strictObject({
391
- format: external_exports.union([external_exports.strictObject({
392
- type: external_exports.literal("json_object").describe("The format type. Must be json_object.")
393
- }).describe("A flexible JSON object output format."), external_exports.strictObject({
394
- type: external_exports.literal("json_schema").describe("The format type. Must be json_schema."),
395
- name: external_exports.string().describe("The schema name reported to the model."),
396
- schema: external_exports.looseObject({}).describe("Any JSON object."),
397
- strict: external_exports.boolean().describe("Whether the model must strictly follow the declared schema.").optional()
398
- }).describe("A JSON Schema output format.")]).optional()
399
- }).describe("Text output configuration for the response.").optional(),
400
- top_p: external_exports.number().min(0).max(1).describe("The nucleus sampling threshold.").optional(),
401
- user: external_exports.string().describe("An end-user identifier passed through to the upstream API.").optional(),
402
- stream: external_exports.boolean().describe("Whether to request a streaming response. This connector only accepts false or an omitted value.").optional()
403
- }).describe("The input payload for creating a non-streaming OpenAI response.");
404
- var createResponseOutput = external_exports.looseObject({
405
- id: external_exports.string().describe("The response identifier."),
406
- object: external_exports.string().describe("The top-level object type.").optional(),
407
- created_at: external_exports.int().describe("The Unix timestamp when the response was created.").optional(),
408
- status: external_exports.string().describe("The response status.").optional(),
409
- model: external_exports.string().describe("The model that generated the response.").optional(),
410
- output: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The raw output items returned by the response."),
411
- output_text: external_exports.string().describe("The aggregated plain text extracted from the output items.").optional(),
412
- usage: external_exports.looseObject({}).describe("Any JSON object.").optional(),
413
- error: external_exports.looseObject({}).describe("Any JSON object.").nullable().optional(),
414
- incomplete_details: external_exports.looseObject({}).describe("Any JSON object.").nullable().optional(),
415
- previous_response_id: external_exports.string().describe("The previous response ID referenced by this response.").nullable().optional(),
416
- store: external_exports.boolean().describe("Whether the response is stored by the upstream platform.").optional(),
417
- expire_at: external_exports.int().describe("The Unix timestamp when the stored response expires.").optional()
418
- }).describe("The response payload returned by the OpenAI Responses API.");
419
- var getResponseInput = external_exports.looseObject({
420
- response_id: external_exports.string().describe("The response identifier."),
421
- include: external_exports.array(external_exports.string().describe("One response field path to include.")).min(1).describe("Additional response fields to include in the result.").optional()
422
- }).describe("The input payload for retrieving one stored OpenAI response.");
423
- var getResponseOutput = external_exports.looseObject({
424
- id: external_exports.string().describe("The response identifier."),
425
- object: external_exports.string().describe("The top-level object type.").optional(),
426
- created_at: external_exports.int().describe("The Unix timestamp when the response was created.").optional(),
427
- status: external_exports.string().describe("The response status.").optional(),
428
- model: external_exports.string().describe("The model that generated the response.").optional(),
429
- output: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The raw output items returned by the response."),
430
- output_text: external_exports.string().describe("The aggregated plain text extracted from the output items.").optional(),
431
- usage: external_exports.looseObject({}).describe("Any JSON object.").optional(),
432
- error: external_exports.looseObject({}).describe("Any JSON object.").nullable().optional(),
433
- incomplete_details: external_exports.looseObject({}).describe("Any JSON object.").nullable().optional(),
434
- previous_response_id: external_exports.string().describe("The previous response ID referenced by this response.").nullable().optional(),
435
- store: external_exports.boolean().describe("Whether the response is stored by the upstream platform.").optional(),
436
- expire_at: external_exports.int().describe("The Unix timestamp when the stored response expires.").optional()
437
- }).describe("The response payload returned by the OpenAI Responses API.");
438
- var listInputItemsInput = external_exports.looseObject({
439
- response_id: external_exports.string().describe("The response identifier whose input items should be listed."),
440
- after: external_exports.string().describe("Return items after this item identifier.").optional(),
441
- include: external_exports.array(external_exports.string().describe("One input item field path to include.")).min(1).describe("Additional input item fields to include in the result.").optional(),
442
- limit: external_exports.int().min(1).describe("The maximum number of input items to return.").optional(),
443
- order: external_exports.enum(["asc", "desc"]).describe("The sort order for returned items.").optional()
444
- }).describe("The input payload for listing stored response input items.");
445
- var listInputItemsOutput = external_exports.looseObject({
446
- object: external_exports.string().describe("The object type returned by the API.").optional(),
447
- data: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The returned input items."),
448
- first_id: external_exports.string().describe("The first item identifier in the page.").optional(),
449
- last_id: external_exports.string().describe("The last item identifier in the page.").optional(),
450
- has_more: external_exports.boolean().describe("Whether more input items are available.").optional()
451
- }).describe("The response payload for listing stored response input items.");
452
- var getInputTokenCountsInput = external_exports.looseObject({
453
- model: external_exports.string().describe("The model used for counting the input tokens.").optional(),
454
- input: external_exports.union([external_exports.string().describe("A plain text prompt."), external_exports.array(external_exports.strictObject({
455
- role: external_exports.enum(["system", "user", "assistant", "developer"]).describe("The role of the message author."),
456
- content: external_exports.union([external_exports.string().describe("Plain text content for a simple message."), external_exports.array(external_exports.union([external_exports.strictObject({
457
- type: external_exports.literal("input_text").describe("The content type. Must be input_text."),
458
- text: external_exports.string().describe("The text content sent to the model.")
459
- }).describe("A text content block for a response input message."), external_exports.strictObject({
460
- type: external_exports.literal("input_image").describe("The content type. Must be input_image."),
461
- image_url: external_exports.string().describe("A remote image URL or a data URL containing the image bytes."),
462
- detail: external_exports.enum(["auto", "low", "high", "original"]).describe("The requested image detail level.").optional()
463
- }).describe("An image content block for a response input message."), external_exports.strictObject({
464
- type: external_exports.literal("input_file").describe("The content type. Must be input_file."),
465
- file_id: external_exports.string().describe("The uploaded file ID to reference.").optional(),
466
- file_data: external_exports.string().describe("The inline file data encoded as base64 or supplied as a data URL.").optional(),
467
- filename: external_exports.string().describe("The filename to report for inline file data.").optional()
468
- }).describe("A file content block for a response input message.")])).min(1).describe("Structured multimodal content blocks.")])
469
- }).describe("A message in the Responses API input array.")).min(1).describe("An ordered array of conversation messages.")]).optional(),
470
- instructions: external_exports.string().describe("Top-level instructions to include in the token count.").optional(),
471
- previous_response_id: external_exports.string().describe("A previous response identifier to continue counting from.").optional(),
472
- text: external_exports.strictObject({
473
- format: external_exports.union([external_exports.strictObject({
474
- type: external_exports.literal("json_object").describe("The format type. Must be json_object.")
475
- }).describe("A flexible JSON object output format."), external_exports.strictObject({
476
- type: external_exports.literal("json_schema").describe("The format type. Must be json_schema."),
477
- name: external_exports.string().describe("The schema name reported to the model."),
478
- schema: external_exports.looseObject({}).describe("Any JSON object."),
479
- strict: external_exports.boolean().describe("Whether the model must strictly follow the declared schema.").optional()
480
- }).describe("A JSON Schema output format.")]).optional()
481
- }).describe("Text output configuration for the response.").optional(),
482
- truncation: external_exports.string().describe("The truncation mode to apply before counting.").optional()
483
- }).describe("The input payload for counting input tokens for a Responses-style request.");
484
- var getInputTokenCountsOutput = external_exports.looseObject({
485
- object: external_exports.string().describe("The object type returned by the API.").optional(),
486
- input_tokens: external_exports.int().describe("The number of input tokens the request would consume.")
487
- }).describe("The token count payload returned by the Responses input token count API.");
488
- var createEmbeddingsInput = external_exports.looseObject({
489
- input: external_exports.union([external_exports.string().describe("A single input string to embed."), external_exports.array(external_exports.string().describe("One input string.")).min(1).describe("A batch of input strings."), external_exports.array(external_exports.int().describe("A single token ID.")).min(1).describe("A tokenized input sequence."), external_exports.array(external_exports.array(external_exports.int().describe("A single token ID.")).min(1)).min(1).describe("A batch of tokenized input sequences.")]),
490
- model: external_exports.string().describe("The embedding model to use."),
491
- dimensions: external_exports.int().min(1).describe("The number of embedding dimensions to request.").optional(),
492
- encoding_format: external_exports.enum(["float", "base64"]).describe("The embedding encoding format to return.").optional(),
493
- user: external_exports.string().describe("An end-user identifier passed through to the upstream API.").optional()
494
- }).describe("The input payload for creating OpenAI embeddings.");
495
- var createEmbeddingsOutput = external_exports.looseObject({
496
- object: external_exports.string().describe("The top-level object type."),
497
- data: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The embedding items returned by the API."),
498
- model: external_exports.string().describe("The model that generated the embeddings."),
499
- usage: external_exports.looseObject({}).describe("Any JSON object.")
500
- }).describe("The response payload for creating OpenAI embeddings.");
501
- var createModerationInput = external_exports.looseObject({
502
- input: external_exports.union([external_exports.string().describe("A single text input."), external_exports.array(external_exports.union([external_exports.string().describe("One text input."), external_exports.strictObject({
503
- type: external_exports.enum(["text", "image_url"]).describe("The moderation input type."),
504
- text: external_exports.string().describe("The text content when the input type is text.").optional(),
505
- image_url: external_exports.union([external_exports.string().describe("A direct image URL."), external_exports.looseObject({}).describe("Any JSON object.")]).optional()
506
- }).describe("A multimodal moderation input item.")])).min(1).describe("A batch of moderation inputs.")]),
507
- model: external_exports.string().describe("The moderation model to use.").optional()
508
- }).describe("The input payload for creating an OpenAI moderation request.");
509
- var createModerationOutput = external_exports.looseObject({
510
- id: external_exports.string().describe("The moderation request identifier."),
511
- model: external_exports.string().describe("The moderation model used for the request."),
512
- results: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The moderation results for each input.")
513
- }).describe("The response payload for creating an OpenAI moderation request.");
514
- var createImageInput = external_exports.looseObject({
515
- prompt: external_exports.string().describe("The prompt used to generate the image."),
516
- model: external_exports.string().describe("The image generation model to use.").optional(),
517
- background: external_exports.enum(["auto", "opaque", "transparent"]).describe("The background treatment to request for generated images.").optional(),
518
- moderation: external_exports.string().describe("The moderation level applied to the generation.").optional(),
519
- n: external_exports.int().min(1).describe("The number of images to generate.").optional(),
520
- output_compression: external_exports.int().min(0).max(100).describe("The output compression level to apply.").optional(),
521
- output_format: external_exports.enum(["png", "jpeg", "webp"]).describe("The image output format to request.").optional(),
522
- partial_images: external_exports.int().min(0).describe("The number of partial images to stream before completion.").optional(),
523
- quality: external_exports.string().describe("The image quality to request.").optional(),
524
- response_format: external_exports.enum(["b64_json", "url"]).describe("The image payload format to return.").optional(),
525
- size: external_exports.string().describe("The requested image size.").optional(),
526
- stream: external_exports.boolean().describe("Whether to request a streaming image generation response. This connector only accepts false or an omitted value.").optional(),
527
- user: external_exports.string().describe("An end-user identifier passed through to the upstream API.").optional()
528
- }).describe("The input payload for creating one or more OpenAI images.");
529
- var createImageOutput = external_exports.looseObject({
530
- created: external_exports.int().describe("The Unix timestamp when the image response was created.").optional(),
531
- data: external_exports.array(external_exports.looseObject({
532
- b64_json: external_exports.string().describe("The generated image encoded as base64.").optional(),
533
- url: external_exports.string().describe("The signed image URL returned by the API.").optional(),
534
- revised_prompt: external_exports.string().describe("The prompt potentially revised by the model before generation.").optional()
535
- }).describe("One generated image item returned by the API.")).describe("The generated image items returned by the API."),
536
- usage: external_exports.looseObject({}).describe("Any JSON object.").optional()
537
- }).describe("The response payload for creating OpenAI images.");
538
- var createSpeechInput = external_exports.looseObject({
539
- model: external_exports.string().describe("The text-to-speech model to use."),
540
- input: external_exports.string().describe("The text to synthesize into speech."),
541
- voice: external_exports.union([external_exports.string().describe("A built-in voice name."), external_exports.looseObject({}).describe("Any JSON object.")]),
542
- instructions: external_exports.string().describe("Optional voice instructions that guide the synthesis style.").optional(),
543
- response_format: external_exports.enum(["mp3", "opus", "aac", "flac", "wav", "pcm"]).describe("The audio format to return.").optional(),
544
- speed: external_exports.number().min(0.25).max(4).describe("The playback speed multiplier.").optional(),
545
- stream_format: external_exports.enum(["audio", "sse"]).describe("The speech response delivery format. This connector only accepts audio or an omitted value.").optional()
546
- }).describe("The input payload for creating OpenAI speech audio.");
547
- var createSpeechOutput = external_exports.looseObject({
548
- content_base64: external_exports.string().describe("The synthesized audio encoded as base64."),
549
- content_type: external_exports.string().describe("The MIME type of the synthesized audio.")
550
- }).describe("The normalized speech audio payload returned by the connector.");
551
- var createAudioTranscriptionInput = external_exports.looseObject({
552
- file: external_exports.strictObject({
553
- name: external_exports.string().min(1).describe("The filename to report when uploading the audio file."),
554
- mimetype: external_exports.string().describe("The MIME type of the audio file.").optional(),
555
- url: external_exports.string().describe("A public URL pointing to the audio file.").optional(),
556
- content_base64: external_exports.string().min(1).describe("The base64-encoded audio content to upload.").optional()
557
- }).describe("The audio file source to upload."),
558
- model: external_exports.string().describe("The transcription model to use."),
559
- chunking_strategy: external_exports.looseObject({}).describe("Any JSON object.").optional(),
560
- include: external_exports.array(external_exports.string().describe("One additional response field to include.")).min(1).describe("Additional response fields to include.").optional(),
561
- language: external_exports.string().describe("The language code of the source audio.").optional(),
562
- prompt: external_exports.string().describe("A guiding prompt for the transcription.").optional(),
563
- response_format: external_exports.string().describe("The response format to return.").optional(),
564
- stream: external_exports.boolean().describe("Whether to request a streaming transcription response. This connector only accepts false or an omitted value.").optional(),
565
- temperature: external_exports.number().min(0).max(1).describe("The sampling temperature.").optional(),
566
- timestamp_granularities: external_exports.array(external_exports.enum(["word", "segment"])).min(1).describe("The timestamp granularities to include.").optional()
567
- }).describe("The input payload for creating an OpenAI audio transcription.");
568
- var createAudioTranscriptionOutput = external_exports.looseObject({
569
- text: external_exports.string().describe("The transcribed or translated text.").optional(),
570
- language: external_exports.string().describe("The detected or returned language code.").optional(),
571
- duration: external_exports.number().describe("The duration of the processed audio in seconds.").optional(),
572
- segments: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The segment-level timing details.").optional(),
573
- words: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The word-level timing details.").optional(),
574
- logprobs: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The token log probabilities, if requested.").optional(),
575
- usage: external_exports.looseObject({}).describe("Any JSON object.").optional()
576
- }).describe("The normalized payload returned by an OpenAI audio text endpoint.");
577
- var createAudioTranslationInput = external_exports.looseObject({
578
- file: external_exports.strictObject({
579
- name: external_exports.string().min(1).describe("The filename to report when uploading the audio file."),
580
- mimetype: external_exports.string().describe("The MIME type of the audio file.").optional(),
581
- url: external_exports.string().describe("A public URL pointing to the audio file.").optional(),
582
- content_base64: external_exports.string().min(1).describe("The base64-encoded audio content to upload.").optional()
583
- }).describe("The audio file source to upload."),
584
- model: external_exports.string().describe("The translation model to use."),
585
- prompt: external_exports.string().describe("A guiding prompt for the translation.").optional(),
586
- response_format: external_exports.string().describe("The response format to return.").optional(),
587
- temperature: external_exports.number().min(0).max(1).describe("The sampling temperature.").optional()
588
- }).describe("The input payload for creating an OpenAI audio translation.");
589
- var createAudioTranslationOutput = external_exports.looseObject({
590
- text: external_exports.string().describe("The transcribed or translated text.").optional(),
591
- language: external_exports.string().describe("The detected or returned language code.").optional(),
592
- duration: external_exports.number().describe("The duration of the processed audio in seconds.").optional(),
593
- segments: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The segment-level timing details.").optional(),
594
- words: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The word-level timing details.").optional(),
595
- logprobs: external_exports.array(external_exports.looseObject({}).describe("Any JSON object.")).describe("The token log probabilities, if requested.").optional(),
596
- usage: external_exports.looseObject({}).describe("Any JSON object.").optional()
597
- }).describe("The normalized payload returned by an OpenAI audio text endpoint.");
598
- var createBatchInput = external_exports.looseObject({
599
- input_file_id: external_exports.string().describe("The uploaded input file identifier to process."),
600
- endpoint: external_exports.string().describe("The API endpoint executed for each batch item."),
601
- completion_window: external_exports.string().describe("The requested completion window, such as `24h`."),
602
- metadata: external_exports.record(external_exports.string(), external_exports.string().describe("Metadata field value.")).describe("String metadata fields attached to the request.").optional()
603
- }).describe("The input payload for creating an OpenAI batch.");
604
- var createBatchOutput = external_exports.looseObject({
605
- id: external_exports.string().describe("The batch identifier."),
606
- object: external_exports.string().describe("The object type returned by the API.").optional(),
607
- endpoint: external_exports.string().describe("The endpoint executed for each batch request.").optional(),
608
- input_file_id: external_exports.string().describe("The input file identifier used by the batch.").optional(),
609
- output_file_id: external_exports.string().describe("The output file identifier created by the batch.").optional(),
610
- error_file_id: external_exports.string().describe("The error file identifier created by the batch.").optional(),
611
- completion_window: external_exports.string().describe("The completion window requested for the batch.").optional(),
612
- status: external_exports.string().describe("The current status of the batch.").optional(),
613
- metadata: external_exports.record(external_exports.string(), external_exports.string().describe("Metadata field value.")).describe("String metadata fields attached to the request.").optional(),
614
- request_counts: external_exports.looseObject({}).describe("Any JSON object.").optional(),
615
- errors: external_exports.unknown().describe("The batch errors returned by the API.").optional(),
616
- created_at: external_exports.int().describe("The Unix timestamp when the batch was created.").optional(),
617
- in_progress_at: external_exports.int().describe("The Unix timestamp when the batch started processing.").optional(),
618
- finalizing_at: external_exports.int().describe("The Unix timestamp when the batch started finalizing.").optional(),
619
- completed_at: external_exports.int().describe("The Unix timestamp when the batch completed.").optional(),
620
- cancelling_at: external_exports.int().describe("The Unix timestamp when the batch started cancelling.").optional(),
621
- cancelled_at: external_exports.int().describe("The Unix timestamp when the batch was cancelled.").optional(),
622
- failed_at: external_exports.int().describe("The Unix timestamp when the batch failed.").optional(),
623
- expired_at: external_exports.int().describe("The Unix timestamp when the batch expired.").optional(),
624
- expires_at: external_exports.int().describe("The Unix timestamp when the batch will expire.").optional()
625
- }).describe("An OpenAI batch object.");
626
- var getBatchInput = external_exports.looseObject({
627
- batch_id: external_exports.string().describe("The batch identifier.")
628
- }).describe("The input payload for a batch lookup action.");
629
- var getBatchOutput = external_exports.looseObject({
630
- id: external_exports.string().describe("The batch identifier."),
631
- object: external_exports.string().describe("The object type returned by the API.").optional(),
632
- endpoint: external_exports.string().describe("The endpoint executed for each batch request.").optional(),
633
- input_file_id: external_exports.string().describe("The input file identifier used by the batch.").optional(),
634
- output_file_id: external_exports.string().describe("The output file identifier created by the batch.").optional(),
635
- error_file_id: external_exports.string().describe("The error file identifier created by the batch.").optional(),
636
- completion_window: external_exports.string().describe("The completion window requested for the batch.").optional(),
637
- status: external_exports.string().describe("The current status of the batch.").optional(),
638
- metadata: external_exports.record(external_exports.string(), external_exports.string().describe("Metadata field value.")).describe("String metadata fields attached to the request.").optional(),
639
- request_counts: external_exports.looseObject({}).describe("Any JSON object.").optional(),
640
- errors: external_exports.unknown().describe("The batch errors returned by the API.").optional(),
641
- created_at: external_exports.int().describe("The Unix timestamp when the batch was created.").optional(),
642
- in_progress_at: external_exports.int().describe("The Unix timestamp when the batch started processing.").optional(),
643
- finalizing_at: external_exports.int().describe("The Unix timestamp when the batch started finalizing.").optional(),
644
- completed_at: external_exports.int().describe("The Unix timestamp when the batch completed.").optional(),
645
- cancelling_at: external_exports.int().describe("The Unix timestamp when the batch started cancelling.").optional(),
646
- cancelled_at: external_exports.int().describe("The Unix timestamp when the batch was cancelled.").optional(),
647
- failed_at: external_exports.int().describe("The Unix timestamp when the batch failed.").optional(),
648
- expired_at: external_exports.int().describe("The Unix timestamp when the batch expired.").optional(),
649
- expires_at: external_exports.int().describe("The Unix timestamp when the batch will expire.").optional()
650
- }).describe("An OpenAI batch object.");
651
- var cancelBatchInput = external_exports.looseObject({
652
- batch_id: external_exports.string().describe("The batch identifier.")
653
- }).describe("The input payload for a batch lookup action.");
654
- var cancelBatchOutput = external_exports.looseObject({
655
- id: external_exports.string().describe("The batch identifier."),
656
- object: external_exports.string().describe("The object type returned by the API.").optional(),
657
- endpoint: external_exports.string().describe("The endpoint executed for each batch request.").optional(),
658
- input_file_id: external_exports.string().describe("The input file identifier used by the batch.").optional(),
659
- output_file_id: external_exports.string().describe("The output file identifier created by the batch.").optional(),
660
- error_file_id: external_exports.string().describe("The error file identifier created by the batch.").optional(),
661
- completion_window: external_exports.string().describe("The completion window requested for the batch.").optional(),
662
- status: external_exports.string().describe("The current status of the batch.").optional(),
663
- metadata: external_exports.record(external_exports.string(), external_exports.string().describe("Metadata field value.")).describe("String metadata fields attached to the request.").optional(),
664
- request_counts: external_exports.looseObject({}).describe("Any JSON object.").optional(),
665
- errors: external_exports.unknown().describe("The batch errors returned by the API.").optional(),
666
- created_at: external_exports.int().describe("The Unix timestamp when the batch was created.").optional(),
667
- in_progress_at: external_exports.int().describe("The Unix timestamp when the batch started processing.").optional(),
668
- finalizing_at: external_exports.int().describe("The Unix timestamp when the batch started finalizing.").optional(),
669
- completed_at: external_exports.int().describe("The Unix timestamp when the batch completed.").optional(),
670
- cancelling_at: external_exports.int().describe("The Unix timestamp when the batch started cancelling.").optional(),
671
- cancelled_at: external_exports.int().describe("The Unix timestamp when the batch was cancelled.").optional(),
672
- failed_at: external_exports.int().describe("The Unix timestamp when the batch failed.").optional(),
673
- expired_at: external_exports.int().describe("The Unix timestamp when the batch expired.").optional(),
674
- expires_at: external_exports.int().describe("The Unix timestamp when the batch will expire.").optional()
675
- }).describe("An OpenAI batch object.");
676
- var openaiActions = {
677
- list_models: {
678
- description: "List the OpenAI models available to the current API key.",
679
- effect: "read",
680
- inputSchema: listModelsInput,
681
- outputSchema: external_exports.toJSONSchema(listModelsOutput, { io: "output", unrepresentable: "any" })
682
- },
683
- get_model: {
684
- description: "Retrieve the metadata for a single OpenAI model by ID.",
685
- effect: "read",
686
- inputSchema: getModelInput,
687
- outputSchema: external_exports.toJSONSchema(getModelOutput, { io: "output", unrepresentable: "any" })
688
- },
689
- create_response: {
690
- description: "Create a non-streaming OpenAI response through the Responses API.",
691
- effect: "write",
692
- inputSchema: createResponseInput,
693
- outputSchema: external_exports.toJSONSchema(createResponseOutput, { io: "output", unrepresentable: "any" })
694
- },
695
- get_response: {
696
- description: "Retrieve one stored OpenAI response by its identifier.",
697
- effect: "read",
698
- inputSchema: getResponseInput,
699
- outputSchema: external_exports.toJSONSchema(getResponseOutput, { io: "output", unrepresentable: "any" })
700
- },
701
- list_input_items: {
702
- description: "List the stored input items for one OpenAI response.",
703
- effect: "read",
704
- inputSchema: listInputItemsInput,
705
- outputSchema: external_exports.toJSONSchema(listInputItemsOutput, { io: "output", unrepresentable: "any" })
706
- },
707
- get_input_token_counts: {
708
- description: "Count how many input tokens a Responses-style OpenAI request would consume.",
709
- effect: "read",
710
- inputSchema: getInputTokenCountsInput,
711
- outputSchema: external_exports.toJSONSchema(getInputTokenCountsOutput, { io: "output", unrepresentable: "any" })
712
- },
713
- create_embeddings: {
714
- description: "Create embeddings with an OpenAI embedding model.",
715
- effect: "write",
716
- inputSchema: createEmbeddingsInput,
717
- outputSchema: external_exports.toJSONSchema(createEmbeddingsOutput, { io: "output", unrepresentable: "any" })
718
- },
719
- create_moderation: {
720
- description: "Classify text or image inputs with the OpenAI Moderations API.",
721
- effect: "write",
722
- inputSchema: createModerationInput,
723
- outputSchema: external_exports.toJSONSchema(createModerationOutput, { io: "output", unrepresentable: "any" })
724
- },
725
- create_image: {
726
- description: "Generate images with the OpenAI image generation API.",
727
- effect: "write",
728
- inputSchema: createImageInput,
729
- outputSchema: external_exports.toJSONSchema(createImageOutput, { io: "output", unrepresentable: "any" })
730
- },
731
- create_speech: {
732
- description: "Synthesize speech audio from text with the OpenAI audio speech API.",
733
- effect: "write",
734
- inputSchema: createSpeechInput,
735
- outputSchema: external_exports.toJSONSchema(createSpeechOutput, { io: "output", unrepresentable: "any" })
736
- },
737
- create_audio_transcription: {
738
- description: "Transcribe one uploaded audio file with the OpenAI audio transcription API.",
739
- effect: "write",
740
- inputSchema: createAudioTranscriptionInput,
741
- outputSchema: external_exports.toJSONSchema(createAudioTranscriptionOutput, { io: "output", unrepresentable: "any" })
742
- },
743
- create_audio_translation: {
744
- description: "Translate one uploaded audio file into English with the OpenAI audio translation API.",
745
- effect: "write",
746
- inputSchema: createAudioTranslationInput,
747
- outputSchema: external_exports.toJSONSchema(createAudioTranslationOutput, { io: "output", unrepresentable: "any" })
748
- },
749
- create_batch: {
750
- description: "Create an OpenAI batch job from an uploaded input file.",
751
- effect: "write",
752
- inputSchema: createBatchInput,
753
- outputSchema: external_exports.toJSONSchema(createBatchOutput, { io: "output", unrepresentable: "any" })
754
- },
755
- get_batch: {
756
- description: "Fetch one OpenAI batch job by its identifier.",
757
- effect: "read",
758
- inputSchema: getBatchInput,
759
- outputSchema: external_exports.toJSONSchema(getBatchOutput, { io: "output", unrepresentable: "any" })
760
- },
761
- cancel_batch: {
762
- description: "Cancel one in-progress OpenAI batch job by its identifier.",
763
- effect: "destructive",
764
- inputSchema: cancelBatchInput,
765
- outputSchema: external_exports.toJSONSchema(cancelBatchOutput, { io: "output", unrepresentable: "any" })
766
- }
767
- };
768
-
769
- // ../plugins/src/openai/index.ts
770
- function createOpenaiPlugin() {
771
- return createProviderPlugin({
772
- description: "OpenAI",
773
- actions: openaiActions,
774
- // 上游 credentialValidators 也打 /models —— 只读、无必填入参,正好当挂载时的凭证探针。
775
- credentialProbe: "list_models",
776
- handlers: {
777
- list_models: listModels,
778
- get_model: getModel,
779
- create_response: createResponse,
780
- get_response: getResponse,
781
- list_input_items: listInputItems,
782
- get_input_token_counts: getInputTokenCounts,
783
- create_embeddings: createEmbeddings,
784
- create_moderation: createModeration,
785
- create_image: createImage,
786
- create_speech: createSpeech,
787
- create_audio_transcription: createAudioTranscription,
788
- create_audio_translation: createAudioTranslation,
789
- create_batch: createBatch,
790
- get_batch: getBatch,
791
- cancel_batch: cancelBatch
792
- }
793
- });
794
- }
795
- var openai_default = createOpenaiPlugin();
796
- export {
797
- createOpenaiPlugin,
798
- openai_default as default
799
- };