@crewx/sdk 0.9.0-rc.174 → 0.9.0-rc.175
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/desktop/index.js +3 -3
- package/dist/esm/desktop/index.js +3 -3
- package/dist/esm/index.js +388 -259
- package/dist/esm/plugins/index.js +95 -91
- package/dist/esm/process/index.js +1 -1
- package/dist/esm/publish/index.js +2 -2
- package/dist/esm/repository/index.js +334 -201
- package/dist/esm/skills/index.js +2 -2
- package/dist/index.browser.js +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +377 -248
- package/dist/lifecycle/task-stop.d.ts +27 -1
- package/dist/lifecycle/update-admission.d.ts +1 -1
- package/dist/mcp-app/types.d.ts +1 -1
- package/dist/migrations/0042_breezy_blue_shield.sql +31 -0
- package/dist/migrations/0043_nervous_darkstar.sql +1 -0
- package/dist/migrations/0044_military_galactus.sql +8 -0
- package/dist/migrations/0045_task_pid_started_at.sql +1 -0
- package/dist/migrations/meta/0042_snapshot.json +4383 -0
- package/dist/migrations/meta/0043_snapshot.json +4390 -0
- package/dist/migrations/meta/0044_snapshot.json +4435 -0
- package/dist/migrations/meta/0045_snapshot.json +4442 -0
- package/dist/migrations/meta/_journal.json +28 -0
- package/dist/plugins/index.js +99 -95
- package/dist/process/index.d.ts +2 -2
- package/dist/process/index.js +1 -1
- package/dist/process/process-control.d.ts +14 -0
- package/dist/publish/index.js +2 -2
- package/dist/repository/db.d.ts +1 -0
- package/dist/repository/index.d.ts +7 -0
- package/dist/repository/index.js +292 -159
- package/dist/repository/run-columns.d.ts +10 -0
- package/dist/repository/run-history.repository.d.ts +112 -0
- package/dist/repository/schedule-run.repository.d.ts +103 -0
- package/dist/repository/task.repository.d.ts +13 -2
- package/dist/repository/workflow-anchor-kinds.d.ts +4 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/run-column-backfill.d.ts +81 -0
- package/dist/schema/schedule-runs.d.ts +451 -0
- package/dist/schema/tasks.d.ts +114 -0
- package/dist/skills/index.js +2 -2
- package/dist/ui-plugin/html-viewer-document-policy.d.ts +23 -0
- package/dist/ui-plugin/index.d.ts +2 -0
- package/dist/ui-plugin/types.d.ts +1 -0
- package/dist/utils/id.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import {spawnSync,spawn}from'child_process';var
|
|
1
|
+
import {spawnSync,spawn}from'child_process';var O=3e3;var b=2e3,g=25,M=100;function R(e){return e instanceof Error?e:e===void 0?void 0:new Error(String(e))}function C(e){return typeof e=="object"&&e!==null&&"code"in e?String(e.code):void 0}function S(e){return Number.isSafeInteger(e)&&e>0}function h(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:R(r)}}}function H(e,t){return new Promise(r=>{let n;try{n=spawn(e,t,{windowsHide:!0});}catch(c){r({status:null,stdout:"",stderr:"",error:R(c)});return}let o="",s="",u=false,i,d=setTimeout(()=>{try{n.kill();}catch{}i({status:null,stdout:o,stderr:s,error:new Error(`Command timed out after ${O}ms`)});},O);i=c=>{u||(u=true,clearTimeout(d),r(c));},n.stdout?.setEncoding("utf8"),n.stderr?.setEncoding("utf8"),n.stdout?.on("data",c=>{o+=String(c);}),n.stderr?.on("data",c=>{s+=String(c);}),n.once("error",c=>{i({status:null,stdout:o,stderr:s,error:c});}),n.once("close",c=>{i({status:c,stdout:o,stderr:s});});})}async function I(e,t,r){return r.runCommandAsync?r.runCommandAsync(e,t):r.runCommand?r.runCommand(e,t):H(e,t)}function G(e){return new Promise(t=>{setTimeout(t,Math.max(0,e));})}function E(){return new Promise(e=>{setImmediate(e);})}function w(e,t=process.kill){try{return t(e,0),"alive"}catch(r){return C(r)==="ESRCH"?"not_found":C(r)==="EPERM"?"alive":"unknown"}}function J(e,t){if(!S(e))return {status:"unknown"};let r=t.platform??process.platform,n=t.runCommand??h,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 B(e,t){let r=w(-e,t),n=w(e,t);return r==="alive"||n==="alive"?"alive":r==="unknown"||n==="unknown"?"unknown":"not_found"}async function x(e,t,r,n){let o=Math.max(0,r),s=Math.max(1,n.pollIntervalMs??g),u=Date.now()+o,i,d=o===0,c=n.sleep?Promise.resolve().then(()=>n.sleep(o)).then(()=>{},()=>{}):new Promise(a=>{i=setTimeout(a,o);});c.then(()=>{d=true;});try{for(await E();;){let a=B(e,t);if(a==="not_found")return a;let m=u-Date.now();if(d||m<=0)return a;await Promise.race([c,G(Math.min(s,m))]);}}finally{i!==void 0&&clearTimeout(i);}}async function N(e,t,r,n,o){let s=await x(e,t,o.hardConfirmMs??M,{...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 V(e,t,r={}){let n=J(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 d=o==="win32"?i.toLowerCase():i;return s.includes(d)})?"owned":"not_owned"}async function j(e,t,r={}){if(!S(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 I(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 d=n==="win32"?i.toLowerCase():i;return t.filter(a=>a.trim().length>0).some(a=>{let m=n==="win32"?a.toLowerCase():a;return d.includes(m)})?"owned":"not_owned"}var Y=3e3,Z=/^(?:(\d+)-)?(?:(\d+):)?(\d{1,2}):(\d{2})$/,q=/^\s*(\d+)\s+(\S+)\s+(\S+)\s*$/,z=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.(\d{6})([+-]\d{3})$/;function v(e){let t=Z.exec(e.trim());if(!t)return;let[,r="0",n="0",o="0",s="0"]=t;return ((Number(r)*24+Number(n))*60+Number(o))*60+Number(s)}function A(e){let t=e.trim(),r=z.exec(t);if(r){let[,o,s,u,i,d,c,a,m]=r;return Date.UTC(Number(o),Number(s)-1,Number(u),Number(i),Number(d),Number(c),Math.trunc(Number(a)/1e3))-Number(m)*6e4}let n=Date.parse(t);return Number.isFinite(n)?n:void 0}function U(e,t){return t==="win32"?{command:"powershell.exe",args:["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",`$p = Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId = ${e}' -ErrorAction Stop; if ($null -ne $p) { [Console]::Write($p.CreationDate.ToUniversalTime().ToString('o')) }`]}:{command:"ps",args:["-p",String(e),"-o","pgid=","-o","etime=","-o","stat="]}}function D(e,t,r){if(e.error)return {status:"unknown"};let n=e.stdout.trim();if(!n)return e.status===0||e.status===1?{status:"not_found"}:{status:"unknown"};if(e.status!==0)return {status:"unknown"};if(t==="win32"){let u=A(n);return u===void 0?{status:"unknown"}:{status:"found",startedAtMs:u,groupId:null}}let o=q.exec(n),s=o?v(o[2]):void 0;return !o||s===void 0?{status:"unknown"}:o[3].startsWith("Z")?{status:"unknown"}:{status:"found",startedAtMs:r-s*1e3,groupId:Number(o[1])}}function Q(e,t={}){if(!S(e))return {status:"unknown"};let r=t.platform??process.platform,{command:n,args:o}=U(e,r),s=t.runCommand??h,u;try{u=s(n,o);}catch{return {status:"unknown"}}return D(u,r,Date.now())}async function ee(e,t={}){if(!S(e))return {status:"unknown"};let r=t.platform??process.platform,{command:n,args:o}=U(e,r),s;try{s=await I(n,o,t);}catch{return {status:"unknown"}}return D(s,r,Date.now())}async function ne(e,t={}){let r=t.platform??process.platform,n=r==="win32"?"taskkill":"process-group",o=f=>({status:"failed",pid:e,method:n,error:f});if(!S(e))return o("Invalid process ID");let s=t.kill??process.kill,u=w(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 f;try{f=await I("taskkill",["/PID",String(e),"/T","/F"],t);}catch(P){f={status:null,stdout:"",stderr:"",error:R(P)};}let p=w(e,s);return p==="not_found"?f.status===0&&!f.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,d=t.signal??"SIGKILL";try{s(-e,d);}catch(f){i=f;}if(d==="SIGKILL")return N(e,s,i,n,t);if(await x(e,s,t.graceMs??b,t)==="not_found")return i?{status:"not_found",pid:e,method:n}:{status:"terminated",pid:e,method:n};let a;try{s(-e,"SIGKILL");}catch(f){a=f;}let m=await N(e,s,a,n,t);return m.status==="terminated"?m:m.status==="not_found"?i?m:{status:"terminated",pid:e,method:n}:o(m.error??"Process termination failed")}var $=1e3,re=["SIGTERM","SIGINT","SIGHUP","SIGKILL"],te=6e4,oe=100,se=3e4,ie=1e3;function y(e,t,r){return Number.isFinite(e)&&e>=t&&e<=r}function ue(e){return Number.isSafeInteger(e)&&e>1&&e!==process.pid}function L(e,t){try{return t(-e,0),"alive"}catch(r){let n=C(r);return n==="ESRCH"?"not_found":n==="EPERM"?"denied":"unknown"}}function T(e,t,r){try{return r(-e,t),"sent"}catch(n){let o=C(n);return o==="ESRCH"?"empty":o==="EPERM"?"denied":"failed"}}function _(){return performance.now()}async function k(e,t,r,n){let o=_()+r;for(;;){await E();let s=L(e,t);if(s==="not_found")return s;let u=o-_();if(u<=0)return s;await G(Math.min(n,u));}}async function ae(e,t,r,n){for(;;){await E();let o=L(e,t);if(o==="not_found"||o==="alive")return o;let s=r-_();if(s<=0)return o;await G(Math.min(n,s));}}function l(e,t,r,n){return {status:t,groupId:e,...r?{lastSignal:r}:{},...n?{errorKind:n}:{}}}async function ce(e,t={}){let r=t.signal??"SIGTERM",n=t.graceMs??b,o=t.hardConfirmMs??$,s=t.pollIntervalMs??g;if(!ue(e))return l(e,"failed",void 0,"invalid_group_id");if(!re.includes(r)||!y(n,0,te)||!y(o,oe,se)||!y(s,1,ie))return l(e,"failed",void 0,"invalid_option");if((t.platform??process.platform)==="win32")return l(e,"unsupported",void 0,"unsupported_platform");let i=t.kill??process.kill,d=L(e,i);if(d==="not_found")return l(e,"exited");let c=n;if(d==="denied"&&r!=="SIGKILL"&&n>0){let p=_()+n,P=await ae(e,i,p,s);if(P==="not_found")return l(e,"exited");if(P!=="alive")return l(e,"failed",void 0,P==="denied"?"probe_denied":"probe_failed");c=Math.max(0,p-_());}else if(d!=="alive")return l(e,"failed",void 0,d==="denied"?"probe_denied":"probe_failed");let a;if(r!=="SIGKILL"){let p=T(e,r,i);if(p==="empty")return l(e,"exited");if(p!=="sent")return l(e,"failed",void 0,p==="denied"?"signal_denied":"signal_failed");a=r;let P=await k(e,i,c,s);if(P==="not_found")return l(e,"exited",a);if(P!=="alive")return l(e,"failed",a,P==="denied"?"probe_denied":"probe_failed")}let m=T(e,"SIGKILL",i);if(m==="empty")return l(e,"exited",a);if(m!=="sent")return l(e,"failed",a,m==="denied"?"signal_denied":"signal_failed");a="SIGKILL";let f=await k(e,i,o,s);return f==="not_found"?l(e,"exited",a):f==="alive"?l(e,"failed",a,"still_running"):l(e,"failed",a,f==="denied"?"probe_denied":"probe_failed")}export{$ as OWNED_GROUP_KILL_CONFIRM_MS,Y as PROCESS_START_TIME_TOLERANCE_MS,g as UNIX_PROCESS_POLL_INTERVAL_MS,M as UNIX_SIGKILL_CONFIRM_MS,b as UNIX_SIGTERM_GRACE_MS,V as checkProcessOwnership,j as checkProcessOwnershipAsync,v as parseProcessElapsedSeconds,A as parseWindowsCreationDate,w as probeProcessLiveness,Q as readProcessIdentity,ee as readProcessIdentityAsync,ce as terminateOwnedProcessGroup,ne as terminateProcessTree};
|