import type { HexisMcpConfig } from './config.js'; import { type McpAppManifest } from '@bevel-software/platform-mcp-core'; export declare class DeploymentError extends Error { readonly status?: number | undefined; /** * The HTTP status, when the deployment answered with one. Carried so a * caller can tell "this deployment does not have that endpoint" (404) from * "the network is having a moment" — the catalog poller stops for the first * and keeps trying through the second. */ constructor(message: string, status?: number | undefined); } /** * A key-mode 401: the deployment refused the connection key itself. Stated * plainly and with no sign-in step — a browser sign-in cannot repair a key, so * a rejected key ends the process, and a fetch that otherwise degrades * quietly (the agent instructions) lets this one through. The trailing * parenthesis exists because Claude Code shows a failed stdio server only as * "failed"; the person needs to know where this text went. `` stays * literal: this process cannot know what the client named it. */ export declare class ConnectionKeyRejectedError extends DeploymentError { constructor(deployment: string); } /** What one read of `/api/config` tells this process about a deployment. */ export interface ResolvedDeployment { /** The deployment's own MCP endpoint (see {@link resolveMcpUrl}). */ mcpUrl: string; /** * Whether the deployment serves `GET /api/agent/instructions` and sends * instructions on its own handshakes. Absent on an older deployment, and * absence is the ONLY signal: probing the route instead would hit the JWT * mounts an unknown `/api/*` path falls through to, which answer 401, and * `getJson` reads a 401 as an expired sign-in. */ agentInstructions: boolean; /** * Whether the deployment serves `GET /api/agent/catalog-revision`, so this * process can notice a manual or a skill changing under a live connection. * Absent on an older deployment, and — like `agentInstructions` — absence is * the ONLY signal: probing the route instead would hit the JWT mounts an * unknown `/api/*` path falls through to, which answer 401, and a poller * would report a dead credential for a route that is merely not there. */ catalogRevision: boolean; /** * Whether the deployment serves `GET /api/agent/tool-hints`, the read-only * hint of every platform tool. Absent on an older deployment and, as above, * absence is the ONLY signal: that deployment answers the unknown route with * 401, and an OAuth config reads a 401 as an expired token — it would * refresh its sign-in on every `tools/list`. */ toolHints: boolean; } /** * Everything this process learns from the deployment's config, in ONE fetch: * the MCP endpoint and whether agent instructions are available. The two * consumers that only need the endpoint keep {@link resolveMcpUrl}. */ export declare function resolveDeployment(config: HexisMcpConfig): Promise; /** * The deployment's own MCP endpoint. * * Asked for rather than computed. `/api/config` derives `mcpUrl` from the same * expression as the OAuth `resourceServerUrl`, which is the identifier that * decides whether a connection works — so a locally-guessed `/api/mcp` * is right only until someone puts the deployment behind a proxy or on a second * domain, and a process on a laptop has no address bar to guess from anyway. * * Falls back to the guess when the field is absent, which is how a deployment * older than that field looks. The frontend's `configureMcpUrl()` degrades the * same way, for the same reason. * * A wrapper over {@link resolveDeployment}: same fetch, one field. Kept as a * public export because the CLI consumes it as a plain string. */ export declare function resolveMcpUrl(config: HexisMcpConfig): Promise; /** * What every connected agent is told at session start, as the deployment * composes it: the platform header plus the admin's `mcp-description.md`. * Passed verbatim as this server's own `instructions`, so a client connected * here receives exactly what one connected to the hosted endpoint receives. * * Throws only a {@link ConnectionKeyRejectedError}: a dead key fails startup * anyway (the manual fetches beside this one need it), and it must say so in * its own words rather than as a degraded-instructions notice. Otherwise the * text is worth having and not worth failing over: a network error, a non-2xx * answer or a body without an `instructions` string logs one line and * resolves to `undefined`, and the server starts without instructions, as it * did before the deployment could send any. */ export declare function fetchAgentInstructions(config: HexisMcpConfig): Promise; /** One `.tool` manual as `GET /api/agent/all-tools` returns it. */ export type RawManual = Record & { name?: unknown; }; /** * Every manual the caller can read, local-only ones included. * * `?remote=false` is the opt-in the REST surface already documents for "a * locally installed MCP server" — the default excludes local-only manuals * precisely because the hosted proxy cannot run them. */ export declare function fetchAllManuals(config: HexisMcpConfig): Promise; /** What this server needs to know about one local-only manual beyond its name. */ export interface LocalManualInfo { /** * How the manual is ADDRESSED on the deployment's REST surface — the key for * the variable-resolution route. Distinct from the manual's UTCP `name`, * which is the namespace its `${VAR}` refs are keyed by; they coincide for a * `.tool` file but not necessarily for every source. */ slug: string; /** The manual's declaring file in the knowledge base, e.g. `Plugins//mcp.json`. */ path: string; } /** * The manuals that only work locally — the ones this server exists to add. * Asking the deployment (rather than inferring from the two list variants) * keeps the definition of "local-only" in the one place that owns it. */ export declare function fetchLocalOnlyManuals(config: HexisMcpConfig): Promise>; /** * A deployment that does not serve `GET /api/agent/catalog-revision` — an * older build than this package. Thrown once, by the first poll, so the * watcher can stop for good instead of asking every few seconds forever. */ export declare class CatalogRevisionUnsupportedError extends DeploymentError { } /** * The fingerprint of THIS caller's released catalog: every tool manual and * every skill the deployment's default branch serves them, as one opaque * string. It changes exactly when that set changes, so two equal readings mean * there is nothing to re-register. * * Opaque on purpose: what goes into it is the deployment's business, and this * process compares it for equality and nothing else. */ export declare function fetchCatalogRevision(config: HexisMcpConfig): Promise; /** What a resolution attempt produced, and whether it actually succeeded. */ export interface LocalToolVariables { /** * Whether the deployment answered. FALSE for a network blip, a refusal, or a * deployment predating the route — distinct from "answered, nothing set", * because only a real answer is worth caching. */ ok: boolean; values: Record; } /** * The variables one LOCAL manual declares, resolved by the deployment. * * The request names the MANUAL, never a variable: the deployment re-reads the * `.tool` file and resolves exactly what that file declares, so the knowledge * base is the allowlist and this process cannot widen it. What comes back is * scoped to one manual's namespace and goes straight into that manual's tool * invocations — see `localVariableLoader`. * * A failure is NOT fatal — except a rejected connection key, which is thrown * so the tool call reports it plainly instead of running without secrets. A manual may declare variables that are simply unset, * the deployment may be an older build without the route, and either way the * tool should still be offered and fail with its own error message rather than * being absent from the toolset. So the caller gets `ok: false` and an empty * map — and, because it is `ok: false`, the caller knows not to cache it. */ export declare function fetchLocalToolVariables(config: HexisMcpConfig, slug: string): Promise; /** A skill as the catalog lists it, and one loaded in full. Shapes mirror the KB tools. */ export declare function callKbTool(config: HexisMcpConfig, tool: string, args: Record): Promise; /** * The deployment's MCP Apps: which of its tools carry a `ui://` view, and the * views themselves. * * The local server bridges a host to a deployment over HTTP. It discovers the * tools as UTCP manuals, and a UTCP manual has nowhere to carry a view — so * the metadata has to arrive as data, keyed by tool name, and the view's HTML * has to arrive with it (this server answers `resources/read` itself). * * DEGRADES TO NOTHING, loudly but harmlessly. A deployment that predates the * route 404s; one behind a proxy may answer HTML. Either way the right outcome * is NO apps: every tool is still listed and still callable, `resources/list` * answers an empty list (this server declares the capability unconditionally, * since a later catalog refresh may bring a view), and a host shows the * tool's text answer — * which is exactly what a host without the extension does anyway. Advertising * a `resourceUri` this server could not serve would be worse than advertising * none: the host would preload a failure and show an empty frame where the * text used to be. * * `previous` is what a TRANSIENT failure answers — the manifest already * being served, on a catalog refresh. A refresh that hit a deployment * mid-redeploy (a 5xx, a dropped connection, a proxy's error page) must not * turn every view off until the next catalog change: the refresh is marked * applied either way, so nothing would read the manifest again. * * A DEFINITE answer replaces it, though, because the same "applied either * way" would otherwise keep a removed view advertised indefinitely: a * manifest that reads as empty, and a route that answers 404/410 (gone) or * 403 (this identity may not have it), all turn the views off. */ export declare function fetchMcpApps(config: HexisMcpConfig, previous?: McpAppManifest): Promise; /** * The read-only hint of every platform tool and every code-mode meta-tool, as * the deployment has them now: its built-in value, or an admin's override. * * Read per LISTING rather than once: an admin who flips a hint on the Tools * page expects the next `tools/list` to carry it, and the tool discovery this * server registered at startup goes through the deployment's MCP endpoint, * whose `annotations` the UTCP MCP protocol drops on the way in. One small * read, beside the catalog check a listing already awaits. * * Asked only of a deployment that advertises the route (`toolHints` in * `/api/config`, see {@link ResolvedDeployment}). Never fatal, and never * louder than once per kind of failure and deployment: a route that answers * 404 anyway is treated as absent, and the right listing for it is the one an * older deployment gets — no hints at all. A transient failure keeps `previous`, the * hints already served, so a deployment mid-redeploy does not flip every hint * off for one listing. */ export declare function fetchToolHints(config: HexisMcpConfig, previous?: Readonly>): Promise>; //# sourceMappingURL=deployment.d.ts.map