opc-agent 1.1.3 → 1.2.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.
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +75 -75
- package/README.md +429 -429
- package/README.zh-CN.md +415 -415
- package/dist/channels/web.js +256 -256
- package/dist/core/streaming.d.ts +56 -0
- package/dist/core/streaming.js +160 -0
- package/dist/deploy/hermes.js +22 -22
- package/dist/deploy/openclaw.js +31 -31
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +13 -148
- package/dist/schema/oad.d.ts +3 -3
- package/dist/templates/code-reviewer.js +5 -5
- package/dist/templates/customer-service.js +2 -2
- package/dist/templates/data-analyst.js +5 -5
- package/dist/templates/knowledge-base.js +2 -2
- package/dist/templates/sales-assistant.js +4 -4
- package/dist/templates/teacher.js +6 -6
- package/dist/tools/gateway.d.ts +28 -0
- package/dist/tools/gateway.js +177 -0
- package/docs/.vitepress/config.ts +103 -103
- package/docs/api/cli.md +48 -48
- package/docs/api/oad-schema.md +64 -64
- package/docs/api/sdk.md +80 -80
- package/docs/guide/concepts.md +51 -51
- package/docs/guide/configuration.md +79 -79
- package/docs/guide/deployment.md +42 -42
- package/docs/guide/getting-started.md +44 -44
- package/docs/guide/templates.md +28 -28
- package/docs/guide/testing.md +84 -84
- package/docs/index.md +27 -27
- package/docs/zh/api/cli.md +54 -54
- package/docs/zh/api/oad-schema.md +87 -87
- package/docs/zh/api/sdk.md +102 -102
- package/docs/zh/guide/concepts.md +104 -104
- package/docs/zh/guide/configuration.md +135 -135
- package/docs/zh/guide/deployment.md +81 -81
- package/docs/zh/guide/getting-started.md +82 -82
- package/docs/zh/guide/templates.md +84 -84
- package/docs/zh/guide/testing.md +88 -88
- package/docs/zh/index.md +27 -27
- package/examples/customer-service-demo/README.md +90 -90
- package/examples/customer-service-demo/oad.yaml +107 -107
- package/package.json +1 -1
- package/src/analytics/index.ts +66 -66
- package/src/channels/discord.ts +192 -192
- package/src/channels/email.ts +177 -177
- package/src/channels/feishu.ts +236 -236
- package/src/channels/index.ts +15 -15
- package/src/channels/slack.ts +160 -160
- package/src/channels/telegram.ts +90 -90
- package/src/channels/voice.ts +106 -106
- package/src/channels/web.ts +17 -17
- package/src/channels/webhook.ts +199 -199
- package/src/channels/websocket.ts +87 -87
- package/src/channels/wechat.ts +149 -149
- package/src/core/a2a.ts +143 -143
- package/src/core/agent.ts +152 -152
- package/src/core/analytics-engine.ts +186 -186
- package/src/core/auth.ts +57 -57
- package/src/core/cache.ts +141 -141
- package/src/core/compose.ts +77 -77
- package/src/core/config.ts +14 -14
- package/src/core/errors.ts +148 -148
- package/src/core/hitl.ts +138 -138
- package/src/core/knowledge.ts +49 -4
- package/src/core/logger.ts +57 -57
- package/src/core/orchestrator.ts +215 -215
- package/src/core/performance.ts +187 -187
- package/src/core/rate-limiter.ts +128 -128
- package/src/core/room.ts +109 -109
- package/src/core/runtime.ts +152 -152
- package/src/core/sandbox.ts +101 -101
- package/src/core/security.ts +171 -171
- package/src/core/streaming.ts +195 -0
- package/src/core/types.ts +68 -68
- package/src/core/versioning.ts +106 -106
- package/src/core/watch.ts +178 -178
- package/src/core/workflow.ts +235 -235
- package/src/deploy/hermes.ts +156 -156
- package/src/deploy/openclaw.ts +200 -200
- package/src/dtv/data.ts +29 -29
- package/src/dtv/trust.ts +43 -43
- package/src/dtv/value.ts +47 -47
- package/src/i18n/index.ts +216 -216
- package/src/index.ts +6 -0
- package/src/marketplace/index.ts +223 -223
- package/src/memory/deepbrain.ts +108 -108
- package/src/memory/index.ts +34 -34
- package/src/plugins/index.ts +208 -208
- package/src/providers/index.ts +12 -3
- package/src/schema/oad.ts +155 -155
- package/src/skills/base.ts +16 -16
- package/src/skills/document.ts +100 -100
- package/src/skills/http.ts +35 -35
- package/src/skills/index.ts +27 -27
- package/src/skills/scheduler.ts +80 -80
- package/src/skills/webhook-trigger.ts +59 -59
- package/src/templates/code-reviewer.ts +34 -34
- package/src/templates/customer-service.ts +80 -80
- package/src/templates/data-analyst.ts +70 -70
- package/src/templates/executive-assistant.ts +71 -71
- package/src/templates/financial-advisor.ts +60 -60
- package/src/templates/knowledge-base.ts +31 -31
- package/src/templates/legal-assistant.ts +71 -71
- package/src/templates/sales-assistant.ts +79 -79
- package/src/templates/teacher.ts +79 -79
- package/src/testing/index.ts +181 -181
- package/src/tools/calculator.ts +73 -73
- package/src/tools/datetime.ts +149 -149
- package/src/tools/gateway.ts +220 -0
- package/src/tools/json-transform.ts +187 -187
- package/src/tools/mcp.ts +76 -76
- package/src/tools/text-analysis.ts +116 -116
- package/templates/Dockerfile +15 -15
- package/templates/code-reviewer/README.md +27 -27
- package/templates/code-reviewer/oad.yaml +41 -41
- package/templates/customer-service/README.md +22 -22
- package/templates/customer-service/oad.yaml +36 -36
- package/templates/docker-compose.yml +21 -21
- package/templates/ecommerce-assistant/README.md +45 -0
- package/templates/ecommerce-assistant/oad.yaml +47 -0
- package/templates/knowledge-base/README.md +28 -28
- package/templates/knowledge-base/oad.yaml +38 -38
- package/templates/sales-assistant/README.md +26 -26
- package/templates/sales-assistant/oad.yaml +43 -43
- package/templates/tech-support/README.md +43 -0
- package/templates/tech-support/oad.yaml +45 -0
- package/tests/a2a.test.ts +66 -66
- package/tests/agent.test.ts +72 -72
- package/tests/analytics.test.ts +50 -50
- package/tests/channel.test.ts +39 -39
- package/tests/e2e.test.ts +134 -134
- package/tests/errors.test.ts +83 -83
- package/tests/gateway.test.ts +71 -0
- package/tests/hitl.test.ts +71 -71
- package/tests/i18n.test.ts +41 -41
- package/tests/mcp.test.ts +54 -54
- package/tests/oad.test.ts +68 -68
- package/tests/performance.test.ts +115 -115
- package/tests/plugin.test.ts +74 -74
- package/tests/room.test.ts +106 -106
- package/tests/runtime.test.ts +42 -42
- package/tests/sandbox.test.ts +46 -46
- package/tests/security.test.ts +60 -60
- package/tests/streaming.test.ts +109 -0
- package/tests/templates.test.ts +77 -77
- package/tests/v070.test.ts +76 -76
- package/tests/versioning.test.ts +75 -75
- package/tests/voice.test.ts +61 -61
- package/tests/webhook.test.ts +29 -29
- package/tests/workflow.test.ts +143 -143
- package/tsconfig.json +19 -19
- package/vitest.config.ts +9 -9
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
|
@@ -108,3 +108,9 @@ export { DiscordChannel } from './channels/discord';
|
|
|
108
108
|
export type { DiscordChannelConfig } from './channels/discord';
|
|
109
109
|
export { ProcessWatcher } from './core/watch';
|
|
110
110
|
export type { WatchPattern, WatchMatch, WatchOptions } from './core/watch';
|
|
111
|
+
|
|
112
|
+
// v1.2.0 modules
|
|
113
|
+
export { ToolGateway } from './tools/gateway';
|
|
114
|
+
export type { ToolGatewayConfig, GatewayToolName } from './tools/gateway';
|
|
115
|
+
export { StreamingManager, StreamableResponse } from './core/streaming';
|
|
116
|
+
export type { StreamChunk, StreamOptions } from './core/streaming';
|