@lensmcp/protocol-types 1.26.1 → 1.26.3
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/index.d.ts +14 -1
- package/index.js +1 -1
- package/lib/changes.d.ts +15 -3
- package/lib/cluster-hosts.d.ts +272 -0
- package/lib/cluster-hosts.js +1 -0
- package/lib/dashboard-lint.d.ts +22 -0
- package/lib/dashboard-updates.d.ts +80 -0
- package/lib/dashboard-updates.js +1 -0
- package/lib/dashboard.d.ts +54 -1
- package/lib/docker-errors.d.ts +123 -0
- package/lib/docker-errors.js +1 -0
- package/lib/docker-jobs.d.ts +673 -0
- package/lib/docker-jobs.js +1 -0
- package/lib/docker-report.d.ts +99 -0
- package/lib/docker-report.js +2 -0
- package/lib/docker-runs.d.ts +300 -0
- package/lib/docker-runs.js +3 -0
- package/lib/expected-failure.d.ts +251 -0
- package/lib/expected-failure.js +2 -0
- package/lib/host-agents.d.ts +139 -0
- package/lib/host-agents.js +1 -0
- package/lib/hosts.d.ts +206 -0
- package/lib/hosts.js +1 -0
- package/lib/main-mirror.d.ts +117 -0
- package/lib/main-mirror.js +1 -0
- package/lib/peers.d.ts +1881 -0
- package/lib/peers.js +1 -0
- package/lib/proof.d.ts +32 -0
- package/lib/remote-instances.d.ts +129 -0
- package/lib/remote-instances.js +1 -0
- package/lib/resources.d.ts +2 -0
- package/lib/resources.js +1 -1
- package/lib/static-checks.d.ts +290 -0
- package/lib/static-checks.js +1 -0
- package/lib/team-delivery.d.ts +13 -0
- package/lib/team.d.ts +60 -2
- package/lib/workspace-actions.d.ts +104 -1
- package/lib/workspace-actions.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { CONTAINER_OOM, DOCKER_ENGINE_LOST, type DockerKillSeen } from './docker-jobs.js';
|
|
2
|
+
import { type ErrorCause } from './error-cause.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reading the two Docker failures off the bus (docker-jobs.ts: `ContainerOomEvent`, `DockerEngineLostEvent`;
|
|
5
|
+
* planning/docker/00-plan.md § 4 «Errors», slice D7): what each IS, in the words every list uses, and which accounts
|
|
6
|
+
* are one failure.
|
|
7
|
+
*
|
|
8
|
+
* Two lists show them — the dashboard's Errors page (`servers/lensmcp-mcp/src/dashboard/errors.ts`) and the agents'
|
|
9
|
+
* `observe_errors` (`apps/agent/src/lib/docker-errors.ts`) — in two processes that fold the same bus file. Both read
|
|
10
|
+
* here, so a row and an entry carry one cause id, one title, one headline and one next step, and count the same
|
|
11
|
+
* occurrences: an agent and the person talk about one thing.
|
|
12
|
+
*
|
|
13
|
+
* Pure and total. The bus is a file any local process appends to and its producer may be another version, so every
|
|
14
|
+
* field is checked, and a failure that lacks one is still told — with what it does say.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The worker Mac a failure happened on, as read (slice D16): its id, and the name to say it by when it has one — none:
|
|
18
|
+
* this Mac. A host that names no id is no host: the failure is read as this Mac's.
|
|
19
|
+
*/
|
|
20
|
+
export interface DockerErrorHost {
|
|
21
|
+
peer: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A container killed for memory, as read: everything but the kind may be missing. */
|
|
25
|
+
export interface ContainerOom {
|
|
26
|
+
kind: typeof CONTAINER_OOM;
|
|
27
|
+
run?: string;
|
|
28
|
+
job?: string;
|
|
29
|
+
service?: string;
|
|
30
|
+
container?: string;
|
|
31
|
+
seen?: DockerKillSeen;
|
|
32
|
+
limitMb?: number;
|
|
33
|
+
peakMb?: number;
|
|
34
|
+
budgetMb?: number;
|
|
35
|
+
context?: string;
|
|
36
|
+
host?: DockerErrorHost;
|
|
37
|
+
}
|
|
38
|
+
/** An engine that stopped answering, as read. */
|
|
39
|
+
export interface DockerEngineLost {
|
|
40
|
+
kind: typeof DOCKER_ENGINE_LOST;
|
|
41
|
+
context?: string;
|
|
42
|
+
runs: Array<{
|
|
43
|
+
run: string;
|
|
44
|
+
job?: string;
|
|
45
|
+
}>;
|
|
46
|
+
why?: string;
|
|
47
|
+
vmTotalMb?: number;
|
|
48
|
+
vmAvailableMb?: number;
|
|
49
|
+
/** Services of its runs found killed for memory once it was gone — part of this loss, not errors of their own. */
|
|
50
|
+
killed?: string[];
|
|
51
|
+
host?: DockerErrorHost;
|
|
52
|
+
}
|
|
53
|
+
export type DockerError = ContainerOom | DockerEngineLost;
|
|
54
|
+
/**
|
|
55
|
+
* One of the two failures out of an event's `raw` — or out of an entry that keeps `raw`'s fields flat, as
|
|
56
|
+
* `observe_errors` lists them — or nothing when it is neither. Never throws: a field of the wrong type is a field
|
|
57
|
+
* that is missing.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readDockerError(raw: unknown): DockerError | undefined;
|
|
60
|
+
/** The runs a failure explains: whatever else failed in one of them failed of it. */
|
|
61
|
+
export declare function dockerErrorRuns(error: DockerError): string[];
|
|
62
|
+
/** The run an error event of another kind says it happened because of (`raw.dockerRun`), if it names one. */
|
|
63
|
+
export declare function dockerRunOfEvent(raw: unknown): string | undefined;
|
|
64
|
+
/** A Docker failure as every list says it. */
|
|
65
|
+
export interface DockerErrorWords {
|
|
66
|
+
/**
|
|
67
|
+
* The cause, built from the job and the service (or the Docker context) as written — not from a folded message,
|
|
68
|
+
* as `errorCause` builds one: folding digits would make `redis6` and `redis7` one service, and a limit that is
|
|
69
|
+
* known on one account and not on the other would make one kill two causes.
|
|
70
|
+
*/
|
|
71
|
+
cause: ErrorCause;
|
|
72
|
+
/** The cause in a line, as both lists title it: `ContainerOOMKilled: api ran out of memory in system-e2e`. */
|
|
73
|
+
title: string;
|
|
74
|
+
/** What happened, in plain words. */
|
|
75
|
+
headline: string;
|
|
76
|
+
/** What to do next — for a kill: which budget, and by how much it was over. */
|
|
77
|
+
hint: string;
|
|
78
|
+
/** This occurrence's own numbers, in a line. */
|
|
79
|
+
facts: string;
|
|
80
|
+
/** Where it was: the job, or the Docker context. */
|
|
81
|
+
where: string;
|
|
82
|
+
}
|
|
83
|
+
/** The class each failure is told under: the pill on its row, and the first part of its cause's id. */
|
|
84
|
+
export declare const CONTAINER_OOM_ERROR = "ContainerOOMKilled";
|
|
85
|
+
export declare const DOCKER_ENGINE_LOST_ERROR = "DockerEngineLost";
|
|
86
|
+
/** How a Docker failure is said — its cause, its title, what it means and what to do next. */
|
|
87
|
+
export declare function dockerErrorWords(error: DockerError): DockerErrorWords;
|
|
88
|
+
/**
|
|
89
|
+
* What is known of one failure once a second account of it arrived: `told` with what `later` adds.
|
|
90
|
+
* - a kill and its other account: the numbers the first lacked, and the higher peak;
|
|
91
|
+
* - a loss and another watcher's account of it: the runs both name;
|
|
92
|
+
* - a loss and a container of one of its runs found killed afterwards: that service, on the loss.
|
|
93
|
+
*/
|
|
94
|
+
export declare function mergeDockerError<T extends DockerError>(told: T, later: DockerError): T;
|
|
95
|
+
/**
|
|
96
|
+
* How far apart two accounts of an engine that stopped answering are still one loss. Each run's watcher notices on its
|
|
97
|
+
* own — its stream ends, its next sample fails — so they tell it seconds apart, never together.
|
|
98
|
+
*/
|
|
99
|
+
export declare const DOCKER_ENGINE_LOSS_SAME_MS = 60000;
|
|
100
|
+
/**
|
|
101
|
+
* Which accounts are one failure — the one rule both lists count by.
|
|
102
|
+
*
|
|
103
|
+
* A KILL has two witnesses: the live events stream, and the inspect at the run's end. The first account of a container
|
|
104
|
+
* is the kill; the other witness's account of the same container completes it. A container killed AGAIN (a restart
|
|
105
|
+
* policy brings it back under the same id) is seen live each time, and each is a kill; the end inspect, which sees
|
|
106
|
+
* only that it was killed, adds none. An account that names no container is matched by its run and service; one that
|
|
107
|
+
* names neither is a kill of its own.
|
|
108
|
+
*
|
|
109
|
+
* A LOST ENGINE is told by every watcher that was on it: accounts for one context within
|
|
110
|
+
* {@link DOCKER_ENGINE_LOSS_SAME_MS} are one loss. A container of a run that was lost, found killed afterwards, went
|
|
111
|
+
* with the engine — part of that loss, never a row per container.
|
|
112
|
+
*/
|
|
113
|
+
export declare class DockerErrorLedger {
|
|
114
|
+
private readonly kills;
|
|
115
|
+
private readonly losses;
|
|
116
|
+
private readonly lostRuns;
|
|
117
|
+
/**
|
|
118
|
+
* Take one account, told by the event `eventId` at `at`. Returns the id of the event that already told this failure
|
|
119
|
+
* — this account only completes it — or undefined: it is a failure of its own, told by this event.
|
|
120
|
+
*/
|
|
121
|
+
account(error: DockerError, eventId: string, at: number): string | undefined;
|
|
122
|
+
private remember;
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var O=Object.defineProperty;var m=(e,o)=>O(e,"name",{value:o,configurable:!0});var B=Object.defineProperty,b=m((e,o)=>B(e,"name",{value:o,configurable:!0}),"m"),I=Object.defineProperty,c=b((e,o)=>I(e,"name",{value:o,configurable:!0}),"c");import{CONTAINER_OOM as k,DOCKER_ENGINE_LOST as g,DOCKER_RUN_FIELD as N}from"./docker-jobs.js";import{joinId as E}from"./error-cause.js";const _=200,f=50,$=c(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),h=c(e=>{if(typeof e!="string")return;const o=e.trim();return o?o.slice(0,_):void 0},"name"),p=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,"someMb"),C=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,"anyMb"),w=c(e=>Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0)),"defined"),D=c(e=>{if(!$(e))return;const o=h(e.peer);if(!o)return;const n=h(e.name);return n?{peer:o,name:n}:{peer:o}},"hostOf"),M=c(e=>e.name??e.peer,"hostWord");export function readDockerError(e){if($(e)){if(e.kind===k)return w({kind:k,run:h(e.run),job:h(e.job),service:h(e.service),container:h(e.container),seen:e.seen==="event"||e.seen==="inspect"?e.seen:void 0,limitMb:p(e.limitMb),peakMb:p(e.peakMb),budgetMb:p(e.budgetMb),context:h(e.context),host:D(e.host)});if(e.kind===g){const o=new Map;for(const r of Array.isArray(e.runs)?e.runs:[]){const i=$(r)?h(r.run):h(r),t=$(r)?h(r.job):void 0;i&&!o.has(i)&&o.size<f&&o.set(i,{run:i,...t?{job:t}:{}})}const n=Array.isArray(e.killed)?[...new Set(e.killed.map(h).filter(r=>!!r))].slice(0,f):[];return w({kind:g,context:h(e.context),runs:[...o.values()],why:h(e.why),vmTotalMb:p(e.vmTotalMb),vmAvailableMb:C(e.vmAvailableMb),killed:n.length?n:void 0,host:D(e.host)})}}}m(readDockerError,"readDockerError"),b(readDockerError,"readDockerError"),c(readDockerError,"readDockerError");export function dockerErrorRuns(e){return e.kind===k?e.run?[e.run]:[]:e.runs.map(o=>o.run)}m(dockerErrorRuns,"dockerErrorRuns"),b(dockerErrorRuns,"dockerErrorRuns"),c(dockerErrorRuns,"dockerErrorRuns");export function dockerRunOfEvent(e){return $(e)?h(e[N]):void 0}m(dockerRunOfEvent,"dockerRunOfEvent"),b(dockerRunOfEvent,"dockerRunOfEvent"),c(dockerRunOfEvent,"dockerRunOfEvent");export const CONTAINER_OOM_ERROR="ContainerOOMKilled",DOCKER_ENGINE_LOST_ERROR="DockerEngineLost";const L=256,a=c(e=>`${Math.round(e)} MiB`,"mib");function x(e){const o=`${e.service??"a container"} ran out of memory in ${e.job??"a Docker job"}`,n=`${e.service?`\xAB${e.service}\xBB`:"A container"} ran out of memory and was killed, in ${e.job?`the Docker job \xAB${e.job}\xBB`:"a Docker job"}${e.host?` on the worker \xAB${M(e.host)}\xBB`:""}`,r=e.job?`\`${e.budgetMb!==void 0&&e.service?`jobs.${e.job}.budget.services.${e.service}`:`jobs.${e.job}.budget`}\` in lensmcp.json`:"its job's budget in lensmcp.json \u2192 jobs",{limitMb:i,peakMb:t,budgetMb:s}=e;let l;if(i!==void 0&&s!==void 0){const d=Math.round(i)-Math.round(s);l=d>0?`It was killed at its ${a(i)} limit \u2014 ${a(d)} over the ${a(s)} it declares. Raise ${r} to what it takes (more than ${a(i)}), and the container's memory limit with it.`:d===0?`It was killed at its ${a(i)} limit, which is all it declares. Raise ${r} to what it takes, and the container's memory limit with it.`:`It was killed at its ${a(i)} limit, ${a(-d)} under the ${a(s)} it declares. Raise the container's memory limit to its budget (${r}) \u2014 and both, if it takes more.`}else if(i!==void 0)l=`It was killed at its ${a(i)} limit. Raise the limit, and ${r}, to what it takes.`;else if(t!==void 0&&s!==void 0){const d=Math.round(t)-Math.round(s);l=d>0?`It held ${a(t)} at its peak \u2014 ${a(d)} over the ${a(s)} it declares. Raise ${r} to what it takes, so the queue lets the job in only when Docker's VM has that much.`:`It held ${a(t)} at its peak, within the ${a(s)} it declares (${r}): it was killed at a lower limit of its own, or when Docker's VM ran out. Check its memory limit in the compose file, and what else the VM held.`}else t!==void 0?l=`It held ${a(t)} at its peak. Check ${r} against that, and the container's memory limit.`:s!==void 0?l=`Its peak was not sampled. It declares ${a(s)}: raise ${r} to what it takes, and the container's memory limit with it.`:l=`Raise ${r} to what the service takes, and the container's memory limit with it.`;const u=[i!==void 0?`killed at its ${a(i)} limit`:"killed for memory",t!==void 0?`peak ${a(t)}`:void 0,s!==void 0?`budget ${a(s)}`:void 0,e.run?`run ${e.run}`:void 0,e.seen==="inspect"?"found by the inspect at the run's end":void 0,e.host?`on the worker ${M(e.host)}`:void 0,e.context?`Docker context ${e.context}`:void 0];return{cause:{id:E("cause",[CONTAINER_OOM_ERROR,e.job,e.service]),errorName:CONTAINER_OOM_ERROR,message:o},title:`${CONTAINER_OOM_ERROR}: ${o}`,headline:n,hint:l,facts:u.filter(Boolean).join(" \xB7 "),where:e.job?`Docker job ${e.job}`:"Docker"}}m(x,"y"),b(x,"A"),c(x,"oomWords");function y(e){const o=e.host?` on the worker ${M(e.host)}`:"",n=`Docker stopped answering${e.context?` (context ${e.context})`:""}${o}`,r=[...new Set(e.runs.map(v=>v.job).filter(v=>!!v))],i=e.runs.length,t=e.host?`Docker on the worker \xAB${M(e.host)}\xBB`:"Docker",s=i===0?`${t} stopped answering while LensMCP ran work in it`:i===1?`${t} stopped answering while ${r[0]?`the job \xAB${r[0]}\xBB`:"a job"} ran: its containers went with it`:`${t} stopped answering while ${i} runs were in it${r.length?` (${r.map(v=>`\xAB${v}\xBB`).join(", ")})`:""}: their containers went with it`,{vmTotalMb:l,vmAvailableMb:u}=e,d=u===void 0?void 0:`${a(u)} free${l!==void 0?` of ${a(l)}`:""}`,j=u===void 0?"If nobody stopped it, its VM most likely ran out of memory: compare the jobs' budgets in lensmcp.json with what Docker's VM has.":u<=L?`Its VM had ${d} when it was last read: it most likely ran out of memory. Let less in at once (the jobs' budgets in lensmcp.json decide), or give Docker's VM more.`:`Its VM had ${d} when it was last read, so memory is not the likely reason: was Docker stopped or restarted?`,A=[i?`${i} run${i===1?"":"s"} lost: ${e.runs.map(v=>`${v.job??"a job"} (run ${v.run})`).join(", ")}`:void 0,e.why,d?`VM ${d}`:void 0,e.killed?.length?`killed for memory before it went: ${e.killed.join(", ")}`:void 0];return{cause:{id:E("cause",e.host?[DOCKER_ENGINE_LOST_ERROR,e.context,e.host.peer]:[DOCKER_ENGINE_LOST_ERROR,e.context]),errorName:DOCKER_ENGINE_LOST_ERROR,message:n},title:`${DOCKER_ENGINE_LOST_ERROR}: ${n}`,headline:s,hint:`Start Docker again${o} and run ${i>1?"the jobs":"the job"} again: a run lost with the engine has no result. ${j}`,facts:A.filter(Boolean).join(" \xB7 "),where:`${e.context?`Docker context ${e.context}`:"Docker"}${o}`}}m(y,"E"),b(y,"I"),c(y,"engineWords");export function dockerErrorWords(e){return e.kind===k?x(e):y(e)}m(dockerErrorWords,"dockerErrorWords"),b(dockerErrorWords,"dockerErrorWords"),c(dockerErrorWords,"dockerErrorWords");export function mergeDockerError(e,o){if(e.kind===k){if(o.kind!==k)return e;const t=Math.max(e.peakMb??0,o.peakMb??0);return w({...o,...e,seen:e.seen==="event"||o.seen==="event"?"event":e.seen??o.seen,peakMb:t>0?t:void 0})}const n=e;if(o.kind===k)return o.service&&!n.killed?.includes(o.service)?{...n,killed:[...n.killed??[],o.service].slice(0,f)}:e;const r=new Map(n.runs.map(t=>[t.run,t]));for(const t of o.runs)(!r.has(t.run)||!r.get(t.run).job&&t.job)&&r.set(t.run,t);const i=[...new Set([...n.killed??[],...o.killed??[]])];return w({...o,...n,runs:[...r.values()].slice(0,f),vmAvailableMb:n.vmAvailableMb!==void 0&&o.vmAvailableMb!==void 0?Math.min(n.vmAvailableMb,o.vmAvailableMb):n.vmAvailableMb??o.vmAvailableMb,killed:i.length?i:void 0})}m(mergeDockerError,"mergeDockerError"),b(mergeDockerError,"mergeDockerError"),c(mergeDockerError,"mergeDockerError");export const DOCKER_ENGINE_LOSS_SAME_MS=6e4;const R=2e3,S=200;export class DockerErrorLedger{static{m(this,"DockerErrorLedger")}static{b(this,"DockerErrorLedger")}static{c(this,"DockerErrorLedger")}constructor(){this.kills=new Map,this.losses=new Map,this.lostRuns=new Map}account(o,n,r){if(o.kind===g){const l=o.host?`${o.host.peer}\0${o.context??""}`:o.context??"",u=this.losses.get(l),d=u&&Math.abs(r-u.at)<=DOCKER_ENGINE_LOSS_SAME_MS?u.told:void 0;d||this.remember(this.losses,l,{told:n,at:r},S);for(const j of o.runs)this.remember(this.lostRuns,j.run,d??n,R);return d}const i=o.seen!=="inspect",t=o.run&&o.container?`${o.run}\0${o.container}`:o.run&&o.service?`${o.run}\0\0${o.service}`:void 0,s=t?this.kills.get(t):void 0;if(!s){const l=!i&&o.run?this.lostRuns.get(o.run):void 0;if(l)return l;t&&this.remember(this.kills,t,{told:n,live:i?1:0},R);return}if(!i)return s.told;if(s.live===0)return s.live=1,s.told;s.live+=1,s.told=n}remember(o,n,r,i){o.delete(n),o.set(n,r),o.size>i&&o.delete(o.keys().next().value)}}
|