@lensmcp/protocol-types 1.26.7 → 1.26.9

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.
Files changed (50) hide show
  1. package/index.d.ts +3 -0
  2. package/index.js +1 -1
  3. package/lib/ai-call-groups.js +2 -2
  4. package/lib/ai-call-row.js +3 -3
  5. package/lib/ai-call.js +9 -9
  6. package/lib/ai-context.js +6 -6
  7. package/lib/ai-origins.js +6 -6
  8. package/lib/backlog.d.ts +83 -0
  9. package/lib/backlog.js +1 -0
  10. package/lib/bounded-clone.js +1 -1
  11. package/lib/bounded-map.js +1 -1
  12. package/lib/bounded-writer.js +1 -1
  13. package/lib/capture-demand.js +1 -1
  14. package/lib/dashboard-path.js +1 -1
  15. package/lib/dashboard.d.ts +15 -0
  16. package/lib/docker-errors.js +1 -1
  17. package/lib/docker-jobs.d.ts +22 -0
  18. package/lib/docker-jobs.js +1 -1
  19. package/lib/docker-report.js +2 -2
  20. package/lib/docker-runs.js +3 -3
  21. package/lib/error-cause.js +6 -6
  22. package/lib/error-dismissal.js +1 -1
  23. package/lib/error-verdict.d.ts +161 -0
  24. package/lib/error-verdict.js +3 -0
  25. package/lib/event-loop.js +1 -1
  26. package/lib/expected-failure.js +2 -2
  27. package/lib/flood-guard.js +1 -1
  28. package/lib/follow-ups.d.ts +4 -0
  29. package/lib/goal-design.js +1 -1
  30. package/lib/host-agents.js +1 -1
  31. package/lib/hosts.d.ts +2 -0
  32. package/lib/lint-coverage.js +1 -1
  33. package/lib/log-query.js +1 -1
  34. package/lib/metrics-reset.js +1 -1
  35. package/lib/overseer-findings.js +1 -1
  36. package/lib/peers.d.ts +14 -1
  37. package/lib/peers.js +1 -1
  38. package/lib/perf-rules.js +1 -1
  39. package/lib/pod-memory.js +1 -1
  40. package/lib/producer-health.js +1 -1
  41. package/lib/remote-instances.d.ts +6 -0
  42. package/lib/remote-instances.js +1 -1
  43. package/lib/sessions.d.ts +233 -0
  44. package/lib/sessions.js +1 -0
  45. package/lib/sources.js +1 -1
  46. package/lib/static-checks.js +1 -1
  47. package/lib/system-report.js +1 -1
  48. package/lib/team.js +1 -1
  49. package/lib/workspace-actions.d.ts +10 -0
  50. package/package.json +1 -1
@@ -0,0 +1,83 @@
1
+ export type BacklogKind = 'bug' | 'feature' | 'task';
2
+ export type BacklogState = 'open' | 'goal' | 'done' | 'dropped';
3
+ export type BacklogPriority = 'high' | 'medium' | 'low';
4
+ export type BacklogRefKind = 'file' | 'route' | 'flow' | 'error' | 'suggestion' | 'goal' | 'url';
5
+ export declare const BACKLOG_KINDS: readonly BacklogKind[];
6
+ export declare const BACKLOG_PRIORITIES: readonly BacklogPriority[];
7
+ export declare const BACKLOG_TITLE_MAX = 200;
8
+ export declare const BACKLOG_BODY_MAX = 8000;
9
+ export declare const BACKLOG_REFS_MAX = 20;
10
+ export interface BacklogRef {
11
+ kind: BacklogRefKind;
12
+ value: string;
13
+ }
14
+ export interface BacklogAuthor {
15
+ who: 'person' | 'agent';
16
+ client?: 'claude' | 'codex';
17
+ /** The agent's session id or name, as it gave it. */
18
+ session?: string;
19
+ role?: string;
20
+ goalId?: string;
21
+ }
22
+ /** How the item went into a goal: a new goal of its own, combined with others, or a task under a running goal. */
23
+ export interface BacklogGoalLink {
24
+ id: string;
25
+ title: string;
26
+ how: 'new' | 'combined' | 'task';
27
+ taskId?: string;
28
+ at: number;
29
+ }
30
+ export interface DashBacklogItem {
31
+ /** `bl-` and 10 hex. */
32
+ id: string;
33
+ kind: BacklogKind;
34
+ title: string;
35
+ body?: string;
36
+ priority?: BacklogPriority;
37
+ refs?: BacklogRef[];
38
+ state: BacklogState;
39
+ by: BacklogAuthor;
40
+ createdAt: number;
41
+ updatedAt: number;
42
+ /** Times the same open title was added again: counted, never a second item. */
43
+ seen?: number;
44
+ goal?: BacklogGoalLink;
45
+ /** Why it was dropped or marked done. */
46
+ closedWhy?: string;
47
+ }
48
+ export interface DashBacklogAnswer {
49
+ items: DashBacklogItem[];
50
+ counts: Record<BacklogState, number>;
51
+ /** Making goals needs the team on; adding and editing do not. */
52
+ teamOn: boolean;
53
+ }
54
+ export interface DashBacklogAddRequest {
55
+ kind: BacklogKind;
56
+ title: string;
57
+ body?: string;
58
+ priority?: BacklogPriority;
59
+ refs?: BacklogRef[];
60
+ requestId: string;
61
+ }
62
+ export interface DashBacklogUpdateRequest {
63
+ id: string;
64
+ kind?: BacklogKind;
65
+ title?: string;
66
+ body?: string;
67
+ priority?: BacklogPriority | null;
68
+ refs?: BacklogRef[];
69
+ /** The person's only: `dropped` or `done` closes it, `open` reopens it. */
70
+ state?: 'open' | 'done' | 'dropped';
71
+ why?: string;
72
+ }
73
+ /** One item → a new goal that waits in `design`. */
74
+ export interface DashBacklogGoalRequest {
75
+ id: string;
76
+ requestId: string;
77
+ }
78
+ /** One item → a task under a running goal. */
79
+ export interface DashBacklogTaskRequest {
80
+ id: string;
81
+ goalId: string;
82
+ requestId: string;
83
+ }
package/lib/backlog.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";export const BACKLOG_KINDS=["bug","feature","task"],BACKLOG_PRIORITIES=["high","medium","low"],BACKLOG_TITLE_MAX=200,BACKLOG_BODY_MAX=8e3,BACKLOG_REFS_MAX=20;
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var c=(t,e)=>_(t,"name",{value:e,configurable:!0});var A=Object.defineProperty,l=c((t,e)=>A(t,"name",{value:e,configurable:!0}),"c"),B=Object.defineProperty,y=l((t,e)=>B(t,"name",{value:e,configurable:!0}),"c"),E=Object.defineProperty,g=y((t,e)=>E(t,"name",{value:e,configurable:!0}),"i"),N=Object.defineProperty,m=g((t,e)=>N(t,"name",{value:e,configurable:!0}),"_");export const DEFAULT_RAW_BYTE_LIMIT=32768,DEFAULT_MAX_STRING_BYTES=4096,DEFAULT_MAX_ARRAY_ITEMS=64,DEFAULT_MAX_DEPTH=12,CHEAP_ENTRY_BYTES=512,NOMINAL_DEEP_BYTES=32,DEEP_REPORT_DEPTH=64,SKELETON_STRING_BYTES=256,MAX_RECORDED_PATHS=20,TRUNCATION_MARKER_KEY="__lensmcpTruncation",TRUNCATED_VALUE_KEY="__lensmcpTruncated";export function estimateJsonBytes(t,e=Number.POSITIVE_INFINITY,n=12){return d(t,e,n,32)}c(estimateJsonBytes,"estimateJsonBytes"),l(estimateJsonBytes,"estimateJsonBytes"),y(estimateJsonBytes,"estimateJsonBytes"),g(estimateJsonBytes,"estimateJsonBytes"),m(estimateJsonBytes,"estimateJsonBytes");export function exceedsJsonByteBudget(t,e,n=12){return d(t,e,n,Number.POSITIVE_INFINITY)>e}c(exceedsJsonByteBudget,"exceedsJsonByteBudget"),l(exceedsJsonByteBudget,"exceedsJsonByteBudget"),y(exceedsJsonByteBudget,"exceedsJsonByteBudget"),g(exceedsJsonByteBudget,"exceedsJsonByteBudget"),m(exceedsJsonByteBudget,"exceedsJsonByteBudget");function d(t,e,n,a){switch(typeof t){case"undefined":case"function":case"symbol":return 0;case"boolean":return 5;case"number":return Number.isFinite(t)?8:4;case"bigint":return 20;case"string":return t.length+2;default:break}if(t===null)return 4;if(n<=0)return a;if(t instanceof Date)return 26;if(Array.isArray(t)){let r=2;for(let u=0;u<t.length;u++)if(r+=d(t[u],e-r,n-1,a)+1,r>e)return r;return r}let s=2;const o=t;for(const r in o){if(!Object.prototype.hasOwnProperty.call(o,r))continue;const u=d(o[r],e-s,n-1,a);if(u!==0&&(s+=r.length+4+u,s>e))return s}return s}c(d,"f"),l(d,"g"),y(d,"y"),g(d,"T"),m(d,"walk");function f(t,e){t.truncatedAnything=!0,t.paths.length<20&&t.paths.push(e||"<root>")}c(f,"p"),l(f,"f"),y(f,"g"),g(f,"A"),m(f,"record");function b(t,e,n){return f(t,n),{[TRUNCATED_VALUE_KEY]:!0,originalBytes:estimateJsonBytes(e,Number.POSITIVE_INFINITY,64)}}c(b,"I"),l(b,"p"),y(b,"f"),g(b,"I"),m(b,"stub");function I(t){if(t===null)return!0;const e=typeof t;return e==="number"||e==="boolean"||e==="string"||e==="bigint"}c(I,"b"),l(I,"m"),y(I,"p"),g(I,"y"),m(I,"isScalar");export function clampValue(t,e,n,a){if(typeof t=="string"){const s=e.budget<=0?256:e.maxStringBytes;if(t.length+2<=s)return e.budget-=t.length+2,t;const o=Math.max(0,s-64);return f(e,a),e.budget-=o,`${t.slice(0,o)}\u2026[lensmcp truncated: ${t.length-o} more chars]`}return t===null||typeof t!="object"?(e.budget-=d(t,Number.POSITIVE_INFINITY,1,32),t):n<=0?b(e,t,a):t instanceof Date?(e.budget-=26,t):Array.isArray(t)?T(t,e,n,a):h(t,e,n,a)}c(clampValue,"clampValue"),l(clampValue,"clampValue"),y(clampValue,"clampValue"),g(clampValue,"clampValue"),m(clampValue,"clampValue");function T(t,e,n,a){const s=[],o=Math.min(t.length,e.maxArrayItems);for(let r=0;r<o&&!(e.budget<=0);r++)s.push(clampValue(t[r],e,n-1,`${a}[${r}]`));return s.length<t.length&&f(e,`${a}[] (+${t.length-s.length} items dropped)`),s}c(T,"d"),l(T,"b"),y(T,"m"),g(T,"f"),m(T,"clampArray");function h(t,e,n,a){const s={};let o;const r=e.budget<=0;for(const u in t){if(!Object.prototype.hasOwnProperty.call(t,u))continue;const i=t[u],p=d(i,512,n-1,Number.POSITIVE_INFINITY);if(p<=512&&(!r||I(i))){s[u]=i,e.budget-=u.length+4+p;continue}(o??=[]).push({key:u,bytes:p})}if(!o)return s;o.sort((u,i)=>u.bytes===i.bytes?0:u.bytes<i.bytes?-1:1);for(const{key:u}of o){const i=a?`${a}.${u}`:u;s[u]=clampValue(t[u],e,n-1,i)}return s}c(h,"T"),l(h,"d"),y(h,"b"),g(h,"m"),m(h,"clampObject");export function boundedClone(t,e={}){const n=e.rawByteLimit??32768,a=e.maxDepth??12;if(n<=0)return{value:void 0,truncated:!1,originalBytes:0,keptBytes:0,paths:[]};if(t==null)return{value:t,truncated:!1,originalBytes:0,keptBytes:0,paths:[]};if(!exceedsJsonByteBudget(t,n,a)){const i=estimateJsonBytes(t,n,a),p={budget:n,maxStringBytes:e.maxStringBytes??4096,maxArrayItems:e.maxArrayItems??64,paths:[],truncatedAnything:!1};return{value:clampValue(t,p,a,""),truncated:!1,originalBytes:i,keptBytes:i,paths:[]}}const s=estimateJsonBytes(t,Number.POSITIVE_INFINITY,64),o={budget:n,maxStringBytes:e.maxStringBytes??4096,maxArrayItems:e.maxArrayItems??64,paths:[],truncatedAnything:!1},r=clampValue(t,o,a,""),u=estimateJsonBytes(r,Number.POSITIVE_INFINITY,a);if(o.truncatedAnything&&r!==null&&typeof r=="object"&&!Array.isArray(r)){const i={truncated:!0,originalBytes:s,keptBytes:u,paths:o.paths};r[TRUNCATION_MARKER_KEY]=i}return{value:r,truncated:o.truncatedAnything,originalBytes:s,keptBytes:u,paths:o.paths}}c(boundedClone,"boundedClone"),l(boundedClone,"boundedClone"),y(boundedClone,"boundedClone"),g(boundedClone,"boundedClone"),m(boundedClone,"boundedClone");
1
+ "use strict";var T=Object.defineProperty;var i=(e,t)=>T(e,"name",{value:t,configurable:!0});var h=Object.defineProperty,l=i((e,t)=>h(e,"name",{value:t,configurable:!0}),"_");export const DEFAULT_RAW_BYTE_LIMIT=32768,DEFAULT_MAX_STRING_BYTES=4096,DEFAULT_MAX_ARRAY_ITEMS=64,DEFAULT_MAX_DEPTH=12,CHEAP_ENTRY_BYTES=512,NOMINAL_DEEP_BYTES=32,DEEP_REPORT_DEPTH=64,SKELETON_STRING_BYTES=256,MAX_RECORDED_PATHS=20,TRUNCATION_MARKER_KEY="__lensmcpTruncation",TRUNCATED_VALUE_KEY="__lensmcpTruncated";export function estimateJsonBytes(e,t=Number.POSITIVE_INFINITY,r=12){return y(e,t,r,32)}i(estimateJsonBytes,"estimateJsonBytes"),l(estimateJsonBytes,"estimateJsonBytes");export function exceedsJsonByteBudget(e,t,r=12){return y(e,t,r,Number.POSITIVE_INFINITY)>t}i(exceedsJsonByteBudget,"exceedsJsonByteBudget"),l(exceedsJsonByteBudget,"exceedsJsonByteBudget");function y(e,t,r,a){switch(typeof e){case"undefined":case"function":case"symbol":return 0;case"boolean":return 5;case"number":return Number.isFinite(e)?8:4;case"bigint":return 20;case"string":return e.length+2;default:break}if(e===null)return 4;if(r<=0)return a;if(e instanceof Date)return 26;if(Array.isArray(e)){let n=2;for(let s=0;s<e.length;s++)if(n+=y(e[s],t-n,r-1,a)+1,n>t)return n;return n}let u=2;const o=e;for(const n in o){if(!Object.prototype.hasOwnProperty.call(o,n))continue;const s=y(o[n],t-u,r-1,a);if(s!==0&&(u+=n.length+4+s,u>t))return u}return u}i(y,"T"),l(y,"walk");function g(e,t){e.truncatedAnything=!0,e.paths.length<20&&e.paths.push(t||"<root>")}i(g,"A"),l(g,"record");function f(e,t,r){return g(e,r),{[TRUNCATED_VALUE_KEY]:!0,originalBytes:estimateJsonBytes(t,Number.POSITIVE_INFINITY,64)}}i(f,"I"),l(f,"stub");function p(e){if(e===null)return!0;const t=typeof e;return t==="number"||t==="boolean"||t==="string"||t==="bigint"}i(p,"y"),l(p,"isScalar");export function clampValue(e,t,r,a){if(typeof e=="string"){const u=t.budget<=0?256:t.maxStringBytes;if(e.length+2<=u)return t.budget-=e.length+2,e;const o=Math.max(0,u-64);return g(t,a),t.budget-=o,`${e.slice(0,o)}\u2026[lensmcp truncated: ${e.length-o} more chars]`}return e===null||typeof e!="object"?(t.budget-=y(e,Number.POSITIVE_INFINITY,1,32),e):r<=0?f(t,e,a):e instanceof Date?(t.budget-=26,e):Array.isArray(e)?m(e,t,r,a):b(e,t,r,a)}i(clampValue,"clampValue"),l(clampValue,"clampValue");function m(e,t,r,a){const u=[],o=Math.min(e.length,t.maxArrayItems);for(let n=0;n<o&&!(t.budget<=0);n++)u.push(clampValue(e[n],t,r-1,`${a}[${n}]`));return u.length<e.length&&g(t,`${a}[] (+${e.length-u.length} items dropped)`),u}i(m,"f"),l(m,"clampArray");function b(e,t,r,a){const u={};let o;const n=t.budget<=0;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const c=e[s],I=y(c,512,r-1,Number.POSITIVE_INFINITY);if(I<=512&&(!n||p(c))){u[s]=c,t.budget-=s.length+4+I;continue}(o??=[]).push({key:s,bytes:I})}if(!o)return u;o.sort((s,c)=>s.bytes===c.bytes?0:s.bytes<c.bytes?-1:1);for(const{key:s}of o){const c=a?`${a}.${s}`:s;u[s]=clampValue(e[s],t,r-1,c)}return u}i(b,"m"),l(b,"clampObject");export function boundedClone(e,t={}){const r=t.rawByteLimit??32768,a=t.maxDepth??12;if(r<=0)return{value:void 0,truncated:!1,originalBytes:0,keptBytes:0,paths:[]};if(e==null)return{value:e,truncated:!1,originalBytes:0,keptBytes:0,paths:[]};if(!exceedsJsonByteBudget(e,r,a)){const c=estimateJsonBytes(e,r,a),I={budget:r,maxStringBytes:t.maxStringBytes??4096,maxArrayItems:t.maxArrayItems??64,paths:[],truncatedAnything:!1};return{value:clampValue(e,I,a,""),truncated:!1,originalBytes:c,keptBytes:c,paths:[]}}const u=estimateJsonBytes(e,Number.POSITIVE_INFINITY,64),o={budget:r,maxStringBytes:t.maxStringBytes??4096,maxArrayItems:t.maxArrayItems??64,paths:[],truncatedAnything:!1},n=clampValue(e,o,a,""),s=estimateJsonBytes(n,Number.POSITIVE_INFINITY,a);if(o.truncatedAnything&&n!==null&&typeof n=="object"&&!Array.isArray(n)){const c={truncated:!0,originalBytes:u,keptBytes:s,paths:o.paths};n[TRUNCATION_MARKER_KEY]=c}return{value:n,truncated:o.truncatedAnything,originalBytes:u,keptBytes:s,paths:o.paths}}i(boundedClone,"boundedClone"),l(boundedClone,"boundedClone");
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var t=(e,a)=>u(e,"name",{value:a,configurable:!0});var f=Object.defineProperty,c=t((e,a)=>f(e,"name",{value:a,configurable:!0}),"a"),l=Object.defineProperty,o=c((e,a)=>l(e,"name",{value:a,configurable:!0}),"t"),b=Object.defineProperty,p=o((e,a)=>b(e,"name",{value:a,configurable:!0}),"t"),s=Object.defineProperty,v=p((e,a)=>s(e,"name",{value:a,configurable:!0}),"o");export function capMap(e,a){if(e.size<=a)return 0;let r=0;const i=e.keys();for(;e.size>a;){const n=i.next();if(n.done)break;e.delete(n.value)&&(r+=1)}return r}t(capMap,"capMap"),c(capMap,"capMap"),o(capMap,"capMap"),p(capMap,"capMap"),v(capMap,"capMap");export const MAX_PRODUCER_KEYS=256;
1
+ "use strict";var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});var i=Object.defineProperty,s=t((e,r)=>i(e,"name",{value:r,configurable:!0}),"o");export function capMap(e,r){if(e.size<=r)return 0;let n=0;const o=e.keys();for(;e.size>r;){const a=o.next();if(a.done)break;e.delete(a.value)&&(n+=1)}return n}t(capMap,"capMap"),s(capMap,"capMap");export const MAX_PRODUCER_KEYS=256;
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var r=(e,t)=>f(e,"name",{value:t,configurable:!0});var M=Object.defineProperty,o=r((e,t)=>M(e,"name",{value:t,configurable:!0}),"r"),x=Object.defineProperty,i=o((e,t)=>x(e,"name",{value:t,configurable:!0}),"r"),F=Object.defineProperty,s=i((e,t)=>F(e,"name",{value:t,configurable:!0}),"r"),E=Object.defineProperty,c=s((e,t)=>E(e,"name",{value:t,configurable:!0}),"c");import{renameSync as m,statSync as p,unlinkSync as h}from"node:fs";export function eventMaxBytes(e=process.env){const t=Number(e.LENSMCP_EVENT_MAX_BYTES);return Number.isFinite(t)&&t>0?t:50*1024*1024}r(eventMaxBytes,"eventMaxBytes"),o(eventMaxBytes,"eventMaxBytes"),i(eventMaxBytes,"eventMaxBytes"),s(eventMaxBytes,"eventMaxBytes"),c(eventMaxBytes,"eventMaxBytes");export function eventMaxFiles(e=process.env){const t=Number(e.LENSMCP_EVENT_MAX_FILES);return Number.isFinite(t)&&t>=1&&t<=20?Math.floor(t):5}r(eventMaxFiles,"eventMaxFiles"),o(eventMaxFiles,"eventMaxFiles"),i(eventMaxFiles,"eventMaxFiles"),s(eventMaxFiles,"eventMaxFiles"),c(eventMaxFiles,"eventMaxFiles");const R=1024*1024,a=new Map;export function maybeRotateEventFile(e,t,v){const l=(a.get(e)??0)+t,u=v?.maxBytes??eventMaxBytes(),y=v?.maxFiles??eventMaxFiles(),b=Math.min(R,u);if(l<b){a.set(e,l);return}try{const n=p(e).size;if(a.set(e,0),n<=u)return}catch{a.set(e,l);return}try{h(`${e}.${y}`)}catch{}for(let n=y-1;n>=1;n--)try{m(`${e}.${n}`,`${e}.${n+1}`)}catch{}try{m(e,`${e}.1`)}catch{}}r(maybeRotateEventFile,"maybeRotateEventFile"),o(maybeRotateEventFile,"maybeRotateEventFile"),i(maybeRotateEventFile,"maybeRotateEventFile"),s(maybeRotateEventFile,"maybeRotateEventFile"),c(maybeRotateEventFile,"maybeRotateEventFile");export function resetRotationThrottle(e){e===void 0?a.clear():a.delete(e)}r(resetRotationThrottle,"resetRotationThrottle"),o(resetRotationThrottle,"resetRotationThrottle"),i(resetRotationThrottle,"resetRotationThrottle"),s(resetRotationThrottle,"resetRotationThrottle"),c(resetRotationThrottle,"resetRotationThrottle");
1
+ "use strict";var y=Object.defineProperty;var r=(e,t)=>y(e,"name",{value:t,configurable:!0});var v=Object.defineProperty,o=r((e,t)=>v(e,"name",{value:t,configurable:!0}),"c");import{renameSync as l,statSync as f,unlinkSync as x}from"node:fs";export function eventMaxBytes(e=process.env){const t=Number(e.LENSMCP_EVENT_MAX_BYTES);return Number.isFinite(t)&&t>0?t:50*1024*1024}r(eventMaxBytes,"eventMaxBytes"),o(eventMaxBytes,"eventMaxBytes");export function eventMaxFiles(e=process.env){const t=Number(e.LENSMCP_EVENT_MAX_FILES);return Number.isFinite(t)&&t>=1&&t<=20?Math.floor(t):5}r(eventMaxFiles,"eventMaxFiles"),o(eventMaxFiles,"eventMaxFiles");const E=1024*1024,a=new Map;export function maybeRotateEventFile(e,t,i){const s=(a.get(e)??0)+t,c=i?.maxBytes??eventMaxBytes(),u=i?.maxFiles??eventMaxFiles(),m=Math.min(E,c);if(s<m){a.set(e,s);return}try{const n=f(e).size;if(a.set(e,0),n<=c)return}catch{a.set(e,s);return}try{x(`${e}.${u}`)}catch{}for(let n=u-1;n>=1;n--)try{l(`${e}.${n}`,`${e}.${n+1}`)}catch{}try{l(e,`${e}.1`)}catch{}}r(maybeRotateEventFile,"maybeRotateEventFile"),o(maybeRotateEventFile,"maybeRotateEventFile");export function resetRotationThrottle(e){e===void 0?a.clear():a.delete(e)}r(resetRotationThrottle,"resetRotationThrottle"),o(resetRotationThrottle,"resetRotationThrottle");
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var a=(r,e)=>u(r,"name",{value:e,configurable:!0});var i=Object.defineProperty,c=a((r,e)=>i(r,"name",{value:e,configurable:!0}),"a"),E=Object.defineProperty,p=c((r,e)=>E(r,"name",{value:e,configurable:!0}),"a"),l=Object.defineProperty,s=p((r,e)=>l(r,"name",{value:e,configurable:!0}),"o"),P=Object.defineProperty,f=s((r,e)=>P(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"),p(appMatchesPage,"appMatchesPage"),s(appMatchesPage,"appMatchesPage"),f(appMatchesPage,"appMatchesPage");export const CAPTURE_RULES_FILENAME="capture-rules.json";
1
+ "use strict";var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});var s=Object.defineProperty,u=o((t,e)=>s(t,"name",{value:e,configurable:!0}),"s");export const CAPTURE_REQUEST_FILENAME="capture-request.json",CAPTURE_PRESENCE_FILENAME="capture-runner.json";export function appMatchesPage(t,e){const r=t.trim().toLowerCase();if(!r)return!1;if(e.project&&e.project.toLowerCase()===r)return!0;const n=e.url.toLowerCase();if(n===r||n.replace(/\/+$/,"")===r.replace(/\/+$/,""))return!0;try{const a=new URL(e.url);return/^\d+$/.test(r)?a.port===r:a.origin.toLowerCase()===r.replace(/\/+$/,"")}catch{return!1}}o(appMatchesPage,"appMatchesPage"),u(appMatchesPage,"appMatchesPage");export const CAPTURE_RULES_FILENAME="capture-rules.json";
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var t=(e,n)=>g(e,"name",{value:n,configurable:!0});var m=Object.defineProperty,c=t((e,n)=>m(e,"name",{value:n,configurable:!0}),"t"),l=Object.defineProperty,o=c((e,n)=>l(e,"name",{value:n,configurable:!0}),"t"),p=Object.defineProperty,r=o((e,n)=>p(e,"name",{value:n,configurable:!0}),"c"),u=Object.defineProperty,d=r((e,n)=>u(e,"name",{value:n,configurable:!0}),"t");const i={"~":"~~","/":"~s","\\":"~b","\0":"~0"},b={"~":"~",s:"/",b:"\\",0:"\0",d:"."},f=/%2f|%5c|%2e|%00/i;export function encodeSegment(e){return e==="."||e===".."?e.replace(/\./g,"~d"):encodeURIComponent(e.replace(/[~/\\\0]/g,n=>i[n])).replace(/%3A/g,":").replace(/%40/g,"@")}t(encodeSegment,"encodeSegment"),c(encodeSegment,"encodeSegment"),o(encodeSegment,"encodeSegment"),r(encodeSegment,"encodeSegment"),d(encodeSegment,"encodeSegment");export function decodeSegment(e){let n;try{n=decodeURIComponent(e)}catch{n=e}return f.test(e)?n:n.replace(/~([~sb0d])/g,(S,a)=>b[a])}t(decodeSegment,"decodeSegment"),c(decodeSegment,"decodeSegment"),o(decodeSegment,"decodeSegment"),r(decodeSegment,"decodeSegment"),d(decodeSegment,"decodeSegment");
1
+ "use strict";var o=Object.defineProperty;var c=(e,t)=>o(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,n=c((e,t)=>d(e,"name",{value:t,configurable:!0}),"t");const a={"~":"~~","/":"~s","\\":"~b","\0":"~0"},p={"~":"~",s:"/",b:"\\",0:"\0",d:"."},g=/%2f|%5c|%2e|%00/i;export function encodeSegment(e){return e==="."||e===".."?e.replace(/\./g,"~d"):encodeURIComponent(e.replace(/[~/\\\0]/g,t=>a[t])).replace(/%3A/g,":").replace(/%40/g,"@")}c(encodeSegment,"encodeSegment"),n(encodeSegment,"encodeSegment");export function decodeSegment(e){let t;try{t=decodeURIComponent(e)}catch{t=e}return g.test(e)?t:t.replace(/~([~sb0d])/g,(l,r)=>p[r])}c(decodeSegment,"decodeSegment"),n(decodeSegment,"decodeSegment");
@@ -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 {
@@ -1 +1 @@
1
- "use strict";var I=Object.defineProperty;var m=(e,r)=>I(e,"name",{value:r,configurable:!0});var N=Object.defineProperty,k=m((e,r)=>N(e,"name",{value:r,configurable:!0}),"m"),_=Object.defineProperty,b=k((e,r)=>_(e,"name",{value:r,configurable:!0}),"m"),L=Object.defineProperty,v=b((e,r)=>L(e,"name",{value:r,configurable:!0}),"m"),C=Object.defineProperty,d=v((e,r)=>C(e,"name",{value:r,configurable:!0}),"c");import{CONTAINER_OOM as f,DOCKER_ENGINE_LOST as D,DOCKER_RUN_FIELD as S}from"./docker-jobs.js";import{joinId as R}from"./error-cause.js";const V=200,j=50,p=d(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),u=d(e=>{if(typeof e!="string")return;const r=e.trim();return r?r.slice(0,V):void 0},"name"),E=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,"someMb"),T=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,"anyMb"),g=d(e=>Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0)),"defined"),O=d(e=>{if(!p(e))return;const r=u(e.peer);if(!r)return;const n=u(e.name);return n?{peer:r,name:n}:{peer:r}},"hostOf"),x=d(e=>e.name??e.peer,"hostWord");export function readDockerError(e){if(p(e)){if(e.kind===f)return g({kind:f,run:u(e.run),job:u(e.job),service:u(e.service),container:u(e.container),seen:e.seen==="event"||e.seen==="inspect"?e.seen:void 0,limitMb:E(e.limitMb),peakMb:E(e.peakMb),budgetMb:E(e.budgetMb),context:u(e.context),host:O(e.host)});if(e.kind===D){const r=new Map;for(const t of Array.isArray(e.runs)?e.runs:[]){const o=p(t)?u(t.run):u(t),i=p(t)?u(t.job):void 0;o&&!r.has(o)&&r.size<j&&r.set(o,{run:o,...i?{job:i}:{}})}const n=Array.isArray(e.killed)?[...new Set(e.killed.map(u).filter(t=>!!t))].slice(0,j):[];return g({kind:D,context:u(e.context),runs:[...r.values()],why:u(e.why),vmTotalMb:E(e.vmTotalMb),vmAvailableMb:T(e.vmAvailableMb),killed:n.length?n:void 0,host:O(e.host)})}}}m(readDockerError,"readDockerError"),k(readDockerError,"readDockerError"),b(readDockerError,"readDockerError"),v(readDockerError,"readDockerError"),d(readDockerError,"readDockerError");export function dockerErrorRuns(e){return e.kind===f?e.run?[e.run]:[]:e.runs.map(r=>r.run)}m(dockerErrorRuns,"dockerErrorRuns"),k(dockerErrorRuns,"dockerErrorRuns"),b(dockerErrorRuns,"dockerErrorRuns"),v(dockerErrorRuns,"dockerErrorRuns"),d(dockerErrorRuns,"dockerErrorRuns");export function dockerRunOfEvent(e){return p(e)?u(e[S]):void 0}m(dockerRunOfEvent,"dockerRunOfEvent"),k(dockerRunOfEvent,"dockerRunOfEvent"),b(dockerRunOfEvent,"dockerRunOfEvent"),v(dockerRunOfEvent,"dockerRunOfEvent"),d(dockerRunOfEvent,"dockerRunOfEvent");export const CONTAINER_OOM_ERROR="ContainerOOMKilled",DOCKER_ENGINE_LOST_ERROR="DockerEngineLost";const W=256,a=d(e=>`${Math.round(e)} MiB`,"mib");function w(e){const r=`${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${x(e.host)}\xBB`:""}`,t=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:o,peakMb:i,budgetMb:s}=e;let l;if(o!==void 0&&s!==void 0){const c=Math.round(o)-Math.round(s);l=c>0?`It was killed at its ${a(o)} limit \u2014 ${a(c)} over the ${a(s)} it declares. Raise ${t} to what it takes (more than ${a(o)}), and the container's memory limit with it.`:c===0?`It was killed at its ${a(o)} limit, which is all it declares. Raise ${t} to what it takes, and the container's memory limit with it.`:`It was killed at its ${a(o)} limit, ${a(-c)} under the ${a(s)} it declares. Raise the container's memory limit to its budget (${t}) \u2014 and both, if it takes more.`}else if(o!==void 0)l=`It was killed at its ${a(o)} limit. Raise the limit, and ${t}, to what it takes.`;else if(i!==void 0&&s!==void 0){const c=Math.round(i)-Math.round(s);l=c>0?`It held ${a(i)} at its peak \u2014 ${a(c)} over the ${a(s)} it declares. Raise ${t} to what it takes, so the queue lets the job in only when Docker's VM has that much.`:`It held ${a(i)} at its peak, within the ${a(s)} it declares (${t}): 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 i!==void 0?l=`It held ${a(i)} at its peak. Check ${t} against that, and the container's memory limit.`:s!==void 0?l=`Its peak was not sampled. It declares ${a(s)}: raise ${t} to what it takes, and the container's memory limit with it.`:l=`Raise ${t} to what the service takes, and the container's memory limit with it.`;const h=[o!==void 0?`killed at its ${a(o)} limit`:"killed for memory",i!==void 0?`peak ${a(i)}`: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 ${x(e.host)}`:void 0,e.context?`Docker context ${e.context}`:void 0];return{cause:{id:R("cause",[CONTAINER_OOM_ERROR,e.job,e.service]),errorName:CONTAINER_OOM_ERROR,message:r},title:`${CONTAINER_OOM_ERROR}: ${r}`,headline:n,hint:l,facts:h.filter(Boolean).join(" \xB7 "),where:e.job?`Docker job ${e.job}`:"Docker"}}m(w,"g"),k(w,"x"),b(w,"y"),v(w,"A"),d(w,"oomWords");function M(e){const r=e.host?` on the worker ${x(e.host)}`:"",n=`Docker stopped answering${e.context?` (context ${e.context})`:""}${r}`,t=[...new Set(e.runs.map($=>$.job).filter($=>!!$))],o=e.runs.length,i=e.host?`Docker on the worker \xAB${x(e.host)}\xBB`:"Docker",s=o===0?`${i} stopped answering while LensMCP ran work in it`:o===1?`${i} stopped answering while ${t[0]?`the job \xAB${t[0]}\xBB`:"a job"} ran: its containers went with it`:`${i} stopped answering while ${o} runs were in it${t.length?` (${t.map($=>`\xAB${$}\xBB`).join(", ")})`:""}: their containers went with it`,{vmTotalMb:l,vmAvailableMb:h}=e,c=h===void 0?void 0:`${a(h)} free${l!==void 0?` of ${a(l)}`:""}`,y=h===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.":h<=W?`Its VM had ${c} 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 ${c} when it was last read, so memory is not the likely reason: was Docker stopped or restarted?`,B=[o?`${o} run${o===1?"":"s"} lost: ${e.runs.map($=>`${$.job??"a job"} (run ${$.run})`).join(", ")}`:void 0,e.why,c?`VM ${c}`:void 0,e.killed?.length?`killed for memory before it went: ${e.killed.join(", ")}`:void 0];return{cause:{id:R("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${r} and run ${o>1?"the jobs":"the job"} again: a run lost with the engine has no result. ${y}`,facts:B.filter(Boolean).join(" \xB7 "),where:`${e.context?`Docker context ${e.context}`:"Docker"}${r}`}}m(M,"E"),k(M,"y"),b(M,"E"),v(M,"I"),d(M,"engineWords");export function dockerErrorWords(e){return e.kind===f?w(e):M(e)}m(dockerErrorWords,"dockerErrorWords"),k(dockerErrorWords,"dockerErrorWords"),b(dockerErrorWords,"dockerErrorWords"),v(dockerErrorWords,"dockerErrorWords"),d(dockerErrorWords,"dockerErrorWords");export function mergeDockerError(e,r){if(e.kind===f){if(r.kind!==f)return e;const i=Math.max(e.peakMb??0,r.peakMb??0);return g({...r,...e,seen:e.seen==="event"||r.seen==="event"?"event":e.seen??r.seen,peakMb:i>0?i:void 0})}const n=e;if(r.kind===f)return r.service&&!n.killed?.includes(r.service)?{...n,killed:[...n.killed??[],r.service].slice(0,j)}:e;const t=new Map(n.runs.map(i=>[i.run,i]));for(const i of r.runs)(!t.has(i.run)||!t.get(i.run).job&&i.job)&&t.set(i.run,i);const o=[...new Set([...n.killed??[],...r.killed??[]])];return g({...r,...n,runs:[...t.values()].slice(0,j),vmAvailableMb:n.vmAvailableMb!==void 0&&r.vmAvailableMb!==void 0?Math.min(n.vmAvailableMb,r.vmAvailableMb):n.vmAvailableMb??r.vmAvailableMb,killed:o.length?o:void 0})}m(mergeDockerError,"mergeDockerError"),k(mergeDockerError,"mergeDockerError"),b(mergeDockerError,"mergeDockerError"),v(mergeDockerError,"mergeDockerError"),d(mergeDockerError,"mergeDockerError");export const DOCKER_ENGINE_LOSS_SAME_MS=6e4;const A=2e3,K=200;export class DockerErrorLedger{static{m(this,"DockerErrorLedger")}static{k(this,"DockerErrorLedger")}static{b(this,"DockerErrorLedger")}static{v(this,"DockerErrorLedger")}static{d(this,"DockerErrorLedger")}constructor(){this.kills=new Map,this.losses=new Map,this.lostRuns=new Map}account(r,n,t){if(r.kind===D){const l=r.host?`${r.host.peer}\0${r.context??""}`:r.context??"",h=this.losses.get(l),c=h&&Math.abs(t-h.at)<=DOCKER_ENGINE_LOSS_SAME_MS?h.told:void 0;c||this.remember(this.losses,l,{told:n,at:t},K);for(const y of r.runs)this.remember(this.lostRuns,y.run,c??n,A);return c}const o=r.seen!=="inspect",i=r.run&&r.container?`${r.run}\0${r.container}`:r.run&&r.service?`${r.run}\0\0${r.service}`:void 0,s=i?this.kills.get(i):void 0;if(!s){const l=!o&&r.run?this.lostRuns.get(r.run):void 0;if(l)return l;i&&this.remember(this.kills,i,{told:n,live:o?1:0},A);return}if(!o)return s.told;if(s.live===0)return s.live=1,s.told;s.live+=1,s.told=n}remember(r,n,t,o){r.delete(n),r.set(n,t),r.size>o&&r.delete(r.keys().next().value)}}
1
+ "use strict";var R=Object.defineProperty;var m=(t,e)=>R(t,"name",{value:e,configurable:!0});var O=Object.defineProperty,c=m((t,e)=>O(t,"name",{value:e,configurable:!0}),"c");import{CONTAINER_OOM as v,DOCKER_ENGINE_LOST as j,DOCKER_RUN_FIELD as B}from"./docker-jobs.js";import{joinId as x}from"./error-cause.js";const I=200,$=50,k=c(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"isObj"),h=c(t=>{if(typeof t!="string")return;const e=t.trim();return e?e.slice(0,I):void 0},"name"),p=c(t=>typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0,"someMb"),N=c(t=>typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0,"anyMb"),w=c(t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),"defined"),g=c(t=>{if(!k(t))return;const e=h(t.peer);if(!e)return;const s=h(t.name);return s?{peer:e,name:s}:{peer:e}},"hostOf"),f=c(t=>t.name??t.peer,"hostWord");export function readDockerError(t){if(k(t)){if(t.kind===v)return w({kind:v,run:h(t.run),job:h(t.job),service:h(t.service),container:h(t.container),seen:t.seen==="event"||t.seen==="inspect"?t.seen:void 0,limitMb:p(t.limitMb),peakMb:p(t.peakMb),budgetMb:p(t.budgetMb),context:h(t.context),host:g(t.host)});if(t.kind===j){const e=new Map;for(const o of Array.isArray(t.runs)?t.runs:[]){const i=k(o)?h(o.run):h(o),r=k(o)?h(o.job):void 0;i&&!e.has(i)&&e.size<$&&e.set(i,{run:i,...r?{job:r}:{}})}const s=Array.isArray(t.killed)?[...new Set(t.killed.map(h).filter(o=>!!o))].slice(0,$):[];return w({kind:j,context:h(t.context),runs:[...e.values()],why:h(t.why),vmTotalMb:p(t.vmTotalMb),vmAvailableMb:N(t.vmAvailableMb),killed:s.length?s:void 0,host:g(t.host)})}}}m(readDockerError,"readDockerError"),c(readDockerError,"readDockerError");export function dockerErrorRuns(t){return t.kind===v?t.run?[t.run]:[]:t.runs.map(e=>e.run)}m(dockerErrorRuns,"dockerErrorRuns"),c(dockerErrorRuns,"dockerErrorRuns");export function dockerRunOfEvent(t){return k(t)?h(t[B]):void 0}m(dockerRunOfEvent,"dockerRunOfEvent"),c(dockerRunOfEvent,"dockerRunOfEvent");export const CONTAINER_OOM_ERROR="ContainerOOMKilled",DOCKER_ENGINE_LOST_ERROR="DockerEngineLost";const _=256,a=c(t=>`${Math.round(t)} MiB`,"mib");function y(t){const e=`${t.service??"a container"} ran out of memory in ${t.job??"a Docker job"}`,s=`${t.service?`\xAB${t.service}\xBB`:"A container"} ran out of memory and was killed, in ${t.job?`the Docker job \xAB${t.job}\xBB`:"a Docker job"}${t.host?` on the worker \xAB${f(t.host)}\xBB`:""}`,o=t.job?`\`${t.budgetMb!==void 0&&t.service?`jobs.${t.job}.budget.services.${t.service}`:`jobs.${t.job}.budget`}\` in lensmcp.json`:"its job's budget in lensmcp.json \u2192 jobs",{limitMb:i,peakMb:r,budgetMb:n}=t;let l;if(i!==void 0&&n!==void 0){const d=Math.round(i)-Math.round(n);l=d>0?`It was killed at its ${a(i)} limit \u2014 ${a(d)} over the ${a(n)} it declares. Raise ${o} 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 ${o} 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(n)} it declares. Raise the container's memory limit to its budget (${o}) \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 ${o}, to what it takes.`;else if(r!==void 0&&n!==void 0){const d=Math.round(r)-Math.round(n);l=d>0?`It held ${a(r)} at its peak \u2014 ${a(d)} over the ${a(n)} it declares. Raise ${o} to what it takes, so the queue lets the job in only when Docker's VM has that much.`:`It held ${a(r)} at its peak, within the ${a(n)} it declares (${o}): 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 r!==void 0?l=`It held ${a(r)} at its peak. Check ${o} against that, and the container's memory limit.`:n!==void 0?l=`Its peak was not sampled. It declares ${a(n)}: raise ${o} to what it takes, and the container's memory limit with it.`:l=`Raise ${o} 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",r!==void 0?`peak ${a(r)}`:void 0,n!==void 0?`budget ${a(n)}`:void 0,t.run?`run ${t.run}`:void 0,t.seen==="inspect"?"found by the inspect at the run's end":void 0,t.host?`on the worker ${f(t.host)}`:void 0,t.context?`Docker context ${t.context}`:void 0];return{cause:{id:x("cause",[CONTAINER_OOM_ERROR,t.job,t.service]),errorName:CONTAINER_OOM_ERROR,message:e},title:`${CONTAINER_OOM_ERROR}: ${e}`,headline:s,hint:l,facts:u.filter(Boolean).join(" \xB7 "),where:t.job?`Docker job ${t.job}`:"Docker"}}m(y,"A"),c(y,"oomWords");function E(t){const e=t.host?` on the worker ${f(t.host)}`:"",s=`Docker stopped answering${t.context?` (context ${t.context})`:""}${e}`,o=[...new Set(t.runs.map(b=>b.job).filter(b=>!!b))],i=t.runs.length,r=t.host?`Docker on the worker \xAB${f(t.host)}\xBB`:"Docker",n=i===0?`${r} stopped answering while LensMCP ran work in it`:i===1?`${r} stopped answering while ${o[0]?`the job \xAB${o[0]}\xBB`:"a job"} ran: its containers went with it`:`${r} stopped answering while ${i} runs were in it${o.length?` (${o.map(b=>`\xAB${b}\xBB`).join(", ")})`:""}: their containers went with it`,{vmTotalMb:l,vmAvailableMb:u}=t,d=u===void 0?void 0:`${a(u)} free${l!==void 0?` of ${a(l)}`:""}`,M=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<=_?`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: ${t.runs.map(b=>`${b.job??"a job"} (run ${b.run})`).join(", ")}`:void 0,t.why,d?`VM ${d}`:void 0,t.killed?.length?`killed for memory before it went: ${t.killed.join(", ")}`:void 0];return{cause:{id:x("cause",t.host?[DOCKER_ENGINE_LOST_ERROR,t.context,t.host.peer]:[DOCKER_ENGINE_LOST_ERROR,t.context]),errorName:DOCKER_ENGINE_LOST_ERROR,message:s},title:`${DOCKER_ENGINE_LOST_ERROR}: ${s}`,headline:n,hint:`Start Docker again${e} and run ${i>1?"the jobs":"the job"} again: a run lost with the engine has no result. ${M}`,facts:A.filter(Boolean).join(" \xB7 "),where:`${t.context?`Docker context ${t.context}`:"Docker"}${e}`}}m(E,"I"),c(E,"engineWords");export function dockerErrorWords(t){return t.kind===v?y(t):E(t)}m(dockerErrorWords,"dockerErrorWords"),c(dockerErrorWords,"dockerErrorWords");export function mergeDockerError(t,e){if(t.kind===v){if(e.kind!==v)return t;const r=Math.max(t.peakMb??0,e.peakMb??0);return w({...e,...t,seen:t.seen==="event"||e.seen==="event"?"event":t.seen??e.seen,peakMb:r>0?r:void 0})}const s=t;if(e.kind===v)return e.service&&!s.killed?.includes(e.service)?{...s,killed:[...s.killed??[],e.service].slice(0,$)}:t;const o=new Map(s.runs.map(r=>[r.run,r]));for(const r of e.runs)(!o.has(r.run)||!o.get(r.run).job&&r.job)&&o.set(r.run,r);const i=[...new Set([...s.killed??[],...e.killed??[]])];return w({...e,...s,runs:[...o.values()].slice(0,$),vmAvailableMb:s.vmAvailableMb!==void 0&&e.vmAvailableMb!==void 0?Math.min(s.vmAvailableMb,e.vmAvailableMb):s.vmAvailableMb??e.vmAvailableMb,killed:i.length?i:void 0})}m(mergeDockerError,"mergeDockerError"),c(mergeDockerError,"mergeDockerError");export const DOCKER_ENGINE_LOSS_SAME_MS=6e4;const D=2e3,C=200;export class DockerErrorLedger{static{m(this,"DockerErrorLedger")}static{c(this,"DockerErrorLedger")}constructor(){this.kills=new Map,this.losses=new Map,this.lostRuns=new Map}account(e,s,o){if(e.kind===j){const l=e.host?`${e.host.peer}\0${e.context??""}`:e.context??"",u=this.losses.get(l),d=u&&Math.abs(o-u.at)<=DOCKER_ENGINE_LOSS_SAME_MS?u.told:void 0;d||this.remember(this.losses,l,{told:s,at:o},C);for(const M of e.runs)this.remember(this.lostRuns,M.run,d??s,D);return d}const i=e.seen!=="inspect",r=e.run&&e.container?`${e.run}\0${e.container}`:e.run&&e.service?`${e.run}\0\0${e.service}`:void 0,n=r?this.kills.get(r):void 0;if(!n){const l=!i&&e.run?this.lostRuns.get(e.run):void 0;if(l)return l;r&&this.remember(this.kills,r,{told:s,live:i?1:0},D);return}if(!i)return n.told;if(n.live===0)return n.live=1,n.told;n.live+=1,n.told=s}remember(e,s,o,i){e.delete(s),e.set(s,o),e.size>i&&e.delete(e.keys().next().value)}}
@@ -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.
@@ -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 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,2 +1,2 @@
1
- "use strict";var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});var j=Object.defineProperty,p=c((e,t)=>j(e,"name",{value:t,configurable:!0}),"c"),A=Object.defineProperty,b=p((e,t)=>A(e,"name",{value:t,configurable:!0}),"c"),y=Object.defineProperty,m=b((e,t)=>y(e,"name",{value:t,configurable:!0}),"h"),R=Object.defineProperty,u=m((e,t)=>R(e,"name",{value:t,configurable:!0}),"u");import{DOCKER_RUN_ENV as w,dockerRunEnded as B,RYUK_DISABLED_ENV as D}from"./docker-jobs.js";export function runUnlabeledWords(e){if(e.scope!=="containers")return[];const t=[],s=`hand ${w.labels} to each container it starts \u2014 a JSON object of labels: .withLabels(JSON.parse(process.env.${w.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, ${s}.`);const a=e.strangers;if(a?.containers.length){const n=a.containers.length+(a.more??0),h=(e.warnings??[]).some(l=>l.startsWith(D));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"}, ${s}.`))}return t}c(runUnlabeledWords,"runUnlabeledWords"),p(runUnlabeledWords,"runUnlabeledWords"),b(runUnlabeledWords,"runUnlabeledWords"),m(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const s=B(e.state),i=(e.services??[]).map(l=>{const o=l.budgetMb===void 0?0:l.peakMb-l.budgetMb;return{...l,...o>0?{overMb:o}:{},...l.peakMb>0?{}:{unsampled:!0}}}).sort((l,o)=>(o.overMb??0)-(l.overMb??0)||o.peakMb-l.peakMb||l.name.localeCompare(o.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:s,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,o)=>l+o.lastMb,0),...a.length?{budgetMb:a.reduce((l,o)=>l+(o.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"),b(dockerRunReport,"dockerRunReport"),m(dockerRunReport,"dockerRunReport"),u(dockerRunReport,"dockerRunReport");const d=u(e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),"when"),k=u(e=>{const t=Math.round(e/1e3);if(t<60)return`${t} s`;const s=Math.floor(t/60);return s<60?`${s} min${t%60?` ${t%60} s`:""}`:`${Math.floor(s/60)} h${s%60?` ${s%60} min`:""}`},"lasted"),M=u((e,t,s)=>`${e} ${e===1?t:s}`,"plural");export{d as dockerTime,k as dockerLasted};function $(e){const t=e.exit?e.exit.signal?`its command was ended by ${e.exit.signal}`:`its command exited ${e.exit.code}`:void 0,s=[e.ranMs!==void 0?`${e.ended?"ran":"running for"} ${k(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 ${s}`}c($,"$"),p($,"g"),b($,"v"),m($,"w"),u($,"stateText");function g(e){const t=e[0].map((s,i)=>Math.max(...e.map(a=>(a[i]??"").length)));return e.map(s=>s.map((i,a)=>a===0?i.padEnd(t[a]):a===s.length-1?i:i.padStart(t[a])).join(" ").trimEnd())}c(g,"g"),p(g,"v"),b(g,"f"),m(g,"k"),u(g,"table");export function dockerRunReportText(e){const{run:t,vm:s,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"}`,` ${$(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 o of e.warnings??[])n.push(` ! ${o}`);t.url?n.push(` URL: ${t.url}`):t.urlNote&&n.push(` no URL: ${t.urlNote}`),n.push("");const h=i?.samples?`${M(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 o=u(r=>r===void 0?"\u2013":String(r),"figure"),f=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(...g([["service","now","peak","budget","limit",""],...e.services.map(r=>[r.name,r.unsampled?"\u2013":String(r.lastMb),r.unsampled?"\u2013":String(r.peakMb),o(r.budgetMb),o(r.limitMb),f(r)]),["all",String(e.totals.lastMb),"",o(e.totals.budgetMb),"",""]]).map(r=>` ${r}`));const v=e.services.filter(r=>r.overMb!==void 0);v.length&&n.push(` ${M(v.length,"service","services")} over what ${v.length===1?"it declares":"they declare"}: raise \`jobs.${t.job}.budget.services\` in lensmcp.json to what ${v.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 o of e.kills){const f=[o.limitMb!==void 0?`at its ${o.limitMb} MiB limit`:"no limit of its own: the VM ran out, or it was not read",o.peakMb!==void 0?`peak ${o.peakMb} MiB`:"never sampled",o.budgetMb!==void 0?`budget ${o.budgetMb} MiB`:void 0,o.seen==="event"?"seen live":"found by the inspect: the live stream did not tell it"].filter(Boolean).join(" \xB7 ");n.push(` ${d(o.at)} ${o.service}${o.name?` (${o.name})`:""} ${f}`)}if(e.killsMore&&n.push(` \u2026 and ${e.killsMore} more, not listed`),e.engineLost){const o=e.engineLost;n.push(""),n.push(`Docker stopped answering at ${d(o.at)} \u2014 ${o.why}`),o.backAt!==void 0&&n.push(` it answered again at ${d(o.backAt)}`),o.killed?.length&&n.push(` found killed for memory once it was gone: ${o.killed.join(", ")} \u2014 they went with the engine`)}s&&(n.push(""),n.push(`Docker's VM: ${s.totalMb} MiB \xB7 ${s.read==="estimate"?"about ":""}${s.availableAtAdmissionMb} MiB free when the run was let in (${s.read==="estimate"?"an estimate: its own figure could not be read":"the VM's own figure"})`+(s.minAvailableMb!==void 0?` \xB7 lowest ${s.minAvailableMb} MiB while it ran`:" \xB7 not read while it ran")+(s.lastAvailableMb!==void 0?` \xB7 ${s.lastAvailableMb} MiB at the last read${s.sampledAt!==void 0?` (${d(s.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 o of e.unlabeled??[])n.push(` ${o}`);if(i?.notes?.length||i?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),i.streamRestarts&&n.push(` the live stream ended ${M(i.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const o of i.notes??[])n.push(` ${o}`)}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"),b(dockerRunReportText,"dockerRunReportText"),m(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
1
+ "use strict";var M=Object.defineProperty;var h=(e,t)=>M(e,"name",{value:t,configurable:!0});var w=Object.defineProperty,u=h((e,t)=>w(e,"name",{value:t,configurable:!0}),"u");import{DOCKER_RUN_ENV as b,dockerRunEnded as k,RYUK_DISABLED_ENV as x}from"./docker-jobs.js";export function runUnlabeledWords(e){if(e.scope!=="containers")return[];const t=[],o=`hand ${b.labels} to each container it starts \u2014 a JSON object of labels: .withLabels(JSON.parse(process.env.${b.labels} ?? '{}'))`,a=e.startedAt!==void 0&&e.watch?.inspected!==void 0&&!e.engineLost&&!(e.services??[]).length;a&&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 i=e.strangers;if(i?.containers.length){const n=i.containers.length+(i.more??0),c=(e.warnings??[]).some(l=>l.startsWith(x));t.push(`${n} container${n===1?"":"s"} without the run's labels came up while it ran and ${n===1?"is":"are"} still there: ${i.containers.join(", ")}${i.more?` and ${i.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. `+(c?"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.")+(a?"":` If the job started ${n===1?"it":"them"}, ${o}.`))}return t}h(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const o=k(e.state),a=(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)),i=a.filter(l=>l.budgetMb!==void 0),n=e.startedAt===void 0?void 0:Math.max(0,(e.endedAt??t)-e.startedAt),c=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:a,totals:{lastMb:a.reduce((l,s)=>l+s.lastMb,0),...i.length?{budgetMb:i.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}:{},...c.length?{unlabeled:c}:{},...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}}}h(dockerRunReport,"dockerRunReport"),u(dockerRunReport,"dockerRunReport");const d=u(e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),"when"),g=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,g as dockerLasted};function v(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"} ${g(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}`}h(v,"w"),u(v,"stateText");function f(e){const t=e[0].map((o,a)=>Math.max(...e.map(i=>(i[a]??"").length)));return e.map(o=>o.map((a,i)=>i===0?a.padEnd(t[i]):i===o.length-1?a:a.padStart(t[i])).join(" ").trimEnd())}h(f,"k"),u(f,"table");export function dockerRunReportText(e){const{run:t,vm:o,watch:a,cleanup:i}=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"}`,` ${v(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 c=a?.samples?`${$(a.samples,"sample","samples")}${a.sampledAt!==void 0?`, the last at ${d(a.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 ${c}`),e.services.length){const s=u(r=>r===void 0?"\u2013":String(r),"figure"),m=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(...f([["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),m(r)]),["all",String(e.totals.lastMb),"",s(e.totals.budgetMb),"",""]]).map(r=>` ${r}`));const p=e.services.filter(r=>r.overMb!==void 0);p.length&&n.push(` ${$(p.length,"service","services")} over what ${p.length===1?"it declares":"they declare"}: raise \`jobs.${t.job}.budget.services\` in lensmcp.json to what ${p.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 m=[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})`:""} ${m}`)}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(""),i?i.done?n.push(`Cleanup: by ${i.by==="project"?"the project's own end (LensMCP looked, and found nothing)":i.by} at ${d(i.at)} \u2014 nothing of the run is left`):n.push(`Cleanup: OWED (${i.by}, ${d(i.at)}) \u2014 ${i.why??"something that carries the run's labels is left"}${i.left?.length?` \u2014 left: ${i.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"),i?.unlabeled?.length&&n.push(` in its Compose project without the run's labels, never removed: ${i.unlabeled.join(", ")}`);for(const s of e.unlabeled??[])n.push(` ${s}`);if(a?.notes?.length||a?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),a.streamRestarts&&n.push(` the live stream ended ${$(a.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const s of a.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
+ `)}h(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
@@ -1,3 +1,3 @@
1
- "use strict";var M=Object.defineProperty;var i=(n,e)=>M(n,"name",{value:e,configurable:!0});var L=Object.defineProperty,a=i((n,e)=>L(n,"name",{value:e,configurable:!0}),"i"),x=Object.defineProperty,k=a((n,e)=>x(n,"name",{value:e,configurable:!0}),"u"),S=Object.defineProperty,p=k((n,e)=>S(n,"name",{value:e,configurable:!0}),"u"),j=Object.defineProperty,l=p((n,e)=>j(n,"name",{value:e,configurable:!0}),"l");import{dockerLasted as v,dockerRunReport as y,dockerTime as m}from"./docker-report.js";export function dockerRunStanding(n){return n.run.ended?n.cleanup?.done===!0?"ended":"owed":"up"}i(dockerRunStanding,"dockerRunStanding"),a(dockerRunStanding,"dockerRunStanding"),k(dockerRunStanding,"dockerRunStanding"),p(dockerRunStanding,"dockerRunStanding"),l(dockerRunStanding,"dockerRunStanding");export function dockerRunsList(n,e={}){const t=e.now??Date.now(),s=n.map(h=>{const c=y(h,t),R=dockerRunStanding(c);return{...c,standing:R,...R==="up"&&e.runnerGone?.(h)?{runnerGone:!0}:{}}}),d=l(h=>s.filter(c=>c.standing===h).sort((c,R)=>(R.run.endedAt??R.run.startedAt??R.run.createdAt)-(c.run.endedAt??c.run.startedAt??c.run.createdAt)||c.run.id.localeCompare(R.run.id)),"of"),o=d("up"),u=d("owed"),r=d("ended"),g=e.all?r.slice(0,e.endedMax??r.length):[];return{counts:{up:o.length,owed:u.length,ended:r.length},all:e.all===!0,...e.all&&g.length<r.length?{endedMore:r.length-g.length}:{},runs:[...o,...u,...g]}}i(dockerRunsList,"dockerRunsList"),a(dockerRunsList,"dockerRunsList"),k(dockerRunsList,"dockerRunsList"),p(dockerRunsList,"dockerRunsList"),l(dockerRunsList,"dockerRunsList");const B={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=l(n=>B[n],"dockerStateWord");export function dockerRunSince(n){const{run:e}=n;return e.ended?e.endedAt??e.startedAt??e.createdAt:e.startedAt??e.createdAt}i(dockerRunSince,"dockerRunSince"),a(dockerRunSince,"dockerRunSince"),k(dockerRunSince,"dockerRunSince"),p(dockerRunSince,"dockerRunSince"),l(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`}i(dockerRunHolds,"dockerRunHolds"),a(dockerRunHolds,"dockerRunHolds"),k(dockerRunHolds,"dockerRunHolds"),p(dockerRunHolds,"dockerRunHolds"),l(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 t=n.services.filter(u=>u.overMb!==void 0);t.length&&e.push(`OVER its budget: ${t.map(u=>`${u.name} by ${u.overMb} MiB`).join(", ")}`);const s=n.kills.length+(n.killsMore??0),d=[...new Set(n.kills.map(u=>u.service))];s&&e.push(`killed for memory: ${s}${d.length?` (${d.join(", ")})`:""}`),n.engineLost&&e.push(`Docker stopped answering at ${m(n.engineLost.at)}${n.engineLost.backAt!==void 0?`, and answered again at ${m(n.engineLost.backAt)}`:""}`);const{cleanup:o}=n;return n.run.ended&&!o?e.push("cleanup OWED: none is recorded \u2014 its guard, or the sweep, has it"):o&&!o.done&&e.push(`cleanup OWED: ${o.why??"something that carries the run's labels is left"}${o.left?.length?` \u2014 left: ${o.left.join(", ")}`:""}`),o?.unlabeled?.length&&e.push(`in its Compose project without the run's labels, never removed: ${o.unlabeled.join(", ")}`),e}i(dockerRunRemarks,"dockerRunRemarks"),a(dockerRunRemarks,"dockerRunRemarks"),k(dockerRunRemarks,"dockerRunRemarks"),p(dockerRunRemarks,"dockerRunRemarks"),l(dockerRunRemarks,"dockerRunRemarks");function f(n){const{run:e}=n,t=dockerRunSince(n),s=e.ended?`ended ${m(t)}${e.ranMs!==void 0?` after ${v(e.ranMs)}`:""}`:e.startedAt!==void 0?`for ${v(e.ranMs??0)}, since ${m(t)}`:`since ${m(t)}`,d=n.standing==="up"?dockerRunHolds(n):void 0,o=[[e.job,`${dockerStateWord(e.state)}${n.standing==="owed"?", cleanup OWED":n.runnerGone?", its runner GONE":""}`,s,...d?[`holds ${d}`]:[],e.id].join(" ")];e.stage&&!e.ended&&o.push(` stage: ${e.stage}`),e.url?o.push(` URL: ${e.url}`):e.urlNote&&!e.ended&&o.push(` no URL: ${e.urlNote}`),e.note&&o.push(` ${e.note}`);for(const u of dockerRunRemarks(n))o.push(` ${u}`);return o}i(f,"m"),a(f,"R"),k(f,"$"),p(f,"R"),l(f,"runLines");const w=l((n,e,t)=>`${n} ${n===1?e:t}`,"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 t=e.ended?` \xB7 ${w(e.ended,"ended one is","ended ones are")} kept${n.all?"":" (--all lists them)"}`:"",s=[`Docker runs of this home \u2014 ${e.up} up, ${e.owed?`${w(e.owed,"owes","owe")} a cleanup`:"none owes a cleanup"}${t}`];n.runs.length||s.push(" Nothing of this home is in Docker now.");for(const d of n.runs)s.push(...f(d).map(o=>` ${o}`));return n.endedMore&&s.push(` \u2026 and ${n.endedMore} more ended, not listed`),e.owed&&s.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."),s.join(`
3
- `)}i(dockerRunsText,"dockerRunsText"),a(dockerRunsText,"dockerRunsText"),k(dockerRunsText,"dockerRunsText"),p(dockerRunsText,"dockerRunsText"),l(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const O=8,A=300,$=l(n=>n.length>A?`${n.slice(0,A-1)}\u2026`:n,"cut"),b=l(n=>n?.length?n.slice(0,O).map(e=>e.slice(0,120)):void 0,"names");export function dockerRunBlock(n){const{run:e,cleanup:t,engineLost:s}=n,d=n.services.slice(0,BLOCK_MAX_SERVICES),o=n.kills.slice(0,BLOCK_MAX_KILLS),u=n.kills.length-o.length+(n.killsMore??0),r=b(t?.left),g=b(t?.unlabeled),h=b(s?.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:$(e.urlNote)}:{},...e.note?{note:$(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:o.map(c=>({...c,container:c.container.slice(0,12)})),...u?{killsMore:u}:{},...s?{engineLost:{at:s.at,why:$(s.why),...s.backAt!==void 0?{backAt:s.backAt}:{},...h?{killed:h}:{}}}:{},...t?{cleanup:{by:t.by,at:t.at,done:t.done,...r?{left:r}:{},...g?{unlabeled:g}:{},...t.why?{why:$(t.why)}:{}}}:{}}}i(dockerRunBlock,"dockerRunBlock"),a(dockerRunBlock,"dockerRunBlock"),k(dockerRunBlock,"dockerRunBlock"),p(dockerRunBlock,"dockerRunBlock"),l(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}}i(dockerRunBlockLess,"dockerRunBlockLess"),a(dockerRunBlockLess,"dockerRunBlockLess"),k(dockerRunBlockLess,"dockerRunBlockLess"),p(dockerRunBlockLess,"dockerRunBlockLess"),l(dockerRunBlockLess,"dockerRunBlockLess");export const PAGE_MAX_ROWS=50;const E=["queued","running"];export function dockerRemoteStanding(n){return n.state==="lost"?"lost":E.includes(n.state)?"up":"ended"}i(dockerRemoteStanding,"dockerRemoteStanding"),a(dockerRemoteStanding,"dockerRemoteStanding"),k(dockerRemoteStanding,"dockerRemoteStanding"),p(dockerRemoteStanding,"dockerRemoteStanding"),l(dockerRemoteStanding,"dockerRemoteStanding");export function dockerRemoteRunsList(n,e={}){const t=l(r=>r.completedAt??r.startedAt??r.queuedAt,"since"),s=[...n].sort((r,g)=>t(g)-t(r)||r.run.localeCompare(g.run)),d=s.filter(r=>dockerRemoteStanding(r)==="up"),o=s.filter(r=>dockerRemoteStanding(r)!=="up"),u=o.slice(0,e.endedMax??o.length);return{counts:{up:d.length,lost:o.filter(r=>r.state==="lost").length,ended:o.filter(r=>r.state!=="lost").length},runs:[...d,...u],...u.length<o.length?{endedMore:o.length-u.length}:{}}}i(dockerRemoteRunsList,"dockerRemoteRunsList"),a(dockerRemoteRunsList,"dockerRemoteRunsList"),k(dockerRemoteRunsList,"dockerRemoteRunsList"),p(dockerRemoteRunsList,"dockerRemoteRunsList"),l(dockerRemoteRunsList,"dockerRemoteRunsList");
1
+ "use strict";var R=Object.defineProperty;var u=(t,e)=>R(t,"name",{value:e,configurable:!0});var b=Object.defineProperty,i=u((t,e)=>b(t,"name",{value:e,configurable:!0}),"l");import{dockerLasted as m,dockerRunReport as A,dockerTime as g}from"./docker-report.js";export function dockerRunStanding(t){return t.run.ended?t.cleanup?.done===!0?"ended":"owed":"up"}u(dockerRunStanding,"dockerRunStanding"),i(dockerRunStanding,"dockerRunStanding");export function dockerRunsList(t,e={}){const o=e.now??Date.now(),s=t.map(p=>{const a=A(p,o),h=dockerRunStanding(a);return{...a,standing:h,...h==="up"&&e.runnerGone?.(p)?{runnerGone:!0}:{}}}),d=i(p=>s.filter(a=>a.standing===p).sort((a,h)=>(h.run.endedAt??h.run.startedAt??h.run.createdAt)-(a.run.endedAt??a.run.startedAt??a.run.createdAt)||a.run.id.localeCompare(h.run.id)),"of"),n=d("up"),l=d("owed"),r=d("ended"),c=e.all?r.slice(0,e.endedMax??r.length):[];return{counts:{up:n.length,owed:l.length,ended:r.length},all:e.all===!0,...e.all&&c.length<r.length?{endedMore:r.length-c.length}:{},runs:[...n,...l,...c]}}u(dockerRunsList,"dockerRunsList"),i(dockerRunsList,"dockerRunsList");const M={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(t=>M[t],"dockerStateWord");export function dockerRunSince(t){const{run:e}=t;return e.ended?e.endedAt??e.startedAt??e.createdAt:e.startedAt??e.createdAt}u(dockerRunSince,"dockerRunSince"),i(dockerRunSince,"dockerRunSince");export function dockerRunHolds(t){if(t.services.some(e=>!e.unsampled))return t.totals.budgetMb===void 0?`${t.totals.lastMb} MiB`:`${t.totals.lastMb} of ${t.totals.budgetMb} MiB`}u(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(t){const e=[];t.runnerGone&&!t.run.ended&&e.push(RUNNER_GONE);const o=t.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 s=t.kills.length+(t.killsMore??0),d=[...new Set(t.kills.map(l=>l.service))];s&&e.push(`killed for memory: ${s}${d.length?` (${d.join(", ")})`:""}`),t.engineLost&&e.push(`Docker stopped answering at ${g(t.engineLost.at)}${t.engineLost.backAt!==void 0?`, and answered again at ${g(t.engineLost.backAt)}`:""}`);const{cleanup:n}=t;return t.run.ended&&!n?e.push("cleanup OWED: none is recorded \u2014 its guard, or the sweep, has it"):n&&!n.done&&e.push(`cleanup OWED: ${n.why??"something that carries the run's labels is left"}${n.left?.length?` \u2014 left: ${n.left.join(", ")}`:""}`),n?.unlabeled?.length&&e.push(`in its Compose project without the run's labels, never removed: ${n.unlabeled.join(", ")}`),e}u(dockerRunRemarks,"dockerRunRemarks"),i(dockerRunRemarks,"dockerRunRemarks");function $(t){const{run:e}=t,o=dockerRunSince(t),s=e.ended?`ended ${g(o)}${e.ranMs!==void 0?` after ${m(e.ranMs)}`:""}`:e.startedAt!==void 0?`for ${m(e.ranMs??0)}, since ${g(o)}`:`since ${g(o)}`,d=t.standing==="up"?dockerRunHolds(t):void 0,n=[[e.job,`${dockerStateWord(e.state)}${t.standing==="owed"?", cleanup OWED":t.runnerGone?", its runner GONE":""}`,s,...d?[`holds ${d}`]:[],e.id].join(" ")];e.stage&&!e.ended&&n.push(` stage: ${e.stage}`),e.url?n.push(` URL: ${e.url}`):e.urlNote&&!e.ended&&n.push(` no URL: ${e.urlNote}`),e.note&&n.push(` ${e.note}`);for(const l of dockerRunRemarks(t))n.push(` ${l}`);return n}u($,"R"),i($,"runLines");const v=i((t,e,o)=>`${t} ${t===1?e:o}`,"plural");export function dockerRunsText(t){const{counts:e}=t;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${t.all?"":" (--all lists them)"}`:"",s=[`Docker runs of this home \u2014 ${e.up} up, ${e.owed?`${v(e.owed,"owes","owe")} a cleanup`:"none owes a cleanup"}${o}`];t.runs.length||s.push(" Nothing of this home is in Docker now.");for(const d of t.runs)s.push(...$(d).map(n=>` ${n}`));return t.endedMore&&s.push(` \u2026 and ${t.endedMore} more ended, not listed`),e.owed&&s.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."),s.join(`
3
+ `)}u(dockerRunsText,"dockerRunsText"),i(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const x=8,w=300,k=i(t=>t.length>w?`${t.slice(0,w-1)}\u2026`:t,"cut"),f=i(t=>t?.length?t.slice(0,x).map(e=>e.slice(0,120)):void 0,"names");export function dockerRunBlock(t){const{run:e,cleanup:o,engineLost:s}=t,d=t.services.slice(0,BLOCK_MAX_SERVICES),n=t.kills.slice(0,BLOCK_MAX_KILLS),l=t.kills.length-n.length+(t.killsMore??0),r=f(o?.left),c=f(o?.unlabeled),p=f(s?.killed);return{run:e.id,job:e.job,kind:e.kind,state:e.state,standing:dockerRunStanding(t),...t.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:k(e.urlNote)}:{},...e.note?{note:k(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}:{},...t.vm?{vm:t.vm}:{},services:d,...t.services.length>d.length?{servicesMore:t.services.length-d.length}:{},totals:t.totals,kills:n.map(a=>({...a,container:a.container.slice(0,12)})),...l?{killsMore:l}:{},...s?{engineLost:{at:s.at,why:k(s.why),...s.backAt!==void 0?{backAt:s.backAt}:{},...p?{killed:p}:{}}}:{},...o?{cleanup:{by:o.by,at:o.at,done:o.done,...r?{left:r}:{},...c?{unlabeled:c}:{},...o.why?{why:k(o.why)}:{}}}:{}}}u(dockerRunBlock,"dockerRunBlock"),i(dockerRunBlock,"dockerRunBlock");export function dockerRunBlockLess(t){if(t.services&&t.services.length>1)return{...t,services:t.services.slice(0,-1),servicesMore:(t.servicesMore??0)+1};if(t.kills&&t.kills.length>1)return{...t,kills:t.kills.slice(0,-1),killsMore:(t.killsMore??0)+1}}u(dockerRunBlockLess,"dockerRunBlockLess"),i(dockerRunBlockLess,"dockerRunBlockLess");export const PAGE_MAX_ROWS=50;const L=["queued","running"];export function dockerRemoteStanding(t){return t.state==="lost"?"lost":L.includes(t.state)?"up":"ended"}u(dockerRemoteStanding,"dockerRemoteStanding"),i(dockerRemoteStanding,"dockerRemoteStanding");export function dockerRemoteRunsList(t,e={}){const o=i(r=>r.completedAt??r.startedAt??r.queuedAt,"since"),s=[...t].sort((r,c)=>o(c)-o(r)||r.run.localeCompare(c.run)),d=s.filter(r=>dockerRemoteStanding(r)==="up"),n=s.filter(r=>dockerRemoteStanding(r)!=="up"),l=n.slice(0,e.endedMax??n.length);return{counts:{up:d.length,lost:n.filter(r=>r.state==="lost").length,ended:n.filter(r=>r.state!=="lost").length},runs:[...d,...l],...l.length<n.length?{endedMore:n.length-l.length}:{}}}u(dockerRemoteRunsList,"dockerRemoteRunsList"),i(dockerRemoteRunsList,"dockerRemoteRunsList");
@@ -1,6 +1,6 @@
1
- "use strict";var E=Object.defineProperty;var r=(e,t)=>E(e,"name",{value:t,configurable:!0});var x=Object.defineProperty,c=r((e,t)=>x(e,"name",{value:t,configurable:!0}),"s"),v=Object.defineProperty,d=c((e,t)=>v(e,"name",{value:t,configurable:!0}),"s"),b=Object.defineProperty,m=d((e,t)=>b(e,"name",{value:t,configurable:!0}),"s"),w=Object.defineProperty,a=m((e,t)=>w(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const i=a(o=>o.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(o=>i(o===void 0?"":String(o)))].join(":")}r(joinId,"joinId"),c(joinId,"joinId"),d(joinId,"joinId"),m(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):""}r(foldMessage,"foldMessage"),c(foldMessage,"foldMessage"),d(foldMessage,"foldMessage"),m(foldMessage,"foldMessage"),a(foldMessage,"foldMessage");const $=a(e=>!!e&&typeof e=="object"&&typeof e.message=="string","isValidationIssue"),k=a(e=>Array.isArray(e)&&e.length?e.map(String).join("."):"(root)","issuePath"),g=3;export function readableErrorMessage(e){const t=e?.trim()??"",i=t.indexOf("["),o=t.slice(0,Math.max(i,0));if(i<0||!/^(?:[A-Za-z_$][\w$]*:\s*)?$/.test(o))return e;let l;try{l=JSON.parse(t.slice(i))}catch{return e}if(!Array.isArray(l)||!l.length||!l.every($))return e;const n=l.map(u=>`${k(u.path)}: ${u.message}`),s=n.length===1?"1 issue":`${n.length} issues`,f=n.length>g?` (+${n.length-g} more)`:"";return[`${o}Validation failed (${s}): ${n.slice(0,g).join("; ")}${f}`,...n.map(u=>` ${u}`)].join(`
3
- `)}r(readableErrorMessage,"readableErrorMessage"),c(readableErrorMessage,"readableErrorMessage"),d(readableErrorMessage,"readableErrorMessage"),m(readableErrorMessage,"readableErrorMessage"),a(readableErrorMessage,"readableErrorMessage");const O=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function h(e){const t=O.exec((e??"").split(`
4
- `)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}r(h,"u"),c(h,"l"),d(h,"h"),m(h,"u"),a(h,"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 o=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(i[1].trim());return o?`${o[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${o[2]}`:i[1].trim()}}r(appFrameOf,"appFrameOf"),c(appFrameOf,"appFrameOf"),d(appFrameOf,"appFrameOf"),m(appFrameOf,"appFrameOf"),a(appFrameOf,"appFrameOf");export function errorCause(e){const t=readableErrorMessage(e.message),i=h(e.stack),o=h(t),l=h(e.title),n=e.name?.trim()||i?.name||o?.name||l?.name;if(!n)return;let s=(t!==e.message?t:void 0)??(i&&i.name===n?i.message:void 0)??t??l?.message??e.title??"";const f=h(s);f&&f.name===n&&(s=f.message),s=s.split(`
6
- `)[0].trim();const u=appFrameOf(e.stack),y=R.has(errorHeadline({name:n,message:s})?.id??"");return{id:joinId("cause",[n,foldMessage(s),y?void 0:u]),errorName:n,message:s,...u?{frame:u}:{}}}r(errorCause,"errorCause"),c(errorCause,"errorCause"),d(errorCause,"errorCause"),m(errorCause,"errorCause"),a(errorCause,"errorCause");const R=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])}r(causeIdWithoutFrame,"causeIdWithoutFrame"),c(causeIdWithoutFrame,"causeIdWithoutFrame"),d(causeIdWithoutFrame,"causeIdWithoutFrame"),m(causeIdWithoutFrame,"causeIdWithoutFrame"),a(causeIdWithoutFrame,"causeIdWithoutFrame");const p=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${p(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${p(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${p(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${p(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 o=i.match(t,e);if(o)return{id:i.id,...i.say(o)}}}r(errorHeadline,"errorHeadline"),c(errorHeadline,"errorHeadline"),d(errorHeadline,"errorHeadline"),m(errorHeadline,"errorHeadline"),a(errorHeadline,"errorHeadline");
1
+ "use strict";var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});var g=Object.defineProperty,i=s((e,t)=>g(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const a=i(n=>n.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(n=>a(n===void 0?"":String(n)))].join(":")}s(joinId,"joinId"),i(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"),i(foldMessage,"foldMessage");const y=i(e=>!!e&&typeof e=="object"&&typeof e.message=="string","isValidationIssue"),E=i(e=>Array.isArray(e)&&e.length?e.map(String).join("."):"(root)","issuePath"),u=3;export function readableErrorMessage(e){const t=e?.trim()??"",a=t.indexOf("["),n=t.slice(0,Math.max(a,0));if(a<0||!/^(?:[A-Za-z_$][\w$]*:\s*)?$/.test(n))return e;let c;try{c=JSON.parse(t.slice(a))}catch{return e}if(!Array.isArray(c)||!c.length||!c.every(y))return e;const o=c.map(d=>`${E(d.path)}: ${d.message}`),r=o.length===1?"1 issue":`${o.length} issues`,m=o.length>u?` (+${o.length-u} more)`:"";return[`${n}Validation failed (${r}): ${o.slice(0,u).join("; ")}${m}`,...o.map(d=>` ${d}`)].join(`
3
+ `)}s(readableErrorMessage,"readableErrorMessage"),i(readableErrorMessage,"readableErrorMessage");const x=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function h(e){const t=x.exec((e??"").split(`
4
+ `)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}s(h,"u"),i(h,"named");export function appFrameOf(e){for(const t of(e??"").split(`
5
+ `)){const a=/^\s*at\s+(.+)$/.exec(t);if(!a||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(a[1]))continue;const n=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(a[1].trim());return n?`${n[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${n[2]}`:a[1].trim()}}s(appFrameOf,"appFrameOf"),i(appFrameOf,"appFrameOf");export function errorCause(e){const t=readableErrorMessage(e.message),a=h(e.stack),n=h(t),c=h(e.title),o=e.name?.trim()||a?.name||n?.name||c?.name;if(!o)return;let r=(t!==e.message?t:void 0)??(a&&a.name===o?a.message:void 0)??t??c?.message??e.title??"";const m=h(r);m&&m.name===o&&(r=m.message),r=r.split(`
6
+ `)[0].trim();const d=appFrameOf(e.stack),p=v.has(errorHeadline({name:o,message:r})?.id??"");return{id:joinId("cause",[o,foldMessage(r),p?void 0:d]),errorName:o,message:r,...d?{frame:d}:{}}}s(errorCause,"errorCause"),i(errorCause,"errorCause");const v=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"),i(causeIdWithoutFrame,"causeIdWithoutFrame");const l=i(e=>e?` (\xAB${e}\xBB)`:"","q");export const ERROR_HEADLINES=[{id:"missing-column",match:i(e=>/column "?([\w.]+)"?(?: of relation "?[\w.]+"?)? does not exist|Unknown column '([^']+)'|ER_BAD_FIELD_ERROR/i.exec(e),"match"),say:i(e=>({headline:`The code expects a database column${l(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:i(e=>/relation "?([\w.]+)"? does not exist|Table '([^']+)' doesn't exist|ER_NO_SUCH_TABLE/i.exec(e),"match"),say:i(e=>({headline:`The code expects a database table${l(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:i((e,t)=>/duplicate key value violates unique constraint "?([\w.]+)"?|Duplicate entry '[^']*' for key '([^']+)'|ER_DUP_ENTRY/i.exec(e)||t.code==="23505","match"),say:i(e=>({headline:`A row with the same unique value already exists${l(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:i((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:i(e=>({headline:`A row points at a row that doesn't exist, or a row still in use was deleted${l(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:i((e,t)=>/ECONNREFUSED|connection refused|connect ECONNREFUSED/i.exec(e)||t.code==="ECONNREFUSED","match"),say:i(()=>({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:i((e,t)=>/heap out of memory|JavaScript heap|out of memory|ENOMEM|Allocation failed/i.exec(e)||t.code==="ENOMEM","match"),say:i(()=>({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:i((e,t)=>/jwt expired|token expired/i.exec(e)||t.name==="TokenExpiredError","match"),say:i(()=>({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:i((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:i(()=>({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:i((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:i(()=>({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:i((e,t)=>t.status===401||t.name==="UnauthorizedException"||/^Unauthorized$/i.test(e.trim()),"match"),say:i(()=>({headline:"The request was not signed in (401)",hint:"It came without a valid session or token."}),"say")},{id:"forbidden",match:i((e,t)=>t.status===403||t.name==="ForbiddenException"||/^Forbidden(?: resource)?$/i.test(e.trim()),"match"),say:i(()=>({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 a of ERROR_HEADLINES){const n=a.match(t,e);if(n)return{id:a.id,...a.say(n)}}}s(errorHeadline,"errorHeadline"),i(errorHeadline,"errorHeadline");
@@ -1 +1 @@
1
- "use strict";var S=Object.defineProperty;var s=(e,r)=>S(e,"name",{value:r,configurable:!0});var b=Object.defineProperty,u=s((e,r)=>b(e,"name",{value:r,configurable:!0}),"s"),y=Object.defineProperty,c=u((e,r)=>y(e,"name",{value:r,configurable:!0}),"s"),g=Object.defineProperty,f=c((e,r)=>g(e,"name",{value:r,configurable:!0}),"s"),I=Object.defineProperty,E=f((e,r)=>I(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 D=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const _=300,v=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 m=Array.isArray(r.eventIds)?r.eventIds.filter(t=>typeof t=="string"&&t.length>0).slice(0,200):[],o=v.has(r.by)?r.by:void 0,a=E((t,p)=>typeof t=="string"&&t.trim()?t.trim().slice(0,p):void 0,"text"),d=a(r.reason,500),l=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,e.timestamp),eventIds:m,...o?{by:o}:{},...d?{reason:d}:{},...l?{title:l}:{}}}s(readErrorDismissal,"readErrorDismissal"),u(readErrorDismissal,"readErrorDismissal"),c(readErrorDismissal,"readErrorDismissal"),f(readErrorDismissal,"readErrorDismissal"),E(readErrorDismissal,"readErrorDismissal");
1
+ "use strict";var f=Object.defineProperty;var s=(t,r)=>f(t,"name",{value:r,configurable:!0});var E=Object.defineProperty,S=s((t,r)=>E(t,"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 g=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const m=300,I=new Set(["dashboard","cli","agent"]);export function readErrorDismissal(t){if(t.source!==LENS_EVENT_SOURCE||!t.raw||typeof t.raw!="object")return;const r=t.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 c=Array.isArray(r.eventIds)?r.eventIds.filter(e=>typeof e=="string"&&e.length>0).slice(0,200):[],o=I.has(r.by)?r.by:void 0,a=S((e,l)=>typeof e=="string"&&e.trim()?e.trim().slice(0,l):void 0,"text"),d=a(r.reason,500),u=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,t.timestamp),eventIds:c,...o?{by:o}:{},...d?{reason:d}:{},...u?{title:u}:{}}}s(readErrorDismissal,"readErrorDismissal"),S(readErrorDismissal,"readErrorDismissal");