@lensmcp/protocol-types 1.26.7 → 1.26.8
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 +1 -0
- package/index.js +1 -1
- package/lib/ai-call-groups.js +2 -2
- package/lib/ai-call-row.js +3 -3
- package/lib/ai-call.js +9 -9
- package/lib/ai-context.js +6 -6
- package/lib/ai-origins.js +8 -8
- package/lib/bounded-clone.js +1 -1
- package/lib/bounded-map.js +1 -1
- package/lib/bounded-writer.js +1 -1
- package/lib/capture-demand.js +1 -1
- package/lib/dashboard-path.js +1 -1
- package/lib/dashboard.d.ts +15 -0
- package/lib/docker-errors.js +1 -1
- package/lib/docker-jobs.d.ts +22 -0
- package/lib/docker-jobs.js +1 -1
- package/lib/docker-report.js +2 -2
- package/lib/docker-runs.js +3 -3
- package/lib/error-cause.js +6 -6
- package/lib/error-dismissal.js +1 -1
- package/lib/error-verdict.d.ts +161 -0
- package/lib/error-verdict.js +3 -0
- package/lib/event-loop.js +1 -1
- package/lib/expected-failure.js +2 -2
- package/lib/flood-guard.js +1 -1
- package/lib/goal-design.js +1 -1
- package/lib/host-agents.js +1 -1
- package/lib/lint-coverage.js +1 -1
- package/lib/log-query.js +1 -1
- package/lib/metrics-reset.js +1 -1
- package/lib/overseer-findings.js +1 -1
- package/lib/peers.d.ts +14 -1
- package/lib/peers.js +1 -1
- package/lib/perf-rules.js +1 -1
- package/lib/pod-memory.js +1 -1
- package/lib/producer-health.js +1 -1
- package/lib/remote-instances.js +1 -1
- package/lib/sources.js +1 -1
- package/lib/static-checks.js +1 -1
- package/lib/system-report.js +1 -1
- package/lib/team.js +1 -1
- package/lib/workspace-actions.d.ts +10 -0
- package/package.json +1 -1
package/lib/capture-demand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=(r,e)=>s(r,"name",{value:e,configurable:!0});var p=Object.defineProperty,c=a((r,e)=>p(r,"name",{value:e,configurable:!0}),"o"),u=Object.defineProperty,E=c((r,e)=>u(r,"name",{value:e,configurable:!0}),"s");export const CAPTURE_REQUEST_FILENAME="capture-request.json",CAPTURE_PRESENCE_FILENAME="capture-runner.json";export function appMatchesPage(r,e){const t=r.trim().toLowerCase();if(!t)return!1;if(e.project&&e.project.toLowerCase()===t)return!0;const o=e.url.toLowerCase();if(o===t||o.replace(/\/+$/,"")===t.replace(/\/+$/,""))return!0;try{const n=new URL(e.url);return/^\d+$/.test(t)?n.port===t:n.origin.toLowerCase()===t.replace(/\/+$/,"")}catch{return!1}}a(appMatchesPage,"appMatchesPage"),c(appMatchesPage,"appMatchesPage"),E(appMatchesPage,"appMatchesPage");export const CAPTURE_RULES_FILENAME="capture-rules.json";
|
package/lib/dashboard-path.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var t=(e,n)=>d(e,"name",{value:n,configurable:!0});var a=Object.defineProperty,c=t((e,n)=>a(e,"name",{value:n,configurable:!0}),"c"),g=Object.defineProperty,o=c((e,n)=>g(e,"name",{value:n,configurable:!0}),"t");const p={"~":"~~","/":"~s","\\":"~b","\0":"~0"},l={"~":"~",s:"/",b:"\\",0:"\0",d:"."},m=/%2f|%5c|%2e|%00/i;export function encodeSegment(e){return e==="."||e===".."?e.replace(/\./g,"~d"):encodeURIComponent(e.replace(/[~/\\\0]/g,n=>p[n])).replace(/%3A/g,":").replace(/%40/g,"@")}t(encodeSegment,"encodeSegment"),c(encodeSegment,"encodeSegment"),o(encodeSegment,"encodeSegment");export function decodeSegment(e){let n;try{n=decodeURIComponent(e)}catch{n=e}return m.test(e)?n:n.replace(/~([~sb0d])/g,(u,r)=>l[r])}t(decodeSegment,"decodeSegment"),c(decodeSegment,"decodeSegment"),o(decodeSegment,"decodeSegment");
|
package/lib/dashboard.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { WorktreeRunOutcome } from './workspace-actions.js';
|
|
|
17
17
|
import type { DesignStage } from './goal-design.js';
|
|
18
18
|
import type { DashExternalBefore, DashSqlBefore } from './metrics-reset.js';
|
|
19
19
|
import type { ExpectedFailureMatch } from './expected-failure.js';
|
|
20
|
+
import type { ErrorJudgement, ErrorVerdict } from './error-verdict.js';
|
|
20
21
|
/** Bumped only on a breaking change to the stream framing itself. */
|
|
21
22
|
export declare const DASHBOARD_PROTOCOL = 1;
|
|
22
23
|
/** The swimlane a flow event belongs to (mirrors `FlowArea` in `@lensmcp/core`'s flow-shape). */
|
|
@@ -918,6 +919,8 @@ export interface DashErrorGroup {
|
|
|
918
919
|
/** The rule that holds it back — on a group in `DashErrors.expected.groups`. */
|
|
919
920
|
expectedBy?: string;
|
|
920
921
|
expectedReason?: string;
|
|
922
|
+
/** Whether it is a bug, as the lens can show it (overseer-105, error-verdict.ts). Absent: a bug, nothing says otherwise; and on a standing group. */
|
|
923
|
+
verdict?: ErrorVerdict;
|
|
921
924
|
}
|
|
922
925
|
/** A standing rule as Errors lists it (overseer-86, expected-failure.ts `ExpectedRuleView`). */
|
|
923
926
|
export interface DashExpectedRule {
|
|
@@ -1028,6 +1031,14 @@ export interface DashErrorCause {
|
|
|
1028
1031
|
ongoing?: boolean;
|
|
1029
1032
|
/** It was dismissed and happened again: counted from its return. */
|
|
1030
1033
|
back?: boolean;
|
|
1034
|
+
/** Its groups' verdicts in one (overseer-105): not a bug only when every one it counts is not. Absent: a bug. */
|
|
1035
|
+
verdict?: ErrorVerdict;
|
|
1036
|
+
}
|
|
1037
|
+
/** `POST /api/errors/verdict` (overseer-105): «this is a bug» over the lens's verdict on these rows, or its undo. */
|
|
1038
|
+
export interface DashVerdictBody {
|
|
1039
|
+
ids?: string[];
|
|
1040
|
+
causes?: string[];
|
|
1041
|
+
verdict: 'bug' | 'clear';
|
|
1031
1042
|
}
|
|
1032
1043
|
/** `POST /api/errors/dismiss` and `/api/errors/restore` — the body, and the answer. */
|
|
1033
1044
|
export interface DashErrorIds {
|
|
@@ -2629,6 +2640,8 @@ export interface DashAiSuggestion {
|
|
|
2629
2640
|
overall?: DashAiOverall;
|
|
2630
2641
|
/** What evidence or approval the review was missing. */
|
|
2631
2642
|
openQuestions?: string[];
|
|
2643
|
+
/** Whether the thing is a bug, in the review's judgement — the error explanation's (overseer-105). Shown as Claude's, never applied. */
|
|
2644
|
+
judgement?: ErrorJudgement;
|
|
2632
2645
|
}
|
|
2633
2646
|
/**
|
|
2634
2647
|
* A review's indicators in one number, 0–100: their weighted mean — held at the score of a bug indicator (correct
|
|
@@ -3113,6 +3126,8 @@ export interface DashReviewSummary {
|
|
|
3113
3126
|
}>;
|
|
3114
3127
|
/** A statement reviewed only in an earlier version under its name: that version's id. */
|
|
3115
3128
|
of?: string;
|
|
3129
|
+
/** Claude's judgement of whether it is a bug, when the review gave one (the error explanation's). */
|
|
3130
|
+
judgement?: ErrorJudgement;
|
|
3116
3131
|
}
|
|
3117
3132
|
/** `/api/ai/review-marks?kind=`: each target of a kind with a review or a run, by its id — a list's review chip. */
|
|
3118
3133
|
export interface DashReviewMarks {
|
package/lib/docker-errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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)}}
|
package/lib/docker-jobs.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ interface LensJobCommon {
|
|
|
107
107
|
timeoutMinutes?: number;
|
|
108
108
|
/** A run lost with its worker may be placed again elsewhere, once. */
|
|
109
109
|
retryable?: boolean;
|
|
110
|
+
/** What a run on a worker does when the link to its organizer drops — none: it goes on {@link DEFAULT_LINK_LOSS_MINUTES} minutes. */
|
|
111
|
+
onLinkLoss?: LensJobLinkLoss;
|
|
110
112
|
/** `<project>:<target>`: `workspace_action_run` runs the job as that target's e2e. */
|
|
111
113
|
nx?: string;
|
|
112
114
|
}
|
|
@@ -151,6 +153,16 @@ export interface PlaywrightJob extends LensJobCommon {
|
|
|
151
153
|
};
|
|
152
154
|
}
|
|
153
155
|
export type LensJob = ComposeJob | TestcontainersJob | PlaywrightJob;
|
|
156
|
+
/**
|
|
157
|
+
* What a run on a worker Mac does when the link to its organizer drops (overseer-104): `"cancel"` — cancelled and
|
|
158
|
+
* cleaned there once 45 s pass without a word; or it goes on, its end and evidence sent when the link is back, for at
|
|
159
|
+
* most `continueMinutes` — then cancelled and cleaned, and lost on the organizer.
|
|
160
|
+
*/
|
|
161
|
+
export type LensJobLinkLoss = 'cancel' | {
|
|
162
|
+
continueMinutes: number;
|
|
163
|
+
};
|
|
164
|
+
/** How long a run goes on through a dropped link when neither its job nor its command line says. */
|
|
165
|
+
export declare const DEFAULT_LINK_LOSS_MINUTES = 15;
|
|
154
166
|
/** What keeps a job from running — of one job, or of the `jobs` block itself. */
|
|
155
167
|
export interface LensJobProblem {
|
|
156
168
|
job?: string;
|
|
@@ -163,6 +175,16 @@ export interface LensJobsRead {
|
|
|
163
175
|
}
|
|
164
176
|
/** A problem as one line: «jobs.system-e2e: api-worker has no budget». */
|
|
165
177
|
export declare const jobProblemText: (p: LensJobProblem) => string;
|
|
178
|
+
/** Why `value` is no {@link LensJobLinkLoss} — undefined when it is one. */
|
|
179
|
+
export declare function linkLossProblem(value: unknown): string | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* The minutes a run goes on through a dropped link — 0: cancelled at once. The run's own choice, else its job's, else
|
|
182
|
+
* {@link DEFAULT_LINK_LOSS_MINUTES}; never past the minutes the run may run.
|
|
183
|
+
*/
|
|
184
|
+
export declare function linkLossMinutes(job: {
|
|
185
|
+
onLinkLoss?: LensJobLinkLoss;
|
|
186
|
+
timeoutMinutes?: number;
|
|
187
|
+
}, run?: LensJobLinkLoss, timeoutMinutes?: number | undefined): number;
|
|
166
188
|
/**
|
|
167
189
|
* `lensmcp.json` → `jobs`, as written: the jobs that may run, and what is wrong with the others. A job with a problem
|
|
168
190
|
* is left out whole — a manifest half-read would run a stack on a budget nobody declared.
|
package/lib/docker-jobs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var a=(e,s)=>w(e,"name",{value:s,configurable:!0});var $=Object.defineProperty,c=a((e,s)=>$(e,"name",{value:s,configurable:!0}),"a"),x=Object.defineProperty,u=c((e,s)=>x(e,"name",{value:s,configurable:!0}),"a"),I=Object.defineProperty,p=u((e,s)=>I(e,"name",{value:s,configurable:!0}),"a"),C=Object.defineProperty,n=p((e,s)=>C(e,"name",{value:s,configurable:!0}),"i");export const DOCKER_LABELS={run:"com.lensmcp.run",home:"com.lensmcp.home",job:"com.lensmcp.job",probe:"com.lensmcp.probe"},LENS_JOB_KINDS=["compose","testcontainers","playwright"];export function neverShipped(e){const s=(e.split("/").at(-1)??"").toLowerCase();return s===".env"||s===".env.local"||/^\.env\..+\.local$/.test(s)}a(neverShipped,"neverShipped"),c(neverShipped,"neverShipped"),u(neverShipped,"neverShipped"),p(neverShipped,"neverShipped"),n(neverShipped,"neverShipped");export const jobInputFiles=n(e=>[...new Set(e.inputs?.files??[])].sort(),"jobInputFiles"),jobMintedFiles=n(e=>[...new Set(e.inputs?.minted??[])].sort(),"jobMintedFiles"),jobProblemText=n(e=>e.job===void 0?e.problem:`jobs.${e.job}: ${e.problem}`,"jobProblemText");const S=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","nx","budget"],P={compose:[...S,"compose"],testcontainers:S,playwright:[...S,"stack"]},R={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},_=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,A=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,N=1024*1024,L=360,g=100,D=4e3,l=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),E=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=N,"isMb"),U=n(e=>e.map(s=>`"${s}"`).join(", "),"quoted");function f(e){return typeof e!="string"||!e||e.length>500||/[\0\\]/.test(e)||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:/.test(e)?!1:!e.split("/").includes("..")}a(f,"f"),c(f,"m"),u(f,"m"),p(f,"b"),n(f,"inTree");function v(e){return Array.isArray(e)&&e.length>=1&&e.length<=g&&e.every(s=>typeof s=="string"&&s.length<=D)&&e[0]!==""}a(v,"g"),c(v,"f"),u(v,"f"),p(v,"g"),n(v,"isArgv");function h(e,s,t,o){const i=Object.keys(e).filter(r=>!s.includes(r));i.length&&o.push(`${t?`${t} has`:"has"} ${i.length===1?"an unknown key":"unknown keys"} ${U(i)}`)}a(h,"l"),c(h,"l"),u(h,"h"),p(h,"f"),n(h,"unknownKeys");function j(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>g||!e.every(f))&&t.push(`${s} is a list of paths inside the checkout`)}a(j,"j"),c(j,"M"),u(j,"A"),p(j,"R"),n(j,"paths");function y(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>g||!e.every(f))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const i=o.split("/");i.some(r=>r===""||r===".")?t.push(`${s} names ${JSON.stringify(o)}: a file is written as git names it \u2014 a/b.json, with no ./, no // and no trailing /`):i.some(r=>r.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}a(y,"v"),c(y,"v"),u(y,"y"),p(y,"A"),n(y,"inputPaths");function M(e){if(!l(e))return["is not an object"];const s=e.kind;if(!LENS_JOB_KINDS.includes(s))return[`kind is ${LENS_JOB_KINDS.slice(0,-1).join(", ")} or ${LENS_JOB_KINDS.at(-1)}`];const t=[];h(e,P[s],"",t),e.lane!==void 0&&e.lane!=="light"&&e.lane!=="heavy"&&t.push("lane is light or heavy"),v(e.command)||t.push("command is a program and its arguments, as a list of strings \u2014 not a shell line"),e.cleanup!==void 0&&!v(e.cleanup)&&t.push("cleanup is a program and its arguments, as a list of strings"),e.prepare!==void 0&&!(Array.isArray(e.prepare)&&e.prepare.length<=g&&e.prepare.every(v))&&t.push("prepare is a list of steps, each a program and its arguments"),e.report!==void 0&&!["jest","vitest","playwright"].includes(e.report)&&t.push("report is jest, vitest or playwright"),j(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=L)&&t.push(`timeoutMinutes is execution minutes, up to ${L}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false"),e.nx!==void 0&&!(typeof e.nx=="string"&&/^\S+:[^\s:]+$/.test(e.nx))&&t.push("nx is <project>:<target>");const o=e.inputs;if(o!==void 0)if(!l(o))t.push("inputs is an object of files, minted and secrets");else{h(o,["files","minted","secrets"],"inputs",t);const r=y(o.files,"inputs.files",t),b=y(o.minted,"inputs.minted",t);for(const m of r)neverShipped(m)&&t.push(`inputs.files names ${m}, which is never shipped to another Mac \u2014 declare it in inputs.minted, and make it in a prepare step`);const d=[...new Set(r.filter(m=>b.includes(m)))];d.length&&t.push(`inputs names ${d.join(", ")} in files and in minted: a file is shipped by hash, or made per run on the host that runs it \u2014 not both`);const k=o.secrets;k!==void 0&&!(Array.isArray(k)&&k.length<=g&&k.every(m=>typeof m=="string"&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(m)))&&t.push("inputs.secrets is a list of variable names, never values")}const i=e.budget;if(!l(i))t.push("has no budget: the memory it declares is what it is admitted by");else{h(i,R[s],"budget",t);for(const r of["buildMb","hostMb","vmMb"])R[s].includes(r)&&i[r]!==void 0&&!E(i[r])&&t.push(`budget.${r} is MiB, a whole number from 1 to ${N}`);if(s==="testcontainers"&&(i.vmMb===void 0||i.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&i.vmMb===void 0&&i.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const r=i.services;if(!l(r)||!Object.keys(r).length)t.push("budget.services is each service's expected peak, MiB, by its name in the compose files");else for(const[b,d]of Object.entries(r))A.test(b)?E(d)||t.push(`budget.services.${b} is MiB, a whole number from 1 to ${N}`):t.push(`budget.services has "${b}", which is no service name`)}}if(s==="compose"){const r=e.compose;if(!l(r))t.push("compose is an object of files and edge");else{h(r,["files","edge"],"compose",t);const b=r.files;(!Array.isArray(b)||!b.length||b.length>g||!b.every(f))&&t.push("compose.files is the compose files, as paths inside the checkout");const d=r.edge;d!==void 0&&(!l(d)||typeof d.service!="string"||!A.test(d.service)||!Number.isInteger(d.port)||d.port<1||d.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(h(d,["service","port"],"compose.edge",t),l(i)&&l(i.services)&&!Object.hasOwn(i.services,d.service)&&t.push(`${d.service} has no budget`)))}}return s==="playwright"&&e.stack!==void 0&&!(typeof e.stack=="string"&&_.test(e.stack))&&t.push("stack is the name of a compose job of this file"),t}a(M,"M"),c(M,"k"),u(M,"E"),p(M,"j"),n(M,"jobProblems");export function readLensJobs(e){const s={jobs:{},problems:[]};if(e===void 0)return s;if(!l(e))return s.problems.push({problem:"jobs is an object of jobs by name"}),s;for(const[t,o]of Object.entries(e)){if(!_.test(t)){s.problems.push({job:t,problem:"a job's name is letters, digits, dots, dashes and underscores \u2014 63 at most, the first a letter or a digit"});continue}const i=M(o);i.length?s.problems.push(...i.map(r=>({job:t,problem:r}))):s.jobs[t]=o}for(const[t,o]of Object.entries(s.jobs))o.kind!=="playwright"||o.stack===void 0||s.jobs[o.stack]?.kind!=="compose"&&(s.problems.push({job:t,problem:`stack names "${o.stack}", which is no compose job of this file that may run`}),delete s.jobs[t]);return s}a(readLensJobs,"readLensJobs"),c(readLensJobs,"readLensJobs"),u(readLensJobs,"readLensJobs"),p(readLensJobs,"readLensJobs"),n(readLensJobs,"readLensJobs");const O=n(e=>Object.values(e).reduce((s,t)=>s+t,0),"sum");export function jobVmNeedMb(e,s={}){if(e.kind==="compose")return Math.max(e.budget.buildMb??0,O(e.budget.services));if(e.kind==="testcontainers")return e.budget.vmMb;const t=e.budget.vmMb??0,o=e.stack===void 0?void 0:s[e.stack];return o?.kind==="compose"?Math.max(o.budget.buildMb??0,O(o.budget.services)+t):t}a(jobVmNeedMb,"jobVmNeedMb"),c(jobVmNeedMb,"jobVmNeedMb"),u(jobVmNeedMb,"jobVmNeedMb"),p(jobVmNeedMb,"jobVmNeedMb"),n(jobVmNeedMb,"jobVmNeedMb");export function jobHostNeedMb(e,s={}){const t=e.budget.hostMb??0,o=e.kind==="playwright"&&e.stack!==void 0?s[e.stack]:void 0;return t+(o?.kind==="compose"?o.budget.hostMb??0:0)}a(jobHostNeedMb,"jobHostNeedMb"),c(jobHostNeedMb,"jobHostNeedMb"),u(jobHostNeedMb,"jobHostNeedMb"),p(jobHostNeedMb,"jobHostNeedMb"),n(jobHostNeedMb,"jobHostNeedMb");export function jobLane(e){return e.lane?e.lane:e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"heavy":"light"}a(jobLane,"jobLane"),c(jobLane,"jobLane"),u(jobLane,"jobLane"),p(jobLane,"jobLane"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}a(unbudgetedServices,"unbudgetedServices"),c(unbudgetedServices,"unbudgetedServices"),u(unbudgetedServices,"unbudgetedServices"),p(unbudgetedServices,"unbudgetedServices"),n(unbudgetedServices,"unbudgetedServices");export const RUN_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/;export function runShortId(e){const s=e.toLowerCase().replace(/^[a-z]+_/,"").replace(/[^a-z0-9]/g,"").slice(0,8);return s.length===8?s:void 0}a(runShortId,"runShortId"),c(runShortId,"runShortId"),u(runShortId,"runShortId"),p(runShortId,"runShortId"),n(runShortId,"runShortId");export const composeProjectOf=n(e=>`lensmcp-${e}`,"composeProjectOf"),DOCKER_RUN_ENV={id:"LENSMCP_RUN_ID",origin:"LENSMCP_RUN_ORIGIN",artifacts:"LENSMCP_RUN_ARTIFACTS",labels:"LENSMCP_RUN_LABELS",override:"LENSMCP_COMPOSE_OVERRIDE",project:"COMPOSE_PROJECT_NAME"};export function dockerRunLabels(e){return{[DOCKER_LABELS.run]:e.id,[DOCKER_LABELS.home]:e.home,[DOCKER_LABELS.job]:e.job}}a(dockerRunLabels,"dockerRunLabels"),c(dockerRunLabels,"dockerRunLabels"),u(dockerRunLabels,"dockerRunLabels"),p(dockerRunLabels,"dockerRunLabels"),n(dockerRunLabels,"dockerRunLabels");export const runLabelsEnv=n(e=>JSON.stringify(e),"runLabelsEnv");export function jobRunScope(e){return e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"stack":jobVmNeedMb(e)>0?"containers":"none"}a(jobRunScope,"jobRunScope"),c(jobRunScope,"jobRunScope"),u(jobRunScope,"jobRunScope"),p(jobRunScope,"jobRunScope"),n(jobRunScope,"jobRunScope");export const RYUK_DISABLED_ENV="TESTCONTAINERS_RYUK_DISABLED",RYUK_LABEL="org.testcontainers.ryuk";export function ryukWarning(e,s){const t=s[RYUK_DISABLED_ENV];if(!(e.kind!=="testcontainers"||t===void 0||t.trim().toLowerCase()!=="true"))return`${RYUK_DISABLED_ENV}=${t.trim()} is set in the job's environment: testcontainers' own reaper (Ryuk) is off, so a container the suite leaves is removed only where it carries the run's labels \u2014 hand ${DOCKER_RUN_ENV.labels} to every container it starts. One that does not carry them stays in Docker's VM: LensMCP never removes it, and nothing else does.`}a(ryukWarning,"ryukWarning"),c(ryukWarning,"ryukWarning"),u(ryukWarning,"ryukWarning"),p(ryukWarning,"ryukWarning"),n(ryukWarning,"ryukWarning");export const MAX_RUN_ROUTE_SEC=14400,DOCKER_RUN_ENDS=["passed","failed","cancelled","timeout","errored","lost"],dockerRunEnded=n(e=>DOCKER_RUN_ENDS.includes(e),"dockerRunEnded"),MAX_RUN_STRANGERS=20,MAX_RUN_KILLS=100,CONTAINER_OOM="container-oom",DOCKER_ENGINE_LOST="docker-engine-lost",DOCKER_RUN_FIELD="dockerRun";
|
|
1
|
+
"use strict";var w=Object.defineProperty;var i=(e,s)=>w(e,"name",{value:s,configurable:!0});var $=Object.defineProperty,r=i((e,s)=>$(e,"name",{value:s,configurable:!0}),"i"),x=Object.defineProperty,n=r((e,s)=>x(e,"name",{value:s,configurable:!0}),"s");export const DOCKER_LABELS={run:"com.lensmcp.run",home:"com.lensmcp.home",job:"com.lensmcp.job",probe:"com.lensmcp.probe"},LENS_JOB_KINDS=["compose","testcontainers","playwright"];export function neverShipped(e){const s=(e.split("/").at(-1)??"").toLowerCase();return s===".env"||s===".env.local"||/^\.env\..+\.local$/.test(s)}i(neverShipped,"neverShipped"),r(neverShipped,"neverShipped"),n(neverShipped,"neverShipped");export const jobInputFiles=n(e=>[...new Set(e.inputs?.files??[])].sort(),"jobInputFiles"),jobMintedFiles=n(e=>[...new Set(e.inputs?.minted??[])].sort(),"jobMintedFiles"),DEFAULT_LINK_LOSS_MINUTES=15,jobProblemText=n(e=>e.job===void 0?e.problem:`jobs.${e.job}: ${e.problem}`,"jobProblemText");const j=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","onLinkLoss","nx","budget"],I={compose:[...j,"compose"],testcontainers:j,playwright:[...j,"stack"]},S={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},E=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,R=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,L=1024*1024,g=360,f=100,C=4e3,l=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),A=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=L,"isMb"),P=n(e=>e.map(s=>`"${s}"`).join(", "),"quoted");export function linkLossProblem(e){if(e==="cancel")return;const s=l(e)&&Object.keys(e).length===1?e.continueMinutes:void 0;if(!(typeof s=="number"&&Number.isInteger(s)&&s>=1&&s<=g))return`onLinkLoss is "cancel" or { "continueMinutes": 1 to ${g} }`}i(linkLossProblem,"linkLossProblem"),r(linkLossProblem,"linkLossProblem"),n(linkLossProblem,"linkLossProblem");export function linkLossMinutes(e,s,t=e.timeoutMinutes){const o=s??e.onLinkLoss??{continueMinutes:DEFAULT_LINK_LOSS_MINUTES};return o==="cancel"?0:Math.min(o.continueMinutes,Math.ceil(t??g))}i(linkLossMinutes,"linkLossMinutes"),r(linkLossMinutes,"linkLossMinutes"),n(linkLossMinutes,"linkLossMinutes");function v(e){return typeof e!="string"||!e||e.length>500||/[\0\\]/.test(e)||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:/.test(e)?!1:!e.split("/").includes("..")}i(v,"v"),r(v,"y"),n(v,"inTree");function y(e){return Array.isArray(e)&&e.length>=1&&e.length<=f&&e.every(s=>typeof s=="string"&&s.length<=C)&&e[0]!==""}i(y,"y"),r(y,"k"),n(y,"isArgv");function m(e,s,t,o){const p=Object.keys(e).filter(u=>!s.includes(u));p.length&&o.push(`${t?`${t} has`:"has"} ${p.length===1?"an unknown key":"unknown keys"} ${P(p)}`)}i(m,"m"),r(m,"m"),n(m,"unknownKeys");function _(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>f||!e.every(v))&&t.push(`${s} is a list of paths inside the checkout`)}i(_,"S"),r(_,"$"),n(_,"paths");function k(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>f||!e.every(v))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const p=o.split("/");p.some(u=>u===""||u===".")?t.push(`${s} names ${JSON.stringify(o)}: a file is written as git names it \u2014 a/b.json, with no ./, no // and no trailing /`):p.some(u=>u.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}i(k,"j"),r(k,"N"),n(k,"inputPaths");function N(e){if(!l(e))return["is not an object"];const s=e.kind;if(!LENS_JOB_KINDS.includes(s))return[`kind is ${LENS_JOB_KINDS.slice(0,-1).join(", ")} or ${LENS_JOB_KINDS.at(-1)}`];const t=[];m(e,I[s],"",t),e.lane!==void 0&&e.lane!=="light"&&e.lane!=="heavy"&&t.push("lane is light or heavy"),y(e.command)||t.push("command is a program and its arguments, as a list of strings \u2014 not a shell line"),e.cleanup!==void 0&&!y(e.cleanup)&&t.push("cleanup is a program and its arguments, as a list of strings"),e.prepare!==void 0&&!(Array.isArray(e.prepare)&&e.prepare.length<=f&&e.prepare.every(y))&&t.push("prepare is a list of steps, each a program and its arguments"),e.report!==void 0&&!["jest","vitest","playwright"].includes(e.report)&&t.push("report is jest, vitest or playwright"),_(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=g)&&t.push(`timeoutMinutes is execution minutes, up to ${g}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false");const o=e.onLinkLoss,p=o===void 0?void 0:linkLossProblem(o);p?t.push(p):l(o)&&typeof e.timeoutMinutes=="number"&&o.continueMinutes>e.timeoutMinutes&&t.push(`onLinkLoss.continueMinutes is past timeoutMinutes (${e.timeoutMinutes}): a run goes on through a dropped link no longer than it may run`),e.nx!==void 0&&!(typeof e.nx=="string"&&/^\S+:[^\s:]+$/.test(e.nx))&&t.push("nx is <project>:<target>");const u=e.inputs;if(u!==void 0)if(!l(u))t.push("inputs is an object of files, minted and secrets");else{m(u,["files","minted","secrets"],"inputs",t);const a=k(u.files,"inputs.files",t),b=k(u.minted,"inputs.minted",t);for(const h of a)neverShipped(h)&&t.push(`inputs.files names ${h}, which is never shipped to another Mac \u2014 declare it in inputs.minted, and make it in a prepare step`);const c=[...new Set(a.filter(h=>b.includes(h)))];c.length&&t.push(`inputs names ${c.join(", ")} in files and in minted: a file is shipped by hash, or made per run on the host that runs it \u2014 not both`);const M=u.secrets;M!==void 0&&!(Array.isArray(M)&&M.length<=f&&M.every(h=>typeof h=="string"&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(h)))&&t.push("inputs.secrets is a list of variable names, never values")}const d=e.budget;if(!l(d))t.push("has no budget: the memory it declares is what it is admitted by");else{m(d,S[s],"budget",t);for(const a of["buildMb","hostMb","vmMb"])S[s].includes(a)&&d[a]!==void 0&&!A(d[a])&&t.push(`budget.${a} is MiB, a whole number from 1 to ${L}`);if(s==="testcontainers"&&(d.vmMb===void 0||d.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&d.vmMb===void 0&&d.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const a=d.services;if(!l(a)||!Object.keys(a).length)t.push("budget.services is each service's expected peak, MiB, by its name in the compose files");else for(const[b,c]of Object.entries(a))R.test(b)?A(c)||t.push(`budget.services.${b} is MiB, a whole number from 1 to ${L}`):t.push(`budget.services has "${b}", which is no service name`)}}if(s==="compose"){const a=e.compose;if(!l(a))t.push("compose is an object of files and edge");else{m(a,["files","edge"],"compose",t);const b=a.files;(!Array.isArray(b)||!b.length||b.length>f||!b.every(v))&&t.push("compose.files is the compose files, as paths inside the checkout");const c=a.edge;c!==void 0&&(!l(c)||typeof c.service!="string"||!R.test(c.service)||!Number.isInteger(c.port)||c.port<1||c.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(m(c,["service","port"],"compose.edge",t),l(d)&&l(d.services)&&!Object.hasOwn(d.services,c.service)&&t.push(`${c.service} has no budget`)))}}return s==="playwright"&&e.stack!==void 0&&!(typeof e.stack=="string"&&E.test(e.stack))&&t.push("stack is the name of a compose job of this file"),t}i(N,"A"),r(N,"j"),n(N,"jobProblems");export function readLensJobs(e){const s={jobs:{},problems:[]};if(e===void 0)return s;if(!l(e))return s.problems.push({problem:"jobs is an object of jobs by name"}),s;for(const[t,o]of Object.entries(e)){if(!E.test(t)){s.problems.push({job:t,problem:"a job's name is letters, digits, dots, dashes and underscores \u2014 63 at most, the first a letter or a digit"});continue}const p=N(o);p.length?s.problems.push(...p.map(u=>({job:t,problem:u}))):s.jobs[t]=o}for(const[t,o]of Object.entries(s.jobs))o.kind!=="playwright"||o.stack===void 0||s.jobs[o.stack]?.kind!=="compose"&&(s.problems.push({job:t,problem:`stack names "${o.stack}", which is no compose job of this file that may run`}),delete s.jobs[t]);return s}i(readLensJobs,"readLensJobs"),r(readLensJobs,"readLensJobs"),n(readLensJobs,"readLensJobs");const O=n(e=>Object.values(e).reduce((s,t)=>s+t,0),"sum");export function jobVmNeedMb(e,s={}){if(e.kind==="compose")return Math.max(e.budget.buildMb??0,O(e.budget.services));if(e.kind==="testcontainers")return e.budget.vmMb;const t=e.budget.vmMb??0,o=e.stack===void 0?void 0:s[e.stack];return o?.kind==="compose"?Math.max(o.budget.buildMb??0,O(o.budget.services)+t):t}i(jobVmNeedMb,"jobVmNeedMb"),r(jobVmNeedMb,"jobVmNeedMb"),n(jobVmNeedMb,"jobVmNeedMb");export function jobHostNeedMb(e,s={}){const t=e.budget.hostMb??0,o=e.kind==="playwright"&&e.stack!==void 0?s[e.stack]:void 0;return t+(o?.kind==="compose"?o.budget.hostMb??0:0)}i(jobHostNeedMb,"jobHostNeedMb"),r(jobHostNeedMb,"jobHostNeedMb"),n(jobHostNeedMb,"jobHostNeedMb");export function jobLane(e){return e.lane?e.lane:e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"heavy":"light"}i(jobLane,"jobLane"),r(jobLane,"jobLane"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}i(unbudgetedServices,"unbudgetedServices"),r(unbudgetedServices,"unbudgetedServices"),n(unbudgetedServices,"unbudgetedServices");export const RUN_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/;export function runShortId(e){const s=e.toLowerCase().replace(/^[a-z]+_/,"").replace(/[^a-z0-9]/g,"").slice(0,8);return s.length===8?s:void 0}i(runShortId,"runShortId"),r(runShortId,"runShortId"),n(runShortId,"runShortId");export const composeProjectOf=n(e=>`lensmcp-${e}`,"composeProjectOf"),DOCKER_RUN_ENV={id:"LENSMCP_RUN_ID",origin:"LENSMCP_RUN_ORIGIN",artifacts:"LENSMCP_RUN_ARTIFACTS",labels:"LENSMCP_RUN_LABELS",override:"LENSMCP_COMPOSE_OVERRIDE",project:"COMPOSE_PROJECT_NAME"};export function dockerRunLabels(e){return{[DOCKER_LABELS.run]:e.id,[DOCKER_LABELS.home]:e.home,[DOCKER_LABELS.job]:e.job}}i(dockerRunLabels,"dockerRunLabels"),r(dockerRunLabels,"dockerRunLabels"),n(dockerRunLabels,"dockerRunLabels");export const runLabelsEnv=n(e=>JSON.stringify(e),"runLabelsEnv");export function jobRunScope(e){return e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"stack":jobVmNeedMb(e)>0?"containers":"none"}i(jobRunScope,"jobRunScope"),r(jobRunScope,"jobRunScope"),n(jobRunScope,"jobRunScope");export const RYUK_DISABLED_ENV="TESTCONTAINERS_RYUK_DISABLED",RYUK_LABEL="org.testcontainers.ryuk";export function ryukWarning(e,s){const t=s[RYUK_DISABLED_ENV];if(!(e.kind!=="testcontainers"||t===void 0||t.trim().toLowerCase()!=="true"))return`${RYUK_DISABLED_ENV}=${t.trim()} is set in the job's environment: testcontainers' own reaper (Ryuk) is off, so a container the suite leaves is removed only where it carries the run's labels \u2014 hand ${DOCKER_RUN_ENV.labels} to every container it starts. One that does not carry them stays in Docker's VM: LensMCP never removes it, and nothing else does.`}i(ryukWarning,"ryukWarning"),r(ryukWarning,"ryukWarning"),n(ryukWarning,"ryukWarning");export const MAX_RUN_ROUTE_SEC=14400,DOCKER_RUN_ENDS=["passed","failed","cancelled","timeout","errored","lost"],dockerRunEnded=n(e=>DOCKER_RUN_ENDS.includes(e),"dockerRunEnded"),MAX_RUN_STRANGERS=20,MAX_RUN_KILLS=100,CONTAINER_OOM="container-oom",DOCKER_ENGINE_LOST="docker-engine-lost",DOCKER_RUN_FIELD="dockerRun";
|
package/lib/docker-report.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}c(dockerRunReportText,"dockerRunReportText"),p(dockerRunReportText,"dockerRunReportText"),
|
|
1
|
+
"use strict";var w=Object.defineProperty;var c=(e,t)=>w(e,"name",{value:t,configurable:!0});var k=Object.defineProperty,p=c((e,t)=>k(e,"name",{value:t,configurable:!0}),"h"),x=Object.defineProperty,u=p((e,t)=>x(e,"name",{value:t,configurable:!0}),"u");import{DOCKER_RUN_ENV as f,dockerRunEnded as j,RYUK_DISABLED_ENV as A}from"./docker-jobs.js";export function runUnlabeledWords(e){if(e.scope!=="containers")return[];const t=[],o=`hand ${f.labels} to each container it starts \u2014 a JSON object of labels: .withLabels(JSON.parse(process.env.${f.labels} ?? '{}'))`,i=e.startedAt!==void 0&&e.watch?.inspected!==void 0&&!e.engineLost&&!(e.services??[]).length;i&&t.push(`LensMCP saw no container with the run's labels while it ran: it watched none and removed none. If the job starts containers, ${o}.`);const a=e.strangers;if(a?.containers.length){const n=a.containers.length+(a.more??0),h=(e.warnings??[]).some(l=>l.startsWith(A));t.push(`${n} container${n===1?"":"s"} without the run's labels came up while it ran and ${n===1?"is":"are"} still there: ${a.containers.join(", ")}${a.more?` and ${a.more} more`:""}. LensMCP cannot tell whether this run started ${n===1?"it":"them"} \u2014 Docker does not say who starts a container \u2014 and ${n===1?"does not remove it":"removes none of them"}: only what carries the run's labels is the run's. `+(h?"testcontainers' own reaper is off, so nothing else removes what a suite left either.":"Where testcontainers' own reaper is on, it removes what a suite left.")+(i?"":` If the job started ${n===1?"it":"them"}, ${o}.`))}return t}c(runUnlabeledWords,"runUnlabeledWords"),p(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const o=j(e.state),i=(e.services??[]).map(l=>{const s=l.budgetMb===void 0?0:l.peakMb-l.budgetMb;return{...l,...s>0?{overMb:s}:{},...l.peakMb>0?{}:{unsampled:!0}}}).sort((l,s)=>(s.overMb??0)-(l.overMb??0)||s.peakMb-l.peakMb||l.name.localeCompare(s.name)),a=i.filter(l=>l.budgetMb!==void 0),n=e.startedAt===void 0?void 0:Math.max(0,(e.endedAt??t)-e.startedAt),h=runUnlabeledWords(e);return{run:{id:e.id,job:e.job,kind:e.kind,state:e.state,ended:o,scope:e.scope??"stack",project:e.project,root:e.root,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.note?{note:e.note}:{},...e.url?{url:e.url}:{},...e.origin?{origin:e.origin}:{},...e.urlNote?{urlNote:e.urlNote}:{},createdAt:e.createdAt,...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...n!==void 0?{ranMs:n}:{},...e.exit?{exit:e.exit}:{}},services:i,totals:{lastMb:i.reduce((l,s)=>l+s.lastMb,0),...a.length?{budgetMb:a.reduce((l,s)=>l+(s.budgetMb??0),0)}:{}},kills:e.kills??[],...e.killsMore?{killsMore:e.killsMore}:{},...e.engineLost?{engineLost:e.engineLost}:{},...e.vm?{vm:e.vm}:{},...e.cleanup?{cleanup:e.cleanup}:{},...e.warnings?.length?{warnings:e.warnings}:{},...h.length?{unlabeled:h}:{},...e.watch?{watch:e.watch}:{},files:{...e.files.samples?{samples:e.files.samples}:{},...e.files.events?{events:e.files.events}:{},log:e.files.log,artifacts:e.files.artifacts}}}c(dockerRunReport,"dockerRunReport"),p(dockerRunReport,"dockerRunReport"),u(dockerRunReport,"dockerRunReport");const d=u(e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),"when"),M=u(e=>{const t=Math.round(e/1e3);if(t<60)return`${t} s`;const o=Math.floor(t/60);return o<60?`${o} min${t%60?` ${t%60} s`:""}`:`${Math.floor(o/60)} h${o%60?` ${o%60} min`:""}`},"lasted"),$=u((e,t,o)=>`${e} ${e===1?t:o}`,"plural");export{d as dockerTime,M as dockerLasted};function g(e){const t=e.exit?e.exit.signal?`its command was ended by ${e.exit.signal}`:`its command exited ${e.exit.code}`:void 0,o=[e.ranMs!==void 0?`${e.ended?"ran":"running for"} ${M(e.ranMs)}`:void 0,e.startedAt!==void 0?`started ${d(e.startedAt)}`:`created ${d(e.createdAt)}`,e.endedAt!==void 0?`ended ${d(e.endedAt)}`:void 0].filter(Boolean).join(", ");return`${{starting:"starting: nothing of the job has run yet",preparing:"preparing: its prepare steps run",running:"running",cleaning:`cleaning up${t?`: ${t}`:""}`,passed:`passed${t?`: ${t}`:""}`,failed:`failed${t?`: ${t}`:""}`,cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:`lost: its runner died, so nobody knows how it would have ended${t?` (${t})`:""}`}[e.state]} \xB7 ${o}`}c(g,"v"),p(g,"w"),u(g,"stateText");function v(e){const t=e[0].map((o,i)=>Math.max(...e.map(a=>(a[i]??"").length)));return e.map(o=>o.map((i,a)=>a===0?i.padEnd(t[a]):a===o.length-1?i:i.padStart(t[a])).join(" ").trimEnd())}c(v,"f"),p(v,"k"),u(v,"table");export function dockerRunReportText(e){const{run:t,vm:o,watch:i,cleanup:a}=e,n=[`Docker run ${t.id} \u2014 job \xAB${t.job}\xBB (${t.kind}), ${t.project?`Compose project ${t.project}`:t.scope==="none"?"nothing in Docker":"no Compose project: its containers by the run's labels"}`,` ${g(t)}`,` in ${t.root}${t.context?` \xB7 Docker context ${t.context}`:""}`];t.stage&&n.push(` stage: ${t.stage}`),t.note&&n.push(` ${t.note}`);for(const s of e.warnings??[])n.push(` ! ${s}`);t.url?n.push(` URL: ${t.url}`):t.urlNote&&n.push(` no URL: ${t.urlNote}`),n.push("");const h=i?.samples?`${$(i.samples,"sample","samples")}${i.sampledAt!==void 0?`, the last at ${d(i.sampledAt)}`:""}`:"no sample was taken";if(n.push(t.scope==="none"?"Memory: the job declares nothing in Docker's VM \u2014 its commands were given no labels, and Docker was not asked about it.":`Memory by service, MiB \u2014 ${h}`),e.services.length){const s=u(r=>r===void 0?"\u2013":String(r),"figure"),b=u(r=>[r.overMb!==void 0?`OVER its budget by ${r.overMb}`:void 0,r.oomKilled?"killed for memory":void 0,r.exitCode!==void 0?`exit ${r.exitCode}`:void 0,r.unsampled?"never sampled":void 0].filter(Boolean).join(" \xB7 "),"remark");n.push(...v([["service","now","peak","budget","limit",""],...e.services.map(r=>[r.name,r.unsampled?"\u2013":String(r.lastMb),r.unsampled?"\u2013":String(r.peakMb),s(r.budgetMb),s(r.limitMb),b(r)]),["all",String(e.totals.lastMb),"",s(e.totals.budgetMb),"",""]]).map(r=>` ${r}`));const m=e.services.filter(r=>r.overMb!==void 0);m.length&&n.push(` ${$(m.length,"service","services")} over what ${m.length===1?"it declares":"they declare"}: raise \`jobs.${t.job}.budget.services\` in lensmcp.json to what ${m.length===1?"it takes":"they take"} \u2014 the queue lets the job in by these figures.`)}else t.scope!=="none"&&n.push(" No container of the run was seen.");n.push("");const l=e.kills.length+(e.killsMore??0);n.push(l?`Killed for memory: ${l}`:"Killed for memory: none");for(const s of e.kills){const b=[s.limitMb!==void 0?`at its ${s.limitMb} MiB limit`:"no limit of its own: the VM ran out, or it was not read",s.peakMb!==void 0?`peak ${s.peakMb} MiB`:"never sampled",s.budgetMb!==void 0?`budget ${s.budgetMb} MiB`:void 0,s.seen==="event"?"seen live":"found by the inspect: the live stream did not tell it"].filter(Boolean).join(" \xB7 ");n.push(` ${d(s.at)} ${s.service}${s.name?` (${s.name})`:""} ${b}`)}if(e.killsMore&&n.push(` \u2026 and ${e.killsMore} more, not listed`),e.engineLost){const s=e.engineLost;n.push(""),n.push(`Docker stopped answering at ${d(s.at)} \u2014 ${s.why}`),s.backAt!==void 0&&n.push(` it answered again at ${d(s.backAt)}`),s.killed?.length&&n.push(` found killed for memory once it was gone: ${s.killed.join(", ")} \u2014 they went with the engine`)}o&&(n.push(""),n.push(`Docker's VM: ${o.totalMb} MiB \xB7 ${o.read==="estimate"?"about ":""}${o.availableAtAdmissionMb} MiB free when the run was let in (${o.read==="estimate"?"an estimate: its own figure could not be read":"the VM's own figure"})`+(o.minAvailableMb!==void 0?` \xB7 lowest ${o.minAvailableMb} MiB while it ran`:" \xB7 not read while it ran")+(o.lastAvailableMb!==void 0?` \xB7 ${o.lastAvailableMb} MiB at the last read${o.sampledAt!==void 0?` (${d(o.sampledAt)})`:""}`:""))),n.push(""),a?a.done?n.push(`Cleanup: by ${a.by==="project"?"the project's own end (LensMCP looked, and found nothing)":a.by} at ${d(a.at)} \u2014 nothing of the run is left`):n.push(`Cleanup: OWED (${a.by}, ${d(a.at)}) \u2014 ${a.why??"something that carries the run's labels is left"}${a.left?.length?` \u2014 left: ${a.left.join(", ")}`:""}`):n.push(t.ended?"Cleanup: not recorded \u2014 its guard, or the sweep, has it":"Cleanup: not yet \u2014 the run has not ended"),a?.unlabeled?.length&&n.push(` in its Compose project without the run's labels, never removed: ${a.unlabeled.join(", ")}`);for(const s of e.unlabeled??[])n.push(` ${s}`);if(i?.notes?.length||i?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),i.streamRestarts&&n.push(` the live stream ended ${$(i.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const s of i.notes??[])n.push(` ${s}`)}return n.push(""),n.push(`Files: ${[e.files.samples?`samples ${e.files.samples}`:void 0,e.files.events?`events ${e.files.events}`:void 0,`log ${e.files.log}`].filter(Boolean).join(" \xB7 ")}`),n.join(`
|
|
2
|
+
`)}c(dockerRunReportText,"dockerRunReportText"),p(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
|
package/lib/docker-runs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`);const
|
|
3
|
-
`)}
|
|
1
|
+
"use strict";var w=Object.defineProperty;var u=(n,e)=>w(n,"name",{value:e,configurable:!0});var A=Object.defineProperty,a=u((n,e)=>A(n,"name",{value:e,configurable:!0}),"u"),M=Object.defineProperty,i=a((n,e)=>M(n,"name",{value:e,configurable:!0}),"l");import{dockerLasted as $,dockerRunReport as x,dockerTime as h}from"./docker-report.js";export function dockerRunStanding(n){return n.run.ended?n.cleanup?.done===!0?"ended":"owed":"up"}u(dockerRunStanding,"dockerRunStanding"),a(dockerRunStanding,"dockerRunStanding"),i(dockerRunStanding,"dockerRunStanding");export function dockerRunsList(n,e={}){const o=e.now??Date.now(),r=n.map(k=>{const c=x(k,o),g=dockerRunStanding(c);return{...c,standing:g,...g==="up"&&e.runnerGone?.(k)?{runnerGone:!0}:{}}}),d=i(k=>r.filter(c=>c.standing===k).sort((c,g)=>(g.run.endedAt??g.run.startedAt??g.run.createdAt)-(c.run.endedAt??c.run.startedAt??c.run.createdAt)||c.run.id.localeCompare(g.run.id)),"of"),t=d("up"),l=d("owed"),s=d("ended"),p=e.all?s.slice(0,e.endedMax??s.length):[];return{counts:{up:t.length,owed:l.length,ended:s.length},all:e.all===!0,...e.all&&p.length<s.length?{endedMore:s.length-p.length}:{},runs:[...t,...l,...p]}}u(dockerRunsList,"dockerRunsList"),a(dockerRunsList,"dockerRunsList"),i(dockerRunsList,"dockerRunsList");const L={starting:"starting",preparing:"preparing",running:"running",cleaning:"cleaning up",passed:"passed",failed:"failed",cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:"lost"};export const dockerStateWord=i(n=>L[n],"dockerStateWord");export function dockerRunSince(n){const{run:e}=n;return e.ended?e.endedAt??e.startedAt??e.createdAt:e.startedAt??e.createdAt}u(dockerRunSince,"dockerRunSince"),a(dockerRunSince,"dockerRunSince"),i(dockerRunSince,"dockerRunSince");export function dockerRunHolds(n){if(n.services.some(e=>!e.unsampled))return n.totals.budgetMb===void 0?`${n.totals.lastMb} MiB`:`${n.totals.lastMb} of ${n.totals.budgetMb} MiB`}u(dockerRunHolds,"dockerRunHolds"),a(dockerRunHolds,"dockerRunHolds"),i(dockerRunHolds,"dockerRunHolds");export const RUNNER_GONE="its runner is gone: nothing runs it any more \u2014 its guard, or the sweep, writes its end and takes its stack down";export function dockerRunRemarks(n){const e=[];n.runnerGone&&!n.run.ended&&e.push(RUNNER_GONE);const o=n.services.filter(l=>l.overMb!==void 0);o.length&&e.push(`OVER its budget: ${o.map(l=>`${l.name} by ${l.overMb} MiB`).join(", ")}`);const r=n.kills.length+(n.killsMore??0),d=[...new Set(n.kills.map(l=>l.service))];r&&e.push(`killed for memory: ${r}${d.length?` (${d.join(", ")})`:""}`),n.engineLost&&e.push(`Docker stopped answering at ${h(n.engineLost.at)}${n.engineLost.backAt!==void 0?`, and answered again at ${h(n.engineLost.backAt)}`:""}`);const{cleanup:t}=n;return n.run.ended&&!t?e.push("cleanup OWED: none is recorded \u2014 its guard, or the sweep, has it"):t&&!t.done&&e.push(`cleanup OWED: ${t.why??"something that carries the run's labels is left"}${t.left?.length?` \u2014 left: ${t.left.join(", ")}`:""}`),t?.unlabeled?.length&&e.push(`in its Compose project without the run's labels, never removed: ${t.unlabeled.join(", ")}`),e}u(dockerRunRemarks,"dockerRunRemarks"),a(dockerRunRemarks,"dockerRunRemarks"),i(dockerRunRemarks,"dockerRunRemarks");function R(n){const{run:e}=n,o=dockerRunSince(n),r=e.ended?`ended ${h(o)}${e.ranMs!==void 0?` after ${$(e.ranMs)}`:""}`:e.startedAt!==void 0?`for ${$(e.ranMs??0)}, since ${h(o)}`:`since ${h(o)}`,d=n.standing==="up"?dockerRunHolds(n):void 0,t=[[e.job,`${dockerStateWord(e.state)}${n.standing==="owed"?", cleanup OWED":n.runnerGone?", its runner GONE":""}`,r,...d?[`holds ${d}`]:[],e.id].join(" ")];e.stage&&!e.ended&&t.push(` stage: ${e.stage}`),e.url?t.push(` URL: ${e.url}`):e.urlNote&&!e.ended&&t.push(` no URL: ${e.urlNote}`),e.note&&t.push(` ${e.note}`);for(const l of dockerRunRemarks(n))t.push(` ${l}`);return t}u(R,"$"),a(R,"R"),i(R,"runLines");const v=i((n,e,o)=>`${n} ${n===1?e:o}`,"plural");export function dockerRunsText(n){const{counts:e}=n;if(!(e.up+e.owed+e.ended))return["This home's registry holds no Docker run.","A job is declared in the checkout's lensmcp.json \u2192 jobs, and started with `lensmcp docker run <job>`."].join(`
|
|
2
|
+
`);const o=e.ended?` \xB7 ${v(e.ended,"ended one is","ended ones are")} kept${n.all?"":" (--all lists them)"}`:"",r=[`Docker runs of this home \u2014 ${e.up} up, ${e.owed?`${v(e.owed,"owes","owe")} a cleanup`:"none owes a cleanup"}${o}`];n.runs.length||r.push(" Nothing of this home is in Docker now.");for(const d of n.runs)r.push(...R(d).map(t=>` ${t}`));return n.endedMore&&r.push(` \u2026 and ${n.endedMore} more ended, not listed`),e.owed&&r.push("","A cleanup that is owed is taken by the run's guard, then by the sweep: `lensmcp docker sweep --dry-run` says what one would take down."),r.join(`
|
|
3
|
+
`)}u(dockerRunsText,"dockerRunsText"),a(dockerRunsText,"dockerRunsText"),i(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const j=8,b=300,m=i(n=>n.length>b?`${n.slice(0,b-1)}\u2026`:n,"cut"),f=i(n=>n?.length?n.slice(0,j).map(e=>e.slice(0,120)):void 0,"names");export function dockerRunBlock(n){const{run:e,cleanup:o,engineLost:r}=n,d=n.services.slice(0,BLOCK_MAX_SERVICES),t=n.kills.slice(0,BLOCK_MAX_KILLS),l=n.kills.length-t.length+(n.killsMore??0),s=f(o?.left),p=f(o?.unlabeled),k=f(r?.killed);return{run:e.id,job:e.job,kind:e.kind,state:e.state,standing:dockerRunStanding(n),...n.runnerGone&&!e.ended?{runnerGone:!0}:{},project:e.project,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.url?{url:e.url}:{},...e.urlNote?{urlNote:m(e.urlNote)}:{},...e.note?{note:m(e.note)}:{},...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...e.ranMs!==void 0?{ranMs:e.ranMs}:{},...e.exit?{exit:e.exit}:{},...n.vm?{vm:n.vm}:{},services:d,...n.services.length>d.length?{servicesMore:n.services.length-d.length}:{},totals:n.totals,kills:t.map(c=>({...c,container:c.container.slice(0,12)})),...l?{killsMore:l}:{},...r?{engineLost:{at:r.at,why:m(r.why),...r.backAt!==void 0?{backAt:r.backAt}:{},...k?{killed:k}:{}}}:{},...o?{cleanup:{by:o.by,at:o.at,done:o.done,...s?{left:s}:{},...p?{unlabeled:p}:{},...o.why?{why:m(o.why)}:{}}}:{}}}u(dockerRunBlock,"dockerRunBlock"),a(dockerRunBlock,"dockerRunBlock"),i(dockerRunBlock,"dockerRunBlock");export function dockerRunBlockLess(n){if(n.services&&n.services.length>1)return{...n,services:n.services.slice(0,-1),servicesMore:(n.servicesMore??0)+1};if(n.kills&&n.kills.length>1)return{...n,kills:n.kills.slice(0,-1),killsMore:(n.killsMore??0)+1}}u(dockerRunBlockLess,"dockerRunBlockLess"),a(dockerRunBlockLess,"dockerRunBlockLess"),i(dockerRunBlockLess,"dockerRunBlockLess");export const PAGE_MAX_ROWS=50;const y=["queued","running"];export function dockerRemoteStanding(n){return n.state==="lost"?"lost":y.includes(n.state)?"up":"ended"}u(dockerRemoteStanding,"dockerRemoteStanding"),a(dockerRemoteStanding,"dockerRemoteStanding"),i(dockerRemoteStanding,"dockerRemoteStanding");export function dockerRemoteRunsList(n,e={}){const o=i(s=>s.completedAt??s.startedAt??s.queuedAt,"since"),r=[...n].sort((s,p)=>o(p)-o(s)||s.run.localeCompare(p.run)),d=r.filter(s=>dockerRemoteStanding(s)==="up"),t=r.filter(s=>dockerRemoteStanding(s)!=="up"),l=t.slice(0,e.endedMax??t.length);return{counts:{up:d.length,lost:t.filter(s=>s.state==="lost").length,ended:t.filter(s=>s.state!=="lost").length},runs:[...d,...l],...l.length<t.length?{endedMore:t.length-l.length}:{}}}u(dockerRemoteRunsList,"dockerRemoteRunsList"),a(dockerRemoteRunsList,"dockerRemoteRunsList"),i(dockerRemoteRunsList,"dockerRemoteRunsList");
|
package/lib/error-cause.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}
|
|
3
|
-
`)}
|
|
4
|
-
`)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}
|
|
5
|
-
`)){const i=/^\s*at\s+(.+)$/.exec(t);if(!i||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(i[1]))continue;const
|
|
6
|
-
`)[0].trim();const
|
|
1
|
+
"use strict";var g=Object.defineProperty;var s=(e,t)=>g(e,"name",{value:t,configurable:!0});var y=Object.defineProperty,c=s((e,t)=>y(e,"name",{value:t,configurable:!0}),"s"),E=Object.defineProperty,a=c((e,t)=>E(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const i=a(n=>n.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(n=>i(n===void 0?"":String(n)))].join(":")}s(joinId,"joinId"),c(joinId,"joinId"),a(joinId,"joinId");export function foldMessage(e){return e?e.split(`
|
|
2
|
+
`)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}s(foldMessage,"foldMessage"),c(foldMessage,"foldMessage"),a(foldMessage,"foldMessage");const x=a(e=>!!e&&typeof e=="object"&&typeof e.message=="string","isValidationIssue"),v=a(e=>Array.isArray(e)&&e.length?e.map(String).join("."):"(root)","issuePath"),p=3;export function readableErrorMessage(e){const t=e?.trim()??"",i=t.indexOf("["),n=t.slice(0,Math.max(i,0));if(i<0||!/^(?:[A-Za-z_$][\w$]*:\s*)?$/.test(n))return e;let d;try{d=JSON.parse(t.slice(i))}catch{return e}if(!Array.isArray(d)||!d.length||!d.every(x))return e;const o=d.map(m=>`${v(m.path)}: ${m.message}`),r=o.length===1?"1 issue":`${o.length} issues`,h=o.length>p?` (+${o.length-p} more)`:"";return[`${n}Validation failed (${r}): ${o.slice(0,p).join("; ")}${h}`,...o.map(m=>` ${m}`)].join(`
|
|
3
|
+
`)}s(readableErrorMessage,"readableErrorMessage"),c(readableErrorMessage,"readableErrorMessage"),a(readableErrorMessage,"readableErrorMessage");const w=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function l(e){const t=w.exec((e??"").split(`
|
|
4
|
+
`)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}s(l,"h"),c(l,"u"),a(l,"named");export function appFrameOf(e){for(const t of(e??"").split(`
|
|
5
|
+
`)){const i=/^\s*at\s+(.+)$/.exec(t);if(!i||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(i[1]))continue;const n=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(i[1].trim());return n?`${n[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${n[2]}`:i[1].trim()}}s(appFrameOf,"appFrameOf"),c(appFrameOf,"appFrameOf"),a(appFrameOf,"appFrameOf");export function errorCause(e){const t=readableErrorMessage(e.message),i=l(e.stack),n=l(t),d=l(e.title),o=e.name?.trim()||i?.name||n?.name||d?.name;if(!o)return;let r=(t!==e.message?t:void 0)??(i&&i.name===o?i.message:void 0)??t??d?.message??e.title??"";const h=l(r);h&&h.name===o&&(r=h.message),r=r.split(`
|
|
6
|
+
`)[0].trim();const m=appFrameOf(e.stack),f=b.has(errorHeadline({name:o,message:r})?.id??"");return{id:joinId("cause",[o,foldMessage(r),f?void 0:m]),errorName:o,message:r,...m?{frame:m}:{}}}s(errorCause,"errorCause"),c(errorCause,"errorCause"),a(errorCause,"errorCause");const b=new Set(["missing-column","missing-table","connection-refused","out-of-memory"]);export function causeIdWithoutFrame(e){return joinId("cause",[e.errorName,foldMessage(e.message),void 0])}s(causeIdWithoutFrame,"causeIdWithoutFrame"),c(causeIdWithoutFrame,"causeIdWithoutFrame"),a(causeIdWithoutFrame,"causeIdWithoutFrame");const u=a(e=>e?` (\xAB${e}\xBB)`:"","q");export const ERROR_HEADLINES=[{id:"missing-column",match:a(e=>/column "?([\w.]+)"?(?: of relation "?[\w.]+"?)? does not exist|Unknown column '([^']+)'|ER_BAD_FIELD_ERROR/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database column${u(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations, or add the migration the entity change needs."}),"say")},{id:"missing-table",match:a(e=>/relation "?([\w.]+)"? does not exist|Table '([^']+)' doesn't exist|ER_NO_SUCH_TABLE/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database table${u(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations against this database."}),"say")},{id:"unique-violation",match:a((e,t)=>/duplicate key value violates unique constraint "?([\w.]+)"?|Duplicate entry '[^']*' for key '([^']+)'|ER_DUP_ENTRY/i.exec(e)||t.code==="23505","match"),say:a(e=>({headline:`A row with the same unique value already exists${u(e===!0?void 0:e[1]??e[2])}`,hint:"The code inserts a duplicate: look up the existing row first, or upsert."}),"say")},{id:"foreign-key-violation",match:a((e,t)=>/violates foreign key constraint "?([\w.]+)"?|a foreign key constraint fails|ER_NO_REFERENCED_ROW|ER_ROW_IS_REFERENCED/i.exec(e)||t.code==="23503","match"),say:a(e=>({headline:`A row points at a row that doesn't exist, or a row still in use was deleted${u(e===!0?void 0:e[1])}`,hint:"Create the referenced row first, or delete the rows that point at it."}),"say")},{id:"connection-refused",match:a((e,t)=>/ECONNREFUSED|connection refused|connect ECONNREFUSED/i.exec(e)||t.code==="ECONNREFUSED","match"),say:a(()=>({headline:"A service the code connects to is not running, or not listening where the code looks",hint:"Start it (database, cache, broker or API), or fix its host and port."}),"say")},{id:"out-of-memory",match:a((e,t)=>/heap out of memory|JavaScript heap|out of memory|ENOMEM|Allocation failed/i.exec(e)||t.code==="ENOMEM","match"),say:a(()=>({headline:"The process ran out of memory",hint:"Something holds or loads too much at once \u2014 look for an unbounded list, cache or query."}),"say")},{id:"jwt-expired",match:a((e,t)=>/jwt expired|token expired/i.exec(e)||t.name==="TokenExpiredError","match"),say:a(()=>({headline:"A sign-in token expired",hint:"Sign in again; if it keeps happening, the client is not refreshing its token."}),"say")},{id:"jwt-invalid",match:a((e,t)=>/jwt malformed|invalid signature|invalid token|jwt must be provided|jwt audience invalid|jwt issuer invalid/i.exec(e)||t.name==="JsonWebTokenError","match"),say:a(()=>({headline:"A sign-in token is not valid here",hint:"Its signature, audience or issuer does not match what this service expects."}),"say")},{id:"timeout",match:a((e,t)=>/ETIMEDOUT|ESOCKETTIMEDOUT|timed? ?out|timeout exceeded|statement timeout|canceling statement due to|Query read timeout/i.exec(e)||t.name==="TimeoutError"||t.code==="ETIMEDOUT","match"),say:a(()=>({headline:"Something took too long and was cut off",hint:"A slow query, a busy dependency or a lock \u2014 open the failing step to see which."}),"say")},{id:"unauthorized",match:a((e,t)=>t.status===401||t.name==="UnauthorizedException"||/^Unauthorized$/i.test(e.trim()),"match"),say:a(()=>({headline:"The request was not signed in (401)",hint:"It came without a valid session or token."}),"say")},{id:"forbidden",match:a((e,t)=>t.status===403||t.name==="ForbiddenException"||/^Forbidden(?: resource)?$/i.test(e.trim()),"match"),say:a(()=>({headline:"The signed-in user is not allowed to do this (403)",hint:"A role or permission check refused it."}),"say")}];export function errorHeadline(e){const t=[e.code,e.message].filter(Boolean).join(" ");for(const i of ERROR_HEADLINES){const n=i.match(t,e);if(n)return{id:i.id,...i.say(n)}}}s(errorHeadline,"errorHeadline"),c(errorHeadline,"errorHeadline"),a(errorHeadline,"errorHeadline");
|
package/lib/error-dismissal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=Object.defineProperty;var s=(e,r)=>E(e,"name",{value:r,configurable:!0});var m=Object.defineProperty,c=s((e,r)=>m(e,"name",{value:r,configurable:!0}),"s"),p=Object.defineProperty,l=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"s");export const ERROR_DISMISSED="error-dismissed",ERROR_RESTORED="error-restored",LENS_EVENT_SOURCE="lens",MAX_DISMISSAL_EVENT_IDS=200;const y=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const b=300,I=new Set(["dashboard","cli","agent"]);export function readErrorDismissal(e){if(e.source!==LENS_EVENT_SOURCE||!e.raw||typeof e.raw!="object")return;const r=e.raw,i=r.groupId;if(typeof i!="string"||i.length===0||i.length>2048)return;if(r.kind===ERROR_RESTORED)return{kind:ERROR_RESTORED,groupId:i};if(r.kind!==ERROR_DISMISSED)return;const n=r.until;if(typeof n!="number"||!Number.isFinite(n))return;const f=Array.isArray(r.eventIds)?r.eventIds.filter(t=>typeof t=="string"&&t.length>0).slice(0,200):[],o=I.has(r.by)?r.by:void 0,a=l((t,S)=>typeof t=="string"&&t.trim()?t.trim().slice(0,S):void 0,"text"),d=a(r.reason,500),u=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,e.timestamp),eventIds:f,...o?{by:o}:{},...d?{reason:d}:{},...u?{title:u}:{}}}s(readErrorDismissal,"readErrorDismissal"),c(readErrorDismissal,"readErrorDismissal"),l(readErrorDismissal,"readErrorDismissal");
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { BaseEvent } from './event.js';
|
|
2
|
+
import { type DismissedBy } from './error-dismissal.js';
|
|
3
|
+
import type { FailureFacts } from './expected-failure.js';
|
|
4
|
+
/**
|
|
5
|
+
* Whether an error is a bug, as the lens can show it from what it recorded (issues/overseer-105).
|
|
6
|
+
*
|
|
7
|
+
* A dismissal and a standing rule are a person's word. This is the lens's: three narrow checks, each over evidence the
|
|
8
|
+
* bus already carries, each naming the event it rests on.
|
|
9
|
+
*
|
|
10
|
+
* - `restart` — every occurrence fell inside a stop/restart window of the service that raised it (the gateway's own
|
|
11
|
+
* lifecycle events). A window opens AT the stop: what a process printed before it died is no part of it.
|
|
12
|
+
* - `test-expected` — the failing request came from a test run the lens can name (a `test-run` event, by its flow
|
|
13
|
+
* scope), and that run passed.
|
|
14
|
+
* - `auth-expired` — a 401/403 whose request the app said carried an expired token or session, and the client
|
|
15
|
+
* recovered: a refresh then the same request answered, or the page went to sign-in.
|
|
16
|
+
*
|
|
17
|
+
* What keeps it from becoming a way to stop seeing failures:
|
|
18
|
+
* - **No guess.** `bug` is the default. A check whose trigger matched but whose evidence the lens cannot read says
|
|
19
|
+
* `unsure`, never `not-a-bug`.
|
|
20
|
+
* - **Every occurrence.** A group is `not-a-bug` only when every occurrence it counted is: a new one outside the
|
|
21
|
+
* evidence turns it back to `bug`, and one it can no longer check makes it `unsure`.
|
|
22
|
+
* - **Never hidden.** A not-a-bug error stays listed and counted; a person's «this is a bug» (`error-verdict-set`, a
|
|
23
|
+
* bus event undone by `error-verdict-cleared`) wins over the lens.
|
|
24
|
+
*/
|
|
25
|
+
export type NotABugKind = 'restart' | 'test-expected' | 'auth-expired';
|
|
26
|
+
export declare const NOT_A_BUG_KINDS: readonly NotABugKind[];
|
|
27
|
+
/** One thing the lens recorded that a verdict rests on — and what to open to see it. */
|
|
28
|
+
export interface VerdictEvidence {
|
|
29
|
+
kind: NotABugKind;
|
|
30
|
+
/** What it was, in a line: `engine — handed over to a new pod (build)`. */
|
|
31
|
+
line: string;
|
|
32
|
+
/** When: the restart's start, the run's end, the recovery. */
|
|
33
|
+
at: number;
|
|
34
|
+
service?: string;
|
|
35
|
+
runId?: string;
|
|
36
|
+
flowId?: string;
|
|
37
|
+
}
|
|
38
|
+
export type ErrorVerdict = {
|
|
39
|
+
verdict: 'bug';
|
|
40
|
+
note?: string;
|
|
41
|
+
overridden?: {
|
|
42
|
+
by?: DismissedBy;
|
|
43
|
+
at: number;
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
verdict: 'not-a-bug';
|
|
47
|
+
kind: NotABugKind;
|
|
48
|
+
line: string;
|
|
49
|
+
evidence: VerdictEvidence[];
|
|
50
|
+
} | {
|
|
51
|
+
verdict: 'unsure';
|
|
52
|
+
kind: NotABugKind;
|
|
53
|
+
missing: string;
|
|
54
|
+
};
|
|
55
|
+
/** One occurrence as the checks read it: when, and what it, its request and its flow said. */
|
|
56
|
+
export type VerdictOccurrence = {
|
|
57
|
+
at: number;
|
|
58
|
+
} & Pick<FailureFacts, 'service' | 'flowId' | 'requestId' | 'status' | 'method' | 'routes' | 'errorName' | 'message'>;
|
|
59
|
+
/** An occurrence's facts (`failureFacts`, enriched with its request's) as the checks read them. */
|
|
60
|
+
export declare function verdictOccurrence(at: number, f: FailureFacts): VerdictOccurrence;
|
|
61
|
+
/** A test or e2e run's state, as the action runner tells the bus: when it starts and when it ends. */
|
|
62
|
+
export declare const TEST_RUN = "test-run";
|
|
63
|
+
/** What a test process is given to stamp its requests' flows with: a flow id that starts with it is the run's. */
|
|
64
|
+
export declare const TEST_FLOW_SCOPE_ENV = "LENSMCP_TEST_FLOW_SCOPE";
|
|
65
|
+
export declare const testFlowScope: (runId: string) => string;
|
|
66
|
+
/** A flow named as a test's (the flow categories' rule): `e2e-…`, `test-…`, `verify-…`, `smoke-…`, `load-…`. */
|
|
67
|
+
export declare const TEST_FLOW_ID: RegExp;
|
|
68
|
+
export interface TestRunRecord {
|
|
69
|
+
runId: string;
|
|
70
|
+
/** `running` · `passed` · `failed` · `errored` · `cancelled` · `timeout`. */
|
|
71
|
+
state: string;
|
|
72
|
+
flowScope: string;
|
|
73
|
+
action?: string;
|
|
74
|
+
project?: string;
|
|
75
|
+
target?: string;
|
|
76
|
+
counts?: {
|
|
77
|
+
passed: number;
|
|
78
|
+
failed: number;
|
|
79
|
+
total: number;
|
|
80
|
+
};
|
|
81
|
+
at: number;
|
|
82
|
+
}
|
|
83
|
+
export declare const ERROR_VERDICT_SET = "error-verdict-set";
|
|
84
|
+
export declare const ERROR_VERDICT_CLEARED = "error-verdict-cleared";
|
|
85
|
+
/** «This is a bug»: a person's word over the lens's, for a group (and the cause it was made from, and its events). */
|
|
86
|
+
export interface VerdictOverride {
|
|
87
|
+
kind: typeof ERROR_VERDICT_SET;
|
|
88
|
+
groupId: string;
|
|
89
|
+
causeId?: string;
|
|
90
|
+
eventIds: string[];
|
|
91
|
+
by?: DismissedBy;
|
|
92
|
+
at: number;
|
|
93
|
+
}
|
|
94
|
+
export interface VerdictOverrideCleared {
|
|
95
|
+
kind: typeof ERROR_VERDICT_CLEARED;
|
|
96
|
+
groupId: string;
|
|
97
|
+
causeId?: string;
|
|
98
|
+
}
|
|
99
|
+
export declare function readTestRun(e: Pick<BaseEvent, 'source' | 'timestamp' | 'raw'>): TestRunRecord | undefined;
|
|
100
|
+
export declare function readVerdictOverride(e: Pick<BaseEvent, 'source' | 'timestamp' | 'raw'>): VerdictOverride | VerdictOverrideCleared | undefined;
|
|
101
|
+
/** How long a client has to refresh and retry, or to go to sign-in, after a 401. */
|
|
102
|
+
export declare const RECOVERY_MS = 60000;
|
|
103
|
+
interface RestartWindow {
|
|
104
|
+
start: number;
|
|
105
|
+
end?: number;
|
|
106
|
+
how: string;
|
|
107
|
+
/** It was crash-looping: no evidence of a restart. */
|
|
108
|
+
looping?: true;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* What the checks read, folded off the bus — restart windows per service, test runs, and per flow the requests and
|
|
112
|
+
* navigations a recovery is read from. Bounded; cheap per event. Both lens processes keep one (the dashboard's error
|
|
113
|
+
* log, the MCP server's runtime reducer), so both say the same.
|
|
114
|
+
*/
|
|
115
|
+
export declare class ErrorVerdictIndex {
|
|
116
|
+
private readonly windows;
|
|
117
|
+
/** Flow scope → its run's newest state. */
|
|
118
|
+
private readonly runs;
|
|
119
|
+
private readonly requests;
|
|
120
|
+
private readonly navigations;
|
|
121
|
+
private readonly tabOfFlow;
|
|
122
|
+
private readonly expired;
|
|
123
|
+
/** Learn from one bus event. True when a restart window or a test run changed — verdicts may read differently now. */
|
|
124
|
+
observe(e: Pick<BaseEvent, 'source' | 'timestamp' | 'severity' | 'context' | 'raw' | 'title' | 'message'>): boolean;
|
|
125
|
+
/** A stop opens a window, a crash loop spoils it, the service back closes it. True when a window changed. */
|
|
126
|
+
private lifecycle;
|
|
127
|
+
private request;
|
|
128
|
+
/** The page a navigation went to: the client runtime's `route` and `ready`, a route's own flow. */
|
|
129
|
+
private navigation;
|
|
130
|
+
/** The stop/restart window of this service the moment falls in — none while it was crash-looping. */
|
|
131
|
+
restartAround(service: string, at: number): (RestartWindow & {
|
|
132
|
+
service: string;
|
|
133
|
+
}) | undefined;
|
|
134
|
+
/** The test run whose flow scope this flow carries: the flow id, or a part of it that ends before a separator. */
|
|
135
|
+
testRunOf(flowId: string): TestRunRecord | undefined;
|
|
136
|
+
/** What said this occurrence's token or session had expired: its own words, or any event of its request. */
|
|
137
|
+
expiredSaid(o: VerdictOccurrence): string | undefined;
|
|
138
|
+
/** How the client recovered from a refused request within a minute: a refresh then the request again, or sign-in. */
|
|
139
|
+
recovery(o: VerdictOccurrence): {
|
|
140
|
+
line: string;
|
|
141
|
+
at: number;
|
|
142
|
+
} | undefined;
|
|
143
|
+
}
|
|
144
|
+
/** One occurrence's verdict: the first check that clears it, else the first that cannot read its evidence, else a bug. */
|
|
145
|
+
export declare function judgeOccurrence(o: VerdictOccurrence, index: ErrorVerdictIndex, now: number): ErrorVerdict;
|
|
146
|
+
/**
|
|
147
|
+
* A group's verdict from its occurrences' — or a cause's from its surfaces' (`of`). `counted`: how many occurrences the
|
|
148
|
+
* group counted, when more than it still holds to check.
|
|
149
|
+
*/
|
|
150
|
+
export declare function combineVerdicts(verdicts: readonly ErrorVerdict[], counted?: number, of?: string): ErrorVerdict;
|
|
151
|
+
/** What «Explain with Claude» answers beside its explanation — shown as Claude's, never applied as a rule. */
|
|
152
|
+
export interface ErrorJudgement {
|
|
153
|
+
verdict: 'bug' | 'not-a-bug' | 'unsure';
|
|
154
|
+
kind?: NotABugKind | 'other';
|
|
155
|
+
why: string;
|
|
156
|
+
}
|
|
157
|
+
/** The answer's key, as the review is asked for it. */
|
|
158
|
+
export declare const ERROR_JUDGEMENT_ASK: string;
|
|
159
|
+
/** Claude's verdict, field by field. A missing or malformed one reads `unsure`: it is never taken for a verdict it did not give. */
|
|
160
|
+
export declare function readErrorJudgement(raw: unknown): ErrorJudgement;
|
|
161
|
+
export {};
|