@tool-bridge/server 0.1.1 → 0.3.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 (107) hide show
  1. package/dist/airtable-V6446SVY.js +792 -0
  2. package/dist/alt_text_generator_ai-HV7JZPDT.js +72 -0
  3. package/dist/amap-TTTVB6WS.js +755 -0
  4. package/dist/anthropic-JH3RA363.js +224 -0
  5. package/dist/apify-ETNN7ITU.js +262 -0
  6. package/dist/brave_search-3DDR2MMB.js +322 -0
  7. package/dist/chunk-CSJEZHQO.js +252 -0
  8. package/dist/chunk-JLTYA2B3.js +20121 -0
  9. package/dist/chunk-K7FVSFUX.js +333 -0
  10. package/dist/{chunk-MQEYFCJB.js → chunk-KGYJEEBI.js} +2770 -21574
  11. package/dist/circleci-MX3TX3HC.js +409 -0
  12. package/dist/clerk-MRPORVF4.js +1036 -0
  13. package/dist/cloudflare_dns-OWP7DD7L.js +605 -0
  14. package/dist/cohere-GPECP66S.js +197 -0
  15. package/dist/confluence-BN7LZ6BC.js +436 -0
  16. package/dist/convertapi-SBEOFOFQ.js +161 -0
  17. package/dist/currencyapi-P2YY7Y7P.js +306 -0
  18. package/dist/deepseek-MWB3NYIN.js +205 -0
  19. package/dist/docker_hub-3JSCIGQ3.js +946 -0
  20. package/dist/dropbox-RFIBDAXO.js +1308 -0
  21. package/dist/dub-YVP57ELQ.js +706 -0
  22. package/dist/e2b-NFSUHTZR.js +305 -0
  23. package/dist/exa-KTDY6IV3.js +360 -0
  24. package/dist/fal_ai-OCUENLNQ.js +405 -0
  25. package/dist/feishu-5CWBQ7E5.js +225 -0
  26. package/dist/feishu_custom_bot-ZJR22OK6.js +240 -0
  27. package/dist/figma-YULGANSA.js +798 -0
  28. package/dist/firehydrant-2V6YSYAP.js +573 -0
  29. package/dist/fixer-LTCDB3CJ.js +171 -0
  30. package/dist/fly-IXPKMAML.js +478 -0
  31. package/dist/front-KRFB4M5X.js +379 -0
  32. package/dist/geocodio-VVURKYHQ.js +236 -0
  33. package/dist/ghost-6J2RIOUB.js +341 -0
  34. package/dist/github-5Z6KQRYH.js +5410 -0
  35. package/dist/gmail-KU4NZ7VA.js +1894 -0
  36. package/dist/googlecalendar-X44DFFXG.js +2539 -0
  37. package/dist/googledocs-WSGLPKSF.js +1322 -0
  38. package/dist/grafana-4PKSSDXY.js +817 -0
  39. package/dist/graphhopper-DF65ZNGK.js +336 -0
  40. package/dist/index.d.ts +181 -2
  41. package/dist/index.js +2 -1
  42. package/dist/ip2proxy-UCAQ5P2J.js +118 -0
  43. package/dist/ipgeolocation_io-UX6FCA2S.js +333 -0
  44. package/dist/ipqualityscore-MKTRXIZJ.js +287 -0
  45. package/dist/jina_ai-MRHPCSV5.js +119 -0
  46. package/dist/jira-EG7ZPOIW.js +627 -0
  47. package/dist/langsmith-FNO3RCOZ.js +597 -0
  48. package/dist/lemlist-SN6BJHSG.js +298 -0
  49. package/dist/linear-H3VU4PSD.js +2163 -0
  50. package/dist/logsnag-OY2JJT2H.js +167 -0
  51. package/dist/main.js +246 -2
  52. package/dist/mattermost-C5SQ7PGD.js +320 -0
  53. package/dist/mem0-LMLE5BFC.js +567 -0
  54. package/dist/memos-UWFAMBZC.js +781 -0
  55. package/dist/metabase-SRYDSDJ6.js +365 -0
  56. package/dist/mistral_ai-YNIJ7VDM.js +1195 -0
  57. package/dist/mother_duck-CPGOFEXE.js +322 -0
  58. package/dist/ngrok-CDJFBSOM.js +375 -0
  59. package/dist/notes-DIVFH3P3.js +109 -0
  60. package/dist/notion-HGDKS4HK.js +945 -0
  61. package/dist/open_exchange_rates-COHHYJDD.js +216 -0
  62. package/dist/openai-4TRT66GW.js +795 -0
  63. package/dist/opengraph_io-YKVW4PXI.js +377 -0
  64. package/dist/openrouter-6CV7B7V5.js +444 -0
  65. package/dist/outline-YWDUK5F7.js +604 -0
  66. package/dist/paddle-MEU7HWDZ.js +464 -0
  67. package/dist/perplexity-MRQUDBIC.js +238 -0
  68. package/dist/pinecone-JI7X2TAF.js +599 -0
  69. package/dist/pipedrive-6JQPAW23.js +453 -0
  70. package/dist/polar-7BF56CMC.js +400 -0
  71. package/dist/posthog-YPU5ADEN.js +3462 -0
  72. package/dist/postmark-BEU5OFKU.js +441 -0
  73. package/dist/prerender-UT5GOOZH.js +180 -0
  74. package/dist/pubmed-3SGOE24Q.js +1052 -0
  75. package/dist/railway-CEK4GLRQ.js +452 -0
  76. package/dist/readwise-DXQUQU67.js +482 -0
  77. package/dist/render-7TGAU5AW.js +473 -0
  78. package/dist/replicate-VICFSQ5A.js +347 -0
  79. package/dist/resend-3E76WK3O.js +100 -0
  80. package/dist/rootly-36GY46BY.js +345 -0
  81. package/dist/scrapfly-VDVUYAHX.js +289 -0
  82. package/dist/scrapingbee-3KTPMAVY.js +247 -0
  83. package/dist/screenshot_fyi-LKG62C3J.js +116 -0
  84. package/dist/semantic_scholar-4WREECYO.js +626 -0
  85. package/dist/sentry-HUQTGXOV.js +1139 -0
  86. package/dist/shodan-SGRKU4KS.js +303 -0
  87. package/dist/shopify-YCZ4L5HT.js +620 -0
  88. package/dist/stripe-OEBKMELB.js +583 -0
  89. package/dist/supabase-I3DBY7L4.js +937 -0
  90. package/dist/tavily-B2YHCNRD.js +349 -0
  91. package/dist/telegram-2VYJELZX.js +1773 -0
  92. package/dist/telnyx-HHXD3CXL.js +237 -0
  93. package/dist/todoist-PHFDEEIS.js +672 -0
  94. package/dist/trello-WUSAK6YN.js +1091 -0
  95. package/dist/turso-FW56U2B3.js +432 -0
  96. package/dist/twilio-M5JI7XHA.js +321 -0
  97. package/dist/umami-HAYODRC4.js +411 -0
  98. package/dist/unsplash-EDPTNEHJ.js +364 -0
  99. package/dist/upstash_redis-GC2CLIWD.js +299 -0
  100. package/dist/uptimerobot-XMSNYLIT.js +481 -0
  101. package/dist/v2ex-KU4ECD65.js +672 -0
  102. package/dist/vercel-THPCEFHW.js +1096 -0
  103. package/dist/wolfram_alpha_api-WHHTH4GU.js +212 -0
  104. package/dist/wordpress-O6TQEQNF.js +822 -0
  105. package/dist/workos-A3VHHWI3.js +681 -0
  106. package/dist/zhihu-BJAI64YJ.js +273 -0
  107. package/package.json +5 -4
@@ -0,0 +1,347 @@
1
+ import {
2
+ createProviderPlugin,
3
+ guardedFetch,
4
+ requireApiKey,
5
+ upstreamError
6
+ } from "./chunk-CSJEZHQO.js";
7
+ import "./chunk-K7FVSFUX.js";
8
+ import {
9
+ TBError,
10
+ external_exports
11
+ } from "./chunk-JLTYA2B3.js";
12
+ import "./chunk-MLKGABMK.js";
13
+
14
+ // ../plugins/src/replicate/api.ts
15
+ var SERVICE = "replicate";
16
+ var API_BASE = "https://api.replicate.com";
17
+ var ACCOUNT_PATH = "/v1/account";
18
+ function text(value) {
19
+ if (typeof value !== "string") return void 0;
20
+ const trimmed = value.trim();
21
+ return trimmed === "" ? void 0 : trimmed;
22
+ }
23
+ function record(value) {
24
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
25
+ }
26
+ function compact(input) {
27
+ return Object.fromEntries(
28
+ Object.entries(input).filter(([, value]) => value !== void 0)
29
+ );
30
+ }
31
+ function required(value, field) {
32
+ const trimmed = text(value);
33
+ if (trimmed === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
34
+ return trimmed;
35
+ }
36
+ function segment(value, field) {
37
+ return encodeURIComponent(required(value, field));
38
+ }
39
+ async function request(ctx, input) {
40
+ const url = new URL(`${API_BASE}${input.path}`);
41
+ for (const [key, value] of Object.entries(input.query ?? {})) {
42
+ if (value !== void 0 && value !== "") url.searchParams.set(key, value);
43
+ }
44
+ const headers = {
45
+ accept: "application/json",
46
+ authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`,
47
+ ...input.headers
48
+ };
49
+ if (input.body !== void 0) headers["content-type"] = "application/json";
50
+ const response = await guardedFetch(url.toString(), {
51
+ method: input.method ?? "GET",
52
+ headers,
53
+ body: input.body === void 0 ? void 0 : JSON.stringify(input.body)
54
+ });
55
+ const raw = await response.text();
56
+ let payload = {};
57
+ let isJson = true;
58
+ if (raw !== "") {
59
+ try {
60
+ payload = JSON.parse(raw);
61
+ } catch {
62
+ isJson = false;
63
+ payload = { detail: raw };
64
+ }
65
+ }
66
+ if (!response.ok) {
67
+ const body = record(payload) ?? {};
68
+ const message = text(body.detail) ?? text(body.title) ?? `Replicate \u8FD4\u56DE HTTP ${response.status}`;
69
+ throw upstreamError(response.status, message);
70
+ }
71
+ if (!isJson) throw new TBError("unavailable", "Replicate \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
72
+ return payload;
73
+ }
74
+ function requireRecord(value, label) {
75
+ const payload = record(value);
76
+ if (payload === void 0) {
77
+ throw new TBError("unavailable", `Replicate \u7684 ${label} \u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
78
+ }
79
+ return payload;
80
+ }
81
+ function pageOf(value, field) {
82
+ const payload = requireRecord(value, field);
83
+ if (!Array.isArray(payload.results)) {
84
+ throw new TBError("unavailable", `Replicate \u7684 ${field} \u54CD\u5E94\u7F3A\u5C11 results \u6570\u7EC4`, { retryable: true });
85
+ }
86
+ return {
87
+ [field]: payload.results,
88
+ next: typeof payload.next === "string" ? payload.next : null,
89
+ previous: typeof payload.previous === "string" ? payload.previous : null
90
+ };
91
+ }
92
+ function wrap(value, field) {
93
+ return { [field]: requireRecord(value, field) };
94
+ }
95
+ async function getAccount(_input, ctx) {
96
+ return wrap(await request(ctx, { path: ACCOUNT_PATH }), "account");
97
+ }
98
+ async function listModels(input, ctx) {
99
+ const payload = await request(ctx, {
100
+ path: "/v1/models",
101
+ query: compact({
102
+ sort_by: text(input.sortBy),
103
+ sort_direction: text(input.sortDirection)
104
+ })
105
+ });
106
+ return pageOf(payload, "models");
107
+ }
108
+ async function getModel(input, ctx) {
109
+ const path = `/v1/models/${segment(input.owner, "owner")}/${segment(input.model, "model")}`;
110
+ return wrap(await request(ctx, { path }), "model");
111
+ }
112
+ async function listModelVersions(input, ctx) {
113
+ const path = `/v1/models/${segment(input.owner, "owner")}/${segment(input.model, "model")}/versions`;
114
+ return pageOf(await request(ctx, { path }), "versions");
115
+ }
116
+ async function getModelVersion(input, ctx) {
117
+ const path = `/v1/models/${segment(input.owner, "owner")}/${segment(input.model, "model")}/versions/${segment(input.versionId, "versionId")}`;
118
+ return wrap(await request(ctx, { path }), "version");
119
+ }
120
+ async function listCollections(_input, ctx) {
121
+ return pageOf(await request(ctx, { path: "/v1/collections" }), "collections");
122
+ }
123
+ async function getCollection(input, ctx) {
124
+ const path = `/v1/collections/${segment(input.collectionSlug, "collectionSlug")}`;
125
+ return wrap(await request(ctx, { path }), "collection");
126
+ }
127
+ async function createPrediction(input, ctx) {
128
+ const headers = compact({
129
+ "Prefer": input.waitSeconds === void 0 ? void 0 : `wait=${input.waitSeconds}`,
130
+ "Cancel-After": text(input.cancelAfter)
131
+ });
132
+ const payload = await request(ctx, {
133
+ method: "POST",
134
+ path: "/v1/predictions",
135
+ headers,
136
+ body: compact({
137
+ version: required(input.version, "version"),
138
+ input: record(input.input) ?? {},
139
+ webhook: text(input.webhook),
140
+ webhook_events_filter: input.webhookEventsFilter
141
+ })
142
+ });
143
+ return wrap(payload, "prediction");
144
+ }
145
+ async function getPrediction(input, ctx) {
146
+ const path = `/v1/predictions/${segment(input.predictionId, "predictionId")}`;
147
+ return wrap(await request(ctx, { path }), "prediction");
148
+ }
149
+ async function listPredictions(input, ctx) {
150
+ const payload = await request(ctx, {
151
+ path: "/v1/predictions",
152
+ query: compact({
153
+ created_after: text(input.createdAfter),
154
+ created_before: text(input.createdBefore),
155
+ source: text(input.source)
156
+ })
157
+ });
158
+ return pageOf(payload, "predictions");
159
+ }
160
+ async function cancelPrediction(input, ctx) {
161
+ const payload = await request(ctx, {
162
+ method: "POST",
163
+ path: `/v1/predictions/${segment(input.predictionId, "predictionId")}/cancel`,
164
+ // 上游发的是空 JSON 对象(不是无 body)—— 少了它 content-type 也不会带上。
165
+ body: {}
166
+ });
167
+ return wrap(payload, "prediction");
168
+ }
169
+
170
+ // ../plugins/src/replicate/schema.ts
171
+ var getAccountInput = external_exports.strictObject({}).describe("No input parameters are required.");
172
+ var getAccountOutput = external_exports.looseObject({
173
+ account: external_exports.looseObject({}).describe("A Replicate API object.")
174
+ }).describe("The authenticated Replicate account response.");
175
+ var listModelsInput = external_exports.strictObject({
176
+ sortBy: external_exports.enum(["model_created_at", "latest_version_created_at"]).describe("The field used to sort public Replicate models.").optional(),
177
+ sortDirection: external_exports.enum(["asc", "desc"]).describe("The sort direction for Replicate model results.").optional()
178
+ }).describe("Input for listing public Replicate models.");
179
+ var listModelsOutput = external_exports.looseObject({
180
+ models: external_exports.array(external_exports.looseObject({}).describe("A Replicate API object.")).describe("The Replicate models returned for this page."),
181
+ next: external_exports.url().describe("A Replicate pagination URL.").nullable(),
182
+ previous: external_exports.url().describe("A Replicate pagination URL.").nullable()
183
+ }).describe("A paginated list of Replicate models.");
184
+ var getModelInput = external_exports.strictObject({
185
+ owner: external_exports.string().min(1).describe("The Replicate model owner username or organization slug.").optional(),
186
+ model: external_exports.string().min(1).describe("The Replicate model name slug.").optional()
187
+ }).describe("Input for selecting a Replicate model.");
188
+ var getModelOutput = external_exports.looseObject({
189
+ model: external_exports.looseObject({}).describe("A Replicate API object.")
190
+ }).describe("A Replicate model response.");
191
+ var listModelVersionsInput = external_exports.strictObject({
192
+ owner: external_exports.string().min(1).describe("The Replicate model owner username or organization slug.").optional(),
193
+ model: external_exports.string().min(1).describe("The Replicate model name slug.").optional()
194
+ }).describe("Input for selecting a Replicate model.");
195
+ var listModelVersionsOutput = external_exports.looseObject({
196
+ versions: external_exports.array(external_exports.looseObject({}).describe("A Replicate API object.")).describe("The model versions returned for this page."),
197
+ next: external_exports.url().describe("A Replicate pagination URL.").nullable(),
198
+ previous: external_exports.url().describe("A Replicate pagination URL.").nullable()
199
+ }).describe("A paginated list of Replicate model versions.");
200
+ var getModelVersionInput = external_exports.strictObject({
201
+ owner: external_exports.string().min(1).describe("The Replicate model owner username or organization slug.").optional(),
202
+ model: external_exports.string().min(1).describe("The Replicate model name slug.").optional(),
203
+ versionId: external_exports.string().min(1).describe("The Replicate model version identifier.").optional()
204
+ }).describe("Input for selecting a Replicate model version.");
205
+ var getModelVersionOutput = external_exports.looseObject({
206
+ version: external_exports.looseObject({}).describe("A Replicate API object.")
207
+ }).describe("A Replicate model version response.");
208
+ var listCollectionsInput = external_exports.strictObject({}).describe("No input parameters are required.");
209
+ var listCollectionsOutput = external_exports.looseObject({
210
+ collections: external_exports.array(external_exports.looseObject({}).describe("A Replicate API object.")).describe("The Replicate collections returned for this page."),
211
+ next: external_exports.url().describe("A Replicate pagination URL.").nullable(),
212
+ previous: external_exports.url().describe("A Replicate pagination URL.").nullable()
213
+ }).describe("A paginated list of Replicate collections.");
214
+ var getCollectionInput = external_exports.strictObject({
215
+ collectionSlug: external_exports.string().min(1).describe("The Replicate collection slug.").optional()
216
+ }).describe("Input for selecting a Replicate collection.");
217
+ var getCollectionOutput = external_exports.looseObject({
218
+ collection: external_exports.looseObject({}).describe("A Replicate API object.")
219
+ }).describe("A Replicate collection response.");
220
+ var createPredictionInput = external_exports.strictObject({
221
+ version: external_exports.string().min(1).describe("The Replicate model identifier, model version identifier, or owner/model:version reference."),
222
+ input: external_exports.looseObject({}).describe("A JSON-serializable model input object."),
223
+ waitSeconds: external_exports.int().min(1).max(60).describe("Seconds to wait synchronously for prediction output.").optional(),
224
+ cancelAfter: external_exports.string().min(1).describe("Maximum prediction runtime before Replicate cancels it, such as 30s, 5m, or 1h30m.").optional(),
225
+ webhook: external_exports.url().describe("An HTTPS webhook URL for Replicate prediction events.").optional(),
226
+ webhookEventsFilter: external_exports.array(external_exports.enum(["start", "output", "logs", "completed"]).describe("One Replicate webhook event filter.")).min(1).describe("The Replicate prediction event types that should trigger the webhook.").optional()
227
+ }).describe("Input for creating a Replicate prediction from a model or model version.");
228
+ var createPredictionOutput = external_exports.looseObject({
229
+ prediction: external_exports.looseObject({}).describe("A Replicate API object.")
230
+ }).describe("A Replicate prediction response.");
231
+ var getPredictionInput = external_exports.strictObject({
232
+ predictionId: external_exports.string().min(1).describe("The Replicate prediction identifier.").optional()
233
+ }).describe("Input for selecting a Replicate prediction.");
234
+ var getPredictionOutput = external_exports.looseObject({
235
+ prediction: external_exports.looseObject({}).describe("A Replicate API object.")
236
+ }).describe("A Replicate prediction response.");
237
+ var listPredictionsInput = external_exports.strictObject({
238
+ createdAfter: external_exports.iso.datetime({ offset: true }).describe("Include predictions created at or after this ISO 8601 timestamp.").optional(),
239
+ createdBefore: external_exports.iso.datetime({ offset: true }).describe("Include predictions created before this ISO 8601 timestamp.").optional(),
240
+ source: external_exports.literal("web").describe("Filter predictions to those created from the Replicate website.").optional()
241
+ }).describe("Input for filtering Replicate predictions.");
242
+ var listPredictionsOutput = external_exports.looseObject({
243
+ predictions: external_exports.array(external_exports.looseObject({}).describe("A Replicate API object.")).describe("The Replicate predictions returned for this page."),
244
+ next: external_exports.url().describe("A Replicate pagination URL.").nullable(),
245
+ previous: external_exports.url().describe("A Replicate pagination URL.").nullable()
246
+ }).describe("A paginated list of Replicate predictions.");
247
+ var cancelPredictionInput = external_exports.strictObject({
248
+ predictionId: external_exports.string().min(1).describe("The Replicate prediction identifier.").optional()
249
+ }).describe("Input for selecting a Replicate prediction.");
250
+ var cancelPredictionOutput = external_exports.looseObject({
251
+ prediction: external_exports.looseObject({}).describe("A Replicate API object.")
252
+ }).describe("A Replicate prediction response after cancellation.");
253
+ var replicateActions = {
254
+ get_account: {
255
+ description: "Retrieve the authenticated Replicate account for the connected API token.",
256
+ effect: "read",
257
+ inputSchema: getAccountInput,
258
+ outputSchema: external_exports.toJSONSchema(getAccountOutput, { io: "output", unrepresentable: "any" })
259
+ },
260
+ list_models: {
261
+ description: "List public Replicate models with optional official sorting parameters.",
262
+ effect: "read",
263
+ inputSchema: listModelsInput,
264
+ outputSchema: external_exports.toJSONSchema(listModelsOutput, { io: "output", unrepresentable: "any" })
265
+ },
266
+ get_model: {
267
+ description: "Retrieve one Replicate model by owner and model slug.",
268
+ effect: "read",
269
+ inputSchema: getModelInput,
270
+ outputSchema: external_exports.toJSONSchema(getModelOutput, { io: "output", unrepresentable: "any" })
271
+ },
272
+ list_model_versions: {
273
+ description: "List versions for one Replicate model.",
274
+ effect: "read",
275
+ inputSchema: listModelVersionsInput,
276
+ outputSchema: external_exports.toJSONSchema(listModelVersionsOutput, { io: "output", unrepresentable: "any" })
277
+ },
278
+ get_model_version: {
279
+ description: "Retrieve one Replicate model version by owner, model, and version ID.",
280
+ effect: "read",
281
+ inputSchema: getModelVersionInput,
282
+ outputSchema: external_exports.toJSONSchema(getModelVersionOutput, { io: "output", unrepresentable: "any" })
283
+ },
284
+ list_collections: {
285
+ description: "List public Replicate model collections.",
286
+ effect: "read",
287
+ inputSchema: listCollectionsInput,
288
+ outputSchema: external_exports.toJSONSchema(listCollectionsOutput, { io: "output", unrepresentable: "any" })
289
+ },
290
+ get_collection: {
291
+ description: "Retrieve one Replicate collection by slug.",
292
+ effect: "read",
293
+ inputSchema: getCollectionInput,
294
+ outputSchema: external_exports.toJSONSchema(getCollectionOutput, { io: "output", unrepresentable: "any" })
295
+ },
296
+ create_prediction: {
297
+ description: "Create a Replicate prediction using JSON model input and optional synchronous wait headers.",
298
+ effect: "write",
299
+ inputSchema: createPredictionInput,
300
+ outputSchema: external_exports.toJSONSchema(createPredictionOutput, { io: "output", unrepresentable: "any" })
301
+ },
302
+ get_prediction: {
303
+ description: "Retrieve the current state and output of a Replicate prediction.",
304
+ effect: "read",
305
+ inputSchema: getPredictionInput,
306
+ outputSchema: external_exports.toJSONSchema(getPredictionOutput, { io: "output", unrepresentable: "any" })
307
+ },
308
+ list_predictions: {
309
+ description: "List Replicate predictions for the authenticated account.",
310
+ effect: "read",
311
+ inputSchema: listPredictionsInput,
312
+ outputSchema: external_exports.toJSONSchema(listPredictionsOutput, { io: "output", unrepresentable: "any" })
313
+ },
314
+ cancel_prediction: {
315
+ description: "Cancel a running Replicate prediction by prediction ID.",
316
+ effect: "destructive",
317
+ inputSchema: cancelPredictionInput,
318
+ outputSchema: external_exports.toJSONSchema(cancelPredictionOutput, { io: "output", unrepresentable: "any" })
319
+ }
320
+ };
321
+
322
+ // ../plugins/src/replicate/index.ts
323
+ function createReplicatePlugin() {
324
+ return createProviderPlugin({
325
+ description: "Replicate",
326
+ actions: replicateActions,
327
+ credentialProbe: "get_account",
328
+ handlers: {
329
+ get_account: getAccount,
330
+ list_models: listModels,
331
+ get_model: getModel,
332
+ list_model_versions: listModelVersions,
333
+ get_model_version: getModelVersion,
334
+ list_collections: listCollections,
335
+ get_collection: getCollection,
336
+ create_prediction: createPrediction,
337
+ get_prediction: getPrediction,
338
+ list_predictions: listPredictions,
339
+ cancel_prediction: cancelPrediction
340
+ }
341
+ });
342
+ }
343
+ var replicate_default = createReplicatePlugin();
344
+ export {
345
+ createReplicatePlugin,
346
+ replicate_default as default
347
+ };
@@ -0,0 +1,100 @@
1
+ import {
2
+ createProviderPlugin,
3
+ guardedFetch,
4
+ requireApiKey,
5
+ upstreamError
6
+ } from "./chunk-CSJEZHQO.js";
7
+ import "./chunk-K7FVSFUX.js";
8
+ import {
9
+ TBError,
10
+ external_exports
11
+ } from "./chunk-JLTYA2B3.js";
12
+ import "./chunk-MLKGABMK.js";
13
+
14
+ // ../plugins/src/resend/schema.handwritten.ts
15
+ var sendEmailInput = external_exports.strictObject({
16
+ from: external_exports.string().min(1).describe("The sender email address."),
17
+ to: external_exports.string().min(1).describe("The recipient email address."),
18
+ subject: external_exports.string().min(1).describe("The email subject line."),
19
+ html: external_exports.string().describe("The HTML body of the email. Provide at least one of html or text.").optional(),
20
+ text: external_exports.string().describe("The plain text body of the email. Provide at least one of html or text.").optional()
21
+ }).refine(
22
+ (input) => input.html !== void 0 || input.text !== void 0,
23
+ { message: "at least one of html or text is required", path: ["html"] }
24
+ ).describe("The input payload for sending a Resend email.");
25
+ var sendEmailOutput = external_exports.strictObject({
26
+ emailId: external_exports.string().describe("The unique identifier of the sent email.").optional()
27
+ }).describe("The output payload for this action.");
28
+
29
+ // ../plugins/src/resend/schema.ts
30
+ var resendActions = {
31
+ send_email: {
32
+ description: "Send an email with Resend.",
33
+ effect: "write",
34
+ inputSchema: sendEmailInput,
35
+ outputSchema: external_exports.toJSONSchema(sendEmailOutput, { io: "output", unrepresentable: "any" })
36
+ }
37
+ };
38
+
39
+ // ../plugins/src/resend/api.ts
40
+ var SERVICE = "resend";
41
+ var API_BASE = "https://api.resend.com";
42
+ var AUTH_ERROR_NAMES = /* @__PURE__ */ new Set(["invalid_api_key", "missing_api_key"]);
43
+ async function readPayload(response) {
44
+ const text2 = await response.text().catch(() => "");
45
+ if (text2 === "") return {};
46
+ try {
47
+ const parsed = JSON.parse(text2);
48
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
49
+ } catch {
50
+ return { message: text2 };
51
+ }
52
+ }
53
+ function text(value) {
54
+ return typeof value === "string" && value !== "" ? value : void 0;
55
+ }
56
+ function resendError(status, payload) {
57
+ const name = text(payload.name) ?? text(payload.error) ?? "provider_error";
58
+ const message = text(payload.message) ?? text(payload.error_description) ?? `Resend \u8FD4\u56DE HTTP ${status}`;
59
+ if (AUTH_ERROR_NAMES.has(name)) {
60
+ return new TBError("permission_denied", message, { httpStatus: 401 });
61
+ }
62
+ return upstreamError(status, message);
63
+ }
64
+ async function sendEmail(input, ctx) {
65
+ const response = await guardedFetch(`${API_BASE}/emails`, {
66
+ method: "POST",
67
+ headers: {
68
+ "authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
69
+ "content-type": "application/json"
70
+ },
71
+ body: JSON.stringify({
72
+ from: input.from,
73
+ to: input.to,
74
+ subject: input.subject,
75
+ ...input.html === void 0 ? {} : { html: input.html },
76
+ ...input.text === void 0 ? {} : { text: input.text }
77
+ })
78
+ });
79
+ const payload = await readPayload(response);
80
+ if (!response.ok) throw resendError(response.status, payload);
81
+ const emailId = text(payload.id);
82
+ if (emailId === void 0) {
83
+ throw new TBError("unavailable", "Resend \u7684\u6210\u529F\u54CD\u5E94\u91CC\u6CA1\u6709 email id", { retryable: true });
84
+ }
85
+ return { emailId };
86
+ }
87
+
88
+ // ../plugins/src/resend/index.ts
89
+ function createResendPlugin() {
90
+ return createProviderPlugin({
91
+ description: "Resend",
92
+ actions: resendActions,
93
+ handlers: { send_email: sendEmail }
94
+ });
95
+ }
96
+ var resend_default = createResendPlugin();
97
+ export {
98
+ createResendPlugin,
99
+ resend_default as default
100
+ };