@autodevjapan/godd-mcp-alpha 3.6.0 → 3.8.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/README.md +18 -0
- 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 +225 -220
- package/docs/adapter-contracts.md +15 -0
- package/native-assets.json +66 -13
- package/package.json +4 -4
- package/scripts/native-assets.js +71 -8
package/README.md
CHANGED
|
@@ -46,6 +46,12 @@ At server startup, GoDD checks whether the Docker daemon responds. On Windows an
|
|
|
46
46
|
|
|
47
47
|
**Breaking Registry change (#2986):** responses must declare a content generation. `CLIENT_GENERATION_MISSING` means the server migration is incomplete; ask the Registry operator to finish it. `CLIENT_GENERATION_MALFORMED` means the generation metadata is invalid; `CLIENT_GENERATION_SPLIT` means a response mixes generations. These errors stop delivery. `GENERATION_DIGEST_ABSENT` is a separate, nonfatal diagnostic for delivery from the last-known-good cache. Failed MCP prompt requests now return a protocol error, and are not counted as usage.
|
|
48
48
|
|
|
49
|
+
### Optional compatibility reporting with anonymous aggregates
|
|
50
|
+
|
|
51
|
+
**Prepared, currently disabled:** this release sends nothing even with consent. A separate reviewed release will enable reporting only after the public route, operational-log disclosure and settings, privacy policy, and new native artifacts are verified. The following describes that future enabled mode.
|
|
52
|
+
|
|
53
|
+
Reporting is off unless you set `GODD_NATIVE_HANDSHAKE_REPORTING=railway-aggregate-v2` after reading the [privacy policy](https://getgodd.dev/legal/privacy). The [version 2 reporting policy](https://native-handshake-diagnostics-production.up.railway.app/legal/native-handshake-reporting-v2) discloses Railway operational logging of IP, User-Agent, URL and request metadata; the transport is not anonymous. Old anonymous-v1 consent is not reused. This release keeps delivery disabled until the public route and new native artifacts are verified. On a startup compatibility rejection, GoDD sends only its reason code, the stable npm version, and the OS family to a fixed HTTPS endpoint, once, with at most 1.5 seconds waiting for the reporting subprocess, plus binary preparation and cleanup. No license, identity, path, digest, or command is sent. The server keeps daily counts for 30 UTC days; production collection requires verified dedicated ingress and disclosure. Counts are reports from volunteers, not user counts or a rejection rate. Unset the variable and restart GoDD to withdraw consent. Individual reports cannot be identified for deletion. Reporting failures never change startup behavior.
|
|
54
|
+
|
|
49
55
|
### Everything else
|
|
50
56
|
|
|
51
57
|
The full tool list, CLI reference, and troubleshooting live on the **[documentation site](https://www.getgodd.dev/en/docs)**.
|
|
@@ -109,6 +115,12 @@ MCP サーバー起動時に Docker daemon の応答を確認します。Windows
|
|
|
109
115
|
|
|
110
116
|
**Registry の破壊的変更(#2986):** 応答の配信世代情報が必須になります。`CLIENT_GENERATION_MISSING` が出た場合は Registry 管理者にサーバー移行の完了を依頼してください。`CLIENT_GENERATION_MALFORMED` は世代情報の不正、`CLIENT_GENERATION_SPLIT` は応答内の世代混在を示し、いずれも配信を停止します。`GENERATION_DIGEST_ABSENT` は last-known-good キャッシュから配信した場合の非fatal診断です。失敗した MCP プロンプト要求はプロトコルエラーとなり、usage に計上しません。
|
|
111
117
|
|
|
118
|
+
### 起動時の互換検査を任意で報告し匿名集計する
|
|
119
|
+
|
|
120
|
+
**この版では準備済み・送信停止中です。** 同意を設定しても通信しません。公開経路、運用ログの告知と実設定、追加ポリシー、新しい配布物を検証した後、別の版で有効にします。以下は有効化後の参加方法です。
|
|
121
|
+
|
|
122
|
+
送信は初期状態で無効です。[プライバシーポリシー](https://getgodd.dev/legal/privacy)を読み、`GODD_NATIVE_HANDSHAKE_REPORTING=railway-aggregate-v2` を設定した利用者だけが参加します。互換検査が拒否した場合、理由コード・npmの正式製品版・OSの種類だけを固定HTTPS宛先へ1回送ります。報告用の子プロセスを待つ時間は最大1.5秒です。配布バイナリの再検証と後片付けの時間は別にかかります。ライセンス・識別子・パス・digest・コマンドは送信しません。サーバーは日別の件数を30 UTC日保存し、公開経路と新しい配布物の検証が終わるまで送信は停止しています。[追加ポリシー第2版](https://native-handshake-diagnostics-production.up.railway.app/legal/native-handshake-reporting-v2)のとおり、RailwayはIP・User-Agent・URL等を運用ログに記録します。通信経路全体が匿名とは説明しません。旧anonymous-v1の同意は流用しません。件数は任意参加者の報告回数で、利用者数や拒否率ではありません。撤回は変数を削除してGoDDを再起動してください。識別子がないため個別報告の検索・削除はできません。報告失敗は起動結果に影響しません。
|
|
123
|
+
|
|
112
124
|
### その他
|
|
113
125
|
|
|
114
126
|
ツール一覧・CLI リファレンス・トラブルシューティングは **[ドキュメントサイト](https://www.getgodd.dev/docs)** にまとまっています。
|
|
@@ -170,6 +182,12 @@ Node.js 22+ · MCP-клиент (Cursor / Claude Code / Codex / Kimi CLI / Antig
|
|
|
170
182
|
|
|
171
183
|
**Несовместимое изменение Registry (#2986):** ответ должен содержать данные о поколении контента. При `CLIENT_GENERATION_MISSING` попросите оператора Registry завершить миграцию. `CLIENT_GENERATION_MALFORMED` означает некорректные данные, `CLIENT_GENERATION_SPLIT` — смешанные поколения; доставка останавливается. `GENERATION_DIGEST_ABSENT` — отдельная нефатальная диагностика доставки из последнего проверенного кеша. Неудачные MCP-запросы промптов возвращают ошибку протокола и не учитываются как использование.
|
|
172
184
|
|
|
185
|
+
### Добровольные отчёты о совместимости с анонимными агрегатами
|
|
186
|
+
|
|
187
|
+
**Механизм подготовлен, но выключен в этой версии:** даже при согласии данные не передаются. Отправка будет включена отдельной проверенной версией после проверки публичного маршрута, раскрытия и настроек служебных журналов, дополнительной политики и новых нативных артефактов. Ниже описан будущий включённый режим.
|
|
188
|
+
|
|
189
|
+
Отправка выключена, пока вы не прочтёте [политику конфиденциальности](https://getgodd.dev/legal/privacy) и не зададите `GODD_NATIVE_HANDSHAKE_REPORTING=railway-aggregate-v2`. При отказе проверки запуска GoDD один раз отправляет только код причины, стабильную версию npm и семейство ОС на фиксированный HTTPS-адрес. Ожидание процесса отправки — не более 1,5 секунды; подготовка и очистка проверенного бинарного файла требуют дополнительного времени. Лицензия, идентификаторы, пути, хеши и команды не передаются. Сервер хранит дневные счётчики 30 дней UTC. [Дополнительная политика версии 2](https://native-handshake-diagnostics-production.up.railway.app/legal/native-handshake-reporting-v2) раскрывает запись IP, User-Agent, URL и метаданных в служебные журналы Railway; транспорт не является анонимным. Старое согласие anonymous-v1 не используется. В этой версии отправка отключена до проверки публичного маршрута и новых нативных артефактов. Это число добровольных отчётов, а не пользователей или доля отказов. Для отзыва согласия удалите переменную и перезапустите GoDD. Найти и удалить отдельный отчёт невозможно без идентификаторов. Ошибка отправки не меняет результат запуска.
|
|
190
|
+
|
|
173
191
|
### Остальное
|
|
174
192
|
|
|
175
193
|
Полный список инструментов, справочник CLI и устранение неполадок — на **[сайте документации](https://www.getgodd.dev/ru/docs)**.
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
edc8b4ddf2413cd781e46a6f28351f86846a0d70c54be7c5878369b6daa289a9
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4554c598d0502a6c59123d67a684e935b6c28b97975cb9d6cccc617e52e05f4f
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a9f4de4e9277a0d9a6de6da6354dbfebf33e55236a36dd346fb0f528b1ac1573
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
20047d950aa4c37a4b1a2b90435f98f86d66819ed0245977cbdab92c69f760fa
|
|
@@ -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 B=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var ve=(t,e)=>{for(var r in e)B(t,r,{get:e[r],enumerable:!0})},Ie=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ne(e))!De.call(t,o)&&o!==r&&B(t,o,{get:()=>e[o],enumerable:!(n=be(e,o))||n.enumerable});return t};var we=t=>Ie(B({},"__esModule",{value:!0}),t);var at={};ve(at,{CompileCacheRejectedError:()=>v,CompileCacheRuntime:()=>oe,CompileCacheRuntimeError:()=>p,createNdjsonCompileCacheEvaluator:()=>Te,spawnCompileCacheEvaluator:()=>it});module.exports=we(at);var Oe=require("node:child_process");var U={schemaVersion:3,releaseTag:"godd-native-v0.2.59",expectedVersion:"godd-native 0.2.59",sourceCommit:"43c093416bd9830d683750c6ce05b016813435e3",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:45518964,maximumAssetBytes:5e7,maximumTarballBytes:25e6,maximumUnpackedBytes:55e6,targets:{"darwin-arm64":{artifact:"godd-native-aarch64-apple-darwin",targetTriple:"aarch64-apple-darwin",bytes:9692336,sha256:"edc8b4ddf2413cd781e46a6f28351f86846a0d70c54be7c5878369b6daa289a9"},"darwin-x64":{artifact:"godd-native-x86_64-apple-darwin",targetTriple:"x86_64-apple-darwin",bytes:10752400,sha256:"4554c598d0502a6c59123d67a684e935b6c28b97975cb9d6cccc617e52e05f4f"},"linux-x64":{artifact:"godd-native-x86_64-unknown-linux-musl",targetTriple:"x86_64-unknown-linux-musl",bytes:11814704,sha256:"20047d950aa4c37a4b1a2b90435f98f86d66819ed0245977cbdab92c69f760fa"},"win32-x64":{artifact:"godd-native-x86_64-pc-windows-msvc.exe",targetTriple:"x86_64-pc-windows-msvc",bytes:13259264,sha256:"a9f4de4e9277a0d9a6de6da6354dbfebf33e55236a36dd346fb0f528b1ac1573"}}};var j="3.8.0";var ee=require("node:crypto"),h=require("node:fs"),b=require("node:path"),pe=require("node:os"),me=require("node:child_process");var W=require("node:child_process");var V="advisory";var Pe=Object.freeze(["handshake","show","--json"]),Le=5e3,K=65536,Me=64,J=Object.freeze({1:1}),N=/^[0-9a-f]{64}$/,ce=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,ke=/^(?:<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"3368c9ab0a65d72b70b26d596362f7d54bc755670022b264b27af0c7c546c160"}var He=Symbol("AdmittedLaunch"),F=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(n=>Object.hasOwn(t,n))}function k(t,e){return e.every(r=>Object.hasOwn(t,r))}function ie(t,e){if(!Array.isArray(t)||t.length===0)return!1;let r;for(let n of t){if(typeof n!="string"||!e.test(n)||r!==void 0&&r>=n)return!1;r=n}return!0}function xe(t){if(!Array.isArray(t)||t.length===0)return!1;let e=0;for(let r of t){if(!le(r)||r===0||r<=e)return!1;e=r}return!0}function ae(t){return typeof t=="string"&&t.length>0&&!/[\u0000-\u001f\u007f]/.test(t)}function le(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function G(t){return le(t)&&t<=65535}function Ue(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 Ge(t,e){let r=Array.from(t,a=>a.codePointAt(0)),n=Array.from(e,a=>a.codePointAt(0)),o=Math.min(r.length,n.length);for(let a=0;a<o;a+=1)if(r[a]!==n[a])return r[a]-n[a];return r.length-n.length}function X(t,e,r,n){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(!xe(a)||a.some(E=>!G(E))||a.some(E=>!Object.hasOwn(J,E))||!R(i))return null;let c=a.map(String),s=Object.keys(i);if(s.length!==c.length||s.some(E=>!c.includes(E)))return null;let _={};for(let E of a){let g=i[String(E)];if(!G(g))return null;_[E]=g}let u=t.capabilities,l=t.routedCommands,d=t.routedCommandEntryDigests;if(!ie(u,ce)||!ie(l,/^[a-z0-9]+(?:-[a-z0-9]+)*$/)||l.includes("<default>")||!R(d))return null;let f=Object.keys(d);if(f.length!==l.length||f.some(E=>!l.includes(E)))return null;let m={};for(let E of l){let g=d[E];if(typeof g!="string"||!N.test(g))return null;m[E]=g}if(typeof t.capabilityCatalogDigest!="string"||!N.test(t.capabilityCatalogDigest)||!N.test(n.manifestDigest??"")||!Y.test(n.packageVersion))return null;let O=t.targets;if(!Ue(O))return null;let T=O[`${e}-${r}`];return!T||typeof T.targetTriple!="string"||!$.test(T.targetTriple)?null:{supportedProtocolMajors:[...a],minimumProtocolMinorByMajor:_,expectedCapabilityIds:[...u],expectedTargetTriple:T.targetTriple,routedCommandNames:[...l],expectedRoutedCommandEntryDigests:m,expectedCapabilityCatalogDigest:t.capabilityCatalogDigest,packageVersion:n.packageVersion,manifestDigest:n.manifestDigest}}function Be(t){let e=0,r=()=>{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 c=t.slice(e+1,e+5);if(!/^[0-9a-f]{4}$/.test(c))return null;let s=Number.parseInt(c,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}},n=(o=0)=>{if(o>Me)return!1;let a=t[e];if(a==='"')return r()!==null;if(a==="{"){if(e+=1,t[e]==="}")return e+=1,!0;let c;for(;e<t.length;){let s=r();if(s===null||c!==void 0&&Ge(c,s)>=0||t[e]!==":"||(c=s,e+=1,!n(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(!n(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 n()?e===t.length:!1}function z(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function se(t,e){let r;for(let n of t){if(!e.test(n)||r!==void 0&&r>=n)return!1;r=n}return!0}function je(t){return!R(t)||!k(t,["major","minor"])||!G(t.major)||!G(t.minor)?null:{major:t.major,minor:t.minor}}function Ve(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 r=e.slice(0,-1);if(!Be(r))return{status:"malformed"};let n;try{n=JSON.parse(r)}catch{return{status:"malformed"}}if(!R(n))return{status:"malformed"};let o=je(n.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"],c=J[o.major],s=c!==void 0&&o.minor>c,_=o.minor>=1?i:a;if(!(s?k(n,_):M(n,_)))return{status:"malformed"};let l=n.protocol_version;if(!R(l)||!(s?k(l,["major","minor"]):M(l,["major","minor"])))return{status:"malformed"};let d=n.build,f=n.target,m=n.surface_entries,O=n.capability_ids,T=n.routed_commands;return typeof n.surface_fingerprint=="string"&&N.test(n.surface_fingerprint)&&typeof n.capability_catalog_digest=="string"&&N.test(n.capability_catalog_digest)&&z(O)&&se(O,ce)&&R(m)&&Object.keys(m).length>0&&Object.entries(m).every(([g,L])=>ke.test(g)&&typeof L=="string"&&N.test(L))&&Object.hasOwn(m,"<default>")&&R(f)&&(s?k(f,["arch","os","target_triple"]):M(f,["arch","os","target_triple"]))&&typeof f.target_triple=="string"&&$.test(f.target_triple)&&ae(f.os)&&ae(f.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(T)||!se(T,/^[a-z0-9]+(?:-[a-z0-9]+)*$/)||typeof n.surface_projection_digest!="string"||!N.test(n.surface_projection_digest))?{status:"malformed"}:o.minor>=1&&z(T)&&!T.every(g=>Object.hasOwn(m,g))?{status:"malformed"}:{status:"valid",document:n,protocolVersion:o}:{status:"malformed"}}function Ke(t){return Object.fromEntries(Object.entries(t).filter(([e])=>!/^GODD_/i.test(e)))}function de(t){return t?t.code:void 0}function Fe(t){let e=de(t);return e==="ENOBUFS"||e==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"}function ue(t,e,r,n,o,a,i=[]){let c=e?.packageVersion??t.packageVersion,s=e?.manifestDigest??t.manifestDigest??"";return{packageVersion:Y.test(c)?c:"",manifestDigest:N.test(s)?s:"",observedProtocolVersion:a??o?.protocol_version??null,observedSurfaceFingerprint:o?.surface_fingerprint??null,observedCapabilityCatalogDigest:o?.capability_catalog_digest??null,reasonCode:n,advisories:i,digestVerifiedPath:r}}function C(t,e,r,n,o,a){return{verdict:{kind:"Rejected",receipt:ue(t,e,r,n,o,a)},admittedLaunch:null}}function ze(t,e,r,n,o=W.spawnSync,a=process.env){if(!e)return C(r,null,n,"HSHAKE_EXPECTATION_ABSENT");let i;try{i=o(t,Pe,{encoding:null,timeout:Le,killSignal:"SIGKILL",maxBuffer:K,windowsHide:!0,stdio:["ignore","pipe","pipe"],env:Ke(a)})}catch{return C(r,e,n,"HSHAKE_PROBE_SPAWN_FAILED")}if(de(i.error)==="ETIMEDOUT")return C(r,e,n,"HSHAKE_PROBE_TIMEOUT");let s=i.stdout??Buffer.alloc(0),_=i.stderr??Buffer.alloc(0);if(Fe(i.error)){let A=_.length>0&&s.length<=K?"HSHAKE_DOCUMENT_MALFORMED":"HSHAKE_DOCUMENT_OVERSIZE";return C(r,e,n,A)}if(i.error)return C(r,e,n,"HSHAKE_PROBE_SPAWN_FAILED");if(i.status!==0||s.length===0)return C(r,e,n,"HSHAKE_DOCUMENT_ABSENT");if(s.length>K)return C(r,e,n,"HSHAKE_DOCUMENT_OVERSIZE");if(_.length>0)return C(r,e,n,"HSHAKE_DOCUMENT_MALFORMED");let u=Ve(s);if(u.status!=="valid"||!u.protocolVersion)return C(r,e,n,"HSHAKE_DOCUMENT_MALFORMED");let l=u.protocolVersion;if(!e.supportedProtocolMajors.includes(l.major))return C(r,e,n,"HSHAKE_PROTOCOL_MAJOR_UNSUPPORTED",void 0,l);let d=u.document;if(!d)return C(r,e,n,"HSHAKE_DOCUMENT_MALFORMED",void 0,l);let f=e.minimumProtocolMinorByMajor[l.major];if(f===void 0||l.minor<f)return C(r,e,n,"HSHAKE_PROTOCOL_MINOR_TOO_OLD",d,l);if(d.target.target_triple!==e.expectedTargetTriple)return C(r,e,n,"HSHAKE_TARGET_MISMATCH",d,l);let m=new Set(d.capability_ids);if(!e.expectedCapabilityIds.every(A=>m.has(A)))return C(r,e,n,"HSHAKE_CAPABILITY_MISSING",d,l);let O=new Set(d.routed_commands??[]);if(e.routedCommandNames.some(A=>!O.has(A)||d.surface_entries[A]!==e.expectedRoutedCommandEntryDigests[A]))return C(r,e,n,n?"HSHAKE_MANIFEST_SELF_INCONSISTENT":"HSHAKE_SURFACE_PROJECTION_MISMATCH",d,l);let E=[];d.capability_catalog_digest!==e.expectedCapabilityCatalogDigest&&E.push("HSHAKE_CAPABILITY_SURPLUS");let g=new Set(e.routedCommandNames);Object.keys(d.surface_entries).some(A=>A!=="<default>"&&!g.has(A))&&E.push("HSHAKE_SURFACE_SURPLUS");let L=J[l.major];return L!==void 0&&l.minor>L&&E.push("HSHAKE_PROTOCOL_MINOR_AHEAD"),{verdict:{kind:"Admitted",receipt:ue(r,e,n,"HSHAKE_ADMITTED",d,l,E)},admittedLaunch:{[He]:!0,binaryPath:t}}}function Q(t,e,r,n,o=W.spawnSync,a=process.env){if(V==="off")return{kind:"Allowed",launch:{[F]:!0,binaryPath:t},advisoryReceipt:null};let i=ze(t,e,r,n,o,a);return i.admittedLaunch?{kind:"Allowed",launch:{[F]:!0,binaryPath:i.admittedLaunch.binaryPath},advisoryReceipt:null}:V==="advisory"?{kind:"Allowed",launch:{[F]:!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 te=U.targets;function Je(t,e){return te[`${t}-${e}`]?.artifact??null}function Ye(t){if(t.overridePath)return t.overridePath;let e=Je(t.platform,t.arch);if(!e||!t.entryPath)return null;let r=t.realpath?t.realpath(t.entryPath):(0,h.existsSync)(t.entryPath)?(0,h.realpathSync)(t.entryPath):t.entryPath,n=(0,b.resolve)((0,b.dirname)(r),"..");return(0,b.join)(n,"assets","native",e)}function _e(t,e,r){try{let n=te[`${e}-${r}`];return!n||(0,h.statSync)(t).size!==n.bytes?!1:(0,ee.createHash)("sha256").update((0,h.readFileSync)(t)).digest("hex")===n.sha256}catch{return!1}}function Ee(t,e,r,n){let o=t.kind==="Blocked"?t.receipt:t.advisoryReceipt;if(o)try{if(r){r(o,e);return}if(!!1||process.env.GODD_NATIVE_HANDSHAKE_REPORTING!=="railway-aggregate-v2")return;let a=n?.path??Ye({platform:process.platform,arch:process.arch,entryPath:process.argv[1]});if(!a)return;let i=re(a,e,n?.arch??process.arch);if(!i)return;try{(0,me.spawnSync)(i.path,["anonymous-handshake-report"],{input:JSON.stringify(o),env:{...process.platform==="win32"&&process.env.SystemRoot?{SystemRoot:process.env.SystemRoot}:{},GODD_NATIVE_HANDSHAKE_REPORTING:"railway-aggregate-v2"},timeout:1500,windowsHide:!0,shell:!1,stdio:["pipe","ignore","ignore"]})}finally{i.cleanup()}}catch{}}function re(t,e,r,n=te){let o;try{let a=n[`${e}-${r}`];if(!a)return null;let i=(0,h.readFileSync)(t);if(i.length!==a.bytes||(0,ee.createHash)("sha256").update(i).digest("hex")!==a.sha256)return null;o=(0,h.mkdtempSync)((0,b.join)((0,pe.tmpdir)(),"godd-native-"));let c=(0,b.join)(o,`godd-native${(0,b.extname)(t)}`);return(0,h.writeFileSync)(c,i,{mode:448}),{path:c,cleanup:()=>{try{(0,h.rmSync)(o,{recursive:!0,force:!0})}catch{}}}}catch{if(o)try{(0,h.rmSync)(o,{recursive:!0,force:!0})}catch{}return null}}var fe=require("node:crypto"),$e=/^sha256:[0-9a-f]{64}$/u,qe=1024,Xe=Object.freeze({owner:"nextjs-server",clock:"monotonic-milliseconds",trigger:"timer-and-after-lifecycle-event"});function y(t,e,r,n=0){return Object.freeze({action:t,disposition:e,max_retries:n,on_retry_exhausted:n===1?"REJECT":null,reason:r})}var I=Object.freeze({CACHE_HIT:y("USE_CACHED_MODULE","CONTINUE",null),CACHE_MISS_COMPILED:y("PUBLISH_COMPILED_MODULE","CONTINUE",null),SINGLE_FLIGHT_JOINED:y("WAIT_FOR_SINGLE_FLIGHT","CONTINUE",null),TOO_LARGE_FOR_CACHE:y("COMPILE_WITHOUT_CACHE","CONTINUE","ENTRY_LIMIT_EXCEEDED"),BUDGET_OVERFLOW:y("REJECT_CACHE_OPERATION","REJECT","ARITHMETIC_OVERFLOW"),BUDGET_UNRECLAIMABLE:y("RETRY_AFTER_RECONCILE","RETRY","RECLAIMABLE_ENTRIES_INSUFFICIENT",1),BUDGET_EVICTED_LRU:y("DROP_OPAQUE_HANDLE","CONTINUE","LRU_PRESSURE_EVICTION"),SUPERSEDED_BY_NEW_SOURCE:y("DROP_OPAQUE_HANDLE","CONTINUE","SOURCE_GENERATION_SUPERSEDED"),DECK_TOMBSTONED:y("DROP_OPAQUE_HANDLE","CONTINUE","DECK_LIFECYCLE_ENDED"),STALE_GENERATION_REJECTED:y("DISCARD_COMPILED_MODULE","CONTINUE","GENERATION_FENCE_CHANGED"),PREVIEW_LEASE_EXPIRED:y("DROP_OPAQUE_HANDLE","CONTINUE","PREVIEW_LEASE_ENDED"),AGE_EXPIRED:y("DROP_OPAQUE_HANDLE","CONTINUE","MAXIMUM_AGE_EXCEEDED"),IDLE_EXPIRED:y("DROP_OPAQUE_HANDLE","CONTINUE","MAXIMUM_IDLE_EXCEEDED"),RESERVATION_EXPIRED:y("DISCARD_COMPILED_MODULE","CONTINUE","RESERVATION_DEADLINE_EXCEEDED"),COMPILE_FAILED_ROLLED_BACK:y("RELEASE_FAILED_COMPILE","CONTINUE","COMPILE_DID_NOT_COMPLETE"),RECONCILE_CLOCK_REGRESSION:y("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,r){let n=Object.keys(t).sort(),o=[...e].sort();if(n.length!==o.length||n.some((a,i)=>a!==o[i]))throw new TypeError(`${r} has an invalid field set`)}function D(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function H(t){return D(t)&&t>0}function x(t){return typeof t=="string"&&$e.test(t)}function he(t){return t==="unversioned"||x(t)}function ne(t){return typeof t=="string"&&t.length>0&&Buffer.byteLength(t,"utf8")<=qe&&!new RegExp("\\p{Cc}","u").test(t)}function Qe(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"),!ne(e.workspace_id)||!ne(e.deck_id)||!ne(e.slide_filename)||!H(e.deck_generation)||!x(e.canonical_source_digest)||!he(e.mdx_policy_generation)||!x(e.compiler_generation)||e.runtime_abi!=="amaroad")throw new TypeError("compile cache manifest is invalid");return e}function Ze(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"),Qe(e.manifest),e.schema_version!==1||e.operation!=="register"||!D(e.source_bytes)||!H(e.declared_max_compiled_bytes)||!D(e.now_ms))throw new TypeError("compile cache register request is invalid");return e}function ye(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 r=w(e.manifest,"compile cache project manifest");if(S(r,["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 n=Buffer.byteLength(e.canonical_source,"utf8"),o={schema_version:1,operation:"register",manifest:{...r,canonical_source_digest:`sha256:${(0,fe.createHash)("sha256").update(e.canonical_source,"utf8").digest("hex")}`},source_bytes:n,declared_max_compiled_bytes:e.declared_max_compiled_bytes,now_ms:e.now_ms};return Ze(o)}function Ce(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({...Xe,interval_ms:Math.min(e.age_ms,e.idle_ms,e.reservation_ttl_ms)})}function et(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 tt(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[,r]=et(e.outcome);if(e.schema_version!==1||!x(e.canonical_source_digest)||!D(e.deck_generation)||!he(e.mdx_policy_generation)||!x(e.compiler_generation)||!D(e.key_bytes)||!D(e.source_bytes)||!D(e.compiled_bytes)||typeof e.compiled_bytes_measured!="boolean")throw new TypeError("compile cache receipt is invalid");if(e.reason!==r.reason)throw new TypeError("compile cache receipt reason does not match outcome");return e}function ge(t){let e=tt(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 p=class extends Error{code;handshakeReasonCode;constructor(e,r){super(e),this.name="CompileCacheRuntimeError",this.code=e,this.handshakeReasonCode=r??null}},v=class extends Error{outcome;action;disposition;retriesExhausted;constructor(e,r,n,o){super(e),this.name="CompileCacheRejectedError",this.outcome=e,this.action=r,this.disposition=n,this.retriesExhausted=o}},P=class{outcome;action;constructor(e,r){this.outcome=e,this.action=r}},Ae="";function rt(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(Ae)}function Re(t){return[t.canonical_source_digest,String(t.deck_generation),t.mdx_policy_generation,t.compiler_generation].join(Ae)}var oe=class{#s;#y;#c;#u;#p;#o=new Map;#i=new Map;#r=new Map;#m;#n=null;#l=!1;#_=0;#E=null;#d=!1;constructor(e){this.#s=e.evaluator,this.#y=e.budget,this.#c=e.compile,this.#u=e.now,this.#p=e.onReconcileError??(()=>{}),this.#m=Ce({age_ms:e.budget.age_ms,idle_ms:e.budget.idle_ms,reservation_ttl_ms:e.budget.reservation_ttl_ms})}get reconcilePolicy(){return this.#m}get retainedModuleCount(){return this.#o.size}get reconcileTimerStarted(){return this.#n!==null}startReconcileTimer(){if(this.#n!==null)throw new p("RECONCILE_TIMER_ALREADY_OWNED");this.#n=setInterval(()=>{this.#l||(this.#l=!0,this.reconcile().catch(e=>{this.#p(e)}).finally(()=>{this.#l=!1}))},this.#m.interval_ms),this.#n.unref?.()}stopReconcileTimer(){if(this.#n===null)throw new p("RECONCILE_TIMER_NOT_OWNED");clearInterval(this.#n),this.#n=null,this.#l=!1}async close(){this.#n!==null&&this.stopReconcileTimer(),this.#d=!0,this.#o.clear(),this.#i.clear(),this.#r.clear(),await this.#s.close()}async compile(e){await this.#h();let r=await this.#C(e,!1);if(!(r instanceof P))return r;await this.reconcile();let n=await this.#C(e,!0);if(n instanceof P)throw new v(n.outcome,n.action,"RETRY",!0);return n}async reconcile(){await this.#h();let e=await this.#a({schema_version:1,command:"reconcile",now_ms:this.#u()}),r=e.action==="REJECTED",n=this.#t(e.receipts,r);if(r)throw n===null?new p("EVALUATOR_PROTOCOL"):new v(n.outcome,n.action,n.disposition,!1);return e.receipts}async onDeckRemoved(e,r){await this.#f({schema_version:1,command:"tombstone_deck",workspace_id:e,deck_id:r})}async onPreviewLeaseExpired(e,r){await this.#f({schema_version:1,command:"expire_preview_lease",workspace_id:e,deck_id:r})}async onGenerationUpdated(e){await this.#f({schema_version:1,command:"fence_generations",...e})}async#f(e){await this.#h();let r=await this.#a(e);this.#t(r.receipts,!1),await this.reconcile()}async#C(e,r){let n=ye({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}=n,i=await this.#a({command:o,...a}),c=rt(n.manifest),s=Re(n.manifest);switch(i.action){case"HIT":return this.#O(e,i,c,s,r);case"JOINED":return this.#A(i,c,r);case"COMPILE_REQUESTED":return this.#T(e,i,c,s,r);case"REJECTED":return this.#b(e,i,r);default:try{this.#t(i.receipts,!1)}finally{await this.#e(i.lease)}throw new p("EVALUATOR_PROTOCOL")}}async#O(e,r,n,o,a){try{let i=this.#g(r,"USE_CACHED_MODULE"),c=this.#o.get(n),s=!0;if(c===void 0){let _=this.#_,u=await this.#c(e);c=u.module,s=!1;let l=r.receipts[r.receipts.length-1];if(u.compiled_bytes!==l.compiled_bytes||this.#_!==_)return{module:c,outcome:i.outcome,action:i.action,served_from_cache:!1,retained:!1,retried:a};this.#R(n,o,c)}return{module:c,outcome:i.outcome,action:i.action,served_from_cache:s,retained:!0,retried:a}}finally{await this.#e(r.lease)}}async#A(e,r,n){try{let o=this.#g(e,"WAIT_FOR_SINGLE_FLIGHT"),a=this.#r.get(r);if(a===void 0)throw new p("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:n}}finally{await this.#e(e.lease)}}async#T(e,r,n,o,a){try{this.#t(r.receipts,!1)}catch(m){throw await this.#e(r.lease),m}if(r.compile_owner!==!0||r.lease===null)throw await this.#e(r.lease),new p("EVALUATOR_PROTOCOL");let i=r.lease,c,s,_=new Promise((m,O)=>{c=m,s=O});_.catch(()=>{}),this.#r.set(n,_);let u;try{u=await this.#c(e)}catch(m){s?.(m);try{let O=await this.#a({schema_version:1,command:"rollback",lease:i});this.#t(O.receipts,!1)}catch{}throw this.#r.delete(n),m}let l;try{l=await this.#a({schema_version:1,command:"commit",lease:i,compiled_bytes:u.compiled_bytes})}catch(m){throw s?.(m),await this.#e(i),this.#r.delete(n),m}let d;try{d=this.#t(l.receipts,!0)}catch(m){throw s?.(m),this.#r.delete(n),await this.#e(i),m}if(this.#r.delete(n),l.action==="NOOP"||d===null){let m=new p("COMMIT_NOT_ACCEPTED");throw s?.(m),await this.#e(i),m}if(d.action==="PUBLISH_COMPILED_MODULE")return this.#R(n,o,u.module),c?.({module:u.module,retained:!0}),await this.#e(i),{module:u.module,outcome:d.outcome,action:d.action,served_from_cache:!1,retained:!0,retried:a};if(d.action==="COMPILE_WITHOUT_CACHE")return c?.({module:u.module,retained:!1}),await this.#e(i),{module:u.module,outcome:d.outcome,action:d.action,served_from_cache:!1,retained:!1,retried:a};let f=new v(d.outcome,d.action,d.disposition,!1);if(s?.(f),await this.#e(i),d.disposition==="RETRY")return new P(d.outcome,d.action);throw f}async#b(e,r,n){let o=this.#t(r.receipts,!0);if(o===null)throw new p("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:n};throw new v(o.outcome,o.action,o.disposition,!1)}#t(e,r){let n=null;for(let o=0;o<e.length;o+=1){let a=ge(e[o]);o===e.length-1&&(n=a),e[o].compiled_bytes_measured&&(a.action==="DROP_OPAQUE_HANDLE"||a.action==="DISCARD_COMPILED_MODULE"||a.action==="RELEASE_FAILED_COMPILE")&&(this.#_+=1,this.#N(Re(e[o])))}return r?n:null}#g(e,r){let n=this.#t(e.receipts,!0);if(n===null||n.action!==r)throw new p("EVALUATOR_PROTOCOL");return n}#R(e,r,n){this.#o.set(e,n);let o=this.#i.get(r);if(o===void 0){this.#i.set(r,new Set([e]));return}o.add(e)}#N(e){let r=this.#i.get(e);if(r!==void 0){for(let n of r)this.#o.delete(n);this.#i.delete(e)}}async#e(e){if(e!==null)try{let r=await this.#a({schema_version:1,command:"release",lease:e});this.#t(r.receipts,!1)}catch(r){this.#p(r)}}async#h(){if(this.#d)throw new p("EVALUATOR_CLOSED");this.#E??=(async()=>{if((await this.#s.send({schema_version:1,command:"configure",budget:this.#y})).action!=="CONFIGURED")throw new p("EVALUATOR_PROTOCOL")})().catch(e=>{throw this.#E=null,e}),await this.#E}async#a(e){if(this.#d)throw new p("EVALUATOR_CLOSED");try{return await this.#s.send(e)}catch(r){throw r instanceof p&&r.code==="EVALUATOR_CLOSED"&&(this.#d=!0,this.#o.clear(),this.#i.clear(),this.#r.clear()),r}}};function nt(t){if(t===null||typeof t!="object"||Array.isArray(t))throw new p("EVALUATOR_PROTOCOL");let e=t;if(e.schema_version!==1||typeof e.action!="string")throw new p("EVALUATOR_PROTOCOL");if(!Array.isArray(e.receipts))throw new p("EVALUATOR_PROTOCOL");if(e.lease!==null&&(!Number.isSafeInteger(e.lease)||e.lease<1))throw new p("EVALUATOR_PROTOCOL");return t}function Te(t){let e=[],r="",n=null;t.readable.setEncoding?.("utf8"),t.readable.on("data",a=>{r+=typeof a=="string"?a:a.toString("utf8");let i=r.indexOf(`
|
|
6
|
+
`);for(;i>=0;){let c=r.slice(0,i).replace(/\r$/u,"");if(r=r.slice(i+1),i=r.indexOf(`
|
|
7
|
+
`),c.length===0)continue;let s=e.shift();if(s===void 0){n=new p("EVALUATOR_PROTOCOL");continue}try{s.resolve(nt(JSON.parse(c)))}catch(_){s.reject(_)}}});let o=a=>{n=a;for(let i of e.splice(0,e.length))i.reject(a)};return t.readable.on("end",()=>{o(new p("EVALUATOR_CLOSED"))}),t.readable.on("close",()=>{o(new p("EVALUATOR_CLOSED"))}),t.readable.on("error",()=>{o(new p("EVALUATOR_PROTOCOL"))}),{async send(a){if(n!==null)throw n;return new Promise((i,c)=>{let s={resolve:i,reject:c};e.push(s);try{t.writable.write(`${JSON.stringify(a)}
|
|
8
|
+
`)}catch(_){let u=e.indexOf(s);u>=0&&e.splice(u,1),c(_)}})},async close(){o(new p("EVALUATOR_CLOSED")),await t.close()}}}function ot(t,e,r){try{return(0,Oe.spawn)(t.binaryPath,[...e],{stdio:["pipe","pipe","ignore"],windowsHide:!0})}catch(n){throw r(),n}}function it(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 p("EVALUATOR_PROTOCOL");let e=q(),r={packageVersion:j,...e===void 0?{}:{manifestDigest:e}},n=X(U,process.platform,process.arch,r),o=process.platform,a=process.arch,i=!1;try{i=_e(t.command,o,a)}catch{i=!1}if(!i)throw new p("NATIVE_INTEGRITY_REJECTED");let c=re(t.command,o,a);if(!c)throw new p("NATIVE_INTEGRITY_REJECTED");let s=!1,_=()=>{s||(s=!0,c.cleanup())},u;try{u=Q(c.path,n,r,!0)}catch(f){throw _(),f}if(Ee(u,o,void 0,{path:c.path,arch:a}),u.kind==="Blocked")throw _(),new p("NATIVE_HANDSHAKE_REJECTED",u.receipt.reasonCode);u.advisoryReceipt&&process.stderr.write(Z(u.advisoryReceipt));let l=ot(u.launch,t.args??["compile-cache","session"],_);if(l.once("close",_),l.once("error",_),l.stdin===null||l.stdout===null)throw l.stdin?.destroy(),l.stdout?.destroy(),l.kill(),_(),new p("EVALUATOR_PROTOCOL");let d=()=>{l.stdout?.destroy()};return l.on("error",d),l.stdin.on("error",d),Te({writable:l.stdin,readable:l.stdout,close:()=>{l.stdin?.end(),l.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
|