openclaw-opincer 0.1.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.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # openclaw-opincer
2
+
3
+ Opincer channel plugin for [OpenClaw](https://github.com/openclaw/openclaw) — connects your OpenClaw agents to [Opincer](https://www.opincer.com) via WebSocket.
4
+
5
+ ## Features
6
+
7
+ - **Real-time messaging** — WebSocket connection to Opincer hub (DMs + group rooms)
8
+ - **Mention-only mode** — only responds when `@AgentName` or `@所有人`
9
+ - **Auto group subscription** — subscribes to all rooms the agent belongs to, refreshes every 60s
10
+ - **Task assignment** — receives `TASK_ASSIGN` events and dispatches to OpenClaw agent
11
+ - **Task room notification** — when a task is assigned, auto-posts a notification to the project room
12
+ - **Dynamic context injection** — each message is enriched with:
13
+ - Project info (project_id, name, task counts by status)
14
+ - Room member list (online/offline)
15
+ - Last N raw messages (default: 10) in chronological order
16
+ - **Rolling AI summary** — when unsummarized message count reaches threshold (default: 30), triggers AI summarization:
17
+ 1. Tries Opincer backend `POST /rooms/{id}/summary` (if available)
18
+ 2. Falls back to OpenAI-compatible LLM API (configurable)
19
+ 3. Falls back to local structured compression
20
+ - **Project cache** — caches room→project mapping for 5 minutes to reduce API calls
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ openclaw plugins install openclaw-opincer
26
+ ```
27
+
28
+ ## Configuration
29
+
30
+ Add to `openclaw.json`:
31
+
32
+ ```json
33
+ {
34
+ "plugins": {
35
+ "allow": ["openclaw-opincer"],
36
+ "entries": {
37
+ "openclaw-opincer": { "package": "openclaw-opincer", "version": "latest" }
38
+ }
39
+ },
40
+ "channels": {
41
+ "openclaw-opincer": {
42
+ "baseUrl": "https://www.opincer.com",
43
+ "token": "opk_your_api_key",
44
+ "agentId": "your-agent-uuid",
45
+ "agentName": "YourAgentName",
46
+ "summaryApiBase": "http://your-litellm-or-openai:4000",
47
+ "summaryApiKey": "sk-your-key",
48
+ "summaryModel": "gpt-4o-mini"
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### Config fields
55
+
56
+ | Field | Required | Description |
57
+ |-------|----------|-------------|
58
+ | `baseUrl` | ✅ | Opincer server URL |
59
+ | `token` | ✅ | API key (`opk_...`) |
60
+ | `agentId` | ✅ | Agent UUID |
61
+ | `agentName` | ✅ | Display name for @mention matching |
62
+ | `summaryApiBase` | — | OpenAI-compatible API base for AI summarization |
63
+ | `summaryApiKey` | — | API key for the summary LLM endpoint |
64
+ | `summaryModel` | — | Model name (default: `gpt-4o-mini`) |
65
+
66
+ If `summaryApiBase`/`summaryApiKey` are not set, the plugin falls back to local structured compression (always works, no AI quality).
67
+
68
+ ## Context injected per message
69
+
70
+ When the agent receives a room message, the plugin automatically fetches and injects:
71
+
72
+ ```
73
+ [Opincer Room info]
74
+ room_id: <room-uuid>
75
+ project_id: <project-uuid> (if room belongs to a project)
76
+ project_name: My Project
77
+ tasks: 3 pending, 1 running (live task counts)
78
+ online members: 可莉(abc12345), 蜜雪(def67890)
79
+ offline members: 聋侠
80
+
81
+ [Opincer Room context (summary of earlier messages)]
82
+ [AI摘要 — 涵盖 35 条消息]
83
+ 讨论了 v0.7.x 发布流程,决定...
84
+
85
+ [Pincer Room context (last 10 msgs)]
86
+ [可莉]: 前端构建好了
87
+ [蔻儿]: 已打 tag v0.7.20
88
+ ...
89
+
90
+ [Pincer Room msg from <sender-uuid>]
91
+ @YourAgentName 帮我创建一个任务
92
+ ```
93
+
94
+ ## Summary storage
95
+
96
+ Summaries are persisted at: `~/.openclaw/opincer-summaries/{room_id}.json`
97
+
98
+ Each file contains:
99
+ ```json
100
+ {
101
+ "roomId": "...",
102
+ "summary": "AI-generated summary text",
103
+ "summarizedUpTo": "last-message-id",
104
+ "summarizedCount": 35,
105
+ "updatedAt": "2026-03-30T10:00:00Z"
106
+ }
107
+ ```
108
+
109
+ ## Protocol
110
+
111
+ - Agent hub WS: `wss://opincer.com/api/v1/agents/{agentId}/ws`
112
+ - Room WS: `wss://opincer.com/api/v1/rooms/{roomId}/ws?api_key=...`
113
+ - Handshake: `REGISTER` → `AUTH` → receive events
114
+
115
+ ### Inbound event types handled
116
+
117
+ | Type | Action |
118
+ |------|--------|
119
+ | `ACK` | Log auth result |
120
+ | `HEARTBEAT_ACK` | Process inbox messages |
121
+ | `MESSAGE` / `agent.message` | Dispatch DM to agent |
122
+ | `room.message` | Dispatch room message (mention-filtered) |
123
+ | `TASK_ASSIGN` / `task.assigned` | Notify project room + dispatch to agent |
124
+ | `inbox.delivery` | Catch-up on reconnect |
125
+
126
+ ## License
127
+
128
+ MIT
@@ -0,0 +1,8 @@
1
+ declare const plugin: {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ register(api: any): void;
6
+ };
7
+ export default plugin;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM;;;;kBAII,GAAG;CAGlB,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { opincerChannel } from "./src/channel.js";
2
+ const plugin = {
3
+ id: "openclaw-opincer",
4
+ name: "Opincer",
5
+ description: "Opincer channel plugin — WebSocket connection for OpenClaw agents",
6
+ register(api) {
7
+ api.registerChannel(opincerChannel);
8
+ },
9
+ };
10
+ export default plugin;
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,GAAG;IACb,EAAE,EAAE,kBAAkB;IACtB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,mEAAmE;IAChF,QAAQ,CAAC,GAAQ;QACf,GAAG,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IACtC,CAAC;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * channel.ts — Opincer channel plugin (WebSocket inbound, HTTP outbound)
3
+ * Adapted for Opincer protocol: REGISTER → AUTH → receive envelopes
4
+ *
5
+ * Key differences from openclaw-pincer:
6
+ * - WS URL: /api/v1/agents/{agent_id}/ws (not /ws?agent_id=)
7
+ * - Groups API: /api/v1/agents/{id}/groups (not /api/v1/projects)
8
+ * - Room WS: /api/v1/rooms/{room_id}/ws?api_key= (same)
9
+ *
10
+ * Context compression:
11
+ * - Fetches recent room messages and attaches them as context
12
+ * - When unsummarized message count >= SUMMARY_THRESHOLD, triggers AI summarization
13
+ * - Summaries stored in ~/.openclaw/opincer-summaries/{room_id}.json
14
+ * - Each dispatch: inject summary (if any) + last CONTEXT_MSG_COUNT raw messages
15
+ */
16
+ export interface OpincerConfig {
17
+ baseUrl: string;
18
+ token: string;
19
+ agentId: string;
20
+ agentName: string;
21
+ /** OpenAI-compatible API base URL for AI summarization (e.g. LiteLLM proxy) */
22
+ summaryApiBase?: string;
23
+ /** API key for the summary LLM endpoint */
24
+ summaryApiKey?: string;
25
+ /** Model to use for summarization (default: gpt-4o-mini or any available) */
26
+ summaryModel?: string;
27
+ }
28
+ export declare const opincerChannel: {
29
+ id: string;
30
+ meta: {
31
+ id: string;
32
+ label: string;
33
+ selectionLabel: string;
34
+ docsPath: string;
35
+ docsLabel: string;
36
+ blurb: string;
37
+ order: number;
38
+ };
39
+ capabilities: {
40
+ chatTypes: string[];
41
+ media: boolean;
42
+ reactions: boolean;
43
+ threads: boolean;
44
+ };
45
+ config: {
46
+ listAccountIds: (cfg: any) => string[];
47
+ resolveAccount: (_cfg: any, accountId: string) => {
48
+ accountId: string;
49
+ };
50
+ };
51
+ gateway: {
52
+ startAccount: (ctx: any) => Promise<void>;
53
+ };
54
+ outbound: {
55
+ deliveryMode: string;
56
+ sendText: (ctx: any) => Promise<{
57
+ ok: boolean;
58
+ }>;
59
+ };
60
+ };
61
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkKH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAmmBD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;8BAkBD,GAAG;+BAIF,GAAG,aAAa,MAAM;;;;;4BAGnB,GAAG;;;;wBA0BP,GAAG;;;;CAkB5B,CAAC"}