crewx 0.9.0-rc.235 → 0.9.0-rc.237

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 (115) hide show
  1. package/bin/crewx-dispatch.js +3 -0
  2. package/bin/crewx-memory-runtime.js +3 -0
  3. package/bin/crewx.js +9 -2
  4. package/dist/assets/{DocSyncTextDiff-DvjM8Vgr.js → DocSyncTextDiff-B6Xm9KkT.js} +1 -1
  5. package/dist/assets/{GitDiffEditor-fJ0VM5TW.js → GitDiffEditor-C-PWr-1s.js} +1 -1
  6. package/dist/assets/{MarketPage-CktwzxGx.js → MarketPage-rgKLj_sA.js} +1 -1
  7. package/dist/assets/{MonacoDiffSurface-DTvss6yK.js → MonacoDiffSurface-BZmnrlo7.js} +7 -7
  8. package/dist/assets/{PromptTab-D9IWOfzR.js → PromptTab-Bi2btRqZ.js} +1 -1
  9. package/dist/assets/{abnfDiagram-VCTEODGH-CVytGkhC.js → abnfDiagram-VCTEODGH-BoyuSq0D.js} +1 -1
  10. package/dist/assets/{arc-DDVYNnYx.js → arc-E5iEdPfE.js} +1 -1
  11. package/dist/assets/{architectureDiagram-5GKGNRK7-Oc8KWbVv.js → architectureDiagram-5GKGNRK7-DxkKJxW-.js} +1 -1
  12. package/dist/assets/{blockDiagram-I7D4REHJ-oMAtDcWJ.js → blockDiagram-I7D4REHJ--dVaVxm9.js} +1 -1
  13. package/dist/assets/{c4Diagram-7LVT6UL2-Ck63f2v3.js → c4Diagram-7LVT6UL2-CTmTK7FK.js} +1 -1
  14. package/dist/assets/channel-2icooOsQ.js +1 -0
  15. package/dist/assets/{chunk-2Q5K7J3B-odEcoS6-.js → chunk-2Q5K7J3B-mXtBqkPH.js} +1 -1
  16. package/dist/assets/{chunk-5VM5RSS4-NYxZRwMP.js → chunk-5VM5RSS4-CHNwKeYg.js} +1 -1
  17. package/dist/assets/{chunk-F27PBJKO-B1RYRVvk.js → chunk-F27PBJKO-C7y5DoIM.js} +1 -1
  18. package/dist/assets/{chunk-IMKFNOWR-CvZy0wJ2.js → chunk-IMKFNOWR-Cy0d_9oN.js} +1 -1
  19. package/dist/assets/{chunk-JWPE2WC7-CLohUgtr.js → chunk-JWPE2WC7-plHyrLqQ.js} +1 -1
  20. package/dist/assets/{chunk-POPQ4Y6H-D_NOlvF5.js → chunk-POPQ4Y6H-D7RRXLQG.js} +1 -1
  21. package/dist/assets/{chunk-SVP7TREG-BXCpSBDH.js → chunk-SVP7TREG-Df4HRG0z.js} +1 -1
  22. package/dist/assets/{chunk-TICWLB2K-eTLoZ-9R.js → chunk-TICWLB2K-CliZPZEn.js} +1 -1
  23. package/dist/assets/{chunk-XXDRQBXY-Cug-2lnZ.js → chunk-XXDRQBXY-MNVs1Deh.js} +1 -1
  24. package/dist/assets/classDiagram-ZZMXUADV-BWJqEFYO.js +1 -0
  25. package/dist/assets/classDiagram-v2-VYDZK3BY-BWJqEFYO.js +1 -0
  26. package/dist/assets/{cose-bilkent-JH36ORCC-KvJObjt-.js → cose-bilkent-JH36ORCC-BvfKJREV.js} +1 -1
  27. package/dist/assets/{cssMode-nQO5r-T-.js → cssMode-CnrK9xi1.js} +1 -1
  28. package/dist/assets/{cynefin-OW5HDTMX-BrTmIjZd.js → cynefin-OW5HDTMX-BtqQvSax.js} +1 -1
  29. package/dist/assets/{cynefinDiagram-5FMLGOSQ-D8htA4FL.js → cynefinDiagram-5FMLGOSQ-B8IvxJ0y.js} +1 -1
  30. package/dist/assets/{dagre-GXQ25YYZ-B4WVYdAY.js → dagre-GXQ25YYZ-FxGcv8M0.js} +1 -1
  31. package/dist/assets/{diagram-S7CK7UJ4-CtPvpiZa.js → diagram-S7CK7UJ4-DohFMUWD.js} +1 -1
  32. package/dist/assets/{diagram-UQ7AKVKN-GVVunw9Z.js → diagram-UQ7AKVKN-DbWV995D.js} +1 -1
  33. package/dist/assets/{diagram-VSXAHHWV-CVUqc9W2.js → diagram-VSXAHHWV-BXPqvVGH.js} +1 -1
  34. package/dist/assets/{diagram-VX7I27RA-DmhAoXYK.js → diagram-VX7I27RA-CsLgwaku.js} +1 -1
  35. package/dist/assets/{diagram-Z3DM3KII-BHJwMpjF.js → diagram-Z3DM3KII-CfQuaoFx.js} +1 -1
  36. package/dist/assets/{ebnfDiagram-PWID7BFC-D94a2uao.js → ebnfDiagram-PWID7BFC-BPYA-Uu3.js} +1 -1
  37. package/dist/assets/{erDiagram-RLTQ6QDP-DfTcHSRd.js → erDiagram-RLTQ6QDP-DA-9ihpi.js} +1 -1
  38. package/dist/assets/{flowDiagram-HODETNUW-Du6UsnIJ.js → flowDiagram-HODETNUW-NJ2kpyR6.js} +1 -1
  39. package/dist/assets/{freemarker2-B8HTg__u.js → freemarker2-D6VRQn3o.js} +1 -1
  40. package/dist/assets/{ganttDiagram-EL5Y4UJY-BiugklIy.js → ganttDiagram-EL5Y4UJY-CN80a1vb.js} +1 -1
  41. package/dist/assets/{gitGraphDiagram-WWUBYQGX-CUFK8rKJ.js → gitGraphDiagram-WWUBYQGX-DnkPDwzA.js} +1 -1
  42. package/dist/assets/{handlebars-SnwfPwsC.js → handlebars-CBTdj-E_.js} +1 -1
  43. package/dist/assets/{html-CyxfrRMO.js → html-CKlYOoZd.js} +1 -1
  44. package/dist/assets/{htmlMode-C1-kMzTA.js → htmlMode-CQ1XkBcg.js} +1 -1
  45. package/dist/assets/{infoDiagram-27XIBGKW-DnYIb721.js → infoDiagram-27XIBGKW-CeoAEYkn.js} +1 -1
  46. package/dist/assets/{ishikawaDiagram-5VMMS53U-OkR8ku85.js → ishikawaDiagram-5VMMS53U-BH46eDIB.js} +1 -1
  47. package/dist/assets/{javascript-DrPh85q2.js → javascript-DbgeF7Cx.js} +1 -1
  48. package/dist/assets/{journeyDiagram-3NMN7TZE-CT-Oo851.js → journeyDiagram-3NMN7TZE-BOwEcgjc.js} +1 -1
  49. package/dist/assets/{jsonMode-BKKUvDMb.js → jsonMode-BmbNUVVq.js} +1 -1
  50. package/dist/assets/{kanban-definition-UXKFOSKX-CHzhgG5Z.js → kanban-definition-UXKFOSKX-BkCRxeP3.js} +1 -1
  51. package/dist/assets/{layout-BZM9G3GL.js → layout-DQUmCAbR.js} +1 -1
  52. package/dist/assets/{linear-s3PNBkYs.js → linear-gHaVu9xJ.js} +1 -1
  53. package/dist/assets/{liquid-BQv-MNlN.js → liquid-AgidL2-1.js} +1 -1
  54. package/dist/assets/main-BjOE01kD.css +10 -0
  55. package/dist/assets/{main-rOPdQ0S8.js → main-GYuFvIBu.js} +534 -534
  56. package/dist/assets/{mdx-Cje5051-.js → mdx-BQ4WkIVX.js} +1 -1
  57. package/dist/assets/{mindmap-definition-YA3MSWOX-lkRMZnuu.js → mindmap-definition-YA3MSWOX-B9sFUo1T.js} +1 -1
  58. package/dist/assets/{pegDiagram-XKGWAZYB-CautNQd9.js → pegDiagram-XKGWAZYB-CkP54iiU.js} +1 -1
  59. package/dist/assets/{pieDiagram-E7YTZNPT-BjCc-eYX.js → pieDiagram-E7YTZNPT-BarK0Wdr.js} +1 -1
  60. package/dist/assets/{python-DvWGIFgP.js → python-Bvah5-B6.js} +1 -1
  61. package/dist/assets/{quadrantDiagram-AXDQQJYC-DJn_V_wR.js → quadrantDiagram-AXDQQJYC-Bx2yAto_.js} +1 -1
  62. package/dist/assets/{railroadDiagram-O6MQD6OU-BFXAVUrn.js → railroadDiagram-O6MQD6OU-DKwA_Vtz.js} +1 -1
  63. package/dist/assets/{razor-DTEJAEuN.js → razor-BArYzMwx.js} +1 -1
  64. package/dist/assets/{requirementDiagram-BXWQKSXE-CXSItQrt.js → requirementDiagram-BXWQKSXE-Dl3eZsdu.js} +1 -1
  65. package/dist/assets/{sankeyDiagram-P5KCCOFB-Ne8T3pf0.js → sankeyDiagram-P5KCCOFB-BT-EUHg8.js} +1 -1
  66. package/dist/assets/{sequenceDiagram-WJ2MYXX4-Cpgb8a5D.js → sequenceDiagram-WJ2MYXX4-DFN97HFT.js} +1 -1
  67. package/dist/assets/{sizeCapture-INFHLROL-BfGdUbJN.js → sizeCapture-INFHLROL-CFx7FiYM.js} +1 -1
  68. package/dist/assets/{stateDiagram-D77RDMKH-BwKaigd_.js → stateDiagram-D77RDMKH-DpCD-L1t.js} +1 -1
  69. package/dist/assets/stateDiagram-v2-MP3YSRHH-DiycyohT.js +1 -0
  70. package/dist/assets/{swimlanes-42K2YHIH-C2fwTicg.js → swimlanes-42K2YHIH-CXp8IHO4.js} +1 -1
  71. package/dist/assets/swimlanesDiagram-VR7AAH4N-CUuFpDm9.js +8 -0
  72. package/dist/assets/{timeline-definition-24CTP7MA-COmuX8XF.js → timeline-definition-24CTP7MA-DuQyOBST.js} +1 -1
  73. package/dist/assets/{transformers.web-D2rbMeIC.js → transformers.web-QgqVZX_0.js} +1 -1
  74. package/dist/assets/{tsMode-cpL3Q-oP.js → tsMode-6IiKwTYx.js} +1 -1
  75. package/dist/assets/{typescript-BTNSxP9O.js → typescript-DzZFI9VE.js} +1 -1
  76. package/dist/assets/{vennDiagram-4TSXK5OY-C2vo0GB5.js → vennDiagram-4TSXK5OY-CjCy0DlF.js} +1 -1
  77. package/dist/assets/{wardleyDiagram-VM6X3IG4-Dpb7Zec3.js → wardleyDiagram-VM6X3IG4-JWvRIdFS.js} +1 -1
  78. package/dist/assets/{xml-DGM-Sbhe.js → xml-DbG2NXrB.js} +1 -1
  79. package/dist/assets/{xychartDiagram-S5SC5T6Z-B2o_VvWT.js → xychartDiagram-S5SC5T6Z-DUUFW9vj.js} +1 -1
  80. package/dist/assets/{yaml-DNvvW8Lk.js → yaml-DtBZLorE.js} +1 -1
  81. package/dist/index.html +3 -3
  82. package/dist/ui-build.json +1 -1
  83. package/dist-server/domain/doc-control/doc-sync-control.service.js +2 -2
  84. package/dist-server/domain/doc-control/doc-sync.error.js +1 -1
  85. package/dist-server/domain/doc-sync/contract/sowonai-doc.constants.js +1 -1
  86. package/dist-server/domain/doc-sync/contract/sowonai-doc.schemas.js +1 -1
  87. package/dist-server/domain/doc-sync/doc-sync.app-config.js +1 -1
  88. package/dist-server/domain/doc-sync/doc-sync.app-control.host.js +1 -1
  89. package/dist-server/domain/doc-sync/doc-sync.app-document.port.js +1 -1
  90. package/dist-server/domain/doc-sync/doc-sync.app-remote.js +1 -1
  91. package/dist-server/domain/doc-sync/doc-sync.client.js +1 -1
  92. package/dist-server/domain/doc-sync/doc-sync.host.js +2 -1
  93. package/dist-server/domain/doc-sync/dto/app-sync.dto.js +1 -1
  94. package/dist-server/domain/doc-sync/sowonai-doc.client.js +3 -1
  95. package/dist-server/domain/doc-sync/testing/fake-sowonai.js +1 -1
  96. package/dist-server/domain/git/git.service.js +1 -1
  97. package/dist-server/domain/terminal/dto/terminal-ticket.dto.js +1 -0
  98. package/dist-server/domain/terminal/terminal-access-policy.js +1 -1
  99. package/dist-server/domain/terminal/terminal-confirmation.service.js +1 -0
  100. package/dist-server/domain/terminal/terminal.controller.js +1 -1
  101. package/dist-server/domain/terminal/terminal.module.js +1 -1
  102. package/dist-server/domain/workflow/workflow.service.js +2 -2
  103. package/dist-server/repository/task.repository.js +2 -2
  104. package/package.json +29 -21
  105. package/packages/cli/dist/main.d.ts +1 -1
  106. package/packages/cli/dist/main.js +1 -1
  107. package/packages/cli/dist/utils/desktop-snapshot-pin.d.ts +1 -0
  108. package/packages/cli/dist/utils/desktop-snapshot-pin.js +1 -0
  109. package/packages/cli/package.json +1 -1
  110. package/dist/assets/channel-DiqSW183.js +0 -1
  111. package/dist/assets/classDiagram-ZZMXUADV-PfyoT9Vb.js +0 -1
  112. package/dist/assets/classDiagram-v2-VYDZK3BY-PfyoT9Vb.js +0 -1
  113. package/dist/assets/main-CBefalnL.css +0 -10
  114. package/dist/assets/stateDiagram-v2-MP3YSRHH-CKZkaylq.js +0 -1
  115. package/dist/assets/swimlanesDiagram-VR7AAH4N-B8eh_8aq.js +0 -8
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{spawn as m}from"child_process";import{existsSync as O,readFileSync as A,realpathSync as R}from"fs";import{fileURLToPath as N}from"url";import{dirname as h,join as l,resolve as P}from"path";import{homedir as k,tmpdir as X}from"os";import{createRequire as y}from"module";import{defineCommand as x,runCommand as E,renderUsage as g}from"citty";import{setupSignalForwarding as _,resolveRoute as I,ensureCrewxDirs as U,readPairingCredential as W,resolvePairEndpoint as $}from"./crewx-lib.js";const L=N(import.meta.url);const f=h(L);if(process.versions.electron&&process.env.CREWX_ACTIVE_SNAPSHOT_ROOT&&process.env.CREWX_APP_UPDATE_CHANNEL_DIRECTORY){const e=y(import.meta.url);const r=R(P(h(h(f))));const o=R(P(process.env.CREWX_ACTIVE_SNAPSHOT_ROOT));if(o!==r){throw new Error("CrewX CLI entrypoint does not match its selected app snapshot")}const t=process.env.CREWX_FIXED_SHELL_RETENTION_MODULE;if(!t||!t.endsWith(l("dist-shell","retention.cjs"))&&!t.endsWith(l("fixed-shell","retention.cjs"))){throw new Error("CrewX fixed shell pin module is unavailable")}const{acquireSnapshotPin:i}=e(t);const n=i(process.env.CREWX_APP_UPDATE_CHANNEL_DIRECTORY,process.env.CREWX_ACTIVE_SNAPSHOT_ROOT);if(!n){if(process.env.CREWX_APP_SNAPSHOT_SLOT!=="baseline"||h(r).split(/[/\\]/).pop()!=="resources"||r.split(/[/\\]/).pop()!=="baseline-app"){throw new Error("CrewX cannot pin its verified app snapshot")}}else{process.env.CREWX_SNAPSHOT_PIN_ID=n.id;process.once("exit",()=>n.release())}}function D(){const e={...process.env};delete e.ELECTRON_RUN_AS_NODE;e.NODE_ENV="production";return e}function j(e,r=[]){const o=y(import.meta.url);let t;try{t=o("electron")}catch{return false}const i=m(String(t),[e,...r],{stdio:"inherit",env:D(),detached:true});_(i,{escalateKill:true,detached:true});i.on("exit",n=>process.exit(n??0));i.on("error",n=>{console.error("Failed to launch Electron:",n);process.exit(1)});return true}function H({port:e,token:r,tokenFile:o,open:t,https:i,trust:n}={}){const s=l(f,"..","server.js");const c={...process.env,NODE_ENV:"production"};if(i){c.CREWX_HTTPS="true"}if(n){c.CREWX_TRUST_CA="true"}if(e){c.PORT=String(e)}if(r){c.MCP_BEARER_TOKEN=r;process.stderr.write("\u2139\uFE0F Tip: use --token-file to avoid exposing token in shell history.\n")}else if(o){let a;try{a=A(o,"utf8").trim()}catch(b){console.error(`\u274C --token-file not readable: ${o}`);console.error(` ${b.message}`);process.exit(1)}if(!a){console.error(`\u274C --token-file is empty: ${o}`);process.exit(1)}c.MCP_BEARER_TOKEN=a}const C=l(k(),".crewx","tls","cert.pem");if(O(C)){c.NODE_EXTRA_CA_CERTS=C}if(i){console.log("\u{1F512} HTTPS enabled with SowonLabs CA");if(!n){console.log("\u26A0\uFE0F Browser may show a certificate warning.");console.log(" To remove warning: npx crewx serve --https --trust")}}if(t){c.CREWX_OPEN_BROWSER="1";c.CREWX_OPEN_BROWSER_ONCE_FILE=l(X(),`crewx-open-browser-${process.pid}-${Date.now()}`)}const w=m(process.execPath,["--disable-sigusr1",s],{stdio:"inherit",env:c});_(w);w.on("exit",a=>process.exit(a??0));w.on("error",a=>{console.error("Failed to start web server:",a);process.exit(1)})}function q(e){const r=Number(e);if(!Number.isInteger(r)||r<1||r>65535){console.error("\u274C Invalid port number. Use 1-65535.");process.exit(1)}return r}function F(e){if(typeof e!=="string"||e.length===0)return false;try{const r=new URL(e);return(r.protocol==="http:"||r.protocol==="https:")&&r.search===""&&/^#pair=.{1,}$/.test(r.hash)}catch{return false}}async function B(e,r){let o;try{o=await fetch(`${e}/api/v1/auth/local/code`,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${r}`}})}catch{throw new Error(`Could not reach the CrewX server at ${e}.`)}if(!o.ok){throw new Error(`Pairing code request failed (HTTP ${o.status}).`)}let t;try{t=await o.json()}catch{throw new Error("Pairing code response was not valid JSON.")}if(!F(t?.url)){throw new Error("Pairing code response did not contain a valid pairing URL.")}return t.url}const S=x({meta:{name:"pair",description:"Request a one-time local browser pairing link"},args:{port:{type:"string",description:"Port of the CrewX web server"},open:{type:"boolean",description:"Open the pairing link in a browser",default:false},help:{type:"boolean",alias:"h",description:"Show this help"}},async run({args:e}){if(e.help){const s=await g(S);process.stdout.write(s+"\n");process.exit(0)}const r=new Set(["_","port","open","help","h"]);for(const s of Object.keys(e)){if(!r.has(s)){console.error(`\u274C Unknown option for "crewx pair": --${s}`);console.error(" Run `crewx pair --help` for usage.");process.exit(2)}}const o=e.port===void 0?void 0:q(e.port);let t;let i;try{t=$({port:o});i=W()}catch(s){console.error(`\u274C ${s instanceof Error?s.message:"Unable to read pairing credential."}`);process.exit(1)}let n;try{n=await B(t,i)}catch(s){console.error(`\u274C ${s instanceof Error?s.message:"Unable to request pairing link."}`);process.exit(1)}process.stdout.write(`${n}
3
+ `);if(e.open){try{const s=(await import("open")).default;await s(n)}catch{console.error("\u274C Could not open the pairing link automatically.");process.exit(1)}}}});const v=x({meta:{name:"serve",description:"Launch CrewX web server"},args:{port:{type:"string",description:"Port to listen on"},token:{type:"string",description:"MCP bearer token"},"token-file":{type:"string",description:"Read token from file"},https:{type:"boolean",description:"Enable HTTPS with auto-generated certificate"},trust:{type:"boolean",description:"Install CA to system trust store (requires --https)"},open:{type:"boolean",description:"Auto-open browser",default:true},help:{type:"boolean",alias:"h",description:"Show this help"}},async run({args:e}){if(e.help){const t=await g(v);process.stdout.write(t+"\n");process.exit(0)}const r=new Set(["_","port","token","token-file","tokenFile","https","trust","open","help","h"]);for(const t of Object.keys(e)){if(!r.has(t)){console.error(`\u274C Unknown option for "crewx serve": --${t}`);console.error(" Run `crewx serve --help` for usage.");process.exit(2)}}if(e.trust&&!e.https){console.error("\u274C --trust requires --https");process.exit(1)}const o=e.port?Number(e.port):void 0;if(e.port&&(!o||o<1||o>65535)){console.error("\u274C Invalid port number. Use 1-65535.");process.exit(1)}H({port:o,token:e.token,tokenFile:e["token-file"],open:e.open,https:e.https,trust:e.trust})}});function V(e){const r=l(f,"..","server.js");const o=m(process.execPath,[r,"cli",...e],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}});_(o);o.on("exit",t=>process.exit(t??0));o.on("error",t=>{console.error("Failed to run CLI subcommand:",t);process.exit(1)})}const u=process.argv.slice(2);const T=u.length===3&&u[0]==="ai-account"&&u[1]==="capabilities"&&u[2]==="--json";if(!T)U();const{route:p,routeArgs:d,error:M}=T?{route:"cli",routeArgs:u}:I(u);if(p==="serve"){E(v,{rawArgs:d})}else if(p==="pair"){E(S,{rawArgs:d})}else if(p==="electron"){const e=d.includes("--overlay");const r=l(f,"..","dist-electron",e?"overlay.js":"main.js");const o=j(r,e?[]:[]);if(!o){console.error("");console.error(" \u274C Electron is not installed.");console.error("");console.error(" This command requires Electron. Install it:");console.error("");console.error(" npm install -g electron");console.error(" # or in this project:");console.error(" npm install --save-dev electron");console.error("");console.error(" Alternatively, use: crewx serve (web mode)");console.error("");process.exit(1)}}else if(p==="cli"){V(d)}else if(p==="web-default"){E(v,{rawArgs:["--open",...d]})}else if(p==="error"){console.error(`\u274C ${M}`);process.exit(2)}else{console.error(`\u274C Internal routing error: unknown route "${p}"`);process.exit(1)}
@@ -0,0 +1,3 @@
1
+ import{createHash as S}from"node:crypto";import{spawn as T}from"node:child_process";import{chmodSync as _,copyFileSync as C,lstatSync as y,mkdtempSync as N,readFileSync as h,rmSync as R}from"node:fs";import{tmpdir as P}from"node:os";import{fileURLToPath as $}from"node:url";import{basename as O,dirname as w,isAbsolute as A,join as p,relative as L,resolve as v,sep as U}from"node:path";const M=1;const I=["SIGINT","SIGTERM","SIGHUP"];const W={darwin:"darwin",linux:"linux",win32:"windows"};const X={arm64:"arm64",x64:"amd64"};function D(e=process.env){const r=e.CREWX_MEMORY_RUNTIME===void 0?"auto":e.CREWX_MEMORY_RUNTIME;if(!["auto","go","node"].includes(r)){throw new Error("CREWX_MEMORY_RUNTIME must be auto, go, or node.")}return r}function z(e){if(!Array.isArray(e)||e[0]!=="memory")return null;const r=e[1];const n=e[2];if(!n||b(n))return null;if(r==="index"&&e.length===3){return{command:r,agentId:n,argument:void 0}}if(r==="get"&&e.length===4&&e[3]&&!b(e[3])){return{command:r,agentId:n,argument:e[3]}}if(r==="find"&&e.length===4&&e[3]&&!b(e[3])){return{command:r,agentId:n,argument:e[3]}}return null}function b(e){return e==="-h"||e.startsWith("--")}function Q(){return"CREWX_MEMORY_RUNTIME=go supports only `crewx memory index <agent>`, `get <agent> <id>`, and `find <agent> <query>` without options. Use CREWX_MEMORY_RUNTIME=node for other memory commands."}function Z(e){return`Native memory support is unavailable (${e}). Use CREWX_MEMORY_RUNTIME=node to roll back to the existing implementation.`}function ee(e=w(w($(import.meta.url)))){const r=[p(e,"node_modules","@crewx","memory"),p(w(e),"@crewx","memory")];for(const n of r){try{const t=p(n,"package.json");const a=y(t);if(!a.isFile()||a.isSymbolicLink())continue;const o=JSON.parse(h(t,"utf8"));if(o.name==="@crewx/memory"&&typeof o.version==="string")return v(n)}catch{}}throw new Error("installed @crewx/memory package was not found beside CrewX")}function F(e=process.platform,r=process.arch){const n=W[e];const t=X[r];if(!n||!t)return null;return`${n}-${t}`}function te(e,r=process.platform,n=process.arch){const t=F(r,n);if(!t)return{ok:false,reason:`unsupported platform ${r}/${n}`};try{const a=v(e);const o=p(a,"package.json");const s=p(a,"go","native-manifest.json");const m=y(o);const f=y(s);if(!m.isFile()||m.isSymbolicLink()||!f.isFile()||f.isSymbolicLink()){return{ok:false,reason:"package metadata is not a regular installed-package file"}}const u=JSON.parse(h(o,"utf8"));const c=JSON.parse(h(s,"utf8"));if(u.name!=="@crewx/memory"||typeof u.version!=="string"){return{ok:false,reason:"installed memory package identity is invalid"}}if(c.formatVersion!==1||c.protocol!==M){return{ok:false,reason:`unsupported manifest/protocol (expected protocol ${M})`}}if(c.packageVersion!==u.version){return{ok:false,reason:`manifest version ${c.packageVersion??"(missing)"} does not match package ${u.version}`}}const l=c.targets?.[t];if(!l||typeof l.file!=="string"||typeof l.sha256!=="string"){return{ok:false,reason:`no packaged native executable for ${t}`}}const x=t.startsWith("windows-")?".exe":"";const k=`go/bin/crewx-memory-${t}${x}`;if(l.file!==k||A(l.file)||l.file.split(/[\\/]/u).includes("..")){return{ok:false,reason:"native manifest contains an untrusted executable path"}}if(!/^[0-9a-f]{64}$/u.test(l.sha256)){return{ok:false,reason:"native executable hash is invalid"}}const i=v(a,l.file);const d=L(a,i);if(!d||d.startsWith(`..${U}`)||d===".."){return{ok:false,reason:"native executable escaped its installed package"}}const g=y(i);if(!g.isFile()||g.isSymbolicLink()){return{ok:false,reason:"native executable is not a regular packaged file"}}const E=S("sha256").update(h(i)).digest("hex");if(E!==l.sha256){return{ok:false,reason:"native executable hash does not match its protected manifest"}}return{ok:true,artifact:{executablePath:i,packageVersion:u.version,protocol:c.protocol,sha256:E,executable:r==="win32"||(g.mode&73)!==0,skillVersion:V(a)}}}catch(a){return{ok:false,reason:a instanceof Error?a.message:String(a)}}}function re(e,r=process.platform){if(r==="win32"||e.executable){return{ok:true,executablePath:e.executablePath,cleanup:()=>{}}}let n;try{n=N(p(P(),"crewx-memory-native-"));const t=p(n,O(e.executablePath));C(e.executablePath,t);_(t,448);const a=S("sha256").update(h(t)).digest("hex");if(a!==e.sha256)throw new Error("staged native executable hash does not match its installed package artifact");return{ok:true,executablePath:t,temporaryExecutablePath:t,cleanup:()=>R(n,{recursive:true,force:true})}}catch(t){if(n)R(n,{recursive:true,force:true});return{ok:false,reason:t instanceof Error?t.message:String(t),cleanup:()=>{}}}}function V(e){const r=h(p(e,"SKILL.md"),"utf8");const n=r.match(/^---\r?\n([\s\S]*?)\r?\n---/u)?.[1];const t=n?.match(/^\s*version:\s*(.+?)\s*$/mu);if(!t)return null;return t[1].replace(/^['"]|['"]$/gu,"")}async function ne(e,r,n=process.env){try{const{loadCrewxEnvFiles:t}=await import("@crewx/sdk/account");if(typeof t!=="function"){return{ok:false,reason:"the shared CrewX environment loader is unavailable"}}t();if(n.CREWX_NO_TRACE==="1")return{ok:true,handle:null};const a=await import("@crewx/shared/skill-tracer");if(typeof a.trace!=="function"){return{ok:false,reason:"the shared skill activity tracer is unavailable"}}const o=typeof a.getOwnSkillVersion==="function"?a.getOwnSkillVersion(e):null;const s=a.trace("crewx/memory",r.join(" "),{agentId:n.CREWX_AGENT_ID,skillVersion:o});if(!s||s._skipped){return{ok:false,reason:"activity tracing is unavailable because the existing trace database or schema could not be opened. Use CREWX_NO_TRACE=1 to explicitly disable tracing."}}return{ok:true,handle:s}}catch(t){return{ok:false,reason:`activity tracing could not start: ${t instanceof Error?t.message:String(t)}`}}}async function oe(e,r,n=process.env,t=null){const a=[`--crewx-memory-protocol=${e.protocol}`,`--crewx-memory-version=${e.packageVersion}`,r.command,r.agentId];if(r.argument!==void 0)a.push(r.argument);let o;let s;try{o=await G(e.executablePath,a,n)}catch(c){s=c;o={code:127,signal:null,stdout:Buffer.alloc(0),stderr:Buffer.alloc(0)}}const m=o.stdout.toString("utf8");const f=o.stderr.toString("utf8");let u;if(t){try{if(!s&&o.code===0&&!o.signal){t.ok(m||null,{stderr:f||void 0})}else{const c=f.trim()||s?.message||`native memory exited with code ${o.code??o.signal}`;t.fail(c,{stderr:f||void 0})}}catch(c){u=c}}if(o.stdout.length>0)process.stdout.write(o.stdout);if(o.stderr.length>0)process.stderr.write(o.stderr);if(u){process.stderr.write(`[memory] Activity trace update failed after the native read; the read was not retried: ${u.message}
2
+ `);return{exitCode:1}}if(s){process.stderr.write(`Native memory process could not be started: ${s.message}
3
+ `);return{exitCode:127}}return{exitCode:o.signal?Y(o.signal):o.code??1}}function G(e,r,n=process.env,t=process){return new Promise((a,o)=>{let s;try{s=T(e,r,{cwd:process.cwd(),env:n,stdio:["pipe","pipe","pipe"],windowsHide:true})}catch(i){o(i);return}const m=[];const f=[];let u;let c;let l;const x=new Map;const k=i=>{if(c)return;c=i;try{s.kill(i)}catch{}l=setTimeout(()=>{if(s.exitCode===null&&s.signalCode===null)s.kill("SIGKILL")},5e3);l.unref?.()};for(const i of I){const d=k.bind(null,i);x.set(i,d);t.once(i,d)}s.stdin.on("error",()=>{});s.stdout.on("data",i=>m.push(Buffer.from(i)));s.stderr.on("data",i=>f.push(Buffer.from(i)));s.once("error",i=>{u=i});s.once("close",(i,d)=>{for(const g of I)t.removeListener(g,x.get(g));if(l)clearTimeout(l);if(u){o(u);return}a({code:i,signal:d??c??null,stdout:Buffer.concat(m),stderr:Buffer.concat(f)})})})}function Y(e){if(e==="SIGINT")return 130;if(e==="SIGTERM")return 143;if(e==="SIGHUP")return 129;return 1}export{M as MEMORY_PROTOCOL,D as getRuntimeMode,F as nativeTargetKey,Z as nativeUnavailableMessage,z as parseSupportedMemoryRead,re as prepareNativeExecutable,ne as prepareNativeTrace,ee as resolveInstalledMemoryPackageRoot,te as resolveNativeArtifact,G as runForegroundProcess,oe as runNativeMemoryRead,Q as unsupportedNativeReadMessage};
package/bin/crewx.js CHANGED
@@ -1,3 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import{spawn as h}from"child_process";import{existsSync as _,readFileSync as R}from"fs";import{fileURLToPath as k}from"url";import{dirname as S,join as u}from"path";import{homedir as T,tmpdir as O}from"os";import{createRequire as A}from"module";import{defineCommand as v,runCommand as w,renderUsage as x}from"citty";import{setupSignalForwarding as m,resolveRoute as N,ensureCrewxDirs as $,readPairingCredential as U,resolvePairEndpoint as j}from"./crewx-lib.js";const q=k(import.meta.url);const E=S(q);function L(){const e={...process.env};delete e.ELECTRON_RUN_AS_NODE;e.NODE_ENV="production";return e}function I(e,r=[]){const o=A(import.meta.url);let t;try{t=o("electron")}catch{return false}const i=h(String(t),[e,...r],{stdio:"inherit",env:L(),detached:true});m(i,{escalateKill:true,detached:true});i.on("exit",s=>process.exit(s??0));i.on("error",s=>{console.error("Failed to launch Electron:",s);process.exit(1)});return true}function X({port:e,token:r,tokenFile:o,open:t,https:i,trust:s}={}){const n=u(E,"..","server.js");const c={...process.env,NODE_ENV:"production"};if(i){c.CREWX_HTTPS="true"}if(s){c.CREWX_TRUST_CA="true"}if(e){c.PORT=String(e)}if(r){c.MCP_BEARER_TOKEN=r;process.stderr.write("\u2139\uFE0F Tip: use --token-file to avoid exposing token in shell history.\n")}else if(o){let a;try{a=R(o,"utf8").trim()}catch(P){console.error(`\u274C --token-file not readable: ${o}`);console.error(` ${P.message}`);process.exit(1)}if(!a){console.error(`\u274C --token-file is empty: ${o}`);process.exit(1)}c.MCP_BEARER_TOKEN=a}const y=u(T(),".crewx","tls","cert.pem");if(_(y)){c.NODE_EXTRA_CA_CERTS=y}if(i){console.log("\u{1F512} HTTPS enabled with SowonLabs CA");if(!s){console.log("\u26A0\uFE0F Browser may show a certificate warning.");console.log(" To remove warning: npx crewx serve --https --trust")}}if(t){c.CREWX_OPEN_BROWSER="1";c.CREWX_OPEN_BROWSER_ONCE_FILE=u(O(),`crewx-open-browser-${process.pid}-${Date.now()}`)}const f=h(process.execPath,["--disable-sigusr1",n],{stdio:"inherit",env:c});m(f);f.on("exit",a=>process.exit(a??0));f.on("error",a=>{console.error("Failed to start web server:",a);process.exit(1)})}function D(e){const r=Number(e);if(!Number.isInteger(r)||r<1||r>65535){console.error("\u274C Invalid port number. Use 1-65535.");process.exit(1)}return r}function W(e){if(typeof e!=="string"||e.length===0)return false;try{const r=new URL(e);return(r.protocol==="http:"||r.protocol==="https:")&&r.search===""&&/^#pair=.{1,}$/.test(r.hash)}catch{return false}}async function B(e,r){let o;try{o=await fetch(`${e}/api/v1/auth/local/code`,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${r}`}})}catch{throw new Error(`Could not reach the CrewX server at ${e}.`)}if(!o.ok){throw new Error(`Pairing code request failed (HTTP ${o.status}).`)}let t;try{t=await o.json()}catch{throw new Error("Pairing code response was not valid JSON.")}if(!W(t?.url)){throw new Error("Pairing code response did not contain a valid pairing URL.")}return t.url}const b=v({meta:{name:"pair",description:"Request a one-time local browser pairing link"},args:{port:{type:"string",description:"Port of the CrewX web server"},open:{type:"boolean",description:"Open the pairing link in a browser",default:false},help:{type:"boolean",alias:"h",description:"Show this help"}},async run({args:e}){if(e.help){const n=await x(b);process.stdout.write(n+"\n");process.exit(0)}const r=new Set(["_","port","open","help","h"]);for(const n of Object.keys(e)){if(!r.has(n)){console.error(`\u274C Unknown option for "crewx pair": --${n}`);console.error(" Run `crewx pair --help` for usage.");process.exit(2)}}const o=e.port===void 0?void 0:D(e.port);let t;let i;try{t=j({port:o});i=U()}catch(n){console.error(`\u274C ${n instanceof Error?n.message:"Unable to read pairing credential."}`);process.exit(1)}let s;try{s=await B(t,i)}catch(n){console.error(`\u274C ${n instanceof Error?n.message:"Unable to request pairing link."}`);process.exit(1)}process.stdout.write(`${s}
3
- `);if(e.open){try{const n=(await import("open")).default;await n(s)}catch{console.error("\u274C Could not open the pairing link automatically.");process.exit(1)}}}});const g=v({meta:{name:"serve",description:"Launch CrewX web server"},args:{port:{type:"string",description:"Port to listen on"},token:{type:"string",description:"MCP bearer token"},"token-file":{type:"string",description:"Read token from file"},https:{type:"boolean",description:"Enable HTTPS with auto-generated certificate"},trust:{type:"boolean",description:"Install CA to system trust store (requires --https)"},open:{type:"boolean",description:"Auto-open browser",default:true},help:{type:"boolean",alias:"h",description:"Show this help"}},async run({args:e}){if(e.help){const t=await x(g);process.stdout.write(t+"\n");process.exit(0)}const r=new Set(["_","port","token","token-file","tokenFile","https","trust","open","help","h"]);for(const t of Object.keys(e)){if(!r.has(t)){console.error(`\u274C Unknown option for "crewx serve": --${t}`);console.error(" Run `crewx serve --help` for usage.");process.exit(2)}}if(e.trust&&!e.https){console.error("\u274C --trust requires --https");process.exit(1)}const o=e.port?Number(e.port):void 0;if(e.port&&(!o||o<1||o>65535)){console.error("\u274C Invalid port number. Use 1-65535.");process.exit(1)}X({port:o,token:e.token,tokenFile:e["token-file"],open:e.open,https:e.https,trust:e.trust})}});function F(e){const r=u(E,"..","server.js");const o=h(process.execPath,[r,"cli",...e],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}});m(o);o.on("exit",t=>process.exit(t??0));o.on("error",t=>{console.error("Failed to run CLI subcommand:",t);process.exit(1)})}const p=process.argv.slice(2);const C=p.length===3&&p[0]==="ai-account"&&p[1]==="capabilities"&&p[2]==="--json";if(!C)$();const{route:l,routeArgs:d,error:H}=C?{route:"cli",routeArgs:p}:N(p);if(l==="serve"){w(g,{rawArgs:d})}else if(l==="pair"){w(b,{rawArgs:d})}else if(l==="electron"){const e=d.includes("--overlay");const r=u(E,"..","dist-electron",e?"overlay.js":"main.js");const o=I(r,e?[]:[]);if(!o){console.error("");console.error(" \u274C Electron is not installed.");console.error("");console.error(" This command requires Electron. Install it:");console.error("");console.error(" npm install -g electron");console.error(" # or in this project:");console.error(" npm install --save-dev electron");console.error("");console.error(" Alternatively, use: crewx serve (web mode)");console.error("");process.exit(1)}}else if(l==="cli"){F(d)}else if(l==="web-default"){w(g,{rawArgs:["--open",...d]})}else if(l==="error"){console.error(`\u274C ${H}`);process.exit(2)}else{console.error(`\u274C Internal routing error: unknown route "${l}"`);process.exit(1)}
2
+ async function d(){const t=process.argv.slice(2);if(t[0]!=="memory"){await import("./crewx-dispatch.js");return}const e=await import("./crewx-memory-runtime.js");let r;try{r=e.getRuntimeMode(process.env)}catch(s){process.stderr.write(`${s.message}
3
+ `);process.exitCode=2;return}if(r==="node"){await import("./crewx-dispatch.js");return}const c=e.parseSupportedMemoryRead(t);if(!c){if(r==="go"){process.stderr.write(`${e.unsupportedNativeReadMessage()}
4
+ `);process.exitCode=2;return}await import("./crewx-dispatch.js");return}if(process.versions.electron){if(r==="go"){process.stderr.write("Native memory reads are unavailable in CrewX Desktop. Use CREWX_MEMORY_RUNTIME=node or auto.\n");process.exitCode=2;return}await import("./crewx-dispatch.js");return}let n;try{n=e.resolveInstalledMemoryPackageRoot()}catch(s){if(r==="go"){process.stderr.write(`${e.nativeUnavailableMessage(s.message)}
5
+ `);process.exitCode=2;return}await import("./crewx-dispatch.js");return}const o=e.resolveNativeArtifact(n);if(!o.ok){if(r==="go"){process.stderr.write(`${e.nativeUnavailableMessage(o.reason)}
6
+ `);process.exitCode=2;return}await import("./crewx-dispatch.js");return}const a=e.prepareNativeExecutable(o.artifact);if(!a.ok){if(r==="go"){process.stderr.write(`${e.nativeUnavailableMessage(a.reason)}
7
+ `);process.exitCode=2;return}await import("./crewx-dispatch.js");return}const i=await e.prepareNativeTrace(n,t,process.env);if(!i.ok){a.cleanup();if(r==="go"){process.stderr.write(`${i.reason}
8
+ `);process.exitCode=2;return}process.stderr.write(`[memory] Native reads are unavailable: ${i.reason} Falling back to Node.
9
+ `);await import("./crewx-dispatch.js");return}try{const s={...o.artifact,executablePath:a.executablePath};const p=await e.runNativeMemoryRead(s,c,process.env,i.handle);process.exitCode=p.exitCode}finally{a.cleanup()}}d().catch(t=>{process.stderr.write(`crewx: ${t instanceof Error?t.message:String(t)}
10
+ `);process.exitCode=1});
@@ -1 +1 @@
1
- import{aC as w,aD as e,aE as g}from"./main-rOPdQ0S8.js";import{M as j}from"./MonacoDiffSurface-DTvss6yK.js";function p(n){const t=/^---\r?\n[\s\S]*?\r?\n---(?=\r?\n|$)/.exec(n);if(!t)return null;const r=t[0].split(/\r?\n/);return{text:t[0],endLine:r.length,summary:r[1]??r[0]}}function b(n,t){const r=n.split(/\r?\n/),a=Math.max(0,Math.min(r.length-1,t-1));let s=null,i=null;for(let l=a;l>=0&&(!s||!i);l-=1){const c=r[l].trimEnd();!s&&/^##\s+/.test(c)&&(s=c),!i&&/^-\s+/.test(c)&&(i=c)}return{heading:s,listItem:i}}function L(n,t,r){var i,l;const a=new Set,s=[];for(const c of r){const h=[b(n,c.originalStartLineNumber),b(t,c.modifiedStartLineNumber)],u=((i=h.find(f=>f.heading))==null?void 0:i.heading)??null,x=((l=h.find(f=>f.listItem))==null?void 0:l.listItem)??null;if(!u&&!x)continue;const m=JSON.stringify([u,x]);a.has(m)||(a.add(m),s.push({heading:u,listItem:x}))}return s}function v(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?n:t.toISOString()}function y({side:n,label:t,fileVersion:r}){const{t:a}=w(),s=v(n.modifiedAt),i=n.revision===null?null:String(n.revision);return e.jsxs("section",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 px-3 py-2","aria-label":t,children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-gray-900",children:t}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-600",children:[s?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.modifiedAt")," ",e.jsx("time",{dateTime:s,children:s})]}):null,i?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.version")," ",i]}):null]}),e.jsx("code",{className:"mt-1 block max-w-full break-all text-[11px] text-gray-500","data-testid":"doc-sync-file-version",children:r??n.hash})]})}function D({filepath:n,original:t,modified:r,originalLabel:a,modifiedLabel:s,originalVersion:i}){const[l,c]=g.useState([]),h=g.useRef(null),u=p(t.text),x=p(r.text),m=(u==null?void 0:u.text)===(x==null?void 0:x.text)?u:null,f=g.useMemo(()=>L(t.text,r.text,l),[l,r.text,t.text]);return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(y,{side:t,label:a,fileVersion:i}),e.jsx(y,{side:r,label:s})]}),f.length>0?e.jsx("div",{className:"flex min-w-0 flex-col gap-1","aria-label":a,children:f.map((d,o)=>e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-x-2 rounded-md bg-blue-50 px-3 py-1.5 text-xs text-blue-900",children:[d.heading?e.jsx("span",{className:"break-words font-semibold",children:d.heading}):null,d.listItem?e.jsx("span",{className:"break-words",children:d.listItem}):null]},`${d.heading??""}:${d.listItem??""}:${o}`))}):null,m?e.jsxs("details",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 text-xs text-gray-600","data-testid":"doc-sync-frontmatter",children:[e.jsx("summary",{className:"cursor-pointer truncate px-3 py-2",children:m.summary}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words border-t border-gray-200 px-3 py-2 font-mono text-[11px] leading-relaxed text-gray-700","data-testid":"doc-sync-frontmatter-text",children:m.text})]}):null,e.jsx("div",{className:"h-[min(45vh,24rem)] min-h-64 min-w-0 shrink-0 overflow-hidden rounded-md border border-gray-200 bg-white",children:e.jsx(j,{filepath:n,original:t.text,modified:r.text,language:"plaintext",theme:"vs",renderSideBySide:!1,options:{automaticLayout:!0,readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",hideUnchangedRegions:{enabled:!1}},onDiffChange:d=>{c(d.map(o=>({originalStartLineNumber:o.originalStartLineNumber,originalEndLineNumber:o.originalEndLineNumber,modifiedStartLineNumber:o.modifiedStartLineNumber,modifiedEndLineNumber:o.modifiedEndLineNumber}))),window.requestAnimationFrame(()=>{const o=h.current;if(!o)return;const N=m&&m.endLine>2?[{startLineNumber:2,startColumn:1,endLineNumber:m.endLine,endColumn:1}]:[];for(const S of[o.getOriginalEditor(),o.getModifiedEditor()])S.setHiddenAreas(N)})},onEditorReady:d=>{h.current=d}})})]})}export{y as DocSyncSideMetadata,D as DocSyncTextDiff,L as buildDocSyncHunkContexts};
1
+ import{aC as w,aD as e,aE as g}from"./main-GYuFvIBu.js";import{M as j}from"./MonacoDiffSurface-BZmnrlo7.js";function p(n){const t=/^---\r?\n[\s\S]*?\r?\n---(?=\r?\n|$)/.exec(n);if(!t)return null;const r=t[0].split(/\r?\n/);return{text:t[0],endLine:r.length,summary:r[1]??r[0]}}function b(n,t){const r=n.split(/\r?\n/),a=Math.max(0,Math.min(r.length-1,t-1));let s=null,i=null;for(let l=a;l>=0&&(!s||!i);l-=1){const c=r[l].trimEnd();!s&&/^##\s+/.test(c)&&(s=c),!i&&/^-\s+/.test(c)&&(i=c)}return{heading:s,listItem:i}}function L(n,t,r){var i,l;const a=new Set,s=[];for(const c of r){const h=[b(n,c.originalStartLineNumber),b(t,c.modifiedStartLineNumber)],u=((i=h.find(f=>f.heading))==null?void 0:i.heading)??null,x=((l=h.find(f=>f.listItem))==null?void 0:l.listItem)??null;if(!u&&!x)continue;const m=JSON.stringify([u,x]);a.has(m)||(a.add(m),s.push({heading:u,listItem:x}))}return s}function v(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?n:t.toISOString()}function y({side:n,label:t,fileVersion:r}){const{t:a}=w(),s=v(n.modifiedAt),i=n.revision===null?null:String(n.revision);return e.jsxs("section",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 px-3 py-2","aria-label":t,children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-gray-900",children:t}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-600",children:[s?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.modifiedAt")," ",e.jsx("time",{dateTime:s,children:s})]}):null,i?e.jsxs("span",{children:[a("threadAppWorkspace.resultShare.docSync.version")," ",i]}):null]}),e.jsx("code",{className:"mt-1 block max-w-full break-all text-[11px] text-gray-500","data-testid":"doc-sync-file-version",children:r??n.hash})]})}function D({filepath:n,original:t,modified:r,originalLabel:a,modifiedLabel:s,originalVersion:i}){const[l,c]=g.useState([]),h=g.useRef(null),u=p(t.text),x=p(r.text),m=(u==null?void 0:u.text)===(x==null?void 0:x.text)?u:null,f=g.useMemo(()=>L(t.text,r.text,l),[l,r.text,t.text]);return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(y,{side:t,label:a,fileVersion:i}),e.jsx(y,{side:r,label:s})]}),f.length>0?e.jsx("div",{className:"flex min-w-0 flex-col gap-1","aria-label":a,children:f.map((d,o)=>e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-x-2 rounded-md bg-blue-50 px-3 py-1.5 text-xs text-blue-900",children:[d.heading?e.jsx("span",{className:"break-words font-semibold",children:d.heading}):null,d.listItem?e.jsx("span",{className:"break-words",children:d.listItem}):null]},`${d.heading??""}:${d.listItem??""}:${o}`))}):null,m?e.jsxs("details",{className:"min-w-0 rounded-md border border-gray-200 bg-gray-50 text-xs text-gray-600","data-testid":"doc-sync-frontmatter",children:[e.jsx("summary",{className:"cursor-pointer truncate px-3 py-2",children:m.summary}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words border-t border-gray-200 px-3 py-2 font-mono text-[11px] leading-relaxed text-gray-700","data-testid":"doc-sync-frontmatter-text",children:m.text})]}):null,e.jsx("div",{className:"h-[min(45vh,24rem)] min-h-64 min-w-0 shrink-0 overflow-hidden rounded-md border border-gray-200 bg-white",children:e.jsx(j,{filepath:n,original:t.text,modified:r.text,language:"plaintext",theme:"vs",renderSideBySide:!1,options:{automaticLayout:!0,readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",hideUnchangedRegions:{enabled:!1}},onDiffChange:d=>{c(d.map(o=>({originalStartLineNumber:o.originalStartLineNumber,originalEndLineNumber:o.originalEndLineNumber,modifiedStartLineNumber:o.modifiedStartLineNumber,modifiedEndLineNumber:o.modifiedEndLineNumber}))),window.requestAnimationFrame(()=>{const o=h.current;if(!o)return;const N=m&&m.endLine>2?[{startLineNumber:2,startColumn:1,endLineNumber:m.endLine,endColumn:1}]:[];for(const S of[o.getOriginalEditor(),o.getModifiedEditor()])S.setHiddenAreas(N)})},onEditorReady:d=>{h.current=d}})})]})}export{y as DocSyncSideMetadata,D as DocSyncTextDiff,L as buildDocSyncHunkContexts};
@@ -1,4 +1,4 @@
1
- import{bd as z,be as R,aE as a,aC as L,bf as O,bg as A,aD as c,bh as C}from"./main-rOPdQ0S8.js";import{l as b,M as B}from"./MonacoDiffSurface-DTvss6yK.js";/**
1
+ import{bd as z,be as R,aE as a,aC as L,bf as O,bg as A,aD as c,bh as C}from"./main-GYuFvIBu.js";import{l as b,M as B}from"./MonacoDiffSurface-BZmnrlo7.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{bd as H,bi as K,aC as T,bj as Ie,bk as D,aE as l,bl as At,bm as we,bn as B,bo as Ze,bp as P,bq as zt,br as Mt,bs as _t,aD as e,bt as O,bh as me,bu as Dt,bv as Le,bw as Pt,bx as et,by as Ot,bz as Tt,bA as qe,bB as Ft,bC as We,bD as Ut,bE as $t,bF as Vt,bG as Ce,bH as se,bI as Ke,bJ as Bt,bK as tt,bL as Ht,bM as qt,bN as Wt,bO as Kt,bP as st,bQ as rt,bR as at,bS as Se,bT as re,bU as Gt,bV as nt,bW as it,bX as lt,bY as Qt,bZ as Yt,b_ as Jt}from"./main-rOPdQ0S8.js";import{b$ as zs}from"./main-rOPdQ0S8.js";/**
1
+ import{bd as H,bi as K,aC as T,bj as Ie,bk as D,aE as l,bl as At,bm as we,bn as B,bo as Ze,bp as P,bq as zt,br as Mt,bs as _t,aD as e,bt as O,bh as me,bu as Dt,bv as Le,bw as Pt,bx as et,by as Ot,bz as Tt,bA as qe,bB as Ft,bC as We,bD as Ut,bE as $t,bF as Vt,bG as Ce,bH as se,bI as Ke,bJ as Bt,bK as tt,bL as Ht,bM as qt,bN as Wt,bO as Kt,bP as st,bQ as rt,bR as at,bS as Se,bT as re,bU as Gt,bV as nt,bW as it,bX as lt,bY as Qt,bZ as Yt,b_ as Jt}from"./main-GYuFvIBu.js";import{b$ as zs}from"./main-GYuFvIBu.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.