@scoheart/x-search-mcp 0.4.0 → 0.6.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/.env.example +7 -10
- package/README.md +28 -16
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/TOOL.md +57 -78
- package/dist/evidence-licenses.txt +791 -0
- package/dist/evidence.html +170 -0
- package/dist/package.json +10 -3
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.js +6 -11
- package/dist/src/auth.js.map +1 -1
- package/dist/src/call-log.d.ts +5 -4
- package/dist/src/call-log.d.ts.map +1 -1
- package/dist/src/call-log.js +38 -29
- package/dist/src/call-log.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +26 -19
- package/dist/src/cli.js.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +12 -16
- package/dist/src/config.js.map +1 -1
- package/dist/src/device-login.d.ts +15 -41
- package/dist/src/device-login.d.ts.map +1 -1
- package/dist/src/device-login.js +101 -63
- package/dist/src/device-login.js.map +1 -1
- package/dist/src/events.d.ts +16 -0
- package/dist/src/events.d.ts.map +1 -0
- package/dist/src/events.js +128 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/evidence-app.d.ts +4 -0
- package/dist/src/evidence-app.d.ts.map +1 -0
- package/dist/src/evidence-app.js +17 -0
- package/dist/src/evidence-app.js.map +1 -0
- package/dist/src/http-server.d.ts +1 -0
- package/dist/src/http-server.d.ts.map +1 -1
- package/dist/src/http-server.js +6 -4
- package/dist/src/http-server.js.map +1 -1
- package/dist/src/http.d.ts +12 -15
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +78 -118
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/multi-user/service.d.ts.map +1 -1
- package/dist/src/multi-user/service.js +2 -1
- package/dist/src/multi-user/service.js.map +1 -1
- package/dist/src/search-input.d.ts +5 -17
- package/dist/src/search-input.d.ts.map +1 -1
- package/dist/src/search-input.js +5 -8
- package/dist/src/search-input.js.map +1 -1
- package/dist/src/search-response.d.ts +25 -5
- package/dist/src/search-response.d.ts.map +1 -1
- package/dist/src/search-response.js +97 -94
- package/dist/src/search-response.js.map +1 -1
- package/dist/src/search.d.ts +6 -3
- package/dist/src/search.d.ts.map +1 -1
- package/dist/src/search.js +131 -184
- package/dist/src/search.js.map +1 -1
- package/dist/src/server.d.ts +7 -10
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +109 -95
- package/dist/src/server.js.map +1 -1
- package/dist/src/tool-contract.d.ts +159 -126
- package/dist/src/tool-contract.d.ts.map +1 -1
- package/dist/src/tool-contract.js +78 -73
- package/dist/src/tool-contract.js.map +1 -1
- package/dist/src/types.d.ts +7 -37
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/watch-cli.d.ts +2 -0
- package/dist/src/watch-cli.d.ts.map +1 -0
- package/dist/src/watch-cli.js +41 -0
- package/dist/src/watch-cli.js.map +1 -0
- package/dist/src/watch-store.d.ts +41 -0
- package/dist/src/watch-store.d.ts.map +1 -0
- package/dist/src/watch-store.js +171 -0
- package/dist/src/watch-store.js.map +1 -0
- package/dist/ui/evidence.d.ts +2 -0
- package/dist/ui/evidence.d.ts.map +1 -0
- package/dist/ui/evidence.js +150 -0
- package/dist/ui/evidence.js.map +1 -0
- package/docs/events-and-apps.md +40 -0
- package/examples/codex.toml +6 -7
- package/examples/mcp.json +2 -6
- package/package.json +10 -3
- package/server.json +34 -0
- package/src/auth.ts +6 -11
- package/src/call-log.ts +39 -30
- package/src/cli.ts +26 -19
- package/src/config.ts +11 -13
- package/src/device-login.ts +107 -71
- package/src/events.ts +124 -0
- package/src/evidence-app.ts +19 -0
- package/src/http-server.ts +7 -4
- package/src/http.ts +83 -162
- package/src/index.ts +1 -0
- package/src/multi-user/service.ts +2 -1
- package/src/search-input.ts +5 -9
- package/src/search-response.ts +90 -95
- package/src/search.ts +126 -180
- package/src/server.ts +115 -104
- package/src/tool-contract.ts +82 -76
- package/src/types.ts +8 -40
- package/src/watch-cli.ts +35 -0
- package/src/watch-store.ts +182 -0
- package/tsconfig.json +2 -1
package/dist/src/search.js
CHANGED
|
@@ -1,215 +1,162 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
|
+
import { abortError, HttpError, sendHttpRequest } from './http.js';
|
|
2
3
|
import { loadConfig } from './config.js';
|
|
3
4
|
import { writeCallLog } from './call-log.js';
|
|
4
5
|
import { getValidOAuthAccessToken, forceRefreshToken, oauthRequired } from './auth.js';
|
|
5
6
|
import { validateSearchParams } from './search-input.js';
|
|
6
7
|
import { normalizeSearchResponse } from './search-response.js';
|
|
7
8
|
export { validateCalendarDate, validateAndNormalizeHandles, validateSearchParams } from './search-input.js';
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
return
|
|
11
|
-
code:
|
|
12
|
-
|
|
13
|
-
status: err?.status ?? null,
|
|
14
|
-
};
|
|
9
|
+
const endpoint = 'https://api.x.ai/v1/responses';
|
|
10
|
+
function logError(error) {
|
|
11
|
+
return error instanceof HttpError
|
|
12
|
+
? { code: error.code, message: error.message, status: error.status }
|
|
13
|
+
: { code: 'SEARCH_ERROR', message: 'The search could not be completed.', status: null };
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
return {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
function untilAborted(task, signal) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const abort = () => reject(abortError(signal));
|
|
18
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
19
|
+
task.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));
|
|
20
|
+
if (signal.aborted)
|
|
21
|
+
abort();
|
|
22
|
+
});
|
|
22
23
|
}
|
|
23
|
-
/**
|
|
24
|
-
export async function executeSearch(rawParams,
|
|
24
|
+
/** One time budget covers key lookup, any credential refresh, rate limiting and response reads. */
|
|
25
|
+
export async function executeSearch(rawParams, options = {}) {
|
|
26
|
+
const started = performance.now();
|
|
27
|
+
const params = validateSearchParams(rawParams);
|
|
28
|
+
const managed = Boolean(options.resolveApiKey);
|
|
29
|
+
const config = loadConfig({ managed });
|
|
25
30
|
const startedAt = new Date().toISOString();
|
|
26
|
-
const
|
|
31
|
+
const deadline = started + config.deadlineMs;
|
|
32
|
+
const budget = new AbortController();
|
|
33
|
+
const deadlineError = new HttpError('SEARCH_DEADLINE_EXCEEDED', 'The search exceeded its total time budget.');
|
|
34
|
+
const timer = setTimeout(() => budget.abort(deadlineError), Math.max(0, deadline - performance.now()));
|
|
35
|
+
const signal = options.signal ? AbortSignal.any([options.signal, budget.signal]) : budget.signal;
|
|
36
|
+
function checkBudget() {
|
|
37
|
+
if (!signal.aborted && performance.now() >= deadline)
|
|
38
|
+
budget.abort(deadlineError);
|
|
39
|
+
if (signal.aborted)
|
|
40
|
+
throw abortError(signal);
|
|
41
|
+
}
|
|
42
|
+
const { query, detail, ...filters } = params;
|
|
43
|
+
const body = {
|
|
44
|
+
model: config.model,
|
|
45
|
+
input: [{ role: 'user', content: query }],
|
|
46
|
+
tools: [{ type: 'x_search', ...filters }],
|
|
47
|
+
store: false,
|
|
48
|
+
max_turns: config.maxTurns,
|
|
49
|
+
...(config.reasoningEffort ? { reasoning: { effort: config.reasoningEffort } } : {}),
|
|
50
|
+
};
|
|
51
|
+
const serialized = JSON.stringify(body);
|
|
27
52
|
const attempts = [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
const mode = options.authMode ?? config.authMode;
|
|
54
|
+
const usesOAuth = !managed && (mode === 'oauth' || (mode === 'auto' && !config.apiKey));
|
|
55
|
+
const credentialSource = usesOAuth ? 'oauth' : 'api_key';
|
|
56
|
+
let failure = null;
|
|
57
|
+
let xSearchCalls = null;
|
|
58
|
+
function waitForCredential(task) {
|
|
59
|
+
// A submitted refresh can rotate the token. Let it persist under the lock
|
|
60
|
+
// while freeing the search caller on timeout or disconnection.
|
|
61
|
+
options.trackCleanup?.(task);
|
|
62
|
+
return untilAborted(task, signal);
|
|
63
|
+
}
|
|
64
|
+
async function post(credential) {
|
|
65
|
+
checkBudget();
|
|
36
66
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
endpoint: XAI_RESPONSES_URL,
|
|
41
|
-
model,
|
|
42
|
-
query,
|
|
43
|
-
credential_source: credentialSource,
|
|
44
|
-
billing_mode: billingMode,
|
|
45
|
-
request: requestBody,
|
|
46
|
-
attempts,
|
|
47
|
-
outcome,
|
|
48
|
-
error,
|
|
67
|
+
const response = await sendHttpRequest({
|
|
68
|
+
url: endpoint, method: 'POST', body: serialized, signal, maxResponseBytes: config.maxResponseBytes,
|
|
69
|
+
headers: { Authorization: `Bearer ${credential}`, 'Content-Type': 'application/json' },
|
|
49
70
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return logFile;
|
|
71
|
+
attempts.push({ http_status: response.status, raw_response: config.logMode === 'debug' ? response.data : null, error: null });
|
|
72
|
+
return response;
|
|
53
73
|
}
|
|
54
|
-
catch (
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
catch (error) {
|
|
75
|
+
const info = logError(error);
|
|
76
|
+
attempts.push({
|
|
77
|
+
http_status: info.status,
|
|
78
|
+
raw_response: config.logMode === 'debug' && error instanceof HttpError ? error.data ?? null : null,
|
|
79
|
+
error: info,
|
|
80
|
+
});
|
|
81
|
+
throw error;
|
|
57
82
|
}
|
|
58
|
-
}
|
|
83
|
+
}
|
|
59
84
|
try {
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (resolveApiKey) {
|
|
68
|
-
token = await resolveApiKey();
|
|
69
|
-
if (!token)
|
|
70
|
-
throw new HttpError('XAI_KEY_REQUIRED', 'Bind your xAI API key in Settings.', 409);
|
|
71
|
-
credentialSource = 'api_key';
|
|
72
|
-
billingMode = 'api_metered';
|
|
73
|
-
}
|
|
74
|
-
else if (effectiveAuthMode === 'api_key' || (effectiveAuthMode === 'auto' && config.apiKey)) {
|
|
75
|
-
if (!config.apiKey) {
|
|
76
|
-
throw new Error('Credential error: API key is required when auth_mode is "api_key", but neither XAI_API_KEY nor XAI_API_KEY_FILE was provided.');
|
|
77
|
-
}
|
|
78
|
-
token = config.apiKey;
|
|
79
|
-
credentialSource = 'api_key';
|
|
80
|
-
billingMode = 'api_metered';
|
|
85
|
+
checkBudget();
|
|
86
|
+
const credential = options.resolveApiKey ? await waitForCredential(options.resolveApiKey())
|
|
87
|
+
: usesOAuth ? await waitForCredential(getValidOAuthAccessToken(signal))
|
|
88
|
+
: config.apiKey;
|
|
89
|
+
if (!credential) {
|
|
90
|
+
throw managed ? new HttpError('XAI_KEY_REQUIRED', 'Bind an xAI API key in Settings.', 409)
|
|
91
|
+
: new HttpError('API_KEY_REQUIRED', 'Configure XAI_API_KEY or XAI_API_KEY_FILE.');
|
|
81
92
|
}
|
|
82
|
-
|
|
83
|
-
token = await getValidOAuthAccessToken(signal);
|
|
84
|
-
credentialSource = 'oauth';
|
|
85
|
-
billingMode = 'subscription_oauth';
|
|
86
|
-
}
|
|
87
|
-
const toolConfig = {
|
|
88
|
-
type: 'x_search',
|
|
89
|
-
};
|
|
90
|
-
if (validated.allowed_x_handles)
|
|
91
|
-
toolConfig.allowed_x_handles = validated.allowed_x_handles;
|
|
92
|
-
if (validated.excluded_x_handles)
|
|
93
|
-
toolConfig.excluded_x_handles = validated.excluded_x_handles;
|
|
94
|
-
if (validated.from_date)
|
|
95
|
-
toolConfig.from_date = validated.from_date;
|
|
96
|
-
if (validated.to_date)
|
|
97
|
-
toolConfig.to_date = validated.to_date;
|
|
98
|
-
if (validated.enable_image_understanding !== undefined)
|
|
99
|
-
toolConfig.enable_image_understanding = validated.enable_image_understanding;
|
|
100
|
-
if (validated.enable_video_understanding !== undefined)
|
|
101
|
-
toolConfig.enable_video_understanding = validated.enable_video_understanding;
|
|
102
|
-
requestBody = {
|
|
103
|
-
model: config.model,
|
|
104
|
-
input: [
|
|
105
|
-
{
|
|
106
|
-
role: 'user',
|
|
107
|
-
content: validated.query,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
tools: [toolConfig],
|
|
111
|
-
store: false,
|
|
112
|
-
max_turns: config.maxTurns,
|
|
113
|
-
};
|
|
114
|
-
if (config.reasoningEffort) {
|
|
115
|
-
requestBody.reasoning = {
|
|
116
|
-
effort: config.reasoningEffort,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const serializedRequest = JSON.stringify(requestBody);
|
|
120
|
-
const requestWithCredential = (credential, retries) => sendHttpRequest({
|
|
121
|
-
url: XAI_RESPONSES_URL,
|
|
122
|
-
method: 'POST',
|
|
123
|
-
headers: {
|
|
124
|
-
Authorization: `Bearer ${credential}`,
|
|
125
|
-
'Content-Type': 'application/json',
|
|
126
|
-
},
|
|
127
|
-
body: serializedRequest,
|
|
128
|
-
signal,
|
|
129
|
-
timeoutSeconds: config.timeoutSeconds,
|
|
130
|
-
retries,
|
|
131
|
-
});
|
|
132
|
-
let httpRes;
|
|
93
|
+
let response;
|
|
133
94
|
try {
|
|
134
|
-
|
|
135
|
-
httpRes = await requestWithCredential(token, managed ? 0 : config.retries);
|
|
95
|
+
response = await post(credential);
|
|
136
96
|
}
|
|
137
|
-
catch (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (!(error instanceof HttpError))
|
|
99
|
+
throw error;
|
|
100
|
+
if (usesOAuth && error.status === 401) {
|
|
101
|
+
const fresh = await waitForCredential(forceRefreshToken(credential, signal));
|
|
102
|
+
try {
|
|
103
|
+
response = await post(fresh);
|
|
104
|
+
}
|
|
105
|
+
catch (retryError) {
|
|
106
|
+
if (retryError instanceof HttpError && retryError.status === 401) {
|
|
107
|
+
throw oauthRequired('xAI rejected the Grok OAuth credential after refresh.', 401);
|
|
108
|
+
}
|
|
109
|
+
throw retryError;
|
|
149
110
|
}
|
|
150
|
-
|
|
111
|
+
}
|
|
112
|
+
else if (!managed && error.status === 429 && error.retryAfterMs !== undefined
|
|
113
|
+
&& error.retryAfterMs < deadline - performance.now()) {
|
|
114
|
+
if (error.retryAfterMs > 0)
|
|
115
|
+
await delay(error.retryAfterMs, undefined, { signal });
|
|
116
|
+
response = await post(credential);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw error;
|
|
151
120
|
}
|
|
152
121
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!rawData || typeof rawData !== 'object' || Array.isArray(rawData)) {
|
|
157
|
-
const invalid = new HttpError('SEARCH_ERROR', 'Upstream xAI returned empty or unparseable response data.');
|
|
158
|
-
attempt.error = errorInfo(invalid);
|
|
159
|
-
throw invalid;
|
|
122
|
+
const data = response.data;
|
|
123
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
124
|
+
throw new HttpError('INVALID_UPSTREAM_RESPONSE', 'xAI did not return a search response object.', response.status);
|
|
160
125
|
}
|
|
161
|
-
const upstream =
|
|
126
|
+
const upstream = data;
|
|
162
127
|
if (upstream.status === 'failed' || upstream.error) {
|
|
163
|
-
|
|
164
|
-
attempt.error = errorInfo(upstreamError);
|
|
165
|
-
throw upstreamError;
|
|
166
|
-
}
|
|
167
|
-
const response = normalizeSearchResponse(upstream);
|
|
168
|
-
const hasCitations = response.citations.length > 0;
|
|
169
|
-
const degraded = !hasCitations;
|
|
170
|
-
const degradedReason = degraded ? 'No source citations returned by upstream x_search' : null;
|
|
171
|
-
if (!response.answer && !hasCitations) {
|
|
172
|
-
const empty = new HttpError('SEARCH_ERROR', 'Upstream xAI returned no answer or citations.');
|
|
173
|
-
attempt.error = errorInfo(empty);
|
|
174
|
-
throw empty;
|
|
128
|
+
throw new HttpError('UPSTREAM_SERVER_ERROR', 'xAI reported a failed search.', response.status);
|
|
175
129
|
}
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
|
|
130
|
+
const normalized = normalizeSearchResponse(upstream, detail ?? 'concise');
|
|
131
|
+
if (!normalized.answer && !normalized.sources.length) {
|
|
132
|
+
throw new HttpError('EMPTY_SEARCH_RESPONSE', 'xAI returned no answer or sources.', response.status);
|
|
179
133
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
warnings.push('Result contains no source citations and cannot be treated as grounded search evidence.');
|
|
185
|
-
}
|
|
186
|
-
const result = {
|
|
187
|
-
success: true,
|
|
188
|
-
provider: 'xai',
|
|
189
|
-
tool: 'x_search',
|
|
134
|
+
checkBudget();
|
|
135
|
+
xSearchCalls = normalized.usage.x_search_calls;
|
|
136
|
+
return {
|
|
137
|
+
...normalized,
|
|
190
138
|
model: config.model,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
billing_mode: billingMode,
|
|
194
|
-
...response,
|
|
195
|
-
has_citations: hasCitations,
|
|
196
|
-
degraded,
|
|
197
|
-
degraded_reason: degradedReason,
|
|
198
|
-
warnings,
|
|
199
|
-
log_file: null,
|
|
139
|
+
usage: { ...normalized.usage, requests: attempts.length },
|
|
140
|
+
elapsed_ms: Math.round(performance.now() - started),
|
|
200
141
|
};
|
|
201
|
-
result.log_file = await persist('success', null);
|
|
202
|
-
if (config.logEnabled && !result.log_file) {
|
|
203
|
-
result.warnings.push('Call log could not be written.');
|
|
204
|
-
}
|
|
205
|
-
return result;
|
|
206
142
|
}
|
|
207
|
-
catch (
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
143
|
+
catch (error) {
|
|
144
|
+
const cause = signal.aborted ? abortError(signal) : error;
|
|
145
|
+
failure = logError(cause);
|
|
146
|
+
throw cause;
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
clearTimeout(timer);
|
|
150
|
+
if (config.logMode !== 'off') {
|
|
151
|
+
const log = writeCallLog({
|
|
152
|
+
started_at: startedAt,
|
|
153
|
+
elapsed_ms: Math.round(performance.now() - started),
|
|
154
|
+
endpoint, model: config.model, query, credential_source: credentialSource,
|
|
155
|
+
billing_mode: usesOAuth ? 'subscription_oauth' : 'api_metered',
|
|
156
|
+
request: body, attempts, outcome: failure ? 'error' : 'success', error: failure, x_search_calls: xSearchCalls,
|
|
157
|
+
}).catch(() => null);
|
|
158
|
+
options.trackCleanup?.(log);
|
|
159
|
+
}
|
|
213
160
|
}
|
|
214
161
|
}
|
|
215
162
|
//# sourceMappingURL=search.js.map
|
package/dist/src/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,EAAE,oBA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,KAAK,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,YAAY,CAAC;gBACvB,UAAU,EAAE,SAAS;gBACrB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;gBACnD,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,gBAAgB;gBACzE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,aAAa;gBAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY;aAC9G,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/src/server.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { McpServer, type ServerContext } from '@modelcontextprotocol/server';
|
|
2
|
+
import { type HttpServerOptions, type RunningHttpServer } from './http-server.js';
|
|
2
3
|
import { executeSearch } from './search.js';
|
|
3
4
|
import type { XSearchInput } from './types.js';
|
|
4
|
-
type
|
|
5
|
+
type TrackCleanup = (task: Promise<unknown>) => void;
|
|
6
|
+
type SearchHandler = (params: XSearchInput, context: ServerContext, trackCleanup: TrackCleanup) => ReturnType<typeof executeSearch>;
|
|
5
7
|
export declare function createServer(): McpServer;
|
|
6
8
|
export declare function createStdioServer(): McpServer;
|
|
9
|
+
export declare function startPersonalHttp(options: HttpServerOptions & {
|
|
10
|
+
interactiveLogin?: boolean;
|
|
11
|
+
eventsDatabase?: string;
|
|
12
|
+
}): Promise<RunningHttpServer>;
|
|
7
13
|
export declare function createManagedSearchServer(search: SearchHandler, settingsUrl: string): McpServer;
|
|
8
|
-
/** Compatibility factory for existing consumers. A settings URL selects managed HTTP. */
|
|
9
|
-
export declare function createSearchServer(search: SearchHandler, settingsUrl?: string, deviceLoginEnabled?: boolean): McpServer;
|
|
10
|
-
/** @deprecated Create a fresh server with createServer() for each transport. */
|
|
11
|
-
export declare const server: McpServer;
|
|
12
|
-
/**
|
|
13
|
-
* Launch stdio server.
|
|
14
|
-
* stdout is strictly reserved for JSON-RPC MCP messages.
|
|
15
|
-
* Diagnostic logs are written to stderr.
|
|
16
|
-
*/
|
|
17
14
|
export declare function startStdio(): import("@modelcontextprotocol/server/stdio").StdioServerHandle;
|
|
18
15
|
export {};
|
|
19
16
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/src/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAK7E,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AACrD,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,KAAK,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAIpI,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED,wBAAgB,iBAAiB,IAAI,SAAS,CAE7C;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG;IACnE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuC7B;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,CAE/F;AAiFD,wBAAgB,UAAU,mEAEzB"}
|