openclaw-openagent 1.0.13 → 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.
- package/dist/src/messaging/executor.d.ts +2 -3
- package/dist/src/messaging/executor.js +4 -31
- package/dist/src/plugin-ui/assets/openagent-override.js +4 -5
- package/dist/src/runtime/update-checker.d.ts +1 -1
- package/dist/src/runtime/update-checker.js +9 -46
- package/package.json +1 -3
- package/src/app/channel-tools.ts +0 -249
- package/src/app/discovery-tools.ts +0 -273
- package/src/app/download-file-tool.ts +0 -133
- package/src/app/hooks.ts +0 -144
- package/src/app/index.ts +0 -84
- package/src/app/messaging-tools.ts +0 -79
- package/src/app/ops-tools.ts +0 -155
- package/src/app/remote-agent-tool.ts +0 -762
- package/src/app/types.ts +0 -68
- package/src/app/upload-file-tool.ts +0 -411
- package/src/app/verbose-preflight.ts +0 -190
- package/src/auth/config.ts +0 -266
- package/src/auth/credential-manager.ts +0 -146
- package/src/auth/index.ts +0 -24
- package/src/auth/verify.ts +0 -99
- package/src/channel.ts +0 -566
- package/src/compat.ts +0 -94
- package/src/config/config-schema.ts +0 -45
- package/src/messaging/aggregator.ts +0 -120
- package/src/messaging/collector.ts +0 -89
- package/src/messaging/executor.ts +0 -72
- package/src/messaging/inbound.ts +0 -150
- package/src/messaging/index.ts +0 -11
- package/src/messaging/mention-protocol.ts +0 -94
- package/src/messaging/process-c2c-request.ts +0 -564
- package/src/messaging/process-message.ts +0 -373
- package/src/messaging/scheduler.ts +0 -55
- package/src/messaging/types.ts +0 -38
- package/src/plugin-ui/adapters/oc-2026-04.js +0 -103
- package/src/plugin-ui/adapters/oc-2026-05.js +0 -125
- package/src/plugin-ui/adapters/oc-2026-06.js +0 -125
- package/src/plugin-ui/adapters/oc-unknown.js +0 -48
- package/src/plugin-ui/assets/agentbook-icon.svg +0 -5
- package/src/plugin-ui/assets/bg.png +0 -0
- package/src/plugin-ui/assets/icon.png +0 -0
- package/src/plugin-ui/assets/magic.svg +0 -5
- package/src/plugin-ui/assets/openagent-override.js +0 -11263
- package/src/plugin-ui/build.cjs +0 -463
- package/src/plugin-ui/index.ts +0 -18
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +0 -570
- package/src/plugin-ui/modules/agent-book/panel/agent-card.js +0 -170
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +0 -643
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +0 -665
- package/src/plugin-ui/modules/agent-book/panel/mention-state.js +0 -206
- package/src/plugin-ui/modules/agent-book/panel/styles.js +0 -832
- package/src/plugin-ui/modules/agent-book/panel/theme-adapter.js +0 -86
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +0 -295
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +0 -211
- package/src/plugin-ui/modules/agent-book/scanner.js +0 -131
- package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +0 -500
- package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +0 -652
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +0 -262
- package/src/plugin-ui/modules/loader/bootstrap.js +0 -133
- package/src/plugin-ui/modules/loader/shared-state.js +0 -838
- package/src/plugin-ui/modules/loader/ws-intercept.js +0 -199
- package/src/plugin-ui/modules/remote-agent/chunk-parser.js +0 -161
- package/src/plugin-ui/modules/remote-agent/execution-card.js +0 -530
- package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +0 -256
- package/src/plugin-ui/modules/remote-agent/media-links.js +0 -151
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +0 -134
- package/src/plugin-ui/modules/remote-agent/output-card.js +0 -342
- package/src/plugin-ui/modules/remote-agent/progress-store.js +0 -363
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +0 -1700
- package/src/plugin-ui/modules/remote-agent/styles.js +0 -903
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +0 -130
- package/src/plugin-ui/postinstall-deploy.cjs +0 -52
- package/src/plugin-ui/ui-extension-loader/backup.ts +0 -92
- package/src/plugin-ui/ui-extension-loader/index.ts +0 -276
- package/src/plugin-ui/ui-extension-loader/locator.ts +0 -152
- package/src/plugin-ui/ui-extension-loader/manifest.ts +0 -57
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +0 -944
- package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +0 -70
- package/src/plugin-ui/ui-extension-loader/types.ts +0 -72
- package/src/proxy/auth-proxy.ts +0 -414
- package/src/runtime/account.ts +0 -549
- package/src/runtime/index.ts +0 -7
- package/src/runtime/plugin-runtime.ts +0 -94
- package/src/runtime/registry.ts +0 -71
- package/src/runtime/update-checker.ts +0 -286
- package/src/sdk/CLASS_MAP.md +0 -143
- package/src/sdk/index.d.ts +0 -126
- package/src/sdk/index.js +0 -23990
- package/src/sdk/modules/cloud-search-module.js +0 -1117
- package/src/sdk/modules/follow-module.js +0 -1069
- package/src/sdk/modules/group-module.js +0 -7397
- package/src/sdk/modules/relationship-module.js +0 -2269
- package/src/sdk/modules/signaling-module.js +0 -1468
- package/src/sdk/modules/tim-upload-plugin.js +0 -730
- package/src/sdk/node-env/http-request.js +0 -90
- package/src/sdk/node-env/index.js +0 -57
- package/src/sdk/node-env/storage.js +0 -114
- package/src/sdk/package.json +0 -10
- package/src/sdk/tsconfig.json +0 -16
- package/src/state/pending-invocation-store.ts +0 -43
- package/src/state/store.ts +0 -756
- package/src/tim/c2c.ts +0 -451
- package/src/tim/channels.ts +0 -364
- package/src/tim/client.ts +0 -330
- package/src/tim/index.ts +0 -18
- package/src/tim/messages.ts +0 -166
- package/src/tim/sdk-logger-init.ts +0 -50
- package/src/tools.ts +0 -10
- package/src/transport/factory.ts +0 -95
- package/src/transport/oasn/index.ts +0 -17
- package/src/transport/oasn/oasn-agent-card.ts +0 -111
- package/src/transport/oasn/oasn-discovery.ts +0 -108
- package/src/transport/oasn/oasn-files.ts +0 -210
- package/src/transport/oasn/oasn-http.ts +0 -529
- package/src/transport/oasn/oasn-invocation.ts +0 -604
- package/src/transport/oasn/oasn-normalize.ts +0 -133
- package/src/transport/oasn/oasn-register.ts +0 -33
- package/src/transport/oasn/oasn-transport.ts +0 -318
- package/src/transport/oasn/oasn-types.ts +0 -404
- package/src/transport/tim/index.ts +0 -8
- package/src/transport/tim/tim-transport.ts +0 -515
- package/src/transport/types.ts +0 -538
- package/src/types/openclaw-plugin-sdk-media-store.d.ts +0 -9
- package/src/types/openclaw.d.ts +0 -97
- package/src/types/tencentcloud-chat.d.ts +0 -15
- package/src/util/http.ts +0 -113
- package/src/util/logger.ts +0 -131
- package/src/util/url-resolver.ts +0 -77
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ActionExecutor — Triggers OpenClaw agent turn via CLI
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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
|
-
|
|
19
|
-
|
|
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-
|
|
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: "
|
|
55
|
+
buildId: "ae54b0a5de1b",
|
|
56
56
|
|
|
57
57
|
// ── 配置 ──
|
|
58
58
|
OPENAGENT_API: 'https://api.openagent.club',
|
|
@@ -11244,9 +11244,8 @@ function _clShowPluginUpdateNotice(status) {
|
|
|
11244
11244
|
actions.appendChild(close);
|
|
11245
11245
|
notice.appendChild(actions);
|
|
11246
11246
|
|
|
11247
|
-
if (status.policy === 'auto' && status.
|
|
11248
|
-
body.textContent = '
|
|
11249
|
-
actions.remove();
|
|
11247
|
+
if (status.policy === 'auto' && status.autoUpdateSupported === false) {
|
|
11248
|
+
body.textContent = '自动更新受 OpenClaw 安全策略限制,请运行命令完成更新。';
|
|
11250
11249
|
}
|
|
11251
11250
|
|
|
11252
11251
|
document.body.appendChild(notice);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import fs from 'node:fs';
|
|
3
2
|
import os from 'node:os';
|
|
4
3
|
import path from 'node:path';
|
|
@@ -6,6 +5,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
6
5
|
import { logger } from '../util/logger.js';
|
|
7
6
|
const PLUGIN_PACKAGE = 'openclaw-openagent';
|
|
8
7
|
const CLI_PACKAGE = 'openclaw-openagent-cli';
|
|
8
|
+
const CLI_NPX_SPEC = `${CLI_PACKAGE}@latest`;
|
|
9
9
|
const DEFAULT_DIST_TAG = 'latest';
|
|
10
10
|
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
11
11
|
const CHECK_DELAY_MS = 3_000;
|
|
@@ -18,8 +18,8 @@ const updateStatus = {
|
|
|
18
18
|
distTag: DEFAULT_DIST_TAG,
|
|
19
19
|
updateAvailable: false,
|
|
20
20
|
policy: 'notify',
|
|
21
|
-
installCommand: `npx -y ${
|
|
22
|
-
|
|
21
|
+
installCommand: `npx -y ${CLI_NPX_SPEC}`,
|
|
22
|
+
autoUpdateSupported: false,
|
|
23
23
|
};
|
|
24
24
|
export function getOpenagentUpdateStatus() {
|
|
25
25
|
return { ...updateStatus };
|
|
@@ -68,7 +68,7 @@ export async function runOpenagentUpdateCheck() {
|
|
|
68
68
|
logger.warn(`[update-check] new ${PLUGIN_PACKAGE} version available: `
|
|
69
69
|
+ `${updateStatus.currentVersion} -> ${latestVersion}. Run: ${updateStatus.installCommand}`);
|
|
70
70
|
if (config.policy === 'auto') {
|
|
71
|
-
|
|
71
|
+
logger.warn('[update-check] auto update is disabled by OpenClaw plugin security policy; prompt user to run the CLI command instead');
|
|
72
72
|
}
|
|
73
73
|
return getOpenagentUpdateStatus();
|
|
74
74
|
}
|
|
@@ -82,9 +82,6 @@ export async function runOpenagentUpdateCheck() {
|
|
|
82
82
|
}
|
|
83
83
|
function resolveUpdateConfig() {
|
|
84
84
|
const fileConfig = readOpenagentConfig();
|
|
85
|
-
const envPolicy = normalizePolicy(process.env.OPENAGENT_UPDATE_POLICY);
|
|
86
|
-
const autoUpdateEnv = readBool(process.env.OPENAGENT_AUTO_UPDATE ?? process.env.OPENAGENT_PLUGIN_AUTO_UPDATE);
|
|
87
|
-
const checkEnabledEnv = readBool(process.env.OPENAGENT_UPDATE_CHECK);
|
|
88
85
|
const configPolicy = normalizePolicy(readString(fileConfig, 'update_policy', 'updatePolicy'));
|
|
89
86
|
const configAutoUpdate = readBool(readString(fileConfig, 'auto_update', 'autoUpdate'));
|
|
90
87
|
const configUpdateCheck = readBool(readString(fileConfig, 'update_check', 'updateCheck'));
|
|
@@ -93,19 +90,9 @@ function resolveUpdateConfig() {
|
|
|
93
90
|
policy = 'auto';
|
|
94
91
|
if (configUpdateCheck === false)
|
|
95
92
|
policy = 'off';
|
|
96
|
-
|
|
97
|
-
policy = envPolicy;
|
|
98
|
-
if (autoUpdateEnv === true)
|
|
99
|
-
policy = 'auto';
|
|
100
|
-
if (checkEnabledEnv === false)
|
|
101
|
-
policy = 'off';
|
|
102
|
-
const distTag = normalizeDistTag(process.env.OPENAGENT_UPDATE_DIST_TAG
|
|
103
|
-
|| readString(fileConfig, 'update_dist_tag', 'updateDistTag')
|
|
104
|
-
|| process.env.OPENAGENT_PLUGIN_DIST_TAG
|
|
93
|
+
const distTag = normalizeDistTag(readString(fileConfig, 'update_dist_tag', 'updateDistTag')
|
|
105
94
|
|| DEFAULT_DIST_TAG);
|
|
106
|
-
const channel = normalizeDistTag(
|
|
107
|
-
|| readString(fileConfig, 'update_channel', 'updateChannel')
|
|
108
|
-
|| process.env.OPENAGENT_PLUGIN_CHANNEL
|
|
95
|
+
const channel = normalizeDistTag(readString(fileConfig, 'update_channel', 'updateChannel')
|
|
109
96
|
|| '');
|
|
110
97
|
return {
|
|
111
98
|
policy,
|
|
@@ -113,28 +100,8 @@ function resolveUpdateConfig() {
|
|
|
113
100
|
channel,
|
|
114
101
|
};
|
|
115
102
|
}
|
|
116
|
-
function startAutoUpdate(config) {
|
|
117
|
-
if (updateStatus.autoUpdateStarted)
|
|
118
|
-
return;
|
|
119
|
-
updateStatus.autoUpdateStarted = true;
|
|
120
|
-
const npxBin = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
121
|
-
const args = ['-y', CLI_PACKAGE, 'update'];
|
|
122
|
-
if (config.channel) {
|
|
123
|
-
args.push('--channel', config.channel);
|
|
124
|
-
}
|
|
125
|
-
else if (config.distTag && config.distTag !== DEFAULT_DIST_TAG) {
|
|
126
|
-
args.push('--dist-tag', config.distTag);
|
|
127
|
-
}
|
|
128
|
-
logger.warn(`[update-check] auto update started: ${npxBin} ${args.join(' ')}`);
|
|
129
|
-
const child = spawn(npxBin, args, {
|
|
130
|
-
detached: true,
|
|
131
|
-
stdio: 'ignore',
|
|
132
|
-
env: process.env,
|
|
133
|
-
});
|
|
134
|
-
child.unref();
|
|
135
|
-
}
|
|
136
103
|
function buildInstallCommand(config) {
|
|
137
|
-
const parts = ['npx', '-y',
|
|
104
|
+
const parts = ['npx', '-y', CLI_NPX_SPEC, 'update'];
|
|
138
105
|
if (config.channel) {
|
|
139
106
|
parts.push('--channel', config.channel);
|
|
140
107
|
}
|
|
@@ -144,10 +111,7 @@ function buildInstallCommand(config) {
|
|
|
144
111
|
return parts.join(' ');
|
|
145
112
|
}
|
|
146
113
|
async function fetchDistTagVersion(distTag) {
|
|
147
|
-
|
|
148
|
-
return process.env.OPENAGENT_UPDATE_TEST_VERSION;
|
|
149
|
-
}
|
|
150
|
-
const registry = (process.env.OPENAGENT_UPDATE_REGISTRY || DEFAULT_REGISTRY).replace(/\/+$/, '');
|
|
114
|
+
const registry = DEFAULT_REGISTRY.replace(/\/+$/, '');
|
|
151
115
|
const url = `${registry}/${encodeURIComponent(PLUGIN_PACKAGE)}/${encodeURIComponent(distTag)}`;
|
|
152
116
|
const res = await fetch(url, {
|
|
153
117
|
headers: { Accept: 'application/json' },
|
|
@@ -192,8 +156,7 @@ function findPackageJson() {
|
|
|
192
156
|
return null;
|
|
193
157
|
}
|
|
194
158
|
function readOpenagentConfig() {
|
|
195
|
-
const
|
|
196
|
-
const configPath = path.join(stateDir, 'openclaw.json');
|
|
159
|
+
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
|
|
197
160
|
try {
|
|
198
161
|
const root = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
199
162
|
return root.channels?.openagent || {};
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-openagent",
|
|
3
|
-
"version": "1.0.
|
|
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",
|
package/src/app/channel-tools.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel Tools — 8 channel management tools
|
|
3
|
-
*
|
|
4
|
-
* list_channels, search_channels, join_channel, leave_channel,
|
|
5
|
-
* create_channel, get_members, set_channel_skill, get_channel_skill
|
|
6
|
-
*
|
|
7
|
-
* Contract ref: §0.2 refactoring-plan.md
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { registry } from '../runtime/registry.js';
|
|
11
|
-
import { toolResult, type ToolDescriptor, type ToolParams, type ToolResult } from './types.js';
|
|
12
|
-
|
|
13
|
-
function fail(error: string): ToolResult {
|
|
14
|
-
return toolResult(JSON.stringify({ success: false, error }));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntime() {
|
|
18
|
-
const rt = registry.getDefault();
|
|
19
|
-
if (!rt || !rt.isRunning) return null;
|
|
20
|
-
return rt;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function createListChannelsTool(): ToolDescriptor {
|
|
24
|
-
return {
|
|
25
|
-
name: 'openagent_list_channels',
|
|
26
|
-
label: 'List OpenAgent Channels',
|
|
27
|
-
description: 'List all available channels on OpenAgent agent network',
|
|
28
|
-
parameters: { type: 'object', properties: {}, required: [] },
|
|
29
|
-
async execute() {
|
|
30
|
-
const rt = getRuntime();
|
|
31
|
-
if (!rt) return fail('Not connected');
|
|
32
|
-
try {
|
|
33
|
-
const channels = await rt.listChannels();
|
|
34
|
-
return toolResult(JSON.stringify({ success: true, channels }));
|
|
35
|
-
} catch (err) {
|
|
36
|
-
return fail((err as Error).message);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function createSearchChannelsTool(): ToolDescriptor {
|
|
43
|
-
return {
|
|
44
|
-
name: 'openagent_search_channels',
|
|
45
|
-
label: 'Search OpenAgent Channels',
|
|
46
|
-
description: 'Search channels by keyword',
|
|
47
|
-
parameters: {
|
|
48
|
-
type: 'object',
|
|
49
|
-
properties: { keyword: { type: 'string', description: 'Search keyword' } },
|
|
50
|
-
required: ['keyword'],
|
|
51
|
-
},
|
|
52
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
53
|
-
const rt = getRuntime();
|
|
54
|
-
if (!rt) return fail('Not connected');
|
|
55
|
-
try {
|
|
56
|
-
const channels = await rt.searchChannels(String(params.keyword || ''));
|
|
57
|
-
return toolResult(JSON.stringify({ success: true, channels }));
|
|
58
|
-
} catch (err) {
|
|
59
|
-
return fail((err as Error).message);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* join_channel — supports optional `purpose?` per §0.2.
|
|
67
|
-
* If purpose is provided, it is stored via setPurpose().
|
|
68
|
-
*/
|
|
69
|
-
export function createJoinChannelTool(): ToolDescriptor {
|
|
70
|
-
return {
|
|
71
|
-
name: 'openagent_join_channel',
|
|
72
|
-
label: 'Join OpenAgent Channel',
|
|
73
|
-
description: 'Join a channel by ID (e.g. ch-001). Optionally set a purpose for this channel.',
|
|
74
|
-
parameters: {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
channelId: { type: 'string', description: 'Channel ID to join' },
|
|
78
|
-
purpose: { type: 'string', description: 'Optional: your purpose/goal for this channel' },
|
|
79
|
-
},
|
|
80
|
-
required: ['channelId'],
|
|
81
|
-
},
|
|
82
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
83
|
-
const rt = getRuntime();
|
|
84
|
-
if (!rt) return fail('Not connected');
|
|
85
|
-
try {
|
|
86
|
-
const channelId = String(params.channelId);
|
|
87
|
-
const result = await rt.joinChannel(channelId);
|
|
88
|
-
if (result.success && rt.store) {
|
|
89
|
-
rt.store.markJoined(channelId, channelId);
|
|
90
|
-
if (params.purpose) {
|
|
91
|
-
rt.store.setPurpose(channelId, String(params.purpose));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return toolResult(JSON.stringify({
|
|
95
|
-
success: result.success,
|
|
96
|
-
channelId,
|
|
97
|
-
purpose: params.purpose ? String(params.purpose) : undefined,
|
|
98
|
-
}));
|
|
99
|
-
} catch (err) {
|
|
100
|
-
return fail((err as Error).message);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function createLeaveChannelTool(): ToolDescriptor {
|
|
107
|
-
return {
|
|
108
|
-
name: 'openagent_leave_channel',
|
|
109
|
-
label: 'Leave OpenAgent Channel',
|
|
110
|
-
description: 'Leave a channel by ID',
|
|
111
|
-
parameters: {
|
|
112
|
-
type: 'object',
|
|
113
|
-
properties: { channelId: { type: 'string', description: 'Channel ID to leave' } },
|
|
114
|
-
required: ['channelId'],
|
|
115
|
-
},
|
|
116
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
117
|
-
const rt = getRuntime();
|
|
118
|
-
if (!rt) return fail('Not connected');
|
|
119
|
-
try {
|
|
120
|
-
const channelId = String(params.channelId);
|
|
121
|
-
const result = await rt.leaveChannel(channelId);
|
|
122
|
-
if (result.success && rt.store) {
|
|
123
|
-
rt.store.markLeft(channelId);
|
|
124
|
-
}
|
|
125
|
-
return toolResult(JSON.stringify(result));
|
|
126
|
-
} catch (err) {
|
|
127
|
-
return fail((err as Error).message);
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* create_channel — supports optional `channelId?`, `skill?`, `desc?` per §0.2.
|
|
135
|
-
* If channelId is not given, auto-generates one.
|
|
136
|
-
*/
|
|
137
|
-
export function createCreateChannelTool(): ToolDescriptor {
|
|
138
|
-
return {
|
|
139
|
-
name: 'openagent_create_channel',
|
|
140
|
-
label: 'Create OpenAgent Channel',
|
|
141
|
-
description: 'Create a new channel. You become the owner and are automatically joined.',
|
|
142
|
-
parameters: {
|
|
143
|
-
type: 'object',
|
|
144
|
-
properties: {
|
|
145
|
-
name: { type: 'string', description: 'Channel display name (e.g. "AI Research Discussion")' },
|
|
146
|
-
desc: { type: 'string', description: 'Short description of the channel topic' },
|
|
147
|
-
skill: { type: 'string', description: 'Optional initial channel skill/rules' },
|
|
148
|
-
},
|
|
149
|
-
required: ['name'],
|
|
150
|
-
},
|
|
151
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
152
|
-
const rt = getRuntime();
|
|
153
|
-
if (!rt) return fail('Not connected');
|
|
154
|
-
try {
|
|
155
|
-
// Community groups: SDK auto-generates @TGS#_ prefixed groupID
|
|
156
|
-
const result = await rt.createChannel(
|
|
157
|
-
String(params.name),
|
|
158
|
-
String(params.desc || ''),
|
|
159
|
-
params.skill ? String(params.skill) : undefined,
|
|
160
|
-
);
|
|
161
|
-
return toolResult(JSON.stringify(result));
|
|
162
|
-
} catch (err) {
|
|
163
|
-
return fail((err as Error).message);
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* get_members — returns avatar? field per §0.2.
|
|
171
|
-
*/
|
|
172
|
-
export function createGetMembersTool(): ToolDescriptor {
|
|
173
|
-
return {
|
|
174
|
-
name: 'openagent_get_members',
|
|
175
|
-
label: 'Get Channel Members',
|
|
176
|
-
description: 'Get the member list of a channel',
|
|
177
|
-
parameters: {
|
|
178
|
-
type: 'object',
|
|
179
|
-
properties: { channelId: { type: 'string', description: 'Channel ID' } },
|
|
180
|
-
required: ['channelId'],
|
|
181
|
-
},
|
|
182
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
183
|
-
const rt = getRuntime();
|
|
184
|
-
if (!rt) return fail('Not connected');
|
|
185
|
-
try {
|
|
186
|
-
const members = await rt.getMembers(String(params.channelId));
|
|
187
|
-
// Preserve all fields including avatar? per contract
|
|
188
|
-
return toolResult(JSON.stringify({ success: true, members }));
|
|
189
|
-
} catch (err) {
|
|
190
|
-
return fail((err as Error).message);
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export function createSetChannelSkillTool(): ToolDescriptor {
|
|
197
|
-
return {
|
|
198
|
-
name: 'openagent_set_channel_skill',
|
|
199
|
-
label: 'Set Channel Skill',
|
|
200
|
-
description: 'Set the skill/behavior rules for a channel',
|
|
201
|
-
parameters: {
|
|
202
|
-
type: 'object',
|
|
203
|
-
properties: {
|
|
204
|
-
channelId: { type: 'string', description: 'Channel ID' },
|
|
205
|
-
skill: { type: 'string', description: 'Channel rules that control agent behavior' },
|
|
206
|
-
},
|
|
207
|
-
required: ['channelId', 'skill'],
|
|
208
|
-
},
|
|
209
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
210
|
-
const rt = getRuntime();
|
|
211
|
-
if (!rt) return fail('Not connected');
|
|
212
|
-
try {
|
|
213
|
-
await rt.setChannelSkill(String(params.channelId), String(params.skill));
|
|
214
|
-
return toolResult(JSON.stringify({ success: true, message: `Skill set for ${params.channelId}` }));
|
|
215
|
-
} catch (err) {
|
|
216
|
-
return fail((err as Error).message);
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function createGetChannelSkillTool(): ToolDescriptor {
|
|
223
|
-
return {
|
|
224
|
-
name: 'openagent_get_channel_skill',
|
|
225
|
-
label: 'Get Channel Skill',
|
|
226
|
-
description: 'Get the current skill/behavior rules for a channel',
|
|
227
|
-
parameters: {
|
|
228
|
-
type: 'object',
|
|
229
|
-
properties: {
|
|
230
|
-
channelId: { type: 'string', description: 'Channel ID' },
|
|
231
|
-
},
|
|
232
|
-
required: ['channelId'],
|
|
233
|
-
},
|
|
234
|
-
async execute(_id: unknown, params: ToolParams) {
|
|
235
|
-
const rt = getRuntime();
|
|
236
|
-
if (!rt) return fail('Not connected');
|
|
237
|
-
try {
|
|
238
|
-
const skill = await rt.getChannelSkill(String(params.channelId));
|
|
239
|
-
return toolResult(JSON.stringify({
|
|
240
|
-
success: true,
|
|
241
|
-
channelId: params.channelId,
|
|
242
|
-
skill: skill || '(no skill set)',
|
|
243
|
-
}));
|
|
244
|
-
} catch (err) {
|
|
245
|
-
return fail((err as Error).message);
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
}
|