@botmanor/fe-sdk 2026.1205.1 → 2026.1205.2
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 +98 -53
- package/dist/index.js +430 -89
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -165,49 +165,6 @@ export declare function StewardsSdkProvider({ children, ...config }: StewardsSdk
|
|
|
165
165
|
export declare function useStewardsSdk(): StewardsSdkContextValue;
|
|
166
166
|
/** Subscribe to one SDK event for the lifetime of the calling component. */
|
|
167
167
|
export declare function useStewardsEvent<K extends StewardsEventType>(type: K, handler: (payload: StewardsEventMap[K]) => void): void;
|
|
168
|
-
interface StewardConsoleProps {
|
|
169
|
-
/**
|
|
170
|
-
* The steward to show. Omitted lists the workspace's stewards and lets the
|
|
171
|
-
* viewer open one (the host can follow along through `onSelectSteward`).
|
|
172
|
-
*/
|
|
173
|
-
stewardId?: string;
|
|
174
|
-
onSelectSteward?: (stewardId: string) => void;
|
|
175
|
-
/**
|
|
176
|
-
* Link to VibeControls, where a machine's owner grants it to a steward
|
|
177
|
-
* (shown for a steward whose desk kind is OWN_MACHINE).
|
|
178
|
-
*/
|
|
179
|
-
vibecontrolsUrl?: string;
|
|
180
|
-
}
|
|
181
|
-
/** List stewards, or open one: its charter summary, start a run, recent runs. */
|
|
182
|
-
export declare function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl }: StewardConsoleProps): import("react").JSX.Element;
|
|
183
|
-
interface StewardBuilderProps {
|
|
184
|
-
/** Start from an existing agent; omitted shows the agent picker. */
|
|
185
|
-
agentId?: string;
|
|
186
|
-
/** Edit the charter of this steward instead of creating one. */
|
|
187
|
-
stewardId?: string;
|
|
188
|
-
/** Called with the new steward's id once it is created. */
|
|
189
|
-
onCreated?: (stewardId: string) => void;
|
|
190
|
-
/** Called with the steward's id once its charter is saved. */
|
|
191
|
-
onSaved?: (stewardId: string) => void;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Create a steward from an agent and a charter, or edit an existing charter:
|
|
195
|
-
* the charter text, the autonomy level and a daily credit budget. Duties and
|
|
196
|
-
* playbooks live in the full Stewards app.
|
|
197
|
-
*/
|
|
198
|
-
export declare function StewardBuilder(props: StewardBuilderProps): import("react").JSX.Element;
|
|
199
|
-
interface StewardRunViewProps {
|
|
200
|
-
/** The run to show. */
|
|
201
|
-
runId: string;
|
|
202
|
-
/** Poll interval while the run is active. Defaults to 3000 ms. */
|
|
203
|
-
pollIntervalMs?: number;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* One run: its steps, approvals, trust level and budget. Polls the gateway
|
|
207
|
-
* while the run is active (the embed session is not a subscription actor) and
|
|
208
|
-
* emits `run.waiting`, `run.completed` and `run.failed` as the status changes.
|
|
209
|
-
*/
|
|
210
|
-
export declare function StewardRunView({ runId, pollIntervalMs }: StewardRunViewProps): import("react").JSX.Element;
|
|
211
168
|
/**
|
|
212
169
|
* The slice of the workspace gateway schema the SDK reads and writes. Names
|
|
213
170
|
* follow the `Botmanor*` types of the Hive production supergraph (the same
|
|
@@ -372,18 +329,39 @@ interface OwnMachineGrant {
|
|
|
372
329
|
expiresAt: string;
|
|
373
330
|
scopes: string[];
|
|
374
331
|
}
|
|
375
|
-
/** Where the person
|
|
332
|
+
/** Where the person manages their VibeControls machines, by default. */
|
|
376
333
|
export declare const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
377
334
|
/** Machines per page when listing the workspace's VibeControls machines. */
|
|
378
335
|
export declare const OWN_MACHINE_PAGE_SIZE = 100;
|
|
379
336
|
/** Pages read at most (10 000 machines); the list says when it stopped early. */
|
|
380
337
|
export declare const OWN_MACHINE_MAX_PAGES = 100;
|
|
338
|
+
/** The grant lengths the owner can pick, in days. */
|
|
339
|
+
export declare const OWN_MACHINE_GRANT_DAYS: readonly [1, 7, 30];
|
|
340
|
+
type OwnMachineGrantDays = (typeof OWN_MACHINE_GRANT_DAYS)[number];
|
|
341
|
+
/**
|
|
342
|
+
* What the host knows about the viewer, so the picker offers only what the
|
|
343
|
+
* gateway would allow. Every field is optional: an omitted one is not checked
|
|
344
|
+
* here and the gateway decides (an embed without permission data keeps
|
|
345
|
+
* working). The gateway stays the enforcement point either way.
|
|
346
|
+
*/
|
|
347
|
+
interface OwnMachineAccess {
|
|
348
|
+
/** The signed-in person. Choosing, clearing and granting are the steward owner's only. */
|
|
349
|
+
viewerActorId?: string | null;
|
|
350
|
+
/** botmanor-steward:update, on a steward that is not archived. */
|
|
351
|
+
canUpdateSteward?: boolean;
|
|
352
|
+
/** agent:read: list the workspace's machines and the steward's grants. */
|
|
353
|
+
canReadMachines?: boolean;
|
|
354
|
+
/** agent:update: grant a machine to the steward, or revoke the grant. */
|
|
355
|
+
canGrantMachines?: boolean;
|
|
356
|
+
}
|
|
381
357
|
interface StewardOwnMachineDeskProps {
|
|
382
358
|
stewardId: string;
|
|
383
359
|
/** The steward's owner: only their machines are offered. */
|
|
384
360
|
ownerActorId: string;
|
|
385
|
-
/** Link to VibeControls, where a
|
|
361
|
+
/** Link to VibeControls, where a person manages their machines. Pass the current environment's app. */
|
|
386
362
|
vibecontrolsUrl?: string;
|
|
363
|
+
/** What the viewer may do; see {@link OwnMachineAccess}. */
|
|
364
|
+
access?: OwnMachineAccess;
|
|
387
365
|
/** Called after the machine is chosen or cleared. */
|
|
388
366
|
onChanged?: (desk: StewardOwnMachineDesk$1 | null) => void;
|
|
389
367
|
}
|
|
@@ -400,6 +378,23 @@ interface OwnMachineRow {
|
|
|
400
378
|
* past its expiry (`now`, for tests).
|
|
401
379
|
*/
|
|
402
380
|
export declare function ownMachineRows(agents: readonly OwnMachineCandidate[], grants: readonly OwnMachineGrant[], ownerActorId: string, chosenAgentId: string | null, now?: number): OwnMachineRow[];
|
|
381
|
+
/** The expiry to send for a grant of `days`, never past the service's 30-day limit. */
|
|
382
|
+
export declare function ownMachineGrantExpiry(days: OwnMachineGrantDays, now?: number): string;
|
|
383
|
+
/**
|
|
384
|
+
* The app names to send on a grant: one per line, trimmed, lower-cased
|
|
385
|
+
* (VibeControls compares lower-case names), de-duplicated and capped at 64.
|
|
386
|
+
*/
|
|
387
|
+
export declare function ownMachineAllowedApps(text: string): string[];
|
|
388
|
+
/** How many distinct app names the text holds, before the 64-name cap. */
|
|
389
|
+
export declare function ownMachineAppCount(text: string): number;
|
|
390
|
+
/** When the earliest live grant expires (epoch ms), or null. */
|
|
391
|
+
export declare function nextOwnMachineGrantExpiry(grants: readonly OwnMachineGrant[], now?: number): number | null;
|
|
392
|
+
/** What the viewer may do with the picker, from {@link OwnMachineAccess}. */
|
|
393
|
+
export declare function ownMachineAbilities(ownerActorId: string, access?: OwnMachineAccess): {
|
|
394
|
+
manage: boolean;
|
|
395
|
+
read: boolean;
|
|
396
|
+
grant: boolean;
|
|
397
|
+
};
|
|
403
398
|
/**
|
|
404
399
|
* The desk settings of a steward whose desk kind is OWN_MACHINE, inside the
|
|
405
400
|
* SDK's themed wrapper: use it on its own. `StewardConsole` renders
|
|
@@ -408,14 +403,64 @@ export declare function ownMachineRows(agents: readonly OwnMachineCandidate[], g
|
|
|
408
403
|
export declare function StewardOwnMachineDesk(props: StewardOwnMachineDeskProps): import("react").JSX.Element;
|
|
409
404
|
/**
|
|
410
405
|
* The owner's VibeControls machines, which ones have granted this steward,
|
|
411
|
-
* and the one it works on.
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
406
|
+
* and the one it works on. The owner can grant a machine to the steward
|
|
407
|
+
* (`grantVibecontrolsAgentToSteward`), revoke the grant, choose a granted
|
|
408
|
+
* machine (`setBotmanorStewardOwnMachineDesk`) or clear the choice
|
|
409
|
+
* (`clearBotmanorStewardOwnMachineDesk`). Controls follow `access`; the
|
|
410
|
+
* service's refusals (no grant, machine in use, changed concurrently, check
|
|
411
|
+
* unavailable) are shown with the service's own message. Refresh and the tab
|
|
412
|
+
* regaining focus reload the desk, the machines and the grants, and a row
|
|
413
|
+
* re-renders when its grant expires. The gateway stays the enforcement point.
|
|
417
414
|
*/
|
|
418
|
-
export declare function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl, onChanged }: StewardOwnMachineDeskProps): import("react").JSX.Element;
|
|
415
|
+
export declare function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl, access, onChanged }: StewardOwnMachineDeskProps): import("react").JSX.Element;
|
|
416
|
+
interface StewardConsoleProps {
|
|
417
|
+
/**
|
|
418
|
+
* The steward to show. Omitted lists the workspace's stewards and lets the
|
|
419
|
+
* viewer open one (the host can follow along through `onSelectSteward`).
|
|
420
|
+
*/
|
|
421
|
+
stewardId?: string;
|
|
422
|
+
onSelectSteward?: (stewardId: string) => void;
|
|
423
|
+
/**
|
|
424
|
+
* Link to VibeControls, where a machine's owner grants it to a steward
|
|
425
|
+
* (shown for a steward whose desk kind is OWN_MACHINE).
|
|
426
|
+
*/
|
|
427
|
+
vibecontrolsUrl?: string;
|
|
428
|
+
/**
|
|
429
|
+
* What the viewer may do with an own-machine steward's machine (ownership
|
|
430
|
+
* and permissions). Omitted fields are left to the gateway.
|
|
431
|
+
*/
|
|
432
|
+
ownMachineAccess?: OwnMachineAccess;
|
|
433
|
+
}
|
|
434
|
+
/** List stewards, or open one: its charter summary, start a run, recent runs. */
|
|
435
|
+
export declare function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl, ownMachineAccess }: StewardConsoleProps): import("react").JSX.Element;
|
|
436
|
+
interface StewardBuilderProps {
|
|
437
|
+
/** Start from an existing agent; omitted shows the agent picker. */
|
|
438
|
+
agentId?: string;
|
|
439
|
+
/** Edit the charter of this steward instead of creating one. */
|
|
440
|
+
stewardId?: string;
|
|
441
|
+
/** Called with the new steward's id once it is created. */
|
|
442
|
+
onCreated?: (stewardId: string) => void;
|
|
443
|
+
/** Called with the steward's id once its charter is saved. */
|
|
444
|
+
onSaved?: (stewardId: string) => void;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Create a steward from an agent and a charter, or edit an existing charter:
|
|
448
|
+
* the charter text, the autonomy level and a daily credit budget. Duties and
|
|
449
|
+
* playbooks live in the full Stewards app.
|
|
450
|
+
*/
|
|
451
|
+
export declare function StewardBuilder(props: StewardBuilderProps): import("react").JSX.Element;
|
|
452
|
+
interface StewardRunViewProps {
|
|
453
|
+
/** The run to show. */
|
|
454
|
+
runId: string;
|
|
455
|
+
/** Poll interval while the run is active. Defaults to 3000 ms. */
|
|
456
|
+
pollIntervalMs?: number;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* One run: its steps, approvals, trust level and budget. Polls the gateway
|
|
460
|
+
* while the run is active (the embed session is not a subscription actor) and
|
|
461
|
+
* emits `run.waiting`, `run.completed` and `run.failed` as the status changes.
|
|
462
|
+
*/
|
|
463
|
+
export declare function StewardRunView({ runId, pollIntervalMs }: StewardRunViewProps): import("react").JSX.Element;
|
|
419
464
|
interface ApprovalInboxProps {
|
|
420
465
|
/** Limit to one steward; omitted shows every steward approval the viewer can decide. */
|
|
421
466
|
stewardId?: string;
|
|
@@ -428,4 +473,4 @@ interface ApprovalInboxProps {
|
|
|
428
473
|
* `mine: true`) rather than a parallel one.
|
|
429
474
|
*/
|
|
430
475
|
export declare function ApprovalInbox({ stewardId, pollIntervalMs }: ApprovalInboxProps): import("react").JSX.Element;
|
|
431
|
-
export type { ApprovalInboxProps, OwnMachineCandidate, OwnMachineGrant, OwnMachineRow, StewardApprovalRequest, StewardBuilderProps, StewardConsoleProps, StewardDetail, StewardListItem, StewardOwnMachineDeskProps, StewardOwnMachineDesk$1 as StewardOwnMachineDeskRecord, StewardRunDetail, StewardRunSummary, StewardRunViewProps, StewardsClient, StewardsEvent, StewardsEventBus, StewardsEventMap, StewardsEventType, StewardsSdkConfig, StewardsSdkContextValue, StewardsTheme };
|
|
476
|
+
export type { ApprovalInboxProps, OwnMachineAccess, OwnMachineCandidate, OwnMachineGrant, OwnMachineGrantDays, OwnMachineRow, StewardApprovalRequest, StewardBuilderProps, StewardConsoleProps, StewardDetail, StewardListItem, StewardOwnMachineDeskProps, StewardOwnMachineDesk$1 as StewardOwnMachineDeskRecord, StewardRunDetail, StewardRunSummary, StewardRunViewProps, StewardsClient, StewardsEvent, StewardsEventBus, StewardsEventMap, StewardsEventType, StewardsSdkConfig, StewardsSdkContextValue, StewardsTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext, use, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { createContext, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
// src/graphql/client.ts
|
|
@@ -407,11 +407,20 @@ const LIST_OWN_MACHINE_AGENTS = `query StewardOwnMachineAgents($pagination: Pagi
|
|
|
407
407
|
id name hostname platform isActive ownerUserId lastHeartbeat
|
|
408
408
|
}
|
|
409
409
|
}`;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
410
|
+
const OWN_MACHINE_GRANT = `id agentId status expiresAt scopes`;
|
|
411
|
+
/**
|
|
412
|
+
* The steward's active grants (VibeControls returns at most 100, newest
|
|
413
|
+
* first). Pass `agentId` to look one machine up when the list may be cut off.
|
|
414
|
+
*/
|
|
415
|
+
const LIST_OWN_MACHINE_GRANTS = `query StewardOwnMachineGrants($stewardId: ID!, $agentId: ID) {
|
|
416
|
+
vibecontrolsStewardGrants(filter: { stewardId: $stewardId, agentId: $agentId }) { ${OWN_MACHINE_GRANT} }
|
|
417
|
+
}`;
|
|
418
|
+
/** Only the machine's owner can grant it; granting again extends the same grant. */
|
|
419
|
+
const GRANT_OWN_MACHINE = `mutation GrantStewardOwnMachine($input: GrantVibecontrolsAgentToStewardInput!) {
|
|
420
|
+
grantVibecontrolsAgentToSteward(input: $input) { ${OWN_MACHINE_GRANT} }
|
|
421
|
+
}`;
|
|
422
|
+
const REVOKE_OWN_MACHINE_GRANT = `mutation RevokeStewardOwnMachineGrant($id: ID!) {
|
|
423
|
+
revokeVibecontrolsStewardGrant(id: $id) { ${OWN_MACHINE_GRANT} }
|
|
415
424
|
}`;
|
|
416
425
|
|
|
417
426
|
// src/graphql/hooks.ts
|
|
@@ -679,19 +688,34 @@ function humanize(value) {
|
|
|
679
688
|
}
|
|
680
689
|
|
|
681
690
|
// src/components/StewardOwnMachineDesk.tsx
|
|
682
|
-
/** Where the person
|
|
691
|
+
/** Where the person manages their VibeControls machines, by default. */
|
|
683
692
|
const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
684
693
|
/** Machines per page when listing the workspace's VibeControls machines. */
|
|
685
694
|
const OWN_MACHINE_PAGE_SIZE = 100;
|
|
686
695
|
/** Pages read at most (10 000 machines); the list says when it stopped early. */
|
|
687
696
|
const OWN_MACHINE_MAX_PAGES = 100;
|
|
697
|
+
/** The owner's machines looked up one by one when the grant list may miss them. */
|
|
698
|
+
const OWN_MACHINE_GRANT_LOOKUPS = 50;
|
|
699
|
+
/** The grant lengths the owner can pick, in days. */
|
|
700
|
+
const OWN_MACHINE_GRANT_DAYS = [
|
|
701
|
+
1,
|
|
702
|
+
7,
|
|
703
|
+
30
|
|
704
|
+
];
|
|
705
|
+
/** VibeControls accepts at most this many app names on a grant. */
|
|
706
|
+
const OWN_MACHINE_MAX_APPS = 64;
|
|
707
|
+
const DAY_MS = 864e5;
|
|
708
|
+
/** A grant counts while it is ACTIVE and not past its expiry. */
|
|
709
|
+
function isLive(grant, now) {
|
|
710
|
+
return grant.status === "ACTIVE" && new Date(grant.expiresAt).getTime() > now;
|
|
711
|
+
}
|
|
688
712
|
/**
|
|
689
713
|
* The owner's machines for the picker: the owner's agents, chosen one first,
|
|
690
714
|
* then granted ones, then by name. A grant counts while it is ACTIVE and not
|
|
691
715
|
* past its expiry (`now`, for tests).
|
|
692
716
|
*/
|
|
693
717
|
function ownMachineRows(agents, grants, ownerActorId, chosenAgentId, now = Date.now()) {
|
|
694
|
-
const granted = new Set(grants.filter((g) =>
|
|
718
|
+
const granted = new Set(grants.filter((g) => isLive(g, now)).map((g) => g.agentId));
|
|
695
719
|
const rank = (row) => row.chosen ? 0 : row.granted ? 1 : 2;
|
|
696
720
|
return agents.filter((a) => a.ownerUserId === ownerActorId || a.id === chosenAgentId).map((agent) => ({
|
|
697
721
|
agent,
|
|
@@ -699,62 +723,191 @@ function ownMachineRows(agents, grants, ownerActorId, chosenAgentId, now = Date.
|
|
|
699
723
|
chosen: agent.id === chosenAgentId
|
|
700
724
|
})).sort((a, b) => rank(a) - rank(b) || a.agent.name.localeCompare(b.agent.name));
|
|
701
725
|
}
|
|
726
|
+
/** The expiry to send for a grant of `days`, never past the service's 30-day limit. */
|
|
727
|
+
function ownMachineGrantExpiry(days, now = Date.now()) {
|
|
728
|
+
return new Date(now + Math.min(days * DAY_MS, 25917e5)).toISOString();
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* The app names to send on a grant: one per line, trimmed, lower-cased
|
|
732
|
+
* (VibeControls compares lower-case names), de-duplicated and capped at 64.
|
|
733
|
+
*/
|
|
734
|
+
function ownMachineAllowedApps(text) {
|
|
735
|
+
const seen = /* @__PURE__ */ new Set();
|
|
736
|
+
for (const line of text.split(/\r?\n/)) {
|
|
737
|
+
const name = line.trim().toLowerCase();
|
|
738
|
+
if (name) seen.add(name);
|
|
739
|
+
}
|
|
740
|
+
return [...seen].slice(0, 64);
|
|
741
|
+
}
|
|
742
|
+
/** How many distinct app names the text holds, before the 64-name cap. */
|
|
743
|
+
function ownMachineAppCount(text) {
|
|
744
|
+
return new Set(text.split(/\r?\n/).map((line) => line.trim().toLowerCase()).filter(Boolean)).size;
|
|
745
|
+
}
|
|
746
|
+
/** When the earliest live grant expires (epoch ms), or null. */
|
|
747
|
+
function nextOwnMachineGrantExpiry(grants, now = Date.now()) {
|
|
748
|
+
let next = null;
|
|
749
|
+
for (const g of grants) {
|
|
750
|
+
if (!isLive(g, now)) continue;
|
|
751
|
+
const at = new Date(g.expiresAt).getTime();
|
|
752
|
+
if (next === null || at < next) next = at;
|
|
753
|
+
}
|
|
754
|
+
return next;
|
|
755
|
+
}
|
|
756
|
+
/** What the viewer may do with the picker, from {@link OwnMachineAccess}. */
|
|
757
|
+
function ownMachineAbilities(ownerActorId, access = {}) {
|
|
758
|
+
const manage = (access.viewerActorId === void 0 || access.viewerActorId === ownerActorId) && access.canUpdateSteward !== false;
|
|
759
|
+
return {
|
|
760
|
+
manage,
|
|
761
|
+
read: access.canReadMachines !== false,
|
|
762
|
+
grant: manage && access.canGrantMachines !== false
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
const EMPTY_MACHINES = {
|
|
766
|
+
agents: void 0,
|
|
767
|
+
grants: void 0,
|
|
768
|
+
error: void 0,
|
|
769
|
+
loading: false,
|
|
770
|
+
truncated: false,
|
|
771
|
+
unchecked: /* @__PURE__ */ new Set()
|
|
772
|
+
};
|
|
773
|
+
/** Grant lookups sent at once. */
|
|
774
|
+
const GRANT_LOOKUP_CONCURRENCY = 8;
|
|
702
775
|
/**
|
|
703
776
|
* Every VibeControls machine the viewer can see in the workspace, page by
|
|
704
|
-
* page. The agents query has no owner filter,
|
|
705
|
-
*
|
|
777
|
+
* page, and the steward's live grants. The agents query has no owner filter,
|
|
778
|
+
* so the owner's machines can sit on any page. The grants list is capped by
|
|
779
|
+
* the service before it drops expired rows, so a shorter list can still miss
|
|
780
|
+
* a live grant: each of the owner's machines without a live grant in the list
|
|
781
|
+
* is looked up on its own (at most OWN_MACHINE_GRANT_LOOKUPS). Data is keyed
|
|
782
|
+
* by gateway, workspace, steward and owner, so another scope's machines and
|
|
783
|
+
* grants are never shown or acted on; a superseded load is aborted.
|
|
706
784
|
*/
|
|
707
|
-
function
|
|
708
|
-
const { client } = useStewardsSdk();
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
785
|
+
function useOwnMachineData(stewardId, ownerActorId, viewerActorId, enabled) {
|
|
786
|
+
const { client, config: { gatewayUrl, workspaceId } } = useStewardsSdk();
|
|
787
|
+
const scope = JSON.stringify([
|
|
788
|
+
gatewayUrl,
|
|
789
|
+
workspaceId,
|
|
790
|
+
stewardId,
|
|
791
|
+
ownerActorId,
|
|
792
|
+
viewerActorId ?? null
|
|
793
|
+
]);
|
|
794
|
+
const [nonce, setNonce] = useState(0);
|
|
795
|
+
const [state, setState] = useState(void 0);
|
|
796
|
+
const reload = useCallback(() => {
|
|
797
|
+
if (!enabled) return;
|
|
798
|
+
setState((prev) => prev ? {
|
|
718
799
|
...prev,
|
|
719
800
|
loading: true
|
|
720
|
-
})
|
|
801
|
+
} : prev);
|
|
802
|
+
setNonce((n) => n + 1);
|
|
803
|
+
}, [enabled]);
|
|
804
|
+
useEffect(() => {
|
|
805
|
+
if (!enabled) return void 0;
|
|
806
|
+
const controller = new AbortController();
|
|
807
|
+
const grantsOf = async (agentId) => (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
808
|
+
stewardId,
|
|
809
|
+
...agentId ? { agentId } : {}
|
|
810
|
+
}, controller.signal)).vibecontrolsStewardGrants;
|
|
721
811
|
const load = async () => {
|
|
722
812
|
const agents = [];
|
|
813
|
+
let truncated = true;
|
|
723
814
|
for (let page = 0; page < 100; page += 1) {
|
|
724
815
|
const data = await client.request(LIST_OWN_MACHINE_AGENTS, { pagination: {
|
|
725
816
|
limit: 100,
|
|
726
817
|
offset: page * 100
|
|
727
818
|
} }, controller.signal);
|
|
728
819
|
agents.push(...data.vibecontrolsAgents);
|
|
729
|
-
if (data.vibecontrolsAgents.length < 100)
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}
|
|
820
|
+
if (data.vibecontrolsAgents.length < 100) {
|
|
821
|
+
truncated = false;
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const grants = [...await grantsOf()];
|
|
826
|
+
const now = Date.now();
|
|
827
|
+
const live = new Set(grants.filter((g) => isLive(g, now)).map((g) => g.agentId));
|
|
828
|
+
const missing = agents.filter((a) => a.ownerUserId === ownerActorId && !live.has(a.id)).map((a) => a.id);
|
|
829
|
+
const checked = missing.slice(0, 50);
|
|
830
|
+
const unchecked = new Set(missing.slice(50));
|
|
831
|
+
for (let i = 0; i < checked.length; i += GRANT_LOOKUP_CONCURRENCY) {
|
|
832
|
+
const ids = checked.slice(i, i + GRANT_LOOKUP_CONCURRENCY);
|
|
833
|
+
const batch = await Promise.allSettled(ids.map((id) => grantsOf(id)));
|
|
834
|
+
if (controller.signal.aborted) break;
|
|
835
|
+
batch.forEach((result, n) => {
|
|
836
|
+
if (result.status === "fulfilled") grants.push(...result.value);
|
|
837
|
+
else unchecked.add(ids[n]);
|
|
838
|
+
});
|
|
733
839
|
}
|
|
734
840
|
return {
|
|
735
841
|
agents,
|
|
736
|
-
|
|
842
|
+
grants,
|
|
843
|
+
truncated,
|
|
844
|
+
unchecked
|
|
737
845
|
};
|
|
738
846
|
};
|
|
739
|
-
load().then(({ agents, truncated }) => {
|
|
847
|
+
load().then(({ agents, grants, truncated, unchecked }) => {
|
|
740
848
|
if (controller.signal.aborted) return;
|
|
741
849
|
setState({
|
|
850
|
+
scope,
|
|
742
851
|
agents,
|
|
852
|
+
grants,
|
|
743
853
|
error: void 0,
|
|
744
854
|
loading: false,
|
|
745
|
-
truncated
|
|
855
|
+
truncated,
|
|
856
|
+
unchecked
|
|
746
857
|
});
|
|
747
858
|
}, (err) => {
|
|
748
859
|
if (controller.signal.aborted) return;
|
|
749
|
-
setState(
|
|
750
|
-
...
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
})
|
|
860
|
+
setState({
|
|
861
|
+
...EMPTY_MACHINES,
|
|
862
|
+
scope,
|
|
863
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
864
|
+
});
|
|
754
865
|
});
|
|
755
866
|
return () => controller.abort();
|
|
756
|
-
}, [
|
|
757
|
-
|
|
867
|
+
}, [
|
|
868
|
+
client,
|
|
869
|
+
scope,
|
|
870
|
+
stewardId,
|
|
871
|
+
ownerActorId,
|
|
872
|
+
enabled,
|
|
873
|
+
nonce
|
|
874
|
+
]);
|
|
875
|
+
const checkAgent = useCallback(async (agentId) => {
|
|
876
|
+
const found = (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
877
|
+
stewardId,
|
|
878
|
+
agentId
|
|
879
|
+
})).vibecontrolsStewardGrants;
|
|
880
|
+
setState((prev) => {
|
|
881
|
+
if (!prev || prev.scope !== scope) return prev;
|
|
882
|
+
const unchecked = new Set(prev.unchecked);
|
|
883
|
+
unchecked.delete(agentId);
|
|
884
|
+
return {
|
|
885
|
+
...prev,
|
|
886
|
+
grants: [...prev.grants ?? [], ...found],
|
|
887
|
+
unchecked
|
|
888
|
+
};
|
|
889
|
+
});
|
|
890
|
+
}, [
|
|
891
|
+
client,
|
|
892
|
+
stewardId,
|
|
893
|
+
scope
|
|
894
|
+
]);
|
|
895
|
+
if (!enabled) return {
|
|
896
|
+
...EMPTY_MACHINES,
|
|
897
|
+
reload,
|
|
898
|
+
checkAgent
|
|
899
|
+
};
|
|
900
|
+
if (!state || state.scope !== scope) return {
|
|
901
|
+
...EMPTY_MACHINES,
|
|
902
|
+
loading: true,
|
|
903
|
+
reload,
|
|
904
|
+
checkAgent
|
|
905
|
+
};
|
|
906
|
+
return {
|
|
907
|
+
...state,
|
|
908
|
+
reload,
|
|
909
|
+
checkAgent
|
|
910
|
+
};
|
|
758
911
|
}
|
|
759
912
|
/**
|
|
760
913
|
* The desk settings of a steward whose desk kind is OWN_MACHINE, inside the
|
|
@@ -772,27 +925,54 @@ function StewardOwnMachineDesk(props) {
|
|
|
772
925
|
}
|
|
773
926
|
/**
|
|
774
927
|
* The owner's VibeControls machines, which ones have granted this steward,
|
|
775
|
-
* and the one it works on.
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
928
|
+
* and the one it works on. The owner can grant a machine to the steward
|
|
929
|
+
* (`grantVibecontrolsAgentToSteward`), revoke the grant, choose a granted
|
|
930
|
+
* machine (`setBotmanorStewardOwnMachineDesk`) or clear the choice
|
|
931
|
+
* (`clearBotmanorStewardOwnMachineDesk`). Controls follow `access`; the
|
|
932
|
+
* service's refusals (no grant, machine in use, changed concurrently, check
|
|
933
|
+
* unavailable) are shown with the service's own message. Refresh and the tab
|
|
934
|
+
* regaining focus reload the desk, the machines and the grants, and a row
|
|
935
|
+
* re-renders when its grant expires. The gateway stays the enforcement point.
|
|
781
936
|
*/
|
|
782
|
-
function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl = DEFAULT_VIBECONTROLS_URL, onChanged }) {
|
|
937
|
+
function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl = DEFAULT_VIBECONTROLS_URL, access, onChanged }) {
|
|
938
|
+
const abilities = ownMachineAbilities(ownerActorId, access);
|
|
939
|
+
const { client, config } = useStewardsSdk();
|
|
783
940
|
const desk = useStewardsQuery(GET_STEWARD_OWN_MACHINE_DESK, { stewardId });
|
|
784
|
-
const
|
|
785
|
-
const [machinesNonce, setMachinesNonce] = useState(0);
|
|
786
|
-
const machines = useWorkspaceMachines(machinesNonce);
|
|
941
|
+
const machines = useOwnMachineData(stewardId, ownerActorId, access?.viewerActorId, abilities.read);
|
|
787
942
|
const choose = useStewardsMutation(SET_STEWARD_OWN_MACHINE_DESK);
|
|
788
943
|
const clear = useStewardsMutation(CLEAR_STEWARD_OWN_MACHINE_DESK);
|
|
944
|
+
const grant = useStewardsMutation(GRANT_OWN_MACHINE);
|
|
945
|
+
const revoke = useStewardsMutation(REVOKE_OWN_MACHINE_GRANT);
|
|
946
|
+
const [grantDays, setGrantDays] = useState(7);
|
|
947
|
+
const [appsText, setAppsText] = useState("");
|
|
789
948
|
const [lastAction, setLastAction] = useState(null);
|
|
790
|
-
const
|
|
791
|
-
const
|
|
949
|
+
const [grantNotice, setGrantNotice] = useState(void 0);
|
|
950
|
+
const [granting, setGranting] = useState(false);
|
|
951
|
+
const scopeRef = useRef("");
|
|
952
|
+
useEffect(() => {
|
|
953
|
+
scopeRef.current = JSON.stringify([
|
|
954
|
+
config.gatewayUrl,
|
|
955
|
+
config.workspaceId,
|
|
956
|
+
stewardId,
|
|
957
|
+
ownerActorId,
|
|
958
|
+
access?.viewerActorId ?? null,
|
|
959
|
+
abilities.grant
|
|
960
|
+
]);
|
|
961
|
+
});
|
|
962
|
+
useEffect(() => () => {
|
|
963
|
+
scopeRef.current = "";
|
|
964
|
+
}, []);
|
|
965
|
+
const actionError = lastAction ? lastAction === "check" ? grantNotice : lastAction === "grant" ? grantNotice ?? grant.error : {
|
|
966
|
+
choose,
|
|
967
|
+
clear,
|
|
968
|
+
revoke
|
|
969
|
+
}[lastAction].error : void 0;
|
|
970
|
+
const refetchDesk = desk.refetch;
|
|
971
|
+
const reloadMachines = machines.reload;
|
|
792
972
|
const refresh = useCallback(() => {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}, [
|
|
973
|
+
refetchDesk();
|
|
974
|
+
reloadMachines();
|
|
975
|
+
}, [refetchDesk, reloadMachines]);
|
|
796
976
|
useEffect(() => {
|
|
797
977
|
if (typeof window === "undefined") return void 0;
|
|
798
978
|
const onFocus = () => refresh();
|
|
@@ -800,24 +980,86 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
800
980
|
return () => window.removeEventListener("focus", onFocus);
|
|
801
981
|
}, [refresh]);
|
|
802
982
|
const current = desk.data?.botmanorStewardOwnMachineDesk ?? null;
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
const
|
|
983
|
+
const grants = machines.grants ?? [];
|
|
984
|
+
const rows = ownMachineRows(machines.agents ?? [], grants, ownerActorId, current?.agentId ?? null);
|
|
985
|
+
const [expiryTick, setExpiryTick] = useState(0);
|
|
986
|
+
const nextExpiry = nextOwnMachineGrantExpiry(grants);
|
|
987
|
+
useEffect(() => {
|
|
988
|
+
if (nextExpiry === null) return void 0;
|
|
989
|
+
const delay = Math.min(Math.max(nextExpiry - Date.now(), 0) + 1e3, 2 ** 31 - 1);
|
|
990
|
+
const id = setTimeout(() => setExpiryTick((n) => n + 1), delay);
|
|
991
|
+
return () => clearTimeout(id);
|
|
992
|
+
}, [nextExpiry, expiryTick]);
|
|
993
|
+
const deskBusy = choose.loading || clear.loading;
|
|
994
|
+
const busy = deskBusy || granting || grant.loading || revoke.loading || machines.loading;
|
|
995
|
+
const listed = machines.agents !== void 0 && machines.grants !== void 0;
|
|
806
996
|
const onChoose = async (agentId) => {
|
|
807
997
|
setLastAction("choose");
|
|
808
998
|
const result = await choose.mutate({ input: {
|
|
809
999
|
stewardId,
|
|
810
1000
|
agentId
|
|
811
1001
|
} });
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
onChanged?.(result.setBotmanorStewardOwnMachineDesk);
|
|
1002
|
+
refresh();
|
|
1003
|
+
if (result) onChanged?.(result.setBotmanorStewardOwnMachineDesk);
|
|
815
1004
|
};
|
|
816
1005
|
const onClear = async () => {
|
|
817
1006
|
setLastAction("clear");
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
onChanged?.(null);
|
|
1007
|
+
const result = await clear.mutate({ stewardId });
|
|
1008
|
+
refresh();
|
|
1009
|
+
if (result) onChanged?.(null);
|
|
1010
|
+
};
|
|
1011
|
+
const onGrant = async (agentId) => {
|
|
1012
|
+
if (granting) return;
|
|
1013
|
+
setGranting(true);
|
|
1014
|
+
setLastAction("grant");
|
|
1015
|
+
setGrantNotice(void 0);
|
|
1016
|
+
const startedIn = scopeRef.current;
|
|
1017
|
+
if (ownMachineAppCount(appsText) > 64) {
|
|
1018
|
+
setGrantNotice(/* @__PURE__ */ new Error(`A grant allows at most ${64} apps. Shorten the list and grant again.`));
|
|
1019
|
+
setGranting(false);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
try {
|
|
1023
|
+
const existing = (await client.request(LIST_OWN_MACHINE_GRANTS, {
|
|
1024
|
+
stewardId,
|
|
1025
|
+
agentId
|
|
1026
|
+
})).vibecontrolsStewardGrants;
|
|
1027
|
+
if (!startedIn || scopeRef.current !== startedIn) return;
|
|
1028
|
+
if (existing.some((g) => g.status === "ACTIVE")) {
|
|
1029
|
+
setGrantNotice(/* @__PURE__ */ new Error("This machine already has a live grant for this steward. Revoke it first to change its apps or length."));
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
await grant.mutate({ input: {
|
|
1033
|
+
stewardId,
|
|
1034
|
+
agentId,
|
|
1035
|
+
allowedApps: ownMachineAllowedApps(appsText),
|
|
1036
|
+
expiresAt: ownMachineGrantExpiry(grantDays)
|
|
1037
|
+
} });
|
|
1038
|
+
} catch (err) {
|
|
1039
|
+
setGrantNotice(err instanceof Error ? err : new Error(String(err)));
|
|
1040
|
+
} finally {
|
|
1041
|
+
setGranting(false);
|
|
1042
|
+
refresh();
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
const checkAgent = machines.checkAgent;
|
|
1046
|
+
const onCheck = async (agentId) => {
|
|
1047
|
+
setLastAction("check");
|
|
1048
|
+
setGrantNotice(void 0);
|
|
1049
|
+
try {
|
|
1050
|
+
await checkAgent(agentId);
|
|
1051
|
+
} catch (err) {
|
|
1052
|
+
setGrantNotice(err instanceof Error ? err : new Error(String(err)));
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
const onRevoke = async (agentId) => {
|
|
1056
|
+
const now = Date.now();
|
|
1057
|
+
const live = grants.find((g) => g.agentId === agentId && isLive(g, now));
|
|
1058
|
+
if (live) {
|
|
1059
|
+
setLastAction("revoke");
|
|
1060
|
+
await revoke.mutate({ id: live.id });
|
|
1061
|
+
}
|
|
1062
|
+
refresh();
|
|
821
1063
|
};
|
|
822
1064
|
return /* @__PURE__ */ jsxs("section", {
|
|
823
1065
|
"aria-label": "Own machine",
|
|
@@ -831,8 +1073,7 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
831
1073
|
children: "Own machine"
|
|
832
1074
|
}),
|
|
833
1075
|
/* @__PURE__ */ jsxs(Muted, { children: [
|
|
834
|
-
"The steward works on one of your VibeControls machines.
|
|
835
|
-
" ",
|
|
1076
|
+
abilities.manage ? "The steward works on one of your VibeControls machines. Grant a machine to this steward, then choose it. Your machines are also managed in " : "The steward works on one of its owner's VibeControls machines. Only the steward's owner can grant or choose a machine. Machines are managed in ",
|
|
836
1077
|
/* @__PURE__ */ jsx("a", {
|
|
837
1078
|
href: vibecontrolsUrl,
|
|
838
1079
|
target: "_blank",
|
|
@@ -847,33 +1088,103 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
847
1088
|
error: desk.error,
|
|
848
1089
|
current,
|
|
849
1090
|
name: rows.find((r) => r.chosen)?.agent.name,
|
|
850
|
-
|
|
1091
|
+
canClear: abilities.manage,
|
|
1092
|
+
busy: deskBusy,
|
|
851
1093
|
onClear: () => void onClear()
|
|
852
1094
|
}),
|
|
853
1095
|
/* @__PURE__ */ jsx("p", {
|
|
854
1096
|
style: { margin: "8px 0 0" },
|
|
855
1097
|
children: /* @__PURE__ */ jsx(Button, {
|
|
856
1098
|
onClick: refresh,
|
|
857
|
-
disabled: machines.loading ||
|
|
1099
|
+
disabled: machines.loading || desk.loading,
|
|
858
1100
|
label: "Refresh your machines",
|
|
859
1101
|
children: "Refresh"
|
|
860
1102
|
})
|
|
861
1103
|
}),
|
|
862
|
-
/* @__PURE__ */ jsx(
|
|
863
|
-
|
|
1104
|
+
abilities.grant ? /* @__PURE__ */ jsx(GrantOptions, {
|
|
1105
|
+
stewardId,
|
|
1106
|
+
days: grantDays,
|
|
1107
|
+
onDays: setGrantDays,
|
|
1108
|
+
appsText,
|
|
1109
|
+
onAppsText: setAppsText
|
|
1110
|
+
}) : null,
|
|
1111
|
+
abilities.read ? /* @__PURE__ */ jsx(MachineList, {
|
|
1112
|
+
loading: !listed && machines.loading,
|
|
864
1113
|
listed,
|
|
865
1114
|
truncated: machines.truncated,
|
|
866
|
-
error: machines.error
|
|
1115
|
+
error: machines.error,
|
|
867
1116
|
rows,
|
|
1117
|
+
unchecked: machines.unchecked,
|
|
1118
|
+
ownerActorId,
|
|
868
1119
|
busy,
|
|
869
|
-
|
|
870
|
-
|
|
1120
|
+
canChoose: abilities.manage,
|
|
1121
|
+
canGrant: abilities.grant,
|
|
1122
|
+
onCheck: (agentId) => void onCheck(agentId),
|
|
1123
|
+
onChoose: (agentId) => void onChoose(agentId),
|
|
1124
|
+
onGrant: (agentId) => void onGrant(agentId),
|
|
1125
|
+
onRevoke: (agentId) => void onRevoke(agentId)
|
|
1126
|
+
}) : /* @__PURE__ */ jsx(Muted, { children: "Your role cannot see VibeControls machines in this workspace." }),
|
|
871
1127
|
/* @__PURE__ */ jsx(ErrorNote, { error: actionError })
|
|
872
1128
|
]
|
|
873
1129
|
});
|
|
874
1130
|
}
|
|
875
|
-
/**
|
|
876
|
-
function
|
|
1131
|
+
/** How long a new grant lasts, and the apps it allows. */
|
|
1132
|
+
function GrantOptions({ stewardId, days, onDays, appsText, onAppsText }) {
|
|
1133
|
+
const instance = useId();
|
|
1134
|
+
const daysId = `own-machine-days-${stewardId}-${instance}`;
|
|
1135
|
+
const appsId = `own-machine-apps-${stewardId}-${instance}`;
|
|
1136
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1137
|
+
style: {
|
|
1138
|
+
display: "grid",
|
|
1139
|
+
gap: "4px",
|
|
1140
|
+
marginTop: "8px"
|
|
1141
|
+
},
|
|
1142
|
+
children: [
|
|
1143
|
+
/* @__PURE__ */ jsx("label", {
|
|
1144
|
+
htmlFor: daysId,
|
|
1145
|
+
style: {
|
|
1146
|
+
fontSize: "13px",
|
|
1147
|
+
fontWeight: 500
|
|
1148
|
+
},
|
|
1149
|
+
children: "A new grant lasts"
|
|
1150
|
+
}),
|
|
1151
|
+
/* @__PURE__ */ jsx("select", {
|
|
1152
|
+
id: daysId,
|
|
1153
|
+
value: days,
|
|
1154
|
+
onChange: (e) => {
|
|
1155
|
+
const next = OWN_MACHINE_GRANT_DAYS.find((d) => d === Number(e.target.value));
|
|
1156
|
+
if (next) onDays(next);
|
|
1157
|
+
},
|
|
1158
|
+
style: {
|
|
1159
|
+
...fieldStyle,
|
|
1160
|
+
width: "auto"
|
|
1161
|
+
},
|
|
1162
|
+
children: OWN_MACHINE_GRANT_DAYS.map((d) => /* @__PURE__ */ jsx("option", {
|
|
1163
|
+
value: d,
|
|
1164
|
+
children: d === 1 ? "1 day" : `${d} days`
|
|
1165
|
+
}, d))
|
|
1166
|
+
}),
|
|
1167
|
+
/* @__PURE__ */ jsx("label", {
|
|
1168
|
+
htmlFor: appsId,
|
|
1169
|
+
style: {
|
|
1170
|
+
fontSize: "13px",
|
|
1171
|
+
fontWeight: 500
|
|
1172
|
+
},
|
|
1173
|
+
children: "Apps the steward may use on a granted machine"
|
|
1174
|
+
}),
|
|
1175
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
1176
|
+
id: appsId,
|
|
1177
|
+
value: appsText,
|
|
1178
|
+
onChange: (e) => onAppsText(e.target.value),
|
|
1179
|
+
rows: 3,
|
|
1180
|
+
style: fieldStyle
|
|
1181
|
+
}),
|
|
1182
|
+
/* @__PURE__ */ jsx(Muted, { children: "One app name or platform id per line (for example a macOS bundle id). Desktop actions in other apps are refused; browser and workspace-folder actions are not limited by this list." })
|
|
1183
|
+
]
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
/** The machine the steward works on now, with Clear for the owner. */
|
|
1187
|
+
function CurrentMachine({ loading, loaded, error, current, name, canClear, busy, onClear }) {
|
|
877
1188
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
878
1189
|
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading the desk…" }) : null,
|
|
879
1190
|
/* @__PURE__ */ jsx(ErrorNote, { error }),
|
|
@@ -884,19 +1195,19 @@ function CurrentMachine({ loading, loaded, error, current, name, busy, onClear }
|
|
|
884
1195
|
" ",
|
|
885
1196
|
name ?? current.agentId,
|
|
886
1197
|
" ",
|
|
887
|
-
/* @__PURE__ */ jsx(Button, {
|
|
1198
|
+
canClear ? /* @__PURE__ */ jsx(Button, {
|
|
888
1199
|
kind: "danger",
|
|
889
1200
|
onClick: onClear,
|
|
890
1201
|
disabled: busy,
|
|
891
1202
|
label: "Clear the machine",
|
|
892
1203
|
children: "Clear"
|
|
893
|
-
})
|
|
1204
|
+
}) : null
|
|
894
1205
|
]
|
|
895
1206
|
}) : loaded ? /* @__PURE__ */ jsx(Muted, { children: "No machine chosen yet." }) : null
|
|
896
1207
|
] });
|
|
897
1208
|
}
|
|
898
|
-
/** The owner's machines, each with its grant and
|
|
899
|
-
function MachineList({ loading, listed, truncated, error, rows,
|
|
1209
|
+
/** The owner's machines, each with its grant and what the viewer may do. */
|
|
1210
|
+
function MachineList({ loading, listed, truncated, error, rows, ...actions }) {
|
|
900
1211
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
901
1212
|
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading your machines…" }) : null,
|
|
902
1213
|
/* @__PURE__ */ jsx(ErrorNote, { error }),
|
|
@@ -907,13 +1218,13 @@ function MachineList({ loading, listed, truncated, error, rows, busy, onChoose }
|
|
|
907
1218
|
"aria-label": "Your machines",
|
|
908
1219
|
children: rows.map((row) => /* @__PURE__ */ jsx(MachineRow, {
|
|
909
1220
|
row,
|
|
910
|
-
|
|
911
|
-
onChoose
|
|
1221
|
+
...actions
|
|
912
1222
|
}, row.agent.id))
|
|
913
1223
|
}) : null
|
|
914
1224
|
] });
|
|
915
1225
|
}
|
|
916
|
-
function MachineRow({ row: { agent, granted, chosen }, busy, onChoose }) {
|
|
1226
|
+
function MachineRow({ row: { agent, granted, chosen }, unchecked, ownerActorId, onCheck, busy, canChoose, canGrant, onChoose, onGrant, onRevoke }) {
|
|
1227
|
+
const unknown = !granted && unchecked.has(agent.id);
|
|
917
1228
|
return /* @__PURE__ */ jsxs("li", {
|
|
918
1229
|
style: rowStyle,
|
|
919
1230
|
children: [
|
|
@@ -921,17 +1232,40 @@ function MachineRow({ row: { agent, granted, chosen }, busy, onChoose }) {
|
|
|
921
1232
|
" ",
|
|
922
1233
|
/* @__PURE__ */ jsx(Muted, { children: agent.hostname }),
|
|
923
1234
|
" ",
|
|
924
|
-
/* @__PURE__ */ jsx(Badge, { children: agent.isActive ? "
|
|
1235
|
+
/* @__PURE__ */ jsx(Badge, { children: agent.isActive ? "Active" : "Inactive" }),
|
|
1236
|
+
" ",
|
|
1237
|
+
/* @__PURE__ */ jsx(Badge, { children: granted ? "Granted" : unknown ? "Grant not checked" : "Not granted" }),
|
|
1238
|
+
" ",
|
|
1239
|
+
chosen ? /* @__PURE__ */ jsx(Badge, { children: "Chosen" }) : null,
|
|
925
1240
|
" ",
|
|
926
|
-
/* @__PURE__ */ jsx(
|
|
1241
|
+
(canGrant || canChoose) && unknown ? /* @__PURE__ */ jsx(Button, {
|
|
1242
|
+
onClick: () => onCheck(agent.id),
|
|
1243
|
+
disabled: busy,
|
|
1244
|
+
label: `Check the grant on ${agent.name}`,
|
|
1245
|
+
children: "Check grant"
|
|
1246
|
+
}) : null,
|
|
927
1247
|
" ",
|
|
928
|
-
|
|
1248
|
+
canGrant && !granted && !unknown && agent.ownerUserId === ownerActorId ? /* @__PURE__ */ jsx(Button, {
|
|
1249
|
+
onClick: () => onGrant(agent.id),
|
|
1250
|
+
disabled: busy,
|
|
1251
|
+
label: `Grant ${agent.name} to this steward`,
|
|
1252
|
+
children: "Grant to this steward"
|
|
1253
|
+
}) : null,
|
|
1254
|
+
" ",
|
|
1255
|
+
canChoose && granted && !chosen ? /* @__PURE__ */ jsx(Button, {
|
|
929
1256
|
kind: "primary",
|
|
930
1257
|
onClick: () => onChoose(agent.id),
|
|
931
|
-
disabled: busy
|
|
1258
|
+
disabled: busy,
|
|
932
1259
|
label: `Use ${agent.name}`,
|
|
933
1260
|
children: "Use this machine"
|
|
934
|
-
}),
|
|
1261
|
+
}) : null,
|
|
1262
|
+
" ",
|
|
1263
|
+
canGrant && granted ? /* @__PURE__ */ jsx(Button, {
|
|
1264
|
+
onClick: () => onRevoke(agent.id),
|
|
1265
|
+
disabled: busy,
|
|
1266
|
+
label: `Revoke the grant on ${agent.name}`,
|
|
1267
|
+
children: "Revoke grant"
|
|
1268
|
+
}) : null,
|
|
935
1269
|
/* @__PURE__ */ jsxs(Muted, { children: ["Last seen ", formatDate(agent.lastHeartbeat)] })
|
|
936
1270
|
]
|
|
937
1271
|
});
|
|
@@ -1104,7 +1438,7 @@ function RunApprovals({ approvals }) {
|
|
|
1104
1438
|
|
|
1105
1439
|
// src/components/StewardConsole.tsx
|
|
1106
1440
|
/** List stewards, or open one: its charter summary, start a run, recent runs. */
|
|
1107
|
-
function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl }) {
|
|
1441
|
+
function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl, ownMachineAccess }) {
|
|
1108
1442
|
const { config } = useStewardsSdk();
|
|
1109
1443
|
const [opened, setOpened] = useState(void 0);
|
|
1110
1444
|
const current = stewardId ?? opened;
|
|
@@ -1118,7 +1452,8 @@ function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl }) {
|
|
|
1118
1452
|
}), current ? /* @__PURE__ */ jsx(StewardPanel, {
|
|
1119
1453
|
stewardId: current,
|
|
1120
1454
|
onBack: stewardId ? void 0 : () => setOpened(void 0),
|
|
1121
|
-
vibecontrolsUrl
|
|
1455
|
+
vibecontrolsUrl,
|
|
1456
|
+
ownMachineAccess
|
|
1122
1457
|
}) : /* @__PURE__ */ jsx(StewardList, { onSelect: (id) => {
|
|
1123
1458
|
setOpened(id);
|
|
1124
1459
|
onSelectSteward?.(id);
|
|
@@ -1155,7 +1490,7 @@ function StewardList({ onSelect }) {
|
|
|
1155
1490
|
}) : null
|
|
1156
1491
|
] });
|
|
1157
1492
|
}
|
|
1158
|
-
function StewardPanel({ stewardId, onBack, vibecontrolsUrl }) {
|
|
1493
|
+
function StewardPanel({ stewardId, onBack, vibecontrolsUrl, ownMachineAccess }) {
|
|
1159
1494
|
const steward = useStewardsQuery(GET_STEWARD, { id: stewardId });
|
|
1160
1495
|
const runs = useStewardsQuery(LIST_STEWARD_RUNS, {
|
|
1161
1496
|
filter: { stewardId },
|
|
@@ -1183,7 +1518,8 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl }) {
|
|
|
1183
1518
|
/* @__PURE__ */ jsx(StewardSummary, { detail }),
|
|
1184
1519
|
/* @__PURE__ */ jsx(OwnMachineSection, {
|
|
1185
1520
|
detail,
|
|
1186
|
-
vibecontrolsUrl
|
|
1521
|
+
vibecontrolsUrl,
|
|
1522
|
+
access: ownMachineAccess
|
|
1187
1523
|
}),
|
|
1188
1524
|
detail.status === "ACTIVE" ? /* @__PURE__ */ jsx(StartRunForm, {
|
|
1189
1525
|
stewardId,
|
|
@@ -1202,11 +1538,16 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl }) {
|
|
|
1202
1538
|
] });
|
|
1203
1539
|
}
|
|
1204
1540
|
/** The machine picker, for a steward whose desk kind is OWN_MACHINE. */
|
|
1205
|
-
function OwnMachineSection({ detail, vibecontrolsUrl }) {
|
|
1541
|
+
function OwnMachineSection({ detail, vibecontrolsUrl, access }) {
|
|
1206
1542
|
if (detail.defaultDeskKind !== "OWN_MACHINE") return null;
|
|
1543
|
+
const effective = detail.status === "ARCHIVED" ? {
|
|
1544
|
+
...access,
|
|
1545
|
+
canUpdateSteward: false
|
|
1546
|
+
} : access ?? {};
|
|
1207
1547
|
return /* @__PURE__ */ jsx(StewardOwnMachineDeskPanel, {
|
|
1208
1548
|
stewardId: detail.id,
|
|
1209
1549
|
ownerActorId: detail.ownerActorId,
|
|
1550
|
+
access: effective,
|
|
1210
1551
|
...vibecontrolsUrl ? { vibecontrolsUrl } : {}
|
|
1211
1552
|
});
|
|
1212
1553
|
}
|
|
@@ -1701,4 +2042,4 @@ function ApprovalInbox({ stewardId, pollIntervalMs = 15e3 }) {
|
|
|
1701
2042
|
});
|
|
1702
2043
|
}
|
|
1703
2044
|
|
|
1704
|
-
export { ApprovalInbox, DEFAULT_STEWARDS_THEME, DEFAULT_VIBECONTROLS_URL, OWN_MACHINE_MAX_PAGES, OWN_MACHINE_PAGE_SIZE, StewardBuilder, StewardConsole, StewardOwnMachineDesk, StewardOwnMachineDeskPanel, StewardRunView, StewardsRequestError, StewardsSdkProvider, createStewardsEventBus, ownMachineRows, themeToStyle, useStewardsEvent, useStewardsSdk };
|
|
2045
|
+
export { ApprovalInbox, DEFAULT_STEWARDS_THEME, DEFAULT_VIBECONTROLS_URL, OWN_MACHINE_GRANT_DAYS, OWN_MACHINE_MAX_PAGES, OWN_MACHINE_PAGE_SIZE, StewardBuilder, StewardConsole, StewardOwnMachineDesk, StewardOwnMachineDeskPanel, StewardRunView, StewardsRequestError, StewardsSdkProvider, createStewardsEventBus, nextOwnMachineGrantExpiry, ownMachineAbilities, ownMachineAllowedApps, ownMachineAppCount, ownMachineGrantExpiry, ownMachineRows, themeToStyle, useStewardsEvent, useStewardsSdk };
|