opc-agent 0.2.0 → 0.4.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 (80) hide show
  1. package/dist/analytics/index.d.ts +31 -0
  2. package/dist/analytics/index.js +52 -0
  3. package/dist/channels/voice.d.ts +43 -0
  4. package/dist/channels/voice.js +67 -0
  5. package/dist/channels/webhook.d.ts +40 -0
  6. package/dist/channels/webhook.js +193 -0
  7. package/dist/cli.js +157 -13
  8. package/dist/core/a2a.d.ts +46 -0
  9. package/dist/core/a2a.js +99 -0
  10. package/dist/core/hitl.d.ts +41 -0
  11. package/dist/core/hitl.js +100 -0
  12. package/dist/core/performance.d.ts +50 -0
  13. package/dist/core/performance.js +148 -0
  14. package/dist/core/room.d.ts +24 -0
  15. package/dist/core/room.js +97 -0
  16. package/dist/core/sandbox.d.ts +28 -0
  17. package/dist/core/sandbox.js +118 -0
  18. package/dist/core/versioning.d.ts +29 -0
  19. package/dist/core/versioning.js +114 -0
  20. package/dist/core/workflow.d.ts +59 -0
  21. package/dist/core/workflow.js +174 -0
  22. package/dist/i18n/index.d.ts +13 -0
  23. package/dist/i18n/index.js +73 -0
  24. package/dist/index.d.ts +25 -0
  25. package/dist/index.js +36 -1
  26. package/dist/plugins/index.d.ts +47 -0
  27. package/dist/plugins/index.js +59 -0
  28. package/dist/schema/oad.d.ts +483 -15
  29. package/dist/schema/oad.js +53 -2
  30. package/dist/templates/content-writer.d.ts +36 -0
  31. package/dist/templates/content-writer.js +52 -0
  32. package/dist/templates/executive-assistant.d.ts +20 -0
  33. package/dist/templates/executive-assistant.js +70 -0
  34. package/dist/templates/financial-advisor.d.ts +15 -0
  35. package/dist/templates/financial-advisor.js +60 -0
  36. package/dist/templates/hr-recruiter.d.ts +36 -0
  37. package/dist/templates/hr-recruiter.js +52 -0
  38. package/dist/templates/legal-assistant.d.ts +15 -0
  39. package/dist/templates/legal-assistant.js +70 -0
  40. package/dist/templates/project-manager.d.ts +36 -0
  41. package/dist/templates/project-manager.js +52 -0
  42. package/dist/tools/mcp.d.ts +32 -0
  43. package/dist/tools/mcp.js +49 -0
  44. package/package.json +46 -46
  45. package/src/analytics/index.ts +66 -0
  46. package/src/channels/voice.ts +106 -0
  47. package/src/channels/webhook.ts +199 -0
  48. package/src/cli.ts +173 -16
  49. package/src/core/a2a.ts +143 -0
  50. package/src/core/hitl.ts +138 -0
  51. package/src/core/performance.ts +187 -0
  52. package/src/core/room.ts +109 -0
  53. package/src/core/sandbox.ts +101 -0
  54. package/src/core/versioning.ts +106 -0
  55. package/src/core/workflow.ts +235 -0
  56. package/src/i18n/index.ts +79 -0
  57. package/src/index.ts +29 -0
  58. package/src/plugins/index.ts +87 -0
  59. package/src/schema/oad.ts +59 -1
  60. package/src/templates/content-writer.ts +58 -0
  61. package/src/templates/executive-assistant.ts +71 -0
  62. package/src/templates/financial-advisor.ts +60 -0
  63. package/src/templates/hr-recruiter.ts +58 -0
  64. package/src/templates/legal-assistant.ts +71 -0
  65. package/src/templates/project-manager.ts +58 -0
  66. package/src/tools/mcp.ts +76 -0
  67. package/tests/a2a.test.ts +66 -0
  68. package/tests/analytics.test.ts +50 -0
  69. package/tests/hitl.test.ts +71 -0
  70. package/tests/i18n.test.ts +41 -0
  71. package/tests/mcp.test.ts +54 -0
  72. package/tests/performance.test.ts +115 -0
  73. package/tests/plugin.test.ts +74 -0
  74. package/tests/room.test.ts +106 -0
  75. package/tests/sandbox.test.ts +46 -0
  76. package/tests/templates.test.ts +77 -0
  77. package/tests/versioning.test.ts +75 -0
  78. package/tests/voice.test.ts +61 -0
  79. package/tests/webhook.test.ts +29 -0
  80. package/tests/workflow.test.ts +143 -0
@@ -0,0 +1,118 @@
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.Sandbox = void 0;
37
+ const path = __importStar(require("path"));
38
+ const TRUST_RESTRICTIONS = {
39
+ sandbox: {
40
+ fileSystem: { read: ['.'], write: ['.'] },
41
+ network: { allowed: [] },
42
+ shell: false,
43
+ },
44
+ verified: {
45
+ fileSystem: { read: ['.', '..'], write: ['.'] },
46
+ network: { allowed: ['*.deepleaper.com', 'api.openai.com', 'api.deepseek.com'] },
47
+ shell: false,
48
+ },
49
+ certified: {
50
+ fileSystem: { read: ['*'], write: ['.', '..'] },
51
+ network: { allowed: ['*'] },
52
+ shell: true,
53
+ },
54
+ listed: {
55
+ fileSystem: { read: ['*'], write: ['*'] },
56
+ network: { allowed: ['*'] },
57
+ shell: true,
58
+ },
59
+ };
60
+ class Sandbox {
61
+ config;
62
+ restrictions;
63
+ constructor(config) {
64
+ this.config = config;
65
+ this.restrictions = {
66
+ ...TRUST_RESTRICTIONS[config.trustLevel] ?? TRUST_RESTRICTIONS.sandbox,
67
+ };
68
+ if (config.networkAllowlist) {
69
+ this.restrictions.network.allowed = config.networkAllowlist;
70
+ }
71
+ if (config.shellAllowed !== undefined) {
72
+ this.restrictions.shell = config.shellAllowed;
73
+ }
74
+ }
75
+ get trustLevel() {
76
+ return this.config.trustLevel;
77
+ }
78
+ getRestrictions() {
79
+ return { ...this.restrictions };
80
+ }
81
+ checkFileAccess(filePath, mode) {
82
+ const resolved = path.resolve(filePath);
83
+ const agentDir = path.resolve(this.config.agentDir);
84
+ const allowedPaths = mode === 'read' ? this.restrictions.fileSystem.read : this.restrictions.fileSystem.write;
85
+ if (allowedPaths.includes('*'))
86
+ return true;
87
+ for (const allowed of allowedPaths) {
88
+ const allowedResolved = path.resolve(this.config.agentDir, allowed);
89
+ if (resolved.startsWith(allowedResolved))
90
+ return true;
91
+ }
92
+ // Always allow access within agent's own directory
93
+ return resolved.startsWith(agentDir);
94
+ }
95
+ checkNetworkAccess(url) {
96
+ if (this.restrictions.network.allowed.includes('*'))
97
+ return true;
98
+ if (this.restrictions.network.allowed.length === 0)
99
+ return false;
100
+ try {
101
+ const hostname = new URL(url).hostname;
102
+ return this.restrictions.network.allowed.some((pattern) => {
103
+ if (pattern.startsWith('*.')) {
104
+ return hostname.endsWith(pattern.slice(1));
105
+ }
106
+ return hostname === pattern;
107
+ });
108
+ }
109
+ catch {
110
+ return false;
111
+ }
112
+ }
113
+ checkShellAccess() {
114
+ return this.restrictions.shell;
115
+ }
116
+ }
117
+ exports.Sandbox = Sandbox;
118
+ //# sourceMappingURL=sandbox.js.map
@@ -0,0 +1,29 @@
1
+ export interface VersionEntry {
2
+ version: string;
3
+ timestamp: number;
4
+ description?: string;
5
+ oadSnapshot: string;
6
+ }
7
+ export interface Migration {
8
+ fromVersion: string;
9
+ toVersion: string;
10
+ migrate: (oad: Record<string, unknown>) => Record<string, unknown>;
11
+ }
12
+ export declare class VersionManager {
13
+ private versions;
14
+ private migrations;
15
+ private storePath;
16
+ private logger;
17
+ constructor(storePath?: string);
18
+ private load;
19
+ private save;
20
+ snapshot(version: string, oadYaml: string, description?: string): void;
21
+ list(): VersionEntry[];
22
+ get(version: string): VersionEntry | undefined;
23
+ getCurrent(): VersionEntry | undefined;
24
+ rollback(version: string): string | null;
25
+ registerMigration(migration: Migration): void;
26
+ migrate(oad: Record<string, unknown>, fromVersion: string, toVersion: string): Record<string, unknown>;
27
+ clear(): void;
28
+ }
29
+ //# sourceMappingURL=versioning.d.ts.map
@@ -0,0 +1,114 @@
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.VersionManager = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const logger_1 = require("./logger");
39
+ // ── Version Manager ─────────────────────────────────────────
40
+ class VersionManager {
41
+ versions = [];
42
+ migrations = [];
43
+ storePath;
44
+ logger = new logger_1.Logger('versioning');
45
+ constructor(storePath) {
46
+ this.storePath = storePath ?? '.opc-versions.json';
47
+ this.load();
48
+ }
49
+ load() {
50
+ try {
51
+ if (fs.existsSync(this.storePath)) {
52
+ const data = JSON.parse(fs.readFileSync(this.storePath, 'utf-8'));
53
+ this.versions = data.versions ?? [];
54
+ }
55
+ }
56
+ catch {
57
+ this.versions = [];
58
+ }
59
+ }
60
+ save() {
61
+ fs.writeFileSync(this.storePath, JSON.stringify({ versions: this.versions }, null, 2));
62
+ }
63
+ snapshot(version, oadYaml, description) {
64
+ this.versions.push({
65
+ version,
66
+ timestamp: Date.now(),
67
+ description,
68
+ oadSnapshot: oadYaml,
69
+ });
70
+ this.save();
71
+ this.logger.info('Version snapshot saved', { version });
72
+ }
73
+ list() {
74
+ return [...this.versions];
75
+ }
76
+ get(version) {
77
+ return this.versions.find(v => v.version === version);
78
+ }
79
+ getCurrent() {
80
+ return this.versions[this.versions.length - 1];
81
+ }
82
+ rollback(version) {
83
+ const entry = this.get(version);
84
+ if (!entry) {
85
+ this.logger.warn('Version not found', { version });
86
+ return null;
87
+ }
88
+ this.logger.info('Rolling back to version', { version });
89
+ return entry.oadSnapshot;
90
+ }
91
+ registerMigration(migration) {
92
+ this.migrations.push(migration);
93
+ }
94
+ migrate(oad, fromVersion, toVersion) {
95
+ let current = fromVersion;
96
+ let result = { ...oad };
97
+ while (current !== toVersion) {
98
+ const migration = this.migrations.find(m => m.fromVersion === current);
99
+ if (!migration) {
100
+ throw new Error(`No migration path from ${current} to ${toVersion}`);
101
+ }
102
+ result = migration.migrate(result);
103
+ current = migration.toVersion;
104
+ this.logger.info('Migration applied', { from: migration.fromVersion, to: migration.toVersion });
105
+ }
106
+ return result;
107
+ }
108
+ clear() {
109
+ this.versions = [];
110
+ this.save();
111
+ }
112
+ }
113
+ exports.VersionManager = VersionManager;
114
+ //# sourceMappingURL=versioning.js.map
@@ -0,0 +1,59 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { AgentContext, ISkill, IAgent } from './types';
3
+ export type StepType = 'skill' | 'tool' | 'agent' | 'condition' | 'parallel';
4
+ export interface WorkflowStep {
5
+ id: string;
6
+ type: StepType;
7
+ name: string;
8
+ config?: Record<string, unknown>;
9
+ /** For condition steps */
10
+ condition?: string;
11
+ branches?: {
12
+ if: WorkflowStep[];
13
+ else?: WorkflowStep[];
14
+ };
15
+ /** For parallel steps */
16
+ parallel?: WorkflowStep[];
17
+ /** Timeout in ms */
18
+ timeout?: number;
19
+ /** Retry count */
20
+ retries?: number;
21
+ }
22
+ export interface WorkflowDefinition {
23
+ name: string;
24
+ description?: string;
25
+ version?: string;
26
+ steps: WorkflowStep[];
27
+ onError?: 'stop' | 'skip' | 'retry';
28
+ }
29
+ export interface StepResult {
30
+ stepId: string;
31
+ status: 'success' | 'skipped' | 'error';
32
+ output?: string;
33
+ error?: string;
34
+ durationMs: number;
35
+ }
36
+ export interface WorkflowResult {
37
+ workflow: string;
38
+ status: 'completed' | 'failed' | 'partial';
39
+ steps: StepResult[];
40
+ totalDurationMs: number;
41
+ }
42
+ export declare class WorkflowEngine extends EventEmitter {
43
+ private workflows;
44
+ private skills;
45
+ private agents;
46
+ private logger;
47
+ registerWorkflow(workflow: WorkflowDefinition): void;
48
+ unregisterWorkflow(name: string): void;
49
+ getWorkflow(name: string): WorkflowDefinition | undefined;
50
+ listWorkflows(): WorkflowDefinition[];
51
+ registerSkill(skill: ISkill): void;
52
+ registerAgent(agent: IAgent): void;
53
+ run(name: string, context: AgentContext, input?: string): Promise<WorkflowResult>;
54
+ private executeSteps;
55
+ private executeSingleStep;
56
+ private executeStepAction;
57
+ private evaluateCondition;
58
+ }
59
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowEngine = void 0;
4
+ const events_1 = require("events");
5
+ const logger_1 = require("./logger");
6
+ // ── Workflow Engine ─────────────────────────────────────────
7
+ class WorkflowEngine extends events_1.EventEmitter {
8
+ workflows = new Map();
9
+ skills = new Map();
10
+ agents = new Map();
11
+ logger = new logger_1.Logger('workflow');
12
+ registerWorkflow(workflow) {
13
+ this.workflows.set(workflow.name, workflow);
14
+ this.logger.info('Workflow registered', { name: workflow.name, steps: workflow.steps.length });
15
+ }
16
+ unregisterWorkflow(name) {
17
+ this.workflows.delete(name);
18
+ }
19
+ getWorkflow(name) {
20
+ return this.workflows.get(name);
21
+ }
22
+ listWorkflows() {
23
+ return Array.from(this.workflows.values());
24
+ }
25
+ registerSkill(skill) {
26
+ this.skills.set(skill.name, skill);
27
+ }
28
+ registerAgent(agent) {
29
+ this.agents.set(agent.name, agent);
30
+ }
31
+ async run(name, context, input) {
32
+ const workflow = this.workflows.get(name);
33
+ if (!workflow)
34
+ throw new Error(`Workflow "${name}" not found`);
35
+ const startTime = Date.now();
36
+ const results = [];
37
+ let failed = false;
38
+ this.emit('workflow:start', { name, input });
39
+ try {
40
+ await this.executeSteps(workflow.steps, context, input ?? '', results, workflow.onError ?? 'stop');
41
+ }
42
+ catch (err) {
43
+ failed = true;
44
+ this.logger.error('Workflow failed', { name, error: err.message });
45
+ }
46
+ const result = {
47
+ workflow: name,
48
+ status: failed ? 'failed' : results.some(r => r.status === 'error') ? 'partial' : 'completed',
49
+ steps: results,
50
+ totalDurationMs: Date.now() - startTime,
51
+ };
52
+ this.emit('workflow:end', result);
53
+ return result;
54
+ }
55
+ async executeSteps(steps, context, input, results, onError) {
56
+ let currentInput = input;
57
+ for (const step of steps) {
58
+ const stepStart = Date.now();
59
+ try {
60
+ if (step.type === 'parallel' && step.parallel) {
61
+ const parallelResults = await Promise.all(step.parallel.map(s => this.executeSingleStep(s, context, currentInput)));
62
+ const combined = parallelResults.map(r => r.output ?? '').join('\n');
63
+ for (const r of parallelResults)
64
+ results.push(r);
65
+ currentInput = combined;
66
+ }
67
+ else if (step.type === 'condition' && step.branches) {
68
+ const conditionMet = this.evaluateCondition(step.condition ?? '', currentInput, context);
69
+ const branch = conditionMet ? step.branches.if : (step.branches.else ?? []);
70
+ results.push({
71
+ stepId: step.id,
72
+ status: 'success',
73
+ output: `condition=${conditionMet}`,
74
+ durationMs: Date.now() - stepStart,
75
+ });
76
+ currentInput = await this.executeSteps(branch, context, currentInput, results, onError);
77
+ }
78
+ else {
79
+ const result = await this.executeSingleStep(step, context, currentInput);
80
+ results.push(result);
81
+ if (result.status === 'success' && result.output) {
82
+ currentInput = result.output;
83
+ }
84
+ if (result.status === 'error' && onError === 'stop') {
85
+ throw new Error(`Step "${step.id}" failed: ${result.error}`);
86
+ }
87
+ }
88
+ }
89
+ catch (err) {
90
+ if (onError === 'stop')
91
+ throw err;
92
+ // skip: continue
93
+ }
94
+ }
95
+ return currentInput;
96
+ }
97
+ async executeSingleStep(step, context, input) {
98
+ const startTime = Date.now();
99
+ let retries = step.retries ?? 0;
100
+ while (true) {
101
+ try {
102
+ const output = await this.executeStepAction(step, context, input);
103
+ return {
104
+ stepId: step.id,
105
+ status: 'success',
106
+ output,
107
+ durationMs: Date.now() - startTime,
108
+ };
109
+ }
110
+ catch (err) {
111
+ if (retries > 0) {
112
+ retries--;
113
+ continue;
114
+ }
115
+ return {
116
+ stepId: step.id,
117
+ status: 'error',
118
+ error: err.message,
119
+ durationMs: Date.now() - startTime,
120
+ };
121
+ }
122
+ }
123
+ }
124
+ async executeStepAction(step, context, input) {
125
+ const message = {
126
+ id: `wf_${step.id}_${Date.now()}`,
127
+ role: 'user',
128
+ content: input,
129
+ timestamp: Date.now(),
130
+ metadata: { workflowStep: step.id },
131
+ };
132
+ switch (step.type) {
133
+ case 'skill': {
134
+ const skill = this.skills.get(step.name);
135
+ if (!skill)
136
+ throw new Error(`Skill "${step.name}" not found`);
137
+ const result = await skill.execute(context, message);
138
+ return result.response ?? '';
139
+ }
140
+ case 'agent': {
141
+ const agent = this.agents.get(step.name);
142
+ if (!agent)
143
+ throw new Error(`Agent "${step.name}" not found`);
144
+ const response = await agent.handleMessage(message);
145
+ return response.content;
146
+ }
147
+ case 'tool': {
148
+ // Tools are executed via config callback
149
+ const toolFn = step.config?.handler;
150
+ if (toolFn)
151
+ return await toolFn(input);
152
+ return `[tool:${step.name}] executed`;
153
+ }
154
+ default:
155
+ return input;
156
+ }
157
+ }
158
+ evaluateCondition(condition, input, _context) {
159
+ // Simple condition evaluator: supports "contains:keyword", "length>N", "true", "false"
160
+ if (condition === 'true')
161
+ return true;
162
+ if (condition === 'false')
163
+ return false;
164
+ if (condition.startsWith('contains:')) {
165
+ return input.toLowerCase().includes(condition.slice(9).toLowerCase());
166
+ }
167
+ if (condition.startsWith('length>')) {
168
+ return input.length > parseInt(condition.slice(7), 10);
169
+ }
170
+ return !!condition;
171
+ }
172
+ }
173
+ exports.WorkflowEngine = WorkflowEngine;
174
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Internationalization (i18n) support for OPC Agent.
3
+ */
4
+ export type Locale = 'en' | 'zh-CN';
5
+ export interface I18nMessages {
6
+ [key: string]: string;
7
+ }
8
+ export declare function setLocale(locale: Locale): void;
9
+ export declare function getLocale(): Locale;
10
+ export declare function t(key: string, params?: Record<string, string>): string;
11
+ export declare function detectLocale(): Locale;
12
+ export declare function addMessages(locale: Locale, newMessages: I18nMessages): void;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setLocale = setLocale;
4
+ exports.getLocale = getLocale;
5
+ exports.t = t;
6
+ exports.detectLocale = detectLocale;
7
+ exports.addMessages = addMessages;
8
+ const messages = {
9
+ 'en': {
10
+ 'agent.started': 'Agent "{name}" started successfully',
11
+ 'agent.stopped': 'Agent "{name}" stopped',
12
+ 'agent.error': 'An error occurred: {error}',
13
+ 'agent.greeting': 'Hello! How can I help you?',
14
+ 'agent.farewell': 'Goodbye! Have a great day.',
15
+ 'agent.notUnderstood': 'I\'m not sure I understand. Could you rephrase?',
16
+ 'agent.handoff': 'Let me connect you with a human agent.',
17
+ 'cli.init.success': 'Created agent project: {name}',
18
+ 'cli.build.success': 'Build successful: {name} v{version}',
19
+ 'cli.test.pass': 'All tests passed',
20
+ 'cli.stats.title': 'Agent Analytics',
21
+ 'cli.stats.messages': 'Messages Processed',
22
+ 'cli.stats.avgTime': 'Avg Response Time',
23
+ 'cli.stats.errors': 'Errors',
24
+ 'cli.stats.uptime': 'Uptime',
25
+ 'plugin.loaded': 'Plugin "{name}" loaded',
26
+ 'plugin.error': 'Plugin "{name}" failed: {error}',
27
+ },
28
+ 'zh-CN': {
29
+ 'agent.started': '智能体 "{name}" 启动成功',
30
+ 'agent.stopped': '智能体 "{name}" 已停止',
31
+ 'agent.error': '发生错误: {error}',
32
+ 'agent.greeting': '您好!有什么可以帮您的?',
33
+ 'agent.farewell': '再见!祝您愉快。',
34
+ 'agent.notUnderstood': '抱歉,我没有理解您的意思。能换个方式描述吗?',
35
+ 'agent.handoff': '我来为您转接人工客服。',
36
+ 'cli.init.success': '已创建智能体项目: {name}',
37
+ 'cli.build.success': '构建成功: {name} v{version}',
38
+ 'cli.test.pass': '所有测试通过',
39
+ 'cli.stats.title': '智能体分析',
40
+ 'cli.stats.messages': '已处理消息',
41
+ 'cli.stats.avgTime': '平均响应时间',
42
+ 'cli.stats.errors': '错误数',
43
+ 'cli.stats.uptime': '运行时间',
44
+ 'plugin.loaded': '插件 "{name}" 已加载',
45
+ 'plugin.error': '插件 "{name}" 失败: {error}',
46
+ },
47
+ };
48
+ let currentLocale = 'en';
49
+ function setLocale(locale) {
50
+ currentLocale = locale;
51
+ }
52
+ function getLocale() {
53
+ return currentLocale;
54
+ }
55
+ function t(key, params) {
56
+ let msg = messages[currentLocale]?.[key] ?? messages['en']?.[key] ?? key;
57
+ if (params) {
58
+ for (const [k, v] of Object.entries(params)) {
59
+ msg = msg.replace(new RegExp(`\\{${k}\\}`, 'g'), v);
60
+ }
61
+ }
62
+ return msg;
63
+ }
64
+ function detectLocale() {
65
+ const env = process.env.LANG ?? process.env.LC_ALL ?? process.env.LANGUAGE ?? '';
66
+ if (env.startsWith('zh'))
67
+ return 'zh-CN';
68
+ return 'en';
69
+ }
70
+ function addMessages(locale, newMessages) {
71
+ messages[locale] = { ...messages[locale], ...newMessages };
72
+ }
73
+ //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -17,4 +17,29 @@ export { TrustManager } from './dtv/trust';
17
17
  export { ValueTracker } from './dtv/value';
18
18
  export { MRGConfigReader } from './dtv/data';
19
19
  export { createProvider, SUPPORTED_PROVIDERS } from './providers';
20
+ export { Room } from './core/room';
21
+ export type { RoomMessage } from './core/room';
22
+ export { MCPToolRegistry, createMCPTool } from './tools/mcp';
23
+ export type { MCPTool, MCPToolDefinition, MCPToolResult } from './tools/mcp';
24
+ export { PluginManager } from './plugins';
25
+ export type { IPlugin, PluginHooks } from './plugins';
26
+ export { Sandbox } from './core/sandbox';
27
+ export type { SandboxConfig, SandboxRestrictions } from './core/sandbox';
28
+ export { Analytics } from './analytics';
29
+ export { WorkflowEngine } from './core/workflow';
30
+ export type { WorkflowDefinition, WorkflowStep, WorkflowResult, StepResult } from './core/workflow';
31
+ export { AgentRegistry } from './core/a2a';
32
+ export type { A2ARequest, A2AResponse, AgentCapability, AgentRegistration } from './core/a2a';
33
+ export { HITLManager } from './core/hitl';
34
+ export type { ApprovalRequest, ApprovalResponse, HITLConfig } from './core/hitl';
35
+ export { VoiceChannel } from './channels/voice';
36
+ export type { VoiceChannelConfig, STTProvider, TTSProvider } from './channels/voice';
37
+ export { WebhookChannel } from './channels/webhook';
38
+ export type { WebhookConfig, WebhookPayload } from './channels/webhook';
39
+ export { VersionManager } from './core/versioning';
40
+ export type { VersionEntry, Migration } from './core/versioning';
41
+ export { ConnectionPool, RequestBatcher, LazyLoader } from './core/performance';
42
+ export type { AnalyticsSnapshot } from './analytics';
43
+ export { t, setLocale, getLocale, detectLocale, addMessages } from './i18n';
44
+ export type { Locale } from './i18n';
20
45
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUPPORTED_PROVIDERS = exports.createProvider = exports.MRGConfigReader = exports.ValueTracker = exports.TrustManager = exports.DeepBrainMemoryStore = exports.InMemoryStore = exports.SkillRegistry = exports.BaseSkill = exports.WebSocketChannel = exports.TelegramChannel = exports.WebChannel = exports.BaseChannel = exports.OADSchema = exports.validateOAD = exports.loadOAD = exports.Logger = exports.truncateOutput = exports.AgentRuntime = exports.BaseAgent = void 0;
3
+ exports.addMessages = exports.detectLocale = exports.getLocale = exports.setLocale = exports.t = exports.LazyLoader = exports.RequestBatcher = exports.ConnectionPool = exports.VersionManager = exports.WebhookChannel = exports.VoiceChannel = exports.HITLManager = exports.AgentRegistry = exports.WorkflowEngine = exports.Analytics = exports.Sandbox = exports.PluginManager = exports.createMCPTool = exports.MCPToolRegistry = exports.Room = exports.SUPPORTED_PROVIDERS = exports.createProvider = exports.MRGConfigReader = exports.ValueTracker = exports.TrustManager = exports.DeepBrainMemoryStore = exports.InMemoryStore = exports.SkillRegistry = exports.BaseSkill = exports.WebSocketChannel = exports.TelegramChannel = exports.WebChannel = exports.BaseChannel = exports.OADSchema = exports.validateOAD = exports.loadOAD = exports.Logger = exports.truncateOutput = exports.AgentRuntime = exports.BaseAgent = void 0;
4
4
  // OPC Agent — Open Agent Framework
5
5
  var agent_1 = require("./core/agent");
6
6
  Object.defineProperty(exports, "BaseAgent", { enumerable: true, get: function () { return agent_1.BaseAgent; } });
@@ -39,4 +39,39 @@ Object.defineProperty(exports, "MRGConfigReader", { enumerable: true, get: funct
39
39
  var providers_1 = require("./providers");
40
40
  Object.defineProperty(exports, "createProvider", { enumerable: true, get: function () { return providers_1.createProvider; } });
41
41
  Object.defineProperty(exports, "SUPPORTED_PROVIDERS", { enumerable: true, get: function () { return providers_1.SUPPORTED_PROVIDERS; } });
42
+ // v0.3.0 new modules
43
+ var room_1 = require("./core/room");
44
+ Object.defineProperty(exports, "Room", { enumerable: true, get: function () { return room_1.Room; } });
45
+ var mcp_1 = require("./tools/mcp");
46
+ Object.defineProperty(exports, "MCPToolRegistry", { enumerable: true, get: function () { return mcp_1.MCPToolRegistry; } });
47
+ Object.defineProperty(exports, "createMCPTool", { enumerable: true, get: function () { return mcp_1.createMCPTool; } });
48
+ var plugins_1 = require("./plugins");
49
+ Object.defineProperty(exports, "PluginManager", { enumerable: true, get: function () { return plugins_1.PluginManager; } });
50
+ var sandbox_1 = require("./core/sandbox");
51
+ Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return sandbox_1.Sandbox; } });
52
+ var analytics_1 = require("./analytics");
53
+ Object.defineProperty(exports, "Analytics", { enumerable: true, get: function () { return analytics_1.Analytics; } });
54
+ // v0.4.0 modules
55
+ var workflow_1 = require("./core/workflow");
56
+ Object.defineProperty(exports, "WorkflowEngine", { enumerable: true, get: function () { return workflow_1.WorkflowEngine; } });
57
+ var a2a_1 = require("./core/a2a");
58
+ Object.defineProperty(exports, "AgentRegistry", { enumerable: true, get: function () { return a2a_1.AgentRegistry; } });
59
+ var hitl_1 = require("./core/hitl");
60
+ Object.defineProperty(exports, "HITLManager", { enumerable: true, get: function () { return hitl_1.HITLManager; } });
61
+ var voice_1 = require("./channels/voice");
62
+ Object.defineProperty(exports, "VoiceChannel", { enumerable: true, get: function () { return voice_1.VoiceChannel; } });
63
+ var webhook_1 = require("./channels/webhook");
64
+ Object.defineProperty(exports, "WebhookChannel", { enumerable: true, get: function () { return webhook_1.WebhookChannel; } });
65
+ var versioning_1 = require("./core/versioning");
66
+ Object.defineProperty(exports, "VersionManager", { enumerable: true, get: function () { return versioning_1.VersionManager; } });
67
+ var performance_1 = require("./core/performance");
68
+ Object.defineProperty(exports, "ConnectionPool", { enumerable: true, get: function () { return performance_1.ConnectionPool; } });
69
+ Object.defineProperty(exports, "RequestBatcher", { enumerable: true, get: function () { return performance_1.RequestBatcher; } });
70
+ Object.defineProperty(exports, "LazyLoader", { enumerable: true, get: function () { return performance_1.LazyLoader; } });
71
+ var i18n_1 = require("./i18n");
72
+ Object.defineProperty(exports, "t", { enumerable: true, get: function () { return i18n_1.t; } });
73
+ Object.defineProperty(exports, "setLocale", { enumerable: true, get: function () { return i18n_1.setLocale; } });
74
+ Object.defineProperty(exports, "getLocale", { enumerable: true, get: function () { return i18n_1.getLocale; } });
75
+ Object.defineProperty(exports, "detectLocale", { enumerable: true, get: function () { return i18n_1.detectLocale; } });
76
+ Object.defineProperty(exports, "addMessages", { enumerable: true, get: function () { return i18n_1.addMessages; } });
42
77
  //# sourceMappingURL=index.js.map