web-access-cli 0.3.0 → 0.4.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.
@@ -0,0 +1,208 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { WebAccessError } from "../core/errors.js";
4
+ import { buildEndpoint } from "../transport/http.js";
5
+ import { VERSION } from "../version.js";
6
+ import { assertOk, normalizeHits, parseJsonResponse, ref, requireBaseUrl, } from "./common.js";
7
+ const XAI_TYPES = new Set(["xai_x_search", "xai_web_search"]);
8
+ const PROTECTED_HEADERS = new Set([
9
+ "authorization",
10
+ "content-type",
11
+ "accept",
12
+ "x-xai-token-auth",
13
+ "x-grok-client-version",
14
+ "x-grok-client-identifier",
15
+ "x-authenticateresponse",
16
+ "user-agent",
17
+ ]);
18
+ function isRecord(value) {
19
+ return !!value && typeof value === "object" && !Array.isArray(value);
20
+ }
21
+ function redact(value, secrets) {
22
+ if (typeof value === "string") {
23
+ return secrets.reduce((text, secret) => secret.length >= 4 ? text.split(secret).join("[REDACTED]") : text, value);
24
+ }
25
+ if (Array.isArray(value))
26
+ return value.map((item) => redact(item, secrets));
27
+ if (!isRecord(value))
28
+ return value;
29
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redact(item, secrets)]));
30
+ }
31
+ function authError(request, message, secrets = []) {
32
+ return new WebAccessError("auth_error", message, {
33
+ provider: ref(request.instance),
34
+ retryable: false,
35
+ raw: redact({ path: request.instance.authJson }, secrets),
36
+ });
37
+ }
38
+ function readAccessToken(request) {
39
+ const authPath = request.instance.authJson;
40
+ if (!authPath)
41
+ throw authError(request, "xAI OAuth authJson 未配置");
42
+ let parsed;
43
+ try {
44
+ parsed = JSON.parse(readFileSync(resolve(authPath), "utf8"));
45
+ }
46
+ catch {
47
+ throw authError(request, "xAI OAuth authJson 无法读取或解析");
48
+ }
49
+ if (!isRecord(parsed) || parsed.disabled === true)
50
+ throw authError(request, "xAI OAuth 凭据已禁用");
51
+ const token = parsed.access_token;
52
+ if (typeof token !== "string" || token.trim() === "")
53
+ throw authError(request, "xAI OAuth authJson 缺少 access_token");
54
+ return token;
55
+ }
56
+ function snippet(text, start, end) {
57
+ if (typeof start !== "number" || typeof end !== "number")
58
+ return "";
59
+ const value = text
60
+ .slice(Math.max(0, start - 120), Math.min(text.length, end + 120))
61
+ .replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
62
+ .trim();
63
+ return value.length > 300 ? `${value.slice(0, 297)}...` : value;
64
+ }
65
+ function mapResponse(parsed, request) {
66
+ const output = Array.isArray(parsed.output)
67
+ ? parsed.output.filter(isRecord)
68
+ : [];
69
+ const expectedCall = request.instance.type === "xai_x_search"
70
+ ? "custom_tool_call"
71
+ : "web_search_call";
72
+ if (!output.some((item) => item.type === expectedCall))
73
+ throw new WebAccessError("provider_error", `xAI ${request.instance.type} 未返回搜索工具调用`, { provider: ref(request.instance), retryable: true, raw: parsed });
74
+ const items = [];
75
+ for (const item of output) {
76
+ if (item.type === "message" && Array.isArray(item.content)) {
77
+ for (const block of item.content.filter(isRecord)) {
78
+ const annotations = Array.isArray(block.annotations)
79
+ ? block.annotations.filter(isRecord)
80
+ : [];
81
+ for (const annotation of annotations) {
82
+ if (annotation.type !== "url_citation" ||
83
+ typeof annotation.url !== "string")
84
+ continue;
85
+ items.push({
86
+ url: annotation.url,
87
+ ...(typeof annotation.title === "string"
88
+ ? { title: annotation.title }
89
+ : {}),
90
+ snippet: snippet(typeof block.text === "string" ? block.text : "", annotation.start_index, annotation.end_index),
91
+ });
92
+ }
93
+ }
94
+ }
95
+ }
96
+ for (const item of output) {
97
+ if (request.instance.type === "xai_web_search" &&
98
+ item.type === "web_search_call") {
99
+ const sources = isRecord(item.action) && Array.isArray(item.action.sources)
100
+ ? item.action.sources.filter(isRecord)
101
+ : [];
102
+ for (const source of sources) {
103
+ if (typeof source.url !== "string")
104
+ continue;
105
+ items.push({
106
+ url: source.url,
107
+ ...(typeof source.title === "string" ? { title: source.title } : {}),
108
+ snippet: "",
109
+ });
110
+ }
111
+ }
112
+ }
113
+ return {
114
+ results: normalizeHits(items, request.limit, request.includeDomains, request.excludeDomains),
115
+ };
116
+ }
117
+ function requestHeaders(request, token) {
118
+ const headers = Object.fromEntries(Object.entries(request.instance.headers).filter(([name]) => !PROTECTED_HEADERS.has(name.toLowerCase())));
119
+ return {
120
+ ...headers,
121
+ Authorization: `Bearer ${token}`,
122
+ "X-XAI-Token-Auth": "xai-grok-cli",
123
+ "x-grok-client-version": "0.2.120",
124
+ "x-grok-client-identifier": "grok-shell",
125
+ "x-authenticateresponse": "authenticate-response",
126
+ "Content-Type": "application/json",
127
+ Accept: "application/json",
128
+ "User-Agent": `web-access-cli/${VERSION}`,
129
+ };
130
+ }
131
+ function createAdapter(type) {
132
+ return {
133
+ type,
134
+ capabilities: ["search"],
135
+ isConfigured: (instance) => XAI_TYPES.has(instance.type) &&
136
+ !!instance.baseUrl &&
137
+ !!instance.authJson &&
138
+ existsSync(resolve(instance.authJson)),
139
+ async search(request) {
140
+ if (type === "xai_x_search" && request.freshness)
141
+ throw new WebAccessError("provider_unavailable", "xAI x_search 不支持 freshness", { provider: ref(request.instance), retryable: true });
142
+ if (type === "xai_web_search" &&
143
+ request.includeDomains.length > 0 &&
144
+ request.excludeDomains.length > 0)
145
+ throw new WebAccessError("provider_unavailable", "xAI web_search 不能同时设置 include-domain 和 exclude-domain", { provider: ref(request.instance), retryable: true });
146
+ if (type === "xai_web_search" &&
147
+ (request.includeDomains.length > 5 || request.excludeDomains.length > 5))
148
+ throw new WebAccessError("provider_unavailable", "xAI web_search 每次最多支持 5 个域名", { provider: ref(request.instance), retryable: true });
149
+ const token = readAccessToken(request);
150
+ const tool = type === "xai_x_search"
151
+ ? { type: "x_search" }
152
+ : {
153
+ type: "web_search",
154
+ ...(request.includeDomains.length > 0 ||
155
+ request.excludeDomains.length > 0
156
+ ? {
157
+ filters: {
158
+ ...(request.includeDomains.length > 0
159
+ ? {
160
+ allowed_domains: request.includeDomains.slice(0, 5),
161
+ }
162
+ : {}),
163
+ ...(request.excludeDomains.length > 0
164
+ ? {
165
+ excluded_domains: request.excludeDomains.slice(0, 5),
166
+ }
167
+ : {}),
168
+ },
169
+ }
170
+ : {}),
171
+ };
172
+ const response = await request.transport.request(buildEndpoint(requireBaseUrl(request.instance), "responses"), {
173
+ method: "POST",
174
+ headers: requestHeaders(request, token),
175
+ body: JSON.stringify({
176
+ model: request.instance.model ?? "grok-4.6",
177
+ input: `Search the web for: ${request.query}`,
178
+ tools: [tool],
179
+ }),
180
+ signal: request.signal,
181
+ maxResponseBytes: request.maxResponseBytes,
182
+ maxRedirects: 0,
183
+ });
184
+ try {
185
+ assertOk(response, request.instance);
186
+ const parsed = parseJsonResponse(response, request.instance);
187
+ return {
188
+ data: mapResponse(parsed, request),
189
+ raw: redact(parsed, [token]),
190
+ };
191
+ }
192
+ catch (error) {
193
+ if (!(error instanceof WebAccessError))
194
+ throw error;
195
+ throw new WebAccessError(error.code, error.message, {
196
+ retryable: error.retryable,
197
+ provider: error.provider,
198
+ httpStatus: error.httpStatus,
199
+ details: redact(error.details, [token]),
200
+ raw: redact(error.raw, [token]),
201
+ });
202
+ }
203
+ },
204
+ };
205
+ }
206
+ export const XAI_X_SEARCH_ADAPTER = createAdapter("xai_x_search");
207
+ export const XAI_WEB_SEARCH_ADAPTER = createAdapter("xai_web_search");
208
+ //# sourceMappingURL=xai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xai.js","sourceRoot":"","sources":["../../src/providers/xai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,e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# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-access-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Agent-neutral web search and content extraction CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -82,6 +82,14 @@
82
82
  {
83
83
  "type": "string",
84
84
  "const": "deepseek"
85
+ },
86
+ {
87
+ "type": "string",
88
+ "const": "xai_x_search"
89
+ },
90
+ {
91
+ "type": "string",
92
+ "const": "xai_web_search"
85
93
  }
86
94
  ]
87
95
  }
@@ -150,6 +158,71 @@
150
158
  }
151
159
  },
152
160
  "additionalProperties": false
161
+ },
162
+ {
163
+ "type": "object",
164
+ "required": [
165
+ "id",
166
+ "type"
167
+ ],
168
+ "properties": {
169
+ "id": {
170
+ "type": "string",
171
+ "pattern": "^[a-z][a-z0-9_-]{0,63}$"
172
+ },
173
+ "apiKey": {
174
+ "type": "string"
175
+ },
176
+ "apiKeyEnv": {
177
+ "type": "string",
178
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
179
+ },
180
+ "baseUrl": {
181
+ "type": "string",
182
+ "format": "uri"
183
+ },
184
+ "baseUrlEnv": {
185
+ "type": "string",
186
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
187
+ },
188
+ "headers": {
189
+ "type": "object",
190
+ "patternProperties": {
191
+ "^[^\\r\\n]+$": {
192
+ "type": "string",
193
+ "pattern": "^[^\\r\\n]*$"
194
+ }
195
+ },
196
+ "additionalProperties": false
197
+ },
198
+ "authJson": {
199
+ "type": "string"
200
+ },
201
+ "authJsonEnv": {
202
+ "type": "string",
203
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
204
+ },
205
+ "model": {
206
+ "type": "string"
207
+ },
208
+ "modelEnv": {
209
+ "type": "string",
210
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
211
+ },
212
+ "type": {
213
+ "anyOf": [
214
+ {
215
+ "type": "string",
216
+ "const": "xai_x_search"
217
+ },
218
+ {
219
+ "type": "string",
220
+ "const": "xai_web_search"
221
+ }
222
+ ]
223
+ }
224
+ },
225
+ "additionalProperties": false
153
226
  }
154
227
  ]
155
228
  }
@@ -147,6 +147,14 @@
147
147
  {
148
148
  "type": "string",
149
149
  "const": "deepseek"
150
+ },
151
+ {
152
+ "type": "string",
153
+ "const": "xai_x_search"
154
+ },
155
+ {
156
+ "type": "string",
157
+ "const": "xai_web_search"
150
158
  }
151
159
  ]
152
160
  }
@@ -217,6 +225,14 @@
217
225
  {
218
226
  "type": "string",
219
227
  "const": "deepseek"
228
+ },
229
+ {
230
+ "type": "string",
231
+ "const": "xai_x_search"
232
+ },
233
+ {
234
+ "type": "string",
235
+ "const": "xai_web_search"
220
236
  }
221
237
  ]
222
238
  }
@@ -310,6 +326,14 @@
310
326
  {
311
327
  "type": "string",
312
328
  "const": "deepseek"
329
+ },
330
+ {
331
+ "type": "string",
332
+ "const": "xai_x_search"
333
+ },
334
+ {
335
+ "type": "string",
336
+ "const": "xai_web_search"
313
337
  }
314
338
  ]
315
339
  }
@@ -387,6 +411,14 @@
387
411
  {
388
412
  "type": "string",
389
413
  "const": "deepseek"
414
+ },
415
+ {
416
+ "type": "string",
417
+ "const": "xai_x_search"
418
+ },
419
+ {
420
+ "type": "string",
421
+ "const": "xai_web_search"
390
422
  }
391
423
  ]
392
424
  }
@@ -543,6 +575,14 @@
543
575
  {
544
576
  "type": "string",
545
577
  "const": "deepseek"
578
+ },
579
+ {
580
+ "type": "string",
581
+ "const": "xai_x_search"
582
+ },
583
+ {
584
+ "type": "string",
585
+ "const": "xai_web_search"
546
586
  }
547
587
  ]
548
588
  }
@@ -613,6 +653,14 @@
613
653
  {
614
654
  "type": "string",
615
655
  "const": "deepseek"
656
+ },
657
+ {
658
+ "type": "string",
659
+ "const": "xai_x_search"
660
+ },
661
+ {
662
+ "type": "string",
663
+ "const": "xai_web_search"
616
664
  }
617
665
  ]
618
666
  }
@@ -706,6 +754,14 @@
706
754
  {
707
755
  "type": "string",
708
756
  "const": "deepseek"
757
+ },
758
+ {
759
+ "type": "string",
760
+ "const": "xai_x_search"
761
+ },
762
+ {
763
+ "type": "string",
764
+ "const": "xai_web_search"
709
765
  }
710
766
  ]
711
767
  }
@@ -783,6 +839,14 @@
783
839
  {
784
840
  "type": "string",
785
841
  "const": "deepseek"
842
+ },
843
+ {
844
+ "type": "string",
845
+ "const": "xai_x_search"
846
+ },
847
+ {
848
+ "type": "string",
849
+ "const": "xai_web_search"
786
850
  }
787
851
  ]
788
852
  }
@@ -987,6 +1051,14 @@
987
1051
  {
988
1052
  "type": "string",
989
1053
  "const": "deepseek"
1054
+ },
1055
+ {
1056
+ "type": "string",
1057
+ "const": "xai_x_search"
1058
+ },
1059
+ {
1060
+ "type": "string",
1061
+ "const": "xai_web_search"
990
1062
  }
991
1063
  ]
992
1064
  }
@@ -1057,6 +1129,14 @@
1057
1129
  {
1058
1130
  "type": "string",
1059
1131
  "const": "deepseek"
1132
+ },
1133
+ {
1134
+ "type": "string",
1135
+ "const": "xai_x_search"
1136
+ },
1137
+ {
1138
+ "type": "string",
1139
+ "const": "xai_web_search"
1060
1140
  }
1061
1141
  ]
1062
1142
  }
@@ -1150,6 +1230,14 @@
1150
1230
  {
1151
1231
  "type": "string",
1152
1232
  "const": "deepseek"
1233
+ },
1234
+ {
1235
+ "type": "string",
1236
+ "const": "xai_x_search"
1237
+ },
1238
+ {
1239
+ "type": "string",
1240
+ "const": "xai_web_search"
1153
1241
  }
1154
1242
  ]
1155
1243
  }
@@ -1227,6 +1315,14 @@
1227
1315
  {
1228
1316
  "type": "string",
1229
1317
  "const": "deepseek"
1318
+ },
1319
+ {
1320
+ "type": "string",
1321
+ "const": "xai_x_search"
1322
+ },
1323
+ {
1324
+ "type": "string",
1325
+ "const": "xai_web_search"
1230
1326
  }
1231
1327
  ]
1232
1328
  }
@@ -1437,6 +1533,14 @@
1437
1533
  {
1438
1534
  "type": "string",
1439
1535
  "const": "deepseek"
1536
+ },
1537
+ {
1538
+ "type": "string",
1539
+ "const": "xai_x_search"
1540
+ },
1541
+ {
1542
+ "type": "string",
1543
+ "const": "xai_web_search"
1440
1544
  }
1441
1545
  ]
1442
1546
  }