openclaw-openagent 1.0.9 → 1.0.11
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/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 +1553 -826
- package/dist/src/plugin-ui/ui-extension-loader/registry-regex.js +53 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- 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 +1553 -826
- package/src/plugin-ui/build.cjs +79 -4
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +92 -9
- 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 +46 -0
- package/src/plugin-ui/modules/agent-book/panel/styles.js +313 -178
- package/src/plugin-ui/modules/loader/bootstrap.js +1 -1
- package/src/plugin-ui/modules/loader/shared-state.js +54 -0
- package/src/plugin-ui/modules/remote-agent/execution-card.js +347 -124
- package/src/plugin-ui/modules/remote-agent/output-card.js +91 -31
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +97 -18
- package/src/plugin-ui/modules/remote-agent/styles.js +482 -457
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +6 -0
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +50 -5
|
@@ -14,6 +14,8 @@ import { backupFile, restoreFile } from './backup.js';
|
|
|
14
14
|
import { makeMarker, hasMarker } from './types.js';
|
|
15
15
|
// ── 常量 ──────────────────────────────────────────────────────────────────
|
|
16
16
|
const OVERRIDE_ASSET_URL = new URL('../assets/openagent-override.js', import.meta.url);
|
|
17
|
+
const ICON_ASSET_URL = new URL('../assets/icon.png', import.meta.url);
|
|
18
|
+
const BG_ASSET_URL = new URL('../assets/bg.png', import.meta.url);
|
|
17
19
|
function getOverrideAssetHash() {
|
|
18
20
|
return createHash('sha256')
|
|
19
21
|
.update(readFileSync(OVERRIDE_ASSET_URL))
|
|
@@ -113,6 +115,27 @@ const overrideScript = {
|
|
|
113
115
|
}
|
|
114
116
|
copyFileSync(OVERRIDE_ASSET_URL, dest);
|
|
115
117
|
logger.info('[ui-ext:regex] override-script: deployed openagent-override.js');
|
|
118
|
+
// Deploy icon.png alongside
|
|
119
|
+
if (existsSync(ICON_ASSET_URL)) {
|
|
120
|
+
const iconDest = join(controlUiDir, 'icon.png');
|
|
121
|
+
try {
|
|
122
|
+
copyFileSync(ICON_ASSET_URL, iconDest);
|
|
123
|
+
logger.info('[ui-ext:regex] override-script: deployed icon.png');
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
logger.warn('[ui-ext:regex] override-script: failed to deploy icon.png');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (existsSync(BG_ASSET_URL)) {
|
|
130
|
+
const bgDest = join(controlUiDir, 'bg.png');
|
|
131
|
+
try {
|
|
132
|
+
copyFileSync(BG_ASSET_URL, bgDest);
|
|
133
|
+
logger.info('[ui-ext:regex] override-script: deployed bg.png');
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
logger.warn('[ui-ext:regex] override-script: failed to deploy bg.png');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
116
139
|
return true;
|
|
117
140
|
},
|
|
118
141
|
revert(controlUiDir) {
|
|
@@ -121,12 +144,28 @@ const overrideScript = {
|
|
|
121
144
|
unlinkSync(dest);
|
|
122
145
|
logger.info('[ui-ext:regex] override-script: removed');
|
|
123
146
|
}
|
|
147
|
+
const iconDest = join(controlUiDir, 'icon.png');
|
|
148
|
+
if (existsSync(iconDest)) {
|
|
149
|
+
try {
|
|
150
|
+
unlinkSync(iconDest);
|
|
151
|
+
logger.info('[ui-ext:regex] override-script: removed icon.png');
|
|
152
|
+
}
|
|
153
|
+
catch { }
|
|
154
|
+
}
|
|
155
|
+
const bgDest = join(controlUiDir, 'bg.png');
|
|
156
|
+
if (existsSync(bgDest)) {
|
|
157
|
+
try {
|
|
158
|
+
unlinkSync(bgDest);
|
|
159
|
+
logger.info('[ui-ext:regex] override-script: removed bg.png');
|
|
160
|
+
}
|
|
161
|
+
catch { }
|
|
162
|
+
}
|
|
124
163
|
},
|
|
125
164
|
};
|
|
126
165
|
// ── Extension 2: html-script-tag ─────────────────────────────────────────
|
|
127
166
|
const htmlScriptTag = {
|
|
128
167
|
id: 'html-script-tag',
|
|
129
|
-
version:
|
|
168
|
+
version: 5,
|
|
130
169
|
alwaysApply: true,
|
|
131
170
|
apply(controlUiDir) {
|
|
132
171
|
const indexPath = join(controlUiDir, 'index.html');
|
|
@@ -136,11 +175,21 @@ const htmlScriptTag = {
|
|
|
136
175
|
}
|
|
137
176
|
let html = readFileSync(indexPath, 'utf-8');
|
|
138
177
|
const htmlMarker = `<!--openagent:${this.id}-->`;
|
|
178
|
+
const markerPattern = /(?:\/\*openagent:html-script-tag\*\/|<!--openagent:html-script-tag-->)/;
|
|
139
179
|
const overrideHash = getOverrideAssetHash();
|
|
140
180
|
const scriptTag = `${htmlMarker}<script src="./openagent-override.js?v=${overrideHash}"></script>`;
|
|
141
181
|
const markedScriptPattern = /(?:\/\*openagent:html-script-tag\*\/|<!--openagent:html-script-tag-->)<script[^>]*openagent-override[^>]*><\/script>\n?\s*/g;
|
|
142
|
-
|
|
143
|
-
|
|
182
|
+
const oldScriptPattern = /<script[^>]*openagent-override[^>]*><\/script>\n?\s*/g;
|
|
183
|
+
if (markerPattern.test(html)) {
|
|
184
|
+
let nextHtml = html.replace(markedScriptPattern, `${scriptTag}\n `);
|
|
185
|
+
if (nextHtml === html && !nextHtml.includes('openagent-override.js')) {
|
|
186
|
+
nextHtml = nextHtml.replace(markerPattern, `${scriptTag}\n `);
|
|
187
|
+
}
|
|
188
|
+
else if (nextHtml === html && nextHtml.includes('openagent-override.js')) {
|
|
189
|
+
nextHtml = nextHtml
|
|
190
|
+
.replace(oldScriptPattern, '')
|
|
191
|
+
.replace(markerPattern, `${scriptTag}\n `);
|
|
192
|
+
}
|
|
144
193
|
if (nextHtml === html) {
|
|
145
194
|
logger.debug('[ui-ext:regex] html-script-tag: already applied');
|
|
146
195
|
}
|
|
@@ -150,7 +199,6 @@ const htmlScriptTag = {
|
|
|
150
199
|
}
|
|
151
200
|
return true;
|
|
152
201
|
}
|
|
153
|
-
const oldScriptPattern = /<script[^>]*openagent-override[^>]*><\/script>\n?\s*/g;
|
|
154
202
|
if (oldScriptPattern.test(html)) {
|
|
155
203
|
html = html.replace(oldScriptPattern, '');
|
|
156
204
|
}
|
|
@@ -333,7 +381,7 @@ const toolcardRender = {
|
|
|
333
381
|
toolMessageOk = false;
|
|
334
382
|
}
|
|
335
383
|
if (toolMessageOk) {
|
|
336
|
-
const toolMessageHook = `${marker}/* openagent-media-aware-tool-message */let __openagentToolMsgCard=null;
|
|
384
|
+
const toolMessageHook = `${marker}/* openagent-media-aware-tool-message */let __openagentToolMsgCard=null;if(window.__openagentRenderToolCard){for(let __openagentI=${cardsVar}.length-1;__openagentI>=0&&!__openagentToolMsgCard;__openagentI--){let __openagentCandidate=${cardsVar}[__openagentI];if(__openagentCandidate&&(__openagentCandidate.outputText||__openagentCandidate.text))__openagentToolMsgCard=window.__openagentRenderToolCard(__openagentCandidate,${toolMessageSidebarArg})}for(let __openagentI=0;__openagentI<${cardsVar}.length&&!__openagentToolMsgCard;__openagentI++){__openagentToolMsgCard=window.__openagentRenderToolCard(${cardsVar}[__openagentI],${toolMessageSidebarArg})}}if(__openagentToolMsgCard)return ${toolMessageHtmlVar}\`<div class="\${${chatBubbleClassVar}}">\${__openagentToolMsgCard}</div>\`;`;
|
|
337
385
|
const toolMessageInsertAt = toolMessageFn.bodyStart + toolMessageReturnIdx;
|
|
338
386
|
content = content.substring(0, toolMessageInsertAt) + toolMessageHook + content.substring(toolMessageInsertAt);
|
|
339
387
|
patchedToolMessageWrapper = true;
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-openagent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenAgent channel plugin for OpenClaw",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"node": ">=22"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "tsc -p tsconfig.build.json && cp -r src/sdk dist/src/sdk && mkdir -p dist/src/plugin-ui/assets && cp src/plugin-ui/assets/openagent-override.js dist/src/plugin-ui/assets/",
|
|
50
|
+
"build": "tsc -p tsconfig.build.json && cp -r src/sdk dist/src/sdk && mkdir -p dist/src/plugin-ui/assets && cp src/plugin-ui/assets/openagent-override.js src/plugin-ui/assets/icon.png src/plugin-ui/assets/bg.png dist/src/plugin-ui/assets/",
|
|
51
51
|
"build:override": "node ./src/plugin-ui/build.cjs",
|
|
52
52
|
"watch:override": "node ./src/plugin-ui/build.cjs --watch",
|
|
53
53
|
"prepack": "npm run build:override && npm run build && npm run typecheck",
|
|
54
54
|
"typecheck": "tsc --noEmit",
|
|
55
55
|
"prepublishOnly": "npm run typecheck",
|
|
56
|
-
"test:contract": "node tests/contract.test.mjs && node tests/agent-book-batch-category.test.mjs",
|
|
56
|
+
"test:contract": "node tests/contract.test.mjs && node tests/agent-book-batch-category.test.mjs && tsx tests/ui-extension-loader.test.mts",
|
|
57
57
|
"test:smoke": "node tests/smoke.test.mjs",
|
|
58
58
|
"test": "npm run test:contract && npm run test:smoke"
|
|
59
59
|
},
|
|
Binary file
|
|
Binary file
|