opc-agent 0.4.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.
package/README.md CHANGED
@@ -42,6 +42,25 @@ opc run
42
42
  | `knowledge-base` | RAG with DeepBrain semantic search |
43
43
  | `code-reviewer` | Bug detection + style checking |
44
44
 
45
+ ## πŸš€ Deploy to OpenClaw
46
+
47
+ OPC Agent is a **development framework**. [OpenClaw](https://github.com/nicepkg/openclaw) is the **runtime**. Design your agent with OPC, deploy it to OpenClaw, and it runs on Telegram, Discord, or any channel OpenClaw supports.
48
+
49
+ ```bash
50
+ # Generate OpenClaw workspace from your OAD
51
+ opc deploy --target openclaw --output ./my-agent-workspace
52
+
53
+ # Or deploy AND auto-register in OpenClaw
54
+ opc deploy --target openclaw --install
55
+
56
+ # Then restart OpenClaw to pick it up
57
+ openclaw gateway restart
58
+ ```
59
+
60
+ This generates `IDENTITY.md`, `SOUL.md`, `AGENTS.md`, `USER.md`, and `MEMORY.md` β€” everything OpenClaw needs to run your agent.
61
+
62
+ See [`examples/customer-service-demo/`](examples/customer-service-demo/) for a complete walkthrough.
63
+
45
64
  ## CLI Commands
46
65
 
47
66
  | Command | Description |
@@ -53,6 +72,7 @@ opc run
53
72
  | `opc test` | Run in sandbox mode |
54
73
  | `opc run` | Start agent with channels |
55
74
  | `opc dev` | Hot-reload development mode |
75
+ | `opc deploy` | **Deploy to OpenClaw runtime** |
56
76
  | `opc publish` | Validate and generate manifest |
57
77
  | `opc search <query>` | Search OPC Registry (coming soon) |
58
78
 
package/dist/cli.js CHANGED
@@ -52,6 +52,7 @@ const financial_advisor_1 = require("./templates/financial-advisor");
52
52
  const executive_assistant_1 = require("./templates/executive-assistant");
53
53
  const customer_service_2 = require("./templates/customer-service");
54
54
  const analytics_1 = require("./analytics");
55
+ const openclaw_1 = require("./deploy/openclaw");
55
56
  const workflow_1 = require("./core/workflow");
56
57
  const versioning_1 = require("./core/versioning");
57
58
  const program = new commander_1.Command();
@@ -109,7 +110,7 @@ async function select(question, options) {
109
110
  program
110
111
  .name('opc')
111
112
  .description('OPC Agent - Open Agent Framework for business workstations')
112
- .version('0.4.0');
113
+ .version('0.5.0');
113
114
  program
114
115
  .command('init')
115
116
  .description('Initialize a new OPC agent project (interactive)')
@@ -332,6 +333,53 @@ program
332
333
  console.log(` Browse templates with: ${color.cyan('opc init --template <name>')}`);
333
334
  console.log(`\n Available templates: ${Object.keys(TEMPLATES).map(t => color.cyan(t)).join(', ')}\n`);
334
335
  });
336
+ // ── Deploy command ────────────────────────────────────────────
337
+ program
338
+ .command('deploy')
339
+ .description('Deploy agent to a target runtime')
340
+ .option('-f, --file <file>', 'OAD file', 'oad.yaml')
341
+ .option('-t, --target <target>', 'Deploy target', 'openclaw')
342
+ .option('-o, --output <dir>', 'Output directory')
343
+ .option('--install', 'Also register in OpenClaw config')
344
+ .action(async (opts) => {
345
+ if (opts.target !== 'openclaw') {
346
+ console.error(`${icon.error} Unknown target: ${color.bold(opts.target)}. Supported: openclaw`);
347
+ process.exit(1);
348
+ }
349
+ try {
350
+ const runtime = new runtime_1.AgentRuntime();
351
+ const config = await runtime.loadConfig(opts.file);
352
+ const agentId = config.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
353
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '';
354
+ const defaultOutput = path.join(homeDir, '.openclaw', 'agents', agentId, 'workspace');
355
+ const outputDir = path.resolve(opts.output ?? defaultOutput);
356
+ console.log(`\n${icon.rocket} ${color.bold('Deploy to OpenClaw')}\n`);
357
+ console.log(` Agent: ${color.cyan(config.metadata.name)} v${config.metadata.version}`);
358
+ console.log(` Target: ${color.cyan('OpenClaw')}`);
359
+ console.log(` Output: ${color.dim(outputDir)}`);
360
+ const result = (0, openclaw_1.deployToOpenClaw)({ oad: config, outputDir, install: opts.install });
361
+ console.log(`\n${icon.success} Generated ${result.files.length} files:`);
362
+ for (const f of result.files) {
363
+ console.log(` ${icon.file} ${f}`);
364
+ }
365
+ if (result.installed) {
366
+ console.log(`\n${icon.success} Registered in OpenClaw config: ${color.dim(result.configPath)}`);
367
+ console.log(`\n${color.dim('Next:')} Restart OpenClaw gateway to pick up the new agent.`);
368
+ console.log(` ${color.cyan('openclaw gateway restart')}\n`);
369
+ }
370
+ else if (opts.install) {
371
+ console.log(`\n${icon.warn} Could not auto-register. Add the agent manually to openclaw.json.`);
372
+ }
373
+ else {
374
+ console.log(`\n${color.dim('Next:')} Copy the output to your OpenClaw agents directory, or re-run with ${color.cyan('--install')}`);
375
+ console.log(` ${color.cyan(`opc deploy --target openclaw --install`)}\n`);
376
+ }
377
+ }
378
+ catch (err) {
379
+ console.error(`${icon.error} Deploy failed:`, err instanceof Error ? err.message : err);
380
+ process.exit(1);
381
+ }
382
+ });
335
383
  // ── Tool commands ────────────────────────────────────────────
336
384
  const toolCmd = program.command('tool').description('Manage MCP tools');
337
385
  toolCmd
@@ -0,0 +1,14 @@
1
+ import type { OADDocument } from '../schema/oad';
2
+ export interface DeployOptions {
3
+ oad: OADDocument;
4
+ outputDir: string;
5
+ install?: boolean;
6
+ }
7
+ export interface DeployResult {
8
+ outputDir: string;
9
+ files: string[];
10
+ installed: boolean;
11
+ configPath?: string;
12
+ }
13
+ export declare function deployToOpenClaw(options: DeployOptions): DeployResult;
14
+ //# sourceMappingURL=openclaw.d.ts.map
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.deployToOpenClaw = deployToOpenClaw;
37
+ /**
38
+ * OpenClaw Deployer - Convert OAD β†’ OpenClaw agent workspace
39
+ */
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ function generateIdentityMd(oad) {
43
+ const m = oad.metadata;
44
+ return `# IDENTITY.md
45
+
46
+ - **Name:** ${m.name}
47
+ - **Version:** ${m.version}
48
+ - **Description:** ${m.description ?? 'An AI agent'}
49
+ - **Author:** ${m.author ?? 'Unknown'}
50
+ - **License:** ${m.license}
51
+ `;
52
+ }
53
+ function generateSoulMd(oad) {
54
+ const prompt = oad.spec.systemPrompt ?? 'You are a helpful AI assistant.';
55
+ return `# SOUL.md - ${oad.metadata.name}
56
+
57
+ ## System Prompt
58
+
59
+ ${prompt}
60
+
61
+ ## Model Configuration
62
+
63
+ - **Model:** ${oad.spec.model}
64
+ - **Provider:** ${oad.spec.provider?.default ?? 'deepseek'}
65
+ `;
66
+ }
67
+ function generateAgentsMd(oad) {
68
+ const skills = oad.spec.skills;
69
+ const memory = oad.spec.memory;
70
+ const dtv = oad.spec.dtv;
71
+ let md = `# AGENTS.md - ${oad.metadata.name}\n\n`;
72
+ // Skills
73
+ md += `## Skills\n\n`;
74
+ if (skills.length === 0) {
75
+ md += `No skills configured.\n\n`;
76
+ }
77
+ else {
78
+ for (const sk of skills) {
79
+ md += `### ${sk.name}\n`;
80
+ if (sk.description)
81
+ md += `${sk.description}\n`;
82
+ if (sk.config)
83
+ md += `\nConfig:\n\`\`\`json\n${JSON.stringify(sk.config, null, 2)}\n\`\`\`\n`;
84
+ md += `\n`;
85
+ }
86
+ }
87
+ // Memory
88
+ md += `## Memory\n\n`;
89
+ if (memory) {
90
+ md += `- Short-term: ${memory.shortTerm ? 'enabled' : 'disabled'}\n`;
91
+ const lt = memory.longTerm;
92
+ if (typeof lt === 'object' && lt) {
93
+ md += `- Long-term: ${lt.provider} (collection: ${lt.collection ?? 'default'})\n`;
94
+ }
95
+ else {
96
+ md += `- Long-term: ${lt ? 'enabled' : 'disabled'}\n`;
97
+ }
98
+ }
99
+ else {
100
+ md += `Default memory settings.\n`;
101
+ }
102
+ md += `\n`;
103
+ // DTV
104
+ if (dtv) {
105
+ md += `## Trust & Value\n\n`;
106
+ md += `- Trust Level: ${dtv.trust?.level ?? 'sandbox'}\n`;
107
+ if (dtv.value?.metrics?.length) {
108
+ md += `- Metrics: ${dtv.value.metrics.join(', ')}\n`;
109
+ }
110
+ md += `\n`;
111
+ }
112
+ return md;
113
+ }
114
+ function generateUserMd(oad) {
115
+ return `# USER.md
116
+
117
+ - **Name:** (your name)
118
+ - **Role:** User
119
+ - **Notes:** Configure this file with your preferences for ${oad.metadata.name}.
120
+ `;
121
+ }
122
+ function generateMemoryMd(oad) {
123
+ return `# MEMORY.md - ${oad.metadata.name}
124
+
125
+ ## Persistent Knowledge
126
+
127
+ (Agent will store learned information here)
128
+
129
+ ## User Preferences
130
+
131
+ (Discovered user preferences will be noted here)
132
+ `;
133
+ }
134
+ function generateOpenClawConfig(oad, agentDir) {
135
+ const channels = oad.spec.channels;
136
+ const channelConfig = {};
137
+ for (const ch of channels) {
138
+ if (ch.type === 'telegram') {
139
+ channelConfig.telegram = {
140
+ enabled: true,
141
+ note: 'Configure bot token in OpenClaw gateway settings',
142
+ };
143
+ }
144
+ else if (ch.type === 'web' || ch.type === 'websocket') {
145
+ channelConfig.web = { enabled: true, port: ch.port ?? 3000 };
146
+ }
147
+ }
148
+ return {
149
+ name: oad.metadata.name,
150
+ workspace: agentDir,
151
+ channels: channelConfig,
152
+ };
153
+ }
154
+ function deployToOpenClaw(options) {
155
+ const { oad, outputDir, install } = options;
156
+ const files = [];
157
+ // Create output directory
158
+ fs.mkdirSync(outputDir, { recursive: true });
159
+ // Generate all workspace files
160
+ const fileMap = {
161
+ 'IDENTITY.md': generateIdentityMd(oad),
162
+ 'SOUL.md': generateSoulMd(oad),
163
+ 'AGENTS.md': generateAgentsMd(oad),
164
+ 'USER.md': generateUserMd(oad),
165
+ 'MEMORY.md': generateMemoryMd(oad),
166
+ };
167
+ for (const [name, content] of Object.entries(fileMap)) {
168
+ const filePath = path.join(outputDir, name);
169
+ fs.writeFileSync(filePath, content, 'utf-8');
170
+ files.push(name);
171
+ }
172
+ // Generate suggested channel config
173
+ const channelSuggestion = generateOpenClawConfig(oad, outputDir);
174
+ const configNote = path.join(outputDir, 'openclaw-config-suggestion.json');
175
+ fs.writeFileSync(configNote, JSON.stringify(channelSuggestion, null, 2), 'utf-8');
176
+ files.push('openclaw-config-suggestion.json');
177
+ const result = { outputDir, files, installed: false };
178
+ // Install mode: register in openclaw.json
179
+ if (install) {
180
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '';
181
+ const configPath = path.join(homeDir, '.openclaw', 'openclaw.json');
182
+ if (fs.existsSync(configPath)) {
183
+ try {
184
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
185
+ if (!config.agents)
186
+ config.agents = {};
187
+ const agentId = oad.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
188
+ config.agents[agentId] = {
189
+ workspace: outputDir,
190
+ description: oad.metadata.description ?? '',
191
+ };
192
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
193
+ result.installed = true;
194
+ result.configPath = configPath;
195
+ }
196
+ catch (err) {
197
+ // Config exists but couldn't be updated - not fatal
198
+ console.error(`Warning: Could not update ${configPath}:`, err);
199
+ }
200
+ }
201
+ else {
202
+ console.error(`Warning: OpenClaw config not found at ${configPath}`);
203
+ console.error(`Run 'openclaw init' first, then re-run with --install`);
204
+ }
205
+ }
206
+ return result;
207
+ }
208
+ //# sourceMappingURL=openclaw.js.map
@@ -0,0 +1,90 @@
1
+ # ShopBot β€” Customer Service Demo
2
+
3
+ A complete e-commerce customer service agent built with OPC Agent, deployable to OpenClaw.
4
+
5
+ ## What's Inside
6
+
7
+ - `oad.yaml` β€” Full agent definition with product FAQ, order tracking, complaint handling
8
+ - Rich system prompt with personality, escalation rules, and response templates
9
+ - Telegram + Web channel configuration
10
+
11
+ ## Quick Start
12
+
13
+ ### 1. Install OPC Agent
14
+
15
+ ```bash
16
+ npm install -g opc-agent
17
+ ```
18
+
19
+ ### 2. Validate the Agent
20
+
21
+ ```bash
22
+ cd examples/customer-service-demo
23
+ opc info
24
+ opc build
25
+ ```
26
+
27
+ ### 3. Deploy to OpenClaw
28
+
29
+ **Option A: Generate workspace files**
30
+ ```bash
31
+ opc deploy --target openclaw --output ./shopbot-workspace
32
+ ```
33
+
34
+ This creates a complete OpenClaw agent workspace with:
35
+ - `IDENTITY.md` β€” Agent identity
36
+ - `SOUL.md` β€” System prompt and model config
37
+ - `AGENTS.md` β€” Skills, memory, and trust config
38
+ - `USER.md` β€” User preferences template
39
+ - `MEMORY.md` β€” Persistent memory template
40
+
41
+ **Option B: Deploy and auto-register**
42
+ ```bash
43
+ opc deploy --target openclaw --install
44
+ ```
45
+
46
+ This generates the workspace AND registers the agent in `~/.openclaw/openclaw.json`.
47
+
48
+ ### 4. Restart OpenClaw
49
+
50
+ ```bash
51
+ openclaw gateway restart
52
+ ```
53
+
54
+ ### 5. Test in Telegram
55
+
56
+ Send a message to your OpenClaw Telegram bot. ShopBot will respond!
57
+
58
+ Try these:
59
+ - "What headphones do you sell?"
60
+ - "Track my order TS-123456"
61
+ - "I want to return my laptop stand"
62
+ - "This is unacceptable, I want to speak to a manager"
63
+
64
+ ## Architecture
65
+
66
+ ```
67
+ OPC Agent (Development) OpenClaw (Runtime)
68
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
69
+ β”‚ oad.yaml β”‚ β”‚ IDENTITY.md β”‚
70
+ β”‚ (agent definition) │──deploy─│ SOUL.md β”‚
71
+ β”‚ β”‚ β”‚ AGENTS.md β”‚
72
+ β”‚ opc build/test β”‚ β”‚ USER.md β”‚
73
+ β”‚ opc deploy β”‚ β”‚ MEMORY.md β”‚
74
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
75
+ β”‚ ← Telegram/Web β†’ β”‚
76
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
77
+ ```
78
+
79
+ OPC Agent is the **development framework**. OpenClaw is the **runtime**.
80
+
81
+ ## Customization
82
+
83
+ Edit `oad.yaml` to:
84
+ - Change the product catalog
85
+ - Adjust escalation rules
86
+ - Add new skills
87
+ - Switch LLM provider/model
88
+ - Modify the system prompt personality
89
+
90
+ Then re-deploy: `opc deploy --target openclaw --install`
@@ -0,0 +1,107 @@
1
+ apiVersion: opc/v1
2
+ kind: Agent
3
+ metadata:
4
+ name: ShopBot
5
+ version: "1.0.0"
6
+ description: "E-commerce customer service agent for TechStyle β€” handles product FAQs, order tracking, returns, and complaint escalation"
7
+ author: "TechStyle Inc."
8
+ license: Apache-2.0
9
+ marketplace:
10
+ category: customer-service
11
+ pricing: free
12
+ tags: [ecommerce, support, faq, orders]
13
+
14
+ spec:
15
+ provider:
16
+ default: deepseek
17
+ allowed: [openai, deepseek, qwen]
18
+ model: deepseek-chat
19
+
20
+ systemPrompt: |
21
+ You are ShopBot, the friendly and professional customer service agent for TechStyle,
22
+ an online electronics and lifestyle store.
23
+
24
+ ## Personality
25
+ - Warm, helpful, and patient
26
+ - Professional but not robotic β€” use a conversational tone
27
+ - Proactive: anticipate follow-up questions
28
+ - Empathetic: acknowledge customer frustration before solving problems
29
+
30
+ ## Core Capabilities
31
+ 1. **Product FAQ**: Answer questions about products, specs, pricing, availability
32
+ 2. **Order Tracking**: Look up order status by order ID (format: TS-XXXXXX)
33
+ 3. **Returns & Refunds**: Guide customers through return process (30-day policy)
34
+ 4. **Complaint Handling**: De-escalate issues, offer solutions, escalate when needed
35
+
36
+ ## Escalation Rules
37
+ - Escalate to human agent if:
38
+ - Customer asks 3+ times about the same unresolved issue
39
+ - Customer explicitly requests a human
40
+ - Issue involves billing disputes over $100
41
+ - Customer uses abusive language (remain calm, offer to transfer)
42
+ - Say: "Let me connect you with a specialist who can help further."
43
+
44
+ ## Response Guidelines
45
+ - Keep responses under 200 words unless detailed explanation is needed
46
+ - Always confirm understanding: "Just to make sure I understand..."
47
+ - End with a follow-up: "Is there anything else I can help with?"
48
+ - For order lookups, ask for order ID if not provided
49
+ - Never make up order status β€” if you can't find it, say so
50
+
51
+ ## Product Catalog (Quick Reference)
52
+ - TechStyle Pro Headphones β€” $149, wireless, ANC, 30hr battery
53
+ - TechStyle Slim Laptop Stand β€” $59, aluminum, adjustable
54
+ - TechStyle Power Bank 20K β€” $39, 20000mAh, USB-C PD
55
+ - TechStyle Smart Watch S3 β€” $199, health tracking, 5-day battery
56
+ - TechStyle Webcam 4K β€” $89, autofocus, built-in mic
57
+
58
+ ## Return Policy
59
+ - 30-day return window from delivery date
60
+ - Item must be in original packaging
61
+ - Free return shipping for defective items
62
+ - Refund processed within 5-7 business days
63
+ - Gift cards and sale items are final sale
64
+
65
+ skills:
66
+ - name: product-faq
67
+ description: "Answer product questions from the catalog knowledge base"
68
+ config:
69
+ source: catalog
70
+ fallback: "I don't have that info right now. Let me check with the team."
71
+
72
+ - name: order-lookup
73
+ description: "Look up order status by order ID"
74
+ config:
75
+ idPattern: "TS-\\d{6}"
76
+ notFoundMessage: "I couldn't find that order. Double-check the ID (format: TS-XXXXXX)."
77
+
78
+ - name: complaint-handler
79
+ description: "Handle complaints with empathy and escalation logic"
80
+ config:
81
+ maxAttempts: 3
82
+ escalationMessage: "Let me connect you with a specialist who can help further."
83
+
84
+ channels:
85
+ - type: telegram
86
+ config:
87
+ welcomeMessage: "Hi! πŸ‘‹ I'm ShopBot from TechStyle. How can I help you today?"
88
+ - type: web
89
+ port: 3000
90
+
91
+ memory:
92
+ shortTerm: true
93
+ longTerm: false
94
+
95
+ dtv:
96
+ trust:
97
+ level: verified
98
+ value:
99
+ metrics:
100
+ - response_time
101
+ - resolution_rate
102
+ - customer_satisfaction
103
+
104
+ streaming:
105
+ enabled: true
106
+
107
+ locale: en
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opc-agent",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Open Agent Framework β€” Build, test, and run AI Agents for business workstations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",