@alfe.ai/openclaw 0.4.10 → 0.4.11
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 +10 -0
- package/dist/index.cjs +129 -50
- package/dist/index.d.cts +26 -22
- package/dist/index.d.ts +26 -22
- package/dist/index.js +128 -49
- package/dist/plugin2.cjs +622 -252
- package/dist/plugin2.js +623 -253
- package/openclaw.plugin.json +2 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -74,6 +74,16 @@ Integration management (install, remove, configure, health) is handled by
|
|
|
74
74
|
the gateway service directly — this plugin does not process integration
|
|
75
75
|
commands.
|
|
76
76
|
|
|
77
|
+
## Tool Safety
|
|
78
|
+
|
|
79
|
+
- `install_integration` requires `confirm: true` after the user approves the
|
|
80
|
+
runtime change.
|
|
81
|
+
- `remove_integration` requires `confirmIntegrationId` to exactly match the id
|
|
82
|
+
being removed.
|
|
83
|
+
- `set_avatar` accepts a stage-matched Alfe agent-assets URL or a
|
|
84
|
+
workspace-relative PNG/JPEG/WebP path up to 5 MiB. It does not fetch arbitrary
|
|
85
|
+
public URLs or read absolute paths outside the agent workspace.
|
|
86
|
+
|
|
77
87
|
## Links
|
|
78
88
|
|
|
79
89
|
- 🌐 Website: <https://alfe.ai>
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_plugin = require("./plugin2.cjs");
|
|
3
|
-
let
|
|
3
|
+
let node_module = require("node:module");
|
|
4
|
+
let node_events = require("node:events");
|
|
4
5
|
let crypto = require("crypto");
|
|
5
6
|
//#region ../../node_modules/.pnpm/ws@8.19.0_bufferutil@4.1.0_utf-8-validate@6.0.6/node_modules/ws/lib/constants.js
|
|
6
7
|
var require_constants = /* @__PURE__ */ require_plugin.__commonJSMin(((exports, module) => {
|
|
@@ -3748,7 +3749,7 @@ require_websocket_server();
|
|
|
3748
3749
|
var wrapper_default = import_websocket.default;
|
|
3749
3750
|
//#endregion
|
|
3750
3751
|
//#region ../../packages-internal/agent-client/dist/chat-event-bus.js
|
|
3751
|
-
var ChatEventBus = class extends
|
|
3752
|
+
var ChatEventBus = class extends node_events.EventEmitter {
|
|
3752
3753
|
constructor() {
|
|
3753
3754
|
super();
|
|
3754
3755
|
this.setMaxListeners(100);
|
|
@@ -3768,14 +3769,14 @@ const chatEventBus = new ChatEventBus();
|
|
|
3768
3769
|
//#endregion
|
|
3769
3770
|
//#region ../../packages-internal/agent-client/dist/base-client.js
|
|
3770
3771
|
const defaultLogger = {
|
|
3771
|
-
info: (msg) => {
|
|
3772
|
-
console.log(msg);
|
|
3772
|
+
info: (msg, ...args) => {
|
|
3773
|
+
console.log(msg, ...args);
|
|
3773
3774
|
},
|
|
3774
|
-
warn: (msg) => {
|
|
3775
|
-
console.warn(msg);
|
|
3775
|
+
warn: (msg, ...args) => {
|
|
3776
|
+
console.warn(msg, ...args);
|
|
3776
3777
|
},
|
|
3777
|
-
error: (msg) => {
|
|
3778
|
-
console.error(msg);
|
|
3778
|
+
error: (msg, ...args) => {
|
|
3779
|
+
console.error(msg, ...args);
|
|
3779
3780
|
},
|
|
3780
3781
|
debug: () => {}
|
|
3781
3782
|
};
|
|
@@ -3785,9 +3786,11 @@ var BaseAgentClient = class {
|
|
|
3785
3786
|
closed = false;
|
|
3786
3787
|
backoffMs = 1e3;
|
|
3787
3788
|
pending = /* @__PURE__ */ new Map();
|
|
3789
|
+
reconnectTimer = null;
|
|
3788
3790
|
readyResolve = () => {};
|
|
3789
3791
|
readyReject = () => {};
|
|
3790
3792
|
readyPromise;
|
|
3793
|
+
readySettled = false;
|
|
3791
3794
|
log;
|
|
3792
3795
|
opts;
|
|
3793
3796
|
instanceId;
|
|
@@ -3795,10 +3798,7 @@ var BaseAgentClient = class {
|
|
|
3795
3798
|
this.opts = opts;
|
|
3796
3799
|
this.log = opts.logger ?? defaultLogger;
|
|
3797
3800
|
this.instanceId = opts.instanceId ?? (0, crypto.randomUUID)().slice(0, 8);
|
|
3798
|
-
this.
|
|
3799
|
-
this.readyResolve = resolve;
|
|
3800
|
-
this.readyReject = reject;
|
|
3801
|
-
});
|
|
3801
|
+
this.resetReady();
|
|
3802
3802
|
}
|
|
3803
3803
|
get isConnected() {
|
|
3804
3804
|
return this.connected && this.ws?.readyState === wrapper_default.OPEN;
|
|
@@ -3808,13 +3808,26 @@ var BaseAgentClient = class {
|
|
|
3808
3808
|
this.log.info("[agent-client] URL not set — skipping");
|
|
3809
3809
|
return;
|
|
3810
3810
|
}
|
|
3811
|
+
if (this.isConnected) return;
|
|
3812
|
+
if (this.ws || this.reconnectTimer) return this.readyPromise;
|
|
3813
|
+
if (this.readySettled) this.resetReady();
|
|
3811
3814
|
this.closed = false;
|
|
3812
|
-
|
|
3815
|
+
try {
|
|
3816
|
+
this.doConnect();
|
|
3817
|
+
} catch (err) {
|
|
3818
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3819
|
+
this.rejectReady(error);
|
|
3820
|
+
}
|
|
3813
3821
|
return this.readyPromise;
|
|
3814
3822
|
}
|
|
3815
3823
|
stop() {
|
|
3816
3824
|
this.closed = true;
|
|
3817
3825
|
this.connected = false;
|
|
3826
|
+
if (this.reconnectTimer) {
|
|
3827
|
+
clearTimeout(this.reconnectTimer);
|
|
3828
|
+
this.reconnectTimer = null;
|
|
3829
|
+
}
|
|
3830
|
+
this.rejectReady(/* @__PURE__ */ new Error("Client stopped"));
|
|
3818
3831
|
this.onDisconnected();
|
|
3819
3832
|
this.ws?.close();
|
|
3820
3833
|
this.ws = null;
|
|
@@ -3822,8 +3835,11 @@ var BaseAgentClient = class {
|
|
|
3822
3835
|
}
|
|
3823
3836
|
request(method, params, opts) {
|
|
3824
3837
|
if (this.ws?.readyState !== wrapper_default.OPEN) return Promise.reject(/* @__PURE__ */ new Error("Gateway WS not connected"));
|
|
3838
|
+
if (method.trim().length === 0) return Promise.reject(/* @__PURE__ */ new TypeError("Gateway method must not be empty"));
|
|
3825
3839
|
const id = (0, crypto.randomUUID)();
|
|
3826
3840
|
const timeoutMs = opts?.timeoutMs ?? 3e4;
|
|
3841
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 2147483647) return Promise.reject(/* @__PURE__ */ new RangeError("Gateway timeoutMs must be a positive integer no greater than 2147483647"));
|
|
3842
|
+
const ws = this.ws;
|
|
3827
3843
|
return new Promise((resolve, reject) => {
|
|
3828
3844
|
const timer = setTimeout(() => {
|
|
3829
3845
|
this.pending.delete(id);
|
|
@@ -3840,13 +3856,29 @@ var BaseAgentClient = class {
|
|
|
3840
3856
|
},
|
|
3841
3857
|
expectFinal: opts?.expectFinal === true
|
|
3842
3858
|
});
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3859
|
+
try {
|
|
3860
|
+
ws.send(JSON.stringify({
|
|
3861
|
+
type: "req",
|
|
3862
|
+
id,
|
|
3863
|
+
method,
|
|
3864
|
+
params
|
|
3865
|
+
}), (err) => {
|
|
3866
|
+
if (!err) return;
|
|
3867
|
+
const pending = this.pending.get(id);
|
|
3868
|
+
if (!pending) return;
|
|
3869
|
+
this.pending.delete(id);
|
|
3870
|
+
pending.reject(err);
|
|
3871
|
+
});
|
|
3872
|
+
} catch (err) {
|
|
3873
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3874
|
+
const pending = this.pending.get(id);
|
|
3875
|
+
this.pending.delete(id);
|
|
3876
|
+
if (pending) pending.reject(error);
|
|
3877
|
+
else {
|
|
3878
|
+
clearTimeout(timer);
|
|
3879
|
+
reject(error);
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3850
3882
|
});
|
|
3851
3883
|
}
|
|
3852
3884
|
/**
|
|
@@ -3871,88 +3903,131 @@ var BaseAgentClient = class {
|
|
|
3871
3903
|
}
|
|
3872
3904
|
/** Resolve the ready promise (call after handshake + onConnected). */
|
|
3873
3905
|
resolveReady() {
|
|
3906
|
+
if (this.readySettled) return;
|
|
3907
|
+
this.readySettled = true;
|
|
3874
3908
|
this.readyResolve();
|
|
3875
3909
|
}
|
|
3876
3910
|
/** Reject the ready promise (call on handshake failure). */
|
|
3877
3911
|
rejectReady(err) {
|
|
3912
|
+
if (this.readySettled) return;
|
|
3913
|
+
this.readySettled = true;
|
|
3878
3914
|
this.readyReject(err);
|
|
3879
3915
|
}
|
|
3880
3916
|
doConnect() {
|
|
3881
3917
|
if (this.closed) return;
|
|
3882
|
-
|
|
3883
|
-
this.ws
|
|
3884
|
-
|
|
3885
|
-
this.
|
|
3918
|
+
const ws = new wrapper_default(this.opts.url, { maxPayload: this.opts.maxPayload ?? 10 * 1024 * 1024 });
|
|
3919
|
+
this.ws = ws;
|
|
3920
|
+
ws.on("open", () => {
|
|
3921
|
+
if (this.ws !== ws || this.closed) {
|
|
3922
|
+
ws.close();
|
|
3923
|
+
return;
|
|
3924
|
+
}
|
|
3925
|
+
this.log.info("[agent-client] WebSocket connected");
|
|
3926
|
+
this.initiateHandshake(ws);
|
|
3886
3927
|
});
|
|
3887
|
-
|
|
3928
|
+
ws.on("message", (data) => {
|
|
3929
|
+
if (this.ws !== ws || this.closed) return;
|
|
3888
3930
|
const raw = Buffer.isBuffer(data) ? data.toString("utf-8") : data instanceof ArrayBuffer ? Buffer.from(data).toString("utf-8") : Buffer.concat(data).toString("utf-8");
|
|
3889
3931
|
this.handleMessage(raw);
|
|
3890
3932
|
});
|
|
3891
|
-
|
|
3933
|
+
ws.on("close", (code, reason) => {
|
|
3934
|
+
if (this.ws !== ws) return;
|
|
3892
3935
|
this.log.warn(`[agent-client] Closed (${String(code)}): ${reason.toString()}`);
|
|
3893
3936
|
this.ws = null;
|
|
3894
3937
|
this.connected = false;
|
|
3895
3938
|
this.flushPending(/* @__PURE__ */ new Error(`Gateway closed (${String(code)})`));
|
|
3896
|
-
this.
|
|
3897
|
-
|
|
3939
|
+
if (!this.closed) {
|
|
3940
|
+
this.onDisconnected();
|
|
3941
|
+
if (this.readySettled) this.resetReady();
|
|
3942
|
+
this.scheduleReconnect();
|
|
3943
|
+
}
|
|
3898
3944
|
});
|
|
3899
|
-
|
|
3945
|
+
ws.on("error", (err) => {
|
|
3946
|
+
if (this.ws !== ws || this.closed) return;
|
|
3900
3947
|
this.log.error(`[agent-client] Error: ${err.message}`);
|
|
3901
|
-
if (!this.connected) this.
|
|
3948
|
+
if (!this.connected) this.rejectReady(err);
|
|
3902
3949
|
});
|
|
3903
3950
|
}
|
|
3904
|
-
async initiateHandshake() {
|
|
3951
|
+
async initiateHandshake(ws) {
|
|
3905
3952
|
try {
|
|
3906
3953
|
await this.performHandshake();
|
|
3954
|
+
if (!this.isCurrentConnection(ws)) return;
|
|
3907
3955
|
this.setConnected();
|
|
3908
3956
|
this.log.info("[agent-client] Handshake complete");
|
|
3909
3957
|
await this.onConnected();
|
|
3958
|
+
if (!this.isCurrentConnection(ws)) return;
|
|
3910
3959
|
this.resolveReady();
|
|
3911
3960
|
} catch (err) {
|
|
3961
|
+
if (!this.isCurrentConnection(ws)) return;
|
|
3912
3962
|
const message = err instanceof Error ? err.message : String(err);
|
|
3913
3963
|
this.log.error(`[agent-client] Handshake failed: ${message}`);
|
|
3914
3964
|
this.rejectReady(err instanceof Error ? err : new Error(message));
|
|
3915
|
-
|
|
3965
|
+
ws.close(1008, "handshake failed");
|
|
3916
3966
|
}
|
|
3917
3967
|
}
|
|
3968
|
+
isCurrentConnection(ws) {
|
|
3969
|
+
return this.ws === ws && !this.closed;
|
|
3970
|
+
}
|
|
3918
3971
|
handleMessage(raw) {
|
|
3919
3972
|
try {
|
|
3920
3973
|
const parsed = JSON.parse(raw);
|
|
3921
|
-
if (
|
|
3974
|
+
if (!isRecord$1(parsed)) {
|
|
3975
|
+
this.log.warn("[agent-client] Ignoring malformed message");
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3978
|
+
if (typeof parsed.event === "string") {
|
|
3922
3979
|
this.handleEvent(parsed.event, parsed.payload);
|
|
3923
3980
|
return;
|
|
3924
3981
|
}
|
|
3925
|
-
if (
|
|
3926
|
-
const rpc =
|
|
3982
|
+
if (typeof parsed.id === "string" && typeof parsed.ok === "boolean") {
|
|
3983
|
+
const rpc = {
|
|
3984
|
+
id: parsed.id,
|
|
3985
|
+
ok: parsed.ok,
|
|
3986
|
+
payload: parsed.payload,
|
|
3987
|
+
error: parsed.error
|
|
3988
|
+
};
|
|
3927
3989
|
const pending = this.pending.get(rpc.id);
|
|
3928
3990
|
if (!pending) return;
|
|
3929
|
-
if (pending.expectFinal && rpc.payload
|
|
3991
|
+
if (pending.expectFinal && rpc.ok && isRecord$1(rpc.payload) && rpc.payload.status === "accepted") return;
|
|
3930
3992
|
this.pending.delete(rpc.id);
|
|
3931
3993
|
if (rpc.ok) pending.resolve(rpc.payload);
|
|
3932
|
-
else
|
|
3994
|
+
else {
|
|
3995
|
+
const message = isRecord$1(rpc.error) && typeof rpc.error.message === "string" ? rpc.error.message : "Gateway request failed";
|
|
3996
|
+
pending.reject(new Error(message));
|
|
3997
|
+
}
|
|
3998
|
+
return;
|
|
3933
3999
|
}
|
|
4000
|
+
this.log.warn("[agent-client] Ignoring malformed message");
|
|
3934
4001
|
} catch (err) {
|
|
3935
4002
|
this.log.error(`[agent-client] Parse error: ${String(err)}`);
|
|
3936
4003
|
}
|
|
3937
4004
|
}
|
|
3938
4005
|
scheduleReconnect() {
|
|
3939
|
-
if (this.closed) return;
|
|
4006
|
+
if (this.closed || this.reconnectTimer) return;
|
|
3940
4007
|
const delay = this.backoffMs;
|
|
3941
4008
|
this.backoffMs = Math.min(this.backoffMs * 2, 3e4);
|
|
3942
4009
|
this.log.info(`[agent-client] Reconnecting in ${String(delay)}ms...`);
|
|
3943
|
-
setTimeout(() => {
|
|
3944
|
-
this.
|
|
3945
|
-
this.readyResolve = resolve;
|
|
3946
|
-
this.readyReject = reject;
|
|
3947
|
-
});
|
|
4010
|
+
this.reconnectTimer = setTimeout(() => {
|
|
4011
|
+
this.reconnectTimer = null;
|
|
3948
4012
|
this.doConnect();
|
|
3949
4013
|
}, delay);
|
|
3950
4014
|
}
|
|
4015
|
+
resetReady() {
|
|
4016
|
+
this.readySettled = false;
|
|
4017
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
4018
|
+
this.readyResolve = resolve;
|
|
4019
|
+
this.readyReject = reject;
|
|
4020
|
+
});
|
|
4021
|
+
this.readyPromise.catch(() => void 0);
|
|
4022
|
+
}
|
|
3951
4023
|
flushPending(err) {
|
|
3952
4024
|
for (const [, p] of this.pending) p.reject(err);
|
|
3953
4025
|
this.pending.clear();
|
|
3954
4026
|
}
|
|
3955
4027
|
};
|
|
4028
|
+
function isRecord$1(value) {
|
|
4029
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4030
|
+
}
|
|
3956
4031
|
//#endregion
|
|
3957
4032
|
//#region src/ws-client.ts
|
|
3958
4033
|
/**
|
|
@@ -3965,6 +4040,7 @@ var BaseAgentClient = class {
|
|
|
3965
4040
|
* - Agent response parsing (multi-format)
|
|
3966
4041
|
* - Session key formatting
|
|
3967
4042
|
*/
|
|
4043
|
+
const pkg = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("../package.json");
|
|
3968
4044
|
var OpenClawGatewayAdapter = class extends BaseAgentClient {
|
|
3969
4045
|
tickTimer = null;
|
|
3970
4046
|
lastTick = 0;
|
|
@@ -3984,7 +4060,7 @@ var OpenClawGatewayAdapter = class extends BaseAgentClient {
|
|
|
3984
4060
|
client: {
|
|
3985
4061
|
id: this.opts.clientId,
|
|
3986
4062
|
displayName: this.opts.displayName,
|
|
3987
|
-
version: this.opts.version ??
|
|
4063
|
+
version: this.opts.version ?? pkg.version,
|
|
3988
4064
|
platform: process.platform,
|
|
3989
4065
|
mode: "backend",
|
|
3990
4066
|
instanceId: this.instanceId
|
|
@@ -4031,13 +4107,13 @@ var OpenClawGatewayAdapter = class extends BaseAgentClient {
|
|
|
4031
4107
|
}
|
|
4032
4108
|
/** Parse the standard agent response format into plain text. */
|
|
4033
4109
|
static parseAgentResponse(response) {
|
|
4034
|
-
if (typeof response !== "object" || response === null) return "";
|
|
4110
|
+
if (typeof response !== "object" || response === null || Array.isArray(response)) return "";
|
|
4035
4111
|
const r = response;
|
|
4036
|
-
const result = r.result;
|
|
4037
|
-
if (result?.payloads) return result.payloads.map((
|
|
4038
|
-
if (typeof r.text === "string") return r.text;
|
|
4039
|
-
if (typeof r.content === "string") return r.content;
|
|
4040
|
-
if (typeof r.message === "string") return r.message;
|
|
4112
|
+
const result = isRecord(r.result) ? r.result : void 0;
|
|
4113
|
+
if (Array.isArray(result?.payloads)) return result.payloads.slice(0, 1e3).filter(isRecord).map((payload) => payload.text).filter((text) => typeof text === "string").join("\n\n").slice(0, 1024 * 1024);
|
|
4114
|
+
if (typeof r.text === "string") return r.text.slice(0, 1024 * 1024);
|
|
4115
|
+
if (typeof r.content === "string") return r.content.slice(0, 1024 * 1024);
|
|
4116
|
+
if (typeof r.message === "string") return r.message.slice(0, 1024 * 1024);
|
|
4041
4117
|
return "";
|
|
4042
4118
|
}
|
|
4043
4119
|
/** Format a session key with the standard agent prefix. */
|
|
@@ -4045,6 +4121,9 @@ var OpenClawGatewayAdapter = class extends BaseAgentClient {
|
|
|
4045
4121
|
return `agent:${agentId}:${sessionKey}`;
|
|
4046
4122
|
}
|
|
4047
4123
|
};
|
|
4124
|
+
function isRecord(value) {
|
|
4125
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4126
|
+
}
|
|
4048
4127
|
//#endregion
|
|
4049
4128
|
exports.IPCClient = require_plugin.IPCClient;
|
|
4050
4129
|
exports.OpenClawGatewayAdapter = OpenClawGatewayAdapter;
|
package/dist/index.d.cts
CHANGED
|
@@ -42,42 +42,42 @@ declare function isIPCEvent(msg: unknown): msg is IPCEvent;
|
|
|
42
42
|
declare const PROTOCOL_VERSION = 1;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/ipc-client.d.ts
|
|
45
|
-
|
|
45
|
+
interface Logger$1 {
|
|
46
|
+
info(msg: string, ...args: unknown[]): void;
|
|
47
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
48
|
+
error(msg: string, ...args: unknown[]): void;
|
|
49
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
50
|
+
}
|
|
46
51
|
declare class IPCClient extends EventEmitter {
|
|
52
|
+
private readonly socketPath;
|
|
53
|
+
private readonly log;
|
|
47
54
|
private socket;
|
|
48
|
-
private socketPath;
|
|
49
55
|
private buffer;
|
|
56
|
+
private decoder;
|
|
50
57
|
private backoffMs;
|
|
51
58
|
private closed;
|
|
52
|
-
private
|
|
59
|
+
private isSocketConnected;
|
|
53
60
|
private reconnectTimer;
|
|
54
|
-
private pending;
|
|
55
|
-
|
|
56
|
-
constructor(socketPath: string);
|
|
61
|
+
private readonly pending;
|
|
62
|
+
constructor(socketPath: string, log?: Logger$1);
|
|
57
63
|
get connected(): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Start the IPC connection with auto-reconnect.
|
|
60
|
-
*/
|
|
61
64
|
start(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Stop the IPC connection and all timers.
|
|
64
|
-
*/
|
|
65
65
|
stop(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Send a request to the daemon and wait for a response.
|
|
68
|
-
*/
|
|
69
66
|
request(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<IPCResponse>;
|
|
70
|
-
/**
|
|
71
|
-
* Send a response to a daemon request.
|
|
72
|
-
* Used internally by the request event handler.
|
|
73
|
-
*/
|
|
74
67
|
sendResponse(response: IPCResponse): void;
|
|
75
|
-
private
|
|
68
|
+
private openSocket;
|
|
76
69
|
private processBuffer;
|
|
77
70
|
private handleResponse;
|
|
71
|
+
private handleEvent;
|
|
78
72
|
private handleIncomingRequest;
|
|
73
|
+
private serializeFrame;
|
|
74
|
+
private closeOversized;
|
|
75
|
+
private resolveAllPending;
|
|
79
76
|
private scheduleReconnect;
|
|
80
77
|
private clearReconnectTimer;
|
|
78
|
+
private resetDecoder;
|
|
79
|
+
private errorResponse;
|
|
80
|
+
private safeEmit;
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/capability-reporter.d.ts
|
|
@@ -119,10 +119,12 @@ declare abstract class BaseAgentClient {
|
|
|
119
119
|
private connected;
|
|
120
120
|
private closed;
|
|
121
121
|
private backoffMs;
|
|
122
|
-
private pending;
|
|
122
|
+
private readonly pending;
|
|
123
|
+
private reconnectTimer;
|
|
123
124
|
private readyResolve;
|
|
124
125
|
private readyReject;
|
|
125
126
|
private readyPromise;
|
|
127
|
+
private readySettled;
|
|
126
128
|
protected readonly log: Logger;
|
|
127
129
|
protected readonly opts: BaseClientOptions;
|
|
128
130
|
protected readonly instanceId: string;
|
|
@@ -130,7 +132,7 @@ declare abstract class BaseAgentClient {
|
|
|
130
132
|
get isConnected(): boolean;
|
|
131
133
|
start(): Promise<void>;
|
|
132
134
|
stop(): void;
|
|
133
|
-
request(method: string, params:
|
|
135
|
+
request(method: string, params: Record<string, unknown>, opts?: {
|
|
134
136
|
expectFinal?: boolean;
|
|
135
137
|
timeoutMs?: number;
|
|
136
138
|
}): Promise<unknown>;
|
|
@@ -155,8 +157,10 @@ declare abstract class BaseAgentClient {
|
|
|
155
157
|
protected rejectReady(err: Error): void;
|
|
156
158
|
protected doConnect(): void;
|
|
157
159
|
private initiateHandshake;
|
|
160
|
+
private isCurrentConnection;
|
|
158
161
|
private handleMessage;
|
|
159
162
|
private scheduleReconnect;
|
|
163
|
+
private resetReady;
|
|
160
164
|
private flushPending;
|
|
161
165
|
}
|
|
162
166
|
//# sourceMappingURL=base-client.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -42,42 +42,42 @@ declare function isIPCEvent(msg: unknown): msg is IPCEvent;
|
|
|
42
42
|
declare const PROTOCOL_VERSION = 1;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/ipc-client.d.ts
|
|
45
|
-
|
|
45
|
+
interface Logger$1 {
|
|
46
|
+
info(msg: string, ...args: unknown[]): void;
|
|
47
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
48
|
+
error(msg: string, ...args: unknown[]): void;
|
|
49
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
50
|
+
}
|
|
46
51
|
declare class IPCClient extends EventEmitter {
|
|
52
|
+
private readonly socketPath;
|
|
53
|
+
private readonly log;
|
|
47
54
|
private socket;
|
|
48
|
-
private socketPath;
|
|
49
55
|
private buffer;
|
|
56
|
+
private decoder;
|
|
50
57
|
private backoffMs;
|
|
51
58
|
private closed;
|
|
52
|
-
private
|
|
59
|
+
private isSocketConnected;
|
|
53
60
|
private reconnectTimer;
|
|
54
|
-
private pending;
|
|
55
|
-
|
|
56
|
-
constructor(socketPath: string);
|
|
61
|
+
private readonly pending;
|
|
62
|
+
constructor(socketPath: string, log?: Logger$1);
|
|
57
63
|
get connected(): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Start the IPC connection with auto-reconnect.
|
|
60
|
-
*/
|
|
61
64
|
start(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Stop the IPC connection and all timers.
|
|
64
|
-
*/
|
|
65
65
|
stop(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Send a request to the daemon and wait for a response.
|
|
68
|
-
*/
|
|
69
66
|
request(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<IPCResponse>;
|
|
70
|
-
/**
|
|
71
|
-
* Send a response to a daemon request.
|
|
72
|
-
* Used internally by the request event handler.
|
|
73
|
-
*/
|
|
74
67
|
sendResponse(response: IPCResponse): void;
|
|
75
|
-
private
|
|
68
|
+
private openSocket;
|
|
76
69
|
private processBuffer;
|
|
77
70
|
private handleResponse;
|
|
71
|
+
private handleEvent;
|
|
78
72
|
private handleIncomingRequest;
|
|
73
|
+
private serializeFrame;
|
|
74
|
+
private closeOversized;
|
|
75
|
+
private resolveAllPending;
|
|
79
76
|
private scheduleReconnect;
|
|
80
77
|
private clearReconnectTimer;
|
|
78
|
+
private resetDecoder;
|
|
79
|
+
private errorResponse;
|
|
80
|
+
private safeEmit;
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/capability-reporter.d.ts
|
|
@@ -119,10 +119,12 @@ declare abstract class BaseAgentClient {
|
|
|
119
119
|
private connected;
|
|
120
120
|
private closed;
|
|
121
121
|
private backoffMs;
|
|
122
|
-
private pending;
|
|
122
|
+
private readonly pending;
|
|
123
|
+
private reconnectTimer;
|
|
123
124
|
private readyResolve;
|
|
124
125
|
private readyReject;
|
|
125
126
|
private readyPromise;
|
|
127
|
+
private readySettled;
|
|
126
128
|
protected readonly log: Logger;
|
|
127
129
|
protected readonly opts: BaseClientOptions;
|
|
128
130
|
protected readonly instanceId: string;
|
|
@@ -130,7 +132,7 @@ declare abstract class BaseAgentClient {
|
|
|
130
132
|
get isConnected(): boolean;
|
|
131
133
|
start(): Promise<void>;
|
|
132
134
|
stop(): void;
|
|
133
|
-
request(method: string, params:
|
|
135
|
+
request(method: string, params: Record<string, unknown>, opts?: {
|
|
134
136
|
expectFinal?: boolean;
|
|
135
137
|
timeoutMs?: number;
|
|
136
138
|
}): Promise<unknown>;
|
|
@@ -155,8 +157,10 @@ declare abstract class BaseAgentClient {
|
|
|
155
157
|
protected rejectReady(err: Error): void;
|
|
156
158
|
protected doConnect(): void;
|
|
157
159
|
private initiateHandshake;
|
|
160
|
+
private isCurrentConnection;
|
|
158
161
|
private handleMessage;
|
|
159
162
|
private scheduleReconnect;
|
|
163
|
+
private resetReady;
|
|
160
164
|
private flushPending;
|
|
161
165
|
}
|
|
162
166
|
//# sourceMappingURL=base-client.d.ts.map
|