openclaw-openagent 1.0.9 → 1.0.12
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/index.js +1 -1
- package/dist/src/app/remote-agent-tool.js +110 -14
- package/dist/src/app/types.d.ts +2 -2
- package/dist/src/plugin-ui/adapters/adapters/oc-2026-04.js +103 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-2026-05.js +125 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-2026-06.js +125 -0
- package/dist/src/plugin-ui/adapters/adapters/oc-unknown.js +48 -0
- package/dist/src/plugin-ui/adapters/oc-2026-04.js +103 -0
- package/dist/src/plugin-ui/adapters/oc-2026-05.js +125 -0
- package/dist/src/plugin-ui/adapters/oc-2026-06.js +125 -0
- package/dist/src/plugin-ui/adapters/oc-unknown.js +48 -0
- package/dist/src/plugin-ui/assets/bg.png +0 -0
- package/dist/src/plugin-ui/assets/icon.png +0 -0
- package/dist/src/plugin-ui/assets/openagent-override.js +2480 -1004
- package/dist/src/plugin-ui/index.d.ts +1 -1
- package/dist/src/plugin-ui/index.js +2 -2
- package/dist/src/plugin-ui/ui-extension-loader/index.d.ts +2 -1
- package/dist/src/plugin-ui/ui-extension-loader/index.js +5 -5
- package/dist/src/plugin-ui/ui-extension-loader/registry-regex.js +128 -13
- package/dist/src/plugin-ui/ui-extension-loader/types.d.ts +4 -1
- package/dist/src/state/store.d.ts +21 -0
- package/dist/src/state/store.js +54 -0
- package/dist/src/transport/oasn/oasn-invocation.d.ts +3 -0
- package/dist/src/transport/oasn/oasn-invocation.js +28 -12
- package/dist/src/transport/oasn/oasn-types.d.ts +8 -4
- package/index.ts +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +5 -4
- package/src/app/remote-agent-tool.ts +131 -16
- package/src/app/types.ts +2 -2
- package/src/plugin-ui/adapters/oc-2026-04.js +103 -0
- package/src/plugin-ui/adapters/oc-2026-05.js +125 -0
- package/src/plugin-ui/adapters/oc-2026-06.js +125 -0
- package/src/plugin-ui/adapters/oc-unknown.js +48 -0
- package/src/plugin-ui/assets/bg.png +0 -0
- package/src/plugin-ui/assets/icon.png +0 -0
- package/src/plugin-ui/assets/openagent-override.js +2480 -1004
- package/src/plugin-ui/build.cjs +309 -23
- package/src/plugin-ui/index.ts +2 -2
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +187 -14
- package/src/plugin-ui/modules/agent-book/panel/agent-card.js +26 -10
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +1 -1
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +149 -1
- package/src/plugin-ui/modules/agent-book/panel/styles.js +352 -210
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +4 -2
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +4 -1
- package/src/plugin-ui/modules/agent-book/scanner.js +17 -5
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +5 -0
- package/src/plugin-ui/modules/loader/bootstrap.js +1 -1
- package/src/plugin-ui/modules/loader/shared-state.js +278 -0
- package/src/plugin-ui/modules/remote-agent/execution-card.js +385 -124
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +5 -23
- package/src/plugin-ui/modules/remote-agent/output-card.js +97 -31
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +149 -58
- package/src/plugin-ui/modules/remote-agent/styles.js +690 -523
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +77 -3
- package/src/plugin-ui/postinstall-deploy.cjs +52 -0
- package/src/plugin-ui/ui-extension-loader/index.ts +6 -6
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +131 -14
- package/src/plugin-ui/ui-extension-loader/types.ts +5 -1
- package/src/state/store.ts +80 -0
- package/src/transport/oasn/oasn-invocation.ts +47 -12
- package/src/transport/oasn/oasn-types.ts +6 -2
- package/src/types/openclaw-plugin-sdk-media-store.d.ts +9 -0
|
@@ -103,10 +103,12 @@ registerComponent('agent-card', async (data) => {
|
|
|
103
103
|
function _clHandleTripDataSignal(payload, contextNode) {
|
|
104
104
|
if (!payload) return;
|
|
105
105
|
console.log('[trip-data] detected signal, payload:', payload.substring(0, 40));
|
|
106
|
+
const hostTextContextSelector = (typeof CL !== 'undefined' && CL.hostAdapter && CL.hostAdapter.selectors && CL.hostAdapter.selectors.textContext)
|
|
107
|
+
|| '.chat-text';
|
|
106
108
|
|
|
107
109
|
if (payload === 'file') {
|
|
108
110
|
const chatText = contextNode && contextNode.closest
|
|
109
|
-
? contextNode.closest(
|
|
111
|
+
? contextNode.closest(hostTextContextSelector)
|
|
110
112
|
: null;
|
|
111
113
|
if (chatText) {
|
|
112
114
|
chatText.dataset.clProcessed = '';
|
|
@@ -123,7 +125,7 @@ function _clHandleTripDataSignal(payload, contextNode) {
|
|
|
123
125
|
}
|
|
124
126
|
console.log('[trip-data] ✅ Card data from base64');
|
|
125
127
|
const chatText = contextNode && contextNode.closest
|
|
126
|
-
? contextNode.closest(
|
|
128
|
+
? contextNode.closest(hostTextContextSelector)
|
|
127
129
|
: null;
|
|
128
130
|
if (chatText) {
|
|
129
131
|
chatText.dataset.clProcessed = '';
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
// ── 1. CSS 注入 ──
|
|
7
7
|
|
|
8
8
|
(function injectThoughtChainStyles() {
|
|
9
|
-
|
|
9
|
+
var oldStyle = document.getElementById('cl-tools-collapse-css');
|
|
10
|
+
if (oldStyle) oldStyle.remove();
|
|
10
11
|
const style = document.createElement('style');
|
|
11
12
|
style.id = 'cl-tools-collapse-css';
|
|
13
|
+
style.setAttribute('data-openagent-style', 'thought-chain');
|
|
14
|
+
style.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
|
|
12
15
|
style.textContent = `
|
|
13
16
|
/* ── Agent Pill(通用身份标签) ── */
|
|
14
17
|
.cl-agent-pill {
|
|
@@ -5,20 +5,32 @@
|
|
|
5
5
|
|
|
6
6
|
// CL.clScanCount lives on CL.clScanCount
|
|
7
7
|
|
|
8
|
+
function _clIsInsideNativeToolHost(node) {
|
|
9
|
+
var adapter = CL && CL.hostAdapter;
|
|
10
|
+
var cur = node;
|
|
11
|
+
var hops = 0;
|
|
12
|
+
while (cur && cur !== document.body && hops < 12) {
|
|
13
|
+
if (adapter && adapter.isToolLikeShell && adapter.isToolLikeShell(cur)) return true;
|
|
14
|
+
cur = cur.parentElement;
|
|
15
|
+
hops++;
|
|
16
|
+
}
|
|
17
|
+
return !!(node && node.closest && node.closest('details'));
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
function _clScan() {
|
|
9
21
|
CL.clScanCount++;
|
|
10
22
|
|
|
11
23
|
// ── 0.5 清理标记 → 显示为 @agentName ──
|
|
12
|
-
// 新格式: {openagent_call_remote_agent:agent_id="...",agent_name="...",instruction="..."}
|
|
24
|
+
// 新格式: {openagent_call_remote_agent:agent_id="...",agent_name="...",agent_bio="...",instruction="..."}
|
|
13
25
|
// 旧格式: {openagent:agent_id="...",agent_name="..."}
|
|
14
26
|
// 两种都要匹配清理;这里只处理普通聊天气泡,不处理 ToolCard。
|
|
15
27
|
var CL_MENTION_STYLE = '';
|
|
16
28
|
document.querySelectorAll('.chat-bubble').forEach(function(el) {
|
|
17
29
|
if (el.dataset.clMarkerCleaned) return;
|
|
18
|
-
if (el
|
|
30
|
+
if (_clIsInsideNativeToolHost(el)) return;
|
|
19
31
|
|
|
20
32
|
var text = el.textContent || '';
|
|
21
|
-
var rawRegex = /\{openagent(?:_call_remote_agent)?:agent_id="([^"]*)",agent_name="([^"]*)"(?:,
|
|
33
|
+
var rawRegex = /\{openagent(?:_call_remote_agent)?:agent_id="([^"]*)",agent_name="([^"]*)"(?:,[^{}]*)?\}\s*/g;
|
|
22
34
|
if (!rawRegex.test(text)) return;
|
|
23
35
|
|
|
24
36
|
if (el.querySelector('.cl-remote-agent-card')) {
|
|
@@ -26,7 +38,7 @@ function _clScan() {
|
|
|
26
38
|
return; // 包含活 DOM,跳过 innerHTML 重写
|
|
27
39
|
}
|
|
28
40
|
|
|
29
|
-
var htmlRegex = /\{openagent(?:_call_remote_agent)?:agent_id=(?:"|")([^&"]*)(?:"|"),agent_name=(?:"|")([^&"]*)(?:"|")(?:,
|
|
41
|
+
var htmlRegex = /\{openagent(?:_call_remote_agent)?:agent_id=(?:"|")([^&"]*)(?:"|"),agent_name=(?:"|")([^&"]*)(?:"|")(?:,[^{}]*)?\}\s*/g;
|
|
30
42
|
if (CL && typeof CL.diagHtmlRewrite === 'function') {
|
|
31
43
|
CL.diagHtmlRewrite('scanner.marker.before', el, { scan: CL.clScanCount });
|
|
32
44
|
}
|
|
@@ -61,7 +73,7 @@ function _clScan() {
|
|
|
61
73
|
if (mentionedAgents.length > 0) {
|
|
62
74
|
document.querySelectorAll('.chat-bubble').forEach(function(el) {
|
|
63
75
|
if (el.dataset.clAgentStyled) return;
|
|
64
|
-
if (el
|
|
76
|
+
if (_clIsInsideNativeToolHost(el)) return;
|
|
65
77
|
|
|
66
78
|
var text = el.textContent || '';
|
|
67
79
|
var html = el.innerHTML;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// ── 1. CSS 注入 ──
|
|
2
|
+
var _oldTripCSS = document.getElementById('openagent-trip-card-styles');
|
|
3
|
+
if (_oldTripCSS) _oldTripCSS.remove();
|
|
2
4
|
const _tripCSS = document.createElement('style');
|
|
5
|
+
_tripCSS.id = 'openagent-trip-card-styles';
|
|
6
|
+
_tripCSS.setAttribute('data-openagent-style', 'trip-card');
|
|
7
|
+
_tripCSS.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
|
|
3
8
|
_tripCSS.textContent = `
|
|
4
9
|
/* ── 行程文字:普通文字灰色,特殊标注(粗体/链接/标题)黑色 ── */
|
|
5
10
|
.trip-styled li, .trip-styled p { color: #888 !important; }
|
|
@@ -5,7 +5,7 @@ var _clObserverTarget = null;
|
|
|
5
5
|
|
|
6
6
|
const _clObserver = new MutationObserver(() => {
|
|
7
7
|
if (_clDebounceTimer) clearTimeout(_clDebounceTimer);
|
|
8
|
-
_clDebounceTimer = setTimeout(_debouncedClScan,
|
|
8
|
+
_clDebounceTimer = setTimeout(_debouncedClScan, 300); // Debounce to reduce DOM churn feedback loops
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
function _debouncedClScan() {
|
|
@@ -31,6 +31,12 @@ const CL = {
|
|
|
31
31
|
handleDelegateWsEvent: function(msg) {},
|
|
32
32
|
processCustomCards: function(bubble) {},
|
|
33
33
|
|
|
34
|
+
// ── Host 版本(构建时注入,fallback 运行时检测)──
|
|
35
|
+
hostVersion: '__OPENCLAW_HOST_VERSION__',
|
|
36
|
+
|
|
37
|
+
// ── Override 构建标识(构建时注入,用于缓存自检)──
|
|
38
|
+
buildId: '__OPENAGENT_BUILD_ID__',
|
|
39
|
+
|
|
34
40
|
// ── 配置 ──
|
|
35
41
|
OPENAGENT_API: 'https://api.openagent.club',
|
|
36
42
|
AUTH_API: '/plugins/openagent', // Proxied via Gateway registerHttpRoute (see src/proxy/auth-proxy.ts)
|
|
@@ -39,6 +45,252 @@ const CL = {
|
|
|
39
45
|
CACHE_TTL: 30000,
|
|
40
46
|
};
|
|
41
47
|
|
|
48
|
+
function _clFindOverrideScript() {
|
|
49
|
+
try {
|
|
50
|
+
var scripts = document.querySelectorAll('script[src*="openagent-override.js"]');
|
|
51
|
+
return scripts.length ? scripts[scripts.length - 1] : null;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _clReadOverrideScriptVersionFromDocument() {
|
|
58
|
+
try {
|
|
59
|
+
var script = _clFindOverrideScript();
|
|
60
|
+
if (!script) return '';
|
|
61
|
+
var src = script.getAttribute('src') || '';
|
|
62
|
+
var url = new URL(src, window.location.href);
|
|
63
|
+
return url.searchParams.get('v') || '';
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function _clResolveControlUiIndexUrl() {
|
|
70
|
+
try {
|
|
71
|
+
var script = _clFindOverrideScript();
|
|
72
|
+
if (script) {
|
|
73
|
+
var scriptUrl = new URL(script.src || script.getAttribute('src'), window.location.href);
|
|
74
|
+
return new URL('./', scriptUrl.href).href;
|
|
75
|
+
}
|
|
76
|
+
} catch (e) {}
|
|
77
|
+
try {
|
|
78
|
+
var url = new URL(window.location.href);
|
|
79
|
+
url.hash = '';
|
|
80
|
+
url.search = '';
|
|
81
|
+
return url.href;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return '/';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _clExtractOverrideScriptVersionFromHtml(html) {
|
|
88
|
+
var match = String(html || '').match(/openagent-override\.js\?v=([A-Za-z0-9._-]+)/);
|
|
89
|
+
return match ? match[1] : '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function _clInstallOverrideUpdateCheck() {
|
|
93
|
+
if (window.__openagentOverrideUpdateCheckInstalled) return;
|
|
94
|
+
window.__openagentOverrideUpdateCheckInstalled = true;
|
|
95
|
+
|
|
96
|
+
var currentVersion = _clReadOverrideScriptVersionFromDocument() || CL.buildId || '';
|
|
97
|
+
var storageKey = 'openagent.overrideScriptVersion.v1';
|
|
98
|
+
var reloadKey = 'openagent.overrideReloadedVersion.v1';
|
|
99
|
+
try {
|
|
100
|
+
document.documentElement.setAttribute('data-openagent-build-id', CL.buildId || 'unknown');
|
|
101
|
+
if (currentVersion) document.documentElement.setAttribute('data-openagent-script-version', currentVersion);
|
|
102
|
+
} catch (e) {}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
if (window.localStorage && currentVersion) {
|
|
106
|
+
window.localStorage.setItem(storageKey, currentVersion);
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {}
|
|
109
|
+
|
|
110
|
+
function reloadForVersion(nextVersion) {
|
|
111
|
+
if (!nextVersion || nextVersion === currentVersion) return;
|
|
112
|
+
try {
|
|
113
|
+
if (window.sessionStorage && window.sessionStorage.getItem(reloadKey) === nextVersion) return;
|
|
114
|
+
if (window.sessionStorage) window.sessionStorage.setItem(reloadKey, nextVersion);
|
|
115
|
+
} catch (e) {}
|
|
116
|
+
console.info('[openagent] override updated, reloading Control UI', currentVersion, '→', nextVersion);
|
|
117
|
+
window.location.reload();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function checkLatestOverrideVersion() {
|
|
121
|
+
if (document.visibilityState && document.visibilityState === 'hidden') return;
|
|
122
|
+
try {
|
|
123
|
+
var res = await fetch(_clResolveControlUiIndexUrl(), { cache: 'no-store' });
|
|
124
|
+
if (!res || !res.ok) return;
|
|
125
|
+
var latestVersion = _clExtractOverrideScriptVersionFromHtml(await res.text());
|
|
126
|
+
reloadForVersion(latestVersion);
|
|
127
|
+
} catch (e) {}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setTimeout(checkLatestOverrideVersion, 3000);
|
|
131
|
+
setInterval(checkLatestOverrideVersion, 60000);
|
|
132
|
+
window.addEventListener('focus', checkLatestOverrideVersion);
|
|
133
|
+
document.addEventListener('visibilitychange', function() {
|
|
134
|
+
if (!document.hidden) checkLatestOverrideVersion();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_clInstallOverrideUpdateCheck();
|
|
139
|
+
|
|
140
|
+
// ── 版本解析与比较(供 execution-card V2 分支使用)──
|
|
141
|
+
|
|
142
|
+
function _clParseHostVersion(v) {
|
|
143
|
+
if (!v) return [0, 0, 0];
|
|
144
|
+
var base = String(v).split('-')[0];
|
|
145
|
+
var parts = base.split('.');
|
|
146
|
+
if (parts.length !== 3) return [0, 0, 0];
|
|
147
|
+
var y = parseInt(parts[0], 10);
|
|
148
|
+
var m = parseInt(parts[1], 10);
|
|
149
|
+
var d = parseInt(parts[2], 10);
|
|
150
|
+
if (isNaN(y) || isNaN(m) || isNaN(d)) return [0, 0, 0];
|
|
151
|
+
return [y, m, d];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function _clIsHostVersionGte(minVer) {
|
|
155
|
+
if (CL.hostVersionSource !== 'exact' && CL.hostVersionSource !== 'script' && CL.hostVersionSource !== 'runtime') {
|
|
156
|
+
_clRefreshHostVersionFromRuntime();
|
|
157
|
+
}
|
|
158
|
+
var cur = _clParseHostVersion(CL.hostVersion || '');
|
|
159
|
+
var min = _clParseHostVersion(minVer);
|
|
160
|
+
for (var i = 0; i < 3; i++) {
|
|
161
|
+
if (cur[i] > min[i]) return true;
|
|
162
|
+
if (cur[i] < min[i]) return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function _clResolveHostProfile(version) {
|
|
168
|
+
var parsed = _clParseHostVersion(version || '');
|
|
169
|
+
if (parsed[0] === 2026 && parsed[1] === 4) return 'oc-2026-04';
|
|
170
|
+
if (parsed[0] === 2026 && parsed[1] === 5) return 'oc-2026-05';
|
|
171
|
+
if (parsed[0] === 2026 && parsed[1] === 6) return 'oc-2026-06';
|
|
172
|
+
return 'oc-unknown';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function _clNormalizeHostVersion(value) {
|
|
176
|
+
var match = String(value || '').match(/20\d{2}\.\d{1,2}\.\d{1,2}(?:-[A-Za-z0-9._-]+)?/);
|
|
177
|
+
return match ? match[0] : '';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function _clGetByPath(root, path) {
|
|
181
|
+
var cur = root;
|
|
182
|
+
for (var i = 0; i < path.length; i++) {
|
|
183
|
+
if (!cur) return '';
|
|
184
|
+
cur = cur[path[i]];
|
|
185
|
+
}
|
|
186
|
+
return cur;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function _clReadHostVersionFromRuntime() {
|
|
190
|
+
try {
|
|
191
|
+
var scripts = document.querySelectorAll('script[data-openagent-host-version]');
|
|
192
|
+
for (var i = scripts.length - 1; i >= 0; i--) {
|
|
193
|
+
var scriptVersion = _clNormalizeHostVersion(scripts[i].getAttribute('data-openagent-host-version'));
|
|
194
|
+
if (scriptVersion) return { version: scriptVersion, source: 'script' };
|
|
195
|
+
}
|
|
196
|
+
} catch (e) {}
|
|
197
|
+
|
|
198
|
+
var globals = [
|
|
199
|
+
window.__OPENCLAW_HOST_VERSION__,
|
|
200
|
+
window.__OPENCLAW_VERSION__,
|
|
201
|
+
window.__openclawVersion,
|
|
202
|
+
window.openclawVersion,
|
|
203
|
+
];
|
|
204
|
+
for (var g = 0; g < globals.length; g++) {
|
|
205
|
+
var globalVersion = _clNormalizeHostVersion(globals[g]);
|
|
206
|
+
if (globalVersion) return { version: globalVersion, source: 'runtime' };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
var metaVersion = _clNormalizeHostVersion(
|
|
211
|
+
document.querySelector('meta[name="openclaw-version"],meta[name="openclaw:version"]')?.getAttribute('content')
|
|
212
|
+
);
|
|
213
|
+
if (metaVersion) return { version: metaVersion, source: 'runtime' };
|
|
214
|
+
} catch (e) {}
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
var app = document.querySelector('openclaw-app');
|
|
218
|
+
if (app) {
|
|
219
|
+
var paths = [
|
|
220
|
+
['runtime', 'version'],
|
|
221
|
+
['hello', 'server', 'version'],
|
|
222
|
+
['hello', 'version'],
|
|
223
|
+
['client', 'hello', 'server', 'version'],
|
|
224
|
+
['client', 'version'],
|
|
225
|
+
['version'],
|
|
226
|
+
['appVersion'],
|
|
227
|
+
];
|
|
228
|
+
for (var p = 0; p < paths.length; p++) {
|
|
229
|
+
var appVersion = _clNormalizeHostVersion(_clGetByPath(app, paths[p]));
|
|
230
|
+
if (appVersion) return { version: appVersion, source: 'runtime' };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} catch (e) {}
|
|
234
|
+
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function _clApplyHostVersion(version, source) {
|
|
239
|
+
CL.hostVersion = version || '2026.3.0';
|
|
240
|
+
CL.hostVersionSource = source || 'fallback';
|
|
241
|
+
CL.hostProfile = _clResolveHostProfile(CL.hostVersion);
|
|
242
|
+
try {
|
|
243
|
+
document.documentElement.setAttribute('data-openagent-host-version', CL.hostVersion || 'unknown');
|
|
244
|
+
document.documentElement.setAttribute('data-openagent-host-profile', CL.hostProfile);
|
|
245
|
+
document.documentElement.setAttribute('data-openagent-host-version-source', CL.hostVersionSource);
|
|
246
|
+
} catch (e) {}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function _clRefreshHostVersionFromRuntime() {
|
|
250
|
+
var detected = _clReadHostVersionFromRuntime();
|
|
251
|
+
if (!detected) return false;
|
|
252
|
+
if (detected.version !== CL.hostVersion || detected.source !== CL.hostVersionSource) {
|
|
253
|
+
_clApplyHostVersion(detected.version, detected.source);
|
|
254
|
+
console.log('[cl-version] detected via ' + detected.source + ': ' + detected.version);
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function _clScheduleHostVersionRefresh() {
|
|
260
|
+
var attempts = 0;
|
|
261
|
+
var timer = setInterval(function() {
|
|
262
|
+
attempts++;
|
|
263
|
+
if (_clRefreshHostVersionFromRuntime() || attempts >= 20) {
|
|
264
|
+
clearInterval(timer);
|
|
265
|
+
}
|
|
266
|
+
}, 500);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
var _clInitialExactVersion = _clNormalizeHostVersion(CL.hostVersion);
|
|
270
|
+
if (_clInitialExactVersion) {
|
|
271
|
+
_clApplyHostVersion(_clInitialExactVersion, 'exact');
|
|
272
|
+
} else if (!_clRefreshHostVersionFromRuntime()) {
|
|
273
|
+
// ─ 运行时 fallback:只做版本族保守判断,避免把 2026.5 误判为 2026.6.9 ──
|
|
274
|
+
// v5.x (2026.5+) 有 data-theme / --glass-*;v4.x 有 data-theme-mode / --vscode-*。
|
|
275
|
+
try {
|
|
276
|
+
var cs = getComputedStyle(document.documentElement);
|
|
277
|
+
if (document.documentElement.hasAttribute('data-theme-mode')
|
|
278
|
+
|| cs.getPropertyValue('--vscode-editor-background').trim()) {
|
|
279
|
+
_clApplyHostVersion('2026.4.0', 'feature-fallback');
|
|
280
|
+
} else if (document.documentElement.hasAttribute('data-theme')
|
|
281
|
+
|| cs.getPropertyValue('--glass-surface').trim()
|
|
282
|
+
|| cs.getPropertyValue('--kn-bg-primary').trim()) {
|
|
283
|
+
_clApplyHostVersion('2026.5.0', 'feature-fallback');
|
|
284
|
+
} else {
|
|
285
|
+
_clApplyHostVersion('2026.3.0', 'feature-fallback');
|
|
286
|
+
}
|
|
287
|
+
console.log('[cl-version] fallback via DOM/CSS features: ' + CL.hostVersion);
|
|
288
|
+
} catch (e) {
|
|
289
|
+
_clApplyHostVersion('2026.3.0', 'feature-fallback');
|
|
290
|
+
}
|
|
291
|
+
_clScheduleHostVersionRefresh();
|
|
292
|
+
}
|
|
293
|
+
|
|
42
294
|
// 暴露到 window 供控制台调试/测试
|
|
43
295
|
window.__CL = CL;
|
|
44
296
|
|
|
@@ -72,6 +324,28 @@ CL._saveAgentIdentityCache = function() {
|
|
|
72
324
|
} catch (err) {}
|
|
73
325
|
};
|
|
74
326
|
|
|
327
|
+
CL.pickAgentIdentityDescription = function(agent) {
|
|
328
|
+
if (!agent || typeof agent !== 'object') return '';
|
|
329
|
+
var keys = [
|
|
330
|
+
'agent_bio',
|
|
331
|
+
'agentBio',
|
|
332
|
+
'bio',
|
|
333
|
+
'description',
|
|
334
|
+
'desc',
|
|
335
|
+
'agent_description',
|
|
336
|
+
'agentDescription',
|
|
337
|
+
'MOM',
|
|
338
|
+
'mom',
|
|
339
|
+
'introduction',
|
|
340
|
+
'summary'
|
|
341
|
+
];
|
|
342
|
+
for (var i = 0; i < keys.length; i++) {
|
|
343
|
+
var value = agent[keys[i]];
|
|
344
|
+
if (typeof value === 'string' && value.trim()) return value.trim();
|
|
345
|
+
}
|
|
346
|
+
return '';
|
|
347
|
+
};
|
|
348
|
+
|
|
75
349
|
CL.storeAgentIdentity = function(agent, fallbackName) {
|
|
76
350
|
if (!agent || typeof agent !== 'object') return null;
|
|
77
351
|
CL._loadAgentIdentityCache();
|
|
@@ -80,12 +354,16 @@ CL.storeAgentIdentity = function(agent, fallbackName) {
|
|
|
80
354
|
agent.user_id || agent.userId || agent.identifier || agent.tim_user_id || agent.timUserId || '';
|
|
81
355
|
var name = agent.name || agent.agent_name || agent.agentName || fallbackName || '';
|
|
82
356
|
var avatar = agent.avatar || agent.avatar_url || agent.avatarUrl || agent.image || agent.logo || agent.photo || '';
|
|
357
|
+
var bio = CL.pickAgentIdentityDescription(agent);
|
|
83
358
|
var record = {
|
|
84
359
|
id: id,
|
|
85
360
|
agent_id: id,
|
|
86
361
|
tag: agent.tag || id,
|
|
87
362
|
name: name,
|
|
88
363
|
avatar: avatar || null,
|
|
364
|
+
bio: bio,
|
|
365
|
+
description: agent.description || bio || '',
|
|
366
|
+
MOM: agent.MOM || agent.mom || '',
|
|
89
367
|
};
|
|
90
368
|
|
|
91
369
|
var keys = [id, record.tag, name, fallbackName].filter(Boolean);
|