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

Function execute

worker/src/components/security/notify.ts:350–446  ·  view source on GitHub ↗
({ inputs, params }, context)

Source from the content-addressed store, hash-verified

348 ],
349 },
350 async execute({ inputs, params }, context) {
351 // Validate that providerConfig is provided
352 if (!inputs.providerConfig || inputs.providerConfig.trim() === '') {
353 throw new ConfigurationError(
354 'Provider configuration is required. Please provide it via the Provider Config input.',
355 { configKey: 'providerConfig' },
356 );
357 }
358
359 const { messages, recipientIds, providerConfig, notifyConfig } = inputs;
360 const parsedParams = parameterSchema.parse(params);
361 const { providerIds } = parsedParams;
362
363 context.logger.info(
364 `[Notify] Sending ${messages.length} message(s) via ${providerIds && providerIds.length > 0 ? providerIds.join(', ') : 'all configured providers'}`,
365 );
366 context.emitProgress(
367 `Sending ${messages.length} notification${messages.length > 1 ? 's' : ''}`,
368 );
369
370 const tenantId = (context as any).tenantId ?? 'default-tenant';
371 const volume = new IsolatedContainerVolume(tenantId, context.runId);
372 const baseRunner = definition.runner;
373
374 if (baseRunner.kind !== 'docker') {
375 throw new ContainerError('Notify runner is expected to be docker-based.', {
376 details: { expectedKind: 'docker', actualKind: baseRunner.kind },
377 });
378 }
379
380 let rawOutput: string;
381 try {
382 // Prepare input files for the volume
383 const inputFiles: Record<string, string> = {
384 [MESSAGES_FILE_NAME]: messages.join('\n'),
385 [PROVIDER_CONFIG_FILE_NAME]: providerConfig,
386 };
387
388 // Add notify config file if provided
389 if (notifyConfig && notifyConfig.trim().length > 0) {
390 inputFiles[NOTIFY_CONFIG_FILE_NAME] = notifyConfig;
391 }
392
393 const volumeName = await volume.initialize(inputFiles);
394 context.logger.info(`[Notify] Created isolated volume: ${volumeName}`);
395
396 // Build notify CLI arguments in TypeScript
397 const notifyArgs = buildNotifyArgs({
398 messagesFile: `${CONTAINER_INPUT_DIR}/${MESSAGES_FILE_NAME}`,
399 providerConfigFile: `${CONTAINER_INPUT_DIR}/${PROVIDER_CONFIG_FILE_NAME}`,
400 notifyConfigFile:
401 notifyConfig && notifyConfig.trim().length > 0
402 ? `${CONTAINER_INPUT_DIR}/${NOTIFY_CONFIG_FILE_NAME}`
403 : undefined,
404 providerIds,
405 recipientIds,
406 messageFormat: parsedParams.messageFormat,
407 bulk: parsedParams.bulk ?? true,

Callers

nothing calls this directly

Calls 6

initializeMethod · 0.95
getVolumeConfigMethod · 0.95
cleanupMethod · 0.95
buildNotifyArgsFunction · 0.85
parseMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected