@love-moon/conductor-sdk 0.2.19 → 0.2.20
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/client.d.ts +4 -2
- package/dist/client.js +9 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.js +33 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { ConductorConfig } from './config/index.js';
|
|
|
3
3
|
import { MessageRouter } from './message/index.js';
|
|
4
4
|
import { DownstreamCursorStore, DurableUpstreamOutboxStore } from './outbox/index.js';
|
|
5
5
|
import { SessionDiskStore, SessionManager } from './session/index.js';
|
|
6
|
-
import { ConductorWebSocketClient, WebSocketConnectedEvent, WebSocketDisconnectEvent } from './ws/index.js';
|
|
6
|
+
import { ConductorWebSocketClient, WebSocketConnectedEvent, WebSocketDisconnectEvent, WebSocketPongEvent } from './ws/index.js';
|
|
7
7
|
type BackendApiLike = Pick<BackendApiClient, 'listProjects' | 'createProject' | 'listTasks' | 'createTask' | 'updateTask' | 'commitSdkMessage' | 'commitTaskStatusUpdate' | 'commitAgentCommandAck' | 'commitTaskStopAck' | 'matchProjectByPath' | 'getProject' | 'updateProject'>;
|
|
8
|
-
type RealtimeClientLike = Pick<ConductorWebSocketClient, 'registerHandler' | 'connect' | 'disconnect' | 'sendJson'
|
|
8
|
+
type RealtimeClientLike = Pick<ConductorWebSocketClient, 'registerHandler' | 'connect' | 'disconnect' | 'sendJson'> & Partial<Pick<ConductorWebSocketClient, 'forceReconnect'>>;
|
|
9
9
|
export interface ConductorClientConnectOptions {
|
|
10
10
|
config?: ConductorConfig;
|
|
11
11
|
configFile?: string;
|
|
@@ -23,6 +23,7 @@ export interface ConductorClientConnectOptions {
|
|
|
23
23
|
agentHost?: string;
|
|
24
24
|
onConnected?: (event: WebSocketConnectedEvent) => void;
|
|
25
25
|
onDisconnected?: (event: WebSocketDisconnectEvent) => void;
|
|
26
|
+
onPong?: (event: WebSocketPongEvent) => void;
|
|
26
27
|
onStopTask?: (event: StopTaskEvent) => Promise<void> | void;
|
|
27
28
|
}
|
|
28
29
|
interface ConductorClientInit {
|
|
@@ -66,6 +67,7 @@ export declare class ConductorClient {
|
|
|
66
67
|
constructor(init: ConductorClientInit);
|
|
67
68
|
static connect(options?: ConductorClientConnectOptions): Promise<ConductorClient>;
|
|
68
69
|
close(): Promise<void>;
|
|
70
|
+
forceReconnect(reason?: string): Promise<void>;
|
|
69
71
|
createTaskSession(payload: Record<string, any>): Promise<Record<string, any>>;
|
|
70
72
|
sendMessage(taskId: string, content: string, metadata?: Record<string, any>): Promise<Record<string, any>>;
|
|
71
73
|
sendTaskStatus(taskId: string, payload: Record<string, any>): Promise<Record<string, any>>;
|
package/dist/client.js
CHANGED
|
@@ -58,6 +58,7 @@ export class ConductorClient {
|
|
|
58
58
|
hostName: agentHost,
|
|
59
59
|
onConnected: options.onConnected,
|
|
60
60
|
onDisconnected: options.onDisconnected,
|
|
61
|
+
onPong: options.onPong,
|
|
61
62
|
onReconnected: () => {
|
|
62
63
|
if (client.shouldAutoFlushDurableOutbox()) {
|
|
63
64
|
void client.requestDurableOutboxFlush(true);
|
|
@@ -93,6 +94,14 @@ export class ConductorClient {
|
|
|
93
94
|
this.clearDurableOutboxTimer();
|
|
94
95
|
await this.wsClient.disconnect();
|
|
95
96
|
}
|
|
97
|
+
async forceReconnect(reason = 'manual_reconnect') {
|
|
98
|
+
if (typeof this.wsClient.forceReconnect === 'function') {
|
|
99
|
+
await this.wsClient.forceReconnect(reason);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
await this.wsClient.disconnect();
|
|
103
|
+
await this.wsClient.connect();
|
|
104
|
+
}
|
|
96
105
|
async createTaskSession(payload) {
|
|
97
106
|
const projectId = String(payload.project_id || '').trim();
|
|
98
107
|
if (!projectId) {
|
package/dist/config/index.d.ts
CHANGED
|
@@ -19,6 +19,16 @@ export interface ConductorConfigInit {
|
|
|
19
19
|
websocketUrl?: string;
|
|
20
20
|
logLevel?: string;
|
|
21
21
|
daemonName?: string;
|
|
22
|
+
channels?: ConductorChannelsConfig;
|
|
23
|
+
}
|
|
24
|
+
export interface FeishuChannelConfig {
|
|
25
|
+
appId: string;
|
|
26
|
+
appSecret: string;
|
|
27
|
+
verificationToken: string;
|
|
28
|
+
encryptKey?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ConductorChannelsConfig {
|
|
31
|
+
feishu?: FeishuChannelConfig;
|
|
22
32
|
}
|
|
23
33
|
export declare class ConductorConfig {
|
|
24
34
|
readonly agentToken: string;
|
|
@@ -26,6 +36,7 @@ export declare class ConductorConfig {
|
|
|
26
36
|
readonly websocketUrl?: string;
|
|
27
37
|
readonly logLevel: string;
|
|
28
38
|
readonly daemonName?: string;
|
|
39
|
+
readonly channels?: ConductorChannelsConfig;
|
|
29
40
|
constructor(init: ConductorConfigInit);
|
|
30
41
|
get resolvedWebsocketUrl(): string;
|
|
31
42
|
}
|
package/dist/config/index.js
CHANGED
|
@@ -31,12 +31,14 @@ export class ConductorConfig {
|
|
|
31
31
|
websocketUrl;
|
|
32
32
|
logLevel;
|
|
33
33
|
daemonName;
|
|
34
|
+
channels;
|
|
34
35
|
constructor(init) {
|
|
35
36
|
this.agentToken = init.agentToken;
|
|
36
37
|
this.backendUrl = init.backendUrl;
|
|
37
38
|
this.websocketUrl = init.websocketUrl;
|
|
38
39
|
this.logLevel = (init.logLevel || 'info').toLowerCase();
|
|
39
40
|
this.daemonName = normalizeOptionalString(init.daemonName);
|
|
41
|
+
this.channels = init.channels;
|
|
40
42
|
}
|
|
41
43
|
get resolvedWebsocketUrl() {
|
|
42
44
|
if (this.websocketUrl) {
|
|
@@ -91,6 +93,7 @@ export function loadConfig(targetPath, options = {}) {
|
|
|
91
93
|
websocketUrl,
|
|
92
94
|
logLevel: logLevel,
|
|
93
95
|
daemonName: normalizeOptionalString(merged.daemon_name),
|
|
96
|
+
channels: normalizeChannelsConfig(merged.channels),
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
function resolveConfigPath(explicitPath, env) {
|
|
@@ -160,3 +163,33 @@ function normalizeLogLevel(value) {
|
|
|
160
163
|
const lowered = value.trim().toLowerCase();
|
|
161
164
|
return ALLOWED_LOG_LEVELS.has(lowered) ? lowered : undefined;
|
|
162
165
|
}
|
|
166
|
+
function normalizeChannelsConfig(value) {
|
|
167
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
const raw = value;
|
|
171
|
+
const feishu = normalizeFeishuChannelConfig(raw.feishu);
|
|
172
|
+
if (!feishu) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
return { feishu };
|
|
176
|
+
}
|
|
177
|
+
function normalizeFeishuChannelConfig(value) {
|
|
178
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
const raw = value;
|
|
182
|
+
const appId = normalizeOptionalString(raw.app_id);
|
|
183
|
+
const appSecret = normalizeOptionalString(raw.app_secret);
|
|
184
|
+
const verificationToken = normalizeOptionalString(raw.verification_token);
|
|
185
|
+
const encryptKey = normalizeOptionalString(raw.encrypt_key);
|
|
186
|
+
if (!appId || !appSecret || !verificationToken) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
appId,
|
|
191
|
+
appSecret,
|
|
192
|
+
verificationToken,
|
|
193
|
+
...(encryptKey ? { encryptKey } : {}),
|
|
194
|
+
};
|
|
195
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@love-moon/conductor-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"typescript": "^5.6.3",
|
|
28
28
|
"vitest": "^2.1.4"
|
|
29
29
|
},
|
|
30
|
-
"gitCommitId": "
|
|
30
|
+
"gitCommitId": "d622756"
|
|
31
31
|
}
|