@crewx/sdk 0.9.0-rc.163 → 0.9.0-rc.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/app.d.ts +10 -0
- package/dist/app/entry.d.ts +2 -0
- package/dist/app/index.d.ts +6 -0
- package/dist/app/index.js +12 -10
- package/dist/app/job-bridge.child.d.ts +1 -0
- package/dist/app/job-bridge.d.ts +67 -0
- package/dist/app/job-bridge.drain.child.d.ts +1 -0
- package/dist/app/job-bridge.example.d.ts +11 -0
- package/dist/app/job-contract.d.ts +40 -0
- package/dist/app/job-wire.d.ts +149 -0
- package/dist/app/runtime.d.ts +2 -0
- package/dist/app-artifact-policy/check.d.ts +2 -0
- package/dist/app-artifact-policy/contract.d.ts +54 -0
- package/dist/app-artifact-policy/helper.d.ts +15 -0
- package/dist/app-artifact-policy/index.d.ts +3 -0
- package/dist/app-artifact-policy/index.js +18 -0
- package/dist/app-artifact-policy/paths.d.ts +24 -0
- package/dist/app-artifact-policy/scan.d.ts +47 -0
- package/dist/desktop/index.js +3 -3
- package/dist/esm/app/index.js +12 -10
- package/dist/esm/app-artifact-policy/index.js +18 -0
- package/dist/esm/desktop/index.js +3 -3
- package/dist/esm/index.js +251 -226
- package/dist/esm/plugins/index.js +102 -85
- package/dist/esm/process/index.js +1 -1
- package/dist/esm/publish/index.js +2 -2
- package/dist/esm/repository/index.js +134 -111
- package/dist/esm/skills/index.js +2 -2
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.js +4 -4
- package/dist/index.d.ts +14 -2
- package/dist/index.js +250 -225
- package/dist/mcp-app/app-job-bridge.d.ts +30 -0
- package/dist/mcp-app/app-job-bridge.example.d.ts +36 -0
- package/dist/mcp-app/app-job.d.ts +168 -0
- package/dist/mcp-app/index.d.ts +4 -0
- package/dist/mcp-app/skill-backend.d.ts +7 -1
- package/dist/migrations/0041_tranquil_vivisector.sql +54 -0
- package/dist/migrations/meta/0041_snapshot.json +4156 -0
- package/dist/migrations/meta/_journal.json +7 -0
- package/dist/plugins/index.js +102 -85
- package/dist/process/index.d.ts +2 -2
- package/dist/process/index.js +1 -1
- package/dist/process/process-control.d.ts +19 -0
- package/dist/publish/index.js +2 -2
- package/dist/repository/index.d.ts +2 -0
- package/dist/repository/index.js +132 -109
- package/dist/repository/sidebar-tab.repository.d.ts +82 -0
- package/dist/repository/thread.repository.d.ts +10 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/sidebar-tabs.d.ts +466 -0
- package/dist/skills/index.js +2 -2
- package/dist/ui-instance/types.d.ts +6 -0
- package/dist/ui-plugin/types.d.ts +4 -1
- package/package.json +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import {spawnSync,spawn}from'child_process';var
|
|
1
|
+
import {spawnSync,spawn}from'child_process';var O=3e3;var S=2e3,C=25,I=100;function y(e){return e instanceof Error?e:e===void 0?void 0:new Error(String(e))}function w(e){return typeof e=="object"&&e!==null&&"code"in e?String(e.code):void 0}function G(e){return Number.isSafeInteger(e)&&e>0}function D(e,t){try{let r=spawnSync(e,t,{encoding:"utf8",timeout:O,windowsHide:!0});return {status:r.status,stdout:typeof r.stdout=="string"?r.stdout:"",stderr:typeof r.stderr=="string"?r.stderr:"",error:r.error}}catch(r){return {status:null,stdout:"",stderr:"",error:y(r)}}}function F(e,t){return new Promise(r=>{let n;try{n=spawn(e,t,{windowsHide:!0});}catch(a){r({status:null,stdout:"",stderr:"",error:y(a)});return}let o="",s="",u=false,i,l=setTimeout(()=>{try{n.kill();}catch{}i({status:null,stdout:o,stderr:s,error:new Error(`Command timed out after ${O}ms`)});},O);i=a=>{u||(u=true,clearTimeout(l),r(a));},n.stdout?.setEncoding("utf8"),n.stderr?.setEncoding("utf8"),n.stdout?.on("data",a=>{o+=String(a);}),n.stderr?.on("data",a=>{s+=String(a);}),n.once("error",a=>{i({status:null,stdout:o,stderr:s,error:a});}),n.once("close",a=>{i({status:a,stdout:o,stderr:s});});})}async function M(e,t,r){return r.runCommandAsync?r.runCommandAsync(e,t):r.runCommand?r.runCommand(e,t):F(e,t)}function E(e){return new Promise(t=>{setTimeout(t,Math.max(0,e));})}function k(){return new Promise(e=>{setImmediate(e);})}function P(e,t=process.kill){try{return t(e,0),"alive"}catch(r){return w(r)==="ESRCH"?"not_found":w(r)==="EPERM"?"alive":"unknown"}}function W(e,t){if(!G(e))return {status:"unknown"};let r=t.platform??process.platform,n=t.runCommand??D,o=r==="win32"?"powershell.exe":"ps",s=r==="win32"?["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",`$p = Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId = ${e}' -ErrorAction Stop; if ($null -ne $p) { [Console]::Write([string]$p.CommandLine) }`]:["-p",String(e),"-o","command="],u;try{u=n(o,s);}catch{return {status:"unknown"}}if(u.error||u.status!==0)return {status:"unknown"};let i=u.stdout.trim();return i?{status:"found",commandLine:i}:{status:"not_found"}}function $(e,t){let r=P(-e,t),n=P(e,t);return r==="alive"||n==="alive"?"alive":r==="unknown"||n==="unknown"?"unknown":"not_found"}async function h(e,t,r,n){let o=Math.max(0,r),s=Math.max(1,n.pollIntervalMs??C),u=Date.now()+o,i,l=o===0,a=n.sleep?Promise.resolve().then(()=>n.sleep(o)).then(()=>{},()=>{}):new Promise(c=>{i=setTimeout(c,o);});a.then(()=>{l=true;});try{for(await k();;){let c=$(e,t);if(c==="not_found")return c;let d=u-Date.now();if(l||d<=0)return c;await Promise.race([a,E(Math.min(s,d))]);}}finally{i!==void 0&&clearTimeout(i);}}async function g(e,t,r,n,o){let s=await h(e,t,o.hardConfirmMs??I,{...o,sleep:void 0});return s==="not_found"?r?{status:"not_found",pid:e,method:n}:{status:"terminated",pid:e,method:n}:s==="alive"?{status:"failed",pid:e,method:n,error:"Process is still running after termination attempt"}:{status:"failed",pid:e,method:n,error:"Unable to verify process termination"}}function H(e,t,r={}){let n=W(e,r);if(n.status!=="found")return n.status;let o=r.platform??process.platform,s=o==="win32"?n.commandLine.toLowerCase():n.commandLine;return t.filter(i=>i.trim().length>0).some(i=>{let l=o==="win32"?i.toLowerCase():i;return s.includes(l)})?"owned":"not_owned"}async function X(e,t,r={}){if(!G(e))return "unknown";let n=r.platform??process.platform,o=n==="win32"?"powershell.exe":"ps",s=n==="win32"?["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",`$p = Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId = ${e}' -ErrorAction Stop; if ($null -ne $p) { [Console]::Write([string]$p.CommandLine) }`]:["-p",String(e),"-o","command="],u;try{u=await M(o,s,r);}catch{return "unknown"}if(u.error||u.status!==0)return "unknown";let i=u.stdout.trim();if(!i)return "not_found";let l=n==="win32"?i.toLowerCase():i;return t.filter(c=>c.trim().length>0).some(c=>{let d=n==="win32"?c.toLowerCase():c;return l.includes(d)})?"owned":"not_owned"}async function B(e,t={}){let r=t.platform??process.platform,n=r==="win32"?"taskkill":"process-group",o=m=>({status:"failed",pid:e,method:n,error:m});if(!G(e))return o("Invalid process ID");let s=t.kill??process.kill,u=P(e,s);if(u==="not_found")return {status:"not_found",pid:e,method:n};if(u!=="alive")return o("Unable to determine whether the process is alive");if(r==="win32"){let m;try{m=await M("taskkill",["/PID",String(e),"/T","/F"],t);}catch(v){m={status:null,stdout:"",stderr:"",error:y(v)};}let p=P(e,s);return p==="not_found"?m.status===0&&!m.error?{status:"terminated",pid:e,method:n}:{status:"not_found",pid:e,method:n}:o(p==="alive"?"Process is still running after termination attempt":"Unable to verify process termination")}let i,l=t.signal??"SIGKILL";try{s(-e,l);}catch(m){i=m;}if(l==="SIGKILL")return g(e,s,i,n,t);if(await h(e,s,t.graceMs??S,t)==="not_found")return i?{status:"not_found",pid:e,method:n}:{status:"terminated",pid:e,method:n};let c;try{s(-e,"SIGKILL");}catch(m){c=m;}let d=await g(e,s,c,n,t);return d.status==="terminated"?d:d.status==="not_found"?i?d:{status:"terminated",pid:e,method:n}:o(d.error??"Process termination failed")}var T=1e3,J=["SIGTERM","SIGINT","SIGHUP","SIGKILL"],V=6e4,j=100,q=3e4,z=1e3;function _(e,t,r){return Number.isFinite(e)&&e>=t&&e<=r}function Q(e){return Number.isSafeInteger(e)&&e>1&&e!==process.pid}function N(e,t){try{return t(-e,0),"alive"}catch(r){let n=w(r);return n==="ESRCH"?"not_found":n==="EPERM"?"denied":"unknown"}}function R(e,t,r){try{return r(-e,t),"sent"}catch(n){let o=w(n);return o==="ESRCH"?"empty":o==="EPERM"?"denied":"failed"}}function L(){return performance.now()}async function b(e,t,r,n){let o=L()+r;for(;;){await k();let s=N(e,t);if(s==="not_found")return s;let u=o-L();if(u<=0)return s;await E(Math.min(n,u));}}function f(e,t,r,n){return {status:t,groupId:e,...r?{lastSignal:r}:{},...n?{errorKind:n}:{}}}async function Y(e,t={}){let r=t.signal??"SIGTERM",n=t.graceMs??S,o=t.hardConfirmMs??T,s=t.pollIntervalMs??C;if(!Q(e))return f(e,"failed",void 0,"invalid_group_id");if(!J.includes(r)||!_(n,0,V)||!_(o,j,q)||!_(s,1,z))return f(e,"failed",void 0,"invalid_option");if((t.platform??process.platform)==="win32")return f(e,"unsupported",void 0,"unsupported_platform");let i=t.kill??process.kill,l=N(e,i);if(l==="not_found")return f(e,"exited");if(l!=="alive")return f(e,"failed",void 0,l==="denied"?"probe_denied":"probe_failed");let a;if(r!=="SIGKILL"){let m=R(e,r,i);if(m==="empty")return f(e,"exited");if(m!=="sent")return f(e,"failed",void 0,m==="denied"?"signal_denied":"signal_failed");a=r;let p=await b(e,i,n,s);if(p==="not_found")return f(e,"exited",a);if(p!=="alive")return f(e,"failed",a,p==="denied"?"probe_denied":"probe_failed")}let c=R(e,"SIGKILL",i);if(c==="empty")return f(e,"exited",a);if(c!=="sent")return f(e,"failed",a,c==="denied"?"signal_denied":"signal_failed");a="SIGKILL";let d=await b(e,i,o,s);return d==="not_found"?f(e,"exited",a):d==="alive"?f(e,"failed",a,"still_running"):f(e,"failed",a,d==="denied"?"probe_denied":"probe_failed")}export{T as OWNED_GROUP_KILL_CONFIRM_MS,C as UNIX_PROCESS_POLL_INTERVAL_MS,I as UNIX_SIGKILL_CONFIRM_MS,S as UNIX_SIGTERM_GRACE_MS,H as checkProcessOwnership,X as checkProcessOwnershipAsync,P as probeProcessLiveness,Y as terminateOwnedProcessGroup,B as terminateProcessTree};
|