@tool-bridge/server 0.16.0 → 0.19.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.
Files changed (115) hide show
  1. package/dist/{airtable-S3T4TAN7.js → airtable-23JBIM6X.js} +106 -114
  2. package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-ADWBTCIH.js} +25 -16
  3. package/dist/{amap-LGVGNPML.js → amap-CYQCYW2Z.js} +114 -123
  4. package/dist/{anthropic-27RFZO35.js → anthropic-5P62HDNR.js} +34 -56
  5. package/dist/{apify-6WLYAIAS.js → apify-54RZUAGW.js} +31 -49
  6. package/dist/{brave_search-K2SVJ66F.js → brave_search-AHJ6FTD5.js} +52 -77
  7. package/dist/{chunk-VK3V2WTY.js → chunk-B4P6YZFS.js} +4 -6
  8. package/dist/{chunk-BB6ZLMTU.js → chunk-CLEZ6YQ6.js} +2600 -481
  9. package/dist/chunk-JXHMDBAY.js +45 -0
  10. package/dist/chunk-LMLX3DJF.js +50 -0
  11. package/dist/{chunk-YB2FLNWI.js → chunk-OKRZPQ3R.js} +2558 -1926
  12. package/dist/chunk-SWBNHIO4.js +977 -0
  13. package/dist/chunk-U67V476Y.js +35 -0
  14. package/dist/chunk-VLOIDU5U.js +283 -0
  15. package/dist/{circleci-WV3ITU7Q.js → circleci-UM3NSQJ3.js} +36 -55
  16. package/dist/{clerk-NFQEFKS4.js → clerk-FE5LQ2CZ.js} +60 -80
  17. package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-KEZABKUT.js} +90 -113
  18. package/dist/{cohere-5KEW7LWT.js → cohere-4IPJADXP.js} +33 -49
  19. package/dist/{confluence-SZE63S46.js → confluence-56QEKNQI.js} +79 -115
  20. package/dist/{convertapi-QPG2JC5K.js → convertapi-3QRM5K5T.js} +13 -16
  21. package/dist/{currencyapi-UO2APQRY.js → currencyapi-L6G4OND5.js} +30 -53
  22. package/dist/{deepseek-LJELIMM3.js → deepseek-LGC6HBFG.js} +30 -38
  23. package/dist/{docker_hub-2MFXSBOF.js → docker_hub-XDMK3BIU.js} +141 -157
  24. package/dist/{dropbox-GQYNTTVA.js → dropbox-4QARMFZU.js} +134 -141
  25. package/dist/{dub-KI2LHXST.js → dub-C6JSJKOT.js} +61 -93
  26. package/dist/{e2b-WO6ISY3C.js → e2b-6A6TVACJ.js} +39 -69
  27. package/dist/{exa-IZ7B3BPT.js → exa-SIWWW6AA.js} +49 -77
  28. package/dist/{fal_ai-LTMF36GJ.js → fal_ai-3IJXOKSP.js} +37 -44
  29. package/dist/{feishu-WM7SLSFD.js → feishu-L4KDA4DC.js} +4 -6
  30. package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-SDM75H4P.js} +4 -5
  31. package/dist/{figma-2Z274VQZ.js → figma-6DD436DN.js} +56 -81
  32. package/dist/{firehydrant-IFI4R65V.js → firehydrant-SYSGYB3R.js} +40 -53
  33. package/dist/{fixer-BCCZEB3D.js → fixer-FZG7ASTF.js} +31 -43
  34. package/dist/{fly-755FXYB5.js → fly-HMRCZBUC.js} +50 -66
  35. package/dist/{front-4FZKKXXK.js → front-FAFSD7I3.js} +43 -66
  36. package/dist/{geocodio-WYKDJ3DP.js → geocodio-4D3TWENM.js} +37 -63
  37. package/dist/{ghost-5BNQTCOH.js → ghost-OSO2FOZS.js} +51 -57
  38. package/dist/{github-ULELF5VX.js → github-OR4I4RHE.js} +48 -41
  39. package/dist/{gmail-G34WT64J.js → gmail-5AOPJ63E.js} +26 -36
  40. package/dist/{googlecalendar-BQU255SC.js → googlecalendar-SOJIJUWH.js} +57 -78
  41. package/dist/{googledocs-HPCNQXYJ.js → googledocs-QSKN5TLN.js} +14 -22
  42. package/dist/{grafana-VOV24FIC.js → grafana-R3AIZM7M.js} +95 -122
  43. package/dist/{graphhopper-D5RXW6AP.js → graphhopper-4CR3QOAX.js} +32 -46
  44. package/dist/index.d.ts +108 -56
  45. package/dist/index.js +4 -3
  46. package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-OBCG6X6J.js} +35 -42
  47. package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-NHH3DTQW.js} +40 -60
  48. package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-7POMCBEC.js} +30 -42
  49. package/dist/{jina_ai-E6UXFV2P.js → jina_ai-YXVKROV4.js} +32 -58
  50. package/dist/{jira-ZDSXGQ6W.js → jira-LADO3VJU.js} +116 -126
  51. package/dist/{langsmith-TIFJRREW.js → langsmith-XZ6UAQFU.js} +101 -121
  52. package/dist/{lemlist-DASEMJMA.js → lemlist-P74GLNE7.js} +57 -68
  53. package/dist/{linear-KE6UP4SP.js → linear-CXJ7D37A.js} +109 -118
  54. package/dist/{logsnag-IMNDN4R5.js → logsnag-EVVHWFLK.js} +31 -48
  55. package/dist/main.js +103 -102
  56. package/dist/{mattermost-HHHMUXQA.js → mattermost-WG2MRGBD.js} +45 -62
  57. package/dist/{mem0-D2FGGOIY.js → mem0-HQWUKG6U.js} +72 -98
  58. package/dist/{memos-4OVIGFPH.js → memos-SQMJIFOE.js} +68 -122
  59. package/dist/{metabase-33WCX5YD.js → metabase-E27G2DZI.js} +47 -60
  60. package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-MIL63NIT.js} +35 -40
  61. package/dist/{mother_duck-M6VWS2VH.js → mother_duck-AIZVCBNR.js} +42 -62
  62. package/dist/{ngrok-Z2PKQBHH.js → ngrok-XS4DVIQS.js} +42 -58
  63. package/dist/{notes-SS4RPC4K.js → notes-JEOUSL2Y.js} +3 -5
  64. package/dist/{notion-FJCNQ6I7.js → notion-U4EZVDW2.js} +83 -97
  65. package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-AZSQEYEJ.js} +35 -39
  66. package/dist/{openai-JODZ4GKT.js → openai-HW3SYMTQ.js} +51 -55
  67. package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-QX74MAEL.js} +61 -79
  68. package/dist/{openrouter-Q5XXEJZ7.js → openrouter-OXSKYL6N.js} +41 -55
  69. package/dist/{outline-RT2EHJ2X.js → outline-CCQAPDSW.js} +89 -104
  70. package/dist/{paddle-OF2V7GAC.js → paddle-6KQPSSCK.js} +34 -49
  71. package/dist/{perplexity-LNZEWLHG.js → perplexity-2TXO7IQE.js} +33 -50
  72. package/dist/{pinecone-JSJIXZYN.js → pinecone-YOO7NULI.js} +65 -91
  73. package/dist/{pipedrive-D4CKVUXR.js → pipedrive-Q6RIFIFP.js} +37 -59
  74. package/dist/{polar-M7ZYP6UR.js → polar-KUMGCES3.js} +43 -53
  75. package/dist/{posthog-YV7CZOH4.js → posthog-VXQHBSMB.js} +58 -77
  76. package/dist/{postmark-KYHLECRG.js → postmark-YLIPF52S.js} +52 -71
  77. package/dist/{prerender-HCMHBKV2.js → prerender-CRY7UJN5.js} +32 -50
  78. package/dist/{pubmed-WYVLCCN3.js → pubmed-3Z4T5AM7.js} +28 -60
  79. package/dist/{railway-TWIRD5KR.js → railway-BP37IGFL.js} +32 -39
  80. package/dist/{readwise-UZ467IQ7.js → readwise-HTKICF4K.js} +62 -78
  81. package/dist/{render-MECUC5CC.js → render-WIVTUXJH.js} +48 -64
  82. package/dist/{replicate-A5MEK3SW.js → replicate-JJYPA43D.js} +41 -58
  83. package/dist/{resend-BC6EAWJQ.js → resend-TKHZVG7A.js} +27 -37
  84. package/dist/{rootly-ZM3QDUIS.js → rootly-FRSZLG5U.js} +64 -76
  85. package/dist/{scrapfly-WAML42QJ.js → scrapfly-M5WXGQWE.js} +45 -51
  86. package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-PMXNLLBK.js} +25 -33
  87. package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-HFW4TAOH.js} +29 -47
  88. package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-KXVH2VZQ.js} +37 -56
  89. package/dist/{sentry-OKBPSTDM.js → sentry-WWOT2LRX.js} +66 -85
  90. package/dist/{shodan-PPC6DYU4.js → shodan-FY635H35.js} +42 -53
  91. package/dist/{shopify-EWGUHBXO.js → shopify-HQLBVSA5.js} +32 -49
  92. package/dist/{stripe-6RPDPC5W.js → stripe-GJN2GOHB.js} +4 -5
  93. package/dist/{supabase-SK7DQ42N.js → supabase-BBNZGQU6.js} +69 -88
  94. package/dist/{tavily-YCG5VQMH.js → tavily-DPENIBOG.js} +37 -62
  95. package/dist/{telegram-2OES5FYB.js → telegram-L4NONG6H.js} +168 -177
  96. package/dist/{telnyx-POOSBBR4.js → telnyx-H67MAEZS.js} +30 -50
  97. package/dist/{todoist-M7YD6YSS.js → todoist-G2BSP4DX.js} +77 -89
  98. package/dist/{trello-IS6V5W3E.js → trello-7WMVFDG2.js} +108 -122
  99. package/dist/{turso-RCFHUFVH.js → turso-ZUAESFC2.js} +52 -64
  100. package/dist/{twilio-OS2RXFGO.js → twilio-EYFYIX3B.js} +48 -55
  101. package/dist/{umami-PQ2SJ2LN.js → umami-AXAUDUVF.js} +49 -69
  102. package/dist/{unsplash-C6BPZO4E.js → unsplash-UCQAWPLR.js} +35 -52
  103. package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-ZPZ4ASU6.js} +28 -40
  104. package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-4QVKKUD5.js} +11 -12
  105. package/dist/{v2ex-R4JWTEHN.js → v2ex-VGEFJTYC.js} +36 -61
  106. package/dist/{vercel-FZVYUOQD.js → vercel-JME4TSCN.js} +124 -150
  107. package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
  108. package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-TRGU2MDG.js} +26 -34
  109. package/dist/{wordpress-XRWGO6LG.js → wordpress-WRUKLCZR.js} +87 -104
  110. package/dist/{workos-WR4NKOYL.js → workos-ZDW4EHS4.js} +37 -56
  111. package/dist/{zhihu-BKZIB3WA.js → zhihu-4VI67CWU.js} +35 -57
  112. package/package.json +3 -3
  113. package/dist/chunk-2O27H4Y2.js +0 -183
  114. package/dist/chunk-GKX72JMJ.js +0 -378
  115. package/dist/chunk-MLKGABMK.js +0 -9
@@ -1,52 +1,43 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-VLOIDU5U.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-VK3V2WTY.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
15
+ } from "./chunk-B4P6YZFS.js";
16
+ import "./chunk-SWBNHIO4.js";
10
17
  import {
11
18
  TBError,
12
19
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
20
+ } from "./chunk-OKRZPQ3R.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 = text(configured) ?? DEFAULT_REGION;
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 text(configured);
49
+ return trimmedText(configured);
59
50
  }
60
- async function readPayload(response) {
61
- const body = await response.text().catch(() => "");
62
- if (body.trim() === "") return null;
63
- try {
64
- return JSON.parse(body);
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 errorMessage(response, payload) {
70
- const fromText = typeof payload === "string" ? text(payload) : void 0;
71
- const body = record(payload);
72
- return fromText ?? text(body?.detail) ?? text(body?.message) ?? text(body?.error) ?? text(body?.title) ?? text(response.statusText) ?? `langsmith \u8FD4\u56DE HTTP ${response.status}`;
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
- for (const [key, value] of Object.entries(input.query ?? {})) {
79
- if (value === void 0 || value === null) continue;
80
- if (Array.isArray(value)) {
81
- for (const item of value) {
82
- if (item !== void 0 && item !== null) url.searchParams.append(key, String(item));
83
- }
84
- continue;
85
- }
86
- url.searchParams.set(key, String(value));
87
- }
88
- const headers = { "accept": "application/json", "X-Api-Key": apiKey };
89
- if (input.body !== void 0) headers["content-type"] = "application/json";
90
- if (workspaceId !== void 0) headers["X-Tenant-Id"] = workspaceId;
91
- let response;
92
- try {
93
- response = await guardedFetch(url.toString(), {
94
- method: input.method ?? "GET",
95
- headers,
96
- ...input.body === void 0 ? {} : { body: JSON.stringify(input.body) }
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 = record(value);
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 = text(value);
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: text(value.organization_id) ?? null,
128
- display_name: text(value.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: text(value.tenant_handle) ?? null,
132
- data_plane_url: text(value.data_plane_url) ?? null,
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: text(value.name) ?? null,
142
- description: text(value.description) ?? null,
143
- start_time: text(value.start_time) ?? null,
144
- end_time: text(value.end_time) ?? null,
145
- run_count: int(value.run_count) ?? null,
146
- error_rate: num(value.error_rate) ?? null,
147
- default_dataset_id: text(value.default_dataset_id) ?? null,
148
- reference_dataset_id: text(value.reference_dataset_id) ?? null,
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 record(value) ?? {};
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: text(value.name) ?? "",
161
- description: text(value.description) ?? null,
162
- data_type: text(value.data_type) ?? null,
163
- created_at: text(value.created_at) ?? null,
164
- modified_at: text(value.modified_at) ?? null,
165
- example_count: int(value.example_count) ?? null,
166
- session_count: int(value.session_count) ?? null,
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: text(value.name) ?? null,
176
- created_at: text(value.created_at) ?? null,
177
- modified_at: text(value.modified_at) ?? null,
178
- inputs: record(value.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: compact({ include_deleted: input.include_deleted, data_plane_id: text(input.data_plane_id) })
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: compact({
195
- name: text(input.name),
196
- name_contains: text(input.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: compact({ include_stats: input.include_stats })
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: compact({ upsert: input.upsert }),
218
- body: compact({
219
- name: text(input.name),
220
- description: text(input.description),
221
- start_time: text(input.start_time),
222
- end_time: text(input.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: text(input.default_dataset_id),
225
- reference_dataset_id: text(input.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: compact({
234
- name: text(input.name),
235
- name_contains: text(input.name_contains),
236
- data_type: text(input.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: compact({
252
- name: text(input.name),
253
- description: text(input.description),
254
- data_type: text(input.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: compact({
246
+ query: compactDefined({
267
247
  // 线上参数名是 `dataset`,不是入参里的 `datasetId`。
268
- dataset: text(input.datasetId),
248
+ dataset: trimmedText(input.datasetId),
269
249
  full_text_contains: input.full_text_contains,
270
- as_of: text(input.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: compact({ dataset: text(input.datasetId), as_of: text(input.as_of) })
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: compact({
268
+ body: compactDefined({
289
269
  // 建例子时又叫 `dataset_id`(与 list/get 的 `dataset` 不是一个名字)。
290
- dataset_id: text(input.datasetId),
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: text(input.id),
296
- created_at: text(input.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-VLOIDU5U.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-VK3V2WTY.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-2O27H4Y2.js";
9
- import "./chunk-GKX72JMJ.js";
13
+ } from "./chunk-B4P6YZFS.js";
14
+ import "./chunk-SWBNHIO4.js";
10
15
  import {
11
16
  TBError,
12
17
  external_exports
13
- } from "./chunk-YB2FLNWI.js";
14
- import "./chunk-MLKGABMK.js";
18
+ } from "./chunk-OKRZPQ3R.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
- function text(value) {
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(record).filter((item) => item !== void 0);
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 text(payload);
45
- const body = record(payload);
39
+ if (typeof payload === "string") return trimmedText(payload);
40
+ const body = asJsonObject(payload);
46
41
  if (body === void 0) return void 0;
47
- return text(body.message) ?? text(body.error) ?? text(body.reason);
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 url = new URL(`${API_BASE}${path}`);
46
+ const pairs = [];
61
47
  for (const [key, value] of Object.entries(query)) {
62
- if (value !== void 0 && value !== null && value !== "") url.searchParams.set(key, String(value));
63
- }
64
- let response;
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
- return payload;
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 = record(value);
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 compact({
91
- _id: text(team._id),
92
- name: text(team.name),
79
+ return compactDefined({
80
+ _id: trimmedText(team._id),
81
+ name: trimmedText(team.name),
93
82
  userIds: stringArray(team.userIds),
94
- createdBy: text(team.createdBy),
95
- createdAt: text(team.createdAt),
83
+ createdBy: trimmedText(team.createdBy),
84
+ createdAt: trimmedText(team.createdAt),
96
85
  beta: stringArray(team.beta),
97
- pictureId: text(team.pictureId),
98
- customDomain: text(team.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 compact({
105
- _id: text(campaign._id),
106
- name: text(campaign.name),
93
+ return compactDefined({
94
+ _id: trimmedText(campaign._id),
95
+ name: trimmedText(campaign.name),
107
96
  labels: stringArray(campaign.labels),
108
- createdAt: text(campaign.createdAt),
109
- createdBy: text(campaign.createdBy),
110
- status: text(campaign.status),
111
- sequenceId: text(campaign.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: text(campaign.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: record(campaign.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 compact({
124
- _id: text(lead._id),
125
- contactId: text(lead.contactId),
126
- state: text(lead.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
  }