@curio-data/mcp-intelli-search 0.18.0 → 0.19.1
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/README.md +27 -18
- package/dist/{chunk-EHXBTGSE.js → chunk-57DS6B3Q.js} +164 -5
- package/dist/{chunk-ZDA2NLLR.js → chunk-V5TY66GM.js} +127 -18
- package/dist/cli.js +118 -28
- package/dist/runtime.js +3 -3
- package/dist/server.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@curio-data/mcp-intelli-search)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](https://github.com/Curio-Data/pi-intelli-search/blob/main/LICENSE)
|
|
9
|
-

|
|
10
10
|
|
|
11
11
|
Intelligent web research for coding agents: search, extract, collate, and cache grounded web context in one tool call.
|
|
12
12
|
|
|
@@ -43,7 +43,7 @@ Choose the installation route for the host:
|
|
|
43
43
|
|
|
44
44
|
The install branches: [`Pi` Native Extension](https://github.com/Curio-Data/pi-intelli-search/blob/main/README.md#pi-native-extension) and [MCP Server](#mcp-server), with host instructions for [Claude Code](#claude-code), [Codex](#codex) and any [Generic MCP Host](#generic-mcp-host).
|
|
45
45
|
|
|
46
|
-
The native extension uses `Pi` settings and authentication.
|
|
46
|
+
The native extension uses `Pi` settings and authentication. Generic MCP registration requires explicit configuration and a workspace; the Codex launcher supplies project and model defaults. Inference uses an OpenRouter key supplied through the configured environment variable or credential file. The MCP server does not read `Pi` settings or credentials.
|
|
47
47
|
|
|
48
48
|
## Contents
|
|
49
49
|
|
|
@@ -100,7 +100,7 @@ The native extension uses `Pi` settings and authentication. The MCP server requi
|
|
|
100
100
|
- An [OpenRouter API key](https://openrouter.ai/keys) with credit for inference. One key covers all three model roles; charges are separate from the host subscription.
|
|
101
101
|
- An existing project folder for the research cache. The server and host must be able to read the same filesystem.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
Generic registration requires an explicit JavaScript Object Notation (JSON) configuration and absolute workspace path. The Codex launcher supplies its working root as the workspace and uses documented model defaults when no per-user configuration exists. The server reads no host credential stores, `Pi` settings or discovered project configuration. Native fetch assets are verified on _Linux_ x86-64; _macOS_ and _Windows_ are not verified. See [Compatibility](#mcp-server-compatibility) for the recorded scope.
|
|
104
104
|
|
|
105
105
|
#### Claude Code
|
|
106
106
|
|
|
@@ -219,17 +219,27 @@ codex plugin marketplace add Curio-Data/pi-intelli-search
|
|
|
219
219
|
codex plugin add intelli-search --marketplace curio-data-plugins
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
After installation, open a [_Bash_](https://www.gnu.org/software/bash/) shell in the project folder whose `.search/` directory will hold research results. Store the OpenRouter key with the following commands from the plugin's 0.19 release line. The key travels through standard input, not process arguments or configuration JSON:
|
|
223
223
|
|
|
224
224
|
```bash
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
read -r -s -p 'OpenRouter API key: ' OPENROUTER_API_KEY
|
|
226
|
+
printf '\n'
|
|
227
|
+
printf '%s\n' "$OPENROUTER_API_KEY" | \
|
|
228
|
+
npx -y --package @curio-data/mcp-intelli-search@0.19 \
|
|
229
|
+
mcp-intelli-search setup
|
|
230
|
+
unset OPENROUTER_API_KEY
|
|
227
231
|
codex
|
|
228
232
|
```
|
|
229
233
|
|
|
230
|
-
|
|
234
|
+
Setup creates `${XDG_CONFIG_HOME:-$HOME/.config}/mcp-intelli-search/config.json` when absent and stores the key separately as `openrouter.key` with user-only permissions. Existing model and tuning selections are preserved. Setup adds a missing `apiKeyFile` selection and honours an existing custom credential path.
|
|
235
|
+
|
|
236
|
+
The next tool call reads a new or replacement key without a restart when the loaded configuration selects that path. Restart after changing loaded configuration. An exported `OPENROUTER_API_KEY` remains an alternative and takes precedence over the file. Confirm that setup prints `Setup complete.` before starting or using Codex.
|
|
237
|
+
|
|
238
|
+
The plugin starts with `--host codex`, uses the Codex working root as its workspace and needs no path or credential exports. Legacy `INTELLI_SEARCH_CONFIG` and `INTELLI_SEARCH_WORKSPACE` exports are ignored in this mode; explicit command-line selections remain available. A home or filesystem-root working directory produces an actionable `WORKSPACE` tool error instead of an accidental shared cache; restart Codex from the project or with `--cd <project>`. Its four tools appear even before setup. A missing key produces an actionable `CONFIGURATION` tool error rather than a server startup failure. Customise the per-user `config.json` to override the documented default models or tuning, then restart Codex.
|
|
239
|
+
|
|
240
|
+
In the session, ask: “Use intelli_search to find the current TypeScript release and cite the official source.” Confirm a successful MCP tool call and an answer with sources. `codex mcp list` alone does not start the server or prove inference. The `/mcp` status `Auth: Unsupported` is expected because this stdio server does not use the OAuth authorization framework; it does not describe the OpenRouter credential.
|
|
231
241
|
|
|
232
|
-
|
|
242
|
+
The installed `intelli-search` skill covers configuration and unattended tool approval; see the [compatibility matrix](https://github.com/Curio-Data/pi-intelli-search/blob/main/docs/COMPATIBILITY.md#host-plugins) for verified host behaviour.
|
|
233
243
|
|
|
234
244
|
<a id="route-a-direct-mcp-configuration"></a>
|
|
235
245
|
#### Generic MCP Host
|
|
@@ -358,12 +368,11 @@ This reference applies to `@curio-data/mcp-intelli-search` only. Installation ro
|
|
|
358
368
|
### Requirements
|
|
359
369
|
|
|
360
370
|
- [_Node.js_](https://nodejs.org/) satisfying the `engines` range in the [standalone manifest](https://github.com/Curio-Data/pi-intelli-search/blob/main/packages/mcp/package.json).
|
|
361
|
-
- An existing
|
|
362
|
-
-
|
|
363
|
-
- A separately billed OpenRouter API key supplied through a named environment variable before constructing the runtime. Restart the runtime after changing credentials; it snapshots the environment.
|
|
371
|
+
- An existing absolute workspace directory and JSON configuration file for generic registration or direct runtime use. Codex mode supplies its workspace and model defaults.
|
|
372
|
+
- A separately billed OpenRouter API key supplied through a named environment variable before constructing the runtime, or through `setup` and a user-only credential file. Environment changes require a runtime restart; each operation rereads the selected credential file, so a new or replacement key takes effect on the next operation.
|
|
364
373
|
- A platform supported by [_wreq-js_](https://github.com/sqdshguy/wreq-js), the browser-fingerprint fetch dependency. The installation gate exercises its native assets on the running platform; it does not establish support for other platforms.
|
|
365
374
|
|
|
366
|
-
The package neither reads host credential stores nor loads project configuration automatically. Native `Pi` settings, authentication, providers and defaults remain independent.
|
|
375
|
+
The package neither reads host credential stores nor loads project configuration automatically. Codex mode reads only its documented per-user configuration and credential paths. Native `Pi` settings, authentication, providers and defaults remain independent.
|
|
367
376
|
|
|
368
377
|
### Verification
|
|
369
378
|
|
|
@@ -379,7 +388,7 @@ Use the same configuration and workspace as the registered server. If a project-
|
|
|
379
388
|
|
|
380
389
|
### Serving the Protocol
|
|
381
390
|
|
|
382
|
-
An invocation without `--check-config` validates the
|
|
391
|
+
An invocation without `--check-config` validates the selected workspace, then serves the four canonical tools (`intelli_search`, `intelli_extract`, `intelli_collate`, `intelli_research`) over stdio until the input stream closes. An explicitly selected missing, unreadable or invalid configuration file does not prevent connection: each tool call returns an actionable `CONFIGURATION` error, and the server rereads the file on each call until it loads. Repair the file and call again. Once loaded, configuration remains fixed until restart. Generic registration rejects missing launcher arguments and invalid workspaces at startup; `--check-config` remains strict. Codex mode selects its working root and built-in defaults when its per-user configuration is absent. Serving performs no inference at startup; credentials are only required when an operation runs.
|
|
383
392
|
|
|
384
393
|
- **Registration and Schemas.** Tool names and JSON input schemas mirror the native `Pi` tools verbatim; descriptions adapt the native guidance for protocol clients (host-neutral cache wording, embedded `focusPrompt` and breadth guidance), because the protocol offers no separate guidance channel. Invalid tool arguments are reported as tool errors (`isError` results), matching the software development kit (SDK) distinction between malformed protocol requests and invalid arguments.
|
|
385
394
|
- **Results.** Successful calls return the complete operation text both as text content and as `structuredContent.text`, alongside `outcome` and `details`. Hosts that prefer the structured representation receive the same answer, sources and cache suggestions. The duplication is intentional for host compatibility; a host that forwards both representations can consume extra context. Degraded research (`no-links`, `fetch-failed`, `extraction-failed`) remains a normal result. Execution failures return `isError` results tagged with the safe `StandaloneError` category rather than raw provider causes.
|
|
@@ -393,11 +402,11 @@ Startup diagnostics go to standard error. The SDK version range is declared in `
|
|
|
393
402
|
|
|
394
403
|
### Configuration
|
|
395
404
|
|
|
396
|
-
Select the configuration with `--config FILE` or `INTELLI_SEARCH_CONFIG`. Select the workspace with `--workspace ABSOLUTE_DIRECTORY` or `INTELLI_SEARCH_WORKSPACE`. Command-line values take precedence. Relative workspace paths are rejected; existing workspace symlinks are canonicalised.
|
|
405
|
+
Select the configuration with `--config FILE` or `INTELLI_SEARCH_CONFIG`. Select the workspace with `--workspace ABSOLUTE_DIRECTORY` or `INTELLI_SEARCH_WORKSPACE`. Command-line values take precedence. Relative workspace paths are rejected; existing workspace symlinks are canonicalised. `--host codex` instead selects the working root and `${XDG_CONFIG_HOME:-$HOME/.config}/mcp-intelli-search/config.json`; explicit selections still take precedence.
|
|
397
406
|
|
|
398
|
-
The [minimal configuration](#create-the-configuration) explicitly selects OpenRouter for every role; add an optional `tuning` object (for example `"cacheDir": ".search"`) beside `providers` and `models`.
|
|
407
|
+
The [minimal configuration](#create-the-configuration) explicitly selects OpenRouter for every role; add an optional `tuning` object (for example `"cacheDir": ".search"`) beside `providers` and `models`. Generic registration has no model defaults. Codex mode uses `perplexity/sonar` for search and `minimax/minimax-m3` for extraction and collation when no per-user file exists.
|
|
399
408
|
|
|
400
|
-
Only `providers`, `models` and optional `tuning` are accepted at the top level. All three model roles are required. The provider object accepts
|
|
409
|
+
Only `providers`, `models` and optional `tuning` are accepted at the top level. All three model roles are required in a configuration file. The provider object accepts `apiKeyEnv`, an environment-variable name rather than a key value, and optional `apiKeyFile`, an absolute path to a separately stored key. The environment variable takes precedence. Setup writes the key with user-only permissions; each file read rejects symbolic links, hard links, other owners and group or world access on platforms with POSIX permissions. Setup manages the default per-user configuration. For a separately selected generic configuration, set `providers.openrouter.apiKeyFile` to the credential path printed by setup and restart after changing loaded configuration. The initial provider scope is OpenRouter at its fixed `https://openrouter.ai/api/v1` endpoint; custom endpoints, proxy settings, provider fallback and dynamic router model identifiers are not accepted.
|
|
401
410
|
|
|
402
411
|
Configuration loading does not require working credentials. Each operation validates its required model roles against OpenRouter's model catalogue before inference. Full research validates all three roles first. Validation checks exact identifiers, text input/output, advertised reasoning efforts when supplied, and tool support for an enabled search tool. Catalogue lookup is bounded and cancellable. It establishes advertised capabilities, not account credit, per-key model access or future provider availability; inference errors remain possible.
|
|
403
412
|
|
|
@@ -508,9 +517,9 @@ Every startup failure is diagnostic-only and lands on standard error; standard o
|
|
|
508
517
|
| Configuration rejected with an unknown-key or range error | The loader is strict: unknown keys, invalid types and out-of-range values fail validation. Correct the configuration and call again if it has not yet loaded. The [Tuning](#tuning) table lists accepted keys and ranges. |
|
|
509
518
|
| Tools never appear in the host | Check absent launcher arguments, an unusable workspace or an unsafe cache. Read the host's MCP server logs for the standard-error diagnostic. Claude Code can cache a startup failure from an older server: try `/mcp` reconnect, then restart ([evidence and limits](https://github.com/Curio-Data/pi-intelli-search/blob/main/docs/COMPATIBILITY.md#claude-code-evidence-and-limits)). A connected server still needs a successful tool call to verify inference. |
|
|
510
519
|
| `CONFIGURATION` persists after the file is repaired | A file that has not yet loaded is reread on the next call; once loaded, configuration changes require a restart. |
|
|
511
|
-
| Diagnostic names a missing credential environment variable | Supply the named variable
|
|
520
|
+
| Diagnostic names a missing credential environment variable | Supply the named variable before host launch. Codex users can instead run `mcp-intelli-search setup` with the key on standard input. For a separately selected configuration, set `providers.openrouter.apiKeyFile` to the printed credential path. Environment or loaded-configuration changes require restart; file credentials are reread on each call. |
|
|
512
521
|
| Catalogue preflight names a model role or capability | Correct the model identifier or required capabilities using [Configuration](#configuration). Read the diagnostic; catalogue lookup failures are not proof of invalid credentials. Restart after changing loaded model selections. |
|
|
513
|
-
| `PROVIDER` reports authentication, access, credit or transport failure | Follow the specific diagnostic: check credentials, model access, account credit or connectivity. Restart after changing
|
|
522
|
+
| `PROVIDER` reports authentication, access, credit or transport failure | Follow the specific diagnostic: check credentials, model access, account credit or connectivity. Restart after changing an environment credential. For the default Codex configuration, replace a stored key with `setup` and call again. For a separately selected configuration, replace the file named by `providers.openrouter.apiKeyFile`, or select setup's printed path and restart. The category alone does not identify a rejected key. |
|
|
514
523
|
| Repeated `429` retries | Tune pacing to observed account/provider limits. For an observed limit of approximately 0.33 requests per second, try `minRequestIntervalMs: 3000` and `extractionConcurrency: 2`; adjust retry attempts as needed. Raise `llmTimeoutMs` only when its model-call timer expires. |
|
|
515
524
|
| Cache paths unreadable from the host | The host must share the server's filesystem. Sandboxed or remote hosts cannot read local cache paths; run the server where the host can read the workspace. |
|
|
516
525
|
|
|
@@ -223,8 +223,8 @@ async function resolveWorkspace(workspace) {
|
|
|
223
223
|
return canonical;
|
|
224
224
|
}
|
|
225
225
|
async function parseConfig(value, workspace) {
|
|
226
|
-
const { apiKeyEnv, settings } = parseDocument(value);
|
|
227
|
-
return freeze({ workspace: await resolveWorkspace(workspace), apiKeyEnv, settings });
|
|
226
|
+
const { apiKeyEnv, apiKeyFile, settings } = parseDocument(value);
|
|
227
|
+
return freeze({ workspace: await resolveWorkspace(workspace), apiKeyEnv, apiKeyFile, settings });
|
|
228
228
|
}
|
|
229
229
|
function parseDocument(value) {
|
|
230
230
|
const root = object(value, "configuration");
|
|
@@ -232,10 +232,13 @@ function parseDocument(value) {
|
|
|
232
232
|
const providers = object(root.providers, "providers");
|
|
233
233
|
keys(providers, ["openrouter"], "providers");
|
|
234
234
|
const provider = object(providers.openrouter, "providers.openrouter");
|
|
235
|
-
keys(provider, ["apiKeyEnv"], "providers.openrouter");
|
|
235
|
+
keys(provider, ["apiKeyEnv", "apiKeyFile"], "providers.openrouter");
|
|
236
236
|
const apiKeyEnv = text(provider.apiKeyEnv, "providers.openrouter.apiKeyEnv");
|
|
237
237
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(apiKeyEnv))
|
|
238
238
|
throw new Error("apiKeyEnv must name an environment variable, not contain a credential");
|
|
239
|
+
const apiKeyFile = provider.apiKeyFile === void 0 ? void 0 : text(provider.apiKeyFile, "providers.openrouter.apiKeyFile");
|
|
240
|
+
if (apiKeyFile !== void 0 && !isAbsolute(apiKeyFile))
|
|
241
|
+
throw new Error("apiKeyFile must be an absolute path, not contain a credential");
|
|
239
242
|
const models = object(root.models, "models");
|
|
240
243
|
keys(models, ["search", "extract", "collate"], "models");
|
|
241
244
|
const tuning = root.tuning === void 0 ? {} : object(root.tuning, "tuning");
|
|
@@ -283,7 +286,7 @@ function parseDocument(value) {
|
|
|
283
286
|
throw new Error(
|
|
284
287
|
"Search requires an explicitly enabled searchWebSearch tool or a supported Sonar search model"
|
|
285
288
|
);
|
|
286
|
-
return { apiKeyEnv, settings };
|
|
289
|
+
return { apiKeyEnv, apiKeyFile, settings };
|
|
287
290
|
}
|
|
288
291
|
async function loadConfig(file, workspace) {
|
|
289
292
|
const path = resolve(file).replace(/[\x00-\x1f\x7f]/g, "?");
|
|
@@ -323,10 +326,161 @@ async function loadConfig(file, workspace) {
|
|
|
323
326
|
return freeze({
|
|
324
327
|
workspace: await resolveWorkspace(workspace),
|
|
325
328
|
apiKeyEnv: parsed.apiKeyEnv,
|
|
329
|
+
apiKeyFile: parsed.apiKeyFile,
|
|
326
330
|
settings: parsed.settings
|
|
327
331
|
});
|
|
328
332
|
}
|
|
329
333
|
|
|
334
|
+
// packages/mcp/src/errors.ts
|
|
335
|
+
var StandaloneError = class extends Error {
|
|
336
|
+
constructor(code, message) {
|
|
337
|
+
super(message);
|
|
338
|
+
this.code = code;
|
|
339
|
+
this.name = code === "CANCELLED" ? "AbortError" : "StandaloneError";
|
|
340
|
+
}
|
|
341
|
+
code;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
// packages/mcp/src/host.ts
|
|
345
|
+
import { lstat, mkdir, readFile as readFile2, rename, rm, writeFile } from "node:fs/promises";
|
|
346
|
+
import { randomUUID } from "node:crypto";
|
|
347
|
+
import { homedir } from "node:os";
|
|
348
|
+
import { dirname, isAbsolute as isAbsolute2, join } from "node:path";
|
|
349
|
+
function hostPaths(env = process.env) {
|
|
350
|
+
const home = env.HOME || homedir();
|
|
351
|
+
if (!home || !isAbsolute2(home)) throw new Error("A home directory is required");
|
|
352
|
+
const base = env.XDG_CONFIG_HOME && isAbsolute2(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : join(home, ".config");
|
|
353
|
+
const directory = join(base, "mcp-intelli-search");
|
|
354
|
+
return {
|
|
355
|
+
directory,
|
|
356
|
+
config: join(directory, "config.json"),
|
|
357
|
+
credential: join(directory, "openrouter.key")
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function defaultDocument(credential) {
|
|
361
|
+
return {
|
|
362
|
+
providers: {
|
|
363
|
+
openrouter: {
|
|
364
|
+
apiKeyEnv: "OPENROUTER_API_KEY",
|
|
365
|
+
apiKeyFile: credential
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
models: {
|
|
369
|
+
search: { provider: "openrouter", model: "perplexity/sonar" },
|
|
370
|
+
extract: { provider: "openrouter", model: "minimax/minimax-m3" },
|
|
371
|
+
collate: { provider: "openrouter", model: "minimax/minimax-m3" }
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function defaultCodexConfig(workspace, paths) {
|
|
376
|
+
return parseConfig(defaultDocument(paths.credential), workspace);
|
|
377
|
+
}
|
|
378
|
+
function credentialText(source) {
|
|
379
|
+
const value = source.replace(/\r?\n$/, "");
|
|
380
|
+
if (!value || value.length > 4096 || /\s/.test(value))
|
|
381
|
+
throw new Error("OpenRouter credential must be one nonempty line without whitespace");
|
|
382
|
+
return value;
|
|
383
|
+
}
|
|
384
|
+
async function resolveCredential(config, env) {
|
|
385
|
+
const fromEnvironment = env[config.apiKeyEnv];
|
|
386
|
+
if (fromEnvironment) return fromEnvironment;
|
|
387
|
+
if (!config.apiKeyFile) return void 0;
|
|
388
|
+
let source;
|
|
389
|
+
try {
|
|
390
|
+
const metadata = await lstat(config.apiKeyFile);
|
|
391
|
+
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.nlink !== 1)
|
|
392
|
+
throw new StandaloneError(
|
|
393
|
+
"CONFIGURATION",
|
|
394
|
+
"OpenRouter credential file must be one regular, non-linked file"
|
|
395
|
+
);
|
|
396
|
+
if (process.platform !== "win32") {
|
|
397
|
+
if (metadata.uid !== process.getuid?.() || (metadata.mode & 63) !== 0)
|
|
398
|
+
throw new StandaloneError(
|
|
399
|
+
"CONFIGURATION",
|
|
400
|
+
"OpenRouter credential file must be owned by the current user and inaccessible to group and other users; repair it or run mcp-intelli-search setup for the default configuration"
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
source = await readFile2(config.apiKeyFile, "utf8");
|
|
404
|
+
} catch (error) {
|
|
405
|
+
if (error instanceof StandaloneError) throw error;
|
|
406
|
+
if (error.code === "ENOENT") return void 0;
|
|
407
|
+
throw new StandaloneError(
|
|
408
|
+
"CONFIGURATION",
|
|
409
|
+
"OpenRouter credential file is not readable; repair the configured path or run mcp-intelli-search setup for the default configuration"
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
return credentialText(source);
|
|
414
|
+
} catch (error) {
|
|
415
|
+
throw new StandaloneError(
|
|
416
|
+
"CONFIGURATION",
|
|
417
|
+
`${error instanceof Error ? error.message : "Invalid OpenRouter credential"}; replace it or run mcp-intelli-search setup for the default configuration`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
async function writePrivateAtomic(file, source) {
|
|
422
|
+
const directory = dirname(file);
|
|
423
|
+
await mkdir(directory, { recursive: true, mode: 448 });
|
|
424
|
+
const temporary = join(directory, `.${process.pid}.${randomUUID()}.tmp`);
|
|
425
|
+
try {
|
|
426
|
+
await writeFile(temporary, source, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
427
|
+
await rename(temporary, file);
|
|
428
|
+
} finally {
|
|
429
|
+
await rm(temporary, { force: true }).catch(() => {
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async function prepareConfig(paths) {
|
|
434
|
+
let source;
|
|
435
|
+
try {
|
|
436
|
+
source = await readFile2(paths.config, "utf8");
|
|
437
|
+
} catch (error) {
|
|
438
|
+
if (error.code !== "ENOENT") throw error;
|
|
439
|
+
await writePrivateAtomic(
|
|
440
|
+
paths.config,
|
|
441
|
+
`${JSON.stringify(defaultDocument(paths.credential), null, 2)}
|
|
442
|
+
`
|
|
443
|
+
);
|
|
444
|
+
return paths;
|
|
445
|
+
}
|
|
446
|
+
if (source.startsWith("\uFEFF")) source = source.slice(1);
|
|
447
|
+
let value;
|
|
448
|
+
try {
|
|
449
|
+
value = JSON.parse(source);
|
|
450
|
+
} catch {
|
|
451
|
+
throw new ConfigurationError(
|
|
452
|
+
"invalid-json",
|
|
453
|
+
`Configuration file is not valid JSON: ${paths.config}`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
let parsed;
|
|
457
|
+
try {
|
|
458
|
+
parsed = await parseConfig(value, process.cwd());
|
|
459
|
+
} catch (error) {
|
|
460
|
+
if (error instanceof ConfigurationError) throw error;
|
|
461
|
+
throw new ConfigurationError(
|
|
462
|
+
"invalid",
|
|
463
|
+
`Invalid configuration in ${paths.config}: ${error instanceof Error ? error.message : "unknown defect"}`
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
if (parsed.apiKeyFile) return { ...paths, credential: parsed.apiKeyFile };
|
|
467
|
+
const metadata = await lstat(paths.config);
|
|
468
|
+
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.nlink !== 1)
|
|
469
|
+
throw new Error("Configuration must be one regular, non-linked file before setup can update it");
|
|
470
|
+
const document = value;
|
|
471
|
+
document.providers.openrouter.apiKeyFile = paths.credential;
|
|
472
|
+
await writePrivateAtomic(paths.config, `${JSON.stringify(document, null, 2)}
|
|
473
|
+
`);
|
|
474
|
+
return paths;
|
|
475
|
+
}
|
|
476
|
+
async function setupHost(source, env = process.env) {
|
|
477
|
+
const credential = credentialText(source);
|
|
478
|
+
const paths = await prepareConfig(hostPaths(env));
|
|
479
|
+
await writePrivateAtomic(paths.credential, `${credential}
|
|
480
|
+
`);
|
|
481
|
+
return paths;
|
|
482
|
+
}
|
|
483
|
+
|
|
330
484
|
export {
|
|
331
485
|
identity,
|
|
332
486
|
validateCacheDir,
|
|
@@ -334,5 +488,10 @@ export {
|
|
|
334
488
|
ConfigurationError,
|
|
335
489
|
resolveWorkspace,
|
|
336
490
|
parseConfig,
|
|
337
|
-
loadConfig
|
|
491
|
+
loadConfig,
|
|
492
|
+
StandaloneError,
|
|
493
|
+
hostPaths,
|
|
494
|
+
defaultCodexConfig,
|
|
495
|
+
resolveCredential,
|
|
496
|
+
setupHost
|
|
338
497
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
StandaloneError,
|
|
2
3
|
identity,
|
|
4
|
+
resolveCredential,
|
|
3
5
|
validateCacheDir,
|
|
4
6
|
validateDomains
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-57DS6B3Q.js";
|
|
6
8
|
|
|
7
9
|
// packages/mcp/src/runtime.ts
|
|
8
10
|
import { Check } from "typebox/value";
|
|
@@ -250,9 +252,115 @@ async function withRetry(fn, classify, opts) {
|
|
|
250
252
|
if (threw) throw lastError;
|
|
251
253
|
return lastResult;
|
|
252
254
|
}
|
|
253
|
-
var
|
|
255
|
+
var NON_RETRYABLE_LIMIT_PATTERNS = [
|
|
256
|
+
// Subscription or account limits returned as 429 JSON error types. These are
|
|
257
|
+
// permanent for the purposes of a retry loop, not transient throttles.
|
|
258
|
+
"GoUsageLimitError",
|
|
259
|
+
"FreeUsageLimitError",
|
|
260
|
+
"Monthly usage limit reached",
|
|
261
|
+
"available balance",
|
|
262
|
+
// Generic quota/budget/billing exhaustion. `insufficient_quota` is OpenAI's
|
|
263
|
+
// quota/billing error code; the other strings cover common gateway wording.
|
|
264
|
+
"insufficient_quota",
|
|
265
|
+
"out of budget",
|
|
266
|
+
"quota exceeded",
|
|
267
|
+
"billing",
|
|
268
|
+
// Sign in with ChatGPT: the subscription's shared usage limit, which resets
|
|
269
|
+
// after hours rather than seconds.
|
|
270
|
+
"subscription_sharing_usage_limit_exceeded"
|
|
271
|
+
];
|
|
272
|
+
var RETRYABLE_PATTERNS = [
|
|
273
|
+
// Generic provider load, HTTP status, and server-side transient failures.
|
|
274
|
+
"overloaded",
|
|
275
|
+
"server_busy",
|
|
276
|
+
"servers are currently busy",
|
|
277
|
+
"currently experiencing high demand",
|
|
278
|
+
"model is at capacity",
|
|
279
|
+
"rate.?limit",
|
|
280
|
+
"too many requests",
|
|
281
|
+
// Deliberate divergence from upstream: the bare status codes keep word
|
|
282
|
+
// boundaries. The host filters context-overflow errors before classifying,
|
|
283
|
+
// so upstream can match bare digits; this policy has no such pre-filter, and
|
|
284
|
+
// an unbounded "502" would retry a permanent context-length error whose
|
|
285
|
+
// token counts embed a matching run (for example "150293 tokens").
|
|
286
|
+
"\\b(?:429|500|502|503|504|520|524)\\b",
|
|
287
|
+
// Also matches "The service is temporarily unavailable" (pi #10965).
|
|
288
|
+
"service.?(?:is.?)?(?:temporarily.?)?unavailable",
|
|
289
|
+
"server.?error",
|
|
290
|
+
"internal.?error",
|
|
291
|
+
// Wrapper/provider text for transient upstream failures, including OpenRouter
|
|
292
|
+
// "Provider returned error" responses (pi #2264) and gateway wording such as
|
|
293
|
+
// "The upstream provider returned an error" (pi #10842).
|
|
294
|
+
"provider.?returned.?(?:an.?)?error",
|
|
295
|
+
"exceeded request buffer limit while retrying upstream",
|
|
296
|
+
// Gateway failure relaying the upstream response stream, sent as an OpenAI
|
|
297
|
+
// Responses `response.failed` event without an error code (pi #10920).
|
|
298
|
+
"unable to forward upstream",
|
|
299
|
+
// Network, proxy, and fetch transport failures, including raw-fetch failures
|
|
300
|
+
// such as "upstream connect", "connection refused", and "reset before
|
|
301
|
+
// headers" (pi #733), plus OpenRouter connection drops (pi #3317).
|
|
302
|
+
"network.?error",
|
|
303
|
+
"connection.?error",
|
|
304
|
+
"connection.?refused",
|
|
305
|
+
"connection.?lost",
|
|
306
|
+
"other side closed",
|
|
307
|
+
"fetch failed",
|
|
308
|
+
"getaddrinfo",
|
|
309
|
+
"ENOTFOUND",
|
|
310
|
+
"EAI_AGAIN",
|
|
311
|
+
"upstream.?connect",
|
|
312
|
+
"reset before headers",
|
|
313
|
+
"socket hang up",
|
|
314
|
+
"socket connection was closed",
|
|
315
|
+
"timed? out",
|
|
316
|
+
"timeout",
|
|
317
|
+
"terminated",
|
|
318
|
+
// Raw Node transport codes observed on the OpenRouter path; upstream matches
|
|
319
|
+
// the prose forms above but not these codes.
|
|
320
|
+
"ETIMEDOUT",
|
|
321
|
+
"ECONNRESET",
|
|
322
|
+
"ECONNREFUSED",
|
|
323
|
+
// Bare "temporarily unavailable" without a "service" prefix: the standalone
|
|
324
|
+
// OpenRouter adapter uses this wording for a 402 carrying a valid Retry-After
|
|
325
|
+
// header (in-flight spending budget), which is transient.
|
|
326
|
+
"temporarily.?unavailable",
|
|
327
|
+
// Separator-tolerant busy phrasings retained from the pre-alignment
|
|
328
|
+
// classifier; upstream lists only "server_busy" and
|
|
329
|
+
// "servers are currently busy".
|
|
330
|
+
"server[ _-]?busy",
|
|
331
|
+
"currently busy",
|
|
332
|
+
// WebSocket transports can report close/error text instead of HTTP/fetch text.
|
|
333
|
+
"websocket.?closed",
|
|
334
|
+
"websocket.?error",
|
|
335
|
+
// Premature stream endings from SDKs and transports (pi #4433, #3594).
|
|
336
|
+
"ended without",
|
|
337
|
+
"stream ended before message_stop",
|
|
338
|
+
"stream ended before a terminal response event",
|
|
339
|
+
"http2 request did not get a response",
|
|
340
|
+
// Node ERR_HTTP2_STREAM_CANCEL: the HTTP/2 session died before the request
|
|
341
|
+
// was sent, for example after the Bedrock SDK's session timeout (pi #10379).
|
|
342
|
+
"pending stream has been canceled",
|
|
343
|
+
// Provider-requested retry delay cap failures flow through the outer retry
|
|
344
|
+
// policy so callers can surface or abort the backoff (pi #1123).
|
|
345
|
+
"retry delay",
|
|
346
|
+
// Explicit retry guidance emitted mid-stream by OpenAI Responses and Bedrock
|
|
347
|
+
// stream exceptions (pi #6019).
|
|
348
|
+
"you can retry your request",
|
|
349
|
+
"try your request again",
|
|
350
|
+
"please retry your request",
|
|
351
|
+
// gRPC based providers (for example NVIDIA NIM).
|
|
352
|
+
"ResourceExhausted",
|
|
353
|
+
// Sign in with ChatGPT: usage or user data temporarily unavailable. Usage
|
|
354
|
+
// failures can arrive mid-stream without an HTTP 503 in the message.
|
|
355
|
+
"subscription_sharing_usage_unavailable",
|
|
356
|
+
"subscription_sharing_user_unavailable"
|
|
357
|
+
];
|
|
358
|
+
var NON_RETRYABLE_LIMIT_RE = new RegExp(NON_RETRYABLE_LIMIT_PATTERNS.join("|"), "i");
|
|
359
|
+
var RETRYABLE_RE = new RegExp(RETRYABLE_PATTERNS.join("|"), "i");
|
|
254
360
|
function isRetryableMessage(msg) {
|
|
255
|
-
|
|
361
|
+
if (!msg) return false;
|
|
362
|
+
if (NON_RETRYABLE_LIMIT_RE.test(msg)) return false;
|
|
363
|
+
return RETRYABLE_RE.test(msg);
|
|
256
364
|
}
|
|
257
365
|
function parseRetryAfterMs(msg) {
|
|
258
366
|
if (!msg) return void 0;
|
|
@@ -2259,16 +2367,6 @@ var researchSchema = Type.Object({
|
|
|
2259
2367
|
focusPrompt: Type.Optional(Type.String({ description: "Focus guidance for all extractions" }))
|
|
2260
2368
|
});
|
|
2261
2369
|
|
|
2262
|
-
// packages/mcp/src/errors.ts
|
|
2263
|
-
var StandaloneError = class extends Error {
|
|
2264
|
-
constructor(code, message) {
|
|
2265
|
-
super(message);
|
|
2266
|
-
this.code = code;
|
|
2267
|
-
this.name = code === "CANCELLED" ? "AbortError" : "StandaloneError";
|
|
2268
|
-
}
|
|
2269
|
-
code;
|
|
2270
|
-
};
|
|
2271
|
-
|
|
2272
2370
|
// packages/mcp/src/providers/openrouter.ts
|
|
2273
2371
|
var endpoint = "https://openrouter.ai/api/v1";
|
|
2274
2372
|
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
@@ -2362,7 +2460,7 @@ function createOpenRouterClient(config, options) {
|
|
|
2362
2460
|
if (!value || !value.trim() || /\s/.test(value))
|
|
2363
2461
|
throw new StandaloneError(
|
|
2364
2462
|
"CONFIGURATION",
|
|
2365
|
-
`Set the credential environment variable ${config.apiKeyEnv} before creating the runtime; restart it after changing credentials`
|
|
2463
|
+
config.apiKeyFile ? `Set ${config.apiKeyEnv} before launch or supply the key at ${config.apiKeyFile}. mcp-intelli-search setup manages the default per-user configuration; restart after changing loaded configuration` : `Set the credential environment variable ${config.apiKeyEnv} before creating the runtime; restart it after changing credentials`
|
|
2366
2464
|
);
|
|
2367
2465
|
return value;
|
|
2368
2466
|
}
|
|
@@ -2675,8 +2773,13 @@ var stderrLogger = {
|
|
|
2675
2773
|
async function createRuntime(config, options = {}) {
|
|
2676
2774
|
const paths = await workspacePaths(config.workspace, config.settings.cacheDir);
|
|
2677
2775
|
const env = { ...options.env ?? process.env };
|
|
2678
|
-
const
|
|
2679
|
-
|
|
2776
|
+
const secrets = /* @__PURE__ */ new Set();
|
|
2777
|
+
if (env[config.apiKeyEnv]) secrets.add(env[config.apiKeyEnv]);
|
|
2778
|
+
const redact = (message) => {
|
|
2779
|
+
let redacted = message;
|
|
2780
|
+
for (const secret of secrets) if (secret) redacted = redacted.split(secret).join("[REDACTED]");
|
|
2781
|
+
return redacted;
|
|
2782
|
+
};
|
|
2680
2783
|
const sink = options.logger ?? stderrLogger;
|
|
2681
2784
|
const logger = {
|
|
2682
2785
|
error: (message) => sink.error(redact(message)),
|
|
@@ -2700,9 +2803,16 @@ async function createRuntime(config, options = {}) {
|
|
|
2700
2803
|
throwIfAborted(execution.signal);
|
|
2701
2804
|
category = "WORKSPACE";
|
|
2702
2805
|
await assertWorkspaceSafe(paths, execution.signal);
|
|
2806
|
+
category = "CONFIGURATION";
|
|
2807
|
+
const operationEnv = { ...env };
|
|
2808
|
+
const credential = await resolveCredential(config, operationEnv);
|
|
2809
|
+
if (credential) {
|
|
2810
|
+
operationEnv[config.apiKeyEnv] = credential;
|
|
2811
|
+
secrets.add(credential);
|
|
2812
|
+
}
|
|
2703
2813
|
const models = createOpenRouterClient(config, {
|
|
2704
2814
|
fetch: options.fetch,
|
|
2705
|
-
env,
|
|
2815
|
+
env: operationEnv,
|
|
2706
2816
|
logger,
|
|
2707
2817
|
signal: execution.signal
|
|
2708
2818
|
});
|
|
@@ -2781,6 +2891,5 @@ export {
|
|
|
2781
2891
|
extractSchema,
|
|
2782
2892
|
collateSchema,
|
|
2783
2893
|
researchSchema,
|
|
2784
|
-
StandaloneError,
|
|
2785
2894
|
createRuntime
|
|
2786
2895
|
};
|
package/dist/cli.js
CHANGED
|
@@ -4,54 +4,88 @@ import {
|
|
|
4
4
|
} from "./chunk-ZTHYRKI2.js";
|
|
5
5
|
import {
|
|
6
6
|
ConfigurationError,
|
|
7
|
+
defaultCodexConfig,
|
|
8
|
+
hostPaths,
|
|
7
9
|
identity,
|
|
8
10
|
loadConfig,
|
|
9
|
-
resolveWorkspace
|
|
10
|
-
|
|
11
|
+
resolveWorkspace,
|
|
12
|
+
setupHost
|
|
13
|
+
} from "./chunk-57DS6B3Q.js";
|
|
11
14
|
|
|
12
15
|
// packages/mcp/src/cli.ts
|
|
13
16
|
import { parseArgs } from "node:util";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
import { realpath } from "node:fs/promises";
|
|
19
|
+
import { parse as parsePath } from "node:path";
|
|
14
20
|
function cliOptions(argv, env = process.env) {
|
|
15
|
-
const { values } = parseArgs({
|
|
21
|
+
const { values, positionals } = parseArgs({
|
|
16
22
|
args: argv,
|
|
17
23
|
strict: true,
|
|
18
|
-
allowPositionals:
|
|
24
|
+
allowPositionals: true,
|
|
19
25
|
options: {
|
|
20
26
|
config: { type: "string" },
|
|
21
27
|
workspace: { type: "string" },
|
|
28
|
+
host: { type: "string" },
|
|
22
29
|
help: { type: "boolean" },
|
|
23
30
|
version: { type: "boolean" },
|
|
24
31
|
"check-config": { type: "boolean" }
|
|
25
32
|
}
|
|
26
33
|
});
|
|
34
|
+
if (values.host !== void 0 && values.host !== "codex")
|
|
35
|
+
throw new Error("Unsupported host");
|
|
36
|
+
if (positionals.length > 1 || positionals.length === 1 && positionals[0] !== "setup")
|
|
37
|
+
throw new Error("Unsupported command");
|
|
38
|
+
const setup = positionals[0] === "setup";
|
|
27
39
|
return {
|
|
28
40
|
...values,
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
setup,
|
|
42
|
+
config: values.config ?? (setup || values.host === "codex" ? void 0 : env.INTELLI_SEARCH_CONFIG),
|
|
43
|
+
workspace: values.workspace ?? (setup || values.host === "codex" ? void 0 : env.INTELLI_SEARCH_WORKSPACE)
|
|
31
44
|
};
|
|
32
45
|
}
|
|
46
|
+
async function credentialInput() {
|
|
47
|
+
if (process.stdin.isTTY)
|
|
48
|
+
throw new Error(
|
|
49
|
+
"Setup requires the key on standard input; use the hidden-prompt pipeline from the installation guide"
|
|
50
|
+
);
|
|
51
|
+
const chunks = [];
|
|
52
|
+
let length = 0;
|
|
53
|
+
for await (const chunk of process.stdin) {
|
|
54
|
+
const buffer = Buffer.from(chunk);
|
|
55
|
+
length += buffer.length;
|
|
56
|
+
if (length > 4098)
|
|
57
|
+
throw new Error("Credential input exceeds the 4096-byte limit plus its line ending");
|
|
58
|
+
chunks.push(buffer);
|
|
59
|
+
}
|
|
60
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
61
|
+
}
|
|
33
62
|
async function main() {
|
|
34
63
|
let args;
|
|
35
64
|
try {
|
|
36
65
|
args = cliOptions(process.argv.slice(2));
|
|
37
|
-
} catch {
|
|
38
|
-
throw new Error(
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(error instanceof Error ? error.message : "Invalid arguments");
|
|
39
68
|
}
|
|
40
69
|
if (args.help) {
|
|
41
70
|
process.stdout.write(
|
|
42
|
-
`Usage: mcp-intelli-search
|
|
71
|
+
`Usage: mcp-intelli-search setup
|
|
72
|
+
mcp-intelli-search --host codex [--config FILE] [--workspace ABSOLUTE_DIRECTORY]
|
|
73
|
+
mcp-intelli-search --config FILE --workspace ABSOLUTE_DIRECTORY
|
|
74
|
+
|
|
75
|
+
Commands:
|
|
76
|
+
setup Store an OpenRouter key read from standard input and create or connect per-user configuration; accepts no path selections
|
|
43
77
|
|
|
44
78
|
Options:
|
|
45
|
-
--
|
|
46
|
-
--
|
|
79
|
+
--host codex Use the Codex working root and per-user defaults
|
|
80
|
+
--config FILE Explicit generic configuration (or INTELLI_SEARCH_CONFIG)
|
|
81
|
+
--workspace DIR Existing absolute generic workspace (or INTELLI_SEARCH_WORKSPACE)
|
|
47
82
|
--check-config Validate configuration without inference or serving
|
|
48
83
|
--help Show this help
|
|
49
84
|
--version Show package version
|
|
50
85
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
to standard error; standard output carries protocol messages only.
|
|
86
|
+
Generic MCP serving requires explicit configuration and workspace paths.
|
|
87
|
+
Codex mode supplies both from its launcher and works without path exports.
|
|
88
|
+
Standard output carries protocol messages only while serving.
|
|
55
89
|
`
|
|
56
90
|
);
|
|
57
91
|
return;
|
|
@@ -61,27 +95,83 @@ to standard error; standard output carries protocol messages only.
|
|
|
61
95
|
`);
|
|
62
96
|
return;
|
|
63
97
|
}
|
|
64
|
-
if (
|
|
98
|
+
if (args.setup) {
|
|
99
|
+
if (args.config || args.workspace || args.host || args["check-config"])
|
|
100
|
+
throw new Error(
|
|
101
|
+
"Setup accepts no path selections. Remove --config, --workspace, --host and --check-config"
|
|
102
|
+
);
|
|
103
|
+
const paths2 = await setupHost(await credentialInput());
|
|
104
|
+
await loadConfig(paths2.config, process.cwd());
|
|
105
|
+
process.stdout.write(
|
|
106
|
+
`Setup complete.
|
|
107
|
+
Configuration: ${paths2.config}
|
|
108
|
+
Credential: ${paths2.credential}
|
|
109
|
+
The next tool call can use this credential when the selected configuration names its path.
|
|
110
|
+
Restart after changing loaded configuration.
|
|
111
|
+
`
|
|
112
|
+
);
|
|
113
|
+
if (process.env.OPENROUTER_API_KEY)
|
|
114
|
+
process.stderr.write(
|
|
115
|
+
"OPENROUTER_API_KEY is set and takes precedence over the stored credential\n"
|
|
116
|
+
);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const paths = args.host === "codex" ? hostPaths() : void 0;
|
|
120
|
+
const file = args.config ?? paths?.config;
|
|
121
|
+
const workspace = args.workspace ?? (args.host === "codex" ? process.cwd() : void 0);
|
|
122
|
+
if (!file || !workspace)
|
|
65
123
|
throw new Error(
|
|
66
124
|
"Explicit --config and --workspace are required (or their INTELLI_SEARCH_* environment equivalents)"
|
|
67
125
|
);
|
|
68
|
-
const
|
|
126
|
+
const canonicalWorkspace = await resolveWorkspace(workspace);
|
|
127
|
+
let workspaceDefect;
|
|
128
|
+
if (args.host === "codex" && !args.workspace) {
|
|
129
|
+
const home = await realpath(homedir()).catch(() => homedir());
|
|
130
|
+
if (canonicalWorkspace === parsePath(canonicalWorkspace).root || canonicalWorkspace === home)
|
|
131
|
+
workspaceDefect = "Codex working root must be a project directory, not the home or filesystem root; restart Codex from the project or with --cd <project>";
|
|
132
|
+
}
|
|
69
133
|
if (args["check-config"]) {
|
|
70
|
-
|
|
71
|
-
|
|
134
|
+
if (workspaceDefect) throw new Error(workspaceDefect);
|
|
135
|
+
let builtInDefaults = false;
|
|
136
|
+
if (paths && !args.config) {
|
|
137
|
+
try {
|
|
138
|
+
await loadConfig(file, workspace);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (!(error instanceof ConfigurationError) || error.reason !== "missing") throw error;
|
|
141
|
+
await defaultCodexConfig(workspace, paths);
|
|
142
|
+
builtInDefaults = true;
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
await loadConfig(file, workspace);
|
|
146
|
+
}
|
|
147
|
+
process.stdout.write(
|
|
148
|
+
builtInDefaults ? "Configuration is valid (built-in Codex defaults; no per-user file found).\n" : "Configuration is valid.\n"
|
|
149
|
+
);
|
|
72
150
|
return;
|
|
73
151
|
}
|
|
74
|
-
|
|
152
|
+
const loadSelected = async () => {
|
|
153
|
+
const loaded = await loadConfig(file, workspace);
|
|
154
|
+
return paths && !args.config && !loaded.apiKeyFile ? { ...loaded, apiKeyFile: paths.credential } : loaded;
|
|
155
|
+
};
|
|
75
156
|
let config;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
157
|
+
if (workspaceDefect) {
|
|
158
|
+
const defect = workspaceDefect;
|
|
159
|
+
config = () => Promise.reject(new Error(defect));
|
|
160
|
+
} else {
|
|
161
|
+
try {
|
|
162
|
+
config = await loadSelected();
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (!(error instanceof ConfigurationError)) throw error;
|
|
165
|
+
if (paths && !args.config && error.reason === "missing") {
|
|
166
|
+
config = await defaultCodexConfig(workspace, paths);
|
|
167
|
+
} else {
|
|
168
|
+
process.stderr.write(
|
|
169
|
+
`[mcp-intelli-search] ${error.message}. Serving anyway: each tool call reports this and rereads the file until it loads
|
|
82
170
|
`
|
|
83
|
-
|
|
84
|
-
|
|
171
|
+
);
|
|
172
|
+
config = loadSelected;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
85
175
|
}
|
|
86
176
|
installStdoutGuard();
|
|
87
177
|
const { startServer } = await import("./server.js");
|
package/dist/runtime.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
StandaloneError,
|
|
3
2
|
createRuntime
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V5TY66GM.js";
|
|
5
4
|
import {
|
|
6
5
|
ConfigurationError,
|
|
6
|
+
StandaloneError,
|
|
7
7
|
identity,
|
|
8
8
|
loadConfig,
|
|
9
9
|
parseConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-57DS6B3Q.js";
|
|
11
11
|
export {
|
|
12
12
|
ConfigurationError,
|
|
13
13
|
StandaloneError,
|
package/dist/server.js
CHANGED
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
installStdoutGuard
|
|
3
3
|
} from "./chunk-ZTHYRKI2.js";
|
|
4
4
|
import {
|
|
5
|
-
StandaloneError,
|
|
6
5
|
collateSchema,
|
|
7
6
|
createRuntime,
|
|
8
7
|
extractSchema,
|
|
9
8
|
researchSchema,
|
|
10
9
|
searchSchema
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-V5TY66GM.js";
|
|
12
11
|
import {
|
|
13
12
|
ConfigurationError,
|
|
13
|
+
StandaloneError,
|
|
14
14
|
identity
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-57DS6B3Q.js";
|
|
16
16
|
|
|
17
17
|
// packages/mcp/src/server.ts
|
|
18
18
|
import { McpServer, fromJsonSchema } from "@modelcontextprotocol/server";
|
package/package.json
CHANGED