@lensmcp/protocol-types 1.26.5 → 1.26.6

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/peers.d.ts CHANGED
@@ -851,6 +851,7 @@ export declare const PeerErrorBodySchema: z.ZodObject<{
851
851
  code: z.ZodEnum<{
852
852
  timeout: "timeout";
853
853
  lost: "lost";
854
+ refused: "refused";
854
855
  "unknown-type": "unknown-type";
855
856
  "wrong-direction": "wrong-direction";
856
857
  "bad-message": "bad-message";
@@ -858,7 +859,6 @@ export declare const PeerErrorBodySchema: z.ZodObject<{
858
859
  "not-handled": "not-handled";
859
860
  "too-large": "too-large";
860
861
  busy: "busy";
861
- refused: "refused";
862
862
  internal: "internal";
863
863
  "no-window": "no-window";
864
864
  "window-used": "window-used";
@@ -900,6 +900,7 @@ export declare const PEER_BODY_SCHEMAS: {
900
900
  code: z.ZodEnum<{
901
901
  timeout: "timeout";
902
902
  lost: "lost";
903
+ refused: "refused";
903
904
  "unknown-type": "unknown-type";
904
905
  "wrong-direction": "wrong-direction";
905
906
  "bad-message": "bad-message";
@@ -907,7 +908,6 @@ export declare const PEER_BODY_SCHEMAS: {
907
908
  "not-handled": "not-handled";
908
909
  "too-large": "too-large";
909
910
  busy: "busy";
910
- refused: "refused";
911
911
  internal: "internal";
912
912
  "no-window": "no-window";
913
913
  "window-used": "window-used";
@@ -966,6 +966,7 @@ export declare const PAIR_BODY_SCHEMAS: {
966
966
  code: z.ZodEnum<{
967
967
  timeout: "timeout";
968
968
  lost: "lost";
969
+ refused: "refused";
969
970
  "unknown-type": "unknown-type";
970
971
  "wrong-direction": "wrong-direction";
971
972
  "bad-message": "bad-message";
@@ -973,7 +974,6 @@ export declare const PAIR_BODY_SCHEMAS: {
973
974
  "not-handled": "not-handled";
974
975
  "too-large": "too-large";
975
976
  busy: "busy";
976
- refused: "refused";
977
977
  internal: "internal";
978
978
  "no-window": "no-window";
979
979
  "window-used": "window-used";
@@ -1157,10 +1157,10 @@ export declare const MAIN_MIRROR_SCHEMAS: {
1157
1157
  }, z.core.$strict>;
1158
1158
  verdict: z.ZodOptional<z.ZodObject<{
1159
1159
  state: z.ZodEnum<{
1160
+ waiting: "waiting";
1160
1161
  refused: "refused";
1161
1162
  "in-main": "in-main";
1162
1163
  "brought-in": "brought-in";
1163
- waiting: "waiting";
1164
1164
  "not-ff": "not-ff";
1165
1165
  }>;
1166
1166
  count: z.ZodNumber;
@@ -1190,8 +1190,8 @@ export declare const MAIN_MIRROR_SCHEMAS: {
1190
1190
  sent: z.ZodBoolean;
1191
1191
  }, z.core.$strict>>;
1192
1192
  follow: z.ZodEnum<{
1193
- "in-step": "in-step";
1194
1193
  waiting: "waiting";
1194
+ "in-step": "in-step";
1195
1195
  "fast-forward": "fast-forward";
1196
1196
  ahead: "ahead";
1197
1197
  "to-update": "to-update";
@@ -1200,11 +1200,11 @@ export declare const MAIN_MIRROR_SCHEMAS: {
1200
1200
  }>;
1201
1201
  update: z.ZodOptional<z.ZodObject<{
1202
1202
  outcome: z.ZodEnum<{
1203
- refused: "refused";
1204
1203
  waiting: "waiting";
1204
+ refused: "refused";
1205
+ current: "current";
1205
1206
  "fast-forward": "fast-forward";
1206
1207
  merged: "merged";
1207
- current: "current";
1208
1208
  conflicts: "conflicts";
1209
1209
  }>;
1210
1210
  at: z.ZodNumber;
@@ -1233,10 +1233,10 @@ export declare const MAIN_MIRROR_ANSWER_SCHEMAS: {
1233
1233
  why: z.ZodOptional<z.ZodString>;
1234
1234
  verdict: z.ZodOptional<z.ZodObject<{
1235
1235
  state: z.ZodEnum<{
1236
+ waiting: "waiting";
1236
1237
  refused: "refused";
1237
1238
  "in-main": "in-main";
1238
1239
  "brought-in": "brought-in";
1239
- waiting: "waiting";
1240
1240
  "not-ff": "not-ff";
1241
1241
  }>;
1242
1242
  count: z.ZodNumber;
@@ -1251,8 +1251,8 @@ export declare const MAIN_MIRROR_ANSWER_SCHEMAS: {
1251
1251
  needWhole: z.ZodOptional<z.ZodBoolean>;
1252
1252
  why: z.ZodOptional<z.ZodString>;
1253
1253
  follow: z.ZodOptional<z.ZodEnum<{
1254
- "in-step": "in-step";
1255
1254
  waiting: "waiting";
1255
+ "in-step": "in-step";
1256
1256
  "fast-forward": "fast-forward";
1257
1257
  ahead: "ahead";
1258
1258
  "to-update": "to-update";
@@ -1299,8 +1299,8 @@ export declare const PEER_WORK_SCHEMAS: {
1299
1299
  at: z.ZodNumber;
1300
1300
  started: z.ZodOptional<z.ZodLiteral<true>>;
1301
1301
  state: z.ZodOptional<z.ZodEnum<{
1302
- queued: "queued";
1303
1302
  running: "running";
1303
+ queued: "queued";
1304
1304
  }>>;
1305
1305
  note: z.ZodOptional<z.ZodString>;
1306
1306
  queue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1316,11 +1316,11 @@ export declare const PEER_WORK_SCHEMAS: {
1316
1316
  runId: z.ZodString;
1317
1317
  at: z.ZodNumber;
1318
1318
  state: z.ZodEnum<{
1319
- timeout: "timeout";
1319
+ errored: "errored";
1320
1320
  passed: "passed";
1321
1321
  failed: "failed";
1322
- errored: "errored";
1323
1322
  cancelled: "cancelled";
1323
+ timeout: "timeout";
1324
1324
  }>;
1325
1325
  note: z.ZodOptional<z.ZodString>;
1326
1326
  step: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1413,10 +1413,10 @@ export declare const PEER_WORK_SCHEMAS: {
1413
1413
  }, z.core.$strict>;
1414
1414
  why: z.ZodObject<{
1415
1415
  kind: z.ZodEnum<{
1416
+ restarting: "restarting";
1416
1417
  protocol: "protocol";
1417
1418
  version: "version";
1418
1419
  installed: "installed";
1419
- restarting: "restarting";
1420
1420
  "install-failed": "install-failed";
1421
1421
  "restart-failed": "restart-failed";
1422
1422
  "no-store": "no-store";
@@ -1478,18 +1478,18 @@ export declare const StoreReplySchema: z.ZodObject<{
1478
1478
  result: z.ZodOptional<z.ZodUnknown>;
1479
1479
  error: z.ZodOptional<z.ZodObject<{
1480
1480
  name: z.ZodEnum<{
1481
+ Error: "Error";
1481
1482
  CoordinationError: "CoordinationError";
1482
1483
  CapacityRefusal: "CapacityRefusal";
1483
1484
  CoordinationBusyError: "CoordinationBusyError";
1484
1485
  StoreCallRefused: "StoreCallRefused";
1485
- Error: "Error";
1486
1486
  }>;
1487
1487
  message: z.ZodString;
1488
1488
  room: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1489
1489
  step: z.ZodOptional<z.ZodEnum<{
1490
1490
  open: "open";
1491
- write: "write";
1492
1491
  commit: "commit";
1492
+ write: "write";
1493
1493
  read: "read";
1494
1494
  }>>;
1495
1495
  waitedMs: z.ZodOptional<z.ZodNumber>;
@@ -1579,8 +1579,8 @@ export declare const PEER_LAUNCH_SCHEMAS: {
1579
1579
  state: z.ZodEnum<{
1580
1580
  running: "running";
1581
1581
  failed: "failed";
1582
- exited: "exited";
1583
1582
  stopped: "stopped";
1583
+ exited: "exited";
1584
1584
  }>;
1585
1585
  at: z.ZodNumber;
1586
1586
  pid: z.ZodOptional<z.ZodNumber>;
@@ -1785,9 +1785,9 @@ export declare const GOAL_PEER_SCHEMAS: {
1785
1785
  sha256: z.ZodString;
1786
1786
  }, z.core.$strict>;
1787
1787
  services: z.ZodOptional<z.ZodEnum<{
1788
- "on-demand": "on-demand";
1789
- none: "none";
1790
1788
  always: "always";
1789
+ none: "none";
1790
+ "on-demand": "on-demand";
1791
1791
  }>>;
1792
1792
  at: z.ZodNumber;
1793
1793
  }, z.core.$strict>;
@@ -1802,10 +1802,10 @@ export declare const GOAL_PEER_SCHEMAS: {
1802
1802
  readonly 'goal.changes': z.ZodObject<{
1803
1803
  goal: z.ZodString;
1804
1804
  what: z.ZodEnum<{
1805
- commit: "commit";
1806
1805
  files: "files";
1807
- row: "row";
1806
+ commit: "commit";
1808
1807
  diff: "diff";
1808
+ row: "row";
1809
1809
  commits: "commits";
1810
1810
  against: "against";
1811
1811
  }>;
@@ -1846,10 +1846,10 @@ export declare const GOAL_PEER_ANSWER_SCHEMAS: {
1846
1846
  ref: z.ZodString;
1847
1847
  sha: z.ZodOptional<z.ZodString>;
1848
1848
  mirror: z.ZodOptional<z.ZodEnum<{
1849
+ created: "created";
1850
+ current: "current";
1849
1851
  "not-ff": "not-ff";
1850
1852
  "fast-forward": "fast-forward";
1851
- current: "current";
1852
- created: "created";
1853
1853
  "checked-out": "checked-out";
1854
1854
  }>>;
1855
1855
  told: z.ZodOptional<z.ZodString>;
@@ -1866,10 +1866,10 @@ export declare const GOAL_PEER_ANSWER_SCHEMAS: {
1866
1866
  readonly 'goal.update': z.ZodObject<{
1867
1867
  outcome: z.ZodEnum<{
1868
1868
  refused: "refused";
1869
- merged: "merged";
1870
1869
  current: "current";
1871
- conflicts: "conflicts";
1872
1870
  asked: "asked";
1871
+ merged: "merged";
1872
+ conflicts: "conflicts";
1873
1873
  }>;
1874
1874
  why: z.ZodString;
1875
1875
  sha: z.ZodOptional<z.ZodString>;
package/lib/peers.js CHANGED
@@ -1 +1 @@
1
- "use strict";var W=Object.defineProperty;var w=(t,a)=>W(t,"name",{value:a,configurable:!0});var G=Object.defineProperty,s=w((t,a)=>G(t,"name",{value:a,configurable:!0}),"r");import{z as e}from"zod";import{RUN_ID_PATTERN as I}from"./docker-jobs.js";import{REMOTE_DASHBOARD_BASE_PATTERN as K,REMOTE_INSTANCE_ID_PATTERN as S,REMOTE_INSTANCE_NAME_PREFIX as U}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"],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"],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"};const h=s((t,a)=>t.includes(a),"has");export const isPeerMessageType=s(t=>Object.prototype.hasOwnProperty.call(PEER_MESSAGE_SLICE,t),"isPeerMessageType");export function peerMaySend(t,a){return h(EITHER_WAY,a)||h(PEER_REPLIES,a)?!0:h(t==="organizer"?TO_WORKER:TO_ORGANIZER,a)}w(peerMaySend,"peerMaySend"),s(peerMaySend,"peerMaySend");export const isPeerReply=s(t=>h(PEER_REPLIES,t),"isPeerReply");const l=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,m=s(t=>e.string().min(1).max(t).regex(l),"shownText"),z=e.string().regex(/^[A-Za-z0-9_-]{43}$/),D=e.string().regex(/^[0-9a-f]{64}$/),r=e.string().min(1).max(64).regex(/^[0-9A-Za-z.+_-]+$/),F=e.tuple([e.string().regex(/^[a-z]{3,8}$/),e.string().regex(/^[a-z]{3,8}$/),e.string().regex(/^[a-z]{3,8}$/),e.string().regex(/^[a-z]{3,8}$/)]),n=e.number().int().nonnegative();export const PeerEnvelopeSchema=e.strictObject({v:e.literal(1),id:e.string().regex(PEER_MESSAGE_ID),replyTo:e.string().regex(PEER_MESSAGE_ID).optional(),type:e.string().min(1).max(40),body:e.record(e.string(),e.unknown())});const Y=["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=e.strictObject({code:e.enum(Y),message:e.string().max(500),triesLeft:e.number().int().min(0).max(PAIRING_CODE.tries).optional(),retryAfterMs:e.number().int().min(0).max(36e5).optional()});const c=e.string().regex(I);export const WorkerAdvertSchema=e.record(e.string(),e.unknown()).superRefine((t,a)=>{const x=t.runs;x!==void 0&&(!Array.isArray(x)||x.length>256||!x.every(v=>typeof v=="string"&&I.test(v)))&&a.addIssue({code:"custom",message:"runs: at most 256 run ids"})}),PEER_BODY_SCHEMAS={hello:e.strictObject({protocol:e.literal(PEER_PROTOCOL),lensmcp:r,follow:e.boolean().optional(),store:e.array(r).max(64).optional(),capacity:WorkerAdvertSchema.optional()}),ping:e.strictObject({at:n}),pong:e.strictObject({at:n}),ack:e.strictObject({result:e.unknown().optional()}),error:PeerErrorBodySchema,forget:e.strictObject({why:e.string().max(200).regex(l).optional()})},PeerWelcomeSchema=e.strictObject({protocol:e.literal(PEER_PROTOCOL),lensmcp:r,name:m(64),inStep:e.boolean().optional(),why:e.string().max(500).optional()}),PAIR_BODY_SCHEMAS={"pair.hello":e.strictObject({protocol:e.literal(PEER_PROTOCOL),nonce:z,name:m(64),model:m(40),lensmcp:r}),"pair.resume":e.strictObject({protocol:e.literal(PEER_PROTOCOL)}),"pair.challenge":e.strictObject({nonce:z}),"pair.proof":e.strictObject({proof:D}),"pair.accepted":e.strictObject({proof:D,name:m(64),model:m(40),words:F,approveBy:n}),"pair.approved":e.strictObject({at:n}),"pair.declined":e.strictObject({why:e.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 o=e.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),f=e.string().regex(/^[0-9a-f]{16,64}$/),$=e.string().regex(/^[0-9a-f]{64}$/),M=e.string().regex(/^[0-9a-f]{16}$/),d=e.number().int().min(0).max(1e7),O=e.string().min(1).max(250).regex(/^[A-Za-z0-9._/-]+$/),y=e.string().max(1e3),k=e.strictObject({state:e.enum(["in-main","brought-in","waiting","not-ff","refused"]),count:d,sha:o.optional(),main:o.optional(),why:y,at:n}),q=e.strictObject({outcome:e.enum(["merged","fast-forward","current","conflicts","waiting","refused"]),at:n,why:y,sha:o.optional(),conflicts:e.array(e.string().min(1).max(4096)).max(200).optional(),asked:e.array(e.strictObject({who:e.enum(["person","manager"]),goal:e.string().max(64).optional(),to:e.string().max(200).optional()})).max(20).optional()}),P=e.enum(["in-step","fast-forward","ahead","waiting","to-update","not-following","off-branch"]);export const MAIN_MIRROR_SCHEMAS={"bundle.sent":e.strictObject({bundleId:M,repository:f,refs:e.array(O).length(1),size:e.number().int().positive().max(MAIN_MIRROR.maxSendBytes),sha256:$}),"main.moved":e.strictObject({repository:f,branch:O,sha:o,bundle:e.strictObject({id:M,size:e.number().int().positive(),sha256:$}),verdict:k.optional(),at:n}),"main.state":e.strictObject({repository:f,branch:O,head:o.optional(),organizerHead:o.optional(),haves:e.array(o).max(MAIN_MIRROR.maxHaves),notSent:d,toPull:d,uncommitted:e.strictObject({files:d,changedAt:n.optional()}),snapshot:e.strictObject({sha:o,at:n,files:d,sent:e.boolean()}).optional(),follow:P,update:q.optional(),at:n})},MAIN_MIRROR_ANSWER_SCHEMAS={"bundle.sent":e.strictObject({took:e.boolean(),ref:O,sha:o.optional(),code:e.string().max(40).optional(),why:y.optional(),verdict:k.optional()}),"main.moved":e.strictObject({took:e.boolean(),needWhole:e.boolean().optional(),why:y.optional(),follow:P.optional(),head:o.optional()})};const X=e.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/),_=e.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),T=e.string().regex(/^[0-9a-f]{16,64}$/),u=e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),C=s(t=>e.string().min(1).max(t).regex(l),"sentence"),p=e.record(e.string(),e.unknown()),J=e.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,99}$/),i=e.strictObject({lensmcp:r,protocol:e.string().regex(/^peer\/v[1-9]\d{0,3}$/)});export const PEER_WORK_SCHEMAS={capacity:WorkerAdvertSchema,"job.offer":e.strictObject({runId:c,job:X,candidate:_,repository:T,lane:e.enum(["light","heavy"]).optional(),kind:e.enum(["compose","testcontainers","playwright"]).optional(),hostMb:e.number().int().min(0).max(1024*1024).optional(),vmMb:e.number().int().min(0).max(1024*1024).optional(),proof:e.boolean().optional(),timeoutMinutes:e.number().positive().max(360).optional(),secrets:e.record(J,e.string().min(1).max(8192)).refine(t=>Object.keys(t).length<=16,"at most 16 secrets").optional(),origin:e.string().max(300).regex(/^https?:\/\/[A-Za-z0-9.-]+(?::\d{1,5})?$/).optional()}),"job.cancel":e.strictObject({runId:c,why:C(300)}),"job.state":e.strictObject({runId:c,at:n,started:e.literal(!0).optional(),state:e.enum(["queued","running"]).optional(),note:e.string().max(1e3).optional(),queue:p.optional(),docker:p.optional(),edgePort:e.number().int().min(1024).max(65535).optional()}),"job.stage":e.strictObject({runId:c,stage:C(120),at:n}),"job.done":e.strictObject({runId:c,at:n,state:e.enum(["passed","failed","errored","cancelled","timeout"]),note:e.string().max(1e3).optional(),step:p.optional(),docker:p.optional(),givenBack:e.strictObject({why:e.string().min(1).max(1e3)}).optional(),refused:e.strictObject({why:e.string().min(1).max(1e3)}).optional(),proof:p.optional()}),"bundle.ready":e.strictObject({runId:c.optional(),bundleId:u,repository:T,heads:e.array(_).min(1).max(16),basis:e.array(_).max(256).optional(),size:e.number().int().positive().max(64*1024*1024*1024),sha256:e.string().regex(/^[0-9a-f]{64}$/),shipment:p.optional(),blobs:e.record(e.string().regex(/^[0-9a-f]{64}$/),u).refine(t=>Object.keys(t).length<=101,"at most 101 blobs").optional()}),"tunnel.open":e.strictObject({tunnelId:u,runId:c,port:e.number().int().min(1).max(65535).optional()}),"tunnel.close":e.strictObject({tunnelId:u,why:e.string().max(300).optional()}),"version.install":e.strictObject({version:r,from:e.enum(["registry","organizer"]),tarball:e.strictObject({bundleId:u,sha256:e.string().regex(/^[0-9a-f]{64}$/),size:e.number().int().positive().max(8*1024*1024*1024)}).optional()}),"version.state":e.discriminatedUnion("state",[e.strictObject({state:e.literal("in-step"),worker:i,organizer:i}),e.strictObject({state:e.literal("installing"),worker:i,organizer:i,from:e.enum(["registry","organizer"]),since:n}),e.strictObject({state:e.literal("waiting-for-person"),worker:i,organizer:i,stored:e.boolean()}),e.strictObject({state:e.literal("out-of-step"),worker:i,organizer:i,why:e.object({kind:e.enum(["protocol","version","installed","restarting","install-failed","restart-failed","no-store"])}).catchall(e.union([e.string().max(600),e.number(),e.boolean()]))})])},STORE_CALL_LIMITS={args:16,argsBytes:256*1024,answerBytes:480*1024},PEER_LAUNCH_KEY_PATTERN=/^[A-Za-z0-9_-]{43}$/;const N=e.strictObject({added:e.number().int().nonnegative().nullable(),removed:e.number().int().nonnegative().nullable()});export const StoreCallSchema=e.strictObject({v:e.literal(1),kind:e.literal("store.call"),id:e.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),method:e.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:e.array(e.unknown()).max(STORE_CALL_LIMITS.args),launchKey:e.string().min(16).max(512),observe:e.strictObject({intervalMs:e.number().int().min(0).max(864e5).optional(),snapshot:e.strictObject({branch:e.string().max(300).nullable(),head:e.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/).nullable(),files:e.array(e.strictObject({path:e.string().min(1).max(4096),from:e.string().max(4096).optional(),status:e.string().max(2),staged:N.optional(),unstaged:N.optional()})).max(1e3),truncated:e.boolean()}).optional(),failed:e.literal(!0).optional()}).optional()}),StoreReplySchema=e.strictObject({v:e.literal(1),kind:e.literal("store.reply"),id:e.string().max(100),wrote:e.boolean(),result:e.unknown().optional(),error:e.strictObject({name:e.enum(["CoordinationError","CapacityRefusal","CoordinationBusyError","StoreCallRefused","Error"]),message:e.string().max(4e3),room:e.record(e.string(),e.unknown()).optional(),step:e.enum(["open","write","commit","read"]).optional(),waitedMs:e.number().nonnegative().optional(),tries:e.number().int().nonnegative().optional(),wrote:e.boolean().optional(),where:e.string().max(300).optional(),wal:e.boolean().optional()}).optional()}),REMOTE_INSTANCE_BODY_SCHEMAS={"instance.tunnel.open":e.strictObject({tunnelId:e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),instanceId:e.string().regex(S)}),"instance.state":e.strictObject({instanceId:e.string().regex(S),state:e.enum(["up","gone"]),apex:e.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(U).optional(),dashboardBase:e.string().regex(K).optional(),at:n,why:e.string().max(500).regex(l).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 b=e.string().regex(PEER_LAUNCH_ID),Q=e.string().regex(PEER_LAUNCH_KEY_PATTERN),L=e.string().regex(/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i),V=e.string().regex(/^[a-z][a-z0-9-]{0,39}$/),Z=s(t=>e.string().min(1).max(t).regex(/^[A-Za-z0-9][A-Za-z0-9._:/@[\]-]*$/),"clientWord"),A=e.string().min(2).max(1024).regex(/^\/[^\0\r\n]*$/).refine(t=>!t.split("/").includes(".."),"no .. part"),R=e.string().min(1).max(100).regex(/^[A-Za-z0-9._:-]+$/);export const PEER_LAUNCH_SCHEMAS={"launch.start":e.strictObject({launchId:b,repository:f,goal:R,task:L.optional(),role:V,by:R,client:e.enum(["claude","codex"]),model:Z(80).optional(),effort:Z(40).optional(),worktree:A.optional(),placedGoal:e.literal(!0).optional(),prompt:e.string().min(1).max(PEER_LAUNCH_LIMITS.promptChars),roleText:e.string().max(PEER_LAUNCH_LIMITS.roleTextChars).optional(),name:e.string().min(1).max(80).regex(l).optional(),maxMinutes:e.number().int().min(1).max(PEER_LAUNCH_LIMITS.maxMinutes),account:e.string().regex(/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/).optional(),launchKey:Q,lensmcp:r,resume:e.strictObject({launchId:b,threadId:L,from:A.optional()}).optional(),capKind:e.enum(["writers","checkers"]).optional()}).refine(t=>t.worktree===void 0!=(t.placedGoal===void 0),"a launch names its worktree, or that its goal is placed there \u2014 exactly one"),"launch.stop":e.strictObject({launchId:b,why:e.string().max(300).regex(l).optional()}),"launch.state":e.strictObject({launchId:b,state:e.enum(["running","exited","stopped","failed"]),at:n,pid:e.number().int().min(0).max(99999999).optional(),exitCode:e.number().int().min(-1).max(1024).optional(),endedAt:n.optional(),threadId:R.optional(),ended:e.strictObject({quota:e.strictObject({client:e.enum(["claude","codex"]),why:e.string().min(1).max(300),until:n,firstTurn:e.boolean(),account:e.string().max(40).optional()}).optional(),context:e.string().min(1).max(600).optional()}).optional()}),"launch.tail":e.strictObject({launchId:b,lines:e.array(e.string().max(PEER_LAUNCH_LIMITS.tailLineChars+8)).max(PEER_LAUNCH_LIMITS.tailLines),at:n})},LaunchStartedSchema=e.strictObject({started:e.literal(!0),pid:e.number().int().min(2).max(99999999),worktree:A,branch:e.string().max(250).optional(),startedAt:n,deadline:n,threadId:e.string().max(200).optional(),lensmcp:r}),STORE_READ_LIMITS={calls:24,argsBytes:64*1024,answerBytes:STORE_CALL_LIMITS.answerBytes},StoreReadSchema=e.strictObject({v:e.literal(1),kind:e.literal("store.read"),id:e.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),repoId:e.string().regex(/^[0-9a-f]{16,64}$/),calls:e.array(e.strictObject({method:e.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:e.array(e.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 j=e.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),B=e.strictObject({id:e.string().regex(/^[0-9a-f]{16}$/),size:e.number().int().positive().max(64*1024*1024*1024),sha256:e.string().regex(/^[0-9a-f]{64}$/)}),ee=e.string().min(1).max(200).regex(/^lensmcp\/g-[a-z0-9-]{1,30}$/),g=e.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),H=e.string().regex(/^[0-9a-f]{16,64}$/),E=e.string().max(1e3);export const GOAL_PEER_SCHEMAS={"goal.place":e.strictObject({goal:j,title:e.string().min(1).max(300).regex(l),repository:H,worktreeId:e.string().regex(/^[0-9a-f]{24}$/),name:e.string().regex(/^g-[a-z0-9](?:[a-z0-9-]{0,17}[a-z0-9])?$/),branch:ee,base:g,bundle:B,services:e.enum(["on-demand","none","always"]).optional(),at:n}),"goal.sent":e.strictObject({bundleId:e.string().regex(/^[0-9a-f]{16}$/),repository:H,goal:j,ref:e.string().min(1).max(250).regex(/^heads\/lensmcp\/g-[a-z0-9-]{1,30}$/),size:e.number().int().positive().max(GOAL_ON_WORKER.maxSendBytes),sha256:e.string().regex(/^[0-9a-f]{64}$/)}),"goal.changes":e.strictObject({goal:j,what:e.enum(["row","files","diff","commits","commit","against"]),path:e.string().min(1).max(4096).optional(),sha:g.optional(),full:e.boolean().optional(),againstMain:e.boolean().optional()}),"goal.update":e.strictObject({goal:j,main:e.strictObject({branch:e.string().min(1).max(200).regex(/^[A-Za-z0-9._/-]+$/),sha:g,bundle:B}),at:n})},GOAL_PEER_ANSWER_SCHEMAS={"goal.place":e.strictObject({state:e.enum(["ready","creating","failed"]),head:g.optional(),onDemand:e.boolean().optional(),needWhole:e.boolean().optional(),why:E.optional()}),"goal.sent":e.strictObject({took:e.boolean(),ref:e.string().max(250),sha:g.optional(),mirror:e.enum(["created","fast-forward","current","not-ff","checked-out"]).optional(),told:e.string().max(200).optional(),code:e.string().max(40).optional(),why:E.optional()}),"goal.changes":e.strictObject({ok:e.boolean(),value:e.unknown().optional(),status:e.number().int().min(100).max(599).optional(),why:E.optional(),shortened:e.boolean().optional()}),"goal.update":e.strictObject({outcome:e.enum(["current","merged","asked","conflicts","refused"]),why:E,sha:g.optional(),behind:e.number().int().min(0).max(1e7).optional(),dirty:e.number().int().min(0).max(1e7).optional(),conflicts:e.array(e.string().min(1).max(4096)).max(200).optional(),needWhole:e.boolean().optional()})};
1
+ "use strict";var G=Object.defineProperty;var w=(t,a)=>G(t,"name",{value:a,configurable:!0});var K=Object.defineProperty,v=w((t,a)=>K(t,"name",{value:a,configurable:!0}),"w"),U=Object.defineProperty,s=v((t,a)=>U(t,"name",{value:a,configurable:!0}),"r");import{z as e}from"zod";import{RUN_ID_PATTERN as I}from"./docker-jobs.js";import{REMOTE_DASHBOARD_BASE_PATTERN as F,REMOTE_INSTANCE_ID_PATTERN as z,REMOTE_INSTANCE_NAME_PREFIX as Y}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"],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"],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"};const h=s((t,a)=>t.includes(a),"has");export const isPeerMessageType=s(t=>Object.prototype.hasOwnProperty.call(PEER_MESSAGE_SLICE,t),"isPeerMessageType");export function peerMaySend(t,a){return h(EITHER_WAY,a)||h(PEER_REPLIES,a)?!0:h(t==="organizer"?TO_WORKER:TO_ORGANIZER,a)}w(peerMaySend,"peerMaySend"),v(peerMaySend,"peerMaySend"),s(peerMaySend,"peerMaySend");export const isPeerReply=s(t=>h(PEER_REPLIES,t),"isPeerReply");const l=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,m=s(t=>e.string().min(1).max(t).regex(l),"shownText"),D=e.string().regex(/^[A-Za-z0-9_-]{43}$/),$=e.string().regex(/^[0-9a-f]{64}$/),r=e.string().min(1).max(64).regex(/^[0-9A-Za-z.+_-]+$/),q=e.tuple([e.string().regex(/^[a-z]{3,8}$/),e.string().regex(/^[a-z]{3,8}$/),e.string().regex(/^[a-z]{3,8}$/),e.string().regex(/^[a-z]{3,8}$/)]),n=e.number().int().nonnegative();export const PeerEnvelopeSchema=e.strictObject({v:e.literal(1),id:e.string().regex(PEER_MESSAGE_ID),replyTo:e.string().regex(PEER_MESSAGE_ID).optional(),type:e.string().min(1).max(40),body:e.record(e.string(),e.unknown())});const X=["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=e.strictObject({code:e.enum(X),message:e.string().max(500),triesLeft:e.number().int().min(0).max(PAIRING_CODE.tries).optional(),retryAfterMs:e.number().int().min(0).max(36e5).optional()});const c=e.string().regex(I);export const WorkerAdvertSchema=e.record(e.string(),e.unknown()).superRefine((t,a)=>{const x=t.runs;x!==void 0&&(!Array.isArray(x)||x.length>256||!x.every(S=>typeof S=="string"&&I.test(S)))&&a.addIssue({code:"custom",message:"runs: at most 256 run ids"})}),PEER_BODY_SCHEMAS={hello:e.strictObject({protocol:e.literal(PEER_PROTOCOL),lensmcp:r,follow:e.boolean().optional(),store:e.array(r).max(64).optional(),capacity:WorkerAdvertSchema.optional()}),ping:e.strictObject({at:n}),pong:e.strictObject({at:n}),ack:e.strictObject({result:e.unknown().optional()}),error:PeerErrorBodySchema,forget:e.strictObject({why:e.string().max(200).regex(l).optional()})},PeerWelcomeSchema=e.strictObject({protocol:e.literal(PEER_PROTOCOL),lensmcp:r,name:m(64),inStep:e.boolean().optional(),why:e.string().max(500).optional()}),PAIR_BODY_SCHEMAS={"pair.hello":e.strictObject({protocol:e.literal(PEER_PROTOCOL),nonce:D,name:m(64),model:m(40),lensmcp:r}),"pair.resume":e.strictObject({protocol:e.literal(PEER_PROTOCOL)}),"pair.challenge":e.strictObject({nonce:D}),"pair.proof":e.strictObject({proof:$}),"pair.accepted":e.strictObject({proof:$,name:m(64),model:m(40),words:q,approveBy:n}),"pair.approved":e.strictObject({at:n}),"pair.declined":e.strictObject({why:e.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 o=e.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),f=e.string().regex(/^[0-9a-f]{16,64}$/),M=e.string().regex(/^[0-9a-f]{64}$/),k=e.string().regex(/^[0-9a-f]{16}$/),d=e.number().int().min(0).max(1e7),O=e.string().min(1).max(250).regex(/^[A-Za-z0-9._/-]+$/),y=e.string().max(1e3),P=e.strictObject({state:e.enum(["in-main","brought-in","waiting","not-ff","refused"]),count:d,sha:o.optional(),main:o.optional(),why:y,at:n}),J=e.strictObject({outcome:e.enum(["merged","fast-forward","current","conflicts","waiting","refused"]),at:n,why:y,sha:o.optional(),conflicts:e.array(e.string().min(1).max(4096)).max(200).optional(),asked:e.array(e.strictObject({who:e.enum(["person","manager"]),goal:e.string().max(64).optional(),to:e.string().max(200).optional()})).max(20).optional()}),T=e.enum(["in-step","fast-forward","ahead","waiting","to-update","not-following","off-branch"]);export const MAIN_MIRROR_SCHEMAS={"bundle.sent":e.strictObject({bundleId:k,repository:f,refs:e.array(O).length(1),size:e.number().int().positive().max(MAIN_MIRROR.maxSendBytes),sha256:M}),"main.moved":e.strictObject({repository:f,branch:O,sha:o,bundle:e.strictObject({id:k,size:e.number().int().positive(),sha256:M}),verdict:P.optional(),at:n}),"main.state":e.strictObject({repository:f,branch:O,head:o.optional(),organizerHead:o.optional(),haves:e.array(o).max(MAIN_MIRROR.maxHaves),notSent:d,toPull:d,uncommitted:e.strictObject({files:d,changedAt:n.optional()}),snapshot:e.strictObject({sha:o,at:n,files:d,sent:e.boolean()}).optional(),follow:T,update:J.optional(),at:n})},MAIN_MIRROR_ANSWER_SCHEMAS={"bundle.sent":e.strictObject({took:e.boolean(),ref:O,sha:o.optional(),code:e.string().max(40).optional(),why:y.optional(),verdict:P.optional()}),"main.moved":e.strictObject({took:e.boolean(),needWhole:e.boolean().optional(),why:y.optional(),follow:T.optional(),head:o.optional()})};const Q=e.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/),_=e.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),C=e.string().regex(/^[0-9a-f]{16,64}$/),u=e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),N=s(t=>e.string().min(1).max(t).regex(l),"sentence"),p=e.record(e.string(),e.unknown()),V=e.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,99}$/),i=e.strictObject({lensmcp:r,protocol:e.string().regex(/^peer\/v[1-9]\d{0,3}$/)});export const PEER_WORK_SCHEMAS={capacity:WorkerAdvertSchema,"job.offer":e.strictObject({runId:c,job:Q,candidate:_,repository:C,lane:e.enum(["light","heavy"]).optional(),kind:e.enum(["compose","testcontainers","playwright"]).optional(),hostMb:e.number().int().min(0).max(1024*1024).optional(),vmMb:e.number().int().min(0).max(1024*1024).optional(),proof:e.boolean().optional(),timeoutMinutes:e.number().positive().max(360).optional(),secrets:e.record(V,e.string().min(1).max(8192)).refine(t=>Object.keys(t).length<=16,"at most 16 secrets").optional(),origin:e.string().max(300).regex(/^https?:\/\/[A-Za-z0-9.-]+(?::\d{1,5})?$/).optional()}),"job.cancel":e.strictObject({runId:c,why:N(300)}),"job.state":e.strictObject({runId:c,at:n,started:e.literal(!0).optional(),state:e.enum(["queued","running"]).optional(),note:e.string().max(1e3).optional(),queue:p.optional(),docker:p.optional(),edgePort:e.number().int().min(1024).max(65535).optional()}),"job.stage":e.strictObject({runId:c,stage:N(120),at:n}),"job.done":e.strictObject({runId:c,at:n,state:e.enum(["passed","failed","errored","cancelled","timeout"]),note:e.string().max(1e3).optional(),step:p.optional(),docker:p.optional(),givenBack:e.strictObject({why:e.string().min(1).max(1e3)}).optional(),refused:e.strictObject({why:e.string().min(1).max(1e3)}).optional(),proof:p.optional()}),"bundle.ready":e.strictObject({runId:c.optional(),bundleId:u,repository:C,heads:e.array(_).min(1).max(16),basis:e.array(_).max(256).optional(),size:e.number().int().positive().max(64*1024*1024*1024),sha256:e.string().regex(/^[0-9a-f]{64}$/),shipment:p.optional(),blobs:e.record(e.string().regex(/^[0-9a-f]{64}$/),u).refine(t=>Object.keys(t).length<=101,"at most 101 blobs").optional()}),"tunnel.open":e.strictObject({tunnelId:u,runId:c,port:e.number().int().min(1).max(65535).optional()}),"tunnel.close":e.strictObject({tunnelId:u,why:e.string().max(300).optional()}),"version.install":e.strictObject({version:r,from:e.enum(["registry","organizer"]),tarball:e.strictObject({bundleId:u,sha256:e.string().regex(/^[0-9a-f]{64}$/),size:e.number().int().positive().max(8*1024*1024*1024)}).optional()}),"version.state":e.discriminatedUnion("state",[e.strictObject({state:e.literal("in-step"),worker:i,organizer:i}),e.strictObject({state:e.literal("installing"),worker:i,organizer:i,from:e.enum(["registry","organizer"]),since:n}),e.strictObject({state:e.literal("waiting-for-person"),worker:i,organizer:i,stored:e.boolean()}),e.strictObject({state:e.literal("out-of-step"),worker:i,organizer:i,why:e.object({kind:e.enum(["protocol","version","installed","restarting","install-failed","restart-failed","no-store"])}).catchall(e.union([e.string().max(600),e.number(),e.boolean()]))})])},STORE_CALL_LIMITS={args:16,argsBytes:256*1024,answerBytes:480*1024},PEER_LAUNCH_KEY_PATTERN=/^[A-Za-z0-9_-]{43}$/;const L=e.strictObject({added:e.number().int().nonnegative().nullable(),removed:e.number().int().nonnegative().nullable()});export const StoreCallSchema=e.strictObject({v:e.literal(1),kind:e.literal("store.call"),id:e.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),method:e.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:e.array(e.unknown()).max(STORE_CALL_LIMITS.args),launchKey:e.string().min(16).max(512),observe:e.strictObject({intervalMs:e.number().int().min(0).max(864e5).optional(),snapshot:e.strictObject({branch:e.string().max(300).nullable(),head:e.string().regex(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/).nullable(),files:e.array(e.strictObject({path:e.string().min(1).max(4096),from:e.string().max(4096).optional(),status:e.string().max(2),staged:L.optional(),unstaged:L.optional()})).max(1e3),truncated:e.boolean()}).optional(),failed:e.literal(!0).optional()}).optional()}),StoreReplySchema=e.strictObject({v:e.literal(1),kind:e.literal("store.reply"),id:e.string().max(100),wrote:e.boolean(),result:e.unknown().optional(),error:e.strictObject({name:e.enum(["CoordinationError","CapacityRefusal","CoordinationBusyError","StoreCallRefused","Error"]),message:e.string().max(4e3),room:e.record(e.string(),e.unknown()).optional(),step:e.enum(["open","write","commit","read"]).optional(),waitedMs:e.number().nonnegative().optional(),tries:e.number().int().nonnegative().optional(),wrote:e.boolean().optional(),where:e.string().max(300).optional(),wal:e.boolean().optional()}).optional()}),REMOTE_INSTANCE_BODY_SCHEMAS={"instance.tunnel.open":e.strictObject({tunnelId:e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/),instanceId:e.string().regex(z)}),"instance.state":e.strictObject({instanceId:e.string().regex(z),state:e.enum(["up","gone"]),apex:e.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(Y).optional(),dashboardBase:e.string().regex(F).optional(),at:n,why:e.string().max(500).regex(l).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 b=e.string().regex(PEER_LAUNCH_ID),ee=e.string().regex(PEER_LAUNCH_KEY_PATTERN),Z=e.string().regex(/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i),te=e.string().regex(/^[a-z][a-z0-9-]{0,39}$/),B=s(t=>e.string().min(1).max(t).regex(/^[A-Za-z0-9][A-Za-z0-9._:/@[\]-]*$/),"clientWord"),A=e.string().min(2).max(1024).regex(/^\/[^\0\r\n]*$/).refine(t=>!t.split("/").includes(".."),"no .. part"),R=e.string().min(1).max(100).regex(/^[A-Za-z0-9._:-]+$/);export const PEER_LAUNCH_SCHEMAS={"launch.start":e.strictObject({launchId:b,repository:f,goal:R,task:Z.optional(),role:te,by:R,client:e.enum(["claude","codex"]),model:B(80).optional(),effort:B(40).optional(),worktree:A.optional(),placedGoal:e.literal(!0).optional(),prompt:e.string().min(1).max(PEER_LAUNCH_LIMITS.promptChars),roleText:e.string().max(PEER_LAUNCH_LIMITS.roleTextChars).optional(),name:e.string().min(1).max(80).regex(l).optional(),maxMinutes:e.number().int().min(1).max(PEER_LAUNCH_LIMITS.maxMinutes),account:e.string().regex(/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/).optional(),launchKey:ee,lensmcp:r,resume:e.strictObject({launchId:b,threadId:Z,from:A.optional()}).optional(),capKind:e.enum(["writers","checkers"]).optional()}).refine(t=>t.worktree===void 0!=(t.placedGoal===void 0),"a launch names its worktree, or that its goal is placed there \u2014 exactly one"),"launch.stop":e.strictObject({launchId:b,why:e.string().max(300).regex(l).optional()}),"launch.state":e.strictObject({launchId:b,state:e.enum(["running","exited","stopped","failed"]),at:n,pid:e.number().int().min(0).max(99999999).optional(),exitCode:e.number().int().min(-1).max(1024).optional(),endedAt:n.optional(),threadId:R.optional(),ended:e.strictObject({quota:e.strictObject({client:e.enum(["claude","codex"]),why:e.string().min(1).max(300),until:n,firstTurn:e.boolean(),account:e.string().max(40).optional()}).optional(),context:e.string().min(1).max(600).optional()}).optional()}),"launch.tail":e.strictObject({launchId:b,lines:e.array(e.string().max(PEER_LAUNCH_LIMITS.tailLineChars+8)).max(PEER_LAUNCH_LIMITS.tailLines),at:n})},LaunchStartedSchema=e.strictObject({started:e.literal(!0),pid:e.number().int().min(2).max(99999999),worktree:A,branch:e.string().max(250).optional(),startedAt:n,deadline:n,threadId:e.string().max(200).optional(),lensmcp:r}),STORE_READ_LIMITS={calls:24,argsBytes:64*1024,answerBytes:STORE_CALL_LIMITS.answerBytes},StoreReadSchema=e.strictObject({v:e.literal(1),kind:e.literal("store.read"),id:e.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),repoId:e.string().regex(/^[0-9a-f]{16,64}$/),calls:e.array(e.strictObject({method:e.string().regex(/^[A-Za-z][A-Za-z0-9]{0,79}$/),args:e.array(e.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 j=e.string().regex(/^[A-Za-z0-9._:-]{1,100}$/),H=e.strictObject({id:e.string().regex(/^[0-9a-f]{16}$/),size:e.number().int().positive().max(64*1024*1024*1024),sha256:e.string().regex(/^[0-9a-f]{64}$/)}),ne=e.string().min(1).max(200).regex(/^lensmcp\/g-[a-z0-9-]{1,30}$/),g=e.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),W=e.string().regex(/^[0-9a-f]{16,64}$/),E=e.string().max(1e3);export const GOAL_PEER_SCHEMAS={"goal.place":e.strictObject({goal:j,title:e.string().min(1).max(300).regex(l),repository:W,worktreeId:e.string().regex(/^[0-9a-f]{24}$/),name:e.string().regex(/^g-[a-z0-9](?:[a-z0-9-]{0,17}[a-z0-9])?$/),branch:ne,base:g,bundle:H,services:e.enum(["on-demand","none","always"]).optional(),at:n}),"goal.sent":e.strictObject({bundleId:e.string().regex(/^[0-9a-f]{16}$/),repository:W,goal:j,ref:e.string().min(1).max(250).regex(/^heads\/lensmcp\/g-[a-z0-9-]{1,30}$/),size:e.number().int().positive().max(GOAL_ON_WORKER.maxSendBytes),sha256:e.string().regex(/^[0-9a-f]{64}$/)}),"goal.changes":e.strictObject({goal:j,what:e.enum(["row","files","diff","commits","commit","against"]),path:e.string().min(1).max(4096).optional(),sha:g.optional(),full:e.boolean().optional(),againstMain:e.boolean().optional()}),"goal.update":e.strictObject({goal:j,main:e.strictObject({branch:e.string().min(1).max(200).regex(/^[A-Za-z0-9._/-]+$/),sha:g,bundle:H}),at:n})},GOAL_PEER_ANSWER_SCHEMAS={"goal.place":e.strictObject({state:e.enum(["ready","creating","failed"]),head:g.optional(),onDemand:e.boolean().optional(),needWhole:e.boolean().optional(),why:E.optional()}),"goal.sent":e.strictObject({took:e.boolean(),ref:e.string().max(250),sha:g.optional(),mirror:e.enum(["created","fast-forward","current","not-ff","checked-out"]).optional(),told:e.string().max(200).optional(),code:e.string().max(40).optional(),why:E.optional()}),"goal.changes":e.strictObject({ok:e.boolean(),value:e.unknown().optional(),status:e.number().int().min(100).max(599).optional(),why:E.optional(),shortened:e.boolean().optional()}),"goal.update":e.strictObject({outcome:e.enum(["current","merged","asked","conflicts","refused"]),why:E,sha:g.optional(),behind:e.number().int().min(0).max(1e7).optional(),dirty:e.number().int().min(0).max(1e7).optional(),conflicts:e.array(e.string().min(1).max(4096)).max(200).optional(),needWhole:e.boolean().optional()})};
package/lib/perf-rules.js CHANGED
@@ -1 +1 @@
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");
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 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");
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");
@@ -1 +1 @@
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");
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");
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty;var _=(E,e)=>t(E,"name",{value:e,configurable:!0});var o=Object.defineProperty,A=_((E,e)=>o(E,"name",{value:e,configurable:!0}),"o");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}$/;export function remoteLensHost(E){return`${REMOTE_LENS_LABEL}.${E.toLowerCase()}`}_(remoteLensHost,"remoteLensHost"),A(remoteLensHost,"remoteLensHost");export const REMOTE_INSTANCES_FILE="instances.json";
1
+ "use strict";var r=Object.defineProperty;var t=(e,E)=>r(e,"name",{value:E,configurable:!0});var _=Object.defineProperty,o=t((e,E)=>_(e,"name",{value:E,configurable:!0}),"_"),n=Object.defineProperty,A=o((e,E)=>n(e,"name",{value:E,configurable:!0}),"o");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}$/;export function remoteLensHost(e){return`${REMOTE_LENS_LABEL}.${e.toLowerCase()}`}t(remoteLensHost,"remoteLensHost"),o(remoteLensHost,"remoteLensHost"),A(remoteLensHost,"remoteLensHost");export const REMOTE_INSTANCES_FILE="instances.json";
package/lib/sources.js CHANGED
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var a=(t,r)=>T(t,"name",{value:r,configurable:!0});var U=Object.defineProperty,e=a((t,r)=>U(t,"name",{value:r,configurable:!0}),"r");export const SOURCE_KINDS=["queue","loop","store","traffic"],SOURCE_KINDS_READ=["queue","loop","store","traffic"],sourceWireSchema=e(t=>`lensmcp.${t}/v1`,"sourceWireSchema"),QUEUE_WIRE_SCHEMA="lensmcp.queue/v1",LOOP_WIRE_SCHEMA="lensmcp.loop/v1",STORE_WIRE_SCHEMA="lensmcp.store/v1",TRAFFIC_WIRE_SCHEMA="lensmcp.traffic/v1",SOURCE_SNAPSHOT_FIELD={queue:"snapshot",loop:"loop",store:"store",traffic:"traffic"},URI_SOURCES="process://sources",SOURCE_PROVENANCE="reported",QUEUE_OLDEST_WAIT_RULE="queue/oldest-wait",QUEUE_STALLED_RULE="queue/stalled",LOOP_OVERDUE_RULE="loop/overdue",LOOP_FAILING_RULE="loop/failing",LOOP_IDLE_RULE="loop/idle-while-fed",STORE_QUOTA_RULE="store/near-quota",STORE_ERRORS_RULE="store/errors",STORE_ORPHANS_RULE="store/orphans",TRAFFIC_FAILURES_RULE="traffic/failures",TRAFFIC_LATENCY_RULE="traffic/latency",TRAFFIC_RATE_LIMITED_RULE="traffic/rate-limited",SOURCE_RULES=[QUEUE_OLDEST_WAIT_RULE,QUEUE_STALLED_RULE,LOOP_OVERDUE_RULE,LOOP_FAILING_RULE,LOOP_IDLE_RULE,STORE_QUOTA_RULE,STORE_ERRORS_RULE,STORE_ORPHANS_RULE,TRAFFIC_FAILURES_RULE,TRAFFIC_LATENCY_RULE,TRAFFIC_RATE_LIMITED_RULE],SOURCE_EVENT_KINDS=["source-poll","source-declaration","source-event"],CUSTOM_EVENT_SOURCE="custom",QUEUE_EVENTS=["enqueued","admitted","completed","failed","parked"],LOOP_EVENTS=["run-start","run-end"],LOOP_OUTCOMES=["ok","failed","skipped"],STORE_EVENTS=["write","delete","error"],TRAFFIC_EVENTS=["inbound","outbound"],TRAFFIC_OUTCOMES=["ok","failed","rate-limited"],SOURCE_PUSH_EVENTS={queue:QUEUE_EVENTS,loop:LOOP_EVENTS,store:STORE_EVENTS,traffic:TRAFFIC_EVENTS},SOURCE_PUSH_OUTCOMES={queue:[],loop:LOOP_OUTCOMES,store:[],traffic:TRAFFIC_OUTCOMES},SOURCE_POLL_STATES=["current","unreachable","refused","malformed","not-running"],SOURCE_STATES=[...SOURCE_POLL_STATES,"stale","never-polled"],SOURCE_DEFAULT_INTERVAL_SEC=10,SOURCE_MIN_INTERVAL_SEC=2,QUEUE_DEFAULT_OLDEST_WAIT_MIN=10,QUEUE_DEFAULT_STALLED_MIN=15,LOOP_DEFAULT_IDLE_MIN=10,LOOP_OVERDUE_INTERVALS=2,LOOP_FAILING_RUNS=3,SOURCE_FULL_REPORT_MS=6e4,SOURCE_HISTORY_POINTS=60,SOURCE_RUNS_KEPT=30,SOURCE_PUSHED_KEPT=20,STORE_DEFAULT_QUOTA_PCT=90,STORE_DEFAULT_ERROR_RATE_PCT=5,STORE_DEFAULT_ORPHAN_MIN=60,TRAFFIC_DEFAULT_FAILURE_PCT=5,TRAFFIC_DEFAULT_P95_MS=2e3,TRAFFIC_DEFAULT_RATE_LIMITED=1,TRAFFIC_MIN_MESSAGES=10,TRAFFIC_PUSH_WINDOW_MS=10*6e4,TRAFFIC_PUSH_CHANNELS=50,TRAFFIC_PUSH_EVENTS_PER_CHANNEL=1e3,SOURCE_MAX_GROUPS=500,SOURCE_MAX_BYTES=256*1024,SOURCE_STALE_PERIODS=3,SOURCE_STALE_MIN_MS=3e4;export function sourceStaleAfterMs(t){return Math.max(SOURCE_STALE_MIN_MS,SOURCE_STALE_PERIODS*Math.max(0,t))}a(sourceStaleAfterMs,"sourceStaleAfterMs"),e(sourceStaleAfterMs,"sourceStaleAfterMs");const n=e(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"isObj"),s=e(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0,"isCount"),E=e(t=>typeof t=="number"&&Number.isFinite(t)&&t>0,"isTime"),u=e((t,r)=>typeof t=="string"&&t.length>0&&t.length<=r,"isStr"),v=e(t=>t===void 0||typeof t=="number"&&t>0,"isMin");function _(t){if(!SOURCE_KINDS_READ.includes(t.sourceKind)||typeof t.path!="string"&&!(t.path===void 0&&(t.sourceKind==="traffic"||t.sourceKind==="loop"))||!u(t.name,200)||typeof t.intervalSec!="number"||t.feeds!==void 0&&!u(t.feeds,200))return!1;const r=t.thresholds;if(!n(r))return!1;for(const o of["stalledMin","idleMin","oldestWaitMin","quotaPct","errorRatePct","orphanMin","failurePct","p95Ms","rateLimited"])if(!v(r[o]))return!1;return t.sourceKind!=="queue"||typeof r.oldestWaitMin=="number"}a(_,"l"),e(_,"asDecl");const l=e(t=>t===null||typeof t=="string","isIsoOrNull"),c=e(t=>t===void 0||s(t),"isOptCount");function d(t){if(!n(t)||typeof t.at!="string"||!E(t.receivedAt)||!E(t.intervalSec)||!l(t.lastRunAt)||t.nextRunAt!==void 0&&!l(t.nextRunAt))return!1;for(const r of["lastDurationMs","lastItems","runsInWindow","itemsInWindow","failuresInWindow","windowSec"])if(!c(t[r]))return!1;return t.lastOutcome!==void 0&&!LOOP_OUTCOMES.includes(t.lastOutcome)?!1:t.lastError===void 0||typeof t.lastError=="string"}a(d,"_"),e(d,"asLoopSnapshot");const f=e(t=>t===void 0||n(t)&&Object.values(t).every(r=>typeof r=="string"),"isLabels");function S(t){if(!n(t)||typeof t.at!="string"||!E(t.receivedAt)||!s(t.objects)||!s(t.bytes)||t.quotaBytes!==void 0&&t.quotaBytes!==null&&!s(t.quotaBytes))return!1;for(const i of["opsInWindow","writesInWindow","deletesInWindow","errorsInWindow","windowSec"])if(!c(t[i]))return!1;if(t.lastWriteAt!==void 0&&!l(t.lastWriteAt)||t.lastError!==void 0&&typeof t.lastError!="string")return!1;const r=t.truncated;if(r!==void 0&&!(n(r)&&s(r.groups)))return!1;const o=t.groups;return o===void 0?!0:Array.isArray(o)&&o.length<=SOURCE_MAX_GROUPS&&o.every(i=>n(i)&&u(i.group,1e3)&&s(i.objects)&&s(i.bytes)&&f(i.labels))}a(S,"S"),e(S,"asStoreSnapshot");function p(t){if(!n(t)||typeof t.at!="string"||!E(t.receivedAt)||!Array.isArray(t.channels)||!c(t.windowSec))return!1;const r=t.truncated;return r!==void 0&&!(n(r)&&s(r.channels))?!1:t.channels.length<=SOURCE_MAX_GROUPS&&t.channels.every(o=>{if(!n(o)||!u(o.channel,1e3)||!f(o.labels)||o.direction!==void 0&&o.direction!=="inbound"&&o.direction!=="outbound"||o.counterpart!==void 0&&!u(o.counterpart,200))return!1;for(const i of["messagesInWindow","failuresInWindow","rateLimitedInWindow"])if(!c(o[i]))return!1;return o.p95Ms!==void 0&&!(typeof o.p95Ms=="number"&&Number.isFinite(o.p95Ms)&&o.p95Ms>=0)||o.lastAt!==void 0&&!l(o.lastAt)?!1:o.lastError===void 0||typeof o.lastError=="string"})}a(p,"R"),e(p,"asTrafficSnapshot");function R(t){return n(t)&&u(t.digest,100)&&typeof t.at=="string"&&E(t.receivedAt)}a(R,"A"),e(R,"asSame");function A(t){if(!n(t)||!u(t.group,1e3)||!s(t.pending))return!1;for(const i of["inFlight","failed","completedInWindow"])if(t[i]!==void 0&&!s(t[i]))return!1;const r=t.oldestPendingAt;if(r!=null&&typeof r!="string")return!1;const o=t.labels;return o===void 0||n(o)&&Object.values(o).every(i=>typeof i=="string")}a(A,"O"),e(A,"asGroup");function O(t){if(!n(t)||typeof t.at!="string"||!E(t.receivedAt)||!Array.isArray(t.groups))return!1;const r=t.totals;if(!n(r)||!s(r.groups)||!s(r.pending)||!s(r.inFlight)||!s(r.failed))return!1;const o=t.truncated;return o!==void 0&&!(n(o)&&s(o.groups))?!1:t.groups.length<=SOURCE_MAX_GROUPS&&t.groups.every(A)}a(O,"T"),e(O,"asSnapshot");export function asSourcePollRaw(t){if(!n(t)||t.kind!=="source-poll"||!u(t.project,200)||!_(t)||!SOURCE_POLL_STATES.includes(t.state)||!E(t.polledAt)||!E(t.reportEveryMs)||t.path===void 0)return;const r=SOURCE_SNAPSHOT_FIELD[t.sourceKind];for(const i of Object.values(SOURCE_SNAPSHOT_FIELD))if(i!==r&&t[i]!==void 0)return;const o={snapshot:O,loop:d,store:S,traffic:p}[r];if(!(t[r]!==void 0&&!o(t[r]))&&!(t.same!==void 0&&(!R(t.same)||t[r]!==void 0))&&!(t.state==="current"&&t[r]===void 0&&t.same===void 0))return t}a(asSourcePollRaw,"asSourcePollRaw"),e(asSourcePollRaw,"asSourcePollRaw");export function asSourceEventRaw(t){if(!n(t)||t.kind!=="source-event"||!u(t.project,200)||!u(t.name,200))return;const r=t.sourceKind;if(SOURCE_KINDS_READ.includes(r)&&SOURCE_PUSH_EVENTS[r].includes(t.event)&&!(t.item!==void 0&&!u(t.item,200)||t.group!==void 0&&!u(t.group,200))&&!(!c(t.items)||!c(t.durationMs)||!c(t.bytes))&&!(t.outcome!==void 0&&!SOURCE_PUSH_OUTCOMES[r].includes(t.outcome))){for(const o of["object","channel","counterpart","correlation"])if(t[o]!==void 0&&!u(t[o],200))return;if(!(t.error!==void 0&&typeof t.error!="string"))return t}}a(asSourceEventRaw,"asSourceEventRaw"),e(asSourceEventRaw,"asSourceEventRaw");export function asSourceDeclarationRaw(t){if(!(!n(t)||t.kind!=="source-declaration"||!u(t.project,200))&&!(!Array.isArray(t.sources)||!t.sources.every(r=>n(r)&&_(r)))&&!(!Array.isArray(t.problems)||!t.problems.every(r=>typeof r=="string")))return t}a(asSourceDeclarationRaw,"asSourceDeclarationRaw"),e(asSourceDeclarationRaw,"asSourceDeclarationRaw");
1
+ "use strict";var U=Object.defineProperty;var u=(e,r)=>U(e,"name",{value:r,configurable:!0});var v=Object.defineProperty,c=u((e,r)=>v(e,"name",{value:r,configurable:!0}),"a"),I=Object.defineProperty,n=c((e,r)=>I(e,"name",{value:r,configurable:!0}),"r");export const SOURCE_KINDS=["queue","loop","store","traffic"],SOURCE_KINDS_READ=["queue","loop","store","traffic"],sourceWireSchema=n(e=>`lensmcp.${e}/v1`,"sourceWireSchema"),QUEUE_WIRE_SCHEMA="lensmcp.queue/v1",LOOP_WIRE_SCHEMA="lensmcp.loop/v1",STORE_WIRE_SCHEMA="lensmcp.store/v1",TRAFFIC_WIRE_SCHEMA="lensmcp.traffic/v1",SOURCE_SNAPSHOT_FIELD={queue:"snapshot",loop:"loop",store:"store",traffic:"traffic"},URI_SOURCES="process://sources",SOURCE_PROVENANCE="reported",QUEUE_OLDEST_WAIT_RULE="queue/oldest-wait",QUEUE_STALLED_RULE="queue/stalled",LOOP_OVERDUE_RULE="loop/overdue",LOOP_FAILING_RULE="loop/failing",LOOP_IDLE_RULE="loop/idle-while-fed",STORE_QUOTA_RULE="store/near-quota",STORE_ERRORS_RULE="store/errors",STORE_ORPHANS_RULE="store/orphans",TRAFFIC_FAILURES_RULE="traffic/failures",TRAFFIC_LATENCY_RULE="traffic/latency",TRAFFIC_RATE_LIMITED_RULE="traffic/rate-limited",SOURCE_RULES=[QUEUE_OLDEST_WAIT_RULE,QUEUE_STALLED_RULE,LOOP_OVERDUE_RULE,LOOP_FAILING_RULE,LOOP_IDLE_RULE,STORE_QUOTA_RULE,STORE_ERRORS_RULE,STORE_ORPHANS_RULE,TRAFFIC_FAILURES_RULE,TRAFFIC_LATENCY_RULE,TRAFFIC_RATE_LIMITED_RULE],SOURCE_EVENT_KINDS=["source-poll","source-declaration","source-event"],CUSTOM_EVENT_SOURCE="custom",QUEUE_EVENTS=["enqueued","admitted","completed","failed","parked"],LOOP_EVENTS=["run-start","run-end"],LOOP_OUTCOMES=["ok","failed","skipped"],STORE_EVENTS=["write","delete","error"],TRAFFIC_EVENTS=["inbound","outbound"],TRAFFIC_OUTCOMES=["ok","failed","rate-limited"],SOURCE_PUSH_EVENTS={queue:QUEUE_EVENTS,loop:LOOP_EVENTS,store:STORE_EVENTS,traffic:TRAFFIC_EVENTS},SOURCE_PUSH_OUTCOMES={queue:[],loop:LOOP_OUTCOMES,store:[],traffic:TRAFFIC_OUTCOMES},SOURCE_POLL_STATES=["current","unreachable","refused","malformed","not-running"],SOURCE_STATES=[...SOURCE_POLL_STATES,"stale","never-polled"],SOURCE_DEFAULT_INTERVAL_SEC=10,SOURCE_MIN_INTERVAL_SEC=2,QUEUE_DEFAULT_OLDEST_WAIT_MIN=10,QUEUE_DEFAULT_STALLED_MIN=15,LOOP_DEFAULT_IDLE_MIN=10,LOOP_OVERDUE_INTERVALS=2,LOOP_FAILING_RUNS=3,SOURCE_FULL_REPORT_MS=6e4,SOURCE_HISTORY_POINTS=60,SOURCE_RUNS_KEPT=30,SOURCE_PUSHED_KEPT=20,STORE_DEFAULT_QUOTA_PCT=90,STORE_DEFAULT_ERROR_RATE_PCT=5,STORE_DEFAULT_ORPHAN_MIN=60,TRAFFIC_DEFAULT_FAILURE_PCT=5,TRAFFIC_DEFAULT_P95_MS=2e3,TRAFFIC_DEFAULT_RATE_LIMITED=1,TRAFFIC_MIN_MESSAGES=10,TRAFFIC_PUSH_WINDOW_MS=10*6e4,TRAFFIC_PUSH_CHANNELS=50,TRAFFIC_PUSH_EVENTS_PER_CHANNEL=1e3,SOURCE_MAX_GROUPS=500,SOURCE_MAX_BYTES=256*1024,SOURCE_STALE_PERIODS=3,SOURCE_STALE_MIN_MS=3e4;export function sourceStaleAfterMs(e){return Math.max(SOURCE_STALE_MIN_MS,SOURCE_STALE_PERIODS*Math.max(0,e))}u(sourceStaleAfterMs,"sourceStaleAfterMs"),c(sourceStaleAfterMs,"sourceStaleAfterMs"),n(sourceStaleAfterMs,"sourceStaleAfterMs");const i=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),t=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=0,"isCount"),E=n(e=>typeof e=="number"&&Number.isFinite(e)&&e>0,"isTime"),a=n((e,r)=>typeof e=="string"&&e.length>0&&e.length<=r,"isStr"),L=n(e=>e===void 0||typeof e=="number"&&e>0,"isMin");function _(e){if(!SOURCE_KINDS_READ.includes(e.sourceKind)||typeof e.path!="string"&&!(e.path===void 0&&(e.sourceKind==="traffic"||e.sourceKind==="loop"))||!a(e.name,200)||typeof e.intervalSec!="number"||e.feeds!==void 0&&!a(e.feeds,200))return!1;const r=e.thresholds;if(!i(r))return!1;for(const o of["stalledMin","idleMin","oldestWaitMin","quotaPct","errorRatePct","orphanMin","failurePct","p95Ms","rateLimited"])if(!L(r[o]))return!1;return e.sourceKind!=="queue"||typeof r.oldestWaitMin=="number"}u(_,"_"),c(_,"l"),n(_,"asDecl");const d=n(e=>e===null||typeof e=="string","isIsoOrNull"),l=n(e=>e===void 0||t(e),"isOptCount");function f(e){if(!i(e)||typeof e.at!="string"||!E(e.receivedAt)||!E(e.intervalSec)||!d(e.lastRunAt)||e.nextRunAt!==void 0&&!d(e.nextRunAt))return!1;for(const r of["lastDurationMs","lastItems","runsInWindow","itemsInWindow","failuresInWindow","windowSec"])if(!l(e[r]))return!1;return e.lastOutcome!==void 0&&!LOOP_OUTCOMES.includes(e.lastOutcome)?!1:e.lastError===void 0||typeof e.lastError=="string"}u(f,"d"),c(f,"_"),n(f,"asLoopSnapshot");const T=n(e=>e===void 0||i(e)&&Object.values(e).every(r=>typeof r=="string"),"isLabels");function S(e){if(!i(e)||typeof e.at!="string"||!E(e.receivedAt)||!t(e.objects)||!t(e.bytes)||e.quotaBytes!==void 0&&e.quotaBytes!==null&&!t(e.quotaBytes))return!1;for(const s of["opsInWindow","writesInWindow","deletesInWindow","errorsInWindow","windowSec"])if(!l(e[s]))return!1;if(e.lastWriteAt!==void 0&&!d(e.lastWriteAt)||e.lastError!==void 0&&typeof e.lastError!="string")return!1;const r=e.truncated;if(r!==void 0&&!(i(r)&&t(r.groups)))return!1;const o=e.groups;return o===void 0?!0:Array.isArray(o)&&o.length<=SOURCE_MAX_GROUPS&&o.every(s=>i(s)&&a(s.group,1e3)&&t(s.objects)&&t(s.bytes)&&T(s.labels))}u(S,"S"),c(S,"S"),n(S,"asStoreSnapshot");function R(e){if(!i(e)||typeof e.at!="string"||!E(e.receivedAt)||!Array.isArray(e.channels)||!l(e.windowSec))return!1;const r=e.truncated;return r!==void 0&&!(i(r)&&t(r.channels))?!1:e.channels.length<=SOURCE_MAX_GROUPS&&e.channels.every(o=>{if(!i(o)||!a(o.channel,1e3)||!T(o.labels)||o.direction!==void 0&&o.direction!=="inbound"&&o.direction!=="outbound"||o.counterpart!==void 0&&!a(o.counterpart,200))return!1;for(const s of["messagesInWindow","failuresInWindow","rateLimitedInWindow"])if(!l(o[s]))return!1;return o.p95Ms!==void 0&&!(typeof o.p95Ms=="number"&&Number.isFinite(o.p95Ms)&&o.p95Ms>=0)||o.lastAt!==void 0&&!d(o.lastAt)?!1:o.lastError===void 0||typeof o.lastError=="string"})}u(R,"p"),c(R,"R"),n(R,"asTrafficSnapshot");function p(e){return i(e)&&a(e.digest,100)&&typeof e.at=="string"&&E(e.receivedAt)}u(p,"R"),c(p,"A"),n(p,"asSame");function A(e){if(!i(e)||!a(e.group,1e3)||!t(e.pending))return!1;for(const s of["inFlight","failed","completedInWindow"])if(e[s]!==void 0&&!t(e[s]))return!1;const r=e.oldestPendingAt;if(r!=null&&typeof r!="string")return!1;const o=e.labels;return o===void 0||i(o)&&Object.values(o).every(s=>typeof s=="string")}u(A,"A"),c(A,"O"),n(A,"asGroup");function O(e){if(!i(e)||typeof e.at!="string"||!E(e.receivedAt)||!Array.isArray(e.groups))return!1;const r=e.totals;if(!i(r)||!t(r.groups)||!t(r.pending)||!t(r.inFlight)||!t(r.failed))return!1;const o=e.truncated;return o!==void 0&&!(i(o)&&t(o.groups))?!1:e.groups.length<=SOURCE_MAX_GROUPS&&e.groups.every(A)}u(O,"O"),c(O,"T"),n(O,"asSnapshot");export function asSourcePollRaw(e){if(!i(e)||e.kind!=="source-poll"||!a(e.project,200)||!_(e)||!SOURCE_POLL_STATES.includes(e.state)||!E(e.polledAt)||!E(e.reportEveryMs)||e.path===void 0)return;const r=SOURCE_SNAPSHOT_FIELD[e.sourceKind];for(const s of Object.values(SOURCE_SNAPSHOT_FIELD))if(s!==r&&e[s]!==void 0)return;const o={snapshot:O,loop:f,store:S,traffic:R}[r];if(!(e[r]!==void 0&&!o(e[r]))&&!(e.same!==void 0&&(!p(e.same)||e[r]!==void 0))&&!(e.state==="current"&&e[r]===void 0&&e.same===void 0))return e}u(asSourcePollRaw,"asSourcePollRaw"),c(asSourcePollRaw,"asSourcePollRaw"),n(asSourcePollRaw,"asSourcePollRaw");export function asSourceEventRaw(e){if(!i(e)||e.kind!=="source-event"||!a(e.project,200)||!a(e.name,200))return;const r=e.sourceKind;if(SOURCE_KINDS_READ.includes(r)&&SOURCE_PUSH_EVENTS[r].includes(e.event)&&!(e.item!==void 0&&!a(e.item,200)||e.group!==void 0&&!a(e.group,200))&&!(!l(e.items)||!l(e.durationMs)||!l(e.bytes))&&!(e.outcome!==void 0&&!SOURCE_PUSH_OUTCOMES[r].includes(e.outcome))){for(const o of["object","channel","counterpart","correlation"])if(e[o]!==void 0&&!a(e[o],200))return;if(!(e.error!==void 0&&typeof e.error!="string"))return e}}u(asSourceEventRaw,"asSourceEventRaw"),c(asSourceEventRaw,"asSourceEventRaw"),n(asSourceEventRaw,"asSourceEventRaw");export function asSourceDeclarationRaw(e){if(!(!i(e)||e.kind!=="source-declaration"||!a(e.project,200))&&!(!Array.isArray(e.sources)||!e.sources.every(r=>i(r)&&_(r)))&&!(!Array.isArray(e.problems)||!e.problems.every(r=>typeof r=="string")))return e}u(asSourceDeclarationRaw,"asSourceDeclarationRaw"),c(asSourceDeclarationRaw,"asSourceDeclarationRaw"),n(asSourceDeclarationRaw,"asSourceDeclarationRaw");
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});var g=Object.defineProperty,l=c((e,o)=>g(e,"name",{value:o,configurable:!0}),"c");export const OWNER_WORKSPACE="(workspace)",OWNER_EXTERNAL="(external)",UNCOVERED_REASONS=["no-route","needs-build","tsgo-refused","parity-unproven","parity-differs","held-for-memory","not-in-census"],TOOL_ERROR_KINDS=["config-refused","program-error","timeout","signal","exit-without-diagnostics","spawn-failed","unparseable-output"];export function typecheckFindingKey(e){return`${e.file}:${e.line}:${e.col}:${e.code}`}c(typecheckFindingKey,"typecheckFindingKey"),l(typecheckFindingKey,"typecheckFindingKey");export function lintFindingKey(e){return`${e.file}:${e.line}:${e.col}:${e.ruleId??""}`}c(lintFindingKey,"lintFindingKey"),l(lintFindingKey,"lintFindingKey");const a=l((e,o)=>e.file<o.file?-1:e.file>o.file?1:e.line-o.line||e.col-o.col,"byPosition");export function dedupeTypecheckFindings(e,o){const n=new Map;for(const{program:i,diagnostics:r}of e)for(const t of r){const s=typecheckFindingKey(t),u=n.get(s);if(!u){n.set(s,{file:t.file,line:t.line,col:t.col,code:t.code,severity:t.severity,message:t.message,project:o(t.file),programs:[i]});continue}u.programs.includes(i)||u.programs.push(i),t.severity==="error"&&(u.severity="error")}const d=[...n.values()];for(const i of d)i.programs.sort();return d.sort((i,r)=>a(i,r)||(i.code<r.code?-1:i.code>r.code?1:0))}c(dedupeTypecheckFindings,"dedupeTypecheckFindings"),l(dedupeTypecheckFindings,"dedupeTypecheckFindings");export function dedupeLintFindings(e,o){const n=new Map;for(const{unit:r,messages:t}of e)for(const s of t){const u=lintFindingKey(s),f=n.get(u);if(!f){n.set(u,{file:s.file,line:s.line,col:s.col,ruleId:s.ruleId,severity:s.severity,message:s.message,project:o(s.file),units:[r],...s.fixable?{fixable:!0}:{}});continue}f.units.includes(r)||f.units.push(r),s.severity==="error"&&(f.severity="error")}const d=[...n.values()];for(const r of d)r.units.sort();const i=l(r=>r.ruleId??"","rule");return d.sort((r,t)=>a(r,t)||(i(r)<i(t)?-1:i(r)>i(t)?1:0))}c(dedupeLintFindings,"dedupeLintFindings"),l(dedupeLintFindings,"dedupeLintFindings");export function verdictOf(e){const{errors:o,coverage:n}=e;return o>0?"errors":n.toolErrors.length>0||n.inScope<=0||n.checked.count<=0?"no-verdict":n.stale.length>0||n.notCovered.length>0||n.checked.count<n.inScope?"partial":"clean"}c(verdictOf,"verdictOf"),l(verdictOf,"verdictOf");export function exitCodeOf(e,o={}){return e==="errors"?1:e==="clean"||e==="partial"&&o.allowPartial?0:2}c(exitCodeOf,"exitCodeOf"),l(exitCodeOf,"exitCodeOf");
1
+ "use strict";var g=Object.defineProperty;var c=(e,n)=>g(e,"name",{value:n,configurable:!0});var y=Object.defineProperty,u=c((e,n)=>y(e,"name",{value:n,configurable:!0}),"c"),v=Object.defineProperty,l=u((e,n)=>v(e,"name",{value:n,configurable:!0}),"c");export const OWNER_WORKSPACE="(workspace)",OWNER_EXTERNAL="(external)",UNCOVERED_REASONS=["no-route","needs-build","tsgo-refused","parity-unproven","parity-differs","held-for-memory","not-in-census"],TOOL_ERROR_KINDS=["config-refused","program-error","timeout","signal","exit-without-diagnostics","spawn-failed","unparseable-output"];export function typecheckFindingKey(e){return`${e.file}:${e.line}:${e.col}:${e.code}`}c(typecheckFindingKey,"typecheckFindingKey"),u(typecheckFindingKey,"typecheckFindingKey"),l(typecheckFindingKey,"typecheckFindingKey");export function lintFindingKey(e){return`${e.file}:${e.line}:${e.col}:${e.ruleId??""}`}c(lintFindingKey,"lintFindingKey"),u(lintFindingKey,"lintFindingKey"),l(lintFindingKey,"lintFindingKey");const p=l((e,n)=>e.file<n.file?-1:e.file>n.file?1:e.line-n.line||e.col-n.col,"byPosition");export function dedupeTypecheckFindings(e,n){const i=new Map;for(const{program:t,diagnostics:r}of e)for(const o of r){const s=typecheckFindingKey(o),d=i.get(s);if(!d){i.set(s,{file:o.file,line:o.line,col:o.col,code:o.code,severity:o.severity,message:o.message,project:n(o.file),programs:[t]});continue}d.programs.includes(t)||d.programs.push(t),o.severity==="error"&&(d.severity="error")}const f=[...i.values()];for(const t of f)t.programs.sort();return f.sort((t,r)=>p(t,r)||(t.code<r.code?-1:t.code>r.code?1:0))}c(dedupeTypecheckFindings,"dedupeTypecheckFindings"),u(dedupeTypecheckFindings,"dedupeTypecheckFindings"),l(dedupeTypecheckFindings,"dedupeTypecheckFindings");export function dedupeLintFindings(e,n){const i=new Map;for(const{unit:r,messages:o}of e)for(const s of o){const d=lintFindingKey(s),a=i.get(d);if(!a){i.set(d,{file:s.file,line:s.line,col:s.col,ruleId:s.ruleId,severity:s.severity,message:s.message,project:n(s.file),units:[r],...s.fixable?{fixable:!0}:{}});continue}a.units.includes(r)||a.units.push(r),s.severity==="error"&&(a.severity="error")}const f=[...i.values()];for(const r of f)r.units.sort();const t=l(r=>r.ruleId??"","rule");return f.sort((r,o)=>p(r,o)||(t(r)<t(o)?-1:t(r)>t(o)?1:0))}c(dedupeLintFindings,"dedupeLintFindings"),u(dedupeLintFindings,"dedupeLintFindings"),l(dedupeLintFindings,"dedupeLintFindings");export function verdictOf(e){const{errors:n,coverage:i}=e;return n>0?"errors":i.toolErrors.length>0||i.inScope<=0||i.checked.count<=0?"no-verdict":i.stale.length>0||i.notCovered.length>0||i.checked.count<i.inScope?"partial":"clean"}c(verdictOf,"verdictOf"),u(verdictOf,"verdictOf"),l(verdictOf,"verdictOf");export function exitCodeOf(e,n={}){return e==="errors"?1:e==="clean"||e==="partial"&&n.allowPartial?0:2}c(exitCodeOf,"exitCodeOf"),u(exitCodeOf,"exitCodeOf"),l(exitCodeOf,"exitCodeOf");
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var r=(e,n)=>o(e,"name",{value:n,configurable:!0});var a=Object.defineProperty,s=r((e,n)=>a(e,"name",{value:n,configurable:!0}),"n");export function systemScopeId(e){return e.kind==="machine"?"machine":e.kind==="repository"?`repo:${e.repoId}`:`ws:${e.key}`}r(systemScopeId,"systemScopeId"),s(systemScopeId,"systemScopeId");export function systemItemKey(e,n){return`${systemScopeId(e)}/${n}`}r(systemItemKey,"systemItemKey"),s(systemItemKey,"systemItemKey");export function systemValue(e,n){switch(n){case"bytes":{const t=e/1073741824;return t>=1?`${t.toFixed(t>=100?0:1)} GB`:`${Math.round(e/1024**2)} MB`}case"ms":return e>=1e3?`${(e/1e3).toFixed(1)} s`:`${Math.round(e)} ms`;case"percent":return`${Math.round(e)} %`;case"usd":return`$${e.toFixed(2)}`;case"load":return`load ${e.toFixed(1)}`;case"minutes":return`${Math.round(e)} min`;default:return String(e)}}r(systemValue,"systemValue"),s(systemValue,"systemValue");export function systemScopeLabel(e){return e.kind==="machine"?"machine":e.kind==="repository"?e.name:`${e.name} lens`}r(systemScopeLabel,"systemScopeLabel"),s(systemScopeLabel,"systemScopeLabel");const u={"n/a":0,ok:1,warn:2,bad:3};export function systemStatusRank(e){return u[e]}r(systemStatusRank,"systemStatusRank"),s(systemStatusRank,"systemStatusRank");
1
+ "use strict";var o=Object.defineProperty;var s=(e,t)=>o(e,"name",{value:t,configurable:!0});var u=Object.defineProperty,n=s((e,t)=>u(e,"name",{value:t,configurable:!0}),"r"),c=Object.defineProperty,r=n((e,t)=>c(e,"name",{value:t,configurable:!0}),"n");export function systemScopeId(e){return e.kind==="machine"?"machine":e.kind==="repository"?`repo:${e.repoId}`:`ws:${e.key}`}s(systemScopeId,"systemScopeId"),n(systemScopeId,"systemScopeId"),r(systemScopeId,"systemScopeId");export function systemItemKey(e,t){return`${systemScopeId(e)}/${t}`}s(systemItemKey,"systemItemKey"),n(systemItemKey,"systemItemKey"),r(systemItemKey,"systemItemKey");export function systemValue(e,t){switch(t){case"bytes":{const a=e/1073741824;return a>=1?`${a.toFixed(a>=100?0:1)} GB`:`${Math.round(e/1024**2)} MB`}case"ms":return e>=1e3?`${(e/1e3).toFixed(1)} s`:`${Math.round(e)} ms`;case"percent":return`${Math.round(e)} %`;case"usd":return`$${e.toFixed(2)}`;case"load":return`load ${e.toFixed(1)}`;case"minutes":return`${Math.round(e)} min`;default:return String(e)}}s(systemValue,"systemValue"),n(systemValue,"systemValue"),r(systemValue,"systemValue");export function systemScopeLabel(e){return e.kind==="machine"?"machine":e.kind==="repository"?e.name:`${e.name} lens`}s(systemScopeLabel,"systemScopeLabel"),n(systemScopeLabel,"systemScopeLabel"),r(systemScopeLabel,"systemScopeLabel");const m={"n/a":0,ok:1,warn:2,bad:3};export function systemStatusRank(e){return m[e]}s(systemStatusRank,"systemStatusRank"),n(systemStatusRank,"systemStatusRank"),r(systemStatusRank,"systemStatusRank");
package/lib/team.d.ts CHANGED
@@ -38,6 +38,8 @@ export interface DashTeamPersonDone {
38
38
  why: string;
39
39
  proof: 'not-run';
40
40
  wasCancelled?: string;
41
+ /** When the upgrade converted the cancel; `at` is the cancel's (overseer-99). */
42
+ convertedAt?: number;
41
43
  }
42
44
  /** A task closed «not run — the person's decision» (overseer-78): the goal's tests or QA run the person decided not to run. Never passed. */
43
45
  export interface DashTeamPersonNotRun {
package/lib/team.js CHANGED
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var r=(t,e)=>o(t,"name",{value:e,configurable:!0});var i=Object.defineProperty,n=r((t,e)=>i(t,"name",{value:e,configurable:!0}),"o");export const DASH_TEAM_KINDS=["goal","build","bug","review","test","qa","docs","marketing","research","chore"],DASH_TEAM_LINK_KINDS=["task","flow","error","suggestion","ai-call","review","page","route","commit","branch","worktree","file","finding","test"];export function modelClient(t){const e=t?.trim()??"";if(/\b(claude|opus|sonnet|haiku|fable)\b/i.test(e))return"claude";if(/^(gpt|o\d+|codex)\b/i.test(e))return"codex"}r(modelClient,"modelClient"),n(modelClient,"modelClient");export const DASH_TEAM_SEARCH_QUESTION_MAX=300;
1
+ "use strict";var i=Object.defineProperty;var r=(t,e)=>i(t,"name",{value:e,configurable:!0});var n=Object.defineProperty,o=r((t,e)=>n(t,"name",{value:e,configurable:!0}),"r"),a=Object.defineProperty,c=o((t,e)=>a(t,"name",{value:e,configurable:!0}),"o");export const DASH_TEAM_KINDS=["goal","build","bug","review","test","qa","docs","marketing","research","chore"],DASH_TEAM_LINK_KINDS=["task","flow","error","suggestion","ai-call","review","page","route","commit","branch","worktree","file","finding","test"];export function modelClient(t){const e=t?.trim()??"";if(/\b(claude|opus|sonnet|haiku|fable)\b/i.test(e))return"claude";if(/^(gpt|o\d+|codex)\b/i.test(e))return"codex"}r(modelClient,"modelClient"),o(modelClient,"modelClient"),c(modelClient,"modelClient");export const DASH_TEAM_SEARCH_QUESTION_MAX=300;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/protocol-types",
3
- "version": "1.26.5",
3
+ "version": "1.26.6",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",