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/src/app/hooks.ts DELETED
@@ -1,144 +0,0 @@
1
- /**
2
- * Hooks — Scene + Purpose injection + Inline Image Offload
3
- *
4
- * Registers hooks with the OpenClaw API:
5
- * 1. before_prompt_build — injects channel-specific rules (skill) and agent purpose
6
- * 2. agent_turn_prepare — offloads inline base64 images to ~/.openclaw/media/inbound/
7
- * so the model can reference them via media://inbound/<id>
8
- */
9
-
10
- import { registry } from '../runtime/registry.js';
11
- import { logger } from '../util/logger.js';
12
-
13
- interface HookEvent {
14
- [key: string]: unknown;
15
- }
16
-
17
- interface HookContext {
18
- sessionId?: string;
19
- [key: string]: unknown;
20
- }
21
-
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- type AnyApi = any;
24
-
25
- /**
26
- * Register all OpenAgent hooks with OpenClaw API.
27
- */
28
- export function registerHooks(api: AnyApi): void {
29
- // ── Hook 1: Scene + Purpose injection ──
30
- api.registerHook('before_prompt_build', async (_event: HookEvent, ctx: HookContext) => {
31
- // Only fire for openagent channel sessions
32
- if (!ctx.sessionId?.startsWith('openagent:')) return {};
33
-
34
- const channelId = ctx.sessionId.replace('openagent:', '');
35
- const rt = registry.getDefault();
36
- if (!rt) return {};
37
-
38
- const parts: string[] = [];
39
-
40
- // Inject channel rules (skill/scene)
41
- try {
42
- const rules = await rt.getChannelSkill(channelId);
43
- if (rules) parts.push(`[SCENE: ${channelId}]\n${rules}\n[/SCENE]`);
44
- } catch (err) {
45
- logger.warn(`[hooks] rules fetch failed: ${(err as Error).message}`);
46
- }
47
-
48
- // Inject agent purpose for this channel
49
- try {
50
- const purpose = rt.store?.getPurpose(channelId);
51
- if (purpose) parts.push(`[PURPOSE]\n${purpose}\n[/PURPOSE]`);
52
- } catch (err) {
53
- logger.warn(`[hooks] purpose fetch failed: ${(err as Error).message}`);
54
- }
55
-
56
- if (parts.length === 0) return {};
57
-
58
- logger.debug(`[hooks] Injected Scene+Purpose for ${channelId}`);
59
- return { appendSystemContext: parts.join('\n\n') };
60
- }, { name: 'openagent-scene-purpose' });
61
-
62
- // ── Hook 2: Inline image offload ──
63
- //
64
- // When a user uploads a file via Web UI and the model supports vision,
65
- // images < 2MB are sent inline (base64 in the message content) and never
66
- // saved to disk. This hook intercepts those inline images via the llm_input
67
- // event (fires for ALL agent sessions including embedded), extracts the
68
- // base64 data, and writes it to ~/.openclaw/media/inbound/ via saveMediaBuffer.
69
- //
70
- // The model won't see a media://inbound/ URL in its prompt, but
71
- // openagent_upload_file's auto-fallback (resolveLatestInboundFile) will
72
- // pick up the most recently saved file automatically.
73
- //
74
- api.registerHook('llm_input', async (event: HookEvent) => {
75
- const historyMessages = event.historyMessages as unknown[] | undefined;
76
- if (!Array.isArray(historyMessages) || historyMessages.length === 0) return;
77
-
78
- logger.info(
79
- `[hooks] llm_input FIRED imagesCount=${event.imagesCount} historyMsgs=${historyMessages.length}`,
80
- );
81
-
82
- // Scan ALL messages (not just the last user message) for inline images
83
- const MAX_BYTES = 20 * 1024 * 1024;
84
- let savedCount = 0;
85
-
86
- for (const msg of historyMessages as Record<string, unknown>[]) {
87
- if (!msg || typeof msg !== 'object') continue;
88
- const contentRaw = msg.content;
89
- const contentBlocks: Record<string, unknown>[] = Array.isArray(contentRaw)
90
- ? contentRaw as Record<string, unknown>[]
91
- : [];
92
-
93
- for (const block of contentBlocks) {
94
- let base64: string | undefined;
95
- let mimeType: string | undefined;
96
-
97
- // Anthropic-style: { type: "image", source: { type: "base64", media_type: "...", data: "..." } }
98
- if (block?.type === 'image') {
99
- const source = block.source as Record<string, unknown> | undefined;
100
- if (source?.type === 'base64' && typeof source.data === 'string') {
101
- base64 = source.data;
102
- mimeType = (source.media_type as string) || 'image/png';
103
- }
104
- }
105
-
106
- // OpenAI-style: { type: "image_url", image_url: { url: "data:image/png;base64,..." } }
107
- if (!base64 && block?.type === 'image_url') {
108
- const imageUrl = (block.image_url as Record<string, unknown> | undefined)?.url;
109
- if (typeof imageUrl === 'string') {
110
- const match = imageUrl.match(/^data:([^;]+);base64,(.+)$/);
111
- if (match) {
112
- mimeType = match[1]!;
113
- base64 = match[2]!;
114
- }
115
- }
116
- }
117
-
118
- if (!base64) continue;
119
-
120
- const buffer = Buffer.from(base64, 'base64');
121
- const mime = mimeType || 'application/octet-stream';
122
- const ext = mime.split('/')[1] || 'bin';
123
-
124
- try {
125
- const { saveMediaBuffer } = await import('openclaw/plugin-sdk/media-store');
126
- const saved = await saveMediaBuffer(buffer, mime, 'inbound', MAX_BYTES, `webui-inline.${ext}`);
127
- savedCount++;
128
- logger.info(
129
- `[hooks] Offloaded inline image: media://inbound/${saved.id} ` +
130
- `size=${buffer.byteLength} mime=${mime}`,
131
- );
132
- } catch (err) {
133
- logger.warn(
134
- `[hooks] Failed to save inline image: ${(err as Error).message}`,
135
- );
136
- }
137
- }
138
- }
139
-
140
- if (savedCount > 0) {
141
- logger.info(`[hooks] llm_input saved ${savedCount} inline image(s) to media store`);
142
- }
143
- }, { name: 'openagent-inline-image-offload' });
144
- }
package/src/app/index.ts DELETED
@@ -1,84 +0,0 @@
1
- /**
2
- * App — Tool + Hook registration aggregator
3
- *
4
- * Registers all tools and hooks with the OpenClaw API.
5
- */
6
-
7
- import {
8
- createListChannelsTool,
9
- createSearchChannelsTool,
10
- createJoinChannelTool,
11
- createLeaveChannelTool,
12
- createCreateChannelTool,
13
- createGetMembersTool,
14
- createSetChannelSkillTool,
15
- createGetChannelSkillTool,
16
- } from './channel-tools.js';
17
-
18
- import {
19
- createSendMessageTool,
20
- createGetMessagesTool,
21
- } from './messaging-tools.js';
22
-
23
- import {
24
- createSetStrategyTool,
25
- createGetStatusTool,
26
- createSetPurposeTool,
27
- createGetPurposeTool,
28
- } from './ops-tools.js';
29
-
30
- import { createCallRemoteAgentTool } from './remote-agent-tool.js';
31
- import {
32
- createSearchAgentsTool,
33
- createGetAgentDetailTool,
34
- } from './discovery-tools.js';
35
- import { createUploadFileTool } from './upload-file-tool.js';
36
- import { createDownloadFileTool } from './download-file-tool.js';
37
-
38
- import { registerHooks } from './hooks.js';
39
-
40
- import type { ToolFactory } from './types.js';
41
-
42
- import type { OpenClawPluginApi } from 'openclaw/plugin-sdk/plugin-entry';
43
-
44
- /**
45
- * Register all tools with OpenClaw API.
46
- */
47
- export function registerTools(api: OpenClawPluginApi): void {
48
- // ── Channel management (8) — DORMANT: code preserved, not registered ──
49
- // Uncomment to re-enable channel-based social networking features.
50
- // api.registerTool(createListChannelsTool, { optional: false });
51
- // api.registerTool(createSearchChannelsTool, { optional: false });
52
- // api.registerTool(createJoinChannelTool, { optional: false });
53
- // api.registerTool(createLeaveChannelTool, { optional: false });
54
- // api.registerTool(createCreateChannelTool, { optional: false });
55
- // api.registerTool(createGetMembersTool, { optional: false });
56
- // api.registerTool(createSetChannelSkillTool, { optional: false });
57
- // api.registerTool(createGetChannelSkillTool, { optional: false });
58
-
59
- // ── Messaging (2) — DORMANT ──
60
- // api.registerTool(createSendMessageTool, { optional: false });
61
- // api.registerTool(createGetMessagesTool, { optional: false });
62
-
63
- // ── Ops (4) — DORMANT ──
64
- // api.registerTool(createSetStrategyTool, { optional: false });
65
- // api.registerTool(createGetStatusTool, { optional: false });
66
- // api.registerTool(createSetPurposeTool, { optional: false });
67
- // api.registerTool(createGetPurposeTool, { optional: false });
68
-
69
- // ── Remote Agent Orchestration (1) — ACTIVE ──
70
- api.registerTool(createCallRemoteAgentTool, { optional: false });
71
-
72
- // ── Agent Discovery (2) — ACTIVE (OASN-only) ──
73
- // 搜索 / Agent 详情。TIM 模式下工具存在但返回明确错误。
74
- // 注:getCategories() 传输层能力保留给 Agent Book UI 使用,不暴露为 LLM 工具。
75
- api.registerTool(createSearchAgentsTool, { optional: false });
76
- api.registerTool(createGetAgentDetailTool, { optional: false });
77
-
78
- // ── File Upload / Download (2) — ACTIVE (OASN-only) ──
79
- api.registerTool(createUploadFileTool, { optional: false });
80
- api.registerTool(createDownloadFileTool, { optional: false });
81
- }
82
-
83
- export { registerHooks };
84
- export type { ToolDescriptor, ToolFactory } from './types.js';
@@ -1,79 +0,0 @@
1
- /**
2
- * Messaging Tools — 4 message-related tools
3
- *
4
- * send_message, get_messages, set_channel_skill, get_channel_skill
5
- * Note: skill tools are in channel-tools.ts since they manage channel metadata
6
- *
7
- * This file contains: send_message, get_messages
8
- */
9
-
10
- import { registry } from '../runtime/registry.js';
11
- import { logger } from '../util/logger.js';
12
- import { toolResult, type ToolDescriptor, type ToolParams, type ToolResult } from './types.js';
13
-
14
- function fail(error: string): ToolResult {
15
- return toolResult(JSON.stringify({ success: false, error }));
16
- }
17
-
18
- function getRuntime() {
19
- const rt = registry.getDefault();
20
- if (!rt || !rt.isRunning) return null;
21
- return rt;
22
- }
23
-
24
- export function createSendMessageTool(): ToolDescriptor {
25
- return {
26
- name: 'openagent_send_message',
27
- label: 'Send OpenAgent Message',
28
- description: 'Send a text message to a channel',
29
- parameters: {
30
- type: 'object',
31
- properties: {
32
- channelId: { type: 'string', description: 'Channel ID' },
33
- text: { type: 'string', description: 'Message text' },
34
- },
35
- required: ['channelId', 'text'],
36
- },
37
- async execute(_id: unknown, params: ToolParams) {
38
- const rt = getRuntime();
39
- if (!rt) return fail('Not connected');
40
- try {
41
- const result = await rt.sendMessage(String(params.channelId), String(params.text));
42
- if (rt.store) {
43
- rt.store.updateLastReply(String(params.channelId));
44
- }
45
- return toolResult(JSON.stringify({ success: true, messageId: result.messageId }));
46
- } catch (err) {
47
- return fail((err as Error).message);
48
- }
49
- },
50
- };
51
- }
52
-
53
- export function createGetMessagesTool(): ToolDescriptor {
54
- return {
55
- name: 'openagent_get_messages',
56
- label: 'Get Channel Messages',
57
- description: 'Get recent messages from a channel (must join channel first)',
58
- parameters: {
59
- type: 'object',
60
- properties: {
61
- channelId: { type: 'string', description: 'Channel ID' },
62
- count: { type: 'integer', description: 'Number of messages (default 15)' },
63
- },
64
- required: ['channelId'],
65
- },
66
- async execute(_id: unknown, params: ToolParams) {
67
- const rt = getRuntime();
68
- if (!rt) return fail('Not connected');
69
- try {
70
- const count = (params.count as number) || 15;
71
- const messages = await rt.fetchMessages(String(params.channelId), count);
72
- return toolResult(JSON.stringify({ success: true, messages }));
73
- } catch (err) {
74
- logger.error(`[tools] getMessages error: ${(err as Error).message}`);
75
- return fail((err as Error).message);
76
- }
77
- },
78
- };
79
- }
@@ -1,155 +0,0 @@
1
- /**
2
- * Ops Tools — 4 operational tools
3
- *
4
- * set_strategy, get_status, set_purpose, get_purpose
5
- *
6
- * Contract ref: §0.2 refactoring-plan.md
7
- */
8
-
9
- import { registry } from '../runtime/registry.js';
10
- import { toolResult, type ToolDescriptor, type ToolResult } from './types.js';
11
-
12
- function fail(error: string): ToolResult {
13
- return toolResult(JSON.stringify({ success: false, error }));
14
- }
15
-
16
- function getRuntime() {
17
- const rt = registry.getDefault();
18
- if (!rt || !rt.isRunning) return null;
19
- return rt;
20
- }
21
-
22
- export function createSetStrategyTool(): ToolDescriptor {
23
- return {
24
- name: 'openagent_set_strategy',
25
- label: 'Set Message Strategy',
26
- description: 'Configure how you receive and respond to channel messages. Changes take effect immediately.',
27
- parameters: {
28
- type: 'object',
29
- properties: {
30
- batchWindowMs: { type: 'integer', description: 'How long to collect messages before processing (ms, default 20000)' },
31
- maxBatchSize: { type: 'integer', description: 'Max messages to buffer before forced flush (default 20)' },
32
- },
33
- required: [],
34
- },
35
- async execute(_id, params) {
36
- const rt = getRuntime();
37
- if (!rt) return fail('Not connected');
38
- try {
39
- const newConfig: { batchWindowMs?: number; maxBatchSize?: number } = {};
40
- if (params?.batchWindowMs != null) newConfig.batchWindowMs = Number(params.batchWindowMs);
41
- if (params?.maxBatchSize != null) newConfig.maxBatchSize = Number(params.maxBatchSize);
42
- const current = rt.updateStrategy(newConfig);
43
- return toolResult(JSON.stringify({
44
- success: true,
45
- batchWindowMs: current.batchWindowMs,
46
- maxBatchSize: current.maxBatchSize,
47
- }));
48
- } catch (err) {
49
- return fail((err as Error).message);
50
- }
51
- },
52
- };
53
- }
54
-
55
- /**
56
- * get_status — frozen return shape per §0.2:
57
- *
58
- * {
59
- * success, connected, agentId,
60
- * schedulerQueueSize, joinedChannels,
61
- * channels: [{ id, name, lastVisit, lastReply, lastMsgSeq }]
62
- * }
63
- */
64
- export function createGetStatusTool(): ToolDescriptor {
65
- return {
66
- name: 'openagent_get_status',
67
- label: 'Get OpenAgent Status',
68
- description: 'Get current status of the OpenAgent connection and channel state',
69
- parameters: { type: 'object', properties: {}, required: [] },
70
- async execute() {
71
- const rt = getRuntime();
72
- if (!rt) {
73
- return fail('OpenAgent is not running');
74
- }
75
- try {
76
- const joined = rt.store?.getJoinedChannels() || [];
77
- return toolResult(JSON.stringify({
78
- success: true,
79
- connected: rt.client?.isReady ?? false,
80
- agentId: rt.client?.agentId ?? '',
81
- schedulerQueueSize: rt.schedulerQueueSize,
82
- joinedChannels: joined.length,
83
- channels: joined.map((c: { channel_id: string; channel_name: string; last_visit: number; last_reply: number; last_msg_seq: number }) => ({
84
- id: c.channel_id,
85
- name: c.channel_name,
86
- lastVisit: c.last_visit ? new Date(c.last_visit).toISOString() : 'never',
87
- lastReply: c.last_reply ? new Date(c.last_reply).toISOString() : 'never',
88
- lastMsgSeq: c.last_msg_seq,
89
- })),
90
- }));
91
- } catch (err) {
92
- return fail((err as Error).message);
93
- }
94
- },
95
- };
96
- }
97
-
98
- export function createSetPurposeTool(): ToolDescriptor {
99
- return {
100
- name: 'openagent_set_purpose',
101
- label: 'Set Channel Purpose',
102
- description: 'Set or update your purpose/goal for a channel',
103
- parameters: {
104
- type: 'object',
105
- properties: {
106
- channelId: { type: 'string', description: 'Channel ID' },
107
- purpose: { type: 'string', description: 'Your purpose/goal for this channel' },
108
- },
109
- required: ['channelId', 'purpose'],
110
- },
111
- async execute(_id, params) {
112
- const rt = getRuntime();
113
- if (!rt?.store) return fail('Not connected');
114
- try {
115
- rt.store.setPurpose(String(params.channelId), String(params.purpose));
116
- return toolResult(JSON.stringify({
117
- success: true,
118
- channelId: params.channelId,
119
- purpose: params.purpose,
120
- }));
121
- } catch (err) {
122
- return fail((err as Error).message);
123
- }
124
- },
125
- };
126
- }
127
-
128
- export function createGetPurposeTool(): ToolDescriptor {
129
- return {
130
- name: 'openagent_get_purpose',
131
- label: 'Get Channel Purpose',
132
- description: 'Get your current purpose/goal for a channel',
133
- parameters: {
134
- type: 'object',
135
- properties: {
136
- channelId: { type: 'string', description: 'Channel ID' },
137
- },
138
- required: ['channelId'],
139
- },
140
- async execute(_id, params) {
141
- const rt = getRuntime();
142
- if (!rt?.store) return fail('Not connected');
143
- try {
144
- const purpose = rt.store.getPurpose(String(params.channelId));
145
- return toolResult(JSON.stringify({
146
- success: true,
147
- channelId: params.channelId,
148
- purpose: purpose || '(no purpose set)',
149
- }));
150
- } catch (err) {
151
- return fail((err as Error).message);
152
- }
153
- },
154
- };
155
- }