Add human role decision nodes

This commit is contained in:
2026-11-05 22:33:28 +00:00
parent c8a81eba08
commit 36111a3166
5 changed files with 37 additions and 12 deletions
+18 -3
View File
@@ -2,6 +2,8 @@ export type SystemCategory = 'application' | 'service' | 'data' | 'human' | 'ext
export interface PortModel { id: string; name: string; description: string }
export interface ActionModel { id: string; name: string; description: string; payload: string }
export interface HumanActionModel extends ActionModel { connectionId: string }
export interface HumanDecisionModel { roleSystemId: string; task: string; receivedData: string; editableFields: Record<string, string>; actions: HumanActionModel[] }
export interface CapabilityModel { id: string; name: string; description: string; inputs: PortModel[]; outputs: PortModel[]; actions: ActionModel[]; payload: string }
export interface SystemPreset { id: string; name: string; description: string; category: SystemCategory; color: string; capabilities: CapabilityModel[] }
@@ -39,6 +41,7 @@ export interface ScenarioStep {
outcome?: 'success' | 'rejected' | 'timeout'
retryStepId?: string
recoveryStepId?: string
humanDecision?: HumanDecisionModel
}
export interface ScenarioModel {
@@ -75,7 +78,8 @@ export const SYSTEM_PRESETS: SystemPreset[] = [
{ id: 'erp', name: 'ERP', description: 'Back-office fulfilment and inventory management.', category: 'data', color: '#f2a65a', capabilities: [capability('orders', 'Order management', 'Create and progress fulfilment orders.', [port('order-request', 'Order request', 'An order to fulfil.')], [port('order-status', 'Order status', 'Current fulfilment status.')], [action('create-order', 'Create order', 'Create a fictional ERP order.', '{"orderId":"ord_1042","status":"new"}')], '{"orderId":"ord_1042","status":"new"}'), capability('inventory', 'Inventory', 'Check and reserve fictional stock.', [port('stock-check', 'Stock check', 'A product stock request.')], [port('stock-result', 'Stock result', 'Available stock information.')], [action('reserve-stock', 'Reserve stock', 'Reserve fictional stock.', '{"sku":"sample-blue","available":24,"reserved":1}')], '{"sku":"sample-blue","available":24}') ]},
{ id: 'email', name: 'Email Platform', description: 'Transactional and lifecycle messaging.', category: 'external', color: '#4aa3df', capabilities: [capability('transactional-email', 'Transactional email', 'Send a message from a template.', [port('email-request', 'Email request', 'A message request.')], [port('delivery-event', 'Delivery event', 'Delivery status.')], [action('send-email', 'Send email', 'Send a fictional transactional email.', '{"messageId":"msg_44","template":"order-confirmation","to":"sam@example.test"}')], '{"template":"order-confirmation","to":"sam@example.test"}'), capability('campaigns', 'Campaigns', 'Send lifecycle or campaign messages.', [port('campaign-request', 'Campaign request', 'A campaign message request.')], [port('campaign-event', 'Campaign event', 'Campaign delivery status.')], [action('send-campaign', 'Send campaign', 'Send a fictional campaign message.', '{"campaign":"welcome","customerId":"cus_89"}')], '{"campaign":"welcome","customerId":"cus_89"}') ]},
{ id: 'analytics', name: 'Analytics', description: 'Collect and report product and business events.', category: 'data', color: '#8f7cf2', capabilities: [capability('event-collection', 'Event collection', 'Accept events from connected systems.', [port('event', 'Event', 'A product or business event.')], [port('accepted-event', 'Accepted event', 'An accepted analytics event.')], [action('capture-event', 'Capture event', 'Capture a fictional analytics event.', '{"event":"checkout_completed","visitorId":"vis_204"}')], '{"event":"checkout_completed","visitorId":"vis_204"}'), capability('reporting', 'Reporting', 'Produce a simple report payload.', [port('report-query', 'Report query', 'A report query.')], [port('report', 'Report', 'A generated report.')], [action('run-report', 'Run report', 'Generate a fictional report.', '{"report":"weekly-orders","orders":42}')], '{"report":"weekly-orders","orders":42}') ]},
{ id: 'api', name: 'API', description: 'Orchestrate requests between applications and services.', category: 'service', color: '#26c6a6', capabilities: [capability('http-api', 'HTTP API', 'Receive and route application requests.', [port('request', 'Request', 'An inbound API request.')], [port('response', 'Response', 'A response returned to the caller.')], [action('handle-request', 'Handle request', 'Handle a fictional API request.', '{"requestId":"req_1001","status":"accepted"}')], '{"requestId":"req_1001","status":"accepted"}'), capability('webhooks', 'Webhooks', 'Send outbound event notifications.', [port('event', 'Event', 'An event to publish.')], [port('webhook', 'Webhook', 'An outbound webhook delivery.')], [action('send-webhook', 'Send webhook', 'Send a fictional webhook.', '{"event":"order.created","id":"ord_1042"}')], '{"event":"order.created","id":"ord_1042"}') ]}
{ id: 'api', name: 'API', description: 'Orchestrate requests between applications and services.', category: 'service', color: '#26c6a6', capabilities: [capability('http-api', 'HTTP API', 'Receive and route application requests.', [port('request', 'Request', 'An inbound API request.')], [port('response', 'Response', 'A response returned to the caller.')], [action('handle-request', 'Handle request', 'Handle a fictional API request.', '{"requestId":"req_1001","status":"accepted"}')], '{"requestId":"req_1001","status":"accepted"}'), capability('webhooks', 'Webhooks', 'Send outbound event notifications.', [port('event', 'Event', 'An event to publish.')], [port('webhook', 'Webhook', 'An outbound webhook delivery.')], [action('send-webhook', 'Send webhook', 'Send a fictional webhook.', '{"event":"order.created","id":"ord_1042"}')], '{"event":"order.created","id":"ord_1042"}') ]},
{ id: 'sales-review-role', name: 'Sales review', description: 'A sales team role that reviews sample requests.', category: 'human', color: '#f06ca9', capabilities: [capability('sales-review', 'Sales review', 'Review a sample request and choose the next action.', [port('review-request', 'Review request', 'Information waiting for a sales decision.')], [port('decision', 'Decision', 'The selected sales action.')], [action('approve', 'Approve', 'Approve a request for fulfilment.', '{"decision":"approved","reviewerRole":"sales"}'), action('reject', 'Reject', 'Reject a request and notify the customer.', '{"decision":"rejected","reviewerRole":"sales"}'), action('edit', 'Edit', 'Edit the request before forwarding.', '{"decision":"edited","reviewerRole":"sales"}'), action('forward', 'Forward', 'Forward the request for another review.', '{"decision":"forwarded","reviewerRole":"sales"}')], '{"decision":"pending","reviewerRole":"sales"}') ]}
]
export function getPreset(id: string) { return SYSTEM_PRESETS.find((preset) => preset.id === id) }
@@ -89,7 +93,8 @@ export const demoLandscape = (): LandscapeModel => ({
{ id: 'api', name: 'API', description: 'Order and customer orchestration service.', category: 'service', color: '#26c6a6', position: [360, 180], presetId: 'api', capabilities: cloneCapabilities(getPreset('api')!.capabilities) },
{ id: 'erp', name: 'ERP', description: 'Back-office order fulfilment and inventory system.', category: 'data', color: '#f2a65a', position: [650, 100], presetId: 'erp', capabilities: cloneCapabilities(getPreset('erp')!.capabilities) },
{ id: 'crm', name: 'CRM', description: 'Customer profile and lifecycle management.', category: 'data', color: '#dd6bca', position: [650, 290], presetId: 'crm', capabilities: cloneCapabilities(getPreset('crm')!.capabilities) },
{ id: 'email', name: 'Email Platform', description: 'Transactional and lifecycle messaging.', category: 'external', color: '#4aa3df', position: [930, 290], presetId: 'email', capabilities: cloneCapabilities(getPreset('email')!.capabilities) }
{ id: 'email', name: 'Email Platform', description: 'Transactional and lifecycle messaging.', category: 'external', color: '#4aa3df', position: [930, 290], presetId: 'email', capabilities: cloneCapabilities(getPreset('email')!.capabilities) },
{ id: 'sales-review', name: 'Sales review', description: 'Sales team role that reviews sample requests.', category: 'human', color: '#f06ca9', position: [650, 480], presetId: 'sales-review-role', capabilities: cloneCapabilities(getPreset('sales-review-role')!.capabilities) }
],
connections: [
{ id: 'website-api', sourceId: 'website', targetId: 'api', label: 'Order request', description: 'Website submits a new order to the API.', payload: '{"orderId":"ord_1042","total":129.5}' },
@@ -104,7 +109,10 @@ export const demoLandscape = (): LandscapeModel => ({
{ id: 'website-api-sample', sourceId: 'website', targetId: 'api', label: 'Sample request', description: 'Website sends a product sample request.', payload: '{"orderId":"smp_1042","sku":"sample-blue"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true },
{ id: 'api-erp-sample', sourceId: 'api', targetId: 'erp', label: 'Reserve sample', description: 'API asks ERP to reserve sample stock.', payload: '{"sku":"sample-blue","quantity":1}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'scheduled', showCableLabel: true },
{ id: 'website-api-commercial', sourceId: 'website', targetId: 'api', label: 'Commercial order', description: 'Website submits a commercial order.', payload: '{"orderId":"ord_2048","total":249.0}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true },
{ id: 'api-erp-commercial', sourceId: 'api', targetId: 'erp', label: 'Fulfil commercial order', description: 'API creates the commercial order in ERP.', payload: '{"orderId":"ord_2048","status":"new"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true }
{ id: 'api-erp-commercial', sourceId: 'api', targetId: 'erp', label: 'Fulfil commercial order', description: 'API creates the commercial order in ERP.', payload: '{"orderId":"ord_2048","status":"new"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'immediate', showCableLabel: true },
{ id: 'website-sales-review', sourceId: 'website', targetId: 'sales-review', label: 'Sample review', description: 'Website sends a sample request to Sales.', payload: '{"orderId":"smp_1042","sku":"sample-blue"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'manual', showCableLabel: true },
{ id: 'sales-erp', sourceId: 'sales-review', targetId: 'erp', label: 'Approved sample', description: 'Sales approves the sample for ERP fulfilment.', payload: '{"orderId":"smp_1042","decision":"approved"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'manual', showCableLabel: true },
{ id: 'sales-email', sourceId: 'sales-review', targetId: 'email', label: 'Rejected sample notice', description: 'Sales rejection triggers a customer notification.', payload: '{"template":"sample-rejected","orderId":"smp_1042"}', protocol: 'HTTPS', dataType: 'JSON', deliveryMethod: 'manual', showCableLabel: true }
],
scenarios: [
{
@@ -152,6 +160,13 @@ export const demoLandscape = (): LandscapeModel => ({
{ id: 'retry-3', connectionIds: ['api-erp-commercial'], explanation: 'The API retries the fulfilment request after refreshing stock.', payload: '{"orderId":"ord_3001","status":"retry"}', delayMs: 900, outcome: 'success' },
{ id: 'retry-4', connectionIds: ['api-email'], explanation: 'The API sends a recovery confirmation to the customer.', payload: '{"template":"order-retry-recovered","orderId":"ord_3001"}', delayMs: 700, outcome: 'success' }
]
},
{
id: 'sample-sales-review', name: 'Sample request with Sales review', description: 'A human role decides whether a sample reaches ERP or the customer receives a rejection notice.', startSystemId: 'website', startActionId: 'place-sample',
steps: [
{ id: 'human-sample-1', connectionIds: ['website-sales-review'], explanation: 'The website sends a sample request to the Sales review role.', payload: '{"orderId":"smp_1042","sku":"sample-blue"}', delayMs: 800, outcome: 'success' },
{ id: 'human-sample-decision', connectionIds: [], explanation: 'Sales reviews the sample request and chooses what happens next.', payload: '{"decision":"pending","orderId":"smp_1042"}', delayMs: 500, humanDecision: { roleSystemId: 'sales-review', task: 'Review the sample request and decide whether Sales should approve fulfilment or notify the customer that the request cannot proceed.', receivedData: '{"orderId":"smp_1042","sku":"sample-blue","customer":"sam@example.test"}', editableFields: { customerNote: 'Please confirm the colour before fulfilment.' }, actions: [{ id: 'approve', name: 'Approve', description: 'Send the approved sample to ERP.', payload: '{"orderId":"smp_1042","decision":"approved"}', connectionId: 'sales-erp' }, { id: 'reject', name: 'Reject', description: 'Notify the customer that the sample was rejected.', payload: '{"orderId":"smp_1042","decision":"rejected"}', connectionId: 'sales-email' }, { id: 'edit', name: 'Edit', description: 'Edit the request and forward it to ERP.', payload: '{"orderId":"smp_1042","decision":"edited","note":"Please confirm the colour"}', connectionId: 'sales-erp' }, { id: 'forward', name: 'Forward', description: 'Forward the request to ERP for another review.', payload: '{"orderId":"smp_1042","decision":"forwarded"}', connectionId: 'sales-erp' }] } }
]
}
]
})