clawsocial-plugin 1.0.16 → 1.0.17

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/index.ts CHANGED
@@ -9,6 +9,7 @@ import { createSessionsListTool } from "./src/tools/sessions_list.js";
9
9
  import { createSessionGetTool } from "./src/tools/session_get.js";
10
10
  import { createBlockTool } from "./src/tools/block.js";
11
11
  import { createOpenInboxTool } from "./src/tools/open_inbox.js";
12
+ import { createUpdateProfileTool } from "./src/tools/update_profile.js";
12
13
 
13
14
  export default {
14
15
  id: "clawsocial-plugin",
@@ -38,6 +39,7 @@ export default {
38
39
  createSessionGetTool(serverUrl),
39
40
  createBlockTool(),
40
41
  createOpenInboxTool(),
42
+ createUpdateProfileTool(),
41
43
  ];
42
44
 
43
45
  for (const tool of tools) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawsocial-plugin",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "ClawSocial OpenClaw Plugin — social discovery for AI agents",
5
5
  "type": "module",
6
6
  "dependencies": {
package/src/api.ts CHANGED
@@ -83,6 +83,7 @@ const api = {
83
83
  listSessions: () => request<SessionsListResult>("GET", "/sessions"),
84
84
  getSession: (id: string) => request<SessionResult>("GET", `/sessions/${id}`),
85
85
  openInboxToken: () => request<{ url: string; expires_in: number }>("POST", "/auth/web-token"),
86
+ updateProfile: (body: Record<string, unknown>) => request("PATCH", "/agents/me", body),
86
87
  };
87
88
 
88
89
  export default api;
@@ -0,0 +1,86 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import type { AnyAgentTool } from "../types.js";
3
+ import api from "../api.js";
4
+ import { getState } from "../store.js";
5
+
6
+ export function createUpdateProfileTool(): AnyAgentTool {
7
+ return {
8
+ name: "clawsocial_update_profile",
9
+ label: "ClawSocial 更新资料",
10
+ description:
11
+ "Update your ClawSocial profile — interests, topic tags, availability, or public name. " +
12
+ "Use when the user describes who they are, what they are interested in, or wants to change their profile.",
13
+ parameters: Type.Object({
14
+ interest_text: Type.Optional(
15
+ Type.String({
16
+ description:
17
+ "A natural-language summary of the user's interests, role, or what they want to connect about. " +
18
+ "E.g. 'I'm a designer interested in AI art, generative music, and creative coding.'",
19
+ }),
20
+ ),
21
+ topic_tags: Type.Optional(
22
+ Type.Array(Type.String(), {
23
+ description:
24
+ "Short keyword tags extracted from interests. E.g. ['AI art', 'generative music', 'creative coding']",
25
+ }),
26
+ ),
27
+ public_name: Type.Optional(
28
+ Type.String({ description: "Change your public display name" }),
29
+ ),
30
+ availability: Type.Optional(
31
+ Type.Unsafe<"open" | "by-request" | "closed">({
32
+ type: "string",
33
+ enum: ["open", "by-request", "closed"],
34
+ description: "Discoverability: open (default), by-request, or closed",
35
+ }),
36
+ ),
37
+ }),
38
+ async execute(_id: string, params: Record<string, unknown>) {
39
+ const state = getState();
40
+ if (!state.agent_id || !state.token) {
41
+ return {
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: JSON.stringify({
46
+ error: "尚未注册 ClawSocial,请先使用 clawsocial_register 注册。",
47
+ }),
48
+ },
49
+ ],
50
+ };
51
+ }
52
+
53
+ const body: Record<string, unknown> = {};
54
+ if (params.interest_text) body.interest_text = params.interest_text;
55
+ if (params.topic_tags) body.topic_tags = params.topic_tags;
56
+ if (params.public_name) body.public_name = params.public_name;
57
+ if (params.availability) body.availability = params.availability;
58
+
59
+ if (Object.keys(body).length === 0) {
60
+ return {
61
+ content: [
62
+ {
63
+ type: "text",
64
+ text: JSON.stringify({ error: "没有提供任何要更新的内容。" }),
65
+ },
66
+ ],
67
+ };
68
+ }
69
+
70
+ await api.updateProfile(body);
71
+
72
+ return {
73
+ content: [
74
+ {
75
+ type: "text",
76
+ text: JSON.stringify({
77
+ ok: true,
78
+ message: "✅ 资料已更新!其他人现在可以根据你的兴趣找到你了。",
79
+ updated: Object.keys(body),
80
+ }),
81
+ },
82
+ ],
83
+ };
84
+ },
85
+ } as AnyAgentTool;
86
+ }