opc-agent 1.2.1 → 1.3.1

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 (158) hide show
  1. package/.github/workflows/ci.yml +24 -0
  2. package/CONTRIBUTING.md +75 -75
  3. package/README.md +235 -358
  4. package/README.zh-CN.md +415 -415
  5. package/dist/channels/web.js +256 -256
  6. package/dist/cli.js +118 -34
  7. package/dist/core/knowledge.d.ts +5 -0
  8. package/dist/core/knowledge.js +39 -2
  9. package/dist/deploy/hermes.js +22 -22
  10. package/dist/deploy/openclaw.js +31 -40
  11. package/dist/index.d.ts +3 -6
  12. package/dist/index.js +7 -11
  13. package/dist/providers/index.d.ts +1 -1
  14. package/dist/providers/index.js +158 -14
  15. package/dist/schema/oad.d.ts +4 -5
  16. package/dist/templates/code-reviewer.d.ts +0 -8
  17. package/dist/templates/code-reviewer.js +5 -9
  18. package/dist/templates/customer-service.d.ts +0 -8
  19. package/dist/templates/customer-service.js +2 -6
  20. package/dist/templates/data-analyst.d.ts +0 -8
  21. package/dist/templates/data-analyst.js +5 -9
  22. package/dist/templates/knowledge-base.d.ts +0 -8
  23. package/dist/templates/knowledge-base.js +2 -6
  24. package/dist/templates/sales-assistant.d.ts +0 -8
  25. package/dist/templates/sales-assistant.js +4 -8
  26. package/dist/templates/teacher.d.ts +0 -8
  27. package/dist/templates/teacher.js +6 -10
  28. package/dist/traces/index.d.ts +49 -0
  29. package/dist/traces/index.js +102 -0
  30. package/docs/.vitepress/config.ts +103 -103
  31. package/docs/api/cli.md +48 -48
  32. package/docs/api/oad-schema.md +64 -64
  33. package/docs/api/sdk.md +80 -80
  34. package/docs/guide/concepts.md +51 -51
  35. package/docs/guide/configuration.md +79 -79
  36. package/docs/guide/deployment.md +42 -42
  37. package/docs/guide/getting-started.md +44 -44
  38. package/docs/guide/templates.md +28 -28
  39. package/docs/guide/testing.md +84 -84
  40. package/docs/index.md +27 -27
  41. package/docs/zh/api/cli.md +54 -54
  42. package/docs/zh/api/oad-schema.md +87 -87
  43. package/docs/zh/api/sdk.md +102 -102
  44. package/docs/zh/guide/concepts.md +104 -104
  45. package/docs/zh/guide/configuration.md +135 -135
  46. package/docs/zh/guide/deployment.md +81 -81
  47. package/docs/zh/guide/getting-started.md +82 -82
  48. package/docs/zh/guide/templates.md +84 -84
  49. package/docs/zh/guide/testing.md +88 -88
  50. package/docs/zh/index.md +27 -27
  51. package/examples/customer-service-demo/README.md +90 -90
  52. package/examples/customer-service-demo/oad.yaml +107 -107
  53. package/package.json +1 -1
  54. package/src/analytics/index.ts +66 -66
  55. package/src/channels/discord.ts +192 -192
  56. package/src/channels/email.ts +177 -177
  57. package/src/channels/feishu.ts +236 -236
  58. package/src/channels/index.ts +15 -15
  59. package/src/channels/slack.ts +160 -160
  60. package/src/channels/telegram.ts +90 -90
  61. package/src/channels/voice.ts +106 -106
  62. package/src/channels/webhook.ts +199 -199
  63. package/src/channels/websocket.ts +87 -87
  64. package/src/channels/wechat.ts +149 -149
  65. package/src/cli.ts +124 -32
  66. package/src/core/a2a.ts +143 -143
  67. package/src/core/agent.ts +152 -152
  68. package/src/core/analytics-engine.ts +186 -186
  69. package/src/core/auth.ts +57 -57
  70. package/src/core/cache.ts +141 -141
  71. package/src/core/compose.ts +77 -77
  72. package/src/core/config.ts +14 -14
  73. package/src/core/errors.ts +148 -148
  74. package/src/core/hitl.ts +138 -138
  75. package/src/core/logger.ts +57 -57
  76. package/src/core/orchestrator.ts +215 -215
  77. package/src/core/performance.ts +187 -187
  78. package/src/core/rate-limiter.ts +128 -128
  79. package/src/core/room.ts +109 -109
  80. package/src/core/runtime.ts +152 -152
  81. package/src/core/sandbox.ts +101 -101
  82. package/src/core/security.ts +171 -171
  83. package/src/core/types.ts +68 -68
  84. package/src/core/versioning.ts +106 -106
  85. package/src/core/watch.ts +178 -178
  86. package/src/core/workflow.ts +235 -235
  87. package/src/deploy/hermes.ts +156 -156
  88. package/src/deploy/openclaw.ts +190 -200
  89. package/src/i18n/index.ts +216 -216
  90. package/src/index.ts +5 -6
  91. package/src/memory/deepbrain.ts +108 -108
  92. package/src/memory/index.ts +34 -34
  93. package/src/plugins/index.ts +208 -208
  94. package/src/schema/oad.ts +154 -155
  95. package/src/skills/base.ts +16 -16
  96. package/src/skills/document.ts +100 -100
  97. package/src/skills/http.ts +35 -35
  98. package/src/skills/index.ts +27 -27
  99. package/src/skills/scheduler.ts +80 -80
  100. package/src/skills/webhook-trigger.ts +59 -59
  101. package/src/templates/code-reviewer.ts +30 -34
  102. package/src/templates/customer-service.ts +76 -80
  103. package/src/templates/data-analyst.ts +66 -70
  104. package/src/templates/executive-assistant.ts +71 -71
  105. package/src/templates/financial-advisor.ts +60 -60
  106. package/src/templates/knowledge-base.ts +27 -31
  107. package/src/templates/legal-assistant.ts +71 -71
  108. package/src/templates/sales-assistant.ts +75 -79
  109. package/src/templates/teacher.ts +75 -79
  110. package/src/testing/index.ts +181 -181
  111. package/src/tools/calculator.ts +73 -73
  112. package/src/tools/datetime.ts +149 -149
  113. package/src/tools/json-transform.ts +187 -187
  114. package/src/tools/mcp.ts +76 -76
  115. package/src/tools/text-analysis.ts +116 -116
  116. package/src/traces/index.ts +132 -0
  117. package/templates/Dockerfile +15 -15
  118. package/templates/code-reviewer/README.md +27 -27
  119. package/templates/code-reviewer/oad.yaml +41 -41
  120. package/templates/customer-service/README.md +22 -22
  121. package/templates/customer-service/oad.yaml +36 -36
  122. package/templates/docker-compose.yml +21 -21
  123. package/templates/ecommerce-assistant/README.md +45 -45
  124. package/templates/ecommerce-assistant/oad.yaml +47 -47
  125. package/templates/knowledge-base/README.md +28 -28
  126. package/templates/knowledge-base/oad.yaml +38 -38
  127. package/templates/sales-assistant/README.md +26 -26
  128. package/templates/sales-assistant/oad.yaml +43 -43
  129. package/templates/tech-support/README.md +43 -43
  130. package/templates/tech-support/oad.yaml +45 -45
  131. package/tests/a2a.test.ts +66 -66
  132. package/tests/agent.test.ts +72 -72
  133. package/tests/analytics.test.ts +50 -50
  134. package/tests/channel.test.ts +39 -39
  135. package/tests/e2e.test.ts +134 -134
  136. package/tests/errors.test.ts +83 -83
  137. package/tests/hitl.test.ts +71 -71
  138. package/tests/i18n.test.ts +41 -41
  139. package/tests/mcp.test.ts +54 -54
  140. package/tests/oad.test.ts +68 -68
  141. package/tests/performance.test.ts +115 -115
  142. package/tests/plugin.test.ts +74 -74
  143. package/tests/room.test.ts +106 -106
  144. package/tests/runtime.test.ts +42 -42
  145. package/tests/sandbox.test.ts +46 -46
  146. package/tests/security.test.ts +60 -60
  147. package/tests/templates.test.ts +77 -77
  148. package/tests/v070.test.ts +76 -76
  149. package/tests/versioning.test.ts +75 -75
  150. package/tests/voice.test.ts +61 -61
  151. package/tests/webhook.test.ts +29 -29
  152. package/tests/workflow.test.ts +143 -143
  153. package/tsconfig.json +19 -19
  154. package/vitest.config.ts +9 -9
  155. package/src/dtv/data.ts +0 -29
  156. package/src/dtv/trust.ts +0 -43
  157. package/src/dtv/value.ts +0 -47
  158. package/src/marketplace/index.ts +0 -223
package/src/i18n/index.ts CHANGED
@@ -1,216 +1,216 @@
1
- /**
2
- * Internationalization (i18n) support for OPC Agent.
3
- * Supports English, Chinese, and Japanese.
4
- */
5
- export type Locale = 'en' | 'zh-CN' | 'ja';
6
-
7
- export interface I18nMessages {
8
- [key: string]: string;
9
- }
10
-
11
- const messages: Record<Locale, I18nMessages> = {
12
- 'en': {
13
- 'agent.started': 'Agent "{name}" started successfully',
14
- 'agent.stopped': 'Agent "{name}" stopped',
15
- 'agent.error': 'An error occurred: {error}',
16
- 'agent.greeting': 'Hello! How can I help you?',
17
- 'agent.farewell': 'Goodbye! Have a great day.',
18
- 'agent.notUnderstood': 'I\'m not sure I understand. Could you rephrase?',
19
- 'agent.handoff': 'Let me connect you with a human agent.',
20
- 'cli.init.success': 'Created agent project: {name}',
21
- 'cli.init.prompt.name': 'Agent name:',
22
- 'cli.init.prompt.template': 'Choose a template:',
23
- 'cli.init.prompt.provider': 'Choose an LLM provider:',
24
- 'cli.build.success': 'Build successful: {name} v{version}',
25
- 'cli.test.pass': 'All tests passed',
26
- 'cli.test.fail': '{count} test(s) failed',
27
- 'cli.run.starting': 'Starting agent "{name}"...',
28
- 'cli.run.listening': 'Agent "{name}" is running at http://localhost:{port}',
29
- 'cli.deploy.success': 'Deployed "{name}" to {target}',
30
- 'cli.deploy.error': 'Deploy failed: {error}',
31
- 'cli.validate.success': 'OAD validation passed',
32
- 'cli.validate.error': 'OAD validation failed: {error}',
33
- 'cli.analytics.title': 'Agent Analytics',
34
- 'cli.analytics.noData': 'No analytics data yet',
35
- 'cli.stats.title': 'Agent Analytics',
36
- 'cli.stats.messages': 'Messages Processed',
37
- 'cli.stats.avgTime': 'Avg Response Time',
38
- 'cli.stats.errors': 'Errors',
39
- 'cli.stats.uptime': 'Uptime',
40
- 'cli.chat.welcome': 'Chat with your agent. Type "exit" to quit.',
41
- 'cli.dev.watching': 'Watching for changes...',
42
- 'cli.publish.success': 'Published "{name}" v{version}',
43
- 'plugin.loaded': 'Plugin "{name}" loaded',
44
- 'plugin.error': 'Plugin "{name}" failed: {error}',
45
- 'kb.added': 'Added "{file}" to knowledge base',
46
- 'kb.searchResults': '{count} results found',
47
- 'kb.noResults': 'No results found',
48
- 'web.title': 'OPC Agent',
49
- 'web.chat.placeholder': 'Type a message...',
50
- 'web.chat.send': 'Send',
51
- 'web.nav.chat': 'Chat',
52
- 'web.nav.dashboard': 'Dashboard',
53
- 'web.nav.settings': 'Settings',
54
- 'web.dashboard.title': 'Dashboard',
55
- 'web.dashboard.messages': 'Messages',
56
- 'web.dashboard.tokens': 'Tokens Used',
57
- 'web.dashboard.errors': 'Errors',
58
- 'web.dashboard.avgLatency': 'Avg Latency',
59
- 'web.settings.title': 'Settings',
60
- 'web.settings.language': 'Language',
61
- 'web.settings.theme': 'Theme',
62
- 'web.settings.save': 'Save',
63
- 'cache.hit': 'Cache hit',
64
- 'cache.miss': 'Cache miss',
65
- 'rateLimit.exceeded': 'Rate limit exceeded. Please wait.',
66
- },
67
- 'zh-CN': {
68
- 'agent.started': '智能体 "{name}" 启动成功',
69
- 'agent.stopped': '智能体 "{name}" 已停止',
70
- 'agent.error': '发生错误:{error}',
71
- 'agent.greeting': '你好!有什么可以帮你的?',
72
- 'agent.farewell': '再见!祝你愉快。',
73
- 'agent.notUnderstood': '抱歉,我没太理解你的意思。能换个方式描述一下吗?',
74
- 'agent.handoff': '我来帮你转接人工客服。',
75
- 'cli.init.success': '已创建智能体项目:{name}',
76
- 'cli.init.prompt.name': '智能体名称:',
77
- 'cli.init.prompt.template': '选择一个模板:',
78
- 'cli.init.prompt.provider': '选择大语言模型供应商:',
79
- 'cli.build.success': '构建成功:{name} v{version}',
80
- 'cli.test.pass': '所有测试通过',
81
- 'cli.test.fail': '{count} 个测试失败',
82
- 'cli.run.starting': '正在启动智能体 "{name}"...',
83
- 'cli.run.listening': '智能体 "{name}" 已在 http://localhost:{port} 上运行',
84
- 'cli.deploy.success': '已将 "{name}" 部署到 {target}',
85
- 'cli.deploy.error': '部署失败:{error}',
86
- 'cli.validate.success': 'OAD 配置校验通过',
87
- 'cli.validate.error': 'OAD 配置校验失败:{error}',
88
- 'cli.analytics.title': '智能体数据分析',
89
- 'cli.analytics.noData': '暂无分析数据',
90
- 'cli.stats.title': '智能体数据分析',
91
- 'cli.stats.messages': '已处理消息',
92
- 'cli.stats.avgTime': '平均响应时间',
93
- 'cli.stats.errors': '错误数',
94
- 'cli.stats.uptime': '运行时间',
95
- 'cli.chat.welcome': '开始和智能体对话吧。输入 "exit" 退出。',
96
- 'cli.dev.watching': '正在监听文件变更...',
97
- 'cli.publish.success': '已发布 "{name}" v{version}',
98
- 'plugin.loaded': '插件 "{name}" 已加载',
99
- 'plugin.error': '插件 "{name}" 出错:{error}',
100
- 'kb.added': '已将 "{file}" 添加到知识库',
101
- 'kb.searchResults': '找到 {count} 条结果',
102
- 'kb.noResults': '未找到相关结果',
103
- 'web.title': 'OPC 智能体',
104
- 'web.chat.placeholder': '输入消息...',
105
- 'web.chat.send': '发送',
106
- 'web.nav.chat': '对话',
107
- 'web.nav.dashboard': '仪表盘',
108
- 'web.nav.settings': '设置',
109
- 'web.dashboard.title': '仪表盘',
110
- 'web.dashboard.messages': '消息数',
111
- 'web.dashboard.tokens': '已用 Token',
112
- 'web.dashboard.errors': '错误数',
113
- 'web.dashboard.avgLatency': '平均延迟',
114
- 'web.settings.title': '设置',
115
- 'web.settings.language': '语言',
116
- 'web.settings.theme': '主题',
117
- 'web.settings.save': '保存',
118
- 'cache.hit': '缓存命中',
119
- 'cache.miss': '缓存未命中',
120
- 'rateLimit.exceeded': '请求过于频繁,请稍候。',
121
- },
122
- 'ja': {
123
- 'agent.started': 'エージェント「{name}」が正常に起動しました',
124
- 'agent.stopped': 'エージェント「{name}」が停止しました',
125
- 'agent.error': 'エラーが発生しました: {error}',
126
- 'agent.greeting': 'こんにちは!何かお手伝いできますか?',
127
- 'agent.farewell': 'さようなら!良い一日を。',
128
- 'agent.notUnderstood': '申し訳ございません、理解できませんでした。別の言い方でお願いできますか?',
129
- 'agent.handoff': 'オペレーターにおつなぎします。',
130
- 'cli.init.success': 'エージェントプロジェクトを作成しました: {name}',
131
- 'cli.init.prompt.name': 'エージェント名:',
132
- 'cli.init.prompt.template': 'テンプレートを選択:',
133
- 'cli.init.prompt.provider': 'LLMプロバイダーを選択:',
134
- 'cli.build.success': 'ビルド成功: {name} v{version}',
135
- 'cli.test.pass': '全テスト合格',
136
- 'cli.test.fail': '{count} 件のテストが失敗しました',
137
- 'cli.run.starting': 'エージェント「{name}」を起動中...',
138
- 'cli.run.listening': 'エージェント「{name}」が http://localhost:{port} で稼働中',
139
- 'cli.deploy.success': '「{name}」を {target} にデプロイしました',
140
- 'cli.deploy.error': 'デプロイ失敗: {error}',
141
- 'cli.validate.success': 'OADバリデーション成功',
142
- 'cli.validate.error': 'OADバリデーション失敗: {error}',
143
- 'cli.analytics.title': 'エージェント分析',
144
- 'cli.analytics.noData': '分析データがありません',
145
- 'cli.stats.title': 'エージェント分析',
146
- 'cli.stats.messages': '処理済みメッセージ',
147
- 'cli.stats.avgTime': '平均応答時間',
148
- 'cli.stats.errors': 'エラー数',
149
- 'cli.stats.uptime': '稼働時間',
150
- 'cli.chat.welcome': 'エージェントとチャットしましょう。"exit"で終了。',
151
- 'cli.dev.watching': 'ファイル変更を監視中...',
152
- 'cli.publish.success': '「{name}」v{version} を公開しました',
153
- 'plugin.loaded': 'プラグイン「{name}」を読み込みました',
154
- 'plugin.error': 'プラグイン「{name}」でエラー: {error}',
155
- 'kb.added': '「{file}」をナレッジベースに追加しました',
156
- 'kb.searchResults': '{count} 件の結果が見つかりました',
157
- 'kb.noResults': '結果が見つかりませんでした',
158
- 'web.title': 'OPC エージェント',
159
- 'web.chat.placeholder': 'メッセージを入力...',
160
- 'web.chat.send': '送信',
161
- 'web.nav.chat': 'チャット',
162
- 'web.nav.dashboard': 'ダッシュボード',
163
- 'web.nav.settings': '設定',
164
- 'web.dashboard.title': 'ダッシュボード',
165
- 'web.dashboard.messages': 'メッセージ数',
166
- 'web.dashboard.tokens': '使用トークン',
167
- 'web.dashboard.errors': 'エラー数',
168
- 'web.dashboard.avgLatency': '平均レイテンシ',
169
- 'web.settings.title': '設定',
170
- 'web.settings.language': '言語',
171
- 'web.settings.theme': 'テーマ',
172
- 'web.settings.save': '保存',
173
- 'cache.hit': 'キャッシュヒット',
174
- 'cache.miss': 'キャッシュミス',
175
- 'rateLimit.exceeded': 'リクエスト制限を超えました。しばらくお待ちください。',
176
- },
177
- };
178
-
179
- let currentLocale: Locale = 'en';
180
-
181
- export function setLocale(locale: Locale): void {
182
- currentLocale = locale;
183
- }
184
-
185
- export function getLocale(): Locale {
186
- return currentLocale;
187
- }
188
-
189
- export function getSupportedLocales(): { code: Locale; label: string }[] {
190
- return [
191
- { code: 'en', label: 'English' },
192
- { code: 'zh-CN', label: '中文' },
193
- { code: 'ja', label: '日本語' },
194
- ];
195
- }
196
-
197
- export function t(key: string, params?: Record<string, string>): string {
198
- let msg = messages[currentLocale]?.[key] ?? messages['en']?.[key] ?? key;
199
- if (params) {
200
- for (const [k, v] of Object.entries(params)) {
201
- msg = msg.replace(new RegExp(`\\{${k}\\}`, 'g'), v);
202
- }
203
- }
204
- return msg;
205
- }
206
-
207
- export function detectLocale(): Locale {
208
- const env = process.env.LANG ?? process.env.LC_ALL ?? process.env.LANGUAGE ?? '';
209
- if (env.startsWith('zh')) return 'zh-CN';
210
- if (env.startsWith('ja')) return 'ja';
211
- return 'en';
212
- }
213
-
214
- export function addMessages(locale: Locale, newMessages: I18nMessages): void {
215
- messages[locale] = { ...messages[locale], ...newMessages };
216
- }
1
+ /**
2
+ * Internationalization (i18n) support for OPC Agent.
3
+ * Supports English, Chinese, and Japanese.
4
+ */
5
+ export type Locale = 'en' | 'zh-CN' | 'ja';
6
+
7
+ export interface I18nMessages {
8
+ [key: string]: string;
9
+ }
10
+
11
+ const messages: Record<Locale, I18nMessages> = {
12
+ 'en': {
13
+ 'agent.started': 'Agent "{name}" started successfully',
14
+ 'agent.stopped': 'Agent "{name}" stopped',
15
+ 'agent.error': 'An error occurred: {error}',
16
+ 'agent.greeting': 'Hello! How can I help you?',
17
+ 'agent.farewell': 'Goodbye! Have a great day.',
18
+ 'agent.notUnderstood': 'I\'m not sure I understand. Could you rephrase?',
19
+ 'agent.handoff': 'Let me connect you with a human agent.',
20
+ 'cli.init.success': 'Created agent project: {name}',
21
+ 'cli.init.prompt.name': 'Agent name:',
22
+ 'cli.init.prompt.template': 'Choose a template:',
23
+ 'cli.init.prompt.provider': 'Choose an LLM provider:',
24
+ 'cli.build.success': 'Build successful: {name} v{version}',
25
+ 'cli.test.pass': 'All tests passed',
26
+ 'cli.test.fail': '{count} test(s) failed',
27
+ 'cli.run.starting': 'Starting agent "{name}"...',
28
+ 'cli.run.listening': 'Agent "{name}" is running at http://localhost:{port}',
29
+ 'cli.deploy.success': 'Deployed "{name}" to {target}',
30
+ 'cli.deploy.error': 'Deploy failed: {error}',
31
+ 'cli.validate.success': 'OAD validation passed',
32
+ 'cli.validate.error': 'OAD validation failed: {error}',
33
+ 'cli.analytics.title': 'Agent Analytics',
34
+ 'cli.analytics.noData': 'No analytics data yet',
35
+ 'cli.stats.title': 'Agent Analytics',
36
+ 'cli.stats.messages': 'Messages Processed',
37
+ 'cli.stats.avgTime': 'Avg Response Time',
38
+ 'cli.stats.errors': 'Errors',
39
+ 'cli.stats.uptime': 'Uptime',
40
+ 'cli.chat.welcome': 'Chat with your agent. Type "exit" to quit.',
41
+ 'cli.dev.watching': 'Watching for changes...',
42
+ 'cli.publish.success': 'Published "{name}" v{version}',
43
+ 'plugin.loaded': 'Plugin "{name}" loaded',
44
+ 'plugin.error': 'Plugin "{name}" failed: {error}',
45
+ 'kb.added': 'Added "{file}" to knowledge base',
46
+ 'kb.searchResults': '{count} results found',
47
+ 'kb.noResults': 'No results found',
48
+ 'web.title': 'OPC Agent',
49
+ 'web.chat.placeholder': 'Type a message...',
50
+ 'web.chat.send': 'Send',
51
+ 'web.nav.chat': 'Chat',
52
+ 'web.nav.dashboard': 'Dashboard',
53
+ 'web.nav.settings': 'Settings',
54
+ 'web.dashboard.title': 'Dashboard',
55
+ 'web.dashboard.messages': 'Messages',
56
+ 'web.dashboard.tokens': 'Tokens Used',
57
+ 'web.dashboard.errors': 'Errors',
58
+ 'web.dashboard.avgLatency': 'Avg Latency',
59
+ 'web.settings.title': 'Settings',
60
+ 'web.settings.language': 'Language',
61
+ 'web.settings.theme': 'Theme',
62
+ 'web.settings.save': 'Save',
63
+ 'cache.hit': 'Cache hit',
64
+ 'cache.miss': 'Cache miss',
65
+ 'rateLimit.exceeded': 'Rate limit exceeded. Please wait.',
66
+ },
67
+ 'zh-CN': {
68
+ 'agent.started': '智能体 "{name}" 启动成功',
69
+ 'agent.stopped': '智能体 "{name}" 已停止',
70
+ 'agent.error': '发生错误:{error}',
71
+ 'agent.greeting': '你好!有什么可以帮你的?',
72
+ 'agent.farewell': '再见!祝你愉快。',
73
+ 'agent.notUnderstood': '抱歉,我没太理解你的意思。能换个方式描述一下吗?',
74
+ 'agent.handoff': '我来帮你转接人工客服。',
75
+ 'cli.init.success': '已创建智能体项目:{name}',
76
+ 'cli.init.prompt.name': '智能体名称:',
77
+ 'cli.init.prompt.template': '选择一个模板:',
78
+ 'cli.init.prompt.provider': '选择大语言模型供应商:',
79
+ 'cli.build.success': '构建成功:{name} v{version}',
80
+ 'cli.test.pass': '所有测试通过',
81
+ 'cli.test.fail': '{count} 个测试失败',
82
+ 'cli.run.starting': '正在启动智能体 "{name}"...',
83
+ 'cli.run.listening': '智能体 "{name}" 已在 http://localhost:{port} 上运行',
84
+ 'cli.deploy.success': '已将 "{name}" 部署到 {target}',
85
+ 'cli.deploy.error': '部署失败:{error}',
86
+ 'cli.validate.success': 'OAD 配置校验通过',
87
+ 'cli.validate.error': 'OAD 配置校验失败:{error}',
88
+ 'cli.analytics.title': '智能体数据分析',
89
+ 'cli.analytics.noData': '暂无分析数据',
90
+ 'cli.stats.title': '智能体数据分析',
91
+ 'cli.stats.messages': '已处理消息',
92
+ 'cli.stats.avgTime': '平均响应时间',
93
+ 'cli.stats.errors': '错误数',
94
+ 'cli.stats.uptime': '运行时间',
95
+ 'cli.chat.welcome': '开始和智能体对话吧。输入 "exit" 退出。',
96
+ 'cli.dev.watching': '正在监听文件变更...',
97
+ 'cli.publish.success': '已发布 "{name}" v{version}',
98
+ 'plugin.loaded': '插件 "{name}" 已加载',
99
+ 'plugin.error': '插件 "{name}" 出错:{error}',
100
+ 'kb.added': '已将 "{file}" 添加到知识库',
101
+ 'kb.searchResults': '找到 {count} 条结果',
102
+ 'kb.noResults': '未找到相关结果',
103
+ 'web.title': 'OPC 智能体',
104
+ 'web.chat.placeholder': '输入消息...',
105
+ 'web.chat.send': '发送',
106
+ 'web.nav.chat': '对话',
107
+ 'web.nav.dashboard': '仪表盘',
108
+ 'web.nav.settings': '设置',
109
+ 'web.dashboard.title': '仪表盘',
110
+ 'web.dashboard.messages': '消息数',
111
+ 'web.dashboard.tokens': '已用 Token',
112
+ 'web.dashboard.errors': '错误数',
113
+ 'web.dashboard.avgLatency': '平均延迟',
114
+ 'web.settings.title': '设置',
115
+ 'web.settings.language': '语言',
116
+ 'web.settings.theme': '主题',
117
+ 'web.settings.save': '保存',
118
+ 'cache.hit': '缓存命中',
119
+ 'cache.miss': '缓存未命中',
120
+ 'rateLimit.exceeded': '请求过于频繁,请稍候。',
121
+ },
122
+ 'ja': {
123
+ 'agent.started': 'エージェント「{name}」が正常に起動しました',
124
+ 'agent.stopped': 'エージェント「{name}」が停止しました',
125
+ 'agent.error': 'エラーが発生しました: {error}',
126
+ 'agent.greeting': 'こんにちは!何かお手伝いできますか?',
127
+ 'agent.farewell': 'さようなら!良い一日を。',
128
+ 'agent.notUnderstood': '申し訳ございません、理解できませんでした。別の言い方でお願いできますか?',
129
+ 'agent.handoff': 'オペレーターにおつなぎします。',
130
+ 'cli.init.success': 'エージェントプロジェクトを作成しました: {name}',
131
+ 'cli.init.prompt.name': 'エージェント名:',
132
+ 'cli.init.prompt.template': 'テンプレートを選択:',
133
+ 'cli.init.prompt.provider': 'LLMプロバイダーを選択:',
134
+ 'cli.build.success': 'ビルド成功: {name} v{version}',
135
+ 'cli.test.pass': '全テスト合格',
136
+ 'cli.test.fail': '{count} 件のテストが失敗しました',
137
+ 'cli.run.starting': 'エージェント「{name}」を起動中...',
138
+ 'cli.run.listening': 'エージェント「{name}」が http://localhost:{port} で稼働中',
139
+ 'cli.deploy.success': '「{name}」を {target} にデプロイしました',
140
+ 'cli.deploy.error': 'デプロイ失敗: {error}',
141
+ 'cli.validate.success': 'OADバリデーション成功',
142
+ 'cli.validate.error': 'OADバリデーション失敗: {error}',
143
+ 'cli.analytics.title': 'エージェント分析',
144
+ 'cli.analytics.noData': '分析データがありません',
145
+ 'cli.stats.title': 'エージェント分析',
146
+ 'cli.stats.messages': '処理済みメッセージ',
147
+ 'cli.stats.avgTime': '平均応答時間',
148
+ 'cli.stats.errors': 'エラー数',
149
+ 'cli.stats.uptime': '稼働時間',
150
+ 'cli.chat.welcome': 'エージェントとチャットしましょう。"exit"で終了。',
151
+ 'cli.dev.watching': 'ファイル変更を監視中...',
152
+ 'cli.publish.success': '「{name}」v{version} を公開しました',
153
+ 'plugin.loaded': 'プラグイン「{name}」を読み込みました',
154
+ 'plugin.error': 'プラグイン「{name}」でエラー: {error}',
155
+ 'kb.added': '「{file}」をナレッジベースに追加しました',
156
+ 'kb.searchResults': '{count} 件の結果が見つかりました',
157
+ 'kb.noResults': '結果が見つかりませんでした',
158
+ 'web.title': 'OPC エージェント',
159
+ 'web.chat.placeholder': 'メッセージを入力...',
160
+ 'web.chat.send': '送信',
161
+ 'web.nav.chat': 'チャット',
162
+ 'web.nav.dashboard': 'ダッシュボード',
163
+ 'web.nav.settings': '設定',
164
+ 'web.dashboard.title': 'ダッシュボード',
165
+ 'web.dashboard.messages': 'メッセージ数',
166
+ 'web.dashboard.tokens': '使用トークン',
167
+ 'web.dashboard.errors': 'エラー数',
168
+ 'web.dashboard.avgLatency': '平均レイテンシ',
169
+ 'web.settings.title': '設定',
170
+ 'web.settings.language': '言語',
171
+ 'web.settings.theme': 'テーマ',
172
+ 'web.settings.save': '保存',
173
+ 'cache.hit': 'キャッシュヒット',
174
+ 'cache.miss': 'キャッシュミス',
175
+ 'rateLimit.exceeded': 'リクエスト制限を超えました。しばらくお待ちください。',
176
+ },
177
+ };
178
+
179
+ let currentLocale: Locale = 'en';
180
+
181
+ export function setLocale(locale: Locale): void {
182
+ currentLocale = locale;
183
+ }
184
+
185
+ export function getLocale(): Locale {
186
+ return currentLocale;
187
+ }
188
+
189
+ export function getSupportedLocales(): { code: Locale; label: string }[] {
190
+ return [
191
+ { code: 'en', label: 'English' },
192
+ { code: 'zh-CN', label: '中文' },
193
+ { code: 'ja', label: '日本語' },
194
+ ];
195
+ }
196
+
197
+ export function t(key: string, params?: Record<string, string>): string {
198
+ let msg = messages[currentLocale]?.[key] ?? messages['en']?.[key] ?? key;
199
+ if (params) {
200
+ for (const [k, v] of Object.entries(params)) {
201
+ msg = msg.replace(new RegExp(`\\{${k}\\}`, 'g'), v);
202
+ }
203
+ }
204
+ return msg;
205
+ }
206
+
207
+ export function detectLocale(): Locale {
208
+ const env = process.env.LANG ?? process.env.LC_ALL ?? process.env.LANGUAGE ?? '';
209
+ if (env.startsWith('zh')) return 'zh-CN';
210
+ if (env.startsWith('ja')) return 'ja';
211
+ return 'en';
212
+ }
213
+
214
+ export function addMessages(locale: Locale, newMessages: I18nMessages): void {
215
+ messages[locale] = { ...messages[locale], ...newMessages };
216
+ }
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ export { AgentRuntime, truncateOutput } from './core/runtime';
4
4
  export { Logger } from './core/logger';
5
5
  export { loadOAD, validateOAD } from './core/config';
6
6
  export { OADSchema } from './schema/oad';
7
- export type { OADDocument, Metadata, Spec, DTVConfig, TrustLevelType } from './schema/oad';
7
+ export type { OADDocument, Metadata, Spec } from './schema/oad';
8
8
  export type { IAgent, IChannel, ISkill, Message, AgentContext, SkillResult, MemoryStore, AgentState } from './core/types';
9
9
  export { BaseChannel } from './channels';
10
10
  export { WebChannel } from './channels/web';
@@ -14,9 +14,6 @@ export { BaseSkill } from './skills/base';
14
14
  export { SkillRegistry } from './skills';
15
15
  export { InMemoryStore } from './memory';
16
16
  export { DeepBrainMemoryStore } from './memory/deepbrain';
17
- export { TrustManager } from './dtv/trust';
18
- export { ValueTracker } from './dtv/value';
19
- export { MRGConfigReader } from './dtv/data';
20
17
  export { createProvider, SUPPORTED_PROVIDERS } from './providers';
21
18
 
22
19
  // v0.3.0 new modules
@@ -52,8 +49,6 @@ export type { Locale } from './i18n';
52
49
  export { KnowledgeBase } from './core/knowledge';
53
50
  export { deployToHermes } from './deploy/hermes';
54
51
  export type { HermesDeployOptions, HermesDeployResult } from './deploy/hermes';
55
- export { publishAgent, installAgent } from './marketplace';
56
- export type { AgentManifest, PublishOptions, InstallOptions } from './marketplace';
57
52
 
58
53
  // v0.7.0 modules
59
54
  export { createAuthMiddleware, getActiveSessions } from './core/auth';
@@ -114,3 +109,7 @@ export { ToolGateway } from './tools/gateway';
114
109
  export type { ToolGatewayConfig, GatewayToolName } from './tools/gateway';
115
110
  export { StreamingManager, StreamableResponse } from './core/streaming';
116
111
  export type { StreamChunk, StreamOptions } from './core/streaming';
112
+
113
+ // v1.3.0 modules
114
+ export { TraceCollector, ConsoleExporter, DeepBrainExporter } from './traces';
115
+ export type { Span, SpanEvent, TraceExporter } from './traces';