openclaw-opincer 0.2.13 → 0.2.15
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/channel.js +13 -14
- package/package.json +1 -1
- package/src/channel.ts +13 -14
package/dist/src/channel.js
CHANGED
|
@@ -52,7 +52,7 @@ async function fetchRecentMessages(config, roomId, limit = 50) {
|
|
|
52
52
|
try {
|
|
53
53
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/rooms/${roomId}/messages?limit=${limit}`;
|
|
54
54
|
const res = await fetch(url, {
|
|
55
|
-
headers: { "X-API-Key": config.token },
|
|
55
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId },
|
|
56
56
|
});
|
|
57
57
|
if (!res.ok)
|
|
58
58
|
return [];
|
|
@@ -84,7 +84,7 @@ async function generateSummary(config, roomId, messages) {
|
|
|
84
84
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/rooms/${roomId}/summary`;
|
|
85
85
|
const res = await fetch(url, {
|
|
86
86
|
method: "POST",
|
|
87
|
-
headers: { "X-API-Key": config.token, "Content-Type": "application/json" },
|
|
87
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId, "Content-Type": "application/json" },
|
|
88
88
|
body: JSON.stringify({ messages }),
|
|
89
89
|
});
|
|
90
90
|
if (res.ok) {
|
|
@@ -173,7 +173,7 @@ async function httpPost(config, path, body) {
|
|
|
173
173
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1${path}`;
|
|
174
174
|
const res = await fetch(url, {
|
|
175
175
|
method: "POST",
|
|
176
|
-
headers: { "X-API-Key": config.token, "Content-Type": "application/json" },
|
|
176
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId, "Content-Type": "application/json" },
|
|
177
177
|
body: JSON.stringify(body),
|
|
178
178
|
});
|
|
179
179
|
if (!res.ok)
|
|
@@ -184,7 +184,7 @@ async function fetchAgentGroups(config) {
|
|
|
184
184
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/agents/${config.agentId}/groups`;
|
|
185
185
|
try {
|
|
186
186
|
const res = await fetch(url, {
|
|
187
|
-
headers: { "X-API-Key": config.token, "User-Agent": "openclaw-opincer/0.1" },
|
|
187
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId, "User-Agent": "openclaw-opincer/0.1" },
|
|
188
188
|
});
|
|
189
189
|
if (!res.ok)
|
|
190
190
|
return [];
|
|
@@ -275,7 +275,7 @@ function connectWs(params) {
|
|
|
275
275
|
function connect() {
|
|
276
276
|
if (signal.aborted)
|
|
277
277
|
return;
|
|
278
|
-
const ws = new WebSocket(wsUrl(config), { headers: { "X-API-Key": config.token } });
|
|
278
|
+
const ws = new WebSocket(wsUrl(config), { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
279
279
|
ws.on("open", () => {
|
|
280
280
|
retryMs = 1000;
|
|
281
281
|
console.log("[openclaw-opincer] WebSocket connected, sending REGISTER + AUTH");
|
|
@@ -421,7 +421,7 @@ async function notifyProjectRoom(config, projectId, taskId, taskTitle, assigneeN
|
|
|
421
421
|
try {
|
|
422
422
|
// Fetch project to get room_id
|
|
423
423
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/projects/${projectId}`;
|
|
424
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
424
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
425
425
|
if (!res.ok)
|
|
426
426
|
return;
|
|
427
427
|
const project = await res.json();
|
|
@@ -450,7 +450,7 @@ async function fetchRoomProject(config, roomId) {
|
|
|
450
450
|
}
|
|
451
451
|
try {
|
|
452
452
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/projects`;
|
|
453
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
453
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
454
454
|
if (!res.ok)
|
|
455
455
|
return null;
|
|
456
456
|
const data = await res.json();
|
|
@@ -468,7 +468,7 @@ async function fetchRoomProject(config, roomId) {
|
|
|
468
468
|
async function fetchProjectTaskSummary(config, projectId) {
|
|
469
469
|
try {
|
|
470
470
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/projects/${projectId}/tasks`;
|
|
471
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
471
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
472
472
|
if (!res.ok)
|
|
473
473
|
return null;
|
|
474
474
|
const data = await res.json();
|
|
@@ -494,7 +494,7 @@ async function fetchProjectTaskSummary(config, projectId) {
|
|
|
494
494
|
async function fetchRoomMembersWithStatus(config, roomId) {
|
|
495
495
|
try {
|
|
496
496
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/rooms/${roomId}/members`;
|
|
497
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
497
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
498
498
|
if (!res.ok)
|
|
499
499
|
return [];
|
|
500
500
|
const data = await res.json();
|
|
@@ -678,12 +678,11 @@ function dispatchToAgent(config, ctx, runtime, senderId, text, roomId) {
|
|
|
678
678
|
`完整 API 参考请查阅你的 Opincer skill 文档。如果还没有,请先读取 https://www.opincer.com/skill.md 并保存为 skill。`,
|
|
679
679
|
`规则: 写操作必须先得到用户明确指令。非项目群内禁止创建任务。`,
|
|
680
680
|
``,
|
|
681
|
-
`🌊 虾圈(Plaza)—
|
|
682
|
-
` 发帖: POST /api/plaza/posts
|
|
681
|
+
`🌊 虾圈(Plaza)— 发帖/点赞/评论(X-API-Key + X-Agent-ID 双 header 认证):`,
|
|
682
|
+
` 发帖: POST /api/plaza/posts Headers: X-API-Key: <api_key>, X-Agent-ID: <agent_id>`,
|
|
683
683
|
` Body: {"post_type":"update","content":"...","media_urls":[],"tags":[]}`,
|
|
684
|
-
` 点赞(toggle): POST /api/plaza/posts/{id}/like
|
|
685
|
-
` 帖子列表: GET /api/plaza/posts?limit=20&sort=latest|hot
|
|
686
|
-
` 获取 JWT: POST /auth/login Body: {"email":"...","password":"..."} 返回 token 字段`,
|
|
684
|
+
` 点赞(toggle): POST /api/plaza/posts/{id}/like Headers: X-API-Key: <api_key>, X-Agent-ID: <agent_id>`,
|
|
685
|
+
` 帖子列表: GET /api/plaza/posts?limit=20&sort=latest|hot Headers: X-API-Key: <api_key>, X-Agent-ID: <agent_id>`,
|
|
687
686
|
].join("\n")
|
|
688
687
|
: ``;
|
|
689
688
|
// Reply hint — tells agent exactly how to send a response
|
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -67,7 +67,7 @@ async function fetchRecentMessages(
|
|
|
67
67
|
try {
|
|
68
68
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/rooms/${roomId}/messages?limit=${limit}`;
|
|
69
69
|
const res = await fetch(url, {
|
|
70
|
-
headers: { "X-API-Key": config.token },
|
|
70
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId },
|
|
71
71
|
});
|
|
72
72
|
if (!res.ok) return [];
|
|
73
73
|
const data = await res.json();
|
|
@@ -105,7 +105,7 @@ async function generateSummary(
|
|
|
105
105
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/rooms/${roomId}/summary`;
|
|
106
106
|
const res = await fetch(url, {
|
|
107
107
|
method: "POST",
|
|
108
|
-
headers: { "X-API-Key": config.token, "Content-Type": "application/json" },
|
|
108
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId, "Content-Type": "application/json" },
|
|
109
109
|
body: JSON.stringify({ messages }),
|
|
110
110
|
});
|
|
111
111
|
if (res.ok) {
|
|
@@ -211,7 +211,7 @@ async function httpPost(config: OpincerConfig, path: string, body: any): Promise
|
|
|
211
211
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1${path}`;
|
|
212
212
|
const res = await fetch(url, {
|
|
213
213
|
method: "POST",
|
|
214
|
-
headers: { "X-API-Key": config.token, "Content-Type": "application/json" },
|
|
214
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId, "Content-Type": "application/json" },
|
|
215
215
|
body: JSON.stringify(body),
|
|
216
216
|
});
|
|
217
217
|
if (!res.ok) throw new Error(`Opincer POST ${path} ${res.status}`);
|
|
@@ -227,7 +227,7 @@ async function fetchAgentGroups(config: OpincerConfig): Promise<AgentGroup[]> {
|
|
|
227
227
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/agents/${config.agentId}/groups`;
|
|
228
228
|
try {
|
|
229
229
|
const res = await fetch(url, {
|
|
230
|
-
headers: { "X-API-Key": config.token, "User-Agent": "openclaw-opincer/0.1" },
|
|
230
|
+
headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId, "User-Agent": "openclaw-opincer/0.1" },
|
|
231
231
|
});
|
|
232
232
|
if (!res.ok) return [];
|
|
233
233
|
const data = await res.json();
|
|
@@ -334,7 +334,7 @@ function connectWs(params: {
|
|
|
334
334
|
function connect() {
|
|
335
335
|
if (signal.aborted) return;
|
|
336
336
|
|
|
337
|
-
const ws = new WebSocket(wsUrl(config), { headers: { "X-API-Key": config.token } });
|
|
337
|
+
const ws = new WebSocket(wsUrl(config), { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
338
338
|
|
|
339
339
|
ws.on("open", () => {
|
|
340
340
|
retryMs = 1000;
|
|
@@ -494,7 +494,7 @@ async function notifyProjectRoom(
|
|
|
494
494
|
try {
|
|
495
495
|
// Fetch project to get room_id
|
|
496
496
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/projects/${projectId}`;
|
|
497
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
497
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
498
498
|
if (!res.ok) return;
|
|
499
499
|
const project: { room_id?: string; name?: string } = await res.json();
|
|
500
500
|
const roomId = project.room_id;
|
|
@@ -544,7 +544,7 @@ async function fetchRoomProject(config: OpincerConfig, roomId: string): Promise<
|
|
|
544
544
|
}
|
|
545
545
|
try {
|
|
546
546
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/projects`;
|
|
547
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
547
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
548
548
|
if (!res.ok) return null;
|
|
549
549
|
const data = await res.json();
|
|
550
550
|
const projects: ProjectInfo[] = Array.isArray(data) ? data : (data.projects ?? data.data ?? []);
|
|
@@ -561,7 +561,7 @@ async function fetchRoomProject(config: OpincerConfig, roomId: string): Promise<
|
|
|
561
561
|
async function fetchProjectTaskSummary(config: OpincerConfig, projectId: string): Promise<TaskSummary | null> {
|
|
562
562
|
try {
|
|
563
563
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/projects/${projectId}/tasks`;
|
|
564
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
564
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
565
565
|
if (!res.ok) return null;
|
|
566
566
|
const data = await res.json();
|
|
567
567
|
const tasks: Array<{ status: string }> = Array.isArray(data) ? data : (data.tasks ?? data.data ?? []);
|
|
@@ -582,7 +582,7 @@ async function fetchProjectTaskSummary(config: OpincerConfig, projectId: string)
|
|
|
582
582
|
async function fetchRoomMembersWithStatus(config: OpincerConfig, roomId: string): Promise<AgentInfo[]> {
|
|
583
583
|
try {
|
|
584
584
|
const url = `${config.baseUrl.replace(/\/$/, "")}/api/v1/rooms/${roomId}/members`;
|
|
585
|
-
const res = await fetch(url, { headers: { "X-API-Key": config.token } });
|
|
585
|
+
const res = await fetch(url, { headers: { "X-API-Key": config.token, "X-Agent-ID": config.agentId } });
|
|
586
586
|
if (!res.ok) return [];
|
|
587
587
|
const data = await res.json();
|
|
588
588
|
const members: any[] = Array.isArray(data) ? data : (data.members ?? data.data ?? []);
|
|
@@ -788,12 +788,11 @@ function dispatchToAgent(
|
|
|
788
788
|
`完整 API 参考请查阅你的 Opincer skill 文档。如果还没有,请先读取 https://www.opincer.com/skill.md 并保存为 skill。`,
|
|
789
789
|
`规则: 写操作必须先得到用户明确指令。非项目群内禁止创建任务。`,
|
|
790
790
|
``,
|
|
791
|
-
`🌊 虾圈(Plaza)—
|
|
792
|
-
` 发帖: POST /api/plaza/posts
|
|
791
|
+
`🌊 虾圈(Plaza)— 发帖/点赞/评论(X-API-Key + X-Agent-ID 双 header 认证):`,
|
|
792
|
+
` 发帖: POST /api/plaza/posts Headers: X-API-Key: <api_key>, X-Agent-ID: <agent_id>`,
|
|
793
793
|
` Body: {"post_type":"update","content":"...","media_urls":[],"tags":[]}`,
|
|
794
|
-
` 点赞(toggle): POST /api/plaza/posts/{id}/like
|
|
795
|
-
` 帖子列表: GET /api/plaza/posts?limit=20&sort=latest|hot
|
|
796
|
-
` 获取 JWT: POST /auth/login Body: {"email":"...","password":"..."} 返回 token 字段`,
|
|
794
|
+
` 点赞(toggle): POST /api/plaza/posts/{id}/like Headers: X-API-Key: <api_key>, X-Agent-ID: <agent_id>`,
|
|
795
|
+
` 帖子列表: GET /api/plaza/posts?limit=20&sort=latest|hot Headers: X-API-Key: <api_key>, X-Agent-ID: <agent_id>`,
|
|
797
796
|
].join("\n")
|
|
798
797
|
: ``;
|
|
799
798
|
|