diff --git a/pkgs/mcpx/internal/buildcheck/checkphase_test.go b/pkgs/mcpx/internal/buildcheck/checkphase_test.go index d50dde2b54..dc76ef6d81 100644 --- a/pkgs/mcpx/internal/buildcheck/checkphase_test.go +++ b/pkgs/mcpx/internal/buildcheck/checkphase_test.go @@ -17,6 +17,13 @@ const derivedList = `go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPa var excludeBlock = regexp.MustCompile(`(?s)checkExclude = \[(.*?)\];`) +// preCheckBlock matches the preCheck attribute: its regeneration +// invocation names internal/api on purpose (that is the generator's +// home), so the hand-named-package scan below carves it out — the +// guard is about the check phase narrowing its own list, and the +// preCheck is not the check phase. +var preCheckBlock = regexp.MustCompile(`(?s)preCheck = ''.*?'';`) + func readPackageNix(t *testing.T) string { t.Helper() b, err := os.ReadFile(filepath.Join(moduleRoot, "package.nix")) @@ -88,7 +95,7 @@ func TestCheckPhaseTestsEveryPackageWithTests(t *testing.T) { } // A hand-written package list next to the computed one would silently // narrow it again. - if regexp.MustCompile(`go test[^\n]*\./internal/`).MatchString(nix) { + if regexp.MustCompile(`go test[^\n]*\./internal/`).MatchString(preCheckBlock.ReplaceAllString(nix, "")) { t.Fatal("checkPhase names packages by hand; exclude them via checkExclude instead") } diff --git a/pkgs/mcpx/package.nix b/pkgs/mcpx/package.nix index b14307d849..03637c5b0f 100644 --- a/pkgs/mcpx/package.nix +++ b/pkgs/mcpx/package.nix @@ -125,6 +125,19 @@ buildGo127Module { python3 git ]; + # ops.gen.ts is generated from the /v1 table (internal/api's + # PluginTS) but checked in, because the TypeScript plugin consumes + # it from the source tree. Regenerate it here, in the build tree, + # before the check phase compares it: a nix build then never fails + # on a stale checked-in copy (code#4806), while the freshness test + # still guards the checked-in file where that matters — plain + # `go test` runs outside nix. + preCheck = '' + export HOME=$TMPDIR/home MCPX_STATE_DIR=$TMPDIR/state MCPX_CACHE_DIR=$TMPDIR/cache + mkdir -p "$HOME" + go test ./internal/api -run TestPluginOpsAreGenerated -update + ''; + checkPhase = let checkExclude = [ diff --git a/pkgs/mcpx/plugin/opencode/mcpx/ops.gen.ts b/pkgs/mcpx/plugin/opencode/mcpx/ops.gen.ts index e747be4647..6b6787a9eb 100644 --- a/pkgs/mcpx/plugin/opencode/mcpx/ops.gen.ts +++ b/pkgs/mcpx/plugin/opencode/mcpx/ops.gen.ts @@ -6,19 +6,19 @@ // a parameter this file sends is one the route reads. /** Where a parameter travels. */ -type In = "path" | "query" | "body"; +type In = "path" | "query" | "body" -type ParamSpec = { in: In; required?: boolean; raw?: boolean }; +type ParamSpec = { in: In; required?: boolean; raw?: boolean } type OpSpec = { - method: string; - path: string; - params: Record; + method: string + path: string + params: Record /** The body parameter that is the whole body, for routes that take a bare document. */ - wrap?: string; + wrap?: string /** json is parsed; response is handed back for the caller to read as text, bytes or a stream. */ - response: "json" | "response"; -}; + response: "json" | "response" +} /** Every /v1 operation, by name. */ export const OPS: Record = { @@ -802,7 +802,7 @@ export const OPS: Record = { }, response: "json", }, -}; +} /** A refusal from the daemon, with the status and the body kept. */ export class OpError extends Error { @@ -811,23 +811,23 @@ export class OpError extends Error { readonly status: number, readonly body: string, ) { - let msg = body.trim(); + let msg = body.trim() try { - const parsed = JSON.parse(body) as { error?: unknown }; - if (typeof parsed.error === "string" && parsed.error) msg = parsed.error; + const parsed = JSON.parse(body) as { error?: unknown } + if (typeof parsed.error === "string" && parsed.error) msg = parsed.error } catch { // Not JSON; the text is the message. } - super(`mcpx ${op}: ${status}: ${msg}`); + super(`mcpx ${op}: ${status}: ${msg}`) } } const scalar = (v: unknown): string => { - if (typeof v === "string") return v; - if (typeof v === "boolean") return v ? "1" : "0"; - if (typeof v === "number") return String(v); - return JSON.stringify(v); -}; + if (typeof v === "string") return v + if (typeof v === "boolean") return v ? "1" : "0" + if (typeof v === "number") return String(v) + return JSON.stringify(v) +} /** * The path and request for one operation. The same rules as the Go side's @@ -837,46 +837,46 @@ const scalar = (v: unknown): string => { * document. */ export const buildRequest = (name: string, args: Record = {}): { path: string; init: RequestInit } => { - const spec = OPS[name]; - if (!spec) throw new Error(`mcpx: no operation ${name}`); - let path = spec.path; - const query = new URLSearchParams(); - const body: Record = {}; - let raw: BodyInit | undefined; + const spec = OPS[name] + if (!spec) throw new Error(`mcpx: no operation ${name}`) + let path = spec.path + const query = new URLSearchParams() + const body: Record = {} + let raw: BodyInit | undefined for (const [key, value] of Object.entries(args)) { - if (value === undefined) continue; - const p = spec.params[key]; - if (!p) throw new Error(`mcpx ${name} takes no argument ${key}`); - if (p.raw) raw = value as BodyInit; - else if (p.in === "path") path = path.replace(`{${key}}`, encodeURIComponent(scalar(value))); + if (value === undefined) continue + const p = spec.params[key] + if (!p) throw new Error(`mcpx ${name} takes no argument ${key}`) + if (p.raw) raw = value as BodyInit + else if (p.in === "path") path = path.replace(`{${key}}`, encodeURIComponent(scalar(value))) else if (p.in === "query") { - const s = scalar(value); - if (s !== "") query.set(key, s); - } else body[key] = value; + const s = scalar(value) + if (s !== "") query.set(key, s) + } else body[key] = value } for (const [key, p] of Object.entries(spec.params)) { - if (p.required && args[key] === undefined) throw new Error(`mcpx ${name}: ${key} is required`); + if (p.required && args[key] === undefined) throw new Error(`mcpx ${name}: ${key} is required`) } - if (path.includes("{")) throw new Error(`mcpx ${name}: unfilled path parameter in ${path}`); - const qs = query.toString(); - if (qs) path += "?" + qs; - const init: RequestInit = { method: spec.method }; + if (path.includes("{")) throw new Error(`mcpx ${name}: unfilled path parameter in ${path}`) + const qs = query.toString() + if (qs) path += "?" + qs + const init: RequestInit = { method: spec.method } if (raw !== undefined) { - init.body = raw; - init.headers = { "content-type": "application/octet-stream" }; + init.body = raw + init.headers = { "content-type": "application/octet-stream" } } else if (spec.method !== "GET") { - const doc = spec.wrap ? (body[spec.wrap] ?? {}) : body; - init.body = JSON.stringify(doc); - init.headers = { "content-type": "application/json" }; + const doc = spec.wrap ? (body[spec.wrap] ?? {}) : body + init.body = JSON.stringify(doc) + init.headers = { "content-type": "application/json" } } - return { path, init }; -}; + return { path, init } +} /** Sends one request to the daemon; DaemonClient.raw is one. */ -export type Fetcher = (path: string, init: RequestInit) => Promise; +export type Fetcher = (path: string, init: RequestInit) => Promise /** Options every method accepts. */ -export type CallOptions = { signal?: AbortSignal }; +export type CallOptions = { signal?: AbortSignal } /** A typed method for every /v1 operation. */ export class DaemonOps { @@ -884,33 +884,21 @@ export class DaemonOps { /** Performs any operation by name; the typed methods below are this. */ async invoke(name: string, args: Record = {}, opts: CallOptions = {}): Promise { - const { path, init } = buildRequest(name, args); - if (opts.signal) init.signal = opts.signal; - const res = await this.fetcher(path, init); - if (!res.ok) throw new OpError(name, res.status, await res.text()); - if (OPS[name].response === "response") return res; - const text = await res.text(); - return text ? JSON.parse(text) : undefined; + const { path, init } = buildRequest(name, args) + if (opts.signal) init.signal = opts.signal + const res = await this.fetcher(path, init) + if (!res.ok) throw new OpError(name, res.status, await res.text()) + if (OPS[name].response === "response") return res + const text = await res.text() + return text ? JSON.parse(text) : undefined } /** * Add an adapter declaration, live. `POST /v1/adapters`. * Privileged: it changes the daemon rather than reading it. */ - adaptersAdd( - args: { - name: string; - command: string; - runtime?: string; - args?: unknown[]; - env?: Record; - description?: string; - tools?: unknown[]; - replace?: boolean; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("adapters_add", args, opts) as Promise; + adaptersAdd(args: { name: string; command: string; runtime?: string; args?: unknown[]; env?: Record; description?: string; tools?: unknown[]; replace?: boolean }, opts: CallOptions = {}): Promise { + return this.invoke("adapters_add", args, opts) as Promise } /** @@ -919,7 +907,7 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ adaptersRemove(args: { name: string }, opts: CallOptions = {}): Promise { - return this.invoke("adapters_remove", args, opts) as Promise; + return this.invoke("adapters_remove", args, opts) as Promise } /** @@ -928,35 +916,29 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ artifactDelete(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("artifact_delete", args, opts) as Promise; + return this.invoke("artifact_delete", args, opts) as Promise } /** * Fetch one artifact's bytes. `GET /v1/artifacts/{id}`. */ artifactGet(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("artifact_get", args, opts) as Promise; + return this.invoke("artifact_get", args, opts) as Promise } /** * Store a file a script produced. `POST /v1/artifacts`. * Privileged: it changes the daemon rather than reading it. */ - artifactPut( - args: { name: string; mime?: string; run?: string; session?: string; ttl?: string; content: BodyInit }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("artifact_put", args, opts) as Promise; + artifactPut(args: { name: string; mime?: string; run?: string; session?: string; ttl?: string; content: BodyInit }, opts: CallOptions = {}): Promise { + return this.invoke("artifact_put", args, opts) as Promise } /** * Files scripts produced, newest first. `GET /v1/artifacts`. */ - artifactsList( - args: { run?: string; session?: string; limit?: number } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("artifacts_list", args, opts) as Promise; + artifactsList(args: { run?: string; session?: string; limit?: number } = {}, opts: CallOptions = {}): Promise { + return this.invoke("artifacts_list", args, opts) as Promise } /** @@ -965,7 +947,7 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ askAbandon(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("ask_abandon", args, opts) as Promise; + return this.invoke("ask_abandon", args, opts) as Promise } /** @@ -973,136 +955,77 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ askAnswers(args: { id: string; answers: Record }, opts: CallOptions = {}): Promise { - return this.invoke("ask_answers", args, opts) as Promise; + return this.invoke("ask_answers", args, opts) as Promise } /** * Start a call that a server may interrupt with a question. `POST /v1/ask`. */ - askBegin( - args: { - kind: "tools/call" | "prompts/get" | "resources/read"; - server: string; - tool?: string; - name?: string; - uri?: string; - args?: Record; - arguments?: Record; - ttl?: number; - session?: string; - context?: Record; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("ask_begin", args, opts) as Promise; + askBegin(args: { kind: "tools/call" | "prompts/get" | "resources/read"; server: string; tool?: string; name?: string; uri?: string; args?: Record; arguments?: Record; ttl?: number; session?: string; context?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("ask_begin", args, opts) as Promise } /** * What a call is waiting on, or its result. `GET /v1/ask/{id}`. */ askPoll(args: { id: string; waitMs?: number }, opts: CallOptions = {}): Promise { - return this.invoke("ask_poll", args, opts) as Promise; + return this.invoke("ask_poll", args, opts) as Promise } /** * Execute multiple tool calls in a single turn. `POST /v1/batch`. */ - batch( - args: { - calls: unknown[]; - stopOnError?: boolean; - parallel?: boolean; - session?: string; - context?: Record; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("batch", args, opts) as Promise; + batch(args: { calls: unknown[]; stopOnError?: boolean; parallel?: boolean; session?: string; context?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("batch", args, opts) as Promise } /** * Call one tool on one server. `POST /v1/call`. */ - call( - args: { - server: string; - tool: string; - args?: Record; - task?: Record; - session?: string; - context?: Record; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("call", args, opts) as Promise; + call(args: { server: string; tool: string; args?: Record; task?: Record; session?: string; context?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("call", args, opts) as Promise } /** * Call one tool, with the pair in the URL. `POST /v1/call/{server}/{tool}`. */ - callPath( - args: { server: string; tool: string; session?: string; arguments?: Record }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("call_path", args, opts) as Promise; + callPath(args: { server: string; tool: string; session?: string; arguments?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("call_path", args, opts) as Promise } /** * Every namespace with as many signatures as fit a token budget. `GET /v1/catalog`. */ - catalog( - args: { - ns?: string; - budget?: number; - bias?: string; - profile?: string; - skipDefault?: "0" | "1"; - allProfiles?: "0" | "1"; - } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("catalog", args, opts) as Promise; + catalog(args: { ns?: string; budget?: number; bias?: string; profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("catalog", args, opts) as Promise } /** * What changed in the tool schemas, and when. `GET /v1/catalog/history`. */ catalogHistory(args: { tool?: string } = {}, opts: CallOptions = {}): Promise { - return this.invoke("catalog_history", args, opts) as Promise; + return this.invoke("catalog_history", args, opts) as Promise } /** * OpenAI-compatible LLM chat completions endpoint. `POST /v1/chat/completions`. */ chatCompletions(args: { model?: string; messages: unknown[] }, opts: CallOptions = {}): Promise { - return this.invoke("chat_completions", args, opts) as Promise; + return this.invoke("chat_completions", args, opts) as Promise } /** * The generated TypeScript client. `GET /v1/client.ts`. */ - clientModule( - args: { ns?: string; session?: string; profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("client_module", args, opts) as Promise; + clientModule(args: { ns?: string; session?: string; profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("client_module", args, opts) as Promise } /** * Argument autocomplete from an upstream server. `POST /v1/complete`. */ - complete( - args: { - server: string; - ref: Record; - argument: Record; - arguments?: Record; - session?: string; - context?: Record; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("complete", args, opts) as Promise; + complete(args: { server: string; ref: Record; argument: Record; arguments?: Record; session?: string; context?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("complete", args, opts) as Promise } /** @@ -1111,277 +1034,221 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ daemonRestart(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("daemon_restart", args, opts) as Promise; + return this.invoke("daemon_restart", args, opts) as Promise } /** * Live web dashboard HTML. `GET /v1/dashboard`. */ dashboard(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("dashboard", args, opts) as Promise; + return this.invoke("dashboard", args, opts) as Promise } /** * Explain what is wrong with a script, deterministically. `POST /v1/diagnose`. */ diagnose(args: { source: string; session?: string; repair?: boolean }, opts: CallOptions = {}): Promise { - return this.invoke("diagnose", args, opts) as Promise; + return this.invoke("diagnose", args, opts) as Promise } /** * Answer a question a server asked. `POST /v1/elicit/{id}/{action}`. * Privileged: it changes the daemon rather than reading it. */ - elicitAnswer( - args: { id: string; action: "accept" | "decline" | "cancel"; content?: Record }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("elicit_answer", args, opts) as Promise; + elicitAnswer(args: { id: string; action: "accept" | "decline" | "cancel"; content?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("elicit_answer", args, opts) as Promise } /** * One question, with its answer once it has one. `GET /v1/elicit/{id}`. */ elicitGet(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("elicit_get", args, opts) as Promise; + return this.invoke("elicit_get", args, opts) as Promise } /** * Questions servers are waiting on an answer for. `GET /v1/elicit`. */ elicitList(args: { session?: string; audience?: string } = {}, opts: CallOptions = {}): Promise { - return this.invoke("elicit_list", args, opts) as Promise; + return this.invoke("elicit_list", args, opts) as Promise } /** * Compute vector embeddings for text. `POST /v1/embeddings`. */ embeddings(args: { input: string; model?: string }, opts: CallOptions = {}): Promise { - return this.invoke("embeddings", args, opts) as Promise; + return this.invoke("embeddings", args, opts) as Promise } /** * Export cached vector embeddings. `GET /v1/embeddings/export`. */ embeddingsExport(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("embeddings_export", args, opts) as Promise; + return this.invoke("embeddings_export", args, opts) as Promise } /** * Import pre-computed vector embeddings. `POST /v1/embeddings/import`. */ embeddingsImport(args: { content: BodyInit }, opts: CallOptions = {}): Promise { - return this.invoke("embeddings_import", args, opts) as Promise; + return this.invoke("embeddings_import", args, opts) as Promise } /** * Server-sent event stream. `GET /v1/events`. * A stream: read the response body until you are done with it. */ - events( - args: { kinds?: string; session?: string; server?: string; uri?: string; since?: number } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("events", args, opts) as Promise; + events(args: { kinds?: string; session?: string; server?: string; uri?: string; since?: number } = {}, opts: CallOptions = {}): Promise { + return this.invoke("events", args, opts) as Promise } /** * Run TypeScript on the daemon. `POST /v1/exec`. * Privileged: it changes the daemon rather than reading it. */ - exec( - args: { source?: string; file?: string; options?: Record } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("exec", args, opts) as Promise; + exec(args: { source?: string; file?: string; options?: Record } = {}, opts: CallOptions = {}): Promise { + return this.invoke("exec", args, opts) as Promise } /** * Submit quality feedback for a trace. `POST /v1/feedback`. */ - feedback( - args: { - traceId: string; - score: number; - target?: string; - retrievalScore?: number; - executionScore?: number; - notes?: string; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("feedback", args, opts) as Promise; + feedback(args: { traceId: string; score: number; target?: string; retrievalScore?: number; executionScore?: number; notes?: string }, opts: CallOptions = {}): Promise { + return this.invoke("feedback", args, opts) as Promise } /** * Ambient declarations for the installed globals. `GET /v1/globals.d.ts`. */ - globals( - args: { ns?: string; profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("globals", args, opts) as Promise; + globals(args: { ns?: string; profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("globals", args, opts) as Promise } /** * Liveness, version and the loopback endpoint. `GET /v1/health`. */ health(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("health", args, opts) as Promise; + return this.invoke("health", args, opts) as Promise } /** * A request in words, a script back. `POST /v1/intent`. */ - intent( - args: { prompt: string; autonomy?: "propose" | "run"; placeholders?: Record; session?: string }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("intent", args, opts) as Promise; + intent(args: { prompt: string; autonomy?: "propose" | "run"; placeholders?: Record; session?: string }, opts: CallOptions = {}): Promise { + return this.invoke("intent", args, opts) as Promise } /** * Inspect a specific interaction trace. `GET /v1/interactions/{id}`. */ interactionsGet(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("interactions_get", args, opts) as Promise; + return this.invoke("interactions_get", args, opts) as Promise } /** * List and filter past interaction traces. `GET /v1/interactions`. */ - interactionsList( - args: { q?: string; source?: string; target?: string; hasFeedback?: string } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("interactions_list", args, opts) as Promise; + interactionsList(args: { q?: string; source?: string; target?: string; hasFeedback?: string } = {}, opts: CallOptions = {}): Promise { + return this.invoke("interactions_list", args, opts) as Promise } /** * Query the durable log. `GET /v1/log`. */ - logQuery( - args: { - since?: string; - until?: string; - level?: "debug" | "info" | "warn" | "error"; - event?: string; - server?: string; - tool?: string; - session?: string; - trace?: string; - chain?: string; - grep?: string; - limit?: number; - reverse?: "0" | "1"; - } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("log_query", args, opts) as Promise; + logQuery(args: { since?: string; until?: string; level?: "debug" | "info" | "warn" | "error"; event?: string; server?: string; tool?: string; session?: string; trace?: string; chain?: string; grep?: string; limit?: number; reverse?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("log_query", args, opts) as Promise } /** * Append one record to the durable log. `POST /v1/log`. * Privileged: it changes the daemon rather than reading it. */ - logRecord( - args: { level?: "debug" | "info" | "warn" | "error"; record: Record }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("log_record", args, opts) as Promise; + logRecord(args: { level?: "debug" | "info" | "warn" | "error"; record: Record }, opts: CallOptions = {}): Promise { + return this.invoke("log_record", args, opts) as Promise } /** * Token economics telemetry summary. `GET /v1/metrics/tokens`. */ metricsTokens(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("metrics_tokens", args, opts) as Promise; + return this.invoke("metrics_tokens", args, opts) as Promise } /** * Tool call telemetry, error rates, correlations and timelines. `GET /v1/metrics/tools`. */ metricsTools(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("metrics_tools", args, opts) as Promise; + return this.invoke("metrics_tools", args, opts) as Promise } /** * Every configured server, with tool counts. `GET /v1/namespaces`. */ - namespaces( - args: { profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("namespaces", args, opts) as Promise; + namespaces(args: { profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("namespaces", args, opts) as Promise } /** * This API, as an OpenAPI 3.1 document. `GET /v1/openapi.json`. */ openapi(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("openapi", args, opts) as Promise; + return this.invoke("openapi", args, opts) as Promise } /** * Check a script's servers are ready before running it. `POST /v1/preflight`. */ preflight(args: { source: string }, opts: CallOptions = {}): Promise { - return this.invoke("preflight", args, opts) as Promise; + return this.invoke("preflight", args, opts) as Promise } /** * Render one prompt with its arguments filled in. `POST /v1/prompt`. */ - promptGet( - args: { server: string; name: string; arguments?: Record; sessionId?: string; callId?: string }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("prompt_get", args, opts) as Promise; + promptGet(args: { server: string; name: string; arguments?: Record; sessionId?: string; callId?: string }, opts: CallOptions = {}): Promise { + return this.invoke("prompt_get", args, opts) as Promise } /** * Every prompt the configured servers offer. `GET /v1/prompts`. */ prompts(args: { ns?: string } = {}, opts: CallOptions = {}): Promise { - return this.invoke("prompts", args, opts) as Promise; + return this.invoke("prompts", args, opts) as Promise } /** * Which MCP revisions mcpx speaks, in both directions. `GET /v1/protocol`. */ protocol(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("protocol", args, opts) as Promise; + return this.invoke("protocol", args, opts) as Promise } /** * One recipe, with its source. `GET /v1/recipes/{name}`. */ recipeGet(args: { name: string }, opts: CallOptions = {}): Promise { - return this.invoke("recipe_get", args, opts) as Promise; + return this.invoke("recipe_get", args, opts) as Promise } /** * Run a recipe with its placeholders filled in. `POST /v1/recipes/{name}/run`. */ - recipeRun( - args: { name: string; placeholders?: Record; autonomy?: "propose" | "run"; session?: string }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("recipe_run", args, opts) as Promise; + recipeRun(args: { name: string; placeholders?: Record; autonomy?: "propose" | "run"; session?: string }, opts: CallOptions = {}): Promise { + return this.invoke("recipe_run", args, opts) as Promise } /** * Save a script as a recipe. `POST /v1/recipes/{name}`. */ recipeSave(args: { name: string; source: string; overwrite?: boolean }, opts: CallOptions = {}): Promise { - return this.invoke("recipe_save", args, opts) as Promise; + return this.invoke("recipe_save", args, opts) as Promise } /** * Saved scripts, with the placeholders each takes. `GET /v1/recipes`. */ recipesList(args: { q?: string; limit?: number } = {}, opts: CallOptions = {}): Promise { - return this.invoke("recipes_list", args, opts) as Promise; + return this.invoke("recipes_list", args, opts) as Promise } /** @@ -1389,14 +1256,14 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ refresh(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("refresh", args, opts) as Promise; + return this.invoke("refresh", args, opts) as Promise } /** * Search a public registry of MCP servers. `GET /v1/registry/search`. */ registrySearch(args: { q: string; limit?: number }, opts: CallOptions = {}): Promise { - return this.invoke("registry_search", args, opts) as Promise; + return this.invoke("registry_search", args, opts) as Promise } /** @@ -1404,38 +1271,35 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ reload(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("reload", args, opts) as Promise; + return this.invoke("reload", args, opts) as Promise } /** * Which daemon serves a directory. `GET /v1/resolve`. */ resolve(args: { dir: string }, opts: CallOptions = {}): Promise { - return this.invoke("resolve", args, opts) as Promise; + return this.invoke("resolve", args, opts) as Promise } /** * Read one resource from one server. `POST /v1/resource`. */ - resourceRead( - args: { server: string; uri: string; session?: string; context?: Record }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("resource_read", args, opts) as Promise; + resourceRead(args: { server: string; uri: string; session?: string; context?: Record }, opts: CallOptions = {}): Promise { + return this.invoke("resource_read", args, opts) as Promise } /** * Every templated resource the configured servers offer. `GET /v1/resource-templates`. */ resourceTemplates(args: { ns?: string } = {}, opts: CallOptions = {}): Promise { - return this.invoke("resource_templates", args, opts) as Promise; + return this.invoke("resource_templates", args, opts) as Promise } /** * Every resource the configured servers offer. `GET /v1/resources`. */ resources(args: { ns?: string } = {}, opts: CallOptions = {}): Promise { - return this.invoke("resources", args, opts) as Promise; + return this.invoke("resources", args, opts) as Promise } /** @@ -1444,14 +1308,14 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ restart(args: { server?: string; lazy?: boolean } = {}, opts: CallOptions = {}): Promise { - return this.invoke("restart", args, opts) as Promise; + return this.invoke("restart", args, opts) as Promise } /** * Rank tools against a query. `GET /v1/search`. */ search(args: { q: string; limit?: number; semantic?: boolean }, opts: CallOptions = {}): Promise { - return this.invoke("search", args, opts) as Promise; + return this.invoke("search", args, opts) as Promise } /** @@ -1459,28 +1323,28 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ secretRequestDecline(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("secret_request_decline", args, opts) as Promise; + return this.invoke("secret_request_decline", args, opts) as Promise } /** * One secret request, and whether it is still waiting. `GET /v1/secret-requests/{id}`. */ secretRequestGet(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("secret_request_get", args, opts) as Promise; + return this.invoke("secret_request_get", args, opts) as Promise } /** * Requests waiting for a person to give secrets. `GET /v1/secret-requests`. */ secretRequestsList(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("secret_requests_list", args, opts) as Promise; + return this.invoke("secret_requests_list", args, opts) as Promise } /** * Which secrets servers need, and which of them have a value. `GET /v1/secrets`. */ secretsList(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("secrets_list", args, opts) as Promise; + return this.invoke("secrets_list", args, opts) as Promise } /** @@ -1488,7 +1352,7 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ secretsSet(args: { name: string; value: string }, opts: CallOptions = {}): Promise { - return this.invoke("secrets_set", args, opts) as Promise; + return this.invoke("secrets_set", args, opts) as Promise } /** @@ -1497,43 +1361,29 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ secretsUnset(args: { name: string }, opts: CallOptions = {}): Promise { - return this.invoke("secrets_unset", args, opts) as Promise; + return this.invoke("secrets_unset", args, opts) as Promise } /** * Add a server, live. `POST /v1/servers`. * Privileged: it changes the daemon rather than reading it. */ - serversAdd( - args: { - name: string; - command?: string; - args?: unknown[]; - env?: Record; - url?: string; - headers?: Record; - transport?: "stdio" | "http" | "sse"; - mcpx?: Record; - scope?: "project" | "user"; - replace?: boolean; - }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("servers_add", args, opts) as Promise; + serversAdd(args: { name: string; command?: string; args?: unknown[]; env?: Record; url?: string; headers?: Record; transport?: "stdio" | "http" | "sse"; mcpx?: Record; scope?: "project" | "user"; replace?: boolean }, opts: CallOptions = {}): Promise { + return this.invoke("servers_add", args, opts) as Promise } /** * One configured server, and whether it can run now. `GET /v1/servers/{name}`. */ serversGet(args: { name: string }, opts: CallOptions = {}): Promise { - return this.invoke("servers_get", args, opts) as Promise; + return this.invoke("servers_get", args, opts) as Promise } /** * Every configured server as it is written in the configuration. `GET /v1/servers`. */ serversList(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("servers_list", args, opts) as Promise; + return this.invoke("servers_list", args, opts) as Promise } /** @@ -1542,7 +1392,7 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ serversRemove(args: { name: string; scope?: "project" | "user" }, opts: CallOptions = {}): Promise { - return this.invoke("servers_remove", args, opts) as Promise; + return this.invoke("servers_remove", args, opts) as Promise } /** @@ -1550,35 +1400,29 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ sessionRelease(args: { session: string }, opts: CallOptions = {}): Promise { - return this.invoke("session_release", args, opts) as Promise; + return this.invoke("session_release", args, opts) as Promise } /** * One setting. `GET /v1/settings/{path}`. */ settingsGet(args: { path: string }, opts: CallOptions = {}): Promise { - return this.invoke("settings_get", args, opts) as Promise; + return this.invoke("settings_get", args, opts) as Promise } /** * Every setting, its effective value and where that value came from. `GET /v1/settings`. */ - settingsList( - args: { scope?: "daemon" | "client" | "call" | "plugin"; plumbing?: "0" | "1"; changed?: "0" | "1" } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("settings_list", args, opts) as Promise; + settingsList(args: { scope?: "daemon" | "client" | "call" | "plugin"; plumbing?: "0" | "1"; changed?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("settings_list", args, opts) as Promise } /** * Change a setting. `PUT /v1/settings/{path}`. * Privileged: it changes the daemon rather than reading it. */ - settingsSet( - args: { path: string; value: string; persist?: "runtime" | "project" | "user" }, - opts: CallOptions = {}, - ): Promise { - return this.invoke("settings_set", args, opts) as Promise; + settingsSet(args: { path: string; value: string; persist?: "runtime" | "project" | "user" }, opts: CallOptions = {}): Promise { + return this.invoke("settings_set", args, opts) as Promise } /** @@ -1586,7 +1430,7 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ settingsUnset(args: { path: string }, opts: CallOptions = {}): Promise { - return this.invoke("settings_unset", args, opts) as Promise; + return this.invoke("settings_unset", args, opts) as Promise } /** @@ -1595,90 +1439,70 @@ export class DaemonOps { * Destructive: it cannot be undone, and other callers are affected. */ shutdown(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("shutdown", args, opts) as Promise; + return this.invoke("shutdown", args, opts) as Promise } /** * Aggregate the log into numbers. `GET /v1/stats`. */ - statsQuery( - args: { - by?: "calls" | "servers" | "instances" | "errors" | "sessions" | "volume" | "slowest"; - since?: string; - until?: string; - server?: string; - tool?: string; - session?: string; - top?: number; - } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("stats_query", args, opts) as Promise; + statsQuery(args: { by?: "calls" | "servers" | "instances" | "errors" | "sessions" | "volume" | "slowest"; since?: string; until?: string; server?: string; tool?: string; session?: string; top?: number } = {}, opts: CallOptions = {}): Promise { + return this.invoke("stats_query", args, opts) as Promise } /** * The daemon, its pools and live instances. `GET /v1/status`. */ status(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("status", args, opts) as Promise; + return this.invoke("status", args, opts) as Promise } /** * Cancel a running task. `POST /v1/tasks/{id}/cancel`. */ taskCancel(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("task_cancel", args, opts) as Promise; + return this.invoke("task_cancel", args, opts) as Promise } /** * One task's status. `GET /v1/tasks/{id}`. */ taskGet(args: { id: string }, opts: CallOptions = {}): Promise { - return this.invoke("task_get", args, opts) as Promise; + return this.invoke("task_get", args, opts) as Promise } /** * Wait for a task and collect its result. `GET /v1/tasks/{id}/result`. */ taskResult(args: { id: string; waitMs?: number }, opts: CallOptions = {}): Promise { - return this.invoke("task_result", args, opts) as Promise; + return this.invoke("task_result", args, opts) as Promise } /** * Background calls and their status. `GET /v1/tasks`. */ tasksList(args: Record = {}, opts: CallOptions = {}): Promise { - return this.invoke("tasks_list", args, opts) as Promise; + return this.invoke("tasks_list", args, opts) as Promise } /** * Run one of mcpx's own MCP tools as a plain POST. `POST /v1/tools/{tool}`. */ toolInvoke(args: { tool: string; arguments?: Record }, opts: CallOptions = {}): Promise { - return this.invoke("tool_invoke", args, opts) as Promise; + return this.invoke("tool_invoke", args, opts) as Promise } /** * Every tool of every configured server. `GET /v1/tools`. */ tools(args: { ns?: string } = {}, opts: CallOptions = {}): Promise { - return this.invoke("tools", args, opts) as Promise; + return this.invoke("tools", args, opts) as Promise } /** * TypeScript declarations for the named namespaces. `GET /v1/types`. */ - types( - args: { - ns?: string; - instructions?: "0" | "1"; - profile?: string; - skipDefault?: "0" | "1"; - allProfiles?: "0" | "1"; - } = {}, - opts: CallOptions = {}, - ): Promise { - return this.invoke("types", args, opts) as Promise; + types(args: { ns?: string; instructions?: "0" | "1"; profile?: string; skipDefault?: "0" | "1"; allProfiles?: "0" | "1" } = {}, opts: CallOptions = {}): Promise { + return this.invoke("types", args, opts) as Promise } /** @@ -1686,6 +1510,6 @@ export class DaemonOps { * Privileged: it changes the daemon rather than reading it. */ writesClear(args: { server: string }, opts: CallOptions = {}): Promise { - return this.invoke("writes_clear", args, opts) as Promise; + return this.invoke("writes_clear", args, opts) as Promise } }