@pmate/cli 0.24.18 → 0.24.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/index.js +27 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8769,10 +8769,14 @@ var init_AgentClient = __esm({
|
|
|
8769
8769
|
}
|
|
8770
8770
|
if (event.type === "connected") {
|
|
8771
8771
|
this.emit("connected" /* Connected */, event.data);
|
|
8772
|
+
if (!event.data) {
|
|
8773
|
+
this.rejectAuth(new Error("Agent websocket disconnected before auth ack"));
|
|
8774
|
+
}
|
|
8772
8775
|
return;
|
|
8773
8776
|
}
|
|
8774
8777
|
if (event.type === "error") {
|
|
8775
8778
|
this.emit("error" /* Error */, event.data);
|
|
8779
|
+
this.rejectAuth(new Error("Agent websocket error before auth ack"));
|
|
8776
8780
|
}
|
|
8777
8781
|
}
|
|
8778
8782
|
handleIncomingMessage(message) {
|
|
@@ -8782,7 +8786,11 @@ var init_AgentClient = __esm({
|
|
|
8782
8786
|
if (message.opcode === 3 /* ACK */) {
|
|
8783
8787
|
const ack = message.body;
|
|
8784
8788
|
const success = ack?.status === "ok";
|
|
8785
|
-
|
|
8789
|
+
if (!success) {
|
|
8790
|
+
this.rejectAuth(new Error(ack?.message ?? ack?.code ?? "Auth failed"));
|
|
8791
|
+
return;
|
|
8792
|
+
}
|
|
8793
|
+
this.resolveAuth();
|
|
8786
8794
|
return;
|
|
8787
8795
|
}
|
|
8788
8796
|
if (message.opcode === 2 /* AGENT */) {
|
|
@@ -8853,10 +8861,7 @@ var init_AgentClient = __esm({
|
|
|
8853
8861
|
const msg = Msg.create(this.from, "@hub", 4 /* AUTH */, body);
|
|
8854
8862
|
const waiter = this.waitForAuthAck(timeoutMs);
|
|
8855
8863
|
await this.ws.sendMsg(msg);
|
|
8856
|
-
|
|
8857
|
-
if (!success) {
|
|
8858
|
-
throw new Error("Auth failed");
|
|
8859
|
-
}
|
|
8864
|
+
await waiter;
|
|
8860
8865
|
}
|
|
8861
8866
|
waitForAuthAck(timeoutMs) {
|
|
8862
8867
|
if (this.authPromise) {
|
|
@@ -8872,13 +8877,21 @@ var init_AgentClient = __esm({
|
|
|
8872
8877
|
});
|
|
8873
8878
|
return this.authPromise;
|
|
8874
8879
|
}
|
|
8875
|
-
resolveAuth(
|
|
8880
|
+
resolveAuth() {
|
|
8876
8881
|
if (!this.authResolve) {
|
|
8877
8882
|
return;
|
|
8878
8883
|
}
|
|
8879
8884
|
const resolve = this.authResolve;
|
|
8880
8885
|
this.clearAuthWaiter();
|
|
8881
|
-
resolve(
|
|
8886
|
+
resolve();
|
|
8887
|
+
}
|
|
8888
|
+
rejectAuth(error) {
|
|
8889
|
+
if (!this.authReject) {
|
|
8890
|
+
return;
|
|
8891
|
+
}
|
|
8892
|
+
const reject = this.authReject;
|
|
8893
|
+
this.clearAuthWaiter();
|
|
8894
|
+
reject(error);
|
|
8882
8895
|
}
|
|
8883
8896
|
clearAuthWaiter() {
|
|
8884
8897
|
if (this.authTimer) {
|
|
@@ -9083,7 +9096,7 @@ function resolveMimeType(filePath) {
|
|
|
9083
9096
|
return "application/octet-stream";
|
|
9084
9097
|
}
|
|
9085
9098
|
}
|
|
9086
|
-
var import_node_fs7, import_node_path11, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE,
|
|
9099
|
+
var import_node_fs7, import_node_path11, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE, DEFAULT_AGENT_PROMPT_TIMEOUT_MS, AgentLlmClient;
|
|
9087
9100
|
var init_AgentLlmClient = __esm({
|
|
9088
9101
|
"src/llm/AgentLlmClient.ts"() {
|
|
9089
9102
|
"use strict";
|
|
@@ -9095,7 +9108,6 @@ var init_AgentLlmClient = __esm({
|
|
|
9095
9108
|
DEFAULT_AGENT_API_BASE_URL = "https://agent-api.pmate.chat";
|
|
9096
9109
|
DEFAULT_AGENT_HUB_BASE_URL = "https://hub.pmate.chat";
|
|
9097
9110
|
DEFAULT_NAMESPACE = "pmate-cli";
|
|
9098
|
-
DEFAULT_FROM = "pmate-cli";
|
|
9099
9111
|
DEFAULT_AGENT_PROMPT_TIMEOUT_MS = 12e4;
|
|
9100
9112
|
AgentLlmClient = class {
|
|
9101
9113
|
constructor(options) {
|
|
@@ -9107,7 +9119,7 @@ var init_AgentLlmClient = __esm({
|
|
|
9107
9119
|
this.agentApiBaseUrl = resolveAgentApiBaseUrl(options?.agentApiBaseUrl);
|
|
9108
9120
|
this.authApiBaseUrl = resolveAuthApiBaseUrl(options?.authApiBaseUrl);
|
|
9109
9121
|
this.hubBaseUrl = resolveHubBaseUrl(options?.hubBaseUrl);
|
|
9110
|
-
this.from = options?.from
|
|
9122
|
+
this.from = options?.from?.trim() || void 0;
|
|
9111
9123
|
this.agentService = new AgentService({
|
|
9112
9124
|
agentApiBaseUrl: this.agentApiBaseUrl,
|
|
9113
9125
|
token: this.token
|
|
@@ -9125,7 +9137,7 @@ var init_AgentLlmClient = __esm({
|
|
|
9125
9137
|
});
|
|
9126
9138
|
try {
|
|
9127
9139
|
const profileId = await this.resolveProfileId();
|
|
9128
|
-
await client.login(options?.from
|
|
9140
|
+
await client.login(this.resolveFrom(options?.from, profileId), {
|
|
9129
9141
|
token: this.token,
|
|
9130
9142
|
profileId
|
|
9131
9143
|
});
|
|
@@ -9148,7 +9160,7 @@ var init_AgentLlmClient = __esm({
|
|
|
9148
9160
|
});
|
|
9149
9161
|
try {
|
|
9150
9162
|
const profileId = await this.resolveProfileId();
|
|
9151
|
-
await client.login(options?.from
|
|
9163
|
+
await client.login(this.resolveFrom(options?.from, profileId), {
|
|
9152
9164
|
token: this.token,
|
|
9153
9165
|
profileId
|
|
9154
9166
|
});
|
|
@@ -9179,6 +9191,9 @@ var init_AgentLlmClient = __esm({
|
|
|
9179
9191
|
authApiBaseUrl: this.authApiBaseUrl
|
|
9180
9192
|
});
|
|
9181
9193
|
}
|
|
9194
|
+
resolveFrom(value, profileId) {
|
|
9195
|
+
return value?.trim() || this.from || profileId;
|
|
9196
|
+
}
|
|
9182
9197
|
};
|
|
9183
9198
|
}
|
|
9184
9199
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/cli",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.20",
|
|
4
4
|
"description": "CLI utilities for the pMate project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"yaml": "^2.8.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@pmate/agent-sdk": "^1.1.
|
|
59
|
+
"@pmate/agent-sdk": "^1.1.12",
|
|
60
60
|
"@pmate/meta": "^1.1.13",
|
|
61
61
|
"@pmate/utils": "^1.1.3",
|
|
62
62
|
"@types/node": "^25.0.3",
|