openclaw-openagent 1.0.0

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 (113) hide show
  1. package/index.ts +114 -0
  2. package/openclaw.plugin.json +159 -0
  3. package/package.json +79 -0
  4. package/skills/clawlink/SKILL.md +145 -0
  5. package/skills/clawlink/SKILL.md.bak +165 -0
  6. package/src/app/channel-tools.ts +249 -0
  7. package/src/app/discovery-tools.ts +273 -0
  8. package/src/app/hooks.ts +60 -0
  9. package/src/app/index.ts +78 -0
  10. package/src/app/messaging-tools.ts +79 -0
  11. package/src/app/ops-tools.ts +155 -0
  12. package/src/app/remote-agent-tool.ts +476 -0
  13. package/src/app/types.ts +67 -0
  14. package/src/app/verbose-preflight.ts +190 -0
  15. package/src/auth/config.ts +197 -0
  16. package/src/auth/credential-manager.ts +146 -0
  17. package/src/auth/index.ts +24 -0
  18. package/src/auth/verify.ts +99 -0
  19. package/src/channel.ts +565 -0
  20. package/src/compat.ts +82 -0
  21. package/src/config/config-schema.ts +39 -0
  22. package/src/messaging/aggregator.ts +120 -0
  23. package/src/messaging/collector.ts +89 -0
  24. package/src/messaging/executor.ts +72 -0
  25. package/src/messaging/inbound.ts +150 -0
  26. package/src/messaging/index.ts +11 -0
  27. package/src/messaging/mention-protocol.ts +94 -0
  28. package/src/messaging/process-c2c-request.ts +564 -0
  29. package/src/messaging/process-message.ts +373 -0
  30. package/src/messaging/scheduler.ts +55 -0
  31. package/src/messaging/types.ts +38 -0
  32. package/src/plugin-ui/assets/agentbook-icon.svg +5 -0
  33. package/src/plugin-ui/assets/magic.svg +5 -0
  34. package/src/plugin-ui/assets/openagent-override.js +9329 -0
  35. package/src/plugin-ui/build.cjs +175 -0
  36. package/src/plugin-ui/index.ts +18 -0
  37. package/src/plugin-ui/modules/agent-book/panel/agent-book.js +458 -0
  38. package/src/plugin-ui/modules/agent-book/panel/agent-card.js +154 -0
  39. package/src/plugin-ui/modules/agent-book/panel/agent-data.js +644 -0
  40. package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +456 -0
  41. package/src/plugin-ui/modules/agent-book/panel/mention-state.js +206 -0
  42. package/src/plugin-ui/modules/agent-book/panel/styles.js +670 -0
  43. package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +293 -0
  44. package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +208 -0
  45. package/src/plugin-ui/modules/agent-book/scanner.js +119 -0
  46. package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +500 -0
  47. package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +652 -0
  48. package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +251 -0
  49. package/src/plugin-ui/modules/loader/bootstrap.js +38 -0
  50. package/src/plugin-ui/modules/loader/shared-state.js +560 -0
  51. package/src/plugin-ui/modules/loader/ws-intercept.js +199 -0
  52. package/src/plugin-ui/modules/remote-agent/chunk-parser.js +161 -0
  53. package/src/plugin-ui/modules/remote-agent/execution-card.js +269 -0
  54. package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +256 -0
  55. package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +146 -0
  56. package/src/plugin-ui/modules/remote-agent/output-card.js +259 -0
  57. package/src/plugin-ui/modules/remote-agent/progress-store.js +363 -0
  58. package/src/plugin-ui/modules/remote-agent/render-hooks.js +1609 -0
  59. package/src/plugin-ui/modules/remote-agent/styles.js +668 -0
  60. package/src/plugin-ui/modules/remote-agent/tool-card-model.js +56 -0
  61. package/src/plugin-ui/ui-extension-loader/backup.ts +92 -0
  62. package/src/plugin-ui/ui-extension-loader/index.ts +276 -0
  63. package/src/plugin-ui/ui-extension-loader/locator.ts +152 -0
  64. package/src/plugin-ui/ui-extension-loader/manifest.ts +57 -0
  65. package/src/plugin-ui/ui-extension-loader/registry-regex.ts +729 -0
  66. package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +70 -0
  67. package/src/plugin-ui/ui-extension-loader/types.ts +68 -0
  68. package/src/proxy/auth-proxy.ts +356 -0
  69. package/src/runtime/account.ts +572 -0
  70. package/src/runtime/index.ts +7 -0
  71. package/src/runtime/plugin-runtime.ts +94 -0
  72. package/src/runtime/registry.ts +71 -0
  73. package/src/sdk/CLASS_MAP.md +143 -0
  74. package/src/sdk/index.d.ts +126 -0
  75. package/src/sdk/index.js +23990 -0
  76. package/src/sdk/modules/cloud-search-module.js +1117 -0
  77. package/src/sdk/modules/follow-module.js +1069 -0
  78. package/src/sdk/modules/group-module.js +7397 -0
  79. package/src/sdk/modules/relationship-module.js +2269 -0
  80. package/src/sdk/modules/signaling-module.js +1468 -0
  81. package/src/sdk/modules/tim-upload-plugin.js +730 -0
  82. package/src/sdk/node-env/http-request.js +90 -0
  83. package/src/sdk/node-env/index.js +57 -0
  84. package/src/sdk/node-env/storage.js +114 -0
  85. package/src/sdk/package.json +10 -0
  86. package/src/sdk/tsconfig.json +16 -0
  87. package/src/state/pending-invocation-store.ts +43 -0
  88. package/src/state/store.ts +676 -0
  89. package/src/tim/c2c.ts +451 -0
  90. package/src/tim/channels.ts +364 -0
  91. package/src/tim/client.ts +330 -0
  92. package/src/tim/index.ts +18 -0
  93. package/src/tim/messages.ts +166 -0
  94. package/src/tim/sdk-logger-init.ts +50 -0
  95. package/src/tools.ts +10 -0
  96. package/src/transport/factory.ts +95 -0
  97. package/src/transport/oasn/index.ts +17 -0
  98. package/src/transport/oasn/oasn-agent-card.ts +111 -0
  99. package/src/transport/oasn/oasn-discovery.ts +108 -0
  100. package/src/transport/oasn/oasn-files.ts +210 -0
  101. package/src/transport/oasn/oasn-http.ts +483 -0
  102. package/src/transport/oasn/oasn-invocation.ts +527 -0
  103. package/src/transport/oasn/oasn-normalize.ts +159 -0
  104. package/src/transport/oasn/oasn-register.ts +106 -0
  105. package/src/transport/oasn/oasn-transport.ts +341 -0
  106. package/src/transport/oasn/oasn-types.ts +353 -0
  107. package/src/transport/tim/index.ts +8 -0
  108. package/src/transport/tim/tim-transport.ts +515 -0
  109. package/src/transport/types.ts +541 -0
  110. package/src/types/openclaw.d.ts +97 -0
  111. package/src/types/tencentcloud-chat.d.ts +15 -0
  112. package/src/util/http.ts +113 -0
  113. package/src/util/logger.ts +131 -0
@@ -0,0 +1,353 @@
1
+ /**
2
+ * OASN API 请求/响应类型定义
3
+ *
4
+ * 设计依据:
5
+ * - docs/specs/2026-06-16-oasn-api-module-mapping.md
6
+ * - oasn-01-onboarding/apis.md(agent / claim / auth / agent-card / discovery)
7
+ * - oasn-02-access-layer/apis.md(invocation / file / artifact)
8
+ *
9
+ * 这些类型仅在 OASN transport 内部使用,对外暴露的通用类型在 src/transport/types.ts。
10
+ * onboarding controller 的 Java record 当前使用 camelCase 请求/响应字段;
11
+ * transport 层兼容历史 snake_case 响应,并对外归一到 src/transport/types.ts 的稳定模型。
12
+ */
13
+
14
+ // ═══════════════════════════════════════════════════════════════
15
+ // 通用错误响应
16
+ // ═══════════════════════════════════════════════════════════════
17
+
18
+ /**
19
+ * OASN 统一错误响应格式(所有 4xx/5xx 接口返回此结构)。
20
+ * 详见 api-module-mapping.md §五 通用错误处理。
21
+ */
22
+ export interface OasnErrorBody {
23
+ error: {
24
+ /** 错误码:UNAUTHENTICATED / FORBIDDEN / TARGET_UNAVAILABLE / ... */
25
+ code: string;
26
+ /** 人类可读消息 */
27
+ message: string;
28
+ /** 客户端是否可重试(服务端裁决) */
29
+ retryable: boolean;
30
+ /** 附加上下文(端点定义具体字段) */
31
+ details?: Record<string, unknown>;
32
+ /** 排障追踪 id */
33
+ request_id?: string;
34
+ };
35
+ }
36
+
37
+ // ═══════════════════════════════════════════════════════════════
38
+ // Agent 注册 / 认领
39
+ // ═══════════════════════════════════════════════════════════════
40
+
41
+ export interface RegisterAgentRequest {
42
+ /** 当前固定为 "openclaw"(也可能是 "codex" / "claude_code" / "hermes") */
43
+ platform: string;
44
+ }
45
+
46
+ export interface RegisterAgentResponse {
47
+ agentId?: string;
48
+ agent_id?: string;
49
+ agentType?: 'client';
50
+ agent_type?: 'client';
51
+ /** 一次性明文 api_key,仅此响应返回;服务端只存 hash */
52
+ apiKey?: string;
53
+ api_key?: string;
54
+ claimUrl?: string;
55
+ claim_url?: string;
56
+ status: 'unclaimed';
57
+ agentCard?: AgentCardResponse;
58
+ agent_card?: AgentCardResponse;
59
+ }
60
+
61
+ export interface AgentStatusResponse {
62
+ agentId?: string;
63
+ agent_id?: string;
64
+ status: 'unclaimed' | 'claim_pending' | 'claimed';
65
+ access_token?: string;
66
+ accessToken?: string;
67
+ }
68
+
69
+ export interface AgentCardResponse {
70
+ agentId?: string;
71
+ agent_id?: string;
72
+ agentType?: 'client' | 'service';
73
+ agent_type?: 'client' | 'service';
74
+ agentStatus?: string;
75
+ agent_status?: string;
76
+ claimStatus?: string;
77
+ claim_status?: string;
78
+ name: string;
79
+ description: string | null;
80
+ MOM: string | null;
81
+ tags: Array<{ tagId?: string; tag_id?: string; name: string }>;
82
+ category: string[];
83
+ avatarRef?: string | null;
84
+ avatar_ref?: string | null;
85
+ avatarUrl?: string | null;
86
+ avatar_url?: string | null;
87
+ visibility?: 'public' | 'private';
88
+ publicMetadata?: Record<string, unknown> | null;
89
+ public_metadata?: Record<string, unknown> | null;
90
+ updatedAt?: string;
91
+ updated_at?: string;
92
+ }
93
+
94
+ export interface ClaimAgentRequest {
95
+ agentId?: string;
96
+ claimToken?: string;
97
+ ownerEmail: string;
98
+ }
99
+
100
+ export interface ClaimAgentResponse {
101
+ agentId?: string;
102
+ agent_id?: string;
103
+ status: 'claim_email_sent';
104
+ ownerEmailMasked?: string;
105
+ owner_email_masked?: string;
106
+ expiresAt?: string;
107
+ expires_at?: string;
108
+ }
109
+
110
+ export interface UpdateAgentCardRequest {
111
+ name?: string | null;
112
+ description?: string | null;
113
+ MOM?: string | null;
114
+ tags?: string[] | null;
115
+ category?: string[] | null;
116
+ avatarRef?: string | null;
117
+ visibility?: 'public' | 'private';
118
+ publicMetadata?: Record<string, unknown> | null;
119
+ }
120
+
121
+ // ═══════════════════════════════════════════════════════════════
122
+ // Discovery
123
+ // ═══════════════════════════════════════════════════════════════
124
+
125
+ export interface CategoryNodeResponse {
126
+ categoryId?: string;
127
+ category_id?: string;
128
+ name: string;
129
+ children?: CategoryNodeResponse[];
130
+ }
131
+
132
+ export interface CategoryTreeResponse {
133
+ categories: CategoryNodeResponse[];
134
+ updatedAt?: string;
135
+ updated_at?: string;
136
+ }
137
+
138
+ /** 三种搜索端点的请求结构 */
139
+ export interface SearchByQueryRequest {
140
+ query: string;
141
+ agentTypes?: string[];
142
+ sort?: string[];
143
+ pageSize?: number;
144
+ pageNum?: number;
145
+ }
146
+
147
+ export interface SearchByCategoryRequest {
148
+ category: string[];
149
+ agentTypes?: string[];
150
+ sort?: string[];
151
+ pageSize?: number;
152
+ pageNum?: number;
153
+ }
154
+
155
+ export interface SearchByTagsRequest {
156
+ tags: string[];
157
+ agentTypes?: string[];
158
+ sort?: string[];
159
+ pageSize?: number;
160
+ pageNum?: number;
161
+ }
162
+
163
+ export interface SearchResponse {
164
+ searchId?: string;
165
+ search_id?: string;
166
+ agentCards?: AgentCardResponse[];
167
+ agent_cards?: AgentCardResponse[];
168
+ pageNum?: number;
169
+ page_num?: number;
170
+ pageSize?: number;
171
+ page_size?: number;
172
+ hasNext?: boolean;
173
+ has_next?: boolean;
174
+ }
175
+
176
+ // ═══════════════════════════════════════════════════════════════
177
+ // Invocation(核心路径 ⭐)
178
+ // ═══════════════════════════════════════════════════════════════
179
+
180
+ export interface CreateInvocationRequest {
181
+ /** 客户端生成的幂等 key(详见 §11.1) */
182
+ idempotency_key: string;
183
+ service_agent_id: string;
184
+ /** 显式输入意图,至少包含 task 字段 */
185
+ input: { task: string } & Record<string, unknown>;
186
+ session_id?: string;
187
+ input_file_refs?: string[];
188
+ input_artifact_refs?: string[];
189
+ /** 期望超时(服务端裁决最终 effective_timeout_ms) */
190
+ timeout_ms?: number;
191
+ /** 客户端分组标识(可选) */
192
+ client_request_group_id?: string;
193
+ }
194
+
195
+ export interface CreateInvocationResponse {
196
+ invocationId?: string;
197
+ invocation_id?: string;
198
+ sessionId?: string;
199
+ session_id?: string;
200
+ status: 'accepted' | 'queued';
201
+ serviceAgentId?: string;
202
+ service_agent_id?: string;
203
+ effectiveTimeoutMs?: number;
204
+ effective_timeout_ms?: number;
205
+ nextPollAfterMs?: number;
206
+ next_poll_after_ms?: number;
207
+ /** 是否幂等重放(同一 idempotency_key 多次请求返回 true) */
208
+ idempotentReplay?: boolean;
209
+ idempotent_replay?: boolean;
210
+ createdAt?: string;
211
+ created_at?: string;
212
+ }
213
+
214
+ /** Invocation 状态枚举 */
215
+ export type InvocationStatus =
216
+ | 'accepted'
217
+ | 'queued'
218
+ | 'running'
219
+ | 'succeeded'
220
+ | 'failed'
221
+ | 'timed_out'
222
+ | 'cancelled';
223
+
224
+ /** 是否进入终态(停止轮询) */
225
+ export function isInvocationTerminal(status: InvocationStatus): boolean {
226
+ return status === 'succeeded'
227
+ || status === 'failed'
228
+ || status === 'timed_out'
229
+ || status === 'cancelled';
230
+ }
231
+
232
+ export interface InvocationProgress {
233
+ lifecycleState?: string;
234
+ lifecycle_state?: string;
235
+ activityCategory?: string;
236
+ activity_category?: string;
237
+ progressPercent?: number;
238
+ progress_percent?: number;
239
+ elapsedMs?: number;
240
+ elapsed_ms?: number;
241
+ /** 可对外展示的安全状态描述(已脱敏) */
242
+ safeStatusMessage?: string;
243
+ safe_status_message?: string;
244
+ }
245
+
246
+ export interface ArtifactResponse {
247
+ artifactId?: string;
248
+ artifact_id?: string;
249
+ displayName?: string;
250
+ display_name?: string;
251
+ mimeType?: string;
252
+ mime_type?: string;
253
+ sizeBytes?: number;
254
+ size_bytes?: number;
255
+ contentAvailable?: boolean;
256
+ content_available?: boolean;
257
+ contentUrl?: string;
258
+ content_url?: string;
259
+ }
260
+
261
+ export interface GetInvocationResponse {
262
+ invocationId?: string;
263
+ invocation_id?: string;
264
+ sessionId?: string;
265
+ session_id?: string;
266
+ status: InvocationStatus;
267
+ progress?: InvocationProgress;
268
+ inlineResult?: {
269
+ summary: string;
270
+ [key: string]: unknown;
271
+ };
272
+ inline_result?: {
273
+ summary: string;
274
+ [key: string]: unknown;
275
+ };
276
+ artifacts?: ArtifactResponse[];
277
+ /** 终态时为 null */
278
+ nextPollAfterMs?: number | null;
279
+ next_poll_after_ms?: number | null;
280
+ warnings?: string[];
281
+ userError?: { code: string; message: string };
282
+ user_error?: { code: string; message: string };
283
+ createdAt?: string;
284
+ created_at?: string;
285
+ updatedAt?: string;
286
+ updated_at?: string;
287
+ }
288
+
289
+ // ═══════════════════════════════════════════════════════════════
290
+ // File / Artifact
291
+ // ═══════════════════════════════════════════════════════════════
292
+
293
+ export interface UploadFileResponse {
294
+ file_ref: string;
295
+ display_name: string;
296
+ mime_type: string;
297
+ size_bytes: number;
298
+ /** ISO 8601 字符串 */
299
+ expires_at: string;
300
+ created_at: string;
301
+ }
302
+
303
+ // Artifact 下载返回二进制,没有 JSON 结构 —— 详见 oasn-files.ts
304
+
305
+ // ═══════════════════════════════════════════════════════════════
306
+ // Owner
307
+ // ═══════════════════════════════════════════════════════════════
308
+
309
+ export interface OwnerInfoResponse {
310
+ ownerId?: string;
311
+ owner_id?: string;
312
+ ownerType?: string;
313
+ owner_type?: string;
314
+ displayName?: string;
315
+ display_name?: string;
316
+ emailMasked?: string;
317
+ email_masked?: string;
318
+ emailVerifiedAt?: string;
319
+ email_verified_at?: string;
320
+ status: string;
321
+ }
322
+
323
+ // ═══════════════════════════════════════════════════════════════
324
+ // 端点常量
325
+ // ═══════════════════════════════════════════════════════════════
326
+
327
+ /** OASN HTTP 端点路径(相对于 api_base) */
328
+ export const OASN_ENDPOINTS = {
329
+ // Agent
330
+ REGISTER: '/api/agents/register',
331
+ CLAIM: '/api/agents/claim',
332
+ AGENT_STATUS: (agentId: string) => `/api/agents/${encodeURIComponent(agentId)}`,
333
+
334
+ // AgentCard
335
+ AGENT_CARD: (agentId: string) => `/api/agent-cards/${encodeURIComponent(agentId)}`,
336
+
337
+ // Discovery
338
+ CATEGORIES: '/api/agent-card-categories',
339
+ SEARCH_BY_QUERY: '/api/agent-cards/search/by-query',
340
+ SEARCH_BY_CATEGORY: '/api/agent-cards/search/by-category',
341
+ SEARCH_BY_TAGS: '/api/agent-cards/search/by-tags',
342
+
343
+ // Invocation
344
+ INVOCATIONS: '/api/invocations',
345
+ INVOCATION: (id: string) => `/api/invocations/${encodeURIComponent(id)}`,
346
+
347
+ // File / Artifact
348
+ FILES: '/api/files',
349
+ ARTIFACT_CONTENT: (id: string) => `/api/artifacts/${encodeURIComponent(id)}/content`,
350
+
351
+ // Owner
352
+ USERS_ME: '/api/users/me',
353
+ } as const;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * TimTransport 模块导出
3
+ *
4
+ * 设计依据:docs/specs/2026-06-16-oasn-transport-abstraction-design.md §3.1
5
+ */
6
+
7
+ export { TimTransportImpl } from './tim-transport.js';
8
+ export type { TimTransportInitOptions } from './tim-transport.js';