constructor-research-mcp 0.6.4 → 0.6.7-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/INSTALL.md CHANGED
@@ -70,6 +70,8 @@ The first start downloads the package and can exceed Codex's 10-second start lim
70
70
  [mcp_servers.constructor-research]
71
71
  command = "npx"
72
72
  args = ["-y", "constructor-research-mcp@latest"]
73
+ # Inside a Constructor desk: pass the desk and its access key on (Codex passes only a few variables).
74
+ env_vars = ["ROLOS_PROJECT_ID", "ROLOS_DESK_ID", "ROLOS_API_SERVER", "RESEARCH_PROJECT_ID", "RESEARCH_DESK_ID", "RESEARCH_API_SERVER", "RESEARCH_ACCESS_KEY"]
73
75
  startup_timeout_sec = 60
74
76
  tool_timeout_sec = 30
75
77
 
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Constructor Research MCP
2
2
 
3
+ > **0.6.7-beta.0** (npm `beta`; install with `npx -y constructor-research-mcp@beta install`, which keeps the agents on `beta`): every result's text carries what an agent acts on, for clients that show only text (OpenCode): project, application and service IDs, statuses, volumes and public URLs; per build its status, elapsed time, log coverage and step durations; on failure every error found in the whole kept build log, its cause (compile, transient, unknown), and whether each service runs the image this deployment built. A compile error is no longer rebuilt automatically. `update_app` without `project_id` finds the project from `application_id` when exactly one project has it. Lines written together with one timestamp are no longer dropped from kept logs, and secrets are masked in them. Includes 0.6.6 (IDs in the discovery and waiter text), which was not published.
4
+ >
5
+ > **0.6.5:** inside a Constructor desk, the MCP uses the access key the desk provides (`RESEARCH_ACCESS_KEY`), so the user needs no key of their own (once Research sets it); the Codex entry passes the desk's variables on to the MCP.
6
+ >
3
7
  > **0.6.4:** with no project or desk named (and not inside a desk), `deploy_app` creates a new project from a short `project_name` and deploys there.
4
8
  >
5
9
  > **0.6.3:** `delete_resources` deletes applications, services and images, after the user approves the list.
@@ -64,23 +68,24 @@ npx -y -p constructor-research-mcp@latest constructor-research-set-key https://a
64
68
 
65
69
  It goes to `~/.config/constructor-research/access-key.json` (mode 600) together with the Constructor it belongs to, and the MCP works with that Constructor. All harnesses (Claude Code, Codex, OpenCode) and the wait command share this one file. Every request rereads it, so a new key needs no restart. A key is never sent to a Constructor other than the one it was saved for.
66
70
 
67
- `CONSTRUCTOR_ACCESS_KEY` in the MCP settings takes precedence over the file. The wait hooks do not see the MCP settings: with the key there, give the hooks the same two variables in their own environment, or save the key with `set-key` as well.
71
+ `CONSTRUCTOR_ACCESS_KEY` in the MCP settings takes precedence over the file and over a desk's key. The wait hooks do not see the MCP settings: with the key there, give the hooks the same two variables in their own environment, or save the key with `set-key` as well.
68
72
 
69
73
  Without a key, or when Constructor rejects it (401: revoked, expired or for another Constructor), tools return `needs_key` with the command above; a deployment pauses as `needs_key` and resumes on the next check once a valid key is saved. A desk link from another Constructor returns `wrong_environment`.
70
74
 
71
75
  Deployment must be switched on for the project. When it is off, the MCP switches it on (`POST /projects/{id}/deployment`), which only the project owner may do. For anyone else (error 40005), the operation fails at stage `prepare` with a message asking the project owner to switch it on in Constructor.
72
76
 
73
- | Variable | Default |
74
- | ----------------------------------- | ----------------------------------------------------------------------------------------------- |
75
- | `CONSTRUCTOR_BASE_URL` | unset: the Constructor of the saved key, else `https://constructor.app`; set, it fixes the host |
76
- | `CONSTRUCTOR_API_PATH` | `/api/platform-account/v1` |
77
- | `CONSTRUCTOR_STORAGE_PATH` | `/api/platform-storage` |
78
- | `CONSTRUCTOR_ACCESS_KEY` | unset: the key file is used |
79
- | `CONSTRUCTOR_KEY_FILE` | `~/.config/constructor-research/access-key.json` |
80
- | `CONSTRUCTOR_DESK_ROOT` | `~/project` (inside a desk only) |
81
- | `CONSTRUCTOR_STATE_DIR` | `~/.local/state/constructor-research-mcp` |
82
- | `CONSTRUCTOR_UPLOAD_SETTLE_SECONDS` | `30` |
83
- | `CONSTRUCTOR_READINESS_SECONDS` | `60` |
77
+ | Variable | Default |
78
+ | ----------------------------------- | ------------------------------------------------------------------------------------------------------ |
79
+ | `CONSTRUCTOR_BASE_URL` | unset: the Constructor of the saved key, else `https://constructor.app`; set, it fixes the host |
80
+ | `CONSTRUCTOR_API_PATH` | `/api/platform-account/v1` |
81
+ | `CONSTRUCTOR_STORAGE_PATH` | `/api/platform-storage` |
82
+ | `CONSTRUCTOR_ACCESS_KEY` | unset: the key file is used |
83
+ | `RESEARCH_ACCESS_KEY` | set by Constructor Research inside a desk: the desk's key, used when `CONSTRUCTOR_ACCESS_KEY` is unset |
84
+ | `CONSTRUCTOR_KEY_FILE` | `~/.config/constructor-research/access-key.json` |
85
+ | `CONSTRUCTOR_DESK_ROOT` | `~/project` (inside a desk only) |
86
+ | `CONSTRUCTOR_STATE_DIR` | `~/.local/state/constructor-research-mcp` |
87
+ | `CONSTRUCTOR_UPLOAD_SETTLE_SECONDS` | `30` |
88
+ | `CONSTRUCTOR_READINESS_SECONDS` | `60` |
84
89
 
85
90
  HTTPS is required except on localhost.
86
91
 
@@ -93,6 +98,10 @@ When the MCP runs in VS Code inside a Constructor Research desk, it finds that d
93
98
  - `build.dockerfile` is the path inside the project folder (`/backend/Dockerfile`), or `build.local_path` names a folder inside it; Dockerfiles are checked from the local files;
94
99
  - two addresses can lead to the user's Constructor: the one the user named (the saved key's, or `CONSTRUCTOR_BASE_URL`; without either, the desk's server) and the desk's server (`ROLOS_API_SERVER`), which may differ from it, e.g. `https://constructor.app` in a desk opened on `https://acme.constructor.app`. The MCP asks the desk's server once whether it accepts the key: if it does, requests go there, else to the user's address. Links shown to the user and key help keep the user's address, and desk links from either address are accepted. Setup (`install`, `constructor-research-set-key`) checks the key with both and saves it for the user's address when either accepts it.
95
100
 
101
+ - **the desk's access key:** Constructor Research sets `RESEARCH_ACCESS_KEY` in the desk, and the MCP uses it, so the user needs no key of their own and `install` asks for none. A key the user saved for this Constructor stays and takes over when Constructor rejects the desk's key. Once accepted, the desk's key is also saved to the key file, marked `"source": "desk"` (never over a key the user saved), so the wait command and hooks find it even where the agent's shell drops variables named `*KEY*` (Codex does).
102
+
103
+ Codex starts MCP servers with only a few variables (`HOME`, `PATH`, …). Its entry therefore lists the desk's variables in `env_vars` (names only, no values); `install` writes it. Claude Code passes its whole environment on. Agents that pass on neither (Cline) do not see the desk.
104
+
96
105
  `CONSTRUCTOR_LOCAL_DESK=0` turns this off.
97
106
 
98
107
  ## Fourteen tools
@@ -270,8 +279,15 @@ All required builds must succeed before existing services are changed. The MCP s
270
279
  Learned from live runs (28 Oct 2026):
271
280
 
272
281
  - **Upload settle.** A build started right after its Dockerfile was uploaded failed every time; with a pause it built first time. After any upload to a disk, builds on that disk wait until 30 s have passed (status `preparing`, message says so). `CONSTRUCTOR_UPLOAD_SETTLE_SECONDS` changes it; 0 disables.
273
- - **Confirmed failure, one automatic rebuild.** The platform briefly reports `error` and then `in_progress` again, so an error counts only when seen twice for the same image. The first confirmed failure is rebuilt once under a new image name, after re-uploading `local_path` sources and re-checking the Dockerfile on the disk. `build_retried` names the image that failed.
274
- - **Actionable failure.** A build that fails again returns `failure.image_name`, `first_image_name`, `desk_link`, and a message saying how to see the log: Constructor does not keep build logs, so rebuild that Dockerfile from the UI and watch it live.
282
+ - **Confirmed failure, at most one automatic rebuild.** The platform briefly reports `error` and then `in_progress` again, so an error counts only when seen twice for the same image. The MCP then waits (up to 5 s) for the build log to end and classifies the failure from the whole kept log (`build_attempts`, with `cause` and `reason`):
283
+ - `compile`: compiler errors (`error[E…]` from rustc, `error TS…`, `file.go:3: error`, …). Not rebuilt: the same sources fail the same way. Fix them and repeat the call with `deployment_id` and that service's build.
284
+ - `transient`: pulling, registry, network or builder trouble, or files that had not reached the builder (`COPY failed`). Rebuilt once under a new image name, after re-uploading `local_path` sources and re-checking the Dockerfile on the disk.
285
+ - `unknown`: no log, or nothing the MCP recognises. Rebuilt once, and the result says the cause is uncertain.
286
+
287
+ `build_retried` names the image that was rebuilt.
288
+
289
+ - **Actionable failure.** A failed build returns `failure.image_id`, `image_name`, `desk_link`, `cause` and `cause_reason`, `diagnostics` (every error block found in the whole kept log with its location lines, bounded to about 4000 characters, first and last errors kept when some are left out, counted in `diagnostics_found`/`diagnostics_omitted`), `log_tail` (the last 20 lines), `log_coverage` (`complete`: the MCP followed the build to its end; `partial`; `live`; `none`) and `logs_hint` (`get_logs` with the image ID). With no log captured, the message says how to see it: Constructor does not keep build logs, so rebuild that Dockerfile from the UI and watch it live.
290
+ - **What runs now.** A deployment's services show the image each one runs and the image this deployment attempted (`attempted_image_id`, `runs_attempted_image`): after a failed build the old version keeps running, and the text says so instead of calling the app updated.
275
291
  - **Readiness check.** After start, the MCP requests each public URL until it answers (any HTTP status below 500) or 60 s pass (status `verifying`). `readiness` is then `http_ok`, `not_responding` (with `readiness_checks` and a hint; services of the deployment that printed nothing since starting are named, with an ordered checklist: entrypoint not executable, wrong entrypoint path, nginx IPv6 listen, wrong listen address or port), or `no_public_url`. `CONSTRUCTOR_READINESS_SECONDS` changes the window; 0 disables.
276
292
 
277
293
  ## State and recovery
@@ -284,6 +300,16 @@ Terminal states: `built`, `started`, `stopped`, `failed`, `needs_reconciliation`
284
300
 
285
301
  For `needs_reconciliation`, inspect the possible remote mutation before submitting a new operation. The server never blindly repeats an uncertain create. A `.lock` left by a process that no longer exists (a server killed or restarted mid-step) is removed automatically on the next operation; a lock held by a live process returns `busy`. Checkpoints remain available. No rollback or resource deletion is automated.
286
302
 
303
+ ## What an agent reads (text results)
304
+
305
+ Some clients pass the agent only the text of a tool result, never `structuredContent` (OpenCode does). So the text carries everything needed to act; `structuredContent` is unchanged and has the full data.
306
+
307
+ - `get_deployment` with no arguments: every project with deployment on, each application with `application_id`, each service with `service_id`, status, `image_id`, volumes and public URL, and how to call `update_app`. With `project_id` or `desk_url`: the same for one project, plus desks and images.
308
+ - Deployments (`deploy_app`, `update_app`, `build_image`, `start_app`, `stop_app`, `get_deployment` with `deployment_id`, the wait command): status and elapsed time (`running for` or `took`), project and application IDs, each service with its ID, status, the image it runs (and whether that is the image this deployment attempted), volumes, public URL and readiness answer; each build with image ID, status, log coverage and the build steps with their durations; earlier failed attempts with cause and what the MCP did; the failure with its errors; the next step.
309
+ - A value Constructor did not return reads `unavailable`. Long lists are cut with a count; a text is at most 12,000 characters.
310
+
311
+ What Constructor does not report, and the MCP therefore cannot show: build start and end times (elapsed time is counted from the request; build age from the image's `created_at`), build stages (image pull, compile, push, rollout; the step durations come from the timestamps of the kept log lines and include pulling a step's base image), build attempt IDs separate from image IDs, and when a service changed image. A build log the MCP did not follow while the build ran is gone (Constructor answers "not found" after the build).
312
+
287
313
  ## Logs
288
314
 
289
315
  Constructor serves logs only live, as a stream: a build log while the build runs, a service log for the service's current container. Each connection replays the log from the start, then streams. Nothing is kept afterwards: a finished build has no log, and a restarted container starts with an empty one, so a crash-looping service shows no log at all. The MCP therefore follows every build and service it starts and keeps the last 2000 lines of each in `logs/` in the state directory, where other MCP processes, the wait command and a restarted agent read them too. Files untouched for 14 days are deleted, and the oldest go first when all of them pass 100 MB.
@@ -293,12 +319,14 @@ Constructor serves logs only live, as a stream: a build log while the build runs
293
319
  - Restarts: Constructor reports no restart count, so the MCP detects them in the stream. When a new container starts (the platform's "Container is waiting to start" line after the container's own lines, or a reconnect that begins with newer lines than were kept), it inserts `--- new container (restart N) ---` and keeps the old container's last lines above it, which usually show why it stopped. `get_logs` and the services in `get_deployment` report `restarts_seen` and `restarted_at`.
294
320
  - `get_deployment` services also carry `status_changes`: the native statuses this MCP process saw, with times, once a service has had more than one.
295
321
  - Lines that are only a timestamp are dropped, and identical consecutive lines are collapsed into one with a count (`(×5)`).
296
- - A failed build or start puts the last 20 lines into `failure.log_tail`.
322
+ - A failed build or start puts the last 20 lines into `failure.log_tail` and the errors from the whole kept log into `failure.diagnostics`.
323
+ - Kept lines are masked: access keys (`rk-…`), bearer tokens, passwords in URLs and `NAME=value` pairs whose name says token, secret, password or key.
324
+ - Several lines written at once can carry the same timestamp; all of them are kept, and a reconnect skips exactly the ones already kept.
297
325
  - `get_logs` takes `image_id`, `service_id` or `deployment_id` (all its builds and services) and `lines` (10–500, default 20). It also reads builds and services this MCP did not start, but only while they run.
298
326
 
299
327
  ## Waiting for long builds
300
328
 
301
- Builds can run for many minutes. The MCP keeps executing in the background, but an agent that has ended its turn is not told when they finish. `dist/wait.js` (bin `constructor-research-wait`) blocks until the given deployments, or all in-progress ones when no ID is given, finish, and prints one line each: status, message, services with public URLs, next step. Exit codes: `0` finished, `2` needs the user (failed, key, upload, volume confirmation), `3` still running at `--max-minutes` (default 60), `4` nothing in progress.
329
+ Builds can run for many minutes. The MCP keeps executing in the background, but an agent that has ended its turn is not told when they finish. `dist/wait.js` (bin `constructor-research-wait`) blocks until the given deployments, or all in-progress ones when no ID is given, finish, and prints for each the same text `get_deployment` returns: status and elapsed time, services with IDs and public URLs, builds, failure with errors, next step. Exit codes: `0` finished, `2` needs the user (failed, key, upload, volume confirmation), `3` still running at `--max-minutes` (default 60), `4` nothing in progress. Do not pipe it into `tail` or `head`: a pipeline returns the last command's exit code, so a failure reads as success. If you must, run `set -o pipefail` first.
302
330
 
303
331
  ```sh
304
332
  npx -y -p constructor-research-mcp@latest constructor-research-wait <deployment_id>
package/dist/agents.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export declare const SERVER = "constructor-research";
2
- export declare const PACKAGE_SPEC = "constructor-research-mcp@latest";
2
+ /** A beta stays on beta: its installer must not point agents back at latest. */
3
+ export declare const PACKAGE_SPEC: string;
3
4
  export type Scope = "project" | "global";
4
5
  export type Kind = "claude" | "codex" | "opencode" | "cline" | "jcode" | "mcpServers";
5
6
  export interface Spec {
@@ -41,7 +42,11 @@ export interface Result {
41
42
  export declare const succeeded: (r: Result) => boolean;
42
43
  /** The entry as each agent expects it. */
43
44
  export declare function entryFor(kind: Kind, spec: Spec, opencodeV2?: boolean): object;
44
- /** Codex: the first npx start downloads the package and can exceed Codex's 10 s start limit. */
45
+ /**
46
+ * Codex: the first npx start downloads the package and can exceed Codex's 10 s start limit.
47
+ * Codex starts MCP servers with only a few variables (HOME, PATH, …); env_vars passes on the
48
+ * ones a Constructor desk sets, names only, so the MCP finds the desk and the desk's key.
49
+ */
45
50
  export declare const tomlBlock: ({ command, args }: Spec) => string;
46
51
  /** What will be written, for --verbose. */
47
52
  export declare function describe(kind: Kind, spec: Spec, opencodeV2?: boolean): string[];
package/dist/agents.js CHANGED
@@ -12,8 +12,11 @@ import { homedir } from "node:os";
12
12
  import { basename, dirname, join } from "node:path";
13
13
  import { isDeepStrictEqual } from "node:util";
14
14
  import { parse as parseToml } from "smol-toml";
15
+ import { DESK_ENV } from "./desk.js";
16
+ import { CHANNEL } from "./config.js";
15
17
  export const SERVER = "constructor-research";
16
- export const PACKAGE_SPEC = "constructor-research-mcp@latest";
18
+ /** A beta stays on beta: its installer must not point agents back at latest. */
19
+ export const PACKAGE_SPEC = `constructor-research-mcp@${CHANNEL}`;
17
20
  /** The command every agent runs. On Windows npx is a .cmd script, which agents start through cmd. */
18
21
  export function mcpCommand(platform = process.platform) {
19
22
  return platform === "win32"
@@ -163,8 +166,12 @@ export function entryFor(kind, spec, opencodeV2 = false) {
163
166
  }
164
167
  }
165
168
  const tomlString = (s) => JSON.stringify(s);
166
- /** Codex: the first npx start downloads the package and can exceed Codex's 10 s start limit. */
167
- export const tomlBlock = ({ command, args }) => `[mcp_servers.${SERVER}]\ncommand = ${tomlString(command)}\nargs = [${args.map(tomlString).join(", ")}]\nstartup_timeout_sec = 60\n`;
169
+ /**
170
+ * Codex: the first npx start downloads the package and can exceed Codex's 10 s start limit.
171
+ * Codex starts MCP servers with only a few variables (HOME, PATH, …); env_vars passes on the
172
+ * ones a Constructor desk sets, names only, so the MCP finds the desk and the desk's key.
173
+ */
174
+ export const tomlBlock = ({ command, args }) => `[mcp_servers.${SERVER}]\ncommand = ${tomlString(command)}\nargs = [${args.map(tomlString).join(", ")}]\nenv_vars = [${DESK_ENV.map(tomlString).join(", ")}]\nstartup_timeout_sec = 60\n`;
168
175
  /** What will be written, for --verbose. */
169
176
  export function describe(kind, spec, opencodeV2 = false) {
170
177
  if (kind === "codex")
@@ -349,7 +356,11 @@ export function writeToml(path, spec, scope) {
349
356
  return untouched("could not be edited safely");
350
357
  }
351
358
  const entry = after.mcp_servers?.[SERVER];
352
- if (!isDeepStrictEqual(plain(entry), { ...spec, startup_timeout_sec: 60 }) ||
359
+ if (!isDeepStrictEqual(plain(entry), {
360
+ ...spec,
361
+ env_vars: DESK_ENV,
362
+ startup_timeout_sec: 60,
363
+ }) ||
353
364
  !isDeepStrictEqual(withoutOurs(parseToml(old)), withoutOurs(after)))
354
365
  return untouched(`sets ${SERVER} in a form this setup does not edit`);
355
366
  const backup = backupOnce(file);
package/dist/api.d.ts CHANGED
@@ -38,6 +38,18 @@ export declare class PlatformApi {
38
38
  * changes; an unreachable server is asked again after a minute.
39
39
  */
40
40
  origin(key: string): Promise<string>;
41
+ /** What Constructor said about the desk's key; see deskKey(). */
42
+ private deskCheck?;
43
+ /**
44
+ * Inside a Constructor desk, RESEARCH_ACCESS_KEY is the key the desk provides, so the user
45
+ * need not supply one. It is used first; a key the user saved for this Constructor takes over
46
+ * when Constructor rejects it. Once accepted it is saved to the key file (marked "desk") unless
47
+ * the user saved a key of their own there, so the wait command and hooks find it even when the
48
+ * agent's shell drops variables named *KEY*. Constructor is asked about the key once, and only
49
+ * when there is a choice or something to save.
50
+ */
51
+ private deskKey;
52
+ private checkDeskKey;
41
53
  /** The access-key header for a request, and the origin the request goes to. */
42
54
  private auth;
43
55
  private rejected;
package/dist/api.js CHANGED
@@ -2,7 +2,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { createHash } from "node:crypto";
3
3
  import { setTimeout as delay } from "node:timers/promises";
4
4
  import { DEFAULT_BASE_URL, VERSION } from "./config.js";
5
- import { readKeyFile, routeKey } from "./key.js";
5
+ import { readKeyFile, routeKey, saveKeyFile, } from "./key.js";
6
6
  export class ToolError extends Error {
7
7
  code;
8
8
  status;
@@ -49,6 +49,7 @@ export class PlatformApi {
49
49
  * Read before every tool call, so a key saved meanwhile is used without a restart.
50
50
  */
51
51
  async refresh() {
52
+ // A key in the MCP settings names no Constructor; it wins over the desk's and the file's.
52
53
  if (this.config.baseUrlFixed || this.config.accessKey)
53
54
  return;
54
55
  const saved = await readKeyFile(this.config.keyFile).catch(() => undefined);
@@ -88,10 +89,68 @@ export class PlatformApi {
88
89
  this.route = route;
89
90
  return route.origin;
90
91
  }
92
+ /** What Constructor said about the desk's key; see deskKey(). */
93
+ deskCheck;
94
+ /**
95
+ * Inside a Constructor desk, RESEARCH_ACCESS_KEY is the key the desk provides, so the user
96
+ * need not supply one. It is used first; a key the user saved for this Constructor takes over
97
+ * when Constructor rejects it. Once accepted it is saved to the key file (marked "desk") unless
98
+ * the user saved a key of their own there, so the wait command and hooks find it even when the
99
+ * agent's shell drops variables named *KEY*. Constructor is asked about the key once, and only
100
+ * when there is a choice or something to save.
101
+ */
102
+ async deskKey(env, saved) {
103
+ const usable = saved?.url === this.config.baseUrl ? saved : undefined;
104
+ const clean = cleanKey(env);
105
+ if (!clean)
106
+ return usable?.key ?? env;
107
+ if (usable && cleanKey(usable.key) === clean)
108
+ return clean;
109
+ const save = !saved || (saved.source === "desk" && !!usable);
110
+ if (!usable && !save)
111
+ return clean;
112
+ const result = await this.checkDeskKey(clean);
113
+ if (result === "rejected") {
114
+ if (usable)
115
+ return usable.key;
116
+ throw new ToolError("needs_key", this.keyHelp("Constructor rejected the access key this desk provides (RESEARCH_ACCESS_KEY)."), 401);
117
+ }
118
+ if (result === "ok" && save)
119
+ await saveKeyFile(this.config.keyFile, this.config.baseUrl, clean, "desk")
120
+ // The key still works from the environment; only the wait command misses the copy.
121
+ .catch(() => undefined);
122
+ return clean;
123
+ }
124
+ checkDeskKey(key) {
125
+ const home = this.config.baseUrl;
126
+ const server = this.config.localDesk?.server;
127
+ const tag = createHash("sha256")
128
+ .update(`${home}\n${server}\n${key}`)
129
+ .digest("hex");
130
+ if (this.deskCheck?.tag === tag && Date.now() < this.deskCheck.until)
131
+ return this.deskCheck.result;
132
+ const check = {
133
+ tag,
134
+ until: Infinity,
135
+ result: routeKey(home, server, this.config.apiPath, key, {
136
+ checkHome: true,
137
+ timeoutMs: Math.min(5000, this.config.requestTimeoutMs),
138
+ }).then((r) => {
139
+ // Only a clear yes or no holds; an unreachable Constructor is asked again in a minute.
140
+ if (r.result !== "ok" && r.result !== "rejected")
141
+ check.until = Date.now() + 60000;
142
+ return r.result ?? "unreachable";
143
+ }),
144
+ };
145
+ this.deskCheck = check;
146
+ return check.result;
147
+ }
91
148
  /** The access-key header for a request, and the origin the request goes to. */
92
149
  async auth() {
93
150
  let key = this.config.accessKey;
94
- if (key === undefined) {
151
+ if (key === undefined && this.config.deskKey)
152
+ key = await this.deskKey(this.config.deskKey, await readKeyFile(this.config.keyFile).catch(() => undefined));
153
+ else if (key === undefined) {
95
154
  let saved;
96
155
  try {
97
156
  saved = await readKeyFile(this.config.keyFile);
@@ -115,6 +174,9 @@ export class PlatformApi {
115
174
  };
116
175
  }
117
176
  rejected() {
177
+ // The next call asks again which key to use and where it goes.
178
+ this.deskCheck = undefined;
179
+ this.route = undefined;
118
180
  return new ToolError("needs_key", this.keyHelp("Constructor rejected the access key (revoked, expired or for another Constructor)."), 401);
119
181
  }
120
182
  /**
package/dist/config.d.ts CHANGED
@@ -16,6 +16,8 @@ export interface Config {
16
16
  keeperPath?: string;
17
17
  /** Personal access key (rk-…) from CONSTRUCTOR_ACCESS_KEY; without it the key file is read. */
18
18
  accessKey?: string;
19
+ /** Inside a desk: the access key Constructor Research provides there (RESEARCH_ACCESS_KEY). */
20
+ deskKey?: string;
19
21
  /** Saved key and the Constructor it belongs to (JSON, mode 600); CONSTRUCTOR_KEY_FILE moves it. */
20
22
  keyFile: string;
21
23
  stateDir: string;
@@ -34,8 +36,12 @@ export declare function configFromEnv(env?: NodeJS.ProcessEnv): Config;
34
36
  export declare const DEFAULT_KEY_FILE = "~/.config/constructor-research/access-key.json";
35
37
  /** Shell command that waits for deployments, carrying the settings that differ from the defaults. */
36
38
  export declare function waitCommand(config: Config, ids: string[]): string;
39
+ /** The npm dist-tag this version is published under: a prerelease (0.6.7-beta.0) goes to beta. */
40
+ export declare const channel: (version: string) => "beta" | "latest";
37
41
  /** This package's version, as published; the server reports it on connect. */
38
42
  export declare const VERSION: string;
43
+ /** Where agents and hooks set up by this version get the MCP from: the same channel. */
44
+ export declare const CHANNEL: string;
39
45
  /**
40
46
  * How to run the wait CLI of this very version. Run through npx, the MCP lives in npx's
41
47
  * cache, whose folder npm may replace at any time, so the hint names the package instead.
package/dist/config.js CHANGED
@@ -50,6 +50,7 @@ export function configFromEnv(env = process.env) {
50
50
  storagePath: storagePath.replace(/\/$/, ""),
51
51
  keeperPath: keeperPath.replace(/\/$/, ""),
52
52
  accessKey: env.CONSTRUCTOR_ACCESS_KEY?.trim() || undefined,
53
+ deskKey: (localDesk && env.RESEARCH_ACCESS_KEY?.trim()) || undefined,
53
54
  keyFile: expand(env.CONSTRUCTOR_KEY_FILE ?? DEFAULT_KEY_FILE),
54
55
  stateDir: expand(env.CONSTRUCTOR_STATE_DIR ?? "~/.local/state/constructor-research-mcp"),
55
56
  requestTimeoutMs: 15000,
@@ -82,8 +83,12 @@ export function waitCommand(config, ids) {
82
83
  .join("");
83
84
  return `${env}${waitProgram()} ${ids.join(" ")}`;
84
85
  }
86
+ /** The npm dist-tag this version is published under: a prerelease (0.6.7-beta.0) goes to beta. */
87
+ export const channel = (version) => version.includes("-") ? "beta" : "latest";
85
88
  /** This package's version, as published; the server reports it on connect. */
86
89
  export const VERSION = JSON.parse(readFileSync(join(fileURLToPath(import.meta.url), "..", "..", "package.json"), "utf8")).version;
90
+ /** Where agents and hooks set up by this version get the MCP from: the same channel. */
91
+ export const CHANNEL = channel(VERSION);
87
92
  /**
88
93
  * How to run the wait CLI of this very version. Run through npx, the MCP lives in npx's
89
94
  * cache, whose folder npm may replace at any time, so the hint names the package instead.
@@ -153,6 +153,12 @@ export declare class DeploymentEngine {
153
153
  private supersede;
154
154
  private resume;
155
155
  observe(id: string): Promise<any>;
156
+ /**
157
+ * The project of an application, for an update that names only application_id. Earlier
158
+ * deployments on this machine are asked first, then every project with deployment on; the
159
+ * answer is used only when exactly one project has the application. Never by name.
160
+ */
161
+ locateApplication(applicationId: string): Promise<string>;
156
162
  /** Map of every deployment-enabled project with its applications and services. */
157
163
  private overview;
158
164
  get(raw: unknown): Promise<any>;
@@ -198,6 +204,12 @@ export declare class DeploymentEngine {
198
204
  }> | undefined;
199
205
  message: string;
200
206
  };
207
+ /**
208
+ * The builds of this operation: each service's current image with its status, name and
209
+ * age, plus what the kept build log shows (coverage, steps with their durations, the step
210
+ * running now). Constructor reports only build_status; the rest comes from the log stamps.
211
+ */
212
+ private buildViews;
201
213
  private view;
202
214
  }
203
215
  /**