openclaw-openagent 1.0.3 → 1.0.5
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/dist/src/app/download-file-tool.js +1 -1
- package/dist/src/app/remote-agent-tool.js +6 -1
- package/dist/src/plugin-ui/assets/openagent-override.js +1 -1
- package/package.json +1 -1
- package/src/app/download-file-tool.ts +1 -1
- package/src/app/remote-agent-tool.ts +10 -1
- package/src/plugin-ui/assets/openagent-override.js +1 -1
- package/src/plugin-ui/modules/agent-book/panel/theme-adapter.js +86 -0
|
@@ -71,7 +71,7 @@ export function createDownloadFileTool() {
|
|
|
71
71
|
return fail('OASN transport not ready');
|
|
72
72
|
}
|
|
73
73
|
// ② Resolve download URL
|
|
74
|
-
const accessBase = rt.config?.accessApiBase;
|
|
74
|
+
const accessBase = rt.config?.accessApiBase || rt.config?.apiBase;
|
|
75
75
|
const downloadUrl = resolveOasnAccessUrl(accessBase, contentUrl);
|
|
76
76
|
logger.info(`[download-tool] Downloading artifact: url=${downloadUrl} saveTo=${savePath}`);
|
|
77
77
|
// ③ Download
|
|
@@ -288,9 +288,9 @@ export function createCallRemoteAgentTool() {
|
|
|
288
288
|
}
|
|
289
289
|
// WebUI continuation:声明了 webui 能力的 ServiceAgent 在 succeeded 后会
|
|
290
290
|
// 在 visible_result.webui_continuation 里返回可继续交互的入口。
|
|
291
|
+
const accessBase = rt.config?.accessApiBase || rt.config?.apiBase;
|
|
291
292
|
if (result.webuiContinuation?.launchUrl) {
|
|
292
293
|
const rawLink = result.webuiContinuation.launchUrl;
|
|
293
|
-
const accessBase = rt.config?.accessApiBase;
|
|
294
294
|
const link = resolveOasnAccessUrl(accessBase, rawLink);
|
|
295
295
|
const label = result.webuiContinuation.displayName || 'Open WebUI';
|
|
296
296
|
content = content.trim()
|
|
@@ -315,6 +315,11 @@ export function createCallRemoteAgentTool() {
|
|
|
315
315
|
? `${content}\n\nFiles from remote agent (use openagent_download_file to save):\n${artifactLines.join('\n')}`
|
|
316
316
|
: `Files from remote agent:\n${artifactLines.join('\n')}`;
|
|
317
317
|
}
|
|
318
|
+
// Resolve OASN-relative URLs in content (remote agent may have embedded
|
|
319
|
+
// /webui/continuations/... or /api/artifacts/... in its output text).
|
|
320
|
+
if (content && accessBase) {
|
|
321
|
+
content = content.replace(/(?<![a-zA-Z0-9])(\/webui\/[^\s"')\]]+|\/api\/[^\s"')\]]+)/g, (match) => resolveOasnAccessUrl(accessBase, match));
|
|
322
|
+
}
|
|
318
323
|
// OASN 的非文本 artifacts 暂继续复用 ArtifactRef.contentUrl 作为 mediaUrls。
|
|
319
324
|
reply = {
|
|
320
325
|
status: 'complete',
|
package/package.json
CHANGED
|
@@ -93,7 +93,7 @@ export function createDownloadFileTool(): ToolDescriptor {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// ② Resolve download URL
|
|
96
|
-
const accessBase = rt.config?.accessApiBase;
|
|
96
|
+
const accessBase = rt.config?.accessApiBase || rt.config?.apiBase;
|
|
97
97
|
const downloadUrl = resolveOasnAccessUrl(accessBase, contentUrl);
|
|
98
98
|
|
|
99
99
|
logger.info(
|
|
@@ -347,9 +347,9 @@ export function createCallRemoteAgentTool(): ToolDescriptor {
|
|
|
347
347
|
|
|
348
348
|
// WebUI continuation:声明了 webui 能力的 ServiceAgent 在 succeeded 后会
|
|
349
349
|
// 在 visible_result.webui_continuation 里返回可继续交互的入口。
|
|
350
|
+
const accessBase = rt.config?.accessApiBase || rt.config?.apiBase;
|
|
350
351
|
if (result.webuiContinuation?.launchUrl) {
|
|
351
352
|
const rawLink = result.webuiContinuation.launchUrl;
|
|
352
|
-
const accessBase = rt.config?.accessApiBase;
|
|
353
353
|
const link = resolveOasnAccessUrl(accessBase, rawLink);
|
|
354
354
|
const label = result.webuiContinuation.displayName || 'Open WebUI';
|
|
355
355
|
content = content.trim()
|
|
@@ -378,6 +378,15 @@ export function createCallRemoteAgentTool(): ToolDescriptor {
|
|
|
378
378
|
: `Files from remote agent:\n${artifactLines.join('\n')}`;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
// Resolve OASN-relative URLs in content (remote agent may have embedded
|
|
382
|
+
// /webui/continuations/... or /api/artifacts/... in its output text).
|
|
383
|
+
if (content && accessBase) {
|
|
384
|
+
content = content.replace(
|
|
385
|
+
/(?<![a-zA-Z0-9])(\/webui\/[^\s"')\]]+|\/api\/[^\s"')\]]+)/g,
|
|
386
|
+
(match) => resolveOasnAccessUrl(accessBase, match),
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
381
390
|
// OASN 的非文本 artifacts 暂继续复用 ArtifactRef.contentUrl 作为 mediaUrls。
|
|
382
391
|
reply = {
|
|
383
392
|
status: 'complete',
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// ── OpenAgent Theme Adapter ──
|
|
2
|
+
//
|
|
3
|
+
// 运行时检测 OpenClaw Control UI 主题系统(v4.x vscode tokens / v5.x glassmorphism),
|
|
4
|
+
// 注入 --oa-* CSS 变量供 styles.js 中的 var() fallback 消费。
|
|
5
|
+
//
|
|
6
|
+
// 必须早于 styles.js 加载(由 build.cjs MANIFEST 顺序保证)。
|
|
7
|
+
|
|
8
|
+
(function _clInitThemeAdapter() {
|
|
9
|
+
if (window.__openagentThemeAdapterInstalled) return;
|
|
10
|
+
window.__openagentThemeAdapterInstalled = true;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 检测当前 OC 主题系统类型。
|
|
14
|
+
* @returns {{ hasGlass: boolean, hasVscode: boolean, isDark: boolean }}
|
|
15
|
+
*/
|
|
16
|
+
function detectThemeSystem() {
|
|
17
|
+
var cs = getComputedStyle(document.documentElement);
|
|
18
|
+
var hasGlass = !!(cs.getPropertyValue('--glass-surface').trim());
|
|
19
|
+
var hasKn = !!(cs.getPropertyValue('--kn-bg-primary').trim());
|
|
20
|
+
var hasVscode = !!(cs.getPropertyValue('--vscode-editor-background').trim());
|
|
21
|
+
|
|
22
|
+
// 多策略暗色检测:v4 data-theme-mode / v5 data-theme / prefers-color-scheme
|
|
23
|
+
var themeMode = document.documentElement.getAttribute('data-theme-mode') // v4.x
|
|
24
|
+
|| document.documentElement.getAttribute('data-theme') // v5.x
|
|
25
|
+
|| '';
|
|
26
|
+
var isDark = themeMode.indexOf('dark') >= 0
|
|
27
|
+
|| window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
hasGlass: hasGlass || hasKn,
|
|
31
|
+
hasVscode: hasVscode,
|
|
32
|
+
isDark: isDark
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 注入 --oa-* CSS 变量到 :root。
|
|
38
|
+
* styles.js 中的 var(--oa-xxx, fallback) 会优先取这些值。
|
|
39
|
+
*/
|
|
40
|
+
function setupThemeVariables() {
|
|
41
|
+
var system = detectThemeSystem();
|
|
42
|
+
var root = document.documentElement;
|
|
43
|
+
|
|
44
|
+
if (system.hasGlass) {
|
|
45
|
+
// v5.x Glassmorphism: 使用 --glass-* / --kn-* token 族
|
|
46
|
+
root.style.setProperty('--oa-panel-bg', 'var(--glass-surface, var(--card))');
|
|
47
|
+
root.style.setProperty('--oa-panel-text', 'var(--kn-text-primary, var(--text, #e0e0e0))');
|
|
48
|
+
root.style.setProperty('--oa-card-bg', 'var(--glass-card, var(--card, #f5f5f5))');
|
|
49
|
+
root.style.setProperty('--oa-card-hover-bg', 'var(--glass-card-hover, var(--card-hover))');
|
|
50
|
+
root.style.setProperty('--oa-border', 'var(--glass-border, var(--border, #e5e5e5))');
|
|
51
|
+
root.style.setProperty('--oa-shadow-color', 'rgba(0, 0, 0, 0.08)');
|
|
52
|
+
root.style.setProperty('--oa-divider', 'var(--glass-divider, var(--border, #eee))');
|
|
53
|
+
root.style.setProperty('--oa-muted-text', 'var(--kn-text-secondary, var(--text-secondary, #999))');
|
|
54
|
+
} else if (system.hasVscode) {
|
|
55
|
+
// v4.x VSCode tokens: 使用 --vscode-* 变量
|
|
56
|
+
root.style.setProperty('--oa-panel-bg', 'var(--vscode-editor-background, #fff)');
|
|
57
|
+
root.style.setProperty('--oa-panel-text', 'var(--vscode-editor-foreground, #2F2F33)');
|
|
58
|
+
root.style.setProperty('--oa-card-bg', 'var(--vscode-sideBar-background, #f5f5f5)');
|
|
59
|
+
root.style.setProperty('--oa-card-hover-bg', 'var(--vscode-list-hoverBackground, #f0f0f0)');
|
|
60
|
+
root.style.setProperty('--oa-border', 'var(--vscode-panel-border, #e5e5e5)');
|
|
61
|
+
root.style.setProperty('--oa-shadow-color', 'rgba(0, 0, 0, 0.10)');
|
|
62
|
+
root.style.setProperty('--oa-divider', 'var(--vscode-sideBar-border, #eee)');
|
|
63
|
+
root.style.setProperty('--oa-muted-text', 'var(--vscode-descriptionForeground, #999)');
|
|
64
|
+
}
|
|
65
|
+
// 无特征 → 不注入变量,styles.js 中的 var() 会 fallback 到硬编码值
|
|
66
|
+
|
|
67
|
+
// 注入暗色 class 标记供 styles.js 选择器使用
|
|
68
|
+
if (system.isDark) {
|
|
69
|
+
root.style.setProperty('--oa-is-dark', '1');
|
|
70
|
+
} else {
|
|
71
|
+
root.style.setProperty('--oa-is-dark', '0');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 立即执行 + 监听主题变更(v5.x 可能运行时切换主题)
|
|
76
|
+
setupThemeVariables();
|
|
77
|
+
|
|
78
|
+
// 监听 data-theme / data-theme-mode 属性变更
|
|
79
|
+
var themeObserver = new MutationObserver(function () {
|
|
80
|
+
setupThemeVariables();
|
|
81
|
+
});
|
|
82
|
+
themeObserver.observe(document.documentElement, {
|
|
83
|
+
attributes: true,
|
|
84
|
+
attributeFilter: ['data-theme', 'data-theme-mode', 'class']
|
|
85
|
+
});
|
|
86
|
+
})();
|