@tool-bridge/server 0.16.0 → 0.17.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/{airtable-S3T4TAN7.js → airtable-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-LGVGNPML.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-27RFZO35.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-6WLYAIAS.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-K2SVJ66F.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-YB2FLNWI.js → chunk-RVWZN3CI.js} +2103 -1775
- package/dist/{chunk-BB6ZLMTU.js → chunk-TLNUIPFZ.js} +492 -300
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-VK3V2WTY.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-WV3ITU7Q.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-NFQEFKS4.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-5KEW7LWT.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-SZE63S46.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-QPG2JC5K.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-UO2APQRY.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-LJELIMM3.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-2MFXSBOF.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-GQYNTTVA.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KI2LHXST.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-WO6ISY3C.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-IZ7B3BPT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-LTMF36GJ.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-WM7SLSFD.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-2Z274VQZ.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-IFI4R65V.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-BCCZEB3D.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-755FXYB5.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-4FZKKXXK.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-WYKDJ3DP.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-5BNQTCOH.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-ULELF5VX.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-G34WT64J.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-BQU255SC.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-HPCNQXYJ.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-VOV24FIC.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-D5RXW6AP.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +57 -50
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-E6UXFV2P.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-ZDSXGQ6W.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-TIFJRREW.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-DASEMJMA.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-KE6UP4SP.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-IMNDN4R5.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-HHHMUXQA.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-D2FGGOIY.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-4OVIGFPH.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-33WCX5YD.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-M6VWS2VH.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-Z2PKQBHH.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-SS4RPC4K.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-FJCNQ6I7.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-JODZ4GKT.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-Q5XXEJZ7.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-RT2EHJ2X.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-OF2V7GAC.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-LNZEWLHG.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-JSJIXZYN.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-D4CKVUXR.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-M7ZYP6UR.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-YV7CZOH4.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-KYHLECRG.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-HCMHBKV2.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-WYVLCCN3.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-TWIRD5KR.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-UZ467IQ7.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-MECUC5CC.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-A5MEK3SW.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-BC6EAWJQ.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-ZM3QDUIS.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-WAML42QJ.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-OKBPSTDM.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-PPC6DYU4.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-EWGUHBXO.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-6RPDPC5W.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-SK7DQ42N.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-YCG5VQMH.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-2OES5FYB.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-POOSBBR4.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-M7YD6YSS.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-IS6V5W3E.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-RCFHUFVH.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-OS2RXFGO.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-PQ2SJ2LN.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-C6BPZO4E.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-R4JWTEHN.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-FZVYUOQD.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-XRWGO6LG.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-WR4NKOYL.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-BKZIB3WA.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-2O27H4Y2.js +0 -183
- package/dist/chunk-GKX72JMJ.js +0 -378
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -1,31 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
trimmedText
|
|
7
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
8
|
import {
|
|
2
9
|
createProviderPlugin,
|
|
3
10
|
requireApiKey,
|
|
4
11
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-YASUMV2K.js";
|
|
6
13
|
import {
|
|
7
|
-
assertPublicHttpUrl
|
|
8
|
-
|
|
9
|
-
} from "./chunk-2O27H4Y2.js";
|
|
10
|
-
import "./chunk-GKX72JMJ.js";
|
|
14
|
+
assertPublicHttpUrl
|
|
15
|
+
} from "./chunk-U5UHT7CX.js";
|
|
11
16
|
import {
|
|
12
17
|
TBError,
|
|
13
18
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-RVWZN3CI.js";
|
|
20
|
+
import "./chunk-U67V476Y.js";
|
|
16
21
|
|
|
17
22
|
// ../plugins/src/metabase/api.ts
|
|
18
23
|
var SERVICE = "metabase";
|
|
19
24
|
var API_PATH_PREFIX = "/api";
|
|
20
25
|
var CURRENT_USER_PATH = "/user/current";
|
|
21
|
-
|
|
22
|
-
if (typeof value !== "string") return void 0;
|
|
23
|
-
const trimmed = value.trim();
|
|
24
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
25
|
-
}
|
|
26
|
-
function record(value) {
|
|
27
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
28
|
-
}
|
|
26
|
+
var http = createProviderHttpClient({ service: SERVICE });
|
|
29
27
|
function configError(message) {
|
|
30
28
|
return new TBError("invalid_argument", `${SERVICE} \u7684 ${message}`);
|
|
31
29
|
}
|
|
@@ -34,7 +32,7 @@ function resolveApiBase(ctx) {
|
|
|
34
32
|
if (configured !== void 0 && typeof configured !== "string") {
|
|
35
33
|
throw configError("instanceUrl \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
36
34
|
}
|
|
37
|
-
const raw =
|
|
35
|
+
const raw = trimmedText(configured);
|
|
38
36
|
if (raw === void 0) {
|
|
39
37
|
throw configError("instanceUrl \u5FC5\u586B:\u7ED9\u6302\u8F7D\u8282\u70B9\u914D config.instanceUrl \u6307\u5411\u4F60\u7684 Metabase \u5B9E\u4F8B");
|
|
40
38
|
}
|
|
@@ -59,60 +57,49 @@ function pathSegment(value, field) {
|
|
|
59
57
|
return encodeURIComponent(segment);
|
|
60
58
|
}
|
|
61
59
|
function errorMessage(payload, status) {
|
|
62
|
-
const body =
|
|
60
|
+
const body = asJsonObject(payload);
|
|
63
61
|
const errors = body?.errors;
|
|
64
62
|
const serialized = typeof errors === "object" && errors !== null ? JSON.stringify(errors) : void 0;
|
|
65
|
-
return
|
|
63
|
+
return trimmedText(body?.message) ?? trimmedText(body?.error) ?? trimmedText(body?.cause) ?? serialized ?? `Metabase \u8FD4\u56DE HTTP ${status}`;
|
|
64
|
+
}
|
|
65
|
+
function errorPayload(data, bodyKind) {
|
|
66
|
+
return bodyKind === "invalid-json" ? { message: data } : data;
|
|
66
67
|
}
|
|
67
68
|
async function request(ctx, path, query) {
|
|
68
69
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
throw upstreamError(502, `Metabase \u8BF7\u6C42\u5931\u8D25:${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`);
|
|
87
|
-
}
|
|
88
|
-
const raw = await response.text().catch(() => "");
|
|
89
|
-
let payload = null;
|
|
90
|
-
if (raw !== "") {
|
|
91
|
-
try {
|
|
92
|
-
payload = JSON.parse(raw);
|
|
93
|
-
} catch {
|
|
94
|
-
if (response.ok) throw upstreamError(502, "Metabase \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
|
|
95
|
-
payload = { message: raw };
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
|
|
99
|
-
return payload;
|
|
70
|
+
const result = await http.request({
|
|
71
|
+
baseUrl: `${resolveApiBase(ctx)}/`,
|
|
72
|
+
path,
|
|
73
|
+
// `models` 是多选,数组由薄层展开成重复同名参数。
|
|
74
|
+
query: Object.entries(query ?? {}),
|
|
75
|
+
headers: { "accept": "application/json", "x-api-key": apiKey },
|
|
76
|
+
invalidJsonMessage: "Metabase \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
77
|
+
mapError: ({ bodyKind, data, status }) => upstreamError(
|
|
78
|
+
status,
|
|
79
|
+
errorMessage(errorPayload(data, bodyKind), status)
|
|
80
|
+
),
|
|
81
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
82
|
+
502,
|
|
83
|
+
`Metabase \u8BF7\u6C42\u5931\u8D25:${message ?? "\u672A\u77E5\u9519\u8BEF"}`
|
|
84
|
+
)
|
|
85
|
+
});
|
|
86
|
+
return result.data === void 0 ? null : result.data;
|
|
100
87
|
}
|
|
101
88
|
function requireObject(payload, label) {
|
|
102
|
-
const object =
|
|
89
|
+
const object = asJsonObject(payload);
|
|
103
90
|
if (object === void 0) {
|
|
104
91
|
throw new TBError("unavailable", `${label} \u54CD\u5E94\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
|
|
105
92
|
}
|
|
106
93
|
return object;
|
|
107
94
|
}
|
|
108
95
|
function listItems(payload) {
|
|
109
|
-
const body =
|
|
96
|
+
const body = asJsonObject(payload);
|
|
110
97
|
const data = body?.data;
|
|
111
98
|
const candidate = Array.isArray(payload) ? payload : Array.isArray(data) ? data : [];
|
|
112
|
-
return candidate.map((item) =>
|
|
99
|
+
return candidate.map((item) => asJsonObject(item) ?? { value: item });
|
|
113
100
|
}
|
|
114
101
|
function rawObject(payload) {
|
|
115
|
-
return
|
|
102
|
+
return asJsonObject(payload) ?? { data: payload };
|
|
116
103
|
}
|
|
117
104
|
async function getCurrentUser(_input, ctx) {
|
|
118
105
|
const payload = await request(ctx, CURRENT_USER_PATH);
|
|
@@ -120,7 +107,7 @@ async function getCurrentUser(_input, ctx) {
|
|
|
120
107
|
}
|
|
121
108
|
async function listDatabases(input, ctx) {
|
|
122
109
|
const payload = await request(ctx, "/database", {
|
|
123
|
-
"include":
|
|
110
|
+
"include": trimmedText(input.include),
|
|
124
111
|
"include_analytics": input.includeAnalytics,
|
|
125
112
|
"saved": input.saved,
|
|
126
113
|
"include_editable_data_model": input.includeEditableDataModel,
|
|
@@ -135,7 +122,7 @@ async function listDatabases(input, ctx) {
|
|
|
135
122
|
}
|
|
136
123
|
async function getDatabase(input, ctx) {
|
|
137
124
|
const payload = await request(ctx, `/database/${pathSegment(input.id, "id")}`, {
|
|
138
|
-
include:
|
|
125
|
+
include: trimmedText(input.include),
|
|
139
126
|
include_editable_data_model: input.includeEditableDataModel,
|
|
140
127
|
exclude_uneditable_details: input.excludeUneditableDetails
|
|
141
128
|
});
|
|
@@ -145,7 +132,7 @@ async function listCollections(input, ctx) {
|
|
|
145
132
|
const payload = await request(ctx, "/collection", {
|
|
146
133
|
"archived": input.archived,
|
|
147
134
|
"exclude-other-user-collections": input.excludeOtherUserCollections,
|
|
148
|
-
"namespace":
|
|
135
|
+
"namespace": trimmedText(input.namespace),
|
|
149
136
|
"personal-only": input.personalOnly
|
|
150
137
|
});
|
|
151
138
|
return { collections: listItems(payload), raw: rawObject(payload) };
|
|
@@ -155,7 +142,7 @@ async function getCollection(input, ctx) {
|
|
|
155
142
|
return { collection: requireObject(payload, "Metabase \u96C6\u5408"), raw: rawObject(payload) };
|
|
156
143
|
}
|
|
157
144
|
async function listCards(input, ctx) {
|
|
158
|
-
const payload = await request(ctx, "/card", { f:
|
|
145
|
+
const payload = await request(ctx, "/card", { f: trimmedText(input.filter), model_id: input.modelId });
|
|
159
146
|
return { cards: listItems(payload), raw: rawObject(payload) };
|
|
160
147
|
}
|
|
161
148
|
async function getCard(input, ctx) {
|
|
@@ -163,7 +150,7 @@ async function getCard(input, ctx) {
|
|
|
163
150
|
return { card: requireObject(payload, "Metabase \u5361\u7247"), raw: rawObject(payload) };
|
|
164
151
|
}
|
|
165
152
|
async function listDashboards(input, ctx) {
|
|
166
|
-
const payload = await request(ctx, "/dashboard", { f:
|
|
153
|
+
const payload = await request(ctx, "/dashboard", { f: trimmedText(input.filter) });
|
|
167
154
|
return { dashboards: listItems(payload), raw: rawObject(payload) };
|
|
168
155
|
}
|
|
169
156
|
async function getDashboard(input, ctx) {
|
|
@@ -173,8 +160,8 @@ async function getDashboard(input, ctx) {
|
|
|
173
160
|
async function search(input, ctx) {
|
|
174
161
|
const payload = await request(ctx, "/search", {
|
|
175
162
|
// 线上参数名是 `q`;`collection` / `table_db_id` 也与入参名不同。
|
|
176
|
-
q:
|
|
177
|
-
context:
|
|
163
|
+
q: trimmedText(input.query),
|
|
164
|
+
context: trimmedText(input.context),
|
|
178
165
|
archived: input.archived,
|
|
179
166
|
collection: input.collectionId,
|
|
180
167
|
table_db_id: input.tableDatabaseId,
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readBoundedResponseBytes
|
|
3
|
+
} from "./chunk-LMLX3DJF.js";
|
|
4
|
+
import {
|
|
5
|
+
createProviderHttpClient
|
|
6
|
+
} from "./chunk-WW2IMPQK.js";
|
|
7
|
+
import {
|
|
8
|
+
asJsonObject
|
|
9
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
10
|
import {
|
|
2
11
|
createProviderPlugin,
|
|
3
12
|
requireApiKey,
|
|
4
13
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YASUMV2K.js";
|
|
6
15
|
import {
|
|
7
16
|
assertPublicHttpUrl,
|
|
8
17
|
guardedFetch
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-GKX72JMJ.js";
|
|
18
|
+
} from "./chunk-U5UHT7CX.js";
|
|
11
19
|
import {
|
|
12
20
|
TBError,
|
|
13
21
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-RVWZN3CI.js";
|
|
23
|
+
import "./chunk-U67V476Y.js";
|
|
16
24
|
|
|
17
25
|
// ../plugins/src/mistral_ai/schema.ts
|
|
18
26
|
var listModelsInput = external_exports.strictObject({}).describe("No input parameters are required for this action.");
|
|
@@ -806,6 +814,7 @@ var mistralAiActions = {
|
|
|
806
814
|
var SERVICE = "mistral_ai";
|
|
807
815
|
var API_BASE = "https://api.mistral.ai";
|
|
808
816
|
var MAX_REMOTE_UPLOAD_BYTES = 100 * 1024 * 1024;
|
|
817
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
809
818
|
var SPECS = {
|
|
810
819
|
list_models: { method: "GET", path: "/v1/models" },
|
|
811
820
|
get_model: { method: "GET", path: "/v1/models/{model_id}", pathKeys: ["model_id"] },
|
|
@@ -934,9 +943,6 @@ var SPECS = {
|
|
|
934
943
|
bodyOnDelete: true
|
|
935
944
|
}
|
|
936
945
|
};
|
|
937
|
-
function toRecord(value) {
|
|
938
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
939
|
-
}
|
|
940
946
|
function text(value) {
|
|
941
947
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
942
948
|
}
|
|
@@ -972,7 +978,7 @@ async function errorMessage(response) {
|
|
|
972
978
|
const body = await response.text().catch(() => "");
|
|
973
979
|
if (body.trim() === "") return fallback;
|
|
974
980
|
try {
|
|
975
|
-
const payload =
|
|
981
|
+
const payload = asJsonObject(JSON.parse(body));
|
|
976
982
|
return text(payload?.detail) ?? text(payload?.message) ?? text(payload?.error) ?? fallback;
|
|
977
983
|
} catch {
|
|
978
984
|
return body;
|
|
@@ -1030,33 +1036,14 @@ function decodeBase64(value) {
|
|
|
1030
1036
|
return bytes;
|
|
1031
1037
|
}
|
|
1032
1038
|
async function readBounded(response, maxBytes, field) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
for (; ; ) {
|
|
1039
|
-
const { done, value } = await reader.read();
|
|
1040
|
-
if (done) break;
|
|
1041
|
-
total += value.byteLength;
|
|
1042
|
-
if (total > maxBytes) {
|
|
1043
|
-
throw new TBError("invalid_argument", `${field} \u8D85\u8FC7 ${maxBytes} \u5B57\u8282\u4E0A\u9650`);
|
|
1044
|
-
}
|
|
1045
|
-
chunks.push(value);
|
|
1046
|
-
}
|
|
1047
|
-
} finally {
|
|
1048
|
-
await reader.cancel().catch(() => void 0);
|
|
1049
|
-
}
|
|
1050
|
-
const bytes = new Uint8Array(total);
|
|
1051
|
-
let offset = 0;
|
|
1052
|
-
for (const chunk of chunks) {
|
|
1053
|
-
bytes.set(chunk, offset);
|
|
1054
|
-
offset += chunk.byteLength;
|
|
1055
|
-
}
|
|
1056
|
-
return bytes;
|
|
1039
|
+
return readBoundedResponseBytes(response, {
|
|
1040
|
+
checkContentLength: false,
|
|
1041
|
+
maxBytes,
|
|
1042
|
+
tooLarge: () => new TBError("invalid_argument", `${field} \u8D85\u8FC7 ${maxBytes} \u5B57\u8282\u4E0A\u9650`)
|
|
1043
|
+
});
|
|
1057
1044
|
}
|
|
1058
1045
|
async function resolveUpload(remaining) {
|
|
1059
|
-
const file =
|
|
1046
|
+
const file = asJsonObject(remaining.file);
|
|
1060
1047
|
if (file === void 0) throw new TBError("invalid_argument", "file is required.");
|
|
1061
1048
|
if (text(file.fileId) !== void 0) {
|
|
1062
1049
|
throw new TBError(
|
|
@@ -1096,14 +1083,22 @@ function authHeaders(ctx, json) {
|
|
|
1096
1083
|
async function executeJson(spec, input, ctx) {
|
|
1097
1084
|
const { url, remaining } = buildUrl(spec, input);
|
|
1098
1085
|
const sendsBody = spec.method === "POST" || spec.method === "PUT" || spec.method === "PATCH" || spec.method === "DELETE" && spec.bodyOnDelete === true;
|
|
1099
|
-
const
|
|
1086
|
+
const result = await http.request({
|
|
1087
|
+
path: url,
|
|
1100
1088
|
method: spec.method,
|
|
1101
1089
|
headers: authHeaders(ctx, true),
|
|
1102
|
-
...sendsBody ? {
|
|
1090
|
+
...sendsBody ? { json: compactJson(remaining) } : {},
|
|
1091
|
+
responseType: "auto",
|
|
1092
|
+
invalidJsonMessage: "mistral_ai returned malformed JSON",
|
|
1093
|
+
mapError: ({ data, rawText, status }) => {
|
|
1094
|
+
const payload = asJsonObject(data);
|
|
1095
|
+
const fallback = `mistral_ai request failed with ${status}`;
|
|
1096
|
+
const message = text(payload?.detail) ?? text(payload?.message) ?? text(payload?.error) ?? text(rawText) ?? fallback;
|
|
1097
|
+
return upstreamError(status === 422 ? 400 : status || 502, message);
|
|
1098
|
+
}
|
|
1103
1099
|
});
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
return await readResponse(response);
|
|
1100
|
+
if (result.status === 204) return { deleted: true };
|
|
1101
|
+
return result.bodyKind === "empty" ? "" : result.data;
|
|
1107
1102
|
}
|
|
1108
1103
|
async function executeMultipart(spec, input, ctx) {
|
|
1109
1104
|
const { url, remaining } = buildUrl(spec, input);
|
|
@@ -1123,7 +1118,7 @@ async function executeMultipart(spec, input, ctx) {
|
|
|
1123
1118
|
}
|
|
1124
1119
|
async function executeAudioTranscription(spec, input, ctx) {
|
|
1125
1120
|
const { url, remaining } = buildUrl(spec, input);
|
|
1126
|
-
const file =
|
|
1121
|
+
const file = asJsonObject(remaining.file);
|
|
1127
1122
|
const fileId = text(remaining.file_id);
|
|
1128
1123
|
const fileUrl = text(file?.url);
|
|
1129
1124
|
const inline = text(file?.content_base64) ?? text(file?.fileId);
|
|
@@ -1,102 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
compactDefined,
|
|
7
|
+
trimmedText
|
|
8
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
9
|
import {
|
|
2
10
|
createProviderPlugin,
|
|
3
11
|
requireApiKey,
|
|
4
12
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-YASUMV2K.js";
|
|
14
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
15
|
import {
|
|
11
16
|
TBError,
|
|
12
17
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-RVWZN3CI.js";
|
|
19
|
+
import "./chunk-U67V476Y.js";
|
|
15
20
|
|
|
16
21
|
// ../plugins/src/mother_duck/api.ts
|
|
17
22
|
var SERVICE = "mother_duck";
|
|
18
23
|
var API_BASE = "https://api.motherduck.com";
|
|
19
|
-
|
|
20
|
-
if (typeof value !== "string") return void 0;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
-
}
|
|
24
|
-
function record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
27
|
-
function compact(input) {
|
|
28
|
-
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
29
|
-
}
|
|
24
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
30
25
|
function errorMessage(payload) {
|
|
31
|
-
const body =
|
|
26
|
+
const body = asJsonObject(payload);
|
|
32
27
|
if (body === void 0) return void 0;
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
async function readPayload(response) {
|
|
36
|
-
const body = await response.text().catch(() => "");
|
|
37
|
-
if (body.trim() === "") return {};
|
|
38
|
-
try {
|
|
39
|
-
return JSON.parse(body);
|
|
40
|
-
} catch {
|
|
41
|
-
return { message: body };
|
|
42
|
-
}
|
|
28
|
+
return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.code);
|
|
43
29
|
}
|
|
44
30
|
function isEmpty(payload) {
|
|
45
|
-
const object =
|
|
31
|
+
const object = asJsonObject(payload);
|
|
46
32
|
return object !== void 0 && Object.keys(object).length === 0;
|
|
47
33
|
}
|
|
48
34
|
async function request(ctx, path, input = {}) {
|
|
49
35
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw upstreamError(
|
|
36
|
+
const result = await http.request({
|
|
37
|
+
path,
|
|
38
|
+
method: input.method ?? "GET",
|
|
39
|
+
headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
|
|
40
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
41
|
+
invalidJson: "text",
|
|
42
|
+
mapError: ({ bodyKind, data, status }) => upstreamError(
|
|
43
|
+
status,
|
|
44
|
+
bodyKind === "invalid-json" && typeof data === "string" ? data : errorMessage(data) ?? `MotherDuck \u8BF7\u6C42\u5931\u8D25,HTTP ${status}`
|
|
45
|
+
),
|
|
46
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
64
47
|
502,
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
const payload =
|
|
69
|
-
if (!response.ok) {
|
|
70
|
-
throw upstreamError(response.status, errorMessage(payload) ?? `MotherDuck \u8BF7\u6C42\u5931\u8D25,HTTP ${response.status}`);
|
|
71
|
-
}
|
|
48
|
+
message === void 0 ? "MotherDuck \u8BF7\u6C42\u5931\u8D25" : `MotherDuck \u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
49
|
+
)
|
|
50
|
+
});
|
|
51
|
+
const payload = result.bodyKind === "empty" ? {} : result.bodyKind === "invalid-json" && typeof result.data === "string" ? { message: result.data } : result.data;
|
|
72
52
|
if (input.allowEmpty === true && isEmpty(payload)) return {};
|
|
73
53
|
return payload;
|
|
74
54
|
}
|
|
75
55
|
function requireArrayProperty(payload, key) {
|
|
76
|
-
const value =
|
|
56
|
+
const value = asJsonObject(payload)?.[key];
|
|
77
57
|
if (!Array.isArray(value)) {
|
|
78
58
|
throw new TBError("unavailable", `MotherDuck \u7684 ${key} \u54CD\u5E94\u975E\u6CD5`, { retryable: true });
|
|
79
59
|
}
|
|
80
60
|
return value;
|
|
81
61
|
}
|
|
82
62
|
function normalizeToken(value) {
|
|
83
|
-
const token =
|
|
63
|
+
const token = asJsonObject(value);
|
|
84
64
|
if (token === void 0) {
|
|
85
65
|
throw new TBError("unavailable", "MotherDuck \u8FD4\u56DE\u7684 token \u4E0D\u662F\u5BF9\u8C61", { retryable: true });
|
|
86
66
|
}
|
|
87
|
-
return
|
|
88
|
-
id:
|
|
89
|
-
name:
|
|
90
|
-
token:
|
|
91
|
-
expire_at:
|
|
92
|
-
created_ts:
|
|
67
|
+
return compactDefined({
|
|
68
|
+
id: trimmedText(token.id),
|
|
69
|
+
name: trimmedText(token.name),
|
|
70
|
+
token: trimmedText(token.token),
|
|
71
|
+
expire_at: trimmedText(token.expire_at),
|
|
72
|
+
created_ts: trimmedText(token.created_ts),
|
|
93
73
|
read_only: typeof token.read_only === "boolean" ? token.read_only : void 0,
|
|
94
|
-
token_type:
|
|
74
|
+
token_type: trimmedText(token.token_type),
|
|
95
75
|
raw: token
|
|
96
76
|
});
|
|
97
77
|
}
|
|
98
78
|
function responseUsername(payload, fallback) {
|
|
99
|
-
return
|
|
79
|
+
return trimmedText(asJsonObject(payload)?.username) ?? fallback;
|
|
100
80
|
}
|
|
101
81
|
async function listActiveAccounts(_input, ctx) {
|
|
102
82
|
const payload = await request(ctx, "/v1/active_accounts");
|
|
@@ -120,7 +100,7 @@ async function createToken(input, ctx) {
|
|
|
120
100
|
const path = `/v1/users/${encodeURIComponent(input.username.trim())}/tokens`;
|
|
121
101
|
const payload = await request(ctx, path, {
|
|
122
102
|
method: "POST",
|
|
123
|
-
body:
|
|
103
|
+
body: compactDefined({ name: input.name.trim(), ttl: input.ttl, token_type: input.token_type })
|
|
124
104
|
});
|
|
125
105
|
return { token: normalizeToken(payload) };
|
|
126
106
|
}
|
|
@@ -1,84 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
messageFrom,
|
|
7
|
+
trimmedText
|
|
8
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
9
|
import {
|
|
2
10
|
createProviderPlugin,
|
|
3
11
|
requireApiKey,
|
|
4
12
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
13
|
+
} from "./chunk-YASUMV2K.js";
|
|
14
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
15
|
import {
|
|
11
16
|
external_exports
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-RVWZN3CI.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
14
19
|
|
|
15
20
|
// ../plugins/src/ngrok/api.ts
|
|
16
21
|
var SERVICE = "ngrok";
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
23
|
-
}
|
|
24
|
-
function record(value) {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
26
|
-
}
|
|
27
|
-
function errorMessage(payload, status) {
|
|
28
|
-
const body = record(payload);
|
|
29
|
-
return text(body?.msg) ?? text(body?.message) ?? text(body?.error) ?? `ngrok request failed with ${status}`;
|
|
30
|
-
}
|
|
31
|
-
async function request(ctx, path, query = {}) {
|
|
32
|
-
const url = new URL(path, API_BASE);
|
|
33
|
-
for (const [key, value] of Object.entries(query)) {
|
|
34
|
-
if (value !== void 0) url.searchParams.set(key, value);
|
|
35
|
-
}
|
|
36
|
-
const response = await guardedFetch(url.toString(), {
|
|
37
|
-
method: "GET",
|
|
22
|
+
var http = createProviderHttpClient({ baseUrl: "https://api.ngrok.com/", service: SERVICE });
|
|
23
|
+
async function request(ctx, path, query) {
|
|
24
|
+
const { data } = await http.request({
|
|
25
|
+
path,
|
|
26
|
+
query,
|
|
38
27
|
headers: {
|
|
39
28
|
"accept": "application/json",
|
|
40
29
|
"authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
|
|
41
|
-
"ngrok-version":
|
|
42
|
-
}
|
|
30
|
+
"ngrok-version": "2"
|
|
31
|
+
},
|
|
32
|
+
invalidJson: "text",
|
|
33
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
34
|
+
status,
|
|
35
|
+
messageFrom(payload, ["msg", "message", "error"], `ngrok request failed with ${status}`)
|
|
36
|
+
)
|
|
43
37
|
});
|
|
44
|
-
const
|
|
45
|
-
let payload = null;
|
|
46
|
-
if (raw !== "") {
|
|
47
|
-
try {
|
|
48
|
-
payload = JSON.parse(raw);
|
|
49
|
-
} catch {
|
|
50
|
-
payload = raw;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(payload, response.status));
|
|
54
|
-
const result = record(payload);
|
|
38
|
+
const result = asJsonObject(data);
|
|
55
39
|
if (result === void 0) throw upstreamError(502, "ngrok response was not a JSON object");
|
|
56
40
|
return result;
|
|
57
41
|
}
|
|
58
42
|
function listQuery(input) {
|
|
59
|
-
return
|
|
60
|
-
limit
|
|
61
|
-
before_id
|
|
62
|
-
filter
|
|
63
|
-
|
|
43
|
+
return [
|
|
44
|
+
["limit", input.limit],
|
|
45
|
+
["before_id", trimmedText(input.before_id)],
|
|
46
|
+
["filter", trimmedText(input.filter)]
|
|
47
|
+
];
|
|
64
48
|
}
|
|
65
|
-
|
|
66
|
-
return request(ctx, "
|
|
49
|
+
function listEndpoints(input, ctx) {
|
|
50
|
+
return request(ctx, "endpoints", listQuery(input));
|
|
67
51
|
}
|
|
68
|
-
|
|
69
|
-
return request(ctx,
|
|
52
|
+
function getEndpoint(input, ctx) {
|
|
53
|
+
return request(ctx, `endpoints/${encodeURIComponent(input.endpoint_id)}`);
|
|
70
54
|
}
|
|
71
|
-
|
|
72
|
-
return request(ctx, "
|
|
55
|
+
function listTunnels(input, ctx) {
|
|
56
|
+
return request(ctx, "tunnels", listQuery(input));
|
|
73
57
|
}
|
|
74
|
-
|
|
75
|
-
return request(ctx, "
|
|
58
|
+
function listTunnelSessions(input, ctx) {
|
|
59
|
+
return request(ctx, "tunnel_sessions", listQuery(input));
|
|
76
60
|
}
|
|
77
|
-
|
|
78
|
-
return request(ctx, "
|
|
61
|
+
function listReservedDomains(input, ctx) {
|
|
62
|
+
return request(ctx, "reserved_domains", listQuery(input));
|
|
79
63
|
}
|
|
80
|
-
|
|
81
|
-
return request(ctx,
|
|
64
|
+
function getReservedDomain(input, ctx) {
|
|
65
|
+
return request(ctx, `reserved_domains/${encodeURIComponent(input.reserved_domain_id)}`);
|
|
82
66
|
}
|
|
83
67
|
|
|
84
68
|
// ../plugins/src/ngrok/schema.ts
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createPlugin
|
|
3
|
-
} from "./chunk-GKX72JMJ.js";
|
|
4
1
|
import {
|
|
5
2
|
TBError,
|
|
3
|
+
createPlugin,
|
|
6
4
|
external_exports
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-RVWZN3CI.js";
|
|
6
|
+
import "./chunk-U67V476Y.js";
|
|
9
7
|
|
|
10
8
|
// ../plugins/src/notes/index.ts
|
|
11
9
|
function uriOf(mountPath, path) {
|