@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,52 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
compactDefined,
|
|
7
|
+
finiteNumber,
|
|
8
|
+
integerValue,
|
|
9
|
+
trimmedText
|
|
10
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
11
|
import {
|
|
2
12
|
createProviderPlugin,
|
|
3
13
|
requireApiKey,
|
|
4
14
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
15
|
+
} from "./chunk-YASUMV2K.js";
|
|
16
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
17
|
import {
|
|
11
18
|
TBError,
|
|
12
19
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-RVWZN3CI.js";
|
|
21
|
+
import "./chunk-U67V476Y.js";
|
|
15
22
|
|
|
16
23
|
// ../plugins/src/langsmith/api.ts
|
|
17
24
|
var SERVICE = "langsmith";
|
|
18
25
|
var WORKSPACES_PATH = "/api/v1/workspaces";
|
|
19
26
|
var DEFAULT_REGION = "us";
|
|
27
|
+
var http = createProviderHttpClient({ service: SERVICE });
|
|
20
28
|
var REGION_BASE_URLS = {
|
|
21
29
|
us: "https://api.smith.langchain.com",
|
|
22
30
|
eu: "https://eu.api.smith.langchain.com",
|
|
23
31
|
apac: "https://apac.api.smith.langchain.com",
|
|
24
32
|
aws_us: "https://aws.api.smith.langchain.com"
|
|
25
33
|
};
|
|
26
|
-
function text(value) {
|
|
27
|
-
if (typeof value !== "string") return void 0;
|
|
28
|
-
const trimmed = value.trim();
|
|
29
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
30
|
-
}
|
|
31
|
-
function num(value) {
|
|
32
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
33
|
-
}
|
|
34
|
-
function int(value) {
|
|
35
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
36
|
-
}
|
|
37
|
-
function record(value) {
|
|
38
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
39
|
-
}
|
|
40
|
-
function compact(value) {
|
|
41
|
-
return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0));
|
|
42
|
-
}
|
|
43
34
|
function configError(message) {
|
|
44
35
|
return new TBError("invalid_argument", `${SERVICE} \u7684 ${message}`);
|
|
45
36
|
}
|
|
46
37
|
function resolveApiBase(ctx) {
|
|
47
38
|
const configured = ctx.config?.region;
|
|
48
39
|
if (configured !== void 0 && typeof configured !== "string") throw configError("region \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
49
|
-
const raw =
|
|
40
|
+
const raw = trimmedText(configured) ?? DEFAULT_REGION;
|
|
50
41
|
const region = raw === "aws" ? "aws_us" : raw;
|
|
51
42
|
const base = REGION_BASE_URLS[region];
|
|
52
43
|
if (base === void 0) throw configError("region \u5FC5\u987B\u662F us\u3001eu\u3001apac \u6216 aws_us \u4E4B\u4E00");
|
|
@@ -55,56 +46,45 @@ function resolveApiBase(ctx) {
|
|
|
55
46
|
function resolveWorkspaceId(ctx) {
|
|
56
47
|
const configured = ctx.config?.workspaceId;
|
|
57
48
|
if (configured !== void 0 && typeof configured !== "string") throw configError("workspaceId \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
58
|
-
return
|
|
49
|
+
return trimmedText(configured);
|
|
59
50
|
}
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} catch {
|
|
66
|
-
return body;
|
|
67
|
-
}
|
|
51
|
+
function errorMessage(context) {
|
|
52
|
+
const payload = context.data;
|
|
53
|
+
const fromText = typeof payload === "string" ? trimmedText(payload) : void 0;
|
|
54
|
+
const body = asJsonObject(payload);
|
|
55
|
+
return fromText ?? trimmedText(body?.detail) ?? trimmedText(body?.message) ?? trimmedText(body?.error) ?? trimmedText(body?.title) ?? trimmedText(context.statusText) ?? `langsmith \u8FD4\u56DE HTTP ${context.status}`;
|
|
68
56
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
57
|
+
function queryPairs(query) {
|
|
58
|
+
return Object.entries(query ?? {}).flatMap(([key, value]) => {
|
|
59
|
+
if (value === void 0 || value === null) return [];
|
|
60
|
+
return Array.isArray(value) ? value.flatMap((item) => item === void 0 || item === null ? [] : [[key, String(item)]]) : [[key, String(value)]];
|
|
61
|
+
});
|
|
73
62
|
}
|
|
74
63
|
async function request(ctx, input) {
|
|
75
64
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
76
|
-
const url = new URL(input.path, resolveApiBase(ctx));
|
|
77
65
|
const workspaceId = resolveWorkspaceId(ctx);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
} catch (error) {
|
|
99
|
-
if (error instanceof TBError) throw error;
|
|
100
|
-
throw upstreamError(502, `langsmith \u8BF7\u6C42\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`);
|
|
101
|
-
}
|
|
102
|
-
const payload = await readPayload(response);
|
|
103
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(response, payload));
|
|
104
|
-
return payload;
|
|
66
|
+
const result = await http.request({
|
|
67
|
+
baseUrl: resolveApiBase(ctx),
|
|
68
|
+
path: input.path,
|
|
69
|
+
method: input.method ?? "GET",
|
|
70
|
+
query: queryPairs(input.query),
|
|
71
|
+
headers: {
|
|
72
|
+
"accept": "application/json",
|
|
73
|
+
"X-Api-Key": apiKey,
|
|
74
|
+
...workspaceId === void 0 ? {} : { "X-Tenant-Id": workspaceId }
|
|
75
|
+
},
|
|
76
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
77
|
+
invalidJson: "text",
|
|
78
|
+
mapError: (context) => upstreamError(context.status, errorMessage(context)),
|
|
79
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
80
|
+
502,
|
|
81
|
+
`langsmith \u8BF7\u6C42\u5931\u8D25: ${message ?? "\u672A\u77E5\u9519\u8BEF"}`
|
|
82
|
+
)
|
|
83
|
+
});
|
|
84
|
+
return result.data === void 0 ? null : result.data;
|
|
105
85
|
}
|
|
106
86
|
function ensureObject(value, label) {
|
|
107
|
-
const result =
|
|
87
|
+
const result = asJsonObject(value);
|
|
108
88
|
if (result === void 0) {
|
|
109
89
|
throw new TBError("unavailable", `${label} response is not an object`, { retryable: true });
|
|
110
90
|
}
|
|
@@ -117,19 +97,19 @@ function ensureObjectArray(value, label) {
|
|
|
117
97
|
return value.map((item) => ensureObject(item, label));
|
|
118
98
|
}
|
|
119
99
|
function requirePathId(value, field) {
|
|
120
|
-
const id =
|
|
100
|
+
const id = trimmedText(value);
|
|
121
101
|
if (id === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
122
102
|
return encodeURIComponent(id);
|
|
123
103
|
}
|
|
124
104
|
function normalizeWorkspace(value) {
|
|
125
105
|
return {
|
|
126
106
|
id: String(value.id ?? ""),
|
|
127
|
-
organization_id:
|
|
128
|
-
display_name:
|
|
107
|
+
organization_id: trimmedText(value.organization_id) ?? null,
|
|
108
|
+
display_name: trimmedText(value.display_name) ?? "",
|
|
129
109
|
is_personal: value.is_personal === true,
|
|
130
110
|
is_deleted: value.is_deleted === true,
|
|
131
|
-
tenant_handle:
|
|
132
|
-
data_plane_url:
|
|
111
|
+
tenant_handle: trimmedText(value.tenant_handle) ?? null,
|
|
112
|
+
data_plane_url: trimmedText(value.data_plane_url) ?? null,
|
|
133
113
|
// 裁剪后的字段是稳定契约,`raw` 是逃生阀:上游加了新字段也不必等我们改代码。
|
|
134
114
|
raw: value
|
|
135
115
|
};
|
|
@@ -138,32 +118,32 @@ function normalizeProject(value) {
|
|
|
138
118
|
return {
|
|
139
119
|
id: String(value.id ?? ""),
|
|
140
120
|
tenant_id: String(value.tenant_id ?? ""),
|
|
141
|
-
name:
|
|
142
|
-
description:
|
|
143
|
-
start_time:
|
|
144
|
-
end_time:
|
|
145
|
-
run_count:
|
|
146
|
-
error_rate:
|
|
147
|
-
default_dataset_id:
|
|
148
|
-
reference_dataset_id:
|
|
121
|
+
name: trimmedText(value.name) ?? null,
|
|
122
|
+
description: trimmedText(value.description) ?? null,
|
|
123
|
+
start_time: trimmedText(value.start_time) ?? null,
|
|
124
|
+
end_time: trimmedText(value.end_time) ?? null,
|
|
125
|
+
run_count: integerValue(value.run_count) ?? null,
|
|
126
|
+
error_rate: finiteNumber(value.error_rate) ?? null,
|
|
127
|
+
default_dataset_id: trimmedText(value.default_dataset_id) ?? null,
|
|
128
|
+
reference_dataset_id: trimmedText(value.reference_dataset_id) ?? null,
|
|
149
129
|
raw: value
|
|
150
130
|
};
|
|
151
131
|
}
|
|
152
132
|
function nullableObject(value) {
|
|
153
133
|
if (value === null || value === void 0) return null;
|
|
154
|
-
return
|
|
134
|
+
return asJsonObject(value) ?? {};
|
|
155
135
|
}
|
|
156
136
|
function normalizeDataset(value) {
|
|
157
137
|
return {
|
|
158
138
|
id: String(value.id ?? ""),
|
|
159
139
|
tenant_id: String(value.tenant_id ?? ""),
|
|
160
|
-
name:
|
|
161
|
-
description:
|
|
162
|
-
data_type:
|
|
163
|
-
created_at:
|
|
164
|
-
modified_at:
|
|
165
|
-
example_count:
|
|
166
|
-
session_count:
|
|
140
|
+
name: trimmedText(value.name) ?? "",
|
|
141
|
+
description: trimmedText(value.description) ?? null,
|
|
142
|
+
data_type: trimmedText(value.data_type) ?? null,
|
|
143
|
+
created_at: trimmedText(value.created_at) ?? null,
|
|
144
|
+
modified_at: trimmedText(value.modified_at) ?? null,
|
|
145
|
+
example_count: integerValue(value.example_count) ?? null,
|
|
146
|
+
session_count: integerValue(value.session_count) ?? null,
|
|
167
147
|
metadata: nullableObject(value.metadata),
|
|
168
148
|
raw: value
|
|
169
149
|
};
|
|
@@ -172,10 +152,10 @@ function normalizeExample(value) {
|
|
|
172
152
|
return {
|
|
173
153
|
id: String(value.id ?? ""),
|
|
174
154
|
dataset_id: String(value.dataset_id ?? ""),
|
|
175
|
-
name:
|
|
176
|
-
created_at:
|
|
177
|
-
modified_at:
|
|
178
|
-
inputs:
|
|
155
|
+
name: trimmedText(value.name) ?? null,
|
|
156
|
+
created_at: trimmedText(value.created_at) ?? null,
|
|
157
|
+
modified_at: trimmedText(value.modified_at) ?? null,
|
|
158
|
+
inputs: asJsonObject(value.inputs) ?? {},
|
|
179
159
|
outputs: nullableObject(value.outputs),
|
|
180
160
|
metadata: nullableObject(value.metadata),
|
|
181
161
|
raw: value
|
|
@@ -184,16 +164,16 @@ function normalizeExample(value) {
|
|
|
184
164
|
async function listWorkspaces(input, ctx) {
|
|
185
165
|
const payload = await request(ctx, {
|
|
186
166
|
path: WORKSPACES_PATH,
|
|
187
|
-
query:
|
|
167
|
+
query: compactDefined({ include_deleted: input.include_deleted, data_plane_id: trimmedText(input.data_plane_id) })
|
|
188
168
|
});
|
|
189
169
|
return { workspaces: ensureObjectArray(payload, "LangSmith workspace list").map(normalizeWorkspace) };
|
|
190
170
|
}
|
|
191
171
|
async function listProjects(input, ctx) {
|
|
192
172
|
const payload = await request(ctx, {
|
|
193
173
|
path: "/api/v1/sessions",
|
|
194
|
-
query:
|
|
195
|
-
name:
|
|
196
|
-
name_contains:
|
|
174
|
+
query: compactDefined({
|
|
175
|
+
name: trimmedText(input.name),
|
|
176
|
+
name_contains: trimmedText(input.name_contains),
|
|
197
177
|
include_stats: input.include_stats,
|
|
198
178
|
sort_by_desc: input.sort_by_desc,
|
|
199
179
|
offset: input.offset,
|
|
@@ -205,7 +185,7 @@ async function listProjects(input, ctx) {
|
|
|
205
185
|
async function getProject(input, ctx) {
|
|
206
186
|
const payload = await request(ctx, {
|
|
207
187
|
path: `/api/v1/sessions/${requirePathId(input.projectId, "projectId")}`,
|
|
208
|
-
query:
|
|
188
|
+
query: compactDefined({ include_stats: input.include_stats })
|
|
209
189
|
});
|
|
210
190
|
return { project: normalizeProject(ensureObject(payload, "LangSmith project")) };
|
|
211
191
|
}
|
|
@@ -214,15 +194,15 @@ async function createProject(input, ctx) {
|
|
|
214
194
|
method: "POST",
|
|
215
195
|
path: "/api/v1/sessions",
|
|
216
196
|
// upsert 是 query 参数而不是 body 字段 —— 放进 body 会被忽略,同名项目直接 409。
|
|
217
|
-
query:
|
|
218
|
-
body:
|
|
219
|
-
name:
|
|
220
|
-
description:
|
|
221
|
-
start_time:
|
|
222
|
-
end_time:
|
|
197
|
+
query: compactDefined({ upsert: input.upsert }),
|
|
198
|
+
body: compactDefined({
|
|
199
|
+
name: trimmedText(input.name),
|
|
200
|
+
description: trimmedText(input.description),
|
|
201
|
+
start_time: trimmedText(input.start_time),
|
|
202
|
+
end_time: trimmedText(input.end_time),
|
|
223
203
|
extra: input.extra,
|
|
224
|
-
default_dataset_id:
|
|
225
|
-
reference_dataset_id:
|
|
204
|
+
default_dataset_id: trimmedText(input.default_dataset_id),
|
|
205
|
+
reference_dataset_id: trimmedText(input.reference_dataset_id)
|
|
226
206
|
})
|
|
227
207
|
});
|
|
228
208
|
return { project: normalizeProject(ensureObject(payload, "LangSmith created project")) };
|
|
@@ -230,10 +210,10 @@ async function createProject(input, ctx) {
|
|
|
230
210
|
async function listDatasets(input, ctx) {
|
|
231
211
|
const payload = await request(ctx, {
|
|
232
212
|
path: "/api/v1/datasets",
|
|
233
|
-
query:
|
|
234
|
-
name:
|
|
235
|
-
name_contains:
|
|
236
|
-
data_type:
|
|
213
|
+
query: compactDefined({
|
|
214
|
+
name: trimmedText(input.name),
|
|
215
|
+
name_contains: trimmedText(input.name_contains),
|
|
216
|
+
data_type: trimmedText(input.data_type),
|
|
237
217
|
offset: input.offset,
|
|
238
218
|
limit: input.limit
|
|
239
219
|
})
|
|
@@ -248,10 +228,10 @@ async function createDataset(input, ctx) {
|
|
|
248
228
|
const payload = await request(ctx, {
|
|
249
229
|
method: "POST",
|
|
250
230
|
path: "/api/v1/datasets",
|
|
251
|
-
body:
|
|
252
|
-
name:
|
|
253
|
-
description:
|
|
254
|
-
data_type:
|
|
231
|
+
body: compactDefined({
|
|
232
|
+
name: trimmedText(input.name),
|
|
233
|
+
description: trimmedText(input.description),
|
|
234
|
+
data_type: trimmedText(input.data_type),
|
|
255
235
|
inputs_schema_definition: input.inputs_schema_definition,
|
|
256
236
|
outputs_schema_definition: input.outputs_schema_definition,
|
|
257
237
|
metadata: input.metadata,
|
|
@@ -263,11 +243,11 @@ async function createDataset(input, ctx) {
|
|
|
263
243
|
async function listExamples(input, ctx) {
|
|
264
244
|
const payload = await request(ctx, {
|
|
265
245
|
path: "/api/v1/examples",
|
|
266
|
-
query:
|
|
246
|
+
query: compactDefined({
|
|
267
247
|
// 线上参数名是 `dataset`,不是入参里的 `datasetId`。
|
|
268
|
-
dataset:
|
|
248
|
+
dataset: trimmedText(input.datasetId),
|
|
269
249
|
full_text_contains: input.full_text_contains,
|
|
270
|
-
as_of:
|
|
250
|
+
as_of: trimmedText(input.as_of),
|
|
271
251
|
offset: input.offset,
|
|
272
252
|
limit: input.limit
|
|
273
253
|
})
|
|
@@ -277,7 +257,7 @@ async function listExamples(input, ctx) {
|
|
|
277
257
|
async function getExample(input, ctx) {
|
|
278
258
|
const payload = await request(ctx, {
|
|
279
259
|
path: `/api/v1/examples/${requirePathId(input.exampleId, "exampleId")}`,
|
|
280
|
-
query:
|
|
260
|
+
query: compactDefined({ dataset: trimmedText(input.datasetId), as_of: trimmedText(input.as_of) })
|
|
281
261
|
});
|
|
282
262
|
return { example: normalizeExample(ensureObject(payload, "LangSmith example")) };
|
|
283
263
|
}
|
|
@@ -285,15 +265,15 @@ async function createExample(input, ctx) {
|
|
|
285
265
|
const payload = await request(ctx, {
|
|
286
266
|
method: "POST",
|
|
287
267
|
path: "/api/v1/examples",
|
|
288
|
-
body:
|
|
268
|
+
body: compactDefined({
|
|
289
269
|
// 建例子时又叫 `dataset_id`(与 list/get 的 `dataset` 不是一个名字)。
|
|
290
|
-
dataset_id:
|
|
270
|
+
dataset_id: trimmedText(input.datasetId),
|
|
291
271
|
inputs: input.inputs,
|
|
292
272
|
outputs: input.outputs,
|
|
293
273
|
metadata: input.metadata,
|
|
294
274
|
split: input.split,
|
|
295
|
-
id:
|
|
296
|
-
created_at:
|
|
275
|
+
id: trimmedText(input.id),
|
|
276
|
+
created_at: trimmedText(input.created_at)
|
|
297
277
|
})
|
|
298
278
|
});
|
|
299
279
|
return { example: normalizeExample(ensureObject(payload, "LangSmith created example")) };
|
|
@@ -1,38 +1,33 @@
|
|
|
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/lemlist/api.ts
|
|
17
22
|
var SERVICE = "lemlist";
|
|
18
23
|
var API_BASE = "https://api.lemlist.com/api";
|
|
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 stringArray(value) {
|
|
31
26
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
|
|
32
27
|
}
|
|
33
28
|
function objectArray(value) {
|
|
34
29
|
if (!Array.isArray(value)) return void 0;
|
|
35
|
-
return value.map(
|
|
30
|
+
return value.map(asJsonObject).filter((item) => item !== void 0);
|
|
36
31
|
}
|
|
37
32
|
function basicAuthHeader(apiKey) {
|
|
38
33
|
const bytes = new TextEncoder().encode(`:${apiKey}`);
|
|
@@ -41,43 +36,37 @@ function basicAuthHeader(apiKey) {
|
|
|
41
36
|
return `Basic ${btoa(binary)}`;
|
|
42
37
|
}
|
|
43
38
|
function errorMessage(payload) {
|
|
44
|
-
if (typeof payload === "string") return
|
|
45
|
-
const body =
|
|
39
|
+
if (typeof payload === "string") return trimmedText(payload);
|
|
40
|
+
const body = asJsonObject(payload);
|
|
46
41
|
if (body === void 0) return void 0;
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
async function readPayload(response) {
|
|
50
|
-
const body = await response.text().catch(() => "");
|
|
51
|
-
if (body.trim() === "") return null;
|
|
52
|
-
try {
|
|
53
|
-
return JSON.parse(body);
|
|
54
|
-
} catch {
|
|
55
|
-
return body;
|
|
56
|
-
}
|
|
42
|
+
return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.reason);
|
|
57
43
|
}
|
|
58
44
|
async function request(ctx, path, query = {}) {
|
|
59
45
|
const apiKey = requireApiKey(ctx, SERVICE);
|
|
60
|
-
const
|
|
46
|
+
const pairs = [];
|
|
61
47
|
for (const [key, value] of Object.entries(query)) {
|
|
62
|
-
if (value
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
response = await guardedFetch(url.toString(), {
|
|
67
|
-
method: "GET",
|
|
68
|
-
headers: { accept: "application/json", authorization: basicAuthHeader(apiKey) }
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {
|
|
71
|
-
throw upstreamError(502, error instanceof Error ? `lemlist \u8BF7\u6C42\u5931\u8D25: ${error.message}` : "lemlist \u8BF7\u6C42\u5931\u8D25");
|
|
72
|
-
}
|
|
73
|
-
const payload = await readPayload(response);
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
throw upstreamError(response.status, errorMessage(payload) ?? `lemlist \u8BF7\u6C42\u5931\u8D25,HTTP ${response.status}`);
|
|
48
|
+
if (typeof value === "number" || typeof value === "string" && value !== "") {
|
|
49
|
+
pairs.push([key, value]);
|
|
50
|
+
}
|
|
76
51
|
}
|
|
77
|
-
|
|
52
|
+
const { data } = await http.request({
|
|
53
|
+
path,
|
|
54
|
+
query: pairs,
|
|
55
|
+
headers: { accept: "application/json", authorization: basicAuthHeader(apiKey) },
|
|
56
|
+
invalidJson: "text",
|
|
57
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
58
|
+
status,
|
|
59
|
+
errorMessage(payload) ?? `lemlist \u8BF7\u6C42\u5931\u8D25,HTTP ${status}`
|
|
60
|
+
),
|
|
61
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
62
|
+
502,
|
|
63
|
+
message === void 0 ? "lemlist \u8BF7\u6C42\u5931\u8D25" : `lemlist \u8BF7\u6C42\u5931\u8D25: ${message}`
|
|
64
|
+
)
|
|
65
|
+
});
|
|
66
|
+
return data ?? null;
|
|
78
67
|
}
|
|
79
68
|
function requireObject(value, message) {
|
|
80
|
-
const object =
|
|
69
|
+
const object = asJsonObject(value);
|
|
81
70
|
if (object === void 0) throw new TBError("unavailable", message, { retryable: true });
|
|
82
71
|
return object;
|
|
83
72
|
}
|
|
@@ -87,43 +76,43 @@ function requireArray(value, message) {
|
|
|
87
76
|
}
|
|
88
77
|
function normalizeTeam(value) {
|
|
89
78
|
const team = requireObject(value, "lemlist team \u54CD\u5E94\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
90
|
-
return
|
|
91
|
-
_id:
|
|
92
|
-
name:
|
|
79
|
+
return compactDefined({
|
|
80
|
+
_id: trimmedText(team._id),
|
|
81
|
+
name: trimmedText(team.name),
|
|
93
82
|
userIds: stringArray(team.userIds),
|
|
94
|
-
createdBy:
|
|
95
|
-
createdAt:
|
|
83
|
+
createdBy: trimmedText(team.createdBy),
|
|
84
|
+
createdAt: trimmedText(team.createdAt),
|
|
96
85
|
beta: stringArray(team.beta),
|
|
97
|
-
pictureId:
|
|
98
|
-
customDomain:
|
|
86
|
+
pictureId: trimmedText(team.pictureId),
|
|
87
|
+
customDomain: trimmedText(team.customDomain),
|
|
99
88
|
raw: team
|
|
100
89
|
});
|
|
101
90
|
}
|
|
102
91
|
function normalizeCampaign(value) {
|
|
103
92
|
const campaign = requireObject(value, "lemlist campaign \u54CD\u5E94\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
104
|
-
return
|
|
105
|
-
_id:
|
|
106
|
-
name:
|
|
93
|
+
return compactDefined({
|
|
94
|
+
_id: trimmedText(campaign._id),
|
|
95
|
+
name: trimmedText(campaign.name),
|
|
107
96
|
labels: stringArray(campaign.labels),
|
|
108
|
-
createdAt:
|
|
109
|
-
createdBy:
|
|
110
|
-
status:
|
|
111
|
-
sequenceId:
|
|
97
|
+
createdAt: trimmedText(campaign.createdAt),
|
|
98
|
+
createdBy: trimmedText(campaign.createdBy),
|
|
99
|
+
status: trimmedText(campaign.status),
|
|
100
|
+
sequenceId: trimmedText(campaign.sequenceId),
|
|
112
101
|
scheduleIds: stringArray(campaign.scheduleIds),
|
|
113
|
-
teamId:
|
|
102
|
+
teamId: trimmedText(campaign.teamId),
|
|
114
103
|
hasError: typeof campaign.hasError === "boolean" ? campaign.hasError : void 0,
|
|
115
104
|
errors: stringArray(campaign.errors),
|
|
116
|
-
creator:
|
|
105
|
+
creator: asJsonObject(campaign.creator),
|
|
117
106
|
senders: objectArray(campaign.senders),
|
|
118
107
|
raw: campaign
|
|
119
108
|
});
|
|
120
109
|
}
|
|
121
110
|
function normalizeLead(value) {
|
|
122
111
|
const lead = requireObject(value, "lemlist lead \u54CD\u5E94\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
123
|
-
return
|
|
124
|
-
_id:
|
|
125
|
-
contactId:
|
|
126
|
-
state:
|
|
112
|
+
return compactDefined({
|
|
113
|
+
_id: trimmedText(lead._id),
|
|
114
|
+
contactId: trimmedText(lead.contactId),
|
|
115
|
+
state: trimmedText(lead.state),
|
|
127
116
|
raw: lead
|
|
128
117
|
});
|
|
129
118
|
}
|