@onklave/agent-cli 0.1.41 → 0.1.42
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/main.js +34 -11
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -127,6 +127,7 @@ var CredentialStore = class {
|
|
|
127
127
|
|
|
128
128
|
// _apps/@onklave/agent-cli/src/services/auth.service.ts
|
|
129
129
|
var DEFAULT_PLATFORM_URL = "https://api.onklave.app";
|
|
130
|
+
var DEFAULT_COMMS_URL = "wss://comms.onklave.app";
|
|
130
131
|
var AuthService = class {
|
|
131
132
|
constructor() {
|
|
132
133
|
this.store = new CredentialStore();
|
|
@@ -147,6 +148,7 @@ var AuthService = class {
|
|
|
147
148
|
...existing,
|
|
148
149
|
token,
|
|
149
150
|
platformUrl: metadata?.platformUrl ?? existing?.platformUrl ?? DEFAULT_PLATFORM_URL,
|
|
151
|
+
commsUrl: metadata?.commsUrl ?? existing?.commsUrl,
|
|
150
152
|
userId: metadata?.userId ?? existing?.userId,
|
|
151
153
|
orgId: metadata?.orgId ?? existing?.orgId,
|
|
152
154
|
expiresAt: metadata?.expiresAt ?? existing?.expiresAt
|
|
@@ -206,6 +208,15 @@ var AuthService = class {
|
|
|
206
208
|
const creds = await this.getCredentials();
|
|
207
209
|
return creds?.platformUrl ?? DEFAULT_PLATFORM_URL;
|
|
208
210
|
}
|
|
211
|
+
/*
|
|
212
|
+
* Get the comms (Socket.IO) URL from credentials or fallback to default.
|
|
213
|
+
* Resolved separately from the platform URL because comms is reached on a
|
|
214
|
+
* dedicated host, not through the gateway.
|
|
215
|
+
*/
|
|
216
|
+
async getCommsUrl() {
|
|
217
|
+
const creds = await this.getCredentials();
|
|
218
|
+
return creds?.commsUrl ?? DEFAULT_COMMS_URL;
|
|
219
|
+
}
|
|
209
220
|
};
|
|
210
221
|
|
|
211
222
|
// _apps/@onklave/agent-cli/src/utils.ts
|
|
@@ -257,10 +268,11 @@ async function loginCommand(args) {
|
|
|
257
268
|
const authService = new AuthService();
|
|
258
269
|
const token = flags["token"];
|
|
259
270
|
const platformUrl = flags["platform-url"];
|
|
271
|
+
const commsUrl = flags["comms-url"];
|
|
260
272
|
if (typeof token !== "string" || !token) {
|
|
261
273
|
console.log("Onklave Agent CLI \u2014 Login\n");
|
|
262
274
|
console.log(
|
|
263
|
-
"Usage: onklave login --token <token> [--platform-url <url>]\n"
|
|
275
|
+
"Usage: onklave login --token <token> [--platform-url <url>] [--comms-url <url>]\n"
|
|
264
276
|
);
|
|
265
277
|
console.log("To obtain a token:");
|
|
266
278
|
console.log(
|
|
@@ -277,6 +289,9 @@ async function loginCommand(args) {
|
|
|
277
289
|
if (typeof platformUrl === "string") {
|
|
278
290
|
metadata.platformUrl = platformUrl;
|
|
279
291
|
}
|
|
292
|
+
if (typeof commsUrl === "string") {
|
|
293
|
+
metadata.commsUrl = commsUrl;
|
|
294
|
+
}
|
|
280
295
|
try {
|
|
281
296
|
await authService.saveToken(token, metadata);
|
|
282
297
|
console.log("Successfully authenticated with Onklave platform.");
|
|
@@ -284,6 +299,9 @@ async function loginCommand(args) {
|
|
|
284
299
|
if (typeof platformUrl === "string") {
|
|
285
300
|
console.log(`Platform URL: ${platformUrl}`);
|
|
286
301
|
}
|
|
302
|
+
if (typeof commsUrl === "string") {
|
|
303
|
+
console.log(`Comms URL: ${commsUrl}`);
|
|
304
|
+
}
|
|
287
305
|
} catch (err) {
|
|
288
306
|
console.error(`Login failed: ${err.message}`);
|
|
289
307
|
process.exitCode = 1;
|
|
@@ -319,6 +337,7 @@ async function whoamiCommand() {
|
|
|
319
337
|
const isValid = await authService.isAuthenticated();
|
|
320
338
|
console.log("Onklave Agent CLI \u2014 Identity\n");
|
|
321
339
|
console.log(` Platform URL: ${creds.platformUrl}`);
|
|
340
|
+
console.log(` Comms URL: ${await authService.getCommsUrl()}`);
|
|
322
341
|
console.log(` User ID: ${creds.userId ?? "(not set)"}`);
|
|
323
342
|
console.log(` Org ID: ${creds.orgId ?? "(not set)"}`);
|
|
324
343
|
console.log(` Machine ID: ${creds.machineId ?? "(not registered)"}`);
|
|
@@ -548,6 +567,7 @@ var ConfigResolver = class {
|
|
|
548
567
|
};
|
|
549
568
|
|
|
550
569
|
// _apps/@onklave/agent-cli/src/services/platform-client.ts
|
|
570
|
+
var GATEWAY_SERVICE_PREFIX = "/agent-orchestration";
|
|
551
571
|
var PlatformClient = class {
|
|
552
572
|
constructor(baseUrl, token) {
|
|
553
573
|
this.baseUrl = baseUrl;
|
|
@@ -716,7 +736,7 @@ var PlatformClient = class {
|
|
|
716
736
|
* Make an authenticated HTTP request to the platform.
|
|
717
737
|
*/
|
|
718
738
|
async request(method, path8, body, extraHeaders) {
|
|
719
|
-
const url = `${this.baseUrl}${path8}`;
|
|
739
|
+
const url = `${this.baseUrl}${GATEWAY_SERVICE_PREFIX}${path8}`;
|
|
720
740
|
const headers = {
|
|
721
741
|
Authorization: `Bearer ${this.token}`,
|
|
722
742
|
"Content-Type": "application/json",
|
|
@@ -765,13 +785,15 @@ var CommsClient = class {
|
|
|
765
785
|
}
|
|
766
786
|
/*
|
|
767
787
|
* Connect to the Onklave comms service via Socket.IO.
|
|
788
|
+
* `commsUrl` is the comms service host (e.g. wss://comms.onklave.app) — NOT
|
|
789
|
+
* the gateway/platform URL; comms is reached on its own dedicated ingress.
|
|
768
790
|
* Pass `machineId` so the server can route inbound runner events
|
|
769
791
|
* (e.g. `assignment:claim-available`) to this specific runner.
|
|
770
792
|
*/
|
|
771
|
-
async connect(
|
|
793
|
+
async connect(commsUrl, token, extra) {
|
|
772
794
|
return new Promise((resolve3, reject) => {
|
|
773
|
-
const
|
|
774
|
-
this.socket = io(`${
|
|
795
|
+
const baseUrl = commsUrl.replace(/\/+$/, "");
|
|
796
|
+
this.socket = io(`${baseUrl}/agent-cli`, {
|
|
775
797
|
auth: {
|
|
776
798
|
token,
|
|
777
799
|
machineId: extra?.machineId,
|
|
@@ -1387,7 +1409,7 @@ var HeartbeatService = class {
|
|
|
1387
1409
|
};
|
|
1388
1410
|
try {
|
|
1389
1411
|
const response = await fetch(
|
|
1390
|
-
`${this.opts.platformUrl}/api/v1/runner/heartbeat`,
|
|
1412
|
+
`${this.opts.platformUrl}/agent-orchestration/api/v1/runner/heartbeat`,
|
|
1391
1413
|
{
|
|
1392
1414
|
method: "POST",
|
|
1393
1415
|
headers: {
|
|
@@ -2037,7 +2059,7 @@ async function runCommand(args) {
|
|
|
2037
2059
|
const auditStreamer = new AuditStreamer(commsClient);
|
|
2038
2060
|
try {
|
|
2039
2061
|
console.log("Connecting to Onklave comms service...");
|
|
2040
|
-
await commsClient.connect(
|
|
2062
|
+
await commsClient.connect(await authService.getCommsUrl(), creds.token, {
|
|
2041
2063
|
machineId: creds.machineId,
|
|
2042
2064
|
deviceToken: creds.deviceToken,
|
|
2043
2065
|
orgId: creds.orgId
|
|
@@ -2695,7 +2717,7 @@ async function checkWebSocket() {
|
|
|
2695
2717
|
}
|
|
2696
2718
|
const commsClient = new CommsClient();
|
|
2697
2719
|
try {
|
|
2698
|
-
await commsClient.connect(
|
|
2720
|
+
await commsClient.connect(await authService.getCommsUrl(), creds.token);
|
|
2699
2721
|
commsClient.disconnect();
|
|
2700
2722
|
return {
|
|
2701
2723
|
name: "WebSocket",
|
|
@@ -3011,7 +3033,7 @@ var DaemonCommsService = class {
|
|
|
3011
3033
|
let attempt = 0;
|
|
3012
3034
|
while (!this.stopRequested) {
|
|
3013
3035
|
try {
|
|
3014
|
-
await this.client.connect(this.opts.
|
|
3036
|
+
await this.client.connect(this.opts.commsUrl, this.opts.token, {
|
|
3015
3037
|
machineId: this.opts.machineId,
|
|
3016
3038
|
deviceToken: this.opts.deviceToken,
|
|
3017
3039
|
orgId: this.opts.orgId
|
|
@@ -3415,7 +3437,7 @@ var PlatformBrokerClient = class {
|
|
|
3415
3437
|
);
|
|
3416
3438
|
}
|
|
3417
3439
|
async request(method, path8, body) {
|
|
3418
|
-
const url = `${this.baseUrl}${path8}`;
|
|
3440
|
+
const url = `${this.baseUrl}/agent-orchestration${path8}`;
|
|
3419
3441
|
const response = await fetch(url, {
|
|
3420
3442
|
method,
|
|
3421
3443
|
headers: {
|
|
@@ -4232,8 +4254,9 @@ async function daemonStart() {
|
|
|
4232
4254
|
creds.machineId
|
|
4233
4255
|
);
|
|
4234
4256
|
const platformUrl = await authService.getPlatformUrl();
|
|
4257
|
+
const commsUrl = await authService.getCommsUrl();
|
|
4235
4258
|
const comms = new DaemonCommsService({
|
|
4236
|
-
|
|
4259
|
+
commsUrl,
|
|
4237
4260
|
token: creds.token,
|
|
4238
4261
|
machineId: creds.machineId,
|
|
4239
4262
|
deviceToken: creds.deviceToken,
|