@autodevjapan/godd-mcp-alpha 3.6.0 → 3.7.0
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/assets/native/godd-native-aarch64-apple-darwin +0 -0
- package/assets/native/godd-native-aarch64-apple-darwin.sha256 +1 -1
- package/assets/native/godd-native-x86_64-apple-darwin +0 -0
- package/assets/native/godd-native-x86_64-apple-darwin.sha256 +1 -1
- package/assets/native/godd-native-x86_64-pc-windows-msvc.exe +0 -0
- package/assets/native/godd-native-x86_64-pc-windows-msvc.exe.sha256 +1 -1
- package/assets/native/godd-native-x86_64-unknown-linux-musl +0 -0
- package/assets/native/godd-native-x86_64-unknown-linux-musl.sha256 +1 -1
- package/dist/compile-cache-runtime.cjs +8 -4
- package/dist/compile-cache-runtime.d.ts +3 -2
- package/dist/godd.cjs +214 -209
- package/docs/adapter-contracts.md +15 -0
- package/native-assets.json +66 -13
- package/package.json +3 -3
- package/scripts/native-assets.js +71 -8
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bc5d184a91763df0e01cc871fca05ba9873036c77f888a44f313763fcc013405
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e7dcb70f85bf1428a673edb95c65caebbab42c96153f8b31af02f06a1790efe9
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3720b019e07b4d0330ed577623760ef16b05e0d51f4411d82939fa6520aee5ba
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
20089cbc07284c1cae14f2e918d554a7b2aba5f8d4940628b4194790feaf60af
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var V=(o,e)=>{for(var i in e)I(o,i,{get:e[i],enumerable:!0})},B=(o,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of H(e))!G.call(o,n)&&n!==i&&I(o,n,{get:()=>e[n],enumerable:!(t=F(e,n))||t.enumerable});return o};var j=o=>B(I({},"__esModule",{value:!0}),o);var ee={};V(ee,{CompileCacheRejectedError:()=>p,CompileCacheRuntime:()=>L,CompileCacheRuntimeError:()=>c,createNdjsonCompileCacheEvaluator:()=>k,spawnCompileCacheEvaluator:()=>Z});module.exports=j(ee);var U=require("node:child_process");var b=require("node:crypto"),K=/^sha256:[0-9a-f]{64}$/u,J=1024,W=Object.freeze({owner:"nextjs-server",clock:"monotonic-milliseconds",trigger:"timer-and-after-lifecycle-event"});function d(o,e,i,t=0){return Object.freeze({action:o,disposition:e,max_retries:t,on_retry_exhausted:t===1?"REJECT":null,reason:i})}var h=Object.freeze({CACHE_HIT:d("USE_CACHED_MODULE","CONTINUE",null),CACHE_MISS_COMPILED:d("PUBLISH_COMPILED_MODULE","CONTINUE",null),SINGLE_FLIGHT_JOINED:d("WAIT_FOR_SINGLE_FLIGHT","CONTINUE",null),TOO_LARGE_FOR_CACHE:d("COMPILE_WITHOUT_CACHE","CONTINUE","ENTRY_LIMIT_EXCEEDED"),BUDGET_OVERFLOW:d("REJECT_CACHE_OPERATION","REJECT","ARITHMETIC_OVERFLOW"),BUDGET_UNRECLAIMABLE:d("RETRY_AFTER_RECONCILE","RETRY","RECLAIMABLE_ENTRIES_INSUFFICIENT",1),BUDGET_EVICTED_LRU:d("DROP_OPAQUE_HANDLE","CONTINUE","LRU_PRESSURE_EVICTION"),SUPERSEDED_BY_NEW_SOURCE:d("DROP_OPAQUE_HANDLE","CONTINUE","SOURCE_GENERATION_SUPERSEDED"),DECK_TOMBSTONED:d("DROP_OPAQUE_HANDLE","CONTINUE","DECK_LIFECYCLE_ENDED"),STALE_GENERATION_REJECTED:d("DISCARD_COMPILED_MODULE","CONTINUE","GENERATION_FENCE_CHANGED"),PREVIEW_LEASE_EXPIRED:d("DROP_OPAQUE_HANDLE","CONTINUE","PREVIEW_LEASE_ENDED"),AGE_EXPIRED:d("DROP_OPAQUE_HANDLE","CONTINUE","MAXIMUM_AGE_EXCEEDED"),IDLE_EXPIRED:d("DROP_OPAQUE_HANDLE","CONTINUE","MAXIMUM_IDLE_EXCEEDED"),RESERVATION_EXPIRED:d("DISCARD_COMPILED_MODULE","CONTINUE","RESERVATION_DEADLINE_EXCEEDED"),COMPILE_FAILED_ROLLED_BACK:d("RELEASE_FAILED_COMPILE","CONTINUE","COMPILE_DID_NOT_COMPLETE"),RECONCILE_CLOCK_REGRESSION:d("REJECT_CACHE_OPERATION","REJECT","RECONCILE_CLOCK_REGRESSED")});function y(o,e){if(o===null||typeof o!="object"||Array.isArray(o))throw new TypeError(`${e} must be an object`);return o}function R(o,e,i){let t=Object.keys(o).sort(),n=[...e].sort();if(t.length!==n.length||t.some((a,r)=>a!==n[r]))throw new TypeError(`${i} has an invalid field set`)}function u(o){return typeof o=="number"&&Number.isSafeInteger(o)&&o>=0}function T(o){return u(o)&&o>0}function g(o){return typeof o=="string"&&K.test(o)}function N(o){return o==="unversioned"||g(o)}function A(o){return typeof o=="string"&&o.length>0&&Buffer.byteLength(o,"utf8")<=J&&!new RegExp("\\p{Cc}","u").test(o)}function X(o){let e=y(o,"compile cache manifest");if(R(e,["workspace_id","deck_id","deck_generation","slide_filename","canonical_source_digest","mdx_policy_generation","compiler_generation","runtime_abi"],"compile cache manifest"),!A(e.workspace_id)||!A(e.deck_id)||!A(e.slide_filename)||!T(e.deck_generation)||!g(e.canonical_source_digest)||!N(e.mdx_policy_generation)||!g(e.compiler_generation)||e.runtime_abi!=="amaroad")throw new TypeError("compile cache manifest is invalid");return e}function q(o){let e=y(o,"compile cache register request");if(R(e,["schema_version","operation","manifest","source_bytes","declared_max_compiled_bytes","now_ms"],"compile cache register request"),X(e.manifest),e.schema_version!==1||e.operation!=="register"||!u(e.source_bytes)||!T(e.declared_max_compiled_bytes)||!u(e.now_ms))throw new TypeError("compile cache register request is invalid");return e}function P(o){let e=y(o,"compile cache project input");R(e,["schema_version","manifest","canonical_source","declared_max_compiled_bytes","now_ms"],"compile cache project input");let i=y(e.manifest,"compile cache project manifest");if(R(i,["workspace_id","deck_id","deck_generation","slide_filename","mdx_policy_generation","compiler_generation","runtime_abi"],"compile cache project manifest"),typeof e.canonical_source!="string")throw new TypeError("compile cache canonical source is invalid");let t=Buffer.byteLength(e.canonical_source,"utf8"),n={schema_version:1,operation:"register",manifest:{...i,canonical_source_digest:`sha256:${(0,b.createHash)("sha256").update(e.canonical_source,"utf8").digest("hex")}`},source_bytes:t,declared_max_compiled_bytes:e.declared_max_compiled_bytes,now_ms:e.now_ms};return q(n)}function M(o){let e=y(o,"compile cache time budget");if(R(e,["age_ms","idle_ms","reservation_ttl_ms"],"compile cache time budget"),!T(e.age_ms)||!T(e.idle_ms)||!T(e.reservation_ttl_ms))throw new TypeError("compile cache time budget is invalid");return Object.freeze({...W,interval_ms:Math.min(e.age_ms,e.idle_ms,e.reservation_ttl_ms)})}function Y(o){if(typeof o!="string"||!Object.hasOwn(h,o))throw new TypeError("compile cache receipt outcome is unsupported");let e=o;return[e,h[e]]}function Q(o){let e=y(o,"compile cache receipt");R(e,["schema_version","canonical_source_digest","deck_generation","mdx_policy_generation","compiler_generation","key_bytes","source_bytes","compiled_bytes","compiled_bytes_measured","outcome","reason"],"compile cache receipt");let[,i]=Y(e.outcome);if(e.schema_version!==1||!g(e.canonical_source_digest)||!u(e.deck_generation)||!N(e.mdx_policy_generation)||!g(e.compiler_generation)||!u(e.key_bytes)||!u(e.source_bytes)||!u(e.compiled_bytes)||typeof e.compiled_bytes_measured!="boolean")throw new TypeError("compile cache receipt is invalid");if(e.reason!==i.reason)throw new TypeError("compile cache receipt reason does not match outcome");return e}function v(o){let e=Q(o);return Object.freeze({action:h[e.outcome].action,disposition:h[e.outcome].disposition,max_retries:h[e.outcome].max_retries,on_retry_exhausted:h[e.outcome].on_retry_exhausted,outcome:e.outcome})}var c=class extends Error{code;constructor(e){super(e),this.name="CompileCacheRuntimeError",this.code=e}},p=class extends Error{outcome;action;disposition;retriesExhausted;constructor(e,i,t,n){super(e),this.name="CompileCacheRejectedError",this.outcome=e,this.action=i,this.disposition=t,this.retriesExhausted=n}},O=class{outcome;action;constructor(e,i){this.outcome=e,this.action=i}},x="";function z(o){return[o.workspace_id,o.deck_id,String(o.deck_generation),o.slide_filename,o.canonical_source_digest,o.mdx_policy_generation,o.compiler_generation,o.runtime_abi].join(x)}function S(o){return[o.canonical_source_digest,String(o.deck_generation),o.mdx_policy_generation,o.compiler_generation].join(x)}var L=class{#c;#y;#s;#m;#_;#n=new Map;#r=new Map;#i=new Map;#E;#t=null;#l=!1;#C=0;#u=null;#d=!1;constructor(e){this.#c=e.evaluator,this.#y=e.budget,this.#s=e.compile,this.#m=e.now,this.#_=e.onReconcileError??(()=>{}),this.#E=M({age_ms:e.budget.age_ms,idle_ms:e.budget.idle_ms,reservation_ttl_ms:e.budget.reservation_ttl_ms})}get reconcilePolicy(){return this.#E}get retainedModuleCount(){return this.#n.size}get reconcileTimerStarted(){return this.#t!==null}startReconcileTimer(){if(this.#t!==null)throw new c("RECONCILE_TIMER_ALREADY_OWNED");this.#t=setInterval(()=>{this.#l||(this.#l=!0,this.reconcile().catch(e=>{this.#_(e)}).finally(()=>{this.#l=!1}))},this.#E.interval_ms),this.#t.unref?.()}stopReconcileTimer(){if(this.#t===null)throw new c("RECONCILE_TIMER_NOT_OWNED");clearInterval(this.#t),this.#t=null,this.#l=!1}async close(){this.#t!==null&&this.stopReconcileTimer(),this.#d=!0,this.#n.clear(),this.#r.clear(),this.#i.clear(),await this.#c.close()}async compile(e){await this.#h();let i=await this.#R(e,!1);if(!(i instanceof O))return i;await this.reconcile();let t=await this.#R(e,!0);if(t instanceof O)throw new p(t.outcome,t.action,"RETRY",!0);return t}async reconcile(){await this.#h();let e=await this.#a({schema_version:1,command:"reconcile",now_ms:this.#m()}),i=e.action==="REJECTED",t=this.#o(e.receipts,i);if(i)throw t===null?new c("EVALUATOR_PROTOCOL"):new p(t.outcome,t.action,t.disposition,!1);return e.receipts}async onDeckRemoved(e,i){await this.#p({schema_version:1,command:"tombstone_deck",workspace_id:e,deck_id:i})}async onPreviewLeaseExpired(e,i){await this.#p({schema_version:1,command:"expire_preview_lease",workspace_id:e,deck_id:i})}async onGenerationUpdated(e){await this.#p({schema_version:1,command:"fence_generations",...e})}async#p(e){await this.#h();let i=await this.#a(e);this.#o(i.receipts,!1),await this.reconcile()}async#R(e,i){let t=P({schema_version:1,manifest:e.manifest,canonical_source:e.canonical_source,declared_max_compiled_bytes:e.declared_max_compiled_bytes,now_ms:this.#m()}),{operation:n,...a}=t,r=await this.#a({command:n,...a}),s=z(t.manifest),l=S(t.manifest);switch(r.action){case"HIT":return this.#T(e,r,s,l,i);case"JOINED":return this.#g(r,s,i);case"COMPILE_REQUESTED":return this.#w(e,r,s,l,i);case"REJECTED":return this.#I(e,r,i);default:try{this.#o(r.receipts,!1)}finally{await this.#e(r.lease)}throw new c("EVALUATOR_PROTOCOL")}}async#T(e,i,t,n,a){try{let r=this.#O(i,"USE_CACHED_MODULE"),s=this.#n.get(t),l=!0;if(s===void 0){let C=this.#C,E=await this.#s(e);s=E.module,l=!1;let f=i.receipts[i.receipts.length-1];if(E.compiled_bytes!==f.compiled_bytes||this.#C!==C)return{module:s,outcome:r.outcome,action:r.action,served_from_cache:!1,retained:!1,retried:a};this.#f(t,n,s)}return{module:s,outcome:r.outcome,action:r.action,served_from_cache:l,retained:!0,retried:a}}finally{await this.#e(i.lease)}}async#g(e,i,t){try{let n=this.#O(e,"WAIT_FOR_SINGLE_FLIGHT"),a=this.#i.get(i);if(a===void 0)throw new c("SINGLE_FLIGHT_MISSING");let r=await a;return{module:r.module,outcome:n.outcome,action:n.action,served_from_cache:!0,retained:r.retained,retried:t}}finally{await this.#e(e.lease)}}async#w(e,i,t,n,a){try{this.#o(i.receipts,!1)}catch(m){throw await this.#e(i.lease),m}if(i.compile_owner!==!0||i.lease===null)throw await this.#e(i.lease),new c("EVALUATOR_PROTOCOL");let r=i.lease,s,l,C=new Promise((m,w)=>{s=m,l=w});C.catch(()=>{}),this.#i.set(t,C);let E;try{E=await this.#s(e)}catch(m){l?.(m);try{let w=await this.#a({schema_version:1,command:"rollback",lease:r});this.#o(w.receipts,!1)}catch{}throw this.#i.delete(t),m}let f;try{f=await this.#a({schema_version:1,command:"commit",lease:r,compiled_bytes:E.compiled_bytes})}catch(m){throw l?.(m),await this.#e(r),this.#i.delete(t),m}let _;try{_=this.#o(f.receipts,!0)}catch(m){throw l?.(m),this.#i.delete(t),await this.#e(r),m}if(this.#i.delete(t),f.action==="NOOP"||_===null){let m=new c("COMMIT_NOT_ACCEPTED");throw l?.(m),await this.#e(r),m}if(_.action==="PUBLISH_COMPILED_MODULE")return this.#f(t,n,E.module),s?.({module:E.module,retained:!0}),await this.#e(r),{module:E.module,outcome:_.outcome,action:_.action,served_from_cache:!1,retained:!0,retried:a};if(_.action==="COMPILE_WITHOUT_CACHE")return s?.({module:E.module,retained:!1}),await this.#e(r),{module:E.module,outcome:_.outcome,action:_.action,served_from_cache:!1,retained:!1,retried:a};let D=new p(_.outcome,_.action,_.disposition,!1);if(l?.(D),await this.#e(r),_.disposition==="RETRY")return new O(_.outcome,_.action);throw D}async#I(e,i,t){let n=this.#o(i.receipts,!0);if(n===null)throw new c("EVALUATOR_PROTOCOL");if(n.disposition==="RETRY")return new O(n.outcome,n.action);if(n.action==="COMPILE_WITHOUT_CACHE")return{module:(await this.#s(e)).module,outcome:n.outcome,action:n.action,served_from_cache:!1,retained:!1,retried:t};throw new p(n.outcome,n.action,n.disposition,!1)}#o(e,i){let t=null;for(let n=0;n<e.length;n+=1){let a=v(e[n]);n===e.length-1&&(t=a),e[n].compiled_bytes_measured&&(a.action==="DROP_OPAQUE_HANDLE"||a.action==="DISCARD_COMPILED_MODULE"||a.action==="RELEASE_FAILED_COMPILE")&&(this.#C+=1,this.#A(S(e[n])))}return i?t:null}#O(e,i){let t=this.#o(e.receipts,!0);if(t===null||t.action!==i)throw new c("EVALUATOR_PROTOCOL");return t}#f(e,i,t){this.#n.set(e,t);let n=this.#r.get(i);if(n===void 0){this.#r.set(i,new Set([e]));return}n.add(e)}#A(e){let i=this.#r.get(e);if(i!==void 0){for(let t of i)this.#n.delete(t);this.#r.delete(e)}}async#e(e){if(e!==null)try{let i=await this.#a({schema_version:1,command:"release",lease:e});this.#o(i.receipts,!1)}catch(i){this.#_(i)}}async#h(){if(this.#d)throw new c("EVALUATOR_CLOSED");this.#u??=(async()=>{if((await this.#c.send({schema_version:1,command:"configure",budget:this.#y})).action!=="CONFIGURED")throw new c("EVALUATOR_PROTOCOL")})().catch(e=>{throw this.#u=null,e}),await this.#u}async#a(e){if(this.#d)throw new c("EVALUATOR_CLOSED");try{return await this.#c.send(e)}catch(i){throw i instanceof c&&i.code==="EVALUATOR_CLOSED"&&(this.#d=!0,this.#n.clear(),this.#r.clear(),this.#i.clear()),i}}};function $(o){if(o===null||typeof o!="object"||Array.isArray(o))throw new c("EVALUATOR_PROTOCOL");let e=o;if(e.schema_version!==1||typeof e.action!="string")throw new c("EVALUATOR_PROTOCOL");if(!Array.isArray(e.receipts))throw new c("EVALUATOR_PROTOCOL");if(e.lease!==null&&(!Number.isSafeInteger(e.lease)||e.lease<1))throw new c("EVALUATOR_PROTOCOL");return o}function k(o){let e=[],i="",t=null;o.readable.setEncoding?.("utf8"),o.readable.on("data",a=>{i+=typeof a=="string"?a:a.toString("utf8");let r=i.indexOf(`
|
|
2
|
-
`)
|
|
3
|
-
|
|
4
|
-
`)}catch(
|
|
1
|
+
"use strict";var j=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var De=(t,e)=>{for(var n in e)j(t,n,{get:e[n],enumerable:!0})},Ne=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ae(e))!Te.call(t,o)&&o!==n&&j(t,o,{get:()=>e[o],enumerable:!(r=be(e,o))||r.enumerable});return t};var ve=t=>Ne(j({},"__esModule",{value:!0}),t);var tt={};De(tt,{CompileCacheRejectedError:()=>v,CompileCacheRuntime:()=>ne,CompileCacheRuntimeError:()=>u,createNdjsonCompileCacheEvaluator:()=>Oe,spawnCompileCacheEvaluator:()=>et});module.exports=ve(tt);var ge=require("node:child_process");var U={schemaVersion:3,releaseTag:"godd-native-v0.2.57",expectedVersion:"godd-native 0.2.57",sourceCommit:"a51f1fad7a4f91ebee21759f4eb35002ea91b080",capabilities:["autonomy","cobol-evidence","codec-capability","compile-cache","content-generation","gateway-operations","mcp-stdio","operate","peer-summary","plan-audit","research"],handshakeProtocol:{supportedProtocolMajors:[1],minimumProtocolMinorByMajor:{"1":1}},capabilityCatalogDigest:"7fd64d8c567f76c32bb18711a8a0aa616df842da10d0e5ca4685a878fd68fb3d",routedCommands:["autonomy","codec-capability","compile-cache","content-generation","dataset-coverage","evidence-cobol","gateway-operations","godd-a-dir","learn-skill","managed-gitignore","operate","peer-summary","plan-audit","realtime-admission","realtime-admission-dev","research","shard-partition","test-evidence"],routedCommandEntryDigests:{autonomy:"9968e855a0dfbb8c861b41a9ef77c07b6bef6021e2b519098882a66c533df17f","codec-capability":"c42a0a334e7744fd47c040c2e5c09dff624eee02fbea1cd01a721f35b57520bd","compile-cache":"cd4949c86b20fa19a8ca83646424e2f2ab15a2b652c343c8b443b697c6fdc539","content-generation":"e4c5e1731fa9f3439e62a19a1d4c9cb21efdc28162731e51116a194cf6bf4b4f","dataset-coverage":"31be076baa2b47e7851adbd42d0885d3a6f902b56133ea3384991772df66a88b","evidence-cobol":"086ee7120c4db890b9e2de627fc00b2c843939b07e014553f2549ad219203f8b","gateway-operations":"97218eff67bfb58c600ee4988b3e1dcf7071fe15f0a9acdcf94fdb885e1d1a2f","godd-a-dir":"7810bf4642150849d45f6031cb4bfe7e8834c4000356d77e3f7d2f0e8f9dd1aa","learn-skill":"e8cb2f1bf1fe59cfa4ed2cee070ff753c8f2595e91f9eadf2f43d64812793f43","managed-gitignore":"487b7167c4f4d7691b105e550c1e06c71113a434258c4f8525b90a86f75db73e",operate:"2f619fe4b46c760b966bc1890f0380b048958fc70d27c79e3df38df79405170a","peer-summary":"b0f612e5b5c5f90c9a97486a5bdac22999dd21a609ccbf2e5431351a52c2d3c3","plan-audit":"9bc81d0ac70c62917cbd0d8c6b9723428c4a170e8fb48165e1fa64ced768a28c","realtime-admission":"200468566f677d5b82d1ef2d9ce76855bba5a40998a512a1539bb9dcadcd81c8","realtime-admission-dev":"cab9e64721cb7f9442797744a193a12d2aa3a5d4a71234f60173b291c19ed0a6",research:"a2b9cc8a7cf3499891f4d7fa4f4b603df2d28baf77a02397bd718224e7cfefad","shard-partition":"0f90efb80a81187e9031a3cf7779c238959ac706bf7742affe6e4a562da5d645","test-evidence":"12814a80813f56bf013729b8f01e520e94adbfc6561c607acfa952a9a56bf764"},baselineBytes:45513844,maximumAssetBytes:5e7,maximumTarballBytes:25e6,maximumUnpackedBytes:55e6,targets:{"darwin-arm64":{artifact:"godd-native-aarch64-apple-darwin",targetTriple:"aarch64-apple-darwin",bytes:9692336,sha256:"bc5d184a91763df0e01cc871fca05ba9873036c77f888a44f313763fcc013405"},"darwin-x64":{artifact:"godd-native-x86_64-apple-darwin",targetTriple:"x86_64-apple-darwin",bytes:10752400,sha256:"e7dcb70f85bf1428a673edb95c65caebbab42c96153f8b31af02f06a1790efe9"},"linux-x64":{artifact:"godd-native-x86_64-unknown-linux-musl",targetTriple:"x86_64-unknown-linux-musl",bytes:11814704,sha256:"20089cbc07284c1cae14f2e918d554a7b2aba5f8d4940628b4194790feaf60af"},"win32-x64":{artifact:"godd-native-x86_64-pc-windows-msvc.exe",targetTriple:"x86_64-pc-windows-msvc",bytes:13254144,sha256:"3720b019e07b4d0330ed577623760ef16b05e0d51f4411d82939fa6520aee5ba"}}};var G="3.7.0";var ee=require("node:crypto"),C=require("node:fs"),D=require("node:path"),de=require("node:os");var W=require("node:child_process");var F="advisory";var we=Object.freeze(["handshake","show","--json"]),Se=5e3,V=65536,Pe=64,J=Object.freeze({1:1}),T=/^[0-9a-f]{64}$/,ae=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Le=/^(?:<default>|[a-z0-9]+(?:-[a-z0-9]+)*|--[a-z0-9]+(?:-[a-z0-9]+)*|-[a-z0-9])$/,Y=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)*$/,$=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function q(){return"8137507be86afcd139b4a4b0c7412e877079236bf6d94648dbfe71982e9cf545"}var Me=Symbol("AdmittedLaunch"),K=Symbol("AuthorizedNativeLaunch");function R(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function M(t,e){return Object.keys(t).length===e.length&&e.every(r=>Object.hasOwn(t,r))}function k(t,e){return e.every(n=>Object.hasOwn(t,n))}function re(t,e){if(!Array.isArray(t)||t.length===0)return!1;let n;for(let r of t){if(typeof r!="string"||!e.test(r)||n!==void 0&&n>=r)return!1;n=r}return!0}function ke(t){if(!Array.isArray(t)||t.length===0)return!1;let e=0;for(let n of t){if(!se(n)||n===0||n<=e)return!1;e=n}return!0}function oe(t){return typeof t=="string"&&t.length>0&&!/[\u0000-\u001f\u007f]/.test(t)}function se(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function B(t){return se(t)&&t<=65535}function He(t){if(!R(t)||Object.keys(t).length===0)return!1;for(let e of Object.values(t))if(!R(e)||typeof e.targetTriple!="string"||!$.test(e.targetTriple))return!1;return!0}function xe(t,e){let n=Array.from(t,a=>a.codePointAt(0)),r=Array.from(e,a=>a.codePointAt(0)),o=Math.min(n.length,r.length);for(let a=0;a<o;a+=1)if(n[a]!==r[a])return n[a]-r[a];return n.length-r.length}function X(t,e,n,r){if(!R(t)||t.schemaVersion!==3)return null;let o=t.handshakeProtocol;if(!R(o)||!M(o,["supportedProtocolMajors","minimumProtocolMinorByMajor"]))return null;let a=o.supportedProtocolMajors,i=o.minimumProtocolMinorByMajor;if(!ke(a)||a.some(_=>!B(_))||a.some(_=>!Object.hasOwn(J,_))||!R(i))return null;let l=a.map(String),s=Object.keys(i);if(s.length!==l.length||s.some(_=>!l.includes(_)))return null;let f={};for(let _ of a){let g=i[String(_)];if(!B(g))return null;f[_]=g}let m=t.capabilities,c=t.routedCommands,d=t.routedCommandEntryDigests;if(!re(m,ae)||!re(c,/^[a-z0-9]+(?:-[a-z0-9]+)*$/)||c.includes("<default>")||!R(d))return null;let E=Object.keys(d);if(E.length!==c.length||E.some(_=>!c.includes(_)))return null;let p={};for(let _ of c){let g=d[_];if(typeof g!="string"||!T.test(g))return null;p[_]=g}if(typeof t.capabilityCatalogDigest!="string"||!T.test(t.capabilityCatalogDigest)||!T.test(r.manifestDigest??"")||!Y.test(r.packageVersion))return null;let O=t.targets;if(!He(O))return null;let A=O[`${e}-${n}`];return!A||typeof A.targetTriple!="string"||!$.test(A.targetTriple)?null:{supportedProtocolMajors:[...a],minimumProtocolMinorByMajor:f,expectedCapabilityIds:[...m],expectedTargetTriple:A.targetTriple,routedCommandNames:[...c],expectedRoutedCommandEntryDigests:p,expectedCapabilityCatalogDigest:t.capabilityCatalogDigest,packageVersion:r.packageVersion,manifestDigest:r.manifestDigest}}function Ue(t){let e=0,n=()=>{if(t[e]!=='"')return null;let o=e;for(e+=1;e<t.length&&t[e]!=='"';){if(t.charCodeAt(e)<32)return null;if(t[e]==="\\"){e+=1;let i=t[e];if(i==='"'||i==="\\"||i==="b"||i==="f"||i==="n"||i==="r"||i==="t"){e+=1;continue}if(i!=="u")return null;let l=t.slice(e+1,e+5);if(!/^[0-9a-f]{4}$/.test(l))return null;let s=Number.parseInt(l,16);if(s>31||[8,9,10,12,13].includes(s))return null;e+=5;continue}e+=1}if(e>=t.length)return null;e+=1;try{return JSON.parse(t.slice(o,e))}catch{return null}},r=(o=0)=>{if(o>Pe)return!1;let a=t[e];if(a==='"')return n()!==null;if(a==="{"){if(e+=1,t[e]==="}")return e+=1,!0;let l;for(;e<t.length;){let s=n();if(s===null||l!==void 0&&xe(l,s)>=0||t[e]!==":"||(l=s,e+=1,!r(o+1)))return!1;if(t[e]==="}")return e+=1,!0;if(t[e]!==",")return!1;e+=1}return!1}if(a==="["){if(e+=1,t[e]==="]")return e+=1,!0;for(;e<t.length;){if(!r(o+1))return!1;if(t[e]==="]")return e+=1,!0;if(t[e]!==",")return!1;e+=1}return!1}if(a==="t"&&t.slice(e,e+4)==="true")return e+=4,!0;if(a==="f"&&t.slice(e,e+5)==="false")return e+=5,!0;if(a==="n"&&t.slice(e,e+4)==="null")return e+=4,!0;let i=e;if(t[e]==="-"&&(e+=1),t[e]==="0"){if(e+=1,/[0-9]/.test(t[e]??""))return!1}else{if(!/[1-9]/.test(t[e]??""))return!1;for(e+=1;/[0-9]/.test(t[e]??"");)e+=1}return e>i&&t.slice(i,e)!=="-0"&&!/[.eE]/.test(t[e]??"")};return r()?e===t.length:!1}function z(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function ie(t,e){let n;for(let r of t){if(!e.test(r)||n!==void 0&&n>=r)return!1;n=r}return!0}function Be(t){return!R(t)||!k(t,["major","minor"])||!B(t.major)||!B(t.minor)?null:{major:t.major,minor:t.minor}}function je(t){if(t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191)return{status:"malformed"};let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return{status:"malformed"}}if(!e.endsWith(`
|
|
2
|
+
`)||e.endsWith(`
|
|
3
|
+
|
|
4
|
+
`)||e.includes("\r"))return{status:"malformed"};let n=e.slice(0,-1);if(!Ue(n))return{status:"malformed"};let r;try{r=JSON.parse(n)}catch{return{status:"malformed"}}if(!R(r))return{status:"malformed"};let o=Be(r.protocol_version);if(!o)return{status:"malformed"};if(o.major!==1)return{status:"valid",protocolVersion:o};let a=["build","capability_catalog_digest","capability_ids","protocol_version","surface_entries","surface_fingerprint","target"],i=["build","capability_catalog_digest","capability_ids","protocol_version","routed_commands","surface_entries","surface_fingerprint","surface_projection_digest","target"],l=J[o.major],s=l!==void 0&&o.minor>l,f=o.minor>=1?i:a;if(!(s?k(r,f):M(r,f)))return{status:"malformed"};let c=r.protocol_version;if(!R(c)||!(s?k(c,["major","minor"]):M(c,["major","minor"])))return{status:"malformed"};let d=r.build,E=r.target,p=r.surface_entries,O=r.capability_ids,A=r.routed_commands;return typeof r.surface_fingerprint=="string"&&T.test(r.surface_fingerprint)&&typeof r.capability_catalog_digest=="string"&&T.test(r.capability_catalog_digest)&&z(O)&&ie(O,ae)&&R(p)&&Object.keys(p).length>0&&Object.entries(p).every(([g,L])=>Le.test(g)&&typeof L=="string"&&T.test(L))&&Object.hasOwn(p,"<default>")&&R(E)&&(s?k(E,["arch","os","target_triple"]):M(E,["arch","os","target_triple"]))&&typeof E.target_triple=="string"&&$.test(E.target_triple)&&oe(E.os)&&oe(E.arch)&&R(d)&&(s?k(d,["crate_version"]):M(d,["crate_version"]))&&typeof d.crate_version=="string"&&Y.test(d.crate_version)?o.minor>=1&&(!z(A)||!ie(A,/^[a-z0-9]+(?:-[a-z0-9]+)*$/)||typeof r.surface_projection_digest!="string"||!T.test(r.surface_projection_digest))?{status:"malformed"}:o.minor>=1&&z(A)&&!A.every(g=>Object.hasOwn(p,g))?{status:"malformed"}:{status:"valid",document:r,protocolVersion:o}:{status:"malformed"}}function Ge(t){return Object.fromEntries(Object.entries(t).filter(([e])=>!/^GODD_/i.test(e)))}function ce(t){return t?t.code:void 0}function Fe(t){let e=ce(t);return e==="ENOBUFS"||e==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"}function le(t,e,n,r,o,a,i=[]){let l=e?.packageVersion??t.packageVersion,s=e?.manifestDigest??t.manifestDigest??"";return{packageVersion:Y.test(l)?l:"",manifestDigest:T.test(s)?s:"",observedProtocolVersion:a??o?.protocol_version??null,observedSurfaceFingerprint:o?.surface_fingerprint??null,observedCapabilityCatalogDigest:o?.capability_catalog_digest??null,reasonCode:r,advisories:i,digestVerifiedPath:n}}function y(t,e,n,r,o,a){return{verdict:{kind:"Rejected",receipt:le(t,e,n,r,o,a)},admittedLaunch:null}}function Ve(t,e,n,r,o=W.spawnSync,a=process.env){if(!e)return y(n,null,r,"HSHAKE_EXPECTATION_ABSENT");let i;try{i=o(t,we,{encoding:null,timeout:Se,killSignal:"SIGKILL",maxBuffer:V,windowsHide:!0,stdio:["ignore","pipe","pipe"],env:Ge(a)})}catch{return y(n,e,r,"HSHAKE_PROBE_SPAWN_FAILED")}if(ce(i.error)==="ETIMEDOUT")return y(n,e,r,"HSHAKE_PROBE_TIMEOUT");let s=i.stdout??Buffer.alloc(0),f=i.stderr??Buffer.alloc(0);if(Fe(i.error)){let b=f.length>0&&s.length<=V?"HSHAKE_DOCUMENT_MALFORMED":"HSHAKE_DOCUMENT_OVERSIZE";return y(n,e,r,b)}if(i.error)return y(n,e,r,"HSHAKE_PROBE_SPAWN_FAILED");if(i.status!==0||s.length===0)return y(n,e,r,"HSHAKE_DOCUMENT_ABSENT");if(s.length>V)return y(n,e,r,"HSHAKE_DOCUMENT_OVERSIZE");if(f.length>0)return y(n,e,r,"HSHAKE_DOCUMENT_MALFORMED");let m=je(s);if(m.status!=="valid"||!m.protocolVersion)return y(n,e,r,"HSHAKE_DOCUMENT_MALFORMED");let c=m.protocolVersion;if(!e.supportedProtocolMajors.includes(c.major))return y(n,e,r,"HSHAKE_PROTOCOL_MAJOR_UNSUPPORTED",void 0,c);let d=m.document;if(!d)return y(n,e,r,"HSHAKE_DOCUMENT_MALFORMED",void 0,c);let E=e.minimumProtocolMinorByMajor[c.major];if(E===void 0||c.minor<E)return y(n,e,r,"HSHAKE_PROTOCOL_MINOR_TOO_OLD",d,c);if(d.target.target_triple!==e.expectedTargetTriple)return y(n,e,r,"HSHAKE_TARGET_MISMATCH",d,c);let p=new Set(d.capability_ids);if(!e.expectedCapabilityIds.every(b=>p.has(b)))return y(n,e,r,"HSHAKE_CAPABILITY_MISSING",d,c);let O=new Set(d.routed_commands??[]);if(e.routedCommandNames.some(b=>!O.has(b)||d.surface_entries[b]!==e.expectedRoutedCommandEntryDigests[b]))return y(n,e,r,r?"HSHAKE_MANIFEST_SELF_INCONSISTENT":"HSHAKE_SURFACE_PROJECTION_MISMATCH",d,c);let _=[];d.capability_catalog_digest!==e.expectedCapabilityCatalogDigest&&_.push("HSHAKE_CAPABILITY_SURPLUS");let g=new Set(e.routedCommandNames);Object.keys(d.surface_entries).some(b=>b!=="<default>"&&!g.has(b))&&_.push("HSHAKE_SURFACE_SURPLUS");let L=J[c.major];return L!==void 0&&c.minor>L&&_.push("HSHAKE_PROTOCOL_MINOR_AHEAD"),{verdict:{kind:"Admitted",receipt:le(n,e,r,"HSHAKE_ADMITTED",d,c,_)},admittedLaunch:{[Me]:!0,binaryPath:t}}}function Q(t,e,n,r,o=W.spawnSync,a=process.env){if(F==="off")return{kind:"Allowed",launch:{[K]:!0,binaryPath:t},advisoryReceipt:null};let i=Ve(t,e,n,r,o,a);return i.admittedLaunch?{kind:"Allowed",launch:{[K]:!0,binaryPath:i.admittedLaunch.binaryPath},advisoryReceipt:null}:F==="advisory"?{kind:"Allowed",launch:{[K]:!0,binaryPath:t},advisoryReceipt:i.verdict.receipt}:{kind:"Blocked",receipt:i.verdict.receipt}}function Z(t){return`[GoDD MCP \u03B1] Native handshake advisory: ${JSON.stringify(t)}
|
|
5
|
+
`}var ue=U.targets;function me(t,e,n){try{let r=ue[`${e}-${n}`];return!r||(0,C.statSync)(t).size!==r.bytes?!1:(0,ee.createHash)("sha256").update((0,C.readFileSync)(t)).digest("hex")===r.sha256}catch{return!1}}function pe(t,e,n,r=ue){let o;try{let a=r[`${e}-${n}`];if(!a)return null;let i=(0,C.readFileSync)(t);if(i.length!==a.bytes||(0,ee.createHash)("sha256").update(i).digest("hex")!==a.sha256)return null;o=(0,C.mkdtempSync)((0,D.join)((0,de.tmpdir)(),"godd-native-"));let l=(0,D.join)(o,`godd-native${(0,D.extname)(t)}`);return(0,C.writeFileSync)(l,i,{mode:448}),{path:l,cleanup:()=>{try{(0,C.rmSync)(o,{recursive:!0,force:!0})}catch{}}}}catch{if(o)try{(0,C.rmSync)(o,{recursive:!0,force:!0})}catch{}return null}}var fe=require("node:crypto"),Ke=/^sha256:[0-9a-f]{64}$/u,ze=1024,We=Object.freeze({owner:"nextjs-server",clock:"monotonic-milliseconds",trigger:"timer-and-after-lifecycle-event"});function h(t,e,n,r=0){return Object.freeze({action:t,disposition:e,max_retries:r,on_retry_exhausted:r===1?"REJECT":null,reason:n})}var I=Object.freeze({CACHE_HIT:h("USE_CACHED_MODULE","CONTINUE",null),CACHE_MISS_COMPILED:h("PUBLISH_COMPILED_MODULE","CONTINUE",null),SINGLE_FLIGHT_JOINED:h("WAIT_FOR_SINGLE_FLIGHT","CONTINUE",null),TOO_LARGE_FOR_CACHE:h("COMPILE_WITHOUT_CACHE","CONTINUE","ENTRY_LIMIT_EXCEEDED"),BUDGET_OVERFLOW:h("REJECT_CACHE_OPERATION","REJECT","ARITHMETIC_OVERFLOW"),BUDGET_UNRECLAIMABLE:h("RETRY_AFTER_RECONCILE","RETRY","RECLAIMABLE_ENTRIES_INSUFFICIENT",1),BUDGET_EVICTED_LRU:h("DROP_OPAQUE_HANDLE","CONTINUE","LRU_PRESSURE_EVICTION"),SUPERSEDED_BY_NEW_SOURCE:h("DROP_OPAQUE_HANDLE","CONTINUE","SOURCE_GENERATION_SUPERSEDED"),DECK_TOMBSTONED:h("DROP_OPAQUE_HANDLE","CONTINUE","DECK_LIFECYCLE_ENDED"),STALE_GENERATION_REJECTED:h("DISCARD_COMPILED_MODULE","CONTINUE","GENERATION_FENCE_CHANGED"),PREVIEW_LEASE_EXPIRED:h("DROP_OPAQUE_HANDLE","CONTINUE","PREVIEW_LEASE_ENDED"),AGE_EXPIRED:h("DROP_OPAQUE_HANDLE","CONTINUE","MAXIMUM_AGE_EXCEEDED"),IDLE_EXPIRED:h("DROP_OPAQUE_HANDLE","CONTINUE","MAXIMUM_IDLE_EXCEEDED"),RESERVATION_EXPIRED:h("DISCARD_COMPILED_MODULE","CONTINUE","RESERVATION_DEADLINE_EXCEEDED"),COMPILE_FAILED_ROLLED_BACK:h("RELEASE_FAILED_COMPILE","CONTINUE","COMPILE_DID_NOT_COMPLETE"),RECONCILE_CLOCK_REGRESSION:h("REJECT_CACHE_OPERATION","REJECT","RECONCILE_CLOCK_REGRESSED")});function w(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object`);return t}function S(t,e,n){let r=Object.keys(t).sort(),o=[...e].sort();if(r.length!==o.length||r.some((a,i)=>a!==o[i]))throw new TypeError(`${n} has an invalid field set`)}function N(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function H(t){return N(t)&&t>0}function x(t){return typeof t=="string"&&Ke.test(t)}function _e(t){return t==="unversioned"||x(t)}function te(t){return typeof t=="string"&&t.length>0&&Buffer.byteLength(t,"utf8")<=ze&&!new RegExp("\\p{Cc}","u").test(t)}function Je(t){let e=w(t,"compile cache manifest");if(S(e,["workspace_id","deck_id","deck_generation","slide_filename","canonical_source_digest","mdx_policy_generation","compiler_generation","runtime_abi"],"compile cache manifest"),!te(e.workspace_id)||!te(e.deck_id)||!te(e.slide_filename)||!H(e.deck_generation)||!x(e.canonical_source_digest)||!_e(e.mdx_policy_generation)||!x(e.compiler_generation)||e.runtime_abi!=="amaroad")throw new TypeError("compile cache manifest is invalid");return e}function Ye(t){let e=w(t,"compile cache register request");if(S(e,["schema_version","operation","manifest","source_bytes","declared_max_compiled_bytes","now_ms"],"compile cache register request"),Je(e.manifest),e.schema_version!==1||e.operation!=="register"||!N(e.source_bytes)||!H(e.declared_max_compiled_bytes)||!N(e.now_ms))throw new TypeError("compile cache register request is invalid");return e}function Ee(t){let e=w(t,"compile cache project input");S(e,["schema_version","manifest","canonical_source","declared_max_compiled_bytes","now_ms"],"compile cache project input");let n=w(e.manifest,"compile cache project manifest");if(S(n,["workspace_id","deck_id","deck_generation","slide_filename","mdx_policy_generation","compiler_generation","runtime_abi"],"compile cache project manifest"),typeof e.canonical_source!="string")throw new TypeError("compile cache canonical source is invalid");let r=Buffer.byteLength(e.canonical_source,"utf8"),o={schema_version:1,operation:"register",manifest:{...n,canonical_source_digest:`sha256:${(0,fe.createHash)("sha256").update(e.canonical_source,"utf8").digest("hex")}`},source_bytes:r,declared_max_compiled_bytes:e.declared_max_compiled_bytes,now_ms:e.now_ms};return Ye(o)}function he(t){let e=w(t,"compile cache time budget");if(S(e,["age_ms","idle_ms","reservation_ttl_ms"],"compile cache time budget"),!H(e.age_ms)||!H(e.idle_ms)||!H(e.reservation_ttl_ms))throw new TypeError("compile cache time budget is invalid");return Object.freeze({...We,interval_ms:Math.min(e.age_ms,e.idle_ms,e.reservation_ttl_ms)})}function $e(t){if(typeof t!="string"||!Object.hasOwn(I,t))throw new TypeError("compile cache receipt outcome is unsupported");let e=t;return[e,I[e]]}function qe(t){let e=w(t,"compile cache receipt");S(e,["schema_version","canonical_source_digest","deck_generation","mdx_policy_generation","compiler_generation","key_bytes","source_bytes","compiled_bytes","compiled_bytes_measured","outcome","reason"],"compile cache receipt");let[,n]=$e(e.outcome);if(e.schema_version!==1||!x(e.canonical_source_digest)||!N(e.deck_generation)||!_e(e.mdx_policy_generation)||!x(e.compiler_generation)||!N(e.key_bytes)||!N(e.source_bytes)||!N(e.compiled_bytes)||typeof e.compiled_bytes_measured!="boolean")throw new TypeError("compile cache receipt is invalid");if(e.reason!==n.reason)throw new TypeError("compile cache receipt reason does not match outcome");return e}function ye(t){let e=qe(t);return Object.freeze({action:I[e.outcome].action,disposition:I[e.outcome].disposition,max_retries:I[e.outcome].max_retries,on_retry_exhausted:I[e.outcome].on_retry_exhausted,outcome:e.outcome})}var u=class extends Error{code;handshakeReasonCode;constructor(e,n){super(e),this.name="CompileCacheRuntimeError",this.code=e,this.handshakeReasonCode=n??null}},v=class extends Error{outcome;action;disposition;retriesExhausted;constructor(e,n,r,o){super(e),this.name="CompileCacheRejectedError",this.outcome=e,this.action=n,this.disposition=r,this.retriesExhausted=o}},P=class{outcome;action;constructor(e,n){this.outcome=e,this.action=n}},Re="";function Xe(t){return[t.workspace_id,t.deck_id,String(t.deck_generation),t.slide_filename,t.canonical_source_digest,t.mdx_policy_generation,t.compiler_generation,t.runtime_abi].join(Re)}function Ce(t){return[t.canonical_source_digest,String(t.deck_generation),t.mdx_policy_generation,t.compiler_generation].join(Re)}var ne=class{#s;#y;#c;#u;#m;#o=new Map;#i=new Map;#n=new Map;#p;#r=null;#l=!1;#f=0;#_=null;#d=!1;constructor(e){this.#s=e.evaluator,this.#y=e.budget,this.#c=e.compile,this.#u=e.now,this.#m=e.onReconcileError??(()=>{}),this.#p=he({age_ms:e.budget.age_ms,idle_ms:e.budget.idle_ms,reservation_ttl_ms:e.budget.reservation_ttl_ms})}get reconcilePolicy(){return this.#p}get retainedModuleCount(){return this.#o.size}get reconcileTimerStarted(){return this.#r!==null}startReconcileTimer(){if(this.#r!==null)throw new u("RECONCILE_TIMER_ALREADY_OWNED");this.#r=setInterval(()=>{this.#l||(this.#l=!0,this.reconcile().catch(e=>{this.#m(e)}).finally(()=>{this.#l=!1}))},this.#p.interval_ms),this.#r.unref?.()}stopReconcileTimer(){if(this.#r===null)throw new u("RECONCILE_TIMER_NOT_OWNED");clearInterval(this.#r),this.#r=null,this.#l=!1}async close(){this.#r!==null&&this.stopReconcileTimer(),this.#d=!0,this.#o.clear(),this.#i.clear(),this.#n.clear(),await this.#s.close()}async compile(e){await this.#h();let n=await this.#C(e,!1);if(!(n instanceof P))return n;await this.reconcile();let r=await this.#C(e,!0);if(r instanceof P)throw new v(r.outcome,r.action,"RETRY",!0);return r}async reconcile(){await this.#h();let e=await this.#a({schema_version:1,command:"reconcile",now_ms:this.#u()}),n=e.action==="REJECTED",r=this.#t(e.receipts,n);if(n)throw r===null?new u("EVALUATOR_PROTOCOL"):new v(r.outcome,r.action,r.disposition,!1);return e.receipts}async onDeckRemoved(e,n){await this.#E({schema_version:1,command:"tombstone_deck",workspace_id:e,deck_id:n})}async onPreviewLeaseExpired(e,n){await this.#E({schema_version:1,command:"expire_preview_lease",workspace_id:e,deck_id:n})}async onGenerationUpdated(e){await this.#E({schema_version:1,command:"fence_generations",...e})}async#E(e){await this.#h();let n=await this.#a(e);this.#t(n.receipts,!1),await this.reconcile()}async#C(e,n){let r=Ee({schema_version:1,manifest:e.manifest,canonical_source:e.canonical_source,declared_max_compiled_bytes:e.declared_max_compiled_bytes,now_ms:this.#u()}),{operation:o,...a}=r,i=await this.#a({command:o,...a}),l=Xe(r.manifest),s=Ce(r.manifest);switch(i.action){case"HIT":return this.#O(e,i,l,s,n);case"JOINED":return this.#b(i,l,n);case"COMPILE_REQUESTED":return this.#A(e,i,l,s,n);case"REJECTED":return this.#T(e,i,n);default:try{this.#t(i.receipts,!1)}finally{await this.#e(i.lease)}throw new u("EVALUATOR_PROTOCOL")}}async#O(e,n,r,o,a){try{let i=this.#g(n,"USE_CACHED_MODULE"),l=this.#o.get(r),s=!0;if(l===void 0){let f=this.#f,m=await this.#c(e);l=m.module,s=!1;let c=n.receipts[n.receipts.length-1];if(m.compiled_bytes!==c.compiled_bytes||this.#f!==f)return{module:l,outcome:i.outcome,action:i.action,served_from_cache:!1,retained:!1,retried:a};this.#R(r,o,l)}return{module:l,outcome:i.outcome,action:i.action,served_from_cache:s,retained:!0,retried:a}}finally{await this.#e(n.lease)}}async#b(e,n,r){try{let o=this.#g(e,"WAIT_FOR_SINGLE_FLIGHT"),a=this.#n.get(n);if(a===void 0)throw new u("SINGLE_FLIGHT_MISSING");let i=await a;return{module:i.module,outcome:o.outcome,action:o.action,served_from_cache:!0,retained:i.retained,retried:r}}finally{await this.#e(e.lease)}}async#A(e,n,r,o,a){try{this.#t(n.receipts,!1)}catch(p){throw await this.#e(n.lease),p}if(n.compile_owner!==!0||n.lease===null)throw await this.#e(n.lease),new u("EVALUATOR_PROTOCOL");let i=n.lease,l,s,f=new Promise((p,O)=>{l=p,s=O});f.catch(()=>{}),this.#n.set(r,f);let m;try{m=await this.#c(e)}catch(p){s?.(p);try{let O=await this.#a({schema_version:1,command:"rollback",lease:i});this.#t(O.receipts,!1)}catch{}throw this.#n.delete(r),p}let c;try{c=await this.#a({schema_version:1,command:"commit",lease:i,compiled_bytes:m.compiled_bytes})}catch(p){throw s?.(p),await this.#e(i),this.#n.delete(r),p}let d;try{d=this.#t(c.receipts,!0)}catch(p){throw s?.(p),this.#n.delete(r),await this.#e(i),p}if(this.#n.delete(r),c.action==="NOOP"||d===null){let p=new u("COMMIT_NOT_ACCEPTED");throw s?.(p),await this.#e(i),p}if(d.action==="PUBLISH_COMPILED_MODULE")return this.#R(r,o,m.module),l?.({module:m.module,retained:!0}),await this.#e(i),{module:m.module,outcome:d.outcome,action:d.action,served_from_cache:!1,retained:!0,retried:a};if(d.action==="COMPILE_WITHOUT_CACHE")return l?.({module:m.module,retained:!1}),await this.#e(i),{module:m.module,outcome:d.outcome,action:d.action,served_from_cache:!1,retained:!1,retried:a};let E=new v(d.outcome,d.action,d.disposition,!1);if(s?.(E),await this.#e(i),d.disposition==="RETRY")return new P(d.outcome,d.action);throw E}async#T(e,n,r){let o=this.#t(n.receipts,!0);if(o===null)throw new u("EVALUATOR_PROTOCOL");if(o.disposition==="RETRY")return new P(o.outcome,o.action);if(o.action==="COMPILE_WITHOUT_CACHE")return{module:(await this.#c(e)).module,outcome:o.outcome,action:o.action,served_from_cache:!1,retained:!1,retried:r};throw new v(o.outcome,o.action,o.disposition,!1)}#t(e,n){let r=null;for(let o=0;o<e.length;o+=1){let a=ye(e[o]);o===e.length-1&&(r=a),e[o].compiled_bytes_measured&&(a.action==="DROP_OPAQUE_HANDLE"||a.action==="DISCARD_COMPILED_MODULE"||a.action==="RELEASE_FAILED_COMPILE")&&(this.#f+=1,this.#D(Ce(e[o])))}return n?r:null}#g(e,n){let r=this.#t(e.receipts,!0);if(r===null||r.action!==n)throw new u("EVALUATOR_PROTOCOL");return r}#R(e,n,r){this.#o.set(e,r);let o=this.#i.get(n);if(o===void 0){this.#i.set(n,new Set([e]));return}o.add(e)}#D(e){let n=this.#i.get(e);if(n!==void 0){for(let r of n)this.#o.delete(r);this.#i.delete(e)}}async#e(e){if(e!==null)try{let n=await this.#a({schema_version:1,command:"release",lease:e});this.#t(n.receipts,!1)}catch(n){this.#m(n)}}async#h(){if(this.#d)throw new u("EVALUATOR_CLOSED");this.#_??=(async()=>{if((await this.#s.send({schema_version:1,command:"configure",budget:this.#y})).action!=="CONFIGURED")throw new u("EVALUATOR_PROTOCOL")})().catch(e=>{throw this.#_=null,e}),await this.#_}async#a(e){if(this.#d)throw new u("EVALUATOR_CLOSED");try{return await this.#s.send(e)}catch(n){throw n instanceof u&&n.code==="EVALUATOR_CLOSED"&&(this.#d=!0,this.#o.clear(),this.#i.clear(),this.#n.clear()),n}}};function Qe(t){if(t===null||typeof t!="object"||Array.isArray(t))throw new u("EVALUATOR_PROTOCOL");let e=t;if(e.schema_version!==1||typeof e.action!="string")throw new u("EVALUATOR_PROTOCOL");if(!Array.isArray(e.receipts))throw new u("EVALUATOR_PROTOCOL");if(e.lease!==null&&(!Number.isSafeInteger(e.lease)||e.lease<1))throw new u("EVALUATOR_PROTOCOL");return t}function Oe(t){let e=[],n="",r=null;t.readable.setEncoding?.("utf8"),t.readable.on("data",a=>{n+=typeof a=="string"?a:a.toString("utf8");let i=n.indexOf(`
|
|
6
|
+
`);for(;i>=0;){let l=n.slice(0,i).replace(/\r$/u,"");if(n=n.slice(i+1),i=n.indexOf(`
|
|
7
|
+
`),l.length===0)continue;let s=e.shift();if(s===void 0){r=new u("EVALUATOR_PROTOCOL");continue}try{s.resolve(Qe(JSON.parse(l)))}catch(f){s.reject(f)}}});let o=a=>{r=a;for(let i of e.splice(0,e.length))i.reject(a)};return t.readable.on("end",()=>{o(new u("EVALUATOR_CLOSED"))}),t.readable.on("close",()=>{o(new u("EVALUATOR_CLOSED"))}),t.readable.on("error",()=>{o(new u("EVALUATOR_PROTOCOL"))}),{async send(a){if(r!==null)throw r;return new Promise((i,l)=>{let s={resolve:i,reject:l};e.push(s);try{t.writable.write(`${JSON.stringify(a)}
|
|
8
|
+
`)}catch(f){let m=e.indexOf(s);m>=0&&e.splice(m,1),l(f)}})},async close(){o(new u("EVALUATOR_CLOSED")),await t.close()}}}function Ze(t,e,n){try{return(0,ge.spawn)(t.binaryPath,[...e],{stdio:["pipe","pipe","ignore"],windowsHide:!0})}catch(r){throw n(),r}}function et(t){if(t.args!==void 0&&(!Array.isArray(t.args)||t.args.length!==2||t.args[0]!=="compile-cache"||t.args[1]!=="session"))throw new u("EVALUATOR_PROTOCOL");let e=q(),n={packageVersion:G,...e===void 0?{}:{manifestDigest:e}},r=X(U,process.platform,process.arch,n),o=process.platform,a=process.arch,i=!1;try{i=me(t.command,o,a)}catch{i=!1}if(!i)throw new u("NATIVE_INTEGRITY_REJECTED");let l=pe(t.command,o,a);if(!l)throw new u("NATIVE_INTEGRITY_REJECTED");let s=!1,f=()=>{s||(s=!0,l.cleanup())},m;try{m=Q(l.path,r,n,!0)}catch(E){throw f(),E}if(m.kind==="Blocked")throw f(),new u("NATIVE_HANDSHAKE_REJECTED",m.receipt.reasonCode);m.advisoryReceipt&&process.stderr.write(Z(m.advisoryReceipt));let c=Ze(m.launch,t.args??["compile-cache","session"],f);if(c.once("close",f),c.once("error",f),c.stdin===null||c.stdout===null)throw c.stdin?.destroy(),c.stdout?.destroy(),c.kill(),f(),new u("EVALUATOR_PROTOCOL");let d=()=>{c.stdout?.destroy()};return c.on("error",d),c.stdin.on("error",d),Oe({writable:c.stdin,readable:c.stdout,close:()=>{c.stdin?.end(),c.kill()}})}0&&(module.exports={CompileCacheRejectedError,CompileCacheRuntime,CompileCacheRuntimeError,createNdjsonCompileCacheEvaluator,spawnCompileCacheEvaluator});
|
|
@@ -40,10 +40,11 @@ export interface CompileCacheEvaluator {
|
|
|
40
40
|
send(command: Readonly<Record<string, unknown>>): Promise<CompileCacheEvaluatorResponse>;
|
|
41
41
|
close(): Promise<void>;
|
|
42
42
|
}
|
|
43
|
-
export type CompileCacheRuntimeErrorCode = "EVALUATOR_PROTOCOL" | "EVALUATOR_CLOSED" | "RECONCILE_TIMER_ALREADY_OWNED" | "RECONCILE_TIMER_NOT_OWNED" | "SINGLE_FLIGHT_MISSING" | "COMMIT_NOT_ACCEPTED";
|
|
43
|
+
export type CompileCacheRuntimeErrorCode = "EVALUATOR_PROTOCOL" | "EVALUATOR_CLOSED" | "RECONCILE_TIMER_ALREADY_OWNED" | "RECONCILE_TIMER_NOT_OWNED" | "SINGLE_FLIGHT_MISSING" | "COMMIT_NOT_ACCEPTED" | "NATIVE_INTEGRITY_REJECTED" | "NATIVE_HANDSHAKE_REJECTED";
|
|
44
44
|
export declare class CompileCacheRuntimeError extends Error {
|
|
45
45
|
readonly code: CompileCacheRuntimeErrorCode;
|
|
46
|
-
|
|
46
|
+
readonly handshakeReasonCode: string | null;
|
|
47
|
+
constructor(code: CompileCacheRuntimeErrorCode, handshakeReasonCode?: string);
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* A cache operation the contract refuses to continue past. Carries the outcome
|