@tool-bridge/server 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{airtable-ZNWHIJMO.js → airtable-LLZDFN7M.js} +19 -16
- package/dist/{alt_text_generator_ai-X7RMDDM5.js → alt_text_generator_ai-W7O34SNG.js} +4 -4
- package/dist/{amap-3VER75VH.js → amap-VOX4T2AW.js} +4 -4
- package/dist/{anthropic-N7NTB3UC.js → anthropic-G23NN3X5.js} +23 -25
- package/dist/{apify-JB5P5AJI.js → apify-Y3SS734K.js} +20 -19
- package/dist/{brave_search-USL5OOBS.js → brave_search-ZC7OAPSZ.js} +16 -14
- package/dist/{chunk-6ANLYNFB.js → chunk-ATK45BXV.js} +1 -1
- package/dist/{chunk-6X55ALDX.js → chunk-E6JCVKW6.js} +6 -5
- package/dist/{chunk-RVUERWUZ.js → chunk-KMTT3I6D.js} +768 -1048
- package/dist/chunk-R6P4XAE5.js +248 -0
- package/dist/{chunk-3WL6EXYX.js → chunk-U7B6DS2O.js} +1 -1
- package/dist/{chunk-WIGQCP6O.js → chunk-UZM2RXZH.js} +159 -182
- package/dist/chunk-XYBU3WZH.js +71 -0
- package/dist/{circleci-LBGB25LP.js → circleci-3BAX5FCG.js} +20 -24
- package/dist/{clerk-6RX37CNZ.js → clerk-6LEM6TNU.js} +22 -21
- package/dist/{cloudflare_dns-NQGW7FHV.js → cloudflare_dns-KINYTJUD.js} +21 -17
- package/dist/{cohere-XPC2NAEW.js → cohere-XCJ5AJ6B.js} +19 -17
- package/dist/{confluence-ZUG2LT5A.js → confluence-B3EWPZVE.js} +16 -11
- package/dist/{convertapi-ZLXKWV3L.js → convertapi-EUWSQYPF.js} +3 -3
- package/dist/{currencyapi-T3A3HSOD.js → currencyapi-KVTIK3GL.js} +23 -26
- package/dist/{deepseek-NJMOD23E.js → deepseek-PC5YGNC5.js} +27 -17
- package/dist/{docker_hub-D2MQCSJ7.js → docker_hub-C3MA5FU6.js} +4 -4
- package/dist/{dropbox-MI6U3SOT.js → dropbox-XBV7Z2IR.js} +9 -8
- package/dist/{dub-P2BYBYV4.js → dub-LDOFG3HC.js} +22 -19
- package/dist/{e2b-BGKIAE54.js → e2b-JMCPSVBW.js} +20 -20
- package/dist/{exa-EUY7VV4C.js → exa-RAK7O7RD.js} +22 -25
- package/dist/{fal_ai-AAOG5FYJ.js → fal_ai-23E7JPNT.js} +18 -17
- package/dist/feishu-7QRIDUV6.js +12019 -0
- package/dist/{feishu_custom_bot-BWGMNVXF.js → feishu_custom_bot-TJ4K7QNJ.js} +3 -3
- package/dist/{figma-SJSWYCGD.js → figma-E6IX5DTH.js} +21 -23
- package/dist/{firehydrant-MOXK2PST.js → firehydrant-ZBLPQREE.js} +15 -15
- package/dist/{fixer-ISIDUDZU.js → fixer-BWON27UO.js} +4 -4
- package/dist/{fly-U4KPSGBF.js → fly-ZH3HFCZJ.js} +20 -16
- package/dist/{front-ZHM2YX2E.js → front-QCGXYEDJ.js} +20 -23
- package/dist/{geocodio-SVCCAXAV.js → geocodio-YGNI7DA4.js} +4 -4
- package/dist/{ghost-INTR7FIY.js → ghost-EVSGKH2Q.js} +4 -4
- package/dist/{github-T275VVWR.js → github-MA2BGRCJ.js} +28 -27
- package/dist/{gmail-KSSPOE67.js → gmail-E5E6AADE.js} +17 -17
- package/dist/{googlecalendar-JB5RW27L.js → googlecalendar-BTLFPXTD.js} +22 -19
- package/dist/{googledocs-G522PUGW.js → googledocs-BUHL4J2H.js} +6 -5
- package/dist/{grafana-44ZPIV5P.js → grafana-GLU2DWF2.js} +24 -25
- package/dist/{graphhopper-2MORXLOW.js → graphhopper-WSMB3TCD.js} +4 -4
- package/dist/index.d.ts +31 -30
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-R4K4KEMI.js → ip2proxy-EZ64Y4ZH.js} +4 -4
- package/dist/{ipgeolocation_io-H4J55OGI.js → ipgeolocation_io-AA7HAS22.js} +4 -4
- package/dist/{ipqualityscore-XGID4OHA.js → ipqualityscore-BHJXVTJT.js} +4 -4
- package/dist/{jina_ai-7ZVDOR3Z.js → jina_ai-EFBHTBXL.js} +20 -21
- package/dist/{jira-CTIYZTT3.js → jira-HQSHAA5K.js} +20 -16
- package/dist/{langsmith-ISP567FS.js → langsmith-5W6SCT6F.js} +25 -25
- package/dist/{lemlist-OGKK272F.js → lemlist-HJWH6UMK.js} +23 -24
- package/dist/{linear-6JX4E3JI.js → linear-K7RYFYAD.js} +6 -5
- package/dist/{logsnag-BVB36ZCL.js → logsnag-4KFOHL37.js} +20 -22
- package/dist/main.js +103 -102
- package/dist/{mattermost-UECVPZGY.js → mattermost-S2BRCWLQ.js} +21 -17
- package/dist/{mem0-EUA7S2OO.js → mem0-CAW43CIC.js} +15 -15
- package/dist/{memos-BYSBJRWZ.js → memos-TWEGPKFM.js} +39 -34
- package/dist/{metabase-4JXZH3YG.js → metabase-MMSEPCOF.js} +22 -18
- package/dist/{mistral_ai-2C5BTBKW.js → mistral_ai-64BGZQHP.js} +24 -21
- package/dist/{mother_duck-ZGNNNR3X.js → mother_duck-H7PCQNZ2.js} +23 -19
- package/dist/{ngrok-NTPGMRXI.js → ngrok-GQCUGZKJ.js} +17 -22
- package/dist/{notes-KGYXX6N6.js → notes-PFMKRO33.js} +1 -1
- package/dist/{notion-EX3X2G7G.js → notion-DQWZWP4N.js} +20 -17
- package/dist/{open_exchange_rates-2V2LIGPS.js → open_exchange_rates-QMMD735E.js} +4 -4
- package/dist/{openai-KQFQPK7Z.js → openai-W6PX32NZ.js} +22 -16
- package/dist/{opengraph_io-B63SEYJY.js → opengraph_io-HNDBXYNW.js} +4 -4
- package/dist/{openrouter-62A4H62Q.js → openrouter-JJYMEAUL.js} +19 -14
- package/dist/{outline-QC33XLCK.js → outline-MCBNQZYY.js} +18 -20
- package/dist/{paddle-HDZG35Y7.js → paddle-D2SKLUDN.js} +17 -15
- package/dist/{perplexity-M7LOMJWA.js → perplexity-XIFMKUAE.js} +19 -23
- package/dist/{pinecone-Y7YCJRZM.js → pinecone-HUFTALV2.js} +19 -24
- package/dist/{pipedrive-FLJA62UX.js → pipedrive-Y2O7QGFF.js} +22 -23
- package/dist/{polar-AE55Q425.js → polar-TYTOMOSR.js} +19 -17
- package/dist/{posthog-IAY5D3YW.js → posthog-43JAR3VW.js} +29 -24
- package/dist/{postmark-NMKAXDXZ.js → postmark-KL2QJYSG.js} +19 -17
- package/dist/{prerender-CDJM7I7N.js → prerender-MENYM2TY.js} +4 -4
- package/dist/{pubmed-N437ZJOR.js → pubmed-GOXUVVH5.js} +6 -5
- package/dist/{railway-NBWYXCUM.js → railway-V2SID4WV.js} +3 -3
- package/dist/{readwise-QRO3UC3R.js → readwise-CI4GIMMJ.js} +16 -15
- package/dist/{render-NEW7SROG.js → render-SUBJ6YRZ.js} +21 -20
- package/dist/{replicate-73YQLRTY.js → replicate-756MXPYX.js} +20 -21
- package/dist/{resend-R5BAZFHZ.js → resend-ZKH3BTBI.js} +15 -11
- package/dist/{rootly-5BLALPCS.js → rootly-CD2LJHPI.js} +19 -18
- package/dist/{scrapfly-EHFLNNUZ.js → scrapfly-NSRHFDIQ.js} +4 -4
- package/dist/{scrapingbee-UXLYS72S.js → scrapingbee-OQHLAVEY.js} +4 -4
- package/dist/{screenshot_fyi-KC3NLTJ6.js → screenshot_fyi-DVWG3AXC.js} +4 -4
- package/dist/{semantic_scholar-SA5OIUWA.js → semantic_scholar-T4A252KW.js} +21 -20
- package/dist/{sentry-BAE3XLJN.js → sentry-546MNDJG.js} +22 -19
- package/dist/{shodan-FJR6MKKW.js → shodan-C3OON3Z3.js} +4 -4
- package/dist/{shopify-7OA6SLN5.js → shopify-Y2HN2MCQ.js} +23 -19
- package/dist/{stripe-MUWDZGGF.js → stripe-VE3CD3AY.js} +3 -3
- package/dist/{supabase-SWWGNWYR.js → supabase-U2SL4D63.js} +18 -17
- package/dist/{tavily-XQNJ5EDI.js → tavily-KCZHK6HE.js} +20 -20
- package/dist/{telegram-RR6JPZOG.js → telegram-3URFBCMY.js} +4 -4
- package/dist/{telnyx-7PKXOWSO.js → telnyx-CXQ4EZUX.js} +19 -19
- package/dist/{todoist-63X5IUJE.js → todoist-HNPWNYTD.js} +18 -17
- package/dist/{trello-MOG63DAI.js → trello-3W2MIXRP.js} +4 -4
- package/dist/{turso-ENWTSHDL.js → turso-2EQF7C2Z.js} +23 -30
- package/dist/{twilio-FDXUN7VX.js → twilio-4PDBJKWX.js} +6 -5
- package/dist/{umami-TM7PROWF.js → umami-5REN7TGP.js} +23 -28
- package/dist/{unsplash-NWXLKSOW.js → unsplash-EIXL424F.js} +19 -18
- package/dist/{upstash_redis-CUTQ5L2N.js → upstash_redis-G4LQBYHA.js} +17 -13
- package/dist/{uptimerobot-NNO32M3I.js → uptimerobot-KNJ3EYLY.js} +3 -3
- package/dist/{v2ex-24KMSWS7.js → v2ex-RHJ234PZ.js} +35 -18
- package/dist/{vercel-B45LPF6I.js → vercel-AS6NCIC7.js} +21 -18
- package/dist/{wolfram_alpha_api-DKJWVR6G.js → wolfram_alpha_api-3G4PUJWB.js} +4 -4
- package/dist/{wordpress-XYFSDZXY.js → wordpress-KNDAAUV7.js} +21 -17
- package/dist/{workos-BEM7EPHM.js → workos-R6UITSJ7.js} +26 -27
- package/dist/{zhihu-CFHZ4NC7.js → zhihu-AGK4HILK.js} +21 -21
- package/package.json +5 -5
- package/dist/feishu-AN5IJYOW.js +0 -231
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
booleanValue,
|
|
@@ -10,21 +11,19 @@ import {
|
|
|
10
11
|
} from "./chunk-JXHMDBAY.js";
|
|
11
12
|
import {
|
|
12
13
|
createProviderPlugin,
|
|
13
|
-
requireApiKey,
|
|
14
14
|
upstreamError
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-ATK45BXV.js";
|
|
16
|
+
import "./chunk-U7B6DS2O.js";
|
|
17
17
|
import {
|
|
18
18
|
TBError,
|
|
19
19
|
external_exports
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-UZM2RXZH.js";
|
|
21
21
|
import "./chunk-U67V476Y.js";
|
|
22
22
|
|
|
23
23
|
// ../plugins/src/airtable/api.ts
|
|
24
24
|
var SERVICE = "airtable";
|
|
25
25
|
var API_BASE = "https://api.airtable.com";
|
|
26
26
|
var BASES_PATH = "/v0/meta/bases";
|
|
27
|
-
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
28
27
|
var GET_URL_LENGTH_SOFT_LIMIT = 15e3;
|
|
29
28
|
function requireText(value, field) {
|
|
30
29
|
const result = trimmedText(value);
|
|
@@ -82,21 +81,25 @@ function mapAirtableError(context) {
|
|
|
82
81
|
return upstreamError(502, "airtable response parsing failed: invalid JSON");
|
|
83
82
|
}
|
|
84
83
|
}
|
|
84
|
+
var http = createAuthedClient({
|
|
85
|
+
baseUrl: API_BASE,
|
|
86
|
+
service: SERVICE,
|
|
87
|
+
auth: { kind: "bearer" },
|
|
88
|
+
headers: { accept: "application/json" },
|
|
89
|
+
mapError: mapAirtableError,
|
|
90
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
91
|
+
502,
|
|
92
|
+
`airtable request failed: ${message ?? "unknown request error"}`
|
|
93
|
+
)
|
|
94
|
+
});
|
|
85
95
|
async function request(ctx, input) {
|
|
86
|
-
const
|
|
87
|
-
const result = await http.request({
|
|
96
|
+
const result = await http.request(ctx, {
|
|
88
97
|
path: input.path,
|
|
89
98
|
method: input.method ?? "GET",
|
|
90
99
|
query: input.query,
|
|
91
|
-
headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
|
|
92
100
|
...input.body === void 0 ? {} : { json: input.body },
|
|
93
101
|
invalidJson: "text",
|
|
94
|
-
responseType: "auto"
|
|
95
|
-
mapError: mapAirtableError,
|
|
96
|
-
mapTransportError: ({ message }) => upstreamError(
|
|
97
|
-
502,
|
|
98
|
-
`airtable request failed: ${message ?? "unknown request error"}`
|
|
99
|
-
)
|
|
102
|
+
responseType: "auto"
|
|
100
103
|
});
|
|
101
104
|
return responsePayload(result);
|
|
102
105
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderHttpClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E6JCVKW6.js";
|
|
4
4
|
import "./chunk-JXHMDBAY.js";
|
|
5
5
|
import {
|
|
6
6
|
createProviderPlugin,
|
|
7
7
|
requireApiKey,
|
|
8
8
|
upstreamError
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-ATK45BXV.js";
|
|
10
|
+
import "./chunk-U7B6DS2O.js";
|
|
11
11
|
import {
|
|
12
12
|
TBError,
|
|
13
13
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UZM2RXZH.js";
|
|
15
15
|
import "./chunk-U67V476Y.js";
|
|
16
16
|
|
|
17
17
|
// ../plugins/src/alt_text_generator_ai/schema.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderHttpClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E6JCVKW6.js";
|
|
4
4
|
import {
|
|
5
5
|
asJsonObject,
|
|
6
6
|
booleanValue,
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
createProviderPlugin,
|
|
11
11
|
requireApiKey,
|
|
12
12
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-ATK45BXV.js";
|
|
14
|
+
import "./chunk-U7B6DS2O.js";
|
|
15
15
|
import {
|
|
16
16
|
TBError,
|
|
17
17
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UZM2RXZH.js";
|
|
19
19
|
import "./chunk-U67V476Y.js";
|
|
20
20
|
|
|
21
21
|
// ../plugins/src/amap/api.ts
|
|
@@ -1,57 +1,55 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
|
-
asJsonObject,
|
|
6
6
|
compactDefined,
|
|
7
7
|
trimmedText
|
|
8
8
|
} from "./chunk-JXHMDBAY.js";
|
|
9
9
|
import {
|
|
10
10
|
createProviderPlugin,
|
|
11
|
-
requireApiKey,
|
|
12
11
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
15
14
|
import {
|
|
16
15
|
TBError,
|
|
17
16
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
19
18
|
import "./chunk-U67V476Y.js";
|
|
20
19
|
|
|
21
20
|
// ../plugins/src/anthropic/api.ts
|
|
22
21
|
var SERVICE = "anthropic";
|
|
23
22
|
var API_BASE = "https://api.anthropic.com";
|
|
24
23
|
var API_VERSION = "2023-06-01";
|
|
25
|
-
var http =
|
|
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
|
+
});
|
|
26
40
|
function requireText(value, field) {
|
|
27
41
|
const result = trimmedText(value);
|
|
28
42
|
if (result === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
29
43
|
return result;
|
|
30
44
|
}
|
|
31
|
-
function headers(apiKey) {
|
|
32
|
-
return {
|
|
33
|
-
"accept": "application/json",
|
|
34
|
-
"anthropic-version": API_VERSION,
|
|
35
|
-
"content-type": "application/json",
|
|
36
|
-
"x-api-key": apiKey
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function errorMessage(status, payload) {
|
|
40
|
-
const fallback = `anthropic request failed with ${status}`;
|
|
41
|
-
const nested = asJsonObject(asJsonObject(payload)?.error);
|
|
42
|
-
return trimmedText(nested?.message) ?? trimmedText(payload) ?? fallback;
|
|
43
|
-
}
|
|
44
45
|
async function request(ctx, input) {
|
|
45
|
-
const apiKey = requireApiKey(ctx, SERVICE);
|
|
46
46
|
const method = input.method ?? "GET";
|
|
47
|
-
const { data } = await http.request({
|
|
47
|
+
const { data } = await http.request(ctx, {
|
|
48
48
|
path: input.path,
|
|
49
49
|
method,
|
|
50
50
|
query: Object.entries(input.query ?? {}),
|
|
51
|
-
headers: headers(apiKey),
|
|
52
51
|
...input.body === void 0 ? {} : { json: input.body },
|
|
53
52
|
invalidJsonMessage: "anthropic returned malformed JSON",
|
|
54
|
-
mapError: ({ data: payload, status }) => upstreamError(status, errorMessage(status, payload)),
|
|
55
53
|
mapTransportError: ({ message }) => upstreamError(
|
|
56
54
|
502,
|
|
57
55
|
`anthropic ${method} ${input.path} failed before receiving response: ${message ?? "unknown network error"}`
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject
|
|
6
7
|
} from "./chunk-JXHMDBAY.js";
|
|
7
8
|
import {
|
|
8
9
|
createProviderPlugin,
|
|
9
|
-
requireApiKey,
|
|
10
10
|
upstreamError
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-ATK45BXV.js";
|
|
12
|
+
import "./chunk-U7B6DS2O.js";
|
|
13
13
|
import {
|
|
14
14
|
TBError,
|
|
15
15
|
external_exports
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UZM2RXZH.js";
|
|
17
17
|
import "./chunk-U67V476Y.js";
|
|
18
18
|
|
|
19
19
|
// ../plugins/src/apify/api.ts
|
|
20
20
|
var SERVICE = "apify";
|
|
21
21
|
var API_BASE = "https://api.apify.com";
|
|
22
22
|
var CURRENT_USER_PATH = "/v2/users/me";
|
|
23
|
-
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
24
23
|
function nonEmpty(value) {
|
|
25
24
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
26
25
|
}
|
|
@@ -29,6 +28,18 @@ function errorMessage(payload, status) {
|
|
|
29
28
|
const error = asJsonObject(record?.error);
|
|
30
29
|
return nonEmpty(error?.message) ?? nonEmpty(record?.message) ?? nonEmpty(error?.type) ?? `Apify request failed with status ${status}`;
|
|
31
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
|
+
});
|
|
32
43
|
function requiredId(value, field) {
|
|
33
44
|
if (value === void 0 || value === "") {
|
|
34
45
|
throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
@@ -36,22 +47,12 @@ function requiredId(value, field) {
|
|
|
36
47
|
return encodeURIComponent(value);
|
|
37
48
|
}
|
|
38
49
|
async function request(ctx, path, init = {}) {
|
|
39
|
-
const { data } = await http.request({
|
|
50
|
+
const { data } = await http.request(ctx, {
|
|
40
51
|
path,
|
|
41
52
|
method: init.method ?? "GET",
|
|
42
53
|
query: Object.entries(init.query ?? {}),
|
|
43
|
-
headers: {
|
|
44
|
-
accept: "application/json",
|
|
45
|
-
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
46
|
-
},
|
|
47
54
|
...init.body === void 0 ? {} : { json: init.body },
|
|
48
|
-
invalidJsonMessage: "Apify \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
49
|
-
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)),
|
|
50
|
-
mapTransportError: ({ message }) => new TBError(
|
|
51
|
-
"unavailable",
|
|
52
|
-
message === void 0 ? "Apify \u8BF7\u6C42\u5931\u8D25" : `Apify \u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
53
|
-
{ retryable: true }
|
|
54
|
-
)
|
|
55
|
+
invalidJsonMessage: "Apify \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
55
56
|
});
|
|
56
57
|
return data ?? null;
|
|
57
58
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
asJsonObject,
|
|
6
7
|
compactDefined,
|
|
@@ -8,20 +9,18 @@ import {
|
|
|
8
9
|
} from "./chunk-JXHMDBAY.js";
|
|
9
10
|
import {
|
|
10
11
|
createProviderPlugin,
|
|
11
|
-
requireApiKey,
|
|
12
12
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-ATK45BXV.js";
|
|
14
|
+
import "./chunk-U7B6DS2O.js";
|
|
15
15
|
import {
|
|
16
16
|
TBError,
|
|
17
17
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UZM2RXZH.js";
|
|
19
19
|
import "./chunk-U67V476Y.js";
|
|
20
20
|
|
|
21
21
|
// ../plugins/src/brave_search/api.ts
|
|
22
22
|
var SERVICE = "brave_search";
|
|
23
23
|
var API_BASE = "https://api.search.brave.com";
|
|
24
|
-
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
25
24
|
var RATE_LIMIT_CODES = /* @__PURE__ */ new Set(["QUOTA_LIMITED", "RATE_LIMITED", "USAGE_LIMIT_EXCEEDED"]);
|
|
26
25
|
var AUTH_CODES = /* @__PURE__ */ new Set(["SUBSCRIPTION_TOKEN_INVALID", "SUBSCRIPTION_NOT_FOUND"]);
|
|
27
26
|
var INVALID_CODES = /* @__PURE__ */ new Set(["RESOURCE_NOT_ALLOWED", "OPTION_NOT_IN_PLAN", "INVALID_URL"]);
|
|
@@ -60,17 +59,20 @@ function braveSearchError(status, payload) {
|
|
|
60
59
|
}
|
|
61
60
|
return upstreamError(status, message);
|
|
62
61
|
}
|
|
62
|
+
var http = createAuthedClient({
|
|
63
|
+
baseUrl: `${API_BASE}/`,
|
|
64
|
+
service: SERVICE,
|
|
65
|
+
auth: { kind: "header", name: "x-subscription-token" },
|
|
66
|
+
headers: { accept: "application/json" },
|
|
67
|
+
// 稳定错误码码表比 HTTP 状态准,整段覆写而不用标准键序提取。
|
|
68
|
+
mapError: ({ data: payload, status }) => braveSearchError(status, payload)
|
|
69
|
+
});
|
|
63
70
|
async function request(ctx, path, query) {
|
|
64
|
-
const { data } = await http.request({
|
|
71
|
+
const { data } = await http.request(ctx, {
|
|
65
72
|
path,
|
|
66
73
|
method: "GET",
|
|
67
74
|
query: Object.entries(query),
|
|
68
|
-
|
|
69
|
-
"accept": "application/json",
|
|
70
|
-
"x-subscription-token": requireApiKey(ctx, SERVICE)
|
|
71
|
-
},
|
|
72
|
-
invalidJsonMessage: "Brave Search \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
73
|
-
mapError: ({ data: payload, status }) => braveSearchError(status, payload)
|
|
75
|
+
invalidJsonMessage: "Brave Search \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
74
76
|
});
|
|
75
77
|
return data ?? null;
|
|
76
78
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
upstreamError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ATK45BXV.js";
|
|
4
4
|
import {
|
|
5
5
|
createGuardedFetch
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-U7B6DS2O.js";
|
|
7
7
|
import {
|
|
8
|
-
TBError
|
|
9
|
-
|
|
8
|
+
TBError,
|
|
9
|
+
isTBError
|
|
10
|
+
} from "./chunk-UZM2RXZH.js";
|
|
10
11
|
|
|
11
12
|
// ../plugins/src/_runtime/providerHttp.ts
|
|
12
13
|
function credentialLike(name) {
|
|
@@ -241,7 +242,7 @@ function createProviderHttpClient(options) {
|
|
|
241
242
|
return { parsed: parsed2, response: response2 };
|
|
242
243
|
})());
|
|
243
244
|
} catch (error) {
|
|
244
|
-
if (error
|
|
245
|
+
if (isTBError(error) && signal?.aborted !== true) throw error;
|
|
245
246
|
const kind = signal?.aborted === true ? "timeout" : "network";
|
|
246
247
|
const rawMessage = error instanceof Error ? error.message : void 0;
|
|
247
248
|
const context = {
|