@fonz/tgcc 0.6.18 → 0.7.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 +77 -0
- package/dist/bridge.js +41 -11
- package/dist/bridge.js.map +1 -1
- package/dist/plugin/index.d.ts +41 -0
- package/dist/plugin/index.js +161 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/openclaw.plugin.json +55 -0
- package/dist/plugin/package.json +6 -0
- package/dist/plugin/skills/tgcc-agents/SKILL.md +161 -0
- package/dist/plugin/src/client.d.ts +167 -0
- package/dist/plugin/src/client.js +523 -0
- package/dist/plugin/src/client.js.map +1 -0
- package/dist/plugin/src/events.d.ts +44 -0
- package/dist/plugin/src/events.js +226 -0
- package/dist/plugin/src/events.js.map +1 -0
- package/dist/plugin/src/permissions.d.ts +21 -0
- package/dist/plugin/src/permissions.js +78 -0
- package/dist/plugin/src/permissions.js.map +1 -0
- package/dist/plugin/src/tools/tgcc-kill.d.ts +6 -0
- package/dist/plugin/src/tools/tgcc-kill.js +52 -0
- package/dist/plugin/src/tools/tgcc-kill.js.map +1 -0
- package/dist/plugin/src/tools/tgcc-send.d.ts +9 -0
- package/dist/plugin/src/tools/tgcc-send.js +61 -0
- package/dist/plugin/src/tools/tgcc-send.js.map +1 -0
- package/dist/plugin/src/tools/tgcc-spawn.d.ts +9 -0
- package/dist/plugin/src/tools/tgcc-spawn.js +79 -0
- package/dist/plugin/src/tools/tgcc-spawn.js.map +1 -0
- package/dist/plugin/src/tools/tgcc-status.d.ts +9 -0
- package/dist/plugin/src/tools/tgcc-status.js +74 -0
- package/dist/plugin/src/tools/tgcc-status.js.map +1 -0
- package/dist/streaming.d.ts +61 -89
- package/dist/streaming.js +672 -677
- package/dist/streaming.js.map +1 -1
- package/dist/telegram-html-ast.js +3 -0
- package/dist/telegram-html-ast.js.map +1 -1
- package/package.json +10 -3
- package/plugin/openclaw.plugin.json +55 -0
- package/plugin/skills/tgcc-agents/SKILL.md +161 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenClaw plugin entry point for the TGCC Bridge.
|
|
4
|
+
*
|
|
5
|
+
* Connects to TGCC's control socket as a supervisor, registers agent tools
|
|
6
|
+
* (tgcc_spawn, tgcc_send, tgcc_status, tgcc_kill), and relays events.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const client_js_1 = require("./src/client.js");
|
|
15
|
+
const events_js_1 = require("./src/events.js");
|
|
16
|
+
const tgcc_spawn_js_1 = require("./src/tools/tgcc-spawn.js");
|
|
17
|
+
const tgcc_send_js_1 = require("./src/tools/tgcc-send.js");
|
|
18
|
+
const tgcc_status_js_1 = require("./src/tools/tgcc-status.js");
|
|
19
|
+
const tgcc_kill_js_1 = require("./src/tools/tgcc-kill.js");
|
|
20
|
+
const permissions_js_1 = require("./src/permissions.js");
|
|
21
|
+
function parseConfig(raw) {
|
|
22
|
+
const obj = raw ?? {};
|
|
23
|
+
return {
|
|
24
|
+
enabled: typeof obj.enabled === "boolean" ? obj.enabled : true,
|
|
25
|
+
socketDir: typeof obj.socketDir === "string" ? obj.socketDir : "/tmp/tgcc/ctl",
|
|
26
|
+
defaultAgent: typeof obj.defaultAgent === "string" ? obj.defaultAgent : undefined,
|
|
27
|
+
agents: Array.isArray(obj.agents) ? obj.agents : undefined,
|
|
28
|
+
telegramChatId: typeof obj.telegramChatId === "string" ? obj.telegramChatId : undefined,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Socket discovery — find .sock files in the socket directory
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
function discoverSocket(socketDir) {
|
|
35
|
+
try {
|
|
36
|
+
const files = node_fs_1.default.readdirSync(socketDir);
|
|
37
|
+
const sock = files.find((f) => f.endsWith(".sock"));
|
|
38
|
+
return sock ? node_path_1.default.join(socketDir, sock) : null;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Plugin export
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
const tgccPlugin = {
|
|
48
|
+
id: "tgcc",
|
|
49
|
+
name: "TGCC Bridge",
|
|
50
|
+
description: "Bridge OpenClaw agents to Claude Code sessions via TGCC",
|
|
51
|
+
configSchema: {
|
|
52
|
+
parse(value) {
|
|
53
|
+
const raw = value && typeof value === "object" && !Array.isArray(value)
|
|
54
|
+
? value
|
|
55
|
+
: {};
|
|
56
|
+
return parseConfig(raw);
|
|
57
|
+
},
|
|
58
|
+
uiHints: {
|
|
59
|
+
socketDir: {
|
|
60
|
+
label: "Socket Directory",
|
|
61
|
+
help: "Directory containing TGCC control sockets (default: /tmp/tgcc/ctl)",
|
|
62
|
+
},
|
|
63
|
+
defaultAgent: {
|
|
64
|
+
label: "Default Agent",
|
|
65
|
+
help: "Default TGCC agent ID for spawns",
|
|
66
|
+
},
|
|
67
|
+
agents: { label: "Agent IDs" },
|
|
68
|
+
telegramChatId: {
|
|
69
|
+
label: "Telegram Chat ID",
|
|
70
|
+
help: "Chat ID for permission request buttons",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
register(api) {
|
|
75
|
+
const config = parseConfig(api.pluginConfig);
|
|
76
|
+
if (!config.enabled) {
|
|
77
|
+
api.logger.info("[tgcc] plugin disabled");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const log = api.logger;
|
|
81
|
+
let client = null;
|
|
82
|
+
const getClient = () => client;
|
|
83
|
+
// ── Register tools ──────────────────────────────────────────────
|
|
84
|
+
api.registerTool((0, tgcc_spawn_js_1.createTgccSpawnTool)(getClient, config.defaultAgent));
|
|
85
|
+
api.registerTool((0, tgcc_send_js_1.createTgccSendTool)(getClient));
|
|
86
|
+
api.registerTool((0, tgcc_status_js_1.createTgccStatusTool)(getClient));
|
|
87
|
+
api.registerTool((0, tgcc_kill_js_1.createTgccKillTool)(getClient));
|
|
88
|
+
// ── Register gateway methods ────────────────────────────────────
|
|
89
|
+
// Permission response gateway method
|
|
90
|
+
api.registerGatewayMethod("tgcc.permission_response", (0, permissions_js_1.createPermissionResponseHandler)(getClient, log));
|
|
91
|
+
// Status gateway method (for programmatic access)
|
|
92
|
+
api.registerGatewayMethod("tgcc.status", async ({ params, respond }) => {
|
|
93
|
+
const c = getClient();
|
|
94
|
+
if (!c?.isConnected()) {
|
|
95
|
+
respond(false, { error: "Not connected to TGCC" });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const agentId = typeof params.agentId === "string" ? params.agentId : undefined;
|
|
100
|
+
const status = await c.getStatus(agentId);
|
|
101
|
+
respond(true, status);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
respond(false, { error: err instanceof Error ? err.message : String(err) });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
// Send message gateway method
|
|
108
|
+
api.registerGatewayMethod("tgcc.send", async ({ params, respond }) => {
|
|
109
|
+
const c = getClient();
|
|
110
|
+
if (!c?.isConnected()) {
|
|
111
|
+
respond(false, { error: "Not connected to TGCC" });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const agentId = typeof params.agentId === "string" ? params.agentId : "";
|
|
115
|
+
const text = typeof params.text === "string" ? params.text : "";
|
|
116
|
+
if (!agentId || !text) {
|
|
117
|
+
respond(false, { error: "agentId and text are required" });
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const result = await c.sendMessage(agentId, text, { subscribe: true });
|
|
122
|
+
respond(true, result);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
respond(false, { error: err instanceof Error ? err.message : String(err) });
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
// ── Register background service ─────────────────────────────────
|
|
129
|
+
api.registerService({
|
|
130
|
+
id: "tgcc-supervisor",
|
|
131
|
+
async start() {
|
|
132
|
+
const socketPath = discoverSocket(config.socketDir);
|
|
133
|
+
if (!socketPath) {
|
|
134
|
+
log.info(`[tgcc] no socket found in ${config.socketDir}, will retry on reconnect`);
|
|
135
|
+
}
|
|
136
|
+
const effectiveSocket = socketPath ?? node_path_1.default.join(config.socketDir, "tgcc.sock");
|
|
137
|
+
client = new client_js_1.TgccSupervisorClient({
|
|
138
|
+
socket: effectiveSocket,
|
|
139
|
+
logger: log,
|
|
140
|
+
});
|
|
141
|
+
// Wire up event handlers
|
|
142
|
+
(0, events_js_1.attachEventHandlers)(client, log);
|
|
143
|
+
// Wire up permission request handler
|
|
144
|
+
(0, events_js_1.setPermissionRequestHandler)((event) => {
|
|
145
|
+
(0, permissions_js_1.handlePermissionRequest)(event, api.runtime, config.telegramChatId, log);
|
|
146
|
+
});
|
|
147
|
+
client.start();
|
|
148
|
+
log.info(`[tgcc] supervisor service started (socket: ${effectiveSocket})`);
|
|
149
|
+
},
|
|
150
|
+
async stop() {
|
|
151
|
+
if (client) {
|
|
152
|
+
client.stop();
|
|
153
|
+
client = null;
|
|
154
|
+
log.info("[tgcc] supervisor service stopped");
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
exports.default = tgccPlugin;
|
|
161
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../plugin/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAEH,0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
"version": "0.6.19",
|
|
6
|
+
"uiHints": {
|
|
7
|
+
"socketDir": {
|
|
8
|
+
"label": "Socket Directory",
|
|
9
|
+
"help": "Directory containing TGCC control sockets (default: /tmp/tgcc/ctl)"
|
|
10
|
+
},
|
|
11
|
+
"defaultAgent": {
|
|
12
|
+
"label": "Default Agent",
|
|
13
|
+
"help": "Default TGCC agent ID for spawns"
|
|
14
|
+
},
|
|
15
|
+
"agents": {
|
|
16
|
+
"label": "Agent IDs",
|
|
17
|
+
"help": "TGCC agent IDs to subscribe to (default: all)"
|
|
18
|
+
},
|
|
19
|
+
"telegramChatId": {
|
|
20
|
+
"label": "Telegram Chat ID",
|
|
21
|
+
"help": "Chat ID for permission request buttons"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"configSchema": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"properties": {
|
|
28
|
+
"enabled": {
|
|
29
|
+
"type": "boolean"
|
|
30
|
+
},
|
|
31
|
+
"socketDir": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Directory containing TGCC control sockets (default: /tmp/tgcc/ctl)"
|
|
34
|
+
},
|
|
35
|
+
"defaultAgent": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Default TGCC agent to use for spawns (e.g. 'tgcc')"
|
|
38
|
+
},
|
|
39
|
+
"agents": {
|
|
40
|
+
"type": "array",
|
|
41
|
+
"items": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"description": "TGCC agent IDs to subscribe to (default: all)"
|
|
45
|
+
},
|
|
46
|
+
"telegramChatId": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Telegram chat ID for permission request buttons"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"skills": [
|
|
53
|
+
"skills/tgcc-agents"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tgcc-agents
|
|
3
|
+
description: 'Manage TGCC agents (Claude Code via Telegram) using tgcc_spawn, tgcc_send, tgcc_status, tgcc_kill tools. Use when: spawning CC sessions through TGCC, sending tasks to persistent TGCC bots, checking agent status, killing sessions, or creating ephemeral agents for one-off work.'
|
|
4
|
+
homepage: https://github.com/botverse/tgcc
|
|
5
|
+
metadata:
|
|
6
|
+
{
|
|
7
|
+
"openclaw":
|
|
8
|
+
{
|
|
9
|
+
"emoji": "🔌",
|
|
10
|
+
"requires": { "sockets": ["/tmp/tgcc/ctl/tgcc.sock"] },
|
|
11
|
+
"install":
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
"id": "npm",
|
|
15
|
+
"kind": "npm",
|
|
16
|
+
"package": "@fonz/tgcc",
|
|
17
|
+
"label": "Install TGCC plugin",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
"setup": "Install with `openclaw plugins install @fonz/tgcc`, then configure plugin with socketDir and defaultAgent.",
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# TGCC Agents — OpenClaw Plugin
|
|
26
|
+
|
|
27
|
+
Manage **Claude Code sessions via TGCC** (Telegram ↔ Claude Code bridge) using four dedicated tools. TGCC manages CC processes with Telegram rendering — you get visibility in both OpenClaw and Telegram.
|
|
28
|
+
|
|
29
|
+
## Tools
|
|
30
|
+
|
|
31
|
+
### `tgcc_status` — Check what's running
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
tgcc_status # all agents
|
|
35
|
+
tgcc_status agentId="tgcc" # specific agent
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
- **agents**: list with repo, type (persistent/ephemeral), state (idle/active/spawning)
|
|
40
|
+
- **pendingResults**: completed CC results not yet consumed (use `drain=true` to consume)
|
|
41
|
+
- **pendingPermissions**: permission requests waiting for approval
|
|
42
|
+
- **recentEvents**: last events (cc_spawned, result, error, etc.)
|
|
43
|
+
|
|
44
|
+
### `tgcc_spawn` — Start a CC session
|
|
45
|
+
|
|
46
|
+
**Existing agent** (persistent, has Telegram bot):
|
|
47
|
+
```
|
|
48
|
+
tgcc_spawn agentId="tgcc" task="Fix the render pipeline bug"
|
|
49
|
+
tgcc_spawn agentId="sentinella" task="Check tile coverage for Ibiza"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Ephemeral agent** (one-off, no Telegram bot — requires `repo`):
|
|
53
|
+
```
|
|
54
|
+
tgcc_spawn agentId="my-task" repo="/home/user/project" task="Add error handling"
|
|
55
|
+
tgcc_spawn agentId="review-pr" repo="/tmp/pr-42" task="Review this PR" model="opus"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Optional params:
|
|
59
|
+
- `model`: override CC model (e.g. `opus`, `sonnet`)
|
|
60
|
+
- `permissionMode`: CC permission mode (`plan`, `default`, `bypassPermissions`)
|
|
61
|
+
|
|
62
|
+
### `tgcc_send` — Message an active agent
|
|
63
|
+
|
|
64
|
+
Send a follow-up message or new task to an agent that already has a CC session:
|
|
65
|
+
```
|
|
66
|
+
tgcc_send agentId="tgcc" text="Also run the tests"
|
|
67
|
+
tgcc_send agentId="sentinella" text="Now compare with last month"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If the agent is idle (no CC process), this spawns a new session. If active, the message is queued and sent to CC when it's ready for input.
|
|
71
|
+
|
|
72
|
+
### `tgcc_kill` — Stop a CC session
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
tgcc_kill agentId="tgcc" # kill CC process, keep agent
|
|
76
|
+
tgcc_kill agentId="my-task" destroy=true # kill CC + destroy ephemeral agent
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Typical Workflows
|
|
80
|
+
|
|
81
|
+
### Delegate a coding task
|
|
82
|
+
```
|
|
83
|
+
tgcc_spawn agentId="tgcc" task="Implement the OpenClaw plugin per specs/openclaw-plugin.md"
|
|
84
|
+
# ... wait ...
|
|
85
|
+
tgcc_status # check pendingResults for completion
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Multi-agent coordination
|
|
89
|
+
```
|
|
90
|
+
tgcc_send agentId="sentinella" text="Generate the fire risk report"
|
|
91
|
+
tgcc_send agentId="kyobot" text="Update the booking dashboard"
|
|
92
|
+
tgcc_status # see both working in parallel
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Ephemeral agent for isolated work
|
|
96
|
+
```
|
|
97
|
+
tgcc_spawn agentId="pr-review" repo="/tmp/pr-42" task="Review changes" model="opus"
|
|
98
|
+
# ... result comes back ...
|
|
99
|
+
tgcc_kill agentId="pr-review" destroy=true # clean up
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Follow up on running work
|
|
103
|
+
```
|
|
104
|
+
tgcc_send agentId="tgcc" text="Also fix the edge case in splitMessage"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## How It Works
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
OpenClaw Plugin TGCC Bridge CC Process
|
|
111
|
+
│ │ │
|
|
112
|
+
│── send_message ───────────►│ │
|
|
113
|
+
│ {agentId, text} │── spawn/resume CC ──────►│
|
|
114
|
+
│◄── ack ───────────────────│ {sessionId, state} │
|
|
115
|
+
│ │ │
|
|
116
|
+
│ (CC works, visible │ │
|
|
117
|
+
│ in Telegram chat) │ │
|
|
118
|
+
│ │◄── result ───────────────│
|
|
119
|
+
│◄── event: result ─────────│ {text, cost} │
|
|
120
|
+
│ │ │
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- **Protocol**: NDJSON over Unix socket (default: `/tmp/tgcc/ctl/*.sock`)
|
|
124
|
+
- **Connection**: Plugin registers as supervisor, auto-reconnects with backoff
|
|
125
|
+
- **Discovery**: Agents auto-discovered on connect (persistent bots + ephemeral)
|
|
126
|
+
- **Events**: cc_spawned, result, process_exit, permission_request, api_error
|
|
127
|
+
- **Shared sessions**: Persistent agents share CC sessions with Telegram users — both see the same work
|
|
128
|
+
|
|
129
|
+
## Plugin Configuration
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"plugins": {
|
|
134
|
+
"entries": {
|
|
135
|
+
"tgcc": {
|
|
136
|
+
"enabled": true,
|
|
137
|
+
"config": {
|
|
138
|
+
"socketDir": "/tmp/tgcc/ctl",
|
|
139
|
+
"defaultAgent": "tgcc",
|
|
140
|
+
"telegramChatId": "7016073156"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- **socketDir**: where TGCC control sockets live (default: `/tmp/tgcc/ctl`)
|
|
149
|
+
- **defaultAgent**: fallback agentId when none specified
|
|
150
|
+
- **telegramChatId**: chat ID for permission request buttons
|
|
151
|
+
- **agents**: optional array of agent IDs to subscribe to (default: all)
|
|
152
|
+
|
|
153
|
+
## Permission Requests
|
|
154
|
+
|
|
155
|
+
When CC needs permission (file write, bash command, etc.), TGCC forwards it through the plugin. If `telegramChatId` is configured, approval buttons appear in Telegram (✅ Allow / ❌ Deny). Otherwise, permissions follow CC's configured `permissionMode`.
|
|
156
|
+
|
|
157
|
+
## When NOT to Use This
|
|
158
|
+
|
|
159
|
+
- **Quick file edits**: use the `edit` tool directly
|
|
160
|
+
- **Reading/exploring code**: use `read` / `exec` tools
|
|
161
|
+
- **Tasks needing full isolation from Telegram**: spawn CC directly via coding-agent skill
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TgccSupervisorClient — Unix socket client for the TGCC Supervisor Protocol.
|
|
3
|
+
*
|
|
4
|
+
* Connects to TGCC's ctl socket, registers as a supervisor, and provides
|
|
5
|
+
* async methods for interacting with TGCC-managed agents and CC processes.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from the OpenClaw fork (src/agents/tgcc-supervisor/client.ts)
|
|
8
|
+
* to use only the plugin API — no OpenClaw internal imports.
|
|
9
|
+
*/
|
|
10
|
+
import { EventEmitter } from "node:events";
|
|
11
|
+
import type { PluginLogger } from "openclaw/plugin-sdk";
|
|
12
|
+
export interface SupervisorCommand {
|
|
13
|
+
type: "command";
|
|
14
|
+
requestId: string;
|
|
15
|
+
action: string;
|
|
16
|
+
params?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface SupervisorResponse {
|
|
19
|
+
type: "response";
|
|
20
|
+
requestId: string;
|
|
21
|
+
result?: unknown;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SupervisorEvent {
|
|
25
|
+
type: "event";
|
|
26
|
+
event: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface TgccAgentStatus {
|
|
30
|
+
id: string;
|
|
31
|
+
type: "persistent" | "ephemeral";
|
|
32
|
+
state: "idle" | "active";
|
|
33
|
+
sessionId: string | null;
|
|
34
|
+
repo: string;
|
|
35
|
+
supervisorSubscribed: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface TgccStatusResult {
|
|
38
|
+
agents: TgccAgentStatus[];
|
|
39
|
+
sessions?: Array<{
|
|
40
|
+
id: string;
|
|
41
|
+
agentId: string;
|
|
42
|
+
messageCount?: number;
|
|
43
|
+
totalCostUsd?: number;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export interface TgccResultEvent {
|
|
47
|
+
agentId: string;
|
|
48
|
+
sessionId: string;
|
|
49
|
+
text: string;
|
|
50
|
+
cost_usd?: number;
|
|
51
|
+
duration_ms?: number;
|
|
52
|
+
is_error?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface TgccProcessExitEvent {
|
|
55
|
+
agentId: string;
|
|
56
|
+
sessionId: string;
|
|
57
|
+
exitCode: number | null;
|
|
58
|
+
}
|
|
59
|
+
export interface TgccSessionTakeoverEvent {
|
|
60
|
+
agentId: string;
|
|
61
|
+
sessionId: string;
|
|
62
|
+
exitCode: number | null;
|
|
63
|
+
}
|
|
64
|
+
export interface TgccApiErrorEvent {
|
|
65
|
+
agentId: string;
|
|
66
|
+
sessionId: string;
|
|
67
|
+
message: string;
|
|
68
|
+
}
|
|
69
|
+
export interface TgccPermissionRequestEvent {
|
|
70
|
+
agentId: string;
|
|
71
|
+
toolName: string;
|
|
72
|
+
requestId: string;
|
|
73
|
+
description: string;
|
|
74
|
+
}
|
|
75
|
+
export interface TgccSupervisorClientConfig {
|
|
76
|
+
socket: string;
|
|
77
|
+
logger: PluginLogger;
|
|
78
|
+
reconnectInitialMs?: number;
|
|
79
|
+
reconnectMaxMs?: number;
|
|
80
|
+
heartbeatMs?: number;
|
|
81
|
+
}
|
|
82
|
+
export declare class TgccSupervisorClient extends EventEmitter {
|
|
83
|
+
private log;
|
|
84
|
+
private socketPath;
|
|
85
|
+
private socket;
|
|
86
|
+
private connected;
|
|
87
|
+
private destroyed;
|
|
88
|
+
private reconnectDelay;
|
|
89
|
+
private reconnectInitialMs;
|
|
90
|
+
private reconnectMaxMs;
|
|
91
|
+
private heartbeatMs;
|
|
92
|
+
private reconnectTimer;
|
|
93
|
+
private heartbeatTimer;
|
|
94
|
+
private pongTimer;
|
|
95
|
+
private pendingRequests;
|
|
96
|
+
private lineBuffer;
|
|
97
|
+
constructor(config: TgccSupervisorClientConfig);
|
|
98
|
+
start(): void;
|
|
99
|
+
stop(): void;
|
|
100
|
+
isConnected(): boolean;
|
|
101
|
+
sendMessage(agentId: string, text: string, opts?: {
|
|
102
|
+
sessionId?: string;
|
|
103
|
+
subscribe?: boolean;
|
|
104
|
+
}): Promise<{
|
|
105
|
+
sessionId: string;
|
|
106
|
+
state: string;
|
|
107
|
+
subscribed?: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
sendToCC(agentId: string, text: string): Promise<{
|
|
110
|
+
sent: boolean;
|
|
111
|
+
}>;
|
|
112
|
+
getStatus(agentId?: string): Promise<TgccStatusResult>;
|
|
113
|
+
killCC(agentId: string): Promise<unknown>;
|
|
114
|
+
subscribe(agentId: string, sessionId?: string): Promise<unknown>;
|
|
115
|
+
unsubscribe(agentId: string): Promise<unknown>;
|
|
116
|
+
respondToPermission(agentId: string, permissionRequestId: string, decision: "allow" | "deny"): Promise<unknown>;
|
|
117
|
+
createAgent(params: {
|
|
118
|
+
agentId?: string;
|
|
119
|
+
repo: string;
|
|
120
|
+
model?: string;
|
|
121
|
+
permissionMode?: string;
|
|
122
|
+
timeoutMs?: number;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
agentId: string;
|
|
125
|
+
state: string;
|
|
126
|
+
}>;
|
|
127
|
+
destroyAgent(agentId: string): Promise<{
|
|
128
|
+
destroyed: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
getLog(agentId: string, opts?: {
|
|
131
|
+
offset?: number;
|
|
132
|
+
limit?: number;
|
|
133
|
+
grep?: string;
|
|
134
|
+
since?: number;
|
|
135
|
+
type?: string;
|
|
136
|
+
}): Promise<{
|
|
137
|
+
totalLines: number;
|
|
138
|
+
returnedLines: number;
|
|
139
|
+
offset: number;
|
|
140
|
+
lines: Array<{
|
|
141
|
+
ts: number;
|
|
142
|
+
type: string;
|
|
143
|
+
text: string;
|
|
144
|
+
}>;
|
|
145
|
+
}>;
|
|
146
|
+
private connect;
|
|
147
|
+
private scheduleReconnect;
|
|
148
|
+
private register;
|
|
149
|
+
private startHeartbeat;
|
|
150
|
+
private sendPing;
|
|
151
|
+
private forceReconnect;
|
|
152
|
+
private handleData;
|
|
153
|
+
private handleMessage;
|
|
154
|
+
private handleResponse;
|
|
155
|
+
private handleEvent;
|
|
156
|
+
private syncStateAfterConnect;
|
|
157
|
+
private handleReverseCommand;
|
|
158
|
+
private handleExecCommand;
|
|
159
|
+
private handleRestartServiceCommand;
|
|
160
|
+
private handleNotifyCommand;
|
|
161
|
+
private sendResponse;
|
|
162
|
+
private sendCommand;
|
|
163
|
+
private sendRaw;
|
|
164
|
+
private clearTimers;
|
|
165
|
+
private clearHeartbeat;
|
|
166
|
+
private rejectAllPending;
|
|
167
|
+
}
|