@botmanor/fe-sdk 2026.1205.4 → 2026.1206.1
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 +41 -2
- package/dist/index.js +152 -37
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -404,6 +404,8 @@ interface OwnMachineGrant {
|
|
|
404
404
|
status: "ACTIVE" | "EXPIRED" | "REVOKED";
|
|
405
405
|
expiresAt: string;
|
|
406
406
|
scopes: string[];
|
|
407
|
+
/** Who granted it: the grantor may revoke it as well as the machine's owner (BOFF-18818). */
|
|
408
|
+
grantorActorId?: string | null;
|
|
407
409
|
}
|
|
408
410
|
/** Where the person manages their VibeControls machines, by default. */
|
|
409
411
|
export declare const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
@@ -411,6 +413,8 @@ export declare const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
|
411
413
|
export declare const OWN_MACHINE_PAGE_SIZE = 100;
|
|
412
414
|
/** Pages read at most (10 000 machines); the list says when it stopped early. */
|
|
413
415
|
export declare const OWN_MACHINE_MAX_PAGES = 100;
|
|
416
|
+
/** The owner's machines looked up one by one when the grant list may miss them. */
|
|
417
|
+
export declare const OWN_MACHINE_GRANT_LOOKUPS = 50;
|
|
414
418
|
/** The grant lengths the owner can pick, in days. */
|
|
415
419
|
export declare const OWN_MACHINE_GRANT_DAYS: readonly [1, 7, 30];
|
|
416
420
|
type OwnMachineGrantDays = (typeof OWN_MACHINE_GRANT_DAYS)[number];
|
|
@@ -447,13 +451,40 @@ interface OwnMachineRow {
|
|
|
447
451
|
granted: boolean;
|
|
448
452
|
/** The steward works on this machine now. */
|
|
449
453
|
chosen: boolean;
|
|
454
|
+
/**
|
|
455
|
+
* The steward holds a live grant on a machine that is not the steward
|
|
456
|
+
* owner's (it was given to someone else, or is not listed): the row offers
|
|
457
|
+
* only Revoke, to whoever the service lets revoke it (BOFF-18818).
|
|
458
|
+
*/
|
|
459
|
+
revokeOnly?: true;
|
|
460
|
+
/** The machine list does not hold this machine; only its id is known. */
|
|
461
|
+
unlisted?: true;
|
|
450
462
|
}
|
|
451
463
|
/**
|
|
452
464
|
* The owner's machines for the picker: the owner's agents, chosen one first,
|
|
453
465
|
* then granted ones, then by name. A grant counts while it is ACTIVE and not
|
|
454
|
-
* past its expiry (`now`, for tests).
|
|
466
|
+
* past its expiry (`now`, for tests). A live grant on any other machine
|
|
467
|
+
* follows as a revoke-only row, so the person who may revoke it still can
|
|
468
|
+
* (BOFF-18818); a machine the list does not hold is named by its id.
|
|
469
|
+
* Machines in `unchecked` (their grant could not be looked up) stay listed
|
|
470
|
+
* too, so the viewer can check the grant by hand.
|
|
471
|
+
*/
|
|
472
|
+
export declare function ownMachineRows(agents: readonly OwnMachineCandidate[], grants: readonly OwnMachineGrant[], ownerActorId: string, chosenAgentId: string | null, now?: number, unchecked?: ReadonlySet<string>): OwnMachineRow[];
|
|
473
|
+
/**
|
|
474
|
+
* The machines whose grant is looked up one by one, because the capped grant
|
|
475
|
+
* list may have left a live grant out. `lookup` holds the steward owner's
|
|
476
|
+
* machines without a live grant in the list, looked up before the picker
|
|
477
|
+
* shows. `later` holds, for a viewer who is not the owner, the viewer's own
|
|
478
|
+
* machines (a machine owner may revoke a grant on their machine, BOFF-18818);
|
|
479
|
+
* they are looked up after the picker shows, so they never hold up the rows
|
|
480
|
+
* already known. At most {@link OWN_MACHINE_GRANT_LOOKUPS} are looked up in
|
|
481
|
+
* all, owner's first; the rest are `unchecked`.
|
|
455
482
|
*/
|
|
456
|
-
export declare function
|
|
483
|
+
export declare function ownMachineGrantLookups(agents: readonly OwnMachineCandidate[], grants: readonly OwnMachineGrant[], ownerActorId: string, viewerActorId?: string | null, now?: number): {
|
|
484
|
+
lookup: string[];
|
|
485
|
+
later: string[];
|
|
486
|
+
unchecked: string[];
|
|
487
|
+
};
|
|
457
488
|
/** The expiry to send for a grant of `days`, never past the service's 30-day limit. */
|
|
458
489
|
export declare function ownMachineGrantExpiry(days: OwnMachineGrantDays, now?: number): string;
|
|
459
490
|
/**
|
|
@@ -465,6 +496,14 @@ export declare function ownMachineAllowedApps(text: string): string[];
|
|
|
465
496
|
export declare function ownMachineAppCount(text: string): number;
|
|
466
497
|
/** When the earliest live grant expires (epoch ms), or null. */
|
|
467
498
|
export declare function nextOwnMachineGrantExpiry(grants: readonly OwnMachineGrant[], now?: number): number | null;
|
|
499
|
+
/**
|
|
500
|
+
* May the viewer revoke a steward's grant on a machine (BOFF-18818)? The
|
|
501
|
+
* gateway needs agent:update, and the service then lets the grant's grantor
|
|
502
|
+
* or the machine's current owner revoke it, whatever they may do with the
|
|
503
|
+
* steward itself (botmanor-steward:update is not needed). As elsewhere here,
|
|
504
|
+
* data the host did not give is left to the gateway.
|
|
505
|
+
*/
|
|
506
|
+
export declare function ownMachineCanRevoke(machineOwnerId: string | null | undefined, grantorActorId: string | null | undefined, access?: OwnMachineAccess): boolean;
|
|
468
507
|
/** What the viewer may do with the picker, from {@link OwnMachineAccess}. */
|
|
469
508
|
export declare function ownMachineAbilities(ownerActorId: string, access?: OwnMachineAccess): {
|
|
470
509
|
manage: boolean;
|
package/dist/index.js
CHANGED
|
@@ -459,7 +459,7 @@ const LIST_OWN_MACHINE_AGENTS = `query StewardOwnMachineAgents($pagination: Pagi
|
|
|
459
459
|
id name hostname platform isActive ownerUserId lastHeartbeat
|
|
460
460
|
}
|
|
461
461
|
}`;
|
|
462
|
-
const OWN_MACHINE_GRANT = `id agentId status expiresAt scopes`;
|
|
462
|
+
const OWN_MACHINE_GRANT = `id agentId status expiresAt scopes grantorActorId`;
|
|
463
463
|
/**
|
|
464
464
|
* The steward's active grants (VibeControls returns at most 100, newest
|
|
465
465
|
* first). Pass `agentId` to look one machine up when the list may be cut off.
|
|
@@ -1235,16 +1235,58 @@ function isLive(grant, now) {
|
|
|
1235
1235
|
/**
|
|
1236
1236
|
* The owner's machines for the picker: the owner's agents, chosen one first,
|
|
1237
1237
|
* then granted ones, then by name. A grant counts while it is ACTIVE and not
|
|
1238
|
-
* past its expiry (`now`, for tests).
|
|
1238
|
+
* past its expiry (`now`, for tests). A live grant on any other machine
|
|
1239
|
+
* follows as a revoke-only row, so the person who may revoke it still can
|
|
1240
|
+
* (BOFF-18818); a machine the list does not hold is named by its id.
|
|
1241
|
+
* Machines in `unchecked` (their grant could not be looked up) stay listed
|
|
1242
|
+
* too, so the viewer can check the grant by hand.
|
|
1239
1243
|
*/
|
|
1240
|
-
function ownMachineRows(agents, grants, ownerActorId, chosenAgentId, now = Date.now()) {
|
|
1244
|
+
function ownMachineRows(agents, grants, ownerActorId, chosenAgentId, now = Date.now(), unchecked = /* @__PURE__ */ new Set()) {
|
|
1241
1245
|
const granted = new Set(grants.filter((g) => isLive(g, now)).map((g) => g.agentId));
|
|
1242
|
-
const rank = (row) => row.chosen ? 0 : row.granted ? 1 : 2;
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1246
|
+
const rank = (row) => row.revokeOnly ? 3 : row.chosen ? 0 : row.granted ? 1 : 2;
|
|
1247
|
+
const listed = new Set(agents.map((a) => a.id));
|
|
1248
|
+
const unlisted = [...granted].filter((id) => !listed.has(id)).map((id) => ({
|
|
1249
|
+
id,
|
|
1250
|
+
name: `Machine ${id.slice(0, 8)}`,
|
|
1251
|
+
hostname: "",
|
|
1252
|
+
platform: "",
|
|
1253
|
+
isActive: false,
|
|
1254
|
+
ownerUserId: null,
|
|
1255
|
+
lastHeartbeat: null
|
|
1256
|
+
}));
|
|
1257
|
+
return [...agents, ...unlisted].filter((a) => a.ownerUserId === ownerActorId || a.id === chosenAgentId || granted.has(a.id) || unchecked.has(a.id)).map((agent) => {
|
|
1258
|
+
const row = {
|
|
1259
|
+
agent,
|
|
1260
|
+
granted: granted.has(agent.id),
|
|
1261
|
+
chosen: agent.id === chosenAgentId
|
|
1262
|
+
};
|
|
1263
|
+
if (agent.ownerUserId !== ownerActorId && !row.chosen) row.revokeOnly = true;
|
|
1264
|
+
if (!listed.has(agent.id)) row.unlisted = true;
|
|
1265
|
+
return row;
|
|
1266
|
+
}).sort((a, b) => rank(a) - rank(b) || a.agent.name.localeCompare(b.agent.name));
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* The machines whose grant is looked up one by one, because the capped grant
|
|
1270
|
+
* list may have left a live grant out. `lookup` holds the steward owner's
|
|
1271
|
+
* machines without a live grant in the list, looked up before the picker
|
|
1272
|
+
* shows. `later` holds, for a viewer who is not the owner, the viewer's own
|
|
1273
|
+
* machines (a machine owner may revoke a grant on their machine, BOFF-18818);
|
|
1274
|
+
* they are looked up after the picker shows, so they never hold up the rows
|
|
1275
|
+
* already known. At most {@link OWN_MACHINE_GRANT_LOOKUPS} are looked up in
|
|
1276
|
+
* all, owner's first; the rest are `unchecked`.
|
|
1277
|
+
*/
|
|
1278
|
+
function ownMachineGrantLookups(agents, grants, ownerActorId, viewerActorId = null, now = Date.now()) {
|
|
1279
|
+
const live = new Set(grants.filter((g) => isLive(g, now)).map((g) => g.agentId));
|
|
1280
|
+
const missingOf = (owner) => agents.filter((a) => a.ownerUserId === owner && !live.has(a.id)).map((a) => a.id);
|
|
1281
|
+
const owners = missingOf(ownerActorId);
|
|
1282
|
+
const viewers = viewerActorId && viewerActorId !== ownerActorId ? missingOf(viewerActorId) : [];
|
|
1283
|
+
const lookup = owners.slice(0, 50);
|
|
1284
|
+
const later = viewers.slice(0, 50 - lookup.length);
|
|
1285
|
+
return {
|
|
1286
|
+
lookup,
|
|
1287
|
+
later,
|
|
1288
|
+
unchecked: [...owners.slice(lookup.length), ...viewers.slice(later.length)]
|
|
1289
|
+
};
|
|
1248
1290
|
}
|
|
1249
1291
|
/** The expiry to send for a grant of `days`, never past the service's 30-day limit. */
|
|
1250
1292
|
function ownMachineGrantExpiry(days, now = Date.now()) {
|
|
@@ -1276,6 +1318,21 @@ function nextOwnMachineGrantExpiry(grants, now = Date.now()) {
|
|
|
1276
1318
|
}
|
|
1277
1319
|
return next;
|
|
1278
1320
|
}
|
|
1321
|
+
/**
|
|
1322
|
+
* May the viewer revoke a steward's grant on a machine (BOFF-18818)? The
|
|
1323
|
+
* gateway needs agent:update, and the service then lets the grant's grantor
|
|
1324
|
+
* or the machine's current owner revoke it, whatever they may do with the
|
|
1325
|
+
* steward itself (botmanor-steward:update is not needed). As elsewhere here,
|
|
1326
|
+
* data the host did not give is left to the gateway.
|
|
1327
|
+
*/
|
|
1328
|
+
function ownMachineCanRevoke(machineOwnerId, grantorActorId, access = {}) {
|
|
1329
|
+
if (access.canGrantMachines === false) return false;
|
|
1330
|
+
const viewer = access.viewerActorId;
|
|
1331
|
+
if (viewer === void 0) return true;
|
|
1332
|
+
if (!viewer) return false;
|
|
1333
|
+
if (!machineOwnerId) return true;
|
|
1334
|
+
return viewer === machineOwnerId || viewer === grantorActorId;
|
|
1335
|
+
}
|
|
1279
1336
|
/** What the viewer may do with the picker, from {@link OwnMachineAccess}. */
|
|
1280
1337
|
function ownMachineAbilities(ownerActorId, access = {}) {
|
|
1281
1338
|
const manage = (access.viewerActorId === void 0 || access.viewerActorId === ownerActorId) && access.canUpdateSteward !== false;
|
|
@@ -1291,10 +1348,35 @@ const EMPTY_MACHINES = {
|
|
|
1291
1348
|
error: void 0,
|
|
1292
1349
|
loading: false,
|
|
1293
1350
|
truncated: false,
|
|
1294
|
-
unchecked: /* @__PURE__ */ new Set()
|
|
1351
|
+
unchecked: /* @__PURE__ */ new Set(),
|
|
1352
|
+
pending: 0
|
|
1295
1353
|
};
|
|
1296
1354
|
/** Grant lookups sent at once. */
|
|
1297
1355
|
const GRANT_LOOKUP_CONCURRENCY = 8;
|
|
1356
|
+
/** A one-machine grant lookup that takes longer falls back to Check grant. */
|
|
1357
|
+
const OWN_MACHINE_GRANT_LOOKUP_TIMEOUT_MS = 15e3;
|
|
1358
|
+
/**
|
|
1359
|
+
* Runs a one-machine grant lookup with its own signal, given up at the
|
|
1360
|
+
* deadline or when `parent` aborts. The signal stops the request, so a
|
|
1361
|
+
* stalled one never outlives its slot; the race also covers the host's token
|
|
1362
|
+
* getters, which run before the request and do not see the signal.
|
|
1363
|
+
*/
|
|
1364
|
+
async function withLookupDeadline(run, parent) {
|
|
1365
|
+
const own = new AbortController();
|
|
1366
|
+
const stop = () => own.abort();
|
|
1367
|
+
parent?.addEventListener("abort", stop, { once: true });
|
|
1368
|
+
const timer = setTimeout(stop, OWN_MACHINE_GRANT_LOOKUP_TIMEOUT_MS);
|
|
1369
|
+
const deadline = new Promise((_, reject) => {
|
|
1370
|
+
own.signal.addEventListener("abort", () => reject(/* @__PURE__ */ new Error("The grant check took too long. Try Check grant again in a moment.")), { once: true });
|
|
1371
|
+
});
|
|
1372
|
+
deadline.catch(() => void 0);
|
|
1373
|
+
try {
|
|
1374
|
+
return await Promise.race([run(own.signal), deadline]);
|
|
1375
|
+
} finally {
|
|
1376
|
+
clearTimeout(timer);
|
|
1377
|
+
parent?.removeEventListener("abort", stop);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1298
1380
|
/**
|
|
1299
1381
|
* Every VibeControls machine the viewer can see in the workspace, page by
|
|
1300
1382
|
* page, and the steward's live grants. The agents query has no owner filter,
|
|
@@ -1305,7 +1387,7 @@ const GRANT_LOOKUP_CONCURRENCY = 8;
|
|
|
1305
1387
|
* by gateway, workspace, steward and owner, so another scope's machines and
|
|
1306
1388
|
* grants are never shown or acted on; a superseded load is aborted.
|
|
1307
1389
|
*/
|
|
1308
|
-
function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
1390
|
+
function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled, lookupViewerMachines) {
|
|
1309
1391
|
const { client, config: { gatewayUrl, workspaceId } } = useStewardsSdk();
|
|
1310
1392
|
const scope = JSON.stringify([
|
|
1311
1393
|
gatewayUrl,
|
|
@@ -1327,10 +1409,11 @@ function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
|
1327
1409
|
useEffect(() => {
|
|
1328
1410
|
if (!enabled) return void 0;
|
|
1329
1411
|
const controller = new AbortController();
|
|
1330
|
-
const grantsOf = async (agentId) => (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
1412
|
+
const grantsOf = async (agentId, signal = controller.signal) => (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
1331
1413
|
stewardId,
|
|
1332
1414
|
...agentId ? { agentId } : {}
|
|
1333
|
-
},
|
|
1415
|
+
}, signal)).vibecontrolsStewardGrants;
|
|
1416
|
+
const grantsWithDeadline = (agentId) => withLookupDeadline((signal) => grantsOf(agentId, signal), controller.signal);
|
|
1334
1417
|
const load = async () => {
|
|
1335
1418
|
const agents = [];
|
|
1336
1419
|
let truncated = true;
|
|
@@ -1346,14 +1429,11 @@ function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
|
1346
1429
|
}
|
|
1347
1430
|
}
|
|
1348
1431
|
const grants = [...await grantsOf()];
|
|
1349
|
-
const
|
|
1350
|
-
const
|
|
1351
|
-
const missing = agents.filter((a) => a.ownerUserId === ownerActorId && !live.has(a.id)).map((a) => a.id);
|
|
1352
|
-
const checked = missing.slice(0, 50);
|
|
1353
|
-
const unchecked = new Set(missing.slice(50));
|
|
1432
|
+
const { lookup: checked, later, unchecked: skipped } = ownMachineGrantLookups(agents, grants, ownerActorId, lookupViewerMachines ? viewerActorId ?? null : null);
|
|
1433
|
+
const unchecked = new Set(skipped);
|
|
1354
1434
|
for (let i = 0; i < checked.length; i += GRANT_LOOKUP_CONCURRENCY) {
|
|
1355
1435
|
const ids = checked.slice(i, i + GRANT_LOOKUP_CONCURRENCY);
|
|
1356
|
-
const batch = await Promise.allSettled(ids.map((id) =>
|
|
1436
|
+
const batch = await Promise.allSettled(ids.map((id) => grantsWithDeadline(id)));
|
|
1357
1437
|
if (controller.signal.aborted) break;
|
|
1358
1438
|
batch.forEach((result, n) => {
|
|
1359
1439
|
if (result.status === "fulfilled") grants.push(...result.value);
|
|
@@ -1364,10 +1444,32 @@ function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
|
1364
1444
|
agents,
|
|
1365
1445
|
grants,
|
|
1366
1446
|
truncated,
|
|
1367
|
-
unchecked
|
|
1447
|
+
unchecked,
|
|
1448
|
+
later
|
|
1449
|
+
};
|
|
1450
|
+
};
|
|
1451
|
+
const applyLater = (found, failed) => setState((prev) => prev && prev.scope === scope ? {
|
|
1452
|
+
...prev,
|
|
1453
|
+
grants: [...prev.grants ?? [], ...found],
|
|
1454
|
+
unchecked: /* @__PURE__ */ new Set([...prev.unchecked, ...failed]),
|
|
1455
|
+
pending: Math.max(prev.pending - 1, 0)
|
|
1456
|
+
} : prev);
|
|
1457
|
+
const lookUpOneLater = async (agentId) => {
|
|
1458
|
+
try {
|
|
1459
|
+
const found = await grantsWithDeadline(agentId);
|
|
1460
|
+
if (!controller.signal.aborted) applyLater(found, []);
|
|
1461
|
+
} catch {
|
|
1462
|
+
if (!controller.signal.aborted) applyLater([], [agentId]);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
const lookUpLater = async (later) => {
|
|
1466
|
+
const queue = [...later];
|
|
1467
|
+
const worker = async () => {
|
|
1468
|
+
for (let next = queue.shift(); next !== void 0 && !controller.signal.aborted; next = queue.shift()) await lookUpOneLater(next);
|
|
1368
1469
|
};
|
|
1470
|
+
await Promise.all(Array.from({ length: Math.min(GRANT_LOOKUP_CONCURRENCY, queue.length) }, worker));
|
|
1369
1471
|
};
|
|
1370
|
-
load().then(({ agents, grants, truncated, unchecked }) => {
|
|
1472
|
+
load().then(({ agents, grants, truncated, unchecked, later }) => {
|
|
1371
1473
|
if (controller.signal.aborted) return;
|
|
1372
1474
|
setState({
|
|
1373
1475
|
scope,
|
|
@@ -1376,8 +1478,10 @@ function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
|
1376
1478
|
error: void 0,
|
|
1377
1479
|
loading: false,
|
|
1378
1480
|
truncated,
|
|
1379
|
-
unchecked
|
|
1481
|
+
unchecked,
|
|
1482
|
+
pending: later.length
|
|
1380
1483
|
});
|
|
1484
|
+
lookUpLater(later);
|
|
1381
1485
|
}, (err) => {
|
|
1382
1486
|
if (controller.signal.aborted) return;
|
|
1383
1487
|
setState({
|
|
@@ -1392,14 +1496,16 @@ function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
|
1392
1496
|
scope,
|
|
1393
1497
|
stewardId,
|
|
1394
1498
|
ownerActorId,
|
|
1499
|
+
viewerActorId,
|
|
1395
1500
|
enabled,
|
|
1501
|
+
lookupViewerMachines,
|
|
1396
1502
|
nonce
|
|
1397
1503
|
]);
|
|
1398
1504
|
const checkAgent = useCallback(async (agentId) => {
|
|
1399
|
-
const found = (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
1505
|
+
const found = await withLookupDeadline(async (signal) => (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
1400
1506
|
stewardId,
|
|
1401
1507
|
agentId
|
|
1402
|
-
})).vibecontrolsStewardGrants;
|
|
1508
|
+
}, signal)).vibecontrolsStewardGrants);
|
|
1403
1509
|
setState((prev) => {
|
|
1404
1510
|
if (!prev || prev.scope !== scope) return prev;
|
|
1405
1511
|
const unchecked = new Set(prev.unchecked);
|
|
@@ -1461,7 +1567,7 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
1461
1567
|
const abilities = ownMachineAbilities(ownerActorId, access);
|
|
1462
1568
|
const { client, config } = useStewardsSdk();
|
|
1463
1569
|
const desk = useStewardsQuery(GET_STEWARD_OWN_MACHINE_DESK, { stewardId });
|
|
1464
|
-
const machines = useOwnMachineData(stewardId, ownerActorId, access?.viewerActorId, abilities.read);
|
|
1570
|
+
const machines = useOwnMachineData(stewardId, ownerActorId, access?.viewerActorId, abilities.read, access?.canGrantMachines !== false);
|
|
1465
1571
|
const choose = useStewardsMutation(SET_STEWARD_OWN_MACHINE_DESK);
|
|
1466
1572
|
const clear = useStewardsMutation(CLEAR_STEWARD_OWN_MACHINE_DESK);
|
|
1467
1573
|
const grant = useStewardsMutation(GRANT_OWN_MACHINE);
|
|
@@ -1504,7 +1610,7 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
1504
1610
|
}, [refresh]);
|
|
1505
1611
|
const current = desk.data?.botmanorStewardOwnMachineDesk ?? null;
|
|
1506
1612
|
const grants = machines.grants ?? [];
|
|
1507
|
-
const rows = ownMachineRows(machines.agents ?? [], grants, ownerActorId, current?.agentId ?? null);
|
|
1613
|
+
const rows = ownMachineRows(machines.agents ?? [], grants, ownerActorId, current?.agentId ?? null, void 0, machines.unchecked);
|
|
1508
1614
|
const [expiryTick, setExpiryTick] = useState(0);
|
|
1509
1615
|
const nextExpiry = nextOwnMachineGrantExpiry(grants);
|
|
1510
1616
|
useEffect(() => {
|
|
@@ -1633,6 +1739,8 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
1633
1739
|
}) : null,
|
|
1634
1740
|
abilities.read ? /* @__PURE__ */ jsx(MachineList, {
|
|
1635
1741
|
loading: !listed && machines.loading,
|
|
1742
|
+
pending: machines.pending > 0,
|
|
1743
|
+
ownerView: !access?.viewerActorId || access.viewerActorId === ownerActorId,
|
|
1636
1744
|
listed,
|
|
1637
1745
|
truncated: machines.truncated,
|
|
1638
1746
|
error: machines.error,
|
|
@@ -1642,6 +1750,8 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
1642
1750
|
busy,
|
|
1643
1751
|
canChoose: abilities.manage,
|
|
1644
1752
|
canGrant: abilities.grant,
|
|
1753
|
+
canCheck: abilities.grant || abilities.manage || access?.canGrantMachines !== false,
|
|
1754
|
+
canRevoke: (agent) => ownMachineCanRevoke(agent.ownerUserId, grants.find((g) => g.agentId === agent.id && isLive(g, Date.now()))?.grantorActorId, access),
|
|
1645
1755
|
onCheck: (agentId) => void onCheck(agentId),
|
|
1646
1756
|
onChoose: (agentId) => void onChoose(agentId),
|
|
1647
1757
|
onGrant: (agentId) => void onGrant(agentId),
|
|
@@ -1736,11 +1846,12 @@ function CurrentMachine({ loading, loaded, error, current, name, canClear, busy,
|
|
|
1736
1846
|
] });
|
|
1737
1847
|
}
|
|
1738
1848
|
/** The owner's machines, each with its grant and what the viewer may do. */
|
|
1739
|
-
function MachineList({ loading, listed, truncated, error, rows, ...actions }) {
|
|
1849
|
+
function MachineList({ loading, pending, ownerView, listed, truncated, error, rows, ...actions }) {
|
|
1740
1850
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1741
1851
|
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading your machines…" }) : null,
|
|
1742
1852
|
/* @__PURE__ */ jsx(GuidedErrorNote, { error }),
|
|
1743
|
-
|
|
1853
|
+
pending ? /* @__PURE__ */ jsx(Muted, { children: "Checking your machines for grants to this steward…" }) : null,
|
|
1854
|
+
listed && !pending && rows.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: ownerView ? "You have no VibeControls machines in this workspace." : "No machines to show: none of the steward owner's machines are listed here, and no grant to this steward was found on yours." }) : null,
|
|
1744
1855
|
truncated ? /* @__PURE__ */ jsx(Muted, { children: "Only the first machines in this workspace are listed." }) : null,
|
|
1745
1856
|
rows.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
1746
1857
|
style: listStyle,
|
|
@@ -1752,22 +1863,26 @@ function MachineList({ loading, listed, truncated, error, rows, ...actions }) {
|
|
|
1752
1863
|
}) : null
|
|
1753
1864
|
] });
|
|
1754
1865
|
}
|
|
1755
|
-
function MachineRow({ row: { agent, granted, chosen }, unchecked, ownerActorId, onCheck, busy, canChoose, canGrant, onChoose, onGrant, onRevoke }) {
|
|
1866
|
+
function MachineRow({ row: { agent, granted, chosen, revokeOnly, unlisted }, unchecked, ownerActorId, onCheck, busy, canChoose, canGrant, canCheck, canRevoke, onChoose, onGrant, onRevoke }) {
|
|
1756
1867
|
const unknown = !granted && unchecked.has(agent.id);
|
|
1757
1868
|
return /* @__PURE__ */ jsxs("li", {
|
|
1758
1869
|
style: rowStyle,
|
|
1759
1870
|
children: [
|
|
1760
1871
|
/* @__PURE__ */ jsx("strong", { children: agent.name }),
|
|
1761
1872
|
" ",
|
|
1762
|
-
/* @__PURE__ */
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1873
|
+
unlisted ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1874
|
+
/* @__PURE__ */ jsx(Muted, { children: agent.hostname }),
|
|
1875
|
+
" ",
|
|
1876
|
+
/* @__PURE__ */ jsx(Badge, { children: agent.isActive ? "Active" : "Inactive" }),
|
|
1877
|
+
" "
|
|
1878
|
+
] }),
|
|
1766
1879
|
/* @__PURE__ */ jsx(Badge, { children: granted ? "Granted" : unknown ? "Grant not checked" : "Not granted" }),
|
|
1767
1880
|
" ",
|
|
1768
1881
|
chosen ? /* @__PURE__ */ jsx(Badge, { children: "Chosen" }) : null,
|
|
1769
1882
|
" ",
|
|
1770
|
-
|
|
1883
|
+
revokeOnly && !unlisted ? /* @__PURE__ */ jsx(Badge, { children: "Not the steward owner's machine" }) : null,
|
|
1884
|
+
" ",
|
|
1885
|
+
canCheck && unknown ? /* @__PURE__ */ jsx(Button, {
|
|
1771
1886
|
onClick: () => onCheck(agent.id),
|
|
1772
1887
|
disabled: busy,
|
|
1773
1888
|
label: `Check the grant on ${agent.name}`,
|
|
@@ -1781,7 +1896,7 @@ function MachineRow({ row: { agent, granted, chosen }, unchecked, ownerActorId,
|
|
|
1781
1896
|
children: "Grant to this steward"
|
|
1782
1897
|
}) : null,
|
|
1783
1898
|
" ",
|
|
1784
|
-
canChoose && granted && !chosen ? /* @__PURE__ */ jsx(Button, {
|
|
1899
|
+
canChoose && granted && !chosen && !revokeOnly ? /* @__PURE__ */ jsx(Button, {
|
|
1785
1900
|
kind: "primary",
|
|
1786
1901
|
onClick: () => onChoose(agent.id),
|
|
1787
1902
|
disabled: busy,
|
|
@@ -1789,7 +1904,7 @@ function MachineRow({ row: { agent, granted, chosen }, unchecked, ownerActorId,
|
|
|
1789
1904
|
children: "Use this machine"
|
|
1790
1905
|
}) : null,
|
|
1791
1906
|
" ",
|
|
1792
|
-
|
|
1907
|
+
granted && canRevoke(agent) ? /* @__PURE__ */ jsx(Button, {
|
|
1793
1908
|
onClick: () => onRevoke(agent.id),
|
|
1794
1909
|
disabled: busy,
|
|
1795
1910
|
label: `Revoke the grant on ${agent.name}`,
|
|
@@ -3026,4 +3141,4 @@ function ApprovalInbox({ stewardId, pollIntervalMs = 15e3 }) {
|
|
|
3026
3141
|
});
|
|
3027
3142
|
}
|
|
3028
3143
|
|
|
3029
|
-
export { AGENT_STATUS_LABELS, AGENT_STATUS_SHORT_LABELS, ApprovalInbox, DEFAULT_BOTMANOR_APP_URL, DEFAULT_STEWARDS_THEME, DEFAULT_VIBECONTROLS_URL, GUIDED_ENTRIES, GUIDED_PERMISSIONS, GuidedErrorNote, OWN_MACHINE_GRANT_DAYS, OWN_MACHINE_MAX_PAGES, OWN_MACHINE_PAGE_SIZE, PERMISSION_LABELS, STOP_REASON_LABELS, StewardBuilder, StewardConsole, StewardOwnMachineDesk, StewardOwnMachineDeskPanel, StewardRunView, StewardsRequestError, StewardsSdkProvider, agentPickerLabel, botmanorPath, buildGuidedError, cloudDeskAvailability, createStewardsEventBus, crossShellUrl, describeGuidedError, describeRunFailure, englishGuidedTranslate, extractGuidedSource, fillGuidedParams, guidedI18nBase, guidedParams, guidedText, guidedTranslateFrom, isDefiniteRefusal, isStaleStateError, nextOwnMachineGrantExpiry, ownMachineAbilities, ownMachineAllowedApps, ownMachineAppCount, ownMachineGrantExpiry, ownMachineRows, permissionLabelKey, pickableAgents, planGuidedActions, reasonCamel, resolveGuidedLocation, stepReasonCode, stopReasonLabel, themeToStyle, useStewardsEvent, useStewardsSdk };
|
|
3144
|
+
export { AGENT_STATUS_LABELS, AGENT_STATUS_SHORT_LABELS, ApprovalInbox, DEFAULT_BOTMANOR_APP_URL, DEFAULT_STEWARDS_THEME, DEFAULT_VIBECONTROLS_URL, GUIDED_ENTRIES, GUIDED_PERMISSIONS, GuidedErrorNote, OWN_MACHINE_GRANT_DAYS, OWN_MACHINE_GRANT_LOOKUPS, OWN_MACHINE_MAX_PAGES, OWN_MACHINE_PAGE_SIZE, PERMISSION_LABELS, STOP_REASON_LABELS, StewardBuilder, StewardConsole, StewardOwnMachineDesk, StewardOwnMachineDeskPanel, StewardRunView, StewardsRequestError, StewardsSdkProvider, agentPickerLabel, botmanorPath, buildGuidedError, cloudDeskAvailability, createStewardsEventBus, crossShellUrl, describeGuidedError, describeRunFailure, englishGuidedTranslate, extractGuidedSource, fillGuidedParams, guidedI18nBase, guidedParams, guidedText, guidedTranslateFrom, isDefiniteRefusal, isStaleStateError, nextOwnMachineGrantExpiry, ownMachineAbilities, ownMachineAllowedApps, ownMachineAppCount, ownMachineCanRevoke, ownMachineGrantExpiry, ownMachineGrantLookups, ownMachineRows, permissionLabelKey, pickableAgents, planGuidedActions, reasonCamel, resolveGuidedLocation, stepReasonCode, stopReasonLabel, themeToStyle, useStewardsEvent, useStewardsSdk };
|