openclaw-openagent 1.0.12 → 1.0.14

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 (132) hide show
  1. package/dist/index.js +2 -0
  2. package/dist/src/config/config-schema.d.ts +9 -0
  3. package/dist/src/config/config-schema.js +6 -0
  4. package/dist/src/messaging/executor.d.ts +2 -3
  5. package/dist/src/messaging/executor.js +4 -31
  6. package/dist/src/plugin-ui/assets/openagent-override.js +124 -18
  7. package/dist/src/proxy/auth-proxy.js +5 -0
  8. package/dist/src/runtime/update-checker.d.ts +18 -0
  9. package/dist/src/runtime/update-checker.js +216 -0
  10. package/index.ts +3 -0
  11. package/package.json +1 -3
  12. package/src/app/channel-tools.ts +0 -249
  13. package/src/app/discovery-tools.ts +0 -273
  14. package/src/app/download-file-tool.ts +0 -133
  15. package/src/app/hooks.ts +0 -144
  16. package/src/app/index.ts +0 -84
  17. package/src/app/messaging-tools.ts +0 -79
  18. package/src/app/ops-tools.ts +0 -155
  19. package/src/app/remote-agent-tool.ts +0 -762
  20. package/src/app/types.ts +0 -68
  21. package/src/app/upload-file-tool.ts +0 -411
  22. package/src/app/verbose-preflight.ts +0 -190
  23. package/src/auth/config.ts +0 -266
  24. package/src/auth/credential-manager.ts +0 -146
  25. package/src/auth/index.ts +0 -24
  26. package/src/auth/verify.ts +0 -99
  27. package/src/channel.ts +0 -566
  28. package/src/compat.ts +0 -94
  29. package/src/config/config-schema.ts +0 -39
  30. package/src/messaging/aggregator.ts +0 -120
  31. package/src/messaging/collector.ts +0 -89
  32. package/src/messaging/executor.ts +0 -72
  33. package/src/messaging/inbound.ts +0 -150
  34. package/src/messaging/index.ts +0 -11
  35. package/src/messaging/mention-protocol.ts +0 -94
  36. package/src/messaging/process-c2c-request.ts +0 -564
  37. package/src/messaging/process-message.ts +0 -373
  38. package/src/messaging/scheduler.ts +0 -55
  39. package/src/messaging/types.ts +0 -38
  40. package/src/plugin-ui/adapters/oc-2026-04.js +0 -103
  41. package/src/plugin-ui/adapters/oc-2026-05.js +0 -125
  42. package/src/plugin-ui/adapters/oc-2026-06.js +0 -125
  43. package/src/plugin-ui/adapters/oc-unknown.js +0 -48
  44. package/src/plugin-ui/assets/agentbook-icon.svg +0 -5
  45. package/src/plugin-ui/assets/bg.png +0 -0
  46. package/src/plugin-ui/assets/icon.png +0 -0
  47. package/src/plugin-ui/assets/magic.svg +0 -5
  48. package/src/plugin-ui/assets/openagent-override.js +0 -11156
  49. package/src/plugin-ui/build.cjs +0 -463
  50. package/src/plugin-ui/index.ts +0 -18
  51. package/src/plugin-ui/modules/agent-book/panel/agent-book.js +0 -570
  52. package/src/plugin-ui/modules/agent-book/panel/agent-card.js +0 -170
  53. package/src/plugin-ui/modules/agent-book/panel/agent-data.js +0 -643
  54. package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +0 -665
  55. package/src/plugin-ui/modules/agent-book/panel/mention-state.js +0 -206
  56. package/src/plugin-ui/modules/agent-book/panel/styles.js +0 -833
  57. package/src/plugin-ui/modules/agent-book/panel/theme-adapter.js +0 -86
  58. package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +0 -295
  59. package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +0 -211
  60. package/src/plugin-ui/modules/agent-book/scanner.js +0 -131
  61. package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +0 -500
  62. package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +0 -652
  63. package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +0 -256
  64. package/src/plugin-ui/modules/loader/bootstrap.js +0 -38
  65. package/src/plugin-ui/modules/loader/shared-state.js +0 -838
  66. package/src/plugin-ui/modules/loader/ws-intercept.js +0 -199
  67. package/src/plugin-ui/modules/remote-agent/chunk-parser.js +0 -161
  68. package/src/plugin-ui/modules/remote-agent/execution-card.js +0 -530
  69. package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +0 -256
  70. package/src/plugin-ui/modules/remote-agent/media-links.js +0 -151
  71. package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +0 -134
  72. package/src/plugin-ui/modules/remote-agent/output-card.js +0 -342
  73. package/src/plugin-ui/modules/remote-agent/progress-store.js +0 -363
  74. package/src/plugin-ui/modules/remote-agent/render-hooks.js +0 -1700
  75. package/src/plugin-ui/modules/remote-agent/styles.js +0 -896
  76. package/src/plugin-ui/modules/remote-agent/tool-card-model.js +0 -130
  77. package/src/plugin-ui/postinstall-deploy.cjs +0 -52
  78. package/src/plugin-ui/ui-extension-loader/backup.ts +0 -92
  79. package/src/plugin-ui/ui-extension-loader/index.ts +0 -276
  80. package/src/plugin-ui/ui-extension-loader/locator.ts +0 -152
  81. package/src/plugin-ui/ui-extension-loader/manifest.ts +0 -57
  82. package/src/plugin-ui/ui-extension-loader/registry-regex.ts +0 -944
  83. package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +0 -70
  84. package/src/plugin-ui/ui-extension-loader/types.ts +0 -72
  85. package/src/proxy/auth-proxy.ts +0 -409
  86. package/src/runtime/account.ts +0 -549
  87. package/src/runtime/index.ts +0 -7
  88. package/src/runtime/plugin-runtime.ts +0 -94
  89. package/src/runtime/registry.ts +0 -71
  90. package/src/sdk/CLASS_MAP.md +0 -143
  91. package/src/sdk/index.d.ts +0 -126
  92. package/src/sdk/index.js +0 -23990
  93. package/src/sdk/modules/cloud-search-module.js +0 -1117
  94. package/src/sdk/modules/follow-module.js +0 -1069
  95. package/src/sdk/modules/group-module.js +0 -7397
  96. package/src/sdk/modules/relationship-module.js +0 -2269
  97. package/src/sdk/modules/signaling-module.js +0 -1468
  98. package/src/sdk/modules/tim-upload-plugin.js +0 -730
  99. package/src/sdk/node-env/http-request.js +0 -90
  100. package/src/sdk/node-env/index.js +0 -57
  101. package/src/sdk/node-env/storage.js +0 -114
  102. package/src/sdk/package.json +0 -10
  103. package/src/sdk/tsconfig.json +0 -16
  104. package/src/state/pending-invocation-store.ts +0 -43
  105. package/src/state/store.ts +0 -756
  106. package/src/tim/c2c.ts +0 -451
  107. package/src/tim/channels.ts +0 -364
  108. package/src/tim/client.ts +0 -330
  109. package/src/tim/index.ts +0 -18
  110. package/src/tim/messages.ts +0 -166
  111. package/src/tim/sdk-logger-init.ts +0 -50
  112. package/src/tools.ts +0 -10
  113. package/src/transport/factory.ts +0 -95
  114. package/src/transport/oasn/index.ts +0 -17
  115. package/src/transport/oasn/oasn-agent-card.ts +0 -111
  116. package/src/transport/oasn/oasn-discovery.ts +0 -108
  117. package/src/transport/oasn/oasn-files.ts +0 -210
  118. package/src/transport/oasn/oasn-http.ts +0 -529
  119. package/src/transport/oasn/oasn-invocation.ts +0 -604
  120. package/src/transport/oasn/oasn-normalize.ts +0 -133
  121. package/src/transport/oasn/oasn-register.ts +0 -33
  122. package/src/transport/oasn/oasn-transport.ts +0 -318
  123. package/src/transport/oasn/oasn-types.ts +0 -404
  124. package/src/transport/tim/index.ts +0 -8
  125. package/src/transport/tim/tim-transport.ts +0 -515
  126. package/src/transport/types.ts +0 -538
  127. package/src/types/openclaw-plugin-sdk-media-store.d.ts +0 -9
  128. package/src/types/openclaw.d.ts +0 -97
  129. package/src/types/tencentcloud-chat.d.ts +0 -15
  130. package/src/util/http.ts +0 -113
  131. package/src/util/logger.ts +0 -131
  132. package/src/util/url-resolver.ts +0 -77
@@ -1,463 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * build.js — 将 modules/ 下的源模块按显式顺序拼接为 openagent-override.js
4
- *
5
- * 用法: node src/plugin-ui/build.cjs
6
- * 输出: src/plugin-ui/assets/openagent-override.js
7
- *
8
- * 规则:
9
- * - 顺序由 MANIFEST 数组决定,新增模块必须手动注册
10
- * - 缺少任何模块立即报错退出
11
- * - 产物不入 Git,通过 prepack hook 在 npm pack/publish 时自动生成
12
- */
13
-
14
- const fs = require('fs');
15
- const path = require('path');
16
- const crypto = require('crypto');
17
- const childProcess = require('child_process');
18
-
19
- // ── 读取 OpenClaw 版本(用于注入到产物中)──
20
- function resolveBuildHostVersion() {
21
- // 优先使用环境变量
22
- if (process.env.OPENCLAW_HOST_VERSION) return normalizeHostVersion(process.env.OPENCLAW_HOST_VERSION);
23
-
24
- var packageCandidates = [
25
- path.join(__dirname, '..', '..', 'node_modules', 'openclaw', 'package.json'),
26
- path.join(__dirname, '..', '..', 'package.json'),
27
- ];
28
- for (var i = 0; i < packageCandidates.length; i++) {
29
- try {
30
- if (!fs.existsSync(packageCandidates[i])) continue;
31
- var candidatePkg = JSON.parse(fs.readFileSync(packageCandidates[i], 'utf-8'));
32
- if (candidatePkg && candidatePkg.name === 'openclaw') {
33
- var exactVersion = normalizeHostVersion(candidatePkg.version);
34
- if (exactVersion) return exactVersion;
35
- }
36
- var depVersion = candidatePkg && candidatePkg.devDependencies && candidatePkg.devDependencies.openclaw;
37
- depVersion = normalizeHostVersion(String(depVersion || '').replace(/^[\^~>=<]+/, '').trim());
38
- if (depVersion) return depVersion;
39
- } catch (e) {}
40
- }
41
-
42
- return '';
43
- }
44
-
45
- // ═══════════════════════════════════════════════════════════════
46
- // MANIFEST — 显式构建顺序,不要用 readdir+sort
47
- // 新增模块必须在此注册,否则不进产物
48
- // ═══════════════════════════════════════════════════════════════
49
- const MANIFEST = [
50
- // ── loader ──
51
- 'loader/shared-state.js',
52
- 'loader/ws-intercept.js',
53
- // ── agent-book/panel ──
54
- 'agent-book/panel/agent-data.js',
55
- 'agent-book/panel/agent-card.js',
56
- 'agent-book/panel/theme-adapter.js', // 必须在 styles.js 之前,设置 --oa-* CSS 变量
57
- 'agent-book/panel/styles.js',
58
- 'agent-book/panel/mention-state.js',
59
- 'agent-book/panel/agent-book.js',
60
- 'agent-book/panel/inject-ui.js',
61
- // ── agent-book/remote-agent-tool ──
62
- 'agent-book/remote-agent-tool/components-core.js',
63
- 'agent-book/remote-agent-tool/thought-chain-card.js',
64
- // ── agent-book/travelcard ──
65
- 'agent-book/travelcard/travel-styles.js',
66
- 'agent-book/travelcard/travel-cards.js',
67
- 'agent-book/travelcard/travel-engine.js',
68
- // ── agent-book (跨模块) ──
69
- 'agent-book/scanner.js',
70
- // ── remote-agent(renderToolCardSidebar hook)──
71
- // 顺序:adapter → styles → parser/model → UI cards → hooks
72
- 'remote-agent/native-style-adapter.js',
73
- 'remote-agent/styles.js',
74
- 'remote-agent/chunk-parser.js',
75
- 'remote-agent/progress-store.js',
76
- 'remote-agent/tool-card-model.js',
77
- 'remote-agent/execution-card.js',
78
- 'remote-agent/markdown-renderer.js',
79
- 'remote-agent/media-links.js',
80
- 'remote-agent/output-card.js',
81
- 'remote-agent/render-hooks.js',
82
- // ── loader (bootstrap 必须最后) ──
83
- 'loader/bootstrap.js',
84
- ];
85
-
86
- // ═══════════════════════════════════════════════════════════════
87
-
88
- const modulesDir = path.join(__dirname, 'modules');
89
- const adaptersDir = path.join(__dirname, 'adapters');
90
- const assetsDir = path.join(__dirname, 'assets');
91
- const outFile = path.join(assetsDir, 'openagent-override.js');
92
- const iconFile = path.join(assetsDir, 'icon.png');
93
- const bgFile = path.join(assetsDir, 'bg.png');
94
- const HOST_VERSION_TOKEN = "hostVersion: '__OPENCLAW_HOST_VERSION__'";
95
- const BUILD_ID_TOKEN = "buildId: '__OPENAGENT_BUILD_ID__'";
96
- const BUILD_ID_ASSIGNMENT_RE = /buildId:\s*(?:"[^"]*"|'[^']*')/;
97
- const HOST_ADAPTER_START = '/*__OPENAGENT_HOST_ADAPTER_START__*/';
98
- const HOST_ADAPTER_END = '/*__OPENAGENT_HOST_ADAPTER_END__*/';
99
- const HOST_ADAPTER_BLOCK_RE = /\/\*__OPENAGENT_HOST_ADAPTER_START__\*\/[\s\S]*?\/\*__OPENAGENT_HOST_ADAPTER_END__\*\//;
100
-
101
- function normalizeHostVersion(version) {
102
- var match = String(version || '').match(/20\d{2}\.\d{1,2}\.\d{1,2}(?:-[A-Za-z0-9._-]+)?/);
103
- return match ? match[0] : '';
104
- }
105
-
106
- function injectHostVersion(content, hostVersion) {
107
- hostVersion = normalizeHostVersion(hostVersion);
108
- if (!hostVersion) return content;
109
- return content.replace(HOST_VERSION_TOKEN, 'hostVersion: ' + JSON.stringify(hostVersion));
110
- }
111
-
112
- function resolveHostAdapterId(hostVersion) {
113
- var parsed = normalizeHostVersion(hostVersion).split('.');
114
- var year = parseInt(parsed[0], 10);
115
- var month = parseInt(parsed[1], 10);
116
- if (year === 2026 && month === 4) return 'oc-2026-04';
117
- if (year === 2026 && month === 5) return 'oc-2026-05';
118
- if (year === 2026 && month === 6) return 'oc-2026-06';
119
- return 'oc-unknown';
120
- }
121
-
122
- function getHostAdapterBlock(hostVersion) {
123
- var adapterId = resolveHostAdapterId(hostVersion);
124
- var adapterPath = path.join(adaptersDir, adapterId + '.js');
125
- if (!fs.existsSync(adapterPath)) {
126
- adapterId = 'oc-unknown';
127
- adapterPath = path.join(adaptersDir, adapterId + '.js');
128
- }
129
- var adapterContent = fs.readFileSync(adapterPath, 'utf-8').trimEnd();
130
- return [
131
- HOST_ADAPTER_START,
132
- '// HOST ADAPTER: ' + adapterId,
133
- adapterContent,
134
- HOST_ADAPTER_END,
135
- ].join('\n');
136
- }
137
-
138
- function injectHostAdapter(content, hostVersion) {
139
- var block = getHostAdapterBlock(hostVersion);
140
- if (HOST_ADAPTER_BLOCK_RE.test(content)) {
141
- return content.replace(HOST_ADAPTER_BLOCK_RE, block);
142
- }
143
- return content;
144
- }
145
-
146
- function renderOverrideContent(content, hostVersion) {
147
- return injectBuildId(injectHostAdapter(injectHostVersion(content, hostVersion), hostVersion));
148
- }
149
-
150
- function hashContent(content) {
151
- return crypto.createHash('sha256').update(content).digest('hex').slice(0, 12);
152
- }
153
-
154
- function injectBuildId(content) {
155
- var normalized = content.replace(BUILD_ID_ASSIGNMENT_RE, BUILD_ID_TOKEN);
156
- var buildId = hashContent(normalized);
157
- return normalized.replace(BUILD_ID_TOKEN, 'buildId: ' + JSON.stringify(buildId));
158
- }
159
-
160
- function resolveControlUiHostVersion(controlUiDir) {
161
- if (process.env.OPENCLAW_HOST_VERSION) return normalizeHostVersion(process.env.OPENCLAW_HOST_VERSION);
162
-
163
- var candidates = [
164
- path.join(controlUiDir, '..', '..', 'package.json'),
165
- path.join(controlUiDir, '..', 'package.json'),
166
- ];
167
- for (var i = 0; i < candidates.length; i++) {
168
- try {
169
- if (!fs.existsSync(candidates[i])) continue;
170
- var pkg = JSON.parse(fs.readFileSync(candidates[i], 'utf-8'));
171
- if (pkg && pkg.name === 'openclaw') return normalizeHostVersion(pkg.version);
172
- } catch (e) {}
173
- }
174
- return '';
175
- }
176
-
177
- function pushUniquePath(list, candidate) {
178
- if (!list || !candidate) return;
179
- var resolved = path.resolve(candidate);
180
- for (var i = 0; i < list.length; i++) {
181
- if (path.resolve(list[i]) === resolved) return;
182
- }
183
- list.push(resolved);
184
- }
185
-
186
- function collectCommandOutputLines(command, args) {
187
- try {
188
- var result = childProcess.spawnSync(command, args, {
189
- encoding: 'utf-8',
190
- stdio: ['ignore', 'pipe', 'ignore'],
191
- });
192
- return String(result.stdout || '')
193
- .split(/\r?\n/)
194
- .map(function(line) { return line.trim(); })
195
- .filter(Boolean);
196
- } catch (e) {
197
- return [];
198
- }
199
- }
200
-
201
- function collectGlobalNodeModuleRoots() {
202
- var roots = [];
203
-
204
- try {
205
- pushUniquePath(roots, path.join(path.dirname(process.execPath), '..', 'lib', 'node_modules'));
206
- } catch (e) {}
207
-
208
- var npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
209
- var npmRoots = collectCommandOutputLines(npmCommand, ['root', '-g']);
210
- for (var n = 0; n < npmRoots.length; n++) {
211
- pushUniquePath(roots, npmRoots[n]);
212
- }
213
-
214
- var openclawLocator = process.platform === 'win32' ? 'where' : 'which';
215
- var openclawBins = collectCommandOutputLines(openclawLocator, ['openclaw']);
216
- for (var b = 0; b < openclawBins.length; b++) {
217
- var binPath = openclawBins[b];
218
- try {
219
- pushUniquePath(roots, path.join(path.dirname(binPath), '..', 'lib', 'node_modules'));
220
- } catch (e) {}
221
- try {
222
- var realBin = fs.realpathSync(binPath);
223
- var needle = path.join('node_modules', 'openclaw');
224
- var idx = realBin.lastIndexOf(needle);
225
- if (idx >= 0) {
226
- pushUniquePath(roots, realBin.substring(0, idx + 'node_modules'.length));
227
- }
228
- } catch (e) {}
229
- }
230
-
231
- return roots;
232
- }
233
-
234
- function addGlobalOpenclawTargets(deployTargets, assetTargets) {
235
- var roots = collectGlobalNodeModuleRoots();
236
- for (var i = 0; i < roots.length; i++) {
237
- var root = roots[i];
238
- pushUniquePath(deployTargets, path.join(root, 'openclaw', 'dist', 'control-ui', 'openagent-override.js'));
239
- pushUniquePath(deployTargets, path.join(root, 'openclaw-openagent', 'src', 'plugin-ui', 'assets', 'openagent-override.js'));
240
- pushUniquePath(deployTargets, path.join(root, 'openclaw-openagent', 'dist', 'src', 'plugin-ui', 'assets', 'openagent-override.js'));
241
-
242
- pushUniquePath(assetTargets, path.join(root, 'openclaw', 'dist', 'control-ui'));
243
- pushUniquePath(assetTargets, path.join(root, 'openclaw-openagent', 'src', 'plugin-ui', 'assets'));
244
- pushUniquePath(assetTargets, path.join(root, 'openclaw-openagent', 'dist', 'src', 'plugin-ui', 'assets'));
245
- }
246
- }
247
-
248
- function updateControlUiIndex(controlUiDir, contentHash, hostVersion) {
249
- var indexPath = path.join(controlUiDir, 'index.html');
250
- if (!fs.existsSync(indexPath)) return false;
251
-
252
- var html = fs.readFileSync(indexPath, 'utf-8');
253
- var htmlMarker = '<!--openagent:html-script-tag-->';
254
- var hostVersionAttr = hostVersion ? ' data-openagent-host-version="' + hostVersion + '"' : '';
255
- var scriptTag = htmlMarker + '<script src="./openagent-override.js?v=' + contentHash + '"' + hostVersionAttr + '></script>';
256
- var markedScriptPattern = /(?:\/\*openagent:html-script-tag\*\/|<!--openagent:html-script-tag-->)<script[^>]*openagent-override[^>]*><\/script>\n?\s*/g;
257
- var oldScriptPattern = /<script[^>]*openagent-override[^>]*><\/script>\n?\s*/g;
258
- var nextHtml;
259
-
260
- if (/(?:\/\*openagent:html-script-tag\*\/|<!--openagent:html-script-tag-->)/.test(html)) {
261
- nextHtml = html.replace(markedScriptPattern, scriptTag + '\n ');
262
- if (nextHtml === html && !nextHtml.includes('openagent-override.js')) {
263
- nextHtml = nextHtml.replace(/(?:\/\*openagent:html-script-tag\*\/|<!--openagent:html-script-tag-->)/, scriptTag + '\n ');
264
- } else if (nextHtml === html && nextHtml.includes('openagent-override.js')) {
265
- nextHtml = nextHtml.replace(oldScriptPattern, '').replace(/(?:\/\*openagent:html-script-tag\*\/|<!--openagent:html-script-tag-->)/, scriptTag + '\n ');
266
- }
267
- } else {
268
- nextHtml = html.replace(oldScriptPattern, '');
269
- var viteAnchor = '<script type="module" crossorigin src="./assets/index-';
270
- var anchorIdx = nextHtml.indexOf(viteAnchor);
271
- if (anchorIdx >= 0) {
272
- nextHtml = nextHtml.substring(0, anchorIdx) + scriptTag + '\n ' + nextHtml.substring(anchorIdx);
273
- } else {
274
- nextHtml = nextHtml.replace('</head>', scriptTag + '\n</head>');
275
- }
276
- }
277
-
278
- if (nextHtml && nextHtml !== html) {
279
- fs.writeFileSync(indexPath, nextHtml, 'utf-8');
280
- return true;
281
- }
282
- return false;
283
- }
284
-
285
- const HEADER = `/**
286
- * OpenAgent UI Override — Auto-generated, do not edit directly!
287
- *
288
- * Source: src/plugin-ui/modules/
289
- * Built: ${new Date().toISOString()}
290
- *
291
- * To modify, edit the source modules and run:
292
- * npm run build:override
293
- */
294
-
295
- (() => {
296
- 'use strict';
297
- `;
298
-
299
- const FOOTER = `
300
- })();
301
- `;
302
-
303
- // ── Build Logic ──
304
-
305
- function build() {
306
- console.log(`\n[${new Date().toLocaleTimeString()}] Building override...`);
307
- let body = '';
308
- let errors = 0;
309
-
310
- for (const file of MANIFEST) {
311
- const filePath = path.join(modulesDir, file);
312
-
313
- if (!fs.existsSync(filePath)) {
314
- console.error(`❌ Missing module: ${file}`);
315
- errors++;
316
- continue;
317
- }
318
-
319
- const content = fs.readFileSync(filePath, 'utf-8');
320
- body += `\n// ════════════════════════════════════════════════════════════════\n`;
321
- body += `// MODULE: ${file}\n`;
322
- body += `// ════════════════════════════════════════════════════════════════\n\n`;
323
- body += content.trimEnd() + '\n';
324
- if (file === 'loader/shared-state.js') {
325
- body += `\n// ════════════════════════════════════════════════════════════════\n`;
326
- body += `// MODULE: host-adapter/selected\n`;
327
- body += `// ════════════════════════════════════════════════════════════════\n\n`;
328
- body += getHostAdapterBlock('') + '\n';
329
- }
330
- }
331
-
332
- if (errors > 0) {
333
- console.error(`\n❌ Build failed: ${errors} missing module(s)`);
334
- if (!isWatchMode) process.exit(1);
335
- return;
336
- }
337
-
338
- // ── 不做构建时版本注入,由运行时 DOM/CSS 特征检测 ──
339
- // (build.cjs 无法知道实际运行的 OpenClaw 版本)
340
- var output = HEADER + body + FOOTER;
341
- var assetOutput = renderOverrideContent(output, '');
342
-
343
- fs.mkdirSync(path.dirname(outFile), { recursive: true });
344
- fs.writeFileSync(outFile, assetOutput, 'utf-8');
345
-
346
- const lineCount = assetOutput.split('\n').length;
347
- console.log(`✅ Built: ${path.relative(process.cwd(), outFile)} (${lineCount} lines)`);
348
-
349
- // ── Auto-deploy to runtime targets ──────────────────────────────────────
350
- // 开发时自动复制到插件安装目录和 control-ui,省去手动 cp
351
- // 任何 target 不存在都静默跳过(CI/CD 环境不影响)
352
-
353
- const homedir = require('os').homedir();
354
-
355
- const DEPLOY_TARGETS = [
356
- // 插件安装目录(Gateway 启动时从这里读取并复制到 control-ui)
357
- path.join(homedir, '.openclaw-docker/extensions/openclaw-openagent/src/inject/assets/openagent-override.js'),
358
- path.join(homedir, '.openclaw-docker/extensions/openclaw-openagent/src/plugin-ui/assets/openagent-override.js'),
359
- path.join(homedir, '.openclaw/extensions/openclaw-openagent/src/inject/assets/openagent-override.js'),
360
- path.join(homedir, '.openclaw/extensions/openclaw-openagent/src/plugin-ui/assets/openagent-override.js'),
361
- // 本地开发 dist/ 目录
362
- path.join(__dirname, '..', '..', 'dist', 'src', 'plugin-ui', 'assets', 'openagent-override.js'),
363
- // 本地 node_modules 中的 openclaw control-ui(Gateway 实际运行路径)
364
- path.join(__dirname, '..', '..', 'node_modules', 'openclaw', 'dist', 'control-ui', 'openagent-override.js'),
365
- // npm 全局安装 + 项目缓存(Gateway 可能从这些路径加载)
366
- path.join(homedir, '.openclaw/npm/projects/openclaw-openagent/node_modules/openclaw-openagent/src/plugin-ui/assets/openagent-override.js'),
367
- path.join(homedir, '.openclaw/npm/projects/openclaw-openagent/node_modules/openclaw-openagent/dist/src/plugin-ui/assets/openagent-override.js'),
368
- path.join(homedir, '.nvm/versions/node/v22.21.1/lib/node_modules/openclaw-openagent/src/plugin-ui/assets/openagent-override.js'),
369
- path.join(homedir, '.nvm/versions/node/v22.21.1/lib/node_modules/openclaw-openagent/dist/src/plugin-ui/assets/openagent-override.js'),
370
- ];
371
- addGlobalOpenclawTargets(DEPLOY_TARGETS, null);
372
-
373
- let deployed = 0;
374
- for (const target of DEPLOY_TARGETS) {
375
- try {
376
- if (fs.existsSync(path.dirname(target))) {
377
- const targetDir = path.dirname(target);
378
- const hostVersion = path.basename(targetDir) === 'control-ui'
379
- ? resolveControlUiHostVersion(targetDir)
380
- : '';
381
- const targetOutput = renderOverrideContent(output, hostVersion);
382
- fs.writeFileSync(target, targetOutput, 'utf-8');
383
- if (hostVersion) {
384
- const contentHash = hashContent(targetOutput);
385
- if (updateControlUiIndex(targetDir, contentHash, hostVersion)) {
386
- console.log(` ↻ updated index.html cache-bust (${hostVersion}, ${resolveHostAdapterId(hostVersion)}, ${contentHash})`);
387
- }
388
- }
389
- console.log(` → ${path.relative(homedir, target)}`);
390
- deployed++;
391
- }
392
- } catch {}
393
- }
394
-
395
- if (deployed > 0) {
396
- console.log(`✅ Auto-deployed override to ${deployed} target(s)`);
397
- } else {
398
- console.log('ℹ️ No deploy targets found (standalone build)');
399
- }
400
-
401
- // ── Shared asset deploy targets (control-ui + extension dirs) ──
402
- const ASSET_DEPLOY_TARGETS = [
403
- path.join(homedir, '.openclaw-docker/extensions/openclaw-openagent/src/inject/assets'),
404
- path.join(homedir, '.openclaw-docker/extensions/openclaw-openagent/src/plugin-ui/assets'),
405
- path.join(homedir, '.openclaw/extensions/openclaw-openagent/src/inject/assets'),
406
- path.join(homedir, '.openclaw/extensions/openclaw-openagent/src/plugin-ui/assets'),
407
- path.join(__dirname, '..', '..', 'dist', 'src', 'plugin-ui', 'assets'),
408
- path.join(__dirname, '..', '..', 'node_modules', 'openclaw', 'dist', 'control-ui'),
409
- path.join(homedir, '.openclaw/npm/projects/openclaw-openagent/node_modules/openclaw-openagent/src/plugin-ui/assets'),
410
- path.join(homedir, '.openclaw/npm/projects/openclaw-openagent/node_modules/openclaw-openagent/dist/src/plugin-ui/assets'),
411
- path.join(homedir, '.nvm/versions/node/v22.21.1/lib/node_modules/openclaw-openagent/src/plugin-ui/assets'),
412
- path.join(homedir, '.nvm/versions/node/v22.21.1/lib/node_modules/openclaw-openagent/dist/src/plugin-ui/assets'),
413
- ];
414
- addGlobalOpenclawTargets(null, ASSET_DEPLOY_TARGETS);
415
-
416
- // ── Deploy image assets (icon.png, bg.png) ──
417
- const IMAGE_ASSETS = [
418
- { file: iconFile, name: 'icon.png' },
419
- { file: bgFile, name: 'bg.png' },
420
- ];
421
-
422
- for (const asset of IMAGE_ASSETS) {
423
- if (!fs.existsSync(asset.file)) continue;
424
- let deployed = 0;
425
- for (const dir of ASSET_DEPLOY_TARGETS) {
426
- try {
427
- const dest = path.join(dir, asset.name);
428
- if (fs.existsSync(dir)) {
429
- fs.copyFileSync(asset.file, dest);
430
- deployed++;
431
- }
432
- } catch {}
433
- }
434
- if (deployed > 0) {
435
- console.log(`✅ Auto-deployed ${asset.name} to ${deployed} target(s)`);
436
- }
437
- }
438
- }
439
-
440
- // ── Execution ──
441
-
442
- const isWatchMode = process.argv.includes('--watch');
443
-
444
- build();
445
-
446
- if (isWatchMode) {
447
- console.log(`\n👀 Watching for changes in ${path.relative(process.cwd(), modulesDir)} and ${path.relative(process.cwd(), adaptersDir)}...`);
448
-
449
- let debounceTimer;
450
- function watchSourceDir(sourceDir) {
451
- fs.watch(sourceDir, { recursive: true }, (eventType, filename) => {
452
- // Ignore dot files and non-js files
453
- if (!filename || filename.startsWith('.') || !filename.endsWith('.js')) return;
454
-
455
- clearTimeout(debounceTimer);
456
- debounceTimer = setTimeout(() => {
457
- build();
458
- }, 100);
459
- });
460
- }
461
- watchSourceDir(modulesDir);
462
- watchSourceDir(adaptersDir);
463
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Plugin UI — UIExtensionLoader 入口
3
- *
4
- * 将 UI 扩展加载委托给 ui-extension-loader 模块。
5
- * 保持对外 API 不变(injectControlUiOverride),内部全部走新框架。
6
- */
7
-
8
- import { loadUIExtensions } from './ui-extension-loader/index.js';
9
-
10
- /**
11
- * 加载全部 UI 扩展。
12
- *
13
- * 由 index.ts register() 调用。内部通过 Manifest Reconciler
14
- * 自动完成扩展点的 apply / revert / skip。
15
- */
16
- export async function injectControlUiOverride(hostVersion?: string): Promise<void> {
17
- await loadUIExtensions({ hostVersion });
18
- }