@quantiya/codevibe-core 2.0.74 → 2.0.75
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/dist/index.js +1 -1
- package/dist/orchestration-shell/cli.js +3 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -823,7 +823,7 @@ ${n.stack}`)):typeof n=="object"?s+=` ${JSON.stringify(n,Pte)}`:s+=` ${n}`),s}lo
|
|
|
823
823
|
decisionClaimId
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
-
`}});function QC(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function are(t){let e=ay(Buffer.from(t.privateKeyB64,"base64")),r=Buffer.from(t.publicKeyB64,"base64");if(r.length!==64)throw new Error(`class-a-sign: public key must be raw 64-byte x||y (no 0x04 prefix), got ${r.length}`);let n=r.subarray(0,32),i=r.subarray(32,64),o={kty:"EC",crv:"P-256",d:QC(e.toString("base64")),x:QC(n.toString("base64")),y:QC(i.toString("base64"))};return zk.createPrivateKey({key:o,format:"jwk"})}function ZC(t,e){let r={...t};return delete r[e],(0,XC.canonicalize)(r)}function Ua(t,e){let r=are(e);return zk.sign("sha256",Buffer.from(t,"utf8"),{key:r,dsaEncoding:"ieee-p1363"}).toString("base64")}function J1(t,e){let r=`${py}\0${(0,XC.canonicalize)(t)}`;return Ua(r,e)}function eO(t,e){let r=ZC(t,"signature");return Ua(r,e)}function tO(t,e,r){let n={...t,leDeviceId:r},i=ZC(n,"signatureB64");return Ua(i,e)}var zk,XC,py,Ld=D(()=>{"use strict";zk=F(require("node:crypto")),XC=require("json-freeze");km();py="codevibe.encrypted_desktop_event.writer.v1"});function gi(){throw new ve("INVALID_SYNC_INPUT")}function $d(t){if(Fd.some(e=>t[e]!==void 0))return(typeof t.ownerToken!="string"||!/^[A-Za-z0-9_-]{32,128}$/.test(t.ownerToken)||t.promptId!==Fa(t.ownerToken)||!["PLUGIN_APPROVAL","CORE_OFFER"].includes(t.producerKind)||typeof t.mobileActionable!="boolean"||!["INTERACTIVE_PROMPT","NOTIFICATION"].includes(t.type))&&gi(),Object.freeze({promptId:t.promptId,ownerToken:t.ownerToken,producerKind:t.producerKind,mobileActionable:t.mobileActionable})}function Bd(t){if(typeof t!="string"||!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(t))return!1;let e=Date.parse(t);return Number.isFinite(e)&&new Date(e).toISOString()===t}function pre(t){let e=new Set,r=0,n=(i,o)=>{if((++r>1e5||o>32)&&gi(),i===null||typeof i=="boolean"||typeof i=="string"||typeof i=="number"&&Number.isFinite(i))return i;(!Array.isArray(i)&&!Ha(i)||e.has(i))&&gi(),e.add(i);let s=c=>{let l=Object.getOwnPropertyDescriptor(i,c);return(!l||!Gi(l,"value"))&&gi(),n(l.value,o+1)},a;return Array.isArray(i)?(Object.keys(i).length!==i.length&&gi(),a=Array.from({length:i.length},(c,l)=>s(String(l)))):a=Object.fromEntries(Object.keys(i).map(c=>[c,s(c)])),e.delete(i),a};return n(t,0)}function $n(t,e){let r=t==="CREATE_EVENT"?lre:t==="UPDATE_EVENT"?dre:ure;(!Ha(e)||Object.keys(e).some(o=>!r.includes(o)))&&gi();let n=Object.keys(e).map(o=>{let s=Object.getOwnPropertyDescriptor(e,o);return Gi(s,"value")||gi(),[o,s.value]}),i=pre(Object.fromEntries(n.filter(([,o])=>o!==void 0)));if((typeof i.clientOperationId!="string"||!Y1.test(i.clientOperationId)||typeof i.sessionGenerationId!="string"||!Y1.test(i.sessionGenerationId)||typeof i.sessionId!="string"||!my.test(i.sessionId)||typeof i.expectedSessionKeyGen!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(i.expectedSessionKeyGen))&&gi(),i.clientOperationId=i.clientOperationId.toLowerCase(),i.sessionGenerationId=i.sessionGenerationId.toLowerCase(),t==="CREATE_EVENT"){(typeof i.type!="string"||!cre.has(i.type)||i.content!=null&&typeof i.content!="string"||Gi(i,"timestamp")&&!Bd(i.timestamp)||typeof i.isEncrypted!="boolean"||(i.isEncrypted?i.encryptionVersion!==1:Gi(i,"encryptionVersion")))&&gi(),i.source="DESKTOP";let o=$d(i);if(i.type==="INTERACTIVE_PROMPT"&&!o&&gi(),(fy(i.type)||o)&&(i.isEncrypted!==!0||!Bd(i.timestamp)||typeof i.content!="string"||!i.content||!Ha(i.metadata)||Object.keys(i.metadata).join(",")!=="encrypted"||typeof i.metadata.encrypted!="string"||!i.metadata.encrypted||Gi(i,"writerAttestation"))&&gi(),Gi(i,"writerAttestation")){let s=i.writerAttestation;(!Ha(s)||Object.keys(s).sort().join(",")!=="contentCiphertextSha256,metadataCiphertextSha256,schema,signatureB64,writerEventNonce"||s.schema!=="codevibe.encrypted_desktop_event.writer.v1"||s.writerEventNonce!==i.clientOperationId||!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(i.clientOperationId)||Gi(i,"timestamp")||!["USER_PROMPT","ASSISTANT_RESPONSE"].includes(i.type)||i.isEncrypted!==!0||typeof i.content!="string"||!i.content||!Ha(i.metadata)||Object.keys(i.metadata).join(",")!=="encrypted"||typeof i.metadata.encrypted!="string"||!i.metadata.encrypted||s.contentCiphertextSha256!==(0,Jk.createHash)("sha256").update(i.content).digest("hex")||s.metadataCiphertextSha256!==(0,Jk.createHash)("sha256").update(i.metadata.encrypted).digest("hex")||typeof s.signatureB64!="string"||Buffer.from(s.signatureB64,"base64").length!==64||Buffer.from(s.signatureB64,"base64").toString("base64")!==s.signatureB64)&&gi()}}else t==="UPDATE_EVENT"?(typeof i.eventId!="string"||!my.test(i.eventId)||!Bd(i.timestamp)||typeof i.baseRevision!="string"||!/^(0|[1-9][0-9]{0,18})$/.test(i.baseRevision)||BigInt(i.baseRevision)>=(1n<<63n)-1n||typeof i.immutableIdentityDigest!="string"||!/^[a-f0-9]{64}$/.test(i.immutableIdentityDigest)||!Ha(i.metadataMerge)||Gi(i.metadataMerge,"emittedBy"))&&gi():(typeof i.eventId!="string"||!my.test(i.eventId)||!Bd(i.timestamp)||!["DELIVERED","EXECUTED"].includes(i.deliveryStatus))&&gi();return i}function Tm(t,e,r,n,i){(!/^[A-Za-z0-9_-]{1,128}$/.test(r)||!Number.isSafeInteger(i)||i<0||i>253402300739e3)&&gi();let o=(0,Jk.createHash)("sha256").update((0,rO.canonicalize)(e)).digest("hex"),s={clientOperationId:e.clientOperationId,issuedAtEpochMs:i},a=Ua("codevibe-sync-desktop-event-v1\0"+(0,rO.canonicalize)({userId:r,action:t,...s,requestSha256:o}),n),c=t==="CREATE_EVENT"?"metadata":"metadataMerge";return Object.freeze({...e,...Gi(e,c)&&{[c]:JSON.stringify(e[c])},desktopProof:Object.freeze({...s,signature:a})})}function ls(t,e){let r=()=>{throw new ve("INVALID_SYNC_RECEIPT")};if(typeof t=="string"){Buffer.byteLength(t)>2048&&r();try{t=JSON.parse(t)}catch{r()}}(!Ha(t)||Object.keys(t).sort().join(",")!==[...Q1].sort().join(","))&&r();let n=t;return(Q1.some(i=>typeof n[i]!="string"||Buffer.byteLength(n[i])>256)||Buffer.byteLength(JSON.stringify(n))>2048||!my.test(n.eventId)||n.eventId.startsWith("local-throttled")||n.sessionId!==e.sessionId||!Bd(n.timestamp)||!Object.values(Ga).includes(n.type)||!["DESKTOP","MOBILE"].includes(n.source)||!["IMPLEMENTOR","SYSTEM","USER"].includes(n.emittedBy))&&r(),Gi(e,"type")?((n.type!==e.type||n.source!=="DESKTOP"||n.emittedBy!=="IMPLEMENTOR")&&r(),e.type==="TOOL_ACTIVITY"&&Gi(e,"clientOperationId")&&n.eventId!==e.clientOperationId&&r()):(n.eventId!==e.eventId||n.timestamp!==e.timestamp)&&r(),Object.freeze({...n})}function Yk(t,e){let r=()=>{throw new ve("INVALID_SYNC_RECEIPT")};if(typeof t=="string"){Buffer.byteLength(t)>2048&&r();try{t=JSON.parse(t)}catch{r()}}let n=["sessionId","sessionGenerationId","eventId","timestamp","type","source","deliveryStatus","deliveredAt"];(!Ha(t)||Object.keys(t).some(o=>![...n,"executedAt"].includes(o))||n.some(o=>typeof t[o]!="string")||Buffer.byteLength(JSON.stringify(t))>2048)&&r();let i=t;return(i.sessionId!==e.sessionId||i.sessionGenerationId!==e.sessionGenerationId||i.eventId!==e.eventId||i.timestamp!==e.timestamp||i.source!=="MOBILE"||!["USER_PROMPT","PROMPT_RESPONSE"].includes(i.type)||!Bd(i.deliveredAt)||!["DELIVERED","EXECUTED"].includes(i.deliveryStatus)||e.deliveryStatus==="EXECUTED"&&i.deliveryStatus!=="EXECUTED"||(i.deliveryStatus==="EXECUTED"?!Bd(i.executedAt):Gi(i,"executedAt")))&&r(),Object.freeze({...i})}function Qk(t,e){let r=()=>{throw new ve("INVALID_SYNC_RECEIPT")};if(typeof t=="string"){Buffer.byteLength(t)>2048&&r();try{t=JSON.parse(t)}catch{r()}}Ha(t)||r();let n=t,i=n.status==="REFRESHED"&&Gi(n,"expiresAt")?["expiresAt","promptId","status"]:["promptId","status"];return(Object.keys(n).sort().join(",")!==i.join(",")||n.promptId!==e||!my.test(e)||!["REFRESHED","RERAISE_REQUIRED"].includes(n.status)||n.status==="REFRESHED"&&Gi(n,"expiresAt")&&(typeof n.expiresAt!="number"||!Number.isSafeInteger(n.expiresAt)||n.expiresAt<=0||n.expiresAt>253402300799))&&r(),Object.freeze({...n})}var Jk,rO,Am,fy,ve,Y1,my,cre,nO,Fd,lre,dre,ure,Q1,Gi,Ha,Gn=D(()=>{"use strict";Jk=require("node:crypto"),rO=require("json-freeze");Ld();Nd();Kk();Am=Object.freeze(["TOOL_ACTIVITY","NOTIFICATION","MODE_SELECTED","PLANNER_DECISION","PLANNER_CACHE_HIT","PLANNER_DEGRADED","PLANNER_OUTAGE","PLANNER_RECOVERED","SLASH_COMMAND_INVOKED","STRUCTURAL_SUMMARY_GENERATED","LOCAL_AUTHORITY_REFUSAL","TEAM_DECOMPOSED","TEAM_TRACK_STATUS","TEAM_GROUP_RESOLVED"]),fy=t=>typeof t=="string"&&Am.includes(t),ve=class extends Error{constructor(r){super(r);this.code=r;this.name="SyncEventClientError"}},Y1=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,my=/^[A-Za-z0-9_-]{1,256}$/,cre=new Set(["USER_PROMPT","ASSISTANT_RESPONSE","REASONING","TOOL_USE","INTERACTIVE_PROMPT",...Am]),nO=["clientOperationId","sessionId","sessionGenerationId","expectedSessionKeyGen"],Fd=Object.freeze(["promptId","ownerToken","producerKind","mobileActionable"]),lre=[...nO,"type","content","metadata","isEncrypted","encryptionVersion","writerAttestation","timestamp",...Fd],dre=[...nO,"eventId","timestamp","baseRevision","immutableIdentityDigest","metadataMerge"],ure=[...nO,"eventId","timestamp","deliveryStatus"],Q1=["eventId","sessionId","type","source","timestamp","emittedBy"],Gi=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ha=t=>!!t&&typeof t=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(t))});function eH(t,e){if(t.controlGeneration!==e.controlGeneration)return t.controlGeneration>e.controlGeneration?"REPLACE":"RETAIN";if(t.accountingGeneration!==e.accountingGeneration)return"CONFLICT";if(t.entitlementVersion!==e.entitlementVersion)return BigInt(t.entitlementVersion)>BigInt(e.entitlementVersion)?"REPLACE":"RETAIN";if(t.periodId!==e.periodId)return(t.periodId??"")>(e.periodId??"")?"REPLACE":"RETAIN";let r=BigInt(t.usage?.usageRevision??"0"),n=BigInt(e.usage?.usageRevision??"0");if(r!==n)return r>n?"REPLACE":"RETAIN";let i=o=>(0,Z1.canonicalize)({...o,observedAtEpochMs:0,validUntilEpochMs:0});return i(t)!==i(e)?"CONFLICT":t.observedAtEpochMs!==e.observedAtEpochMs?t.observedAtEpochMs>e.observedAtEpochMs?"REPLACE":"RETAIN":t.validUntilEpochMs>=e.validUntilEpochMs?"REPLACE":"RETAIN"}function tH(t,e=Date.now()){return!t||!Number.isSafeInteger(e)||t.observedAtEpochMs>e+sl||e>=t.validUntilEpochMs?"Companion sync status unavailable":t.usage?.syncState==="PAUSED"?"Companion sync paused":t.protocol==="FROZEN"?"Companion sync unavailable":t.usage?.syncState==="WARNING"?"Companion sync 80%+":null}function eE(t,e=Date.now()){let r=["Companion sync status unavailable"];if(!t||!Number.isSafeInteger(e)||t.observedAtEpochMs>e+sl||e>=t.validUntilEpochMs)return r;if(t.protocol==="LEGACY")return["Legacy Companion accounting"];if(!t.usage||t.resetAtEpochMs===null)return r;let n=t.usage.syncState==="PAUSED",i=!n&&t.protocol==="SYNC_V2",o=[n?"Companion sync paused":i?t.usage.syncState==="WARNING"?"Companion sync 80%+":"Companion sync active":"Companion sync unavailable"],s=[["syncUnits","Sync units"],["mobileAttachmentCount","Mobile images"],["mobileAttachmentBytes","Mobile upload bytes"]];for(let[a,c]of s)o.push(`${c}: ${t.usage[`${a}Committed`]} committed \xB7 ${t.usage[`${a}Reserved`]} reserved \xB7 ${t.usage[`${a}Limit`]} limit`);return o.push(`Resets ${new Date(t.resetAtEpochMs).toISOString().slice(0,16).replace("T"," ")} UTC.`),o.push("Desktop-local image attachments do not count."),(n||BigInt(t.usage.gapStartedAtEpochMs)>0n)&&o.push("Messages omitted while paused will not be backfilled."),i||o.push("Continue on desktop."),o}function ni(){throw new ve("INVALID_SYNC_STATE")}function ol(t){return(typeof t!="string"||!/^(0|[1-9][0-9]{0,18})$/.test(t)||BigInt(t)>(1n<<63n)-1n)&&ni(),BigInt(t)}function tE(t,e,r=Date.now()){if(typeof t=="string"){Buffer.byteLength(t)>2048&&ni();try{t=JSON.parse(t)}catch{ni()}}(!Xk(t,rH(t)&&Object.prototype.hasOwnProperty.call(t,"quotaNotice")?[...X1,"quotaNotice"]:X1)||Buffer.byteLength(JSON.stringify(t))>2048||t.schemaVersion!==1||t.environment!==e||!["development","production"].includes(t.environment)||!["FREE","PRO","MAX"].includes(t.tier)||!["LEGACY","SHADOW","AUTHORITATIVE","ROLLBACK_FREEZE"].includes(t.mode)||!["LEGACY","SYNC_V2","FROZEN"].includes(t.protocol)||!Number.isSafeInteger(t.controlGeneration)||t.controlGeneration<0||!Number.isSafeInteger(t.observedAtEpochMs)||t.observedAtEpochMs<Date.UTC(2e3,0,1)||t.observedAtEpochMs>r+sl||!Number.isSafeInteger(t.validUntilEpochMs)||t.validUntilEpochMs<=r||t.validUntilEpochMs<=t.observedAtEpochMs||t.validUntilEpochMs-t.observedAtEpochMs>18e5||t.accountingGeneration!==null&&(typeof t.accountingGeneration!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(t.accountingGeneration))||!Xk(t.limits,Zk))&&ni(),ol(t.entitlementVersion);for(let n of Zk)ol(t.limits[n])===0n&&ni();if(t.mode==="AUTHORITATIVE"){(t.protocol==="LEGACY"||!t.accountingGeneration||!Xk(t.usage,fre)||typeof t.periodId!="string"||!/^\d{4}-(0[1-9]|1[0-2])$/.test(t.periodId))&&ni();let n=new Date(t.observedAtEpochMs),i=Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1);(t.periodId!==n.toISOString().slice(0,7)||t.resetAtEpochMs!==i||t.validUntilEpochMs>i)&&ni(),ol(t.usage.usageRevision);let o=ol(t.usage.gapStartedAtEpochMs),s=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1);o!==0n&&(o<BigInt(s)||o>BigInt(t.observedAtEpochMs))&&ni();let a="ACTIVE";for(let c of Zk){let l=ol(t.usage[`${c}Committed`]);ol(t.usage[`${c}Reserved`]);let d=ol(t.usage[`${c}Limit`]),u=ol(t.usage[`${c}PauseLimit`]);u>0n&&o===0n&&ni(),t.usage[`${c}Limit`]!==t.limits[c]&&ni(),c==="syncUnits"&&(l>=d||u>=d)?a="PAUSED":l*5n>=d*4n&&a!=="PAUSED"&&(a="WARNING")}t.usage.syncState!==a&&ni()}else(t.protocol==="SYNC_V2"&&t.mode!=="SHADOW"||t.mode==="ROLLBACK_FREEZE"&&t.protocol!=="FROZEN"||t.usage!==null||t.periodId!==null||t.resetAtEpochMs!==null)&&ni();if(t.accountingGeneration===null&&(t.mode!=="LEGACY"||t.controlGeneration!==0)&&ni(),t.accountingGeneration!==null&&t.controlGeneration<1&&ni(),t.usage?.syncState==="PAUSED"){let n=t.quotaNotice;(!Xk(n,["schemaVersion","kind","noticeId","reasonCode","localizationKey","content"])||n.schemaVersion!==1||n.kind!=="QUOTA_PAUSED"||typeof n.noticeId!="string"||!/^[a-f0-9]{64}$/.test(n.noticeId)||n.reasonCode!=="SYNC_QUOTA_EXHAUSTED"||n.localizationKey!=="codevibe.sync.quota_paused"||n.content!==mre)&&ni()}else Object.prototype.hasOwnProperty.call(t,"quotaNotice")&&ni();return Object.freeze({...t,limits:Object.freeze({...t.limits}),usage:t.usage===null?null:Object.freeze({...t.usage}),...t.quotaNotice&&{quotaNotice:Object.freeze({...t.quotaNotice})}})}var Z1,sl,mre,X1,Zk,fre,rH,Xk,Pm=D(()=>{"use strict";Gn();Z1=require("json-freeze"),sl=6e4,mre="Companion sync paused. Continue on desktop. Messages omitted while paused will not be backfilled.";X1=["schemaVersion","environment","observedAtEpochMs","validUntilEpochMs","entitlementVersion","tier","mode","protocol","controlGeneration","accountingGeneration","periodId","resetAtEpochMs","limits","usage"],Zk=["syncUnits","mobileAttachmentCount","mobileAttachmentBytes"],fre=[...Zk.flatMap(t=>[`${t}Committed`,`${t}Reserved`,`${t}Limit`,`${t}PauseLimit`]),"syncState","usageRevision","gapStartedAtEpochMs"],rH=t=>!!t&&typeof t=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(t)),Xk=(t,e)=>rH(t)&&Object.keys(t).sort().join(",")===[...e].sort().join(",")});function rE(t,e){return!t||typeof t!="object"||![Object.prototype,null].includes(Object.getPrototypeOf(t))||Reflect.ownKeys(t).length!==e.length?!1:Reflect.ownKeys(t).every(r=>{let n=Object.getOwnPropertyDescriptor(t,r);return typeof r=="string"&&e.includes(r)&&n.enumerable&&"value"in n})}function oH(t,e){return typeof t!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(t)||!rE(e,nH)||nH.some(r=>typeof e[r]!="string")||!iO.test(e.sessionId)||!iO.test(e.sessionGenerationId)||!/^[A-Za-z0-9_-]{1,128}$/.test(e.expectedSessionKeyGen)||!["ISOLATION_OFF","COARSE_EGRESS"].includes(e.posture)?gre():Object.freeze({...e,clientOperationId:(0,nE.v5)((0,oO.canonicalize)({userId:t,...e}),hre)})}function yre(t){return(0,iH.createHash)("sha256").update("codevibe-security-posture-v1\0"+(0,oO.canonicalize)({sessionId:t.sessionId,sessionGenerationId:t.sessionGenerationId,posture:t.posture})).digest("hex")}function wre(t,e){try{return typeof t=="string"?Buffer.byteLength(t)>e?hy():JSON.parse(t):Buffer.byteLength(JSON.stringify(t))>e?hy():t}catch{return hy()}}function sH(t,e){let r=wre(t,2048);if(!rE(r,["schemaVersion","kind","state","sessionId","sessionGenerationId","posture","noticeId","delivery"])||r.schemaVersion!==1||r.kind!=="SECURITY_POSTURE"||r.state!=="RECORDED"||r.sessionId!==e.sessionId||r.sessionGenerationId!==e.sessionGenerationId||r.posture!==e.posture||r.noticeId!==yre(e)||!rE(r.delivery,["state","outcomes"])||!["ATTEMPTED","REPLAY_NO_SEND"].includes(r.delivery.state)||!Array.isArray(r.delivery.outcomes)||r.delivery.outcomes.length>3||r.delivery.state==="REPLAY_NO_SEND"&&r.delivery.outcomes.length!==0)return hy();let n=new Set;for(let i of r.delivery.outcomes){if(!rE(i,["installationId","outcome"])||typeof i.installationId!="string"||!iO.test(i.installationId)||n.has(i.installationId)||!["SUBMITTED","STALE_RECIPIENT","ATTEMPT_UNCONFIRMED"].includes(i.outcome))return hy();n.add(i.installationId)}return r}var iH,nE,oO,iO,hre,nH,gre,hy,aH=D(()=>{"use strict";iH=require("node:crypto"),nE=require("uuid"),oO=require("json-freeze");Gn();iO=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,hre=(0,nE.v5)("codevibe:sync:security-posture:v1",nE.v5.URL),nH=["sessionId","sessionGenerationId","expectedSessionKeyGen","posture"];gre=()=>{throw new ve("INVALID_SYNC_INPUT")},hy=()=>{throw new ve("INVALID_SYNC_RECEIPT")}});function _m(t){throw new ve(t)}function oE(t,e){return!!t&&typeof t=="object"&&!Array.isArray(t)&&[Object.prototype,null].includes(Object.getPrototypeOf(t))&&Reflect.ownKeys(t).length===e.length&&e.every(r=>{let n=Object.getOwnPropertyDescriptor(t,r);return n?.enumerable&&"value"in n})}function cH(t){if(!oE(t,bre)||!iE.test(t.sessionId)||t.type!=="NOTIFICATION"||t.source!=="DESKTOP"||t.writerEventKind!=="WORKSPACE_OUTCOME"||typeof t.writerSessionGenerationId!="string"||!iE.test(t.writerSessionGenerationId)||t.isEncrypted!==!0||t.encryptionVersion!==1||typeof t.content!="string"||!t.content||!oE(t.metadata,["encrypted"])||typeof t.metadata.encrypted!="string"||!t.metadata.encrypted||!oE(t.writerAttestation,["schema","writerEventNonce","contentCiphertextSha256","metadataCiphertextSha256","signatureB64"])||!iE.test(t.writerAttestation.writerEventNonce))return _m("INVALID_SYNC_INPUT");let e=JSON.stringify(t);return Buffer.byteLength(e)>180*1024?_m("INVALID_SYNC_INPUT"):JSON.parse(e)}function sO(t,e){if(typeof t=="string"){if(Buffer.byteLength(t)>2048)return _m("INVALID_SYNC_RECEIPT");try{t=JSON.parse(t)}catch{return _m("INVALID_SYNC_RECEIPT")}}return!oE(t,Sre)||Buffer.byteLength(JSON.stringify(t))>2048||t.schemaVersion!==1||t.kind!=="WORKSPACE_OUTCOME"||t.state!=="ACKED"||t.sessionId!==e.sessionId||t.sessionGenerationId!==e.writerSessionGenerationId||t.writerEventNonce!==e.writerAttestation?.writerEventNonce||typeof t.eventId!="string"||!iE.test(t.eventId)||typeof t.timestamp!="string"||!Number.isFinite(Date.parse(t.timestamp))||new Date(t.timestamp).toISOString()!==t.timestamp||!["ADMITTED","OMITTED_QUOTA","LEGACY_COMMITTED"].includes(t.syncDisposition)?_m("INVALID_SYNC_RECEIPT"):Object.freeze({...t})}function lH(t,e){return!t||t.sessionId!==e.sessionId||t.type!=="NOTIFICATION"||t.source!=="DESKTOP"||t.writerAuthenticated!==!0||t.writerEventKind!=="WORKSPACE_OUTCOME"||t.writerEventNonce!==e.writerAttestation?.writerEventNonce||t.writerSessionGenerationId!==e.writerSessionGenerationId?_m("INVALID_SYNC_RECEIPT"):sO({schemaVersion:1,kind:"WORKSPACE_OUTCOME",state:"ACKED",sessionId:t.sessionId,sessionGenerationId:t.writerSessionGenerationId,writerEventNonce:t.writerEventNonce,eventId:t.eventId,timestamp:t.timestamp,syncDisposition:"ADMITTED"},e)}var iE,bre,Sre,aO=D(()=>{"use strict";Gn();iE=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,bre=["sessionId","type","source","content","metadata","isEncrypted","encryptionVersion","writerEventKind","writerSessionGenerationId","writerOutcomeSubject","writerCausalPredecessor","writerAttestation"],Sre=["schemaVersion","kind","state","sessionId","sessionGenerationId","writerEventNonce","eventId","timestamp","syncDisposition"]});function st(t){let e={...t};for(let r of sE)delete e[r];return e}var sE,Or=D(()=>{"use strict";sE=["CODEVIBE_GOOGLE_SEARCH_API_KEY","CODEVIBE_GOOGLE_SEARCH_CX","CODEVIBE_BRAVE_SEARCH_API_KEY"]});function aE(t){return!!(t===".."||t.startsWith(".."+Ui.sep)||Ui.sep!=="/"&&t.startsWith("../"))}function gy(t){let e=Ui.basename(t);for(let r of xm)if(e===r){if(r==="credentials"){let n=Ui.dirname(t);if(Ui.basename(n)===".aws")return!0;continue}return!0}for(let r of xm)if(r.startsWith("id_")&&e.startsWith(r))return!0;if(e.startsWith(".env."))return!0;for(let r of vre)if(e.endsWith(r)&&e.length>r.length)return!0;return!1}function yy(t,e,r){if(e.has(t))return!0;let n=t;for(let i=0;i<4096;i++){if(r.has(n))return!0;let o=Ui.dirname(n);if(o===n)return!1;n=o}return!1}function Cm(t,e,r){if(e.has(t))return!0;let n=t;for(let i=0;i<4096;i++){if(r.has(n))return!0;let o=Ui.dirname(n);if(o===n)return!1;n=o}return!1}function al(t,e,r=!1){if(gy(t))return{admissible:!1,reason:"secret"};if(!e.notInGitRepo&&e.untrackedSet.has(t))return{admissible:!1,reason:"untracked"};if(!e.notInGitRepo&&yy(t,e.ignoredExactPaths,e.ignoredDirPrefixes))return{admissible:!1,reason:"gitignore"};let n=Ui.relative(e.realRootPath,t);return n.length>0&&!aE(n)&&!Ui.isAbsolute(n)&&e.userIgnoreMatcher.ignores(n,r)?{admissible:!1,reason:"userIgnore"}:{admissible:!0}}var Ui,xm,vre,cl=D(()=>{"use strict";Ui=F(require("path"));xm=[".env",".env.local",".env.development",".env.production",".env.test",".env.staging","credentials","id_rsa","id_dsa","id_ecdsa","id_ed25519"],vre=[".pem",".key",".crt",".pfx",".p12",".keystore"]});var br,ll=D(()=>{"use strict";br=class extends Error{constructor(e,r){super(e),this.name="StructuralSummaryError",this.kind=r}}});function kre(t){let e=t,r=e.startsWith("/");r&&(e=e.slice(1)),e=Ere(e);let n=e.includes("/"),i="",o=0;for(;o<e.length;){let a=e[o];if(a==="*"&&e[o+1]==="*"){let c=o===0,l=o+2===e.length,d=o>0&&e[o-1]==="/",u=e[o+2]==="/";if(d&&u){i=i.slice(0,-1)+"(?:/.+)?/",o+=3;continue}if(c&&u){i+="(?:.+/)?",o+=3;continue}if(d&&l){i=i.slice(0,-1)+"/.+",o+=2;continue}i+=".*",o+=2;continue}a==="*"?i+="[^/]*":a==="?"?i+="[^/]":/[.+^${}()|\\[\]]/.test(a)?i+="\\"+a:i+=a,o++}let s;return r||n?s=`^${i}(/.*)?$`:s=`^(.*/)?${i}(/.*)?$`,new RegExp(s)}function Ere(t){if(!t.includes("**"))return t;let e=t.split("/"),r=[];for(let n of e)n==="**"&&r.length>0&&r[r.length-1]==="**"||r.push(n);return r.join("/")}function Rre(t){let e=[];for(let r of t.split(`
|
|
826
|
+
`}});function QC(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function are(t){let e=ay(Buffer.from(t.privateKeyB64,"base64")),r=Buffer.from(t.publicKeyB64,"base64");if(r.length!==64)throw new Error(`class-a-sign: public key must be raw 64-byte x||y (no 0x04 prefix), got ${r.length}`);let n=r.subarray(0,32),i=r.subarray(32,64),o={kty:"EC",crv:"P-256",d:QC(e.toString("base64")),x:QC(n.toString("base64")),y:QC(i.toString("base64"))};return zk.createPrivateKey({key:o,format:"jwk"})}function ZC(t,e){let r={...t};return delete r[e],(0,XC.canonicalize)(r)}function Ua(t,e){let r=are(e);return zk.sign("sha256",Buffer.from(t,"utf8"),{key:r,dsaEncoding:"ieee-p1363"}).toString("base64")}function J1(t,e){let r=`${py}\0${(0,XC.canonicalize)(t)}`;return Ua(r,e)}function eO(t,e){let r=ZC(t,"signature");return Ua(r,e)}function tO(t,e,r){let n={...t,leDeviceId:r},i=ZC(n,"signatureB64");return Ua(i,e)}var zk,XC,py,Ld=D(()=>{"use strict";zk=F(require("node:crypto")),XC=require("json-freeze");km();py="codevibe.encrypted_desktop_event.writer.v1"});function gi(){throw new ve("INVALID_SYNC_INPUT")}function $d(t){if(Fd.some(e=>t[e]!==void 0))return(typeof t.ownerToken!="string"||!/^[A-Za-z0-9_-]{32,128}$/.test(t.ownerToken)||t.promptId!==Fa(t.ownerToken)||!["PLUGIN_APPROVAL","CORE_OFFER"].includes(t.producerKind)||typeof t.mobileActionable!="boolean"||!["INTERACTIVE_PROMPT","NOTIFICATION"].includes(t.type))&&gi(),Object.freeze({promptId:t.promptId,ownerToken:t.ownerToken,producerKind:t.producerKind,mobileActionable:t.mobileActionable})}function Bd(t){if(typeof t!="string"||!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(t))return!1;let e=Date.parse(t);return Number.isFinite(e)&&new Date(e).toISOString()===t}function pre(t){let e=new Set,r=0,n=(i,o)=>{if((++r>1e5||o>32)&&gi(),i===null||typeof i=="boolean"||typeof i=="string"||typeof i=="number"&&Number.isFinite(i))return i;(!Array.isArray(i)&&!Ha(i)||e.has(i))&&gi(),e.add(i);let s=c=>{let l=Object.getOwnPropertyDescriptor(i,c);return(!l||!Gi(l,"value"))&&gi(),n(l.value,o+1)},a;return Array.isArray(i)?(Object.keys(i).length!==i.length&&gi(),a=Array.from({length:i.length},(c,l)=>s(String(l)))):a=Object.fromEntries(Object.keys(i).map(c=>[c,s(c)])),e.delete(i),a};return n(t,0)}function $n(t,e){let r=t==="CREATE_EVENT"?lre:t==="UPDATE_EVENT"?dre:ure;(!Ha(e)||Object.keys(e).some(o=>!r.includes(o)))&&gi();let n=Object.keys(e).map(o=>{let s=Object.getOwnPropertyDescriptor(e,o);return Gi(s,"value")||gi(),[o,s.value]}),i=pre(Object.fromEntries(n.filter(([,o])=>o!==void 0)));if((typeof i.clientOperationId!="string"||!Y1.test(i.clientOperationId)||typeof i.sessionGenerationId!="string"||!Y1.test(i.sessionGenerationId)||typeof i.sessionId!="string"||!my.test(i.sessionId)||typeof i.expectedSessionKeyGen!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(i.expectedSessionKeyGen))&&gi(),i.clientOperationId=i.clientOperationId.toLowerCase(),i.sessionGenerationId=i.sessionGenerationId.toLowerCase(),t==="CREATE_EVENT"){(typeof i.type!="string"||!cre.has(i.type)||i.content!=null&&typeof i.content!="string"||Gi(i,"timestamp")&&!Bd(i.timestamp)||typeof i.isEncrypted!="boolean"||(i.isEncrypted?i.encryptionVersion!==1:Gi(i,"encryptionVersion")))&&gi(),i.source="DESKTOP";let o=$d(i);if(i.type==="INTERACTIVE_PROMPT"&&!o&&gi(),(fy(i.type)||o)&&(i.isEncrypted!==!0||!Bd(i.timestamp)||typeof i.content!="string"||!i.content||!Ha(i.metadata)||Object.keys(i.metadata).join(",")!=="encrypted"||typeof i.metadata.encrypted!="string"||!i.metadata.encrypted||Gi(i,"writerAttestation"))&&gi(),Gi(i,"writerAttestation")){let s=i.writerAttestation;(!Ha(s)||Object.keys(s).sort().join(",")!=="contentCiphertextSha256,metadataCiphertextSha256,schema,signatureB64,writerEventNonce"||s.schema!=="codevibe.encrypted_desktop_event.writer.v1"||s.writerEventNonce!==i.clientOperationId||!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(i.clientOperationId)||Gi(i,"timestamp")||!["USER_PROMPT","ASSISTANT_RESPONSE"].includes(i.type)||i.isEncrypted!==!0||typeof i.content!="string"||!i.content||!Ha(i.metadata)||Object.keys(i.metadata).join(",")!=="encrypted"||typeof i.metadata.encrypted!="string"||!i.metadata.encrypted||s.contentCiphertextSha256!==(0,Jk.createHash)("sha256").update(i.content).digest("hex")||s.metadataCiphertextSha256!==(0,Jk.createHash)("sha256").update(i.metadata.encrypted).digest("hex")||typeof s.signatureB64!="string"||Buffer.from(s.signatureB64,"base64").length!==64||Buffer.from(s.signatureB64,"base64").toString("base64")!==s.signatureB64)&&gi()}}else t==="UPDATE_EVENT"?(typeof i.eventId!="string"||!my.test(i.eventId)||!Bd(i.timestamp)||typeof i.baseRevision!="string"||!/^(0|[1-9][0-9]{0,18})$/.test(i.baseRevision)||BigInt(i.baseRevision)>=(1n<<63n)-1n||typeof i.immutableIdentityDigest!="string"||!/^[a-f0-9]{64}$/.test(i.immutableIdentityDigest)||!Ha(i.metadataMerge)||Gi(i.metadataMerge,"emittedBy"))&&gi():(typeof i.eventId!="string"||!my.test(i.eventId)||!Bd(i.timestamp)||!["DELIVERED","EXECUTED"].includes(i.deliveryStatus))&&gi();return i}function Tm(t,e,r,n,i){(!/^[A-Za-z0-9_-]{1,128}$/.test(r)||!Number.isSafeInteger(i)||i<0||i>253402300739e3)&&gi();let o=(0,Jk.createHash)("sha256").update((0,rO.canonicalize)(e)).digest("hex"),s={clientOperationId:e.clientOperationId,issuedAtEpochMs:i},a=Ua("codevibe-sync-desktop-event-v1\0"+(0,rO.canonicalize)({userId:r,action:t,...s,requestSha256:o}),n),c=t==="CREATE_EVENT"?"metadata":"metadataMerge";return Object.freeze({...e,...Gi(e,c)&&{[c]:JSON.stringify(e[c])},desktopProof:Object.freeze({...s,signature:a})})}function ls(t,e){let r=()=>{throw new ve("INVALID_SYNC_RECEIPT")};if(typeof t=="string"){Buffer.byteLength(t)>2048&&r();try{t=JSON.parse(t)}catch{r()}}(!Ha(t)||Object.keys(t).sort().join(",")!==[...Q1].sort().join(","))&&r();let n=t;return(Q1.some(i=>typeof n[i]!="string"||Buffer.byteLength(n[i])>256)||Buffer.byteLength(JSON.stringify(n))>2048||!my.test(n.eventId)||n.eventId.startsWith("local-throttled")||n.sessionId!==e.sessionId||!Bd(n.timestamp)||!Object.values(Ga).includes(n.type)||!["DESKTOP","MOBILE"].includes(n.source)||!["IMPLEMENTOR","SYSTEM","USER"].includes(n.emittedBy))&&r(),Gi(e,"type")?((n.type!==e.type||n.source!=="DESKTOP"||n.emittedBy!=="IMPLEMENTOR")&&r(),e.type==="TOOL_ACTIVITY"&&Gi(e,"clientOperationId")&&n.eventId!==e.clientOperationId&&r()):(n.eventId!==e.eventId||n.timestamp!==e.timestamp)&&r(),Object.freeze({...n})}function Yk(t,e){let r=()=>{throw new ve("INVALID_SYNC_RECEIPT")};if(typeof t=="string"){Buffer.byteLength(t)>2048&&r();try{t=JSON.parse(t)}catch{r()}}let n=["sessionId","sessionGenerationId","eventId","timestamp","type","source","deliveryStatus","deliveredAt"];(!Ha(t)||Object.keys(t).some(o=>![...n,"executedAt"].includes(o))||n.some(o=>typeof t[o]!="string")||Buffer.byteLength(JSON.stringify(t))>2048)&&r();let i=t;return(i.sessionId!==e.sessionId||i.sessionGenerationId!==e.sessionGenerationId||i.eventId!==e.eventId||i.timestamp!==e.timestamp||i.source!=="MOBILE"||!["USER_PROMPT","PROMPT_RESPONSE"].includes(i.type)||!Bd(i.deliveredAt)||!["DELIVERED","EXECUTED"].includes(i.deliveryStatus)||e.deliveryStatus==="EXECUTED"&&i.deliveryStatus!=="EXECUTED"||(i.deliveryStatus==="EXECUTED"?!Bd(i.executedAt):Gi(i,"executedAt")))&&r(),Object.freeze({...i})}function Qk(t,e){let r=()=>{throw new ve("INVALID_SYNC_RECEIPT")};if(typeof t=="string"){Buffer.byteLength(t)>2048&&r();try{t=JSON.parse(t)}catch{r()}}Ha(t)||r();let n=t,i=n.status==="REFRESHED"&&Gi(n,"expiresAt")?["expiresAt","promptId","status"]:["promptId","status"];return(Object.keys(n).sort().join(",")!==i.join(",")||n.promptId!==e||!my.test(e)||!["REFRESHED","RERAISE_REQUIRED"].includes(n.status)||n.status==="REFRESHED"&&Gi(n,"expiresAt")&&(typeof n.expiresAt!="number"||!Number.isSafeInteger(n.expiresAt)||n.expiresAt<=0||n.expiresAt>253402300799))&&r(),Object.freeze({...n})}var Jk,rO,Am,fy,ve,Y1,my,cre,nO,Fd,lre,dre,ure,Q1,Gi,Ha,Gn=D(()=>{"use strict";Jk=require("node:crypto"),rO=require("json-freeze");Ld();Nd();Kk();Am=Object.freeze(["TOOL_ACTIVITY","NOTIFICATION","MODE_SELECTED","PLANNER_DECISION","PLANNER_CACHE_HIT","PLANNER_DEGRADED","PLANNER_OUTAGE","PLANNER_RECOVERED","SLASH_COMMAND_INVOKED","STRUCTURAL_SUMMARY_GENERATED","LOCAL_AUTHORITY_REFUSAL","TEAM_DECOMPOSED","TEAM_TRACK_STATUS","TEAM_GROUP_RESOLVED"]),fy=t=>typeof t=="string"&&Am.includes(t),ve=class extends Error{constructor(r){super(r);this.code=r;this.name="SyncEventClientError"}},Y1=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,my=/^[A-Za-z0-9_-]{1,256}$/,cre=new Set(["USER_PROMPT","ASSISTANT_RESPONSE","REASONING","TOOL_USE","INTERACTIVE_PROMPT",...Am]),nO=["clientOperationId","sessionId","sessionGenerationId","expectedSessionKeyGen"],Fd=Object.freeze(["promptId","ownerToken","producerKind","mobileActionable"]),lre=[...nO,"type","content","metadata","isEncrypted","encryptionVersion","writerAttestation","timestamp",...Fd],dre=[...nO,"eventId","timestamp","baseRevision","immutableIdentityDigest","metadataMerge"],ure=[...nO,"eventId","timestamp","deliveryStatus"],Q1=["eventId","sessionId","type","source","timestamp","emittedBy"],Gi=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ha=t=>!!t&&typeof t=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(t))});function eH(t,e){if(t.controlGeneration!==e.controlGeneration)return t.controlGeneration>e.controlGeneration?"REPLACE":"RETAIN";if(t.accountingGeneration!==e.accountingGeneration)return"CONFLICT";if(t.entitlementVersion!==e.entitlementVersion)return BigInt(t.entitlementVersion)>BigInt(e.entitlementVersion)?"REPLACE":"RETAIN";if(t.periodId!==e.periodId)return(t.periodId??"")>(e.periodId??"")?"REPLACE":"RETAIN";let r=BigInt(t.usage?.usageRevision??"0"),n=BigInt(e.usage?.usageRevision??"0");if(r!==n)return r>n?"REPLACE":"RETAIN";let i=o=>(0,Z1.canonicalize)({...o,observedAtEpochMs:0,validUntilEpochMs:0});return i(t)!==i(e)?"CONFLICT":t.observedAtEpochMs!==e.observedAtEpochMs?t.observedAtEpochMs>e.observedAtEpochMs?"REPLACE":"RETAIN":t.validUntilEpochMs>=e.validUntilEpochMs?"REPLACE":"RETAIN"}function tH(t,e=Date.now()){return!t||!Number.isSafeInteger(e)||t.observedAtEpochMs>e+sl||e>=t.validUntilEpochMs?"Companion sync status unavailable":t.usage?.syncState==="PAUSED"?"Companion sync paused":t.protocol==="FROZEN"?"Companion sync unavailable":t.usage?.syncState==="WARNING"?"Companion sync 80%+":null}function eE(t,e=Date.now()){let r=["Companion sync status unavailable"];if(!t||!Number.isSafeInteger(e)||t.observedAtEpochMs>e+sl||e>=t.validUntilEpochMs)return r;if(t.protocol==="LEGACY")return["Legacy Companion accounting"];if(!t.usage||t.resetAtEpochMs===null)return r;let n=t.usage.syncState==="PAUSED",i=!n&&t.protocol==="SYNC_V2",o=[n?"Companion sync paused":i?t.usage.syncState==="WARNING"?"Companion sync 80%+":"Companion sync active":"Companion sync unavailable"],s=[["syncUnits","Sync units"],["mobileAttachmentCount","Mobile images"],["mobileAttachmentBytes","Mobile upload bytes"]];for(let[a,c]of s)o.push(`${c}: ${t.usage[`${a}Committed`]} committed \xB7 ${t.usage[`${a}Reserved`]} reserved \xB7 ${t.usage[`${a}Limit`]} limit`);return o.push(`Resets ${new Date(t.resetAtEpochMs).toISOString().slice(0,16).replace("T"," ")} UTC.`),o.push("Desktop-local image attachments do not count."),(n||BigInt(t.usage.gapStartedAtEpochMs)>0n)&&o.push("Messages omitted while paused will not be backfilled."),i||o.push("Continue on desktop."),o}function ni(){throw new ve("INVALID_SYNC_STATE")}function ol(t){return(typeof t!="string"||!/^(0|[1-9][0-9]{0,18})$/.test(t)||BigInt(t)>(1n<<63n)-1n)&&ni(),BigInt(t)}function tE(t,e,r=Date.now()){if(typeof t=="string"){Buffer.byteLength(t)>2048&&ni();try{t=JSON.parse(t)}catch{ni()}}(!Xk(t,rH(t)&&Object.prototype.hasOwnProperty.call(t,"quotaNotice")?[...X1,"quotaNotice"]:X1)||Buffer.byteLength(JSON.stringify(t))>2048||t.schemaVersion!==1||t.environment!==e||!["development","production"].includes(t.environment)||!["FREE","PRO","MAX"].includes(t.tier)||!["LEGACY","SHADOW","AUTHORITATIVE","ROLLBACK_FREEZE"].includes(t.mode)||!["LEGACY","SYNC_V2","FROZEN"].includes(t.protocol)||!Number.isSafeInteger(t.controlGeneration)||t.controlGeneration<0||!Number.isSafeInteger(t.observedAtEpochMs)||t.observedAtEpochMs<Date.UTC(2e3,0,1)||t.observedAtEpochMs>r+sl||!Number.isSafeInteger(t.validUntilEpochMs)||t.validUntilEpochMs<=r||t.validUntilEpochMs<=t.observedAtEpochMs||t.validUntilEpochMs-t.observedAtEpochMs>18e5||t.accountingGeneration!==null&&(typeof t.accountingGeneration!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(t.accountingGeneration))||!Xk(t.limits,Zk))&&ni(),ol(t.entitlementVersion);for(let n of Zk)ol(t.limits[n])===0n&&ni();if(t.mode==="AUTHORITATIVE"){(t.protocol==="LEGACY"||!t.accountingGeneration||!Xk(t.usage,fre)||typeof t.periodId!="string"||!/^\d{4}-(0[1-9]|1[0-2])$/.test(t.periodId))&&ni();let n=new Date(t.observedAtEpochMs),i=Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1);(t.periodId!==n.toISOString().slice(0,7)||t.resetAtEpochMs!==i||t.validUntilEpochMs>i)&&ni(),ol(t.usage.usageRevision);let o=ol(t.usage.gapStartedAtEpochMs),s=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1);o!==0n&&(o<BigInt(s)||o>BigInt(t.observedAtEpochMs))&&ni(),["ACTIVE","WARNING","PAUSED"].includes(t.usage.syncState)||ni();for(let a of Zk)ol(t.usage[`${a}Committed`]),ol(t.usage[`${a}Reserved`]),ol(t.usage[`${a}Limit`]),ol(t.usage[`${a}PauseLimit`])>0n&&o===0n&&ni(),t.usage[`${a}Limit`]!==t.limits[a]&&ni()}else(t.protocol==="SYNC_V2"&&t.mode!=="SHADOW"||t.mode==="ROLLBACK_FREEZE"&&t.protocol!=="FROZEN"||t.usage!==null||t.periodId!==null||t.resetAtEpochMs!==null)&&ni();if(t.accountingGeneration===null&&(t.mode!=="LEGACY"||t.controlGeneration!==0)&&ni(),t.accountingGeneration!==null&&t.controlGeneration<1&&ni(),t.usage?.syncState==="PAUSED"){let n=t.quotaNotice;(!Xk(n,["schemaVersion","kind","noticeId","reasonCode","localizationKey","content"])||n.schemaVersion!==1||n.kind!=="QUOTA_PAUSED"||typeof n.noticeId!="string"||!/^[a-f0-9]{64}$/.test(n.noticeId)||n.reasonCode!=="SYNC_QUOTA_EXHAUSTED"||n.localizationKey!=="codevibe.sync.quota_paused"||n.content!==mre)&&ni()}else Object.prototype.hasOwnProperty.call(t,"quotaNotice")&&ni();return Object.freeze({...t,limits:Object.freeze({...t.limits}),usage:t.usage===null?null:Object.freeze({...t.usage}),...t.quotaNotice&&{quotaNotice:Object.freeze({...t.quotaNotice})}})}var Z1,sl,mre,X1,Zk,fre,rH,Xk,Pm=D(()=>{"use strict";Gn();Z1=require("json-freeze"),sl=6e4,mre="Companion sync paused. Continue on desktop. Messages omitted while paused will not be backfilled.";X1=["schemaVersion","environment","observedAtEpochMs","validUntilEpochMs","entitlementVersion","tier","mode","protocol","controlGeneration","accountingGeneration","periodId","resetAtEpochMs","limits","usage"],Zk=["syncUnits","mobileAttachmentCount","mobileAttachmentBytes"],fre=[...Zk.flatMap(t=>[`${t}Committed`,`${t}Reserved`,`${t}Limit`,`${t}PauseLimit`]),"syncState","usageRevision","gapStartedAtEpochMs"],rH=t=>!!t&&typeof t=="object"&&[Object.prototype,null].includes(Object.getPrototypeOf(t)),Xk=(t,e)=>rH(t)&&Object.keys(t).sort().join(",")===[...e].sort().join(",")});function rE(t,e){return!t||typeof t!="object"||![Object.prototype,null].includes(Object.getPrototypeOf(t))||Reflect.ownKeys(t).length!==e.length?!1:Reflect.ownKeys(t).every(r=>{let n=Object.getOwnPropertyDescriptor(t,r);return typeof r=="string"&&e.includes(r)&&n.enumerable&&"value"in n})}function oH(t,e){return typeof t!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(t)||!rE(e,nH)||nH.some(r=>typeof e[r]!="string")||!iO.test(e.sessionId)||!iO.test(e.sessionGenerationId)||!/^[A-Za-z0-9_-]{1,128}$/.test(e.expectedSessionKeyGen)||!["ISOLATION_OFF","COARSE_EGRESS"].includes(e.posture)?gre():Object.freeze({...e,clientOperationId:(0,nE.v5)((0,oO.canonicalize)({userId:t,...e}),hre)})}function yre(t){return(0,iH.createHash)("sha256").update("codevibe-security-posture-v1\0"+(0,oO.canonicalize)({sessionId:t.sessionId,sessionGenerationId:t.sessionGenerationId,posture:t.posture})).digest("hex")}function wre(t,e){try{return typeof t=="string"?Buffer.byteLength(t)>e?hy():JSON.parse(t):Buffer.byteLength(JSON.stringify(t))>e?hy():t}catch{return hy()}}function sH(t,e){let r=wre(t,2048);if(!rE(r,["schemaVersion","kind","state","sessionId","sessionGenerationId","posture","noticeId","delivery"])||r.schemaVersion!==1||r.kind!=="SECURITY_POSTURE"||r.state!=="RECORDED"||r.sessionId!==e.sessionId||r.sessionGenerationId!==e.sessionGenerationId||r.posture!==e.posture||r.noticeId!==yre(e)||!rE(r.delivery,["state","outcomes"])||!["ATTEMPTED","REPLAY_NO_SEND"].includes(r.delivery.state)||!Array.isArray(r.delivery.outcomes)||r.delivery.outcomes.length>3||r.delivery.state==="REPLAY_NO_SEND"&&r.delivery.outcomes.length!==0)return hy();let n=new Set;for(let i of r.delivery.outcomes){if(!rE(i,["installationId","outcome"])||typeof i.installationId!="string"||!iO.test(i.installationId)||n.has(i.installationId)||!["SUBMITTED","STALE_RECIPIENT","ATTEMPT_UNCONFIRMED"].includes(i.outcome))return hy();n.add(i.installationId)}return r}var iH,nE,oO,iO,hre,nH,gre,hy,aH=D(()=>{"use strict";iH=require("node:crypto"),nE=require("uuid"),oO=require("json-freeze");Gn();iO=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,hre=(0,nE.v5)("codevibe:sync:security-posture:v1",nE.v5.URL),nH=["sessionId","sessionGenerationId","expectedSessionKeyGen","posture"];gre=()=>{throw new ve("INVALID_SYNC_INPUT")},hy=()=>{throw new ve("INVALID_SYNC_RECEIPT")}});function _m(t){throw new ve(t)}function oE(t,e){return!!t&&typeof t=="object"&&!Array.isArray(t)&&[Object.prototype,null].includes(Object.getPrototypeOf(t))&&Reflect.ownKeys(t).length===e.length&&e.every(r=>{let n=Object.getOwnPropertyDescriptor(t,r);return n?.enumerable&&"value"in n})}function cH(t){if(!oE(t,bre)||!iE.test(t.sessionId)||t.type!=="NOTIFICATION"||t.source!=="DESKTOP"||t.writerEventKind!=="WORKSPACE_OUTCOME"||typeof t.writerSessionGenerationId!="string"||!iE.test(t.writerSessionGenerationId)||t.isEncrypted!==!0||t.encryptionVersion!==1||typeof t.content!="string"||!t.content||!oE(t.metadata,["encrypted"])||typeof t.metadata.encrypted!="string"||!t.metadata.encrypted||!oE(t.writerAttestation,["schema","writerEventNonce","contentCiphertextSha256","metadataCiphertextSha256","signatureB64"])||!iE.test(t.writerAttestation.writerEventNonce))return _m("INVALID_SYNC_INPUT");let e=JSON.stringify(t);return Buffer.byteLength(e)>180*1024?_m("INVALID_SYNC_INPUT"):JSON.parse(e)}function sO(t,e){if(typeof t=="string"){if(Buffer.byteLength(t)>2048)return _m("INVALID_SYNC_RECEIPT");try{t=JSON.parse(t)}catch{return _m("INVALID_SYNC_RECEIPT")}}return!oE(t,Sre)||Buffer.byteLength(JSON.stringify(t))>2048||t.schemaVersion!==1||t.kind!=="WORKSPACE_OUTCOME"||t.state!=="ACKED"||t.sessionId!==e.sessionId||t.sessionGenerationId!==e.writerSessionGenerationId||t.writerEventNonce!==e.writerAttestation?.writerEventNonce||typeof t.eventId!="string"||!iE.test(t.eventId)||typeof t.timestamp!="string"||!Number.isFinite(Date.parse(t.timestamp))||new Date(t.timestamp).toISOString()!==t.timestamp||!["ADMITTED","OMITTED_QUOTA","LEGACY_COMMITTED"].includes(t.syncDisposition)?_m("INVALID_SYNC_RECEIPT"):Object.freeze({...t})}function lH(t,e){return!t||t.sessionId!==e.sessionId||t.type!=="NOTIFICATION"||t.source!=="DESKTOP"||t.writerAuthenticated!==!0||t.writerEventKind!=="WORKSPACE_OUTCOME"||t.writerEventNonce!==e.writerAttestation?.writerEventNonce||t.writerSessionGenerationId!==e.writerSessionGenerationId?_m("INVALID_SYNC_RECEIPT"):sO({schemaVersion:1,kind:"WORKSPACE_OUTCOME",state:"ACKED",sessionId:t.sessionId,sessionGenerationId:t.writerSessionGenerationId,writerEventNonce:t.writerEventNonce,eventId:t.eventId,timestamp:t.timestamp,syncDisposition:"ADMITTED"},e)}var iE,bre,Sre,aO=D(()=>{"use strict";Gn();iE=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,bre=["sessionId","type","source","content","metadata","isEncrypted","encryptionVersion","writerEventKind","writerSessionGenerationId","writerOutcomeSubject","writerCausalPredecessor","writerAttestation"],Sre=["schemaVersion","kind","state","sessionId","sessionGenerationId","writerEventNonce","eventId","timestamp","syncDisposition"]});function st(t){let e={...t};for(let r of sE)delete e[r];return e}var sE,Or=D(()=>{"use strict";sE=["CODEVIBE_GOOGLE_SEARCH_API_KEY","CODEVIBE_GOOGLE_SEARCH_CX","CODEVIBE_BRAVE_SEARCH_API_KEY"]});function aE(t){return!!(t===".."||t.startsWith(".."+Ui.sep)||Ui.sep!=="/"&&t.startsWith("../"))}function gy(t){let e=Ui.basename(t);for(let r of xm)if(e===r){if(r==="credentials"){let n=Ui.dirname(t);if(Ui.basename(n)===".aws")return!0;continue}return!0}for(let r of xm)if(r.startsWith("id_")&&e.startsWith(r))return!0;if(e.startsWith(".env."))return!0;for(let r of vre)if(e.endsWith(r)&&e.length>r.length)return!0;return!1}function yy(t,e,r){if(e.has(t))return!0;let n=t;for(let i=0;i<4096;i++){if(r.has(n))return!0;let o=Ui.dirname(n);if(o===n)return!1;n=o}return!1}function Cm(t,e,r){if(e.has(t))return!0;let n=t;for(let i=0;i<4096;i++){if(r.has(n))return!0;let o=Ui.dirname(n);if(o===n)return!1;n=o}return!1}function al(t,e,r=!1){if(gy(t))return{admissible:!1,reason:"secret"};if(!e.notInGitRepo&&e.untrackedSet.has(t))return{admissible:!1,reason:"untracked"};if(!e.notInGitRepo&&yy(t,e.ignoredExactPaths,e.ignoredDirPrefixes))return{admissible:!1,reason:"gitignore"};let n=Ui.relative(e.realRootPath,t);return n.length>0&&!aE(n)&&!Ui.isAbsolute(n)&&e.userIgnoreMatcher.ignores(n,r)?{admissible:!1,reason:"userIgnore"}:{admissible:!0}}var Ui,xm,vre,cl=D(()=>{"use strict";Ui=F(require("path"));xm=[".env",".env.local",".env.development",".env.production",".env.test",".env.staging","credentials","id_rsa","id_dsa","id_ecdsa","id_ed25519"],vre=[".pem",".key",".crt",".pfx",".p12",".keystore"]});var br,ll=D(()=>{"use strict";br=class extends Error{constructor(e,r){super(e),this.name="StructuralSummaryError",this.kind=r}}});function kre(t){let e=t,r=e.startsWith("/");r&&(e=e.slice(1)),e=Ere(e);let n=e.includes("/"),i="",o=0;for(;o<e.length;){let a=e[o];if(a==="*"&&e[o+1]==="*"){let c=o===0,l=o+2===e.length,d=o>0&&e[o-1]==="/",u=e[o+2]==="/";if(d&&u){i=i.slice(0,-1)+"(?:/.+)?/",o+=3;continue}if(c&&u){i+="(?:.+/)?",o+=3;continue}if(d&&l){i=i.slice(0,-1)+"/.+",o+=2;continue}i+=".*",o+=2;continue}a==="*"?i+="[^/]*":a==="?"?i+="[^/]":/[.+^${}()|\\[\]]/.test(a)?i+="\\"+a:i+=a,o++}let s;return r||n?s=`^${i}(/.*)?$`:s=`^(.*/)?${i}(/.*)?$`,new RegExp(s)}function Ere(t){if(!t.includes("**"))return t;let e=t.split("/"),r=[];for(let n of e)n==="**"&&r.length>0&&r[r.length-1]==="**"||r.push(n);return r.join("/")}function Rre(t){let e=[];for(let r of t.split(`
|
|
827
827
|
`)){let n=r.replace(/[\r]+$/,"").replace(/\s+$/u,"");if(n.length===0||n.startsWith("#"))continue;let i=!1;n.startsWith("!")&&(i=!0,n=n.slice(1));let o=n.endsWith("/");o&&(n=n.slice(0,-1)),n.length!==0&&e.push({pattern:kre(n),negated:i,directoryOnly:o})}return e}function cE(t){return!t||t.trim().length===0?dH:new cO(t)}function lE(){return dH}var cO,dH,lO=D(()=>{"use strict";cO=class{constructor(e){this.rules=Rre(e)}ignores(e,r=!1){let n=e.split(/[/\\]/).filter(o=>o.length>0).join("/");if(n.length===0)return!1;let i=!1;for(let o of this.rules)o.directoryOnly&&!r||o.pattern.test(n)&&(i=!o.negated);return i}},dH={ignores:()=>!1}});async function dE(t){let e;try{e=await ds.realpath(t.rootPath)}catch{e=t.rootPath}let r=await Tre(t.rootPath,e,t.ignoreFile);if(!r.notInGitRepo&&yy(e,r.ignoredExactPaths,r.ignoredDirPrefixes))return{directoryTree:{path:t.rootPath,fileCount:0,bytes:0,children:[]},fileExtensions:new Map,excludedByGitignore:1,excludedByIgnoreFile:0,excludedAsUntracked:0,truncated:!1,bodyBudgetExceeded:!1,notInGitRepo:r.notInGitRepo,exclusionState:r,countedExactPaths:new Set,countedPrunedPrefixes:new Set([e])};let n={state:r,opts:t,counts:{excludedByGitignore:0,excludedByIgnoreFile:0,excludedAsUntracked:0},truncated:!1,bodyBudgetExceeded:!1,countedExactPaths:new Set,countedPrunedPrefixes:new Set,fileExtensions:new Map};return{directoryTree:await fH(e,t.rootPath,0,n,!0),fileExtensions:n.fileExtensions,excludedByGitignore:n.counts.excludedByGitignore,excludedByIgnoreFile:n.counts.excludedByIgnoreFile,excludedAsUntracked:n.counts.excludedAsUntracked,truncated:n.truncated,bodyBudgetExceeded:n.bodyBudgetExceeded,notInGitRepo:r.notInGitRepo,exclusionState:r,countedExactPaths:n.countedExactPaths,countedPrunedPrefixes:n.countedPrunedPrefixes}}async function fH(t,e,r,n,i){let o={path:e,fileCount:0,bytes:0,children:[]};if(r>=n.opts.maxDepth)return o.truncatedByDepth=!0,o;let s;try{s=await ds.readdir(t,{withFileTypes:!0})}catch(a){if(i)throw new br(`Launch root readdir failed: ${a.message}`,"fs_unreadable");return w.info(`[structural-summary] readdir failed for ${t}`,{error:a.message}),o}s.sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0);for(let a of s){if(n.truncated)break;if(n.opts.fileCountBudget.remaining<=0){n.truncated=!0;break}let c=Un.join(t,a.name),l=Un.join(e,a.name);if(a.isDirectory()&&Ire.has(a.name)){n.counts.excludedByGitignore++,n.countedPrunedPrefixes.add(c);continue}let d=al(c,n.state,a.isDirectory());if(!d.admissible){switch(d.reason){case"secret":break;case"untracked":n.counts.excludedAsUntracked++,n.countedExactPaths.add(c);break;case"gitignore":n.counts.excludedByGitignore++,a.isDirectory()?n.countedPrunedPrefixes.add(c):n.countedExactPaths.add(c);break;case"userIgnore":n.counts.excludedByIgnoreFile++,a.isDirectory()?n.countedPrunedPrefixes.add(c):n.countedExactPaths.add(c);break}continue}if(a.isSymbolicLink()){let u={path:l,fileCount:0,bytes:0,children:[]};o.children.push(u);continue}if(a.isDirectory()){let u=await fH(c,l,r+1,n,!1);o.children.push(u),o.fileCount+=u.fileCount,o.bytes+=u.bytes,u.truncatedByDepth&&(o.truncatedByDepth=!0);continue}if(a.isFile()){let u=0;try{u=(await ds.stat(c)).size}catch{continue}n.opts.fileCountBudget.remaining--,o.fileCount++,o.bytes+=u;let p=Un.extname(a.name).toLowerCase();if(p&&n.fileExtensions.set(p,(n.fileExtensions.get(p)??0)+1),Are(c,n.opts.includeBodies,n.state.realRootPath))if(n.opts.bodyBudget.remaining<=0){n.bodyBudgetExceeded=!0;let m={path:l,fileCount:0,bytes:0,children:[],bodyTruncated:!0};o.children.push(m)}else{let m={path:l,fileCount:0,bytes:0,children:[]},f=Math.min(u,uH);if(u>uH)try{let h=await ds.open(c,"r");try{let g=Buffer.alloc(f);await h.read(g,0,f,0),m.body=g.toString("utf8")}finally{await h.close()}m.bodyTruncated=!0}catch{m.bodyTruncated=!0}else try{m.body=await ds.readFile(c,"utf8")}catch{m.bodyTruncated=!0}n.opts.bodyBudget.remaining-=f,n.opts.bodyBudget.remaining<=0&&(n.bodyBudgetExceeded=!0),o.children.push(m)}}}return o}function Are(t,e,r){if(!e||e.length===0)return!1;for(let n of e){if(!Un.isAbsolute(n))continue;if(t===n)return!0;let i=n.endsWith(Un.sep)?n:n+Un.sep;if(t.startsWith(i))return!0}return!1}async function Tre(t,e,r){let n="",i=!1;try{let{stdout:l}=await dO("git",["rev-parse","--show-toplevel"],{cwd:e,env:st({...process.env})});if(n=l.trim(),!n)i=!0;else{let d=Un.relative(n,e);d.length>0&&(aE(d)||Un.isAbsolute(d))&&(i=!0,w.info("[structural-summary] realRootPath outside repoTopLevel \u2014 non-git fallback",{realRootPath:e,repoTopLevel:n}))}}catch(l){i=!0,w.info("[structural-summary] git rev-parse failed \u2014 non-git fallback",{rootPath:t,error:l.message})}let o=new Set;if(!i)try{let{stdout:l}=await dO("git",["status","--porcelain","-z","--untracked-files=all"],{cwd:n,maxBuffer:67108864,env:st({...process.env})}),d=l.split("\0").filter(u=>u.length>0);for(let u of d)if(u.startsWith("?? ")){let p=u.slice(3),m=Un.join(n,p),f=Un.relative(e,m);f.length>0&&!aE(f)&&!Un.isAbsolute(f)&&o.add(m)}}catch(l){w.info("[structural-summary] git status failed \u2014 empty untracked set",{error:l.message})}let s=new Set,a=new Set;if(!i)try{let{stdout:l}=await dO("git",["ls-files","-z","--ignored","--exclude-standard","--others","--directory"],{cwd:n,maxBuffer:67108864,env:st({...process.env})}),d=l.split("\0").filter(u=>u.length>0);for(let u of d){let p=u.endsWith("/"),m=p?u.slice(0,-1):u,f=Un.join(n,m);p?a.add(f):s.add(f)}}catch(l){w.info("[structural-summary] git ls-files failed \u2014 empty ignored set",{error:l.message})}let c=lE();if(r)try{let l=await ds.readFile(r,"utf8");c=cE(l)}catch(l){let d=l.code;d&&d!=="ENOENT"&&w.warn("[structural-summary] failed to read user-ignore file",{ignoreFile:r,error:l.message})}return{rootPath:t,realRootPath:e,notInGitRepo:i,repoTopLevel:n,untrackedSet:o,ignoredExactPaths:s,ignoredDirPrefixes:a,userIgnoreMatcher:c,secretDenyList:xm}}var ds,Un,pH,mH,dO,uH,Ire,uO=D(()=>{"use strict";ds=F(require("fs/promises")),Un=F(require("path")),pH=require("child_process"),mH=require("util");Or();Xe();cl();lO();cl();ll();cl();dO=(0,mH.promisify)(pH.execFile),uH=512*1024,Ire=new Set(["node_modules","target","build","dist",".git",".next",".nuxt","Pods",".gradle",".dart_tool","vendor"])});async function us(t){let e;try{e=await uE.lstat(t,{bigint:!0})}catch{return null}if(e.isSymbolicLink()||!e.isFile())return null;let r=pO.constants.O_NOFOLLOW,n=pO.constants.O_RDONLY|(r??0),i;try{i=await uE.open(t,n)}catch{return null}try{let o=await i.stat({bigint:!0});return!o.isFile()||o.dev!==e.dev||o.ino!==e.ino?null:await i.readFile("utf8")}catch{return null}finally{try{await i.close()}catch{}}}var uE,pO,wy=D(()=>{"use strict";uE=F(require("fs/promises")),pO=F(require("fs"))});var mO={};Jr(mO,{findManifest:()=>Pre,parse:()=>_re});async function Pre(t){let e=gH.join(t,"package.json");try{let r=await hH.lstat(e);if(r.isSymbolicLink())return null;if(r.isFile())return e}catch{return null}return null}async function _re(t){let e=await us(t);if(e===null)throw new br(`npm manifest read refused (symlink / non-regular / dev-ino-mismatch): ${t}`,"fs_unreadable");let r=JSON.parse(e),n=typeof r.name=="string"?r.name:void 0,i=new Set;for(let o of["dependencies","peerDependencies","optionalDependencies"]){let s=r[o];if(s&&typeof s=="object"&&!Array.isArray(s))for(let a of Object.keys(s))i.add(a)}return{type:"npm",packageName:n,dependencies:Array.from(i).sort()}}var hH,gH,yH=D(()=>{"use strict";hH=F(require("fs/promises")),gH=F(require("path"));wy();ll()});var fO={};Jr(fO,{findManifest:()=>xre,parse:()=>Cre});async function xre(t){let e=bH.join(t,"Cargo.toml");try{let r=await wH.lstat(e);if(r.isSymbolicLink())return null;if(r.isFile())return e}catch{return null}return null}async function Cre(t){let e=await us(t);if(e===null)throw new br(`cargo manifest read refused (symlink / non-regular / dev-ino-mismatch): ${t}`,"fs_unreadable");let r=SH.parse(e),n,i=r.package;if(i&&typeof i=="object"&&!Array.isArray(i)){let c=i.name;typeof c=="string"&&(n=c)}let o=new Set,s=r.dependencies;if(s&&typeof s=="object"&&!Array.isArray(s))for(let c of Object.keys(s))o.add(c);let a=r.workspace;if(a&&typeof a=="object"&&!Array.isArray(a)){let c=a.dependencies;if(c&&typeof c=="object"&&!Array.isArray(c))for(let l of Object.keys(c))o.add(l)}return{type:"cargo",packageName:n,dependencies:Array.from(o).sort()}}var wH,bH,SH,vH=D(()=>{"use strict";wH=F(require("fs/promises")),bH=F(require("path")),SH=F(require("@iarna/toml"));wy();ll()});var by,Sy,kH,EH,RH,IH,AH=D(()=>{"use strict";by=F(require("fs/promises")),Sy=F(require("path"));Xe();wy();ll();kH={async findManifest(t){let e=Sy.join(t,"pyproject.toml");try{let r=await by.lstat(e);if(r.isSymbolicLink())return null;if(r.isFile())return e}catch{return null}return null},async parse(t){let e=await us(t);if(e===null)throw new br(`pyproject manifest read refused (symlink / non-regular / dev-ino-mismatch): ${t}`,"fs_unreadable");let r=e.indexOf("[project]");if(r===-1)return{type:"pyproject",dependencies:[]};let n=e.slice(r+9),i=n.match(/\n\[[^\]]+\]/),o=i?n.slice(0,i.index??n.length):n,s,a=o.match(/\bname\s*=\s*["']([^"']+)["']/);a&&(s=a[1]);let c=[],l=o.match(/\bdependencies\s*=\s*\[([\s\S]*?)\]/);if(l){let d=l[1],u=/["']([^"']+)["']/g,p;for(;(p=u.exec(d))!==null;){let f=p[1].trim().split(/[\s<>=!~;]/)[0]?.trim();f&&f.length>0&&c.push(f)}}return{type:"pyproject",packageName:s,dependencies:Array.from(new Set(c)).sort()}}},EH={async findManifest(t){let e=Sy.join(t,"go.mod");try{let r=await by.lstat(e);if(r.isSymbolicLink())return null;if(r.isFile())return e}catch{return null}return null},async parse(t){let e=await us(t);if(e===null)throw new br(`go.mod manifest read refused (symlink / non-regular / dev-ino-mismatch): ${t}`,"fs_unreadable");let r,n=e.match(/^\s*module\s+(\S+)/m);n&&(r=n[1]);let i=[],o=e.match(/require\s*\(([\s\S]*?)\)/);if(o){let c=o[1];for(let l of c.split(`
|
|
828
828
|
`)){let d=l.trim();if(!d||d.startsWith("//"))continue;let u=d.match(/^(\S+)/);u&&i.push(u[1])}}let s=/^require\s+([^\s(]+)\s+\S+/gm,a;for(;(a=s.exec(e))!==null;)i.push(a[1]);return{type:"go",packageName:r,dependencies:Array.from(new Set(i)).sort()}}},RH={async findManifest(t){let e=Sy.join(t,"Podfile");try{let r=await by.lstat(e);if(r.isSymbolicLink())return null;if(r.isFile())return e}catch{return null}return null},async parse(t){let e=await us(t);if(e===null)throw new br(`Podfile manifest read refused (symlink / non-regular / dev-ino-mismatch): ${t}`,"fs_unreadable");let r,n=e.match(/\btarget\s+['"]([^'"]+)['"]\s+do/);n&&(r=n[1]);let i=[],o=/^\s*pod\s+['"]([^'"]+)['"]/gm,s;for(;(s=o.exec(e))!==null;)i.push(s[1]);return i.length===0&&w.warn("[structural-summary] Podfile parsed with 0 pod entries \u2014 likely conditional/non-standard syntax",{file:t}),{type:"podfile",packageName:r,dependencies:Array.from(new Set(i)).sort()}}},IH={async findManifest(t){for(let e of["build.gradle","build.gradle.kts"]){let r=Sy.join(t,e);try{let n=await by.lstat(r);if(n.isSymbolicLink())continue;if(n.isFile())return r}catch{continue}}return null},async parse(t){let e=await us(t);if(e===null)throw new br(`gradle manifest read refused (symlink / non-regular / dev-ino-mismatch): ${t}`,"fs_unreadable");let r,n=e.match(/\bapplicationId\s*=?\s*["']([^"']+)["']/)||e.match(/\bnamespace\s*=?\s*["']([^"']+)["']/);n&&(r=n[1]);let i=[],o=/\b(?:implementation|api|compileOnly|runtimeOnly|testImplementation|androidTestImplementation)\s*\(?\s*["']([^"']+)["']/g,s;for(;(s=o.exec(e))!==null;)i.push(s[1]);return{type:"gradle",packageName:r,dependencies:Array.from(new Set(i)).sort()}}}});async function TH(t,e,r,n,i){for(let o of Ore){let s=await o.findManifest(t);if(!s)continue;let a=pE.join(e.realRootPath,pE.basename(s)),c=al(a,e);if(!c.admissible){let l=Cm(a,r,n);if(!l)switch(c.reason){case"untracked":i.excludedAsUntracked++;break;case"gitignore":i.excludedByGitignore++;break;case"userIgnore":i.excludedByIgnoreFile++;break;case"secret":break}w.info(`[structural-summary] Manifest at ${a} is inadmissible (${c.reason}); skipping (walkerAccountedFor=${l})`);continue}try{return await o.parse(a)}catch(l){w.warn(`[structural-summary] Failed to parse ${a}; continuing to next parser`,{err:l.message});continue}}return{type:"none",dependencies:[]}}var pE,Ore,PH=D(()=>{"use strict";pE=F(require("path"));Xe();cl();yH();vH();AH();Ore=[mO,fO,kH,EH,RH,IH]});function fE(){return{generate:Lre}}async function Lre(t){if(t.includeBodies&&t.includeBodies.length>0&&t.tier!=="MAX")throw new br("includeBodies opt-in is Max-tier only. Upgrade at quantiya.ai/codevibe/pricing.","tier_gate");if(t.includeBodies){for(let y of t.includeBodies)if(!mE.isAbsolute(y))throw new br(`includeBodies entry must be absolute (got: ${y}).`,"invalid_path")}let e={remaining:t._test_caps?.fileCountCap??Nre},r={remaining:t._test_caps?.bodyByteCap??Mre},n=[],i=0,o=0,s=0,a=!1,c=!1,l;for(let y of t.rootPaths){if(e.remaining<=0){c=!0,l=l??"fileCount";break}let S=await dE({rootPath:y,ignoreFile:t.ignoreFile,includeBodies:t.includeBodies??[],maxDepth:12,fileCountBudget:e,bodyBudget:r});i+=S.excludedByGitignore,o+=S.excludedByIgnoreFile,s+=S.excludedAsUntracked,a=a||S.notInGitRepo,S.truncated&&!l&&(l="fileCount"),S.bodyBudgetExceeded&&!l&&(l="bodyBytes"),c=c||S.truncated||S.bodyBudgetExceeded;let b=S.exclusionState,v=S.countedExactPaths,E=S.countedPrunedPrefixes,I={excludedAsUntracked:0,excludedByGitignore:0,excludedByIgnoreFile:0},R=await TH(y,b,v,E,I);s+=I.excludedAsUntracked,i+=I.excludedByGitignore,o+=I.excludedByIgnoreFile;let k=Ure(S.fileExtensions),T={excludedAsUntracked:0,excludedByGitignore:0,excludedByIgnoreFile:0},A=await hO(y,b,v,E,T);s+=T.excludedAsUntracked,i+=T.excludedByGitignore,o+=T.excludedByIgnoreFile,n.push({rootPath:y,manifestType:R.type,packageName:R.packageName,dependencies:R.dependencies,inferredLanguages:k,readmePreview:A,directoryTree:S.directoryTree})}let d={bodyInclusionPaths:t.includeBodies??[],excludedByGitignore:i,excludedByIgnoreFile:o,excludedAsUntracked:s,budgetExceeded:c,budgetReason:l,notInGitRepo:a},u=n.reduce((y,S)=>y+Fre(S.directoryTree),0),p=n.reduce((y,S)=>y+$re(S.directoryTree),0),m={generatedAt:new Date().toISOString(),rootPaths:t.rootPaths,repos:n,totalFileCount:u,totalBytes:p,privacyEnvelope:d},{generatedAt:f,...h}=m,g=_H.createHash("sha256").update(JSON.stringify(h,Bre)).digest("hex");return{...m,sha256:g}}function Bre(t,e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=e,n={};for(let i of Object.keys(r).sort())n[i]=r[i];return n}return e}function Fre(t){return t.fileCount}function $re(t){return t.bytes}async function hO(t,e,r,n,i){for(let o of Gre){let s=mE.join(e.realRootPath,o);try{let a=al(s,e);if(!a.admissible){let d=Cm(s,r,n);if(!d)switch(a.reason){case"untracked":i.excludedAsUntracked++;break;case"gitignore":i.excludedByGitignore++;break;case"userIgnore":i.excludedByIgnoreFile++;break;case"secret":break}w.info(`[structural-summary] README candidate ${s} is inadmissible (${a.reason}); skipping (walkerAccountedFor=${d})`);continue}let c=await us(s);if(c===null){w.info(`[structural-summary] README candidate ${s} refused by safeReadTextFile (symlink / non-regular / dev-ino-mismatch); skipping`);continue}return c.split(`
|
|
829
829
|
`).slice(0,50).join(`
|
|
@@ -8605,15 +8605,9 @@ function parseCompanionSyncState(value, environment, now = Date.now()) {
|
|
|
8605
8605
|
let date = new Date(value.observedAtEpochMs), resetAt = Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 1);
|
|
8606
8606
|
(value.periodId !== date.toISOString().slice(0, 7) || value.resetAtEpochMs !== resetAt || value.validUntilEpochMs > resetAt) && invalid2(), count(value.usage.usageRevision);
|
|
8607
8607
|
let gap2 = count(value.usage.gapStartedAtEpochMs), periodStart = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1);
|
|
8608
|
-
gap2 !== 0n && (gap2 < BigInt(periodStart) || gap2 > BigInt(value.observedAtEpochMs)) && invalid2();
|
|
8609
|
-
let
|
|
8610
|
-
|
|
8611
|
-
let committed = count(value.usage[`${meter}Committed`]);
|
|
8612
|
-
count(value.usage[`${meter}Reserved`]);
|
|
8613
|
-
let limit = count(value.usage[`${meter}Limit`]), pausedAtLimit = count(value.usage[`${meter}PauseLimit`]);
|
|
8614
|
-
pausedAtLimit > 0n && gap2 === 0n && invalid2(), value.usage[`${meter}Limit`] !== value.limits[meter] && invalid2(), meter === "syncUnits" && (committed >= limit || pausedAtLimit >= limit) ? state = "PAUSED" : committed * 5n >= limit * 4n && state !== "PAUSED" && (state = "WARNING");
|
|
8615
|
-
}
|
|
8616
|
-
value.usage.syncState !== state && invalid2();
|
|
8608
|
+
gap2 !== 0n && (gap2 < BigInt(periodStart) || gap2 > BigInt(value.observedAtEpochMs)) && invalid2(), ["ACTIVE", "WARNING", "PAUSED"].includes(value.usage.syncState) || invalid2();
|
|
8609
|
+
for (let meter of METERS)
|
|
8610
|
+
count(value.usage[`${meter}Committed`]), count(value.usage[`${meter}Reserved`]), count(value.usage[`${meter}Limit`]), count(value.usage[`${meter}PauseLimit`]) > 0n && gap2 === 0n && invalid2(), value.usage[`${meter}Limit`] !== value.limits[meter] && invalid2();
|
|
8617
8611
|
} else (value.protocol === "SYNC_V2" && value.mode !== "SHADOW" || value.mode === "ROLLBACK_FREEZE" && value.protocol !== "FROZEN" || value.usage !== null || value.periodId !== null || value.resetAtEpochMs !== null) && invalid2();
|
|
8618
8612
|
if (value.accountingGeneration === null && (value.mode !== "LEGACY" || value.controlGeneration !== 0) && invalid2(), value.accountingGeneration !== null && value.controlGeneration < 1 && invalid2(), value.usage?.syncState === "PAUSED") {
|
|
8619
8613
|
let notice2 = value.quotaNotice;
|
package/package.json
CHANGED