@pmate/cli 0.24.20 → 0.24.22
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.d.ts +1 -0
- package/dist/index.js +575 -93
- package/package.json +11 -18
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -111,13 +111,13 @@ function saveLoginSession(session, requestedApp = DEFAULT_APP_ID) {
|
|
|
111
111
|
const token = session.token?.trim();
|
|
112
112
|
const issuedAt = session.session.issuedAt?.trim();
|
|
113
113
|
const expiresAt = session.session.expiresAt?.trim();
|
|
114
|
-
if (!accountId || !token || !issuedAt || !expiresAt) {
|
|
114
|
+
if (!accountId || !profileId || !token || !issuedAt || !expiresAt) {
|
|
115
115
|
throw new Error("Invalid login session payload.");
|
|
116
116
|
}
|
|
117
117
|
const nextSession = {
|
|
118
118
|
token,
|
|
119
119
|
accountId,
|
|
120
|
-
|
|
120
|
+
profileId,
|
|
121
121
|
issuedAt,
|
|
122
122
|
expiresAt,
|
|
123
123
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -181,6 +181,11 @@ function loadSessionStoreWithPath() {
|
|
|
181
181
|
return { sessionPath, store };
|
|
182
182
|
}
|
|
183
183
|
function normalizeStore(value) {
|
|
184
|
+
if (isLegacySessionStoreVersion(value)) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`Unsupported session store version in ${buildSessionStorePath()}. Run "pmate login" again.`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
184
189
|
if (!isSessionStore(value)) {
|
|
185
190
|
throw new Error(
|
|
186
191
|
`Invalid session store format in ${buildSessionStorePath()}. Run "pmate login" again.`
|
|
@@ -188,6 +193,9 @@ function normalizeStore(value) {
|
|
|
188
193
|
}
|
|
189
194
|
return value;
|
|
190
195
|
}
|
|
196
|
+
function isLegacySessionStoreVersion(value) {
|
|
197
|
+
return !!value && typeof value === "object" && "version" in value && value.version !== SESSION_STORE_VERSION;
|
|
198
|
+
}
|
|
191
199
|
function isSessionStore(value) {
|
|
192
200
|
if (!value || typeof value !== "object") {
|
|
193
201
|
return false;
|
|
@@ -233,7 +241,7 @@ function isStoredSession(value) {
|
|
|
233
241
|
return false;
|
|
234
242
|
}
|
|
235
243
|
const session = value;
|
|
236
|
-
return typeof session.token === "string" && !!session.token.trim() && typeof session.accountId === "string" && !!session.accountId.trim() &&
|
|
244
|
+
return typeof session.token === "string" && !!session.token.trim() && typeof session.accountId === "string" && !!session.accountId.trim() && typeof session.profileId === "string" && !!session.profileId.trim() && typeof session.issuedAt === "string" && !!session.issuedAt.trim() && typeof session.expiresAt === "string" && !!session.expiresAt.trim() && typeof session.updatedAt === "string" && !!session.updatedAt.trim();
|
|
237
245
|
}
|
|
238
246
|
function resolveReadApp(store, options) {
|
|
239
247
|
const requestedApp = options?.app?.trim();
|
|
@@ -281,47 +289,7 @@ var init_sessionStore = __esm({
|
|
|
281
289
|
import_node_path3 = __toESM(require("path"));
|
|
282
290
|
init_namespacedRef();
|
|
283
291
|
DEFAULT_APP_ID = "pmate:factory";
|
|
284
|
-
SESSION_STORE_VERSION =
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
// src/profileClient.ts
|
|
289
|
-
async function fetchDefaultProfileId(options) {
|
|
290
|
-
const token = options.token.trim();
|
|
291
|
-
const app = options.app.trim();
|
|
292
|
-
const accountId = options.accountId.trim();
|
|
293
|
-
if (!token || !app || !accountId) {
|
|
294
|
-
throw new Error("Missing token, app, or accountId for profile lookup.");
|
|
295
|
-
}
|
|
296
|
-
const url = new URL(`${resolveAuthApiBaseUrl(options.authApiBaseUrl)}/profiles`);
|
|
297
|
-
url.searchParams.set("app", app);
|
|
298
|
-
url.searchParams.set("account", accountId);
|
|
299
|
-
const response = await fetch(url, {
|
|
300
|
-
headers: {
|
|
301
|
-
Authorization: `Bearer ${token}`
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
if (!response.ok) {
|
|
305
|
-
const detail = await response.text();
|
|
306
|
-
throw new Error(
|
|
307
|
-
`Failed to resolve default profile (${response.status}): ${detail || response.statusText}`
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
const envelope = await response.json();
|
|
311
|
-
const profileId = envelope.data?.[0]?.id?.trim();
|
|
312
|
-
if (!profileId) {
|
|
313
|
-
throw new Error(`No profile found for app ${app} and account ${accountId}.`);
|
|
314
|
-
}
|
|
315
|
-
return profileId;
|
|
316
|
-
}
|
|
317
|
-
function resolveAuthApiBaseUrl(value) {
|
|
318
|
-
return (value || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || DEFAULT_AUTH_API_BASE_URL).replace(/\/+$/, "");
|
|
319
|
-
}
|
|
320
|
-
var DEFAULT_AUTH_API_BASE_URL;
|
|
321
|
-
var init_profileClient = __esm({
|
|
322
|
-
"src/profileClient.ts"() {
|
|
323
|
-
"use strict";
|
|
324
|
-
DEFAULT_AUTH_API_BASE_URL = "https://auth-api-v2.pmate.chat";
|
|
292
|
+
SESSION_STORE_VERSION = 4;
|
|
325
293
|
}
|
|
326
294
|
});
|
|
327
295
|
|
|
@@ -417,12 +385,9 @@ var init_logs_types = __esm({
|
|
|
417
385
|
});
|
|
418
386
|
|
|
419
387
|
// node_modules/@pmate/meta/src/types/message.types.ts
|
|
420
|
-
var PING, PONG;
|
|
421
388
|
var init_message_types = __esm({
|
|
422
389
|
"node_modules/@pmate/meta/src/types/message.types.ts"() {
|
|
423
390
|
"use strict";
|
|
424
|
-
PING = 1;
|
|
425
|
-
PONG = 2;
|
|
426
391
|
}
|
|
427
392
|
});
|
|
428
393
|
|
|
@@ -5974,12 +5939,426 @@ var init_AsyncStream = __esm({
|
|
|
5974
5939
|
}
|
|
5975
5940
|
});
|
|
5976
5941
|
|
|
5942
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/account.types.ts
|
|
5943
|
+
var init_account_types2 = __esm({
|
|
5944
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/account.types.ts"() {
|
|
5945
|
+
"use strict";
|
|
5946
|
+
}
|
|
5947
|
+
});
|
|
5948
|
+
|
|
5949
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/achievements.types.ts
|
|
5950
|
+
var init_achievements_types2 = __esm({
|
|
5951
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/achievements.types.ts"() {
|
|
5952
|
+
"use strict";
|
|
5953
|
+
}
|
|
5954
|
+
});
|
|
5955
|
+
|
|
5956
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/aigen.types.ts
|
|
5957
|
+
var init_aigen_types2 = __esm({
|
|
5958
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/aigen.types.ts"() {
|
|
5959
|
+
"use strict";
|
|
5960
|
+
}
|
|
5961
|
+
});
|
|
5962
|
+
|
|
5963
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent.types.ts
|
|
5964
|
+
var init_agent_types2 = __esm({
|
|
5965
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent.types.ts"() {
|
|
5966
|
+
"use strict";
|
|
5967
|
+
}
|
|
5968
|
+
});
|
|
5969
|
+
|
|
5970
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent-registry.types.ts
|
|
5971
|
+
var init_agent_registry_types2 = __esm({
|
|
5972
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/agent-registry.types.ts"() {
|
|
5973
|
+
"use strict";
|
|
5974
|
+
}
|
|
5975
|
+
});
|
|
5976
|
+
|
|
5977
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/runner-registry.types.ts
|
|
5978
|
+
var init_runner_registry_types2 = __esm({
|
|
5979
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/runner-registry.types.ts"() {
|
|
5980
|
+
"use strict";
|
|
5981
|
+
}
|
|
5982
|
+
});
|
|
5983
|
+
|
|
5984
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/blockchain.types.ts
|
|
5985
|
+
var init_blockchain_types2 = __esm({
|
|
5986
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/blockchain.types.ts"() {
|
|
5987
|
+
"use strict";
|
|
5988
|
+
}
|
|
5989
|
+
});
|
|
5990
|
+
|
|
5991
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/breakdown.types.ts
|
|
5992
|
+
var init_breakdown_types2 = __esm({
|
|
5993
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/breakdown.types.ts"() {
|
|
5994
|
+
"use strict";
|
|
5995
|
+
}
|
|
5996
|
+
});
|
|
5997
|
+
|
|
5998
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/chat.types.ts
|
|
5999
|
+
var init_chat_types2 = __esm({
|
|
6000
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/chat.types.ts"() {
|
|
6001
|
+
"use strict";
|
|
6002
|
+
}
|
|
6003
|
+
});
|
|
6004
|
+
|
|
6005
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/companion.types.ts
|
|
6006
|
+
var init_companion_types2 = __esm({
|
|
6007
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/companion.types.ts"() {
|
|
6008
|
+
"use strict";
|
|
6009
|
+
}
|
|
6010
|
+
});
|
|
6011
|
+
|
|
6012
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/enums.ts
|
|
6013
|
+
var init_enums2 = __esm({
|
|
6014
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/enums.ts"() {
|
|
6015
|
+
"use strict";
|
|
6016
|
+
}
|
|
6017
|
+
});
|
|
6018
|
+
|
|
6019
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/lang.types.ts
|
|
6020
|
+
var init_lang_types2 = __esm({
|
|
6021
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/lang.types.ts"() {
|
|
6022
|
+
"use strict";
|
|
6023
|
+
}
|
|
6024
|
+
});
|
|
6025
|
+
|
|
6026
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/logs.types.ts
|
|
6027
|
+
var init_logs_types2 = __esm({
|
|
6028
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/logs.types.ts"() {
|
|
6029
|
+
"use strict";
|
|
6030
|
+
}
|
|
6031
|
+
});
|
|
6032
|
+
|
|
6033
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/message.types.ts
|
|
6034
|
+
var PING, PONG;
|
|
6035
|
+
var init_message_types2 = __esm({
|
|
6036
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/message.types.ts"() {
|
|
6037
|
+
"use strict";
|
|
6038
|
+
PING = 1;
|
|
6039
|
+
PONG = 2;
|
|
6040
|
+
}
|
|
6041
|
+
});
|
|
6042
|
+
|
|
6043
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/newLog.types.ts
|
|
6044
|
+
var init_newLog_types2 = __esm({
|
|
6045
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/newLog.types.ts"() {
|
|
6046
|
+
"use strict";
|
|
6047
|
+
}
|
|
6048
|
+
});
|
|
6049
|
+
|
|
6050
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/novel.types.ts
|
|
6051
|
+
var init_novel_types2 = __esm({
|
|
6052
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/novel.types.ts"() {
|
|
6053
|
+
"use strict";
|
|
6054
|
+
}
|
|
6055
|
+
});
|
|
6056
|
+
|
|
6057
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/offline.types.ts
|
|
6058
|
+
var init_offline_types2 = __esm({
|
|
6059
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/offline.types.ts"() {
|
|
6060
|
+
"use strict";
|
|
6061
|
+
}
|
|
6062
|
+
});
|
|
6063
|
+
|
|
6064
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/prompt.types.ts
|
|
6065
|
+
var init_prompt_types2 = __esm({
|
|
6066
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/prompt.types.ts"() {
|
|
6067
|
+
"use strict";
|
|
6068
|
+
}
|
|
6069
|
+
});
|
|
6070
|
+
|
|
6071
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/reading.types.ts
|
|
6072
|
+
var init_reading_types2 = __esm({
|
|
6073
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/reading.types.ts"() {
|
|
6074
|
+
"use strict";
|
|
6075
|
+
}
|
|
6076
|
+
});
|
|
6077
|
+
|
|
6078
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/settings.types.ts
|
|
6079
|
+
var init_settings_types2 = __esm({
|
|
6080
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/settings.types.ts"() {
|
|
6081
|
+
"use strict";
|
|
6082
|
+
}
|
|
6083
|
+
});
|
|
6084
|
+
|
|
6085
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/subscription.types.ts
|
|
6086
|
+
var init_subscription_types2 = __esm({
|
|
6087
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/subscription.types.ts"() {
|
|
6088
|
+
"use strict";
|
|
6089
|
+
}
|
|
6090
|
+
});
|
|
6091
|
+
|
|
6092
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/types.ts
|
|
6093
|
+
var buildVoiceKey2, createVoice2;
|
|
6094
|
+
var init_types3 = __esm({
|
|
6095
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/types.ts"() {
|
|
6096
|
+
"use strict";
|
|
6097
|
+
buildVoiceKey2 = (provider, name) => {
|
|
6098
|
+
return `${provider}:${name}`;
|
|
6099
|
+
};
|
|
6100
|
+
createVoice2 = ({
|
|
6101
|
+
name,
|
|
6102
|
+
provider,
|
|
6103
|
+
gender,
|
|
6104
|
+
instructions
|
|
6105
|
+
}) => {
|
|
6106
|
+
return {
|
|
6107
|
+
name,
|
|
6108
|
+
provider,
|
|
6109
|
+
gender,
|
|
6110
|
+
instructions,
|
|
6111
|
+
key: buildVoiceKey2(provider, name)
|
|
6112
|
+
};
|
|
6113
|
+
};
|
|
6114
|
+
}
|
|
6115
|
+
});
|
|
6116
|
+
|
|
6117
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/wordv5.def.ts
|
|
6118
|
+
var init_wordv5_def2 = __esm({
|
|
6119
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/wordv5.def.ts"() {
|
|
6120
|
+
"use strict";
|
|
6121
|
+
}
|
|
6122
|
+
});
|
|
6123
|
+
|
|
6124
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/auth.types.ts
|
|
6125
|
+
var init_auth_types2 = __esm({
|
|
6126
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/auth.types.ts"() {
|
|
6127
|
+
"use strict";
|
|
6128
|
+
}
|
|
6129
|
+
});
|
|
6130
|
+
|
|
6131
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/apps.types.ts
|
|
6132
|
+
var init_apps_types2 = __esm({
|
|
6133
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/apps.types.ts"() {
|
|
6134
|
+
"use strict";
|
|
6135
|
+
}
|
|
6136
|
+
});
|
|
6137
|
+
|
|
6138
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/response.types.ts
|
|
6139
|
+
var init_response_types2 = __esm({
|
|
6140
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/response.types.ts"() {
|
|
6141
|
+
"use strict";
|
|
6142
|
+
}
|
|
6143
|
+
});
|
|
6144
|
+
|
|
6145
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/role.types.ts
|
|
6146
|
+
var init_role_types2 = __esm({
|
|
6147
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/role.types.ts"() {
|
|
6148
|
+
"use strict";
|
|
6149
|
+
}
|
|
6150
|
+
});
|
|
6151
|
+
|
|
6152
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/index.ts
|
|
6153
|
+
var init_types4 = __esm({
|
|
6154
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/types/index.ts"() {
|
|
6155
|
+
"use strict";
|
|
6156
|
+
init_account_types2();
|
|
6157
|
+
init_achievements_types2();
|
|
6158
|
+
init_aigen_types2();
|
|
6159
|
+
init_agent_types2();
|
|
6160
|
+
init_agent_registry_types2();
|
|
6161
|
+
init_runner_registry_types2();
|
|
6162
|
+
init_blockchain_types2();
|
|
6163
|
+
init_breakdown_types2();
|
|
6164
|
+
init_chat_types2();
|
|
6165
|
+
init_companion_types2();
|
|
6166
|
+
init_enums2();
|
|
6167
|
+
init_lang_types2();
|
|
6168
|
+
init_logs_types2();
|
|
6169
|
+
init_message_types2();
|
|
6170
|
+
init_newLog_types2();
|
|
6171
|
+
init_novel_types2();
|
|
6172
|
+
init_offline_types2();
|
|
6173
|
+
init_prompt_types2();
|
|
6174
|
+
init_reading_types2();
|
|
6175
|
+
init_settings_types2();
|
|
6176
|
+
init_subscription_types2();
|
|
6177
|
+
init_types3();
|
|
6178
|
+
init_wordv5_def2();
|
|
6179
|
+
init_auth_types2();
|
|
6180
|
+
init_apps_types2();
|
|
6181
|
+
init_response_types2();
|
|
6182
|
+
init_role_types2();
|
|
6183
|
+
}
|
|
6184
|
+
});
|
|
6185
|
+
|
|
6186
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/BizErrorCode.ts
|
|
6187
|
+
var init_BizErrorCode2 = __esm({
|
|
6188
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/BizErrorCode.ts"() {
|
|
6189
|
+
"use strict";
|
|
6190
|
+
}
|
|
6191
|
+
});
|
|
6192
|
+
|
|
6193
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/consts.ts
|
|
6194
|
+
var init_consts2 = __esm({
|
|
6195
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/consts.ts"() {
|
|
6196
|
+
"use strict";
|
|
6197
|
+
}
|
|
6198
|
+
});
|
|
6199
|
+
|
|
6200
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/TopicNames.ts
|
|
6201
|
+
var TopicNames2, topicKindMatchers2;
|
|
6202
|
+
var init_TopicNames2 = __esm({
|
|
6203
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/TopicNames.ts"() {
|
|
6204
|
+
"use strict";
|
|
6205
|
+
init_types4();
|
|
6206
|
+
TopicNames2 = class _TopicNames {
|
|
6207
|
+
static rooms() {
|
|
6208
|
+
return "@pmate/rooms";
|
|
6209
|
+
}
|
|
6210
|
+
static userThreads(user) {
|
|
6211
|
+
return `@pmate/user_threads:${user}`;
|
|
6212
|
+
}
|
|
6213
|
+
static userLogs(user) {
|
|
6214
|
+
return `@pmate/user_logs:${user}`;
|
|
6215
|
+
}
|
|
6216
|
+
static legacyUserLogs(user) {
|
|
6217
|
+
return _TopicNames.userLogs(user);
|
|
6218
|
+
}
|
|
6219
|
+
static userContacts(profileId) {
|
|
6220
|
+
return `@pmate/user_contacts:${profileId}`;
|
|
6221
|
+
}
|
|
6222
|
+
static usersMessage(userId) {
|
|
6223
|
+
return `@pmate/user_messages:${userId}`;
|
|
6224
|
+
}
|
|
6225
|
+
static userMapping() {
|
|
6226
|
+
return "@pmate/username_mapping";
|
|
6227
|
+
}
|
|
6228
|
+
static userMobileMapping() {
|
|
6229
|
+
return "@pmate/mobile_account";
|
|
6230
|
+
}
|
|
6231
|
+
static mapping() {
|
|
6232
|
+
return "@pmate/mapping";
|
|
6233
|
+
}
|
|
6234
|
+
static profiles() {
|
|
6235
|
+
return "@pmate/profiles";
|
|
6236
|
+
}
|
|
6237
|
+
static groups() {
|
|
6238
|
+
return "@pmate/groups";
|
|
6239
|
+
}
|
|
6240
|
+
static relationships() {
|
|
6241
|
+
return "@pmate/relationships";
|
|
6242
|
+
}
|
|
6243
|
+
};
|
|
6244
|
+
topicKindMatchers2 = [
|
|
6245
|
+
{
|
|
6246
|
+
kind: 1e3 /* UserLogs */,
|
|
6247
|
+
match: (topic) => topic.startsWith("@pmate/user_logs:")
|
|
6248
|
+
},
|
|
6249
|
+
{
|
|
6250
|
+
kind: 2e3 /* UserMessages */,
|
|
6251
|
+
match: (topic) => topic.startsWith("@pmate/user_messages:")
|
|
6252
|
+
},
|
|
6253
|
+
{
|
|
6254
|
+
kind: 3e3 /* Relationships */,
|
|
6255
|
+
match: (topic) => topic === TopicNames2.relationships()
|
|
6256
|
+
},
|
|
6257
|
+
{
|
|
6258
|
+
kind: 4e3 /* Rooms */,
|
|
6259
|
+
match: (topic) => topic === TopicNames2.rooms()
|
|
6260
|
+
},
|
|
6261
|
+
{
|
|
6262
|
+
kind: 5e3 /* UserContacts */,
|
|
6263
|
+
match: (topic) => topic.startsWith("@pmate/user_contacts:")
|
|
6264
|
+
},
|
|
6265
|
+
{
|
|
6266
|
+
kind: 8002 /* Entity_GROUP */,
|
|
6267
|
+
match: (topic) => topic === TopicNames2.groups()
|
|
6268
|
+
},
|
|
6269
|
+
{
|
|
6270
|
+
kind: 6e3 /* UserMapping */,
|
|
6271
|
+
match: (topic) => topic === TopicNames2.userMapping()
|
|
6272
|
+
},
|
|
6273
|
+
{
|
|
6274
|
+
kind: 7e3 /* UserMobileMapping */,
|
|
6275
|
+
match: (topic) => topic === TopicNames2.userMobileMapping()
|
|
6276
|
+
},
|
|
6277
|
+
{
|
|
6278
|
+
kind: 6003 /* Mapping */,
|
|
6279
|
+
match: (topic) => topic === TopicNames2.mapping()
|
|
6280
|
+
},
|
|
6281
|
+
{
|
|
6282
|
+
kind: 9e3 /* UserThreads */,
|
|
6283
|
+
match: (topic) => topic.startsWith("@pmate/user_threads:")
|
|
6284
|
+
}
|
|
6285
|
+
];
|
|
6286
|
+
}
|
|
6287
|
+
});
|
|
6288
|
+
|
|
6289
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/OSSKeys.ts
|
|
6290
|
+
var init_OSSKeys2 = __esm({
|
|
6291
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/OSSKeys.ts"() {
|
|
6292
|
+
"use strict";
|
|
6293
|
+
init_consts2();
|
|
6294
|
+
}
|
|
6295
|
+
});
|
|
6296
|
+
|
|
6297
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/CompanionProfiles.ts
|
|
6298
|
+
var openAICoral2, openAIAsh2, openAIBallad2, openAINova2, openAIVerse2;
|
|
6299
|
+
var init_CompanionProfiles2 = __esm({
|
|
6300
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/CompanionProfiles.ts"() {
|
|
6301
|
+
"use strict";
|
|
6302
|
+
init_types4();
|
|
6303
|
+
openAICoral2 = createVoice2({
|
|
6304
|
+
name: "coral",
|
|
6305
|
+
provider: "openai",
|
|
6306
|
+
gender: "F",
|
|
6307
|
+
instructions: "sweet, cute,naive voice"
|
|
6308
|
+
});
|
|
6309
|
+
openAIAsh2 = createVoice2({
|
|
6310
|
+
name: "ash",
|
|
6311
|
+
provider: "openai",
|
|
6312
|
+
gender: "M"
|
|
6313
|
+
});
|
|
6314
|
+
openAIBallad2 = createVoice2({
|
|
6315
|
+
name: "ballad",
|
|
6316
|
+
provider: "openai",
|
|
6317
|
+
gender: "M",
|
|
6318
|
+
instructions: "bright, young man voice"
|
|
6319
|
+
});
|
|
6320
|
+
openAINova2 = createVoice2({
|
|
6321
|
+
name: "nova",
|
|
6322
|
+
provider: "openai",
|
|
6323
|
+
gender: "F",
|
|
6324
|
+
instructions: "mature, smooth, elegant, warm voice"
|
|
6325
|
+
});
|
|
6326
|
+
openAIVerse2 = createVoice2({
|
|
6327
|
+
name: "verse",
|
|
6328
|
+
provider: "openai",
|
|
6329
|
+
gender: "M",
|
|
6330
|
+
instructions: "elderly,mysterious wizzard voice"
|
|
6331
|
+
});
|
|
6332
|
+
}
|
|
6333
|
+
});
|
|
6334
|
+
|
|
6335
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/index.ts
|
|
6336
|
+
var init_config2 = __esm({
|
|
6337
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/config/index.ts"() {
|
|
6338
|
+
"use strict";
|
|
6339
|
+
init_BizErrorCode2();
|
|
6340
|
+
init_consts2();
|
|
6341
|
+
init_TopicNames2();
|
|
6342
|
+
init_OSSKeys2();
|
|
6343
|
+
init_CompanionProfiles2();
|
|
6344
|
+
}
|
|
6345
|
+
});
|
|
6346
|
+
|
|
6347
|
+
// node_modules/@pmate/utils/node_modules/@pmate/meta/src/index.ts
|
|
6348
|
+
var init_src3 = __esm({
|
|
6349
|
+
"node_modules/@pmate/utils/node_modules/@pmate/meta/src/index.ts"() {
|
|
6350
|
+
"use strict";
|
|
6351
|
+
init_types4();
|
|
6352
|
+
init_config2();
|
|
6353
|
+
}
|
|
6354
|
+
});
|
|
6355
|
+
|
|
5977
6356
|
// node_modules/@pmate/utils/src/uniqHash.ts
|
|
5978
6357
|
var import_js_sha32, sortKeys, uniqHash;
|
|
5979
6358
|
var init_uniqHash = __esm({
|
|
5980
6359
|
"node_modules/@pmate/utils/src/uniqHash.ts"() {
|
|
5981
6360
|
"use strict";
|
|
5982
|
-
|
|
6361
|
+
init_src3();
|
|
5983
6362
|
import_js_sha32 = __toESM(require_sha3(), 1);
|
|
5984
6363
|
sortKeys = (obj) => {
|
|
5985
6364
|
if (Array.isArray(obj)) {
|
|
@@ -6011,7 +6390,7 @@ var init_uniqHash = __esm({
|
|
|
6011
6390
|
var init_createMsg = __esm({
|
|
6012
6391
|
"node_modules/@pmate/utils/src/createMsg.ts"() {
|
|
6013
6392
|
"use strict";
|
|
6014
|
-
|
|
6393
|
+
init_src3();
|
|
6015
6394
|
init_uniqHash();
|
|
6016
6395
|
}
|
|
6017
6396
|
});
|
|
@@ -7709,7 +8088,7 @@ var init_Msg = __esm({
|
|
|
7709
8088
|
"node_modules/@pmate/utils/src/Msg.ts"() {
|
|
7710
8089
|
"use strict";
|
|
7711
8090
|
init_dist();
|
|
7712
|
-
|
|
8091
|
+
init_src3();
|
|
7713
8092
|
init_compress();
|
|
7714
8093
|
init_uniqHash();
|
|
7715
8094
|
encoder = new TextEncoder();
|
|
@@ -7889,7 +8268,7 @@ var init_sha1Hash = __esm({
|
|
|
7889
8268
|
var init_TaskWaiter = __esm({
|
|
7890
8269
|
"node_modules/@pmate/utils/src/TaskWaiter.ts"() {
|
|
7891
8270
|
"use strict";
|
|
7892
|
-
|
|
8271
|
+
init_src4();
|
|
7893
8272
|
}
|
|
7894
8273
|
});
|
|
7895
8274
|
|
|
@@ -7935,7 +8314,7 @@ var logger, WebsocketHeartbeat;
|
|
|
7935
8314
|
var init_WebsocketHeartbeat = __esm({
|
|
7936
8315
|
"node_modules/@pmate/utils/src/websocket/WebsocketHeartbeat.ts"() {
|
|
7937
8316
|
"use strict";
|
|
7938
|
-
|
|
8317
|
+
init_src3();
|
|
7939
8318
|
init_Logger();
|
|
7940
8319
|
logger = Logger.getDebugger("heartbeat");
|
|
7941
8320
|
WebsocketHeartbeat = class {
|
|
@@ -7968,7 +8347,6 @@ var init_WebsocketHeartbeat = __esm({
|
|
|
7968
8347
|
}
|
|
7969
8348
|
handlePong() {
|
|
7970
8349
|
this.lastPong = Date.now();
|
|
7971
|
-
logger.log("Pong received");
|
|
7972
8350
|
return true;
|
|
7973
8351
|
}
|
|
7974
8352
|
};
|
|
@@ -7980,7 +8358,7 @@ var logger2;
|
|
|
7980
8358
|
var init_WebsocketClient = __esm({
|
|
7981
8359
|
"node_modules/@pmate/utils/src/websocket/WebsocketClient.ts"() {
|
|
7982
8360
|
"use strict";
|
|
7983
|
-
|
|
8361
|
+
init_src3();
|
|
7984
8362
|
init_Emitter();
|
|
7985
8363
|
init_Logger();
|
|
7986
8364
|
init_Msg();
|
|
@@ -8000,7 +8378,7 @@ var logger3, WebsocketClientV2;
|
|
|
8000
8378
|
var init_WebsocketClientV2 = __esm({
|
|
8001
8379
|
"node_modules/@pmate/utils/src/websocket/WebsocketClientV2.ts"() {
|
|
8002
8380
|
"use strict";
|
|
8003
|
-
|
|
8381
|
+
init_src3();
|
|
8004
8382
|
init_AsyncStream();
|
|
8005
8383
|
init_Logger();
|
|
8006
8384
|
init_Msg();
|
|
@@ -8269,7 +8647,7 @@ var init_websocket = __esm({
|
|
|
8269
8647
|
});
|
|
8270
8648
|
|
|
8271
8649
|
// node_modules/@pmate/utils/src/index.ts
|
|
8272
|
-
var
|
|
8650
|
+
var init_src4 = __esm({
|
|
8273
8651
|
"node_modules/@pmate/utils/src/index.ts"() {
|
|
8274
8652
|
"use strict";
|
|
8275
8653
|
init_base64();
|
|
@@ -8335,7 +8713,7 @@ var AgentTaskManager;
|
|
|
8335
8713
|
var init_AgentTaskManager = __esm({
|
|
8336
8714
|
"node_modules/@pmate/agent-sdk/dist/AgentTaskManager.js"() {
|
|
8337
8715
|
"use strict";
|
|
8338
|
-
|
|
8716
|
+
init_src4();
|
|
8339
8717
|
init_debug();
|
|
8340
8718
|
AgentTaskManager = class {
|
|
8341
8719
|
constructor() {
|
|
@@ -8514,7 +8892,7 @@ var init_AgentClient = __esm({
|
|
|
8514
8892
|
"node_modules/@pmate/agent-sdk/dist/AgentClient.js"() {
|
|
8515
8893
|
"use strict";
|
|
8516
8894
|
init_src();
|
|
8517
|
-
|
|
8895
|
+
init_src4();
|
|
8518
8896
|
init_AgentTaskManager();
|
|
8519
8897
|
init_debug();
|
|
8520
8898
|
logger5 = Logger.getDebugger("AgentClient");
|
|
@@ -8911,7 +9289,7 @@ var init_AgentRuntime = __esm({
|
|
|
8911
9289
|
"node_modules/@pmate/agent-sdk/dist/AgentRuntime.js"() {
|
|
8912
9290
|
"use strict";
|
|
8913
9291
|
init_src();
|
|
8914
|
-
|
|
9292
|
+
init_src4();
|
|
8915
9293
|
}
|
|
8916
9294
|
});
|
|
8917
9295
|
|
|
@@ -8927,7 +9305,7 @@ var init_PromptAgent = __esm({
|
|
|
8927
9305
|
"node_modules/@pmate/agent-sdk/dist/PromptAgent.js"() {
|
|
8928
9306
|
"use strict";
|
|
8929
9307
|
init_src();
|
|
8930
|
-
|
|
9308
|
+
init_src4();
|
|
8931
9309
|
init_debug();
|
|
8932
9310
|
init_AgentRuntime();
|
|
8933
9311
|
init_PromptTaskContext();
|
|
@@ -8946,7 +9324,7 @@ var init_StreamAgent = __esm({
|
|
|
8946
9324
|
"node_modules/@pmate/agent-sdk/dist/StreamAgent.js"() {
|
|
8947
9325
|
"use strict";
|
|
8948
9326
|
init_src();
|
|
8949
|
-
|
|
9327
|
+
init_src4();
|
|
8950
9328
|
init_AgentRuntime();
|
|
8951
9329
|
init_StreamTaskContext();
|
|
8952
9330
|
}
|
|
@@ -9044,7 +9422,7 @@ var init_dist2 = __esm({
|
|
|
9044
9422
|
init_AgentTaskManager();
|
|
9045
9423
|
init_AgentService();
|
|
9046
9424
|
init_debug();
|
|
9047
|
-
|
|
9425
|
+
init_src4();
|
|
9048
9426
|
}
|
|
9049
9427
|
});
|
|
9050
9428
|
|
|
@@ -9104,7 +9482,6 @@ var init_AgentLlmClient = __esm({
|
|
|
9104
9482
|
import_node_path11 = __toESM(require("path"));
|
|
9105
9483
|
init_dist2();
|
|
9106
9484
|
init_sessionStore();
|
|
9107
|
-
init_profileClient();
|
|
9108
9485
|
DEFAULT_AGENT_API_BASE_URL = "https://agent-api.pmate.chat";
|
|
9109
9486
|
DEFAULT_AGENT_HUB_BASE_URL = "https://hub.pmate.chat";
|
|
9110
9487
|
DEFAULT_NAMESPACE = "pmate-cli";
|
|
@@ -9117,7 +9494,6 @@ var init_AgentLlmClient = __esm({
|
|
|
9117
9494
|
this.token = options?.token ?? this.session.token;
|
|
9118
9495
|
this.profileId = options?.profileId?.trim() || process.env.PMATE_PROFILE_ID || this.session.profileId;
|
|
9119
9496
|
this.agentApiBaseUrl = resolveAgentApiBaseUrl(options?.agentApiBaseUrl);
|
|
9120
|
-
this.authApiBaseUrl = resolveAuthApiBaseUrl(options?.authApiBaseUrl);
|
|
9121
9497
|
this.hubBaseUrl = resolveHubBaseUrl(options?.hubBaseUrl);
|
|
9122
9498
|
this.from = options?.from?.trim() || void 0;
|
|
9123
9499
|
this.agentService = new AgentService({
|
|
@@ -9184,12 +9560,7 @@ var init_AgentLlmClient = __esm({
|
|
|
9184
9560
|
if (profileId) {
|
|
9185
9561
|
return profileId;
|
|
9186
9562
|
}
|
|
9187
|
-
|
|
9188
|
-
token: this.token,
|
|
9189
|
-
app: DEFAULT_APP_ID,
|
|
9190
|
-
accountId: this.session.accountId,
|
|
9191
|
-
authApiBaseUrl: this.authApiBaseUrl
|
|
9192
|
-
});
|
|
9563
|
+
throw new Error(`Missing profileId in session. Run "pmate login --app ${DEFAULT_APP_ID}" again.`);
|
|
9193
9564
|
}
|
|
9194
9565
|
resolveFrom(value, profileId) {
|
|
9195
9566
|
return value?.trim() || this.from || profileId;
|
|
@@ -9638,8 +10009,52 @@ var ListCommandHandler = class {
|
|
|
9638
10009
|
// src/commands/LoginCommandHandler.ts
|
|
9639
10010
|
var import_node_child_process = require("child_process");
|
|
9640
10011
|
var import_node_http = require("http");
|
|
10012
|
+
var import_promises = require("readline/promises");
|
|
9641
10013
|
init_sessionStore();
|
|
9642
|
-
|
|
10014
|
+
|
|
10015
|
+
// src/profileClient.ts
|
|
10016
|
+
var DEFAULT_AUTH_API_BASE_URL = "https://auth-api-v2.pmate.chat";
|
|
10017
|
+
async function fetchDefaultProfileId(options) {
|
|
10018
|
+
const profiles = await fetchProfiles(options);
|
|
10019
|
+
const profileId = profiles[0]?.id?.trim();
|
|
10020
|
+
if (!profileId) {
|
|
10021
|
+
throw new Error(
|
|
10022
|
+
`No profile found for app ${options.app.trim()} and account ${options.accountId.trim()}.`
|
|
10023
|
+
);
|
|
10024
|
+
}
|
|
10025
|
+
return profileId;
|
|
10026
|
+
}
|
|
10027
|
+
async function fetchProfiles(options) {
|
|
10028
|
+
const token = options.token.trim();
|
|
10029
|
+
const app = options.app.trim();
|
|
10030
|
+
const accountId = options.accountId.trim();
|
|
10031
|
+
if (!token || !app || !accountId) {
|
|
10032
|
+
throw new Error("Missing token, app, or accountId for profile lookup.");
|
|
10033
|
+
}
|
|
10034
|
+
const url = new URL(`${resolveAuthApiBaseUrl(options.authApiBaseUrl)}/profiles`);
|
|
10035
|
+
url.searchParams.set("app", app);
|
|
10036
|
+
url.searchParams.set("account", accountId);
|
|
10037
|
+
const response = await fetch(url, {
|
|
10038
|
+
headers: {
|
|
10039
|
+
Authorization: `Bearer ${token}`
|
|
10040
|
+
}
|
|
10041
|
+
});
|
|
10042
|
+
if (!response.ok) {
|
|
10043
|
+
const detail = await response.text();
|
|
10044
|
+
throw new Error(
|
|
10045
|
+
`Failed to resolve default profile (${response.status}): ${detail || response.statusText}`
|
|
10046
|
+
);
|
|
10047
|
+
}
|
|
10048
|
+
const envelope = await response.json();
|
|
10049
|
+
return (envelope.data ?? []).filter(
|
|
10050
|
+
(profile) => !!profile?.id && typeof profile.id === "string"
|
|
10051
|
+
);
|
|
10052
|
+
}
|
|
10053
|
+
function resolveAuthApiBaseUrl(value) {
|
|
10054
|
+
return (value || process.env.PMATE_AUTH_API_BASE_URL || process.env.AUTH_API_BASE_URL || DEFAULT_AUTH_API_BASE_URL).replace(/\/+$/, "");
|
|
10055
|
+
}
|
|
10056
|
+
|
|
10057
|
+
// src/commands/LoginCommandHandler.ts
|
|
9643
10058
|
var AUTH_UI_BASE_URL = "https://auth.pmate.chat";
|
|
9644
10059
|
var AUTH_API_BASE_URL = DEFAULT_AUTH_API_BASE_URL;
|
|
9645
10060
|
var CALLBACK_PATH = "/pmate-login-callback";
|
|
@@ -9672,11 +10087,16 @@ var LoginCommandHandler = class {
|
|
|
9672
10087
|
try {
|
|
9673
10088
|
const token = await callback.waitForToken;
|
|
9674
10089
|
const loginResponse = await this.exchangeSession(token, appId);
|
|
9675
|
-
const
|
|
10090
|
+
const profiles = await fetchProfiles({
|
|
9676
10091
|
token: loginResponse.token,
|
|
9677
10092
|
app: appId,
|
|
9678
10093
|
accountId: loginResponse.session.identity.accountId
|
|
9679
10094
|
});
|
|
10095
|
+
const profileId = await this.resolveProfileId({
|
|
10096
|
+
appId,
|
|
10097
|
+
requestedProfileId: args.profileId,
|
|
10098
|
+
profiles
|
|
10099
|
+
});
|
|
9680
10100
|
savedSession = saveLoginSession({ ...loginResponse, profileId }, appId);
|
|
9681
10101
|
} finally {
|
|
9682
10102
|
await callback.close();
|
|
@@ -9709,6 +10129,58 @@ var LoginCommandHandler = class {
|
|
|
9709
10129
|
}
|
|
9710
10130
|
return resp.data;
|
|
9711
10131
|
}
|
|
10132
|
+
async resolveProfileId(input) {
|
|
10133
|
+
const requestedProfileId = input.requestedProfileId?.trim();
|
|
10134
|
+
if (requestedProfileId) {
|
|
10135
|
+
const exists = input.profiles.some((profile) => profile.id === requestedProfileId);
|
|
10136
|
+
if (!exists) {
|
|
10137
|
+
throw new Error(`Profile ${requestedProfileId} was not found for app ${input.appId}.`);
|
|
10138
|
+
}
|
|
10139
|
+
return requestedProfileId;
|
|
10140
|
+
}
|
|
10141
|
+
if (input.profiles.length === 0) {
|
|
10142
|
+
throw new Error(`No profile found for app ${input.appId}.`);
|
|
10143
|
+
}
|
|
10144
|
+
if (input.profiles.length === 1) {
|
|
10145
|
+
return input.profiles[0].id;
|
|
10146
|
+
}
|
|
10147
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
10148
|
+
const selected = input.profiles[0];
|
|
10149
|
+
ui.warn("Multiple profiles found; non-interactive login selected the first profile.", {
|
|
10150
|
+
app: input.appId,
|
|
10151
|
+
profileId: selected.id
|
|
10152
|
+
});
|
|
10153
|
+
return selected.id;
|
|
10154
|
+
}
|
|
10155
|
+
ui.info(`Multiple profiles found for ${input.appId}. Select one:`);
|
|
10156
|
+
input.profiles.forEach((profile, index) => {
|
|
10157
|
+
ui.plain(`${index + 1}. ${this.formatProfileLabel(profile)}`);
|
|
10158
|
+
});
|
|
10159
|
+
const rl = (0, import_promises.createInterface)({
|
|
10160
|
+
input: process.stdin,
|
|
10161
|
+
output: process.stdout
|
|
10162
|
+
});
|
|
10163
|
+
try {
|
|
10164
|
+
while (true) {
|
|
10165
|
+
const answer = (await rl.question("Profile number: ")).trim();
|
|
10166
|
+
const index = Number.parseInt(answer, 10);
|
|
10167
|
+
if (Number.isInteger(index) && index >= 1 && index <= input.profiles.length) {
|
|
10168
|
+
return input.profiles[index - 1].id;
|
|
10169
|
+
}
|
|
10170
|
+
ui.warn(`Enter a number from 1 to ${input.profiles.length}.`);
|
|
10171
|
+
}
|
|
10172
|
+
} finally {
|
|
10173
|
+
rl.close();
|
|
10174
|
+
}
|
|
10175
|
+
}
|
|
10176
|
+
formatProfileLabel(profile) {
|
|
10177
|
+
const parts = [
|
|
10178
|
+
profile.nickName?.trim(),
|
|
10179
|
+
profile.userName?.trim(),
|
|
10180
|
+
profile.role?.trim()
|
|
10181
|
+
].filter(Boolean);
|
|
10182
|
+
return parts.length > 0 ? `${parts.join(" / ")} (${profile.id})` : profile.id;
|
|
10183
|
+
}
|
|
9712
10184
|
async startCallbackServer() {
|
|
9713
10185
|
let resolveToken;
|
|
9714
10186
|
let rejectToken;
|
|
@@ -10862,7 +11334,7 @@ var import_node_path5 = __toESM(require("path"));
|
|
|
10862
11334
|
var import_node_child_process2 = require("child_process");
|
|
10863
11335
|
|
|
10864
11336
|
// src/serverAddress.ts
|
|
10865
|
-
var
|
|
11337
|
+
var import_promises2 = require("dns/promises");
|
|
10866
11338
|
var IPV4_PATTERN = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
|
|
10867
11339
|
function isIpv4Address(value) {
|
|
10868
11340
|
return IPV4_PATTERN.test(value.trim());
|
|
@@ -10875,7 +11347,7 @@ async function resolveServerAddress(server) {
|
|
|
10875
11347
|
if (isIpv4Address(normalized)) {
|
|
10876
11348
|
return normalized;
|
|
10877
11349
|
}
|
|
10878
|
-
const resolved = await (0,
|
|
11350
|
+
const resolved = await (0, import_promises2.lookup)(normalized, { family: 4 });
|
|
10879
11351
|
return resolved.address;
|
|
10880
11352
|
}
|
|
10881
11353
|
|
|
@@ -11537,7 +12009,7 @@ function formatEnvValue(value) {
|
|
|
11537
12009
|
|
|
11538
12010
|
// src/commands/PrepareDevCommandHandler.ts
|
|
11539
12011
|
var import_node_fs6 = require("fs");
|
|
11540
|
-
var
|
|
12012
|
+
var import_promises3 = require("fs/promises");
|
|
11541
12013
|
var import_node_os3 = __toESM(require("os"));
|
|
11542
12014
|
var import_node_path10 = __toESM(require("path"));
|
|
11543
12015
|
var import_node_child_process5 = require("child_process");
|
|
@@ -11561,7 +12033,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11561
12033
|
return result;
|
|
11562
12034
|
}
|
|
11563
12035
|
async openEnvironment(repo, note, envRoot, baseRoot) {
|
|
11564
|
-
await (0,
|
|
12036
|
+
await (0, import_promises3.mkdir)(envRoot, { recursive: true });
|
|
11565
12037
|
const baseRepoPath = import_node_path10.default.join(baseRoot, repo);
|
|
11566
12038
|
if (!await this.pathExists(baseRepoPath)) {
|
|
11567
12039
|
throw new Error(`Base repo not found: ${baseRepoPath}`);
|
|
@@ -11720,7 +12192,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11720
12192
|
}
|
|
11721
12193
|
async pathExists(targetPath) {
|
|
11722
12194
|
try {
|
|
11723
|
-
await (0,
|
|
12195
|
+
await (0, import_promises3.access)(targetPath, import_node_fs6.constants.F_OK);
|
|
11724
12196
|
return true;
|
|
11725
12197
|
} catch {
|
|
11726
12198
|
return false;
|
|
@@ -11735,7 +12207,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11735
12207
|
note,
|
|
11736
12208
|
openedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11737
12209
|
};
|
|
11738
|
-
await (0,
|
|
12210
|
+
await (0, import_promises3.writeFile)(lockPath, `${JSON.stringify(payload, null, 2)}
|
|
11739
12211
|
`, {
|
|
11740
12212
|
encoding: "utf8",
|
|
11741
12213
|
flag: "wx"
|
|
@@ -11745,7 +12217,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11745
12217
|
if (!await this.pathExists(lockPath)) {
|
|
11746
12218
|
return false;
|
|
11747
12219
|
}
|
|
11748
|
-
await (0,
|
|
12220
|
+
await (0, import_promises3.rm)(lockPath, { force: true });
|
|
11749
12221
|
return true;
|
|
11750
12222
|
}
|
|
11751
12223
|
isLocalOrigin(origin) {
|
|
@@ -12666,7 +13138,7 @@ var import_node_child_process8 = require("child_process");
|
|
|
12666
13138
|
var import_node_fs8 = require("fs");
|
|
12667
13139
|
var import_node_os4 = __toESM(require("os"));
|
|
12668
13140
|
var import_node_path13 = __toESM(require("path"));
|
|
12669
|
-
var
|
|
13141
|
+
var import_promises4 = require("readline/promises");
|
|
12670
13142
|
var import_openai = __toESM(require("openai"));
|
|
12671
13143
|
var import_sdk = require("@linear/sdk");
|
|
12672
13144
|
var ISSUE_SUMMARY_FIELDS = `
|
|
@@ -13517,7 +13989,7 @@ var LinearCommandHandler = class {
|
|
|
13517
13989
|
return accounts[index];
|
|
13518
13990
|
}
|
|
13519
13991
|
}
|
|
13520
|
-
const rl = (0,
|
|
13992
|
+
const rl = (0, import_promises4.createInterface)({
|
|
13521
13993
|
input: process.stdin,
|
|
13522
13994
|
output: process.stdout
|
|
13523
13995
|
});
|
|
@@ -13683,7 +14155,7 @@ var LinearCommandHandler = class {
|
|
|
13683
14155
|
ui.info(issue.description?.trim() ? issue.description : " (no description)");
|
|
13684
14156
|
}
|
|
13685
14157
|
async collectReplInput() {
|
|
13686
|
-
const rl = (0,
|
|
14158
|
+
const rl = (0, import_promises4.createInterface)({
|
|
13687
14159
|
input: process.stdin,
|
|
13688
14160
|
output: process.stdout
|
|
13689
14161
|
});
|
|
@@ -13743,7 +14215,7 @@ var LinearCommandHandler = class {
|
|
|
13743
14215
|
} else {
|
|
13744
14216
|
ui.info("Copy a screenshot to your clipboard, then press Enter.");
|
|
13745
14217
|
}
|
|
13746
|
-
const rl = (0,
|
|
14218
|
+
const rl = (0, import_promises4.createInterface)({
|
|
13747
14219
|
input: process.stdin,
|
|
13748
14220
|
output: process.stdout
|
|
13749
14221
|
});
|
|
@@ -14637,7 +15109,7 @@ var import_node_child_process9 = require("child_process");
|
|
|
14637
15109
|
var import_node_fs10 = require("fs");
|
|
14638
15110
|
var import_node_os5 = __toESM(require("os"));
|
|
14639
15111
|
var import_node_path15 = __toESM(require("path"));
|
|
14640
|
-
var
|
|
15112
|
+
var import_promises5 = require("readline/promises");
|
|
14641
15113
|
var import_jsqr = __toESM(require("jsqr"));
|
|
14642
15114
|
var import_pngjs = require("pngjs");
|
|
14643
15115
|
var QrcodeCommandHandler = class {
|
|
@@ -14669,7 +15141,7 @@ var QrcodeCommandHandler = class {
|
|
|
14669
15141
|
}
|
|
14670
15142
|
async captureScreenshot() {
|
|
14671
15143
|
ui.info("Capture a QR code screenshot now (macOS screencapture).");
|
|
14672
|
-
const rl = (0,
|
|
15144
|
+
const rl = (0, import_promises5.createInterface)({
|
|
14673
15145
|
input: process.stdin,
|
|
14674
15146
|
output: process.stdout
|
|
14675
15147
|
});
|
|
@@ -14720,7 +15192,7 @@ var QrcodeCommandHandler = class {
|
|
|
14720
15192
|
return value ? value : null;
|
|
14721
15193
|
}
|
|
14722
15194
|
async promptValue(detected) {
|
|
14723
|
-
const rl = (0,
|
|
15195
|
+
const rl = (0, import_promises5.createInterface)({
|
|
14724
15196
|
input: process.stdin,
|
|
14725
15197
|
output: process.stdout
|
|
14726
15198
|
});
|
|
@@ -18054,9 +18526,9 @@ function readNamespaceFromPayload(payload) {
|
|
|
18054
18526
|
|
|
18055
18527
|
// src/commands/ServiceCommandHandler.ts
|
|
18056
18528
|
var import_node_fs20 = require("fs");
|
|
18057
|
-
var
|
|
18529
|
+
var import_promises6 = require("fs/promises");
|
|
18058
18530
|
var import_node_path24 = __toESM(require("path"));
|
|
18059
|
-
var
|
|
18531
|
+
var import_promises7 = require("readline/promises");
|
|
18060
18532
|
|
|
18061
18533
|
// src/services/ServiceRuntimeRunner.ts
|
|
18062
18534
|
var import_node_fs19 = require("fs");
|
|
@@ -19785,7 +20257,7 @@ var ServiceCommandHandler = class {
|
|
|
19785
20257
|
}
|
|
19786
20258
|
);
|
|
19787
20259
|
const outputPath = import_node_path24.default.resolve(process.cwd(), args.output);
|
|
19788
|
-
await (0,
|
|
20260
|
+
await (0, import_promises6.writeFile)(outputPath, payload.content, "utf8");
|
|
19789
20261
|
ui.success(`Wrote env file for ${args.appId} to ${outputPath}`);
|
|
19790
20262
|
this.renderJson({ ...payload, output: outputPath }, args.json);
|
|
19791
20263
|
return;
|
|
@@ -19873,7 +20345,7 @@ var ServiceCommandHandler = class {
|
|
|
19873
20345
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
19874
20346
|
throw new Error("Prompt input requires an interactive terminal.");
|
|
19875
20347
|
}
|
|
19876
|
-
const rl = (0,
|
|
20348
|
+
const rl = (0, import_promises7.createInterface)({
|
|
19877
20349
|
input: process.stdin,
|
|
19878
20350
|
output: process.stdout
|
|
19879
20351
|
});
|
|
@@ -20451,7 +20923,13 @@ var AccountCommandHandler = class {
|
|
|
20451
20923
|
signature: this.signBotChallenge(challenge, privateKey)
|
|
20452
20924
|
}
|
|
20453
20925
|
);
|
|
20454
|
-
const
|
|
20926
|
+
const profileId = await fetchDefaultProfileId({
|
|
20927
|
+
token: login.token,
|
|
20928
|
+
app: args.app,
|
|
20929
|
+
accountId: login.session.identity.accountId,
|
|
20930
|
+
authApiBaseUrl: baseUrl
|
|
20931
|
+
});
|
|
20932
|
+
const saved = saveLoginSession({ ...login, profileId }, args.app);
|
|
20455
20933
|
if (!args.json) {
|
|
20456
20934
|
ui.success(`Logged in bot ${args.name} to ${saved.app}`);
|
|
20457
20935
|
}
|
|
@@ -23858,7 +24336,7 @@ var HELP_TEXT = [
|
|
|
23858
24336
|
import_chalk4.default.bold("Commands:"),
|
|
23859
24337
|
` ${import_chalk4.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
|
|
23860
24338
|
` ${import_chalk4.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
|
|
23861
|
-
` ${import_chalk4.default.gray(" [--app <app-id>]")}`,
|
|
24339
|
+
` ${import_chalk4.default.gray(" [--app <app-id>] [--profile-id <id>]")}`,
|
|
23862
24340
|
` ${import_chalk4.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
|
|
23863
24341
|
` ${import_chalk4.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
|
|
23864
24342
|
` ${import_chalk4.default.cyan("sts")} Request an OSS STS token from the CI server`,
|
|
@@ -24081,17 +24559,21 @@ function parseCommandArgs(args) {
|
|
|
24081
24559
|
if (args.rest[0] === "login") {
|
|
24082
24560
|
const rest = args.rest.slice(1);
|
|
24083
24561
|
let app;
|
|
24562
|
+
let profileId;
|
|
24084
24563
|
while (rest.length > 0) {
|
|
24085
24564
|
const token = rest.shift();
|
|
24086
24565
|
switch (token) {
|
|
24087
24566
|
case "--app":
|
|
24088
24567
|
app = requireValue13(rest, token);
|
|
24089
24568
|
break;
|
|
24569
|
+
case "--profile-id":
|
|
24570
|
+
profileId = requireValue13(rest, token);
|
|
24571
|
+
break;
|
|
24090
24572
|
default:
|
|
24091
24573
|
throw new Error(`Unknown login option: ${token}`);
|
|
24092
24574
|
}
|
|
24093
24575
|
}
|
|
24094
|
-
return { type: "login" /* Login */, app };
|
|
24576
|
+
return { type: "login" /* Login */, app, profileId };
|
|
24095
24577
|
}
|
|
24096
24578
|
if (args.rest[0] === "add-dns") {
|
|
24097
24579
|
return parseAddDnsArgs(args.rest.slice(1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/cli",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.22",
|
|
4
4
|
"description": "CLI utilities for the pMate project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -11,16 +11,6 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "npm run clean && tsup --config tsup.config.ts && node scripts/copy-templates.js",
|
|
16
|
-
"clean": "rimraf dist",
|
|
17
|
-
"dev": "ts-node src/index.ts",
|
|
18
|
-
"release": "npm publish",
|
|
19
|
-
"start": "node dist/index.js",
|
|
20
|
-
"test": "vitest run src/tests",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"prepare": "npm run build"
|
|
23
|
-
},
|
|
24
14
|
"keywords": [
|
|
25
15
|
"cli",
|
|
26
16
|
"typescript",
|
|
@@ -58,7 +48,7 @@
|
|
|
58
48
|
"devDependencies": {
|
|
59
49
|
"@pmate/agent-sdk": "^1.1.12",
|
|
60
50
|
"@pmate/meta": "^1.1.13",
|
|
61
|
-
"@pmate/utils": "^1.1.
|
|
51
|
+
"@pmate/utils": "^1.1.4",
|
|
62
52
|
"@types/node": "^25.0.3",
|
|
63
53
|
"@types/pngjs": "^6.0.5",
|
|
64
54
|
"rimraf": "^6.1.2",
|
|
@@ -67,10 +57,13 @@
|
|
|
67
57
|
"typescript": "^5.9.3",
|
|
68
58
|
"vitest": "^4.0.17"
|
|
69
59
|
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "npm run clean && tsup --config tsup.config.ts && node scripts/copy-templates.js",
|
|
62
|
+
"clean": "rimraf dist",
|
|
63
|
+
"dev": "ts-node src/index.ts",
|
|
64
|
+
"release": "npm publish",
|
|
65
|
+
"start": "node dist/index.js",
|
|
66
|
+
"test": "vitest run src/tests",
|
|
67
|
+
"typecheck": "tsc --noEmit"
|
|
75
68
|
}
|
|
76
|
-
}
|
|
69
|
+
}
|