@kodax-ai/kodax 0.7.97-alpha.1 → 0.7.97-alpha.2

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.
Files changed (100) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +13 -0
  3. package/README_CN.md +11 -0
  4. package/dist/chunks/{agent-KDEZEKHT.js → agent-J7SHFM5N.js} +1 -1
  5. package/dist/chunks/argument-completer-ZJQOWTIS.js +2 -0
  6. package/dist/chunks/{chunk-3M5335DB.js → chunk-2GV6MQ4T.js} +2 -2
  7. package/dist/chunks/{chunk-JLZUOLEL.js → chunk-3PS3YEDS.js} +1 -1
  8. package/dist/chunks/{chunk-W7W2XKJC.js → chunk-4VJMQDTH.js} +190 -190
  9. package/dist/chunks/{chunk-OIJYHVTO.js → chunk-5DSUVP46.js} +1 -1
  10. package/dist/chunks/{chunk-NZYG3D5W.js → chunk-5P7RTSZT.js} +1 -1
  11. package/dist/chunks/{chunk-K4Z7DWSV.js → chunk-6ZAQKFIM.js} +1 -1
  12. package/dist/chunks/chunk-7V2QBZ73.js +137 -0
  13. package/dist/chunks/{chunk-2OL4I5TF.js → chunk-F7DHZH6T.js} +1 -1
  14. package/dist/chunks/{chunk-O7VU62ZF.js → chunk-HSRYDDPF.js} +1 -1
  15. package/dist/chunks/chunk-K3DQGSQU.js +372 -0
  16. package/dist/chunks/chunk-NO23K2CB.js +2 -0
  17. package/dist/chunks/{chunk-LGX7WSRT.js → chunk-OT5WHAX4.js} +1 -1
  18. package/dist/chunks/{chunk-27NV62CK.js → chunk-QGWHJIO4.js} +1 -1
  19. package/dist/chunks/{chunk-7TYV3YFX.js → chunk-QOFFAY5C.js} +2 -2
  20. package/dist/chunks/{chunk-KKTVO3ZN.js → chunk-QVDTORL3.js} +1 -1
  21. package/dist/chunks/{chunk-YOKMTTLR.js → chunk-QZ4B4AWG.js} +2 -2
  22. package/dist/chunks/{chunk-EIWAATQU.js → chunk-RXDS6CNA.js} +31 -31
  23. package/dist/chunks/{chunk-AWHU6MSJ.js → chunk-VDGPJQL7.js} +1 -1
  24. package/dist/chunks/{chunk-H2KGA4NZ.js → chunk-VEZ4WHPN.js} +2 -2
  25. package/dist/chunks/{chunk-3IXRUVY7.js → chunk-ZPPAT25E.js} +1 -1
  26. package/dist/chunks/chunk-ZS2GUADU.js +498 -0
  27. package/dist/chunks/{chunk-LIWLDMWE.js → chunk-ZTYZYXGV.js} +1 -1
  28. package/dist/chunks/{chunk-A26WXO3D.js → chunk-ZZQ4GDVU.js} +1 -1
  29. package/dist/chunks/{client-2UJ3ESQU.js → client-MXOJ5XUN.js} +1 -1
  30. package/dist/chunks/{compaction-config-WQ7SKQYF.js → compaction-config-5VZSGKBQ.js} +1 -1
  31. package/dist/chunks/{construction-bootstrap-IOWLYAWA.js → construction-bootstrap-U2ZU2WAT.js} +1 -1
  32. package/dist/chunks/{dist-YWAVSU65.js → dist-CSLNWLOE.js} +1 -1
  33. package/dist/chunks/dist-XXMJMJDU.js +2 -0
  34. package/dist/chunks/host-RUXYZFYN.js +2 -0
  35. package/dist/chunks/readline-helpers-JCVULR4C.js +2 -0
  36. package/dist/chunks/run-manager-DRIM5VNE.js +2 -0
  37. package/dist/chunks/{utils-HFKMRP34.js → utils-MQEBGKIX.js} +1 -1
  38. package/dist/index.d.ts +19 -17
  39. package/dist/index.js +1 -1
  40. package/dist/kodax_bootstrap.js +1 -1
  41. package/dist/kodax_cli.js +1620 -1620
  42. package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
  43. package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
  44. package/dist/native/win32-x64/manifest.json +2 -2
  45. package/dist/sandbox-network-broker.js +77 -77
  46. package/dist/sdk-a2a.d.ts +13 -11
  47. package/dist/sdk-a2a.js +1 -1
  48. package/dist/sdk-agent.d.ts +4 -4
  49. package/dist/sdk-agent.js +1 -1
  50. package/dist/sdk-client.d.ts +15 -4
  51. package/dist/sdk-client.js +1 -1
  52. package/dist/sdk-coding.d.ts +18 -17
  53. package/dist/sdk-coding.js +1 -1
  54. package/dist/sdk-experimental-memory.js +1 -1
  55. package/dist/sdk-llm.d.ts +7 -5
  56. package/dist/sdk-llm.js +1 -1
  57. package/dist/sdk-mcp.js +1 -1
  58. package/dist/sdk-media.js +1 -1
  59. package/dist/sdk-repl.d.ts +18 -16
  60. package/dist/sdk-repl.js +1 -1
  61. package/dist/sdk-runtime.d.ts +64 -129
  62. package/dist/sdk-runtime.js +1 -1
  63. package/dist/sdk-sandbox.js +1 -1
  64. package/dist/sdk-session.d.ts +9 -7
  65. package/dist/sdk-session.js +1 -1
  66. package/dist/sdk-skills.js +1 -1
  67. package/dist/semantic-worker.js +57 -57
  68. package/dist/types-chunks/{base.d-Dz_g7CUo.d.ts → base.d-ZBOdjDUT.d.ts} +1 -0
  69. package/dist/types-chunks/{bash-prefix-extractor.d-BhFz5sIp.d.ts → bash-prefix-extractor.d-DvswAXKS.d.ts} +33 -8
  70. package/dist/types-chunks/{capsule.d-DhXy_i0g.d.ts → capsule.d-B4atvlxE.d.ts} +1 -1
  71. package/dist/types-chunks/{client-contract-DYkkBxuz.d.ts → client-contract-A1jdk6xz.d.ts} +221 -5
  72. package/dist/types-chunks/{controller.d-CA7iiSfI.d.ts → controller.d-yyKajPTi.d.ts} +1 -1
  73. package/dist/types-chunks/{cost-tracker.d-BWI4lFWn.d.ts → cost-tracker.d-BeaenODW.d.ts} +2 -47
  74. package/dist/types-chunks/provider-credential-context.d-BH2OaB1b.d.ts +47 -0
  75. package/dist/types-chunks/provider-request-observation.d-jL8T6wVO.d.ts +34 -0
  76. package/dist/types-chunks/{public-api.d-CofjXB_K.d.ts → public-api.d-Cq8ILMte.d.ts} +4 -2
  77. package/dist/types-chunks/{resolver.d-BMoO2VPt.d.ts → resolver.d-DLY01RHx.d.ts} +3 -1
  78. package/dist/types-chunks/{review-packet.d-BskpQxDZ.d.ts → review-packet.d-D4bbTbq3.d.ts} +1 -1
  79. package/dist/types-chunks/{run-manager.d-BrVCxHum.d.ts → run-manager.d-C7Q71rin.d.ts} +5 -5
  80. package/dist/types-chunks/runtime-client-info-CxnlZlW5.d.ts +175 -0
  81. package/dist/types-chunks/{sdk-session-BjZqSlA-.d.ts → sdk-session-BDFjCpDn.d.ts} +1 -1
  82. package/dist/types-chunks/{side-query.d-DmOU7byC.d.ts → side-query.d-DTrhVd_r.d.ts} +3 -2
  83. package/dist/types-chunks/{trusted-repl-entry-C7tjze05.d.ts → trusted-repl-entry-vbUM8R6P.d.ts} +5 -5
  84. package/dist/types-chunks/{types.d-mlrvOZT1.d.ts → types.d-BJTN-RZr.d.ts} +2 -2
  85. package/dist/types-chunks/{utils.d-Bi-i7O5D.d.ts → utils.d-CWiMhFfu.d.ts} +4 -4
  86. package/docs/CLIENT_CONTRACT.md +4 -0
  87. package/docs/SDK_MIGRATION.md +4 -2
  88. package/docs/SPACE_SDK_SEAMS.md +139 -0
  89. package/package.json +3 -2
  90. package/public_docs/sdk/embedder-guide.md +3 -1
  91. package/dist/chunks/argument-completer-S6XK5OQA.js +0 -2
  92. package/dist/chunks/chunk-75IELO25.js +0 -137
  93. package/dist/chunks/chunk-LDCEV5QA.js +0 -2
  94. package/dist/chunks/chunk-NNB6AZSC.js +0 -372
  95. package/dist/chunks/chunk-SKSS6TDQ.js +0 -498
  96. package/dist/chunks/dist-5Z6YN7Z6.js +0 -2
  97. package/dist/chunks/host-ELUUZWI4.js +0 -2
  98. package/dist/chunks/readline-helpers-ONOPF5J5.js +0 -2
  99. package/dist/chunks/run-manager-7INNATMJ.js +0 -2
  100. package/dist/types-chunks/runtime-client-info-DE3G2vWa.d.ts +0 -15
package/CHANGELOG.md CHANGED
@@ -8,6 +8,39 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  ---
10
10
 
11
+ ## [0.7.97-alpha.2] - 2026-10-10
12
+
13
+ Second alpha of the v0.7.97 line: completes the FEATURE_298 product seams
14
+ embedders need to run the client inside a trusted shell (Space). Execution
15
+ authorization moves to the trusted Main process, every provider wire request
16
+ carries its attribution, and full exits become verifiable. Every
17
+ v0.7.96 stable and v0.7.97-alpha.1 contract is retained. npm publication
18
+ remains a manual maintainer action.
19
+
20
+ ### Added
21
+
22
+ - Trusted Main execution authorization: `connectKodaXClient` /
23
+ `ensureKodaXClient` accept an `authorizeExecution(request, services)`
24
+ callback that runs only in the trusted Main process (Host capability
25
+ `productExecutionAuthorization:1`; older Hosts reject it instead of
26
+ silently dropping bindings). It registers scoped credential and hostTools
27
+ leases and attaches non-secret bindings per operation kind — input,
28
+ command, review, agents_lean, tool, workflow, agent_spawn, agent_followup,
29
+ and manual compaction. Queued consumes bind at consumption time, steers
30
+ keep the target Run's authorization, redirects carry their own, and
31
+ different authorizations never merge or widen.
32
+ - Provider request attribution: every provider wire request carries its
33
+ execution identity and route so hosts and embedders can observe which
34
+ authorization issued it.
35
+ - Client lifecycle and exit: `lifecycle.requestExit` settles client work and
36
+ records durable exit receipts that `readKodaXClientExits` verifies after
37
+ reconnect; full exits no longer rely on disconnect side effects.
38
+ - Host surfaces for embedders: an execution facts store and per-session
39
+ statistics exposed through the daemon, and a bundled product-exit smoke
40
+ joined the release gates.
41
+
42
+ ---
43
+
11
44
  ## [0.7.97-alpha.1] - 2026-10-08
12
45
 
13
46
  First alpha of the v0.7.97 line: FEATURE_298's unified product Host and
package/README.md CHANGED
@@ -769,6 +769,19 @@ provider's model, REPL `/compact` clears the UI only after a durable save, and
769
769
  successful reports carry bounded `summaryRequests` plus `commitMs` per
770
770
  physical summary call.
771
771
 
772
+ **v0.7.97-alpha.2 release:** Completes the FEATURE_298 product seams
773
+ embedders need to run the client inside a trusted shell (Space).
774
+ `connectKodaXClient`/`ensureKodaXClient` accept a trusted
775
+ `authorizeExecution` callback that registers scoped credential and hostTools
776
+ leases and attaches non-secret bindings per operation kind (queued consumes
777
+ bind at consumption, steers keep the target Run's authorization, redirects
778
+ carry their own); every provider wire request carries its execution
779
+ attribution; `lifecycle.requestExit` settles client work and records
780
+ durable exit receipts that `readKodaXClientExits` verifies; and the Host
781
+ exposes execution facts and per-session statistics. See
782
+ [docs/SPACE_SDK_SEAMS.md](docs/SPACE_SDK_SEAMS.md). Every v0.7.96 stable
783
+ and v0.7.97-alpha.1 contract is retained.
784
+
772
785
  **v0.7.97-alpha.1 release:** First alpha of the v0.7.97 line — FEATURE_298's
773
786
  unified product Host and client contract. The interactive REPL pins to the
774
787
  independent Host; the shared product session contract (`KodaXProductClient`
package/README_CN.md CHANGED
@@ -301,6 +301,17 @@ SDK 系统代码契约更新,但没有放宽 shell/sandbox 的 fail-closed 边
301
301
  `handleRuntimePermissionRequest()` 管理 SDK 权限 UI,并在 prepared Session 尾部遇到
302
302
  `data_changed` 时通过权威 delta 合并恢复;后台持久化失败会显示为诊断,不再静默丢失。
303
303
 
304
+ **v0.7.97-alpha.2 发布**:补齐 FEATURE_298 面向嵌入方(Space)的产品接缝——
305
+ 在可信壳内运行客户端所需的最后一块。`connectKodaXClient`/`ensureKodaXClient`
306
+ 接受仅在可信 Main 进程执行的 `authorizeExecution` 回调,注册 scoped credential
307
+ 与 hostTools lease,并按操作种类附加非秘密绑定(排队消费在消费时绑定、steer
308
+ 保留目标 Run 的授权、redirect 携带自身授权);每条 Provider wire request 携带
309
+ 其执行归因;`lifecycle.requestExit` 结清客户端工作并记录持久退出回执,由
310
+ `readKodaXClientExits` 在重连后核验;宿主暴露 execution facts 与按会话统计。
311
+ 详见 [docs/SPACE_SDK_SEAMS.md](docs/SPACE_SDK_SEAMS.md) 与
312
+ [v0.7.97-alpha.2 发布清单](docs/release.md#v0797-alpha2-release-preparation)。
313
+ 所有 v0.7.96 稳定与 v0.7.97-alpha.1 契约全部保留。
314
+
304
315
  **v0.7.97-alpha.1 发布**:v0.7.97 线首个 alpha——FEATURE_298 统一产品宿主
305
316
  与客户端契约。交互式 REPL 绑定独立宿主;共享产品会话契约
306
317
  (`KodaXProductClient`,经 `/client`)承载会话、目标、通知、分页历史、
@@ -1,2 +1,2 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{Ib as k,Xa as g,Za as h,a as c,sa as d,ta as e,ua as f,yb as i,zb as j}from"./chunk-NNB6AZSC.js";import"./chunk-A26WXO3D.js";import"./chunk-W7W2XKJC.js";import"./chunk-2OL4I5TF.js";import"./chunk-OIJYHVTO.js";import{Rb as a,Sb as b}from"./chunk-AWHU6MSJ.js";import"./chunk-3IXRUVY7.js";import"./chunk-75IELO25.js";import"./chunk-ONUPGMER.js";export{e as bucketProviderPayloadSize,g as buildAutoRepoIntelligenceContext,f as checkPromiseSignal,b as cleanupIncompleteToolCalls,h as describeTransientProviderRetry,c as emitResilienceDebug,d as estimateProviderPayloadBytes,k as runKodaX,j as saveRequiredSessionSnapshot,i as saveSessionSnapshot,a as validateAndFixToolHistory};
2
+ import{Ib as k,Xa as g,Za as h,a as c,sa as d,ta as e,ua as f,yb as i,zb as j}from"./chunk-K3DQGSQU.js";import"./chunk-ZZQ4GDVU.js";import"./chunk-4VJMQDTH.js";import"./chunk-F7DHZH6T.js";import"./chunk-5DSUVP46.js";import{Rb as a,Sb as b}from"./chunk-VDGPJQL7.js";import"./chunk-ZPPAT25E.js";import"./chunk-7V2QBZ73.js";import"./chunk-ONUPGMER.js";export{e as bucketProviderPayloadSize,g as buildAutoRepoIntelligenceContext,f as checkPromiseSignal,b as cleanupIncompleteToolCalls,h as describeTransientProviderRetry,c as emitResilienceDebug,d as estimateProviderPayloadBytes,k as runKodaX,j as saveRequiredSessionSnapshot,i as saveSessionSnapshot,a as validateAndFixToolHistory};
@@ -0,0 +1,2 @@
1
+ // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
+ import{$a as a,ab as b}from"./chunk-VEZ4WHPN.js";import"./chunk-ZQYWDI4O.js";import"./chunk-QOFFAY5C.js";import"./chunk-QGWHJIO4.js";import"./chunk-QZ4B4AWG.js";import"./chunk-K3DQGSQU.js";import"./chunk-OT5WHAX4.js";import"./chunk-ZZQ4GDVU.js";import"./chunk-2GV6MQ4T.js";import"./chunk-4VJMQDTH.js";import"./chunk-F7DHZH6T.js";import"./chunk-5DSUVP46.js";import"./chunk-VDGPJQL7.js";import"./chunk-ZPPAT25E.js";import"./chunk-7V2QBZ73.js";import"./chunk-ONUPGMER.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{De as Ye,Ee as Ze,Fe as Qe,Ie as et,Ob as Le,Pb as ze,Sb as Ge,Tb as Je,we as he,xe as Xe}from"./chunk-W7W2XKJC.js";import{Bg as je,Cg as Ue,Eg as Z,Ig as pe,Og as we,Pg as B,Qg as ge,Rg as Ve,Wa as re,Yg as Be,Zg as He,_g as Ke,v as me,yg as oe}from"./chunk-AWHU6MSJ.js";import{aa as De}from"./chunk-75IELO25.js";import{a as i}from"./chunk-ONUPGMER.js";import{basename as vr,dirname as xr}from"node:path";import{execFile as en}from"node:child_process";import ie from"node:path";import{promisify as tn}from"node:util";var nn=tn(en),rn=1e4,st=2,tt=new Set(["write","edit","multi_edit","insert_after_anchor"]),nt=new Set(["read"]);function on(e,t){if(t.includes("*"))return e;if(e.includes("*"))return t;let n=new Set(t);return e.filter(o=>n.has(o))}i(on,"intersectWorkflowToolCeilings");var an=/^\s*(?:let me|i will|i'll|i am going to)\b[\s\S]{0,120}\b(?:start|create|implement|write|build|plan)\b|^\s*(?:我将|让我|接下来)[\s\S]{0,80}(?:开始|创建|编写|实现|制定)/i;function sn(e){if(e?.timeoutMs!==void 0){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw new Error("workflow wait timeoutMs must be a positive number");return Math.floor(e.timeoutMs)}}i(sn,"normalizeWaitTimeoutMs");function ye(e){return e?.requiresMutation===!0||(e?.requiredChangedPaths?.length??0)>0}i(ye,"hasVerificationWork");function H(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}i(H,"normalizeWorkspacePath");function ke(e,t){let n=t.gitRoot?ie.resolve(t.gitRoot):void 0,o=ie.isAbsolute(e)&&n?ie.relative(n,ie.resolve(e)):e;return H(o)}i(ke,"normalizeRequiredPath");function cn(e){let t=(e.readOnly??!1)===!1?{enforcement:"warn",requiresMutation:!0,rejectPreparatoryFinalText:!0}:void 0;if(e.verification!==void 0){let n={...t??{},...e.verification,enforcement:e.verification.enforcement??"hard"},o=e.verification.requiredChangedPaths;return{verification:{...n,...o!==void 0&&o.length>0&&n.requiresMutation===void 0?{requiresMutation:!0}:{}}}}return{verification:t}}i(cn,"resolveVerificationForInput");function dn(e,t){if(t===!0&&e.readOnly===!1)throw new Error(`workflow manifest readOnly=true cannot spawn write-capable child "${e.name}"; set the workflow manifest readOnly=false or use child readOnly:true`);let n=e.readOnly??t??!1;return e.readOnly===n?e:{...e,readOnly:n}}i(dn,"resolveSpawnAgentInput");function ct(e){let t=e.trim();return t.length>0&&an.test(t)}i(ct,"isPreparatoryOnlyText");function un(e,t){let n=e.trim(),o=t?.trim();return o&&(n.length===0||ct(n))?o:e}i(un,"selectWorkflowFinalText");async function ae(e,t){return await re({cwd:t}),(await nn("git",[...e],{cwd:t,timeout:rn,windowsHide:!0,maxBuffer:4*1024*1024})).stdout.toString()}i(ae,"runGit");async function ln(e){let t=e.gitRoot??e.executionCwd??process.cwd(),n=(await ae(["rev-parse","--show-toplevel"],t)).trim(),o=await Promise.all([ae(["diff","--name-only","--"],n),ae(["diff","--cached","--name-only","--"],n),ae(["ls-files","--others","--exclude-standard"],n)]);return[...new Set(o.flatMap(a=>a.split(/\r?\n/)).map(H).filter(a=>a.length>0))]}i(ln,"listGitChangedFiles");async function ve(e,t){try{return{paths:(await t(e)).map(H).filter(o=>o.length>0)}}catch(n){return{paths:[],error:n instanceof Error?n.message:String(n)}}}i(ve,"captureChangedPaths");function fn(){return{toolNameById:new Map,toolPathById:new Map,succeededToolCalls:[],succeededPaths:[],readPathById:new Map,succeededReadPaths:[]}}i(fn,"createMutationRecorder");function rt(e){if(e)for(let t of["path","file_path","target_path"]){let n=e[t];if(typeof n=="string"&&n.trim().length>0)return H(n)}}i(rt,"readMutationPath");function mn(e,t){return{...e??{},onToolUseStart:i((n,o)=>{if(tt.has(n.name)){t.toolNameById.set(n.id,n.name);let a=rt(n.input);a!==void 0&&t.toolPathById.set(n.id,a)}if(nt.has(n.name)){let a=rt(n.input);a!==void 0&&t.readPathById.set(n.id,a)}e?.onToolUseStart?.(n,o)},"onToolUseStart"),onToolResult:i((n,o)=>{let a=t.toolNameById.get(n.id)??n.name;if(tt.has(a)&&!n.content.trimStart().startsWith("[Tool Error]")){t.succeededToolCalls.push(a);let r=t.toolPathById.get(n.id);r!==void 0&&t.succeededPaths.push(r)}if(nt.has(a)&&!n.content.trimStart().startsWith("[Tool Error]")){let r=t.readPathById.get(n.id);r!==void 0&&t.succeededReadPaths.push(r)}e?.onToolResult?.(n,o)},"onToolResult")}}i(mn,"wrapEventsForMutationRecording");function se(e){return[...new Set(e.filter(t=>t.trim().length>0))]}i(se,"uniqueItems");function ot(e){let t=e.verification;if(!t)return;let n=[],o=new Set(e.before.paths.map(H)),a=se(e.after.paths.map(H)),r=a.filter(m=>!o.has(m)),s=se(e.mutationRecorder.succeededToolCalls),d=e.acceptToolMutationEvidence?s:[],g=e.acceptToolMutationEvidence?se(e.mutationRecorder.succeededPaths.map(H)):[],h=r.length>0||d.length>0,y=t.enforcement??"hard",p=(t.requiredChangedPaths??[]).map(m=>ke(m,e.ctx)),b=se(e.mutationRecorder.succeededReadPaths.map(m=>ke(m,e.ctx))),v=(t.requiredReadPaths??[]).map(m=>ke(m,e.ctx));t.requiresMutation===!0&&(e.before.error!==void 0||e.after.error!==void 0?n.push(`workspace mutation verification could not read changed files: ${e.after.error??e.before.error}`):h||n.push(e.acceptToolMutationEvidence||s.length===0?"expected file mutations, but no new workspace changes or successful write tools were observed":"write tools ran in an isolated worktree, but no main workspace changes were present after cleanup")),e.term.limitReached===!0&&!h&&n.push("workflow child reached its iteration limit before satisfying the task");for(let m of p)!a.includes(m)&&!g.includes(m)&&n.push(`required changed path was not present in workspace changes: ${m}`);for(let m of v)b.includes(m)||n.push(`required review evidence was not read: ${m}`);let W=t.minFinalTextChars;return W!==void 0&&!h&&e.term.finalText.trim().length<W&&n.push(`finalText was shorter than the required ${W} characters`),t.rejectPreparatoryFinalText===!0&&!h&&ct(e.term.finalText)&&n.push("finalText looks preparatory instead of terminal"),{ok:n.length===0,enforcement:y,reasons:n,changedPaths:a,mutationToolCalls:s,mutationEvidence:h,...b.length>0?{readPaths:b}:{}}}i(ot,"evaluateVerification");function xe(e,t){if(t.ok)return e;let o=[t.enforcement==="warn"?"[Workflow task completed without verification]":"[Workflow task verification failed]",...t.reasons.map(a=>`- ${a}`)].join(`
2
+ import{De as Ye,Ee as Ze,Fe as Qe,Ie as et,Ob as Le,Pb as ze,Sb as Ge,Tb as Je,we as he,xe as Xe}from"./chunk-4VJMQDTH.js";import{Bg as je,Cg as Ue,Eg as Z,Ig as pe,Og as we,Pg as B,Qg as ge,Rg as Ve,Wa as re,Yg as Be,Zg as He,_g as Ke,v as me,yg as oe}from"./chunk-VDGPJQL7.js";import{ea as De}from"./chunk-7V2QBZ73.js";import{a as i}from"./chunk-ONUPGMER.js";import{basename as vr,dirname as xr}from"node:path";import{execFile as en}from"node:child_process";import ie from"node:path";import{promisify as tn}from"node:util";var nn=tn(en),rn=1e4,st=2,tt=new Set(["write","edit","multi_edit","insert_after_anchor"]),nt=new Set(["read"]);function on(e,t){if(t.includes("*"))return e;if(e.includes("*"))return t;let n=new Set(t);return e.filter(o=>n.has(o))}i(on,"intersectWorkflowToolCeilings");var an=/^\s*(?:let me|i will|i'll|i am going to)\b[\s\S]{0,120}\b(?:start|create|implement|write|build|plan)\b|^\s*(?:我将|让我|接下来)[\s\S]{0,80}(?:开始|创建|编写|实现|制定)/i;function sn(e){if(e?.timeoutMs!==void 0){if(!Number.isFinite(e.timeoutMs)||e.timeoutMs<=0)throw new Error("workflow wait timeoutMs must be a positive number");return Math.floor(e.timeoutMs)}}i(sn,"normalizeWaitTimeoutMs");function ye(e){return e?.requiresMutation===!0||(e?.requiredChangedPaths?.length??0)>0}i(ye,"hasVerificationWork");function H(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}i(H,"normalizeWorkspacePath");function ke(e,t){let n=t.gitRoot?ie.resolve(t.gitRoot):void 0,o=ie.isAbsolute(e)&&n?ie.relative(n,ie.resolve(e)):e;return H(o)}i(ke,"normalizeRequiredPath");function cn(e){let t=(e.readOnly??!1)===!1?{enforcement:"warn",requiresMutation:!0,rejectPreparatoryFinalText:!0}:void 0;if(e.verification!==void 0){let n={...t??{},...e.verification,enforcement:e.verification.enforcement??"hard"},o=e.verification.requiredChangedPaths;return{verification:{...n,...o!==void 0&&o.length>0&&n.requiresMutation===void 0?{requiresMutation:!0}:{}}}}return{verification:t}}i(cn,"resolveVerificationForInput");function dn(e,t){if(t===!0&&e.readOnly===!1)throw new Error(`workflow manifest readOnly=true cannot spawn write-capable child "${e.name}"; set the workflow manifest readOnly=false or use child readOnly:true`);let n=e.readOnly??t??!1;return e.readOnly===n?e:{...e,readOnly:n}}i(dn,"resolveSpawnAgentInput");function ct(e){let t=e.trim();return t.length>0&&an.test(t)}i(ct,"isPreparatoryOnlyText");function un(e,t){let n=e.trim(),o=t?.trim();return o&&(n.length===0||ct(n))?o:e}i(un,"selectWorkflowFinalText");async function ae(e,t){return await re({cwd:t}),(await nn("git",[...e],{cwd:t,timeout:rn,windowsHide:!0,maxBuffer:4*1024*1024})).stdout.toString()}i(ae,"runGit");async function ln(e){let t=e.gitRoot??e.executionCwd??process.cwd(),n=(await ae(["rev-parse","--show-toplevel"],t)).trim(),o=await Promise.all([ae(["diff","--name-only","--"],n),ae(["diff","--cached","--name-only","--"],n),ae(["ls-files","--others","--exclude-standard"],n)]);return[...new Set(o.flatMap(a=>a.split(/\r?\n/)).map(H).filter(a=>a.length>0))]}i(ln,"listGitChangedFiles");async function ve(e,t){try{return{paths:(await t(e)).map(H).filter(o=>o.length>0)}}catch(n){return{paths:[],error:n instanceof Error?n.message:String(n)}}}i(ve,"captureChangedPaths");function fn(){return{toolNameById:new Map,toolPathById:new Map,succeededToolCalls:[],succeededPaths:[],readPathById:new Map,succeededReadPaths:[]}}i(fn,"createMutationRecorder");function rt(e){if(e)for(let t of["path","file_path","target_path"]){let n=e[t];if(typeof n=="string"&&n.trim().length>0)return H(n)}}i(rt,"readMutationPath");function mn(e,t){return{...e??{},onToolUseStart:i((n,o)=>{if(tt.has(n.name)){t.toolNameById.set(n.id,n.name);let a=rt(n.input);a!==void 0&&t.toolPathById.set(n.id,a)}if(nt.has(n.name)){let a=rt(n.input);a!==void 0&&t.readPathById.set(n.id,a)}e?.onToolUseStart?.(n,o)},"onToolUseStart"),onToolResult:i((n,o)=>{let a=t.toolNameById.get(n.id)??n.name;if(tt.has(a)&&!n.content.trimStart().startsWith("[Tool Error]")){t.succeededToolCalls.push(a);let r=t.toolPathById.get(n.id);r!==void 0&&t.succeededPaths.push(r)}if(nt.has(a)&&!n.content.trimStart().startsWith("[Tool Error]")){let r=t.readPathById.get(n.id);r!==void 0&&t.succeededReadPaths.push(r)}e?.onToolResult?.(n,o)},"onToolResult")}}i(mn,"wrapEventsForMutationRecording");function se(e){return[...new Set(e.filter(t=>t.trim().length>0))]}i(se,"uniqueItems");function ot(e){let t=e.verification;if(!t)return;let n=[],o=new Set(e.before.paths.map(H)),a=se(e.after.paths.map(H)),r=a.filter(m=>!o.has(m)),s=se(e.mutationRecorder.succeededToolCalls),d=e.acceptToolMutationEvidence?s:[],g=e.acceptToolMutationEvidence?se(e.mutationRecorder.succeededPaths.map(H)):[],h=r.length>0||d.length>0,y=t.enforcement??"hard",p=(t.requiredChangedPaths??[]).map(m=>ke(m,e.ctx)),b=se(e.mutationRecorder.succeededReadPaths.map(m=>ke(m,e.ctx))),v=(t.requiredReadPaths??[]).map(m=>ke(m,e.ctx));t.requiresMutation===!0&&(e.before.error!==void 0||e.after.error!==void 0?n.push(`workspace mutation verification could not read changed files: ${e.after.error??e.before.error}`):h||n.push(e.acceptToolMutationEvidence||s.length===0?"expected file mutations, but no new workspace changes or successful write tools were observed":"write tools ran in an isolated worktree, but no main workspace changes were present after cleanup")),e.term.limitReached===!0&&!h&&n.push("workflow child reached its iteration limit before satisfying the task");for(let m of p)!a.includes(m)&&!g.includes(m)&&n.push(`required changed path was not present in workspace changes: ${m}`);for(let m of v)b.includes(m)||n.push(`required review evidence was not read: ${m}`);let W=t.minFinalTextChars;return W!==void 0&&!h&&e.term.finalText.trim().length<W&&n.push(`finalText was shorter than the required ${W} characters`),t.rejectPreparatoryFinalText===!0&&!h&&ct(e.term.finalText)&&n.push("finalText looks preparatory instead of terminal"),{ok:n.length===0,enforcement:y,reasons:n,changedPaths:a,mutationToolCalls:s,mutationEvidence:h,...b.length>0?{readPaths:b}:{}}}i(ot,"evaluateVerification");function xe(e,t){if(t.ok)return e;let o=[t.enforcement==="warn"?"[Workflow task completed without verification]":"[Workflow task verification failed]",...t.reasons.map(a=>`- ${a}`)].join(`
3
3
  `);return e.trim().length>0?`${e}
4
4
 
5
5
  ${o}`:o}i(xe,"appendVerificationFailure");function it(){return{ok:!1,enforcement:"warn",reasons:["workflow child reached its iteration limit before satisfying the task"],mutationEvidence:!1}}i(it,"limitReachedWarningVerification");function pn(e){return e.entry.bundle.readOnly!==!0&&e.entry.repairAttempts<st&&e.term.status==="completed"&&e.verification!==void 0&&e.verification.ok!==!0&&e.verification.enforcement!=="warn"}i(pn,"shouldRepairVerificationFailure");function wn(e){let t=e.verification.reasons.map(o=>`- ${o}`).join(`
@@ -13,7 +13,7 @@ ${s.text}`),rubric:t.rubric??xn}))).text,findings:o,degraded:a}}i(Mn,"runParalle
13
13
  `).trim().replace(/[\t\n\f\r ]+/g," ")}i(j,"normalizeText");function ft(e){return j(e).replace(/\\/g,"/")}i(ft,"normalizeLocation");function ce(e){return[...new Set(e.map(j).filter(Boolean))].sort((t,n)=>t<n?-1:t>n?1:0)}i(ce,"uniqueSorted");function En(e,t,n){return An("sha256").update(`${e}\0${ft(t)}\0${j(n)}`,"utf8").digest("hex")}i(En,"findingId");function mt(e,t,n){if(!t&&n.specVerdict!=="not-verifiable")throw new Error('review result must use specVerdict "not-verifiable" when requirements are absent');return{specVerdict:n.specVerdict,qualityVerdict:n.qualityVerdict,findings:n.findings.map(o=>{let a=ft(o.location),r=j(o.claim),s=j(o.evidence);return{findingId:En(e,a,r),severity:o.severity,location:a,claim:r,evidence:s,...o.suggestedFix?{suggestedFix:j(o.suggestedFix)}:{}}}).sort((o,a)=>o.findingId<a.findingId?-1:o.findingId>a.findingId?1:0),unverifiedRequirements:ce(n.unverifiedRequirements)}}i(mt,"normalizeScopedReviewResult");var lt={low:0,medium:1,high:2,critical:3};function Wn(e){return e.reduce((t,n)=>lt[n]>lt[t]?n:t,"low")}i(Wn,"maxSeverity");function pt(e){if(e.length===0)throw new Error("at least one primary review result is required");let t=new Map;for(let a of e)for(let r of a.findings)t.set(r.findingId,[...t.get(r.findingId)??[],r]);let n=[...t.entries()].map(([a,r])=>({findingId:a,severity:Wn(r.map(s=>s.severity)),location:r[0].location,claim:r[0].claim,evidence:ce(r.map(s=>s.evidence)),suggestedFixes:ce(r.flatMap(s=>s.suggestedFix?[s.suggestedFix]:[]))})).sort((a,r)=>a.findingId<r.findingId?-1:a.findingId>r.findingId?1:0);return{specVerdict:e.some(a=>a.specVerdict==="issues")?"issues":e.some(a=>a.specVerdict==="not-verifiable")?"not-verifiable":"compliant",qualityVerdict:e.some(a=>a.qualityVerdict==="needs-fixes")?"needs-fixes":"approved",findings:n,unverifiedRequirements:ce(e.flatMap(a=>a.unverifiedRequirements))}}i(pt,"mergeScopedReviewResults");function wt(e,t){let n=new Set(e.findings.map(s=>s.findingId)),o=new Set;for(let s of t.findings){if(!n.has(s.findingId)||o.has(s.findingId))throw new Error("verifier must return every input findingId exactly once");o.add(s.findingId)}if(o.size!==n.size)throw new Error("verifier must return every input findingId exactly once");let a=new Map(t.findings.map(s=>[s.findingId,s])),r=e.findings.flatMap(s=>{let d=a.get(s.findingId);if(d.disposition==="refuted")return[];let g=d.severityReason?.trim(),h=d.effectiveSeverity!==void 0&&!!g;return[{...s,disposition:d.disposition,severity:h?d.effectiveSeverity:s.severity,verificationEvidence:j(d.evidence),...g?{severityReason:j(g)}:{}}]});return{specVerdict:e.specVerdict,qualityVerdict:e.qualityVerdict,unverifiedRequirements:e.unverifiedRequirements,actionable:r,audit:t,unqualifiedApprovalAllowed:r.length===0&&e.unverifiedRequirements.length===0&&e.specVerdict==="compliant"&&e.qualityVerdict==="approved"}}i(wt,"applyFindingVerification");var Fn={type:"object",additionalProperties:!1,required:["summary"],properties:{summary:{type:"string"}}};function ht(e){return[e.packetPath,...e.evidenceChunks.map(t=>t.path)]}i(ht,"evidencePaths");function On(e){let t=he(e,Re);if(t.length>0)throw new Error(`primary reviewer structured result is invalid: ${t.join("; ")}`);return e}i(On,"rawReview");function qn(e){let t=he(e,be);if(t.length>0)throw new Error(`finding verifier structured result is invalid: ${t.join("; ")}`);return e}i(qn,"rawVerification");function Te(e,t){if(e===null||e.status!=="completed")throw new Error(`${t} did not complete; no verdict was accepted`);if(e.verification!==void 0&&!e.verification.ok)throw new Error(`${t} did not read every required packet path; no verdict was accepted`);return e}i(Te,"resultOrThrow");function Cn(e,t,n){return["Review one immutable KodaX packet as an independent third-party reviewer.",`Packet manifest: ${e.packetPath}`,...e.evidenceChunks.map(o=>`Evidence chunk: ${o.path}`),`This packet has binding requirements: ${e.requirementsPresent?"yes":"no"}.`,t?"This is the additional high-risk primary. Actively seek a disagreement with the first reader; do not assume it was correct.":"Own both specification and implementation-quality verdicts for this scope.",n.lean?"Also identify unnecessary additions, but never remove validation, security, data-loss protection, accessibility, or requested behavior.":"",n.reviewFocus?`Additional user focus: ${n.reviewFocus}`:"","Read the manifest and every listed chunk with the read tool before deciding.","Begin with the required JSON result. No preamble or process narration.","The findings array contains only actionable defects, never approval evidence or positive observations.","When the scope is compliant and approved with no actionable defect, findings must be empty.","If a named requirement cannot be proven compliant or violated from surfaced evidence, use specVerdict not-verifiable, list it in unverifiedRequirements, and emit no finding for that uncertainty; absence of evidence is not proof of a defect.","If requirements are absent, specVerdict must be not-verifiable."].filter(Boolean).join(`
14
14
  `)}i(Cn,"buildScopedReviewPrimaryPrompt");function $n(e,t){return["Independently attempt to refute every candidate finding in this batch.",`Packet manifest: ${e.packetPath}`,...e.evidenceChunks.map(n=>`Evidence chunk: ${n.path}`),`Canonical candidates: ${JSON.stringify(t.findings)}`,"Read the packet evidence. You may run one focused check after naming the concrete doubt.","Return every findingId exactly once. A severity change requires severityReason.","Begin with the required JSON result; no preamble."].join(`
15
15
  `)}i($n,"buildScopedReviewVerificationPrompt");function _n(e){return["Synthesize the structured review results below without rereading packet bodies.","Lead with confirmed findings, keep unresolved findings visibly unresolved, omit refuted findings from the actionable list, and never silently downgrade severity.","Cite locations and state explicitly when no actionable issue was confirmed.",JSON.stringify(e)].join(`
16
- `)}i(_n,"buildScopedReviewFinalPrompt");async function gt(e,t,n,o){let a=Te(await e.runAgent({name:`${n?"high-risk-":""}primary-${t.partitionKey}`,phase:"primary-review",prompt:Cn(t,n,o),scopeSummary:`${t.partitionKey}: ${t.scopePaths.join(", ")}`,constraints:["read every required packet path","return both verdicts","cite evidence at each finding"],readOnly:!0,modelHint:n?"deep":"balanced",verification:{enforcement:"hard",requiredReadPaths:ht(t)},outputSchema:Re,terseResult:!0}),"primary reviewer");return e.log({message:`primary read accepted for ${t.partitionKey}`,data:{kind:"review_packet_read",role:"primary",contentHash:t.contentHash}}),On(a.structured)}i(gt,"runPrimary");async function Nn(e,t,n){if(n.findings.length===0)return{specVerdict:n.specVerdict,qualityVerdict:n.qualityVerdict,unverifiedRequirements:n.unverifiedRequirements,actionable:[],audit:{findings:[]},unqualifiedApprovalAllowed:n.unverifiedRequirements.length===0&&n.specVerdict==="compliant"&&n.qualityVerdict==="approved"};let o=Te(await e.runAgent({name:`verify-${t.partitionKey}`,phase:"verifier",prompt:$n(t,n),scopeSummary:`verify ${n.findings.length} candidate finding(s) in ${t.partitionKey}`,constraints:["fresh context","attempt refutation","one disposition per findingId"],readOnly:!0,modelHint:"deep",verification:{enforcement:"hard",requiredReadPaths:ht(t)},outputSchema:be,terseResult:!0}),"finding verifier");return e.log({message:`verification read accepted for ${t.partitionKey}`,data:{kind:"review_packet_read",role:"verification",contentHash:t.contentHash,reason:"candidate findings"}}),wt(n,qn(o.structured))}i(Nn,"verifyFindings");async function Dn(e,t,n){let o=[await gt(e,t,!1,n)];t.riskFlags.includes("routing-high")&&o.push(await gt(e,t,!0,n));let a=o.map(d=>mt(t.contentHash,t.requirementsPresent,d)),r=pt(a),s=await Nn(e,t,r);return e.log({message:`quality gate completed for ${t.partitionKey}`,data:{kind:"review_quality_gate",contentHash:t.contentHash,actionableFindings:s.actionable.length,unresolvedFindings:s.actionable.filter(d=>d.disposition==="unresolved").length,unqualifiedApprovalAllowed:s.unqualifiedApprovalAllowed}}),{contentHash:t.contentHash,result:s}}i(Dn,"reviewPacket");async function jn(e,t){if(!Array.isArray(t.packets)||t.packets.length===0)throw new Error("scoped-review requires at least one review packet");let n=await e.parallel(t.packets.map(d=>()=>Dn(e,d,t)),{concurrency:4});if(n.some(d=>d===null))throw new Error("one or more scope packets failed review; no final verdict was accepted");let o=n.filter(d=>d!==null);await e.artifact("scoped-review-audit",o);let a=Te(await e.runAgent({name:"final-review-synthesis",phase:"final-synthesis",prompt:_n(o),scopeSummary:`cross-scope synthesis for ${o.length} packet(s)`,constraints:["preserve severity","preserve unresolved uncertainty","do not invent evidence"],readOnly:!0,modelHint:"deep",outputSchema:Fn,terseResult:!0}),"final synthesis"),r=a.structured;return{summary:typeof r?.summary=="string"?r.summary:a.finalText,packetResults:o}}i(jn,"runScopedReview");var yt={meta:{name:"scoped-review",description:"Review immutable scope packets once, verify only candidate findings, then synthesize.",readOnly:!0,phases:["primary-review","verifier","final-synthesis"],maxAgents:64,maxConcurrency:4},run:jn};function kt(e){return{meta:e.meta,run:i((t,n)=>e.run(t,n),"run")}}i(kt,"erase");var vt=[kt(ut),kt(yt)];function xt(e){return vt.find(t=>t.meta.name===e)}i(xt,"getBuiltinWorkflow");function oo(){return vt.map(e=>e.meta)}i(oo,"listBuiltinWorkflows");import{mkdir as It,readdir as Un,readFile as Q,rename as Vn,unlink as Me,writeFile as Ae}from"node:fs/promises";import{basename as Bn,dirname as Pe,join as K}from"node:path";import{pathToFileURL as Hn}from"node:url";var Pt=[".workflow.json",".ts",".mjs",".js"],ee="0.7.49";function Mt(){return"0.7.97-alpha.1"}i(Mt,"currentKodaxWorkflowVersion");function Kn(e){return e.endsWith(".workflow.json")?"capability-generated":"trusted-local"}i(Kn,"executionForPath");function Ln(e){let t=Pt.find(n=>e.endsWith(n));return t?e.slice(0,-t.length):void 0}i(Ln,"stripWorkflowSuffix");function Ee(e){let t=e.trim().replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,80);if(!t||t==="."||t==="..")throw new Error("workflow name must contain at least one safe filename character");return t}i(Ee,"safeWorkflowName");function We(e){return typeof e=="object"&&e!==null}i(We,"isRecord");function St(e,t){let n=e[t];if(typeof n!="string"||n.length===0)throw new Error(`workflow run.json missing ${t}`);return n}i(St,"readRequiredString");async function Rt(e,t){if(!e)return[];let n;try{n=await Un(e)}catch{return[]}let o=new Map;for(let a of Pt)for(let r of n){if(!r.endsWith(a))continue;let s=Ln(r);if(!s||s.length===0||o.has(s))continue;let d=K(e,r);o.set(s,{name:s,path:d,source:t,execution:Kn(d)})}return[...o.values()]}i(Rt,"scanDir");async function te(e){let t=await Rt(e.personal,"personal"),n=await Rt(e.project,"project"),o=new Map;for(let a of t)o.set(a.name,a);for(let a of n)o.set(a.name,a);return[...o.values()].sort((a,r)=>a.name.localeCompare(r.name))}i(te,"discoverSavedWorkflows");function zn(e){return typeof e=="object"&&e!==null&&"meta"in e&&"run"in e&&typeof e.run=="function"}i(zn,"isWorkflowModule");function Gn(e){let t=e.default;if(zn(t))return t;let n=typeof t=="function"?t:e.run,o=e.workflow??e.meta;if(typeof n=="function"&&typeof o=="object"&&o!==null&&"name"in o)return{meta:o,run:n};throw new Error("invalid workflow module: expected a `{ meta, run }` default export, or `export const workflow = {...}` + a default run function")}i(Gn,"normalizeWorkflowModule");function Jn(e){let t=JSON.parse(e);if(!We(t))throw new Error("generated workflow file must be an object");if(t.format!==void 0&&t.format!=="kodax.workflow")throw new Error(`unsupported workflow capsule format: ${String(t.format)}`);if(t.format==="kodax.workflow"){let a=we(t);return{manifest:a.manifest,source:a.source,capsule:a,legacy:!1}}let n=t.source;if(typeof n!="string"||n.trim().length===0)throw new Error("generated workflow file source must be a non-empty string");let o=Z(t.manifest);return{manifest:o,source:n,capsule:B({minKodaxVersion:ee,manifest:o,source:n}),legacy:!0}}i(Jn,"parseGeneratedWorkflowFile");async function Fe(e){let t=Jn(await Q(e,"utf8"));return t.capsule??B({minKodaxVersion:ee,manifest:t.manifest,source:t.source})}i(Fe,"loadSavedWorkflowCapsule");async function At(e){if(e.endsWith(".workflow.json"))return ge(await Fe(e));let t=await import(Hn(e).href);return Gn(t)}i(At,"loadSavedWorkflow");function Oe(e){if(e.mayUseWorktree===!0)return{environment:["git-repo","worktree-capable"]}}i(Oe,"deriveRequirements");function de(e,t){pe(t,{filename:`${e.name}.workflow.js`,requireAsyncRun:!0})}i(de,"assertGeneratedCapsuleSource");async function Xn(e){let t=Ee(e.name),n=Z(e.manifest);de(n,e.source);let o=e.requires??Oe(n),a=B({minKodaxVersion:e.minKodaxVersion??ee,manifest:n,source:e.source,...e.intent!==void 0?{intent:e.intent}:{},...e.inputs!==void 0?{inputs:e.inputs}:{},...o!==void 0?{requires:o}:{},...e.provenance!==void 0?{provenance:e.provenance}:{}});await It(e.dir,{recursive:!0});let r=K(e.dir,`${t}.workflow.json`);return await Ae(r,`${JSON.stringify(a,null,2)}
16
+ `)}i(_n,"buildScopedReviewFinalPrompt");async function gt(e,t,n,o){let a=Te(await e.runAgent({name:`${n?"high-risk-":""}primary-${t.partitionKey}`,phase:"primary-review",prompt:Cn(t,n,o),scopeSummary:`${t.partitionKey}: ${t.scopePaths.join(", ")}`,constraints:["read every required packet path","return both verdicts","cite evidence at each finding"],readOnly:!0,modelHint:n?"deep":"balanced",verification:{enforcement:"hard",requiredReadPaths:ht(t)},outputSchema:Re,terseResult:!0}),"primary reviewer");return e.log({message:`primary read accepted for ${t.partitionKey}`,data:{kind:"review_packet_read",role:"primary",contentHash:t.contentHash}}),On(a.structured)}i(gt,"runPrimary");async function Nn(e,t,n){if(n.findings.length===0)return{specVerdict:n.specVerdict,qualityVerdict:n.qualityVerdict,unverifiedRequirements:n.unverifiedRequirements,actionable:[],audit:{findings:[]},unqualifiedApprovalAllowed:n.unverifiedRequirements.length===0&&n.specVerdict==="compliant"&&n.qualityVerdict==="approved"};let o=Te(await e.runAgent({name:`verify-${t.partitionKey}`,phase:"verifier",prompt:$n(t,n),scopeSummary:`verify ${n.findings.length} candidate finding(s) in ${t.partitionKey}`,constraints:["fresh context","attempt refutation","one disposition per findingId"],readOnly:!0,modelHint:"deep",verification:{enforcement:"hard",requiredReadPaths:ht(t)},outputSchema:be,terseResult:!0}),"finding verifier");return e.log({message:`verification read accepted for ${t.partitionKey}`,data:{kind:"review_packet_read",role:"verification",contentHash:t.contentHash,reason:"candidate findings"}}),wt(n,qn(o.structured))}i(Nn,"verifyFindings");async function Dn(e,t,n){let o=[await gt(e,t,!1,n)];t.riskFlags.includes("routing-high")&&o.push(await gt(e,t,!0,n));let a=o.map(d=>mt(t.contentHash,t.requirementsPresent,d)),r=pt(a),s=await Nn(e,t,r);return e.log({message:`quality gate completed for ${t.partitionKey}`,data:{kind:"review_quality_gate",contentHash:t.contentHash,actionableFindings:s.actionable.length,unresolvedFindings:s.actionable.filter(d=>d.disposition==="unresolved").length,unqualifiedApprovalAllowed:s.unqualifiedApprovalAllowed}}),{contentHash:t.contentHash,result:s}}i(Dn,"reviewPacket");async function jn(e,t){if(!Array.isArray(t.packets)||t.packets.length===0)throw new Error("scoped-review requires at least one review packet");let n=await e.parallel(t.packets.map(d=>()=>Dn(e,d,t)),{concurrency:4});if(n.some(d=>d===null))throw new Error("one or more scope packets failed review; no final verdict was accepted");let o=n.filter(d=>d!==null);await e.artifact("scoped-review-audit",o);let a=Te(await e.runAgent({name:"final-review-synthesis",phase:"final-synthesis",prompt:_n(o),scopeSummary:`cross-scope synthesis for ${o.length} packet(s)`,constraints:["preserve severity","preserve unresolved uncertainty","do not invent evidence"],readOnly:!0,modelHint:"deep",outputSchema:Fn,terseResult:!0}),"final synthesis"),r=a.structured;return{summary:typeof r?.summary=="string"?r.summary:a.finalText,packetResults:o}}i(jn,"runScopedReview");var yt={meta:{name:"scoped-review",description:"Review immutable scope packets once, verify only candidate findings, then synthesize.",readOnly:!0,phases:["primary-review","verifier","final-synthesis"],maxAgents:64,maxConcurrency:4},run:jn};function kt(e){return{meta:e.meta,run:i((t,n)=>e.run(t,n),"run")}}i(kt,"erase");var vt=[kt(ut),kt(yt)];function xt(e){return vt.find(t=>t.meta.name===e)}i(xt,"getBuiltinWorkflow");function oo(){return vt.map(e=>e.meta)}i(oo,"listBuiltinWorkflows");import{mkdir as It,readdir as Un,readFile as Q,rename as Vn,unlink as Me,writeFile as Ae}from"node:fs/promises";import{basename as Bn,dirname as Pe,join as K}from"node:path";import{pathToFileURL as Hn}from"node:url";var Pt=[".workflow.json",".ts",".mjs",".js"],ee="0.7.49";function Mt(){return"0.7.97-alpha.2"}i(Mt,"currentKodaxWorkflowVersion");function Kn(e){return e.endsWith(".workflow.json")?"capability-generated":"trusted-local"}i(Kn,"executionForPath");function Ln(e){let t=Pt.find(n=>e.endsWith(n));return t?e.slice(0,-t.length):void 0}i(Ln,"stripWorkflowSuffix");function Ee(e){let t=e.trim().replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,80);if(!t||t==="."||t==="..")throw new Error("workflow name must contain at least one safe filename character");return t}i(Ee,"safeWorkflowName");function We(e){return typeof e=="object"&&e!==null}i(We,"isRecord");function St(e,t){let n=e[t];if(typeof n!="string"||n.length===0)throw new Error(`workflow run.json missing ${t}`);return n}i(St,"readRequiredString");async function Rt(e,t){if(!e)return[];let n;try{n=await Un(e)}catch{return[]}let o=new Map;for(let a of Pt)for(let r of n){if(!r.endsWith(a))continue;let s=Ln(r);if(!s||s.length===0||o.has(s))continue;let d=K(e,r);o.set(s,{name:s,path:d,source:t,execution:Kn(d)})}return[...o.values()]}i(Rt,"scanDir");async function te(e){let t=await Rt(e.personal,"personal"),n=await Rt(e.project,"project"),o=new Map;for(let a of t)o.set(a.name,a);for(let a of n)o.set(a.name,a);return[...o.values()].sort((a,r)=>a.name.localeCompare(r.name))}i(te,"discoverSavedWorkflows");function zn(e){return typeof e=="object"&&e!==null&&"meta"in e&&"run"in e&&typeof e.run=="function"}i(zn,"isWorkflowModule");function Gn(e){let t=e.default;if(zn(t))return t;let n=typeof t=="function"?t:e.run,o=e.workflow??e.meta;if(typeof n=="function"&&typeof o=="object"&&o!==null&&"name"in o)return{meta:o,run:n};throw new Error("invalid workflow module: expected a `{ meta, run }` default export, or `export const workflow = {...}` + a default run function")}i(Gn,"normalizeWorkflowModule");function Jn(e){let t=JSON.parse(e);if(!We(t))throw new Error("generated workflow file must be an object");if(t.format!==void 0&&t.format!=="kodax.workflow")throw new Error(`unsupported workflow capsule format: ${String(t.format)}`);if(t.format==="kodax.workflow"){let a=we(t);return{manifest:a.manifest,source:a.source,capsule:a,legacy:!1}}let n=t.source;if(typeof n!="string"||n.trim().length===0)throw new Error("generated workflow file source must be a non-empty string");let o=Z(t.manifest);return{manifest:o,source:n,capsule:B({minKodaxVersion:ee,manifest:o,source:n}),legacy:!0}}i(Jn,"parseGeneratedWorkflowFile");async function Fe(e){let t=Jn(await Q(e,"utf8"));return t.capsule??B({minKodaxVersion:ee,manifest:t.manifest,source:t.source})}i(Fe,"loadSavedWorkflowCapsule");async function At(e){if(e.endsWith(".workflow.json"))return ge(await Fe(e));let t=await import(Hn(e).href);return Gn(t)}i(At,"loadSavedWorkflow");function Oe(e){if(e.mayUseWorktree===!0)return{environment:["git-repo","worktree-capable"]}}i(Oe,"deriveRequirements");function de(e,t){pe(t,{filename:`${e.name}.workflow.js`,requireAsyncRun:!0})}i(de,"assertGeneratedCapsuleSource");async function Xn(e){let t=Ee(e.name),n=Z(e.manifest);de(n,e.source);let o=e.requires??Oe(n),a=B({minKodaxVersion:e.minKodaxVersion??ee,manifest:n,source:e.source,...e.intent!==void 0?{intent:e.intent}:{},...e.inputs!==void 0?{inputs:e.inputs}:{},...o!==void 0?{requires:o}:{},...e.provenance!==void 0?{provenance:e.provenance}:{}});await It(e.dir,{recursive:!0});let r=K(e.dir,`${t}.workflow.json`);return await Ae(r,`${JSON.stringify(a,null,2)}
17
17
  `,"utf8"),{name:t,path:r,source:"project",execution:"capability-generated"}}i(Xn,"saveGeneratedWorkflow");async function bt(e,t){await Ae(e,`${JSON.stringify(t,null,2)}
18
18
  `,"utf8")}i(bt,"writeCapsuleFile");async function Yn(e){try{return await Q(e,"utf8"),!0}catch{return!1}}i(Yn,"fileExists");async function fo(e){let t=(await te(e.dirs)).filter(d=>d.name===e.name).filter(d=>e.source===void 0||d.source===e.source);if(t.length===0)throw new Error(`saved workflow not found: ${e.name}`);if(t.length>1)throw new Error(`ambiguous saved workflow name: ${e.name}`);let n=t[0];if(!n.path.endsWith(".workflow.json"))throw new Error("only generated workflow capsules can be renamed");let o=Ee(e.newName),a=K(Pe(n.path),`${o}.workflow.json`);if(a!==n.path&&await Yn(a))throw new Error(`saved workflow already exists: ${o}`);let r=await Fe(n.path);de(r.manifest,r.source);let s=B({minKodaxVersion:r.minKodaxVersion,manifest:{...r.manifest,name:o},source:r.source,...r.intent!==void 0?{intent:r.intent}:{},...r.inputs!==void 0?{inputs:r.inputs}:{},...r.requires!==void 0?{requires:r.requires}:{},...r.provenance!==void 0?{provenance:r.provenance}:{}});return await Ae(a,`${JSON.stringify(s,null,2)}
19
19
  `,"utf8"),a!==n.path&&await Me(n.path),{name:o,path:a,source:n.source,execution:"capability-generated"}}i(fo,"renameSavedWorkflow");async function mo(e){let t=(await te(e.dirs)).filter(o=>o.name===e.name).filter(o=>e.source===void 0||o.source===e.source);if(t.length===0)throw new Error(`saved workflow not found: ${e.name}`);if(t.length>1)throw new Error(`ambiguous saved workflow name: ${e.name}`);let n=t[0];if(!n.path.endsWith(".workflow.json"))throw new Error("only generated workflow capsules can be deleted");return await Me(n.path),n}i(mo,"deleteSavedWorkflow");async function po(e){let t=Ee(e.name),n=(await te(e.dirs)).filter(v=>v.name===t).filter(v=>e.savedSource===void 0||v.source===e.savedSource);if(n.length===0)throw new Error(`saved workflow not found: ${t}`);if(n.length>1)throw new Error(`ambiguous saved workflow name: ${t}`);let o=n[0];if(!o.path.endsWith(".workflow.json"))throw new Error("only generated workflow capsules can be replaced");let a=Z({...e.manifest,name:t});de(a,e.source);let r=e.requires??Oe(a),s=B({minKodaxVersion:e.minKodaxVersion??ee,manifest:a,source:e.source,...e.intent!==void 0?{intent:e.intent}:{},...e.inputs!==void 0?{inputs:e.inputs}:{},...r!==void 0?{requires:r}:{},...e.provenance!==void 0?{provenance:e.provenance}:{}}),d=await Fe(o.path),g=new Date().toISOString().replace(/[:.]/g,"-"),h=K(Pe(o.path),".revisions",t),y=`${g}-${process.hrtime.bigint().toString(36)}`,p=K(h,`${t}-${y}.workflow.json`),b=K(Pe(o.path),`.${t}.${process.pid}.${Date.now().toString(36)}.tmp`);await It(h,{recursive:!0}),await bt(p,d);try{await bt(b,s),await Vn(b,o.path)}catch(v){try{await Me(b)}catch{}throw v}return{name:t,path:o.path,source:o.source,execution:"capability-generated",previousPath:p}}i(po,"replaceSavedWorkflow");function Zn(e){if(!We(e))return;let t=e.request;if(typeof t=="string"&&t.trim().length>0)return t;let n=e.question;if(typeof n=="string"&&n.trim().length>0)return n}i(Zn,"readOptionalOriginalRequest");function Et(e){return Qn(e)}i(Et,"buildCapsuleFromRun");async function Qn(e){let t=JSON.parse(await Q(K(e.runDir,"run.json"),"utf8"));if(!We(t))throw new Error("workflow run.json must be an object");let n=St(t,"scriptSnapshotPath"),o=St(t,"manifestSnapshotPath"),a=await Q(n,"utf8"),r=Z(JSON.parse(await Q(o,"utf8")));de(r,a);let s=typeof t.runId=="string"&&t.runId.length>0?t.runId:Bn(e.runDir),d=Zn(t.args),g=Oe(r),h=Ve(r,d!==void 0?{originalRequest:d}:{}),y={description:"Provide new workflow args matching the generated request shape.",..."args"in t?{examples:[t.args]}:{}};return B({minKodaxVersion:ee,manifest:r,source:a,intent:h,inputs:y,...g!==void 0?{requires:g}:{},provenance:{fromRunId:s,createdAt:new Date().toISOString(),kodaxVersion:Mt()}})}i(Qn,"readCapsuleFromRun");async function wo(e){let t=await Et(e);return{capsule:t,module:ge(t)}}i(wo,"loadGeneratedWorkflowFromRun");async function go(e){let t=await Et(e);return Xn({dir:e.targetDir,name:e.name,manifest:t.manifest,source:t.source,...t.intent!==void 0?{intent:t.intent}:{},...t.inputs!==void 0?{inputs:t.inputs}:{},...t.requires!==void 0?{requires:t.requires}:{},...t.provenance!==void 0?{provenance:t.provenance}:{},minKodaxVersion:t.minKodaxVersion})}i(go,"saveGeneratedWorkflowFromRun");function U(e,t,n,o){e.push({severity:t,requirement:n,message:o})}i(U,"addRequirementIssue");function Tt(e){let t=/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());if(t)return[Number(t[1]),Number(t[2]),Number(t[3])]}i(Tt,"parseSemver");function er(e,t){for(let n=0;n<3;n+=1){let o=e[n]-t[n];if(o!==0)return o}return 0}i(er,"compareSemver");function tr(e,t,n){let o=Tt(t),a=Tt(n);if(!o){U(e,"error","kodax:min-version",`workflow minKodaxVersion is not valid semver: ${t}`);return}if(!a){U(e,"warning","kodax:min-version",`cannot verify workflow minKodaxVersion ${t}; current version is unknown`);return}er(a,o)<0&&U(e,"error","kodax:min-version",`workflow requires KodaX >= ${t}, current version is ${n}`)}i(tr,"addMinVersionIssue");function Ie(e,t,n,o){if(!n)return;if(!o){for(let r of n)U(e,"warning",`${t}:${r}`,`workflow requires ${t}:${r}, but no ${t} inventory was provided`);return}let a=new Set(o);for(let r of n)a.has(r)||U(e,"error",`${t}:${r}`,`missing required workflow ${t}: ${r}`)}i(Ie,"addMissingItems");function ho(e,t={}){let n=we(e),o=[],a=n.requires;tr(o,n.minKodaxVersion,t.kodaxVersion??Mt()),a?.environment?.includes("git-repo")&&t.isGitRepo===!1&&U(o,"error","environment:git-repo","workflow requires a git repository"),a?.environment?.includes("worktree-capable")&&t.worktreeCapable===!1&&U(o,"error","environment:worktree-capable","workflow may request git worktree isolation");try{pe(n.source,{filename:`${n.manifest.name}.workflow.js`,requireAsyncRun:!0})}catch(r){let s=r instanceof Error?r.message:String(r);U(o,"error","workflow:source",s)}return Ie(o,"tools",a?.tools,t.availableTools),Ie(o,"mcp",a?.mcp,t.availableMcp),Ie(o,"skills",a?.skills,t.availableSkills),{ok:!o.some(r=>r.severity==="error"),issues:o}}i(ho,"preflightWorkflowCapsule");function rr(e){return{project:Wt(e,".kodax","workflows"),personal:Wt(nr(),".kodax","workflows")}}i(rr,"defaultSavedWorkflowDirs");async function or(e,t){let o=(await te(t)).find(a=>a.name===e);if(o)return At(o.path)}i(or,"resolveSavedByName");function Ft(e){let t=rr(e);return async n=>xt(n)??await or(n,t)}i(Ft,"createNestedWorkflowResolver");import{existsSync as ir,mkdirSync as ar,readFileSync as sr,writeFileSync as Ot}from"node:fs";import{join as ne}from"node:path";var qt="results";function Ct(e){return e.replace(/[^a-zA-Z0-9._-]/g,"_")}i(Ct,"safeKey");function $t(e,t){let n=ne(e,t);if(ir(n))try{return JSON.parse(sr(n,"utf8"))}catch{return}}i($t,"readResult");function _t(e,t={}){let n=ne(e,qt);ar(n,{recursive:!0});let o=t.readFrom?ne(t.readFrom,qt):void 0;return{get:i(a=>{let r=`${Ct(a)}.json`,s=$t(n,r);if(s!==void 0)return s;if(o===void 0)return;let d=$t(o,r);if(d!==void 0){try{Ot(ne(n,r),JSON.stringify(d),"utf8")}catch{}return d}},"get"),set:i((a,r)=>{try{Ot(ne(n,`${Ct(a)}.json`),JSON.stringify(r),"utf8")}catch{}},"set")}}i(_t,"createFsResultCache");import{mkdirSync as cr,appendFileSync as dr,writeFileSync as le}from"node:fs";import{join as G}from"node:path";function ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}i(ue,"record");function F(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}i(F,"finiteNumber");function Nt(e){let t=new Map,n=new Set,o=[],a=[],r=new Set,s=[],d=[],g=0,h=0,y=0,p=0,b=0,v=0,W=0,m=0,T={},$=[];for(let C of e){let M=C.data??{};if(C.type==="agent_spawned"){let u=typeof M.taskId=="string"?M.taskId:void 0;u&&t.set(u,M),M.role==="primary-review"&&(v+=1);let w=typeof M.role=="string"?M.role:"agent",S=typeof M.requestedTier=="string"?M.requestedTier:"inherited",I=`${w}/${S}`;T[I]=(T[I]??0)+1;continue}if(C.type==="agent_completed"||C.type==="agent_unverified"||C.type==="agent_failed"){let u=typeof M.taskId=="string"?M.taskId:void 0;if(!u||n.has(u))continue;n.add(u);let w=ue(M.usage);!w||typeof w.totalTokens!="number"?typeof t.get(u)?.externalTarget=="string"?a.push(u):o.push(u):(g+=F(w.totalTokens),h+=F(w.inputTokens),y+=F(w.cacheReadTokens??w.cachedReadTokens),p+=F(w.outputTokens));let S=ue(M.digestUsage);b+=F(S?.totalTokens),h+=F(S?.inputTokens),p+=F(S?.outputTokens),y+=F(S?.cacheReadTokens??S?.cachedReadTokens),W+=F(M.iterations);continue}if(C.type==="agent_summary_updated"){let u=ue(M.usage),w=M.summaryKind;if((w==="digest"||w==="digest-failed")&&u){let S=F(u.totalTokens);g+=S,b+=S,h+=F(u.inputTokens),p+=F(u.outputTokens),y+=F(u.cacheReadTokens??u.cachedReadTokens)}continue}if(C.type!=="workflow_log")continue;let f=ue(M.data);if(f?.kind==="review_quality_gate"&&typeof f.contentHash=="string"){$.push({contentHash:f.contentHash,actionableFindings:F(f.actionableFindings),unresolvedFindings:F(f.unresolvedFindings),unqualifiedApprovalAllowed:f.unqualifiedApprovalAllowed===!0});continue}if(f?.kind!=="review_packet_read"||typeof f.contentHash!="string")continue;let l={contentHash:f.contentHash,...typeof f.reason=="string"?{reason:f.reason}:{}};f.role==="primary"?(r.has(f.contentHash)&&(m+=1),r.add(f.contentHash)):f.role==="verification"?s.push(l):f.role==="synthesis"&&d.push(l)}for(let C of t.keys())n.has(C)||o.push(C);let J=[...new Set(o)].sort();return{totalModelTokens:g,inputTokens:h,cacheReadTokens:y,outputTokens:p,digestTokens:b,agentStarts:t.size,childTurns:W,agentStartsByRoleTier:T,primaryReviewStarts:v,duplicatePrimaryPacketReads:m,verificationPacketReads:s,synthesisPacketReads:d,reviewWaves:v>0?1:0,fixWaves:0,rereviewWaves:0,qualityGateOutcomes:$,tokenCoverage:{ok:J.length===0,missingTaskIds:J},excludedExternalTaskIds:[...new Set(a)].sort()}}i(Nt,"buildWorkflowCostReport");function ur(e){let t=e.replace(/[^a-zA-Z0-9._-]/g,"_").slice(0,120);return t.length>0?t:"artifact"}i(ur,"safeWorkflowArtifactName");function Dt(e,t={}){let n=t.now??(()=>Date.now()),o=G(e,"artifacts");cr(o,{recursive:!0});let a=G(e,"events.jsonl");return{runDir:e,onEvent:i(r=>{dr(a,`${JSON.stringify({...r,ts:n()})}
@@ -1,5 +1,5 @@
1
1
  // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{Ka as v}from"./chunk-AWHU6MSJ.js";import{a}from"./chunk-ONUPGMER.js";import{spawnSync as O}from"node:child_process";import{createHash as F}from"node:crypto";import c from"node:fs";import q from"node:os";import i from"node:path";import{fileURLToPath as W}from"node:url";var z=64*1024*1024,Y="v2";function x(){{let e=JSON.parse('{"darwin-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"3822f552af1c81ddc3df0de743f5bbd87c0588d9aa0f9617446f22b6b483a156\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","darwin-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"7c8ab6d7b687cc0a2ff3dd453921eb449f12b8481e1815793bbbccfd39911385\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"3f788f0fb2bd627c758fcfe5b171cfed20da8102fa31d56e41b3047e855c016e\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"a667ba689ef9b95118236496e60612ee4407dae02a67fdef30e6456ee4592a6a\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","win32-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"win32\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-windows-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"a0888d2555da6a81ee99bce92c07673beac4bac11636db51b752aacb35ca1336\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"f8dd90eb71a7af4048bde3ff1d18b7d7280522e0a429ff71b7270a4189cf3568\\"\\n },\\n {\\n \\"file\\": \\"NOTICE-windows-sandbox.txt\\",\\n \\"sha256\\": \\"78723eb162f0782c5e27928f46c681996edc1907d552eba9d0f7f53e014c20c9\\"\\n }\\n ],\\n \\"shellSandbox\\": {\\n \\"file\\": \\"kodax-windows-sandbox.exe\\",\\n \\"protocol\\": 10,\\n \\"sha256\\": \\"b0463c51725a370c5241bd8f513b8eba400553cf7d0dbe0b04df98939c2a1878\\"\\n },\\n \\"asrtRunner\\": {\\n \\"file\\": \\"srt-win.exe\\",\\n \\"version\\": \\"0.0.65\\",\\n \\"sha256\\": \\"777736e17d6cf9b4280f155f5cda731fdff0f789fa16e6cb3adc0006073e241a\\"\\n }\\n}\\n"}');if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("embedded native manifest map is invalid");let t=e[`${process.platform}-${process.arch}`];if(typeof t!="string"||t==="")throw new Error(`embedded native manifest is missing for ${process.platform}-${process.arch}`);return t}return process.platform==="win32",`{
2
+ import{Ka as v}from"./chunk-VDGPJQL7.js";import{a}from"./chunk-ONUPGMER.js";import{spawnSync as O}from"node:child_process";import{createHash as F}from"node:crypto";import c from"node:fs";import q from"node:os";import i from"node:path";import{fileURLToPath as W}from"node:url";var z=64*1024*1024,Y="v2";function x(){{let e=JSON.parse('{"darwin-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"3822f552af1c81ddc3df0de743f5bbd87c0588d9aa0f9617446f22b6b483a156\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","darwin-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"darwin\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"7c8ab6d7b687cc0a2ff3dd453921eb449f12b8481e1815793bbbccfd39911385\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-arm64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"arm64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"3f788f0fb2bd627c758fcfe5b171cfed20da8102fa31d56e41b3047e855c016e\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","linux-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"linux\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"a667ba689ef9b95118236496e60612ee4407dae02a67fdef30e6456ee4592a6a\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"6bdadfab6d5d2b0d4e0ccea244f5e412d1597dc84c56db645556ce192b131e98\\"\\n }\\n ]\\n}\\n","win32-x64":"{\\n \\"version\\": 1,\\n \\"platform\\": \\"win32\\",\\n \\"arch\\": \\"x64\\",\\n \\"textTransaction\\": {\\n \\"file\\": \\"kodax-windows-text-transaction.node\\",\\n \\"protocol\\": 5,\\n \\"sha256\\": \\"f9b3abd5765c501e5828a5ef8d6a8ebf42c77bac25a2e286133d30aafe370fd5\\"\\n },\\n \\"legal\\": [\\n {\\n \\"file\\": \\"LICENSE-APACHE.txt\\",\\n \\"sha256\\": \\"f8dd90eb71a7af4048bde3ff1d18b7d7280522e0a429ff71b7270a4189cf3568\\"\\n },\\n {\\n \\"file\\": \\"NOTICE-windows-sandbox.txt\\",\\n \\"sha256\\": \\"78723eb162f0782c5e27928f46c681996edc1907d552eba9d0f7f53e014c20c9\\"\\n }\\n ],\\n \\"shellSandbox\\": {\\n \\"file\\": \\"kodax-windows-sandbox.exe\\",\\n \\"protocol\\": 10,\\n \\"sha256\\": \\"f9fc7ab01a13735671f00ee02d3db134efdc5b1b96d40ec05b8bf7750fbc0b40\\"\\n },\\n \\"asrtRunner\\": {\\n \\"file\\": \\"srt-win.exe\\",\\n \\"version\\": \\"0.0.65\\",\\n \\"sha256\\": \\"777736e17d6cf9b4280f155f5cda731fdff0f789fa16e6cb3adc0006073e241a\\"\\n }\\n}\\n"}');if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("embedded native manifest map is invalid");let t=e[`${process.platform}-${process.arch}`];if(typeof t!="string"||t==="")throw new Error(`embedded native manifest is missing for ${process.platform}-${process.arch}`);return t}return process.platform==="win32",`{
3
3
  "version": 1,
4
4
  "platform": "linux",
5
5
  "arch": "x64",