Personal Telegram developer console for GitHub
feat(cp7): add policy aware automation runner
davoodmehraban89 committed
Oct 5, 2026 at 06:21 UTC
28eb5c97a4ba64c22ffe67e5df5bd4658922afa6
1 file changed
+1
src/core/automation-runner.js
new
+1
@@ -0,0 +1 @@
1
+import {transitionAutomation} from './automation.js';export class AutomationRunner{constructor({router,store}){this.router=router;this.store=store;}async advance(state){const step=state.steps[state.cursor];if(!step)return state;const routed=await this.router.dispatchCallback(step.callback,{isOwner:true,ownerId:state.ownerId});if(!routed)throw new Error('Automation action unavailable');if(routed.requiresApproval){const next=transitionAutomation(state,{type:'pause',intent:{pluginId:routed.pluginId,actionId:routed.actionId,risk:routed.risk,input:routed.approval?.input,callback:step.callback,key:step.key}});await this.store.put(next);return next;}const checkpoint=await this.store.put(state);const result=routed.execute?await routed.execute():routed;const next=transitionAutomation(checkpoint,{type:'complete_step',key:step.key});await this.store.put(next);return {...next,lastResult:result};}async resume(state,{approval,key}){if(!approval||state.approvalIntent?.key!==key)throw new Error('Matching approval required');const resumed=transitionAutomation(state,{type:'resume',key});await this.store.put(resumed);return resumed;}}