@lensmcp/protocol-types 1.26.29 → 1.26.31

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 (52) hide show
  1. package/lib/ai-cache-facts.js +1 -1
  2. package/lib/ai-cache-verdict.js +1 -1
  3. package/lib/ai-cache.js +3 -3
  4. package/lib/ai-call-groups.js +2 -2
  5. package/lib/ai-call-row.js +3 -3
  6. package/lib/ai-call.js +9 -9
  7. package/lib/ai-compare.js +3 -3
  8. package/lib/ai-context.js +6 -6
  9. package/lib/ai-origins.js +9 -9
  10. package/lib/ai-together.js +5 -5
  11. package/lib/bounded-clone.js +1 -1
  12. package/lib/bounded-map.js +1 -1
  13. package/lib/bounded-writer.js +1 -1
  14. package/lib/canvas-attachments.js +1 -1
  15. package/lib/canvas-catalog.js +3 -3
  16. package/lib/canvas-chat.js +2 -2
  17. package/lib/canvas-editing.js +4 -4
  18. package/lib/canvas-frame-policy.js +1 -1
  19. package/lib/canvas-hub.js +1 -1
  20. package/lib/canvas.d.ts +13 -1
  21. package/lib/canvas.js +1 -1
  22. package/lib/capture-demand.js +1 -1
  23. package/lib/dashboard-path.js +1 -1
  24. package/lib/docker-errors.js +1 -1
  25. package/lib/docker-jobs.js +1 -1
  26. package/lib/docker-report.js +2 -2
  27. package/lib/docker-runs.js +3 -3
  28. package/lib/error-cause.js +6 -6
  29. package/lib/error-dismissal.js +1 -1
  30. package/lib/error-verdict.js +3 -3
  31. package/lib/event-loop.js +1 -1
  32. package/lib/expected-failure.js +2 -2
  33. package/lib/finding-proof.js +1 -1
  34. package/lib/flood-guard.js +1 -1
  35. package/lib/goal-design.js +1 -1
  36. package/lib/host-agents.js +1 -1
  37. package/lib/lens-hosts.js +1 -1
  38. package/lib/lint-coverage.js +1 -1
  39. package/lib/lint-ignores.js +2 -2
  40. package/lib/log-query.js +1 -1
  41. package/lib/metrics-reset.js +1 -1
  42. package/lib/overseer-findings.js +1 -1
  43. package/lib/peers.js +1 -1
  44. package/lib/perf-rules.js +1 -1
  45. package/lib/pod-memory.js +1 -1
  46. package/lib/producer-health.js +1 -1
  47. package/lib/remote-instances.js +1 -1
  48. package/lib/sources.js +1 -1
  49. package/lib/static-checks.js +1 -1
  50. package/lib/system-report.js +1 -1
  51. package/lib/team.js +1 -1
  52. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
- "use strict";var o=Object.defineProperty;var r=(e,t)=>o(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,s=r((e,t)=>d(e,"name",{value:t,configurable:!0}),"i");const n=["neutral","info","success","warning","danger"];export const CANVAS_CHART_TYPES=["bar","line","area","stacked","pie","scatter"],CANVAS_CALLOUT_TYPES=["note","info","tip","warning","danger","success"],CANVAS_COMPONENTS=[{name:"Callout",group:"layout",describe:"A highlighted note.",props:{type:{type:"enum",values:CANVAS_CALLOUT_TYPES,describe:"How it reads: note (default), info, tip, warning, danger, success."},title:{type:"string",describe:"A short heading."}},children:"blocks",example:'<Callout type="warning" title="Before you merge">The migration locks `orders` for about 2 s.</Callout>'},{name:"Details",group:"layout",describe:"A section the person opens.",props:{summary:{type:"string",required:!0,describe:"What the closed section says."},open:{type:"boolean",describe:"Open at first."}},children:"blocks",example:'<Details summary="How it was measured">Three runs on the dev Mac \u2026</Details>'},{name:"Tabs",group:"layout",describe:"Tabs; each child is a `Tab`.",props:{},children:"Tab",example:`<Tabs>
1
+ "use strict";var d=Object.defineProperty;var r=(e,t)=>d(e,"name",{value:t,configurable:!0});var c=Object.defineProperty,s=r((e,t)=>c(e,"name",{value:t,configurable:!0}),"r"),l=Object.defineProperty,n=s((e,t)=>l(e,"name",{value:t,configurable:!0}),"i");const a=["neutral","info","success","warning","danger"];export const CANVAS_CHART_TYPES=["bar","line","area","stacked","pie","scatter"],CANVAS_CALLOUT_TYPES=["note","info","tip","warning","danger","success"],CANVAS_COMPONENTS=[{name:"Callout",group:"layout",describe:"A highlighted note.",props:{type:{type:"enum",values:CANVAS_CALLOUT_TYPES,describe:"How it reads: note (default), info, tip, warning, danger, success."},title:{type:"string",describe:"A short heading."}},children:"blocks",example:'<Callout type="warning" title="Before you merge">The migration locks `orders` for about 2 s.</Callout>'},{name:"Details",group:"layout",describe:"A section the person opens.",props:{summary:{type:"string",required:!0,describe:"What the closed section says."},open:{type:"boolean",describe:"Open at first."}},children:"blocks",example:'<Details summary="How it was measured">Three runs on the dev Mac \u2026</Details>'},{name:"Tabs",group:"layout",describe:"Tabs; each child is a `Tab`.",props:{},children:"Tab",example:`<Tabs>
2
2
  <Tab title="Before">\u2026</Tab>
3
3
  <Tab title="After">\u2026</Tab>
4
4
  </Tabs>`},{name:"Tab",group:"layout",describe:"One tab of a `Tabs`.",props:{title:{type:"string",required:!0,describe:"The tab\u2019s label."}},children:"blocks",parent:"Tabs",example:'<Tab title="After">\u2026</Tab>'},{name:"Columns",group:"layout",describe:"Children side by side (stacked on a narrow screen).",props:{count:{type:"number",describe:"How many columns (2\u20134, default: one per child)."}},children:"blocks",example:`<Columns>
5
5
  <Stat label="p95" value="120 ms" />
6
6
  <Stat label="Errors" value={3} />
7
- </Columns>`},{name:"Badge",group:"layout",describe:"A small label.",props:{tone:{type:"enum",values:n,describe:"Its color."}},children:"text",example:'<Badge tone="success">shipped</Badge>'},{name:"Stat",group:"data",describe:"One number with a label.",props:{label:{type:"string",required:!0,describe:"What it counts."},value:{type:"any",describe:"The value (or `source`)."},source:{type:"source",describe:"Where the value is: a JSON Pointer into the data (`/totals/cost`) or a get."},unit:{type:"string",describe:"Shown after the value."},delta:{type:"any",describe:"A change to show beside it (`+12%`, or a number)."},tone:{type:"enum",values:n,describe:"Its color."}},children:"none",example:'<Stat label="Monthly cost" source="/totals/cost" unit="USD" />'},{name:"Chart",group:"data",describe:"A chart of rows: bar, line, area, stacked, pie, scatter.",props:{type:{type:"enum",values:CANVAS_CHART_TYPES,required:!0,describe:"Which chart."},data:{type:"rows",describe:"Inline rows (or `source`)."},source:{type:"source",describe:"Where the rows are: a JSON Pointer to an array of objects."},x:{type:"string",required:!0,describe:"The key each row\u2019s x (or slice, for pie) is under."},y:{type:"strings",required:!0,describe:"The numeric key(s) to draw: one series each."},title:{type:"string",describe:"A heading."},unit:{type:"string",describe:"The values\u2019 unit."},height:{type:"number",describe:"Pixels (default 260)."}},children:"none",example:'<Chart type="bar" source="/costs/monthly" x="month" y={["cost"]} unit="USD" />'},{name:"Table",group:"data",describe:"Rows as a sortable table (virtualised past 500 rows).",props:{data:{type:"rows",describe:"Inline rows (or `source`)."},source:{type:"source",describe:"A JSON Pointer to an array of objects."},columns:{type:"columns",describe:"Which keys, in order (default: the first row\u2019s)."},title:{type:"string",describe:"A heading."}},children:"none",example:'<Table source="/checks" columns={["name","state","ms"]} />'},{name:"Timeline",group:"data",describe:"Dated events in order.",props:{data:{type:"rows",describe:"Inline events (or `source`): objects with a date and a title."},source:{type:"source",describe:"A JSON Pointer to an array of objects."},date:{type:"string",describe:"The key of each event\u2019s date (default `date`)."},label:{type:"string",describe:"The key of each event\u2019s title (default `title`)."}},children:"none",example:'<Timeline source="/milestones" />'},{name:"TaskRef",group:"reference",describe:"A link to a task.",props:{id:{type:"string",required:!0,literal:!0,describe:"The task id."}},children:"text",example:'<TaskRef id="6f1c\u2026" />'},{name:"GoalRef",group:"reference",describe:"A link to a goal.",props:{id:{type:"string",required:!0,literal:!0,describe:"The goal id."}},children:"text",example:'<GoalRef id="g-42" />'},{name:"CanvasRef",group:"reference",describe:"A link to another canvas.",props:{id:{type:"string",required:!0,literal:!0,describe:"The canvas id (`cv-\u2026`)."}},children:"text",example:'<CanvasRef id="cv-0123456789abcdef" />'},{name:"FileRef",group:"reference",describe:"A link to a file of the project (opened on the Changes page).",props:{path:{type:"string",required:!0,literal:!0,describe:"Repository-relative path."},line:{type:"number",literal:!0,describe:"A line to open at."}},children:"text",example:'<FileRef path="libs/core/src/index.ts" line={12} />'},{name:"Options",group:"decision",describe:"A decision between options, each an `Option` with its own text; the person picks one.",props:{qid:{type:"string",required:!0,describe:"The decision\u2019s id: what the answer is keyed by."},title:{type:"string",required:!0,describe:"The question the options answer."},blocking:{type:"boolean",describe:"Its linked task waits for the answer: no one claims it until it is answered, and its next holder reads the answer. Asked in Team \u203A Inbox like `inbox`, flagged."},inbox:{type:"boolean",describe:"Also ask it in Team \u203A Inbox: it goes to the linked goal's manager first, then the person (no manager on the team, the manager escalates it, its session ends, or 30 minutes pass)."}},children:"Option",interactive:!0,example:`<Options qid="store" title="Where do canvases live?">
7
+ </Columns>`},{name:"Badge",group:"layout",describe:"A small label.",props:{tone:{type:"enum",values:a,describe:"Its color."}},children:"text",example:'<Badge tone="success">shipped</Badge>'},{name:"Stat",group:"data",describe:"One number with a label.",props:{label:{type:"string",required:!0,describe:"What it counts."},value:{type:"any",describe:"The value (or `source`)."},source:{type:"source",describe:"Where the value is: a JSON Pointer into the data (`/totals/cost`) or a get."},unit:{type:"string",describe:"Shown after the value."},delta:{type:"any",describe:"A change to show beside it (`+12%`, or a number)."},tone:{type:"enum",values:a,describe:"Its color."}},children:"none",example:'<Stat label="Monthly cost" source="/totals/cost" unit="USD" />'},{name:"Chart",group:"data",describe:"A chart of rows: bar, line, area, stacked, pie, scatter.",props:{type:{type:"enum",values:CANVAS_CHART_TYPES,required:!0,describe:"Which chart."},data:{type:"rows",describe:"Inline rows (or `source`)."},source:{type:"source",describe:"Where the rows are: a JSON Pointer to an array of objects."},x:{type:"string",required:!0,describe:"The key each row\u2019s x (or slice, for pie) is under."},y:{type:"strings",required:!0,describe:"The numeric key(s) to draw: one series each."},title:{type:"string",describe:"A heading."},unit:{type:"string",describe:"The values\u2019 unit."},height:{type:"number",describe:"Pixels (default 260)."}},children:"none",example:'<Chart type="bar" source="/costs/monthly" x="month" y={["cost"]} unit="USD" />'},{name:"Table",group:"data",describe:"Rows as a sortable table (virtualised past 500 rows).",props:{data:{type:"rows",describe:"Inline rows (or `source`)."},source:{type:"source",describe:"A JSON Pointer to an array of objects."},columns:{type:"columns",describe:"Which keys, in order (default: the first row\u2019s)."},title:{type:"string",describe:"A heading."}},children:"none",example:'<Table source="/checks" columns={["name","state","ms"]} />'},{name:"Timeline",group:"data",describe:"Dated events in order.",props:{data:{type:"rows",describe:"Inline events (or `source`): objects with a date and a title."},source:{type:"source",describe:"A JSON Pointer to an array of objects."},date:{type:"string",describe:"The key of each event\u2019s date (default `date`)."},label:{type:"string",describe:"The key of each event\u2019s title (default `title`)."}},children:"none",example:'<Timeline source="/milestones" />'},{name:"TaskRef",group:"reference",describe:"A link to a task.",props:{id:{type:"string",required:!0,literal:!0,describe:"The task id."}},children:"text",example:'<TaskRef id="6f1c\u2026" />'},{name:"GoalRef",group:"reference",describe:"A link to a goal.",props:{id:{type:"string",required:!0,literal:!0,describe:"The goal id."}},children:"text",example:'<GoalRef id="g-42" />'},{name:"CanvasRef",group:"reference",describe:"A link to another canvas.",props:{id:{type:"string",required:!0,literal:!0,describe:"The canvas id (`cv-\u2026`)."}},children:"text",example:'<CanvasRef id="cv-0123456789abcdef" />'},{name:"FileRef",group:"reference",describe:"A link to a file of the project (opened on the Changes page).",props:{path:{type:"string",required:!0,literal:!0,describe:"Repository-relative path."},line:{type:"number",literal:!0,describe:"A line to open at."}},children:"text",example:'<FileRef path="libs/core/src/index.ts" line={12} />'},{name:"Options",group:"decision",describe:"A decision between options, each an `Option` with its own text; the person picks one.",props:{qid:{type:"string",required:!0,describe:"The decision\u2019s id: what the answer is keyed by."},title:{type:"string",required:!0,describe:"The question the options answer."},blocking:{type:"boolean",describe:"Its linked task waits for the answer: no one claims it until it is answered, and its next holder reads the answer. Asked in Team \u203A Inbox like `inbox`, flagged."},inbox:{type:"boolean",describe:"Also ask it in Team \u203A Inbox: it goes to the linked goal's manager first, then the person (no manager on the team, the manager escalates it, its session ends, or 30 minutes pass)."}},children:"Option",interactive:!0,example:`<Options qid="store" title="Where do canvases live?">
8
8
  <Option id="sqlite" title="One SQLite database" recommended>\u2026</Option>
9
9
  <Option id="files" title="Files per canvas">\u2026</Option>
10
10
  </Options>`},{name:"Option",group:"decision",describe:"One option of an `Options`: its body is the argument for it.",props:{id:{type:"string",required:!0,describe:"The option\u2019s id (the answer\u2019s value)."},title:{type:"string",required:!0,describe:"Its name."},recommended:{type:"boolean",describe:"The one you recommend."}},children:"blocks",parent:"Options",interactive:!0,example:'<Option id="sqlite" title="One SQLite database" recommended>Transactions, one writer \u2026</Option>'},{name:"Question",group:"interactive",describe:"A question the person answers in the document.",props:{qid:{type:"string",required:!0,describe:"Its id: what the answer is keyed by. Letters, digits, `-`, `_`."},kind:{type:"enum",values:["choice","multi","text","number","confirm","approve"],required:!0,describe:"choice (one option), multi (any), text, number, confirm (yes/no), approve (approve / ask for changes)."},title:{type:"string",required:!0,describe:"The question, as the control shows it."},detail:{type:"string",describe:"A line of context under it."},options:{type:"options",describe:'For choice and multi: `[{id, label, detail?}]` or `["A", "B"]`.'},recommended:{type:"string",describe:"The option id you recommend."},blocking:{type:"boolean",describe:"Its linked task waits for the answer: no one claims it until it is answered, and its next holder reads the answer. Asked in Team \u203A Inbox like `inbox`, flagged."},inbox:{type:"boolean",describe:"Also ask it in Team \u203A Inbox: it goes to the linked goal's manager first, then the person (no manager on the team, the manager escalates it, its session ends, or 30 minutes pass)."},required:{type:"boolean",describe:"An answer is needed."},min:{type:"number",describe:"For number: the least."},max:{type:"number",describe:"For number: the most."},placeholder:{type:"string",describe:"For text and number."}},children:"none",interactive:!0,example:'<Question qid="db" kind="choice" title="Which database?" options={["Postgres", "SQLite"]} recommended="sqlite" />'},{name:"Checklist",group:"interactive",describe:"Items the person ticks; each item is its own answer (`qid/itemId`).",props:{qid:{type:"string",required:!0,describe:"Its id."},title:{type:"string",required:!0,describe:"What the list is for."},items:{type:"options",required:!0,describe:'`[{id, label}]` or `["Lint", "Tests"]`.'}},children:"none",interactive:!0,example:'<Checklist qid="release" title="Before release" items={["Changelog", "Docs", "Smoke test"]} />'},{name:"Field",group:"interactive",describe:"One value the person fills in \u2014 or a file or image they attach, in the dashboard's own picker (the frame never sees it). The answer is `{ asset, name }`; canvas_get and canvas_wait name its `file.path`.",props:{qid:{type:"string",required:!0,describe:"Its id."},label:{type:"string",required:!0,describe:"What to fill in."},kind:{type:"enum",values:["text","number","date","file","image"],required:!0,describe:"text, number, date, file (PNG, JPEG, WebP, GIF, JSON, plain text, Markdown, CSV; at most 10 MB) or image (PNG, JPEG, WebP, GIF)."},placeholder:{type:"string",describe:"A hint inside it."},required:{type:"boolean",describe:"An answer is needed."},min:{type:"number",describe:"For number."},max:{type:"number",describe:"For number."}},children:"none",interactive:!0,example:`<Field qid="deadline" label="Ship by" kind="date" />
11
11
  <Field qid="screenshot" label="A screenshot of the error" kind="image" />`},{name:"When",group:"interactive",describe:"Shows its content (follow-up text and questions) once a question is answered so.",props:{qid:{type:"string",required:!0,describe:"The question it follows."},is:{type:"strings",required:!0,describe:'The option id(s) \u2014 or "yes"/"no" for a confirm \u2014 that show it.'}},children:"blocks",interactive:!0,example:`<When qid="db" is="postgres">
12
12
  <Question qid="pg-host" kind="text" title="Which host?" />
13
- </When>`}],CANVAS_COMPONENT_NAMES=CANVAS_COMPONENTS.map(e=>e.name),canvasComponent=s(e=>CANVAS_COMPONENTS.find(t=>t.name===e),"canvasComponent"),CANVAS_FENCES=["mermaid","diff"];export function canvasComponentSchema(e){const t=Object.entries(e.props).map(([a,i])=>`${a}${i.required?"*":""}: ${i.type==="enum"?(i.values??[]).join("|"):i.type}`);return`${e.name} { ${t.join(", ")} }${e.children==="none"?"":` children: ${e.children}`}`}r(canvasComponentSchema,"canvasComponentSchema"),s(canvasComponentSchema,"canvasComponentSchema");export function canvasOptionId(e){const t=e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63);return/^[a-z]/.test(t)?t:`o-${t||"x"}`.slice(0,63)}r(canvasOptionId,"canvasOptionId"),s(canvasOptionId,"canvasOptionId");export const CANVAS_INTERNAL_COMPONENTS=["CanvasBlock","CanvasMermaid","CanvasDiffBlock"];
13
+ </When>`}],CANVAS_COMPONENT_NAMES=CANVAS_COMPONENTS.map(e=>e.name),canvasComponent=n(e=>CANVAS_COMPONENTS.find(t=>t.name===e),"canvasComponent"),CANVAS_FENCES=["mermaid","diff"];export function canvasComponentSchema(e){const t=Object.entries(e.props).map(([o,i])=>`${o}${i.required?"*":""}: ${i.type==="enum"?(i.values??[]).join("|"):i.type}`);return`${e.name} { ${t.join(", ")} }${e.children==="none"?"":` children: ${e.children}`}`}r(canvasComponentSchema,"canvasComponentSchema"),s(canvasComponentSchema,"canvasComponentSchema"),n(canvasComponentSchema,"canvasComponentSchema");export function canvasOptionId(e){const t=e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63);return/^[a-z]/.test(t)?t:`o-${t||"x"}`.slice(0,63)}r(canvasOptionId,"canvasOptionId"),s(canvasOptionId,"canvasOptionId"),n(canvasOptionId,"canvasOptionId");export const CANVAS_INTERNAL_COMPONENTS=["CanvasBlock","CanvasMermaid","CanvasDiffBlock"];
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var a=(t,e)=>r(t,"name",{value:e,configurable:!0});var o=Object.defineProperty,n=a((t,e)=>o(t,"name",{value:e,configurable:!0}),"a");export const CANVAS_CHAT_ENGINES=["model","agent"],CANVAS_CHAT_STATES=["idle","working","stopped","failed"],CANVAS_CHAT_ROW_KINDS=["person","reply","step","version","edit","error","engine"],CANVAS_CHAT_EFFORTS=["low","medium","high","xhigh","max"],isCanvasChatEffort=n(t=>typeof t=="string"&&CANVAS_CHAT_EFFORTS.includes(t),"isCanvasChatEffort");export function canvasChatEfforts(t,e){return t==="model"?e?.provider==="openai"?CANVAS_CHAT_EFFORTS.slice(0,3):CANVAS_CHAT_EFFORTS:e?.client==="codex"?CANVAS_CHAT_EFFORTS.slice(0,4):CANVAS_CHAT_EFFORTS}a(canvasChatEfforts,"canvasChatEfforts"),n(canvasChatEfforts,"canvasChatEfforts");export function canvasChatEffortFor(t,e){const s=e?.effort;if(!isCanvasChatEffort(s))return;const i=canvasChatEfforts(t,e);return i.includes(s)?s:i[i.length-1]}a(canvasChatEffortFor,"canvasChatEffortFor"),n(canvasChatEffortFor,"canvasChatEffortFor");export const CANVAS_CHAT_LIMITS={textChars:8e3,rows:500,title:120},CANVAS_AUTHOR_ROLE="canvas-author",CANVAS_AUTHOR_IDLE_MINUTES=15;export function canvasAuthorText(t){const e=JSON.stringify(t.chat);return["# Your role: canvas author (LensMCP)","",`You write a canvas with a person, in a chat (${t.chat}). Read it with \`canvas_chat { chat: ${e} }\`, change the canvas with \`canvas_write\` (\`chat: ${e}\` on the first, which makes it), say what you did with \`canvas_chat { chat: ${e}, say }\` \u2014 short \u2014 and wait for the next message with \`canvas_wait { on: ["chat"], chat: ${e}, since }\`. Do not change the repository. Stop after ${CANVAS_AUTHOR_IDLE_MINUTES} idle minutes; the person's next message starts you again with the chat so far.`,"",t.canvas?`- The canvas is ${t.canvas}: read it first (\`canvas_get { id: ${JSON.stringify(t.canvas)}, include: ["mdx", "data", "shape"] }\`), then write \`canvas_write { id: ${JSON.stringify(t.canvas)}, chat: ${e}, ifVersion, note }\`.`:`- There is no canvas yet: your first \`canvas_write { chat: ${e}, mdx, data, note }\` makes it and binds it to the chat; write the next versions with its \`id\`.`,"- Read skill://lensmcp-canvas/SKILL.md before you write: the components, the data and its shape, and what the checker refuses.","- What to do is in the person's messages (`kind: \"person\"`). An `edit` row is a version the person saved themselves: read it before you write, and build on it, never over it. Other rows are the chat's record.","- Read the repository and the lens as the canvas needs; change nothing in the repository \u2014 no edits, no commits, no branches. What you make is the canvas.",`- One message, one answer: the version(s) it asks for, one short \`say\`, then \`canvas_wait\` with the \`seq\` you read. Back with nothing new: wait again \u2014 once ${CANVAS_AUTHOR_IDLE_MINUTES} minutes passed with nothing, end.`].join(`
2
- `)}a(canvasAuthorText,"canvasAuthorText"),n(canvasAuthorText,"canvasAuthorText");export function canvasAuthorStart(t){return`The person wrote to you in the canvas chat ${t.chat}: read it with canvas_chat { chat: ${JSON.stringify(t.chat)} } and answer its newest messages, as your role says. (LensMCP launch ${t.launchId}.)`}a(canvasAuthorStart,"canvasAuthorStart"),n(canvasAuthorStart,"canvasAuthorStart");
1
+ "use strict";var i=Object.defineProperty;var e=(a,t)=>i(a,"name",{value:t,configurable:!0});var h=Object.defineProperty,n=e((a,t)=>h(a,"name",{value:t,configurable:!0}),"a"),c=Object.defineProperty,s=n((a,t)=>c(a,"name",{value:t,configurable:!0}),"a");export const CANVAS_CHAT_ENGINES=["model","agent"],CANVAS_CHAT_STATES=["idle","working","stopped","failed"],CANVAS_CHAT_ROW_KINDS=["person","reply","step","version","edit","error","engine"],CANVAS_CHAT_EFFORTS=["low","medium","high","xhigh","max"],isCanvasChatEffort=s(a=>typeof a=="string"&&CANVAS_CHAT_EFFORTS.includes(a),"isCanvasChatEffort");export function canvasChatEfforts(a,t){return a==="model"?t?.provider==="openai"?CANVAS_CHAT_EFFORTS.slice(0,3):CANVAS_CHAT_EFFORTS:t?.client==="codex"?CANVAS_CHAT_EFFORTS.slice(0,4):CANVAS_CHAT_EFFORTS}e(canvasChatEfforts,"canvasChatEfforts"),n(canvasChatEfforts,"canvasChatEfforts"),s(canvasChatEfforts,"canvasChatEfforts");export function canvasChatEffortFor(a,t){const r=t?.effort;if(!isCanvasChatEffort(r))return;const o=canvasChatEfforts(a,t);return o.includes(r)?r:o[o.length-1]}e(canvasChatEffortFor,"canvasChatEffortFor"),n(canvasChatEffortFor,"canvasChatEffortFor"),s(canvasChatEffortFor,"canvasChatEffortFor");export const CANVAS_CHAT_LIMITS={textChars:8e3,rows:500,title:120},CANVAS_AUTHOR_ROLE="canvas-author",CANVAS_AUTHOR_IDLE_MINUTES=15;export function canvasAuthorText(a){const t=JSON.stringify(a.chat);return["# Your role: canvas author (LensMCP)","",`You write a canvas with a person, in a chat (${a.chat}). Read it with \`canvas_chat { chat: ${t} }\`, change the canvas with \`canvas_write\` (\`chat: ${t}\` on the first, which makes it), say what you did with \`canvas_chat { chat: ${t}, say }\` \u2014 short \u2014 and wait for the next message with \`canvas_wait { on: ["chat"], chat: ${t}, since }\`. Do not change the repository. Stop after ${CANVAS_AUTHOR_IDLE_MINUTES} idle minutes; the person's next message starts you again with the chat so far.`,"",a.canvas?`- The canvas is ${a.canvas}: read it first (\`canvas_get { id: ${JSON.stringify(a.canvas)}, include: ["mdx", "data", "shape"] }\`), then write \`canvas_write { id: ${JSON.stringify(a.canvas)}, chat: ${t}, ifVersion, note }\`.`:`- There is no canvas yet: your first \`canvas_write { chat: ${t}, mdx, data, note }\` makes it and binds it to the chat; write the next versions with its \`id\`.`,"- Read skill://lensmcp-canvas/SKILL.md before you write: the components, the data and its shape, and what the checker refuses.","- What to do is in the person's messages (`kind: \"person\"`). An `edit` row is a version the person saved themselves: read it before you write, and build on it, never over it. Other rows are the chat's record.","- Read the repository and the lens as the canvas needs; change nothing in the repository \u2014 no edits, no commits, no branches. What you make is the canvas.",`- One message, one answer: the version(s) it asks for, one short \`say\`, then \`canvas_wait\` with the \`seq\` you read. Back with nothing new: wait again \u2014 once ${CANVAS_AUTHOR_IDLE_MINUTES} minutes passed with nothing, end.`].join(`
2
+ `)}e(canvasAuthorText,"canvasAuthorText"),n(canvasAuthorText,"canvasAuthorText"),s(canvasAuthorText,"canvasAuthorText");export function canvasAuthorStart(a){return`The person wrote to you in the canvas chat ${a.chat}: read it with canvas_chat { chat: ${JSON.stringify(a.chat)} } and answer its newest messages, as your role says. (LensMCP launch ${a.launchId}.)`}e(canvasAuthorStart,"canvasAuthorStart"),n(canvasAuthorStart,"canvasAuthorStart"),s(canvasAuthorStart,"canvasAuthorStart");
@@ -1,4 +1,4 @@
1
- "use strict";var d=Object.defineProperty;var l=(e,n)=>d(e,"name",{value:n,configurable:!0});var u=Object.defineProperty,p=l((e,n)=>u(e,"name",{value:n,configurable:!0}),"c");export function parseCanvasJsonText(e,n){try{return{ok:!0,value:JSON.parse(e)}}catch(r){const a=r instanceof Error?r.message:String(r),i=/\(line (\d+) column (\d+)\)/.exec(a),c=/position (\d+)/.exec(a);let s,o;if(i)s=Number(i[1]),o=Number(i[2]);else if(c){const t=e.slice(0,Number(c[1]));s=t.split(`
2
- `).length,o=t.length-t.lastIndexOf(`
3
- `)}else if(/end of JSON input/i.test(a)){const t=e.split(`
4
- `);s=t.length,o=(t[t.length-1]?.length??0)+1}const m=a.replace(/^SyntaxError:\s*/,"").replace(/\s*\(line \d+ column \d+\)/,"").replace(/,? ?"[^"]{40,}"? is not valid JSON/," is not valid JSON");return{ok:!1,problem:{code:"json",severity:"error",part:n,message:`The ${n} is not JSON: ${m}`,hint:n==="data"?"Data is one JSON value: quote keys and strings, no trailing commas, no comments.":"A shape is a JSON object: quote keys and strings, no trailing commas, no comments.",...s!==void 0?{line:s}:{},...o!==void 0?{column:o}:{}}}}}l(parseCanvasJsonText,"parseCanvasJsonText"),p(parseCanvasJsonText,"parseCanvasJsonText");
1
+ "use strict";var d=Object.defineProperty;var l=(e,n)=>d(e,"name",{value:n,configurable:!0});var p=Object.defineProperty,m=l((e,n)=>p(e,"name",{value:n,configurable:!0}),"l"),v=Object.defineProperty,g=m((e,n)=>v(e,"name",{value:n,configurable:!0}),"c");export function parseCanvasJsonText(e,n){try{return{ok:!0,value:JSON.parse(e)}}catch(r){const o=r instanceof Error?r.message:String(r),i=/\(line (\d+) column (\d+)\)/.exec(o),c=/position (\d+)/.exec(o);let s,a;if(i)s=Number(i[1]),a=Number(i[2]);else if(c){const t=e.slice(0,Number(c[1]));s=t.split(`
2
+ `).length,a=t.length-t.lastIndexOf(`
3
+ `)}else if(/end of JSON input/i.test(o)){const t=e.split(`
4
+ `);s=t.length,a=(t[t.length-1]?.length??0)+1}const u=o.replace(/^SyntaxError:\s*/,"").replace(/\s*\(line \d+ column \d+\)/,"").replace(/,? ?"[^"]{40,}"? is not valid JSON/," is not valid JSON");return{ok:!1,problem:{code:"json",severity:"error",part:n,message:`The ${n} is not JSON: ${u}`,hint:n==="data"?"Data is one JSON value: quote keys and strings, no trailing commas, no comments.":"A shape is a JSON object: quote keys and strings, no trailing commas, no comments.",...s!==void 0?{line:s}:{},...a!==void 0?{column:a}:{}}}}}l(parseCanvasJsonText,"parseCanvasJsonText"),m(parseCanvasJsonText,"parseCanvasJsonText"),g(parseCanvasJsonText,"parseCanvasJsonText");
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;var n=(s,t)=>e(s,"name",{value:t,configurable:!0});var a=Object.defineProperty,o=n((s,t)=>a(s,"name",{value:t,configurable:!0}),"n");export const CANVAS_FRAME_FILE=/^(?:(?:media|chunks)\/)?[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.(html|js|css|woff2|woff|map|svg)$/,CANVAS_FRAME_TYPES={html:"text/html; charset=utf-8",js:"application/javascript; charset=utf-8",css:"text/css; charset=utf-8",woff2:"font/woff2",woff:"font/woff",map:"application/json",svg:"image/svg+xml"},CANVAS_FRAME_ANCESTORS="http://localhost:* http://127.0.0.1:* https://lensmcp.localhost:* https://*.lensmcp.localhost:* https://lensmcp.local:*";export function canvasFrameCsp(s,t=CANVAS_FRAME_ANCESTORS){return["default-src 'none'",`script-src ${s} 'unsafe-eval'`,`style-src ${s} 'unsafe-inline'`,`font-src ${s}`,"img-src data: blob:","connect-src 'none'","frame-src 'none'","form-action 'none'","base-uri 'none'","object-src 'none'","worker-src 'none'","manifest-src 'none'",`frame-ancestors ${t}`].join("; ")}n(canvasFrameCsp,"canvasFrameCsp"),o(canvasFrameCsp,"canvasFrameCsp");
1
+ "use strict";var a=Object.defineProperty;var n=(e,t)=>a(e,"name",{value:t,configurable:!0});var o=Object.defineProperty,s=n((e,t)=>o(e,"name",{value:t,configurable:!0}),"n"),c=Object.defineProperty,r=s((e,t)=>c(e,"name",{value:t,configurable:!0}),"n");export const CANVAS_FRAME_FILE=/^(?:(?:media|chunks)\/)?[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.(html|js|css|woff2|woff|map|svg)$/,CANVAS_FRAME_TYPES={html:"text/html; charset=utf-8",js:"application/javascript; charset=utf-8",css:"text/css; charset=utf-8",woff2:"font/woff2",woff:"font/woff",map:"application/json",svg:"image/svg+xml"},CANVAS_FRAME_ANCESTORS="http://localhost:* http://127.0.0.1:* https://lensmcp.localhost:* https://*.lensmcp.localhost:* https://lensmcp.local:*";export function canvasFrameCsp(e,t=CANVAS_FRAME_ANCESTORS){return["default-src 'none'",`script-src ${e} 'unsafe-eval'`,`style-src ${e} 'unsafe-inline'`,`font-src ${e}`,"img-src data: blob:","connect-src 'none'","frame-src 'none'","form-action 'none'","base-uri 'none'","object-src 'none'","worker-src 'none'","manifest-src 'none'",`frame-ancestors ${t}`].join("; ")}n(canvasFrameCsp,"canvasFrameCsp"),s(canvasFrameCsp,"canvasFrameCsp"),r(canvasFrameCsp,"canvasFrameCsp");
package/lib/canvas-hub.js CHANGED
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var a=(e,t)=>r(e,"name",{value:t,configurable:!0});var s=Object.defineProperty,n=a((e,t)=>s(e,"name",{value:t,configurable:!0}),"t");export const CANVAS_HUB_API="/hub/v1",CANVAS_HUB_ROLES=["read","answer","write","admin"];export function canvasHubRoleAtLeast(e,t){return e?CANVAS_HUB_ROLES.indexOf(e)>=CANVAS_HUB_ROLES.indexOf(t):!1}a(canvasHubRoleAtLeast,"canvasHubRoleAtLeast"),n(canvasHubRoleAtLeast,"canvasHubRoleAtLeast");export const isCanvasHubRole=n(e=>typeof e=="string"&&CANVAS_HUB_ROLES.includes(e),"isCanvasHubRole");
1
+ "use strict";var s=Object.defineProperty;var n=(e,a)=>s(e,"name",{value:a,configurable:!0});var o=Object.defineProperty,t=n((e,a)=>o(e,"name",{value:a,configurable:!0}),"a"),i=Object.defineProperty,r=t((e,a)=>i(e,"name",{value:a,configurable:!0}),"t");export const CANVAS_HUB_API="/hub/v1",CANVAS_HUB_ROLES=["read","answer","write","admin"];export function canvasHubRoleAtLeast(e,a){return e?CANVAS_HUB_ROLES.indexOf(e)>=CANVAS_HUB_ROLES.indexOf(a):!1}n(canvasHubRoleAtLeast,"canvasHubRoleAtLeast"),t(canvasHubRoleAtLeast,"canvasHubRoleAtLeast"),r(canvasHubRoleAtLeast,"canvasHubRoleAtLeast");export const isCanvasHubRole=r(e=>typeof e=="string"&&CANVAS_HUB_ROLES.includes(e),"isCanvasHubRole");
package/lib/canvas.d.ts CHANGED
@@ -865,6 +865,11 @@ export declare const CANVAS_FRAME_PARAMS: {
865
865
  * frame the real heights). One formula on both sides, so the first layout already leaves the control its room.
866
866
  */
867
867
  export declare function canvasSlotHeight(ask: CanvasAsk): number;
868
+ /**
869
+ * An option's label as it is shown: without the colon its author ended it with — `**Free it by hand now:** what it
870
+ * means` reads its bold part as the label, and the label read «Free it by hand now:» everywhere it stood alone.
871
+ */
872
+ export declare function canvasOptionLabel(label: string): string;
868
873
  /** Parent → frame notifications. */
869
874
  export interface CanvasSlotSizes {
870
875
  /** The height the parent's control for each qid needs. */
@@ -954,8 +959,13 @@ export interface DashCanvasInbox {
954
959
  }
955
960
  export interface DashCanvasList {
956
961
  canvases: DashCanvasRow[];
957
- /** The projects this machine knows, for filters and sharing by name. */
962
+ /**
963
+ * The projects worth naming here, for filters and sharing: this one, each that owns or is named by a canvas this
964
+ * project reads, and each other whose folder is still on this machine — not one of a folder long gone.
965
+ */
958
966
  projects: CanvasProjectRef[];
967
+ /** The titles of the tasks and goals the listed canvases link to, by id — what a link is called on the page. */
968
+ linkTitles?: Record<string, string>;
959
969
  /** The project the dashboard serves. */
960
970
  here?: CanvasProjectRef;
961
971
  /**
@@ -982,6 +992,8 @@ export interface DashCanvasList {
982
992
  export interface DashCanvasDetail {
983
993
  canvas: CanvasRecord;
984
994
  project: CanvasProjectRef;
995
+ /** The titles of the tasks and goals it links to, by id, as this dashboard's board knows them. */
996
+ linkTitles?: Record<string, string>;
985
997
  /** The version drawn: `current`, or `lastGood` under tier 2. */
986
998
  shown: number;
987
999
  tier: CanvasTier;
package/lib/canvas.js CHANGED
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var r=(e,t)=>l(e,"name",{value:t,configurable:!0});var A=Object.defineProperty,o=r((e,t)=>A(e,"name",{value:t,configurable:!0}),"o");import{z as a}from"zod";import{TASK_ARTIFACT_MAX_BYTES as p,TASK_ARTIFACTS_MAX as d,TASK_ARTIFACTS_MAX_BYTES as h}from"./canvas-attachments.js";export const CANVAS_FORMAT=1,CANVAS_FRAME_PROTOCOL=1,CANVAS_FRAME_RUNTIME="frame-v1",CANVAS_FRAME_PATH="/v1",CANVAS_FRAME_HOST="lensmcp.canvas.localhost",CANVAS_ID_PATTERN=/^cv-[0-9a-f]{16}$/,CANVAS_PROJECT_ID_PATTERN=/^pr-[0-9a-f]{16}$/,CANVAS_QID_PATTERN=/^[a-z][a-z0-9_-]{0,63}$/i,isCanvasId=o(e=>typeof e=="string"&&CANVAS_ID_PATTERN.test(e),"isCanvasId"),CANVAS_TAG_PATTERN=/^[a-z0-9][a-z0-9-]{0,31}$/,CANVAS_TAG_LIMITS={count:8,chars:32},CANVAS_DESIGN_TAG="design";export function canvasTags(e){if(!Array.isArray(e))return{why:"`tags` is a list of short labels"};const t=[];for(const s of e){if(typeof s!="string")return{why:"`tags` is a list of short labels"};const n=s.trim().replace(/^#+/,"").toLowerCase().replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(n){if(!CANVAS_TAG_PATTERN.test(n))return{why:`\xAB${s.slice(0,40)}\xBB is not a label: lower-case letters, digits and -, at most ${CANVAS_TAG_LIMITS.chars} characters`};t.includes(n)||t.push(n)}}return t.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${t.length}`}:{tags:t}}r(canvasTags,"canvasTags"),o(canvasTags,"canvasTags");export function authoredCanvasTags(e,t=[]){const s=canvasTags(e);if("why"in s)return s;const n=t.includes(CANVAS_DESIGN_TAG);if(!n&&s.tags.includes(CANVAS_DESIGN_TAG))return{why:`\xAB${CANVAS_DESIGN_TAG}\xBB is LensMCP's own label \u2014 the canvas a goal's design is drawn as; pick another`};const i=n&&!s.tags.includes(CANVAS_DESIGN_TAG)?[CANVAS_DESIGN_TAG,...s.tags]:s.tags;return i.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${i.length}`}:{tags:i}}r(authoredCanvasTags,"authoredCanvasTags"),o(authoredCanvasTags,"authoredCanvasTags");export const CANVAS_LIMITS={mdxBytes:256*1024,mdxWholeBytes:64*1024,dataBytes:2*1024*1024,answerBytes:16*1024,questions:500,assets:d,assetBytes:h,assetFileBytes:p,canvasBytes:256*1024*1024,projectBytes:2*1024*1024*1024,titleChars:200,noteChars:2e3,commentChars:8e3,frameMessageBytes:256*1024,snapshotPartChars:96*1024,snapshotParts:96,depth:64,ops:1e3,checkpointEvery:50,checkpointsKept:20,waitDefaultMs:45e3,waitMaxMs:9e5},CANVAS_KINDS=["doc","decision","plan","review","report","dashboard","qa","template"],CANVAS_TEMPLATE_NAMES=["decision-record","plan-review","weekly-report","goal-dashboard","qa-report"],CANVAS_QUESTION_KINDS=["choice","multi","text","number","confirm","approve"],CANVAS_FIELD_KINDS=["text","number","date","file","image"],CANVAS_INTERACTIVE=["Question","Checklist","Field","Options"];export function canvasAnswerKeys(e){return e.kind==="checklist"?(e.items??[]).map(t=>`${e.qid}/${t.id}`):e.kind==="multi"?(e.options??[]).map(t=>`${e.qid}/${t.id}`):[e.qid]}r(canvasAnswerKeys,"canvasAnswerKeys"),o(canvasAnswerKeys,"canvasAnswerKeys");export const canvasQidOf=o(e=>e.split("/")[0]??e,"canvasQidOf"),CANVAS_SHAPE_KEYS=["type","properties","required","items","enum","minimum","maximum","minItems","maxItems","format","additionalProperties","description","derived","$schema","title"],CANVAS_DATA_OPS=["set","remove","move","copy","append"],CANVAS_HEALTH_STATES=["checked","good","broken","unverified"],CANVAS_ANSWER_VIAS=["document","rail","inbox","cli","api","host"],CANVAS_LEDGER_PARTS=["version","data","answer","got","grant","share","archive","delete","comment","health","meta","asset"],CANVAS_OUTSIDE={timeoutMs:1e4,maxBytes:2*1024*1024,redirects:5,perCanvasPerMinute:30,perOriginPerMinute:60,keptPerCanvas:20,keptBytesPerCanvas:8*1024*1024};export function canvasGrantWords(e){return`This canvas could send what it reads to ${e}, or anywhere.`}r(canvasGrantWords,"canvasGrantWords"),o(canvasGrantWords,"canvasGrantWords");export function canvasGrantPrompt(e){return{title:`Let this canvas read ${e}?`,lines:[canvasGrantWords(e),"A site a canvas may read is also a way out: the addresses its versions ask for can carry what its author knows, each read tells the site you opened the canvas, and the site can pass any of it on.","The dashboard fetches it, never the canvas: only the exact URLs a version declares, public addresses only, GET, no cookies, 10 s and 2 MB at most. Revoke it here at any time; the ledger records both."],act:`Approve ${e}`}}r(canvasGrantPrompt,"canvasGrantPrompt"),o(canvasGrantPrompt,"canvasGrantPrompt");export const CANVAS_BROKER_METHODS=["ui/initialize","ui/notifications/size-changed","ui/open-link","canvas/heartbeat","canvas/slots","canvas/focus","canvas/get","canvas/rendered","canvas/problem","canvas/health","canvas/data-changed","canvas/answers-changed","canvas/selection","canvas/copy","canvas/download","canvas/open-ref","canvas/slot-sizes","canvas/theme","canvas/escape","canvas/snapshot-asked","canvas/snapshot","canvas/print"],CANVAS_APP_MIME="text/html;profile=mcp-app",CANVAS_APP_URI_TEMPLATE="ui://canvas/{id}",canvasAppUri=o(e=>`ui://canvas/${e}`,"canvasAppUri"),CANVAS_APP_VIEW_URI="ui://canvas/view",CANVAS_ANSWER_TOOL="canvas_answer",CANVAS_APP_PROTOCOL=1;export function canvasConfirmedAnswers(e){const t=new Map;for(const n of e){if(!n.confirmed)continue;const i=t.get(n.key);(!i||n.seq>i.seq)&&t.set(n.key,n)}const s={};for(const[n,i]of t)i.state==="current"&&(s[n]=i.value);return s}r(canvasConfirmedAnswers,"canvasConfirmedAnswers"),o(canvasConfirmedAnswers,"canvasConfirmedAnswers");export function canvasFrameInit(e){const t=e.detail;return{protocol:CANVAS_FRAME_PROTOCOL,theme:e.theme,tokens:e.tokens,canvas:t.canvas.id,version:t.shown,code:e.code,compiler:e.compiler,contract:t.version.contract,bindings:t.version.bindings,data:t.data,marks:t.marks,answers:canvasConfirmedAnswers(t.answers),got:{},...e.anchor?{anchor:e.anchor}:{},fallback:e.fallback,dir:"auto"}}r(canvasFrameInit,"canvasFrameInit"),o(canvasFrameInit,"canvasFrameInit");const c=a.number(),v=a.object({qid:a.string().max(64),x:c,y:c,width:c.min(0).max(1e4),height:c.min(0).max(1e4),visible:a.boolean()}),m=a.object({message:a.string().max(4e3),block:a.string().max(200).optional(),line:a.number().int().min(0).max(1e6).optional(),column:a.number().int().min(0).max(1e5).optional(),component:a.string().max(100).optional()});export const CANVAS_FRAME_PARAMS={"ui/initialize":a.looseObject({protocol:a.number().int()}),"ui/notifications/size-changed":a.object({height:c.min(0).max(1e6),width:c.min(0).max(1e5).optional()}),"ui/open-link":a.object({url:a.string().max(4e3)}),"canvas/heartbeat":a.object({t:c}),"canvas/slots":a.object({slots:a.array(v).max(CANVAS_LIMITS.questions)}),"canvas/focus":a.object({qid:a.string().max(64)}),"canvas/get":a.object({uri:a.string().max(2e3)}),"canvas/rendered":a.object({ms:c.min(0),blocks:a.number().int().min(0),errors:a.number().int().min(0)}),"canvas/problem":a.object({errors:a.array(m).max(200)}),"canvas/health":a.object({ok:a.boolean(),errors:a.array(m).max(200)}),"canvas/selection":a.object({text:a.string().max(8e3),block:a.string().max(200).optional(),lines:a.tuple([a.number().int(),a.number().int()]).optional()}),"canvas/copy":a.object({text:a.string().max(1024*1024)}),"canvas/download":a.object({name:a.string().max(200),type:a.enum(["csv","json","png","txt","md"]),text:a.string().max(4*1024*1024)}),"canvas/open-ref":a.object({kind:a.enum(["task","goal","file","canvas"]),id:a.string().max(2e3),line:a.number().int().optional()}),"canvas/escape":a.object({}),"canvas/snapshot":a.object({n:a.number().int().min(0),part:a.number().int().min(0).max(CANVAS_LIMITS.snapshotParts-1),parts:a.number().int().min(1).max(CANVAS_LIMITS.snapshotParts),html:a.string().max(CANVAS_LIMITS.snapshotPartChars),dir:a.enum(["ltr","rtl","auto"]).optional()}),"canvas/print":a.object({})};export function canvasSlotHeight(e){const t=40+(e.detail?20:0),s=44;switch(e.kind){case"choice":case"multi":return t+36*Math.max(1,e.options?.length??0)+s;case"checklist":return t+32*Math.max(1,e.items?.length??0);case"confirm":return t+s;case"approve":return t+72+s;case"text":return t+84+s;default:return t+40+s}}r(canvasSlotHeight,"canvasSlotHeight"),o(canvasSlotHeight,"canvasSlotHeight");
1
+ "use strict";var p=Object.defineProperty;var r=(a,t)=>p(a,"name",{value:t,configurable:!0});var A=Object.defineProperty,i=r((a,t)=>A(a,"name",{value:t,configurable:!0}),"r"),v=Object.defineProperty,o=i((a,t)=>v(a,"name",{value:t,configurable:!0}),"o");import{z as e}from"zod";import{TASK_ARTIFACT_MAX_BYTES as d,TASK_ARTIFACTS_MAX as h,TASK_ARTIFACTS_MAX_BYTES as u}from"./canvas-attachments.js";export const CANVAS_FORMAT=1,CANVAS_FRAME_PROTOCOL=1,CANVAS_FRAME_RUNTIME="frame-v1",CANVAS_FRAME_PATH="/v1",CANVAS_FRAME_HOST="lensmcp.canvas.localhost",CANVAS_ID_PATTERN=/^cv-[0-9a-f]{16}$/,CANVAS_PROJECT_ID_PATTERN=/^pr-[0-9a-f]{16}$/,CANVAS_QID_PATTERN=/^[a-z][a-z0-9_-]{0,63}$/i,isCanvasId=o(a=>typeof a=="string"&&CANVAS_ID_PATTERN.test(a),"isCanvasId"),CANVAS_TAG_PATTERN=/^[a-z0-9][a-z0-9-]{0,31}$/,CANVAS_TAG_LIMITS={count:8,chars:32},CANVAS_DESIGN_TAG="design";export function canvasTags(a){if(!Array.isArray(a))return{why:"`tags` is a list of short labels"};const t=[];for(const n of a){if(typeof n!="string")return{why:"`tags` is a list of short labels"};const s=n.trim().replace(/^#+/,"").toLowerCase().replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(s){if(!CANVAS_TAG_PATTERN.test(s))return{why:`\xAB${n.slice(0,40)}\xBB is not a label: lower-case letters, digits and -, at most ${CANVAS_TAG_LIMITS.chars} characters`};t.includes(s)||t.push(s)}}return t.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${t.length}`}:{tags:t}}r(canvasTags,"canvasTags"),i(canvasTags,"canvasTags"),o(canvasTags,"canvasTags");export function authoredCanvasTags(a,t=[]){const n=canvasTags(a);if("why"in n)return n;const s=t.includes(CANVAS_DESIGN_TAG);if(!s&&n.tags.includes(CANVAS_DESIGN_TAG))return{why:`\xAB${CANVAS_DESIGN_TAG}\xBB is LensMCP's own label \u2014 the canvas a goal's design is drawn as; pick another`};const c=s&&!n.tags.includes(CANVAS_DESIGN_TAG)?[CANVAS_DESIGN_TAG,...n.tags]:n.tags;return c.length>CANVAS_TAG_LIMITS.count?{why:`a canvas has at most ${CANVAS_TAG_LIMITS.count} labels; got ${c.length}`}:{tags:c}}r(authoredCanvasTags,"authoredCanvasTags"),i(authoredCanvasTags,"authoredCanvasTags"),o(authoredCanvasTags,"authoredCanvasTags");export const CANVAS_LIMITS={mdxBytes:256*1024,mdxWholeBytes:64*1024,dataBytes:2*1024*1024,answerBytes:16*1024,questions:500,assets:h,assetBytes:u,assetFileBytes:d,canvasBytes:256*1024*1024,projectBytes:2*1024*1024*1024,titleChars:200,noteChars:2e3,commentChars:8e3,frameMessageBytes:256*1024,snapshotPartChars:96*1024,snapshotParts:96,depth:64,ops:1e3,checkpointEvery:50,checkpointsKept:20,waitDefaultMs:45e3,waitMaxMs:9e5},CANVAS_KINDS=["doc","decision","plan","review","report","dashboard","qa","template"],CANVAS_TEMPLATE_NAMES=["decision-record","plan-review","weekly-report","goal-dashboard","qa-report"],CANVAS_QUESTION_KINDS=["choice","multi","text","number","confirm","approve"],CANVAS_FIELD_KINDS=["text","number","date","file","image"],CANVAS_INTERACTIVE=["Question","Checklist","Field","Options"];export function canvasAnswerKeys(a){return a.kind==="checklist"?(a.items??[]).map(t=>`${a.qid}/${t.id}`):a.kind==="multi"?(a.options??[]).map(t=>`${a.qid}/${t.id}`):[a.qid]}r(canvasAnswerKeys,"canvasAnswerKeys"),i(canvasAnswerKeys,"canvasAnswerKeys"),o(canvasAnswerKeys,"canvasAnswerKeys");export const canvasQidOf=o(a=>a.split("/")[0]??a,"canvasQidOf"),CANVAS_SHAPE_KEYS=["type","properties","required","items","enum","minimum","maximum","minItems","maxItems","format","additionalProperties","description","derived","$schema","title"],CANVAS_DATA_OPS=["set","remove","move","copy","append"],CANVAS_HEALTH_STATES=["checked","good","broken","unverified"],CANVAS_ANSWER_VIAS=["document","rail","inbox","cli","api","host"],CANVAS_LEDGER_PARTS=["version","data","answer","got","grant","share","archive","delete","comment","health","meta","asset"],CANVAS_OUTSIDE={timeoutMs:1e4,maxBytes:2*1024*1024,redirects:5,perCanvasPerMinute:30,perOriginPerMinute:60,keptPerCanvas:20,keptBytesPerCanvas:8*1024*1024};export function canvasGrantWords(a){return`This canvas could send what it reads to ${a}, or anywhere.`}r(canvasGrantWords,"canvasGrantWords"),i(canvasGrantWords,"canvasGrantWords"),o(canvasGrantWords,"canvasGrantWords");export function canvasGrantPrompt(a){return{title:`Let this canvas read ${a}?`,lines:[canvasGrantWords(a),"A site a canvas may read is also a way out: the addresses its versions ask for can carry what its author knows, each read tells the site you opened the canvas, and the site can pass any of it on.","The dashboard fetches it, never the canvas: only the exact URLs a version declares, public addresses only, GET, no cookies, 10 s and 2 MB at most. Revoke it here at any time; the ledger records both."],act:`Approve ${a}`}}r(canvasGrantPrompt,"canvasGrantPrompt"),i(canvasGrantPrompt,"canvasGrantPrompt"),o(canvasGrantPrompt,"canvasGrantPrompt");export const CANVAS_BROKER_METHODS=["ui/initialize","ui/notifications/size-changed","ui/open-link","canvas/heartbeat","canvas/slots","canvas/focus","canvas/get","canvas/rendered","canvas/problem","canvas/health","canvas/data-changed","canvas/answers-changed","canvas/selection","canvas/copy","canvas/download","canvas/open-ref","canvas/slot-sizes","canvas/theme","canvas/escape","canvas/snapshot-asked","canvas/snapshot","canvas/print"],CANVAS_APP_MIME="text/html;profile=mcp-app",CANVAS_APP_URI_TEMPLATE="ui://canvas/{id}",canvasAppUri=o(a=>`ui://canvas/${a}`,"canvasAppUri"),CANVAS_APP_VIEW_URI="ui://canvas/view",CANVAS_ANSWER_TOOL="canvas_answer",CANVAS_APP_PROTOCOL=1;export function canvasConfirmedAnswers(a){const t=new Map;for(const s of a){if(!s.confirmed)continue;const c=t.get(s.key);(!c||s.seq>c.seq)&&t.set(s.key,s)}const n={};for(const[s,c]of t)c.state==="current"&&(n[s]=c.value);return n}r(canvasConfirmedAnswers,"canvasConfirmedAnswers"),i(canvasConfirmedAnswers,"canvasConfirmedAnswers"),o(canvasConfirmedAnswers,"canvasConfirmedAnswers");export function canvasFrameInit(a){const t=a.detail;return{protocol:CANVAS_FRAME_PROTOCOL,theme:a.theme,tokens:a.tokens,canvas:t.canvas.id,version:t.shown,code:a.code,compiler:a.compiler,contract:t.version.contract,bindings:t.version.bindings,data:t.data,marks:t.marks,answers:canvasConfirmedAnswers(t.answers),got:{},...a.anchor?{anchor:a.anchor}:{},fallback:a.fallback,dir:"auto"}}r(canvasFrameInit,"canvasFrameInit"),i(canvasFrameInit,"canvasFrameInit"),o(canvasFrameInit,"canvasFrameInit");const l=e.number(),g=e.object({qid:e.string().max(64),x:l,y:l,width:l.min(0).max(1e4),height:l.min(0).max(1e4),visible:e.boolean()}),m=e.object({message:e.string().max(4e3),block:e.string().max(200).optional(),line:e.number().int().min(0).max(1e6).optional(),column:e.number().int().min(0).max(1e5).optional(),component:e.string().max(100).optional()});export const CANVAS_FRAME_PARAMS={"ui/initialize":e.looseObject({protocol:e.number().int()}),"ui/notifications/size-changed":e.object({height:l.min(0).max(1e6),width:l.min(0).max(1e5).optional()}),"ui/open-link":e.object({url:e.string().max(4e3)}),"canvas/heartbeat":e.object({t:l}),"canvas/slots":e.object({slots:e.array(g).max(CANVAS_LIMITS.questions)}),"canvas/focus":e.object({qid:e.string().max(64)}),"canvas/get":e.object({uri:e.string().max(2e3)}),"canvas/rendered":e.object({ms:l.min(0),blocks:e.number().int().min(0),errors:e.number().int().min(0)}),"canvas/problem":e.object({errors:e.array(m).max(200)}),"canvas/health":e.object({ok:e.boolean(),errors:e.array(m).max(200)}),"canvas/selection":e.object({text:e.string().max(8e3),block:e.string().max(200).optional(),lines:e.tuple([e.number().int(),e.number().int()]).optional()}),"canvas/copy":e.object({text:e.string().max(1024*1024)}),"canvas/download":e.object({name:e.string().max(200),type:e.enum(["csv","json","png","txt","md"]),text:e.string().max(4*1024*1024)}),"canvas/open-ref":e.object({kind:e.enum(["task","goal","file","canvas"]),id:e.string().max(2e3),line:e.number().int().optional()}),"canvas/escape":e.object({}),"canvas/snapshot":e.object({n:e.number().int().min(0),part:e.number().int().min(0).max(CANVAS_LIMITS.snapshotParts-1),parts:e.number().int().min(1).max(CANVAS_LIMITS.snapshotParts),html:e.string().max(CANVAS_LIMITS.snapshotPartChars),dir:e.enum(["ltr","rtl","auto"]).optional()}),"canvas/print":e.object({})};export function canvasSlotHeight(a){if(a.component==="Options"&&a.kind==="choice")return 26+40*Math.ceil(Math.max(1,a.options?.length??0)/2);const t=40+(a.detail?20:0),n=44;switch(a.kind){case"choice":case"multi":return t+36*Math.max(1,a.options?.length??0)+n;case"checklist":return t+32*Math.max(1,a.items?.length??0);case"confirm":return t+n;case"approve":return t+72+n;case"text":return t+84+n;default:return t+40+n}}r(canvasSlotHeight,"canvasSlotHeight"),i(canvasSlotHeight,"canvasSlotHeight"),o(canvasSlotHeight,"canvasSlotHeight");export function canvasOptionLabel(a){return a.replace(/\s*[::]+\s*$/u,"")||a}r(canvasOptionLabel,"canvasOptionLabel"),i(canvasOptionLabel,"canvasOptionLabel"),o(canvasOptionLabel,"canvasOptionLabel");
@@ -1 +1 @@
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
+ "use strict";var s=Object.defineProperty;var a=(r,e)=>s(r,"name",{value:e,configurable:!0});var p=Object.defineProperty,c=a((r,e)=>p(r,"name",{value:e,configurable:!0}),"o"),u=Object.defineProperty,E=c((r,e)=>u(r,"name",{value:e,configurable:!0}),"s");export const CAPTURE_REQUEST_FILENAME="capture-request.json",CAPTURE_PRESENCE_FILENAME="capture-runner.json";export function appMatchesPage(r,e){const t=r.trim().toLowerCase();if(!t)return!1;if(e.project&&e.project.toLowerCase()===t)return!0;const o=e.url.toLowerCase();if(o===t||o.replace(/\/+$/,"")===t.replace(/\/+$/,""))return!0;try{const n=new URL(e.url);return/^\d+$/.test(t)?n.port===t:n.origin.toLowerCase()===t.replace(/\/+$/,"")}catch{return!1}}a(appMatchesPage,"appMatchesPage"),c(appMatchesPage,"appMatchesPage"),E(appMatchesPage,"appMatchesPage");export const CAPTURE_RULES_FILENAME="capture-rules.json";
@@ -1 +1 @@
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");
1
+ "use strict";var d=Object.defineProperty;var t=(e,n)=>d(e,"name",{value:n,configurable:!0});var a=Object.defineProperty,c=t((e,n)=>a(e,"name",{value:n,configurable:!0}),"c"),g=Object.defineProperty,o=c((e,n)=>g(e,"name",{value:n,configurable:!0}),"t");const p={"~":"~~","/":"~s","\\":"~b","\0":"~0"},l={"~":"~",s:"/",b:"\\",0:"\0",d:"."},m=/%2f|%5c|%2e|%00/i;export function encodeSegment(e){return e==="."||e===".."?e.replace(/\./g,"~d"):encodeURIComponent(e.replace(/[~/\\\0]/g,n=>p[n])).replace(/%3A/g,":").replace(/%40/g,"@")}t(encodeSegment,"encodeSegment"),c(encodeSegment,"encodeSegment"),o(encodeSegment,"encodeSegment");export function decodeSegment(e){let n;try{n=decodeURIComponent(e)}catch{n=e}return m.test(e)?n:n.replace(/~([~sb0d])/g,(u,r)=>l[r])}t(decodeSegment,"decodeSegment"),c(decodeSegment,"decodeSegment"),o(decodeSegment,"decodeSegment");
@@ -1 +1 @@
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)}}
1
+ "use strict";var O=Object.defineProperty;var m=(e,o)=>O(e,"name",{value:o,configurable:!0});var B=Object.defineProperty,b=m((e,o)=>B(e,"name",{value:o,configurable:!0}),"m"),I=Object.defineProperty,c=b((e,o)=>I(e,"name",{value:o,configurable:!0}),"c");import{CONTAINER_OOM as k,DOCKER_ENGINE_LOST as g,DOCKER_RUN_FIELD as N}from"./docker-jobs.js";import{joinId as E}from"./error-cause.js";const _=200,f=50,$=c(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),h=c(e=>{if(typeof e!="string")return;const o=e.trim();return o?o.slice(0,_):void 0},"name"),p=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,"someMb"),C=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,"anyMb"),w=c(e=>Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0)),"defined"),D=c(e=>{if(!$(e))return;const o=h(e.peer);if(!o)return;const n=h(e.name);return n?{peer:o,name:n}:{peer:o}},"hostOf"),M=c(e=>e.name??e.peer,"hostWord");export function readDockerError(e){if($(e)){if(e.kind===k)return w({kind:k,run:h(e.run),job:h(e.job),service:h(e.service),container:h(e.container),seen:e.seen==="event"||e.seen==="inspect"?e.seen:void 0,limitMb:p(e.limitMb),peakMb:p(e.peakMb),budgetMb:p(e.budgetMb),context:h(e.context),host:D(e.host)});if(e.kind===g){const o=new Map;for(const r of Array.isArray(e.runs)?e.runs:[]){const i=$(r)?h(r.run):h(r),t=$(r)?h(r.job):void 0;i&&!o.has(i)&&o.size<f&&o.set(i,{run:i,...t?{job:t}:{}})}const n=Array.isArray(e.killed)?[...new Set(e.killed.map(h).filter(r=>!!r))].slice(0,f):[];return w({kind:g,context:h(e.context),runs:[...o.values()],why:h(e.why),vmTotalMb:p(e.vmTotalMb),vmAvailableMb:C(e.vmAvailableMb),killed:n.length?n:void 0,host:D(e.host)})}}}m(readDockerError,"readDockerError"),b(readDockerError,"readDockerError"),c(readDockerError,"readDockerError");export function dockerErrorRuns(e){return e.kind===k?e.run?[e.run]:[]:e.runs.map(o=>o.run)}m(dockerErrorRuns,"dockerErrorRuns"),b(dockerErrorRuns,"dockerErrorRuns"),c(dockerErrorRuns,"dockerErrorRuns");export function dockerRunOfEvent(e){return $(e)?h(e[N]):void 0}m(dockerRunOfEvent,"dockerRunOfEvent"),b(dockerRunOfEvent,"dockerRunOfEvent"),c(dockerRunOfEvent,"dockerRunOfEvent");export const CONTAINER_OOM_ERROR="ContainerOOMKilled",DOCKER_ENGINE_LOST_ERROR="DockerEngineLost";const L=256,a=c(e=>`${Math.round(e)} MiB`,"mib");function x(e){const o=`${e.service??"a container"} ran out of memory in ${e.job??"a Docker job"}`,n=`${e.service?`\xAB${e.service}\xBB`:"A container"} ran out of memory and was killed, in ${e.job?`the Docker job \xAB${e.job}\xBB`:"a Docker job"}${e.host?` on the worker \xAB${M(e.host)}\xBB`:""}`,r=e.job?`\`${e.budgetMb!==void 0&&e.service?`jobs.${e.job}.budget.services.${e.service}`:`jobs.${e.job}.budget`}\` in lensmcp.json`:"its job's budget in lensmcp.json \u2192 jobs",{limitMb:i,peakMb:t,budgetMb:s}=e;let l;if(i!==void 0&&s!==void 0){const d=Math.round(i)-Math.round(s);l=d>0?`It was killed at its ${a(i)} limit \u2014 ${a(d)} over the ${a(s)} it declares. Raise ${r} to what it takes (more than ${a(i)}), and the container's memory limit with it.`:d===0?`It was killed at its ${a(i)} limit, which is all it declares. Raise ${r} to what it takes, and the container's memory limit with it.`:`It was killed at its ${a(i)} limit, ${a(-d)} under the ${a(s)} it declares. Raise the container's memory limit to its budget (${r}) \u2014 and both, if it takes more.`}else if(i!==void 0)l=`It was killed at its ${a(i)} limit. Raise the limit, and ${r}, to what it takes.`;else if(t!==void 0&&s!==void 0){const d=Math.round(t)-Math.round(s);l=d>0?`It held ${a(t)} at its peak \u2014 ${a(d)} over the ${a(s)} it declares. Raise ${r} to what it takes, so the queue lets the job in only when Docker's VM has that much.`:`It held ${a(t)} at its peak, within the ${a(s)} it declares (${r}): it was killed at a lower limit of its own, or when Docker's VM ran out. Check its memory limit in the compose file, and what else the VM held.`}else t!==void 0?l=`It held ${a(t)} at its peak. Check ${r} against that, and the container's memory limit.`:s!==void 0?l=`Its peak was not sampled. It declares ${a(s)}: raise ${r} to what it takes, and the container's memory limit with it.`:l=`Raise ${r} to what the service takes, and the container's memory limit with it.`;const u=[i!==void 0?`killed at its ${a(i)} limit`:"killed for memory",t!==void 0?`peak ${a(t)}`:void 0,s!==void 0?`budget ${a(s)}`:void 0,e.run?`run ${e.run}`:void 0,e.seen==="inspect"?"found by the inspect at the run's end":void 0,e.host?`on the worker ${M(e.host)}`:void 0,e.context?`Docker context ${e.context}`:void 0];return{cause:{id:E("cause",[CONTAINER_OOM_ERROR,e.job,e.service]),errorName:CONTAINER_OOM_ERROR,message:o},title:`${CONTAINER_OOM_ERROR}: ${o}`,headline:n,hint:l,facts:u.filter(Boolean).join(" \xB7 "),where:e.job?`Docker job ${e.job}`:"Docker"}}m(x,"y"),b(x,"A"),c(x,"oomWords");function y(e){const o=e.host?` on the worker ${M(e.host)}`:"",n=`Docker stopped answering${e.context?` (context ${e.context})`:""}${o}`,r=[...new Set(e.runs.map(v=>v.job).filter(v=>!!v))],i=e.runs.length,t=e.host?`Docker on the worker \xAB${M(e.host)}\xBB`:"Docker",s=i===0?`${t} stopped answering while LensMCP ran work in it`:i===1?`${t} stopped answering while ${r[0]?`the job \xAB${r[0]}\xBB`:"a job"} ran: its containers went with it`:`${t} stopped answering while ${i} runs were in it${r.length?` (${r.map(v=>`\xAB${v}\xBB`).join(", ")})`:""}: their containers went with it`,{vmTotalMb:l,vmAvailableMb:u}=e,d=u===void 0?void 0:`${a(u)} free${l!==void 0?` of ${a(l)}`:""}`,j=u===void 0?"If nobody stopped it, its VM most likely ran out of memory: compare the jobs' budgets in lensmcp.json with what Docker's VM has.":u<=L?`Its VM had ${d} when it was last read: it most likely ran out of memory. Let less in at once (the jobs' budgets in lensmcp.json decide), or give Docker's VM more.`:`Its VM had ${d} when it was last read, so memory is not the likely reason: was Docker stopped or restarted?`,A=[i?`${i} run${i===1?"":"s"} lost: ${e.runs.map(v=>`${v.job??"a job"} (run ${v.run})`).join(", ")}`:void 0,e.why,d?`VM ${d}`:void 0,e.killed?.length?`killed for memory before it went: ${e.killed.join(", ")}`:void 0];return{cause:{id:E("cause",e.host?[DOCKER_ENGINE_LOST_ERROR,e.context,e.host.peer]:[DOCKER_ENGINE_LOST_ERROR,e.context]),errorName:DOCKER_ENGINE_LOST_ERROR,message:n},title:`${DOCKER_ENGINE_LOST_ERROR}: ${n}`,headline:s,hint:`Start Docker again${o} and run ${i>1?"the jobs":"the job"} again: a run lost with the engine has no result. ${j}`,facts:A.filter(Boolean).join(" \xB7 "),where:`${e.context?`Docker context ${e.context}`:"Docker"}${o}`}}m(y,"E"),b(y,"I"),c(y,"engineWords");export function dockerErrorWords(e){return e.kind===k?x(e):y(e)}m(dockerErrorWords,"dockerErrorWords"),b(dockerErrorWords,"dockerErrorWords"),c(dockerErrorWords,"dockerErrorWords");export function mergeDockerError(e,o){if(e.kind===k){if(o.kind!==k)return e;const t=Math.max(e.peakMb??0,o.peakMb??0);return w({...o,...e,seen:e.seen==="event"||o.seen==="event"?"event":e.seen??o.seen,peakMb:t>0?t:void 0})}const n=e;if(o.kind===k)return o.service&&!n.killed?.includes(o.service)?{...n,killed:[...n.killed??[],o.service].slice(0,f)}:e;const r=new Map(n.runs.map(t=>[t.run,t]));for(const t of o.runs)(!r.has(t.run)||!r.get(t.run).job&&t.job)&&r.set(t.run,t);const i=[...new Set([...n.killed??[],...o.killed??[]])];return w({...o,...n,runs:[...r.values()].slice(0,f),vmAvailableMb:n.vmAvailableMb!==void 0&&o.vmAvailableMb!==void 0?Math.min(n.vmAvailableMb,o.vmAvailableMb):n.vmAvailableMb??o.vmAvailableMb,killed:i.length?i:void 0})}m(mergeDockerError,"mergeDockerError"),b(mergeDockerError,"mergeDockerError"),c(mergeDockerError,"mergeDockerError");export const DOCKER_ENGINE_LOSS_SAME_MS=6e4;const R=2e3,S=200;export class DockerErrorLedger{static{m(this,"DockerErrorLedger")}static{b(this,"DockerErrorLedger")}static{c(this,"DockerErrorLedger")}constructor(){this.kills=new Map,this.losses=new Map,this.lostRuns=new Map}account(o,n,r){if(o.kind===g){const l=o.host?`${o.host.peer}\0${o.context??""}`:o.context??"",u=this.losses.get(l),d=u&&Math.abs(r-u.at)<=DOCKER_ENGINE_LOSS_SAME_MS?u.told:void 0;d||this.remember(this.losses,l,{told:n,at:r},S);for(const j of o.runs)this.remember(this.lostRuns,j.run,d??n,R);return d}const i=o.seen!=="inspect",t=o.run&&o.container?`${o.run}\0${o.container}`:o.run&&o.service?`${o.run}\0\0${o.service}`:void 0,s=t?this.kills.get(t):void 0;if(!s){const l=!i&&o.run?this.lostRuns.get(o.run):void 0;if(l)return l;t&&this.remember(this.kills,t,{told:n,live:i?1:0},R);return}if(!i)return s.told;if(s.live===0)return s.live=1,s.told;s.live+=1,s.told=n}remember(o,n,r,i){o.delete(n),o.set(n,r),o.size>i&&o.delete(o.keys().next().value)}}
@@ -1 +1 @@
1
- "use strict";var R=Object.defineProperty;var i=(e,s)=>R(e,"name",{value:s,configurable:!0});var w=Object.defineProperty,n=i((e,s)=>w(e,"name",{value:s,configurable:!0}),"s");export const DOCKER_LABELS={run:"com.lensmcp.run",home:"com.lensmcp.home",job:"com.lensmcp.job",probe:"com.lensmcp.probe"},LENS_JOB_KINDS=["compose","testcontainers","playwright"];export function neverShipped(e){const s=(e.split("/").at(-1)??"").toLowerCase();return s===".env"||s===".env.local"||/^\.env\..+\.local$/.test(s)}i(neverShipped,"neverShipped"),n(neverShipped,"neverShipped");export const jobInputFiles=n(e=>[...new Set(e.inputs?.files??[])].sort(),"jobInputFiles"),jobMintedFiles=n(e=>[...new Set(e.inputs?.minted??[])].sort(),"jobMintedFiles"),DEFAULT_LINK_LOSS_MINUTES=15,jobProblemText=n(e=>e.job===void 0?e.problem:`jobs.${e.job}: ${e.problem}`,"jobProblemText");const M=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","onLinkLoss","nx","budget"],$={compose:[...M,"compose"],testcontainers:M,playwright:[...M,"stack"]},L={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},_=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,N=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,k=1024*1024,f=360,b=100,x=4e3,l=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),E=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=k,"isMb"),I=n(e=>e.map(s=>`"${s}"`).join(", "),"quoted");export function linkLossProblem(e){if(e==="cancel")return;const s=l(e)&&Object.keys(e).length===1?e.continueMinutes:void 0;if(!(typeof s=="number"&&Number.isInteger(s)&&s>=1&&s<=f))return`onLinkLoss is "cancel" or { "continueMinutes": 1 to ${f} }`}i(linkLossProblem,"linkLossProblem"),n(linkLossProblem,"linkLossProblem");export function linkLossMinutes(e,s,t=e.timeoutMinutes){const o=s??e.onLinkLoss??{continueMinutes:DEFAULT_LINK_LOSS_MINUTES};return o==="cancel"?0:Math.min(o.continueMinutes,Math.ceil(t??f))}i(linkLossMinutes,"linkLossMinutes"),n(linkLossMinutes,"linkLossMinutes");function v(e){return typeof e!="string"||!e||e.length>500||/[\0\\]/.test(e)||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:/.test(e)?!1:!e.split("/").includes("..")}i(v,"y"),n(v,"inTree");function y(e){return Array.isArray(e)&&e.length>=1&&e.length<=b&&e.every(s=>typeof s=="string"&&s.length<=x)&&e[0]!==""}i(y,"k"),n(y,"isArgv");function m(e,s,t,o){const c=Object.keys(e).filter(a=>!s.includes(a));c.length&&o.push(`${t?`${t} has`:"has"} ${c.length===1?"an unknown key":"unknown keys"} ${I(c)}`)}i(m,"m"),n(m,"unknownKeys");function S(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>b||!e.every(v))&&t.push(`${s} is a list of paths inside the checkout`)}i(S,"$"),n(S,"paths");function j(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>b||!e.every(v))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const c=o.split("/");c.some(a=>a===""||a===".")?t.push(`${s} names ${JSON.stringify(o)}: a file is written as git names it \u2014 a/b.json, with no ./, no // and no trailing /`):c.some(a=>a.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}i(j,"N"),n(j,"inputPaths");function A(e){if(!l(e))return["is not an object"];const s=e.kind;if(!LENS_JOB_KINDS.includes(s))return[`kind is ${LENS_JOB_KINDS.slice(0,-1).join(", ")} or ${LENS_JOB_KINDS.at(-1)}`];const t=[];m(e,$[s],"",t),e.lane!==void 0&&e.lane!=="light"&&e.lane!=="heavy"&&t.push("lane is light or heavy"),y(e.command)||t.push("command is a program and its arguments, as a list of strings \u2014 not a shell line"),e.cleanup!==void 0&&!y(e.cleanup)&&t.push("cleanup is a program and its arguments, as a list of strings"),e.prepare!==void 0&&!(Array.isArray(e.prepare)&&e.prepare.length<=b&&e.prepare.every(y))&&t.push("prepare is a list of steps, each a program and its arguments"),e.report!==void 0&&!["jest","vitest","playwright"].includes(e.report)&&t.push("report is jest, vitest or playwright"),S(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=f)&&t.push(`timeoutMinutes is execution minutes, up to ${f}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false");const o=e.onLinkLoss,c=o===void 0?void 0:linkLossProblem(o);c?t.push(c):l(o)&&typeof e.timeoutMinutes=="number"&&o.continueMinutes>e.timeoutMinutes&&t.push(`onLinkLoss.continueMinutes is past timeoutMinutes (${e.timeoutMinutes}): a run goes on through a dropped link no longer than it may run`),e.nx!==void 0&&!(typeof e.nx=="string"&&/^\S+:[^\s:]+$/.test(e.nx))&&t.push("nx is <project>:<target>");const a=e.inputs;if(a!==void 0)if(!l(a))t.push("inputs is an object of files, minted and secrets");else{m(a,["files","minted","secrets"],"inputs",t);const r=j(a.files,"inputs.files",t),d=j(a.minted,"inputs.minted",t);for(const h of r)neverShipped(h)&&t.push(`inputs.files names ${h}, which is never shipped to another Mac \u2014 declare it in inputs.minted, and make it in a prepare step`);const u=[...new Set(r.filter(h=>d.includes(h)))];u.length&&t.push(`inputs names ${u.join(", ")} in files and in minted: a file is shipped by hash, or made per run on the host that runs it \u2014 not both`);const g=a.secrets;g!==void 0&&!(Array.isArray(g)&&g.length<=b&&g.every(h=>typeof h=="string"&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(h)))&&t.push("inputs.secrets is a list of variable names, never values")}const p=e.budget;if(!l(p))t.push("has no budget: the memory it declares is what it is admitted by");else{m(p,L[s],"budget",t);for(const r of["buildMb","hostMb","vmMb"])L[s].includes(r)&&p[r]!==void 0&&!E(p[r])&&t.push(`budget.${r} is MiB, a whole number from 1 to ${k}`);if(s==="testcontainers"&&(p.vmMb===void 0||p.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&p.vmMb===void 0&&p.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const r=p.services;if(!l(r)||!Object.keys(r).length)t.push("budget.services is each service's expected peak, MiB, by its name in the compose files");else for(const[d,u]of Object.entries(r))N.test(d)?E(u)||t.push(`budget.services.${d} is MiB, a whole number from 1 to ${k}`):t.push(`budget.services has "${d}", which is no service name`)}}if(s==="compose"){const r=e.compose;if(!l(r))t.push("compose is an object of files and edge");else{m(r,["files","edge"],"compose",t);const d=r.files;(!Array.isArray(d)||!d.length||d.length>b||!d.every(v))&&t.push("compose.files is the compose files, as paths inside the checkout");const u=r.edge;u!==void 0&&(!l(u)||typeof u.service!="string"||!N.test(u.service)||!Number.isInteger(u.port)||u.port<1||u.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(m(u,["service","port"],"compose.edge",t),l(p)&&l(p.services)&&!Object.hasOwn(p.services,u.service)&&t.push(`${u.service} has no budget`)))}}return s==="playwright"&&e.stack!==void 0&&!(typeof e.stack=="string"&&_.test(e.stack))&&t.push("stack is the name of a compose job of this file"),t}i(A,"j"),n(A,"jobProblems");export function readLensJobs(e){const s={jobs:{},problems:[]};if(e===void 0)return s;if(!l(e))return s.problems.push({problem:"jobs is an object of jobs by name"}),s;for(const[t,o]of Object.entries(e)){if(!_.test(t)){s.problems.push({job:t,problem:"a job's name is letters, digits, dots, dashes and underscores \u2014 63 at most, the first a letter or a digit"});continue}const c=A(o);c.length?s.problems.push(...c.map(a=>({job:t,problem:a}))):s.jobs[t]=o}for(const[t,o]of Object.entries(s.jobs))o.kind!=="playwright"||o.stack===void 0||s.jobs[o.stack]?.kind!=="compose"&&(s.problems.push({job:t,problem:`stack names "${o.stack}", which is no compose job of this file that may run`}),delete s.jobs[t]);return s}i(readLensJobs,"readLensJobs"),n(readLensJobs,"readLensJobs");const O=n(e=>Object.values(e).reduce((s,t)=>s+t,0),"sum");export function jobVmNeedMb(e,s={}){if(e.kind==="compose")return Math.max(e.budget.buildMb??0,O(e.budget.services));if(e.kind==="testcontainers")return e.budget.vmMb;const t=e.budget.vmMb??0,o=e.stack===void 0?void 0:s[e.stack];return o?.kind==="compose"?Math.max(o.budget.buildMb??0,O(o.budget.services)+t):t}i(jobVmNeedMb,"jobVmNeedMb"),n(jobVmNeedMb,"jobVmNeedMb");export function jobHostNeedMb(e,s={}){const t=e.budget.hostMb??0,o=e.kind==="playwright"&&e.stack!==void 0?s[e.stack]:void 0;return t+(o?.kind==="compose"?o.budget.hostMb??0:0)}i(jobHostNeedMb,"jobHostNeedMb"),n(jobHostNeedMb,"jobHostNeedMb");export function jobLane(e){return e.lane?e.lane:e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"heavy":"light"}i(jobLane,"jobLane"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}i(unbudgetedServices,"unbudgetedServices"),n(unbudgetedServices,"unbudgetedServices");export const RUN_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/;export function runShortId(e){const s=e.toLowerCase().replace(/^[a-z]+_/,"").replace(/[^a-z0-9]/g,"").slice(0,8);return s.length===8?s:void 0}i(runShortId,"runShortId"),n(runShortId,"runShortId");export const composeProjectOf=n(e=>`lensmcp-${e}`,"composeProjectOf"),DOCKER_RUN_ENV={id:"LENSMCP_RUN_ID",origin:"LENSMCP_RUN_ORIGIN",artifacts:"LENSMCP_RUN_ARTIFACTS",labels:"LENSMCP_RUN_LABELS",override:"LENSMCP_COMPOSE_OVERRIDE",project:"COMPOSE_PROJECT_NAME"};export function dockerRunLabels(e){return{[DOCKER_LABELS.run]:e.id,[DOCKER_LABELS.home]:e.home,[DOCKER_LABELS.job]:e.job}}i(dockerRunLabels,"dockerRunLabels"),n(dockerRunLabels,"dockerRunLabels");export const runLabelsEnv=n(e=>JSON.stringify(e),"runLabelsEnv");export function jobRunScope(e){return e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"stack":jobVmNeedMb(e)>0?"containers":"none"}i(jobRunScope,"jobRunScope"),n(jobRunScope,"jobRunScope");export const RYUK_DISABLED_ENV="TESTCONTAINERS_RYUK_DISABLED",RYUK_LABEL="org.testcontainers.ryuk";export function ryukWarning(e,s){const t=s[RYUK_DISABLED_ENV];if(!(e.kind!=="testcontainers"||t===void 0||t.trim().toLowerCase()!=="true"))return`${RYUK_DISABLED_ENV}=${t.trim()} is set in the job's environment: testcontainers' own reaper (Ryuk) is off, so a container the suite leaves is removed only where it carries the run's labels \u2014 hand ${DOCKER_RUN_ENV.labels} to every container it starts. One that does not carry them stays in Docker's VM: LensMCP never removes it, and nothing else does.`}i(ryukWarning,"ryukWarning"),n(ryukWarning,"ryukWarning");export const MAX_RUN_ROUTE_SEC=14400,DOCKER_RUN_ENDS=["passed","failed","cancelled","timeout","errored","lost"],dockerRunEnded=n(e=>DOCKER_RUN_ENDS.includes(e),"dockerRunEnded"),MAX_RUN_STRANGERS=20,MAX_RUN_KILLS=100,CONTAINER_OOM="container-oom",DOCKER_ENGINE_LOST="docker-engine-lost",DOCKER_RUN_FIELD="dockerRun";
1
+ "use strict";var w=Object.defineProperty;var i=(e,s)=>w(e,"name",{value:s,configurable:!0});var $=Object.defineProperty,r=i((e,s)=>$(e,"name",{value:s,configurable:!0}),"i"),x=Object.defineProperty,n=r((e,s)=>x(e,"name",{value:s,configurable:!0}),"s");export const DOCKER_LABELS={run:"com.lensmcp.run",home:"com.lensmcp.home",job:"com.lensmcp.job",probe:"com.lensmcp.probe"},LENS_JOB_KINDS=["compose","testcontainers","playwright"];export function neverShipped(e){const s=(e.split("/").at(-1)??"").toLowerCase();return s===".env"||s===".env.local"||/^\.env\..+\.local$/.test(s)}i(neverShipped,"neverShipped"),r(neverShipped,"neverShipped"),n(neverShipped,"neverShipped");export const jobInputFiles=n(e=>[...new Set(e.inputs?.files??[])].sort(),"jobInputFiles"),jobMintedFiles=n(e=>[...new Set(e.inputs?.minted??[])].sort(),"jobMintedFiles"),DEFAULT_LINK_LOSS_MINUTES=15,jobProblemText=n(e=>e.job===void 0?e.problem:`jobs.${e.job}: ${e.problem}`,"jobProblemText");const j=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","onLinkLoss","nx","budget"],I={compose:[...j,"compose"],testcontainers:j,playwright:[...j,"stack"]},S={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},E=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,R=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,L=1024*1024,g=360,f=100,C=4e3,l=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),A=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=L,"isMb"),P=n(e=>e.map(s=>`"${s}"`).join(", "),"quoted");export function linkLossProblem(e){if(e==="cancel")return;const s=l(e)&&Object.keys(e).length===1?e.continueMinutes:void 0;if(!(typeof s=="number"&&Number.isInteger(s)&&s>=1&&s<=g))return`onLinkLoss is "cancel" or { "continueMinutes": 1 to ${g} }`}i(linkLossProblem,"linkLossProblem"),r(linkLossProblem,"linkLossProblem"),n(linkLossProblem,"linkLossProblem");export function linkLossMinutes(e,s,t=e.timeoutMinutes){const o=s??e.onLinkLoss??{continueMinutes:DEFAULT_LINK_LOSS_MINUTES};return o==="cancel"?0:Math.min(o.continueMinutes,Math.ceil(t??g))}i(linkLossMinutes,"linkLossMinutes"),r(linkLossMinutes,"linkLossMinutes"),n(linkLossMinutes,"linkLossMinutes");function v(e){return typeof e!="string"||!e||e.length>500||/[\0\\]/.test(e)||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:/.test(e)?!1:!e.split("/").includes("..")}i(v,"v"),r(v,"y"),n(v,"inTree");function y(e){return Array.isArray(e)&&e.length>=1&&e.length<=f&&e.every(s=>typeof s=="string"&&s.length<=C)&&e[0]!==""}i(y,"y"),r(y,"k"),n(y,"isArgv");function m(e,s,t,o){const p=Object.keys(e).filter(u=>!s.includes(u));p.length&&o.push(`${t?`${t} has`:"has"} ${p.length===1?"an unknown key":"unknown keys"} ${P(p)}`)}i(m,"m"),r(m,"m"),n(m,"unknownKeys");function _(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>f||!e.every(v))&&t.push(`${s} is a list of paths inside the checkout`)}i(_,"S"),r(_,"$"),n(_,"paths");function k(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>f||!e.every(v))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const p=o.split("/");p.some(u=>u===""||u===".")?t.push(`${s} names ${JSON.stringify(o)}: a file is written as git names it \u2014 a/b.json, with no ./, no // and no trailing /`):p.some(u=>u.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}i(k,"j"),r(k,"N"),n(k,"inputPaths");function N(e){if(!l(e))return["is not an object"];const s=e.kind;if(!LENS_JOB_KINDS.includes(s))return[`kind is ${LENS_JOB_KINDS.slice(0,-1).join(", ")} or ${LENS_JOB_KINDS.at(-1)}`];const t=[];m(e,I[s],"",t),e.lane!==void 0&&e.lane!=="light"&&e.lane!=="heavy"&&t.push("lane is light or heavy"),y(e.command)||t.push("command is a program and its arguments, as a list of strings \u2014 not a shell line"),e.cleanup!==void 0&&!y(e.cleanup)&&t.push("cleanup is a program and its arguments, as a list of strings"),e.prepare!==void 0&&!(Array.isArray(e.prepare)&&e.prepare.length<=f&&e.prepare.every(y))&&t.push("prepare is a list of steps, each a program and its arguments"),e.report!==void 0&&!["jest","vitest","playwright"].includes(e.report)&&t.push("report is jest, vitest or playwright"),_(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=g)&&t.push(`timeoutMinutes is execution minutes, up to ${g}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false");const o=e.onLinkLoss,p=o===void 0?void 0:linkLossProblem(o);p?t.push(p):l(o)&&typeof e.timeoutMinutes=="number"&&o.continueMinutes>e.timeoutMinutes&&t.push(`onLinkLoss.continueMinutes is past timeoutMinutes (${e.timeoutMinutes}): a run goes on through a dropped link no longer than it may run`),e.nx!==void 0&&!(typeof e.nx=="string"&&/^\S+:[^\s:]+$/.test(e.nx))&&t.push("nx is <project>:<target>");const u=e.inputs;if(u!==void 0)if(!l(u))t.push("inputs is an object of files, minted and secrets");else{m(u,["files","minted","secrets"],"inputs",t);const a=k(u.files,"inputs.files",t),b=k(u.minted,"inputs.minted",t);for(const h of a)neverShipped(h)&&t.push(`inputs.files names ${h}, which is never shipped to another Mac \u2014 declare it in inputs.minted, and make it in a prepare step`);const c=[...new Set(a.filter(h=>b.includes(h)))];c.length&&t.push(`inputs names ${c.join(", ")} in files and in minted: a file is shipped by hash, or made per run on the host that runs it \u2014 not both`);const M=u.secrets;M!==void 0&&!(Array.isArray(M)&&M.length<=f&&M.every(h=>typeof h=="string"&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(h)))&&t.push("inputs.secrets is a list of variable names, never values")}const d=e.budget;if(!l(d))t.push("has no budget: the memory it declares is what it is admitted by");else{m(d,S[s],"budget",t);for(const a of["buildMb","hostMb","vmMb"])S[s].includes(a)&&d[a]!==void 0&&!A(d[a])&&t.push(`budget.${a} is MiB, a whole number from 1 to ${L}`);if(s==="testcontainers"&&(d.vmMb===void 0||d.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&d.vmMb===void 0&&d.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const a=d.services;if(!l(a)||!Object.keys(a).length)t.push("budget.services is each service's expected peak, MiB, by its name in the compose files");else for(const[b,c]of Object.entries(a))R.test(b)?A(c)||t.push(`budget.services.${b} is MiB, a whole number from 1 to ${L}`):t.push(`budget.services has "${b}", which is no service name`)}}if(s==="compose"){const a=e.compose;if(!l(a))t.push("compose is an object of files and edge");else{m(a,["files","edge"],"compose",t);const b=a.files;(!Array.isArray(b)||!b.length||b.length>f||!b.every(v))&&t.push("compose.files is the compose files, as paths inside the checkout");const c=a.edge;c!==void 0&&(!l(c)||typeof c.service!="string"||!R.test(c.service)||!Number.isInteger(c.port)||c.port<1||c.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(m(c,["service","port"],"compose.edge",t),l(d)&&l(d.services)&&!Object.hasOwn(d.services,c.service)&&t.push(`${c.service} has no budget`)))}}return s==="playwright"&&e.stack!==void 0&&!(typeof e.stack=="string"&&E.test(e.stack))&&t.push("stack is the name of a compose job of this file"),t}i(N,"A"),r(N,"j"),n(N,"jobProblems");export function readLensJobs(e){const s={jobs:{},problems:[]};if(e===void 0)return s;if(!l(e))return s.problems.push({problem:"jobs is an object of jobs by name"}),s;for(const[t,o]of Object.entries(e)){if(!E.test(t)){s.problems.push({job:t,problem:"a job's name is letters, digits, dots, dashes and underscores \u2014 63 at most, the first a letter or a digit"});continue}const p=N(o);p.length?s.problems.push(...p.map(u=>({job:t,problem:u}))):s.jobs[t]=o}for(const[t,o]of Object.entries(s.jobs))o.kind!=="playwright"||o.stack===void 0||s.jobs[o.stack]?.kind!=="compose"&&(s.problems.push({job:t,problem:`stack names "${o.stack}", which is no compose job of this file that may run`}),delete s.jobs[t]);return s}i(readLensJobs,"readLensJobs"),r(readLensJobs,"readLensJobs"),n(readLensJobs,"readLensJobs");const O=n(e=>Object.values(e).reduce((s,t)=>s+t,0),"sum");export function jobVmNeedMb(e,s={}){if(e.kind==="compose")return Math.max(e.budget.buildMb??0,O(e.budget.services));if(e.kind==="testcontainers")return e.budget.vmMb;const t=e.budget.vmMb??0,o=e.stack===void 0?void 0:s[e.stack];return o?.kind==="compose"?Math.max(o.budget.buildMb??0,O(o.budget.services)+t):t}i(jobVmNeedMb,"jobVmNeedMb"),r(jobVmNeedMb,"jobVmNeedMb"),n(jobVmNeedMb,"jobVmNeedMb");export function jobHostNeedMb(e,s={}){const t=e.budget.hostMb??0,o=e.kind==="playwright"&&e.stack!==void 0?s[e.stack]:void 0;return t+(o?.kind==="compose"?o.budget.hostMb??0:0)}i(jobHostNeedMb,"jobHostNeedMb"),r(jobHostNeedMb,"jobHostNeedMb"),n(jobHostNeedMb,"jobHostNeedMb");export function jobLane(e){return e.lane?e.lane:e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"heavy":"light"}i(jobLane,"jobLane"),r(jobLane,"jobLane"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}i(unbudgetedServices,"unbudgetedServices"),r(unbudgetedServices,"unbudgetedServices"),n(unbudgetedServices,"unbudgetedServices");export const RUN_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/;export function runShortId(e){const s=e.toLowerCase().replace(/^[a-z]+_/,"").replace(/[^a-z0-9]/g,"").slice(0,8);return s.length===8?s:void 0}i(runShortId,"runShortId"),r(runShortId,"runShortId"),n(runShortId,"runShortId");export const composeProjectOf=n(e=>`lensmcp-${e}`,"composeProjectOf"),DOCKER_RUN_ENV={id:"LENSMCP_RUN_ID",origin:"LENSMCP_RUN_ORIGIN",artifacts:"LENSMCP_RUN_ARTIFACTS",labels:"LENSMCP_RUN_LABELS",override:"LENSMCP_COMPOSE_OVERRIDE",project:"COMPOSE_PROJECT_NAME"};export function dockerRunLabels(e){return{[DOCKER_LABELS.run]:e.id,[DOCKER_LABELS.home]:e.home,[DOCKER_LABELS.job]:e.job}}i(dockerRunLabels,"dockerRunLabels"),r(dockerRunLabels,"dockerRunLabels"),n(dockerRunLabels,"dockerRunLabels");export const runLabelsEnv=n(e=>JSON.stringify(e),"runLabelsEnv");export function jobRunScope(e){return e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"stack":jobVmNeedMb(e)>0?"containers":"none"}i(jobRunScope,"jobRunScope"),r(jobRunScope,"jobRunScope"),n(jobRunScope,"jobRunScope");export const RYUK_DISABLED_ENV="TESTCONTAINERS_RYUK_DISABLED",RYUK_LABEL="org.testcontainers.ryuk";export function ryukWarning(e,s){const t=s[RYUK_DISABLED_ENV];if(!(e.kind!=="testcontainers"||t===void 0||t.trim().toLowerCase()!=="true"))return`${RYUK_DISABLED_ENV}=${t.trim()} is set in the job's environment: testcontainers' own reaper (Ryuk) is off, so a container the suite leaves is removed only where it carries the run's labels \u2014 hand ${DOCKER_RUN_ENV.labels} to every container it starts. One that does not carry them stays in Docker's VM: LensMCP never removes it, and nothing else does.`}i(ryukWarning,"ryukWarning"),r(ryukWarning,"ryukWarning"),n(ryukWarning,"ryukWarning");export const MAX_RUN_ROUTE_SEC=14400,DOCKER_RUN_ENDS=["passed","failed","cancelled","timeout","errored","lost"],dockerRunEnded=n(e=>DOCKER_RUN_ENDS.includes(e),"dockerRunEnded"),MAX_RUN_STRANGERS=20,MAX_RUN_KILLS=100,CONTAINER_OOM="container-oom",DOCKER_ENGINE_LOST="docker-engine-lost",DOCKER_RUN_FIELD="dockerRun";
@@ -1,2 +1,2 @@
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} ?? '{}'))`,i=e.startedAt!==void 0&&e.watch?.inspected!==void 0&&!e.engineLost&&!(e.services??[]).length;i&&t.push(`LensMCP saw no container with the run's labels while it ran: it watched none and removed none. If the job starts containers, ${o}.`);const a=e.strangers;if(a?.containers.length){const n=a.containers.length+(a.more??0),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: ${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. `+(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.")+(i?"":` If the job started ${n===1?"it":"them"}, ${o}.`))}else e.strangersNote&&t.push(`LensMCP cannot say which containers without the run's labels came up while it ran: ${e.strangersNote}.`);return t}h(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const o=k(e.state),i=(e.services??[]).map(l=>{const s=l.budgetMb===void 0?0:l.peakMb-l.budgetMb;return{...l,...s>0?{overMb:s}:{},...l.peakMb>0?{}:{unsampled:!0}}}).sort((l,s)=>(s.overMb??0)-(l.overMb??0)||s.peakMb-l.peakMb||l.name.localeCompare(s.name)),a=i.filter(l=>l.budgetMb!==void 0),n=e.startedAt===void 0?void 0:Math.max(0,(e.endedAt??t)-e.startedAt),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:i,totals:{lastMb:i.reduce((l,s)=>l+s.lastMb,0),...a.length?{budgetMb:a.reduce((l,s)=>l+(s.budgetMb??0),0)}:{}},kills:e.kills??[],...e.killsMore?{killsMore:e.killsMore}:{},...e.engineLost?{engineLost:e.engineLost}:{},...e.vm?{vm:e.vm}:{},...e.cleanup?{cleanup:e.cleanup}:{},...e.warnings?.length?{warnings:e.warnings}:{},...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,i)=>Math.max(...e.map(a=>(a[i]??"").length)));return e.map(o=>o.map((i,a)=>a===0?i.padEnd(t[a]):a===o.length-1?i:i.padStart(t[a])).join(" ").trimEnd())}h(f,"k"),u(f,"table");export function dockerRunReportText(e){const{run:t,vm:o,watch:i,cleanup:a}=e,n=[`Docker run ${t.id} \u2014 job \xAB${t.job}\xBB (${t.kind}), ${t.project?`Compose project ${t.project}`:t.scope==="none"?"nothing in Docker":"no Compose project: its containers by the run's labels"}`,` ${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=i?.samples?`${$(i.samples,"sample","samples")}${i.sampledAt!==void 0?`, the last at ${d(i.sampledAt)}`:""}`:"no sample was taken";if(n.push(t.scope==="none"?"Memory: the job declares nothing in Docker's VM \u2014 its commands were given no labels, and Docker was not asked about it.":`Memory by service, MiB \u2014 ${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(""),a?a.done?n.push(`Cleanup: by ${a.by==="project"?"the project's own end (LensMCP looked, and found nothing)":a.by} at ${d(a.at)} \u2014 nothing of the run is left`):n.push(`Cleanup: OWED (${a.by}, ${d(a.at)}) \u2014 ${a.why??"something that carries the run's labels is left"}${a.left?.length?` \u2014 left: ${a.left.join(", ")}`:""}`):n.push(t.ended?"Cleanup: not recorded \u2014 its guard, or the sweep, has it":"Cleanup: not yet \u2014 the run has not ended"),a?.unlabeled?.length&&n.push(` in its Compose project without the run's labels, never removed: ${a.unlabeled.join(", ")}`);for(const s of e.unlabeled??[])n.push(` ${s}`);if(i?.notes?.length||i?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),i.streamRestarts&&n.push(` the live stream ended ${$(i.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const s of i.notes??[])n.push(` ${s}`)}return n.push(""),n.push(`Files: ${[e.files.samples?`samples ${e.files.samples}`:void 0,e.files.events?`events ${e.files.events}`:void 0,`log ${e.files.log}`].filter(Boolean).join(" \xB7 ")}`),n.join(`
2
- `)}h(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
1
+ "use strict";var w=Object.defineProperty;var c=(e,t)=>w(e,"name",{value:t,configurable:!0});var k=Object.defineProperty,p=c((e,t)=>k(e,"name",{value:t,configurable:!0}),"h"),x=Object.defineProperty,u=p((e,t)=>x(e,"name",{value:t,configurable:!0}),"u");import{DOCKER_RUN_ENV as f,dockerRunEnded as j,RYUK_DISABLED_ENV as A}from"./docker-jobs.js";export function runUnlabeledWords(e){if(e.scope!=="containers")return[];const t=[],o=`hand ${f.labels} to each container it starts \u2014 a JSON object of labels: .withLabels(JSON.parse(process.env.${f.labels} ?? '{}'))`,i=e.startedAt!==void 0&&e.watch?.inspected!==void 0&&!e.engineLost&&!(e.services??[]).length;i&&t.push(`LensMCP saw no container with the run's labels while it ran: it watched none and removed none. If the job starts containers, ${o}.`);const a=e.strangers;if(a?.containers.length){const n=a.containers.length+(a.more??0),h=(e.warnings??[]).some(l=>l.startsWith(A));t.push(`${n} container${n===1?"":"s"} without the run's labels came up while it ran and ${n===1?"is":"are"} still there: ${a.containers.join(", ")}${a.more?` and ${a.more} more`:""}. LensMCP cannot tell whether this run started ${n===1?"it":"them"} \u2014 Docker does not say who starts a container \u2014 and ${n===1?"does not remove it":"removes none of them"}: only what carries the run's labels is the run's. `+(h?"testcontainers' own reaper is off, so nothing else removes what a suite left either.":"Where testcontainers' own reaper is on, it removes what a suite left.")+(i?"":` If the job started ${n===1?"it":"them"}, ${o}.`))}else e.strangersNote&&t.push(`LensMCP cannot say which containers without the run's labels came up while it ran: ${e.strangersNote}.`);return t}c(runUnlabeledWords,"runUnlabeledWords"),p(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const o=j(e.state),i=(e.services??[]).map(l=>{const s=l.budgetMb===void 0?0:l.peakMb-l.budgetMb;return{...l,...s>0?{overMb:s}:{},...l.peakMb>0?{}:{unsampled:!0}}}).sort((l,s)=>(s.overMb??0)-(l.overMb??0)||s.peakMb-l.peakMb||l.name.localeCompare(s.name)),a=i.filter(l=>l.budgetMb!==void 0),n=e.startedAt===void 0?void 0:Math.max(0,(e.endedAt??t)-e.startedAt),h=runUnlabeledWords(e);return{run:{id:e.id,job:e.job,kind:e.kind,state:e.state,ended:o,scope:e.scope??"stack",project:e.project,root:e.root,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.note?{note:e.note}:{},...e.url?{url:e.url}:{},...e.origin?{origin:e.origin}:{},...e.urlNote?{urlNote:e.urlNote}:{},createdAt:e.createdAt,...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...n!==void 0?{ranMs:n}:{},...e.exit?{exit:e.exit}:{}},services:i,totals:{lastMb:i.reduce((l,s)=>l+s.lastMb,0),...a.length?{budgetMb:a.reduce((l,s)=>l+(s.budgetMb??0),0)}:{}},kills:e.kills??[],...e.killsMore?{killsMore:e.killsMore}:{},...e.engineLost?{engineLost:e.engineLost}:{},...e.vm?{vm:e.vm}:{},...e.cleanup?{cleanup:e.cleanup}:{},...e.warnings?.length?{warnings:e.warnings}:{},...h.length?{unlabeled:h}:{},...e.watch?{watch:e.watch}:{},files:{...e.files.samples?{samples:e.files.samples}:{},...e.files.events?{events:e.files.events}:{},log:e.files.log,artifacts:e.files.artifacts}}}c(dockerRunReport,"dockerRunReport"),p(dockerRunReport,"dockerRunReport"),u(dockerRunReport,"dockerRunReport");const d=u(e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),"when"),M=u(e=>{const t=Math.round(e/1e3);if(t<60)return`${t} s`;const o=Math.floor(t/60);return o<60?`${o} min${t%60?` ${t%60} s`:""}`:`${Math.floor(o/60)} h${o%60?` ${o%60} min`:""}`},"lasted"),$=u((e,t,o)=>`${e} ${e===1?t:o}`,"plural");export{d as dockerTime,M as dockerLasted};function g(e){const t=e.exit?e.exit.signal?`its command was ended by ${e.exit.signal}`:`its command exited ${e.exit.code}`:void 0,o=[e.ranMs!==void 0?`${e.ended?"ran":"running for"} ${M(e.ranMs)}`:void 0,e.startedAt!==void 0?`started ${d(e.startedAt)}`:`created ${d(e.createdAt)}`,e.endedAt!==void 0?`ended ${d(e.endedAt)}`:void 0].filter(Boolean).join(", ");return`${{starting:"starting: nothing of the job has run yet",preparing:"preparing: its prepare steps run",running:"running",cleaning:`cleaning up${t?`: ${t}`:""}`,passed:`passed${t?`: ${t}`:""}`,failed:`failed${t?`: ${t}`:""}`,cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:`lost: its runner died, so nobody knows how it would have ended${t?` (${t})`:""}`}[e.state]} \xB7 ${o}`}c(g,"v"),p(g,"w"),u(g,"stateText");function v(e){const t=e[0].map((o,i)=>Math.max(...e.map(a=>(a[i]??"").length)));return e.map(o=>o.map((i,a)=>a===0?i.padEnd(t[a]):a===o.length-1?i:i.padStart(t[a])).join(" ").trimEnd())}c(v,"f"),p(v,"k"),u(v,"table");export function dockerRunReportText(e){const{run:t,vm:o,watch:i,cleanup:a}=e,n=[`Docker run ${t.id} \u2014 job \xAB${t.job}\xBB (${t.kind}), ${t.project?`Compose project ${t.project}`:t.scope==="none"?"nothing in Docker":"no Compose project: its containers by the run's labels"}`,` ${g(t)}`,` in ${t.root}${t.context?` \xB7 Docker context ${t.context}`:""}`];t.stage&&n.push(` stage: ${t.stage}`),t.note&&n.push(` ${t.note}`);for(const s of e.warnings??[])n.push(` ! ${s}`);t.url?n.push(` URL: ${t.url}`):t.urlNote&&n.push(` no URL: ${t.urlNote}`),n.push("");const h=i?.samples?`${$(i.samples,"sample","samples")}${i.sampledAt!==void 0?`, the last at ${d(i.sampledAt)}`:""}`:"no sample was taken";if(n.push(t.scope==="none"?"Memory: the job declares nothing in Docker's VM \u2014 its commands were given no labels, and Docker was not asked about it.":`Memory by service, MiB \u2014 ${h}`),e.services.length){const s=u(r=>r===void 0?"\u2013":String(r),"figure"),b=u(r=>[r.overMb!==void 0?`OVER its budget by ${r.overMb}`:void 0,r.oomKilled?"killed for memory":void 0,r.exitCode!==void 0?`exit ${r.exitCode}`:void 0,r.unsampled?"never sampled":void 0].filter(Boolean).join(" \xB7 "),"remark");n.push(...v([["service","now","peak","budget","limit",""],...e.services.map(r=>[r.name,r.unsampled?"\u2013":String(r.lastMb),r.unsampled?"\u2013":String(r.peakMb),s(r.budgetMb),s(r.limitMb),b(r)]),["all",String(e.totals.lastMb),"",s(e.totals.budgetMb),"",""]]).map(r=>` ${r}`));const m=e.services.filter(r=>r.overMb!==void 0);m.length&&n.push(` ${$(m.length,"service","services")} over what ${m.length===1?"it declares":"they declare"}: raise \`jobs.${t.job}.budget.services\` in lensmcp.json to what ${m.length===1?"it takes":"they take"} \u2014 the queue lets the job in by these figures.`)}else t.scope!=="none"&&n.push(" No container of the run was seen.");n.push("");const l=e.kills.length+(e.killsMore??0);n.push(l?`Killed for memory: ${l}`:"Killed for memory: none");for(const s of e.kills){const b=[s.limitMb!==void 0?`at its ${s.limitMb} MiB limit`:"no limit of its own: the VM ran out, or it was not read",s.peakMb!==void 0?`peak ${s.peakMb} MiB`:"never sampled",s.budgetMb!==void 0?`budget ${s.budgetMb} MiB`:void 0,s.seen==="event"?"seen live":"found by the inspect: the live stream did not tell it"].filter(Boolean).join(" \xB7 ");n.push(` ${d(s.at)} ${s.service}${s.name?` (${s.name})`:""} ${b}`)}if(e.killsMore&&n.push(` \u2026 and ${e.killsMore} more, not listed`),e.engineLost){const s=e.engineLost;n.push(""),n.push(`Docker stopped answering at ${d(s.at)} \u2014 ${s.why}`),s.backAt!==void 0&&n.push(` it answered again at ${d(s.backAt)}`),s.killed?.length&&n.push(` found killed for memory once it was gone: ${s.killed.join(", ")} \u2014 they went with the engine`)}o&&(n.push(""),n.push(`Docker's VM: ${o.totalMb} MiB \xB7 ${o.read==="estimate"?"about ":""}${o.availableAtAdmissionMb} MiB free when the run was let in (${o.read==="estimate"?"an estimate: its own figure could not be read":"the VM's own figure"})`+(o.minAvailableMb!==void 0?` \xB7 lowest ${o.minAvailableMb} MiB while it ran`:" \xB7 not read while it ran")+(o.lastAvailableMb!==void 0?` \xB7 ${o.lastAvailableMb} MiB at the last read${o.sampledAt!==void 0?` (${d(o.sampledAt)})`:""}`:""))),n.push(""),a?a.done?n.push(`Cleanup: by ${a.by==="project"?"the project's own end (LensMCP looked, and found nothing)":a.by} at ${d(a.at)} \u2014 nothing of the run is left`):n.push(`Cleanup: OWED (${a.by}, ${d(a.at)}) \u2014 ${a.why??"something that carries the run's labels is left"}${a.left?.length?` \u2014 left: ${a.left.join(", ")}`:""}`):n.push(t.ended?"Cleanup: not recorded \u2014 its guard, or the sweep, has it":"Cleanup: not yet \u2014 the run has not ended"),a?.unlabeled?.length&&n.push(` in its Compose project without the run's labels, never removed: ${a.unlabeled.join(", ")}`);for(const s of e.unlabeled??[])n.push(` ${s}`);if(i?.notes?.length||i?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),i.streamRestarts&&n.push(` the live stream ended ${$(i.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const s of i.notes??[])n.push(` ${s}`)}return n.push(""),n.push(`Files: ${[e.files.samples?`samples ${e.files.samples}`:void 0,e.files.events?`events ${e.files.events}`:void 0,`log ${e.files.log}`].filter(Boolean).join(" \xB7 ")}`),n.join(`
2
+ `)}c(dockerRunReportText,"dockerRunReportText"),p(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
@@ -1,3 +1,3 @@
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
+ "use strict";var w=Object.defineProperty;var u=(n,e)=>w(n,"name",{value:e,configurable:!0});var A=Object.defineProperty,a=u((n,e)=>A(n,"name",{value:e,configurable:!0}),"u"),M=Object.defineProperty,i=a((n,e)=>M(n,"name",{value:e,configurable:!0}),"l");import{dockerLasted as $,dockerRunReport as x,dockerTime as h}from"./docker-report.js";export function dockerRunStanding(n){return n.run.ended?n.cleanup?.done===!0?"ended":"owed":"up"}u(dockerRunStanding,"dockerRunStanding"),a(dockerRunStanding,"dockerRunStanding"),i(dockerRunStanding,"dockerRunStanding");export function dockerRunsList(n,e={}){const o=e.now??Date.now(),r=n.map(k=>{const c=x(k,o),g=dockerRunStanding(c);return{...c,standing:g,...g==="up"&&e.runnerGone?.(k)?{runnerGone:!0}:{}}}),d=i(k=>r.filter(c=>c.standing===k).sort((c,g)=>(g.run.endedAt??g.run.startedAt??g.run.createdAt)-(c.run.endedAt??c.run.startedAt??c.run.createdAt)||c.run.id.localeCompare(g.run.id)),"of"),t=d("up"),l=d("owed"),s=d("ended"),p=e.all?s.slice(0,e.endedMax??s.length):[];return{counts:{up:t.length,owed:l.length,ended:s.length},all:e.all===!0,...e.all&&p.length<s.length?{endedMore:s.length-p.length}:{},runs:[...t,...l,...p]}}u(dockerRunsList,"dockerRunsList"),a(dockerRunsList,"dockerRunsList"),i(dockerRunsList,"dockerRunsList");const L={starting:"starting",preparing:"preparing",running:"running",cleaning:"cleaning up",passed:"passed",failed:"failed",cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:"lost"};export const dockerStateWord=i(n=>L[n],"dockerStateWord");export function dockerRunSince(n){const{run:e}=n;return e.ended?e.endedAt??e.startedAt??e.createdAt:e.startedAt??e.createdAt}u(dockerRunSince,"dockerRunSince"),a(dockerRunSince,"dockerRunSince"),i(dockerRunSince,"dockerRunSince");export function dockerRunHolds(n){if(n.services.some(e=>!e.unsampled))return n.totals.budgetMb===void 0?`${n.totals.lastMb} MiB`:`${n.totals.lastMb} of ${n.totals.budgetMb} MiB`}u(dockerRunHolds,"dockerRunHolds"),a(dockerRunHolds,"dockerRunHolds"),i(dockerRunHolds,"dockerRunHolds");export const RUNNER_GONE="its runner is gone: nothing runs it any more \u2014 its guard, or the sweep, writes its end and takes its stack down";export function dockerRunRemarks(n){const e=[];n.runnerGone&&!n.run.ended&&e.push(RUNNER_GONE);const o=n.services.filter(l=>l.overMb!==void 0);o.length&&e.push(`OVER its budget: ${o.map(l=>`${l.name} by ${l.overMb} MiB`).join(", ")}`);const r=n.kills.length+(n.killsMore??0),d=[...new Set(n.kills.map(l=>l.service))];r&&e.push(`killed for memory: ${r}${d.length?` (${d.join(", ")})`:""}`),n.engineLost&&e.push(`Docker stopped answering at ${h(n.engineLost.at)}${n.engineLost.backAt!==void 0?`, and answered again at ${h(n.engineLost.backAt)}`:""}`);const{cleanup:t}=n;return n.run.ended&&!t?e.push("cleanup OWED: none is recorded \u2014 its guard, or the sweep, has it"):t&&!t.done&&e.push(`cleanup OWED: ${t.why??"something that carries the run's labels is left"}${t.left?.length?` \u2014 left: ${t.left.join(", ")}`:""}`),t?.unlabeled?.length&&e.push(`in its Compose project without the run's labels, never removed: ${t.unlabeled.join(", ")}`),e}u(dockerRunRemarks,"dockerRunRemarks"),a(dockerRunRemarks,"dockerRunRemarks"),i(dockerRunRemarks,"dockerRunRemarks");function R(n){const{run:e}=n,o=dockerRunSince(n),r=e.ended?`ended ${h(o)}${e.ranMs!==void 0?` after ${$(e.ranMs)}`:""}`:e.startedAt!==void 0?`for ${$(e.ranMs??0)}, since ${h(o)}`:`since ${h(o)}`,d=n.standing==="up"?dockerRunHolds(n):void 0,t=[[e.job,`${dockerStateWord(e.state)}${n.standing==="owed"?", cleanup OWED":n.runnerGone?", its runner GONE":""}`,r,...d?[`holds ${d}`]:[],e.id].join(" ")];e.stage&&!e.ended&&t.push(` stage: ${e.stage}`),e.url?t.push(` URL: ${e.url}`):e.urlNote&&!e.ended&&t.push(` no URL: ${e.urlNote}`),e.note&&t.push(` ${e.note}`);for(const l of dockerRunRemarks(n))t.push(` ${l}`);return t}u(R,"$"),a(R,"R"),i(R,"runLines");const v=i((n,e,o)=>`${n} ${n===1?e:o}`,"plural");export function dockerRunsText(n){const{counts:e}=n;if(!(e.up+e.owed+e.ended))return["This home's registry holds no Docker run.","A job is declared in the checkout's lensmcp.json \u2192 jobs, and started with `lensmcp docker run <job>`."].join(`
2
+ `);const o=e.ended?` \xB7 ${v(e.ended,"ended one is","ended ones are")} kept${n.all?"":" (--all lists them)"}`:"",r=[`Docker runs of this home \u2014 ${e.up} up, ${e.owed?`${v(e.owed,"owes","owe")} a cleanup`:"none owes a cleanup"}${o}`];n.runs.length||r.push(" Nothing of this home is in Docker now.");for(const d of n.runs)r.push(...R(d).map(t=>` ${t}`));return n.endedMore&&r.push(` \u2026 and ${n.endedMore} more ended, not listed`),e.owed&&r.push("","A cleanup that is owed is taken by the run's guard, then by the sweep: `lensmcp docker sweep --dry-run` says what one would take down."),r.join(`
3
+ `)}u(dockerRunsText,"dockerRunsText"),a(dockerRunsText,"dockerRunsText"),i(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const j=8,b=300,m=i(n=>n.length>b?`${n.slice(0,b-1)}\u2026`:n,"cut"),f=i(n=>n?.length?n.slice(0,j).map(e=>e.slice(0,120)):void 0,"names");export function dockerRunBlock(n){const{run:e,cleanup:o,engineLost:r}=n,d=n.services.slice(0,BLOCK_MAX_SERVICES),t=n.kills.slice(0,BLOCK_MAX_KILLS),l=n.kills.length-t.length+(n.killsMore??0),s=f(o?.left),p=f(o?.unlabeled),k=f(r?.killed);return{run:e.id,job:e.job,kind:e.kind,state:e.state,standing:dockerRunStanding(n),...n.runnerGone&&!e.ended?{runnerGone:!0}:{},project:e.project,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.url?{url:e.url}:{},...e.urlNote?{urlNote:m(e.urlNote)}:{},...e.note?{note:m(e.note)}:{},...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...e.ranMs!==void 0?{ranMs:e.ranMs}:{},...e.exit?{exit:e.exit}:{},...n.vm?{vm:n.vm}:{},services:d,...n.services.length>d.length?{servicesMore:n.services.length-d.length}:{},totals:n.totals,kills:t.map(c=>({...c,container:c.container.slice(0,12)})),...l?{killsMore:l}:{},...r?{engineLost:{at:r.at,why:m(r.why),...r.backAt!==void 0?{backAt:r.backAt}:{},...k?{killed:k}:{}}}:{},...o?{cleanup:{by:o.by,at:o.at,done:o.done,...s?{left:s}:{},...p?{unlabeled:p}:{},...o.why?{why:m(o.why)}:{}}}:{}}}u(dockerRunBlock,"dockerRunBlock"),a(dockerRunBlock,"dockerRunBlock"),i(dockerRunBlock,"dockerRunBlock");export function dockerRunBlockLess(n){if(n.services&&n.services.length>1)return{...n,services:n.services.slice(0,-1),servicesMore:(n.servicesMore??0)+1};if(n.kills&&n.kills.length>1)return{...n,kills:n.kills.slice(0,-1),killsMore:(n.killsMore??0)+1}}u(dockerRunBlockLess,"dockerRunBlockLess"),a(dockerRunBlockLess,"dockerRunBlockLess"),i(dockerRunBlockLess,"dockerRunBlockLess");export const PAGE_MAX_ROWS=50;const y=["queued","running"];export function dockerRemoteStanding(n){return n.state==="lost"?"lost":y.includes(n.state)?"up":"ended"}u(dockerRemoteStanding,"dockerRemoteStanding"),a(dockerRemoteStanding,"dockerRemoteStanding"),i(dockerRemoteStanding,"dockerRemoteStanding");export function dockerRemoteRunsList(n,e={}){const o=i(s=>s.completedAt??s.startedAt??s.queuedAt,"since"),r=[...n].sort((s,p)=>o(p)-o(s)||s.run.localeCompare(p.run)),d=r.filter(s=>dockerRemoteStanding(s)==="up"),t=r.filter(s=>dockerRemoteStanding(s)!=="up"),l=t.slice(0,e.endedMax??t.length);return{counts:{up:d.length,lost:t.filter(s=>s.state==="lost").length,ended:t.filter(s=>s.state!=="lost").length},runs:[...d,...l],...l.length<t.length?{endedMore:t.length-l.length}:{}}}u(dockerRemoteRunsList,"dockerRemoteRunsList"),a(dockerRemoteRunsList,"dockerRemoteRunsList"),i(dockerRemoteRunsList,"dockerRemoteRunsList");
@@ -1,6 +1,6 @@
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
+ "use strict";var g=Object.defineProperty;var s=(e,t)=>g(e,"name",{value:t,configurable:!0});var y=Object.defineProperty,c=s((e,t)=>y(e,"name",{value:t,configurable:!0}),"s"),E=Object.defineProperty,a=c((e,t)=>E(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const i=a(n=>n.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(n=>i(n===void 0?"":String(n)))].join(":")}s(joinId,"joinId"),c(joinId,"joinId"),a(joinId,"joinId");export function foldMessage(e){return e?e.split(`
2
+ `)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}s(foldMessage,"foldMessage"),c(foldMessage,"foldMessage"),a(foldMessage,"foldMessage");const x=a(e=>!!e&&typeof e=="object"&&typeof e.message=="string","isValidationIssue"),v=a(e=>Array.isArray(e)&&e.length?e.map(String).join("."):"(root)","issuePath"),p=3;export function readableErrorMessage(e){const t=e?.trim()??"",i=t.indexOf("["),n=t.slice(0,Math.max(i,0));if(i<0||!/^(?:[A-Za-z_$][\w$]*:\s*)?$/.test(n))return e;let d;try{d=JSON.parse(t.slice(i))}catch{return e}if(!Array.isArray(d)||!d.length||!d.every(x))return e;const o=d.map(m=>`${v(m.path)}: ${m.message}`),r=o.length===1?"1 issue":`${o.length} issues`,h=o.length>p?` (+${o.length-p} more)`:"";return[`${n}Validation failed (${r}): ${o.slice(0,p).join("; ")}${h}`,...o.map(m=>` ${m}`)].join(`
3
+ `)}s(readableErrorMessage,"readableErrorMessage"),c(readableErrorMessage,"readableErrorMessage"),a(readableErrorMessage,"readableErrorMessage");const w=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function l(e){const t=w.exec((e??"").split(`
4
+ `)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}s(l,"h"),c(l,"u"),a(l,"named");export function appFrameOf(e){for(const t of(e??"").split(`
5
+ `)){const i=/^\s*at\s+(.+)$/.exec(t);if(!i||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(i[1]))continue;const n=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(i[1].trim());return n?`${n[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${n[2]}`:i[1].trim()}}s(appFrameOf,"appFrameOf"),c(appFrameOf,"appFrameOf"),a(appFrameOf,"appFrameOf");export function errorCause(e){const t=readableErrorMessage(e.message),i=l(e.stack),n=l(t),d=l(e.title),o=e.name?.trim()||i?.name||n?.name||d?.name;if(!o)return;let r=(t!==e.message?t:void 0)??(i&&i.name===o?i.message:void 0)??t??d?.message??e.title??"";const h=l(r);h&&h.name===o&&(r=h.message),r=r.split(`
6
+ `)[0].trim();const m=appFrameOf(e.stack),f=b.has(errorHeadline({name:o,message:r})?.id??"");return{id:joinId("cause",[o,foldMessage(r),f?void 0:m]),errorName:o,message:r,...m?{frame:m}:{}}}s(errorCause,"errorCause"),c(errorCause,"errorCause"),a(errorCause,"errorCause");const b=new Set(["missing-column","missing-table","connection-refused","out-of-memory"]);export function causeIdWithoutFrame(e){return joinId("cause",[e.errorName,foldMessage(e.message),void 0])}s(causeIdWithoutFrame,"causeIdWithoutFrame"),c(causeIdWithoutFrame,"causeIdWithoutFrame"),a(causeIdWithoutFrame,"causeIdWithoutFrame");const u=a(e=>e?` (\xAB${e}\xBB)`:"","q");export const ERROR_HEADLINES=[{id:"missing-column",match:a(e=>/column "?([\w.]+)"?(?: of relation "?[\w.]+"?)? does not exist|Unknown column '([^']+)'|ER_BAD_FIELD_ERROR/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database column${u(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations, or add the migration the entity change needs."}),"say")},{id:"missing-table",match:a(e=>/relation "?([\w.]+)"? does not exist|Table '([^']+)' doesn't exist|ER_NO_SUCH_TABLE/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database table${u(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations against this database."}),"say")},{id:"unique-violation",match:a((e,t)=>/duplicate key value violates unique constraint "?([\w.]+)"?|Duplicate entry '[^']*' for key '([^']+)'|ER_DUP_ENTRY/i.exec(e)||t.code==="23505","match"),say:a(e=>({headline:`A row with the same unique value already exists${u(e===!0?void 0:e[1]??e[2])}`,hint:"The code inserts a duplicate: look up the existing row first, or upsert."}),"say")},{id:"foreign-key-violation",match:a((e,t)=>/violates foreign key constraint "?([\w.]+)"?|a foreign key constraint fails|ER_NO_REFERENCED_ROW|ER_ROW_IS_REFERENCED/i.exec(e)||t.code==="23503","match"),say:a(e=>({headline:`A row points at a row that doesn't exist, or a row still in use was deleted${u(e===!0?void 0:e[1])}`,hint:"Create the referenced row first, or delete the rows that point at it."}),"say")},{id:"connection-refused",match:a((e,t)=>/ECONNREFUSED|connection refused|connect ECONNREFUSED/i.exec(e)||t.code==="ECONNREFUSED","match"),say:a(()=>({headline:"A service the code connects to is not running, or not listening where the code looks",hint:"Start it (database, cache, broker or API), or fix its host and port."}),"say")},{id:"out-of-memory",match:a((e,t)=>/heap out of memory|JavaScript heap|out of memory|ENOMEM|Allocation failed/i.exec(e)||t.code==="ENOMEM","match"),say:a(()=>({headline:"The process ran out of memory",hint:"Something holds or loads too much at once \u2014 look for an unbounded list, cache or query."}),"say")},{id:"jwt-expired",match:a((e,t)=>/jwt expired|token expired/i.exec(e)||t.name==="TokenExpiredError","match"),say:a(()=>({headline:"A sign-in token expired",hint:"Sign in again; if it keeps happening, the client is not refreshing its token."}),"say")},{id:"jwt-invalid",match:a((e,t)=>/jwt malformed|invalid signature|invalid token|jwt must be provided|jwt audience invalid|jwt issuer invalid/i.exec(e)||t.name==="JsonWebTokenError","match"),say:a(()=>({headline:"A sign-in token is not valid here",hint:"Its signature, audience or issuer does not match what this service expects."}),"say")},{id:"timeout",match:a((e,t)=>/ETIMEDOUT|ESOCKETTIMEDOUT|timed? ?out|timeout exceeded|statement timeout|canceling statement due to|Query read timeout/i.exec(e)||t.name==="TimeoutError"||t.code==="ETIMEDOUT","match"),say:a(()=>({headline:"Something took too long and was cut off",hint:"A slow query, a busy dependency or a lock \u2014 open the failing step to see which."}),"say")},{id:"unauthorized",match:a((e,t)=>t.status===401||t.name==="UnauthorizedException"||/^Unauthorized$/i.test(e.trim()),"match"),say:a(()=>({headline:"The request was not signed in (401)",hint:"It came without a valid session or token."}),"say")},{id:"forbidden",match:a((e,t)=>t.status===403||t.name==="ForbiddenException"||/^Forbidden(?: resource)?$/i.test(e.trim()),"match"),say:a(()=>({headline:"The signed-in user is not allowed to do this (403)",hint:"A role or permission check refused it."}),"say")}];export function errorHeadline(e){const t=[e.code,e.message].filter(Boolean).join(" ");for(const i of ERROR_HEADLINES){const n=i.match(t,e);if(n)return{id:i.id,...i.say(n)}}}s(errorHeadline,"errorHeadline"),c(errorHeadline,"errorHeadline"),a(errorHeadline,"errorHeadline");
@@ -1 +1 @@
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");
1
+ "use strict";var E=Object.defineProperty;var s=(e,r)=>E(e,"name",{value:r,configurable:!0});var m=Object.defineProperty,c=s((e,r)=>m(e,"name",{value:r,configurable:!0}),"s"),p=Object.defineProperty,l=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"s");export const ERROR_DISMISSED="error-dismissed",ERROR_RESTORED="error-restored",LENS_EVENT_SOURCE="lens",MAX_DISMISSAL_EVENT_IDS=200;const y=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const b=300,I=new Set(["dashboard","cli","agent"]);export function readErrorDismissal(e){if(e.source!==LENS_EVENT_SOURCE||!e.raw||typeof e.raw!="object")return;const r=e.raw,i=r.groupId;if(typeof i!="string"||i.length===0||i.length>2048)return;if(r.kind===ERROR_RESTORED)return{kind:ERROR_RESTORED,groupId:i};if(r.kind!==ERROR_DISMISSED)return;const n=r.until;if(typeof n!="number"||!Number.isFinite(n))return;const f=Array.isArray(r.eventIds)?r.eventIds.filter(t=>typeof t=="string"&&t.length>0).slice(0,200):[],o=I.has(r.by)?r.by:void 0,a=l((t,S)=>typeof t=="string"&&t.trim()?t.trim().slice(0,S):void 0,"text"),d=a(r.reason,500),u=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,e.timestamp),eventIds:f,...o?{by:o}:{},...d?{reason:d}:{},...u?{title:u}:{}}}s(readErrorDismissal,"readErrorDismissal"),c(readErrorDismissal,"readErrorDismissal"),l(readErrorDismissal,"readErrorDismissal");