@lensmcp/protocol-types 1.26.37 → 1.26.38
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 +4 -0
- package/index.js +1 -1
- package/lib/account-drain.js +1 -1
- package/lib/ai-cache-facts.js +1 -1
- package/lib/ai-cache-verdict.js +1 -1
- package/lib/ai-cache.js +3 -3
- 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-compare.js +3 -3
- package/lib/ai-context.js +6 -6
- package/lib/ai-origins.js +9 -9
- package/lib/ai-together.js +5 -5
- package/lib/bounded-clone.js +1 -1
- package/lib/bounded-map.js +1 -1
- package/lib/bounded-writer.js +1 -1
- package/lib/canvas-attachments.js +1 -1
- package/lib/canvas-catalog.d.ts +10 -5
- package/lib/canvas-catalog.js +1 -1
- package/lib/canvas-chat.js +2 -2
- package/lib/canvas-diagram.d.ts +130 -0
- package/lib/canvas-diagram.js +8 -0
- package/lib/canvas-editing.js +4 -4
- package/lib/canvas-frame-policy.js +1 -1
- package/lib/canvas-hub.js +1 -1
- package/lib/canvas.d.ts +9 -5
- package/lib/capture-demand.js +1 -1
- package/lib/dashboard-path.js +1 -1
- package/lib/delivery-actions.d.ts +25 -2
- package/lib/delivery-actions.js +1 -1
- package/lib/delivery-status.d.ts +8 -1
- package/lib/docker-errors.js +1 -1
- 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.js +3 -3
- package/lib/event-loop.js +1 -1
- package/lib/expected-failure.js +2 -2
- package/lib/finding-proof.js +1 -1
- package/lib/flood-guard.js +1 -1
- package/lib/goal-design.js +1 -1
- package/lib/goal-main-follow.d.ts +103 -0
- package/lib/goal-main-follow.js +1 -0
- package/lib/goal-number.js +1 -1
- package/lib/goal-process.d.ts +8 -0
- package/lib/goal-review.d.ts +126 -0
- package/lib/goal-review.js +6 -0
- package/lib/host-agents.js +1 -1
- package/lib/lens-hosts.js +1 -1
- package/lib/lint-coverage.js +1 -1
- package/lib/lint-ignores.js +2 -2
- 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 +30 -30
- 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/pull-requests.d.ts +33 -2
- package/lib/remote-instances.js +1 -1
- package/lib/source.d.ts +414 -0
- package/lib/source.js +1 -0
- package/lib/sources.js +1 -1
- package/lib/static-checks.js +1 -1
- package/lib/system-report.js +1 -1
- package/lib/team-decide.js +1 -1
- package/lib/team.d.ts +9 -2
- package/lib/team.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DashPrMerger } from './goal-main-follow.js';
|
|
1
2
|
import type { DashDeliveryCommit } from './delivery-status.js';
|
|
2
3
|
/**
|
|
3
4
|
* Delivery ships work from the page (issues/closed/foodguard-334). The owner, 2026-11-25: «… to have options to merge and
|
|
@@ -115,8 +116,11 @@ export interface DashDeliveryActionRun {
|
|
|
115
116
|
stage: string;
|
|
116
117
|
startedAt: number;
|
|
117
118
|
endedAt?: number;
|
|
118
|
-
/**
|
|
119
|
-
|
|
119
|
+
/**
|
|
120
|
+
* The person's click, the steward's own act (with the person's standing permission), or LensMCP's auto-merge of a
|
|
121
|
+
* goal's pull request that is ready, green and holds origin's main (issues/closed/hub-19).
|
|
122
|
+
*/
|
|
123
|
+
by: 'person' | 'steward' | 'lensmcp';
|
|
120
124
|
/** What happened, line by line. */
|
|
121
125
|
did: string[];
|
|
122
126
|
error?: string;
|
|
@@ -181,6 +185,18 @@ export interface DashStewardSettings {
|
|
|
181
185
|
tidy: 'on' | 'off';
|
|
182
186
|
/** «The steward may land, push and merge»: steps that change main or origin run without a click. Off by default. */
|
|
183
187
|
landPushMerge: 'on' | 'off';
|
|
188
|
+
/**
|
|
189
|
+
* «Label linked pull requests by itself» (issues/closed/hub-13): an open pull request proven to carry a goal (its
|
|
190
|
+
* branch, or the goal's verified commit) that lacks the goal's label is labelled as «Tag» does. On by default.
|
|
191
|
+
*/
|
|
192
|
+
autoLabel: 'on' | 'off';
|
|
193
|
+
/**
|
|
194
|
+
* «Auto-merge» (issues/closed/hub-19): LensMCP merges a goal's pull request by itself once it is ready, green
|
|
195
|
+
* and holds origin's main. Unset: flow.json `delivery.autoMerge`, on by default while pull requests are.
|
|
196
|
+
*/
|
|
197
|
+
autoMerge?: 'on' | 'off';
|
|
198
|
+
/** «PR merger»: after a goal completes, its open pull request is a merge task of the repository's one PR merger. Unset: on. */
|
|
199
|
+
prMerger?: 'on' | 'off';
|
|
184
200
|
updatedAt?: number;
|
|
185
201
|
}
|
|
186
202
|
export declare const STEWARD_DEFAULTS: DashStewardSettings;
|
|
@@ -226,6 +242,13 @@ export interface DashStewardView {
|
|
|
226
242
|
/** This dashboard runs the background look (the main checkout's). */
|
|
227
243
|
looks: boolean;
|
|
228
244
|
nextLookAt?: number;
|
|
245
|
+
/** «Auto-merge» as it stands now (issues/closed/hub-19): on or off, and why — the switch, flow.json, or pull requests off. */
|
|
246
|
+
autoMerge?: {
|
|
247
|
+
on: boolean;
|
|
248
|
+
why: string;
|
|
249
|
+
};
|
|
250
|
+
/** The repository's PR merger: its switch, the agent running, its queue (hub-19). */
|
|
251
|
+
merger?: DashPrMerger;
|
|
229
252
|
}
|
|
230
253
|
/** `POST /api/team/delivery/steward/settings`: one switch, the person's. */
|
|
231
254
|
export interface DashStewardSettingRequest {
|
package/lib/delivery-actions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const DELIVERY_ACTION_KINDS=["land","pr","merge-pr","push","pull","cleanup","park","fetch"],STEWARD_DEFAULTS={look:"off",tidy:"off",landPushMerge:"off"};
|
|
1
|
+
"use strict";export const DELIVERY_ACTION_KINDS=["land","pr","merge-pr","push","pull","cleanup","park","fetch"],STEWARD_DEFAULTS={look:"off",tidy:"off",landPushMerge:"off",autoLabel:"on"};
|
package/lib/delivery-status.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DashDeliveryActionKind } from './delivery-actions.js';
|
|
2
2
|
import type { DashPrProblemKind } from './pull-requests.js';
|
|
3
|
+
import type { DashGoalReviewBrief } from './goal-review.js';
|
|
3
4
|
/**
|
|
4
5
|
* Delivery › Status (issues/closed/foodguard-312): the repository's whole delivery at a glance. The owner, 2026-11-25:
|
|
5
6
|
* «along with prs page we need understand how we can display the full status of the system, how much prs, what is need
|
|
@@ -10,7 +11,7 @@ import type { DashPrProblemKind } from './pull-requests.js';
|
|
|
10
11
|
*/
|
|
11
12
|
/** One line of «What needs you»: how many, what, and what to do. */
|
|
12
13
|
export interface DashDeliveryNeed {
|
|
13
|
-
key: 'main-behind' | 'main-diverged' | 'main-ahead' | 'main-ci' | 'prs-blocked' | 'prs-ready' | 'retarget' | 'goals-asking' | 'goals-ready' | 'goals-landed' | 'uncommitted' | 'goals-working' | 'goal-prs-closed' | 'goal-prs-failed' | 'goals-left';
|
|
14
|
+
key: 'main-behind' | 'main-diverged' | 'main-ahead' | 'main-ci' | 'prs-blocked' | 'prs-ready' | 'retarget' | 'goals-asking' | 'goals-ready' | 'goals-landed' | 'uncommitted' | 'goals-working' | 'goal-prs-closed' | 'goal-prs-failed' | 'goals-left' | 'goal-prs-parked';
|
|
14
15
|
tone: 'bad' | 'warn' | 'info';
|
|
15
16
|
count: number;
|
|
16
17
|
text: string;
|
|
@@ -169,6 +170,10 @@ export interface DashDeliveryWorktree {
|
|
|
169
170
|
};
|
|
170
171
|
}
|
|
171
172
|
export interface DashDeliveryStatus {
|
|
173
|
+
/**
|
|
174
|
+
* When git was read for it (main, origin's main, the goal refs) — at most every 20 s, and an answer never waits for
|
|
175
|
+
* the next read (issues/closed/hub-13): `prs.at` says when GitHub was.
|
|
176
|
+
*/
|
|
172
177
|
at: number;
|
|
173
178
|
/** «What needs you», most urgent first — none: nothing does. */
|
|
174
179
|
needs: DashDeliveryNeed[];
|
|
@@ -252,6 +257,8 @@ export interface DashGoalLanding {
|
|
|
252
257
|
steps: DashLandingStep[];
|
|
253
258
|
/** What the goal-end sweep did with what it left behind (issues/closed/foodguard-321) — none: not swept here. */
|
|
254
259
|
cleanup?: DashGoalCleanup;
|
|
260
|
+
/** Its review canvas and the person's word on it (issues/closed/hub-18) — none: no review canvas yet. */
|
|
261
|
+
review?: DashGoalReviewBrief;
|
|
255
262
|
}
|
|
256
263
|
/**
|
|
257
264
|
* A finished goal's cleanup as the goal-end sweep recorded it (storage goal-cleanup.ts), for Delivery's rows and drawer
|
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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty;var i=(e,s)=>R(e,"name",{value:s,configurable:!0});var w=Object.defineProperty,n=i((e,s)=>w(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"),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 M=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","onLinkLoss","nx","budget"],$={compose:[...M,"compose"],testcontainers:M,playwright:[...M,"stack"]},L={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},_=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,N=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,k=1024*1024,f=360,b=100,x=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<=k,"isMb"),I=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<=f))return`onLinkLoss is "cancel" or { "continueMinutes": 1 to ${f} }`}i(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??f))}i(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,"y"),n(v,"inTree");function y(e){return Array.isArray(e)&&e.length>=1&&e.length<=b&&e.every(s=>typeof s=="string"&&s.length<=x)&&e[0]!==""}i(y,"k"),n(y,"isArgv");function m(e,s,t,o){const c=Object.keys(e).filter(a=>!s.includes(a));c.length&&o.push(`${t?`${t} has`:"has"} ${c.length===1?"an unknown key":"unknown keys"} ${I(c)}`)}i(m,"m"),n(m,"unknownKeys");function S(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>b||!e.every(v))&&t.push(`${s} is a list of paths inside the checkout`)}i(S,"$"),n(S,"paths");function j(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>b||!e.every(v))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const c=o.split("/");c.some(a=>a===""||a===".")?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 /`):c.some(a=>a.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}i(j,"N"),n(j,"inputPaths");function A(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,$[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<=b&&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"),S(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=f)&&t.push(`timeoutMinutes is execution minutes, up to ${f}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false");const o=e.onLinkLoss,c=o===void 0?void 0:linkLossProblem(o);c?t.push(c):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 a=e.inputs;if(a!==void 0)if(!l(a))t.push("inputs is an object of files, minted and secrets");else{m(a,["files","minted","secrets"],"inputs",t);const r=j(a.files,"inputs.files",t),d=j(a.minted,"inputs.minted",t);for(const h of r)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 u=[...new Set(r.filter(h=>d.includes(h)))];u.length&&t.push(`inputs names ${u.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 g=a.secrets;g!==void 0&&!(Array.isArray(g)&&g.length<=b&&g.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 p=e.budget;if(!l(p))t.push("has no budget: the memory it declares is what it is admitted by");else{m(p,L[s],"budget",t);for(const r of["buildMb","hostMb","vmMb"])L[s].includes(r)&&p[r]!==void 0&&!E(p[r])&&t.push(`budget.${r} is MiB, a whole number from 1 to ${k}`);if(s==="testcontainers"&&(p.vmMb===void 0||p.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&p.vmMb===void 0&&p.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const r=p.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[d,u]of Object.entries(r))N.test(d)?E(u)||t.push(`budget.services.${d} is MiB, a whole number from 1 to ${k}`):t.push(`budget.services has "${d}", 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{m(r,["files","edge"],"compose",t);const d=r.files;(!Array.isArray(d)||!d.length||d.length>b||!d.every(v))&&t.push("compose.files is the compose files, as paths inside the checkout");const u=r.edge;u!==void 0&&(!l(u)||typeof u.service!="string"||!N.test(u.service)||!Number.isInteger(u.port)||u.port<1||u.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(m(u,["service","port"],"compose.edge",t),l(p)&&l(p.services)&&!Object.hasOwn(p.services,u.service)&&t.push(`${u.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}i(A,"j"),n(A,"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 c=A(o);c.length?s.problems.push(...c.map(a=>({job:t,problem:a}))):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"),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"),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"),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"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}i(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"),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"),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"),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"),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
|
-
`)}
|
|
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}.`))}else e.strangersNote&&t.push(`LensMCP cannot say which containers without the run's labels came up while it ran: ${e.strangersNote}.`);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 o=e.ended?` \xB7 ${v(e.ended,"ended one is","ended ones are")} kept${
|
|
3
|
-
`)}u(dockerRunsText,"dockerRunsText"),i(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const
|
|
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):""}s(foldMessage,"foldMessage"),
|
|
3
|
-
`)}s(readableErrorMessage,"readableErrorMessage"),
|
|
4
|
-
`)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}s(h,"u"),
|
|
5
|
-
`)){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");
|
package/lib/error-verdict.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)[0].slice(0,120)),this.expired.size>
|
|
3
|
-
`)[0].slice(0,120):e.requestId?this.expired.get(e.requestId):void 0}recovery(e){if(!e.flowId)return;const s=c(d=>d>=e.at&&d<=e.at+RECOVERY_MS,"within"),
|
|
1
|
+
"use strict";var j=Object.defineProperty;var f=(t,e)=>j(t,"name",{value:e,configurable:!0});var N=Object.defineProperty,w=f((t,e)=>N(t,"name",{value:e,configurable:!0}),"p"),V=Object.defineProperty,c=w((t,e)=>V(t,"name",{value:e,configurable:!0}),"a");import{LENS_EVENT_SOURCE as O}from"./error-dismissal.js";export const NOT_A_BUG_KINDS=["restart","test-expected","auth-expired"];export function verdictOccurrence(t,e){return{at:t,...e.service?{service:e.service}:{},...e.flowId?{flowId:e.flowId}:{},...e.requestId?{requestId:e.requestId}:{},...e.status!==void 0?{status:e.status}:{},...e.method?{method:e.method}:{},...e.routes?{routes:e.routes}:{},...e.errorName?{errorName:e.errorName}:{},...e.message?{message:e.message}:{}}}f(verdictOccurrence,"verdictOccurrence"),w(verdictOccurrence,"verdictOccurrence"),c(verdictOccurrence,"verdictOccurrence");export const TEST_RUN="test-run",TEST_FLOW_SCOPE_ENV="LENSMCP_TEST_FLOW_SCOPE",testFlowScope=c(t=>`e2e-${t}`,"testFlowScope"),TEST_FLOW_ID=/^(verify|e2e|test|smoke|load)[-_:]/i,ERROR_VERDICT_SET="error-verdict-set",ERROR_VERDICT_CLEARED="error-verdict-cleared";const g=c(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"isObj"),a=c((t,e=300)=>typeof t=="string"&&t.trim()?t.trim().slice(0,e):void 0,"str"),$=c(t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,"num"),F=200,A=new Set(["dashboard","cli","agent"]);export function readTestRun(t){if(t.source!==O||!g(t.raw)||t.raw.kind!==TEST_RUN)return;const e=t.raw,s=a(e.runId,120),i=a(e.state,20),n=a(e.flowScope,200);if(!s||!i||!n)return;const r=g(e.counts)?e.counts:void 0,o=$(r?.passed),u=$(r?.failed),l=$(r?.total);return{runId:s,state:i,flowScope:n,...a(e.action,40)?{action:a(e.action,40)}:{},...a(e.project,200)?{project:a(e.project,200)}:{},...a(e.target,200)?{target:a(e.target,200)}:{},...o!==void 0&&u!==void 0&&l!==void 0?{counts:{passed:o,failed:u,total:l}}:{},at:t.timestamp}}f(readTestRun,"readTestRun"),w(readTestRun,"readTestRun"),c(readTestRun,"readTestRun");export function readVerdictOverride(t){if(t.source!==O||!g(t.raw))return;const e=t.raw,s=a(e.groupId,2048);if(!s)return;const i=a(e.causeId,2048);if(e.kind===ERROR_VERDICT_CLEARED)return{kind:ERROR_VERDICT_CLEARED,groupId:s,...i?{causeId:i}:{}};if(e.kind!==ERROR_VERDICT_SET||e.verdict!=="bug")return;const n=Array.isArray(e.eventIds)?e.eventIds.filter(r=>typeof r=="string"&&r.length>0).slice(0,F):[];return{kind:ERROR_VERDICT_SET,groupId:s,...i?{causeId:i}:{},eventIds:n,...A.has(e.by)?{by:e.by}:{},at:t.timestamp}}f(readVerdictOverride,"readVerdictOverride"),w(readVerdictOverride,"readVerdictOverride"),c(readVerdictOverride,"readVerdictOverride");const E=2*6e4,M=1e4;export const RECOVERY_MS=6e4;const S=50,C=200,z=200,k=2e3,y=40,B=5e3,_={"service-restart":c(t=>`restarted${a(t.reason,80)?` (${a(t.reason,80)})`:""}`,"service-restart"),"pod-handoff-start":c(t=>`handed over to a new pod${a(t.reason,80)?` (${a(t.reason,80)})`:""}`,"pod-handoff-start"),"pod-recycle":c(t=>`its pod was recycled${a(t.reason,80)?` (${a(t.reason,80)})`:""}`,"pod-recycle"),"service-recycle":c(()=>"recycled after it stopped answering","service-recycle"),"idle-kill":c(()=>"stopped while idle","idle-kill"),"service-down":c(()=>"went down","service-down"),"service-respawn":c(()=>"started again by self-heal","service-respawn"),"service-starting":c(()=>"was starting","service-starting"),"worker-stopped":c(t=>`${b(t)} stopped`,"worker-stopped"),"worker-crashed":c(t=>`${b(t)} crashed and was started again`,"worker-crashed")};function b(t){const e=a(t.worker,80);return e?`its worker ${e}`:"its worker"}f(b,"y"),w(b,"x"),c(b,"workerOf");const D=new Set(["service-up","pod-handoff-complete","pod-handoff-failed","worker-started","worker-up"]),R=/\b(?:TokenExpired(?:Error)?|JWTExpired|jwt expired|(?:token|session|jwt|credentials?) (?:has |is |was )?expired|expired (?:token|session|jwt|credentials?)|"exp" claim)/i,L=/(?:^|[/._-])(?:refresh|renew|re-?auth|silent|token)(?:[/._-]|$)/i,U=/(?:^|\/)(?:log-?in|sign-?in)(?:\/|$)/i,J=/[-_:/.]/,P=new Set(["failed","errored","cancelled","timeout"]),W=new Set(["server-request","gateway-request","fetch-done","fetch"]),I=c(t=>{const e=t.split(/[?#]/)[0]??t,s=/^[a-z][a-z0-9+.-]*:\/\/[^/]+(\/.*)?$/i.exec(e);return s?s[1]??"/":e},"pathOf"),G=c(t=>t!==void 0&&t>=200&&t<300,"ok"),T=c(t=>new Date(t).toISOString().slice(11,19),"clock");function x(t,e,s,i,n){const r=t.get(e);if(r){r.push(s),r.length>i&&r.splice(0,r.length-i);return}t.set(e,[s]),t.size>n&&t.delete(t.keys().next().value)}f(x,"$"),w(x,"E"),c(x,"push");export class ErrorVerdictIndex{static{f(this,"ErrorVerdictIndex")}static{w(this,"ErrorVerdictIndex")}static{c(this,"ErrorVerdictIndex")}constructor(){this.windows=new Map,this.runs=new Map,this.requests=new Map,this.navigations=new Map,this.tabOfFlow=new Map,this.expired=new Map}observe(e){const s=g(e.raw)?e.raw:{},i=e.context??{},n=a(s.kind,60);if(e.source==="gateway"&&n&&this.lifecycle(n,s,e.timestamp))return!0;const r=readTestRun(e);if(r)return P.has(this.runs.get(r.flowScope)?.state??"")?!1:(this.runs.delete(r.flowScope),this.runs.set(r.flowScope,r),this.runs.size>z&&this.runs.delete(this.runs.keys().next().value),!0);const o=a(i.flowId,400),u=a(i.tabId,200),l=a(i.requestId,400);o&&u&&!this.tabOfFlow.has(o)&&(this.tabOfFlow.set(o,u),this.tabOfFlow.size>k&&this.tabOfFlow.delete(this.tabOfFlow.keys().next().value)),o&&n&&W.has(n)&&this.request(o,s,e.timestamp);const d=this.navigation(n,s,i);if(d&&(o&&x(this.navigations,`flow:${o}`,{at:e.timestamp,path:d},y,k),u&&x(this.navigations,`tab:${u}`,{at:e.timestamp,path:d},y,k)),l&&(e.severity==="warning"||e.severity==="error"||e.severity==="fatal")&&!this.expired.has(l)){const v=[(g(s.request)?s.request:{}).error,g(s.span)?s.span.error:void 0,s.error].filter(g),h=[e.title,e.message,...v.flatMap(p=>[p.name,p.message])].map(p=>a(p,600)).find(p=>p!==void 0&&R.test(p));h&&(this.expired.set(l,h.split(`
|
|
2
|
+
`)[0].slice(0,120)),this.expired.size>B&&this.expired.delete(this.expired.keys().next().value))}return!1}lifecycle(e,s,i){const n=a(s.project,200);if(!n)return!1;const r=this.windows.get(n)??[],o=r.find(l=>l.end===void 0&&i-l.start<=E),u=e==="service-crash-loop"||e==="worker-crashed"&&s.crashLooping===!0;if((e==="service-restart"?s.phase==="started":_[e])||u){const l=o??{start:i,how:(_[e]??(()=>"crash-looping"))(s)};u&&(l.looping=!0),o||r.push(l)}else if(D.has(e)||e==="service-restart"){if(!o)return!1;o.end=i}else return!1;return r.length>S&&r.splice(0,r.length-S),this.windows.delete(n),this.windows.set(n,r),this.windows.size>C&&this.windows.delete(this.windows.keys().next().value),!0}request(e,s,i){const n=g(s.request)?s.request:s,r=[a(n.route,400),a(n.url,2e3)?I(a(n.url,2e3)):void 0].filter(l=>!!l),o=a(n.method,10)?.toUpperCase(),u=$(n.status);x(this.requests,e,{at:i,...o?{method:o}:{},paths:r,...u!==void 0?{status:u}:{}},y,k)}navigation(e,s,i){if((e==="route"||e==="ready")&&a(s.url,2e3))return I(a(s.url,2e3));const n=a(i.originType,40);if(n!=="route-load"&&n!=="page-load")return;const r=a(i.originNodeId,400);return r?.startsWith("route:")?r.slice(6):a(i.route,400)??(a(i.url,2e3)?I(a(i.url,2e3)):void 0)}restartAround(e,s){const i=this.windows.get(e)?.find(n=>!n.looping&&s>=n.start&&s<=(n.end??n.start+E)+M);return i&&{...i,service:e}}testRunOf(e){if(this.runs.size)for(let s=e.length;s>0;s--){if(s<e.length&&!J.test(e[s]))continue;const i=this.runs.get(e.slice(0,s));if(i)return i}}expiredSaid(e){const s=[e.errorName,e.message].map(i=>a(i,600)).find(i=>i!==void 0&&R.test(i));return s?s.split(`
|
|
3
|
+
`)[0].slice(0,120):e.requestId?this.expired.get(e.requestId):void 0}recovery(e){if(!e.flowId)return;const s=c(d=>d>=e.at&&d<=e.at+RECOVERY_MS,"within"),i=new Set(e.routes??[]),n=(this.requests.get(e.flowId)??[]).filter(d=>s(d.at)&&G(d.status)),r=n.find(d=>d.paths.some(v=>L.test(v))&&!d.paths.some(v=>i.has(v))),o=r&&n.find(d=>d.at>=r.at&&d!==r&&(!e.method||!d.method||d.method===e.method)&&d.paths.some(v=>i.has(v)));if(r&&o)return{line:`refreshed (${r.method??""} ${r.paths[0]} \u2192 ${r.status}) and retried (${o.paths[0]} \u2192 ${o.status})`.replace("( ","("),at:o.at};const u=this.tabOfFlow.get(e.flowId),l=[...this.navigations.get(`flow:${e.flowId}`)??[],...u?this.navigations.get(`tab:${u}`)??[]:[]].find(d=>s(d.at)&&U.test(d.path));return l?{line:`went to sign-in (${l.path})`,at:l.at}:void 0}}const q={verdict:"bug"};export function judgeOccurrence(t,e,s){let i,n;if(t.service){const r=e.restartAround(t.service,t.at);if(r){const o=`${r.service} ${r.how} at ${T(r.start)}${r.end!==void 0?`, back at ${T(r.end)}`:""} UTC`;return{verdict:"not-a-bug",kind:"restart",line:o,evidence:[{kind:"restart",line:o,at:r.start,service:r.service}]}}}if(t.flowId){const r=e.testRunOf(t.flowId);if(r?.state==="passed"){const o=r.project?` (${r.project}${r.target?`:${r.target}`:""})`:"",u=`test run ${r.runId}${o} passed${r.counts?` \u2014 ${r.counts.passed} of ${r.counts.total} tests`:""}: the failure was part of the test`;return{verdict:"not-a-bug",kind:"test-expected",line:u,evidence:[{kind:"test-expected",line:u,at:r.at,runId:r.runId,flowId:t.flowId}]}}r?.state==="running"||r?.state==="queued"?i??={verdict:"unsure",kind:"test-expected",missing:`its test run ${r.runId} has not ended`}:r?n??=`its test run ${r.runId} ${r.state} \u2014 a failing run is no evidence it was expected`:TEST_FLOW_ID.test(t.flowId)&&(i??={verdict:"unsure",kind:"test-expected",missing:`flow ${t.flowId} is a test's, but no test run the lens holds names it`})}if(t.status===401||t.status===403)if(!t.flowId)i??={verdict:"unsure",kind:"auth-expired",missing:"not part of a flow: whether the client recovered cannot be followed"};else{const r=e.expiredSaid(t),o=e.recovery(t);if(r&&o){const u=`${t.status}: the app said \xAB${r}\xBB, and the client ${o.line}`;return{verdict:"not-a-bug",kind:"auth-expired",line:u,evidence:[{kind:"auth-expired",line:u,at:o.at,flowId:t.flowId}]}}o?i??={verdict:"unsure",kind:"auth-expired",missing:`the client ${o.line}, but nothing it recorded says the token had expired \u2014 a valid token refused reads the same`}:s-t.at<RECOVERY_MS?i??={verdict:"unsure",kind:"auth-expired",missing:"waiting up to a minute for the client to refresh and retry, or go to sign-in"}:r&&(n??=`its token had expired (\xAB${r}\xBB) and the client did not recover within a minute \u2014 no refresh and retry, no sign-in`)}return i??(n?{verdict:"bug",note:n}:q)}f(judgeOccurrence,"judgeOccurrence"),w(judgeOccurrence,"judgeOccurrence"),c(judgeOccurrence,"judgeOccurrence");const K={restart:"fell inside a restart","test-expected":"came from a passing test run","auth-expired":"were an expired session the client recovered from"},Y=5;export function combineVerdicts(t,e=t.length,s="occurrences"){if(!t.length)return q;const i=t.filter(h=>h.verdict==="not-a-bug"),n=t.filter(h=>h.verdict==="bug"),r=new Map;for(const h of i)r.set(h.kind,(r.get(h.kind)??0)+1);const o=[...r].sort((h,p)=>p[1]-h[1])[0]?.[0];if(n.length){const h=n.find(m=>m.overridden)?.overridden,p=o?`${i.length} of ${t.length} ${s} ${K[o]}; ${n.length} did not`:n.find(m=>m.note)?.note;return{verdict:"bug",...p?{note:p}:{},...h?{overridden:h}:{}}}const u=t.find(h=>h.verdict==="unsure");if(u)return u;const l=e-t.length;if(l>0)return{verdict:"unsure",kind:o,missing:`${l} older occurrence${l===1?" is":"s are"} no longer held to check`};const d=[];for(const h of i)for(const p of h.evidence)d.length<Y&&!d.some(m=>m.line===p.line)&&d.push(p);const v=i.find(h=>h.kind===o);return{verdict:"not-a-bug",kind:o,line:`${v.line}${d.length>1?` (and ${d.length-1} more)`:""}`,evidence:d}}f(combineVerdicts,"combineVerdicts"),w(combineVerdicts,"combineVerdicts"),c(combineVerdicts,"combineVerdicts");export const ERROR_JUDGEMENT_ASK=`"isBug": { "verdict": "bug" | "not-a-bug" | "unsure", "kind": ${NOT_A_BUG_KINDS.map(t=>`"${t}"`).join(" | ")} | "other" (only for not-a-bug), "why": "one line, citing the evidence" } \u2014 not-a-bug only when the evidence shows it is no defect: a service stopping or restarting, a test that expected it, a session that expired and the client recovered; unsure when the evidence cannot tell`;export function readErrorJudgement(t){if(!g(t))return{verdict:"unsure",why:"the review gave no verdict"};const e=a(t.why,400),s=t.verdict;if(s!=="bug"&&s!=="not-a-bug"&&s!=="unsure")return{verdict:"unsure",why:"the review's verdict was not one of bug, not-a-bug, unsure"};if(!e)return{verdict:"unsure",why:`the review said ${s} without saying why`};if(s!=="not-a-bug")return{verdict:s,why:e};const i=NOT_A_BUG_KINDS.includes(t.kind)?t.kind:"other";return{verdict:s,kind:i,why:e}}f(readErrorJudgement,"readErrorJudgement"),w(readErrorJudgement,"readErrorJudgement"),c(readErrorJudgement,"readErrorJudgement");
|
package/lib/event-loop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});var w=Object.defineProperty,a=s((e,t)=>w(e,"name",{value:t,configurable:!0}),"r"),h=Object.defineProperty,l=a((e,t)=>h(e,"name",{value:t,configurable:!0}),"r");export const LENS_CAUSES={"lensmcp-gc":"forced GC","lensmcp-cleanup":"cleanup","lensmcp-write":"writing events","lensmcp-capture":"capturing values"};export function lensOwnWork(e){const t=typeof e.cause=="string"&&e.cause.startsWith("lensmcp-");if(!t&&!(typeof e.lensMs=="number"&&e.durationMs>0&&e.lensMs>=e.durationMs/2))return;const o=t?LENS_CAUSES[e.cause]:void 0;return o?`LensMCP's own work \u2014 ${o}`:"LensMCP's own work"}s(lensOwnWork,"lensOwnWork"),a(lensOwnWork,"lensOwnWork"),l(lensOwnWork,"lensOwnWork");export function waitedBehind(e){const t=new Set,o=new Set;for(const n of e.evidence)n.relation==="executing"||(n.requestId?n.requestId===e.requestId:!n.flowId||n.flowId===e.flowId)||(t.add(n.requestId??n.flowId),n.flowId&&n.flowId!==e.flowId&&o.add(n.flowId));return{requests:t.size,flows:o.size,atLeast:e.evidenceTruncated}}s(waitedBehind,"waitedBehind"),a(waitedBehind,"waitedBehind"),l(waitedBehind,"waitedBehind");export function waitedLine(e){const t=waitedBehind(e);return t.requests?`${t.atLeast?"at least ":""}${t.requests} request${t.requests===1?"":"s"} waited behind it`:void 0}s(waitedLine,"waitedLine"),a(waitedLine,"waitedLine"),l(waitedLine,"waitedLine");export function flowStalls(e,t){const o={ran:[],overlapped:[]};for(const n of e){if(lensOwnWork(n))continue;if(n.flowId===t){o.ran.push(n);continue}const u=n.endAt??n.observedAt,d=n.evidence.filter(r=>r.flowId===t).map(r=>[Math.max(r.startAt,n.startAt),Math.min(r.endAt,u)]).filter(([r,i])=>i>=r).sort((r,i)=>r[0]-i[0]);if(!d.length)continue;let p=0,c=-1/0;for(const[r,i]of d)i>c&&(p+=i-Math.max(r,c)),c=Math.max(c,i);o.overlapped.push({incident:n,overlapMs:Math.round(p*100)/100})}return o}s(flowStalls,"flowStalls"),a(flowStalls,"flowStalls"),l(flowStalls,"flowStalls");export function overlapLine(e){if(!e.length)return;const t=[...new Set(e.map(u=>u.incident.loop.project))],o=t.length<=2?t.join(" and "):`${t.length} services`,n=e.length;return{count:n,services:t,longestMs:Math.max(...e.map(u=>u.overlapMs)),text:`${n} pause${n===1?"":"s"} in ${o} while this flow was open \u2014 not this flow\u2019s code`}}s(overlapLine,"overlapLine"),a(overlapLine,"overlapLine"),l(overlapLine,"overlapLine");export const LOOP_STARTUP_MS=6e4;export function loopStartedAt(e){if(!e.startsWith("node:"))return;const t=Number(e.slice(e.lastIndexOf(":")+1));return Number.isFinite(t)&&t>0?t:void 0}s(loopStartedAt,"loopStartedAt"),a(loopStartedAt,"loopStartedAt"),l(loopStartedAt,"loopStartedAt");export function loopPhaseAt(e,t){const o=loopStartedAt(e);if(o===void 0)return;const n=Math.max(0,Math.round(t-o));return{phase:n<LOOP_STARTUP_MS?"startup":"running",sinceStartMs:n}}s(loopPhaseAt,"loopPhaseAt"),a(loopPhaseAt,"loopPhaseAt"),l(loopPhaseAt,"loopPhaseAt");
|