@newbase-clawchat/openclaw-clawchat 2026.5.4 → 2026.5.12-13

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 (85) hide show
  1. package/INSTALL.md +64 -0
  2. package/README.md +121 -19
  3. package/dist/index.js +10 -19
  4. package/dist/setup-entry.js +3 -0
  5. package/dist/src/api-client.js +78 -10
  6. package/dist/src/api-types.test-d.js +10 -0
  7. package/dist/src/channel.js +25 -156
  8. package/dist/src/channel.setup.js +120 -0
  9. package/dist/src/client.js +37 -41
  10. package/dist/src/config.js +75 -17
  11. package/dist/src/inbound.js +79 -61
  12. package/dist/src/login.runtime.js +84 -19
  13. package/dist/src/media-runtime.js +8 -8
  14. package/dist/src/message-mapper.js +1 -1
  15. package/dist/src/mock-transport.js +31 -0
  16. package/dist/src/outbound.js +410 -26
  17. package/dist/src/protocol-types.js +63 -0
  18. package/dist/src/protocol-types.typecheck.js +1 -0
  19. package/dist/src/protocol.js +2 -7
  20. package/dist/src/reply-dispatcher.js +157 -54
  21. package/dist/src/runtime.js +795 -119
  22. package/dist/src/storage.js +689 -0
  23. package/dist/src/tools-schema.js +98 -16
  24. package/dist/src/tools.js +422 -135
  25. package/dist/src/ws-alignment.js +178 -0
  26. package/dist/src/ws-client.js +588 -0
  27. package/dist/src/ws-log.js +19 -0
  28. package/index.ts +10 -22
  29. package/openclaw.plugin.json +37 -2
  30. package/package.json +17 -4
  31. package/setup-entry.ts +4 -0
  32. package/skills/clawchat/SKILL.md +88 -0
  33. package/src/api-client.test.ts +274 -14
  34. package/src/api-client.ts +138 -23
  35. package/src/api-types.test-d.ts +12 -0
  36. package/src/api-types.ts +90 -4
  37. package/src/buffered-stream.test.ts +14 -12
  38. package/src/buffered-stream.ts +1 -1
  39. package/src/channel.outbound.test.ts +269 -60
  40. package/src/channel.setup.ts +146 -0
  41. package/src/channel.test.ts +130 -24
  42. package/src/channel.ts +30 -186
  43. package/src/client.test.ts +197 -11
  44. package/src/client.ts +50 -57
  45. package/src/config.test.ts +108 -6
  46. package/src/config.ts +95 -24
  47. package/src/inbound.test.ts +288 -37
  48. package/src/inbound.ts +96 -84
  49. package/src/login.runtime.test.ts +347 -13
  50. package/src/login.runtime.ts +105 -23
  51. package/src/manifest.test.ts +146 -74
  52. package/src/media-runtime.test.ts +57 -2
  53. package/src/media-runtime.ts +26 -17
  54. package/src/message-mapper.test.ts +2 -2
  55. package/src/message-mapper.ts +2 -2
  56. package/src/mock-transport.test.ts +35 -0
  57. package/src/mock-transport.ts +38 -0
  58. package/src/outbound.test.ts +694 -73
  59. package/src/outbound.ts +484 -31
  60. package/src/plugin-entry.test.ts +1 -0
  61. package/src/protocol-types.test.ts +69 -0
  62. package/src/protocol-types.ts +296 -0
  63. package/src/protocol-types.typecheck.ts +89 -0
  64. package/src/protocol.test.ts +1 -6
  65. package/src/protocol.ts +2 -7
  66. package/src/reply-dispatcher.test.ts +819 -119
  67. package/src/reply-dispatcher.ts +202 -60
  68. package/src/runtime.test.ts +2120 -41
  69. package/src/runtime.ts +935 -142
  70. package/src/scripts.test.ts +85 -0
  71. package/src/storage.test.ts +793 -0
  72. package/src/storage.ts +1095 -0
  73. package/src/streaming.test.ts +9 -8
  74. package/src/streaming.ts +1 -1
  75. package/src/tools-schema.ts +148 -20
  76. package/src/tools.test.ts +377 -50
  77. package/src/tools.ts +574 -154
  78. package/src/ws-alignment.test.ts +103 -0
  79. package/src/ws-alignment.ts +275 -0
  80. package/src/ws-client.test.ts +1218 -0
  81. package/src/ws-client.ts +662 -0
  82. package/src/ws-log.test.ts +32 -0
  83. package/src/ws-log.ts +31 -0
  84. package/skills/clawchat-account-tools/SKILL.md +0 -26
  85. package/skills/clawchat-activate/SKILL.md +0 -47
@@ -1,4 +1,4 @@
1
- import type { ClawlingChatClient } from "@newbase-clawchat/sdk";
1
+ import type { ClawlingChatClient } from "./ws-client.ts";
2
2
  import { describe, expect, it, vi } from "vitest";
3
3
  import { sendStreamingText } from "./streaming.ts";
4
4
 
@@ -23,7 +23,7 @@ describe("openclaw-clawchat streaming", () => {
23
23
  await sendStreamingText({
24
24
  client,
25
25
  to: { id: "u1", type: "direct" },
26
- sender: { sender_id: "a1", type: "direct", display_name: "Clawling" },
26
+ sender: { id: "a1", type: "direct", nick_name: "Clawling" },
27
27
  chunks: ["Hel", "lo ", "world"],
28
28
  messageId: "m1",
29
29
  });
@@ -47,7 +47,7 @@ describe("openclaw-clawchat streaming", () => {
47
47
  await sendStreamingText({
48
48
  client,
49
49
  to: { id: "u1", type: "direct" },
50
- sender: { sender_id: "a1", type: "direct", display_name: "Clawling" },
50
+ sender: { id: "a1", type: "direct", nick_name: "Clawling" },
51
51
  chunks: ["a", "b", "c"],
52
52
  messageId: "m1",
53
53
  });
@@ -65,7 +65,7 @@ describe("openclaw-clawchat streaming", () => {
65
65
  await sendStreamingText({
66
66
  client,
67
67
  to: { id: "u1", type: "direct" },
68
- sender: { sender_id: "a1", type: "direct", display_name: "Clawling" },
68
+ sender: { id: "a1", type: "direct", nick_name: "Clawling" },
69
69
  chunks: ["Hel", "lo ", "world"],
70
70
  messageId: "m1",
71
71
  });
@@ -88,7 +88,7 @@ describe("openclaw-clawchat streaming", () => {
88
88
  await sendStreamingText({
89
89
  client,
90
90
  to: { id: "u1", type: "direct" },
91
- sender: { sender_id: "a1", type: "direct", display_name: "Clawling" },
91
+ sender: { id: "a1", type: "direct", nick_name: "Clawling" },
92
92
  chunks: [],
93
93
  messageId: "m1",
94
94
  });
@@ -96,7 +96,7 @@ describe("openclaw-clawchat streaming", () => {
96
96
  expect(events).toEqual(["message.created", "message.done"]);
97
97
  });
98
98
 
99
- it("sendStreamingFailure emits failed with reason and typing(false)", async () => {
99
+ it("sendStreamingFailure emits failed with StreamDonePayload shape and typing(false)", async () => {
100
100
  const { client, sent } = mockClient();
101
101
  const { sendStreamingFailure } = await import("./streaming.ts");
102
102
  await sendStreamingFailure({
@@ -107,8 +107,9 @@ describe("openclaw-clawchat streaming", () => {
107
107
  reason: "boom",
108
108
  });
109
109
  expect(sent[0]!.event).toBe("message.failed");
110
- expect(sent[0]!.payload.sequence).toBe(2);
111
- expect(sent[0]!.payload.reason).toBe("boom");
110
+ expect(sent[0]!.payload).not.toHaveProperty("sequence");
111
+ expect(sent[0]!.payload).not.toHaveProperty("reason");
112
+ expect((sent[0]!.payload.streaming as { sequence: number }).sequence).toBe(2);
112
113
  expect(sent[0]!.payload).toHaveProperty("completed_at");
113
114
  expect(sent[0]!.payload).not.toHaveProperty("failed_at");
114
115
  expect(sent[0]!.payload.fragments).toEqual([{ kind: "text", text: "boom" }]);
package/src/streaming.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClawlingChatClient } from "@newbase-clawchat/sdk";
1
+ import type { ClawlingChatClient } from "./ws-client.ts";
2
2
  import {
3
3
  emitStreamAdd,
4
4
  emitStreamCreated,
@@ -5,33 +5,168 @@ export type ClawchatGetAccountProfileParams = Static<typeof ClawchatGetAccountPr
5
5
 
6
6
  export const ClawchatGetUserProfileSchema = Type.Object({
7
7
  userId: Type.String({
8
- description: "Target ClawChat user id (required). Do not infer this from a nickname.",
8
+ description:
9
+ "Explicit target ClawChat user id (required). Do not infer this from a nickname; use clawchat_get_account_profile for the agent's own connected ClawChat account unless an explicit userId is provided.",
9
10
  }),
10
11
  });
11
12
  export type ClawchatGetUserProfileParams = Static<typeof ClawchatGetUserProfileSchema>;
12
13
 
13
- export const ClawchatListAccountFriendsSchema = Type.Object({
14
- page: Type.Optional(Type.Integer({ minimum: 1, description: "1-based page number (default 1)" })),
15
- pageSize: Type.Optional(
14
+ export const ClawchatListAccountFriendsSchema = Type.Object({});
15
+ export type ClawchatListAccountFriendsParams = Static<typeof ClawchatListAccountFriendsSchema>;
16
+
17
+ export const ClawchatSearchUsersSchema = Type.Object({
18
+ q: Type.Optional(
19
+ Type.String({
20
+ description: "Search query for ClawChat username or nickname",
21
+ }),
22
+ ),
23
+ limit: Type.Optional(
16
24
  Type.Integer({
17
25
  minimum: 1,
18
26
  maximum: 100,
19
- description: "Page size 1..100 (default 20)",
27
+ description: "Max results (default 20)",
20
28
  }),
21
29
  ),
22
30
  });
23
- export type ClawchatListAccountFriendsParams = Static<typeof ClawchatListAccountFriendsSchema>;
31
+ export type ClawchatSearchUsersParams = Static<typeof ClawchatSearchUsersSchema>;
32
+
33
+ export const ClawchatListConversationsSchema = Type.Object({
34
+ before: Type.Optional(
35
+ Type.String({
36
+ description: "Cursor; return conversations before this value",
37
+ }),
38
+ ),
39
+ limit: Type.Optional(
40
+ Type.Integer({
41
+ minimum: 1,
42
+ maximum: 100,
43
+ description: "Max conversations to return",
44
+ }),
45
+ ),
46
+ });
47
+ export type ClawchatListConversationsParams = Static<typeof ClawchatListConversationsSchema>;
48
+
49
+ export const ClawchatGetConversationSchema = Type.Object({
50
+ conversationId: Type.String({
51
+ description: "Concrete ClawChat conversation id to fetch",
52
+ }),
53
+ });
54
+ export type ClawchatGetConversationParams = Static<typeof ClawchatGetConversationSchema>;
55
+
56
+ export const ClawchatListMomentsSchema = Type.Object({
57
+ before: Type.Optional(
58
+ Type.Integer({
59
+ minimum: 1,
60
+ description: "Cursor; return moments with id < before",
61
+ }),
62
+ ),
63
+ limit: Type.Optional(
64
+ Type.Integer({
65
+ minimum: 1,
66
+ maximum: 100,
67
+ description: "Max items (default 30)",
68
+ }),
69
+ ),
70
+ });
71
+ export type ClawchatListMomentsParams = Static<typeof ClawchatListMomentsSchema>;
72
+
73
+ export const ClawchatCreateMomentSchema = Type.Object({
74
+ text: Type.Optional(
75
+ Type.String({
76
+ description: "Moment text. At least one of text or images is required.",
77
+ }),
78
+ ),
79
+ images: Type.Optional(
80
+ Type.Array(
81
+ Type.String({
82
+ description: "Image URL for the moment. Upload local files first; do not pass local paths.",
83
+ }),
84
+ ),
85
+ ),
86
+ });
87
+ export type ClawchatCreateMomentParams = Static<typeof ClawchatCreateMomentSchema>;
88
+
89
+ export const ClawchatDeleteMomentSchema = Type.Object({
90
+ momentId: Type.Integer({
91
+ minimum: 1,
92
+ description: "Concrete ClawChat moment id to delete",
93
+ }),
94
+ });
95
+ export type ClawchatDeleteMomentParams = Static<typeof ClawchatDeleteMomentSchema>;
96
+
97
+ export const ClawchatToggleMomentReactionSchema = Type.Object({
98
+ momentId: Type.Integer({
99
+ minimum: 1,
100
+ description: "Concrete ClawChat moment id to react to",
101
+ }),
102
+ emoji: Type.String({
103
+ description: "Emoji reaction to toggle",
104
+ }),
105
+ });
106
+ export type ClawchatToggleMomentReactionParams = Static<
107
+ typeof ClawchatToggleMomentReactionSchema
108
+ >;
109
+
110
+ export const ClawchatCreateMomentCommentSchema = Type.Object({
111
+ momentId: Type.Integer({
112
+ minimum: 1,
113
+ description: "Concrete ClawChat moment id to comment on",
114
+ }),
115
+ text: Type.String({
116
+ description: "Top-level comment text",
117
+ }),
118
+ });
119
+ export type ClawchatCreateMomentCommentParams = Static<
120
+ typeof ClawchatCreateMomentCommentSchema
121
+ >;
122
+
123
+ export const ClawchatReplyMomentCommentSchema = Type.Object({
124
+ momentId: Type.Integer({
125
+ minimum: 1,
126
+ description: "Concrete ClawChat moment id containing the comment",
127
+ }),
128
+ replyToCommentId: Type.Integer({
129
+ minimum: 1,
130
+ description: "Concrete comment id being replied to",
131
+ }),
132
+ text: Type.String({
133
+ description: "Reply text",
134
+ }),
135
+ });
136
+ export type ClawchatReplyMomentCommentParams = Static<typeof ClawchatReplyMomentCommentSchema>;
137
+
138
+ export const ClawchatDeleteMomentCommentSchema = Type.Object({
139
+ momentId: Type.Integer({
140
+ minimum: 1,
141
+ description: "Concrete ClawChat moment id containing the comment",
142
+ }),
143
+ commentId: Type.Integer({
144
+ minimum: 1,
145
+ description: "Concrete comment id to delete",
146
+ }),
147
+ });
148
+ export type ClawchatDeleteMomentCommentParams = Static<
149
+ typeof ClawchatDeleteMomentCommentSchema
150
+ >;
24
151
 
25
152
  export const ClawchatUpdateAccountProfileSchema = Type.Object({
26
- nickname: Type.Optional(Type.String({ description: "New ClawChat account nickname" })),
153
+ nickname: Type.Optional(
154
+ Type.String({
155
+ description:
156
+ "New nickname/display name for the agent's connected ClawChat account, mirroring the local assistant identity",
157
+ }),
158
+ ),
27
159
  avatar_url: Type.Optional(
28
160
  Type.String({
29
161
  description:
30
- "Avatar URL for the ClawChat account profile (use clawchat_upload_avatar_image first to obtain one from a local image)",
162
+ "Avatar URL for the agent's connected ClawChat account profile (use clawchat_upload_avatar_image first to obtain one from a local image)",
31
163
  }),
32
164
  ),
33
165
  bio: Type.Optional(
34
- Type.String({ description: "New ClawChat account self-introduction / bio text" }),
166
+ Type.String({
167
+ description:
168
+ "New self-introduction / bio text for the agent's connected ClawChat account, mirroring the local assistant identity",
169
+ }),
35
170
  ),
36
171
  });
37
172
  export type ClawchatUpdateAccountProfileParams = Static<
@@ -40,23 +175,16 @@ export type ClawchatUpdateAccountProfileParams = Static<
40
175
 
41
176
  export const ClawchatUploadMediaFileSchema = Type.Object({
42
177
  filePath: Type.String({
43
- description: "Absolute local path of the media/file to upload to ClawChat (max 20MB)",
178
+ description:
179
+ "Absolute local path of the non-avatar media/file to upload to ClawChat for a ClawChat-accessible URL (max 20MB)",
44
180
  }),
45
181
  });
46
182
  export type ClawchatUploadMediaFileParams = Static<typeof ClawchatUploadMediaFileSchema>;
47
183
 
48
184
  export const ClawchatUploadAvatarImageSchema = Type.Object({
49
185
  filePath: Type.String({
50
- description: "Absolute local path of the avatar image to upload to ClawChat (max 20MB)",
51
- }),
52
- });
53
- export type ClawchatUploadAvatarImageParams = Static<typeof ClawchatUploadAvatarImageSchema>;
54
-
55
- export const ClawchatActivateSchema = Type.Object({
56
- code: Type.String({
57
186
  description:
58
- "The invite code (six uppercase letters/digits, e.g. 'A1B2C3') extracted from the user's message. " +
59
- "Whitespace is trimmed automatically.",
187
+ "Absolute local path of the avatar image to upload for the agent's connected ClawChat account (max 20MB)",
60
188
  }),
61
189
  });
62
- export type ClawchatActivateParams = Static<typeof ClawchatActivateSchema>;
190
+ export type ClawchatUploadAvatarImageParams = Static<typeof ClawchatUploadAvatarImageSchema>;