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
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import { registerTools, registerHooks } from './src/app/index.js';
14
14
  import { installOpenagentVerbosePreflight } from './src/app/verbose-preflight.js';
15
15
  // guard.ts removed — unhandled rejections fixed at source in ws-frame.ts send()
16
16
  import { setOpenagentPluginRuntime } from './src/runtime/plugin-runtime.js';
17
+ import { startOpenagentUpdateChecker } from './src/runtime/update-checker.js';
17
18
  import { injectControlUiOverride } from './src/plugin-ui/index.js';
18
19
  import { createAuthProxyHandler } from './src/proxy/auth-proxy.js';
19
20
  import { logger } from './src/util/logger.js';
@@ -104,6 +105,7 @@ export default {
104
105
  injectControlUiOverride(api.runtime?.version).catch(err => {
105
106
  logger.warn(`[entry] Control UI injection failed: ${err.message}`);
106
107
  });
108
+ startOpenagentUpdateChecker();
107
109
  logger.info('[entry] Tools + hooks registered (full mode)');
108
110
  _fullModeRegistered = true;
109
111
  },
@@ -31,6 +31,15 @@ export declare const OpenagentConfigSchema: z.ZodObject<{
31
31
  }>>>;
32
32
  api_base: z.ZodOptional<z.ZodString>;
33
33
  access_api_base: z.ZodOptional<z.ZodString>;
34
+ update_policy: z.ZodOptional<z.ZodEnum<{
35
+ auto: "auto";
36
+ off: "off";
37
+ notify: "notify";
38
+ }>>;
39
+ update_check: z.ZodOptional<z.ZodBoolean>;
40
+ auto_update: z.ZodOptional<z.ZodBoolean>;
41
+ update_channel: z.ZodOptional<z.ZodString>;
42
+ update_dist_tag: z.ZodOptional<z.ZodString>;
34
43
  accounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
35
44
  name: z.ZodOptional<z.ZodString>;
36
45
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -13,6 +13,7 @@ import { z } from 'zod';
13
13
  // Zod config schema
14
14
  // ---------------------------------------------------------------------------
15
15
  const transportSchema = z.enum(['oasn', 'tim']).default('oasn');
16
+ const updatePolicySchema = z.enum(['notify', 'auto', 'off']).optional();
16
17
  const openagentAccountSchema = z.object({
17
18
  name: z.string().optional(),
18
19
  enabled: z.boolean().optional(),
@@ -30,5 +31,10 @@ export const OpenagentConfigSchema = openagentAccountSchema.extend({
30
31
  transport: transportSchema.optional(),
31
32
  api_base: z.string().optional(),
32
33
  access_api_base: z.string().optional(),
34
+ update_policy: updatePolicySchema,
35
+ update_check: z.boolean().optional(),
36
+ auto_update: z.boolean().optional(),
37
+ update_channel: z.string().optional(),
38
+ update_dist_tag: z.string().optional(),
33
39
  accounts: z.record(z.string(), openagentAccountSchema).optional(),
34
40
  });
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * ActionExecutor — Triggers OpenClaw agent turn via CLI
3
3
  *
4
- * Uses `openclaw agent` to inject inbound messages.
5
- * Agent replies via openagent_send_message tool call.
4
+ * Legacy shell-out pipeline retained for type compatibility.
5
+ * Current runtime dispatches inbound messages without invoking the OpenClaw CLI.
6
6
  */
7
7
  import type { ChannelDelta } from './types.js';
8
8
  export declare class ActionExecutor {
9
9
  private accountId;
10
- private openclawBin;
11
10
  setAccountId(accountId: string): void;
12
11
  handleDelta(delta: ChannelDelta): Promise<void>;
13
12
  private _formatDeltaText;
@@ -1,45 +1,18 @@
1
1
  /**
2
2
  * ActionExecutor — Triggers OpenClaw agent turn via CLI
3
3
  *
4
- * Uses `openclaw agent` to inject inbound messages.
5
- * Agent replies via openagent_send_message tool call.
4
+ * Legacy shell-out pipeline retained for type compatibility.
5
+ * Current runtime dispatches inbound messages without invoking the OpenClaw CLI.
6
6
  */
7
- import { execFile } from 'node:child_process';
8
- import { promisify } from 'node:util';
9
7
  import { logger } from '../util/logger.js';
10
- const execFileAsync = promisify(execFile);
11
8
  export class ActionExecutor {
12
9
  accountId = 'default';
13
- openclawBin = 'openclaw';
14
10
  setAccountId(accountId) {
15
11
  this.accountId = accountId || 'default';
16
12
  }
17
13
  async handleDelta(delta) {
18
- const text = this._formatDeltaText(delta);
19
- logger.info(`[executor] INBOUND ch=${delta.channelId} msgs=${delta.messageCount} mention=${delta.hasMention}`);
20
- try {
21
- const args = [
22
- 'agent',
23
- '--agent', 'main',
24
- '--channel', 'openagent',
25
- '--message', text,
26
- '--session-id', `openagent:${delta.channelId}`,
27
- '--json',
28
- ];
29
- const { stdout, stderr } = await execFileAsync(this.openclawBin, args, {
30
- timeout: 120_000,
31
- env: { ...process.env },
32
- });
33
- if (stderr) {
34
- logger.debug(`[executor] stderr: ${stderr.substring(0, 500)}`);
35
- }
36
- if (stdout) {
37
- logger.info(`[executor] Agent turn completed for ch=${delta.channelId}`);
38
- }
39
- }
40
- catch (err) {
41
- logger.error(`[executor] Agent turn failed: ${err.message}`);
42
- }
14
+ logger.warn(`[executor] legacy ActionExecutor disabled account=${this.accountId} `
15
+ + `ch=${delta.channelId} msgs=${delta.messageCount} mention=${delta.hasMention}`);
43
16
  }
44
17
  _formatDeltaText(delta) {
45
18
  const { channelId, messages, hasMention } = delta;
@@ -2,7 +2,7 @@
2
2
  * OpenAgent UI Override — Auto-generated, do not edit directly!
3
3
  *
4
4
  * Source: src/plugin-ui/modules/
5
- * Built: 2026-07-06T03:23:32.989Z
5
+ * Built: 2026-07-07T02:49:55.071Z
6
6
  *
7
7
  * To modify, edit the source modules and run:
8
8
  * npm run build:override
@@ -52,7 +52,7 @@ const CL = {
52
52
  hostVersion: '__OPENCLAW_HOST_VERSION__',
53
53
 
54
54
  // ── Override 构建标识(构建时注入,用于缓存自检)──
55
- buildId: "65bf8968e270",
55
+ buildId: "ae54b0a5de1b",
56
56
 
57
57
  // ── 配置 ──
58
58
  OPENAGENT_API: 'https://api.openagent.club',
@@ -2118,6 +2118,13 @@ function injectStyles() {
2118
2118
  padding: 14px;
2119
2119
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
2120
2120
  box-sizing: border-box;
2121
+ scrollbar-width: none;
2122
+ -ms-overflow-style: none;
2123
+ }
2124
+ .openagent-agent-panel::-webkit-scrollbar {
2125
+ width: 0;
2126
+ height: 0;
2127
+ display: none;
2121
2128
  }
2122
2129
  .openagent-agent-panel.visible {
2123
2130
  display: flex;
@@ -2357,21 +2364,13 @@ function injectStyles() {
2357
2364
  flex-direction: column;
2358
2365
  min-height: 0;
2359
2366
  max-height: min(56vh, 451px);
2360
- scrollbar-width: thin;
2361
- scrollbar-color: #ddd transparent;
2367
+ scrollbar-width: none;
2368
+ -ms-overflow-style: none;
2362
2369
  }
2363
2370
  .openagent-agent-list::-webkit-scrollbar {
2364
- width: 4px;
2365
- }
2366
- .openagent-agent-list::-webkit-scrollbar-track {
2367
- background: transparent;
2368
- }
2369
- .openagent-agent-list::-webkit-scrollbar-thumb {
2370
- background: #ddd;
2371
- border-radius: 2px;
2372
- }
2373
- .openagent-agent-list::-webkit-scrollbar-thumb:hover {
2374
- background: #bbb;
2371
+ width: 0;
2372
+ height: 0;
2373
+ display: none;
2375
2374
  }
2376
2375
 
2377
2376
  .openagent-agent-section {
@@ -4923,7 +4922,13 @@ margin: 0 8px; position: relative; top: -1px;
4923
4922
  .trip-img-card {
4924
4923
  display: flex; flex-direction: row; gap: 6px;
4925
4924
  overflow-x: auto; padding: 8px 0; margin-left: 20px;
4926
- scrollbar-width: thin;
4925
+ scrollbar-width: none;
4926
+ -ms-overflow-style: none;
4927
+ }
4928
+ .trip-img-card::-webkit-scrollbar {
4929
+ width: 0;
4930
+ height: 0;
4931
+ display: none;
4927
4932
  }
4928
4933
  .trip-img-item {
4929
4934
  position: relative; width: 191px; height: 100px; border-radius: 8px;
@@ -6983,6 +6988,14 @@ function _clScan() {
6983
6988
  ' overflow-x: auto;',
6984
6989
  ' white-space: pre-wrap;',
6985
6990
  ' word-break: break-all;',
6991
+ ' scrollbar-width: none;',
6992
+ ' -ms-overflow-style: none;',
6993
+ '}',
6994
+ '.cl-output-card > .cl-thought-chain-content pre::-webkit-scrollbar,',
6995
+ '.cl-output-card > .cl-thought-chain-content code::-webkit-scrollbar {',
6996
+ ' width: 0;',
6997
+ ' height: 0;',
6998
+ ' display: none;',
6986
6999
  '}',
6987
7000
  // V2 output card:统一 border/padding 与 execution card 一致
6988
7001
  '.cl-exec-v2.cl-output-card {',
@@ -7225,8 +7238,7 @@ function _clScan() {
7225
7238
  '.cl-exec-v2 .cl-exec-agent-avatar-v2 {',
7226
7239
  ' width: 68px !important;',
7227
7240
  ' height: 68px !important;',
7228
- ' border-radius: 50% !important;',
7229
- ' object-fit: cover;',
7241
+ ' object-fit: contain;',
7230
7242
  ' flex-shrink: 0;',
7231
7243
  '}',
7232
7244
 
@@ -11142,9 +11154,103 @@ function _startClObserver() {
11142
11154
  _clObserverTarget = document.querySelector('openclaw-app') || document.body;
11143
11155
  _clObserver.observe(_clObserverTarget, { childList: true, subtree: true });
11144
11156
  setTimeout(_debouncedClScan, 2000);
11157
+ setTimeout(_clCheckPluginUpdateStatus, 5000);
11145
11158
  /* muted */ void 0;
11146
11159
  }
11147
11160
 
11161
+ function _clCheckPluginUpdateStatus() {
11162
+ fetch('/plugins/openagent/update-status', { cache: 'no-store' })
11163
+ .then(function(res) {
11164
+ if (!res.ok) return null;
11165
+ return res.json();
11166
+ })
11167
+ .then(function(status) {
11168
+ if (!status || !status.updateAvailable) return;
11169
+ _clShowPluginUpdateNotice(status);
11170
+ })
11171
+ .catch(function() {});
11172
+ }
11173
+
11174
+ function _clShowPluginUpdateNotice(status) {
11175
+ var latestVersion = String(status.latestVersion || '').trim();
11176
+ var currentVersion = String(status.currentVersion || '').trim();
11177
+ var dismissKey = 'openagent-update-dismissed-' + latestVersion;
11178
+ try {
11179
+ if (latestVersion && localStorage.getItem(dismissKey) === '1') return;
11180
+ } catch (e) {}
11181
+
11182
+ var existing = document.getElementById('openagent-update-notice');
11183
+ if (existing) existing.remove();
11184
+
11185
+ var notice = document.createElement('div');
11186
+ notice.id = 'openagent-update-notice';
11187
+ notice.style.cssText = [
11188
+ 'position:fixed',
11189
+ 'right:18px',
11190
+ 'bottom:18px',
11191
+ 'z-index:2147483647',
11192
+ 'max-width:360px',
11193
+ 'padding:14px 16px',
11194
+ 'border:1px solid rgba(0,0,0,0.08)',
11195
+ 'border-radius:12px',
11196
+ 'background:#fff',
11197
+ 'box-shadow:0 12px 32px rgba(15,23,42,0.16)',
11198
+ 'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif',
11199
+ 'color:#1f2937',
11200
+ 'font-size:13px',
11201
+ 'line-height:1.5'
11202
+ ].join(';');
11203
+
11204
+ var title = document.createElement('div');
11205
+ title.textContent = 'OpenAgent 有新版本 ' + latestVersion;
11206
+ title.style.cssText = 'font-weight:600;font-size:14px;margin-right:22px;margin-bottom:4px;';
11207
+ notice.appendChild(title);
11208
+
11209
+ var body = document.createElement('div');
11210
+ var command = String(status.installCommand || 'npx -y openclaw-openagent-cli update');
11211
+ body.textContent = currentVersion ? ('当前版本 ' + currentVersion + ',运行命令完成更新。') : '运行命令完成更新。';
11212
+ body.style.cssText = 'color:#4b5563;margin-bottom:10px;';
11213
+ notice.appendChild(body);
11214
+
11215
+ var code = document.createElement('code');
11216
+ code.textContent = command;
11217
+ code.style.cssText = 'display:block;white-space:normal;word-break:break-all;background:#f6f7f9;border-radius:8px;padding:8px 10px;color:#111827;';
11218
+ notice.appendChild(code);
11219
+
11220
+ var actions = document.createElement('div');
11221
+ actions.style.cssText = 'display:flex;justify-content:flex-end;gap:8px;margin-top:10px;';
11222
+ var copy = document.createElement('button');
11223
+ copy.type = 'button';
11224
+ copy.textContent = '复制命令';
11225
+ copy.style.cssText = 'border:1px solid #d1d5db;background:#fff;border-radius:8px;padding:6px 10px;cursor:pointer;color:#374151;';
11226
+ copy.onclick = function() {
11227
+ try {
11228
+ navigator.clipboard.writeText(command);
11229
+ copy.textContent = '已复制';
11230
+ } catch (e) {}
11231
+ };
11232
+ actions.appendChild(copy);
11233
+
11234
+ var close = document.createElement('button');
11235
+ close.type = 'button';
11236
+ close.textContent = '关闭';
11237
+ close.style.cssText = 'border:0;background:#111827;color:#fff;border-radius:8px;padding:6px 10px;cursor:pointer;';
11238
+ close.onclick = function() {
11239
+ try {
11240
+ if (latestVersion) localStorage.setItem(dismissKey, '1');
11241
+ } catch (e) {}
11242
+ notice.remove();
11243
+ };
11244
+ actions.appendChild(close);
11245
+ notice.appendChild(actions);
11246
+
11247
+ if (status.policy === 'auto' && status.autoUpdateSupported === false) {
11248
+ body.textContent = '自动更新受 OpenClaw 安全策略限制,请运行命令完成更新。';
11249
+ }
11250
+
11251
+ document.body.appendChild(notice);
11252
+ }
11253
+
11148
11254
  if (document.readyState === 'loading') {
11149
11255
  document.addEventListener('DOMContentLoaded', _startClObserver);
11150
11256
  } else {
@@ -17,6 +17,7 @@ import fs from 'node:fs';
17
17
  import nodePath from 'node:path';
18
18
  import { logger } from '../util/logger.js';
19
19
  import { registry } from '../runtime/registry.js';
20
+ import { getOpenagentUpdateStatus } from '../runtime/update-checker.js';
20
21
  import { isUnconfiguredOasnApiBase } from '../auth/config.js';
21
22
  import { resolveOasnRelativeUrl } from '../util/url-resolver.js';
22
23
  /** TIM 路径默认上游(兼容旧版) */
@@ -90,6 +91,10 @@ export function createAuthProxyHandler() {
90
91
  if (targetPath.startsWith('/media/')) {
91
92
  return serveLocalMedia(targetPath, res);
92
93
  }
94
+ if (targetPath === '/update-status') {
95
+ writeJson(res, 200, getOpenagentUpdateStatus());
96
+ return true;
97
+ }
93
98
  // v3.9+ 双轨抽象:上游按当前 transport 切换(OASN → api.oasn.ai;TIM → auth.ai-talk.live)
94
99
  const method = req.method ?? 'GET';
95
100
  const rt = registry.getDefault();
@@ -0,0 +1,18 @@
1
+ export type OpenagentUpdatePolicy = 'notify' | 'auto' | 'off';
2
+ export type OpenagentUpdateStatus = {
3
+ checked: boolean;
4
+ checking: boolean;
5
+ currentVersion: string;
6
+ latestVersion: string;
7
+ distTag: string;
8
+ updateAvailable: boolean;
9
+ policy: OpenagentUpdatePolicy;
10
+ installCommand: string;
11
+ autoUpdateSupported: boolean;
12
+ lastCheckedAt?: string;
13
+ error?: string;
14
+ };
15
+ export declare function getOpenagentUpdateStatus(): OpenagentUpdateStatus;
16
+ export declare function startOpenagentUpdateChecker(): void;
17
+ export declare function runOpenagentUpdateCheck(): Promise<OpenagentUpdateStatus>;
18
+ export declare function compareVersions(a: string, b: string): number;
@@ -0,0 +1,216 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { logger } from '../util/logger.js';
6
+ const PLUGIN_PACKAGE = 'openclaw-openagent';
7
+ const CLI_PACKAGE = 'openclaw-openagent-cli';
8
+ const CLI_NPX_SPEC = `${CLI_PACKAGE}@latest`;
9
+ const DEFAULT_DIST_TAG = 'latest';
10
+ const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
11
+ const CHECK_DELAY_MS = 3_000;
12
+ let checkerStarted = false;
13
+ const updateStatus = {
14
+ checked: false,
15
+ checking: false,
16
+ currentVersion: '',
17
+ latestVersion: '',
18
+ distTag: DEFAULT_DIST_TAG,
19
+ updateAvailable: false,
20
+ policy: 'notify',
21
+ installCommand: `npx -y ${CLI_NPX_SPEC}`,
22
+ autoUpdateSupported: false,
23
+ };
24
+ export function getOpenagentUpdateStatus() {
25
+ return { ...updateStatus };
26
+ }
27
+ export function startOpenagentUpdateChecker() {
28
+ if (checkerStarted)
29
+ return;
30
+ checkerStarted = true;
31
+ setTimeout(() => {
32
+ void runOpenagentUpdateCheck().catch((err) => {
33
+ updateStatus.checked = true;
34
+ updateStatus.checking = false;
35
+ updateStatus.error = err.message;
36
+ updateStatus.lastCheckedAt = new Date().toISOString();
37
+ logger.warn(`[update-check] failed: ${err.message}`);
38
+ });
39
+ }, CHECK_DELAY_MS).unref?.();
40
+ }
41
+ export async function runOpenagentUpdateCheck() {
42
+ const config = resolveUpdateConfig();
43
+ updateStatus.policy = config.policy;
44
+ updateStatus.distTag = config.distTag;
45
+ updateStatus.installCommand = buildInstallCommand(config);
46
+ updateStatus.currentVersion = resolveCurrentVersion();
47
+ if (config.policy === 'off') {
48
+ updateStatus.checked = true;
49
+ updateStatus.checking = false;
50
+ updateStatus.updateAvailable = false;
51
+ updateStatus.lastCheckedAt = new Date().toISOString();
52
+ logger.info('[update-check] disabled by policy');
53
+ return getOpenagentUpdateStatus();
54
+ }
55
+ updateStatus.checking = true;
56
+ updateStatus.error = undefined;
57
+ try {
58
+ const latestVersion = await fetchDistTagVersion(config.distTag);
59
+ updateStatus.latestVersion = latestVersion;
60
+ updateStatus.updateAvailable = compareVersions(latestVersion, updateStatus.currentVersion) > 0;
61
+ updateStatus.checked = true;
62
+ updateStatus.checking = false;
63
+ updateStatus.lastCheckedAt = new Date().toISOString();
64
+ if (!updateStatus.updateAvailable) {
65
+ logger.info(`[update-check] up to date: ${PLUGIN_PACKAGE}@${updateStatus.currentVersion}`);
66
+ return getOpenagentUpdateStatus();
67
+ }
68
+ logger.warn(`[update-check] new ${PLUGIN_PACKAGE} version available: `
69
+ + `${updateStatus.currentVersion} -> ${latestVersion}. Run: ${updateStatus.installCommand}`);
70
+ if (config.policy === 'auto') {
71
+ logger.warn('[update-check] auto update is disabled by OpenClaw plugin security policy; prompt user to run the CLI command instead');
72
+ }
73
+ return getOpenagentUpdateStatus();
74
+ }
75
+ catch (err) {
76
+ updateStatus.checked = true;
77
+ updateStatus.checking = false;
78
+ updateStatus.error = err.message;
79
+ updateStatus.lastCheckedAt = new Date().toISOString();
80
+ throw err;
81
+ }
82
+ }
83
+ function resolveUpdateConfig() {
84
+ const fileConfig = readOpenagentConfig();
85
+ const configPolicy = normalizePolicy(readString(fileConfig, 'update_policy', 'updatePolicy'));
86
+ const configAutoUpdate = readBool(readString(fileConfig, 'auto_update', 'autoUpdate'));
87
+ const configUpdateCheck = readBool(readString(fileConfig, 'update_check', 'updateCheck'));
88
+ let policy = configPolicy || 'notify';
89
+ if (configAutoUpdate === true)
90
+ policy = 'auto';
91
+ if (configUpdateCheck === false)
92
+ policy = 'off';
93
+ const distTag = normalizeDistTag(readString(fileConfig, 'update_dist_tag', 'updateDistTag')
94
+ || DEFAULT_DIST_TAG);
95
+ const channel = normalizeDistTag(readString(fileConfig, 'update_channel', 'updateChannel')
96
+ || '');
97
+ return {
98
+ policy,
99
+ distTag: channel || distTag,
100
+ channel,
101
+ };
102
+ }
103
+ function buildInstallCommand(config) {
104
+ const parts = ['npx', '-y', CLI_NPX_SPEC, 'update'];
105
+ if (config.channel) {
106
+ parts.push('--channel', config.channel);
107
+ }
108
+ else if (config.distTag && config.distTag !== DEFAULT_DIST_TAG) {
109
+ parts.push('--dist-tag', config.distTag);
110
+ }
111
+ return parts.join(' ');
112
+ }
113
+ async function fetchDistTagVersion(distTag) {
114
+ const registry = DEFAULT_REGISTRY.replace(/\/+$/, '');
115
+ const url = `${registry}/${encodeURIComponent(PLUGIN_PACKAGE)}/${encodeURIComponent(distTag)}`;
116
+ const res = await fetch(url, {
117
+ headers: { Accept: 'application/json' },
118
+ signal: AbortSignal.timeout(5_000),
119
+ });
120
+ if (!res.ok) {
121
+ throw new Error(`npm registry ${res.status} for ${PLUGIN_PACKAGE}@${distTag}`);
122
+ }
123
+ const data = await res.json();
124
+ const version = typeof data.version === 'string' ? data.version : '';
125
+ if (!version)
126
+ throw new Error(`npm registry response missing version for ${PLUGIN_PACKAGE}@${distTag}`);
127
+ return version;
128
+ }
129
+ function resolveCurrentVersion() {
130
+ const packageJson = findPackageJson();
131
+ if (!packageJson)
132
+ return '0.0.0';
133
+ try {
134
+ const data = JSON.parse(fs.readFileSync(packageJson, 'utf8'));
135
+ return typeof data.version === 'string' ? data.version : '0.0.0';
136
+ }
137
+ catch {
138
+ return '0.0.0';
139
+ }
140
+ }
141
+ function findPackageJson() {
142
+ let dir = path.dirname(fileURLToPath(import.meta.url));
143
+ for (let i = 0; i < 8; i += 1) {
144
+ const candidate = path.join(dir, 'package.json');
145
+ try {
146
+ const data = JSON.parse(fs.readFileSync(candidate, 'utf8'));
147
+ if (data.name === PLUGIN_PACKAGE)
148
+ return candidate;
149
+ }
150
+ catch { }
151
+ const parent = path.dirname(dir);
152
+ if (parent === dir)
153
+ break;
154
+ dir = parent;
155
+ }
156
+ return null;
157
+ }
158
+ function readOpenagentConfig() {
159
+ const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
160
+ try {
161
+ const root = JSON.parse(fs.readFileSync(configPath, 'utf8'));
162
+ return root.channels?.openagent || {};
163
+ }
164
+ catch {
165
+ return {};
166
+ }
167
+ }
168
+ function readString(obj, ...keys) {
169
+ for (const key of keys) {
170
+ const value = obj[key];
171
+ if (typeof value === 'string' && value.trim())
172
+ return value.trim();
173
+ if (typeof value === 'boolean')
174
+ return value ? 'true' : 'false';
175
+ }
176
+ return '';
177
+ }
178
+ function readBool(value) {
179
+ if (typeof value === 'boolean')
180
+ return value;
181
+ const text = typeof value === 'string' ? value.trim().toLowerCase() : '';
182
+ if (!text)
183
+ return null;
184
+ if (['1', 'true', 'yes', 'on', 'auto'].includes(text))
185
+ return true;
186
+ if (['0', 'false', 'no', 'off', 'notify'].includes(text))
187
+ return false;
188
+ return null;
189
+ }
190
+ function normalizePolicy(value) {
191
+ const text = typeof value === 'string' ? value.trim().toLowerCase() : '';
192
+ if (text === 'auto' || text === 'notify' || text === 'off')
193
+ return text;
194
+ return '';
195
+ }
196
+ function normalizeDistTag(value) {
197
+ const text = typeof value === 'string' ? value.trim() : '';
198
+ if (!text)
199
+ return '';
200
+ return /^[A-Za-z0-9._-]+$/.test(text) ? text : '';
201
+ }
202
+ export function compareVersions(a, b) {
203
+ const pa = parseVersion(a);
204
+ const pb = parseVersion(b);
205
+ for (let i = 0; i < 3; i += 1) {
206
+ if (pa[i] !== pb[i])
207
+ return pa[i] - pb[i];
208
+ }
209
+ return 0;
210
+ }
211
+ function parseVersion(version) {
212
+ const match = String(version || '').match(/(\d+)\.(\d+)\.(\d+)/);
213
+ if (!match)
214
+ return [0, 0, 0];
215
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
216
+ }
package/index.ts CHANGED
@@ -17,6 +17,7 @@ import { registerTools, registerHooks } from './src/app/index.js';
17
17
  import { installOpenagentVerbosePreflight } from './src/app/verbose-preflight.js';
18
18
  // guard.ts removed — unhandled rejections fixed at source in ws-frame.ts send()
19
19
  import { setOpenagentPluginRuntime } from './src/runtime/plugin-runtime.js';
20
+ import { startOpenagentUpdateChecker } from './src/runtime/update-checker.js';
20
21
  import { injectControlUiOverride } from './src/plugin-ui/index.js';
21
22
  import { createAuthProxyHandler } from './src/proxy/auth-proxy.js';
22
23
  import { logger } from './src/util/logger.js';
@@ -122,6 +123,8 @@ export default {
122
123
  logger.warn(`[entry] Control UI injection failed: ${(err as Error).message}`);
123
124
  });
124
125
 
126
+ startOpenagentUpdateChecker();
127
+
125
128
  logger.info('[entry] Tools + hooks registered (full mode)');
126
129
  _fullModeRegistered = true;
127
130
  },
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "openclaw-openagent",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "type": "module",
5
5
  "description": "OpenAgent channel plugin for OpenClaw",
6
6
  "license": "MIT",
7
7
  "main": "./dist/index.js",
8
8
  "files": [
9
9
  "dist/",
10
- "src/",
11
10
  "skills/",
12
11
  "index.ts",
13
12
  "openclaw.plugin.json"
@@ -50,7 +49,6 @@
50
49
  "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/ && cp -r src/plugin-ui/adapters dist/src/plugin-ui/adapters",
51
50
  "build:override": "node ./src/plugin-ui/build.cjs",
52
51
  "watch:override": "node ./src/plugin-ui/build.cjs --watch",
53
- "postinstall": "node ./src/plugin-ui/postinstall-deploy.cjs",
54
52
  "prepack": "npm run build:override && npm run build && npm run typecheck",
55
53
  "typecheck": "tsc --noEmit",
56
54
  "prepublishOnly": "npm run typecheck",