@botmanor/fe-sdk 2026.1204.3 → 2026.1205.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/README.md +16 -4
- package/dist/index.d.ts +99 -14
- package/dist/index.js +321 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Embed BotManor **Stewards** (🗺️ in development — BOFF-15352).
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
StewardsSdkProvider,
|
|
8
|
+
StewardConsole,
|
|
9
|
+
useStewardsEvent,
|
|
10
|
+
} from "@botmanor/fe-sdk";
|
|
7
11
|
|
|
8
12
|
<StewardsSdkProvider
|
|
9
13
|
gatewayUrl={gatewayUrl}
|
|
@@ -12,10 +16,10 @@ import { StewardsSdkProvider, StewardConsole, useStewardsEvent } from '@botmanor
|
|
|
12
16
|
getWorkspaceToken={() => auth.currentWorkspaceToken()} // app shells only
|
|
13
17
|
onTokenExpired={() => auth.refresh()}
|
|
14
18
|
onEvent={(e) => analytics.track(e.type)}
|
|
15
|
-
theme={{ accent:
|
|
19
|
+
theme={{ accent: "var(--my-brand)" }}
|
|
16
20
|
>
|
|
17
21
|
<StewardConsole stewardId={stewardId} />
|
|
18
|
-
</StewardsSdkProvider
|
|
22
|
+
</StewardsSdkProvider>;
|
|
19
23
|
```
|
|
20
24
|
|
|
21
25
|
Theme variables are scoped to the SDK's wrapper; the SDK never styles your page.
|
|
@@ -32,7 +36,11 @@ cookies, no referrer. Inside a Burdenoff app shell, also pass
|
|
|
32
36
|
(sent as `X-Workspace-Authorization`) beside the access token for
|
|
33
37
|
workspace-scoped fields. An embed on a third-party page leaves it out. A 401 or
|
|
34
38
|
`UNAUTHENTICATED` (or a `getWorkspaceToken` that throws) raises `onTokenExpired`
|
|
35
|
-
and the `auth.expired` event.
|
|
39
|
+
and the `auth.expired` event. Requests never follow a redirect. An app
|
|
40
|
+
shell behind Cloudflare Access that serves the gateway through a same-origin
|
|
41
|
+
proxy sets `sameOriginCredentials` so the Access session cookie reaches it;
|
|
42
|
+
cookies then go only to the page's own origin, never to a cross-origin
|
|
43
|
+
gateway. Operations match `@burdenoff/microfe-stewards` and use the
|
|
36
44
|
`Botmanor*` schema; the SDK does not depend on that package because it pulls in
|
|
37
45
|
Apollo and the fe-libs shell.
|
|
38
46
|
|
|
@@ -40,6 +48,10 @@ Apollo and the fe-libs shell.
|
|
|
40
48
|
- `StewardBuilder`: create from an agent and charter, or edit a charter (`stewardId`).
|
|
41
49
|
- `StewardRunView`: steps, approvals, trust level and budget; polls while active.
|
|
42
50
|
- `ApprovalInbox`: pending steward approvals with the approval scope choice.
|
|
51
|
+
- `StewardOwnMachineDesk`: for a steward whose desk kind is `OWN_MACHINE`, the
|
|
52
|
+
owner's VibeControls machines, which ones have granted the steward, and the
|
|
53
|
+
one it works on (choose or clear). `StewardConsole` shows it on such a
|
|
54
|
+
steward; `vibecontrolsUrl` sets where the grant link points.
|
|
43
55
|
|
|
44
56
|
## Events
|
|
45
57
|
|
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,14 @@ interface StewardsSdkConfig {
|
|
|
129
129
|
* it: its single embed session token already names the workspace.
|
|
130
130
|
*/
|
|
131
131
|
getWorkspaceToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Send the browser's cookies when `gatewayUrl` is on the page's own origin
|
|
134
|
+
* (`credentials: "same-origin"`). Off by default: requests carry no cookies.
|
|
135
|
+
* A Burdenoff app shell behind Cloudflare Access (alpha) turns it on, because
|
|
136
|
+
* it serves the gateway through a same-origin proxy and the Access session
|
|
137
|
+
* cookie must reach it. A cross-origin gateway never gets cookies.
|
|
138
|
+
*/
|
|
139
|
+
sameOriginCredentials?: boolean;
|
|
132
140
|
/** Called when the token getter throws or the gateway answers 401. */
|
|
133
141
|
onTokenExpired?: (reason: string) => void;
|
|
134
142
|
/** Every SDK event, for hosts that prefer one callback to `useStewardsEvent`. */
|
|
@@ -164,9 +172,14 @@ interface StewardConsoleProps {
|
|
|
164
172
|
*/
|
|
165
173
|
stewardId?: string;
|
|
166
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;
|
|
167
180
|
}
|
|
168
181
|
/** List stewards, or open one: its charter summary, start a run, recent runs. */
|
|
169
|
-
export declare function StewardConsole({ stewardId, onSelectSteward }: StewardConsoleProps): import("react").JSX.Element;
|
|
182
|
+
export declare function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl }: StewardConsoleProps): import("react").JSX.Element;
|
|
170
183
|
interface StewardBuilderProps {
|
|
171
184
|
/** Start from an existing agent; omitted shows the agent picker. */
|
|
172
185
|
agentId?: string;
|
|
@@ -195,18 +208,6 @@ interface StewardRunViewProps {
|
|
|
195
208
|
* emits `run.waiting`, `run.completed` and `run.failed` as the status changes.
|
|
196
209
|
*/
|
|
197
210
|
export declare function StewardRunView({ runId, pollIntervalMs }: StewardRunViewProps): import("react").JSX.Element;
|
|
198
|
-
interface ApprovalInboxProps {
|
|
199
|
-
/** Limit to one steward; omitted shows every steward approval the viewer can decide. */
|
|
200
|
-
stewardId?: string;
|
|
201
|
-
/** Poll interval. Defaults to 15000 ms. */
|
|
202
|
-
pollIntervalMs?: number;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Pending steward approvals the viewer can decide, with the approval scope
|
|
206
|
-
* choice. Extends the platform tool-approval queue (`source: STEWARD`,
|
|
207
|
-
* `mine: true`) rather than a parallel one.
|
|
208
|
-
*/
|
|
209
|
-
export declare function ApprovalInbox({ stewardId, pollIntervalMs }: ApprovalInboxProps): import("react").JSX.Element;
|
|
210
211
|
/**
|
|
211
212
|
* The slice of the workspace gateway schema the SDK reads and writes. Names
|
|
212
213
|
* follow the `Botmanor*` types of the Hive production supergraph (the same
|
|
@@ -343,4 +344,88 @@ interface StewardApprovalRequest {
|
|
|
343
344
|
expiresAt: string;
|
|
344
345
|
createdAt: string;
|
|
345
346
|
}
|
|
346
|
-
|
|
347
|
+
/** The machine a steward with desk kind OWN_MACHINE works on (BOFF-18623). */
|
|
348
|
+
interface StewardOwnMachineDesk$1 {
|
|
349
|
+
id: string;
|
|
350
|
+
stewardId: string;
|
|
351
|
+
agentId: string;
|
|
352
|
+
/** READY while no run uses the machine, IN_USE while one does. */
|
|
353
|
+
state: string;
|
|
354
|
+
createdAt: string;
|
|
355
|
+
updatedAt: string;
|
|
356
|
+
}
|
|
357
|
+
/** A VibeControls machine (agent) in the workspace. */
|
|
358
|
+
interface OwnMachineCandidate {
|
|
359
|
+
id: string;
|
|
360
|
+
name: string;
|
|
361
|
+
hostname: string;
|
|
362
|
+
platform: string;
|
|
363
|
+
isActive: boolean;
|
|
364
|
+
ownerUserId: string | null;
|
|
365
|
+
lastHeartbeat: string | null;
|
|
366
|
+
}
|
|
367
|
+
/** A VibeControls grant of a machine to a steward. */
|
|
368
|
+
interface OwnMachineGrant {
|
|
369
|
+
id: string;
|
|
370
|
+
agentId: string;
|
|
371
|
+
status: "ACTIVE" | "EXPIRED" | "REVOKED";
|
|
372
|
+
expiresAt: string;
|
|
373
|
+
scopes: string[];
|
|
374
|
+
}
|
|
375
|
+
/** Where the person grants a machine to a steward, by default. */
|
|
376
|
+
export declare const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
377
|
+
/** Machines per page when listing the workspace's VibeControls machines. */
|
|
378
|
+
export declare const OWN_MACHINE_PAGE_SIZE = 100;
|
|
379
|
+
/** Pages read at most (10 000 machines); the list says when it stopped early. */
|
|
380
|
+
export declare const OWN_MACHINE_MAX_PAGES = 100;
|
|
381
|
+
interface StewardOwnMachineDeskProps {
|
|
382
|
+
stewardId: string;
|
|
383
|
+
/** The steward's owner: only their machines are offered. */
|
|
384
|
+
ownerActorId: string;
|
|
385
|
+
/** Link to VibeControls, where a machine's owner grants it to a steward. */
|
|
386
|
+
vibecontrolsUrl?: string;
|
|
387
|
+
/** Called after the machine is chosen or cleared. */
|
|
388
|
+
onChanged?: (desk: StewardOwnMachineDesk$1 | null) => void;
|
|
389
|
+
}
|
|
390
|
+
interface OwnMachineRow {
|
|
391
|
+
agent: OwnMachineCandidate;
|
|
392
|
+
/** The steward has an active, unexpired grant on this machine. */
|
|
393
|
+
granted: boolean;
|
|
394
|
+
/** The steward works on this machine now. */
|
|
395
|
+
chosen: boolean;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The owner's machines for the picker: the owner's agents, chosen one first,
|
|
399
|
+
* then granted ones, then by name. A grant counts while it is ACTIVE and not
|
|
400
|
+
* past its expiry (`now`, for tests).
|
|
401
|
+
*/
|
|
402
|
+
export declare function ownMachineRows(agents: readonly OwnMachineCandidate[], grants: readonly OwnMachineGrant[], ownerActorId: string, chosenAgentId: string | null, now?: number): OwnMachineRow[];
|
|
403
|
+
/**
|
|
404
|
+
* The desk settings of a steward whose desk kind is OWN_MACHINE, inside the
|
|
405
|
+
* SDK's themed wrapper: use it on its own. `StewardConsole` renders
|
|
406
|
+
* {@link StewardOwnMachineDeskPanel} under its own wrapper.
|
|
407
|
+
*/
|
|
408
|
+
export declare function StewardOwnMachineDesk(props: StewardOwnMachineDeskProps): import("react").JSX.Element;
|
|
409
|
+
/**
|
|
410
|
+
* The owner's VibeControls machines, which ones have granted this steward,
|
|
411
|
+
* and the one it works on. Choosing calls `setBotmanorStewardOwnMachineDesk`,
|
|
412
|
+
* clearing calls `clearBotmanorStewardOwnMachineDesk`; the service's refusals
|
|
413
|
+
* (no grant, machine in use, changed concurrently, check unavailable) are
|
|
414
|
+
* shown with the service's own message. The list refreshes when the tab gets
|
|
415
|
+
* focus again (the owner may have just granted a machine in VibeControls) and
|
|
416
|
+
* on "Refresh". The gateway stays the enforcement point.
|
|
417
|
+
*/
|
|
418
|
+
export declare function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl, onChanged }: StewardOwnMachineDeskProps): import("react").JSX.Element;
|
|
419
|
+
interface ApprovalInboxProps {
|
|
420
|
+
/** Limit to one steward; omitted shows every steward approval the viewer can decide. */
|
|
421
|
+
stewardId?: string;
|
|
422
|
+
/** Poll interval. Defaults to 15000 ms. */
|
|
423
|
+
pollIntervalMs?: number;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Pending steward approvals the viewer can decide, with the approval scope
|
|
427
|
+
* choice. Extends the platform tool-approval queue (`source: STEWARD`,
|
|
428
|
+
* `mine: true`) rather than a parallel one.
|
|
429
|
+
*/
|
|
430
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -55,8 +55,18 @@ async function resolveWorkspaceToken(config, options) {
|
|
|
55
55
|
/**
|
|
56
56
|
* GraphQL transport over the public workspace gateway. The access token goes
|
|
57
57
|
* in the `Authorization` header only (never in the URL or body), the host's
|
|
58
|
-
* workspace token, when it gives one, in `X-Workspace-Authorization
|
|
59
|
-
*
|
|
58
|
+
* workspace token, when it gives one, in `X-Workspace-Authorization`, and no
|
|
59
|
+
* referrer leaks the embedding page.
|
|
60
|
+
*
|
|
61
|
+
* Cookies are not sent (`credentials: "omit"`) unless the host sets
|
|
62
|
+
* `sameOriginCredentials`; then they go only to the page's own origin
|
|
63
|
+
* (`credentials: "same-origin"`). An app shell behind Cloudflare Access on
|
|
64
|
+
* alpha serves the gateway through a same-origin proxy, and the Access session
|
|
65
|
+
* cookie must reach it (BOFF-18393).
|
|
66
|
+
*
|
|
67
|
+
* Redirects are refused (`redirect: "error"`). Fetch drops `Authorization` on a
|
|
68
|
+
* cross-origin redirect but keeps custom headers, so following one could carry
|
|
69
|
+
* the workspace token past the configured gateway (BOFF-18393).
|
|
60
70
|
*/
|
|
61
71
|
function createStewardsClient(options) {
|
|
62
72
|
const send = async (document, variables, signal) => {
|
|
@@ -79,7 +89,8 @@ function createStewardsClient(options) {
|
|
|
79
89
|
query: document,
|
|
80
90
|
variables
|
|
81
91
|
}),
|
|
82
|
-
credentials: "omit",
|
|
92
|
+
credentials: config.sameOriginCredentials ? "same-origin" : "omit",
|
|
93
|
+
redirect: "error",
|
|
83
94
|
referrerPolicy: "no-referrer",
|
|
84
95
|
signal
|
|
85
96
|
});
|
|
@@ -207,13 +218,14 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
207
218
|
})
|
|
208
219
|
};
|
|
209
220
|
});
|
|
210
|
-
const { gatewayUrl, workspaceId, getAccessToken, getWorkspaceToken, onTokenExpired, theme } = config;
|
|
221
|
+
const { gatewayUrl, workspaceId, getAccessToken, getWorkspaceToken, sameOriginCredentials, onTokenExpired, theme } = config;
|
|
211
222
|
const value = useMemo(() => ({
|
|
212
223
|
config: {
|
|
213
224
|
gatewayUrl,
|
|
214
225
|
workspaceId,
|
|
215
226
|
getAccessToken,
|
|
216
227
|
...getWorkspaceToken ? { getWorkspaceToken } : {},
|
|
228
|
+
...sameOriginCredentials ? { sameOriginCredentials } : {},
|
|
217
229
|
...onTokenExpired ? { onTokenExpired } : {},
|
|
218
230
|
...onEvent ? { onEvent } : {},
|
|
219
231
|
...theme ? { theme } : {}
|
|
@@ -225,6 +237,7 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
225
237
|
workspaceId,
|
|
226
238
|
getAccessToken,
|
|
227
239
|
getWorkspaceToken,
|
|
240
|
+
sameOriginCredentials,
|
|
228
241
|
onTokenExpired,
|
|
229
242
|
onEvent,
|
|
230
243
|
theme,
|
|
@@ -373,6 +386,33 @@ const DECIDE_APPROVAL = `mutation DecideBotmanorToolApproval($id: ID!, $decision
|
|
|
373
386
|
id status grantedScope decidedAt
|
|
374
387
|
}
|
|
375
388
|
}`;
|
|
389
|
+
/**
|
|
390
|
+
* Own-machine desk (BOFF-18623, S-16145a): the VibeControls machine a steward
|
|
391
|
+
* with desk kind OWN_MACHINE works on. The machines and their grants come from
|
|
392
|
+
* the VibeControls subgraph on the same workspace gateway.
|
|
393
|
+
*/
|
|
394
|
+
const OWN_MACHINE_DESK = `id stewardId agentId state createdAt updatedAt`;
|
|
395
|
+
const GET_STEWARD_OWN_MACHINE_DESK = `query BotmanorStewardOwnMachineDesk($stewardId: ID!) {
|
|
396
|
+
botmanorStewardOwnMachineDesk(stewardId: $stewardId) { ${OWN_MACHINE_DESK} }
|
|
397
|
+
}`;
|
|
398
|
+
const SET_STEWARD_OWN_MACHINE_DESK = `mutation SetBotmanorStewardOwnMachineDesk($input: SetBotmanorStewardOwnMachineDeskInput!) {
|
|
399
|
+
setBotmanorStewardOwnMachineDesk(input: $input) { ${OWN_MACHINE_DESK} }
|
|
400
|
+
}`;
|
|
401
|
+
const CLEAR_STEWARD_OWN_MACHINE_DESK = `mutation ClearBotmanorStewardOwnMachineDesk($stewardId: ID!) {
|
|
402
|
+
clearBotmanorStewardOwnMachineDesk(stewardId: $stewardId)
|
|
403
|
+
}`;
|
|
404
|
+
/** One page of the workspace's VibeControls machines (paged by offset). */
|
|
405
|
+
const LIST_OWN_MACHINE_AGENTS = `query StewardOwnMachineAgents($pagination: PaginationInput) {
|
|
406
|
+
vibecontrolsAgents(pagination: $pagination) {
|
|
407
|
+
id name hostname platform isActive ownerUserId lastHeartbeat
|
|
408
|
+
}
|
|
409
|
+
}`;
|
|
410
|
+
/** The steward's active grants (VibeControls returns at most 100, newest first). */
|
|
411
|
+
const LIST_OWN_MACHINE_GRANTS = `query StewardOwnMachineGrants($stewardId: ID!) {
|
|
412
|
+
vibecontrolsStewardGrants(filter: { stewardId: $stewardId }) {
|
|
413
|
+
id agentId status expiresAt scopes
|
|
414
|
+
}
|
|
415
|
+
}`;
|
|
376
416
|
|
|
377
417
|
// src/graphql/hooks.ts
|
|
378
418
|
function asError(err) {
|
|
@@ -638,6 +678,265 @@ function humanize(value) {
|
|
|
638
678
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
639
679
|
}
|
|
640
680
|
|
|
681
|
+
// src/components/StewardOwnMachineDesk.tsx
|
|
682
|
+
/** Where the person grants a machine to a steward, by default. */
|
|
683
|
+
const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
684
|
+
/** Machines per page when listing the workspace's VibeControls machines. */
|
|
685
|
+
const OWN_MACHINE_PAGE_SIZE = 100;
|
|
686
|
+
/** Pages read at most (10 000 machines); the list says when it stopped early. */
|
|
687
|
+
const OWN_MACHINE_MAX_PAGES = 100;
|
|
688
|
+
/**
|
|
689
|
+
* The owner's machines for the picker: the owner's agents, chosen one first,
|
|
690
|
+
* then granted ones, then by name. A grant counts while it is ACTIVE and not
|
|
691
|
+
* past its expiry (`now`, for tests).
|
|
692
|
+
*/
|
|
693
|
+
function ownMachineRows(agents, grants, ownerActorId, chosenAgentId, now = Date.now()) {
|
|
694
|
+
const granted = new Set(grants.filter((g) => g.status === "ACTIVE" && new Date(g.expiresAt).getTime() > now).map((g) => g.agentId));
|
|
695
|
+
const rank = (row) => row.chosen ? 0 : row.granted ? 1 : 2;
|
|
696
|
+
return agents.filter((a) => a.ownerUserId === ownerActorId || a.id === chosenAgentId).map((agent) => ({
|
|
697
|
+
agent,
|
|
698
|
+
granted: granted.has(agent.id),
|
|
699
|
+
chosen: agent.id === chosenAgentId
|
|
700
|
+
})).sort((a, b) => rank(a) - rank(b) || a.agent.name.localeCompare(b.agent.name));
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Every VibeControls machine the viewer can see in the workspace, page by
|
|
704
|
+
* page. The agents query has no owner filter, so the owner's machines can sit
|
|
705
|
+
* on any page; reading only the first would hide them in a large workspace.
|
|
706
|
+
*/
|
|
707
|
+
function useWorkspaceMachines(nonce) {
|
|
708
|
+
const { client } = useStewardsSdk();
|
|
709
|
+
const [state, setState] = useState({
|
|
710
|
+
agents: void 0,
|
|
711
|
+
error: void 0,
|
|
712
|
+
loading: true,
|
|
713
|
+
truncated: false
|
|
714
|
+
});
|
|
715
|
+
useEffect(() => {
|
|
716
|
+
const controller = new AbortController();
|
|
717
|
+
setState((prev) => ({
|
|
718
|
+
...prev,
|
|
719
|
+
loading: true
|
|
720
|
+
}));
|
|
721
|
+
const load = async () => {
|
|
722
|
+
const agents = [];
|
|
723
|
+
for (let page = 0; page < 100; page += 1) {
|
|
724
|
+
const data = await client.request(LIST_OWN_MACHINE_AGENTS, { pagination: {
|
|
725
|
+
limit: 100,
|
|
726
|
+
offset: page * 100
|
|
727
|
+
} }, controller.signal);
|
|
728
|
+
agents.push(...data.vibecontrolsAgents);
|
|
729
|
+
if (data.vibecontrolsAgents.length < 100) return {
|
|
730
|
+
agents,
|
|
731
|
+
truncated: false
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
agents,
|
|
736
|
+
truncated: true
|
|
737
|
+
};
|
|
738
|
+
};
|
|
739
|
+
load().then(({ agents, truncated }) => {
|
|
740
|
+
if (controller.signal.aborted) return;
|
|
741
|
+
setState({
|
|
742
|
+
agents,
|
|
743
|
+
error: void 0,
|
|
744
|
+
loading: false,
|
|
745
|
+
truncated
|
|
746
|
+
});
|
|
747
|
+
}, (err) => {
|
|
748
|
+
if (controller.signal.aborted) return;
|
|
749
|
+
setState((prev) => ({
|
|
750
|
+
...prev,
|
|
751
|
+
error: err instanceof Error ? err : new Error(String(err)),
|
|
752
|
+
loading: false
|
|
753
|
+
}));
|
|
754
|
+
});
|
|
755
|
+
return () => controller.abort();
|
|
756
|
+
}, [client, nonce]);
|
|
757
|
+
return state;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* The desk settings of a steward whose desk kind is OWN_MACHINE, inside the
|
|
761
|
+
* SDK's themed wrapper: use it on its own. `StewardConsole` renders
|
|
762
|
+
* {@link StewardOwnMachineDeskPanel} under its own wrapper.
|
|
763
|
+
*/
|
|
764
|
+
function StewardOwnMachineDesk(props) {
|
|
765
|
+
const { config } = useStewardsSdk();
|
|
766
|
+
return /* @__PURE__ */ jsx(ScopedTheme, {
|
|
767
|
+
theme: config.theme,
|
|
768
|
+
label: "Own machine settings",
|
|
769
|
+
component: "steward-own-machine-desk",
|
|
770
|
+
children: /* @__PURE__ */ jsx(StewardOwnMachineDeskPanel, { ...props })
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* The owner's VibeControls machines, which ones have granted this steward,
|
|
775
|
+
* and the one it works on. Choosing calls `setBotmanorStewardOwnMachineDesk`,
|
|
776
|
+
* clearing calls `clearBotmanorStewardOwnMachineDesk`; the service's refusals
|
|
777
|
+
* (no grant, machine in use, changed concurrently, check unavailable) are
|
|
778
|
+
* shown with the service's own message. The list refreshes when the tab gets
|
|
779
|
+
* focus again (the owner may have just granted a machine in VibeControls) and
|
|
780
|
+
* on "Refresh". The gateway stays the enforcement point.
|
|
781
|
+
*/
|
|
782
|
+
function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl = DEFAULT_VIBECONTROLS_URL, onChanged }) {
|
|
783
|
+
const desk = useStewardsQuery(GET_STEWARD_OWN_MACHINE_DESK, { stewardId });
|
|
784
|
+
const grants = useStewardsQuery(LIST_OWN_MACHINE_GRANTS, { stewardId });
|
|
785
|
+
const [machinesNonce, setMachinesNonce] = useState(0);
|
|
786
|
+
const machines = useWorkspaceMachines(machinesNonce);
|
|
787
|
+
const choose = useStewardsMutation(SET_STEWARD_OWN_MACHINE_DESK);
|
|
788
|
+
const clear = useStewardsMutation(CLEAR_STEWARD_OWN_MACHINE_DESK);
|
|
789
|
+
const [lastAction, setLastAction] = useState(null);
|
|
790
|
+
const actionError = lastAction === "choose" ? choose.error : lastAction === "clear" ? clear.error : void 0;
|
|
791
|
+
const refetchGrants = grants.refetch;
|
|
792
|
+
const refresh = useCallback(() => {
|
|
793
|
+
refetchGrants();
|
|
794
|
+
setMachinesNonce((n) => n + 1);
|
|
795
|
+
}, [refetchGrants]);
|
|
796
|
+
useEffect(() => {
|
|
797
|
+
if (typeof window === "undefined") return void 0;
|
|
798
|
+
const onFocus = () => refresh();
|
|
799
|
+
window.addEventListener("focus", onFocus);
|
|
800
|
+
return () => window.removeEventListener("focus", onFocus);
|
|
801
|
+
}, [refresh]);
|
|
802
|
+
const current = desk.data?.botmanorStewardOwnMachineDesk ?? null;
|
|
803
|
+
const rows = ownMachineRows(machines.agents ?? [], grants.data?.vibecontrolsStewardGrants ?? [], ownerActorId, current?.agentId ?? null);
|
|
804
|
+
const busy = choose.loading || clear.loading;
|
|
805
|
+
const listed = machines.agents !== void 0 && grants.data !== void 0;
|
|
806
|
+
const onChoose = async (agentId) => {
|
|
807
|
+
setLastAction("choose");
|
|
808
|
+
const result = await choose.mutate({ input: {
|
|
809
|
+
stewardId,
|
|
810
|
+
agentId
|
|
811
|
+
} });
|
|
812
|
+
if (!result) return;
|
|
813
|
+
desk.refetch();
|
|
814
|
+
onChanged?.(result.setBotmanorStewardOwnMachineDesk);
|
|
815
|
+
};
|
|
816
|
+
const onClear = async () => {
|
|
817
|
+
setLastAction("clear");
|
|
818
|
+
if (!await clear.mutate({ stewardId })) return;
|
|
819
|
+
desk.refetch();
|
|
820
|
+
onChanged?.(null);
|
|
821
|
+
};
|
|
822
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
823
|
+
"aria-label": "Own machine",
|
|
824
|
+
style: { marginTop: "16px" },
|
|
825
|
+
children: [
|
|
826
|
+
/* @__PURE__ */ jsx("h3", {
|
|
827
|
+
style: {
|
|
828
|
+
...headingStyle,
|
|
829
|
+
fontSize: "14px"
|
|
830
|
+
},
|
|
831
|
+
children: "Own machine"
|
|
832
|
+
}),
|
|
833
|
+
/* @__PURE__ */ jsxs(Muted, { children: [
|
|
834
|
+
"The steward works on one of your VibeControls machines. A machine can be chosen once you have granted it to this steward in",
|
|
835
|
+
" ",
|
|
836
|
+
/* @__PURE__ */ jsx("a", {
|
|
837
|
+
href: vibecontrolsUrl,
|
|
838
|
+
target: "_blank",
|
|
839
|
+
rel: "noreferrer noopener",
|
|
840
|
+
children: "VibeControls"
|
|
841
|
+
}),
|
|
842
|
+
"."
|
|
843
|
+
] }),
|
|
844
|
+
/* @__PURE__ */ jsx(CurrentMachine, {
|
|
845
|
+
loading: desk.loading && !desk.data,
|
|
846
|
+
loaded: desk.data !== void 0,
|
|
847
|
+
error: desk.error,
|
|
848
|
+
current,
|
|
849
|
+
name: rows.find((r) => r.chosen)?.agent.name,
|
|
850
|
+
busy,
|
|
851
|
+
onClear: () => void onClear()
|
|
852
|
+
}),
|
|
853
|
+
/* @__PURE__ */ jsx("p", {
|
|
854
|
+
style: { margin: "8px 0 0" },
|
|
855
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
856
|
+
onClick: refresh,
|
|
857
|
+
disabled: machines.loading || grants.loading,
|
|
858
|
+
label: "Refresh your machines",
|
|
859
|
+
children: "Refresh"
|
|
860
|
+
})
|
|
861
|
+
}),
|
|
862
|
+
/* @__PURE__ */ jsx(MachineList, {
|
|
863
|
+
loading: !listed && (machines.loading || grants.loading),
|
|
864
|
+
listed,
|
|
865
|
+
truncated: machines.truncated,
|
|
866
|
+
error: machines.error ?? grants.error,
|
|
867
|
+
rows,
|
|
868
|
+
busy,
|
|
869
|
+
onChoose: (agentId) => void onChoose(agentId)
|
|
870
|
+
}),
|
|
871
|
+
/* @__PURE__ */ jsx(ErrorNote, { error: actionError })
|
|
872
|
+
]
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
/** The machine the steward works on now, with Clear. */
|
|
876
|
+
function CurrentMachine({ loading, loaded, error, current, name, busy, onClear }) {
|
|
877
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
878
|
+
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading the desk…" }) : null,
|
|
879
|
+
/* @__PURE__ */ jsx(ErrorNote, { error }),
|
|
880
|
+
current ? /* @__PURE__ */ jsxs("p", {
|
|
881
|
+
style: { margin: "8px 0 0" },
|
|
882
|
+
children: [
|
|
883
|
+
/* @__PURE__ */ jsx(Badge, { children: humanize(current.state) }),
|
|
884
|
+
" ",
|
|
885
|
+
name ?? current.agentId,
|
|
886
|
+
" ",
|
|
887
|
+
/* @__PURE__ */ jsx(Button, {
|
|
888
|
+
kind: "danger",
|
|
889
|
+
onClick: onClear,
|
|
890
|
+
disabled: busy,
|
|
891
|
+
label: "Clear the machine",
|
|
892
|
+
children: "Clear"
|
|
893
|
+
})
|
|
894
|
+
]
|
|
895
|
+
}) : loaded ? /* @__PURE__ */ jsx(Muted, { children: "No machine chosen yet." }) : null
|
|
896
|
+
] });
|
|
897
|
+
}
|
|
898
|
+
/** The owner's machines, each with its grant and a way to choose it. */
|
|
899
|
+
function MachineList({ loading, listed, truncated, error, rows, busy, onChoose }) {
|
|
900
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
901
|
+
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading your machines…" }) : null,
|
|
902
|
+
/* @__PURE__ */ jsx(ErrorNote, { error }),
|
|
903
|
+
listed && rows.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: "You have no VibeControls machines in this workspace." }) : null,
|
|
904
|
+
truncated ? /* @__PURE__ */ jsx(Muted, { children: "Only the first machines in this workspace are listed." }) : null,
|
|
905
|
+
rows.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
906
|
+
style: listStyle,
|
|
907
|
+
"aria-label": "Your machines",
|
|
908
|
+
children: rows.map((row) => /* @__PURE__ */ jsx(MachineRow, {
|
|
909
|
+
row,
|
|
910
|
+
busy,
|
|
911
|
+
onChoose
|
|
912
|
+
}, row.agent.id))
|
|
913
|
+
}) : null
|
|
914
|
+
] });
|
|
915
|
+
}
|
|
916
|
+
function MachineRow({ row: { agent, granted, chosen }, busy, onChoose }) {
|
|
917
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
918
|
+
style: rowStyle,
|
|
919
|
+
children: [
|
|
920
|
+
/* @__PURE__ */ jsx("strong", { children: agent.name }),
|
|
921
|
+
" ",
|
|
922
|
+
/* @__PURE__ */ jsx(Muted, { children: agent.hostname }),
|
|
923
|
+
" ",
|
|
924
|
+
/* @__PURE__ */ jsx(Badge, { children: agent.isActive ? "Online" : "Offline" }),
|
|
925
|
+
" ",
|
|
926
|
+
/* @__PURE__ */ jsx(Badge, { children: granted ? "Granted" : "Not granted" }),
|
|
927
|
+
" ",
|
|
928
|
+
chosen ? /* @__PURE__ */ jsx(Badge, { children: "Chosen" }) : /* @__PURE__ */ jsx(Button, {
|
|
929
|
+
kind: "primary",
|
|
930
|
+
onClick: () => onChoose(agent.id),
|
|
931
|
+
disabled: busy || !granted,
|
|
932
|
+
label: `Use ${agent.name}`,
|
|
933
|
+
children: "Use this machine"
|
|
934
|
+
}),
|
|
935
|
+
/* @__PURE__ */ jsxs(Muted, { children: ["Last seen ", formatDate(agent.lastHeartbeat)] })
|
|
936
|
+
]
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
|
|
641
940
|
// src/components/StewardRunView.tsx
|
|
642
941
|
const WAITING_REASON = {
|
|
643
942
|
WAITING_APPROVAL: "APPROVAL",
|
|
@@ -805,7 +1104,7 @@ function RunApprovals({ approvals }) {
|
|
|
805
1104
|
|
|
806
1105
|
// src/components/StewardConsole.tsx
|
|
807
1106
|
/** List stewards, or open one: its charter summary, start a run, recent runs. */
|
|
808
|
-
function StewardConsole({ stewardId, onSelectSteward }) {
|
|
1107
|
+
function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl }) {
|
|
809
1108
|
const { config } = useStewardsSdk();
|
|
810
1109
|
const [opened, setOpened] = useState(void 0);
|
|
811
1110
|
const current = stewardId ?? opened;
|
|
@@ -818,7 +1117,8 @@ function StewardConsole({ stewardId, onSelectSteward }) {
|
|
|
818
1117
|
children: "Steward console"
|
|
819
1118
|
}), current ? /* @__PURE__ */ jsx(StewardPanel, {
|
|
820
1119
|
stewardId: current,
|
|
821
|
-
onBack: stewardId ? void 0 : () => setOpened(void 0)
|
|
1120
|
+
onBack: stewardId ? void 0 : () => setOpened(void 0),
|
|
1121
|
+
vibecontrolsUrl
|
|
822
1122
|
}) : /* @__PURE__ */ jsx(StewardList, { onSelect: (id) => {
|
|
823
1123
|
setOpened(id);
|
|
824
1124
|
onSelectSteward?.(id);
|
|
@@ -855,7 +1155,7 @@ function StewardList({ onSelect }) {
|
|
|
855
1155
|
}) : null
|
|
856
1156
|
] });
|
|
857
1157
|
}
|
|
858
|
-
function StewardPanel({ stewardId, onBack }) {
|
|
1158
|
+
function StewardPanel({ stewardId, onBack, vibecontrolsUrl }) {
|
|
859
1159
|
const steward = useStewardsQuery(GET_STEWARD, { id: stewardId });
|
|
860
1160
|
const runs = useStewardsQuery(LIST_STEWARD_RUNS, {
|
|
861
1161
|
filter: { stewardId },
|
|
@@ -881,6 +1181,10 @@ function StewardPanel({ stewardId, onBack }) {
|
|
|
881
1181
|
notFound ? /* @__PURE__ */ jsx(Muted, { children: "This steward was not found." }) : null,
|
|
882
1182
|
detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
883
1183
|
/* @__PURE__ */ jsx(StewardSummary, { detail }),
|
|
1184
|
+
/* @__PURE__ */ jsx(OwnMachineSection, {
|
|
1185
|
+
detail,
|
|
1186
|
+
vibecontrolsUrl
|
|
1187
|
+
}),
|
|
884
1188
|
detail.status === "ACTIVE" ? /* @__PURE__ */ jsx(StartRunForm, {
|
|
885
1189
|
stewardId,
|
|
886
1190
|
onStarted
|
|
@@ -897,6 +1201,15 @@ function StewardPanel({ stewardId, onBack }) {
|
|
|
897
1201
|
] }) : null
|
|
898
1202
|
] });
|
|
899
1203
|
}
|
|
1204
|
+
/** The machine picker, for a steward whose desk kind is OWN_MACHINE. */
|
|
1205
|
+
function OwnMachineSection({ detail, vibecontrolsUrl }) {
|
|
1206
|
+
if (detail.defaultDeskKind !== "OWN_MACHINE") return null;
|
|
1207
|
+
return /* @__PURE__ */ jsx(StewardOwnMachineDeskPanel, {
|
|
1208
|
+
stewardId: detail.id,
|
|
1209
|
+
ownerActorId: detail.ownerActorId,
|
|
1210
|
+
...vibecontrolsUrl ? { vibecontrolsUrl } : {}
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
900
1213
|
function usageLine(detail) {
|
|
901
1214
|
const credits = detail.usageToday?.credits;
|
|
902
1215
|
const usage = credits != null ? `, ${credits} credits used today` : "";
|
|
@@ -1388,4 +1701,4 @@ function ApprovalInbox({ stewardId, pollIntervalMs = 15e3 }) {
|
|
|
1388
1701
|
});
|
|
1389
1702
|
}
|
|
1390
1703
|
|
|
1391
|
-
export { ApprovalInbox, DEFAULT_STEWARDS_THEME, StewardBuilder, StewardConsole, StewardRunView, StewardsRequestError, StewardsSdkProvider, createStewardsEventBus, themeToStyle, useStewardsEvent, useStewardsSdk };
|
|
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 };
|