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
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import { type FrpTunnelConfig } from "../infra/frp";
|
|
3
|
-
import { type AgentRecord } from "./agent-registry";
|
|
4
|
-
import { type AgentProfile } from "./agent-profile";
|
|
5
|
-
import { type TeamRecord, type TeamMember } from "../team/team-store";
|
|
6
|
-
import type { GatewayConfig } from "../infra/gateway-client";
|
|
7
|
-
export type MulticlawsServiceOptions = {
|
|
8
|
-
stateDir: string;
|
|
9
|
-
port?: number;
|
|
10
|
-
displayName?: string;
|
|
11
|
-
selfUrl?: string;
|
|
12
|
-
cwd?: string;
|
|
13
|
-
tunnel?: FrpTunnelConfig & {
|
|
14
|
-
type: "frp";
|
|
15
|
-
};
|
|
16
|
-
gatewayConfig?: GatewayConfig;
|
|
17
|
-
logger?: {
|
|
18
|
-
info: (message: string) => void;
|
|
19
|
-
warn: (message: string) => void;
|
|
20
|
-
error: (message: string) => void;
|
|
21
|
-
debug?: (message: string) => void;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export type DelegateTaskResult = {
|
|
25
|
-
taskId?: string;
|
|
26
|
-
output?: string;
|
|
27
|
-
status: string;
|
|
28
|
-
error?: string;
|
|
29
|
-
};
|
|
30
|
-
export type NotificationTarget = {
|
|
31
|
-
type: "channel";
|
|
32
|
-
conversationId: string;
|
|
33
|
-
} | {
|
|
34
|
-
type: "web";
|
|
35
|
-
sessionKey: string;
|
|
36
|
-
};
|
|
37
|
-
export declare class MulticlawsService extends EventEmitter {
|
|
38
|
-
private readonly options;
|
|
39
|
-
private started;
|
|
40
|
-
private httpServer;
|
|
41
|
-
private readonly agentRegistry;
|
|
42
|
-
private readonly teamStore;
|
|
43
|
-
private readonly profileStore;
|
|
44
|
-
private readonly taskTracker;
|
|
45
|
-
private agentExecutor;
|
|
46
|
-
private a2aRequestHandler;
|
|
47
|
-
private agentCard;
|
|
48
|
-
private readonly clientFactory;
|
|
49
|
-
private readonly httpRateLimiter;
|
|
50
|
-
private frpTunnel;
|
|
51
|
-
private selfUrl;
|
|
52
|
-
private profileDescription;
|
|
53
|
-
private readonly gatewayConfig;
|
|
54
|
-
private readonly resolvedCwd;
|
|
55
|
-
private readonly notificationTargets;
|
|
56
|
-
constructor(options: MulticlawsServiceOptions);
|
|
57
|
-
start(): Promise<void>;
|
|
58
|
-
stop(): Promise<void>;
|
|
59
|
-
updateGatewayConfig(config: GatewayConfig): void;
|
|
60
|
-
listAgents(): Promise<AgentRecord[]>;
|
|
61
|
-
addAgent(params: {
|
|
62
|
-
url: string;
|
|
63
|
-
apiKey?: string;
|
|
64
|
-
}): Promise<AgentRecord>;
|
|
65
|
-
removeAgent(url: string): Promise<boolean>;
|
|
66
|
-
delegateTask(params: {
|
|
67
|
-
agentUrl: string;
|
|
68
|
-
task: string;
|
|
69
|
-
}): Promise<DelegateTaskResult>;
|
|
70
|
-
/**
|
|
71
|
-
* Synchronous delegation: sends A2A task and waits for the result.
|
|
72
|
-
* Used by sub-agents internally via the multiclaws_delegate_send tool.
|
|
73
|
-
*/
|
|
74
|
-
delegateTaskSync(params: {
|
|
75
|
-
agentUrl: string;
|
|
76
|
-
task: string;
|
|
77
|
-
}): Promise<DelegateTaskResult>;
|
|
78
|
-
/**
|
|
79
|
-
* Spawn a sub-agent to handle delegation asynchronously.
|
|
80
|
-
* The sub-agent uses multiclaws_delegate_send internally and
|
|
81
|
-
* reports results back to the user via the message tool.
|
|
82
|
-
*/
|
|
83
|
-
spawnDelegation(params: {
|
|
84
|
-
agentUrl: string;
|
|
85
|
-
task: string;
|
|
86
|
-
}): Promise<{
|
|
87
|
-
message: string;
|
|
88
|
-
}>;
|
|
89
|
-
getTaskStatus(taskId: string): import("../task/tracker").TaskRecord | null;
|
|
90
|
-
getProfile(): Promise<AgentProfile>;
|
|
91
|
-
/**
|
|
92
|
-
* Throws if the profile is incomplete (ownerName or bio missing).
|
|
93
|
-
* Call this before any action that exposes the user's identity to other agents.
|
|
94
|
-
*/
|
|
95
|
-
private requireCompleteProfile;
|
|
96
|
-
setProfile(patch: {
|
|
97
|
-
ownerName?: string;
|
|
98
|
-
bio?: string;
|
|
99
|
-
}): Promise<AgentProfile>;
|
|
100
|
-
private updateProfileDescription;
|
|
101
|
-
private getPendingReviewPath;
|
|
102
|
-
getPendingProfileReview(): Promise<{
|
|
103
|
-
pending: boolean;
|
|
104
|
-
profile?: AgentProfile;
|
|
105
|
-
message?: string;
|
|
106
|
-
}>;
|
|
107
|
-
setPendingProfileReview(): Promise<void>;
|
|
108
|
-
clearPendingProfileReview(): Promise<void>;
|
|
109
|
-
createTeam(name: string): Promise<TeamRecord>;
|
|
110
|
-
createInvite(teamId?: string): Promise<string>;
|
|
111
|
-
joinTeam(inviteCode: string): Promise<TeamRecord>;
|
|
112
|
-
leaveTeam(teamId?: string): Promise<void>;
|
|
113
|
-
listTeamMembers(teamId?: string): Promise<{
|
|
114
|
-
team: TeamRecord;
|
|
115
|
-
members: TeamMember[];
|
|
116
|
-
} | {
|
|
117
|
-
teams: Array<{
|
|
118
|
-
team: TeamRecord;
|
|
119
|
-
members: TeamMember[];
|
|
120
|
-
}>;
|
|
121
|
-
} | null>;
|
|
122
|
-
private mountTeamRoutes;
|
|
123
|
-
private broadcastProfileToTeams;
|
|
124
|
-
private fetchMemberDescriptions;
|
|
125
|
-
private syncTeamToRegistry;
|
|
126
|
-
private createA2AClient;
|
|
127
|
-
/**
|
|
128
|
-
* Send a message using A2A streaming to minimize latency.
|
|
129
|
-
* Instead of a single blocking HTTP call, consume the SSE stream and
|
|
130
|
-
* return the final Task or Message as soon as B signals completion.
|
|
131
|
-
*/
|
|
132
|
-
private processTaskResult;
|
|
133
|
-
private extractArtifactText;
|
|
134
|
-
/** Fetch with up to 2 retries and exponential backoff. */
|
|
135
|
-
private fetchWithRetry;
|
|
136
|
-
/**
|
|
137
|
-
* Called by the `multiclaws_task_respond` tool when the local human
|
|
138
|
-
* approves or rejects a pending risky incoming task.
|
|
139
|
-
*/
|
|
140
|
-
respondToTask(taskId: string, approved: boolean): boolean;
|
|
141
|
-
/** Resolve a pending A2A callback from sub-agent. */
|
|
142
|
-
resolveA2ACallback(taskId: string, result: string): boolean;
|
|
143
|
-
addNotificationTarget(key: string, target: NotificationTarget): void;
|
|
144
|
-
/** Consistent name for this agent: AgentCard.name or fallback. */
|
|
145
|
-
private getFormattedName;
|
|
146
|
-
/** Discover the most recently active non-internal session via sessions_list. */
|
|
147
|
-
private discoverActiveSession;
|
|
148
|
-
notifyUser(message: string): Promise<void>;
|
|
149
|
-
private log;
|
|
150
|
-
}
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { type FrpTunnelConfig } from "../infra/frp";
|
|
3
|
+
import { type AgentRecord } from "./agent-registry";
|
|
4
|
+
import { type AgentProfile } from "./agent-profile";
|
|
5
|
+
import { type TeamRecord, type TeamMember } from "../team/team-store";
|
|
6
|
+
import type { GatewayConfig } from "../infra/gateway-client";
|
|
7
|
+
export type MulticlawsServiceOptions = {
|
|
8
|
+
stateDir: string;
|
|
9
|
+
port?: number;
|
|
10
|
+
displayName?: string;
|
|
11
|
+
selfUrl?: string;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
tunnel?: FrpTunnelConfig & {
|
|
14
|
+
type: "frp";
|
|
15
|
+
};
|
|
16
|
+
gatewayConfig?: GatewayConfig;
|
|
17
|
+
logger?: {
|
|
18
|
+
info: (message: string) => void;
|
|
19
|
+
warn: (message: string) => void;
|
|
20
|
+
error: (message: string) => void;
|
|
21
|
+
debug?: (message: string) => void;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type DelegateTaskResult = {
|
|
25
|
+
taskId?: string;
|
|
26
|
+
output?: string;
|
|
27
|
+
status: string;
|
|
28
|
+
error?: string;
|
|
29
|
+
};
|
|
30
|
+
export type NotificationTarget = {
|
|
31
|
+
type: "channel";
|
|
32
|
+
conversationId: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "web";
|
|
35
|
+
sessionKey: string;
|
|
36
|
+
};
|
|
37
|
+
export declare class MulticlawsService extends EventEmitter {
|
|
38
|
+
private readonly options;
|
|
39
|
+
private started;
|
|
40
|
+
private httpServer;
|
|
41
|
+
private readonly agentRegistry;
|
|
42
|
+
private readonly teamStore;
|
|
43
|
+
private readonly profileStore;
|
|
44
|
+
private readonly taskTracker;
|
|
45
|
+
private agentExecutor;
|
|
46
|
+
private a2aRequestHandler;
|
|
47
|
+
private agentCard;
|
|
48
|
+
private readonly clientFactory;
|
|
49
|
+
private readonly httpRateLimiter;
|
|
50
|
+
private frpTunnel;
|
|
51
|
+
private selfUrl;
|
|
52
|
+
private profileDescription;
|
|
53
|
+
private readonly gatewayConfig;
|
|
54
|
+
private readonly resolvedCwd;
|
|
55
|
+
private readonly notificationTargets;
|
|
56
|
+
constructor(options: MulticlawsServiceOptions);
|
|
57
|
+
start(): Promise<void>;
|
|
58
|
+
stop(): Promise<void>;
|
|
59
|
+
updateGatewayConfig(config: GatewayConfig): void;
|
|
60
|
+
listAgents(): Promise<AgentRecord[]>;
|
|
61
|
+
addAgent(params: {
|
|
62
|
+
url: string;
|
|
63
|
+
apiKey?: string;
|
|
64
|
+
}): Promise<AgentRecord>;
|
|
65
|
+
removeAgent(url: string): Promise<boolean>;
|
|
66
|
+
delegateTask(params: {
|
|
67
|
+
agentUrl: string;
|
|
68
|
+
task: string;
|
|
69
|
+
}): Promise<DelegateTaskResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Synchronous delegation: sends A2A task and waits for the result.
|
|
72
|
+
* Used by sub-agents internally via the multiclaws_delegate_send tool.
|
|
73
|
+
*/
|
|
74
|
+
delegateTaskSync(params: {
|
|
75
|
+
agentUrl: string;
|
|
76
|
+
task: string;
|
|
77
|
+
}): Promise<DelegateTaskResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Spawn a sub-agent to handle delegation asynchronously.
|
|
80
|
+
* The sub-agent uses multiclaws_delegate_send internally and
|
|
81
|
+
* reports results back to the user via the message tool.
|
|
82
|
+
*/
|
|
83
|
+
spawnDelegation(params: {
|
|
84
|
+
agentUrl: string;
|
|
85
|
+
task: string;
|
|
86
|
+
}): Promise<{
|
|
87
|
+
message: string;
|
|
88
|
+
}>;
|
|
89
|
+
getTaskStatus(taskId: string): import("../task/tracker").TaskRecord | null;
|
|
90
|
+
getProfile(): Promise<AgentProfile>;
|
|
91
|
+
/**
|
|
92
|
+
* Throws if the profile is incomplete (ownerName or bio missing).
|
|
93
|
+
* Call this before any action that exposes the user's identity to other agents.
|
|
94
|
+
*/
|
|
95
|
+
private requireCompleteProfile;
|
|
96
|
+
setProfile(patch: {
|
|
97
|
+
ownerName?: string;
|
|
98
|
+
bio?: string;
|
|
99
|
+
}): Promise<AgentProfile>;
|
|
100
|
+
private updateProfileDescription;
|
|
101
|
+
private getPendingReviewPath;
|
|
102
|
+
getPendingProfileReview(): Promise<{
|
|
103
|
+
pending: boolean;
|
|
104
|
+
profile?: AgentProfile;
|
|
105
|
+
message?: string;
|
|
106
|
+
}>;
|
|
107
|
+
setPendingProfileReview(): Promise<void>;
|
|
108
|
+
clearPendingProfileReview(): Promise<void>;
|
|
109
|
+
createTeam(name: string): Promise<TeamRecord>;
|
|
110
|
+
createInvite(teamId?: string): Promise<string>;
|
|
111
|
+
joinTeam(inviteCode: string): Promise<TeamRecord>;
|
|
112
|
+
leaveTeam(teamId?: string): Promise<void>;
|
|
113
|
+
listTeamMembers(teamId?: string): Promise<{
|
|
114
|
+
team: TeamRecord;
|
|
115
|
+
members: TeamMember[];
|
|
116
|
+
} | {
|
|
117
|
+
teams: Array<{
|
|
118
|
+
team: TeamRecord;
|
|
119
|
+
members: TeamMember[];
|
|
120
|
+
}>;
|
|
121
|
+
} | null>;
|
|
122
|
+
private mountTeamRoutes;
|
|
123
|
+
private broadcastProfileToTeams;
|
|
124
|
+
private fetchMemberDescriptions;
|
|
125
|
+
private syncTeamToRegistry;
|
|
126
|
+
private createA2AClient;
|
|
127
|
+
/**
|
|
128
|
+
* Send a message using A2A streaming to minimize latency.
|
|
129
|
+
* Instead of a single blocking HTTP call, consume the SSE stream and
|
|
130
|
+
* return the final Task or Message as soon as B signals completion.
|
|
131
|
+
*/
|
|
132
|
+
private processTaskResult;
|
|
133
|
+
private extractArtifactText;
|
|
134
|
+
/** Fetch with up to 2 retries and exponential backoff. */
|
|
135
|
+
private fetchWithRetry;
|
|
136
|
+
/**
|
|
137
|
+
* Called by the `multiclaws_task_respond` tool when the local human
|
|
138
|
+
* approves or rejects a pending risky incoming task.
|
|
139
|
+
*/
|
|
140
|
+
respondToTask(taskId: string, approved: boolean): boolean;
|
|
141
|
+
/** Resolve a pending A2A callback from sub-agent. */
|
|
142
|
+
resolveA2ACallback(taskId: string, result: string): boolean;
|
|
143
|
+
addNotificationTarget(key: string, target: NotificationTarget): void;
|
|
144
|
+
/** Consistent name for this agent: AgentCard.name or fallback. */
|
|
145
|
+
private getFormattedName;
|
|
146
|
+
/** Discover the most recently active non-internal session via sessions_list. */
|
|
147
|
+
private discoverActiveSession;
|
|
148
|
+
notifyUser(message: string): Promise<void>;
|
|
149
|
+
private log;
|
|
150
|
+
}
|