fix(workflow): propagate cancellation in latest-job snapshots
This commit is contained in:
commit
70d619e464
5 files changed
+38
-21
No files matched your search
Vendored
+1
-1
@@ -360,7 +360,7 @@ ${V$({"\u5F53\u524D\u751F\u6548\u914D\u7F6E\u6587\u4EF6":Y,"\u51ED\u8BC1\u4FDD\u
|
||||
`)})}
|
||||
`,stderr:"",exitCode:0}}var uS=C(()=>{W6();E$();I$();N0()});function rQ($){if(!$)return"CUSTOM";let U=$.toLowerCase();if(U==="clock"||U.includes("timer")||U.includes("schedule"))return"SCHEDULE";if(U.includes("flowform")||U.includes("ebot")||U.includes("flow-")||U==="other-event-trigger"||U.includes("requisition"))return"FLOW_FORM";if(U.includes("datalink")||U.includes("entity"))return"DATALINK";if(U.includes("webhook")||U.includes("hab-trigger")||U.includes("xrxs")||U.includes("fxiaoke"))return"WEBHOOK";return"CUSTOM"}var iQ,M6,rh,dQ,nS,pQ,ah,sh,eh,$u,Uu,Wu,Xu,Du,Gu,Qu,Yu,Lu,Ku,AX,cS,iS,dS,lS,i4,oQ,pS,mS,oS,tS,rS,aS,Ju,EO,PX,tQ,IO,SO,sS,eS,$2,X$$,U2,Zu,D$$,Hu,G$$,zu,W2,Nu,X2,D2;var BX=C(()=>{B0();iQ=N.object({id:N.string(),name:N.string(),nameSpell:N.string().default(""),enName:N.string().nullable().optional(),code:N.string().default(""),corporationId:N.string(),active:N.boolean().default(!0),type:N.string().default(""),groupType:N.string().default(""),platformType:N.string().default(""),source:N.string().default(""),adminIds:N.array(N.string()).nullish().transform(($)=>$??[]),desc:N.string().nullable().optional(),importMethod:N.array(N.string()).nullish().transform(($)=>$??[]),createTime:N.number().default(0),updateTime:N.number().default(0)}),M6=N.object({name:N.string(),type:N.string(),label:N.string(),desc:N.string().optional(),groupName:N.string(),orderIndex:N.number(),levelIndex:N.array(N.number()),status:N.string(),displayName:N.string().optional()}),rh=N.object({key:N.string(),value:N.any().optional(),compare:N.string()}),dQ=N.lazy(()=>N.object({filters:N.array(N.union([rh,dQ])),condition:N.string()})),nS=N.union([N.object({key:N.string()}),N.object({key:N.string(),value:N.string()})]),pQ=N.object({defaultAction:N.string()}),ah=M6.extend({type:N.literal("condition"),tasksMaxLevel:N.number(),combineFilters:dQ,tasks:N.lazy(()=>N.array(AX))}),sh=M6.extend({type:N.literal("every"),batch:N.boolean(),batchSize:N.number().optional(),mode:N.string(),list:N.string(),filters:N.array(N.any()),tasksMaxLevel:N.number(),tasks:N.lazy(()=>N.array(AX))}),eh=M6.extend({type:N.literal("webhook"),sampleId:N.string(),params:N.array(N.object({key:N.string(),value:N.string()})),urlPath:N.string()}),$u=M6.extend({type:N.literal("stop")}),Uu=M6.extend({type:N.literal("http"),method:N.string(),url:N.string(),bodyType:N.string().optional(),bodyRaw:N.record(N.string(),N.any()).optional(),header:N.array(N.any()),params:N.array(N.object({key:N.string(),value:N.string()})),successCode:N.array(N.string()),sampleData:N.record(N.string(),N.any()).optional()}),Wu=M6.extend({type:N.literal("flow-detail"),specificationId:N.string(),mapping:N.union([N.boolean(),N.array(N.object({key:N.string(),value:N.string()}))]),flowCode:N.string()}),Xu=M6.extend({type:N.literal("code"),code:N.string()}),Du=M6.extend({type:N.literal("code-js2"),code:N.string(),mapping:N.array(N.object({key:N.string(),value:N.string()})).optional(),onError:pQ.optional()}),Gu=M6.extend({type:N.literal("ekuaibao-datalink-filter"),mode:N.string(),entityId:N.string(),fields:N.array(nS),filters:N.array(N.any()),selectFields:N.array(N.any()),combineFilters:dQ,orderKey:N.string(),orderMode:N.string(),limitCount:N.string(),onError:pQ.optional()}),Qu=M6.extend({type:N.literal("ekuaibao-datalink-create"),mode:N.string(),entityId:N.string(),fields:N.array(nS),filters:N.array(N.any()),combineFilters:dQ}),Yu=M6.extend({type:N.literal("data-convert"),mode:N.string(),path:N.array(N.string()),fields:N.array(N.object({key:N.string(),value:N.string()})),onError:pQ.optional(),subType:N.string(),itemType:N.string(),targetType:N.string(),feeFormType:N.string()}),Lu=M6.extend({type:N.literal("flow-create-task"),specificationId:N.string(),formState:N.string(),form:N.record(N.string(),N.string()),details:N.record(N.string(),N.any()),onError:pQ.optional()}),Ku=N.object({name:N.string().default("task"),type:N.string(),label:N.string().optional(),desc:N.string().optional(),groupName:N.string().default("trigger"),orderIndex:N.number().default(0),levelIndex:N.array(N.number()).default([0]),status:N.string().default("active"),displayName:N.string().optional()}).passthrough(),AX=N.union([eh,ah,sh,$u,Uu,Wu,Xu,Du,Gu,Qu,Yu,Lu,Ku]),cS=N.object({id:N.string(),pipelineName:N.string().default(""),state:N.number().default(0),runningCount:N.number().default(0),errorCount:N.number().default(0),updateTime:N.string().default(""),updateUser:N.string().nullable().optional(),tasks:N.array(AX).default([]),desc:N.string().nullable().optional(),customDesc:N.string().nullable().optional()}),iS=N.object({pipelineNum:N.number().default(0),runningNum:N.number().default(0),allRunCount:N.number().default(0),errorCount:N.number().default(0),number:N.number().default(1),size:N.number().default(20),totalPages:N.number().default(0),totalItems:N.number().default(0),pipelineList:N.array(cS).default([])}),dS=N.object({total:N.number().default(0),completed:N.number().default(0),failed:N.number().default(0),started:N.number().de
Line truncated
|
||||
\u21B3 \u26A0\uFE0F \u5F02\u5E38\u8DF3\u8FC7\u539F\u56E0: ${$.error}`:"";return` \u26A0\uFE0F [${$.taskType}] ${$.name||$.executionId}${$.label?` (${$.label})`:""} SKIPPED (${$.durationMs??0}ms)${$.loopPath?` [\u5FAA\u73AF: ${$.loopPath}]`:""}${D}`}case"task_failed":return` \u274C [${$.taskType}] ${$.name||$.executionId}${$.label?` (${$.label})`:""} FAILED (${$.durationMs??0}ms)${$.loopPath?` [\u5FAA\u73AF: ${$.loopPath}]`:""}
|
||||
\u21B3 \u9519\u8BEF\u8BE6\u60C5: ${$.error||"\u672A\u6355\u83B7\u660E\u786E\u9519\u8BEF\u4FE1\u606F"}`;case"job_completed":{let D=$.jobSummary,G=D?.status==="COMPLETED"&&!D.hasError&&D.errorCount===0?"\uD83C\uDFC1":"\u274C",Q=D?.status||"COMPLETED";return`${X} ${G} Job [${$.jobId}] \u6267\u884C\u7ED3\u675F: \u72B6\u6001 [${Q}] | \u8017\u65F6: ${D?.durationMs??"-"}ms | \u6210\u529F: ${D?.successCount??0} | \u5931\u8D25: ${D?.errorCount??0} | \u5B58\u5728\u9519\u8BEF: ${D?.hasError?"\u662F":"\u5426"}`}case"timeout":return`${X} \u23F1\uFE0F \u76D1\u542C\u8D85\u65F6\uFF0C\u672A\u5728\u6307\u5B9A\u65F6\u95F4\u5185\u6355\u83B7\u5230\u65B0\u7684\u4EFB\u52A1\u72B6\u6001\u53D8\u66F4\u3002`;case"cancelled":return`${X} \u76D1\u542C\u5DF2\u53D6\u6D88\uFF0C\u672A\u5BA3\u79F0 Job \u6267\u884C\u5B8C\u6210\u3002`;case"idle":return`${X} \uD83D\uDCA4 \u6682\u65E0\u65B0\u8FD0\u884C\u5B9E\u4F8B\uFF0C\u7EE7\u7EED\u7B49\u5F85\u4E2D...`;default:return`${X} [${$.type}]`}}async function wX($,U,X={}){let D=Math.max(X.intervalMs??1500,500),W=X.timeoutMs??60000,G=Date.now(),Q=new eQ(U),Y=[],K=async(S)=>{if(X.failedOnly){if(S.type!=="task_failed"&&!(S.type==="task_skipped"&&S.error)&&S.type!=="job_completed"&&S.type!=="timeout"&&S.type!=="cancelled")return}if(Y.push(S),X.onEvent)await X.onEvent(S)},L,J=!1;while(Date.now()-G<W){if(X.signal?.aborted)break;try{L=await S8($,U)}catch{}let S=c1(L);try{let I=await MX($,U),q=Q.processExecutions(I);for(let _ of q)await K(_)}catch{}if(SX(S)){J=!0;break}if(X.once)break;let E=Date.now()-G,b=W-E;if(b<=0)break;await new Promise((I)=>setTimeout(I,Math.min(D,b)))}let Z=X.signal?.aborted===!0,H=!X.once&&!J&&!Z,O=[];try{if(!Z)O=(await VX($,U)).items||[]}catch{}let z=c1(L),P=L,A=Number(P?.successTaskCount??0),B=Math.max(Number(P?.errorTaskCount??0),O.length),M=P?.hasError===!0||P?.hasError==="\u5B58\u5728"||B>0||z==="FAILED",j=typeof P?.durationTime==="number"?P.durationTime:void 0,V={type:"job_completed",jobId:U,status:z,timestamp:Date.now(),jobSummary:{status:z,durationMs:j,successCount:A,errorCount:B,hasError:M}};if(J)await K(V);else if(H||Z)await K({type:Z?"cancelled":"timeout",jobId:U,status:z,timestamp:Date.now()});return{timedOut:H,cancelled:Z,jobId:U,pipelineId:L?.pipelineId||"",status:z,runType:L?.runType,durationMs:j,successCount:A,errorCount:B,hasError:M,events:Y}}var hO=C(()=>{aQ();EX();fO()});async function uO($,U,X={}){let D=Math.max(X.intervalMs??2000,500),W=X.timeoutMs??(X.once||X.jobId?60000:1/0),G=X.jobId?1:X.maxJobs??(X.follow?1/0:1),Q=Date.now(),Y=[],K=new Set,L=async(z)=>{if(X.failedOnly){if(z.type!=="task_failed"&&!(z.type==="task_skipped"&&z.error)&&z.type!=="job_completed"&&z.type!=="timeout"&&z.type!=="cancelled")return}if(X.onEvent)await X.onEvent(z)};if(X.jobId){let z=await wX($,X.jobId,{...X,onEvent:L});return Y.push(z),{pipelineId:U,totalJobsWatched:1,jobs:Y,timedOut:Boolean(z.timedOut),cancelled:z.cancelled,hasFailures:z.hasError||z.status==="FAILED"}}let J="";try{J=(await b8($,U)).label||""}catch{}if(await L({type:"pipeline_watch_start",pipelineId:U,pipelineLabel:J,timestamp:Date.now()}),X.once){let z;try{let A=await jX($,U,"DEBUG");if(A.length>0)z=A[0].id}catch{}if(!z)try{let A=await F8($,U,{pageSize:1});if(A.jobList&&A.jobList.length>0){let B=A.jobList[0];z=B.jobId||B.id}}catch{}if(!z)return{pipelineId:U,totalJobsWatched:0,jobs:[],timedOut:!1,hasFailures:!1};let P=await wX($,z,{...X,once:!0,onEvent:L});return{pipelineId:U,totalJobsWatched:1,jobs:[P],timedOut:!1,hasFailures:P.hasError||P.status==="FAILED"}}let Z=!1;try{let z=await F8($,U,{pageSize:5});for(let P of z.jobList||[]){let A=P.jobId||P.id,B=c1(P);if(A&&!SX(B));else if(A)K.add(A)}}catch{}while(Date.now()-Q<W){if(X.signal?.aborted)break;let z;try{let M=(await jX($,U,"DEBUG")).find((j)=>!K.has(j.id));if(M)z={id:M.id,status:M.status||"RUNNING",runType:"DEBUG"}}catch{}if(!z)try{let B=await F8($,U,{pageSize:3});for(let M of B.jobList||[]){let j=M.jobId||M.id;if(j&&!K.has(j)){z={id:j,status:c1(M),runType:M.runType};break}}}catch{}if(z){K.add(z.id),await L({type:"job_detected",pipelineId:U,jobId:z.id,status:z.status,runType:z.runType,timestamp:Date.now()});let B=await wX($,z.id,{...X,timeoutMs:Math.max(1,W-(Date.now()-Q)),onEvent:L});if(Y.push(B),B.timedOut){Z=!0;break}if(B.cancelled)break;if(Y.length>=G)break}let P=Date.now()-Q,A=W-P;if(A<=0){Z=!0;break}await new Promise((B)=>setTimeout(B,Math.min(D,A)))}let H=X.signal?.aborted===!0;if(!H&&Date.now()-Q>=W&&Y.length<G){if(Z=!0,!Y.at(-1)?.timedOut)await L({type:"timeout",pipelineId:U,timestamp:Date.now()})}if(H&&!Y.at(-1)?.cancelled)await L({type:"cancelled",pipelineId:U,timestamp:Date.now()});let O=Y.some((z)=>z.hasError||z.status==="FAILED");return{pipelineId:U,totalJobsWatched:Y.length,jobs:Y,timedOut:Z,cancelled:H,hasFailures:O}}var I2=C(()=>{aQ();EX();hO()});var w2=C(()=>{EX();fO();hO();I2()});function v2($){if($.type==="webhook")return $.urlPath?`urlPath: ${$.urlPath}`:"\u672A\u914D\u7F6EURL";if($.type==="clock")return`cron: ${$.cron||"0 0 * * *"} (${$.timeZonLine truncated
|
||||
\u21B3 \u9519\u8BEF\u8BE6\u60C5: ${$.error||"\u672A\u6355\u83B7\u660E\u786E\u9519\u8BEF\u4FE1\u606F"}`;case"job_completed":{let D=$.jobSummary,G=D?.status==="COMPLETED"&&!D.hasError&&D.errorCount===0?"\uD83C\uDFC1":"\u274C",Q=D?.status||"COMPLETED";return`${X} ${G} Job [${$.jobId}] \u6267\u884C\u7ED3\u675F: \u72B6\u6001 [${Q}] | \u8017\u65F6: ${D?.durationMs??"-"}ms | \u6210\u529F: ${D?.successCount??0} | \u5931\u8D25: ${D?.errorCount??0} | \u5B58\u5728\u9519\u8BEF: ${D?.hasError?"\u662F":"\u5426"}`}case"timeout":return`${X} \u23F1\uFE0F \u76D1\u542C\u8D85\u65F6\uFF0C\u672A\u5728\u6307\u5B9A\u65F6\u95F4\u5185\u6355\u83B7\u5230\u65B0\u7684\u4EFB\u52A1\u72B6\u6001\u53D8\u66F4\u3002`;case"cancelled":return`${X} \u76D1\u542C\u5DF2\u53D6\u6D88\uFF0C\u672A\u5BA3\u79F0 Job \u6267\u884C\u5B8C\u6210\u3002`;case"idle":return`${X} \uD83D\uDCA4 \u6682\u65E0\u65B0\u8FD0\u884C\u5B9E\u4F8B\uFF0C\u7EE7\u7EED\u7B49\u5F85\u4E2D...`;default:return`${X} [${$.type}]`}}async function wX($,U,X={}){let D=Math.max(X.intervalMs??1500,500),W=X.timeoutMs??60000,G=Date.now(),Q=new eQ(U),Y=[],K=async(S)=>{if(X.failedOnly){if(S.type!=="task_failed"&&!(S.type==="task_skipped"&&S.error)&&S.type!=="job_completed"&&S.type!=="timeout"&&S.type!=="cancelled")return}if(Y.push(S),X.onEvent)await X.onEvent(S)},L,J=!1;while(Date.now()-G<W){if(X.signal?.aborted)break;try{L=await S8($,U)}catch{}let S=c1(L);try{let I=await MX($,U),q=Q.processExecutions(I);for(let _ of q)await K(_)}catch{}if(SX(S)){J=!0;break}if(X.once)break;let E=Date.now()-G,b=W-E;if(b<=0)break;await new Promise((I)=>setTimeout(I,Math.min(D,b)))}let Z=X.signal?.aborted===!0,H=!X.once&&!J&&!Z,O=[];try{if(!Z)O=(await VX($,U)).items||[]}catch{}let z=c1(L),P=L,A=Number(P?.successTaskCount??0),B=Math.max(Number(P?.errorTaskCount??0),O.length),M=P?.hasError===!0||P?.hasError==="\u5B58\u5728"||B>0||z==="FAILED",j=typeof P?.durationTime==="number"?P.durationTime:void 0,V={type:"job_completed",jobId:U,status:z,timestamp:Date.now(),jobSummary:{status:z,durationMs:j,successCount:A,errorCount:B,hasError:M}};if(J)await K(V);else if(H||Z)await K({type:Z?"cancelled":"timeout",jobId:U,status:z,timestamp:Date.now()});return{timedOut:H,cancelled:Z,jobId:U,pipelineId:L?.pipelineId||"",status:z,runType:L?.runType,durationMs:j,successCount:A,errorCount:B,hasError:M,events:Y}}var hO=C(()=>{aQ();EX();fO()});async function uO($,U,X={}){let D=Math.max(X.intervalMs??2000,500),W=X.timeoutMs??(X.once||X.jobId?60000:1/0),G=X.jobId?1:X.maxJobs??(X.follow?1/0:1),Q=Date.now(),Y=[],K=new Set,L=async(z)=>{if(X.failedOnly){if(z.type!=="task_failed"&&!(z.type==="task_skipped"&&z.error)&&z.type!=="job_completed"&&z.type!=="timeout"&&z.type!=="cancelled")return}if(X.onEvent)await X.onEvent(z)};if(X.jobId){let z=await wX($,X.jobId,{...X,onEvent:L});return Y.push(z),{pipelineId:U,totalJobsWatched:1,jobs:Y,timedOut:Boolean(z.timedOut),cancelled:z.cancelled,hasFailures:z.hasError||z.status==="FAILED"}}let J="";try{J=(await b8($,U)).label||""}catch{}if(await L({type:"pipeline_watch_start",pipelineId:U,pipelineLabel:J,timestamp:Date.now()}),X.once){let z;try{let A=await jX($,U,"DEBUG");if(A.length>0)z=A[0].id}catch{}if(!z)try{let A=await F8($,U,{pageSize:1});if(A.jobList&&A.jobList.length>0){let B=A.jobList[0];z=B.jobId||B.id}}catch{}if(!z)return{pipelineId:U,totalJobsWatched:0,jobs:[],timedOut:!1,hasFailures:!1};let P=await wX($,z,{...X,once:!0,onEvent:L});return{pipelineId:U,totalJobsWatched:1,jobs:[P],timedOut:Boolean(P.timedOut),cancelled:P.cancelled,hasFailures:P.hasError||P.status==="FAILED"}}let Z=!1;try{let z=await F8($,U,{pageSize:5});for(let P of z.jobList||[]){let A=P.jobId||P.id,B=c1(P);if(A&&!SX(B));else if(A)K.add(A)}}catch{}while(Date.now()-Q<W){if(X.signal?.aborted)break;let z;try{let M=(await jX($,U,"DEBUG")).find((j)=>!K.has(j.id));if(M)z={id:M.id,status:M.status||"RUNNING",runType:"DEBUG"}}catch{}if(!z)try{let B=await F8($,U,{pageSize:3});for(let M of B.jobList||[]){let j=M.jobId||M.id;if(j&&!K.has(j)){z={id:j,status:c1(M),runType:M.runType};break}}}catch{}if(z){K.add(z.id),await L({type:"job_detected",pipelineId:U,jobId:z.id,status:z.status,runType:z.runType,timestamp:Date.now()});let B=await wX($,z.id,{...X,timeoutMs:Math.max(1,W-(Date.now()-Q)),onEvent:L});if(Y.push(B),B.timedOut){Z=!0;break}if(B.cancelled)break;if(Y.length>=G)break}let P=Date.now()-Q,A=W-P;if(A<=0){Z=!0;break}await new Promise((B)=>setTimeout(B,Math.min(D,A)))}let H=X.signal?.aborted===!0;if(!H&&Date.now()-Q>=W&&Y.length<G){if(Z=!0,!Y.at(-1)?.timedOut)await L({type:"timeout",pipelineId:U,timestamp:Date.now()})}if(H&&!Y.at(-1)?.cancelled)await L({type:"cancelled",pipelineId:U,timestamp:Date.now()});let O=Y.some((z)=>z.hasError||z.status==="FAILED");return{pipelineId:U,totalJobsWatched:Y.length,jobs:Y,timedOut:Z,cancelled:H,hasFailures:O}}var I2=C(()=>{aQ();EX();hO()});var w2=C(()=>{EX();fO();hO();I2()});function v2($){if($.type==="webhook")return $.urlPath?`urlPath: ${$.urlPath}`:"\u672A\u914D\u7F6EURL";if($.type==="clock")return`crLine truncated
|
||||
`)[0]||"";return`\u811A\u672C (${U.length} \u5B57\u7B26): ${X.slice(0,40)}${X.length>40?"...":""}`}if($.type==="http")return`${$.method||"POST"} ${$.url||""}`;if($.type==="every")return`\u5FAA\u73AF\u904D\u5386: ${$.list||"$item"} (\u542B ${$.tasks?.length||0} \u4E2A\u5B50\u8282\u70B9)`;if($.type==="condition")return`\u5206\u652F\u6761\u4EF6: ${($.combineFilters?.filters||[]).length} \u7EC4\u89C4\u5219 (\u542B ${$.tasks?.length||0} \u4E2A\u5B50\u8282\u70B9)`;if($.type==="stop")return"\u963B\u65AD\u7EC8\u6B62\u6D41\u7A0B";if($.type==="ekuaibao-datalink-create-trigger")return"\u4E1A\u52A1\u5BF9\u8C61\u53F0\u8D26\u65B0\u589E\u89E6\u53D1";if($.type==="ekuaibao-flowform-trigger")return"\u5355\u636E\u6D41\u8F6C\u4E8B\u4EF6\u89E6\u53D1";return $.desc||$.label||$.type}function lO($){let U=[],X=0;function D(W,G,Q,Y,K){for(let L=0;L<W.length;L++){let J=W[L];X+=1;let Z=G?`${G}.${L+1}`:`${L+1}`,H=Y?`${Y}.${L}`:`tasks.${L}`;if(U.push({task:J,index:X,hierarchicalIndex:Z,depth:Q,path:H,parentName:K,summary:v2(J)}),J.tasks&&Array.isArray(J.tasks)&&J.tasks.length>0)D(J.tasks,Z,Q+1,`${H}.tasks`,J.name)}}return D($,"",0,"tasks"),U}function n6($,U){let X=Array.isArray($)?$:$?.tasks||[],D=String(U).trim(),W=Number(D),G=!Number.isNaN(W)&&Number.isInteger(W)&&W>0,Q=0;function Y(K,L,J,Z){for(let H=0;H<K.length;H++){let O=K[H];Q+=1;let z=L?`${L}.${H+1}`:`${H+1}`,P=J?`${J}.${H}`:`tasks.${H}`;if(O.name===D||z===D||G&&Q===W)return{task:O,path:P,parentTasks:K,arrayIndex:H,hierarchicalIndex:z,globalIndex:Q,parentName:Z};if(O.tasks&&Array.isArray(O.tasks)&&O.tasks.length>0){let B=Y(O.tasks,z,`${P}.tasks`,O.name);if(B)return B}}return null}return Y(X,"","tasks")}function UY($,U=[],X=0){let D=X;for(let W=0;W<$.length;W++){let G=$[W];if(G.orderIndex=D++,G.levelIndex=[...U,W],G.tasks&&Array.isArray(G.tasks))D=UY(G.tasks,G.levelIndex,D)}return D}function C2($){let U=Math.random().toString(36).substring(2,8);if($==="every"||$==="condition")return`control_${U}`;if($.includes("trigger")||$==="webhook"||$==="clock")return`trigger_${U}`;return`action_${U}`}function T2($,U={}){let X=$.trim(),D=C2(X);switch(X){case"code-js2":return{name:D,type:"code-js2",label:U.label||"JS\u8282\u70B9\uFF08\u65B0\uFF09",desc:U.desc||"\u6267\u884C\u4E00\u6BB5JavaScript\u4EE3\u7801",groupName:"action",code:U.code||`// \u7F16\u5199\u5904\u7406\u903B\u8F91
|
||||
return items;`,orderIndex:0,levelIndex:[0],status:"active",...U.extra};case"code":return{name:D,type:"code",label:U.label||"\u4EE3\u7801\u8282\u70B9",desc:U.desc||"\u6267\u884C\u4E00\u6BB5MVEL\u4EE3\u7801",groupName:"action",code:U.code||"return true;",orderIndex:0,levelIndex:[0],status:"active",...U.extra};case"http":return{name:D,type:"http",label:U.label||"HTTP\u8BF7\u6C42",groupName:"action",method:U.extra?.method||"POST",url:U.extra?.url||"",header:U.extra?.header||[],params:U.extra?.params||[],successCode:U.extra?.successCode||["200"],orderIndex:0,levelIndex:[0],status:"active",...U.extra};case"stop":return{name:D,type:"stop",label:U.label||"\u7EC8\u6B62\u6D41\u7A0B",desc:U.desc||"\u5982\u679C\u6EE1\u8DB3\u6761\u4EF6\u7EC8\u6B62\u6D41\u7A0B",groupName:"control",orderIndex:0,levelIndex:[0],status:"active",...U.extra};case"every":return{name:D,type:"every",label:U.label||"\u4F9D\u6B21\u6267\u884C",desc:U.desc||"\u4F9D\u6B21\u904D\u5386\u6BCF\u4E2A\u5BF9\u8C61",groupName:"control",mode:"sequence",batch:!1,list:U.extra?.list||"@{choose('...$item')}",filters:[],tasksMaxLevel:1,tasks:[],orderIndex:0,levelIndex:[0],status:"active",...U.extra};case"condition":return{name:D,type:"condition",label:U.label||"\u6761\u4EF6\u5206\u652F",desc:U.desc||"\u5982\u679C\u6EE1\u8DB3\u6761\u4EF6\u5219\u6267\u884C\u4EE5\u4E0B\u52A8\u4F5C",groupName:"control",combineFilters:U.extra?.combineFilters||{condition:"or",filters:[]},tasksMaxLevel:1,tasks:[],orderIndex:0,levelIndex:[0],status:"active",...U.extra};case"webhook":return{name:D,type:"webhook",label:U.label||"Webhook\u89E6\u53D1",groupName:"trigger",orderIndex:0,levelIndex:[0],status:"active",urlPath:crypto.randomUUID(),params:[],...U.extra};case"clock":return{name:D,type:"clock",label:U.label||"\u5B9A\u65F6\u89E6\u53D1",groupName:"trigger",orderIndex:0,levelIndex:[0],status:"active",cron:U.extra?.cron||"0 0 * * *",timeZone:U.extra?.timeZone||"Asia/Shanghai",...U.extra};default:return{name:D,type:X,label:U.label||`${X}\u8282\u70B9`,desc:U.desc||"",groupName:X.startsWith("control")?"control":"action",orderIndex:0,levelIndex:[0],status:"active",...U.extra}}}function mO($,U){let X=JSON.parse(JSON.stringify($));if(!X.tasks)X.tasks=[];let D=T2(U.type,U);if(U.after!==void 0&&U.after!==""){let W=n6(X.tasks,U.after);if(!W)throw new a$(`\u672A\u627E\u5230\u63D2\u5165\u57FA\u51C6\u8282\u70B9 (--after): ${U.after}`);W.parentTasks.splice(W.arrayIndex+1,0,D)}else if(U.parent!==void 0&&U.parent!==""){let W=n6(X.tasks,U.parent);if(!W)throw new a$(`\u672A\u627E\u5230\u7236\u7EA7\u5BB9\u5668\u8282\u70B9 (--parent): ${U.parent}`);if(!W.task.tasks)W.task.tasks=[];W.task.tasks.push(D)}else X.tasks.push(D);return UY(X.tasks),{workflow:X,newTask:D}}function nO($,U,X){let D=JSON.parse(JSON.stringify($));if(!D.tasks)D.tasks=[];let W=n6(D.tasks,U);if(!W)throw new a$(`\u672A\u627E\u5230\u76EE\u6807\u5DE5\u4F5C\u6D41\u4EFB\u52A1\u8282\u70B9: ${U}`);let{task:G}=W;if(X.label!==void 0)G.label=X.label;if(X.desc!==void 0)G.desc=X.desc;if(X.code!==void 0)G.code=X.code;if(X.set&&typeof X.set==="object")for(let[Q,Y]of Object.entries(X.set))G[Q]=Y;return{workflow:D,editedTask:G}}function cO($,U){let X=JSON.parse(JSON.stringify($));if(!X.tasks||X.tasks.length===0)throw new p$("\u5DE5\u4F5C\u6D41\u4E2D\u65E0\u4EFB\u4F55\u4EFB\u52A1\u8282\u70B9\uFF0C\u65E0\u6CD5\u5220\u9664");let D=n6(X.tasks,U);if(!D)throw new a$(`\u672A\u627E\u5230\u5F85\u5220\u9664\u7684\u5DE5\u4F5C\u6D41\u4EFB\u52A1\u8282\u70B9: ${U}`);if(D.parentTasks===X.tasks&&D.arrayIndex===0&&X.tasks.length>1&&(D.task.groupName==="trigger"||D.task.type.includes("trigger")||D.task.type==="webhook"||D.task.type==="clock"))throw new p$(`\u8282\u70B9 [${D.task.name}] (${D.task.label||D.task.type}) \u662F\u5DE5\u4F5C\u6D41\u7684\u89E6\u53D1\u6E90\u8282\u70B9\u3002\u76F4\u63A5\u79FB\u9664\u4F1A\u5BFC\u81F4\u5DE5\u4F5C\u6D41\u7F3A\u5C11\u89E6\u53D1\u5668\uFF0C\u8BF7\u4F7F\u7528 workflow save \u6216\u5728\u8BBE\u8BA1\u5668\u4E2D\u8C03\u6574\u89E6\u53D1\u5668\u3002`);let[W]=D.parentTasks.splice(D.arrayIndex,1);return UY(X.tasks),{workflow:X,removedTask:W}}var q2=C(()=>{Q0()});var g2={};I0(g2,{isKnownGrayNodeType:()=>_2,findGrayNode:()=>k2,GRAY_NODES_CATALOG:()=>I8});function k2($){let U=$.trim().toLowerCase();return iO.get(U)||R2.get(U)}function _2($){return iO.has($.trim().toLowerCase())}var I8,iO,R2;var WY=C(()=>{I8=[{displayName:"JS\u8282\u70B9\uFF08\u65B0\uFF09",name:"JS\u8282\u70B9\uFF08\u65B0\uFF09",type:"code-js2",category:"action"},{displayName:"\u91CD\u7B97\u5BA1\u6279\u6D41",name:"\u91CD\u7B97\u5BA1\u6279\u6D41",type:"recalculate-the-approval-flow",category:"action"},{displayName:"\u63D0\u793A\u6846",name:"\u63D0\u793A\u6846",type:"ui-notification",category:"action"},{displayName:"\u5B9A\u65F6\u4EFB\u52A1\u8282\u70B9",name:"\u5B9A\u65F6\u4EFB\u52A1\u8282\u70B9",type:"start",category:"trigger"},{displayName:"\u63A8\u9001\u98DE\u4E66\u6D88\u606F",name:"\u63A8\u9001\u98DE\u4E66\u6D88\u606F",type:"feishu-sendMsg",category:"action"},{displayName:"\u98DE\
Line truncated
|
||||
`&&L!=="\r")X[K]=" ";if(D==="line"){if(L===`
|
||||
|
||||
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
// Shell fixtures start several processes; allow headroom on a busy host.
|
||||
const fixtures: string[] = [];
|
||||
afterEach(() => { for (const root of fixtures.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
||||
const hash = (data: Buffer | string) => createHash("sha256").update(data).digest("hex");
|
||||
@@ -63,7 +64,7 @@ if [ -n "$dest" ]; then cp "$file" "$dest"; else cat "$file"; fi
|
||||
const run = (env: Record<string, string> = {}) => spawnSync("bash", [resolve(import.meta.dir, "install.sh")], {
|
||||
cwd: root,
|
||||
env: { ...process.env, PATH: `${tools}:${process.env.PATH}`, HOSE_USE_INSTALL_DIR: target, HOSE_USE_VERSION: "9.9.9", HOSE_USE_MIRROR: "auto", HOSE_FIXTURE_SOURCE: source, HOSE_FIXTURE_LOG: join(root, "skill.log"), HOSE_FIXTURE_REQUESTS: join(root, "requests.log"), ...env },
|
||||
encoding: "utf8", timeout: 10_000,
|
||||
encoding: "utf8", timeout: 30_000,
|
||||
});
|
||||
return { root, source, target, run, binary };
|
||||
}
|
||||
@@ -77,7 +78,7 @@ describe("verified standalone installer", () => {
|
||||
expect(readlinkSync(join(f.target, "hose-aipro"))).toBe("hose-use");
|
||||
expect(readFileSync(join(f.root, "skill.log"), "utf8").trim()).toBe("skill install --yes");
|
||||
expect(readdirSync(f.target).sort()).toEqual(["hose-aipro", "hose-use"]);
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
for (const options of [{ badHash: true }, { missingEntry: true }, { duplicate: true }]) {
|
||||
test(`rejects an invalid manifest/archive and preserves the old binary: ${JSON.stringify(options)}`, () => {
|
||||
@@ -89,7 +90,7 @@ describe("verified standalone installer", () => {
|
||||
expect(result.status).toBe(1);
|
||||
expect(readFileSync(join(f.target, "hose-use"), "utf8")).toBe("old binary");
|
||||
expect(existsSync(join(f.root, "skill.log"))).toBe(false);
|
||||
});
|
||||
}, 60_000);
|
||||
}
|
||||
|
||||
test("does not silently bypass missing checksums or guess an old tag", () => {
|
||||
@@ -100,7 +101,7 @@ describe("verified standalone installer", () => {
|
||||
expect(unknown.stderr).toContain("could not resolve");
|
||||
expect(existsSync(join(f.target, "hose-use"))).toBe(false);
|
||||
expect(readFileSync(join(f.root, "requests.log"), "utf8")).not.toContain("v0.8.9");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("uses a verified raw fallback and a fixed tag when the first mirror fails", () => {
|
||||
const f = fixture({ rawOnly: true });
|
||||
@@ -110,7 +111,7 @@ describe("verified standalone installer", () => {
|
||||
const requests = readFileSync(join(f.root, "requests.log"), "utf8");
|
||||
expect(requests).toContain("/download/v9.9.9/");
|
||||
expect(requests).not.toContain("/latest/download/");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("reports Skill failure without claiming it was installed", () => {
|
||||
const f = fixture();
|
||||
@@ -119,7 +120,7 @@ describe("verified standalone installer", () => {
|
||||
expect(result.stderr).toContain("binary installed");
|
||||
expect(result.stdout).not.toContain("Agent skill installed");
|
||||
expect(result.stdout).not.toContain("successfully installed");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("does not replace directories or follow an existing alias into a directory", () => {
|
||||
const f = fixture();
|
||||
@@ -133,5 +134,5 @@ describe("verified standalone installer", () => {
|
||||
writeFileSync(join(f.target, "hose-use"), "old binary");
|
||||
expect(f.run().status).toBe(1);
|
||||
expect(readFileSync(join(f.target, "hose-use"), "utf8")).toBe("old binary");
|
||||
});
|
||||
}, 60_000);
|
||||
});
|
||||
@@ -8,6 +8,7 @@ import { parse } from "yaml";
|
||||
import { bumpVersion } from "./bump-version.js";
|
||||
import { verifyReleaseTag } from "./verify-release.js";
|
||||
|
||||
// Shell fixtures start several processes; allow headroom on a busy host.
|
||||
const roots: string[] = [];
|
||||
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
||||
|
||||
@@ -72,7 +73,7 @@ esac
|
||||
`, { mode: 0o755 });
|
||||
const workflow = parse(readFileSync(join(import.meta.dir, "../.github/workflows/release.yml"), "utf8"));
|
||||
const step = workflow.jobs["build-and-publish"].steps.find((s: { name?: string }) => s.name === "Publish Gitea Release");
|
||||
return { ...f, files, run: () => spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${tools}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0", MIRROR_ONLY: String(mirrorOnly), GITHUB_REPOSITORY: "test/repo", MIRROR_FIXTURE: f.root, MIRROR_MODE: mode }, encoding: "utf8", timeout: 5000 }) };
|
||||
return { ...f, files, run: () => spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${tools}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0", MIRROR_ONLY: String(mirrorOnly), GITHUB_REPOSITORY: "test/repo", MIRROR_FIXTURE: f.root, MIRROR_MODE: mode }, encoding: "utf8", timeout: 30_000 }) };
|
||||
}
|
||||
|
||||
describe("release preparation and publication guards", () => {
|
||||
@@ -86,7 +87,7 @@ describe("release preparation and publication guards", () => {
|
||||
for (const version of ["1.0.0", "0.9.9", "1.0.01", "1.0.1-rc.01", "invalid"]) expect(() => bumpVersion(f.root, version, () => {})).toThrow();
|
||||
expect(f.version()).toBe("1.0.0");
|
||||
expect(f.git("status", "--porcelain")).toBe("");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("bump updates sources on its release branch and explicitly invokes regeneration", () => {
|
||||
const f = repository();
|
||||
@@ -97,7 +98,7 @@ describe("release preparation and publication guards", () => {
|
||||
expect(f.version()).toBe("1.0.1");
|
||||
expect(readFileSync(join(f.root, "skills/hose-use/SKILL.md"), "utf8")).toContain("version: 1.0.1");
|
||||
expect(parse(readFileSync(join(f.root, "specs/openapi/openapi.yaml"), "utf8")).info.version).toBe("1.0.1");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("an existing release tag cannot be reused during bump", () => {
|
||||
const f = repository();
|
||||
@@ -105,7 +106,7 @@ describe("release preparation and publication guards", () => {
|
||||
f.git("tag", "v1.0.1");
|
||||
expect(() => bumpVersion(f.root, "patch", () => {})).toThrow("already exists");
|
||||
expect(f.version()).toBe("1.0.0");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("publication validates the actual HEAD, main ancestry and package version", () => {
|
||||
const f = repository();
|
||||
@@ -120,7 +121,7 @@ describe("release preparation and publication guards", () => {
|
||||
expect(() => verifyReleaseTag(f.root, "v1.0.0")).toThrow("exact tagged commit");
|
||||
f.git("tag", "v1.0.1");
|
||||
expect(() => verifyReleaseTag(f.root, "v1.0.1")).toThrow("ancestor");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("workflows validate committed versions before generation and ship the checksum manifest", () => {
|
||||
const root = join(import.meta.dir, "..");
|
||||
@@ -140,7 +141,7 @@ describe("release preparation and publication guards", () => {
|
||||
for (const name of ["Compile multi-target binaries", "Package release archives", "Publish GitHub Release"]) {
|
||||
expect(steps.find((s: { name?: string }) => s.name === name).if).toBe("${{ !inputs.mirror_only }}");
|
||||
}
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("a failed background Gitea upload makes the Release step fail", () => {
|
||||
const f = repository();
|
||||
@@ -159,11 +160,11 @@ for arg in "$@"; do
|
||||
done
|
||||
exit 22
|
||||
`, { mode: 0o755 });
|
||||
const result = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${join(f.root, "tools")}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0" }, encoding: "utf8", timeout: 5000 });
|
||||
const result = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${join(f.root, "tools")}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0" }, encoding: "utf8", timeout: 30_000 });
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toContain("assets failed to upload");
|
||||
expect(result.stdout).not.toContain("Successfully published");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("transient asset upload failures are retried", () => {
|
||||
const f = mirrorFixture("retry");
|
||||
@@ -171,20 +172,20 @@ exit 22
|
||||
expect(result.status).toBe(0);
|
||||
for (const name of f.files) expect(readFileSync(join(f.root, `count-${name}`), "utf8")).toBe("2");
|
||||
expect(result.stdout).toContain("attempt 2/3");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("correct mirror assets are verified and retained without uploading replacements", () => {
|
||||
const f = mirrorFixture("skip");
|
||||
const result = f.run();
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout.match(/already matches SHA-256/g)).toHaveLength(f.files.length);
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("mirror-only recovery downloads and verifies the existing GitHub assets", () => {
|
||||
const f = mirrorFixture("skip", true);
|
||||
expect(f.run().status).toBe(0);
|
||||
expect(readFileSync(join(f.root, "gh.log"), "utf8")).toContain("release download v1.0.0");
|
||||
});
|
||||
}, 60_000);
|
||||
|
||||
test("asset transfers never exceed two concurrent workers", () => {
|
||||
const f = mirrorFixture("concurrency");
|
||||
@@ -196,5 +197,5 @@ exit 22
|
||||
}
|
||||
expect(active).toBe(0);
|
||||
expect(peak).toBeLessThanOrEqual(2);
|
||||
});
|
||||
}, 60_000);
|
||||
});
|
||||
@@ -111,7 +111,8 @@ export async function watchWorkflowPipeline(
|
||||
pipelineId,
|
||||
totalJobsWatched: 1,
|
||||
jobs: [singleRes],
|
||||
timedOut: false,
|
||||
timedOut: Boolean(singleRes.timedOut),
|
||||
cancelled: singleRes.cancelled,
|
||||
hasFailures: singleRes.hasError || singleRes.status === "FAILED",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,3 +27,17 @@ test("cancellation is distinct from timeout and completion", async () => {
|
||||
expect(result.events.map(e => e.type)).toEqual(["cancelled"]);
|
||||
expect(c.get).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("latest-job snapshots propagate cancellation from the selected job", async () => {
|
||||
const controller = new AbortController();
|
||||
const c = { get: async (path: string) => {
|
||||
if (path.endsWith("/running")) return Response.json({ data: [{ id: "job", pipelineId: "wf" }] });
|
||||
if (path.includes("/pipelines/")) return Response.json({ data: { id: "wf", tasks: [] } });
|
||||
if (path.includes("/execution")) return Response.json({ data: [] });
|
||||
controller.abort();
|
||||
return Response.json({ data: { id: "job", pipelineId: "wf", status: "RUNNING" } });
|
||||
} } as any;
|
||||
const report = await watchWorkflowPipeline(c, "wf", { once: true, signal: controller.signal });
|
||||
expect(report.cancelled).toBe(true); expect(report.timedOut).toBe(false);
|
||||
expect(report.jobs[0].events.some(e => e.type === "job_completed")).toBe(false);
|
||||
});
|
||||
Reference in new issue
Block a user