@nexrall/code-core 1.4.67 → 1.4.69

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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA8B,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAiErH,eAAO,MAAM,QAAQ,QAAmB,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5D,OAAO,EAAE,CAAC,EAAE,EACZ,UAAU,EAAE,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,CAAC,EAAE,CAeL;AAiGD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IACnC,oFAAoF;IACpF,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IACjG,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6IAA6I;IAC7I,MAA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sE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,OAAO,CAAC,aAAa,CAAC,CAYzB;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;IACL,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACA,OAAO,CAAC,aAAa,CAAC,CAYxB;AAED,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAI5E;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAKlF"}
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.API_BASE = void 0;
6
+ exports.SCHEDULE_MAX_MINUTES = exports.SCHEDULE_MIN_MINUTES = exports.API_BASE = void 0;
7
7
  exports.chooseFinalContent = chooseFinalContent;
8
+ exports.refreshAccessToken = refreshAccessToken;
8
9
  exports.earlyToolResolveEnabled = earlyToolResolveEnabled;
9
10
  exports.gzipRequestsEnabled = gzipRequestsEnabled;
10
11
  exports.streamChat = streamChat;
@@ -20,6 +21,13 @@ exports.getUsageDaily = getUsageDaily;
20
21
  exports.exchangeVscodeCode = exchangeVscodeCode;
21
22
  exports.login = login;
22
23
  exports.getUserProfile = getUserProfile;
24
+ exports.clampScheduleMinutes = clampScheduleMinutes;
25
+ exports.listCloudSchedules = listCloudSchedules;
26
+ exports.createCloudSchedule = createCloudSchedule;
27
+ exports.updateCloudSchedule = updateCloudSchedule;
28
+ exports.deleteCloudSchedule = deleteCloudSchedule;
29
+ exports.runCloudScheduleNow = runCloudScheduleNow;
30
+ exports.getCloudScheduleRuns = getCloudScheduleRuns;
23
31
  const eventsource_parser_1 = require("eventsource-parser");
24
32
  const node_fetch_1 = __importDefault(require("node-fetch"));
25
33
  const crypto_1 = require("crypto");
@@ -152,6 +160,12 @@ let _refreshInFlight = null;
152
160
  *
153
161
  * Deliberately never throws: every call site treats `false` as "carry on and let
154
162
  * the original 401/403 surface", which is the correct fallback in all cases.
163
+ *
164
+ * Exported for holders of a LONG-LIVED connection that authenticates once and
165
+ * then reconnects on its own schedule (the §93 session-share socket): its auth
166
+ * callback runs per reconnect attempt, and without this it could not recover
167
+ * from an access token that expired mid-session even though the refresh token
168
+ * is still good.
155
169
  */
156
170
  async function refreshAccessToken() {
157
171
  if (_refreshInFlight)
@@ -1982,4 +1996,169 @@ async function getUserProfile() {
1982
1996
  }
1983
1997
  return (await response.json());
1984
1998
  }
1999
+ // ─── Cloud schedules ────────────────────────────────────────────────────────
2000
+ //
2001
+ // Recurring agent tasks that run on NEXRALL'S servers (routes/browserAgent.js
2002
+ // `/api/browser-agent/schedules`, picked up every 60s by services/agentTaskCron),
2003
+ // so the user can close the laptop and the schedule still fires — NOT the same
2004
+ // thing as the local `/loop` + cron tools, which live and die with the session.
2005
+ //
2006
+ // Wire-format notes that decide the code below:
2007
+ // • ids are sharded BIGINTs (migrations 048/080) that exceed
2008
+ // Number.MAX_SAFE_INTEGER. pg returns them as strings, the server's own
2009
+ // routes validate /^\d+$/ and pass the string straight back to pg — so an
2010
+ // id is a digit STRING from end to end here. A Number()/parseInt anywhere on
2011
+ // this path would round to the wrong row (the exact bug class the server
2012
+ // route comments about).
2013
+ // • the server clamps intervals to 15 minutes – 7 days (clampInterval in
2014
+ // routes/browserAgent.js); we validate client-side too, so callers can show
2015
+ // the real rule instead of relaying a 400.
2016
+ // • rows come back snake_case (raw pg). We expose camelCase, one stable shape
2017
+ // for every caller, so no caller has to know column names.
2018
+ exports.SCHEDULE_MIN_MINUTES = 15;
2019
+ exports.SCHEDULE_MAX_MINUTES = 7 * 24 * 60;
2020
+ /** Enforce the server's own bounds with a message that names them. */
2021
+ function clampScheduleMinutes(v) {
2022
+ const n = Math.round(Number(v));
2023
+ if (!Number.isFinite(n) || n < exports.SCHEDULE_MIN_MINUTES || n > exports.SCHEDULE_MAX_MINUTES) {
2024
+ throw new Error(`Interval must be between ${exports.SCHEDULE_MIN_MINUTES} minutes and ${exports.SCHEDULE_MAX_MINUTES / (24 * 60)} days.`);
2025
+ }
2026
+ return n;
2027
+ }
2028
+ /**
2029
+ * A schedule id, still a digit string. Validated here because a malformed id
2030
+ * would otherwise be interpolated into the request path.
2031
+ */
2032
+ function scheduleId(id) {
2033
+ const s = String(id ?? '').trim();
2034
+ if (!/^\d+$/.test(s)) {
2035
+ throw new Error(`Invalid schedule id "${id}" — expected the digit string shown in the schedule list.`);
2036
+ }
2037
+ return s;
2038
+ }
2039
+ function isoOrNull(v) {
2040
+ return typeof v === 'string' && v ? v : null;
2041
+ }
2042
+ /** One shape for a list row, a create response or a partial patch response. */
2043
+ function scheduleRow(row) {
2044
+ return {
2045
+ // String(), never Number() — see the header note on sharded ids.
2046
+ id: row.id == null ? '' : String(row.id),
2047
+ task: typeof row.task === 'string' ? row.task : '',
2048
+ startUrl: isoOrNull(row.start_url ?? row.startUrl),
2049
+ domains: Array.isArray(row.domains) ? row.domains.map((d) => String(d)) : null,
2050
+ intervalMinutes: Number(row.interval_minutes ?? row.intervalMinutes ?? 0) || 0,
2051
+ enabled: row.enabled === true,
2052
+ nextRunAt: isoOrNull(row.next_run_at ?? row.nextRunAt),
2053
+ lastRunAt: isoOrNull(row.last_run_at ?? row.lastRunAt),
2054
+ lastStatus: isoOrNull(row.last_status ?? row.lastStatus),
2055
+ };
2056
+ }
2057
+ function scheduleRunRow(row) {
2058
+ return {
2059
+ id: row.id == null ? '' : String(row.id),
2060
+ status: typeof row.status === 'string' ? row.status : '',
2061
+ summary: typeof row.summary === 'string' && row.summary ? row.summary : null,
2062
+ steps: Number(row.steps ?? 0) || 0,
2063
+ createdAt: isoOrNull(row.created_at ?? row.createdAt),
2064
+ };
2065
+ }
2066
+ /** The server answers errors as {error: '<sentence>'}; prefer that sentence. */
2067
+ function apiErrorMessage(status, text) {
2068
+ try {
2069
+ const j = JSON.parse(text);
2070
+ if (typeof j.error === 'string' && j.error)
2071
+ return j.error;
2072
+ }
2073
+ catch { /* not JSON — fall through to the raw text */ }
2074
+ return `API error ${status}${text ? `: ${text}` : ''}`;
2075
+ }
2076
+ async function scheduleRequest(method, path, body) {
2077
+ const fetchOnce = () => (0, node_fetch_1.default)(`${exports.API_BASE}/api/browser-agent${path}`, {
2078
+ method,
2079
+ headers: authHeaders(),
2080
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
2081
+ });
2082
+ let response = await fetchOnce();
2083
+ // Same silent-refresh pattern as getBalance/getOrgs — an expired token on the
2084
+ // first call of a session is the common case, not an error to surface.
2085
+ if (response.status === 401 || response.status === 403) {
2086
+ const text = await response.text().catch(() => '');
2087
+ if (isExpiredTokenResponse(response.status, text) && await refreshAccessToken()) {
2088
+ response = await fetchOnce();
2089
+ }
2090
+ else {
2091
+ throw new Error(apiErrorMessage(response.status, text));
2092
+ }
2093
+ }
2094
+ if (!response.ok) {
2095
+ throw new Error(apiErrorMessage(response.status, await response.text().catch(() => '')));
2096
+ }
2097
+ return response.json().catch(() => null);
2098
+ }
2099
+ async function listCloudSchedules() {
2100
+ const json = (await scheduleRequest('GET', '/schedules'));
2101
+ return Array.isArray(json?.schedules)
2102
+ ? json.schedules.map((r) => scheduleRow(r))
2103
+ : [];
2104
+ }
2105
+ async function createCloudSchedule(input) {
2106
+ const task = String(input.task ?? '').trim();
2107
+ if (!task)
2108
+ throw new Error('A schedule needs a task.');
2109
+ const json = (await scheduleRequest('POST', '/schedules', {
2110
+ task,
2111
+ intervalMinutes: clampScheduleMinutes(input.intervalMinutes),
2112
+ ...(input.startUrl != null && input.startUrl !== '' ? { startUrl: input.startUrl } : {}),
2113
+ ...(Array.isArray(input.domains) && input.domains.length ? { domains: input.domains } : {}),
2114
+ ...(input.enabled === false ? { enabled: false } : {}),
2115
+ }));
2116
+ if (!json?.schedule)
2117
+ throw new Error('The server accepted the schedule but returned no record.');
2118
+ return scheduleRow(json.schedule);
2119
+ }
2120
+ async function updateCloudSchedule(id, patch) {
2121
+ const body = {};
2122
+ if (typeof patch.task === 'string' && patch.task.trim())
2123
+ body.task = patch.task.trim();
2124
+ if (patch.intervalMinutes != null)
2125
+ body.intervalMinutes = clampScheduleMinutes(patch.intervalMinutes);
2126
+ if (typeof patch.enabled === 'boolean')
2127
+ body.enabled = patch.enabled;
2128
+ if (typeof patch.startUrl === 'string')
2129
+ body.startUrl = patch.startUrl;
2130
+ if (Array.isArray(patch.domains))
2131
+ body.domains = patch.domains;
2132
+ if (!Object.keys(body).length)
2133
+ throw new Error('Nothing to update.');
2134
+ const json = (await scheduleRequest('PATCH', `/schedules/${scheduleId(id)}`, body));
2135
+ if (!json?.schedule)
2136
+ throw new Error('The server accepted the update but returned no record.');
2137
+ return scheduleRow(json.schedule);
2138
+ }
2139
+ async function deleteCloudSchedule(id) {
2140
+ await scheduleRequest('DELETE', `/schedules/${scheduleId(id)}`);
2141
+ }
2142
+ /**
2143
+ * Fire a cloud schedule now instead of waiting for its next interval.
2144
+ *
2145
+ * The server only ARMS the row (`next_run_at = now()`); the platform's ticker
2146
+ * (services/agentTaskCron — one cluster-wide leader, 60s tick) picks it up and
2147
+ * advances the schedule itself. So a successful call means "queued", not
2148
+ * "already ran" — poll `getCloudScheduleRuns` for the outcome. A paused
2149
+ * schedule is refused by the server ("resume it first"): run-now must never
2150
+ * silently un-pause it.
2151
+ */
2152
+ async function runCloudScheduleNow(id) {
2153
+ const json = (await scheduleRequest('POST', `/schedules/${scheduleId(id)}/run`));
2154
+ if (!json?.schedule)
2155
+ throw new Error('The server accepted run-now but returned no record.');
2156
+ return scheduleRow(json.schedule);
2157
+ }
2158
+ async function getCloudScheduleRuns(id) {
2159
+ const json = (await scheduleRequest('GET', `/schedules/${scheduleId(id)}/runs`));
2160
+ return Array.isArray(json?.runs)
2161
+ ? json.runs.map((r) => scheduleRunRow(r))
2162
+ : [];
2163
+ }
1985
2164
  //# sourceMappingURL=client.js.map
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export * from './agent/skills';
18
18
  export * from './mcp/client';
19
19
  export * from './mcp/httpClient';
20
20
  export * from './mcp/manager';
21
+ export * from './mcp/server';
21
22
  export * from './mcp/stats';
22
23
  export * from './checkpoint/manager';
23
24
  export * from './commands/loader';
@@ -32,6 +33,7 @@ export * from './permissions/destructive';
32
33
  export * from './plugins/index';
33
34
  export * from './plugins/installer';
34
35
  export * from './plugins/sources';
36
+ export * from './plugins/data';
35
37
  export * from './agent/trust';
36
38
  export * from './agent/crossProcessLock';
37
39
  export * from './agent/worktree';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,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AC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __exportStar(require("./agent/skills"), exports);
34
34
  __exportStar(require("./mcp/client"), exports);
35
35
  __exportStar(require("./mcp/httpClient"), exports);
36
36
  __exportStar(require("./mcp/manager"), exports);
37
+ __exportStar(require("./mcp/server"), exports);
37
38
  __exportStar(require("./mcp/stats"), exports);
38
39
  __exportStar(require("./checkpoint/manager"), exports);
39
40
  __exportStar(require("./commands/loader"), exports);
@@ -48,6 +49,7 @@ __exportStar(require("./permissions/destructive"), exports);
48
49
  __exportStar(require("./plugins/index"), exports);
49
50
  __exportStar(require("./plugins/installer"), exports);
50
51
  __exportStar(require("./plugins/sources"), exports);
52
+ __exportStar(require("./plugins/data"), exports);
51
53
  __exportStar(require("./agent/trust"), exports);
52
54
  __exportStar(require("./agent/crossProcessLock"), exports);
53
55
  __exportStar(require("./agent/worktree"), exports);
@@ -0,0 +1,39 @@
1
+ import type { Readable, Writable } from 'stream';
2
+ import type { ToolResult } from '../types';
3
+ export interface McpServerTool {
4
+ name: string;
5
+ description: string;
6
+ inputSchema: {
7
+ type: 'object';
8
+ properties?: Record<string, unknown>;
9
+ required?: string[];
10
+ };
11
+ run(input: Record<string, unknown>, ctx: {
12
+ workDir: string;
13
+ }): Promise<ToolResult>;
14
+ }
15
+ export interface ServeOptions {
16
+ /** Workspace root relative paths resolve against (the client's project). */
17
+ workDir: string;
18
+ /** Reported in `serverInfo` during initialize. */
19
+ version?: string;
20
+ /** Defaults to `readOnlyMcpTools()`. */
21
+ tools?: McpServerTool[];
22
+ /** Injectable for tests; default process.stdin/stdout. */
23
+ input?: Readable;
24
+ output?: Writable;
25
+ /** Diagnostics — stderr by convention. NEVER stdout. */
26
+ log?: (message: string) => void;
27
+ }
28
+ /**
29
+ * The read-only surface `nex mcp serve` offers. Kept small on purpose: every tool here is one
30
+ * an outside agent can call with no human in the loop, so nothing that writes, deletes or
31
+ * executes may join without a permission story first.
32
+ */
33
+ export declare function readOnlyMcpTools(): McpServerTool[];
34
+ /**
35
+ * Serve MCP on stdio until the client closes the pipe. Resolves (never rejects) at EOF — the
36
+ * standard way an MCP client says "stop" is to close stdin, and the exit code is then 0.
37
+ */
38
+ export declare function serveMcp(opts: ServeOptions): Promise<void>;
39
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,wDAAwD;IACxD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAaD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,EAAE,CA+BlD;AASD;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuHhE"}
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ // MCP server — the other direction of `mcp/client.ts`.
3
+ //
4
+ // Point any MCP client at `nex mcp serve` and it can read this machine's files with the same
5
+ // tools the CLI uses. Deliberately READ-ONLY for now: the client is usually another agent with
6
+ // its own permission model, and a server that silently edits files has no one to ask — a write
7
+ // toolset only belongs here once there is a person (or a policy file) behind the approval.
8
+ //
9
+ // Framing is the same newline-delimited JSON-RPC 2.0 the client parses, so our own client is
10
+ // the natural test driver. Two hard rules, both enforced by tests:
11
+ // * stdout carries protocol frames and NOTHING else — one stray console.log corrupts the
12
+ // channel; every diagnostic goes to stderr;
13
+ // * a bad line, an unknown method or a throwing tool must never end the loop.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.readOnlyMcpTools = readOnlyMcpTools;
16
+ exports.serveMcp = serveMcp;
17
+ const executor_1 = require("../tools/executor");
18
+ // ─── The toolset ──────────────────────────────────────────────────────────────
19
+ /** Wrap one executor tool. The executor is the single source of behaviour — same caps, same
20
+ * error messages, same path resolution as the CLI's own turns. */
21
+ const fromExecutor = (name, description, inputSchema) => ({
22
+ name,
23
+ description,
24
+ inputSchema,
25
+ run: (input, ctx) => (0, executor_1.executeTool)(name, input, undefined, undefined, ctx.workDir),
26
+ });
27
+ /**
28
+ * The read-only surface `nex mcp serve` offers. Kept small on purpose: every tool here is one
29
+ * an outside agent can call with no human in the loop, so nothing that writes, deletes or
30
+ * executes may join without a permission story first.
31
+ */
32
+ function readOnlyMcpTools() {
33
+ return [
34
+ fromExecutor('read_file', 'Read a text file. Returns numbered lines so later edits can cite them. Binary files are refused.', { type: 'object', properties: {
35
+ path: { type: 'string', description: 'File path, absolute or relative to the workspace root' },
36
+ offset: { type: 'number', description: '0-based line to start from (default 0)' },
37
+ limit: { type: 'number', description: 'How many lines to return' },
38
+ }, required: ['path'] }),
39
+ fromExecutor('list_directory', 'List the entries of a directory, each marked as file or directory.', { type: 'object', properties: {
40
+ path: { type: 'string', description: 'Directory path (default: the workspace root)' },
41
+ } }),
42
+ fromExecutor('glob', 'Find files by glob pattern, e.g. "**/*.ts" or "src/**/*.test.js".', { type: 'object', properties: {
43
+ pattern: { type: 'string', description: 'Glob pattern' },
44
+ path: { type: 'string', description: 'Directory to search from (default: the workspace root)' },
45
+ }, required: ['pattern'] }),
46
+ fromExecutor('search_files', 'Search file contents with a regular expression. Returns matching file paths by default; ask for context lines to get the matches themselves.', { type: 'object', properties: {
47
+ pattern: { type: 'string', description: 'Regular expression' },
48
+ path: { type: 'string', description: 'Directory to search (default: the workspace root)' },
49
+ type: { type: 'string', description: '"files" (paths only) or "content" (matching lines)' },
50
+ include: { type: 'string', description: 'Only files matching this glob, e.g. "*.ts"' },
51
+ case_insensitive: { type: 'boolean', description: 'Case-insensitive match' },
52
+ context_lines: { type: 'number', description: 'Lines of context around each match (implies type "content")' },
53
+ }, required: ['pattern'] }),
54
+ ];
55
+ }
56
+ // ─── Protocol ─────────────────────────────────────────────────────────────────
57
+ /** Versions whose framing we actually implement (they are all the same for our surface). */
58
+ const SUPPORTED_PROTOCOLS = ['2024-11-05', '2025-03-26', '2025-06-18'];
59
+ const DEFAULT_PROTOCOL = '2024-11-05';
60
+ const SERVER_NAME = 'nexrall';
61
+ /**
62
+ * Serve MCP on stdio until the client closes the pipe. Resolves (never rejects) at EOF — the
63
+ * standard way an MCP client says "stop" is to close stdin, and the exit code is then 0.
64
+ */
65
+ async function serveMcp(opts) {
66
+ const input = opts.input ?? process.stdin;
67
+ const output = opts.output ?? process.stdout;
68
+ const log = opts.log ?? ((m) => process.stderr.write(`[nexrall mcp] ${m}\n`));
69
+ const tools = opts.tools ?? readOnlyMcpTools();
70
+ const version = opts.version ?? '0.0.0';
71
+ const byName = new Map(tools.map((t) => [t.name, t]));
72
+ const send = (msg) => { output.write(JSON.stringify(msg) + '\n'); };
73
+ const reply = (id, result) => send({ jsonrpc: '2.0', id, result });
74
+ const replyError = (id, code, message) => send({ jsonrpc: '2.0', id, error: { code, message } });
75
+ async function handle(message) {
76
+ const id = message.id;
77
+ const isRequest = id !== undefined && id !== null;
78
+ const method = message.method;
79
+ const params = (message.params ?? {});
80
+ switch (method) {
81
+ case 'initialize': {
82
+ // Echo the client's version when we implement it, else our default — that is the
83
+ // spec's instruction and the number is inert for this surface either way.
84
+ const asked = typeof params.protocolVersion === 'string' ? params.protocolVersion : '';
85
+ reply(id, {
86
+ protocolVersion: SUPPORTED_PROTOCOLS.includes(asked) ? asked : DEFAULT_PROTOCOL,
87
+ capabilities: { tools: {} },
88
+ serverInfo: { name: SERVER_NAME, version },
89
+ instructions: `Read-only file access to ${opts.workDir}. ` +
90
+ `Tools: ${tools.map((t) => t.name).join(', ')}. Nothing here writes, deletes or runs commands.`,
91
+ });
92
+ log(`initialize from ${typeof params.clientInfo === 'object' && params.clientInfo ? JSON.stringify(params.clientInfo.name ?? 'client') : 'client'}`);
93
+ return;
94
+ }
95
+ case 'notifications/initialized':
96
+ case 'notifications/cancelled':
97
+ return; // notifications take no reply
98
+ case 'ping':
99
+ reply(id, {});
100
+ return;
101
+ case 'tools/list':
102
+ reply(id, { tools: tools.map(({ name, description, inputSchema }) => ({ name, description, inputSchema })) });
103
+ return;
104
+ case 'tools/call': {
105
+ const name = typeof params.name === 'string' ? params.name : '';
106
+ const args = (params.arguments ?? {});
107
+ if (!name)
108
+ return replyError(id, -32602, 'Invalid params: name is required');
109
+ const tool = byName.get(name);
110
+ if (!tool) {
111
+ // A RESULT, not a protocol error: the calling model should read "not offered" as tool
112
+ // output and pick another route, not see the whole call fail.
113
+ reply(id, { content: [{ type: 'text', text: `Tool "${name}" is not offered by this server (read-only). Available: ${[...byName.keys()].join(', ')}.` }], isError: true });
114
+ return;
115
+ }
116
+ try {
117
+ const res = await tool.run(args, { workDir: opts.workDir });
118
+ if (res.error)
119
+ reply(id, { content: [{ type: 'text', text: res.error }], isError: true });
120
+ else
121
+ reply(id, { content: [{ type: 'text', text: res.output ?? '' }] });
122
+ }
123
+ catch (err) {
124
+ // A throwing tool is the tool's problem, not the session's — answer and keep serving.
125
+ reply(id, { content: [{ type: 'text', text: err instanceof Error ? err.message : String(err) }], isError: true });
126
+ }
127
+ return;
128
+ }
129
+ default:
130
+ if (isRequest)
131
+ replyError(id, -32601, `Method not found: ${method}`);
132
+ return;
133
+ }
134
+ }
135
+ input.setEncoding('utf8');
136
+ let buffer = '';
137
+ let queue = Promise.resolve();
138
+ const feed = (line) => {
139
+ // Chain instead of racing: responses stay in request order and writes never interleave.
140
+ queue = queue.then(async () => {
141
+ const trimmed = line.trim();
142
+ if (!trimmed)
143
+ return;
144
+ let message;
145
+ try {
146
+ message = JSON.parse(trimmed);
147
+ }
148
+ catch {
149
+ log(`ignoring a line that is not JSON (${trimmed.slice(0, 80)})`);
150
+ return;
151
+ }
152
+ if (!message || message.jsonrpc !== '2.0' || typeof message.method !== 'string') {
153
+ log('ignoring a message without jsonrpc 2.0 + method');
154
+ return;
155
+ }
156
+ try {
157
+ await handle(message);
158
+ }
159
+ catch (err) {
160
+ // handle() is written not to throw, so reaching here is a bug in the server — report
161
+ // it as a JSON-RPC error rather than dropping the connection.
162
+ if (message.id !== undefined)
163
+ replyError(message.id, -32603, err instanceof Error ? err.message : String(err));
164
+ }
165
+ });
166
+ };
167
+ await new Promise((resolve) => {
168
+ input.on('data', (chunk) => {
169
+ buffer += chunk.toString();
170
+ let nl;
171
+ while ((nl = buffer.indexOf('\n')) >= 0) {
172
+ feed(buffer.slice(0, nl));
173
+ buffer = buffer.slice(nl + 1);
174
+ }
175
+ });
176
+ const done = () => {
177
+ if (buffer.trim()) {
178
+ feed(buffer);
179
+ buffer = '';
180
+ }
181
+ resolve();
182
+ };
183
+ input.on('end', done);
184
+ input.on('close', done);
185
+ });
186
+ await queue; // let in-flight calls finish before the process exits
187
+ log('client closed stdin — server exiting');
188
+ }
189
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1,23 @@
1
+ /** Claude Code's rule: letters, digits, `_`, `-` survive; everything else becomes `-`. */
2
+ export declare function sanitizePluginId(name: string): string;
3
+ /** Where this plugin's persistent data lives. Pure — does not touch the disk. */
4
+ export declare function pluginDataDir(name: string): string;
5
+ /**
6
+ * `pluginDataDir`, created if missing. Returns the path either way.
7
+ *
8
+ * Called right before a plugin's process is spawned with NEXRALL_PLUGIN_DATA in
9
+ * its environment, so the promise "the variable points at a directory you may
10
+ * write to" holds the moment the plugin can read it.
11
+ */
12
+ export declare function ensurePluginDataDir(name: string): string;
13
+ /** True when the plugin has data on disk from earlier runs. */
14
+ export declare function pluginHasData(name: string): boolean;
15
+ /**
16
+ * Raw bytes under a plugin's data directory (0 when missing). Bounded walk: a
17
+ * plugin can park a large tree here, and reporting the size must not be the
18
+ * thing that makes `nex plugin prune` slow, so entries are counted up to a cap.
19
+ */
20
+ export declare function pluginDataSize(name: string, maxEntries?: number): number;
21
+ /** Remove a plugin's data directory. Returns true when something was removed. */
22
+ export declare function removePluginData(name: string): boolean;
23
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/plugins/data.ts"],"names":[],"mappings":"AAwBA,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAAO,GAAG,MAAM,CAiBtE;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAStD"}