Skip to content

Commit 9116e8f

Browse files
committed
feat: update agent and flow definitions with improved descriptions and type annotations
1 parent caf37a4 commit 9116e8f

22 files changed

Lines changed: 83 additions & 125 deletions

examples/app-crm/src/agents/email-campaign.agent.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const EmailCampaignAgent: Agent = {
1+
/** Email Campaign Agent — creates and optimizes email campaigns */
2+
export const EmailCampaignAgent = {
43
name: 'email_campaign',
54
label: 'Email Campaign Agent',
6-
description: 'AI agent to create and optimize email campaigns',
75
role: 'creator',
8-
6+
97
instructions: `You are an email marketing AI that creates and optimizes email campaigns.
108
119
Your responsibilities:
@@ -19,13 +17,13 @@ Your responsibilities:
1917
Follow email marketing best practices and maintain brand voice.`,
2018

2119
model: { provider: 'anthropic', model: 'claude-3-opus', temperature: 0.8, maxTokens: 2000 },
22-
20+
2321
tools: [
24-
{ type: 'action', name: 'generate_email_copy', description: 'Generate email campaign copy' },
25-
{ type: 'action', name: 'optimize_subject_line', description: 'Optimize email subject line' },
26-
{ type: 'action', name: 'personalize_content', description: 'Personalize email content' },
22+
{ type: 'action' as const, name: 'generate_email_copy', description: 'Generate email campaign copy' },
23+
{ type: 'action' as const, name: 'optimize_subject_line', description: 'Optimize email subject line' },
24+
{ type: 'action' as const, name: 'personalize_content', description: 'Personalize email content' },
2725
],
28-
26+
2927
knowledge: {
3028
topics: ['email_marketing', 'brand_guidelines', 'campaign_templates'],
3129
indexes: ['sales_knowledge'],
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const LeadEnrichmentAgent: Agent = {
1+
/** Lead Enrichment Agent — automatically enriches lead data from external sources */
2+
export const LeadEnrichmentAgent = {
43
name: 'lead_enrichment',
54
label: 'Lead Enrichment Agent',
6-
description: 'AI agent to automatically enrich lead data from external sources',
75
role: 'worker',
8-
6+
97
instructions: `You are a lead enrichment AI that enhances lead records with additional data.
108
119
Your responsibilities:
@@ -19,21 +17,21 @@ Your responsibilities:
1917
Always use reputable data sources and maintain data quality.`,
2018

2119
model: { provider: 'openai', model: 'gpt-3.5-turbo', temperature: 0.3, maxTokens: 1000 },
22-
20+
2321
tools: [
24-
{ type: 'action', name: 'lookup_company', description: 'Look up company information' },
25-
{ type: 'action', name: 'enrich_contact', description: 'Enrich contact information' },
26-
{ type: 'action', name: 'validate_email', description: 'Validate email address' },
22+
{ type: 'action' as const, name: 'lookup_company', description: 'Look up company information' },
23+
{ type: 'action' as const, name: 'enrich_contact', description: 'Enrich contact information' },
24+
{ type: 'action' as const, name: 'validate_email', description: 'Validate email address' },
2725
],
28-
26+
2927
knowledge: {
3028
topics: ['lead_enrichment', 'company_data'],
3129
indexes: ['sales_knowledge'],
3230
},
33-
31+
3432
triggers: [
3533
{ type: 'object_create', objectName: 'lead' },
3634
],
37-
35+
3836
schedule: { type: 'cron', expression: '0 */4 * * *', timezone: 'UTC' },
3937
};
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const RevenueIntelligenceAgent: Agent = {
1+
/** Revenue Intelligence Agent — analyzes pipeline and provides revenue insights */
2+
export const RevenueIntelligenceAgent = {
43
name: 'revenue_intelligence',
54
label: 'Revenue Intelligence Agent',
6-
description: 'AI agent to analyze pipeline and provide revenue insights',
75
role: 'analyst',
8-
6+
97
instructions: `You are a revenue intelligence AI that analyzes sales data and provides insights.
108
119
Your responsibilities:
@@ -19,17 +17,17 @@ Your responsibilities:
1917
Use statistical analysis and machine learning to provide data-driven insights.`,
2018

2119
model: { provider: 'openai', model: 'gpt-4', temperature: 0.2, maxTokens: 3000 },
22-
20+
2321
tools: [
24-
{ type: 'query', name: 'analyze_pipeline', description: 'Analyze sales pipeline health' },
25-
{ type: 'query', name: 'identify_at_risk', description: 'Identify at-risk opportunities' },
26-
{ type: 'query', name: 'forecast_revenue', description: 'Generate revenue forecast' },
22+
{ type: 'query' as const, name: 'analyze_pipeline', description: 'Analyze sales pipeline health' },
23+
{ type: 'query' as const, name: 'identify_at_risk', description: 'Identify at-risk opportunities' },
24+
{ type: 'query' as const, name: 'forecast_revenue', description: 'Generate revenue forecast' },
2725
],
28-
26+
2927
knowledge: {
3028
topics: ['pipeline_analytics', 'revenue_forecasting', 'deal_risk'],
3129
indexes: ['sales_knowledge'],
3230
},
33-
31+
3432
schedule: { type: 'cron', expression: '0 8 * * 1', timezone: 'America/Los_Angeles' },
3533
};

examples/app-crm/src/agents/sales.agent.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const SalesAssistantAgent: Agent = {
1+
/** Sales Assistant — helps reps with lead qualification and opportunity management */
2+
export const SalesAssistantAgent = {
43
name: 'sales_assistant',
54
label: 'Sales Assistant',
6-
description: 'AI agent to help sales reps with lead qualification and opportunity management',
75
role: 'assistant',
8-
6+
97
instructions: `You are a sales assistant AI helping sales representatives manage their pipeline.
108
119
Your responsibilities:
@@ -19,18 +17,18 @@ Your responsibilities:
1917
Always be professional, data-driven, and focused on helping close deals.`,
2018

2119
model: { provider: 'openai', model: 'gpt-4', temperature: 0.7, maxTokens: 2000 },
22-
20+
2321
tools: [
24-
{ type: 'action', name: 'analyze_lead', description: 'Analyze a lead and provide qualification score' },
25-
{ type: 'action', name: 'suggest_next_action', description: 'Suggest next best action for an opportunity' },
26-
{ type: 'action', name: 'generate_email', description: 'Generate a personalized email template' },
22+
{ type: 'action' as const, name: 'analyze_lead', description: 'Analyze a lead and provide qualification score' },
23+
{ type: 'action' as const, name: 'suggest_next_action', description: 'Suggest next best action for an opportunity' },
24+
{ type: 'action' as const, name: 'generate_email', description: 'Generate a personalized email template' },
2725
],
28-
26+
2927
knowledge: {
3028
topics: ['sales_playbook', 'product_catalog', 'lead_qualification'],
3129
indexes: ['sales_knowledge'],
3230
},
33-
31+
3432
triggers: [
3533
{ type: 'object_create', objectName: 'lead', condition: 'rating = "hot"' },
3634
{ type: 'object_update', objectName: 'opportunity', condition: 'ISCHANGED(stage)' },

examples/app-crm/src/agents/service.agent.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import type { Agent } from '@objectstack/spec/ai';
2-
3-
export const ServiceAgent: Agent = {
1+
/** Customer Service Agent — assists with case triage and resolution */
2+
export const ServiceAgent = {
43
name: 'service_agent',
54
label: 'Customer Service Agent',
6-
description: 'AI agent to assist with customer support cases',
75
role: 'assistant',
8-
6+
97
instructions: `You are a customer service AI agent helping support representatives resolve customer issues.
108
119
Your responsibilities:
@@ -19,18 +17,18 @@ Your responsibilities:
1917
Always be empathetic, solution-focused, and customer-centric.`,
2018

2119
model: { provider: 'openai', model: 'gpt-4', temperature: 0.5, maxTokens: 1500 },
22-
20+
2321
tools: [
24-
{ type: 'action', name: 'triage_case', description: 'Analyze case and assign priority' },
25-
{ type: 'vector_search', name: 'search_knowledge', description: 'Search knowledge base for solutions' },
26-
{ type: 'action', name: 'generate_response', description: 'Generate customer response' },
22+
{ type: 'action' as const, name: 'triage_case', description: 'Analyze case and assign priority' },
23+
{ type: 'vector_search' as const, name: 'search_knowledge', description: 'Search knowledge base for solutions' },
24+
{ type: 'action' as const, name: 'generate_response', description: 'Generate customer response' },
2725
],
28-
26+
2927
knowledge: {
3028
topics: ['support_kb', 'sla_policies', 'case_resolution'],
3129
indexes: ['support_knowledge'],
3230
},
33-
31+
3432
triggers: [
3533
{ type: 'object_create', objectName: 'case' },
3634
{ type: 'object_update', objectName: 'case', condition: 'priority = "critical"' },

examples/app-crm/src/flows/campaign-enrollment.flow.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const CampaignEnrollmentFlow: Flow = {
1+
/** Campaign Enrollment — scheduled flow to bulk enroll leads */
2+
export const CampaignEnrollmentFlow = {
43
name: 'campaign_enrollment',
54
label: 'Enroll Leads in Campaign',
65
description: 'Bulk enroll leads into marketing campaigns',
76
type: 'autolaunched',
87
triggerType: 'scheduled',
98
schedule: '0 9 * * 1', // Monday at 9am
10-
9+
1110
variables: [
1211
{ name: 'campaignId', type: 'text', isInput: true, isOutput: false },
1312
{ name: 'leadStatus', type: 'text', isInput: true, isOutput: false },
1413
],
15-
14+
1615
steps: [
1716
{
1817
id: 'get_campaign',

examples/app-crm/src/flows/case-escalation.flow.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const CaseEscalationFlow: Flow = {
1+
/** Case Escalation — auto-escalate high-priority cases */
2+
export const CaseEscalationFlow = {
43
name: 'case_escalation',
54
label: 'Case Escalation Process',
65
description: 'Automatically escalate high-priority cases',
76
type: 'autolaunched',
87
triggerType: 'on_create',
98
objectName: 'case',
109
criteria: 'priority = "critical" OR (priority = "high" AND account.type = "customer")',
11-
10+
1211
variables: [
1312
{ name: 'caseId', type: 'text', isInput: true, isOutput: false },
1413
],
15-
14+
1615
steps: [
1716
{
1817
id: 'get_case',

examples/app-crm/src/flows/lead-conversion.flow.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const LeadConversionFlow: Flow = {
1+
/** Lead Conversion — multi-step screen flow to convert qualified leads */
2+
export const LeadConversionFlow = {
43
name: 'lead_conversion',
54
label: 'Lead Conversion Process',
65
description: 'Automated flow to convert qualified leads to accounts, contacts, and opportunities',
76
type: 'screen',
87
triggerType: 'manual',
98
objectName: 'lead',
10-
9+
1110
variables: [
1211
{ name: 'leadId', type: 'text', isInput: true, isOutput: false },
1312
{ name: 'createOpportunity', type: 'boolean', isInput: true, isOutput: false },
1413
{ name: 'opportunityName', type: 'text', isInput: true, isOutput: false },
1514
{ name: 'opportunityAmount', type: 'text', isInput: true, isOutput: false },
1615
],
17-
16+
1817
steps: [
1918
{
2019
id: 'screen_1',

examples/app-crm/src/flows/opportunity-approval.flow.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const OpportunityApprovalFlow: Flow = {
1+
/** Opportunity Approval — multi-level approval for deals over $100K */
2+
export const OpportunityApprovalFlow = {
43
name: 'opportunity_approval',
54
label: 'Large Deal Approval',
65
description: 'Approval process for opportunities over $100K',
76
type: 'autolaunched',
87
triggerType: 'on_update',
98
objectName: 'opportunity',
109
criteria: 'amount > 100000 AND stage = "proposal"',
11-
10+
1211
variables: [
1312
{ name: 'opportunityId', type: 'text', isInput: true, isOutput: false },
1413
],
15-
14+
1615
steps: [
1716
{
1817
id: 'get_opportunity',

examples/app-crm/src/flows/quote-generation.flow.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import type { Flow } from '@objectstack/spec/automation';
2-
3-
export const QuoteGenerationFlow: Flow = {
1+
/** Quote Generation — screen flow to create a quote from an opportunity */
2+
export const QuoteGenerationFlow = {
43
name: 'quote_generation',
54
label: 'Generate Quote from Opportunity',
65
description: 'Create a quote based on opportunity details',
76
type: 'screen',
87
triggerType: 'manual',
98
objectName: 'opportunity',
10-
9+
1110
variables: [
1211
{ name: 'opportunityId', type: 'text', isInput: true, isOutput: false },
1312
{ name: 'quoteName', type: 'text', isInput: true, isOutput: false },
1413
{ name: 'expirationDays', type: 'number', isInput: true, isOutput: false },
1514
{ name: 'discount', type: 'number', isInput: true, isOutput: false },
1615
],
17-
16+
1817
steps: [
1918
{
2019
id: 'screen_1',

0 commit comments

Comments
 (0)