MCPcopy
hub / github.com/lightningpixel/modly / run

Method run

electron/main/process-runner.ts:118–145  ·  view source on GitHub ↗
(
    input:  ProcessInput,
    params: Record<string, unknown>,
    onProgress?: (percent: number, label: string) => void,
    onLog?:      (message: string) => void,
  )

Source from the content-addressed store, hash-verified

116 }
117
118 async run(
119 input: ProcessInput,
120 params: Record<string, unknown>,
121 onProgress?: (percent: number, label: string) => void,
122 onLog?: (message: string) => void,
123 ): Promise<ProcessResult> {
124 await this.ensureReady()
125 const worker = this.worker!
126
127 return new Promise((resolve, reject) => {
128 const handler = (msg: { type: string; result?: ProcessResult; message?: string; percent?: number; label?: string }) => {
129 if (msg.type === 'progress') {
130 onProgress?.(msg.percent ?? 0, msg.label ?? '')
131 } else if (msg.type === 'log') {
132 onLog?.(msg.message ?? '')
133 } else if (msg.type === 'done') {
134 worker.off('message', handler)
135 resolve(msg.result ?? {})
136 } else if (msg.type === 'error') {
137 worker.off('message', handler)
138 reject(new Error(msg.message))
139 }
140 }
141
142 worker.on('message', handler)
143 worker.postMessage({ action: 'run', input, params })
144 })
145 }
146
147 terminate(): void {
148 this.worker?.terminate()

Callers

nothing calls this directly

Calls 2

ensureReadyMethod · 0.95
onMethod · 0.80

Tested by

no test coverage detected