opc-agent 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +20 -0
  2. package/dist/channels/voice.d.ts +43 -0
  3. package/dist/channels/voice.js +67 -0
  4. package/dist/channels/webhook.d.ts +40 -0
  5. package/dist/channels/webhook.js +193 -0
  6. package/dist/cli.js +143 -13
  7. package/dist/core/a2a.d.ts +46 -0
  8. package/dist/core/a2a.js +99 -0
  9. package/dist/core/hitl.d.ts +41 -0
  10. package/dist/core/hitl.js +100 -0
  11. package/dist/core/performance.d.ts +50 -0
  12. package/dist/core/performance.js +148 -0
  13. package/dist/core/versioning.d.ts +29 -0
  14. package/dist/core/versioning.js +114 -0
  15. package/dist/core/workflow.d.ts +59 -0
  16. package/dist/core/workflow.js +174 -0
  17. package/dist/deploy/openclaw.d.ts +14 -0
  18. package/dist/deploy/openclaw.js +208 -0
  19. package/dist/index.d.ts +13 -0
  20. package/dist/index.js +18 -1
  21. package/dist/schema/oad.d.ts +352 -15
  22. package/dist/schema/oad.js +41 -2
  23. package/dist/templates/executive-assistant.d.ts +20 -0
  24. package/dist/templates/executive-assistant.js +70 -0
  25. package/dist/templates/financial-advisor.d.ts +15 -0
  26. package/dist/templates/financial-advisor.js +60 -0
  27. package/dist/templates/legal-assistant.d.ts +15 -0
  28. package/dist/templates/legal-assistant.js +70 -0
  29. package/examples/customer-service-demo/README.md +90 -0
  30. package/examples/customer-service-demo/oad.yaml +107 -0
  31. package/package.json +46 -46
  32. package/src/channels/voice.ts +106 -0
  33. package/src/channels/webhook.ts +199 -0
  34. package/src/cli.ts +524 -384
  35. package/src/core/a2a.ts +143 -0
  36. package/src/core/hitl.ts +138 -0
  37. package/src/core/performance.ts +187 -0
  38. package/src/core/versioning.ts +106 -0
  39. package/src/core/workflow.ts +235 -0
  40. package/src/deploy/openclaw.ts +200 -0
  41. package/src/index.ts +15 -0
  42. package/src/schema/oad.ts +45 -1
  43. package/src/templates/executive-assistant.ts +71 -0
  44. package/src/templates/financial-advisor.ts +60 -0
  45. package/src/templates/legal-assistant.ts +71 -0
  46. package/tests/a2a.test.ts +66 -0
  47. package/tests/hitl.test.ts +71 -0
  48. package/tests/performance.test.ts +115 -0
  49. package/tests/templates.test.ts +77 -0
  50. package/tests/versioning.test.ts +75 -0
  51. package/tests/voice.test.ts +61 -0
  52. package/tests/webhook.test.ts +29 -0
  53. package/tests/workflow.test.ts +143 -0
@@ -0,0 +1,235 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { Message, AgentContext, ISkill, IAgent } from './types';
3
+ import { Logger } from './logger';
4
+
5
+ // ── Workflow Types ──────────────────────────────────────────
6
+
7
+ export type StepType = 'skill' | 'tool' | 'agent' | 'condition' | 'parallel';
8
+
9
+ export interface WorkflowStep {
10
+ id: string;
11
+ type: StepType;
12
+ name: string;
13
+ config?: Record<string, unknown>;
14
+ /** For condition steps */
15
+ condition?: string;
16
+ branches?: { if: WorkflowStep[]; else?: WorkflowStep[] };
17
+ /** For parallel steps */
18
+ parallel?: WorkflowStep[];
19
+ /** Timeout in ms */
20
+ timeout?: number;
21
+ /** Retry count */
22
+ retries?: number;
23
+ }
24
+
25
+ export interface WorkflowDefinition {
26
+ name: string;
27
+ description?: string;
28
+ version?: string;
29
+ steps: WorkflowStep[];
30
+ onError?: 'stop' | 'skip' | 'retry';
31
+ }
32
+
33
+ export interface StepResult {
34
+ stepId: string;
35
+ status: 'success' | 'skipped' | 'error';
36
+ output?: string;
37
+ error?: string;
38
+ durationMs: number;
39
+ }
40
+
41
+ export interface WorkflowResult {
42
+ workflow: string;
43
+ status: 'completed' | 'failed' | 'partial';
44
+ steps: StepResult[];
45
+ totalDurationMs: number;
46
+ }
47
+
48
+ // ── Workflow Engine ─────────────────────────────────────────
49
+
50
+ export class WorkflowEngine extends EventEmitter {
51
+ private workflows: Map<string, WorkflowDefinition> = new Map();
52
+ private skills: Map<string, ISkill> = new Map();
53
+ private agents: Map<string, IAgent> = new Map();
54
+ private logger = new Logger('workflow');
55
+
56
+ registerWorkflow(workflow: WorkflowDefinition): void {
57
+ this.workflows.set(workflow.name, workflow);
58
+ this.logger.info('Workflow registered', { name: workflow.name, steps: workflow.steps.length });
59
+ }
60
+
61
+ unregisterWorkflow(name: string): void {
62
+ this.workflows.delete(name);
63
+ }
64
+
65
+ getWorkflow(name: string): WorkflowDefinition | undefined {
66
+ return this.workflows.get(name);
67
+ }
68
+
69
+ listWorkflows(): WorkflowDefinition[] {
70
+ return Array.from(this.workflows.values());
71
+ }
72
+
73
+ registerSkill(skill: ISkill): void {
74
+ this.skills.set(skill.name, skill);
75
+ }
76
+
77
+ registerAgent(agent: IAgent): void {
78
+ this.agents.set(agent.name, agent);
79
+ }
80
+
81
+ async run(name: string, context: AgentContext, input?: string): Promise<WorkflowResult> {
82
+ const workflow = this.workflows.get(name);
83
+ if (!workflow) throw new Error(`Workflow "${name}" not found`);
84
+
85
+ const startTime = Date.now();
86
+ const results: StepResult[] = [];
87
+ let failed = false;
88
+
89
+ this.emit('workflow:start', { name, input });
90
+
91
+ try {
92
+ await this.executeSteps(workflow.steps, context, input ?? '', results, workflow.onError ?? 'stop');
93
+ } catch (err) {
94
+ failed = true;
95
+ this.logger.error('Workflow failed', { name, error: (err as Error).message });
96
+ }
97
+
98
+ const result: WorkflowResult = {
99
+ workflow: name,
100
+ status: failed ? 'failed' : results.some(r => r.status === 'error') ? 'partial' : 'completed',
101
+ steps: results,
102
+ totalDurationMs: Date.now() - startTime,
103
+ };
104
+
105
+ this.emit('workflow:end', result);
106
+ return result;
107
+ }
108
+
109
+ private async executeSteps(
110
+ steps: WorkflowStep[],
111
+ context: AgentContext,
112
+ input: string,
113
+ results: StepResult[],
114
+ onError: string,
115
+ ): Promise<string> {
116
+ let currentInput = input;
117
+
118
+ for (const step of steps) {
119
+ const stepStart = Date.now();
120
+
121
+ try {
122
+ if (step.type === 'parallel' && step.parallel) {
123
+ const parallelResults = await Promise.all(
124
+ step.parallel.map(s => this.executeSingleStep(s, context, currentInput)),
125
+ );
126
+ const combined = parallelResults.map(r => r.output ?? '').join('\n');
127
+ for (const r of parallelResults) results.push(r);
128
+ currentInput = combined;
129
+ } else if (step.type === 'condition' && step.branches) {
130
+ const conditionMet = this.evaluateCondition(step.condition ?? '', currentInput, context);
131
+ const branch = conditionMet ? step.branches.if : (step.branches.else ?? []);
132
+ results.push({
133
+ stepId: step.id,
134
+ status: 'success',
135
+ output: `condition=${conditionMet}`,
136
+ durationMs: Date.now() - stepStart,
137
+ });
138
+ currentInput = await this.executeSteps(branch, context, currentInput, results, onError);
139
+ } else {
140
+ const result = await this.executeSingleStep(step, context, currentInput);
141
+ results.push(result);
142
+ if (result.status === 'success' && result.output) {
143
+ currentInput = result.output;
144
+ }
145
+ if (result.status === 'error' && onError === 'stop') {
146
+ throw new Error(`Step "${step.id}" failed: ${result.error}`);
147
+ }
148
+ }
149
+ } catch (err) {
150
+ if (onError === 'stop') throw err;
151
+ // skip: continue
152
+ }
153
+ }
154
+
155
+ return currentInput;
156
+ }
157
+
158
+ private async executeSingleStep(
159
+ step: WorkflowStep,
160
+ context: AgentContext,
161
+ input: string,
162
+ ): Promise<StepResult> {
163
+ const startTime = Date.now();
164
+ let retries = step.retries ?? 0;
165
+
166
+ while (true) {
167
+ try {
168
+ const output = await this.executeStepAction(step, context, input);
169
+ return {
170
+ stepId: step.id,
171
+ status: 'success',
172
+ output,
173
+ durationMs: Date.now() - startTime,
174
+ };
175
+ } catch (err) {
176
+ if (retries > 0) {
177
+ retries--;
178
+ continue;
179
+ }
180
+ return {
181
+ stepId: step.id,
182
+ status: 'error',
183
+ error: (err as Error).message,
184
+ durationMs: Date.now() - startTime,
185
+ };
186
+ }
187
+ }
188
+ }
189
+
190
+ private async executeStepAction(step: WorkflowStep, context: AgentContext, input: string): Promise<string> {
191
+ const message: Message = {
192
+ id: `wf_${step.id}_${Date.now()}`,
193
+ role: 'user',
194
+ content: input,
195
+ timestamp: Date.now(),
196
+ metadata: { workflowStep: step.id },
197
+ };
198
+
199
+ switch (step.type) {
200
+ case 'skill': {
201
+ const skill = this.skills.get(step.name);
202
+ if (!skill) throw new Error(`Skill "${step.name}" not found`);
203
+ const result = await skill.execute(context, message);
204
+ return result.response ?? '';
205
+ }
206
+ case 'agent': {
207
+ const agent = this.agents.get(step.name);
208
+ if (!agent) throw new Error(`Agent "${step.name}" not found`);
209
+ const response = await agent.handleMessage(message);
210
+ return response.content;
211
+ }
212
+ case 'tool': {
213
+ // Tools are executed via config callback
214
+ const toolFn = step.config?.handler as ((input: string) => Promise<string>) | undefined;
215
+ if (toolFn) return await toolFn(input);
216
+ return `[tool:${step.name}] executed`;
217
+ }
218
+ default:
219
+ return input;
220
+ }
221
+ }
222
+
223
+ private evaluateCondition(condition: string, input: string, _context: AgentContext): boolean {
224
+ // Simple condition evaluator: supports "contains:keyword", "length>N", "true", "false"
225
+ if (condition === 'true') return true;
226
+ if (condition === 'false') return false;
227
+ if (condition.startsWith('contains:')) {
228
+ return input.toLowerCase().includes(condition.slice(9).toLowerCase());
229
+ }
230
+ if (condition.startsWith('length>')) {
231
+ return input.length > parseInt(condition.slice(7), 10);
232
+ }
233
+ return !!condition;
234
+ }
235
+ }
@@ -0,0 +1,200 @@
1
+ /**
2
+ * OpenClaw Deployer - Convert OAD → OpenClaw agent workspace
3
+ */
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ import type { OADDocument } from '../schema/oad';
7
+
8
+ export interface DeployOptions {
9
+ oad: OADDocument;
10
+ outputDir: string;
11
+ install?: boolean; // also register in openclaw.json
12
+ }
13
+
14
+ export interface DeployResult {
15
+ outputDir: string;
16
+ files: string[];
17
+ installed: boolean;
18
+ configPath?: string;
19
+ }
20
+
21
+ function generateIdentityMd(oad: OADDocument): string {
22
+ const m = oad.metadata;
23
+ return `# IDENTITY.md
24
+
25
+ - **Name:** ${m.name}
26
+ - **Version:** ${m.version}
27
+ - **Description:** ${m.description ?? 'An AI agent'}
28
+ - **Author:** ${m.author ?? 'Unknown'}
29
+ - **License:** ${m.license}
30
+ `;
31
+ }
32
+
33
+ function generateSoulMd(oad: OADDocument): string {
34
+ const prompt = oad.spec.systemPrompt ?? 'You are a helpful AI assistant.';
35
+ return `# SOUL.md - ${oad.metadata.name}
36
+
37
+ ## System Prompt
38
+
39
+ ${prompt}
40
+
41
+ ## Model Configuration
42
+
43
+ - **Model:** ${oad.spec.model}
44
+ - **Provider:** ${oad.spec.provider?.default ?? 'deepseek'}
45
+ `;
46
+ }
47
+
48
+ function generateAgentsMd(oad: OADDocument): string {
49
+ const skills = oad.spec.skills;
50
+ const memory = oad.spec.memory;
51
+ const dtv = oad.spec.dtv;
52
+
53
+ let md = `# AGENTS.md - ${oad.metadata.name}\n\n`;
54
+
55
+ // Skills
56
+ md += `## Skills\n\n`;
57
+ if (skills.length === 0) {
58
+ md += `No skills configured.\n\n`;
59
+ } else {
60
+ for (const sk of skills) {
61
+ md += `### ${sk.name}\n`;
62
+ if (sk.description) md += `${sk.description}\n`;
63
+ if (sk.config) md += `\nConfig:\n\`\`\`json\n${JSON.stringify(sk.config, null, 2)}\n\`\`\`\n`;
64
+ md += `\n`;
65
+ }
66
+ }
67
+
68
+ // Memory
69
+ md += `## Memory\n\n`;
70
+ if (memory) {
71
+ md += `- Short-term: ${memory.shortTerm ? 'enabled' : 'disabled'}\n`;
72
+ const lt = memory.longTerm;
73
+ if (typeof lt === 'object' && lt) {
74
+ md += `- Long-term: ${lt.provider} (collection: ${lt.collection ?? 'default'})\n`;
75
+ } else {
76
+ md += `- Long-term: ${lt ? 'enabled' : 'disabled'}\n`;
77
+ }
78
+ } else {
79
+ md += `Default memory settings.\n`;
80
+ }
81
+ md += `\n`;
82
+
83
+ // DTV
84
+ if (dtv) {
85
+ md += `## Trust & Value\n\n`;
86
+ md += `- Trust Level: ${dtv.trust?.level ?? 'sandbox'}\n`;
87
+ if (dtv.value?.metrics?.length) {
88
+ md += `- Metrics: ${dtv.value.metrics.join(', ')}\n`;
89
+ }
90
+ md += `\n`;
91
+ }
92
+
93
+ return md;
94
+ }
95
+
96
+ function generateUserMd(oad: OADDocument): string {
97
+ return `# USER.md
98
+
99
+ - **Name:** (your name)
100
+ - **Role:** User
101
+ - **Notes:** Configure this file with your preferences for ${oad.metadata.name}.
102
+ `;
103
+ }
104
+
105
+ function generateMemoryMd(oad: OADDocument): string {
106
+ return `# MEMORY.md - ${oad.metadata.name}
107
+
108
+ ## Persistent Knowledge
109
+
110
+ (Agent will store learned information here)
111
+
112
+ ## User Preferences
113
+
114
+ (Discovered user preferences will be noted here)
115
+ `;
116
+ }
117
+
118
+ function generateOpenClawConfig(oad: OADDocument, agentDir: string): Record<string, any> {
119
+ const channels = oad.spec.channels;
120
+ const channelConfig: Record<string, any> = {};
121
+
122
+ for (const ch of channels) {
123
+ if (ch.type === 'telegram') {
124
+ channelConfig.telegram = {
125
+ enabled: true,
126
+ note: 'Configure bot token in OpenClaw gateway settings',
127
+ };
128
+ } else if (ch.type === 'web' || ch.type === 'websocket') {
129
+ channelConfig.web = { enabled: true, port: ch.port ?? 3000 };
130
+ }
131
+ }
132
+
133
+ return {
134
+ name: oad.metadata.name,
135
+ workspace: agentDir,
136
+ channels: channelConfig,
137
+ };
138
+ }
139
+
140
+ export function deployToOpenClaw(options: DeployOptions): DeployResult {
141
+ const { oad, outputDir, install } = options;
142
+ const files: string[] = [];
143
+
144
+ // Create output directory
145
+ fs.mkdirSync(outputDir, { recursive: true });
146
+
147
+ // Generate all workspace files
148
+ const fileMap: Record<string, string> = {
149
+ 'IDENTITY.md': generateIdentityMd(oad),
150
+ 'SOUL.md': generateSoulMd(oad),
151
+ 'AGENTS.md': generateAgentsMd(oad),
152
+ 'USER.md': generateUserMd(oad),
153
+ 'MEMORY.md': generateMemoryMd(oad),
154
+ };
155
+
156
+ for (const [name, content] of Object.entries(fileMap)) {
157
+ const filePath = path.join(outputDir, name);
158
+ fs.writeFileSync(filePath, content, 'utf-8');
159
+ files.push(name);
160
+ }
161
+
162
+ // Generate suggested channel config
163
+ const channelSuggestion = generateOpenClawConfig(oad, outputDir);
164
+ const configNote = path.join(outputDir, 'openclaw-config-suggestion.json');
165
+ fs.writeFileSync(configNote, JSON.stringify(channelSuggestion, null, 2), 'utf-8');
166
+ files.push('openclaw-config-suggestion.json');
167
+
168
+ const result: DeployResult = { outputDir, files, installed: false };
169
+
170
+ // Install mode: register in openclaw.json
171
+ if (install) {
172
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '';
173
+ const configPath = path.join(homeDir, '.openclaw', 'openclaw.json');
174
+
175
+ if (fs.existsSync(configPath)) {
176
+ try {
177
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
178
+ if (!config.agents) config.agents = {};
179
+
180
+ const agentId = oad.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
181
+ config.agents[agentId] = {
182
+ workspace: outputDir,
183
+ description: oad.metadata.description ?? '',
184
+ };
185
+
186
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
187
+ result.installed = true;
188
+ result.configPath = configPath;
189
+ } catch (err) {
190
+ // Config exists but couldn't be updated - not fatal
191
+ console.error(`Warning: Could not update ${configPath}:`, err);
192
+ }
193
+ } else {
194
+ console.error(`Warning: OpenClaw config not found at ${configPath}`);
195
+ console.error(`Run 'openclaw init' first, then re-run with --install`);
196
+ }
197
+ }
198
+
199
+ return result;
200
+ }
package/src/index.ts CHANGED
@@ -29,6 +29,21 @@ export type { IPlugin, PluginHooks } from './plugins';
29
29
  export { Sandbox } from './core/sandbox';
30
30
  export type { SandboxConfig, SandboxRestrictions } from './core/sandbox';
31
31
  export { Analytics } from './analytics';
32
+
33
+ // v0.4.0 modules
34
+ export { WorkflowEngine } from './core/workflow';
35
+ export type { WorkflowDefinition, WorkflowStep, WorkflowResult, StepResult } from './core/workflow';
36
+ export { AgentRegistry } from './core/a2a';
37
+ export type { A2ARequest, A2AResponse, AgentCapability, AgentRegistration } from './core/a2a';
38
+ export { HITLManager } from './core/hitl';
39
+ export type { ApprovalRequest, ApprovalResponse, HITLConfig } from './core/hitl';
40
+ export { VoiceChannel } from './channels/voice';
41
+ export type { VoiceChannelConfig, STTProvider, TTSProvider } from './channels/voice';
42
+ export { WebhookChannel } from './channels/webhook';
43
+ export type { WebhookConfig, WebhookPayload } from './channels/webhook';
44
+ export { VersionManager } from './core/versioning';
45
+ export type { VersionEntry, Migration } from './core/versioning';
46
+ export { ConnectionPool, RequestBatcher, LazyLoader } from './core/performance';
32
47
  export type { AnalyticsSnapshot } from './analytics';
33
48
  export { t, setLocale, getLocale, detectLocale, addMessages } from './i18n';
34
49
  export type { Locale } from './i18n';
package/src/schema/oad.ts CHANGED
@@ -8,8 +8,48 @@ export const SkillRefSchema = z.object({
8
8
  config: z.record(z.unknown()).optional(),
9
9
  });
10
10
 
11
+ export const WorkflowStepSchema: z.ZodType<any> = z.lazy(() => z.object({
12
+ id: z.string(),
13
+ type: z.enum(['skill', 'tool', 'agent', 'condition', 'parallel']),
14
+ name: z.string(),
15
+ config: z.record(z.unknown()).optional(),
16
+ condition: z.string().optional(),
17
+ branches: z.object({ if: z.array(WorkflowStepSchema), else: z.array(WorkflowStepSchema).optional() }).optional(),
18
+ parallel: z.array(WorkflowStepSchema).optional(),
19
+ timeout: z.number().optional(),
20
+ retries: z.number().optional(),
21
+ }));
22
+
23
+ export const WorkflowSchema = z.object({
24
+ name: z.string(),
25
+ description: z.string().optional(),
26
+ version: z.string().optional(),
27
+ steps: z.array(WorkflowStepSchema).default([]),
28
+ onError: z.enum(['stop', 'skip', 'retry']).optional(),
29
+ });
30
+
31
+ export const VoiceSchema = z.object({
32
+ enabled: z.boolean().default(false),
33
+ sttProvider: z.string().optional(),
34
+ ttsProvider: z.string().optional(),
35
+ language: z.string().optional(),
36
+ });
37
+
38
+ export const WebhookSchema = z.object({
39
+ path: z.string().optional(),
40
+ secret: z.string().optional(),
41
+ retryAttempts: z.number().optional(),
42
+ });
43
+
44
+ export const HITLSchema = z.object({
45
+ enabled: z.boolean().default(false),
46
+ requireApproval: z.array(z.string()).default([]),
47
+ defaultTimeoutMs: z.number().default(60000),
48
+ defaultAction: z.enum(['approve', 'deny']).default('deny'),
49
+ });
50
+
11
51
  export const ChannelSchema = z.object({
12
- type: z.enum(['web', 'websocket', 'telegram', 'cli']),
52
+ type: z.enum(['web', 'websocket', 'telegram', 'cli', 'voice', 'webhook']),
13
53
  port: z.number().optional(),
14
54
  config: z.record(z.unknown()).optional(),
15
55
  });
@@ -80,6 +120,10 @@ export const SpecSchema = z.object({
80
120
  room: RoomSchema.optional(),
81
121
  streaming: z.union([z.boolean(), StreamingSchema]).default(false),
82
122
  locale: z.enum(['en', 'zh-CN']).optional(),
123
+ workflows: z.array(WorkflowSchema).optional(),
124
+ voice: VoiceSchema.optional(),
125
+ webhook: WebhookSchema.optional(),
126
+ hitl: HITLSchema.optional(),
83
127
  });
84
128
 
85
129
  export const OADSchema = z.object({
@@ -0,0 +1,71 @@
1
+ import { BaseSkill } from '../skills/base';
2
+ import type { AgentContext, Message, SkillResult } from '../core/types';
3
+ import type { OADDocument } from '../schema/oad';
4
+
5
+ export class CalendarSkill extends BaseSkill {
6
+ name = 'calendar-management';
7
+ description = 'Manage calendar and scheduling';
8
+
9
+ async execute(_context: AgentContext, message: Message): Promise<SkillResult> {
10
+ const lower = message.content.toLowerCase();
11
+ if (lower.includes('schedule') || lower.includes('meeting') || lower.includes('calendar')) {
12
+ return this.match('I can help manage your calendar. I can schedule meetings, check availability, send invites, and set reminders. What would you like to do?', 0.8);
13
+ }
14
+ if (lower.includes('remind') || lower.includes('reminder')) {
15
+ return this.match('I\'ll set a reminder for you. Please provide the date, time, and what you\'d like to be reminded about.', 0.75);
16
+ }
17
+ return this.noMatch();
18
+ }
19
+ }
20
+
21
+ export class EmailDraftSkill extends BaseSkill {
22
+ name = 'email-drafting';
23
+ description = 'Draft professional emails';
24
+
25
+ async execute(_context: AgentContext, message: Message): Promise<SkillResult> {
26
+ const lower = message.content.toLowerCase();
27
+ if (lower.includes('email') || lower.includes('draft') || lower.includes('write')) {
28
+ return this.match('I can draft emails for you. Please provide: the recipient, subject, key points to cover, and desired tone (formal/casual/friendly).', 0.8);
29
+ }
30
+ return this.noMatch();
31
+ }
32
+ }
33
+
34
+ export class MeetingPrepSkill extends BaseSkill {
35
+ name = 'meeting-prep';
36
+ description = 'Prepare for meetings with agendas and notes';
37
+
38
+ async execute(_context: AgentContext, message: Message): Promise<SkillResult> {
39
+ const lower = message.content.toLowerCase();
40
+ if (lower.includes('agenda') || lower.includes('prep') || lower.includes('prepare')) {
41
+ return this.match('I can prepare meeting materials including: agenda creation, attendee briefings, talking points, action item tracking, and follow-up summaries.', 0.8);
42
+ }
43
+ return this.noMatch();
44
+ }
45
+ }
46
+
47
+ export function createExecutiveAssistantConfig(): OADDocument {
48
+ return {
49
+ apiVersion: 'opc/v1',
50
+ kind: 'Agent',
51
+ metadata: {
52
+ name: 'executive-assistant',
53
+ version: '1.0.0',
54
+ description: 'AI Executive Assistant - calendar management, email drafting, meeting prep',
55
+ author: 'OPC',
56
+ license: 'Apache-2.0',
57
+ },
58
+ spec: {
59
+ model: 'deepseek-chat',
60
+ systemPrompt: 'You are an executive assistant AI. Help users manage their calendar, draft emails, and prepare for meetings. Be professional, concise, and proactive.',
61
+ skills: [
62
+ { name: 'calendar-management', description: 'Manage calendar and scheduling' },
63
+ { name: 'email-drafting', description: 'Draft professional emails' },
64
+ { name: 'meeting-prep', description: 'Prepare meeting materials' },
65
+ ],
66
+ channels: [{ type: 'web', port: 3000 }],
67
+ memory: { shortTerm: true, longTerm: false },
68
+ streaming: false,
69
+ },
70
+ };
71
+ }
@@ -0,0 +1,60 @@
1
+ import { BaseSkill } from '../skills/base';
2
+ import type { AgentContext, Message, SkillResult } from '../core/types';
3
+ import type { OADDocument } from '../schema/oad';
4
+
5
+ export class BudgetAnalysisSkill extends BaseSkill {
6
+ name = 'budget-analysis';
7
+ description = 'Analyze budgets and expenses';
8
+
9
+ async execute(_context: AgentContext, message: Message): Promise<SkillResult> {
10
+ const lower = message.content.toLowerCase();
11
+ if (lower.includes('budget') || lower.includes('expense') || lower.includes('cost')) {
12
+ return this.match('I can help analyze your budget. Please share your income and expense categories, and I\'ll provide insights on spending patterns and savings opportunities.', 0.8);
13
+ }
14
+ if (lower.includes('save') || lower.includes('saving')) {
15
+ return this.match('Common savings strategies: 50/30/20 rule (needs/wants/savings), automate transfers, review subscriptions, negotiate bills, and track daily spending.', 0.75);
16
+ }
17
+ return this.noMatch();
18
+ }
19
+ }
20
+
21
+ export class FinancialPlanningSkill extends BaseSkill {
22
+ name = 'financial-planning';
23
+ description = 'Help with financial planning and advice';
24
+
25
+ async execute(_context: AgentContext, message: Message): Promise<SkillResult> {
26
+ const lower = message.content.toLowerCase();
27
+ if (lower.includes('invest') || lower.includes('portfolio')) {
28
+ return this.match('For investment planning, consider: risk tolerance, time horizon, diversification, asset allocation, and regular rebalancing. This is general guidance — consult a certified financial advisor for personalized advice.', 0.8);
29
+ }
30
+ if (lower.includes('retire') || lower.includes('pension')) {
31
+ return this.match('Retirement planning essentials: estimate target savings (25x annual expenses), maximize employer matching, consider tax-advantaged accounts, and start early for compound growth.', 0.8);
32
+ }
33
+ return this.noMatch();
34
+ }
35
+ }
36
+
37
+ export function createFinancialAdvisorConfig(): OADDocument {
38
+ return {
39
+ apiVersion: 'opc/v1',
40
+ kind: 'Agent',
41
+ metadata: {
42
+ name: 'financial-advisor',
43
+ version: '1.0.0',
44
+ description: 'AI Financial Advisor - budget analysis, expense tracking, financial planning',
45
+ author: 'OPC',
46
+ license: 'Apache-2.0',
47
+ },
48
+ spec: {
49
+ model: 'deepseek-chat',
50
+ systemPrompt: 'You are a financial advisor AI. Help users with budget analysis, expense tracking, and financial planning. Always recommend consulting a certified financial advisor for binding decisions.',
51
+ skills: [
52
+ { name: 'budget-analysis', description: 'Analyze budgets and expenses' },
53
+ { name: 'financial-planning', description: 'Financial planning advice' },
54
+ ],
55
+ channels: [{ type: 'web', port: 3000 }],
56
+ memory: { shortTerm: true, longTerm: false },
57
+ streaming: false,
58
+ },
59
+ };
60
+ }