ai-agentmanager 1.51.1 → 1.54.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/src/manager.js CHANGED
@@ -2,11 +2,13 @@ import crypto from 'node:crypto';
2
2
  import { EventEmitter } from 'node:events';
3
3
  import { ownStatusLine } from './trust.js';
4
4
  import { statusLineScript, usageFile } from './usage.js';
5
+ import { leanScript } from './lean.js';
6
+ import { laneEnv, laneOf, lanePrompt, laneSettings, nextLane } from './lanes.js';
5
7
  import fs from 'node:fs';
6
8
  import os from 'node:os';
7
9
  import path from 'node:path';
8
10
  import pty from 'node-pty';
9
- import { expandHome, paths } from './config.js';
11
+ import { PORT, expandHome, paths } from './config.js';
10
12
  import { DEFAULT_ENGINE, ENGINES, engineOf, installed, notInstalled } from './engines/index.js';
11
13
  import {
12
14
  DOC_KINDS,
@@ -38,6 +40,9 @@ import {
38
40
  debugPrompt,
39
41
  debugFixPrompt,
40
42
  reversePath,
43
+ securityPath,
44
+ securityPrompt,
45
+ securityFixPrompt,
41
46
  reversePrompt,
42
47
  reverseBuildPrompt,
43
48
  specDocsInfo,
@@ -152,6 +157,9 @@ import {
152
157
  // Per-session markers a parent Claude Code session sets. Inherited, they make the
153
158
  // agent think it is a nested child session (which, among other things, turns
154
159
  // transcript saving off, so the session could never be resumed).
160
+ /** Where the whole of an agent's trimmed command outputs are kept (lean.js). */
161
+ export const leanDir = (agentId) => path.join(paths.home, 'lean', agentId);
162
+
155
163
  const STRIP_ENV = [
156
164
  'AI_AGENT',
157
165
  'CLAUDECODE',
@@ -382,6 +390,8 @@ export class AgentManager extends EventEmitter {
382
390
  priority: agent.priority ?? 2,
383
391
  activeAt: this.activeAt(agent, rt),
384
392
  projectInfo: this.projectInfo(agent),
393
+ // Its ports and name ending (lanes.js), once it has been started with lanes on.
394
+ laneInfo: laneSettings(this.config).enabled ? laneOf(agent.lane, laneSettings(this.config)) : null,
385
395
  usage,
386
396
  // Claude Code's own cost figure from the transcripts (absent until it records one).
387
397
  costUsd: costs.length ? costs.reduce((a, b) => a + b, 0) : null,
@@ -838,7 +848,7 @@ export class AgentManager extends EventEmitter {
838
848
  /** One of an agent's intent, spec and plan files. */
839
849
  specDoc(ref, name) {
840
850
  const agent = this.mustGet(ref);
841
- if (!['intent', 'spec', 'plan', 'designdoc', 'benchmark', 'debug', 'reverse'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan, designdoc, benchmark, debug or reverse)'), { status: 400 });
851
+ if (!['intent', 'spec', 'plan', 'designdoc', 'benchmark', 'debug', 'reverse', 'security'].includes(name)) throw Object.assign(new Error('Unknown file (intent, spec, plan, designdoc, benchmark, debug, reverse or security)'), { status: 400 });
842
852
  return readSpecDoc(agent.id, name) ?? { name, markdown: null };
843
853
  }
844
854
 
@@ -864,6 +874,28 @@ export class AgentManager extends EventEmitter {
864
874
  return this.view(this.patch(agent.id, { debug: { asks, startedAt: agent.debug?.startedAt ?? now() } }));
865
875
  }
866
876
 
877
+ /**
878
+ * Security audit: ask the agent to audit the code in its session and keep a report
879
+ * (SECURITY-AUDIT.md): the attack surface, findings by severity with evidence, each checked a
880
+ * second time before it is listed, what was found sound and what was not covered. `question`:
881
+ * what to audit (nothing: the whole project), or a follow-up once there is a report. `fix`: fix
882
+ * the report's findings (which ones, in words; true for the verified ones). Waits in the queue.
883
+ */
884
+ security(ref, { question = '', fix = null } = {}) {
885
+ const agent = this.mustGet(ref);
886
+ if (!agent.workdir || agent.status === 'preparing') throw Object.assign(new Error('The agent has no folder to audit yet'), { status: 409 });
887
+ const q = String(question ?? '').replace(/\s+/g, ' ').trim().slice(0, 2000);
888
+ const has = Boolean(readSpecDoc(agent.id, 'security')?.markdown?.trim());
889
+ if (fix && !has) throw Object.assign(new Error('There is no audit report yet: start the audit first'), { status: 409 });
890
+ if (!fix && has && q.length < 3) throw Object.assign(new Error('Say what to look at next'), { status: 400 });
891
+ fs.mkdirSync(briefDir(agent.id), { recursive: true });
892
+ const file = path.join(fs.realpathSync(briefDir(agent.id)), path.basename(securityPath(agent.id)));
893
+ const which = fix === true ? '' : String(fix ?? '').replace(/\s+/g, ' ').trim().slice(0, 500);
894
+ this.tell(agent.id, fix ? securityFixPrompt(file, which) : securityPrompt(file, q, { again: has }), { source: 'security' });
895
+ const asks = [...(agent.security?.asks ?? []), { text: fix ? `Fix findings${which ? `: ${which}` : ''}` : q || 'The whole project', kind: fix ? 'fix' : has ? 'follow-up' : 'audit', at: now() }].slice(-20);
896
+ return this.view(this.patch(agent.id, { security: { ...agent.security, asks, startedAt: agent.security?.startedAt ?? now() } }));
897
+ }
898
+
867
899
  /**
868
900
  * Reverse engineer: ask the agent to work out how something in a target (an app's folder, a
869
901
  * binary, a website) works, with REA's tools, and keep a report (REVERSE.md) with diagrams, the
@@ -1421,6 +1453,9 @@ export class AgentManager extends EventEmitter {
1421
1453
  prompts.push(teamPrompt(agent.team.role, dir));
1422
1454
  }
1423
1455
  }
1456
+ // Its own ports and name ending, so what it starts doesn't collide with another agent's.
1457
+ const lane = this.laneFor(agent);
1458
+ if (lane && task) prompts.push(lanePrompt(lane, laneSettings(this.config)));
1424
1459
  // Appended system prompts last only for the process they're passed to, so they go on every launch.
1425
1460
  // Files attached for it (at creation or in its terminal): readable without a permission prompt.
1426
1461
  const uploads = path.join(paths.uploads, agent.id);
@@ -1428,8 +1463,15 @@ export class AgentManager extends EventEmitter {
1428
1463
  const dir = fs.realpathSync(uploads);
1429
1464
  writableDir = writableDir ? [writableDir, dir].flat() : dir;
1430
1465
  }
1431
- // A status line that records the plan's usage (not in a container: the script isn't there).
1432
- return { extra: [...engine.extraArgs(this.config), ...(agent.isolation === 'container' ? [] : engine.usageArgs?.(this.config, statusLineScript()) ?? [])], permissionMode: agent.permissionMode, model: agent.model, writableDir, instructions: prompts.join('\n\n') || null, agents, allowedTools };
1466
+ // A status line that records the plan's usage, and with lean output on the hook that trims long
1467
+ // command output (not in a container: the scripts aren't there).
1468
+ const own = agent.isolation !== 'container' && Boolean(engine.settingsArgs);
1469
+ if (own && this.config.lean?.enabled === true) {
1470
+ // Where the whole of a trimmed output is kept: readable without a permission prompt.
1471
+ fs.mkdirSync(leanDir(agent.id), { recursive: true });
1472
+ writableDir = [writableDir ?? [], fs.realpathSync(leanDir(agent.id))].flat();
1473
+ }
1474
+ return { extra: [...engine.extraArgs(this.config), ...(own ? engine.settingsArgs(this.config, { statusLine: statusLineScript(), lean: leanScript() }) : [])], permissionMode: agent.permissionMode, model: agent.model, writableDir, instructions: prompts.join('\n\n') || null, agents, allowedTools };
1433
1475
  }
1434
1476
 
1435
1477
  /** Spawn the agent's engine in a PTY, reusing its terminal clients and scrollback. */
@@ -1772,8 +1814,24 @@ export class AgentManager extends EventEmitter {
1772
1814
  });
1773
1815
  }
1774
1816
 
1817
+ /**
1818
+ * The agent's lane: ports and a name ending no other agent has (lanes.js). Given the first time
1819
+ * it is asked for and kept until the agent is deleted. Null with lanes off, or in a container,
1820
+ * which has its own ports.
1821
+ */
1822
+ laneFor(agent) {
1823
+ const settings = laneSettings(this.config);
1824
+ if (!agent || !settings.enabled || agent.isolation === 'container' || agent.machine) return null;
1825
+ if (!laneOf(agent.lane, settings)) {
1826
+ const n = nextLane(this.store.list().map((a) => a.lane).filter(Boolean), settings, [PORT]);
1827
+ if (!n || !this.store.patch(agent.id, { lane: n })) return null;
1828
+ agent.lane = n;
1829
+ }
1830
+ return laneOf(agent.lane, settings);
1831
+ }
1832
+
1775
1833
  childEnv(agent) {
1776
- const env = { ...process.env, ...(agent ? { AGENTMGR_AGENT_ID: agent.id } : {}), TERM: 'xterm-256color', COLORTERM: 'truecolor', AGENTMGR_TERMINAL: '1', AGENTMGR_USAGE_FILE: usageFile(), AGENTMGR_USER_STATUSLINE: ownStatusLine() };
1834
+ const env = { ...process.env, ...(agent ? { AGENTMGR_AGENT_ID: agent.id, AGENTMGR_LEAN_DIR: leanDir(agent.id), ...laneEnv(this.laneFor(agent), laneSettings(this.config)) } : {}), TERM: 'xterm-256color', COLORTERM: 'truecolor', AGENTMGR_TERMINAL: '1', AGENTMGR_USAGE_FILE: usageFile(), AGENTMGR_USER_STATUSLINE: ownStatusLine() };
1777
1835
  for (const key of STRIP_ENV) delete env[key];
1778
1836
  return env;
1779
1837
  }
@@ -2442,6 +2500,14 @@ export class AgentManager extends EventEmitter {
2442
2500
  } catch {}
2443
2501
  if (at !== (agent.debug.reportAt ?? null)) this.patch(id, { debug: { ...this.store.get(id).debug, reportAt: at } });
2444
2502
  }
2503
+ // And for a security audit.
2504
+ if (agent.security) {
2505
+ let at = null;
2506
+ try {
2507
+ at = fs.statSync(securityPath(id)).mtime.toISOString();
2508
+ } catch {}
2509
+ if (at !== (agent.security.reportAt ?? null)) this.patch(id, { security: { ...this.store.get(id).security, reportAt: at } });
2510
+ }
2445
2511
  // The same for a reverse-engineering report.
2446
2512
  if (agent.reverse) {
2447
2513
  let at = null;
package/src/races.js CHANGED
@@ -5,6 +5,7 @@ import crypto from 'node:crypto';
5
5
  import { spawn } from 'node:child_process';
6
6
  import { EventEmitter } from 'node:events';
7
7
  import * as git from './git.js';
8
+ import { cleanRuns, repeatRuns } from './eval.js';
8
9
 
9
10
  const err = (status, message) => Object.assign(new Error(message), { status });
10
11
  const now = () => new Date().toISOString();
@@ -112,9 +113,10 @@ export class Races extends EventEmitter {
112
113
  }
113
114
 
114
115
  /** Run the race's test command in every attempt's worktree (two at a time). */
115
- async runTests(id, { command } = {}) {
116
+ async runTests(id, { command, runs } = {}) {
116
117
  const race = this.get(id);
117
118
  if (command !== undefined) race.testCommand = command.trim() || null;
119
+ if (runs !== undefined) race.testRuns = cleanRuns(runs);
118
120
  if (!race.testCommand) throw err(400, 'Set a test command first');
119
121
  const queue = race.members.map((m) => this.manager.store.get(m)).filter((a) => a?.workdir);
120
122
  for (const a of queue) race.tests[a.id] = { status: 'queued', at: now() };
@@ -126,9 +128,22 @@ export class Races extends EventEmitter {
126
128
  return this.view(id);
127
129
  }
128
130
 
129
- runOne(race, agent) {
131
+ /**
132
+ * The test command in one attempt's folder, as many times as the race asks (eval.js: one run
133
+ * that fails is run once more). Passed in some runs and failed in others is "flaky".
134
+ */
135
+ async runOne(race, agent) {
130
136
  race.tests[agent.id] = { status: 'running', at: now() };
131
137
  this.save(race);
138
+ const started = Date.now();
139
+ const all = await repeatRuns(() => this.runOnce(race, agent), race.testRuns);
140
+ const { exitCode, output, at, status } = all.shown;
141
+ race.tests[agent.id] = { status: status === 'error' ? 'error' : all.passed ? 'passed' : all.flaky ? 'flaky' : 'failed', exitCode, runs: all.runs, passes: all.passes, seconds: Math.round((Date.now() - started) / 1000), output, at };
142
+ this.save(race);
143
+ }
144
+
145
+ /** One run: { status, exitCode, output, at, passed, timedOut }. */
146
+ runOnce(race, agent) {
132
147
  return new Promise((resolve) => {
133
148
  const child = spawn(process.env.SHELL || '/bin/sh', ['-lc', race.testCommand], { cwd: agent.workdir, env: this.manager.childEnv(agent), detached: true });
134
149
  this.running.set(`${race.id}:${agent.id}`, child);
@@ -136,8 +151,9 @@ export class Races extends EventEmitter {
136
151
  const keep = (d) => (out = (out + d).slice(-6000));
137
152
  child.stdout.on('data', keep);
138
153
  child.stderr.on('data', keep);
139
- const started = Date.now();
154
+ let timedOut = false;
140
155
  const timer = setTimeout(() => {
156
+ timedOut = true;
141
157
  try {
142
158
  process.kill(-child.pid, 'SIGKILL');
143
159
  } catch {}
@@ -145,15 +161,8 @@ export class Races extends EventEmitter {
145
161
  const finish = (code, error) => {
146
162
  clearTimeout(timer);
147
163
  this.running.delete(`${race.id}:${agent.id}`);
148
- race.tests[agent.id] = {
149
- status: error ? 'error' : code === 0 ? 'passed' : 'failed',
150
- exitCode: code,
151
- seconds: Math.round((Date.now() - started) / 1000),
152
- output: (error ? `${error}\n` : '') + out.slice(-4000),
153
- at: now(),
154
- };
155
- this.save(race);
156
- resolve();
164
+ // A command that could not be started is not run again.
165
+ resolve({ status: error ? 'error' : code === 0 ? 'passed' : 'failed', exitCode: code, output: (error ? `${error}\n` : '') + out.slice(-4000), at: now(), passed: !error && code === 0, timedOut: timedOut || Boolean(error) });
157
166
  };
158
167
  child.on('error', (e) => finish(null, e.message));
159
168
  child.on('close', (code) => finish(code));
package/src/server.js CHANGED
@@ -55,6 +55,9 @@ import { Advisor } from './advisor.js';
55
55
  import { Runbooks } from './runbooks.js';
56
56
  import { reaStatus } from './rea.js';
57
57
  import { EngineUsage, codexWindows } from './usage.js';
58
+ import { leanSettings, leanStats, leanSweep } from './lean.js';
59
+ import { laneOf, laneSettings } from './lanes.js';
60
+ import { Skills } from './skills.js';
58
61
  import { Milestones } from './milestones.js';
59
62
  import { Decisions } from './decisions.js';
60
63
  import { Debt } from './debt.js';
@@ -342,6 +345,12 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
342
345
  manager.on('limit', ({ engine, text, resetAt }) => usage.limited(engine, { text, resetAt }));
343
346
  manager.plugins.api('usage', config).policy((action, details) => usage.policy(action, details));
344
347
  usage.tick();
348
+ // Skills: Claude Code's Agent Skills here, and adding more from a repository (skills.js).
349
+ const skills = new Skills({
350
+ store,
351
+ projects: () => manager.listProjects().filter((p) => p.dir).map((p) => ({ key: p.shortcut ?? p.key, name: p.name ?? p.shortcut, dir: p.dir })),
352
+ sessions: () => manager.store.list().filter((a) => engineOf(a).id === 'claude' && a.workdir && a.sessionId).map((a) => ({ id: a.id, name: a.name, file: engineOf(a).sessionFile(a.workdir, a.sessionId) })),
353
+ });
345
354
  // Runbooks for the support team, from a release ticket, an epic, or the code changes of a time frame (runbooks.js).
346
355
  const runbooks = new Runbooks({
347
356
  store,
@@ -415,7 +424,8 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
415
424
  // "Open on this machine" links from the hub point at remote access, when it's on.
416
425
  // OS: this computer and its load right now, and what each open session takes (system.js).
417
426
  const system = new System({
418
- agents: () => store.list().map((x) => ({ id: x.id, name: x.name, pid: x.pid })),
427
+ agents: () => store.list().map((x) => ({ id: x.id, name: x.name, pid: x.pid, lane: laneSettings(config).enabled ? laneOf(x.lane, laneSettings(config)) : null })),
428
+ lanes: () => laneSettings(config),
419
429
  folders: () => [['Home', os.homedir()], ['Agents and data', paths.home]],
420
430
  version: pkgVersion,
421
431
  });
@@ -767,6 +777,8 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
767
777
  api.post('/agents/:id/reverse', wrap((req) => manager.reverse(req.params.id, { target: req.body?.target, question: req.body?.question, build: req.body?.build ?? null })));
768
778
  // Whether REA is registered with Claude Code for this agent's folder (read from Claude Code's files; nothing is run).
769
779
  api.get('/agents/:id/reverse/rea', wrap((req) => reaStatus(manager.mustGet(req.params.id).workdir ?? null)));
780
+ // Security audit: what to audit (nothing: the whole project) or a follow-up, or `fix` to fix the report's findings; the report is /specs/security.
781
+ api.post('/agents/:id/security', wrap((req) => manager.security(req.params.id, { question: req.body?.question, fix: req.body?.fix ?? null })));
770
782
  // Debug: what to debug (or a follow-up), or `fix` to apply the report's fixes; the report is /specs/debug.
771
783
  api.post('/agents/:id/debug', wrap((req) => manager.debug(req.params.id, { question: req.body?.question, fix: req.body?.fix ?? null })));
772
784
  api.post('/agents/:id/answer', wrap((req) => manager.answerQuestion(req.params.id, req.body?.question, req.body?.text)));
@@ -1040,7 +1052,7 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
1040
1052
  evals.verify(a.id).catch((e) => console.log(`[agentmgr] eval: ${e.message}`));
1041
1053
  return { started: true };
1042
1054
  }));
1043
- api.put('/agents/:id/eval/command', wrap((req) => evals.setTestCommand(req.params.id, req.body?.command)));
1055
+ api.put('/agents/:id/eval/command', wrap((req) => evals.setTestCommand(req.params.id, req.body?.command, req.body?.runs)));
1044
1056
  api.post('/agents/:id/eval/gaps', wrap((req) => evals.closeGaps(req.params.id)));
1045
1057
  api.post('/agents/:id/eval/seen', wrap((req) => evals.seen(req.params.id, req.body?.seen !== false)));
1046
1058
  api.post('/agents/:id/eval/post', wrap((req) => review.postEval(req.params.id, evals.view(manager.mustGet(req.params.id).id)?.markdown)));
@@ -1134,9 +1146,14 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
1134
1146
  api.post('/milestones/:project/reach', wrap((req) => milestones.reach(req.params.project, req.body?.stage, req.body?.reached !== false)));
1135
1147
  api.post('/milestones/:project/task', wrap((req) => milestones.task(req.params.project, req.body?.stage, req.body?.item)));
1136
1148
  // Plan → Decisions: the log (?project=<key>&q=<words>; ?format=markdown), one of your own, and removal.
1137
- api.get('/usage', wrap(() => usage.view()));
1149
+ // Lean output (lean.js) rides with Usage: whether it is on, and what trimming has saved.
1150
+ const leanHome = path.join(paths.home, 'lean');
1151
+ const usageView = (v = usage.view()) => ({ ...v, lean: { enabled: leanSettings(config).enabled, ...leanStats(leanHome) } });
1152
+ leanSweep(leanHome);
1153
+ setInterval(() => leanSweep(leanHome), 6 * 3_600_000).unref();
1154
+ api.get('/usage', wrap(() => usageView()));
1138
1155
  // A reading taken now (a one-word Claude Code session, so its status line reports).
1139
- api.post('/usage/refresh', wrap(() => usage.refresh()));
1156
+ api.post('/usage/refresh', wrap(async () => usageView(await usage.refresh())));
1140
1157
  api.put('/usage', wrap((req) => {
1141
1158
  const b = req.body ?? {};
1142
1159
  const next = usage.update(b);
@@ -1147,10 +1164,23 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
1147
1164
  config.engine = b.engine;
1148
1165
  patch.engine = b.engine;
1149
1166
  }
1167
+ // Lean output: on or off, for the sessions started from now on.
1168
+ if ('lean' in b) {
1169
+ config.lean = { ...config.lean, enabled: b.lean === true || b.lean === 'on' };
1170
+ patch.lean = config.lean;
1171
+ }
1150
1172
  saveConfig(patch);
1151
1173
  pushUsage();
1152
- return usage.view();
1174
+ return usageView();
1153
1175
  }));
1176
+ // Skills: the list; one to read (?id=); what a repository offers; adding, checking, updating and removing.
1177
+ api.get('/skills', wrap(() => skills.list()));
1178
+ api.get('/skills/one', wrap((req) => skills.show(String(req.query.id ?? ''))));
1179
+ api.post('/skills/preview', wrap((req) => skills.preview(req.body?.repo)));
1180
+ api.post('/skills', wrap((req) => skills.install(req.body ?? {})));
1181
+ api.post('/skills/check', wrap((req) => skills.check(String(req.body?.id ?? ''))));
1182
+ api.post('/skills/update', wrap((req) => skills.update(String(req.body?.id ?? ''))));
1183
+ api.delete('/skills', wrap((req) => skills.remove(String(req.query.id ?? ''))));
1154
1184
  api.get('/runbooks', wrap(() => runbooks.list()));
1155
1185
  api.post('/runbooks', wrap((req) => runbooks.create(req.body ?? {})));
1156
1186
  api.get('/runbooks/:id', (req, res) => {
@@ -1208,6 +1238,29 @@ export async function startServer({ port = PORT, host = HOST, evalTimer = true }
1208
1238
  api.put('/calendar', wrap((req) => calendar.set(req.body ?? {}, saveConfig)));
1209
1239
  // AI News: the entries, a refresh now (answers at once; the page hears when it's done), and "seen".
1210
1240
  api.get('/system', wrap(() => system.view()));
1241
+ // Lanes: every agent's own ports and name ending (lanes.js), and the settings for them. A change
1242
+ // reaches a session the next time it starts.
1243
+ const lanesView = () => {
1244
+ const settings = laneSettings(config);
1245
+ return { ...settings, agents: store.list().filter((a) => laneOf(a.lane, settings)).map((a) => ({ id: a.id, name: a.name, running: Boolean(a.pid), ...laneOf(a.lane, settings) })).sort((x, y) => x.n - y.n) };
1246
+ };
1247
+ api.get('/lanes', wrap(() => lanesView()));
1248
+ api.put('/lanes', wrap((req) => {
1249
+ const b = req.body ?? {};
1250
+ const on = (v) => v === true || v === 'on';
1251
+ const next = { ...config.lanes };
1252
+ if ('enabled' in b) next.enabled = on(b.enabled);
1253
+ if ('port' in b) next.port = on(b.port);
1254
+ for (const k of ['base', 'size']) {
1255
+ if (!(k in b)) continue;
1256
+ if (laneSettings({ lanes: { [k]: b[k] } })[k] !== Number(b[k])) throw fail(400, k === 'base' ? 'The first port is a number from 1024 to 32667' : 'A lane has 1 to 100 ports');
1257
+ next[k] = Number(b[k]);
1258
+ }
1259
+ config.lanes = next;
1260
+ saveConfig({ lanes: next });
1261
+ for (const a of store.list()) manager.changed?.(a);
1262
+ return lanesView();
1263
+ }));
1211
1264
  api.get('/news', wrap(() => news.view()));
1212
1265
  api.post('/news/refresh', wrap((req) => {
1213
1266
  news.refresh({ search: req.body?.search === true ? true : null }).catch(() => {});