@lensmcp/protocol-types 1.26.36 → 1.26.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +7 -0
- package/index.js +1 -1
- package/lib/account-drain.js +1 -1
- package/lib/ai-cache-facts.js +1 -1
- package/lib/ai-cache-verdict.js +1 -1
- package/lib/ai-cache.js +3 -3
- package/lib/ai-call-groups.js +2 -2
- package/lib/ai-call-row.js +3 -3
- package/lib/ai-call.js +9 -9
- package/lib/ai-compare.js +3 -3
- package/lib/ai-context.js +6 -6
- package/lib/ai-origins.js +9 -9
- package/lib/ai-together.js +5 -5
- package/lib/bounded-clone.js +1 -1
- package/lib/bounded-map.js +1 -1
- package/lib/bounded-writer.js +1 -1
- package/lib/canvas-attachments.js +1 -1
- package/lib/canvas-catalog.d.ts +10 -5
- package/lib/canvas-catalog.js +1 -1
- package/lib/canvas-chat.js +2 -2
- package/lib/canvas-diagram.d.ts +130 -0
- package/lib/canvas-diagram.js +8 -0
- package/lib/canvas-editing.js +4 -4
- package/lib/canvas-frame-policy.js +1 -1
- package/lib/canvas-hub.js +1 -1
- package/lib/canvas.d.ts +9 -5
- package/lib/capture-demand.js +1 -1
- package/lib/dashboard-path.js +1 -1
- package/lib/dashboard.d.ts +2 -0
- package/lib/delivery-actions.d.ts +257 -0
- package/lib/delivery-actions.js +1 -0
- package/lib/delivery-status.d.ts +201 -4
- package/lib/docker-errors.js +1 -1
- package/lib/docker-jobs.js +1 -1
- package/lib/docker-report.js +2 -2
- package/lib/docker-runs.js +3 -3
- package/lib/error-cause.js +6 -6
- package/lib/error-dismissal.js +1 -1
- package/lib/error-verdict.js +3 -3
- package/lib/event-loop.js +1 -1
- package/lib/expected-failure.js +2 -2
- package/lib/finding-proof.js +1 -1
- package/lib/flood-guard.js +1 -1
- package/lib/goal-design.js +1 -1
- package/lib/goal-main-follow.d.ts +103 -0
- package/lib/goal-main-follow.js +1 -0
- package/lib/goal-number.js +1 -1
- package/lib/goal-process.d.ts +449 -0
- package/lib/goal-process.js +1 -0
- package/lib/goal-review.d.ts +126 -0
- package/lib/goal-review.js +6 -0
- package/lib/host-agents.js +1 -1
- package/lib/lens-hosts.js +1 -1
- package/lib/lint-coverage.js +1 -1
- package/lib/lint-ignores.js +2 -2
- package/lib/log-query.js +1 -1
- package/lib/metrics-reset.js +1 -1
- package/lib/overseer-findings.js +1 -1
- package/lib/peers.d.ts +31 -31
- package/lib/peers.js +1 -1
- package/lib/perf-rules.js +1 -1
- package/lib/pod-memory.js +1 -1
- package/lib/producer-health.js +1 -1
- package/lib/pull-requests.d.ts +33 -2
- package/lib/remote-instances.js +1 -1
- package/lib/source.d.ts +414 -0
- package/lib/source.js +1 -0
- package/lib/sources.js +1 -1
- package/lib/static-checks.js +1 -1
- package/lib/system-report.js +1 -1
- package/lib/team-decide.d.ts +191 -0
- package/lib/team-decide.js +1 -0
- package/lib/team-design.d.ts +43 -7
- package/lib/team-design.js +1 -1
- package/lib/team-library.d.ts +2 -0
- package/lib/team-roadmap.d.ts +44 -2
- package/lib/team.d.ts +63 -3
- package/lib/team.js +1 -1
- package/package.json +1 -1
package/lib/lint-ignores.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var $=Object.defineProperty;var u=(r
|
|
2
|
-
`}u(lintIgnoresText,"lintIgnoresText"),
|
|
1
|
+
"use strict";var $=Object.defineProperty;var u=(e,r)=>$(e,"name",{value:r,configurable:!0});var w=Object.defineProperty,c=u((e,r)=>w(e,"name",{value:r,configurable:!0}),"u"),x=Object.defineProperty,l=c((e,r)=>x(e,"name",{value:r,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 j=l(e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0,"obj"),h=l(e=>typeof e=="string"&&e.trim()?e.replace(/\s+/g," ").trim():void 0,"text");export function lintIgnoreKey(e,r){return`${r}\0${e}`}u(lintIgnoreKey,"lintIgnoreKey"),c(lintIgnoreKey,"lintIgnoreKey"),l(lintIgnoreKey,"lintIgnoreKey");export function checkLintIgnore(e){const r=h(e.rule),o=h(e.project),t=h(e.reason),n=LINT_IGNORE_LIMITS;return r?r==="fatal"?{problem:"a file ESLint could not parse is never ignored \u2014 fix it"}:r.length>n.rule?{problem:`the rule is at most ${n.rule} characters`}:o?o.length>n.project?{problem:`the project is at most ${n.project} characters`}:t?t.length>n.reason?{problem:`the reason is at most ${n.reason} characters`}:{rule:r,project:o,reason:t}:{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)"}}u(checkLintIgnore,"checkLintIgnore"),c(checkLintIgnore,"checkLintIgnore"),l(checkLintIgnore,"checkLintIgnore");export function parseLintIgnores(e){if(e===void 0||!e.trim())return{ignores:[],problems:[]};let r;try{r=JSON.parse(e)}catch(s){return{ignores:[],problems:[`${LINT_IGNORES_FILE} is not JSON (${s instanceof Error?s.message:String(s)}) \u2014 no lint is ignored until it is`]}}const o=j(r),t=o?o.ignores:void 0;if(!o||!Array.isArray(t))return{ignores:[],problems:[`${LINT_IGNORES_FILE} holds no "ignores" list \u2014 no lint is ignored until it does`]};const n=[],a=[],i=new Set;return t.forEach((s,p)=>{const f=j(s);if(!f){a.push(`ignores[${p}] is not an object`);return}const g=checkLintIgnore(f);if("problem"in g){a.push(`ignores[${p}]: ${g.problem}`);return}const d=lintIgnoreKey(g.rule,g.project);if(i.has(d)){a.push(`ignores[${p}]: ${g.rule} in ${g.project} is ignored above already \u2014 the first stands`);return}if(n.length>=LINT_IGNORE_LIMITS.ignores){a.push(`ignores[${p}]: past ${LINT_IGNORE_LIMITS.ignores} ignores \u2014 the rest are not read`);return}i.add(d);const b=h(f.by)?.slice(0,LINT_IGNORE_LIMITS.by),m=h(f.at),y=h(f.proposal);n.push({...g,...b?{by:b}:{},...m&&!Number.isNaN(Date.parse(m))?{at:m}:{},...y?{proposal:y.slice(0,40)}:{}})}),{ignores:n,problems:a}}u(parseLintIgnores,"parseLintIgnores"),c(parseLintIgnores,"parseLintIgnores"),l(parseLintIgnores,"parseLintIgnores");export function lintIgnoresText(e){const r=[...e].sort((t,n)=>t.project<n.project?-1:t.project>n.project?1:t.rule<n.rule?-1:t.rule>n.rule?1:0),o=l(t=>({rule:t.rule,project:t.project,reason:t.reason,...t.by?{by:t.by}:{},...t.at?{at:t.at}:{},...t.proposal?{proposal:t.proposal}:{}}),"entry");return`${JSON.stringify({version:1,ignores:r.map(o)},null,2)}
|
|
2
|
+
`}u(lintIgnoresText,"lintIgnoresText"),c(lintIgnoresText,"lintIgnoresText"),l(lintIgnoresText,"lintIgnoresText");export function withLintIgnore(e,r){const o=lintIgnoreKey(r.rule,r.project);return[...e.filter(t=>lintIgnoreKey(t.rule,t.project)!==o),r]}u(withLintIgnore,"withLintIgnore"),c(withLintIgnore,"withLintIgnore"),l(withLintIgnore,"withLintIgnore");export function withoutLintIgnore(e,r,o){const t=lintIgnoreKey(r,o);return e.filter(n=>lintIgnoreKey(n.rule,n.project)!==t)}u(withoutLintIgnore,"withoutLintIgnore"),c(withoutLintIgnore,"withoutLintIgnore"),l(withoutLintIgnore,"withoutLintIgnore");export function lintIgnoreMatcher(e){if(!e.length)return()=>{};const r=new Map(e.map(o=>[lintIgnoreKey(o.rule,o.project),o]));return({rule:o,project:t,scope:n})=>{if(!o||o==="fatal")return;const a=t??n;return a===void 0?void 0:r.get(lintIgnoreKey(o,a))}}u(lintIgnoreMatcher,"lintIgnoreMatcher"),c(lintIgnoreMatcher,"lintIgnoreMatcher"),l(lintIgnoreMatcher,"lintIgnoreMatcher");export function lintIgnoredSummary(e,r){if(!e.ignores.length&&!e.problems.length)return;let o=0,t=0;const n=e.ignores.map(i=>{const s=r.get(lintIgnoreKey(i.rule,i.project))??{errors:0,warnings:0};return o+=s.errors,t+=s.warnings,{rule:i.rule,project:i.project,reason:i.reason,...i.by?{by:i.by}:{},...i.at?{at:i.at}:{},errors:s.errors,warnings:s.warnings}}).map((i,s)=>({r:i,i:s})).sort((i,s)=>s.r.errors-i.r.errors||s.r.warnings-i.r.warnings||i.i-s.i).map(({r:i})=>i),a=n.length-LINT_IGNORED_RULES_SAID;return{file:LINT_IGNORES_FILE,errors:o,warnings:t,rules:n.slice(0,LINT_IGNORED_RULES_SAID),...a>0?{moreRules:a}:{},...e.problems.length?{problems:e.problems.slice(0,10)}:{},note:LINT_IGNORED_NOTE}}u(lintIgnoredSummary,"lintIgnoredSummary"),c(lintIgnoredSummary,"lintIgnoredSummary"),l(lintIgnoredSummary,"lintIgnoredSummary");export function lintIgnoreTally(e){const r=lintIgnoreMatcher(e.ignores),o=new Map;return{hides(t,n,a=1){const i=r(t);if(!i)return;const s=lintIgnoreKey(i.rule,i.project),p=o.get(s)??{errors:0,warnings:0};return n==="error"?p.errors+=a:p.warnings+=a,o.set(s,p),i},summary:l(()=>lintIgnoredSummary(e,o),"summary")}}u(lintIgnoreTally,"lintIgnoreTally"),c(lintIgnoreTally,"lintIgnoreTally"),l(lintIgnoreTally,"lintIgnoreTally");const I=10,L=l((e,r)=>`${e} ${r}${e===1?"":"s"}`,"counted");export function lintIgnoredLines(e){if(!e)return[];const r=[],o=e.rules.filter(n=>n.errors||n.warnings),t=[e.errors?L(e.errors,"error"):"",e.warnings?L(e.warnings,"warning"):""].filter(Boolean).join(", ");t&&r.push(` ignored (${e.file}): ${t} left out \u2014 not counted, not to be fixed`);for(const n of o.slice(0,I))r.push(` ${n.rule} in ${n.project} \u2014 ${n.reason}`);o.length>I&&r.push(` and ${o.length-I} more (--json lists them)`);for(const n of e.problems??[])r.push(` ${e.file}: ${n}`);return r}u(lintIgnoredLines,"lintIgnoredLines"),c(lintIgnoredLines,"lintIgnoredLines"),l(lintIgnoredLines,"lintIgnoredLines");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 L=Object.defineProperty;var a=(e,t)=>L(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,c=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"a"),h=Object.defineProperty,u=c((e,t)=>h(e,"name",{value:t,configurable:!0}),"c");const p={level:"level",severity:"level",service:"service",svc:"service",src:"service",source:"service",flow:"flow",trace:"trace",request:"trace",category:"category",cat:"category",ms:"ms"},C={warn:"warning",err:"error"},k=/(-?)(?:([A-Za-z]+):)?(?:"([^"]*)"|(\S+))/g;export function parseLogQuery(e){const t=[],r=[];for(const s of e.matchAll(k)){const[o,n,g,y,w]=s,i=(y??w??"").trim(),l=g?p[g.toLowerCase()]:void 0;if(l&&i){const m=l==="level"?C[i.toLowerCase()]??i.toLowerCase():i;t.push({key:l,value:m,negate:n==="-"})}else o.trim()&&r.push(o.trim())}return{tokens:t,text:r.join(" ")}}a(parseLogQuery,"parseLogQuery"),c(parseLogQuery,"parseLogQuery"),u(parseLogQuery,"parseLogQuery");export function formatLogQuery(e){const t=u(r=>/\s/.test(r)?`"${r}"`:r,"quote");return[...e.tokens.map(r=>`${r.negate?"-":""}${r.key}:${t(r.value)}`),e.text].filter(Boolean).join(" ")}a(formatLogQuery,"formatLogQuery"),c(formatLogQuery,"formatLogQuery"),u(formatLogQuery,"formatLogQuery");function v(e,t){if(e===void 0)return!1;const r=/^(>=|<=|>|<|=)?\s*(\d+(?:\.\d+)?)$/.exec(t);if(!r)return!1;const s=Number(r[2]);switch(r[1]){case">":return e>s;case"<":return e<s;case"<=":return e<=s;case"=":return e===s;default:return e>=s}}a(v,"v"),c(v,"h"),u(v,"msMatches");function f(e,t){const r=t.value.toLowerCase();switch(t.key){case"level":return e.severity.toLowerCase()===r;case"service":return e.source.toLowerCase()===r;case"flow":return!!e.flowId&&e.flowId.toLowerCase().startsWith(r);case"trace":return!!e.requestId&&e.requestId.toLowerCase().startsWith(r);case"category":return e.category.toLowerCase()===r;case"ms":return v(e.durationMs,t.value)}}a(f,"l"),c(f,"i"),u(f,"tokenMatches");export function matchesLogQuery(e,t,r){const s=new Map;for(const o of t.tokens){if(o.negate){if(f(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=>f(e,n)))return!1;if(t.text){const o=`${e.title} ${e.message??""} ${e.source} ${e.flowId??""}`;return r?r(o):o.toLowerCase().includes(t.text.toLowerCase())}return!0}a(matchesLogQuery,"matchesLogQuery"),c(matchesLogQuery,"matchesLogQuery"),u(matchesLogQuery,"matchesLogQuery");
|
package/lib/metrics-reset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var i=(e,t)=>l(e,"name",{value:t,configurable:!0});var f=Object.defineProperty,a=i((e,t)=>f(e,"name",{value:t,configurable:!0}),"i"),u=Object.defineProperty,c=a((e,t)=>u(e,"name",{value:t,configurable:!0}),"s");import{LENS_EVENT_SOURCE as S}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 d=16*1024,p=c(e=>e==="sql"||e==="external","isScope"),E=c(e=>typeof e=="string"&&e.length>0&&e.length<=MAX_METRICS_RESET_ID_LENGTH,"isId");export function readMetricsReset(e){if(e.source!==S||!e.raw||typeof e.raw!="object")return;const t=e.raw,r=t.kind;if(r!==METRICS_RESET&&r!==METRICS_RESTORED)return;const n=t.scope;if(!p(n))return;let s;if(t.ids!==void 0&&(!Array.isArray(t.ids)||(s=[...new Set(t.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 o=t.at;if(!(typeof o!="number"||!Number.isFinite(o)))return{kind:r,scope:n,at:Math.min(o,e.timestamp),...s?{ids:s}:{}}}i(readMetricsReset,"readMetricsReset"),a(readMetricsReset,"readMetricsReset"),c(readMetricsReset,"readMetricsReset");export function metricsIdBatches(e){const t=[];let r=[],n=0;for(const s of new Set(e.filter(E)))r.length&&(r.length>=METRICS_RESET_IDS_PER_EVENT||n+s.length+3>d)&&(t.push(r),r=[],n=0),r.push(s),n+=s.length+3;return r.length&&t.push(r),t}i(metricsIdBatches,"metricsIdBatches"),a(metricsIdBatches,"metricsIdBatches"),c(metricsIdBatches,"metricsIdBatches");
|
package/lib/overseer-findings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var s=(n,e)=>u(n,"name",{value:e,configurable:!0});var l=Object.defineProperty,c=s((n,e)=>l(n,"name",{value:e,configurable:!0}),"s"),f=Object.defineProperty,r=c((n,e)=>f(n,"name",{value:e,configurable:!0}),"s");import{systemValue as a}from"./system-report.js";export const FINDING_RUN_KINDS=["operate","stop-launch","close-session","role","role-off","check","rule","flow","lesson"];export function findingSightingValue(n,e){const i=a(n.value,n.check?n.unit:e.unit);if(!n.check||e.checks.length<=1)return i;const t=n.check.slice(n.check.lastIndexOf("/")+1),o=t.slice(t.lastIndexOf(".")+1);return i.startsWith(`${o} `)?`${t}${i.slice(o.length)}`:`${t} ${i}`}s(findingSightingValue,"findingSightingValue"),c(findingSightingValue,"findingSightingValue"),r(findingSightingValue,"findingSightingValue");export function findingLive(n){return n.state==="open"||n.state==="proposed"||n.state==="applied"}s(findingLive,"findingLive"),c(findingLive,"findingLive"),r(findingLive,"findingLive");export function findingRunsActions(n,e={}){return n.actions.some(i=>FINDING_RUN_KINDS.includes(i.kind)||i.kind==="issue"&&e.issuesFolder===!0)}s(findingRunsActions,"findingRunsActions"),c(findingRunsActions,"findingRunsActions"),r(findingRunsActions,"findingRunsActions");export function findingsForCheck(n,e,i){const t=`repo:${e}/team.${i}`;return n.filter(o=>findingLive(o)&&o.checks.includes(t))}s(findingsForCheck,"findingsForCheck"),c(findingsForCheck,"findingsForCheck"),r(findingsForCheck,"findingsForCheck");
|
package/lib/peers.d.ts
CHANGED
|
@@ -921,9 +921,10 @@ export declare const PeerEnvelopeSchema: z.ZodObject<{
|
|
|
921
921
|
}, z.core.$strict>;
|
|
922
922
|
export declare const PeerErrorBodySchema: z.ZodObject<{
|
|
923
923
|
code: z.ZodEnum<{
|
|
924
|
-
timeout: "timeout";
|
|
925
924
|
lost: "lost";
|
|
926
925
|
refused: "refused";
|
|
926
|
+
protocol: "protocol";
|
|
927
|
+
timeout: "timeout";
|
|
927
928
|
"unknown-type": "unknown-type";
|
|
928
929
|
"wrong-direction": "wrong-direction";
|
|
929
930
|
"bad-message": "bad-message";
|
|
@@ -936,7 +937,6 @@ export declare const PeerErrorBodySchema: z.ZodObject<{
|
|
|
936
937
|
"window-used": "window-used";
|
|
937
938
|
"window-closed": "window-closed";
|
|
938
939
|
"wrong-code": "wrong-code";
|
|
939
|
-
protocol: "protocol";
|
|
940
940
|
}>;
|
|
941
941
|
message: z.ZodString;
|
|
942
942
|
triesLeft: z.ZodOptional<z.ZodNumber>;
|
|
@@ -970,9 +970,10 @@ export declare const PEER_BODY_SCHEMAS: {
|
|
|
970
970
|
}, z.core.$strict>;
|
|
971
971
|
readonly error: z.ZodObject<{
|
|
972
972
|
code: z.ZodEnum<{
|
|
973
|
-
timeout: "timeout";
|
|
974
973
|
lost: "lost";
|
|
975
974
|
refused: "refused";
|
|
975
|
+
protocol: "protocol";
|
|
976
|
+
timeout: "timeout";
|
|
976
977
|
"unknown-type": "unknown-type";
|
|
977
978
|
"wrong-direction": "wrong-direction";
|
|
978
979
|
"bad-message": "bad-message";
|
|
@@ -985,7 +986,6 @@ export declare const PEER_BODY_SCHEMAS: {
|
|
|
985
986
|
"window-used": "window-used";
|
|
986
987
|
"window-closed": "window-closed";
|
|
987
988
|
"wrong-code": "wrong-code";
|
|
988
|
-
protocol: "protocol";
|
|
989
989
|
}>;
|
|
990
990
|
message: z.ZodString;
|
|
991
991
|
triesLeft: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1036,9 +1036,10 @@ export declare const PAIR_BODY_SCHEMAS: {
|
|
|
1036
1036
|
}, z.core.$strict>;
|
|
1037
1037
|
readonly error: z.ZodObject<{
|
|
1038
1038
|
code: z.ZodEnum<{
|
|
1039
|
-
timeout: "timeout";
|
|
1040
1039
|
lost: "lost";
|
|
1041
1040
|
refused: "refused";
|
|
1041
|
+
protocol: "protocol";
|
|
1042
|
+
timeout: "timeout";
|
|
1042
1043
|
"unknown-type": "unknown-type";
|
|
1043
1044
|
"wrong-direction": "wrong-direction";
|
|
1044
1045
|
"bad-message": "bad-message";
|
|
@@ -1051,7 +1052,6 @@ export declare const PAIR_BODY_SCHEMAS: {
|
|
|
1051
1052
|
"window-used": "window-used";
|
|
1052
1053
|
"window-closed": "window-closed";
|
|
1053
1054
|
"wrong-code": "wrong-code";
|
|
1054
|
-
protocol: "protocol";
|
|
1055
1055
|
}>;
|
|
1056
1056
|
message: z.ZodString;
|
|
1057
1057
|
triesLeft: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1229,8 +1229,8 @@ export declare const MAIN_MIRROR_SCHEMAS: {
|
|
|
1229
1229
|
}, z.core.$strict>;
|
|
1230
1230
|
verdict: z.ZodOptional<z.ZodObject<{
|
|
1231
1231
|
state: z.ZodEnum<{
|
|
1232
|
-
waiting: "waiting";
|
|
1233
1232
|
refused: "refused";
|
|
1233
|
+
waiting: "waiting";
|
|
1234
1234
|
"in-main": "in-main";
|
|
1235
1235
|
"brought-in": "brought-in";
|
|
1236
1236
|
"not-ff": "not-ff";
|
|
@@ -1272,9 +1272,9 @@ export declare const MAIN_MIRROR_SCHEMAS: {
|
|
|
1272
1272
|
}>;
|
|
1273
1273
|
update: z.ZodOptional<z.ZodObject<{
|
|
1274
1274
|
outcome: z.ZodEnum<{
|
|
1275
|
-
waiting: "waiting";
|
|
1276
|
-
refused: "refused";
|
|
1277
1275
|
merged: "merged";
|
|
1276
|
+
refused: "refused";
|
|
1277
|
+
waiting: "waiting";
|
|
1278
1278
|
current: "current";
|
|
1279
1279
|
"fast-forward": "fast-forward";
|
|
1280
1280
|
conflicts: "conflicts";
|
|
@@ -1285,8 +1285,8 @@ export declare const MAIN_MIRROR_SCHEMAS: {
|
|
|
1285
1285
|
conflicts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1286
1286
|
asked: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1287
1287
|
who: z.ZodEnum<{
|
|
1288
|
-
person: "person";
|
|
1289
1288
|
manager: "manager";
|
|
1289
|
+
person: "person";
|
|
1290
1290
|
}>;
|
|
1291
1291
|
goal: z.ZodOptional<z.ZodString>;
|
|
1292
1292
|
to: z.ZodOptional<z.ZodString>;
|
|
@@ -1305,8 +1305,8 @@ export declare const MAIN_MIRROR_ANSWER_SCHEMAS: {
|
|
|
1305
1305
|
why: z.ZodOptional<z.ZodString>;
|
|
1306
1306
|
verdict: z.ZodOptional<z.ZodObject<{
|
|
1307
1307
|
state: z.ZodEnum<{
|
|
1308
|
-
waiting: "waiting";
|
|
1309
1308
|
refused: "refused";
|
|
1309
|
+
waiting: "waiting";
|
|
1310
1310
|
"in-main": "in-main";
|
|
1311
1311
|
"brought-in": "brought-in";
|
|
1312
1312
|
"not-ff": "not-ff";
|
|
@@ -1374,8 +1374,8 @@ export declare const PEER_WORK_SCHEMAS: {
|
|
|
1374
1374
|
at: z.ZodNumber;
|
|
1375
1375
|
started: z.ZodOptional<z.ZodLiteral<true>>;
|
|
1376
1376
|
state: z.ZodOptional<z.ZodEnum<{
|
|
1377
|
-
running: "running";
|
|
1378
1377
|
queued: "queued";
|
|
1378
|
+
running: "running";
|
|
1379
1379
|
}>>;
|
|
1380
1380
|
note: z.ZodOptional<z.ZodString>;
|
|
1381
1381
|
queue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1391,11 +1391,11 @@ export declare const PEER_WORK_SCHEMAS: {
|
|
|
1391
1391
|
runId: z.ZodString;
|
|
1392
1392
|
at: z.ZodNumber;
|
|
1393
1393
|
state: z.ZodEnum<{
|
|
1394
|
-
|
|
1394
|
+
cancelled: "cancelled";
|
|
1395
1395
|
passed: "passed";
|
|
1396
1396
|
failed: "failed";
|
|
1397
|
-
cancelled: "cancelled";
|
|
1398
1397
|
timeout: "timeout";
|
|
1398
|
+
errored: "errored";
|
|
1399
1399
|
}>;
|
|
1400
1400
|
note: z.ZodOptional<z.ZodString>;
|
|
1401
1401
|
step: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1488,9 +1488,9 @@ export declare const PEER_WORK_SCHEMAS: {
|
|
|
1488
1488
|
}, z.core.$strict>;
|
|
1489
1489
|
why: z.ZodObject<{
|
|
1490
1490
|
kind: z.ZodEnum<{
|
|
1491
|
-
restarting: "restarting";
|
|
1492
|
-
protocol: "protocol";
|
|
1493
1491
|
version: "version";
|
|
1492
|
+
protocol: "protocol";
|
|
1493
|
+
restarting: "restarting";
|
|
1494
1494
|
installed: "installed";
|
|
1495
1495
|
"install-failed": "install-failed";
|
|
1496
1496
|
"restart-failed": "restart-failed";
|
|
@@ -1553,11 +1553,11 @@ export declare const StoreReplySchema: z.ZodObject<{
|
|
|
1553
1553
|
result: z.ZodOptional<z.ZodUnknown>;
|
|
1554
1554
|
error: z.ZodOptional<z.ZodObject<{
|
|
1555
1555
|
name: z.ZodEnum<{
|
|
1556
|
-
Error: "Error";
|
|
1557
1556
|
CoordinationError: "CoordinationError";
|
|
1558
1557
|
CapacityRefusal: "CapacityRefusal";
|
|
1559
1558
|
CoordinationBusyError: "CoordinationBusyError";
|
|
1560
1559
|
StoreCallRefused: "StoreCallRefused";
|
|
1560
|
+
Error: "Error";
|
|
1561
1561
|
}>;
|
|
1562
1562
|
message: z.ZodString;
|
|
1563
1563
|
room: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1621,9 +1621,9 @@ export declare const CanvasReplySchema: z.ZodObject<{
|
|
|
1621
1621
|
image: z.ZodOptional<z.ZodString>;
|
|
1622
1622
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1623
1623
|
kind: z.ZodEnum<{
|
|
1624
|
+
asset: "asset";
|
|
1624
1625
|
render: "render";
|
|
1625
1626
|
mirror: "mirror";
|
|
1626
|
-
asset: "asset";
|
|
1627
1627
|
}>;
|
|
1628
1628
|
name: z.ZodString;
|
|
1629
1629
|
base64: z.ZodString;
|
|
@@ -1652,8 +1652,8 @@ export declare const REMOTE_INSTANCE_BODY_SCHEMAS: {
|
|
|
1652
1652
|
readonly 'instance.state': z.ZodObject<{
|
|
1653
1653
|
instanceId: z.ZodString;
|
|
1654
1654
|
state: z.ZodEnum<{
|
|
1655
|
-
up: "up";
|
|
1656
1655
|
gone: "gone";
|
|
1656
|
+
up: "up";
|
|
1657
1657
|
}>;
|
|
1658
1658
|
apex: z.ZodOptional<z.ZodString>;
|
|
1659
1659
|
dashboardBase: z.ZodOptional<z.ZodString>;
|
|
@@ -1685,8 +1685,8 @@ export declare const PEER_LAUNCH_SCHEMAS: {
|
|
|
1685
1685
|
role: z.ZodString;
|
|
1686
1686
|
by: z.ZodString;
|
|
1687
1687
|
client: z.ZodEnum<{
|
|
1688
|
-
claude: "claude";
|
|
1689
1688
|
codex: "codex";
|
|
1689
|
+
claude: "claude";
|
|
1690
1690
|
}>;
|
|
1691
1691
|
model: z.ZodOptional<z.ZodString>;
|
|
1692
1692
|
effort: z.ZodOptional<z.ZodString>;
|
|
@@ -1716,8 +1716,8 @@ export declare const PEER_LAUNCH_SCHEMAS: {
|
|
|
1716
1716
|
readonly 'launch.state': z.ZodObject<{
|
|
1717
1717
|
launchId: z.ZodString;
|
|
1718
1718
|
state: z.ZodEnum<{
|
|
1719
|
-
running: "running";
|
|
1720
1719
|
failed: "failed";
|
|
1720
|
+
running: "running";
|
|
1721
1721
|
stopped: "stopped";
|
|
1722
1722
|
exited: "exited";
|
|
1723
1723
|
}>;
|
|
@@ -1729,8 +1729,8 @@ export declare const PEER_LAUNCH_SCHEMAS: {
|
|
|
1729
1729
|
ended: z.ZodOptional<z.ZodObject<{
|
|
1730
1730
|
quota: z.ZodOptional<z.ZodObject<{
|
|
1731
1731
|
client: z.ZodEnum<{
|
|
1732
|
-
claude: "claude";
|
|
1733
1732
|
codex: "codex";
|
|
1733
|
+
claude: "claude";
|
|
1734
1734
|
}>;
|
|
1735
1735
|
why: z.ZodString;
|
|
1736
1736
|
until: z.ZodNumber;
|
|
@@ -1924,9 +1924,9 @@ export declare const GOAL_PEER_SCHEMAS: {
|
|
|
1924
1924
|
sha256: z.ZodString;
|
|
1925
1925
|
}, z.core.$strict>;
|
|
1926
1926
|
services: z.ZodOptional<z.ZodEnum<{
|
|
1927
|
-
always: "always";
|
|
1928
1927
|
none: "none";
|
|
1929
1928
|
"on-demand": "on-demand";
|
|
1929
|
+
always: "always";
|
|
1930
1930
|
}>>;
|
|
1931
1931
|
at: z.ZodNumber;
|
|
1932
1932
|
}, z.core.$strict>;
|
|
@@ -1941,12 +1941,12 @@ export declare const GOAL_PEER_SCHEMAS: {
|
|
|
1941
1941
|
readonly 'goal.changes': z.ZodObject<{
|
|
1942
1942
|
goal: z.ZodString;
|
|
1943
1943
|
what: z.ZodEnum<{
|
|
1944
|
-
files: "files";
|
|
1945
1944
|
commit: "commit";
|
|
1945
|
+
files: "files";
|
|
1946
1946
|
diff: "diff";
|
|
1947
|
-
against: "against";
|
|
1948
1947
|
row: "row";
|
|
1949
1948
|
commits: "commits";
|
|
1949
|
+
against: "against";
|
|
1950
1950
|
}>;
|
|
1951
1951
|
path: z.ZodOptional<z.ZodString>;
|
|
1952
1952
|
sha: z.ZodOptional<z.ZodString>;
|
|
@@ -1985,8 +1985,8 @@ export declare const GOAL_PEER_ANSWER_SCHEMAS: {
|
|
|
1985
1985
|
ref: z.ZodString;
|
|
1986
1986
|
sha: z.ZodOptional<z.ZodString>;
|
|
1987
1987
|
mirror: z.ZodOptional<z.ZodEnum<{
|
|
1988
|
-
created: "created";
|
|
1989
1988
|
current: "current";
|
|
1989
|
+
created: "created";
|
|
1990
1990
|
"not-ff": "not-ff";
|
|
1991
1991
|
"fast-forward": "fast-forward";
|
|
1992
1992
|
"checked-out": "checked-out";
|
|
@@ -2004,11 +2004,11 @@ export declare const GOAL_PEER_ANSWER_SCHEMAS: {
|
|
|
2004
2004
|
}, z.core.$strict>;
|
|
2005
2005
|
readonly 'goal.update': z.ZodObject<{
|
|
2006
2006
|
outcome: z.ZodEnum<{
|
|
2007
|
-
refused: "refused";
|
|
2008
2007
|
merged: "merged";
|
|
2008
|
+
refused: "refused";
|
|
2009
2009
|
current: "current";
|
|
2010
|
-
asked: "asked";
|
|
2011
2010
|
conflicts: "conflicts";
|
|
2011
|
+
asked: "asked";
|
|
2012
2012
|
}>;
|
|
2013
2013
|
why: z.ZodString;
|
|
2014
2014
|
sha: z.ZodOptional<z.ZodString>;
|
|
@@ -2157,8 +2157,8 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2157
2157
|
row: z.ZodObject<{
|
|
2158
2158
|
id: z.ZodString;
|
|
2159
2159
|
client: z.ZodEnum<{
|
|
2160
|
-
claude: "claude";
|
|
2161
2160
|
codex: "codex";
|
|
2161
|
+
claude: "claude";
|
|
2162
2162
|
}>;
|
|
2163
2163
|
nativeId: z.ZodString;
|
|
2164
2164
|
account: z.ZodString;
|
|
@@ -2174,12 +2174,12 @@ export declare const CONVERSATION_PEER_SCHEMAS: {
|
|
|
2174
2174
|
lastAt: z.ZodNumber;
|
|
2175
2175
|
state: z.ZodEnum<{
|
|
2176
2176
|
running: "running";
|
|
2177
|
-
ended: "ended";
|
|
2178
2177
|
kept: "kept";
|
|
2178
|
+
ended: "ended";
|
|
2179
2179
|
}>;
|
|
2180
2180
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
2181
|
-
person: "person";
|
|
2182
2181
|
team: "team";
|
|
2182
|
+
person: "person";
|
|
2183
2183
|
outside: "outside";
|
|
2184
2184
|
}>>;
|
|
2185
2185
|
sessionId: z.ZodOptional<z.ZodString>;
|
package/lib/peers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Y=Object.defineProperty;var v=(e,o)=>Y(e,"name",{value:o,configurable:!0});var X=Object.defineProperty,i=v((e,o)=>X(e,"name",{value:o,configurable:!0}),"i");import{z as t}from"zod";import{RUN_ID_PATTERN as z}from"./docker-jobs.js";import{CONVERSATION_ID as J,CONVERSATION_LIST_MAX as C,CONVERSATION_TOOL_OUTPUT_CHARS as T,CONVERSATION_TURN_CHARS as Q}from"./conversations.js";import{REMOTE_DASHBOARD_BASE_PATTERN as tt,REMOTE_INSTANCE_ID_PATTERN as D,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}$/,CANVAS_CALL_TOOLS=["canvas_write","canvas_data","canvas_get","canvas_render","canvas_list","canvas_wait","canvas_comment","canvas_resource"],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","canvas.call"],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","canvas.call":"canvas phase 14"};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)}v(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"),M=t.string().regex(/^[A-Za-z0-9_-]{43}$/),$=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 m=t.string().regex(z);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(N=>typeof N=="string"&&z.test(N)))&&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:M,name:d(64),model:d(40),lensmcp:l}),"pair.resume":t.strictObject({protocol:t.literal(PEER_PROTOCOL)}),"pair.challenge":t.strictObject({nonce:M}),"pair.proof":t.strictObject({proof:$}),"pair.accepted":t.strictObject({proof:$,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),_=t.string().min(1).max(250).regex(/^[A-Za-z0-9._/-]+$/),j=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:j,at:n}),ot=t.strictObject({outcome:t.enum(["merged","fast-forward","current","conflicts","waiting","refused"]),at:n,why:j,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()}),Z=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(_).length(1),size:t.number().int().positive().max(MAIN_MIRROR.maxSendBytes),sha256:P}),"main.moved":t.strictObject({repository:y,branch:_,sha:r,bundle:t.strictObject({id:L,size:t.number().int().positive(),sha256:P}),verdict:B.optional(),at:n}),"main.state":t.strictObject({repository:y,branch:_,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:Z,update:ot.optional(),at:n})},MAIN_MIRROR_ANSWER_SCHEMAS={"bundle.sent":t.strictObject({took:t.boolean(),ref:_,sha:r.optional(),code:t.string().max(40).optional(),why:j.optional(),verdict:B.optional()}),"main.moved":t.strictObject({took:t.boolean(),needWhole:t.boolean().optional(),why:j.optional(),follow:Z.optional(),head:r.optional()})};const rt=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/),w=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"),p=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:m,job:rt,candidate:w,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:m,why:W(300)}),"job.state":t.strictObject({runId:m,at:n,started:t.literal(!0).optional(),state:t.enum(["queued","running"]).optional(),note:t.string().max(1e3).optional(),queue:p.optional(),docker:p.optional(),edgePort:t.number().int().min(1024).max(65535).optional()}),"job.stage":t.strictObject({runId:m,stage:W(120),at:n}),"job.done":t.strictObject({runId:m,at:n,state:t.enum(["passed","failed","errored","cancelled","timeout"]),note:t.string().max(1e3).optional(),step:p.optional(),docker:p.optional(),givenBack:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),refused:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),proof:p.optional()}),"bundle.ready":t.strictObject({runId:m.optional(),bundleId:b,repository:H,heads:t.array(w).min(1).max(16),basis:t.array(w).max(256).optional(),size:t.number().int().positive().max(64*1024*1024*1024),sha256:t.string().regex(/^[0-9a-f]{64}$/),shipment:p.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:m,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()}),CANVAS_CALL_LIMITS={inputBytes:400*1024,answerBytes:480*1024,fileBytes:300*1024,waitSliceMs:2e4},CANVAS_CALL_FILE_NAME=/^cv-[0-9a-f]{16}[A-Za-z0-9._-]{0,80}\.(?:png|html|mdx|json|jpg|webp|gif|txt|md|csv)$/,CANVAS_WORKER_FILE="lensmcp-worker:",CanvasCallSchema=t.strictObject({v:t.literal(1),kind:t.literal("canvas.call"),id:t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),tool:t.enum(CANVAS_CALL_TOOLS),input:t.record(t.string(),t.unknown()),caller:t.strictObject({session:t.string().max(200).optional(),client:t.string().max(200).optional()}).optional(),launchKey:t.string().min(16).max(512)}),CanvasReplySchema=t.strictObject({v:t.literal(1),kind:t.literal("canvas.reply"),id:t.string().max(100),result:t.record(t.string(),t.unknown()).optional(),image:t.string().max(200).optional(),files:t.array(t.strictObject({kind:t.enum(["render","mirror","asset"]),name:t.string().regex(CANVAS_CALL_FILE_NAME),base64:t.string().regex(/^[A-Za-z0-9+/]*={0,2}$/)})).max(8).optional(),error:t.strictObject({code:t.enum(["NOT_FOUND","REFUSED","UNAVAILABLE","ERROR"]),message:t.string().max(4e3)}).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(D)}),"instance.state":t.strictObject({instanceId:t.string().regex(D),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),G=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}$/),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"),S=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:S,task:G.optional(),role:lt,by:S,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:st,lensmcp:l,resume:t.strictObject({launchId:x,threadId:G,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:S.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 E=t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),K=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})$/),F=t.string().regex(/^[0-9a-f]{16,64}$/),A=t.string().max(1e3);export const GOAL_PEER_SCHEMAS={"goal.place":t.strictObject({goal:E,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:ct,base:g,bundle:K,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:E,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:E,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:E,main:t.strictObject({branch:t.string().min(1).max(200).regex(/^[A-Za-z0-9._/-]+$/),sha:g,bundle:K}),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 I=t.string().regex(J),q=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),mt=t.strictObject({id:I,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:I.optional()}),pt=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(T).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(C).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:q,macBasis:t.string().regex(/^[\w-]{8,128}$/),conversations:t.array(t.strictObject({row:mt,turns:t.array(pt).max(CONVERSATION_PEER_LIMITS.turns),settles:t.array(t.strictObject({seq:k,outcome:t.enum(["ok","error"]),output:a(T).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:q,ask:dt})},CONVERSATION_PEER_ANSWER_SCHEMAS={"conversation.sync":t.strictObject({v:t.literal(1),held:t.array(t.strictObject({id:I,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(C),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 X=Object.defineProperty;var v=(e,o)=>X(e,"name",{value:o,configurable:!0});var J=Object.defineProperty,C=v((e,o)=>J(e,"name",{value:o,configurable:!0}),"v"),Q=Object.defineProperty,i=C((e,o)=>Q(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 tt,CONVERSATION_LIST_MAX as N,CONVERSATION_TOOL_OUTPUT_CHARS as D,CONVERSATION_TURN_CHARS as et}from"./conversations.js";import{REMOTE_DASHBOARD_BASE_PATTERN as nt,REMOTE_INSTANCE_ID_PATTERN as M,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}$/,CANVAS_CALL_TOOLS=["canvas_write","canvas_data","canvas_get","canvas_render","canvas_list","canvas_wait","canvas_comment","canvas_resource"],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","canvas.call"],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","canvas.call":"canvas phase 14"};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)}v(peerMaySend,"peerMaySend"),C(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}$/),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 m=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: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}$/),B=t.string().regex(/^[0-9a-f]{16}$/),u=t.number().int().min(0).max(1e7),_=t.string().min(1).max(250).regex(/^[A-Za-z0-9._/-]+$/),j=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:j,at:n}),it=t.strictObject({outcome:t.enum(["merged","fast-forward","current","conflicts","waiting","refused"]),at:n,why:j,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:B,repository:y,refs:t.array(_).length(1),size:t.number().int().positive().max(MAIN_MIRROR.maxSendBytes),sha256:L}),"main.moved":t.strictObject({repository:y,branch:_,sha:r,bundle:t.strictObject({id:B,size:t.number().int().positive(),sha256:L}),verdict:Z.optional(),at:n}),"main.state":t.strictObject({repository:y,branch:_,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:_,sha:r.optional(),code:t.string().max(40).optional(),why:j.optional(),verdict:Z.optional()}),"main.moved":t.strictObject({took:t.boolean(),needWhole:t.boolean().optional(),why:j.optional(),follow:H.optional(),head:r.optional()})};const st=t.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/),w=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}$/),U=i(e=>t.string().min(1).max(e).regex(s),"sentence"),p=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:m,job:st,candidate:w,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:m,why:U(300)}),"job.state":t.strictObject({runId:m,at:n,started:t.literal(!0).optional(),state:t.enum(["queued","running"]).optional(),note:t.string().max(1e3).optional(),queue:p.optional(),docker:p.optional(),edgePort:t.number().int().min(1024).max(65535).optional()}),"job.stage":t.strictObject({runId:m,stage:U(120),at:n}),"job.done":t.strictObject({runId:m,at:n,state:t.enum(["passed","failed","errored","cancelled","timeout"]),note:t.string().max(1e3).optional(),step:p.optional(),docker:p.optional(),givenBack:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),refused:t.strictObject({why:t.string().min(1).max(1e3)}).optional(),proof:p.optional()}),"bundle.ready":t.strictObject({runId:m.optional(),bundleId:b,repository:W,heads:t.array(w).min(1).max(16),basis:t.array(w).max(256).optional(),size:t.number().int().positive().max(64*1024*1024*1024),sha256:t.string().regex(/^[0-9a-f]{64}$/),shipment:p.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:m,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()}),CANVAS_CALL_LIMITS={inputBytes:400*1024,answerBytes:480*1024,fileBytes:300*1024,waitSliceMs:2e4},CANVAS_CALL_FILE_NAME=/^cv-[0-9a-f]{16}[A-Za-z0-9._-]{0,80}\.(?:png|html|mdx|json|jpg|webp|gif|txt|md|csv)$/,CANVAS_WORKER_FILE="lensmcp-worker:",CanvasCallSchema=t.strictObject({v:t.literal(1),kind:t.literal("canvas.call"),id:t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),tool:t.enum(CANVAS_CALL_TOOLS),input:t.record(t.string(),t.unknown()),caller:t.strictObject({session:t.string().max(200).optional(),client:t.string().max(200).optional()}).optional(),launchKey:t.string().min(16).max(512)}),CanvasReplySchema=t.strictObject({v:t.literal(1),kind:t.literal("canvas.reply"),id:t.string().max(100),result:t.record(t.string(),t.unknown()).optional(),image:t.string().max(200).optional(),files:t.array(t.strictObject({kind:t.enum(["render","mirror","asset"]),name:t.string().regex(CANVAS_CALL_FILE_NAME),base64:t.string().regex(/^[A-Za-z0-9+/]*={0,2}$/)})).max(8).optional(),error:t.strictObject({code:t.enum(["NOT_FOUND","REFUSED","UNAVAILABLE","ERROR"]),message:t.string().max(4e3)}).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(M)}),"instance.state":t.strictObject({instanceId:t.string().regex(M),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),V=t.string().regex(/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i),mt=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"),S=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:S,task:V.optional(),role:mt,by:S,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:ct,lensmcp:l,resume:t.strictObject({launchId:x,threadId:V,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:S.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 E=t.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),F=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}$/)}),pt=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:E,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:pt,base:g,bundle:F,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:E,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:E,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:E,main:t.strictObject({branch:t.string().min(1).max(200).regex(/^[A-Za-z0-9._/-]+$/),sha:g,bundle:F}),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 I=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:I,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:I.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(D).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(N).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(D).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:I,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(N),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 c=Object.defineProperty;var a=(r,e)=>c(r,"name",{value:e,configurable:!0});var l=Object.defineProperty,o=a((r,e)=>l(r,"name",{value:e,configurable:!0}),"o"),f=Object.defineProperty,p=o((r,e)=>f(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}`}a(perfRuleFingerprint,"perfRuleFingerprint"),o(perfRuleFingerprint,"perfRuleFingerprint"),p(perfRuleFingerprint,"perfRuleFingerprint");export function perfRuleScanFingerprint(r,e){return`perf-rule-scan:${r}:${e}`}a(perfRuleScanFingerprint,"perfRuleScanFingerprint"),o(perfRuleScanFingerprint,"perfRuleScanFingerprint"),p(perfRuleScanFingerprint,"perfRuleScanFingerprint");const s=/^[a-z][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/,d=12,y=4e3,t=p((r,e=y)=>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(u=>t(u,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>d||!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}a(asPerfRuleRaw,"asPerfRuleRaw"),o(asPerfRuleRaw,"asPerfRuleRaw"),p(asPerfRuleRaw,"asPerfRuleRaw");
|
package/lib/pod-memory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var o=(r,e)=>n(r,"name",{value:e,configurable:!0});var d=Object.defineProperty,t=o((r,e)=>d(r,"name",{value:e,configurable:!0}),"r"),m=Object.defineProperty,i=t((r,e)=>m(r,"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(r){if(!r||typeof r!="object")return;const e=r;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 r}o(asPodMemoryRaw,"asPodMemoryRaw"),t(asPodMemoryRaw,"asPodMemoryRaw"),i(asPodMemoryRaw,"asPodMemoryRaw");
|
package/lib/producer-health.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var R=Object.defineProperty;var i=(e,o)=>R(e,"name",{value:o,configurable:!0});var $=Object.defineProperty,d=i((e,o)=>$(e,"name",{value:o,configurable:!0}),"i"),b=Object.defineProperty,m=d((e,o)=>b(e,"name",{value:o,configurable:!0}),"u");import{z as r}from"zod";export const ProducerStateSchema=r.enum(["none","connected"]),ProducerRunStatusSchema=r.enum(["running","clean","failing","error"]),ProducerReportSchema=r.object({id:r.string(),tool:r.string(),project:r.string().optional(),firstReportedAt:r.number().int().nonnegative(),lastReportedAt:r.number().int().nonnegative(),lastRunStatus:ProducerRunStatusSchema,lastRunDurationMs:r.number().int().nonnegative().optional(),errorCount:r.number().int().nonnegative(),warningCount:r.number().int().nonnegative().optional(),error:r.string().optional()}),ProducerHealthSchema=r.object({producer:ProducerStateSchema,producers:r.array(ProducerReportSchema),lastReportedAt:r.number().int().nonnegative().optional(),ageMs:r.number().int().nonnegative().optional(),stale:r.boolean(),detail:r.string()}),PRODUCER_STALE_AFTER_MS=10*6e4;export function summariseProducers(e){const o=e.now??Date.now(),t=[...e.producers].sort((n,h)=>h.lastReportedAt-n.lastReportedAt);if(t.length===0)return{producer:"none",producers:[],stale:!1,detail:`No ${e.domain} producer has ever reported into this session \u2014 this is NOT a clean result, nothing is watching. ${e.noProducerHint}`};const l=t[0].lastReportedAt,u=Math.max(0,o-l),p=u>PRODUCER_STALE_AFTER_MS,g=t.filter(n=>n.lastRunStatus==="failing"),s=t.filter(n=>n.lastRunStatus==="error"),a=[`${t.length} ${e.domain} producer${t.length===1?"":"s"} reporting (${t.map(n=>n.id).join(", ")}); newest report ${c(u)}.`];return s.length>0&&a.push(`${s.length} produced NO verdict (the tool itself failed): ${s.map(n=>`${n.id} \u2014 ${n.error??"unknown error"}`).join("; ")}.`),g.length>0&&a.push(`${g.length} reporting errors.`),p&&a.push(`Older than ${Math.round(PRODUCER_STALE_AFTER_MS/6e4)}m \u2014 the verdict may predate the current source.`),{producer:"connected",producers:t,lastReportedAt:l,ageMs:u,stale:p,detail:a.join(" ")}}i(summariseProducers,"summariseProducers"),d(summariseProducers,"summariseProducers"),m(summariseProducers,"summariseProducers");function c(e){return e<1e3?"just now":e<6e4?`${Math.round(e/1e3)}s ago`:e<36e5?`${Math.round(e/6e4)}m ago`:`${Math.round(e/36e5)}h ago`}i(c,"g"),d(c,"g"),m(c,"describeAge");
|
package/lib/pull-requests.d.ts
CHANGED
|
@@ -57,9 +57,35 @@ export interface DashPrGoal {
|
|
|
57
57
|
};
|
|
58
58
|
/** Labelled and marked in its body — what `lensmcp agent pr` and «Tag» leave. */
|
|
59
59
|
tagged: boolean;
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* «Tag» adds the label and the marker: a goal the team knows, linked by a commit or its branch, not tagged yet. A
|
|
62
|
+
* proven link of an open one missing its label is labelled by LensMCP itself ({@link DashPrAutoLabel}); «Tag» stays
|
|
63
|
+
* for the rest — a guessed link, a closed one, or a label LensMCP could not add.
|
|
64
|
+
*/
|
|
61
65
|
taggable: boolean;
|
|
62
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* What LensMCP did by itself on a pull request (issues/closed/hub-13). The owner, 2026-11-25: «why tagging need button
|
|
69
|
+
* and not automatic adding label to the pr?» — an open pull request whose link to a goal of the team is proven (its
|
|
70
|
+
* head is the goal's branch, or it carries the goal's commit, verified) and lacks the goal's label is labelled and
|
|
71
|
+
* marked as «Tag» does, after a read of the pull requests, while the person's switch «Label linked pull requests by
|
|
72
|
+
* itself» is on (on by default). Once per head commit: a failure is said once on the goal's log and kept until the
|
|
73
|
+
* pull request's head moves — never tried again in a loop.
|
|
74
|
+
*/
|
|
75
|
+
export interface DashPrAutoLabel {
|
|
76
|
+
/** `trying`: a dashboard labels it now; `labelled`: done; `failed`: gh could not — `error` says why. */
|
|
77
|
+
state: 'trying' | 'labelled' | 'failed';
|
|
78
|
+
/** When it was tried, or done. */
|
|
79
|
+
at: number;
|
|
80
|
+
goalId: string;
|
|
81
|
+
/** The label it adds: `goal:G-44`. */
|
|
82
|
+
label: string;
|
|
83
|
+
/** The head commit it was tried at — tried again only once the head moves. */
|
|
84
|
+
head: string;
|
|
85
|
+
/** How the link was proven: its branch is the goal's, or a verified commit of the goal's. */
|
|
86
|
+
proof: 'branch' | 'commit';
|
|
87
|
+
error?: string;
|
|
88
|
+
}
|
|
63
89
|
export interface DashPullRequest {
|
|
64
90
|
number: number;
|
|
65
91
|
title: string;
|
|
@@ -94,6 +120,8 @@ export interface DashPullRequest {
|
|
|
94
120
|
stackedOn?: number;
|
|
95
121
|
/** Its base was a pull request's head that has merged: retarget it to main. */
|
|
96
122
|
retarget?: string;
|
|
123
|
+
/** What LensMCP's own labelling did on it (issues/closed/hub-13) — absent: nothing. */
|
|
124
|
+
autoLabel?: DashPrAutoLabel;
|
|
97
125
|
}
|
|
98
126
|
/** Pull requests stacked on one another, in merge order: the first merges into main, each next one into the one before. */
|
|
99
127
|
export interface DashPrStack {
|
|
@@ -106,7 +134,10 @@ export interface DashPrStack {
|
|
|
106
134
|
/** Why the pull requests could not be read: no `gh`, `gh` not signed in, no GitHub remote, anything else. */
|
|
107
135
|
export type DashPrProblemKind = 'no-gh' | 'signed-out' | 'no-remote' | 'error';
|
|
108
136
|
export interface DashPullRequestsAnswer {
|
|
109
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* When GitHub was read — at most once a minute per repository. An answer never waits for the next read
|
|
139
|
+
* (issues/closed/hub-13): past {@link nextAt} it is the last one read, while the next one runs behind it.
|
|
140
|
+
*/
|
|
110
141
|
at: number;
|
|
111
142
|
/** The next read of GitHub, no sooner. */
|
|
112
143
|
nextAt: number;
|
package/lib/remote-instances.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _=Object.defineProperty;var t=(e,E)=>_(e,"name",{value:E,configurable:!0});var r=Object.defineProperty,n=t((e,E)=>r(e,"name",{value:E,configurable:!0}),"_"),o=Object.defineProperty,A=n((e,E)=>o(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()}`}t(remoteLensHost,"remoteLensHost"),n(remoteLensHost,"remoteLensHost"),A(remoteLensHost,"remoteLensHost");export const REMOTE_INSTANCES_FILE="instances.json";
|