@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.
- package/dist/admin.js +170 -0
- package/dist/airtable-VMQVXLHK.js +790 -0
- package/dist/{alt_text_generator_ai-W7O34SNG.js → alt_text_generator_ai-FTWY4RU4.js} +12 -11
- package/dist/{amap-VOX4T2AW.js → amap-OK5VBHYC.js} +221 -220
- package/dist/anthropic-S67AZFZ3.js +203 -0
- package/dist/apify-ZE6MYQI3.js +248 -0
- package/dist/brave_search-TG2M2KOD.js +302 -0
- package/dist/chunk-2JNAI4OC.js +161 -0
- package/dist/{chunk-KMTT3I6D.js → chunk-4XJPN3DY.js} +19392 -26136
- package/dist/chunk-5ICRY3VU.js +8432 -0
- package/dist/chunk-7CTWGTDU.js +302 -0
- package/dist/chunk-BADVCN6K.js +378 -0
- package/dist/{chunk-XYBU3WZH.js → chunk-TDAWLMDE.js} +3 -3
- package/dist/chunk-U7PTOA3U.js +7320 -0
- package/dist/{chunk-E6JCVKW6.js → chunk-VWRUGUSU.js} +3 -3
- package/dist/{chunk-ATK45BXV.js → chunk-WJHG6OK7.js} +4 -2
- package/dist/circleci-3L3WJVSK.js +389 -0
- package/dist/clerk-EZPF2V7T.js +1019 -0
- package/dist/cohere-U27DPO64.js +185 -0
- package/dist/{confluence-B3EWPZVE.js → confluence-G2KL6ERH.js} +105 -104
- package/dist/{convertapi-EUWSQYPF.js → convertapi-L4CLJ2M3.js} +32 -31
- package/dist/{currencyapi-KVTIK3GL.js → currencyapi-YPYXG7YY.js} +71 -71
- package/dist/deepseek-6HT6WF3M.js +210 -0
- package/dist/docker_hub-LPE3PCVB.js +933 -0
- package/dist/dropbox-V56ABHTA.js +1305 -0
- package/dist/dub-6OKQ7MHT.js +680 -0
- package/dist/e2b-JS2U2QFU.js +278 -0
- package/dist/exa-DPWVYXSP.js +332 -0
- package/dist/{fal_ai-23E7JPNT.js → fal_ai-DK6Y27ZF.js} +81 -80
- package/dist/{feishu-7QRIDUV6.js → feishu-K7EGSRF3.js} +528 -572
- package/dist/{feishu_custom_bot-TJ4K7QNJ.js → feishu_custom_bot-2JUGFYNG.js} +57 -53
- package/dist/figma-FT5I7ITD.js +777 -0
- package/dist/firehydrant-EIKLKHX2.js +563 -0
- package/dist/{fixer-BWON27UO.js → fixer-U5QXIAKD.js} +34 -33
- package/dist/fly-T3JYFZ2M.js +469 -0
- package/dist/{front-QCGXYEDJ.js → front-D72MGVOR.js} +104 -104
- package/dist/geocodio-BOTD5TI5.js +213 -0
- package/dist/ghost-KYP7SZGB.js +338 -0
- package/dist/github-AGMZT3VY.js +5421 -0
- package/dist/gmail-BLJNJOBG.js +1887 -0
- package/dist/googlecalendar-GTHWNCF6.js +2524 -0
- package/dist/{googledocs-BUHL4J2H.js → googledocs-6EEDMEBQ.js} +341 -340
- package/dist/{grafana-GLU2DWF2.js → grafana-GMW6EKSQ.js} +221 -220
- package/dist/graphhopper-6OLGBDGB.js +325 -0
- package/dist/index.d.ts +1132 -332
- package/dist/index.js +31 -14
- package/dist/{ip2proxy-EZ64Y4ZH.js → ip2proxy-4QN42E6T.js} +28 -27
- package/dist/ipgeolocation_io-SK4XKDA2.js +315 -0
- package/dist/ipqualityscore-6ANBPXKT.js +279 -0
- package/dist/{jina_ai-EFBHTBXL.js → jina_ai-IHPSVRM5.js} +23 -23
- package/dist/{jira-HQSHAA5K.js → jira-46KKM4LC.js} +118 -117
- package/dist/langsmith-JZA345I5.js +593 -0
- package/dist/lemlist-43IV7DK6.js +289 -0
- package/dist/{linear-K7RYFYAD.js → linear-5LFH7XNL.js} +327 -326
- package/dist/logsnag-5RMYAHIL.js +150 -0
- package/dist/main.js +57 -280
- package/dist/{mattermost-S2BRCWLQ.js → mattermost-XFL6SHGG.js} +59 -58
- package/dist/mem0-NYO4DTP6.js +544 -0
- package/dist/memos-37MPQOLV.js +744 -0
- package/dist/{metabase-MMSEPCOF.js → metabase-KYBKZFMG.js} +90 -89
- package/dist/mistral_ai-6PL3K4PM.js +1196 -0
- package/dist/{mother_duck-H7PCQNZ2.js → mother_duck-2NH7W5M5.js} +94 -93
- package/dist/ngrok-UO6CDYCA.js +356 -0
- package/dist/{notes-PFMKRO33.js → notes-I3P32WP4.js} +11 -9
- package/dist/notion-BEAJFUOE.js +940 -0
- package/dist/open_exchange_rates-CMF62JB4.js +215 -0
- package/dist/openai-IHOMKVND.js +800 -0
- package/dist/opengraph_io-ZQ2FGLHX.js +362 -0
- package/dist/openrouter-HXLW3NR5.js +441 -0
- package/dist/outline-ELCP4NEU.js +599 -0
- package/dist/paddle-O77LALVN.js +454 -0
- package/dist/perplexity-JCU654QV.js +220 -0
- package/dist/pinecone-W5W4LRKL.js +571 -0
- package/dist/{pipedrive-Y2O7QGFF.js → pipedrive-ITMJLLPZ.js} +99 -98
- package/dist/polar-R33XU4L3.js +395 -0
- package/dist/posthog-JVNTOLTV.js +3464 -0
- package/dist/postmark-6SBG7HWV.js +427 -0
- package/dist/{prerender-MENYM2TY.js → prerender-GPNKTNFC.js} +31 -30
- package/dist/{pubmed-GOXUVVH5.js → pubmed-UP6ZEEIH.js} +239 -238
- package/dist/{railway-V2SID4WV.js → railway-KWEWXHTY.js} +118 -117
- package/dist/readwise-BLATSMC3.js +470 -0
- package/dist/render-QYRVIXII.js +461 -0
- package/dist/{replicate-756MXPYX.js → replicate-JYTWH4NF.js} +81 -80
- package/dist/{resend-ZKH3BTBI.js → resend-L5N75SZM.js} +20 -16
- package/dist/rootly-MHCPEQ26.js +336 -0
- package/dist/{scrapfly-NSRHFDIQ.js → scrapfly-PTPGYSJM.js} +62 -61
- package/dist/{scrapingbee-OQHLAVEY.js → scrapingbee-JN6UH5PY.js} +56 -56
- package/dist/{screenshot_fyi-DVWG3AXC.js → screenshot_fyi-4QRVSV55.js} +16 -16
- package/dist/semantic_scholar-LRSWA2GE.js +611 -0
- package/dist/{sentry-546MNDJG.js → sentry-2G6PF5W6.js} +208 -207
- package/dist/{shodan-C3OON3Z3.js → shodan-WKKPP5C6.js} +62 -61
- package/dist/shopify-64YDK5T2.js +610 -0
- package/dist/stripe-QAIGGOTF.js +585 -0
- package/dist/{supabase-U2SL4D63.js → supabase-WHTGR6ND.js} +245 -244
- package/dist/tavily-QIXCDDWO.js +326 -0
- package/dist/telegram-E6G7CWI6.js +1767 -0
- package/dist/{telnyx-CXQ4EZUX.js → telnyx-ZDVVS7PK.js} +57 -56
- package/dist/todoist-DMYF3G7J.js +664 -0
- package/dist/trello-HY2RYIRP.js +1080 -0
- package/dist/turso-HAQWMGRP.js +416 -0
- package/dist/{twilio-4PDBJKWX.js → twilio-MLXYPHJE.js} +70 -69
- package/dist/umami-DZHBLPVG.js +389 -0
- package/dist/unsplash-GS2OPXKE.js +351 -0
- package/dist/{upstash_redis-G4LQBYHA.js → upstash_redis-XMXWTNAJ.js} +51 -50
- package/dist/uptimerobot-TF5WRZ4G.js +483 -0
- package/dist/v2ex-2BVXAPDF.js +667 -0
- package/dist/vercel-YMJGQYJE.js +1076 -0
- package/dist/{wolfram_alpha_api-3G4PUJWB.js → wolfram_alpha_api-I56SXWFZ.js} +36 -35
- package/dist/wordpress-R7TDFZ2P.js +812 -0
- package/dist/workos-HDNHWVMS.js +664 -0
- package/dist/zhihu-LX6AGGDS.js +254 -0
- package/package.json +18 -9
- package/dist/airtable-LLZDFN7M.js +0 -789
- package/dist/anthropic-G23NN3X5.js +0 -202
- package/dist/apify-Y3SS734K.js +0 -247
- package/dist/brave_search-ZC7OAPSZ.js +0 -301
- package/dist/chunk-R6P4XAE5.js +0 -248
- package/dist/chunk-U7B6DS2O.js +0 -977
- package/dist/chunk-UZM2RXZH.js +0 -23436
- package/dist/circleci-3BAX5FCG.js +0 -388
- package/dist/clerk-6LEM6TNU.js +0 -1019
- package/dist/cloudflare_dns-KINYTJUD.js +0 -588
- package/dist/cohere-XCJ5AJ6B.js +0 -185
- package/dist/deepseek-PC5YGNC5.js +0 -209
- package/dist/docker_hub-C3MA5FU6.js +0 -932
- package/dist/dropbox-XBV7Z2IR.js +0 -1304
- package/dist/dub-LDOFG3HC.js +0 -679
- package/dist/e2b-JMCPSVBW.js +0 -277
- package/dist/exa-RAK7O7RD.js +0 -331
- package/dist/figma-E6IX5DTH.js +0 -773
- package/dist/firehydrant-ZBLPQREE.js +0 -562
- package/dist/fly-ZH3HFCZJ.js +0 -468
- package/dist/geocodio-YGNI7DA4.js +0 -212
- package/dist/ghost-EVSGKH2Q.js +0 -337
- package/dist/github-MA2BGRCJ.js +0 -5420
- package/dist/gmail-E5E6AADE.js +0 -1886
- package/dist/googlecalendar-BTLFPXTD.js +0 -2523
- package/dist/graphhopper-WSMB3TCD.js +0 -324
- package/dist/ipgeolocation_io-AA7HAS22.js +0 -315
- package/dist/ipqualityscore-BHJXVTJT.js +0 -277
- package/dist/langsmith-5W6SCT6F.js +0 -592
- package/dist/lemlist-HJWH6UMK.js +0 -288
- package/dist/logsnag-4KFOHL37.js +0 -150
- package/dist/mem0-CAW43CIC.js +0 -543
- package/dist/memos-TWEGPKFM.js +0 -740
- package/dist/mistral_ai-64BGZQHP.js +0 -1195
- package/dist/ngrok-GQCUGZKJ.js +0 -356
- package/dist/notion-DQWZWP4N.js +0 -936
- package/dist/open_exchange_rates-QMMD735E.js +0 -214
- package/dist/openai-W6PX32NZ.js +0 -799
- package/dist/opengraph_io-HNDBXYNW.js +0 -361
- package/dist/openrouter-JJYMEAUL.js +0 -437
- package/dist/outline-MCBNQZYY.js +0 -595
- package/dist/paddle-D2SKLUDN.js +0 -453
- package/dist/perplexity-XIFMKUAE.js +0 -219
- package/dist/pinecone-HUFTALV2.js +0 -570
- package/dist/polar-TYTOMOSR.js +0 -394
- package/dist/posthog-43JAR3VW.js +0 -3463
- package/dist/postmark-KL2QJYSG.js +0 -426
- package/dist/readwise-CI4GIMMJ.js +0 -469
- package/dist/render-SUBJ6YRZ.js +0 -460
- package/dist/rootly-CD2LJHPI.js +0 -336
- package/dist/semantic_scholar-T4A252KW.js +0 -610
- package/dist/shopify-Y2HN2MCQ.js +0 -609
- package/dist/stripe-VE3CD3AY.js +0 -584
- package/dist/tavily-KCZHK6HE.js +0 -326
- package/dist/telegram-3URFBCMY.js +0 -1766
- package/dist/todoist-HNPWNYTD.js +0 -663
- package/dist/trello-3W2MIXRP.js +0 -1079
- package/dist/turso-2EQF7C2Z.js +0 -415
- package/dist/umami-5REN7TGP.js +0 -388
- package/dist/unsplash-EIXL424F.js +0 -350
- package/dist/uptimerobot-KNJ3EYLY.js +0 -482
- package/dist/v2ex-RHJ234PZ.js +0 -666
- package/dist/vercel-AS6NCIC7.js +0 -1075
- package/dist/wordpress-KNDAAUV7.js +0 -811
- package/dist/workos-R6UITSJ7.js +0 -663
- package/dist/zhihu-AGK4HILK.js +0 -253
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-TDAWLMDE.js";
|
|
4
|
+
import "./chunk-VWRUGUSU.js";
|
|
5
|
+
import {
|
|
6
|
+
compactDefined,
|
|
7
|
+
trimmedText
|
|
8
|
+
} from "./chunk-JXHMDBAY.js";
|
|
9
|
+
import {
|
|
10
|
+
createProviderPlugin,
|
|
11
|
+
upstreamError
|
|
12
|
+
} from "./chunk-WJHG6OK7.js";
|
|
13
|
+
import "./chunk-2JNAI4OC.js";
|
|
14
|
+
import "./chunk-BADVCN6K.js";
|
|
15
|
+
import {
|
|
16
|
+
TBError
|
|
17
|
+
} from "./chunk-5ICRY3VU.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
19
|
+
|
|
20
|
+
// ../plugins/src/anthropic/api.ts
|
|
21
|
+
var SERVICE = "anthropic";
|
|
22
|
+
var API_BASE = "https://api.anthropic.com";
|
|
23
|
+
var API_VERSION = "2023-06-01";
|
|
24
|
+
var http = createAuthedClient({
|
|
25
|
+
baseUrl: `${API_BASE}/`,
|
|
26
|
+
service: SERVICE,
|
|
27
|
+
auth: { kind: "header", name: "x-api-key" },
|
|
28
|
+
// content-type 不分 method 全量带,与迁移前的头集合一致(GET 也发)。
|
|
29
|
+
headers: {
|
|
30
|
+
"accept": "application/json",
|
|
31
|
+
"anthropic-version": API_VERSION,
|
|
32
|
+
"content-type": "application/json"
|
|
33
|
+
},
|
|
34
|
+
// Anthropic 的错误体是 `{type, error:{type, message}}`;网关层的错误可能是纯文本。
|
|
35
|
+
errorMessage: {
|
|
36
|
+
keys: ["error.message"],
|
|
37
|
+
fallback: (status) => `anthropic request failed with ${status}`
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function requireText(value, field) {
|
|
41
|
+
const result = trimmedText(value);
|
|
42
|
+
if (result === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
async function request(ctx, input) {
|
|
46
|
+
const method = input.method ?? "GET";
|
|
47
|
+
const { data } = await http.request(ctx, {
|
|
48
|
+
path: input.path,
|
|
49
|
+
method,
|
|
50
|
+
query: Object.entries(input.query ?? {}),
|
|
51
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
52
|
+
invalidJsonMessage: "anthropic returned malformed JSON",
|
|
53
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
54
|
+
502,
|
|
55
|
+
`anthropic ${method} ${input.path} failed before receiving response: ${message ?? "unknown network error"}`
|
|
56
|
+
)
|
|
57
|
+
});
|
|
58
|
+
if (data === void 0) throw upstreamError(502, "anthropic returned malformed JSON");
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
61
|
+
function assertStreamingDisabled(input) {
|
|
62
|
+
if (input.stream === true) {
|
|
63
|
+
throw new TBError("invalid_argument", "stream=true is not supported by connector actions");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function listModels(input, ctx) {
|
|
67
|
+
return request(ctx, {
|
|
68
|
+
path: "/v1/models",
|
|
69
|
+
query: { before_id: input.before_id, after_id: input.after_id, limit: input.limit }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async function getModel(input, ctx) {
|
|
73
|
+
return request(ctx, { path: `/v1/models/${encodeURIComponent(requireText(input.model_id, "model_id"))}` });
|
|
74
|
+
}
|
|
75
|
+
async function createMessage(input, ctx) {
|
|
76
|
+
assertStreamingDisabled(input);
|
|
77
|
+
return request(ctx, { method: "POST", path: "/v1/messages", body: compactDefined(input) });
|
|
78
|
+
}
|
|
79
|
+
async function countMessageTokens(input, ctx) {
|
|
80
|
+
return request(ctx, { method: "POST", path: "/v1/messages/count_tokens", body: compactDefined(input) });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ../plugins/src/anthropic/schema.ts
|
|
84
|
+
import { z } from "zod/v4";
|
|
85
|
+
var listModelsInput = z.strictObject({
|
|
86
|
+
before_id: z.string().describe("Returns models before this model identifier.").optional(),
|
|
87
|
+
after_id: z.string().describe("Returns models after this model identifier.").optional(),
|
|
88
|
+
limit: z.int().min(1).max(1e3).describe("The maximum number of models to return.").optional()
|
|
89
|
+
}).describe("The input payload for listing Anthropic models.");
|
|
90
|
+
var listModelsOutput = z.looseObject({
|
|
91
|
+
data: z.array(z.looseObject({
|
|
92
|
+
id: z.string().describe("The model identifier.").optional(),
|
|
93
|
+
type: z.string().describe("The object type returned by the API.").optional(),
|
|
94
|
+
display_name: z.string().describe("A human-readable model name.").optional(),
|
|
95
|
+
created_at: z.iso.datetime({ offset: true }).describe("The date and time when the model was created.").optional()
|
|
96
|
+
}).describe("An Anthropic model record.")).describe("The list of Anthropic models.").optional(),
|
|
97
|
+
has_more: z.boolean().describe("Whether more results are available.").optional(),
|
|
98
|
+
first_id: z.string().describe("The first model identifier in this page.").nullable().optional(),
|
|
99
|
+
last_id: z.string().describe("The last model identifier in this page.").nullable().optional()
|
|
100
|
+
}).describe("The response payload for listing Anthropic models.");
|
|
101
|
+
var getModelInput = z.strictObject({
|
|
102
|
+
model_id: z.string().describe("The exact Anthropic model identifier to retrieve.").optional()
|
|
103
|
+
}).describe("The input payload for retrieving an Anthropic model.");
|
|
104
|
+
var getModelOutput = z.looseObject({
|
|
105
|
+
id: z.string().describe("The model identifier.").optional(),
|
|
106
|
+
type: z.string().describe("The object type returned by the API.").optional(),
|
|
107
|
+
display_name: z.string().describe("A human-readable model name.").optional(),
|
|
108
|
+
created_at: z.iso.datetime({ offset: true }).describe("The date and time when the model was created.").optional()
|
|
109
|
+
}).describe("An Anthropic model record.");
|
|
110
|
+
var createMessageInput = z.looseObject({
|
|
111
|
+
model: z.string().describe("The Anthropic model identifier to use."),
|
|
112
|
+
max_tokens: z.int().min(1).describe("The maximum number of tokens to generate."),
|
|
113
|
+
messages: z.array(z.looseObject({
|
|
114
|
+
role: z.enum(["user", "assistant"]).describe("The role of the message author.").optional(),
|
|
115
|
+
content: z.union([z.string().describe("Plain text message content."), z.array(z.looseObject({}).describe("A structured Anthropic content block.")).min(1).describe("Structured content blocks.")]).describe("Anthropic message content.").optional()
|
|
116
|
+
}).describe("An input message in an Anthropic conversation.")).min(1).describe("The ordered conversation history sent to the model."),
|
|
117
|
+
system: z.union([z.string().describe("Plain text system prompt."), z.array(z.looseObject({}).describe("A structured Anthropic content block.")).min(1).describe("Structured system prompt content blocks.")]).describe("System prompt content.").optional(),
|
|
118
|
+
metadata: z.looseObject({
|
|
119
|
+
user_id: z.string().describe("An external user identifier for abuse detection.").optional()
|
|
120
|
+
}).describe("Metadata about the request.").optional(),
|
|
121
|
+
stop_sequences: z.array(z.string().describe("A stop sequence.")).describe("Custom text sequences that stop generation.").optional(),
|
|
122
|
+
stream: z.boolean().describe("Whether to request a streaming response. This connector only accepts false or an omitted value.").optional(),
|
|
123
|
+
temperature: z.number().min(0).max(1).describe("The sampling temperature.").optional(),
|
|
124
|
+
thinking: z.record(z.string(), z.unknown().describe("Any JSON value accepted by the Anthropic API.")).describe("A JSON object passed through to the Anthropic API.").optional(),
|
|
125
|
+
tool_choice: z.union([z.enum(["auto", "any", "none"]).describe("A predefined tool choice mode."), z.record(z.string(), z.unknown().describe("Any JSON value accepted by the Anthropic API.")).describe("A JSON object passed through to the Anthropic API.")]).describe("Tool selection strategy for the request.").optional(),
|
|
126
|
+
tools: z.array(z.record(z.string(), z.unknown().describe("Any JSON value accepted by the Anthropic API.")).describe("A JSON object passed through to the Anthropic API.")).describe("Tools available to the model.").optional(),
|
|
127
|
+
top_k: z.int().min(0).describe("Only sample from the top K options for each token.").optional(),
|
|
128
|
+
top_p: z.number().min(0).max(1).describe("The nucleus sampling threshold.").optional()
|
|
129
|
+
}).describe("The input payload for creating a non-streaming Anthropic message.");
|
|
130
|
+
var createMessageOutput = z.looseObject({
|
|
131
|
+
id: z.string().describe("The message identifier.").optional(),
|
|
132
|
+
type: z.string().describe("The object type returned by the API.").optional(),
|
|
133
|
+
role: z.string().describe("The role of the returned message.").optional(),
|
|
134
|
+
model: z.string().describe("The model used to generate the response.").optional(),
|
|
135
|
+
content: z.array(z.looseObject({}).describe("A structured Anthropic content block.")).describe("Content blocks generated by the model.").optional(),
|
|
136
|
+
stop_reason: z.string().describe("The reason generation stopped.").nullable().optional(),
|
|
137
|
+
stop_sequence: z.string().describe("The stop sequence that ended generation.").nullable().optional(),
|
|
138
|
+
usage: z.looseObject({
|
|
139
|
+
input_tokens: z.int().describe("The number of input tokens consumed.").optional(),
|
|
140
|
+
output_tokens: z.int().describe("The number of output tokens generated.").optional()
|
|
141
|
+
}).describe("Token usage information.").optional()
|
|
142
|
+
}).describe("The response payload for an Anthropic message.");
|
|
143
|
+
var countMessageTokensInput = z.looseObject({
|
|
144
|
+
model: z.string().describe("The Anthropic model identifier to use."),
|
|
145
|
+
messages: z.array(z.looseObject({
|
|
146
|
+
role: z.enum(["user", "assistant"]).describe("The role of the message author.").optional(),
|
|
147
|
+
content: z.union([z.string().describe("Plain text message content."), z.array(z.looseObject({}).describe("A structured Anthropic content block.")).min(1).describe("Structured content blocks.")]).describe("Anthropic message content.").optional()
|
|
148
|
+
}).describe("An input message in an Anthropic conversation.")).min(1).describe("The ordered conversation history to count."),
|
|
149
|
+
system: z.union([z.string().describe("Plain text system prompt."), z.array(z.looseObject({}).describe("A structured Anthropic content block.")).min(1).describe("Structured system prompt content blocks.")]).describe("System prompt content.").optional(),
|
|
150
|
+
thinking: z.record(z.string(), z.unknown().describe("Any JSON value accepted by the Anthropic API.")).describe("A JSON object passed through to the Anthropic API.").optional(),
|
|
151
|
+
tool_choice: z.union([z.enum(["auto", "any", "none"]).describe("A predefined tool choice mode."), z.record(z.string(), z.unknown().describe("Any JSON value accepted by the Anthropic API.")).describe("A JSON object passed through to the Anthropic API.")]).describe("Tool selection strategy for the request.").optional(),
|
|
152
|
+
tools: z.array(z.record(z.string(), z.unknown().describe("Any JSON value accepted by the Anthropic API.")).describe("A JSON object passed through to the Anthropic API.")).describe("Tools available to the model.").optional()
|
|
153
|
+
}).describe("The input payload for counting tokens in an Anthropic message request.");
|
|
154
|
+
var countMessageTokensOutput = z.looseObject({
|
|
155
|
+
input_tokens: z.int().describe("The number of input tokens counted for the request.").optional()
|
|
156
|
+
}).describe("The response payload for counting Anthropic message tokens.");
|
|
157
|
+
var anthropicActions = {
|
|
158
|
+
list_models: {
|
|
159
|
+
description: "List Anthropic models available to the current API key.",
|
|
160
|
+
effect: "read",
|
|
161
|
+
inputSchema: listModelsInput,
|
|
162
|
+
outputSchema: z.toJSONSchema(listModelsOutput, { io: "output", unrepresentable: "any" })
|
|
163
|
+
},
|
|
164
|
+
get_model: {
|
|
165
|
+
description: "Fetch metadata for one Anthropic model.",
|
|
166
|
+
effect: "read",
|
|
167
|
+
inputSchema: getModelInput,
|
|
168
|
+
outputSchema: z.toJSONSchema(getModelOutput, { io: "output", unrepresentable: "any" })
|
|
169
|
+
},
|
|
170
|
+
create_message: {
|
|
171
|
+
description: "Create a non-streaming Anthropic message.",
|
|
172
|
+
effect: "write",
|
|
173
|
+
inputSchema: createMessageInput,
|
|
174
|
+
outputSchema: z.toJSONSchema(createMessageOutput, { io: "output", unrepresentable: "any" })
|
|
175
|
+
},
|
|
176
|
+
count_message_tokens: {
|
|
177
|
+
description: "Count input tokens for an Anthropic message request.",
|
|
178
|
+
effect: "read",
|
|
179
|
+
inputSchema: countMessageTokensInput,
|
|
180
|
+
outputSchema: z.toJSONSchema(countMessageTokensOutput, { io: "output", unrepresentable: "any" })
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// ../plugins/src/anthropic/index.ts
|
|
185
|
+
function createAnthropicPlugin() {
|
|
186
|
+
return createProviderPlugin({
|
|
187
|
+
description: "Anthropic",
|
|
188
|
+
actions: anthropicActions,
|
|
189
|
+
// 上游 credentialValidators 也打 /v1/models —— 只读、无必填入参,正好当挂载时的凭证探针。
|
|
190
|
+
credentialProbe: "list_models",
|
|
191
|
+
handlers: {
|
|
192
|
+
list_models: listModels,
|
|
193
|
+
get_model: getModel,
|
|
194
|
+
create_message: createMessage,
|
|
195
|
+
count_message_tokens: countMessageTokens
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
var anthropic_default = createAnthropicPlugin();
|
|
200
|
+
export {
|
|
201
|
+
createAnthropicPlugin,
|
|
202
|
+
anthropic_default as default
|
|
203
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-TDAWLMDE.js";
|
|
4
|
+
import "./chunk-VWRUGUSU.js";
|
|
5
|
+
import {
|
|
6
|
+
asJsonObject
|
|
7
|
+
} from "./chunk-JXHMDBAY.js";
|
|
8
|
+
import {
|
|
9
|
+
createProviderPlugin,
|
|
10
|
+
upstreamError
|
|
11
|
+
} from "./chunk-WJHG6OK7.js";
|
|
12
|
+
import "./chunk-2JNAI4OC.js";
|
|
13
|
+
import "./chunk-BADVCN6K.js";
|
|
14
|
+
import {
|
|
15
|
+
TBError
|
|
16
|
+
} from "./chunk-5ICRY3VU.js";
|
|
17
|
+
import "./chunk-U67V476Y.js";
|
|
18
|
+
|
|
19
|
+
// ../plugins/src/apify/api.ts
|
|
20
|
+
var SERVICE = "apify";
|
|
21
|
+
var API_BASE = "https://api.apify.com";
|
|
22
|
+
var CURRENT_USER_PATH = "/v2/users/me";
|
|
23
|
+
function nonEmpty(value) {
|
|
24
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
function errorMessage(payload, status) {
|
|
27
|
+
const record = asJsonObject(payload);
|
|
28
|
+
const error = asJsonObject(record?.error);
|
|
29
|
+
return nonEmpty(error?.message) ?? nonEmpty(record?.message) ?? nonEmpty(error?.type) ?? `Apify request failed with status ${status}`;
|
|
30
|
+
}
|
|
31
|
+
var http = createAuthedClient({
|
|
32
|
+
baseUrl: `${API_BASE}/`,
|
|
33
|
+
service: SERVICE,
|
|
34
|
+
auth: { kind: "bearer" },
|
|
35
|
+
headers: { accept: "application/json" },
|
|
36
|
+
mapError: ({ bodyKind, data: payload, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "Apify \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true }) : upstreamError(status, errorMessage(payload, status)),
|
|
37
|
+
mapTransportError: ({ message }) => new TBError(
|
|
38
|
+
"unavailable",
|
|
39
|
+
message === void 0 ? "Apify \u8BF7\u6C42\u5931\u8D25" : `Apify \u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
40
|
+
{ retryable: true }
|
|
41
|
+
)
|
|
42
|
+
});
|
|
43
|
+
function requiredId(value, field) {
|
|
44
|
+
if (value === void 0 || value === "") {
|
|
45
|
+
throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
46
|
+
}
|
|
47
|
+
return encodeURIComponent(value);
|
|
48
|
+
}
|
|
49
|
+
async function request(ctx, path, init = {}) {
|
|
50
|
+
const { data } = await http.request(ctx, {
|
|
51
|
+
path,
|
|
52
|
+
method: init.method ?? "GET",
|
|
53
|
+
query: Object.entries(init.query ?? {}),
|
|
54
|
+
...init.body === void 0 ? {} : { json: init.body },
|
|
55
|
+
invalidJsonMessage: "Apify \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
56
|
+
});
|
|
57
|
+
return data ?? null;
|
|
58
|
+
}
|
|
59
|
+
function unwrap(payload, label) {
|
|
60
|
+
const record = asJsonObject(payload);
|
|
61
|
+
if (record === void 0) {
|
|
62
|
+
throw new TBError("unavailable", `Apify \u7684${label}\u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
63
|
+
}
|
|
64
|
+
if (!Object.prototype.hasOwnProperty.call(record, "data")) return record;
|
|
65
|
+
const data = asJsonObject(record.data);
|
|
66
|
+
if (data === void 0) {
|
|
67
|
+
throw new TBError("unavailable", `Apify \u7684${label}\u54CD\u5E94 data \u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
function flag(value) {
|
|
72
|
+
return value === void 0 ? void 0 : value ? 1 : 0;
|
|
73
|
+
}
|
|
74
|
+
async function getCurrentUser(_input, ctx) {
|
|
75
|
+
return { user: unwrap(await request(ctx, CURRENT_USER_PATH), "user") };
|
|
76
|
+
}
|
|
77
|
+
async function getActor(input, ctx) {
|
|
78
|
+
const payload = await request(ctx, `/v2/acts/${requiredId(input.actorId, "actorId")}`);
|
|
79
|
+
return { actor: unwrap(payload, "actor") };
|
|
80
|
+
}
|
|
81
|
+
async function runActor(input, ctx) {
|
|
82
|
+
const payload = await request(ctx, `/v2/acts/${encodeURIComponent(input.actorId)}/runs`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
// 上游即使没给 input 也发一个空对象体(Apify 要求 POST 带 JSON body)。
|
|
85
|
+
body: input.input ?? {},
|
|
86
|
+
query: {
|
|
87
|
+
build: input.build,
|
|
88
|
+
memory: input.memoryMbytes,
|
|
89
|
+
timeout: input.timeoutSecs
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return { run: unwrap(payload, "run") };
|
|
93
|
+
}
|
|
94
|
+
async function getRun(input, ctx) {
|
|
95
|
+
const payload = await request(ctx, `/v2/actor-runs/${encodeURIComponent(input.runId)}`, {
|
|
96
|
+
query: { waitForFinish: input.waitForFinishSeconds }
|
|
97
|
+
});
|
|
98
|
+
return { run: unwrap(payload, "run") };
|
|
99
|
+
}
|
|
100
|
+
async function getDatasetItems(input, ctx) {
|
|
101
|
+
const payload = await request(ctx, `/v2/datasets/${encodeURIComponent(input.datasetId)}/items`, {
|
|
102
|
+
query: {
|
|
103
|
+
limit: input.limit,
|
|
104
|
+
offset: input.offset,
|
|
105
|
+
clean: flag(input.clean),
|
|
106
|
+
skipHidden: flag(input.skipHidden)
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (!Array.isArray(payload)) {
|
|
110
|
+
throw new TBError("unavailable", "Apify \u7684 dataset items \u54CD\u5E94\u4E0D\u662F\u6570\u7EC4", { retryable: true });
|
|
111
|
+
}
|
|
112
|
+
return { items: payload };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ../plugins/src/apify/schema.ts
|
|
116
|
+
import { z } from "zod/v4";
|
|
117
|
+
var getCurrentUserInput = z.strictObject({}).describe("The input for retrieving the current Apify user.");
|
|
118
|
+
var getCurrentUserOutput = z.strictObject({
|
|
119
|
+
user: z.looseObject({
|
|
120
|
+
id: z.string().describe("The Apify user identifier.").optional(),
|
|
121
|
+
username: z.string().describe("The Apify username."),
|
|
122
|
+
email: z.string().describe("The email address of the Apify user.").optional(),
|
|
123
|
+
plan: z.looseObject({}).describe("The Apify subscription plan.").optional(),
|
|
124
|
+
proxy: z.looseObject({}).describe("The Apify proxy configuration.").optional()
|
|
125
|
+
}).describe("The current Apify user account.").optional()
|
|
126
|
+
}).describe("The current authenticated Apify user response.");
|
|
127
|
+
var getActorInput = z.strictObject({
|
|
128
|
+
actorId: z.string().min(1).describe("The Apify actor identifier, such as apify~web-scraper or apify/web-scraper.").optional()
|
|
129
|
+
}).describe("The input for retrieving one Apify actor.");
|
|
130
|
+
var getActorOutput = z.strictObject({
|
|
131
|
+
actor: z.looseObject({
|
|
132
|
+
id: z.string().describe("The Apify actor identifier."),
|
|
133
|
+
userId: z.string().describe("The owner user identifier."),
|
|
134
|
+
name: z.string().describe("The internal actor name."),
|
|
135
|
+
username: z.string().describe("The actor owner's username."),
|
|
136
|
+
title: z.string().describe("The actor display title.").optional(),
|
|
137
|
+
description: z.string().describe("The actor description.").optional(),
|
|
138
|
+
isPublic: z.boolean().describe("Whether the actor is public."),
|
|
139
|
+
createdAt: z.string().describe("When the actor was created.").optional(),
|
|
140
|
+
modifiedAt: z.string().describe("When the actor was last modified.").optional(),
|
|
141
|
+
stats: z.looseObject({}).describe("Actor usage and popularity statistics.").optional()
|
|
142
|
+
}).describe("An Apify actor.").optional()
|
|
143
|
+
}).describe("The Apify actor response.");
|
|
144
|
+
var runActorInput = z.strictObject({
|
|
145
|
+
actorId: z.string().min(1).describe("The Apify actor identifier, such as apify~web-scraper or apify/web-scraper."),
|
|
146
|
+
input: z.record(z.string(), z.unknown().describe("A JSON-compatible Apify value.")).describe("The JSON input object passed to the actor run.").optional(),
|
|
147
|
+
build: z.string().min(1).describe("The actor build tag or number to run.").optional(),
|
|
148
|
+
memoryMbytes: z.int().min(1).describe("The memory limit for the run in megabytes.").optional(),
|
|
149
|
+
timeoutSecs: z.int().min(1).describe("The maximum runtime for the run in seconds.").optional()
|
|
150
|
+
}).describe("The input for starting one Apify actor run.");
|
|
151
|
+
var runActorOutput = z.strictObject({
|
|
152
|
+
run: z.looseObject({
|
|
153
|
+
id: z.string().describe("The Apify run identifier."),
|
|
154
|
+
actId: z.string().describe("The actor identifier associated with the run."),
|
|
155
|
+
status: z.string().describe("The current run status."),
|
|
156
|
+
startedAt: z.string().describe("When the run started.").optional(),
|
|
157
|
+
finishedAt: z.string().describe("When the run finished.").optional(),
|
|
158
|
+
defaultDatasetId: z.string().describe("The default dataset identifier created for the run.").optional(),
|
|
159
|
+
defaultKeyValueStoreId: z.string().describe("The default key-value store identifier created for the run.").optional(),
|
|
160
|
+
defaultRequestQueueId: z.string().describe("The default request queue identifier created for the run.").optional(),
|
|
161
|
+
stats: z.looseObject({}).describe("The run statistics object.").optional(),
|
|
162
|
+
options: z.looseObject({}).describe("The run options object.").optional(),
|
|
163
|
+
usage: z.looseObject({}).describe("The run usage summary object.").optional()
|
|
164
|
+
}).describe("An Apify actor run.").optional()
|
|
165
|
+
}).describe("The Apify actor run creation response.");
|
|
166
|
+
var getRunInput = z.strictObject({
|
|
167
|
+
runId: z.string().min(1).describe("The Apify actor run identifier."),
|
|
168
|
+
waitForFinishSeconds: z.int().min(0).max(60).describe("How many seconds to wait for run completion before returning.").optional()
|
|
169
|
+
}).describe("The input for retrieving one Apify actor run.");
|
|
170
|
+
var getRunOutput = z.strictObject({
|
|
171
|
+
run: z.looseObject({
|
|
172
|
+
id: z.string().describe("The Apify run identifier."),
|
|
173
|
+
actId: z.string().describe("The actor identifier associated with the run."),
|
|
174
|
+
status: z.string().describe("The current run status."),
|
|
175
|
+
startedAt: z.string().describe("When the run started.").optional(),
|
|
176
|
+
finishedAt: z.string().describe("When the run finished.").optional(),
|
|
177
|
+
defaultDatasetId: z.string().describe("The default dataset identifier created for the run.").optional(),
|
|
178
|
+
defaultKeyValueStoreId: z.string().describe("The default key-value store identifier created for the run.").optional(),
|
|
179
|
+
defaultRequestQueueId: z.string().describe("The default request queue identifier created for the run.").optional(),
|
|
180
|
+
stats: z.looseObject({}).describe("The run statistics object.").optional(),
|
|
181
|
+
options: z.looseObject({}).describe("The run options object.").optional(),
|
|
182
|
+
usage: z.looseObject({}).describe("The run usage summary object.").optional()
|
|
183
|
+
}).describe("An Apify actor run.").optional()
|
|
184
|
+
}).describe("The Apify actor run response.");
|
|
185
|
+
var getDatasetItemsInput = z.strictObject({
|
|
186
|
+
datasetId: z.string().min(1).describe("The Apify dataset identifier."),
|
|
187
|
+
limit: z.int().min(1).describe("The maximum number of items to return.").optional(),
|
|
188
|
+
offset: z.int().min(0).describe("How many items to skip before returning results.").optional(),
|
|
189
|
+
clean: z.boolean().describe("Whether hidden fields and empty values should be removed from each item.").optional(),
|
|
190
|
+
skipHidden: z.boolean().describe("Whether fields starting with a hash sign should be skipped.").optional()
|
|
191
|
+
}).describe("The input for retrieving items from an Apify dataset.");
|
|
192
|
+
var getDatasetItemsOutput = z.strictObject({
|
|
193
|
+
items: z.array(z.record(z.string(), z.unknown().describe("A JSON-compatible Apify value."))).describe("The ordered list of Apify dataset items.").optional()
|
|
194
|
+
}).describe("The Apify dataset items response.");
|
|
195
|
+
var apifyActions = {
|
|
196
|
+
get_current_user: {
|
|
197
|
+
description: "Retrieve the currently authenticated Apify user account.",
|
|
198
|
+
effect: "read",
|
|
199
|
+
inputSchema: getCurrentUserInput,
|
|
200
|
+
outputSchema: z.toJSONSchema(getCurrentUserOutput, { io: "output", unrepresentable: "any" })
|
|
201
|
+
},
|
|
202
|
+
get_actor: {
|
|
203
|
+
description: "Retrieve metadata for one Apify actor by identifier.",
|
|
204
|
+
effect: "read",
|
|
205
|
+
inputSchema: getActorInput,
|
|
206
|
+
outputSchema: z.toJSONSchema(getActorOutput, { io: "output", unrepresentable: "any" })
|
|
207
|
+
},
|
|
208
|
+
run_actor: {
|
|
209
|
+
description: "Start one Apify actor run with an optional JSON input payload.",
|
|
210
|
+
effect: "write",
|
|
211
|
+
inputSchema: runActorInput,
|
|
212
|
+
outputSchema: z.toJSONSchema(runActorOutput, { io: "output", unrepresentable: "any" })
|
|
213
|
+
},
|
|
214
|
+
get_run: {
|
|
215
|
+
description: "Retrieve the current status and storage identifiers for one Apify actor run.",
|
|
216
|
+
effect: "read",
|
|
217
|
+
inputSchema: getRunInput,
|
|
218
|
+
outputSchema: z.toJSONSchema(getRunOutput, { io: "output", unrepresentable: "any" })
|
|
219
|
+
},
|
|
220
|
+
get_dataset_items: {
|
|
221
|
+
description: "Retrieve JSON items from one Apify dataset.",
|
|
222
|
+
effect: "read",
|
|
223
|
+
inputSchema: getDatasetItemsInput,
|
|
224
|
+
outputSchema: z.toJSONSchema(getDatasetItemsOutput, { io: "output", unrepresentable: "any" })
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// ../plugins/src/apify/index.ts
|
|
229
|
+
function createApifyPlugin() {
|
|
230
|
+
return createProviderPlugin({
|
|
231
|
+
description: "Apify",
|
|
232
|
+
actions: apifyActions,
|
|
233
|
+
// 与上游 credentialValidators 打的是同一个端点(/v2/users/me):只读、无必填入参。
|
|
234
|
+
credentialProbe: "get_current_user",
|
|
235
|
+
handlers: {
|
|
236
|
+
get_current_user: getCurrentUser,
|
|
237
|
+
get_actor: getActor,
|
|
238
|
+
run_actor: runActor,
|
|
239
|
+
get_run: getRun,
|
|
240
|
+
get_dataset_items: getDatasetItems
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
var apify_default = createApifyPlugin();
|
|
245
|
+
export {
|
|
246
|
+
createApifyPlugin,
|
|
247
|
+
apify_default as default
|
|
248
|
+
};
|