aitable-workflow-core 0.1.13-beta.1

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.
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var u=(e,t)=>l(e,"name",{value:t,configurable:!0});function y(e,t,d={}){let r=I(d);if(t.type==="run.record.detected")return{records:S(e.records,{id:t.record.id,title:t.record.title||t.record.id,state:t.record.state,status:t.record.currentStep?"running":"todo",currentStepId:t.record.currentStep,doneStepIds:[],createdAt:r.now(),updatedAt:r.now()}),logs:o(e.logs,t.record.id,t.record.currentStep??"run","info",`\u53D1\u73B0\u5F85\u5904\u7406\u8BB0\u5F55\uFF1A${t.record.title||t.record.id}`,r)};if(t.type==="run.step.started"){let s=d.stepLevel?.(t.stepId,t)??"ai";return{records:p(e.records,t.itemId,n=>({...n,status:n.status==="done"?n.status:"running",currentStepId:n.status==="done"?n.currentStepId:t.stepId,updatedAt:r.now()})),logs:o(e.logs,t.itemId,t.stepId,s,`\u5F00\u59CB\u6267\u884C\u6B65\u9AA4\uFF1A${t.stepName}`,r)}}return t.type==="run.step.succeeded"?{records:p(e.records,t.itemId,s=>({...s,doneStepIds:c(s.doneStepIds,t.stepId),updatedAt:r.now()})),logs:a(o(e.logs,t.itemId,t.stepId,"ok",`\u6B65\u9AA4\u5B8C\u6210\uFF1A${t.stepName}`,r),t.itemId,t.stepId,"info",t.logs,r)}:t.type==="run.step.failed"?{records:p(e.records,t.itemId,s=>({...s,status:s.status==="done"?s.status:"blocked",currentStepId:s.status==="done"?s.currentStepId:t.stepId,updatedAt:r.now()})),logs:a(o(e.logs,t.itemId,t.stepId,"error",`\u6B65\u9AA4\u5931\u8D25\uFF1A${t.stepName} \xB7 ${t.error}`,r),t.itemId,t.stepId,"error",t.logs,r)}:t.type==="run.record.blocked"?{records:p(e.records,t.itemId,s=>({...s,status:s.status==="done"?s.status:t.reason.includes("\u4EBA\u5DE5")?"review":"blocked",currentStepId:s.status==="done"?s.currentStepId:t.stepId,doneStepIds:c(s.doneStepIds,t.stepId),updatedAt:r.now()})),logs:a(o(e.logs,t.itemId,t.stepId,"warn",`${t.stepName}\uFF1A${t.reason}`,r),t.itemId,t.stepId,"info",t.logs,r)}:t.type==="run.record.completed"?{records:p(e.records,t.itemId,s=>({...s,status:"done",currentStepId:null,updatedAt:r.now()})),logs:o(e.logs,t.itemId,"run","ok","\u6D41\u7A0B\u5B8C\u6210",r)}:e}u(y,"applyRunExecutionEvent");function I(e){return{now:e.now??Date.now,id:e.id??m,maxLogs:e.maxLogs??300}}u(I,"createContext");function S(e,t){return e.findIndex(r=>r.id===t.id)<0?[...e,t]:e.map(r=>r.id===t.id?{...r,...t,doneStepIds:r.doneStepIds,status:r.status==="done"?r.status:t.status,currentStepId:r.status==="done"?r.currentStepId:t.currentStepId,createdAt:r.createdAt}:r)}u(S,"upsertRunRecord");function p(e,t,d){return e.map(r=>r.id===t?d(r):r)}u(p,"updateRunRecord");function c(e,t){return e.includes(t)?e:[...e,t]}u(c,"addDoneStep");function o(e,t,d,r,s,n){return e.some(i=>i.itemId===t&&i.stepId===d&&i.level===r&&i.text===s)?e:[...e,{id:n.id(),ts:n.now(),itemId:t,stepId:d,level:r,text:s}].slice(-n.maxLogs)}u(o,"appendRunLog");function a(e,t,d,r,s,n){return s?.length?s.reduce((g,i)=>o(g,t,d,r,i,n),e):e}u(a,"appendRunLogs");function m(){return`run_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}u(m,"createRunLogId");export{u as a,y as b};