MCPcopy Create free account
hub / github.com/ShipSecAI/studio / main

Function main

worker/scripts/workflow-runner.ts:179–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

177}
178
179async function main() {
180 const { workflowRecordId, fileId, limit, shouldRun, list } = parseArgs();
181
182 const __dirname = dirname(fileURLToPath(import.meta.url));
183 config({ path: join(__dirname, '..', '.env') });
184
185 const pool = new Pool({
186 connectionString:
187 process.env.DATABASE_URL ?? 'postgresql://shipsec:shipsec@localhost:5433/shipsec',
188 });
189
190 const definition = await loadDefinition(pool, workflowRecordId);
191
192 const address = process.env.TEMPORAL_ADDRESS ?? 'localhost:7233';
193 const namespace = process.env.TEMPORAL_NAMESPACE ?? 'shipsec-dev';
194
195 const connection = await Connection.connect({ address });
196 const client = new Client({ connection, namespace });
197
198 try {
199 if (list) {
200 const runs = await listRuns(client, workflowRecordId, definition, limit);
201 console.log('--- Existing Runs ---');
202 if (runs.length === 0) {
203 console.log('No runs found for workflow', workflowRecordId);
204 } else {
205 for (const run of runs) {
206 console.log(JSON.stringify(run, null, 2));
207 }
208 }
209 console.log('---------------------');
210 }
211
212 if (shouldRun && fileId) {
213 console.log('Starting new workflow run...');
214 const { runId, result } = await runWorkflow(client, definition, workflowRecordId, fileId);
215 console.log('--- New Run Result ---');
216 console.log(JSON.stringify({ runId, result }, null, 2));
217 console.log('----------------------');
218 }
219 } finally {
220 await connection.close();
221 await pool.end();
222 }
223}
224
225main().catch((error) => {
226 console.error(error);

Callers 1

workflow-runner.tsFile · 0.70

Calls 6

listRunsFunction · 0.85
connectMethod · 0.80
parseArgsFunction · 0.70
loadDefinitionFunction · 0.70
runWorkflowFunction · 0.70
closeMethod · 0.45

Tested by

no test coverage detected