@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
|
trimmedText
|
|
@@ -9,12 +10,12 @@ import {
|
|
|
9
10
|
createProviderPlugin,
|
|
10
11
|
requireApiKey,
|
|
11
12
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-ATK45BXV.js";
|
|
14
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
15
|
import {
|
|
15
16
|
TBError,
|
|
16
17
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
19
|
import "./chunk-U67V476Y.js";
|
|
19
20
|
|
|
20
21
|
// ../plugins/src/v2ex/api.ts
|
|
@@ -22,8 +23,6 @@ var SERVICE = "v2ex";
|
|
|
22
23
|
var API_BASE = "https://www.v2ex.com/api/v2";
|
|
23
24
|
var LEGACY_API_BASE = "https://www.v2ex.com/api";
|
|
24
25
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
25
|
-
var v2Http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
26
|
-
var legacyHttp = createProviderHttpClient({ baseUrl: `${LEGACY_API_BASE}/`, service: SERVICE });
|
|
27
26
|
function invalidResponse(message) {
|
|
28
27
|
return new TBError("unavailable", message, { retryable: true });
|
|
29
28
|
}
|
|
@@ -49,35 +48,53 @@ function errorMessage(payload) {
|
|
|
49
48
|
function envelopeError(payload) {
|
|
50
49
|
return new TBError("invalid_argument", errorMessage(payload) ?? "V2EX request failed");
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
var v2Http = createAuthedClient({
|
|
52
|
+
baseUrl: `${API_BASE}/`,
|
|
53
|
+
service: SERVICE,
|
|
54
|
+
auth: { kind: "bearer" },
|
|
55
|
+
headers: { accept: "application/json" },
|
|
56
|
+
mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed")
|
|
57
|
+
});
|
|
58
|
+
var legacyHttp = createAuthedClient({
|
|
59
|
+
baseUrl: `${LEGACY_API_BASE}/`,
|
|
60
|
+
service: SERVICE,
|
|
61
|
+
// legacy API **不带 Authorization** —— 上游这条路径压根不调 `buildV2exHeaders`,加上 Bearer
|
|
62
|
+
// 也没用。但仍然先 `requireApiKey`:上游整个 provider 的 authType 是 `api_key`,没配凭证时
|
|
63
|
+
// 连 context 都建不起来,这两个 action 一样调不通。这里保留那道闸 —— 否则"配了才能用"
|
|
64
|
+
// 会因为迁移悄悄变成"这两个不用配",挂载语义就不一致了。
|
|
65
|
+
auth: {
|
|
66
|
+
kind: "custom",
|
|
67
|
+
headers: (ctx) => {
|
|
68
|
+
requireApiKey(ctx, SERVICE);
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
headers: { accept: "application/json" },
|
|
73
|
+
mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed")
|
|
74
|
+
});
|
|
75
|
+
async function send(client, ctx, request2, label) {
|
|
76
|
+
const response = await client.request(ctx, {
|
|
54
77
|
...request2,
|
|
55
78
|
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
56
79
|
invalidJson: "text",
|
|
57
|
-
mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed"),
|
|
58
80
|
mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `${label} request timed out after ${REQUEST_TIMEOUT_MS / 1e3} seconds`) : upstreamError(502, message === void 0 ? `${label} request failed` : `${label} request failed: ${message}`)
|
|
59
81
|
});
|
|
60
82
|
return response.bodyKind === "empty" ? null : response.data;
|
|
61
83
|
}
|
|
62
84
|
async function request(ctx, options) {
|
|
63
|
-
|
|
64
|
-
accept: "application/json",
|
|
65
|
-
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
66
|
-
};
|
|
67
|
-
return send(v2Http, {
|
|
85
|
+
return send(v2Http, ctx, {
|
|
68
86
|
method: options.method,
|
|
69
87
|
path: options.path,
|
|
70
88
|
// 上游连**空串**也当作"没给",不只是 undefined/null。
|
|
71
89
|
query: Object.entries(options.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
|
|
72
|
-
headers,
|
|
73
90
|
...options.body === void 0 ? {} : { json: options.body }
|
|
74
91
|
}, `V2EX ${options.path}`);
|
|
75
92
|
}
|
|
76
93
|
async function legacyRequest(ctx, path) {
|
|
77
|
-
requireApiKey(ctx, SERVICE);
|
|
78
94
|
const payload = await send(
|
|
79
95
|
legacyHttp,
|
|
80
|
-
|
|
96
|
+
ctx,
|
|
97
|
+
{ method: "GET", path },
|
|
81
98
|
`V2EX legacy ${path}`
|
|
82
99
|
);
|
|
83
100
|
if (!Array.isArray(payload)) {
|
|
@@ -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,
|
|
@@ -9,21 +10,30 @@ import {
|
|
|
9
10
|
trimmedText
|
|
10
11
|
} from "./chunk-JXHMDBAY.js";
|
|
11
12
|
import {
|
|
12
|
-
createProviderPlugin
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "./chunk-6ANLYNFB.js";
|
|
16
|
-
import "./chunk-3WL6EXYX.js";
|
|
13
|
+
createProviderPlugin
|
|
14
|
+
} from "./chunk-ATK45BXV.js";
|
|
15
|
+
import "./chunk-U7B6DS2O.js";
|
|
17
16
|
import {
|
|
18
17
|
TBError,
|
|
19
18
|
external_exports
|
|
20
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-UZM2RXZH.js";
|
|
21
20
|
import "./chunk-U67V476Y.js";
|
|
22
21
|
|
|
23
22
|
// ../plugins/src/vercel/api.ts
|
|
24
23
|
var SERVICE = "vercel";
|
|
25
24
|
var API_BASE = "https://api.vercel.com";
|
|
26
|
-
var http =
|
|
25
|
+
var http = createAuthedClient({
|
|
26
|
+
baseUrl: API_BASE,
|
|
27
|
+
service: SERVICE,
|
|
28
|
+
auth: { kind: "bearer" },
|
|
29
|
+
// 错误体形如 `{ error: { code, message } }`,少数端点直接把 code/message 放在顶层。
|
|
30
|
+
// 两者都拿不到时:JSON 体不回显原文(那是整个错误 body,可能带上游内部细节),
|
|
31
|
+
// 非 JSON 体(HTML 错误页之类)才把原文当消息用 —— 这是上游 readVercelError 的兜底。
|
|
32
|
+
errorMessage: {
|
|
33
|
+
keys: ["error.message", "message"],
|
|
34
|
+
fallback: (status) => `Vercel \u8FD4\u56DE HTTP ${status}`
|
|
35
|
+
}
|
|
36
|
+
});
|
|
27
37
|
function stringArray(value) {
|
|
28
38
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
|
|
29
39
|
}
|
|
@@ -55,20 +65,13 @@ function arrayPayload(payload, key) {
|
|
|
55
65
|
}
|
|
56
66
|
async function request(ctx, input) {
|
|
57
67
|
const hasBody = input.body !== void 0;
|
|
58
|
-
const { data } = await http.request({
|
|
68
|
+
const { data } = await http.request(ctx, {
|
|
59
69
|
path: input.path,
|
|
60
70
|
method: input.method ?? "GET",
|
|
61
71
|
// 上游 `queryParams` 连空串一起跳过。
|
|
62
72
|
query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
|
|
63
|
-
headers: { authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` },
|
|
64
73
|
...hasBody ? { json: input.body } : {},
|
|
65
|
-
invalidJsonMessage: "Vercel \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
66
|
-
mapError: ({ bodyKind, data: payload, status }) => {
|
|
67
|
-
const body = asJsonObject(payload) ?? {};
|
|
68
|
-
const error = asJsonObject(body.error) ?? {};
|
|
69
|
-
const message = trimmedText(error.message) ?? trimmedText(body.message) ?? (bodyKind === "invalid-json" || bodyKind === "text" ? trimmedText(payload) : void 0) ?? `Vercel \u8FD4\u56DE HTTP ${status}`;
|
|
70
|
-
return upstreamError(status, message);
|
|
71
|
-
}
|
|
74
|
+
invalidJsonMessage: "Vercel \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
|
|
72
75
|
});
|
|
73
76
|
return data ?? {};
|
|
74
77
|
}
|
|
@@ -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
|
trimmedText
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
createProviderPlugin,
|
|
10
10
|
requireApiKey,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/wolfram_alpha_api/api.ts
|
|
@@ -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,
|
|
@@ -10,14 +11,14 @@ import {
|
|
|
10
11
|
createProviderPlugin,
|
|
11
12
|
requireCredential,
|
|
12
13
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ATK45BXV.js";
|
|
14
15
|
import {
|
|
15
16
|
assertPublicHttpUrl
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-U7B6DS2O.js";
|
|
17
18
|
import {
|
|
18
19
|
TBError,
|
|
19
20
|
external_exports
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UZM2RXZH.js";
|
|
21
22
|
import "./chunk-U67V476Y.js";
|
|
22
23
|
|
|
23
24
|
// ../plugins/src/wordpress/api.ts
|
|
@@ -25,7 +26,6 @@ var SERVICE = "wordpress";
|
|
|
25
26
|
var API_PATH = "wp-json/wp/v2";
|
|
26
27
|
var REST_ROOT_SUFFIXES = ["/wp-json/wp/v2", "/wp-json"];
|
|
27
28
|
var CURRENT_USER_PATH = "/users/me";
|
|
28
|
-
var http = createProviderHttpClient({ service: SERVICE });
|
|
29
29
|
function requireRecord(value, message) {
|
|
30
30
|
const result = asJsonObject(value);
|
|
31
31
|
if (result === void 0) throw upstreamError(502, message);
|
|
@@ -90,24 +90,28 @@ function errorMessage(payload, context) {
|
|
|
90
90
|
function jsonPayload(data, bodyKind) {
|
|
91
91
|
return bodyKind === "json" ? data : null;
|
|
92
92
|
}
|
|
93
|
+
var http = createAuthedClient({
|
|
94
|
+
service: SERVICE,
|
|
95
|
+
auth: { kind: "custom", headers: (ctx) => ({ authorization: basicAuthHeader(ctx) }) },
|
|
96
|
+
headers: { accept: "application/json" },
|
|
97
|
+
mapError: (context) => upstreamError(
|
|
98
|
+
context.status || 502,
|
|
99
|
+
errorMessage(jsonPayload(context.data, context.bodyKind), context)
|
|
100
|
+
),
|
|
101
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
102
|
+
502,
|
|
103
|
+
message === void 0 ? "WordPress request failed" : `WordPress request failed: ${message}`
|
|
104
|
+
)
|
|
105
|
+
});
|
|
93
106
|
async function requestResponse(ctx, options) {
|
|
94
|
-
return http.request({
|
|
107
|
+
return http.request(ctx, {
|
|
95
108
|
baseUrl: `${apiBaseUrl(ctx)}/`,
|
|
96
109
|
path: options.path,
|
|
97
110
|
method: options.method ?? "GET",
|
|
98
111
|
query: queryPairs(options.query),
|
|
99
|
-
headers: { accept: "application/json", authorization: basicAuthHeader(ctx) },
|
|
100
112
|
...options.body === void 0 ? {} : { json: options.body },
|
|
101
113
|
// 上游 response.json().catch(() => null):成功或错误上的非 JSON 都按 null。
|
|
102
|
-
invalidJson: "text"
|
|
103
|
-
mapError: (context) => upstreamError(
|
|
104
|
-
context.status || 502,
|
|
105
|
-
errorMessage(jsonPayload(context.data, context.bodyKind), context)
|
|
106
|
-
),
|
|
107
|
-
mapTransportError: ({ message }) => upstreamError(
|
|
108
|
-
502,
|
|
109
|
-
message === void 0 ? "WordPress request failed" : `WordPress request failed: ${message}`
|
|
110
|
-
)
|
|
114
|
+
invalidJson: "text"
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
117
|
async function requestObject(ctx, options) {
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-XYBU3WZH.js";
|
|
4
|
+
import "./chunk-E6JCVKW6.js";
|
|
4
5
|
import {
|
|
5
6
|
compactDefined
|
|
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/workos/api.ts
|
|
20
20
|
var SERVICE = "workos";
|
|
21
21
|
var API_BASE = "https://api.workos.com";
|
|
22
|
-
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
23
22
|
function errorMessage(payload, status) {
|
|
24
23
|
const error = payload.error;
|
|
25
24
|
if (error !== null && typeof error === "object" && !Array.isArray(error)) {
|
|
@@ -31,32 +30,32 @@ function errorMessage(payload, status) {
|
|
|
31
30
|
}
|
|
32
31
|
return `WorkOS \u8FD4\u56DE HTTP ${status}`;
|
|
33
32
|
}
|
|
33
|
+
var http = createAuthedClient({
|
|
34
|
+
baseUrl: `${API_BASE}/`,
|
|
35
|
+
service: SERVICE,
|
|
36
|
+
auth: { kind: "bearer" },
|
|
37
|
+
headers: { accept: "application/json" },
|
|
38
|
+
mapError: ({ bodyKind, data, status }) => {
|
|
39
|
+
if (bodyKind === "invalid-json") {
|
|
40
|
+
return new TBError("unavailable", "WorkOS \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true });
|
|
41
|
+
}
|
|
42
|
+
const payload = bodyKind === "empty" ? {} : data !== null && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
43
|
+
return payload === void 0 ? new TBError("unavailable", "WorkOS \u8FD4\u56DE\u7684\u4E0D\u662F JSON \u5BF9\u8C61", { retryable: true }) : upstreamError(status, errorMessage(payload, status));
|
|
44
|
+
},
|
|
45
|
+
mapTransportError: ({ message }) => new TBError(
|
|
46
|
+
"unavailable",
|
|
47
|
+
message === void 0 ? "WorkOS \u8BF7\u6C42\u5931\u8D25" : `WorkOS \u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
48
|
+
{ retryable: true }
|
|
49
|
+
)
|
|
50
|
+
});
|
|
34
51
|
async function request(ctx, input) {
|
|
35
|
-
const
|
|
36
|
-
const headers = {
|
|
37
|
-
accept: "application/json",
|
|
38
|
-
authorization: `Bearer ${apiKey}`
|
|
39
|
-
};
|
|
40
|
-
const response = await http.request({
|
|
52
|
+
const response = await http.request(ctx, {
|
|
41
53
|
method: input.method,
|
|
42
54
|
path: input.path,
|
|
43
55
|
// 多值过滤是重复同名键(与 Render 的逗号拼接不同)。
|
|
44
56
|
query: Object.entries(input.query ?? {}),
|
|
45
|
-
headers,
|
|
46
57
|
...input.body === void 0 ? {} : { json: input.body },
|
|
47
|
-
invalidJsonMessage: "WorkOS \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
48
|
-
mapError: ({ bodyKind, data, status }) => {
|
|
49
|
-
if (bodyKind === "invalid-json") {
|
|
50
|
-
return new TBError("unavailable", "WorkOS \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true });
|
|
51
|
-
}
|
|
52
|
-
const payload2 = bodyKind === "empty" ? {} : data !== null && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
53
|
-
return payload2 === void 0 ? new TBError("unavailable", "WorkOS \u8FD4\u56DE\u7684\u4E0D\u662F JSON \u5BF9\u8C61", { retryable: true }) : upstreamError(status, errorMessage(payload2, status));
|
|
54
|
-
},
|
|
55
|
-
mapTransportError: ({ message }) => new TBError(
|
|
56
|
-
"unavailable",
|
|
57
|
-
message === void 0 ? "WorkOS \u8BF7\u6C42\u5931\u8D25" : `WorkOS \u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
58
|
-
{ retryable: true }
|
|
59
|
-
)
|
|
58
|
+
invalidJsonMessage: "WorkOS \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
60
59
|
});
|
|
61
60
|
const payload = response.bodyKind === "empty" ? {} : response.data !== null && typeof response.data === "object" && !Array.isArray(response.data) ? response.data : void 0;
|
|
62
61
|
if (payload === void 0) {
|
|
@@ -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
|
trimmedText
|
|
7
8
|
} from "./chunk-JXHMDBAY.js";
|
|
8
9
|
import {
|
|
9
10
|
createProviderPlugin,
|
|
10
|
-
requireApiKey,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-ATK45BXV.js";
|
|
13
|
+
import "./chunk-U7B6DS2O.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError,
|
|
16
16
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UZM2RXZH.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/zhihu/api.ts
|
|
21
21
|
var SERVICE = "zhihu";
|
|
22
22
|
var API_BASE = "https://developer.zhihu.com";
|
|
23
|
-
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
24
23
|
var CODE_STATUS = {
|
|
25
24
|
10001: 400,
|
|
26
25
|
20001: 401,
|
|
@@ -34,25 +33,26 @@ function errorMessage(payload) {
|
|
|
34
33
|
const nested = asJsonObject(record.error);
|
|
35
34
|
return trimmedText(record.Message) ?? trimmedText(record.msg) ?? trimmedText(record.message) ?? trimmedText(nested?.message);
|
|
36
35
|
}
|
|
36
|
+
var http = createAuthedClient({
|
|
37
|
+
baseUrl: `${API_BASE}/`,
|
|
38
|
+
service: SERVICE,
|
|
39
|
+
auth: { kind: "bearer" },
|
|
40
|
+
// 上游对 GET 也发 content-type。无 body 时它没有意义,但照搬以免改变打给上游的请求形状。
|
|
41
|
+
headers: { "content-type": "application/json" },
|
|
42
|
+
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? upstreamError(502, "\u77E5\u4E4E\u8FD4\u56DE\u4E86\u975E\u6CD5 JSON") : upstreamError(status, errorMessage(data) ?? `\u77E5\u4E4E\u8BF7\u6C42\u5931\u8D25(HTTP ${status})`),
|
|
43
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
44
|
+
502,
|
|
45
|
+
message === void 0 ? "\u77E5\u4E4E\u8BF7\u6C42\u5931\u8D25" : `\u77E5\u4E4E\u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
46
|
+
)
|
|
47
|
+
});
|
|
37
48
|
async function request(ctx, input) {
|
|
38
|
-
const
|
|
39
|
-
const response = await http.request({
|
|
49
|
+
const response = await http.request(ctx, {
|
|
40
50
|
method: input.method ?? "GET",
|
|
41
51
|
path: input.path,
|
|
42
52
|
query: Object.entries(input.query ?? {}).map(([key, value]) => [key, value === void 0 ? void 0 : String(value)]),
|
|
43
|
-
headers: {
|
|
44
|
-
"authorization": `Bearer ${apiKey}`,
|
|
45
|
-
// 上游对 GET 也发这个头。无 body 时它没有意义,但照搬以免改变打给上游的请求形状。
|
|
46
|
-
"content-type": "application/json",
|
|
47
|
-
"x-request-timestamp": String(Math.floor(Date.now() / 1e3))
|
|
48
|
-
},
|
|
53
|
+
headers: { "x-request-timestamp": String(Math.floor(Date.now() / 1e3)) },
|
|
49
54
|
...input.body === void 0 ? {} : { json: input.body },
|
|
50
|
-
invalidJsonMessage: "\u77E5\u4E4E\u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
51
|
-
mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? upstreamError(502, "\u77E5\u4E4E\u8FD4\u56DE\u4E86\u975E\u6CD5 JSON") : upstreamError(status, errorMessage(data) ?? `\u77E5\u4E4E\u8BF7\u6C42\u5931\u8D25(HTTP ${status})`),
|
|
52
|
-
mapTransportError: ({ message }) => upstreamError(
|
|
53
|
-
502,
|
|
54
|
-
message === void 0 ? "\u77E5\u4E4E\u8BF7\u6C42\u5931\u8D25" : `\u77E5\u4E4E\u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
55
|
-
)
|
|
55
|
+
invalidJsonMessage: "\u77E5\u4E4E\u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
|
|
56
56
|
});
|
|
57
57
|
const payload = response.bodyKind === "empty" ? {} : response.data;
|
|
58
58
|
const code = asJsonObject(payload)?.Code;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tool-bridge/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "tool-bridge self-hosted server: run the HTBP gateway on Node with SQLite or PostgreSQL persistence, filesystem object storage and WebSocket device channel — single container via docker run",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"ioredis": "^6.0.0",
|
|
41
41
|
"postgres": "^3.4.9",
|
|
42
42
|
"ws": "8.21.0",
|
|
43
|
-
"@tool-bridge/dashboard": "0.
|
|
43
|
+
"@tool-bridge/dashboard": "0.27.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"tsup": "^8.5.1",
|
|
50
50
|
"tsx": "^4.23.0",
|
|
51
51
|
"vitest": "^4.1.10",
|
|
52
|
-
"@tool-bridge/
|
|
53
|
-
"@tool-bridge/
|
|
54
|
-
"@tool-bridge/
|
|
52
|
+
"@tool-bridge/app": "0.20.1",
|
|
53
|
+
"@tool-bridge/core": "0.1.0",
|
|
54
|
+
"@tool-bridge/plugins": "0.1.0"
|
|
55
55
|
},
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|