multiclaws 0.4.42 → 0.4.43
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 +2 -0
- package/dist/gateway/handlers.d.ts +4 -4
- package/dist/gateway/handlers.js +239 -239
- package/dist/index.d.ts +8 -8
- package/dist/index.js +710 -710
- package/dist/infra/frp.d.ts +55 -55
- package/dist/infra/frp.js +398 -398
- package/dist/infra/gateway-client.d.ts +27 -27
- package/dist/infra/gateway-client.js +136 -136
- package/dist/infra/json-store.d.ts +4 -4
- package/dist/infra/json-store.js +57 -57
- package/dist/infra/logger.d.ts +14 -14
- package/dist/infra/logger.js +25 -25
- package/dist/infra/rate-limiter.d.ts +19 -19
- package/dist/infra/rate-limiter.js +69 -69
- package/dist/infra/tailscale.d.ts +19 -19
- package/dist/infra/tailscale.js +120 -120
- package/dist/infra/telemetry.d.ts +3 -3
- package/dist/infra/telemetry.js +17 -17
- package/dist/infra/version.d.ts +1 -1
- package/dist/infra/version.js +19 -19
- package/dist/service/a2a-adapter.d.ts +80 -80
- package/dist/service/a2a-adapter.js +505 -505
- package/dist/service/agent-profile.d.ts +17 -17
- package/dist/service/agent-profile.js +58 -58
- package/dist/service/agent-registry.d.ts +29 -29
- package/dist/service/agent-registry.js +131 -131
- package/dist/service/multiclaws-service.d.ts +150 -150
- package/dist/service/multiclaws-service.js +1137 -1137
- package/dist/service/session-store.d.ts +46 -46
- package/dist/service/session-store.js +143 -143
- package/dist/task/tracker.d.ts +46 -46
- package/dist/task/tracker.js +191 -191
- package/dist/team/team-store.d.ts +42 -42
- package/dist/team/team-store.js +195 -195
- package/dist/types/openclaw.d.ts +109 -109
- package/dist/types/openclaw.js +2 -2
- package/package.json +1 -1
package/dist/team/team-store.js
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TeamStore = void 0;
|
|
4
|
-
exports.encodeInvite = encodeInvite;
|
|
5
|
-
exports.decodeInvite = decodeInvite;
|
|
6
|
-
const node_crypto_1 = require("node:crypto");
|
|
7
|
-
const json_store_1 = require("../infra/json-store");
|
|
8
|
-
function emptyStore() {
|
|
9
|
-
return { version: 1, teams: [] };
|
|
10
|
-
}
|
|
11
|
-
function normalizeStore(raw) {
|
|
12
|
-
if (raw.version !== 1 || !Array.isArray(raw.teams)) {
|
|
13
|
-
return emptyStore();
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
version: 1,
|
|
17
|
-
teams: raw.teams.filter((t) => t &&
|
|
18
|
-
typeof t.teamId === "string" &&
|
|
19
|
-
typeof t.teamName === "string" &&
|
|
20
|
-
Array.isArray(t.members)),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
// ── Invite code helpers ──────────────────────────────────────────────
|
|
24
|
-
const INVITE_PREFIX = "mc:";
|
|
25
|
-
function encodeInvite(teamId, seedUrl) {
|
|
26
|
-
const payload = { t: teamId, u: seedUrl };
|
|
27
|
-
return INVITE_PREFIX + Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
28
|
-
}
|
|
29
|
-
function decodeInvite(code) {
|
|
30
|
-
const trimmed = code.trim();
|
|
31
|
-
const body = trimmed.startsWith(INVITE_PREFIX)
|
|
32
|
-
? trimmed.slice(INVITE_PREFIX.length)
|
|
33
|
-
: trimmed;
|
|
34
|
-
try {
|
|
35
|
-
const json = Buffer.from(body, "base64url").toString("utf8");
|
|
36
|
-
const parsed = JSON.parse(json);
|
|
37
|
-
if (typeof parsed.t !== "string" || typeof parsed.u !== "string") {
|
|
38
|
-
throw new Error("invalid invite payload");
|
|
39
|
-
}
|
|
40
|
-
return parsed;
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
throw new Error("invalid invite code");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// ── TeamStore ────────────────────────────────────────────────────────
|
|
47
|
-
class TeamStore {
|
|
48
|
-
filePath;
|
|
49
|
-
logger;
|
|
50
|
-
constructor(filePath, logger) {
|
|
51
|
-
this.filePath = filePath;
|
|
52
|
-
this.logger = logger;
|
|
53
|
-
}
|
|
54
|
-
log(level, message) {
|
|
55
|
-
const fn = level === "debug" ? this.logger?.debug : this.logger?.[level];
|
|
56
|
-
fn?.(`[team-store] ${message}`);
|
|
57
|
-
}
|
|
58
|
-
async readStore() {
|
|
59
|
-
const store = await (0, json_store_1.readJsonWithFallback)(this.filePath, emptyStore());
|
|
60
|
-
return normalizeStore(store);
|
|
61
|
-
}
|
|
62
|
-
async createTeam(params) {
|
|
63
|
-
this.log("debug", `createTeam(name=${params.teamName})`);
|
|
64
|
-
try {
|
|
65
|
-
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
66
|
-
const store = await this.readStore();
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
const record = {
|
|
69
|
-
teamId: (0, node_crypto_1.randomUUID)(),
|
|
70
|
-
teamName: params.teamName,
|
|
71
|
-
selfUrl: params.selfUrl,
|
|
72
|
-
members: [{ url: params.selfUrl, name: params.selfName, description: params.selfDescription, joinedAtMs: now }],
|
|
73
|
-
createdAtMs: now,
|
|
74
|
-
};
|
|
75
|
-
store.teams.push(record);
|
|
76
|
-
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
77
|
-
return record;
|
|
78
|
-
});
|
|
79
|
-
this.log("debug", `createTeam completed, teamId=${result.teamId}`);
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
this.log("error", `createTeam failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
84
|
-
throw err;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async getTeam(teamId) {
|
|
88
|
-
const store = await this.readStore();
|
|
89
|
-
return store.teams.find((t) => t.teamId === teamId) ?? null;
|
|
90
|
-
}
|
|
91
|
-
async listTeams() {
|
|
92
|
-
const store = await this.readStore();
|
|
93
|
-
return [...store.teams];
|
|
94
|
-
}
|
|
95
|
-
async getFirstTeam() {
|
|
96
|
-
const store = await this.readStore();
|
|
97
|
-
return store.teams[0] ?? null;
|
|
98
|
-
}
|
|
99
|
-
async addMember(teamId, member) {
|
|
100
|
-
this.log("debug", `addMember(teamId=${teamId}, url=${member.url})`);
|
|
101
|
-
try {
|
|
102
|
-
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
103
|
-
const store = await this.readStore();
|
|
104
|
-
const team = store.teams.find((t) => t.teamId === teamId);
|
|
105
|
-
if (!team)
|
|
106
|
-
return false;
|
|
107
|
-
const normalizedUrl = member.url.replace(/\/+$/, "");
|
|
108
|
-
const existing = team.members.findIndex((m) => m.url.replace(/\/+$/, "") === normalizedUrl);
|
|
109
|
-
if (existing >= 0) {
|
|
110
|
-
team.members[existing].name = member.name;
|
|
111
|
-
if (member.description !== undefined) {
|
|
112
|
-
team.members[existing].description = member.description;
|
|
113
|
-
}
|
|
114
|
-
team.members[existing].joinedAtMs = member.joinedAtMs;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
team.members.push({ ...member, url: normalizedUrl });
|
|
118
|
-
}
|
|
119
|
-
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
120
|
-
return true;
|
|
121
|
-
});
|
|
122
|
-
this.log("debug", `addMember completed, result=${result}`);
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
catch (err) {
|
|
126
|
-
this.log("error", `addMember failed for teamId=${teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
|
-
throw err;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async removeMember(teamId, memberUrl) {
|
|
131
|
-
const normalizedUrl = memberUrl.replace(/\/+$/, "");
|
|
132
|
-
this.log("debug", `removeMember(teamId=${teamId}, url=${normalizedUrl})`);
|
|
133
|
-
try {
|
|
134
|
-
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
135
|
-
const store = await this.readStore();
|
|
136
|
-
const team = store.teams.find((t) => t.teamId === teamId);
|
|
137
|
-
if (!team)
|
|
138
|
-
return false;
|
|
139
|
-
const before = team.members.length;
|
|
140
|
-
team.members = team.members.filter((m) => m.url.replace(/\/+$/, "") !== normalizedUrl);
|
|
141
|
-
if (team.members.length === before)
|
|
142
|
-
return false;
|
|
143
|
-
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
144
|
-
return true;
|
|
145
|
-
});
|
|
146
|
-
this.log("debug", `removeMember completed, found=${result}`);
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
catch (err) {
|
|
150
|
-
this.log("error", `removeMember failed for teamId=${teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
151
|
-
throw err;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
async deleteTeam(teamId) {
|
|
155
|
-
this.log("debug", `deleteTeam(teamId=${teamId})`);
|
|
156
|
-
try {
|
|
157
|
-
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
158
|
-
const store = await this.readStore();
|
|
159
|
-
const before = store.teams.length;
|
|
160
|
-
store.teams = store.teams.filter((t) => t.teamId !== teamId);
|
|
161
|
-
if (store.teams.length === before)
|
|
162
|
-
return false;
|
|
163
|
-
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
164
|
-
return true;
|
|
165
|
-
});
|
|
166
|
-
this.log("debug", `deleteTeam completed, found=${result}`);
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
this.log("error", `deleteTeam failed for teamId=${teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
171
|
-
throw err;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
async saveTeam(team) {
|
|
175
|
-
this.log("debug", `saveTeam(teamId=${team.teamId})`);
|
|
176
|
-
try {
|
|
177
|
-
await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
178
|
-
const store = await this.readStore();
|
|
179
|
-
const idx = store.teams.findIndex((t) => t.teamId === team.teamId);
|
|
180
|
-
if (idx >= 0) {
|
|
181
|
-
store.teams[idx] = team;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
store.teams.push(team);
|
|
185
|
-
}
|
|
186
|
-
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
catch (err) {
|
|
190
|
-
this.log("error", `saveTeam failed for teamId=${team.teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
191
|
-
throw err;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
exports.TeamStore = TeamStore;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeamStore = void 0;
|
|
4
|
+
exports.encodeInvite = encodeInvite;
|
|
5
|
+
exports.decodeInvite = decodeInvite;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const json_store_1 = require("../infra/json-store");
|
|
8
|
+
function emptyStore() {
|
|
9
|
+
return { version: 1, teams: [] };
|
|
10
|
+
}
|
|
11
|
+
function normalizeStore(raw) {
|
|
12
|
+
if (raw.version !== 1 || !Array.isArray(raw.teams)) {
|
|
13
|
+
return emptyStore();
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
version: 1,
|
|
17
|
+
teams: raw.teams.filter((t) => t &&
|
|
18
|
+
typeof t.teamId === "string" &&
|
|
19
|
+
typeof t.teamName === "string" &&
|
|
20
|
+
Array.isArray(t.members)),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// ── Invite code helpers ──────────────────────────────────────────────
|
|
24
|
+
const INVITE_PREFIX = "mc:";
|
|
25
|
+
function encodeInvite(teamId, seedUrl) {
|
|
26
|
+
const payload = { t: teamId, u: seedUrl };
|
|
27
|
+
return INVITE_PREFIX + Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
28
|
+
}
|
|
29
|
+
function decodeInvite(code) {
|
|
30
|
+
const trimmed = code.trim();
|
|
31
|
+
const body = trimmed.startsWith(INVITE_PREFIX)
|
|
32
|
+
? trimmed.slice(INVITE_PREFIX.length)
|
|
33
|
+
: trimmed;
|
|
34
|
+
try {
|
|
35
|
+
const json = Buffer.from(body, "base64url").toString("utf8");
|
|
36
|
+
const parsed = JSON.parse(json);
|
|
37
|
+
if (typeof parsed.t !== "string" || typeof parsed.u !== "string") {
|
|
38
|
+
throw new Error("invalid invite payload");
|
|
39
|
+
}
|
|
40
|
+
return parsed;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error("invalid invite code");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// ── TeamStore ────────────────────────────────────────────────────────
|
|
47
|
+
class TeamStore {
|
|
48
|
+
filePath;
|
|
49
|
+
logger;
|
|
50
|
+
constructor(filePath, logger) {
|
|
51
|
+
this.filePath = filePath;
|
|
52
|
+
this.logger = logger;
|
|
53
|
+
}
|
|
54
|
+
log(level, message) {
|
|
55
|
+
const fn = level === "debug" ? this.logger?.debug : this.logger?.[level];
|
|
56
|
+
fn?.(`[team-store] ${message}`);
|
|
57
|
+
}
|
|
58
|
+
async readStore() {
|
|
59
|
+
const store = await (0, json_store_1.readJsonWithFallback)(this.filePath, emptyStore());
|
|
60
|
+
return normalizeStore(store);
|
|
61
|
+
}
|
|
62
|
+
async createTeam(params) {
|
|
63
|
+
this.log("debug", `createTeam(name=${params.teamName})`);
|
|
64
|
+
try {
|
|
65
|
+
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
66
|
+
const store = await this.readStore();
|
|
67
|
+
const now = Date.now();
|
|
68
|
+
const record = {
|
|
69
|
+
teamId: (0, node_crypto_1.randomUUID)(),
|
|
70
|
+
teamName: params.teamName,
|
|
71
|
+
selfUrl: params.selfUrl,
|
|
72
|
+
members: [{ url: params.selfUrl, name: params.selfName, description: params.selfDescription, joinedAtMs: now }],
|
|
73
|
+
createdAtMs: now,
|
|
74
|
+
};
|
|
75
|
+
store.teams.push(record);
|
|
76
|
+
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
77
|
+
return record;
|
|
78
|
+
});
|
|
79
|
+
this.log("debug", `createTeam completed, teamId=${result.teamId}`);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
this.log("error", `createTeam failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async getTeam(teamId) {
|
|
88
|
+
const store = await this.readStore();
|
|
89
|
+
return store.teams.find((t) => t.teamId === teamId) ?? null;
|
|
90
|
+
}
|
|
91
|
+
async listTeams() {
|
|
92
|
+
const store = await this.readStore();
|
|
93
|
+
return [...store.teams];
|
|
94
|
+
}
|
|
95
|
+
async getFirstTeam() {
|
|
96
|
+
const store = await this.readStore();
|
|
97
|
+
return store.teams[0] ?? null;
|
|
98
|
+
}
|
|
99
|
+
async addMember(teamId, member) {
|
|
100
|
+
this.log("debug", `addMember(teamId=${teamId}, url=${member.url})`);
|
|
101
|
+
try {
|
|
102
|
+
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
103
|
+
const store = await this.readStore();
|
|
104
|
+
const team = store.teams.find((t) => t.teamId === teamId);
|
|
105
|
+
if (!team)
|
|
106
|
+
return false;
|
|
107
|
+
const normalizedUrl = member.url.replace(/\/+$/, "");
|
|
108
|
+
const existing = team.members.findIndex((m) => m.url.replace(/\/+$/, "") === normalizedUrl);
|
|
109
|
+
if (existing >= 0) {
|
|
110
|
+
team.members[existing].name = member.name;
|
|
111
|
+
if (member.description !== undefined) {
|
|
112
|
+
team.members[existing].description = member.description;
|
|
113
|
+
}
|
|
114
|
+
team.members[existing].joinedAtMs = member.joinedAtMs;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
team.members.push({ ...member, url: normalizedUrl });
|
|
118
|
+
}
|
|
119
|
+
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
120
|
+
return true;
|
|
121
|
+
});
|
|
122
|
+
this.log("debug", `addMember completed, result=${result}`);
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
this.log("error", `addMember failed for teamId=${teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async removeMember(teamId, memberUrl) {
|
|
131
|
+
const normalizedUrl = memberUrl.replace(/\/+$/, "");
|
|
132
|
+
this.log("debug", `removeMember(teamId=${teamId}, url=${normalizedUrl})`);
|
|
133
|
+
try {
|
|
134
|
+
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
135
|
+
const store = await this.readStore();
|
|
136
|
+
const team = store.teams.find((t) => t.teamId === teamId);
|
|
137
|
+
if (!team)
|
|
138
|
+
return false;
|
|
139
|
+
const before = team.members.length;
|
|
140
|
+
team.members = team.members.filter((m) => m.url.replace(/\/+$/, "") !== normalizedUrl);
|
|
141
|
+
if (team.members.length === before)
|
|
142
|
+
return false;
|
|
143
|
+
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
144
|
+
return true;
|
|
145
|
+
});
|
|
146
|
+
this.log("debug", `removeMember completed, found=${result}`);
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
this.log("error", `removeMember failed for teamId=${teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async deleteTeam(teamId) {
|
|
155
|
+
this.log("debug", `deleteTeam(teamId=${teamId})`);
|
|
156
|
+
try {
|
|
157
|
+
const result = await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
158
|
+
const store = await this.readStore();
|
|
159
|
+
const before = store.teams.length;
|
|
160
|
+
store.teams = store.teams.filter((t) => t.teamId !== teamId);
|
|
161
|
+
if (store.teams.length === before)
|
|
162
|
+
return false;
|
|
163
|
+
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
164
|
+
return true;
|
|
165
|
+
});
|
|
166
|
+
this.log("debug", `deleteTeam completed, found=${result}`);
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
this.log("error", `deleteTeam failed for teamId=${teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
171
|
+
throw err;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async saveTeam(team) {
|
|
175
|
+
this.log("debug", `saveTeam(teamId=${team.teamId})`);
|
|
176
|
+
try {
|
|
177
|
+
await (0, json_store_1.withJsonLock)(this.filePath, emptyStore(), async () => {
|
|
178
|
+
const store = await this.readStore();
|
|
179
|
+
const idx = store.teams.findIndex((t) => t.teamId === team.teamId);
|
|
180
|
+
if (idx >= 0) {
|
|
181
|
+
store.teams[idx] = team;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
store.teams.push(team);
|
|
185
|
+
}
|
|
186
|
+
await (0, json_store_1.writeJsonAtomically)(this.filePath, store);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
this.log("error", `saveTeam failed for teamId=${team.teamId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
191
|
+
throw err;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.TeamStore = TeamStore;
|
package/dist/types/openclaw.d.ts
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
export type GatewayRespond = (ok: boolean, payload?: unknown, error?: {
|
|
2
|
-
code?: string;
|
|
3
|
-
message?: string;
|
|
4
|
-
details?: unknown;
|
|
5
|
-
}) => void;
|
|
6
|
-
export type GatewayRequestHandler = (opts: {
|
|
7
|
-
params: Record<string, unknown>;
|
|
8
|
-
respond: GatewayRespond;
|
|
9
|
-
}) => void | Promise<void>;
|
|
10
|
-
export type PluginServiceContext = {
|
|
11
|
-
stateDir: string;
|
|
12
|
-
logger: {
|
|
13
|
-
info: (message: string) => void;
|
|
14
|
-
warn: (message: string) => void;
|
|
15
|
-
error: (message: string) => void;
|
|
16
|
-
debug?: (message: string) => void;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export type PluginService = {
|
|
20
|
-
id: string;
|
|
21
|
-
start: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
22
|
-
stop?: (ctx?: PluginServiceContext) => void | Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
export type PluginHookMessageContext = {
|
|
25
|
-
channelId: string;
|
|
26
|
-
accountId?: string;
|
|
27
|
-
conversationId?: string;
|
|
28
|
-
};
|
|
29
|
-
export type PluginHookMessageEvent = {
|
|
30
|
-
from: string;
|
|
31
|
-
content: string;
|
|
32
|
-
timestamp?: number;
|
|
33
|
-
metadata?: Record<string, unknown>;
|
|
34
|
-
};
|
|
35
|
-
export type PluginHookGatewayStartEvent = {
|
|
36
|
-
port: number;
|
|
37
|
-
};
|
|
38
|
-
export type PluginHookGatewayStopEvent = {
|
|
39
|
-
reason?: string;
|
|
40
|
-
};
|
|
41
|
-
export type PluginHookAgentContext = {
|
|
42
|
-
agentId?: string;
|
|
43
|
-
sessionKey?: string;
|
|
44
|
-
sessionId?: string;
|
|
45
|
-
workspaceDir?: string;
|
|
46
|
-
channelId?: string;
|
|
47
|
-
trigger?: string;
|
|
48
|
-
};
|
|
49
|
-
export type PluginHookBeforePromptBuildEvent = {
|
|
50
|
-
prompt: string;
|
|
51
|
-
messages: unknown[];
|
|
52
|
-
};
|
|
53
|
-
export type PluginHookBeforePromptBuildResult = {
|
|
54
|
-
systemPrompt?: string;
|
|
55
|
-
prependContext?: string;
|
|
56
|
-
prependSystemContext?: string;
|
|
57
|
-
appendSystemContext?: string;
|
|
58
|
-
};
|
|
59
|
-
export type PluginTool = {
|
|
60
|
-
name: string;
|
|
61
|
-
description: string;
|
|
62
|
-
parameters: Record<string, unknown>;
|
|
63
|
-
execute: (toolCallId: string, args: Record<string, unknown>) => Promise<{
|
|
64
|
-
content: Array<{
|
|
65
|
-
type: "text";
|
|
66
|
-
text: string;
|
|
67
|
-
}>;
|
|
68
|
-
details?: unknown;
|
|
69
|
-
}>;
|
|
70
|
-
};
|
|
71
|
-
export type OpenClawGatewayConfig = {
|
|
72
|
-
port?: number;
|
|
73
|
-
auth?: {
|
|
74
|
-
mode?: string;
|
|
75
|
-
token?: string;
|
|
76
|
-
password?: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
export type OpenClawPluginApi = {
|
|
80
|
-
config?: {
|
|
81
|
-
plugins?: Record<string, unknown>;
|
|
82
|
-
gateway?: OpenClawGatewayConfig;
|
|
83
|
-
[key: string]: unknown;
|
|
84
|
-
};
|
|
85
|
-
pluginConfig?: Record<string, unknown>;
|
|
86
|
-
logger: {
|
|
87
|
-
info: (message: string) => void;
|
|
88
|
-
warn: (message: string) => void;
|
|
89
|
-
error: (message: string) => void;
|
|
90
|
-
debug?: (message: string) => void;
|
|
91
|
-
};
|
|
92
|
-
registerService: (service: PluginService) => void;
|
|
93
|
-
registerGatewayMethod: (method: string, handler: GatewayRequestHandler) => void;
|
|
94
|
-
registerTool: (tool: PluginTool) => void;
|
|
95
|
-
registerHttpRoute: (route: {
|
|
96
|
-
path: string;
|
|
97
|
-
auth?: "plugin" | "gateway";
|
|
98
|
-
handler: (req: unknown, res: {
|
|
99
|
-
statusCode: number;
|
|
100
|
-
end: (body?: string) => void;
|
|
101
|
-
}) => void;
|
|
102
|
-
}) => void;
|
|
103
|
-
on: {
|
|
104
|
-
(name: "message_received", handler: (event: PluginHookMessageEvent, ctx: PluginHookMessageContext) => void | Promise<void>): void;
|
|
105
|
-
(name: "gateway_start", handler: (event: PluginHookGatewayStartEvent) => void | Promise<void>): void;
|
|
106
|
-
(name: "gateway_stop", handler: (event: PluginHookGatewayStopEvent) => void | Promise<void>): void;
|
|
107
|
-
(name: "before_prompt_build", handler: (event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext) => PluginHookBeforePromptBuildResult | void | Promise<PluginHookBeforePromptBuildResult | void>): void;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
1
|
+
export type GatewayRespond = (ok: boolean, payload?: unknown, error?: {
|
|
2
|
+
code?: string;
|
|
3
|
+
message?: string;
|
|
4
|
+
details?: unknown;
|
|
5
|
+
}) => void;
|
|
6
|
+
export type GatewayRequestHandler = (opts: {
|
|
7
|
+
params: Record<string, unknown>;
|
|
8
|
+
respond: GatewayRespond;
|
|
9
|
+
}) => void | Promise<void>;
|
|
10
|
+
export type PluginServiceContext = {
|
|
11
|
+
stateDir: string;
|
|
12
|
+
logger: {
|
|
13
|
+
info: (message: string) => void;
|
|
14
|
+
warn: (message: string) => void;
|
|
15
|
+
error: (message: string) => void;
|
|
16
|
+
debug?: (message: string) => void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type PluginService = {
|
|
20
|
+
id: string;
|
|
21
|
+
start: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
22
|
+
stop?: (ctx?: PluginServiceContext) => void | Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export type PluginHookMessageContext = {
|
|
25
|
+
channelId: string;
|
|
26
|
+
accountId?: string;
|
|
27
|
+
conversationId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type PluginHookMessageEvent = {
|
|
30
|
+
from: string;
|
|
31
|
+
content: string;
|
|
32
|
+
timestamp?: number;
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
export type PluginHookGatewayStartEvent = {
|
|
36
|
+
port: number;
|
|
37
|
+
};
|
|
38
|
+
export type PluginHookGatewayStopEvent = {
|
|
39
|
+
reason?: string;
|
|
40
|
+
};
|
|
41
|
+
export type PluginHookAgentContext = {
|
|
42
|
+
agentId?: string;
|
|
43
|
+
sessionKey?: string;
|
|
44
|
+
sessionId?: string;
|
|
45
|
+
workspaceDir?: string;
|
|
46
|
+
channelId?: string;
|
|
47
|
+
trigger?: string;
|
|
48
|
+
};
|
|
49
|
+
export type PluginHookBeforePromptBuildEvent = {
|
|
50
|
+
prompt: string;
|
|
51
|
+
messages: unknown[];
|
|
52
|
+
};
|
|
53
|
+
export type PluginHookBeforePromptBuildResult = {
|
|
54
|
+
systemPrompt?: string;
|
|
55
|
+
prependContext?: string;
|
|
56
|
+
prependSystemContext?: string;
|
|
57
|
+
appendSystemContext?: string;
|
|
58
|
+
};
|
|
59
|
+
export type PluginTool = {
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
parameters: Record<string, unknown>;
|
|
63
|
+
execute: (toolCallId: string, args: Record<string, unknown>) => Promise<{
|
|
64
|
+
content: Array<{
|
|
65
|
+
type: "text";
|
|
66
|
+
text: string;
|
|
67
|
+
}>;
|
|
68
|
+
details?: unknown;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
export type OpenClawGatewayConfig = {
|
|
72
|
+
port?: number;
|
|
73
|
+
auth?: {
|
|
74
|
+
mode?: string;
|
|
75
|
+
token?: string;
|
|
76
|
+
password?: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export type OpenClawPluginApi = {
|
|
80
|
+
config?: {
|
|
81
|
+
plugins?: Record<string, unknown>;
|
|
82
|
+
gateway?: OpenClawGatewayConfig;
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
};
|
|
85
|
+
pluginConfig?: Record<string, unknown>;
|
|
86
|
+
logger: {
|
|
87
|
+
info: (message: string) => void;
|
|
88
|
+
warn: (message: string) => void;
|
|
89
|
+
error: (message: string) => void;
|
|
90
|
+
debug?: (message: string) => void;
|
|
91
|
+
};
|
|
92
|
+
registerService: (service: PluginService) => void;
|
|
93
|
+
registerGatewayMethod: (method: string, handler: GatewayRequestHandler) => void;
|
|
94
|
+
registerTool: (tool: PluginTool) => void;
|
|
95
|
+
registerHttpRoute: (route: {
|
|
96
|
+
path: string;
|
|
97
|
+
auth?: "plugin" | "gateway";
|
|
98
|
+
handler: (req: unknown, res: {
|
|
99
|
+
statusCode: number;
|
|
100
|
+
end: (body?: string) => void;
|
|
101
|
+
}) => void;
|
|
102
|
+
}) => void;
|
|
103
|
+
on: {
|
|
104
|
+
(name: "message_received", handler: (event: PluginHookMessageEvent, ctx: PluginHookMessageContext) => void | Promise<void>): void;
|
|
105
|
+
(name: "gateway_start", handler: (event: PluginHookGatewayStartEvent) => void | Promise<void>): void;
|
|
106
|
+
(name: "gateway_stop", handler: (event: PluginHookGatewayStopEvent) => void | Promise<void>): void;
|
|
107
|
+
(name: "before_prompt_build", handler: (event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext) => PluginHookBeforePromptBuildResult | void | Promise<PluginHookBeforePromptBuildResult | void>): void;
|
|
108
|
+
};
|
|
109
|
+
};
|
package/dist/types/openclaw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|