@lensmcp/protocol-types 1.26.18 → 1.26.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ai-cache-facts.js +1 -1
- package/lib/ai-cache-verdict.js +1 -1
- package/lib/ai-cache.js +3 -3
- package/lib/ai-call-groups.js +2 -2
- package/lib/ai-call-row.js +3 -3
- package/lib/ai-call.js +9 -9
- package/lib/ai-compare.js +3 -3
- package/lib/ai-context.js +6 -6
- package/lib/ai-origins.js +9 -9
- package/lib/ai-together.js +5 -5
- package/lib/bounded-clone.js +1 -1
- package/lib/bounded-map.js +1 -1
- package/lib/bounded-writer.js +1 -1
- package/lib/capture-demand.js +1 -1
- package/lib/dashboard-path.js +1 -1
- package/lib/dashboard.d.ts +7 -1
- package/lib/dashboard.js +1 -1
- package/lib/docker-errors.js +1 -1
- package/lib/docker-jobs.js +1 -1
- package/lib/docker-report.js +2 -2
- package/lib/docker-runs.js +3 -3
- package/lib/error-cause.js +6 -6
- package/lib/error-dismissal.js +1 -1
- package/lib/error-verdict.js +3 -3
- package/lib/event-loop.js +1 -1
- package/lib/expected-failure.js +2 -2
- package/lib/finding-proof.js +1 -1
- package/lib/flood-guard.js +1 -1
- package/lib/goal-design.js +1 -1
- package/lib/host-agents.js +1 -1
- package/lib/lint-coverage.js +1 -1
- package/lib/lint-ignores.js +2 -2
- package/lib/log-query.js +1 -1
- package/lib/metrics-reset.js +1 -1
- package/lib/overseer-findings.js +1 -1
- package/lib/peers.d.ts +25 -25
- package/lib/peers.js +1 -1
- package/lib/perf-rules.js +1 -1
- package/lib/pod-memory.js +1 -1
- package/lib/producer-health.js +1 -1
- package/lib/remote-instances.js +1 -1
- package/lib/sessions.d.ts +88 -1
- package/lib/sources.js +1 -1
- package/lib/static-checks.js +1 -1
- package/lib/system-report.js +1 -1
- package/lib/team.js +1 -1
- package/package.json +1 -1
package/lib/goal-design.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=(n,e)=>i(n,"name",{value:e,configurable:!0});var o=Object.defineProperty,r=a((n,e)=>o(n,"name",{value:e,configurable:!0}),"a");export const DESIGN_TYPES=["bug","investigation","performance","reliability","feature","architecture","maintenance"],DESIGN_CONCERNS=["security","data","api","ui","integration","operations"],DESIGN_TYPE_INFO={bug:{label:"Bug",when:"Something works wrong, and the cause is known or can be found by reading the code."},investigation:{label:"Investigation",when:"Symptoms without a known cause: research first, and the goal ends in a decision or a fix."},performance:{label:"Performance",when:"Something is measurably slow, heavy or costly: a baseline the lens measured and a target."},reliability:{label:"Reliability",when:"Crashes, stalls, flaky tests, lost work, CI or the machine: how it fails and how often."},feature:{label:"Feature",when:"Someone can do something they cannot do now."},architecture:{label:"Architecture",when:"Boundaries, contracts or structure change, in steps that each ship."},maintenance:{label:"Maintenance",when:"Upgrades, moves, tooling and cleanup: no new behaviour, and nothing breaks."}},DESIGN_CONCERN_INFO={security:{label:"Security",when:"Auth, permissions, secrets, input from outside, or anything an attacker would read."},data:{label:"Data",when:"Schema, migrations, backfills, or data already stored."},api:{label:"API",when:"A request or response other code or other people depend on."},ui:{label:"UI",when:"Screens, flows or what a person sees."},integration:{label:"Integration",when:"A service outside the repository: its API, keys, limits and failures."},operations:{label:"Operations",when:"How it deploys, runs, is watched and is rolled back."}},DESIGN_STAGES=["proposed","requested","drafting","waiting","changes","approved","declined"];export function designWriter(n){if(n.writer)return n.writer;if(n.by==="user")return{kind:"person"};if(n.by==="lensmcp")return{kind:"lensmcp",...n.byName?{name:n.byName}:{}}}a(designWriter,"designWriter"),r(designWriter,"designWriter");const s={claude:"Claude Code",codex:"Codex"};export function designWriterText(n){const e=designWriter(n);if(!e)return"who handed it in was not recorded";const t=e.client?s[e.client]:void 0;switch(e.kind){case"person":return"written by the person";case"lensmcp":return"written by LensMCP's own run";case"terminal":return"handed in from a terminal, as the overseer";case"session":return`handed in by ${t?`a ${t}`:"an agent's"} session${e.role?`, the team's ${e.role}`:" with no role on this team"}`;case"launch":return e.purpose==="design"?`written by a design launch${t?` on ${t}`:""}`:`handed in by the overseer's ${e.purpose==="inbox"?"inbox launch":e.purpose==="round"?"round":"launch"}${t?` on ${t}`:""}`}}a(designWriterText,"designWriterText"),r(designWriterText,"designWriterText");
|
package/lib/host-agents.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var A=Object.defineProperty;var s=(t,e)=>A(t,"name",{value:e,configurable:!0});var c=Object.defineProperty,o=s((t,e)=>c(t,"name",{value:e,configurable:!0}),"o");export const HOST_AGENT_CLIENTS=["claude","codex"],HOST_AGENTS_FILES={agents:"host-agents.json",ceilings:"host-ceilings.json"},HOST_AGENTS_LIMITS={accounts:32,windows:6,label:60,why:300,plan:40,name:40,agents:64},HOST_ACCOUNT_ID=/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/;const n=[/\bsk-[A-Za-z0-9_-]{16,}/,/\b[rs]k_(?:live|test)_[A-Za-z0-9]{12,}/,/\bgh[pousr]_[A-Za-z0-9]{20,}|\bgithub_pat_[A-Za-z0-9_]{20,}/,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bxox[abposr]-[A-Za-z0-9-]{10,}/,/\bAIza[0-9A-Za-z_-]{30,}/,/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,}/,/-----BEGIN [A-Z ]*(?:PRIVATE KEY|CERTIFICATE)-----/,/\bbearer\s+[A-Za-z0-9._~+/=-]{12,}/i],r=/[A-Za-z0-9+/_=-]{32,}/g;export function tokenShaped(t){if(n.some(e=>e.test(t)))return!0;for(const e of t.match(r)??[])if(/\d/.test(e)&&/[A-Za-z]/.test(e))return!0;return!1}s(tokenShaped,"tokenShaped"),o(tokenShaped,"tokenShaped");export function withoutTokens(t){let e=t;for(const a of n)e=e.replace(new RegExp(a.source,a.flags.includes("g")?a.flags:`${a.flags}g`),"\u2026");return e.replace(r,a=>/\d/.test(a)&&/[A-Za-z]/.test(a)?"\u2026":a)}s(withoutTokens,"withoutTokens"),o(withoutTokens,"withoutTokens");
|
package/lib/lint-coverage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var k=Object.defineProperty;var g=(e,n)=>k(e,"name",{value:n,configurable:!0});var v=Object.defineProperty,d=g((e,n)=>v(e,"name",{value:n,configurable:!0}),"i");import{TRUNCATION_MARKER_KEY as C}from"./bounded-clone.js";export const LINT_COVER_KIND="lint-cover",MAX_LINT_UNCOMMITTED=500;const A=["tree","paths","changed","incremental"],h=d(e=>Array.isArray(e)?e.filter(n=>typeof n=="string"&&n.length>0):[],"strings"),i=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,"count"),l=d(e=>typeof e=="string"&&e?e:void 0,"text");export function readLintCoverage(e){if(!e||typeof e!="object"||e[C])return;const n=e.coverage;if(!n||typeof n!="object")return;const t=n,r=t.kind,s=t.root;if(!A.includes(r)||typeof s!="string"||!s)return;const f=h(t.dirs),o=h(t.files),p=h(t.gone),m=i(t.notLinted),$=i(t.untracked),a=t.base&&typeof t.base=="object"?t.base:void 0,y=a&&l(a.sha)&&l(a.run)?{from:a.from==="main"?"main":"own",sha:a.sha,run:a.run}:void 0,b=Array.isArray(t.inputs)?t.inputs.flatMap(u=>Array.isArray(u)&&typeof u[0]=="string"&&typeof u[1]=="string"?[[u[0],u[1]]]:[]):void 0;return{kind:r,root:s,dirs:f,files:o,gone:p,fileCount:i(t.fileCount)??o.length,goneCount:i(t.goneCount)??p.length,linted:i(t.linted)??0,...i(t.dirCount)!==void 0?{dirCount:i(t.dirCount)}:{},...m?{notLinted:m}:{},...$?{untracked:$}:{},...l(t.since)?{since:t.since}:{},...l(t.head)?{head:t.head}:{},...typeof t.dirty=="boolean"?{dirty:t.dirty}:{},...Array.isArray(t.uncommitted)?{uncommitted:h(t.uncommitted)}:{},...t.uncommittedMore===!0?{uncommittedMore:!0}:{},...b?{inputs:b}:{},...l(t.folder)?{folder:t.folder}:{},...t.projects===!0?{projects:!0}:{},...y?{base:y}:{},...t.fromZero===!0?{fromZero:!0}:{},...t.narrowed===!0?{narrowed:!0}:{}}}g(readLintCoverage,"readLintCoverage"),d(readLintCoverage,"readLintCoverage");const c=d((e,n)=>`${e} ${n}${e===1?"":"s"}`,"some");export function lintCoverageLabel(e,n={}){const t=e.files??0,r=e.gone??0;if(e.kind==="changed"){const o=`since ${e.since??"HEAD"}`;if(!t)return`${c(r,"deleted file")} ${o}`;const p=n.untracked&&e.untracked?` (${e.untracked} untracked)`:"";return`${c(t,"changed file")} ${o}${p}${r?`, ${r} deleted`:""}`}if(e.kind==="incremental"){const o=e.since?` since ${e.since.slice(0,7)}`:"";return!t&&!r?`nothing changed${o}`:t?`${c(t,"file")} changed${o}${r?`, ${r} deleted`:""}`:`${c(r,"file")} deleted${o}`}if(e.kind==="tree"&&e.projects)return`the workspace\u2019s ${c(e.projects,"project")}`;if(e.kind==="tree"&&e.paths[0]===".")return"whole checkout";if(e.narrowed)return`${c(t,"file")} ESLint linted with the caller\u2019s arguments`;const s=e.paths.slice(0,3).join(", "),f=(e.more??0)+Math.max(0,e.paths.length-3);return f?`${s} +${f} more`:s}g(lintCoverageLabel,"lintCoverageLabel"),d(lintCoverageLabel,"lintCoverageLabel");
|
package/lib/lint-ignores.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`}p(lintIgnoresText,"lintIgnoresText"),
|
|
1
|
+
"use strict";var y=Object.defineProperty;var p=(e,t)=>y(e,"name",{value:t,configurable:!0});var j=Object.defineProperty,l=p((e,t)=>j(e,"name",{value:t,configurable:!0}),"l");export const LINT_IGNORES_FILE=".lensmcp/lint/ignores.json",LINT_IGNORE_LIMITS={rule:200,project:200,reason:500,evidence:1e3,by:80,ignores:500},LINT_IGNORED_RULES_SAID=50,LINT_IGNORED_NOTE="The person ignored these lints in the repository (each a rule in a project, with why): they are left out of the counts, the verdict and the status \u2014 do not fix them, and do not edit the ESLint config or this file for them. ESLint itself (`nx lint`) still reports them. To ask for another, `lint_ignore_propose`; only the person accepts.";const I=l(e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,"obj"),u=l(e=>typeof e=="string"&&e.trim()?e.replace(/\s+/g," ").trim():void 0,"text");export function lintIgnoreKey(e,t){return`${t}\0${e}`}p(lintIgnoreKey,"lintIgnoreKey"),l(lintIgnoreKey,"lintIgnoreKey");export function checkLintIgnore(e){const t=u(e.rule),n=u(e.project),r=u(e.reason),o=LINT_IGNORE_LIMITS;return t?t==="fatal"?{problem:"a file ESLint could not parse is never ignored \u2014 fix it"}:t.length>o.rule?{problem:`the rule is at most ${o.rule} characters`}:n?n.length>o.project?{problem:`the project is at most ${o.project} characters`}:r?r.length>o.reason?{problem:`the reason is at most ${o.reason} characters`}:{rule:t,project:n,reason:r}:{problem:"say why it is not to be fixed \u2014 the reason is what a teammate and an agent read"}:{problem:"name the project that owns the files"}:{problem:"name the rule (ESLint\u2019s rule id, as the finding names it)"}}p(checkLintIgnore,"checkLintIgnore"),l(checkLintIgnore,"checkLintIgnore");export function parseLintIgnores(e){if(e===void 0||!e.trim())return{ignores:[],problems:[]};let t;try{t=JSON.parse(e)}catch(i){return{ignores:[],problems:[`${LINT_IGNORES_FILE} is not JSON (${i instanceof Error?i.message:String(i)}) \u2014 no lint is ignored until it is`]}}const n=I(t),r=n?n.ignores:void 0;if(!n||!Array.isArray(r))return{ignores:[],problems:[`${LINT_IGNORES_FILE} holds no "ignores" list \u2014 no lint is ignored until it does`]};const o=[],a=[],s=new Set;return r.forEach((i,h)=>{const g=I(i);if(!g){a.push(`ignores[${h}] is not an object`);return}const c=checkLintIgnore(g);if("problem"in c){a.push(`ignores[${h}]: ${c.problem}`);return}const f=lintIgnoreKey(c.rule,c.project);if(s.has(f)){a.push(`ignores[${h}]: ${c.rule} in ${c.project} is ignored above already \u2014 the first stands`);return}if(o.length>=LINT_IGNORE_LIMITS.ignores){a.push(`ignores[${h}]: past ${LINT_IGNORE_LIMITS.ignores} ignores \u2014 the rest are not read`);return}s.add(f);const b=u(g.by)?.slice(0,LINT_IGNORE_LIMITS.by),m=u(g.at),d=u(g.proposal);o.push({...c,...b?{by:b}:{},...m&&!Number.isNaN(Date.parse(m))?{at:m}:{},...d?{proposal:d.slice(0,40)}:{}})}),{ignores:o,problems:a}}p(parseLintIgnores,"parseLintIgnores"),l(parseLintIgnores,"parseLintIgnores");export function lintIgnoresText(e){const t=[...e].sort((r,o)=>r.project<o.project?-1:r.project>o.project?1:r.rule<o.rule?-1:r.rule>o.rule?1:0),n=l(r=>({rule:r.rule,project:r.project,reason:r.reason,...r.by?{by:r.by}:{},...r.at?{at:r.at}:{},...r.proposal?{proposal:r.proposal}:{}}),"entry");return`${JSON.stringify({version:1,ignores:t.map(n)},null,2)}
|
|
2
|
+
`}p(lintIgnoresText,"lintIgnoresText"),l(lintIgnoresText,"lintIgnoresText");export function withLintIgnore(e,t){const n=lintIgnoreKey(t.rule,t.project);return[...e.filter(r=>lintIgnoreKey(r.rule,r.project)!==n),t]}p(withLintIgnore,"withLintIgnore"),l(withLintIgnore,"withLintIgnore");export function withoutLintIgnore(e,t,n){const r=lintIgnoreKey(t,n);return e.filter(o=>lintIgnoreKey(o.rule,o.project)!==r)}p(withoutLintIgnore,"withoutLintIgnore"),l(withoutLintIgnore,"withoutLintIgnore");export function lintIgnoreMatcher(e){if(!e.length)return()=>{};const t=new Map(e.map(n=>[lintIgnoreKey(n.rule,n.project),n]));return({rule:n,project:r,scope:o})=>{if(!n||n==="fatal")return;const a=r??o;return a===void 0?void 0:t.get(lintIgnoreKey(n,a))}}p(lintIgnoreMatcher,"lintIgnoreMatcher"),l(lintIgnoreMatcher,"lintIgnoreMatcher");export function lintIgnoredSummary(e,t){if(!e.ignores.length&&!e.problems.length)return;let n=0,r=0;const o=e.ignores.map(s=>{const i=t.get(lintIgnoreKey(s.rule,s.project))??{errors:0,warnings:0};return n+=i.errors,r+=i.warnings,{rule:s.rule,project:s.project,reason:s.reason,...s.by?{by:s.by}:{},...s.at?{at:s.at}:{},errors:i.errors,warnings:i.warnings}}).map((s,i)=>({r:s,i})).sort((s,i)=>i.r.errors-s.r.errors||i.r.warnings-s.r.warnings||s.i-i.i).map(({r:s})=>s),a=o.length-LINT_IGNORED_RULES_SAID;return{file:LINT_IGNORES_FILE,errors:n,warnings:r,rules:o.slice(0,LINT_IGNORED_RULES_SAID),...a>0?{moreRules:a}:{},...e.problems.length?{problems:e.problems.slice(0,10)}:{},note:LINT_IGNORED_NOTE}}p(lintIgnoredSummary,"lintIgnoredSummary"),l(lintIgnoredSummary,"lintIgnoredSummary");export const LINT_IGNORE_PROPOSAL_LIMITS={open:30,kept:200,requestId:200};
|
package/lib/log-query.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var a=(e,r)=>m(e,"name",{value:r,configurable:!0});var L=Object.defineProperty,c=a((e,r)=>L(e,"name",{value:r,configurable:!0}),"c");const d={level:"level",severity:"level",service:"service",svc:"service",src:"service",source:"service",flow:"flow",trace:"trace",request:"trace",category:"category",cat:"category",ms:"ms"},h={warn:"warning",err:"error"},p=/(-?)(?:([A-Za-z]+):)?(?:"([^"]*)"|(\S+))/g;export function parseLogQuery(e){const r=[],t=[];for(const s of e.matchAll(p)){const[o,n,f,w,g]=s,u=(w??g??"").trim(),i=f?d[f.toLowerCase()]:void 0;if(i&&u){const y=i==="level"?h[u.toLowerCase()]??u.toLowerCase():u;r.push({key:i,value:y,negate:n==="-"})}else o.trim()&&t.push(o.trim())}return{tokens:r,text:t.join(" ")}}a(parseLogQuery,"parseLogQuery"),c(parseLogQuery,"parseLogQuery");export function formatLogQuery(e){const r=c(t=>/\s/.test(t)?`"${t}"`:t,"quote");return[...e.tokens.map(t=>`${t.negate?"-":""}${t.key}:${r(t.value)}`),e.text].filter(Boolean).join(" ")}a(formatLogQuery,"formatLogQuery"),c(formatLogQuery,"formatLogQuery");function v(e,r){if(e===void 0)return!1;const t=/^(>=|<=|>|<|=)?\s*(\d+(?:\.\d+)?)$/.exec(r);if(!t)return!1;const s=Number(t[2]);switch(t[1]){case">":return e>s;case"<":return e<s;case"<=":return e<=s;case"=":return e===s;default:return e>=s}}a(v,"h"),c(v,"msMatches");function l(e,r){const t=r.value.toLowerCase();switch(r.key){case"level":return e.severity.toLowerCase()===t;case"service":return e.source.toLowerCase()===t;case"flow":return!!e.flowId&&e.flowId.toLowerCase().startsWith(t);case"trace":return!!e.requestId&&e.requestId.toLowerCase().startsWith(t);case"category":return e.category.toLowerCase()===t;case"ms":return v(e.durationMs,r.value)}}a(l,"i"),c(l,"tokenMatches");export function matchesLogQuery(e,r,t){const s=new Map;for(const o of r.tokens){if(o.negate){if(l(e,o))return!1;continue}const n=s.get(o.key);n?n.push(o):s.set(o.key,[o])}for(const o of s.values())if(!o.some(n=>l(e,n)))return!1;if(r.text){const o=`${e.title} ${e.message??""} ${e.source} ${e.flowId??""}`;return t?t(o):o.toLowerCase().includes(r.text.toLowerCase())}return!0}a(matchesLogQuery,"matchesLogQuery"),c(matchesLogQuery,"matchesLogQuery");
|
package/lib/metrics-reset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=(t,e)=>a(t,"name",{value:e,configurable:!0});var S=Object.defineProperty,o=i((t,e)=>S(t,"name",{value:e,configurable:!0}),"s");import{LENS_EVENT_SOURCE as f}from"./error-dismissal.js";export const METRICS_RESET="metrics-reset",METRICS_RESTORED="metrics-restored",METRICS_SCOPES=["sql","external"],MAX_METRICS_RESET_IDS=500,MAX_METRICS_RESET_ID_LENGTH=512,METRICS_RESET_IDS_PER_EVENT=64;const l=16*1024,u=o(t=>t==="sql"||t==="external","isScope"),E=o(t=>typeof t=="string"&&t.length>0&&t.length<=MAX_METRICS_RESET_ID_LENGTH,"isId");export function readMetricsReset(t){if(t.source!==f||!t.raw||typeof t.raw!="object")return;const e=t.raw,r=e.kind;if(r!==METRICS_RESET&&r!==METRICS_RESTORED)return;const n=e.scope;if(!u(n))return;let s;if(e.ids!==void 0&&(!Array.isArray(e.ids)||(s=[...new Set(e.ids.filter(E))].slice(0,METRICS_RESET_IDS_PER_EVENT),!s.length)))return;if(r===METRICS_RESTORED)return{kind:r,scope:n,...s?{ids:s}:{}};const c=e.at;if(!(typeof c!="number"||!Number.isFinite(c)))return{kind:r,scope:n,at:Math.min(c,t.timestamp),...s?{ids:s}:{}}}i(readMetricsReset,"readMetricsReset"),o(readMetricsReset,"readMetricsReset");export function metricsIdBatches(t){const e=[];let r=[],n=0;for(const s of new Set(t.filter(E)))r.length&&(r.length>=METRICS_RESET_IDS_PER_EVENT||n+s.length+3>l)&&(e.push(r),r=[],n=0),r.push(s),n+=s.length+3;return r.length&&e.push(r),e}i(metricsIdBatches,"metricsIdBatches"),o(metricsIdBatches,"metricsIdBatches");
|
package/lib/overseer-findings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=(e,n)=>c(e,"name",{value:n,configurable:!0});var u=Object.defineProperty,o=i((e,n)=>u(e,"name",{value:n,configurable:!0}),"s");export const FINDING_RUN_KINDS=["operate","stop-launch","close-session","role","role-off","check","rule","flow","lesson"];export function findingLive(e){return e.state==="open"||e.state==="proposed"||e.state==="applied"}i(findingLive,"findingLive"),o(findingLive,"findingLive");export function findingRunsActions(e,n={}){return e.actions.some(s=>FINDING_RUN_KINDS.includes(s.kind)||s.kind==="issue"&&n.issuesFolder===!0)}i(findingRunsActions,"findingRunsActions"),o(findingRunsActions,"findingRunsActions");export function findingsForCheck(e,n,s){const r=`repo:${n}/team.${s}`;return e.filter(t=>findingLive(t)&&t.checks.includes(r))}i(findingsForCheck,"findingsForCheck"),o(findingsForCheck,"findingsForCheck");
|
package/lib/peers.d.ts
CHANGED
|
@@ -1171,10 +1171,10 @@ export declare const MAIN_MIRROR_SCHEMAS: {
|
|
|
1171
1171
|
}, z.core.$strict>;
|
|
1172
1172
|
verdict: z.ZodOptional<z.ZodObject<{
|
|
1173
1173
|
state: z.ZodEnum<{
|
|
1174
|
-
waiting: "waiting";
|
|
1175
1174
|
refused: "refused";
|
|
1176
1175
|
"in-main": "in-main";
|
|
1177
1176
|
"brought-in": "brought-in";
|
|
1177
|
+
waiting: "waiting";
|
|
1178
1178
|
"not-ff": "not-ff";
|
|
1179
1179
|
}>;
|
|
1180
1180
|
count: z.ZodNumber;
|
|
@@ -1204,8 +1204,8 @@ export declare const MAIN_MIRROR_SCHEMAS: {
|
|
|
1204
1204
|
sent: z.ZodBoolean;
|
|
1205
1205
|
}, z.core.$strict>>;
|
|
1206
1206
|
follow: z.ZodEnum<{
|
|
1207
|
-
waiting: "waiting";
|
|
1208
1207
|
"in-step": "in-step";
|
|
1208
|
+
waiting: "waiting";
|
|
1209
1209
|
"fast-forward": "fast-forward";
|
|
1210
1210
|
ahead: "ahead";
|
|
1211
1211
|
"to-update": "to-update";
|
|
@@ -1214,11 +1214,11 @@ export declare const MAIN_MIRROR_SCHEMAS: {
|
|
|
1214
1214
|
}>;
|
|
1215
1215
|
update: z.ZodOptional<z.ZodObject<{
|
|
1216
1216
|
outcome: z.ZodEnum<{
|
|
1217
|
-
waiting: "waiting";
|
|
1218
|
-
current: "current";
|
|
1219
1217
|
refused: "refused";
|
|
1218
|
+
waiting: "waiting";
|
|
1220
1219
|
"fast-forward": "fast-forward";
|
|
1221
1220
|
merged: "merged";
|
|
1221
|
+
current: "current";
|
|
1222
1222
|
conflicts: "conflicts";
|
|
1223
1223
|
}>;
|
|
1224
1224
|
at: z.ZodNumber;
|
|
@@ -1247,10 +1247,10 @@ export declare const MAIN_MIRROR_ANSWER_SCHEMAS: {
|
|
|
1247
1247
|
why: z.ZodOptional<z.ZodString>;
|
|
1248
1248
|
verdict: z.ZodOptional<z.ZodObject<{
|
|
1249
1249
|
state: z.ZodEnum<{
|
|
1250
|
-
waiting: "waiting";
|
|
1251
1250
|
refused: "refused";
|
|
1252
1251
|
"in-main": "in-main";
|
|
1253
1252
|
"brought-in": "brought-in";
|
|
1253
|
+
waiting: "waiting";
|
|
1254
1254
|
"not-ff": "not-ff";
|
|
1255
1255
|
}>;
|
|
1256
1256
|
count: z.ZodNumber;
|
|
@@ -1265,8 +1265,8 @@ export declare const MAIN_MIRROR_ANSWER_SCHEMAS: {
|
|
|
1265
1265
|
needWhole: z.ZodOptional<z.ZodBoolean>;
|
|
1266
1266
|
why: z.ZodOptional<z.ZodString>;
|
|
1267
1267
|
follow: z.ZodOptional<z.ZodEnum<{
|
|
1268
|
-
waiting: "waiting";
|
|
1269
1268
|
"in-step": "in-step";
|
|
1269
|
+
waiting: "waiting";
|
|
1270
1270
|
"fast-forward": "fast-forward";
|
|
1271
1271
|
ahead: "ahead";
|
|
1272
1272
|
"to-update": "to-update";
|
|
@@ -1316,8 +1316,8 @@ export declare const PEER_WORK_SCHEMAS: {
|
|
|
1316
1316
|
at: z.ZodNumber;
|
|
1317
1317
|
started: z.ZodOptional<z.ZodLiteral<true>>;
|
|
1318
1318
|
state: z.ZodOptional<z.ZodEnum<{
|
|
1319
|
-
queued: "queued";
|
|
1320
1319
|
running: "running";
|
|
1320
|
+
queued: "queued";
|
|
1321
1321
|
}>>;
|
|
1322
1322
|
note: z.ZodOptional<z.ZodString>;
|
|
1323
1323
|
queue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1333,11 +1333,11 @@ export declare const PEER_WORK_SCHEMAS: {
|
|
|
1333
1333
|
runId: z.ZodString;
|
|
1334
1334
|
at: z.ZodNumber;
|
|
1335
1335
|
state: z.ZodEnum<{
|
|
1336
|
-
cancelled: "cancelled";
|
|
1337
|
-
passed: "passed";
|
|
1338
1336
|
failed: "failed";
|
|
1339
|
-
|
|
1337
|
+
passed: "passed";
|
|
1340
1338
|
errored: "errored";
|
|
1339
|
+
cancelled: "cancelled";
|
|
1340
|
+
timeout: "timeout";
|
|
1341
1341
|
}>;
|
|
1342
1342
|
note: z.ZodOptional<z.ZodString>;
|
|
1343
1343
|
step: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1430,10 +1430,10 @@ export declare const PEER_WORK_SCHEMAS: {
|
|
|
1430
1430
|
}, z.core.$strict>;
|
|
1431
1431
|
why: z.ZodObject<{
|
|
1432
1432
|
kind: z.ZodEnum<{
|
|
1433
|
-
restarting: "restarting";
|
|
1434
1433
|
protocol: "protocol";
|
|
1435
1434
|
version: "version";
|
|
1436
1435
|
installed: "installed";
|
|
1436
|
+
restarting: "restarting";
|
|
1437
1437
|
"install-failed": "install-failed";
|
|
1438
1438
|
"restart-failed": "restart-failed";
|
|
1439
1439
|
"no-store": "no-store";
|
|
@@ -1504,9 +1504,9 @@ export declare const StoreReplySchema: z.ZodObject<{
|
|
|
1504
1504
|
message: z.ZodString;
|
|
1505
1505
|
room: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1506
1506
|
step: z.ZodOptional<z.ZodEnum<{
|
|
1507
|
-
commit: "commit";
|
|
1508
1507
|
open: "open";
|
|
1509
1508
|
write: "write";
|
|
1509
|
+
commit: "commit";
|
|
1510
1510
|
read: "read";
|
|
1511
1511
|
}>>;
|
|
1512
1512
|
waitedMs: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1563,8 +1563,8 @@ export declare const PEER_LAUNCH_SCHEMAS: {
|
|
|
1563
1563
|
role: z.ZodString;
|
|
1564
1564
|
by: z.ZodString;
|
|
1565
1565
|
client: z.ZodEnum<{
|
|
1566
|
-
codex: "codex";
|
|
1567
1566
|
claude: "claude";
|
|
1567
|
+
codex: "codex";
|
|
1568
1568
|
}>;
|
|
1569
1569
|
model: z.ZodOptional<z.ZodString>;
|
|
1570
1570
|
effort: z.ZodOptional<z.ZodString>;
|
|
@@ -1594,10 +1594,10 @@ export declare const PEER_LAUNCH_SCHEMAS: {
|
|
|
1594
1594
|
readonly 'launch.state': z.ZodObject<{
|
|
1595
1595
|
launchId: z.ZodString;
|
|
1596
1596
|
state: z.ZodEnum<{
|
|
1597
|
-
failed: "failed";
|
|
1598
|
-
running: "running";
|
|
1599
1597
|
stopped: "stopped";
|
|
1600
1598
|
exited: "exited";
|
|
1599
|
+
running: "running";
|
|
1600
|
+
failed: "failed";
|
|
1601
1601
|
}>;
|
|
1602
1602
|
at: z.ZodNumber;
|
|
1603
1603
|
pid: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1607,8 +1607,8 @@ export declare const PEER_LAUNCH_SCHEMAS: {
|
|
|
1607
1607
|
ended: z.ZodOptional<z.ZodObject<{
|
|
1608
1608
|
quota: z.ZodOptional<z.ZodObject<{
|
|
1609
1609
|
client: z.ZodEnum<{
|
|
1610
|
-
codex: "codex";
|
|
1611
1610
|
claude: "claude";
|
|
1611
|
+
codex: "codex";
|
|
1612
1612
|
}>;
|
|
1613
1613
|
why: z.ZodString;
|
|
1614
1614
|
until: z.ZodNumber;
|
|
@@ -1802,8 +1802,8 @@ export declare const GOAL_PEER_SCHEMAS: {
|
|
|
1802
1802
|
sha256: z.ZodString;
|
|
1803
1803
|
}, z.core.$strict>;
|
|
1804
1804
|
services: z.ZodOptional<z.ZodEnum<{
|
|
1805
|
-
none: "none";
|
|
1806
1805
|
"on-demand": "on-demand";
|
|
1806
|
+
none: "none";
|
|
1807
1807
|
always: "always";
|
|
1808
1808
|
}>>;
|
|
1809
1809
|
at: z.ZodNumber;
|
|
@@ -1863,9 +1863,9 @@ export declare const GOAL_PEER_ANSWER_SCHEMAS: {
|
|
|
1863
1863
|
ref: z.ZodString;
|
|
1864
1864
|
sha: z.ZodOptional<z.ZodString>;
|
|
1865
1865
|
mirror: z.ZodOptional<z.ZodEnum<{
|
|
1866
|
-
current: "current";
|
|
1867
1866
|
"not-ff": "not-ff";
|
|
1868
1867
|
"fast-forward": "fast-forward";
|
|
1868
|
+
current: "current";
|
|
1869
1869
|
created: "created";
|
|
1870
1870
|
"checked-out": "checked-out";
|
|
1871
1871
|
}>>;
|
|
@@ -1882,9 +1882,9 @@ export declare const GOAL_PEER_ANSWER_SCHEMAS: {
|
|
|
1882
1882
|
}, z.core.$strict>;
|
|
1883
1883
|
readonly 'goal.update': z.ZodObject<{
|
|
1884
1884
|
outcome: z.ZodEnum<{
|
|
1885
|
-
current: "current";
|
|
1886
1885
|
refused: "refused";
|
|
1887
1886
|
merged: "merged";
|
|
1887
|
+
current: "current";
|
|
1888
1888
|
conflicts: "conflicts";
|
|
1889
1889
|
asked: "asked";
|
|
1890
1890
|
}>;
|
|
@@ -2035,8 +2035,8 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2035
2035
|
row: z.ZodObject<{
|
|
2036
2036
|
id: z.ZodString;
|
|
2037
2037
|
client: z.ZodEnum<{
|
|
2038
|
-
codex: "codex";
|
|
2039
2038
|
claude: "claude";
|
|
2039
|
+
codex: "codex";
|
|
2040
2040
|
}>;
|
|
2041
2041
|
nativeId: z.ZodString;
|
|
2042
2042
|
account: z.ZodString;
|
|
@@ -2051,13 +2051,13 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2051
2051
|
startedAt: z.ZodNumber;
|
|
2052
2052
|
lastAt: z.ZodNumber;
|
|
2053
2053
|
state: z.ZodEnum<{
|
|
2054
|
+
ended: "ended";
|
|
2054
2055
|
running: "running";
|
|
2055
2056
|
kept: "kept";
|
|
2056
|
-
ended: "ended";
|
|
2057
2057
|
}>;
|
|
2058
2058
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
2059
|
-
team: "team";
|
|
2060
2059
|
person: "person";
|
|
2060
|
+
team: "team";
|
|
2061
2061
|
outside: "outside";
|
|
2062
2062
|
}>>;
|
|
2063
2063
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
@@ -2072,8 +2072,8 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2072
2072
|
seq: z.ZodNumber;
|
|
2073
2073
|
at: z.ZodOptional<z.ZodNumber>;
|
|
2074
2074
|
kind: z.ZodEnum<{
|
|
2075
|
-
tool: "tool";
|
|
2076
2075
|
reply: "reply";
|
|
2076
|
+
tool: "tool";
|
|
2077
2077
|
compaction: "compaction";
|
|
2078
2078
|
prompt: "prompt";
|
|
2079
2079
|
subagent: "subagent";
|
|
@@ -2084,8 +2084,8 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2084
2084
|
name: z.ZodString;
|
|
2085
2085
|
target: z.ZodOptional<z.ZodString>;
|
|
2086
2086
|
outcome: z.ZodOptional<z.ZodEnum<{
|
|
2087
|
-
error: "error";
|
|
2088
2087
|
ok: "ok";
|
|
2088
|
+
error: "error";
|
|
2089
2089
|
}>>;
|
|
2090
2090
|
output: z.ZodOptional<z.ZodString>;
|
|
2091
2091
|
}, z.core.$strict>>;
|
|
@@ -2094,8 +2094,8 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2094
2094
|
settles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2095
2095
|
seq: z.ZodNumber;
|
|
2096
2096
|
outcome: z.ZodEnum<{
|
|
2097
|
-
error: "error";
|
|
2098
2097
|
ok: "ok";
|
|
2098
|
+
error: "error";
|
|
2099
2099
|
}>;
|
|
2100
2100
|
output: z.ZodOptional<z.ZodString>;
|
|
2101
2101
|
}, z.core.$strict>>>;
|
package/lib/peers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var X=Object.defineProperty;var w=(e,o)=>X(e,"name",{value:o,configurable:!0});var J=Object.defineProperty,z=w((e,o)=>J(e,"name",{value:o,configurable:!0}),"w"),Q=Object.defineProperty,i=z((e,o)=>Q(e,"name",{value:o,configurable:!0}),"i");import{z as t}from"zod";import{RUN_ID_PATTERN as D}from"./docker-jobs.js";import{CONVERSATION_ID as tt,CONVERSATION_LIST_MAX as M,CONVERSATION_TOOL_OUTPUT_CHARS as N,CONVERSATION_TURN_CHARS as et}from"./conversations.js";import{REMOTE_DASHBOARD_BASE_PATTERN as nt,REMOTE_INSTANCE_ID_PATTERN as $,REMOTE_INSTANCE_NAME_PREFIX as at}from"./remote-instances.js";export const PEER_PROTOCOL="peer/v1",PEER_PORT=7466,PEER_TIMING={pingMs:5e3,lostMs:45e3,windowMs:10*6e4,approveMs:10*6e4,capacityMs:3e4},PAIRING_CODE={length:10,tries:5},CROCKFORD_ALPHABET="0123456789ABCDEFGHJKMNPQRSTVWXYZ",PEER_PATHS={pair:"/peer/v1/pair",control:"/peer/v1/control",runs:"/peer/v1/runs/",bundles:"/peer/v1/bundles/",sent:"/peer/v1/sent/",tunnel:"/peer/v1/tunnel/"},RUN_UPLOAD_KINDS=["log","samples","events","artifacts"],RUN_UPLOAD_RANGE={from:"x-lensmcp-from",to:"x-lensmcp-to"},PEER_FILES={dir:"peers",key:"identity.key",cert:"identity.crt",window:"window.json",workers:"workers.json",organizer:"organizer.json",hub:"hub.json",hubLock:"hub.lock",hubLog:"hub.log",runs:"runs",instances:"instances"},FINGERPRINT_PATTERN=/^[0-9a-f]{64}$/,REMOTE_RUN_LOST="lost",PEER_MESSAGE_ID=/^[A-Za-z0-9_-]{1,64}$/,TO_WORKER=["job.offer","job.cancel","bundle.ready","tunnel.open","tunnel.close","launch.start","launch.stop","store.reply","version.install","main.moved","instance.tunnel.open","goal.place","goal.changes","goal.update"],TO_ORGANIZER=["hello","capacity","job.state","job.stage","job.done","bundle.sent","launch.state","launch.tail","store.call","version.state","forget","main.state","instance.state","store.read","goal.sent","conversation.sync","conversation.read"],EITHER_WAY=["ping"],PEER_REPLIES=["ack","error","pong"],PEER_MESSAGE_SLICE={hello:"D12 (versions: D13, capacity: D14)",ping:"D12",pong:"D12",ack:"D12",error:"D12",forget:"D11",capacity:"D14","job.offer":"D14","job.cancel":"D14/D18","job.state":"D14/D16","job.stage":"D16","job.done":"D16","bundle.ready":"D15","bundle.sent":"D34 (goal branches: D30)","tunnel.open":"D17","tunnel.close":"D17","launch.start":"D29","launch.stop":"D29","launch.state":"D29","launch.tail":"D29","store.call":"D27/D28","store.reply":"D27/D28","version.install":"D13","version.state":"D13","main.moved":"D34","main.state":"D34","instance.tunnel.open":"D35","instance.state":"D35 (sent by D30)","store.read":"D32","goal.place":"D30","goal.sent":"D30","goal.changes":"D30","goal.update":"D30","conversation.sync":"CV5","conversation.read":"CV5"};const f=i((e,o)=>e.includes(o),"has");export const isPeerMessageType=i(e=>Object.prototype.hasOwnProperty.call(PEER_MESSAGE_SLICE,e),"isPeerMessageType");export function peerMaySend(e,o){return f(EITHER_WAY,o)||f(PEER_REPLIES,o)?!0:f(e==="organizer"?TO_WORKER:TO_ORGANIZER,o)}w(peerMaySend,"peerMaySend"),z(peerMaySend,"peerMaySend"),i(peerMaySend,"peerMaySend");export const isPeerReply=i(e=>f(PEER_REPLIES,e),"isPeerReply");const s=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,d=i(e=>t.string().min(1).max(e).regex(s),"shownText"),C=t.string().regex(/^[A-Za-z0-9_-]{43}$/),P=t.string().regex(/^[0-9a-f]{64}$/),l=t.string().min(1).max(64).regex(/^[0-9A-Za-z.+_-]+$/),ot=t.tuple([t.string().regex(/^[a-z]{3,8}$/),t.string().regex(/^[a-z]{3,8}$/),t.string().regex(/^[a-z]{3,8}$/),t.string().regex(/^[a-z]{3,8}$/)]),n=t.number().int().nonnegative();export const PeerEnvelopeSchema=t.strictObject({v:t.literal(1),id:t.string().regex(PEER_MESSAGE_ID),replyTo:t.string().regex(PEER_MESSAGE_ID).optional(),type:t.string().min(1).max(40),body:t.record(t.string(),t.unknown())});const rt=["unknown-type","wrong-direction","bad-message","hello-first","not-handled","too-large","busy","refused","timeout","lost","internal","no-window","window-used","window-closed","wrong-code","protocol"];export const PeerErrorBodySchema=t.strictObject({code:t.enum(rt),message:t.string().max(500),triesLeft:t.number().int().min(0).max(PAIRING_CODE.tries).optional(),retryAfterMs:t.number().int().min(0).max(36e5).optional()});const p=t.string().regex(D);export const WorkerAdvertSchema=t.record(t.string(),t.unknown()).superRefine((e,o)=>{const O=e.runs;O!==void 0&&(!Array.isArray(O)||O.length>256||!O.every(T=>typeof T=="string"&&D.test(T)))&&o.addIssue({code:"custom",message:"runs: at most 256 run ids"})}),PEER_BODY_SCHEMAS={hello:t.strictObject({protocol:t.literal(PEER_PROTOCOL),lensmcp:l,follow:t.boolean().optional(),store:t.array(l).max(64).optional(),capacity:WorkerAdvertSchema.optional()}),ping:t.strictObject({at:n}),pong:t.strictObject({at:n}),ack:t.strictObject({result:t.unknown().optional()}),error:PeerErrorBodySchema,forget:t.strictObject({why:t.string().max(200).regex(s).optional()})},PeerWelcomeSchema=t.strictObject({protocol:t.literal(PEER_PROTOCOL),lensmcp:l,name:d(64),inStep:t.boolean().optional(),why:t.string().max(500).optional()}),PAIR_BODY_SCHEMAS={"pair.hello":t.strictObject({protocol:t.literal(PEER_PROTOCOL),nonce:C,name:d(64),model:d(40),lensmcp:l}),"pair.resume":t.strictObject({protocol:t.literal(PEER_PROTOCOL)}),"pair.challenge":t.strictObject({nonce:C}),"pair.proof":t.strictObject({proof:P}),"pair.accepted":t.strictObject({proof:P,name:d(64),model:d(40),words:ot,approveBy:n}),"pair.approved":t.strictObject({at:n}),"pair.declined":t.strictObject({why:t.string().max(500)}),error:PeerErrorBodySchema},MAIN_MIRROR={branch:"main",quietMs:10*6e4,snapshotEveryMs:60*6e4,maxSendBytes:512*1024*1024,maxWipBytes:256*1024*1024,maxHaves:16},MAIN_BRING_IN=["in-main","brought-in","waiting","not-ff","refused"],MAIN_FOLLOW_STATES=["in-step","fast-forward","ahead","waiting","to-update","not-following","off-branch"];const r=t.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),y=t.string().regex(/^[0-9a-f]{16,64}$/),L=t.string().regex(/^[0-9a-f]{64}$/),Z=t.string().regex(/^[0-9a-f]{16}$/),u=t.number().int().min(0).max(1e7),j=t.string().min(1).max(250).regex(/^[A-Za-z0-9._/-]+$/),E=t.string().max(1e3),B=t.strictObject({state:t.enum(["in-main","brought-in","waiting","not-ff","refused"]),count:u,sha:r.optional(),main:r.optional(),why:E,at:n}),it=t.strictObject({outcome:t.enum(["merged","fast-forward","current","conflicts","waiting","refused"]),at:n,why:E,sha:r.optional(),conflicts:t.array(t.string().min(1).max(4096)).max(200).optional(),asked:t.array(t.strictObject({who:t.enum(["person","manager"]),goal:t.string().max(64).optional(),to:t.string().max(200).optional()})).max(20).optional()}),H=t.enum(["in-step","fast-forward","ahead","waiting","to-update","not-following","off-branch"]);export const MAIN_MIRROR_SCHEMAS={"bundle.sent":t.strictObject({bundleId:Z,repository:y,refs:t.array(j).length(1),size:t.number().int().positive().max(MAIN_MIRROR.maxSendBytes),sha256:L}),"main.moved":t.strictObject({repository:y,branch:j,sha:r,bundle:t.strictObject({id:Z,size:t.number().int().positive(),sha256:L}),verdict:B.optional(),at:n}),"main.state":t.strictObject({repository:y,branch:j,head:r.optional(),organizerHead:r.optional(),haves:t.array(r).max(MAIN_MIRROR.maxHaves),notSent:u,toPull:u,uncommitted:t.strictObject({files:u,changedAt:n.optional()}),snapshot:t.strictObject({sha:r,at:n,files:u,sent:t.boolean()}).optional(),follow:H,update:it.optional(),at:n})},MAIN_MIRROR_ANSWER_SCHEMAS={"bundle.sent":t.strictObject({took:t.boolean(),ref:j,sha:r.optional(),code:t.string().max(40).optional(),why:E.optional(),verdict:B.optional()}),"main.moved":t.strictObject({took:t.boolean(),needWhole:t.boolean().optional(),why:E.optional(),follow:H.optional(),head:r.optional()})};const st=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/),v=t.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),W=t.string().regex(/^[0-9a-f]{16,64}$/),b=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),G=i(e=>t.string().min(1).max(e).regex(s),"sentence"),m=t.record(t.string(),t.unknown()),lt=t.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,99}$/),c=t.strictObject({lensmcp:l,protocol:t.string().regex(/^peer\/v[1-9]\d{0,3}$/)});export const PEER_WORK_SCHEMAS={capacity:WorkerAdvertSchema,"job.offer":t.strictObject({runId:p,job:st,candidate:v,repository:W,lane:t.enum(["light","heavy"]).optional(),kind:t.enum(["compose","testcontainers","playwright"]).optional(),hostMb:t.number().int().min(0).max(1024*1024).optional(),vmMb:t.number().int().min(0).max(1024*1024).optional(),proof:t.boolean().optional(),timeoutMinutes:t.number().positive().max(360).optional(),onLinkLoss:t.union([t.literal("cancel"),t.strictObject({continueMinutes:t.number().int().min(1).max(360)})]).optional(),secrets:t.record(lt,t.string().min(1).max(8192)).refine(e=>Object.keys(e).length<=16,"at most 16 secrets").optional(),origin:t.string().max(300).regex(/^https?:\/\/[A-Za-z0-9.-]+(?::\d{1,5})?$/).optional()}),"job.cancel":t.strictObject({runId:p,why:G(300)}),"job.state":t.strictObject({runId:p,at:n,started:t.literal(!0).optional(),state:t.enum(["queued","running"]).optional(),note:t.string().max(1e3).optional(),queue:m.optional(),docker:m.optional(),edgePort:t.number().int().min(1024).max(65535).optional()}),"job.stage":t.strictObject({runId:p,stage:G(120),at:n}),"job.done":t.strictObject({runId:p,at:n,state:t.enum(["passed","failed","errored","cancelled","timeout"]),note:t.string().max(1e3).optional(),step:m.optional(),docker:m.optional(),givenBack:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),refused:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),proof:m.optional()}),"bundle.ready":t.strictObject({runId:p.optional(),bundleId:b,repository:W,heads:t.array(v).min(1).max(16),basis:t.array(v).max(256).optional(),size:t.number().int().positive().max(64*1024*1024*1024),sha256:t.string().regex(/^[0-9a-f]{64}$/),shipment:m.optional(),blobs:t.record(t.string().regex(/^[0-9a-f]{64}$/),b).refine(e=>Object.keys(e).length<=101,"at most 101 blobs").optional()}),"tunnel.open":t.strictObject({tunnelId:b,runId:p,port:t.number().int().min(1).max(65535).optional()}),"tunnel.close":t.strictObject({tunnelId:b,why:t.string().max(300).optional()}),"version.install":t.strictObject({version:l,from:t.enum(["registry","organizer"]),tarball:t.strictObject({bundleId:b,sha256:t.string().regex(/^[0-9a-f]{64}$/),size:t.number().int().positive().max(8*1024*1024*1024)}).optional()}),"version.state":t.discriminatedUnion("state",[t.strictObject({state:t.literal("in-step"),worker:c,organizer:c}),t.strictObject({state:t.literal("installing"),worker:c,organizer:c,from:t.enum(["registry","organizer"]),since:n}),t.strictObject({state:t.literal("waiting-for-person"),worker:c,organizer:c,stored:t.boolean()}),t.strictObject({state:t.literal("out-of-step"),worker:c,organizer:c,why:t.object({kind:t.enum(["protocol","version","installed","restarting","install-failed","restart-failed","no-store"])}).catchall(t.union([t.string().max(600),t.number(),t.boolean()]))})])},STORE_CALL_LIMITS={args:16,argsBytes:256*1024,answerBytes:480*1024},PEER_LAUNCH_KEY_PATTERN=/^[A-Za-z0-9_-]{43}$/;const U=t.strictObject({added:t.number().int().nonnegative().nullable(),removed:t.number().int().nonnegative().nullable()});export const StoreCallSchema=t.strictObject({v:t.literal(1),kind:t.literal("store.call"),id:t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),method:t.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:t.array(t.unknown()).max(STORE_CALL_LIMITS.args),launchKey:t.string().min(16).max(512),observe:t.strictObject({intervalMs:t.number().int().min(0).max(864e5).optional(),snapshot:t.strictObject({branch:t.string().max(300).nullable(),head:t.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/).nullable(),files:t.array(t.strictObject({path:t.string().min(1).max(4096),from:t.string().max(4096).optional(),status:t.string().max(2),staged:U.optional(),unstaged:U.optional()})).max(1e3),truncated:t.boolean()}).optional(),failed:t.literal(!0).optional()}).optional()}),StoreReplySchema=t.strictObject({v:t.literal(1),kind:t.literal("store.reply"),id:t.string().max(100),wrote:t.boolean(),result:t.unknown().optional(),error:t.strictObject({name:t.enum(["CoordinationError","CapacityRefusal","CoordinationBusyError","StoreCallRefused","Error"]),message:t.string().max(4e3),room:t.record(t.string(),t.unknown()).optional(),step:t.enum(["open","write","commit","read"]).optional(),waitedMs:t.number().nonnegative().optional(),tries:t.number().int().nonnegative().optional(),wrote:t.boolean().optional(),where:t.string().max(300).optional(),wal:t.boolean().optional()}).optional()}),REMOTE_INSTANCE_BODY_SCHEMAS={"instance.tunnel.open":t.strictObject({tunnelId:t.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),instanceId:t.string().regex($)}),"instance.state":t.strictObject({instanceId:t.string().regex($),state:t.enum(["up","gone"]),apex:t.string().max(253).regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\.localhost$/).startsWith(at).optional(),dashboardBase:t.string().regex(nt).optional(),at:n,why:t.string().max(500).regex(s).optional()})},PEER_LAUNCH_LIMITS={promptChars:64*1024,roleTextChars:64*1024,maxMinutes:720,tailLines:40,tailLineChars:400},PEER_LAUNCH_ID=/^ln-[a-z0-9]{1,12}-[a-f0-9]{6}$/;const x=t.string().regex(PEER_LAUNCH_ID),ct=t.string().regex(PEER_LAUNCH_KEY_PATTERN),K=t.string().regex(/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i),pt=t.string().regex(/^[a-z][a-z0-9-]{0,39}$/),V=i(e=>t.string().min(1).max(e).regex(/^[A-Za-z0-9][A-Za-z0-9._:/@[\]-]*$/),"clientWord"),R=t.string().min(2).max(1024).regex(/^\/[^\0\r\n]*$/).refine(e=>!e.split("/").includes(".."),"no .. part"),I=t.string().min(1).max(100).regex(/^[A-Za-z0-9._:-]+$/);export const PEER_LAUNCH_SCHEMAS={"launch.start":t.strictObject({launchId:x,repository:y,goal:I,task:K.optional(),role:pt,by:I,client:t.enum(["claude","codex"]),model:V(80).optional(),effort:V(40).optional(),worktree:R.optional(),placedGoal:t.literal(!0).optional(),prompt:t.string().min(1).max(PEER_LAUNCH_LIMITS.promptChars),roleText:t.string().max(PEER_LAUNCH_LIMITS.roleTextChars).optional(),name:t.string().min(1).max(80).regex(s).optional(),maxMinutes:t.number().int().min(1).max(PEER_LAUNCH_LIMITS.maxMinutes),account:t.string().regex(/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/).optional(),launchKey:ct,lensmcp:l,resume:t.strictObject({launchId:x,threadId:K,from:R.optional()}).optional(),capKind:t.enum(["writers","checkers"]).optional()}).refine(e=>e.worktree===void 0!=(e.placedGoal===void 0),"a launch names its worktree, or that its goal is placed there \u2014 exactly one"),"launch.stop":t.strictObject({launchId:x,why:t.string().max(300).regex(s).optional()}),"launch.state":t.strictObject({launchId:x,state:t.enum(["running","exited","stopped","failed"]),at:n,pid:t.number().int().min(0).max(99999999).optional(),exitCode:t.number().int().min(-1).max(1024).optional(),endedAt:n.optional(),threadId:I.optional(),ended:t.strictObject({quota:t.strictObject({client:t.enum(["claude","codex"]),why:t.string().min(1).max(300),until:n,firstTurn:t.boolean(),account:t.string().max(40).optional()}).optional(),context:t.string().min(1).max(600).optional()}).optional()}),"launch.tail":t.strictObject({launchId:x,lines:t.array(t.string().max(PEER_LAUNCH_LIMITS.tailLineChars+8)).max(PEER_LAUNCH_LIMITS.tailLines),at:n})},LaunchStartedSchema=t.strictObject({started:t.literal(!0),pid:t.number().int().min(2).max(99999999),worktree:R,branch:t.string().max(250).optional(),startedAt:n,deadline:n,threadId:t.string().max(200).optional(),lensmcp:l}),STORE_READ_LIMITS={calls:24,argsBytes:64*1024,answerBytes:STORE_CALL_LIMITS.answerBytes},StoreReadSchema=t.strictObject({v:t.literal(1),kind:t.literal("store.read"),id:t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),repoId:t.string().regex(/^[0-9a-f]{16,64}$/),calls:t.array(t.strictObject({method:t.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:t.array(t.unknown()).max(STORE_CALL_LIMITS.args)})).min(1).max(STORE_READ_LIMITS.calls)}),GOAL_ON_WORKER={maxSendBytes:512*1024*1024,maxChangesBytes:400*1024,branchPrefix:"lensmcp/g-"};const _=t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),q=t.strictObject({id:t.string().regex(/^[0-9a-f]{16}$/),size:t.number().int().positive().max(64*1024*1024*1024),sha256:t.string().regex(/^[0-9a-f]{64}$/)}),mt=t.string().min(1).max(200).regex(/^lensmcp\/g-[a-z0-9-]{1,30}$/),g=t.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),F=t.string().regex(/^[0-9a-f]{16,64}$/),A=t.string().max(1e3);export const GOAL_PEER_SCHEMAS={"goal.place":t.strictObject({goal:_,title:t.string().min(1).max(300).regex(s),repository:F,worktreeId:t.string().regex(/^[0-9a-f]{24}$/),name:t.string().regex(/^g-[a-z0-9](?:[a-z0-9-]{0,17}[a-z0-9])?$/),branch:mt,base:g,bundle:q,services:t.enum(["on-demand","none","always"]).optional(),at:n}),"goal.sent":t.strictObject({bundleId:t.string().regex(/^[0-9a-f]{16}$/),repository:F,goal:_,ref:t.string().min(1).max(250).regex(/^heads\/lensmcp\/g-[a-z0-9-]{1,30}$/),size:t.number().int().positive().max(GOAL_ON_WORKER.maxSendBytes),sha256:t.string().regex(/^[0-9a-f]{64}$/)}),"goal.changes":t.strictObject({goal:_,what:t.enum(["row","files","diff","commits","commit","against"]),path:t.string().min(1).max(4096).optional(),sha:g.optional(),full:t.boolean().optional(),againstMain:t.boolean().optional()}),"goal.update":t.strictObject({goal:_,main:t.strictObject({branch:t.string().min(1).max(200).regex(/^[A-Za-z0-9._/-]+$/),sha:g,bundle:q}),at:n})},GOAL_PEER_ANSWER_SCHEMAS={"goal.place":t.strictObject({state:t.enum(["ready","creating","failed"]),head:g.optional(),onDemand:t.boolean().optional(),needWhole:t.boolean().optional(),why:A.optional()}),"goal.sent":t.strictObject({took:t.boolean(),ref:t.string().max(250),sha:g.optional(),mirror:t.enum(["created","fast-forward","current","not-ff","checked-out"]).optional(),told:t.string().max(200).optional(),code:t.string().max(40).optional(),why:A.optional()}),"goal.changes":t.strictObject({ok:t.boolean(),value:t.unknown().optional(),status:t.number().int().min(100).max(599).optional(),why:A.optional(),shortened:t.boolean().optional()}),"goal.update":t.strictObject({outcome:t.enum(["current","merged","asked","conflicts","refused"]),why:A,sha:g.optional(),behind:t.number().int().min(0).max(1e7).optional(),dirty:t.number().int().min(0).max(1e7).optional(),conflicts:t.array(t.string().min(1).max(4096)).max(200).optional(),needWhole:t.boolean().optional()})},CONVERSATION_PEER_LIMITS={messageBytes:384*1024,conversations:32,turns:500,settles:64,turnBytes:64*1024,targetChars:4096,beatBytes:1024*1024,beatConversations:64,readTokens:6e4};const S=t.string().regex(tt),Y=t.string().regex(/^[0-9a-f]{16,64}$/),a=i(e=>t.string().max(e),"cvWords"),k=t.number().int().min(1).max(Number.MAX_SAFE_INTEGER),gt=t.strictObject({id:S,client:t.enum(["claude","codex"]),nativeId:t.string().regex(/^[\w.-]{8,128}$/),account:t.string().min(1).max(4200),accountNick:a(200).optional(),checkout:t.strictObject({root:t.string().min(1).max(4096),branch:a(300).optional(),key:a(300).optional()}),cwd:a(4096).optional(),model:a(200).optional(),startedAt:n,lastAt:n,state:t.enum(["running","ended","kept"]),kind:t.enum(["person","team","outside"]).optional(),sessionId:a(200).optional(),launchId:a(200).optional(),role:a(80).optional(),goalId:a(120).optional(),goalTitle:a(300).optional(),taskId:a(120).optional(),continues:S.optional()}),dt=t.strictObject({seq:k,at:n.optional(),kind:t.enum(["prompt","reply","tool","compaction","subagent"]),text:a(et),cut:t.literal(!0).optional(),tool:t.strictObject({name:t.string().min(1).max(200),target:a(CONVERSATION_PEER_LIMITS.targetChars).optional(),outcome:t.enum(["ok","error"]).optional(),output:a(N).optional()}).optional(),files:t.array(t.string().min(1).max(4096)).max(50).optional()}),ut=t.strictObject({checkout:a(400).min(1).optional(),goalId:a(120).min(1).optional(),taskId:a(120).min(1).optional(),role:a(80).min(1).optional(),client:t.enum(["claude","codex"]).optional(),account:a(4200).min(1).optional(),mac:a(128).min(1).optional(),state:t.enum(["running","ended","kept"]).optional(),since:n.optional(),text:a(400).min(1).optional(),limit:t.number().int().min(1).max(M).optional()}),h=t.record(t.string(),t.unknown()),bt=t.discriminatedUnion("what",[t.strictObject({what:t.literal("list"),query:ut}),t.strictObject({what:t.literal("get"),id:t.string().min(1).max(200),part:t.enum(["handoff","turns"]),maxTokens:t.number().int().min(500).max(1e5).optional(),before:k.optional()})]);export const CONVERSATION_PEER_SCHEMAS={"conversation.sync":t.strictObject({v:t.literal(1),kind:t.literal("conversation.sync"),repository:Y,macBasis:t.string().regex(/^[\w-]{8,128}$/),conversations:t.array(t.strictObject({row:gt,turns:t.array(dt).max(CONVERSATION_PEER_LIMITS.turns),settles:t.array(t.strictObject({seq:k,outcome:t.enum(["ok","error"]),output:a(N).optional()})).max(CONVERSATION_PEER_LIMITS.settles).optional(),rewound:t.literal(!0).optional()})).min(1).max(CONVERSATION_PEER_LIMITS.conversations)}),"conversation.read":t.strictObject({v:t.literal(1),kind:t.literal("conversation.read"),repository:Y,ask:bt})},CONVERSATION_PEER_ANSWER_SCHEMAS={"conversation.sync":t.strictObject({v:t.literal(1),held:t.array(t.strictObject({id:S,seq:t.number().int().min(0),refused:a(500).optional()})).max(CONVERSATION_PEER_LIMITS.conversations)}),"conversation.read":t.strictObject({v:t.literal(1),from:t.strictObject({name:t.string().min(1).max(64).regex(s),fingerprint:t.string().regex(FINGERPRINT_PATTERN).optional()}),found:t.boolean(),why:a(1e3).optional(),list:t.object({conversations:t.array(h).max(M),more:t.boolean()}).passthrough().optional(),handoff:t.object({conversation:h,turns:t.array(h),more:t.boolean(),next:t.string()}).passthrough().optional(),page:t.object({conversation:h,turns:t.array(h),more:t.boolean()}).passthrough().optional()})};
|
|
1
|
+
"use strict";var Y=Object.defineProperty;var w=(e,o)=>Y(e,"name",{value:o,configurable:!0});var X=Object.defineProperty,i=w((e,o)=>X(e,"name",{value:o,configurable:!0}),"i");import{z as t}from"zod";import{RUN_ID_PATTERN as T}from"./docker-jobs.js";import{CONVERSATION_ID as J,CONVERSATION_LIST_MAX as D,CONVERSATION_TOOL_OUTPUT_CHARS as M,CONVERSATION_TURN_CHARS as Q}from"./conversations.js";import{REMOTE_DASHBOARD_BASE_PATTERN as tt,REMOTE_INSTANCE_ID_PATTERN as N,REMOTE_INSTANCE_NAME_PREFIX as et}from"./remote-instances.js";export const PEER_PROTOCOL="peer/v1",PEER_PORT=7466,PEER_TIMING={pingMs:5e3,lostMs:45e3,windowMs:10*6e4,approveMs:10*6e4,capacityMs:3e4},PAIRING_CODE={length:10,tries:5},CROCKFORD_ALPHABET="0123456789ABCDEFGHJKMNPQRSTVWXYZ",PEER_PATHS={pair:"/peer/v1/pair",control:"/peer/v1/control",runs:"/peer/v1/runs/",bundles:"/peer/v1/bundles/",sent:"/peer/v1/sent/",tunnel:"/peer/v1/tunnel/"},RUN_UPLOAD_KINDS=["log","samples","events","artifacts"],RUN_UPLOAD_RANGE={from:"x-lensmcp-from",to:"x-lensmcp-to"},PEER_FILES={dir:"peers",key:"identity.key",cert:"identity.crt",window:"window.json",workers:"workers.json",organizer:"organizer.json",hub:"hub.json",hubLock:"hub.lock",hubLog:"hub.log",runs:"runs",instances:"instances"},FINGERPRINT_PATTERN=/^[0-9a-f]{64}$/,REMOTE_RUN_LOST="lost",PEER_MESSAGE_ID=/^[A-Za-z0-9_-]{1,64}$/,TO_WORKER=["job.offer","job.cancel","bundle.ready","tunnel.open","tunnel.close","launch.start","launch.stop","store.reply","version.install","main.moved","instance.tunnel.open","goal.place","goal.changes","goal.update"],TO_ORGANIZER=["hello","capacity","job.state","job.stage","job.done","bundle.sent","launch.state","launch.tail","store.call","version.state","forget","main.state","instance.state","store.read","goal.sent","conversation.sync","conversation.read"],EITHER_WAY=["ping"],PEER_REPLIES=["ack","error","pong"],PEER_MESSAGE_SLICE={hello:"D12 (versions: D13, capacity: D14)",ping:"D12",pong:"D12",ack:"D12",error:"D12",forget:"D11",capacity:"D14","job.offer":"D14","job.cancel":"D14/D18","job.state":"D14/D16","job.stage":"D16","job.done":"D16","bundle.ready":"D15","bundle.sent":"D34 (goal branches: D30)","tunnel.open":"D17","tunnel.close":"D17","launch.start":"D29","launch.stop":"D29","launch.state":"D29","launch.tail":"D29","store.call":"D27/D28","store.reply":"D27/D28","version.install":"D13","version.state":"D13","main.moved":"D34","main.state":"D34","instance.tunnel.open":"D35","instance.state":"D35 (sent by D30)","store.read":"D32","goal.place":"D30","goal.sent":"D30","goal.changes":"D30","goal.update":"D30","conversation.sync":"CV5","conversation.read":"CV5"};const f=i((e,o)=>e.includes(o),"has");export const isPeerMessageType=i(e=>Object.prototype.hasOwnProperty.call(PEER_MESSAGE_SLICE,e),"isPeerMessageType");export function peerMaySend(e,o){return f(EITHER_WAY,o)||f(PEER_REPLIES,o)?!0:f(e==="organizer"?TO_WORKER:TO_ORGANIZER,o)}w(peerMaySend,"peerMaySend"),i(peerMaySend,"peerMaySend");export const isPeerReply=i(e=>f(PEER_REPLIES,e),"isPeerReply");const s=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,d=i(e=>t.string().min(1).max(e).regex(s),"shownText"),$=t.string().regex(/^[A-Za-z0-9_-]{43}$/),C=t.string().regex(/^[0-9a-f]{64}$/),l=t.string().min(1).max(64).regex(/^[0-9A-Za-z.+_-]+$/),nt=t.tuple([t.string().regex(/^[a-z]{3,8}$/),t.string().regex(/^[a-z]{3,8}$/),t.string().regex(/^[a-z]{3,8}$/),t.string().regex(/^[a-z]{3,8}$/)]),n=t.number().int().nonnegative();export const PeerEnvelopeSchema=t.strictObject({v:t.literal(1),id:t.string().regex(PEER_MESSAGE_ID),replyTo:t.string().regex(PEER_MESSAGE_ID).optional(),type:t.string().min(1).max(40),body:t.record(t.string(),t.unknown())});const at=["unknown-type","wrong-direction","bad-message","hello-first","not-handled","too-large","busy","refused","timeout","lost","internal","no-window","window-used","window-closed","wrong-code","protocol"];export const PeerErrorBodySchema=t.strictObject({code:t.enum(at),message:t.string().max(500),triesLeft:t.number().int().min(0).max(PAIRING_CODE.tries).optional(),retryAfterMs:t.number().int().min(0).max(36e5).optional()});const p=t.string().regex(T);export const WorkerAdvertSchema=t.record(t.string(),t.unknown()).superRefine((e,o)=>{const O=e.runs;O!==void 0&&(!Array.isArray(O)||O.length>256||!O.every(z=>typeof z=="string"&&T.test(z)))&&o.addIssue({code:"custom",message:"runs: at most 256 run ids"})}),PEER_BODY_SCHEMAS={hello:t.strictObject({protocol:t.literal(PEER_PROTOCOL),lensmcp:l,follow:t.boolean().optional(),store:t.array(l).max(64).optional(),capacity:WorkerAdvertSchema.optional()}),ping:t.strictObject({at:n}),pong:t.strictObject({at:n}),ack:t.strictObject({result:t.unknown().optional()}),error:PeerErrorBodySchema,forget:t.strictObject({why:t.string().max(200).regex(s).optional()})},PeerWelcomeSchema=t.strictObject({protocol:t.literal(PEER_PROTOCOL),lensmcp:l,name:d(64),inStep:t.boolean().optional(),why:t.string().max(500).optional()}),PAIR_BODY_SCHEMAS={"pair.hello":t.strictObject({protocol:t.literal(PEER_PROTOCOL),nonce:$,name:d(64),model:d(40),lensmcp:l}),"pair.resume":t.strictObject({protocol:t.literal(PEER_PROTOCOL)}),"pair.challenge":t.strictObject({nonce:$}),"pair.proof":t.strictObject({proof:C}),"pair.accepted":t.strictObject({proof:C,name:d(64),model:d(40),words:nt,approveBy:n}),"pair.approved":t.strictObject({at:n}),"pair.declined":t.strictObject({why:t.string().max(500)}),error:PeerErrorBodySchema},MAIN_MIRROR={branch:"main",quietMs:10*6e4,snapshotEveryMs:60*6e4,maxSendBytes:512*1024*1024,maxWipBytes:256*1024*1024,maxHaves:16},MAIN_BRING_IN=["in-main","brought-in","waiting","not-ff","refused"],MAIN_FOLLOW_STATES=["in-step","fast-forward","ahead","waiting","to-update","not-following","off-branch"];const r=t.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),y=t.string().regex(/^[0-9a-f]{16,64}$/),P=t.string().regex(/^[0-9a-f]{64}$/),L=t.string().regex(/^[0-9a-f]{16}$/),u=t.number().int().min(0).max(1e7),j=t.string().min(1).max(250).regex(/^[A-Za-z0-9._/-]+$/),E=t.string().max(1e3),Z=t.strictObject({state:t.enum(["in-main","brought-in","waiting","not-ff","refused"]),count:u,sha:r.optional(),main:r.optional(),why:E,at:n}),ot=t.strictObject({outcome:t.enum(["merged","fast-forward","current","conflicts","waiting","refused"]),at:n,why:E,sha:r.optional(),conflicts:t.array(t.string().min(1).max(4096)).max(200).optional(),asked:t.array(t.strictObject({who:t.enum(["person","manager"]),goal:t.string().max(64).optional(),to:t.string().max(200).optional()})).max(20).optional()}),B=t.enum(["in-step","fast-forward","ahead","waiting","to-update","not-following","off-branch"]);export const MAIN_MIRROR_SCHEMAS={"bundle.sent":t.strictObject({bundleId:L,repository:y,refs:t.array(j).length(1),size:t.number().int().positive().max(MAIN_MIRROR.maxSendBytes),sha256:P}),"main.moved":t.strictObject({repository:y,branch:j,sha:r,bundle:t.strictObject({id:L,size:t.number().int().positive(),sha256:P}),verdict:Z.optional(),at:n}),"main.state":t.strictObject({repository:y,branch:j,head:r.optional(),organizerHead:r.optional(),haves:t.array(r).max(MAIN_MIRROR.maxHaves),notSent:u,toPull:u,uncommitted:t.strictObject({files:u,changedAt:n.optional()}),snapshot:t.strictObject({sha:r,at:n,files:u,sent:t.boolean()}).optional(),follow:B,update:ot.optional(),at:n})},MAIN_MIRROR_ANSWER_SCHEMAS={"bundle.sent":t.strictObject({took:t.boolean(),ref:j,sha:r.optional(),code:t.string().max(40).optional(),why:E.optional(),verdict:Z.optional()}),"main.moved":t.strictObject({took:t.boolean(),needWhole:t.boolean().optional(),why:E.optional(),follow:B.optional(),head:r.optional()})};const rt=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/),v=t.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),H=t.string().regex(/^[0-9a-f]{16,64}$/),b=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),W=i(e=>t.string().min(1).max(e).regex(s),"sentence"),m=t.record(t.string(),t.unknown()),it=t.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,99}$/),c=t.strictObject({lensmcp:l,protocol:t.string().regex(/^peer\/v[1-9]\d{0,3}$/)});export const PEER_WORK_SCHEMAS={capacity:WorkerAdvertSchema,"job.offer":t.strictObject({runId:p,job:rt,candidate:v,repository:H,lane:t.enum(["light","heavy"]).optional(),kind:t.enum(["compose","testcontainers","playwright"]).optional(),hostMb:t.number().int().min(0).max(1024*1024).optional(),vmMb:t.number().int().min(0).max(1024*1024).optional(),proof:t.boolean().optional(),timeoutMinutes:t.number().positive().max(360).optional(),onLinkLoss:t.union([t.literal("cancel"),t.strictObject({continueMinutes:t.number().int().min(1).max(360)})]).optional(),secrets:t.record(it,t.string().min(1).max(8192)).refine(e=>Object.keys(e).length<=16,"at most 16 secrets").optional(),origin:t.string().max(300).regex(/^https?:\/\/[A-Za-z0-9.-]+(?::\d{1,5})?$/).optional()}),"job.cancel":t.strictObject({runId:p,why:W(300)}),"job.state":t.strictObject({runId:p,at:n,started:t.literal(!0).optional(),state:t.enum(["queued","running"]).optional(),note:t.string().max(1e3).optional(),queue:m.optional(),docker:m.optional(),edgePort:t.number().int().min(1024).max(65535).optional()}),"job.stage":t.strictObject({runId:p,stage:W(120),at:n}),"job.done":t.strictObject({runId:p,at:n,state:t.enum(["passed","failed","errored","cancelled","timeout"]),note:t.string().max(1e3).optional(),step:m.optional(),docker:m.optional(),givenBack:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),refused:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),proof:m.optional()}),"bundle.ready":t.strictObject({runId:p.optional(),bundleId:b,repository:H,heads:t.array(v).min(1).max(16),basis:t.array(v).max(256).optional(),size:t.number().int().positive().max(64*1024*1024*1024),sha256:t.string().regex(/^[0-9a-f]{64}$/),shipment:m.optional(),blobs:t.record(t.string().regex(/^[0-9a-f]{64}$/),b).refine(e=>Object.keys(e).length<=101,"at most 101 blobs").optional()}),"tunnel.open":t.strictObject({tunnelId:b,runId:p,port:t.number().int().min(1).max(65535).optional()}),"tunnel.close":t.strictObject({tunnelId:b,why:t.string().max(300).optional()}),"version.install":t.strictObject({version:l,from:t.enum(["registry","organizer"]),tarball:t.strictObject({bundleId:b,sha256:t.string().regex(/^[0-9a-f]{64}$/),size:t.number().int().positive().max(8*1024*1024*1024)}).optional()}),"version.state":t.discriminatedUnion("state",[t.strictObject({state:t.literal("in-step"),worker:c,organizer:c}),t.strictObject({state:t.literal("installing"),worker:c,organizer:c,from:t.enum(["registry","organizer"]),since:n}),t.strictObject({state:t.literal("waiting-for-person"),worker:c,organizer:c,stored:t.boolean()}),t.strictObject({state:t.literal("out-of-step"),worker:c,organizer:c,why:t.object({kind:t.enum(["protocol","version","installed","restarting","install-failed","restart-failed","no-store"])}).catchall(t.union([t.string().max(600),t.number(),t.boolean()]))})])},STORE_CALL_LIMITS={args:16,argsBytes:256*1024,answerBytes:480*1024},PEER_LAUNCH_KEY_PATTERN=/^[A-Za-z0-9_-]{43}$/;const G=t.strictObject({added:t.number().int().nonnegative().nullable(),removed:t.number().int().nonnegative().nullable()});export const StoreCallSchema=t.strictObject({v:t.literal(1),kind:t.literal("store.call"),id:t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),method:t.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:t.array(t.unknown()).max(STORE_CALL_LIMITS.args),launchKey:t.string().min(16).max(512),observe:t.strictObject({intervalMs:t.number().int().min(0).max(864e5).optional(),snapshot:t.strictObject({branch:t.string().max(300).nullable(),head:t.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/).nullable(),files:t.array(t.strictObject({path:t.string().min(1).max(4096),from:t.string().max(4096).optional(),status:t.string().max(2),staged:G.optional(),unstaged:G.optional()})).max(1e3),truncated:t.boolean()}).optional(),failed:t.literal(!0).optional()}).optional()}),StoreReplySchema=t.strictObject({v:t.literal(1),kind:t.literal("store.reply"),id:t.string().max(100),wrote:t.boolean(),result:t.unknown().optional(),error:t.strictObject({name:t.enum(["CoordinationError","CapacityRefusal","CoordinationBusyError","StoreCallRefused","Error"]),message:t.string().max(4e3),room:t.record(t.string(),t.unknown()).optional(),step:t.enum(["open","write","commit","read"]).optional(),waitedMs:t.number().nonnegative().optional(),tries:t.number().int().nonnegative().optional(),wrote:t.boolean().optional(),where:t.string().max(300).optional(),wal:t.boolean().optional()}).optional()}),REMOTE_INSTANCE_BODY_SCHEMAS={"instance.tunnel.open":t.strictObject({tunnelId:t.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),instanceId:t.string().regex(N)}),"instance.state":t.strictObject({instanceId:t.string().regex(N),state:t.enum(["up","gone"]),apex:t.string().max(253).regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\.localhost$/).startsWith(et).optional(),dashboardBase:t.string().regex(tt).optional(),at:n,why:t.string().max(500).regex(s).optional()})},PEER_LAUNCH_LIMITS={promptChars:64*1024,roleTextChars:64*1024,maxMinutes:720,tailLines:40,tailLineChars:400},PEER_LAUNCH_ID=/^ln-[a-z0-9]{1,12}-[a-f0-9]{6}$/;const x=t.string().regex(PEER_LAUNCH_ID),st=t.string().regex(PEER_LAUNCH_KEY_PATTERN),U=t.string().regex(/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i),lt=t.string().regex(/^[a-z][a-z0-9-]{0,39}$/),K=i(e=>t.string().min(1).max(e).regex(/^[A-Za-z0-9][A-Za-z0-9._:/@[\]-]*$/),"clientWord"),R=t.string().min(2).max(1024).regex(/^\/[^\0\r\n]*$/).refine(e=>!e.split("/").includes(".."),"no .. part"),I=t.string().min(1).max(100).regex(/^[A-Za-z0-9._:-]+$/);export const PEER_LAUNCH_SCHEMAS={"launch.start":t.strictObject({launchId:x,repository:y,goal:I,task:U.optional(),role:lt,by:I,client:t.enum(["claude","codex"]),model:K(80).optional(),effort:K(40).optional(),worktree:R.optional(),placedGoal:t.literal(!0).optional(),prompt:t.string().min(1).max(PEER_LAUNCH_LIMITS.promptChars),roleText:t.string().max(PEER_LAUNCH_LIMITS.roleTextChars).optional(),name:t.string().min(1).max(80).regex(s).optional(),maxMinutes:t.number().int().min(1).max(PEER_LAUNCH_LIMITS.maxMinutes),account:t.string().regex(/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/).optional(),launchKey:st,lensmcp:l,resume:t.strictObject({launchId:x,threadId:U,from:R.optional()}).optional(),capKind:t.enum(["writers","checkers"]).optional()}).refine(e=>e.worktree===void 0!=(e.placedGoal===void 0),"a launch names its worktree, or that its goal is placed there \u2014 exactly one"),"launch.stop":t.strictObject({launchId:x,why:t.string().max(300).regex(s).optional()}),"launch.state":t.strictObject({launchId:x,state:t.enum(["running","exited","stopped","failed"]),at:n,pid:t.number().int().min(0).max(99999999).optional(),exitCode:t.number().int().min(-1).max(1024).optional(),endedAt:n.optional(),threadId:I.optional(),ended:t.strictObject({quota:t.strictObject({client:t.enum(["claude","codex"]),why:t.string().min(1).max(300),until:n,firstTurn:t.boolean(),account:t.string().max(40).optional()}).optional(),context:t.string().min(1).max(600).optional()}).optional()}),"launch.tail":t.strictObject({launchId:x,lines:t.array(t.string().max(PEER_LAUNCH_LIMITS.tailLineChars+8)).max(PEER_LAUNCH_LIMITS.tailLines),at:n})},LaunchStartedSchema=t.strictObject({started:t.literal(!0),pid:t.number().int().min(2).max(99999999),worktree:R,branch:t.string().max(250).optional(),startedAt:n,deadline:n,threadId:t.string().max(200).optional(),lensmcp:l}),STORE_READ_LIMITS={calls:24,argsBytes:64*1024,answerBytes:STORE_CALL_LIMITS.answerBytes},StoreReadSchema=t.strictObject({v:t.literal(1),kind:t.literal("store.read"),id:t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),repoId:t.string().regex(/^[0-9a-f]{16,64}$/),calls:t.array(t.strictObject({method:t.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:t.array(t.unknown()).max(STORE_CALL_LIMITS.args)})).min(1).max(STORE_READ_LIMITS.calls)}),GOAL_ON_WORKER={maxSendBytes:512*1024*1024,maxChangesBytes:400*1024,branchPrefix:"lensmcp/g-"};const _=t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),V=t.strictObject({id:t.string().regex(/^[0-9a-f]{16}$/),size:t.number().int().positive().max(64*1024*1024*1024),sha256:t.string().regex(/^[0-9a-f]{64}$/)}),ct=t.string().min(1).max(200).regex(/^lensmcp\/g-[a-z0-9-]{1,30}$/),g=t.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),q=t.string().regex(/^[0-9a-f]{16,64}$/),A=t.string().max(1e3);export const GOAL_PEER_SCHEMAS={"goal.place":t.strictObject({goal:_,title:t.string().min(1).max(300).regex(s),repository:q,worktreeId:t.string().regex(/^[0-9a-f]{24}$/),name:t.string().regex(/^g-[a-z0-9](?:[a-z0-9-]{0,17}[a-z0-9])?$/),branch:ct,base:g,bundle:V,services:t.enum(["on-demand","none","always"]).optional(),at:n}),"goal.sent":t.strictObject({bundleId:t.string().regex(/^[0-9a-f]{16}$/),repository:q,goal:_,ref:t.string().min(1).max(250).regex(/^heads\/lensmcp\/g-[a-z0-9-]{1,30}$/),size:t.number().int().positive().max(GOAL_ON_WORKER.maxSendBytes),sha256:t.string().regex(/^[0-9a-f]{64}$/)}),"goal.changes":t.strictObject({goal:_,what:t.enum(["row","files","diff","commits","commit","against"]),path:t.string().min(1).max(4096).optional(),sha:g.optional(),full:t.boolean().optional(),againstMain:t.boolean().optional()}),"goal.update":t.strictObject({goal:_,main:t.strictObject({branch:t.string().min(1).max(200).regex(/^[A-Za-z0-9._/-]+$/),sha:g,bundle:V}),at:n})},GOAL_PEER_ANSWER_SCHEMAS={"goal.place":t.strictObject({state:t.enum(["ready","creating","failed"]),head:g.optional(),onDemand:t.boolean().optional(),needWhole:t.boolean().optional(),why:A.optional()}),"goal.sent":t.strictObject({took:t.boolean(),ref:t.string().max(250),sha:g.optional(),mirror:t.enum(["created","fast-forward","current","not-ff","checked-out"]).optional(),told:t.string().max(200).optional(),code:t.string().max(40).optional(),why:A.optional()}),"goal.changes":t.strictObject({ok:t.boolean(),value:t.unknown().optional(),status:t.number().int().min(100).max(599).optional(),why:A.optional(),shortened:t.boolean().optional()}),"goal.update":t.strictObject({outcome:t.enum(["current","merged","asked","conflicts","refused"]),why:A,sha:g.optional(),behind:t.number().int().min(0).max(1e7).optional(),dirty:t.number().int().min(0).max(1e7).optional(),conflicts:t.array(t.string().min(1).max(4096)).max(200).optional(),needWhole:t.boolean().optional()})},CONVERSATION_PEER_LIMITS={messageBytes:384*1024,conversations:32,turns:500,settles:64,turnBytes:64*1024,targetChars:4096,beatBytes:1024*1024,beatConversations:64,readTokens:6e4};const S=t.string().regex(J),F=t.string().regex(/^[0-9a-f]{16,64}$/),a=i(e=>t.string().max(e),"cvWords"),k=t.number().int().min(1).max(Number.MAX_SAFE_INTEGER),pt=t.strictObject({id:S,client:t.enum(["claude","codex"]),nativeId:t.string().regex(/^[\w.-]{8,128}$/),account:t.string().min(1).max(4200),accountNick:a(200).optional(),checkout:t.strictObject({root:t.string().min(1).max(4096),branch:a(300).optional(),key:a(300).optional()}),cwd:a(4096).optional(),model:a(200).optional(),startedAt:n,lastAt:n,state:t.enum(["running","ended","kept"]),kind:t.enum(["person","team","outside"]).optional(),sessionId:a(200).optional(),launchId:a(200).optional(),role:a(80).optional(),goalId:a(120).optional(),goalTitle:a(300).optional(),taskId:a(120).optional(),continues:S.optional()}),mt=t.strictObject({seq:k,at:n.optional(),kind:t.enum(["prompt","reply","tool","compaction","subagent"]),text:a(Q),cut:t.literal(!0).optional(),tool:t.strictObject({name:t.string().min(1).max(200),target:a(CONVERSATION_PEER_LIMITS.targetChars).optional(),outcome:t.enum(["ok","error"]).optional(),output:a(M).optional()}).optional(),files:t.array(t.string().min(1).max(4096)).max(50).optional()}),gt=t.strictObject({checkout:a(400).min(1).optional(),goalId:a(120).min(1).optional(),taskId:a(120).min(1).optional(),role:a(80).min(1).optional(),client:t.enum(["claude","codex"]).optional(),account:a(4200).min(1).optional(),mac:a(128).min(1).optional(),state:t.enum(["running","ended","kept"]).optional(),since:n.optional(),text:a(400).min(1).optional(),limit:t.number().int().min(1).max(D).optional()}),h=t.record(t.string(),t.unknown()),dt=t.discriminatedUnion("what",[t.strictObject({what:t.literal("list"),query:gt}),t.strictObject({what:t.literal("get"),id:t.string().min(1).max(200),part:t.enum(["handoff","turns"]),maxTokens:t.number().int().min(500).max(1e5).optional(),before:k.optional()})]);export const CONVERSATION_PEER_SCHEMAS={"conversation.sync":t.strictObject({v:t.literal(1),kind:t.literal("conversation.sync"),repository:F,macBasis:t.string().regex(/^[\w-]{8,128}$/),conversations:t.array(t.strictObject({row:pt,turns:t.array(mt).max(CONVERSATION_PEER_LIMITS.turns),settles:t.array(t.strictObject({seq:k,outcome:t.enum(["ok","error"]),output:a(M).optional()})).max(CONVERSATION_PEER_LIMITS.settles).optional(),rewound:t.literal(!0).optional()})).min(1).max(CONVERSATION_PEER_LIMITS.conversations)}),"conversation.read":t.strictObject({v:t.literal(1),kind:t.literal("conversation.read"),repository:F,ask:dt})},CONVERSATION_PEER_ANSWER_SCHEMAS={"conversation.sync":t.strictObject({v:t.literal(1),held:t.array(t.strictObject({id:S,seq:t.number().int().min(0),refused:a(500).optional()})).max(CONVERSATION_PEER_LIMITS.conversations)}),"conversation.read":t.strictObject({v:t.literal(1),from:t.strictObject({name:t.string().min(1).max(64).regex(s),fingerprint:t.string().regex(FINGERPRINT_PATTERN).optional()}),found:t.boolean(),why:a(1e3).optional(),list:t.object({conversations:t.array(h).max(D),more:t.boolean()}).passthrough().optional(),handoff:t.object({conversation:h,turns:t.array(h),more:t.boolean(),next:t.string()}).passthrough().optional(),page:t.object({conversation:h,turns:t.array(h),more:t.boolean()}).passthrough().optional()})};
|
package/lib/perf-rules.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var o=(r,e)=>u(r,"name",{value:e,configurable:!0});var c=Object.defineProperty,a=o((r,e)=>c(r,"name",{value:e,configurable:!0}),"o");export const PERF_RULE_IDS=["bundle/heavy-barrel-import","pod/heap-budget","pod/retained-generation"],PERF_RULE_EVENT_KINDS=["perf-rule-finding","perf-rule-retracted","perf-rule-scan"],PERF_RULES_DOC="https://github.com/kiwiapps-ltd/lensmcp/blob/main/docs/lensmcp/concepts/memory-and-build-cost.mdx",PERF_RULE_DOCS={"bundle/heavy-barrel-import":`${PERF_RULES_DOC}#bundleheavy-barrel-import`,"pod/heap-budget":`${PERF_RULES_DOC}#podheap-budget`,"pod/retained-generation":`${PERF_RULES_DOC}#podretained-generation`};export function perfRuleFingerprint(r,e,n){return`perf-rule:${r}:${e}:${n}`}o(perfRuleFingerprint,"perfRuleFingerprint"),a(perfRuleFingerprint,"perfRuleFingerprint");export function perfRuleScanFingerprint(r,e){return`perf-rule-scan:${r}:${e}`}o(perfRuleScanFingerprint,"perfRuleScanFingerprint"),a(perfRuleScanFingerprint,"perfRuleScanFingerprint");const s=/^[a-z][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/,l=12,f=4e3,t=a((r,e=f)=>typeof r=="string"&&r.length>0&&r.length<=e,"isText");export function asPerfRuleRaw(r){if(!r||typeof r!="object")return;const e=r;if(!PERF_RULE_EVENT_KINDS.includes(e.kind)||typeof e.rule!="string"||!s.test(e.rule)||!t(e.project,512))return;if(e.kind==="perf-rule-scan"){const i=e.open;return!Array.isArray(i)||i.length>256||!i.every(p=>t(p,512))?void 0:r}if(!t(e.subject,512))return;if(e.kind==="perf-rule-retracted")return r;if(e.severity!=="warning"&&e.severity!=="error"||!t(e.title)||!t(e.summary)||!t(e.verify)||!t(e.docs,1024))return;const n=e.fix;if(!(!Array.isArray(n)||n.length===0||n.length>l||!n.every(i=>t(i)))&&!(!e.evidence||typeof e.evidence!="object"||Array.isArray(e.evidence))&&!(!e.cost||typeof e.cost!="object"||Array.isArray(e.cost)))return r}o(asPerfRuleRaw,"asPerfRuleRaw"),a(asPerfRuleRaw,"asPerfRuleRaw");
|
package/lib/pod-memory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=Object.defineProperty;var r=(o,e)=>t(o,"name",{value:e,configurable:!0});var d=Object.defineProperty,m=r((o,e)=>d(o,"name",{value:e,configurable:!0}),"r");export const POD_MEMORY_KINDS=["pod-memory","pod-memory-retained","pod-memory-released","pod-memory-exited"];export function asPodMemoryRaw(o){if(!o||typeof o!="object")return;const e=o;if(POD_MEMORY_KINDS.includes(e.kind)&&!(typeof e.project!="string"||!e.project)&&!(typeof e.pod!="number"||typeof e.pid!="number")&&!(e.kind==="pod-memory"&&(typeof e.live!="number"||!Number.isFinite(e.live)))&&!((e.kind==="pod-memory-retained"||e.kind==="pod-memory-released")&&typeof e.gen!="number"))return o}r(asPodMemoryRaw,"asPodMemoryRaw"),m(asPodMemoryRaw,"asPodMemoryRaw");
|
package/lib/producer-health.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var i=(t,o)=>m(t,"name",{value:o,configurable:!0});var R=Object.defineProperty,p=i((t,o)=>R(t,"name",{value:o,configurable:!0}),"u");import{z as e}from"zod";export const ProducerStateSchema=e.enum(["none","connected"]),ProducerRunStatusSchema=e.enum(["running","clean","failing","error"]),ProducerReportSchema=e.object({id:e.string(),tool:e.string(),project:e.string().optional(),firstReportedAt:e.number().int().nonnegative(),lastReportedAt:e.number().int().nonnegative(),lastRunStatus:ProducerRunStatusSchema,lastRunDurationMs:e.number().int().nonnegative().optional(),errorCount:e.number().int().nonnegative(),warningCount:e.number().int().nonnegative().optional(),error:e.string().optional()}),ProducerHealthSchema=e.object({producer:ProducerStateSchema,producers:e.array(ProducerReportSchema),lastReportedAt:e.number().int().nonnegative().optional(),ageMs:e.number().int().nonnegative().optional(),stale:e.boolean(),detail:e.string()}),PRODUCER_STALE_AFTER_MS=10*6e4;export function summariseProducers(t){const o=t.now??Date.now(),n=[...t.producers].sort((r,h)=>h.lastReportedAt-r.lastReportedAt);if(n.length===0)return{producer:"none",producers:[],stale:!1,detail:`No ${t.domain} producer has ever reported into this session \u2014 this is NOT a clean result, nothing is watching. ${t.noProducerHint}`};const d=n[0].lastReportedAt,u=Math.max(0,o-d),l=u>PRODUCER_STALE_AFTER_MS,c=n.filter(r=>r.lastRunStatus==="failing"),s=n.filter(r=>r.lastRunStatus==="error"),a=[`${n.length} ${t.domain} producer${n.length===1?"":"s"} reporting (${n.map(r=>r.id).join(", ")}); newest report ${g(u)}.`];return s.length>0&&a.push(`${s.length} produced NO verdict (the tool itself failed): ${s.map(r=>`${r.id} \u2014 ${r.error??"unknown error"}`).join("; ")}.`),c.length>0&&a.push(`${c.length} reporting errors.`),l&&a.push(`Older than ${Math.round(PRODUCER_STALE_AFTER_MS/6e4)}m \u2014 the verdict may predate the current source.`),{producer:"connected",producers:n,lastReportedAt:d,ageMs:u,stale:l,detail:a.join(" ")}}i(summariseProducers,"summariseProducers"),p(summariseProducers,"summariseProducers");function g(t){return t<1e3?"just now":t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}i(g,"g"),p(g,"describeAge");
|
package/lib/remote-instances.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=Object.defineProperty;var _=(E,e)=>t(E,"name",{value:e,configurable:!0});var n=Object.defineProperty,A=_((E,e)=>n(E,"name",{value:e,configurable:!0}),"t");export const REMOTE_INSTANCE_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,39}$/,REMOTE_INSTANCE_NAME_PREFIX="g-",MAX_REMOTE_INSTANCE_SEC=14400,REMOTE_LENS_LABEL="lensmcp",REMOTE_DASHBOARD_BASE_PATTERN=/^\/[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/,PEER_TUNNEL_HEADER="x-lensmcp-peer-tunnel";export function remoteLensHost(E){return`${REMOTE_LENS_LABEL}.${E.toLowerCase()}`}_(remoteLensHost,"remoteLensHost"),A(remoteLensHost,"remoteLensHost");export const REMOTE_INSTANCES_FILE="instances.json";
|