@botmanor/fe-sdk 2026.1205.2 → 2026.1205.4
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/guided-errors-CiQTVYn8.d.ts +386 -0
- package/dist/guided-errors-D5vT9owt.js +2383 -0
- package/dist/guided-errors.d.ts +9 -0
- package/dist/guided-errors.js +4 -0
- package/dist/index.d.ts +141 -5
- package/dist/index.js +1100 -116
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { C as GUIDED_ENTRIES, D as permissionLabelKey, E as PERMISSION_LABELS, S as AGENT_STATUS_SHORT_LABELS, T as GUIDED_PERMISSIONS, _ as isDefiniteRefusal, a as fillGuidedParams, b as extractGuidedSource, c as guidedTranslateFrom, d as botmanorPath, f as crossShellUrl, g as guidedI18nBase, h as describeGuidedError, i as englishGuidedTranslate, l as planGuidedActions, m as buildGuidedError, n as stepReasonCode, o as guidedParams, p as resolveGuidedLocation, r as stopReasonLabel, s as guidedText, t as describeRunFailure, u as DEFAULT_BOTMANOR_APP_URL, v as isStaleStateError, w as STOP_REASON_LABELS, x as AGENT_STATUS_LABELS, y as reasonCamel } from "./guided-errors-D5vT9owt.js";
|
|
4
5
|
|
|
5
6
|
// src/graphql/client.ts
|
|
6
7
|
/** Failure from the gateway: a transport status or a GraphQL error code. */
|
|
7
8
|
var StewardsRequestError = class extends Error {
|
|
8
9
|
code;
|
|
9
10
|
status;
|
|
10
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The plan quota a `QUOTA_EXHAUSTED` refusal names, e.g.
|
|
13
|
+
* `botmanor.stewards.runs` (`extensions.quotaKey`, or the older `quotaName`).
|
|
14
|
+
*/
|
|
11
15
|
quotaName;
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The GraphQL error's whole `extensions` object: `reason`, `i18nKey` and the
|
|
18
|
+
* context fields the guided-error catalog reads (BOFF-18785). Empty for a
|
|
19
|
+
* transport failure.
|
|
20
|
+
*/
|
|
21
|
+
extensions;
|
|
22
|
+
constructor(message, code, status, quotaName, extensions = {}) {
|
|
13
23
|
super(message);
|
|
14
24
|
this.name = "StewardsRequestError";
|
|
15
25
|
this.code = code;
|
|
16
26
|
this.status = status;
|
|
17
27
|
if (quotaName) this.quotaName = quotaName;
|
|
28
|
+
this.extensions = extensions;
|
|
29
|
+
}
|
|
30
|
+
/** `extensions.reason`, the catalog's guided code, when the service sent one. */
|
|
31
|
+
get reason() {
|
|
32
|
+
const reason = this.extensions.reason;
|
|
33
|
+
return typeof reason === "string" ? reason : void 0;
|
|
34
|
+
}
|
|
35
|
+
/** `extensions.i18nKey`, the service's translation key, when it sent one. */
|
|
36
|
+
get i18nKey() {
|
|
37
|
+
const key = this.extensions.i18nKey;
|
|
38
|
+
return typeof key === "string" ? key : void 0;
|
|
18
39
|
}
|
|
19
40
|
};
|
|
20
41
|
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
@@ -112,17 +133,23 @@ function createStewardsClient(options) {
|
|
|
112
133
|
if (first) {
|
|
113
134
|
const code = typeof first.extensions?.code === "string" ? first.extensions.code : "GRAPHQL_ERROR";
|
|
114
135
|
if (code === "UNAUTHENTICATED") options.reportAuthExpired("gateway rejected the token");
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
else if (code === "FORBIDDEN" && typeof first.extensions?.authFailure === "string") options.reportAuthExpired(`gateway refused the session: ${first.extensions.authFailure}`);
|
|
137
|
+
const headerWait = Number(response.headers.get("retry-after"));
|
|
138
|
+
const extensions = first.extensions?.retryAfter === void 0 && Number.isFinite(headerWait) && headerWait > 0 ? {
|
|
139
|
+
...first.extensions ?? {},
|
|
140
|
+
retryAfter: headerWait
|
|
141
|
+
} : first.extensions ?? {};
|
|
142
|
+
const quotaName = typeof extensions.quotaKey === "string" ? extensions.quotaKey : typeof extensions.quotaName === "string" ? extensions.quotaName : void 0;
|
|
143
|
+
throw new StewardsRequestError(first.message ?? "Request failed", code, response.status, quotaName, extensions);
|
|
117
144
|
}
|
|
118
145
|
if (!response.ok || body.data == null) throw new StewardsRequestError(`Unexpected response from the Stewards service (${response.status})`, "BAD_RESPONSE", response.status);
|
|
119
146
|
return body.data;
|
|
120
147
|
};
|
|
121
|
-
return { async request(document, variables = {}, signal) {
|
|
148
|
+
return { async request(document, variables = {}, signal, requestOptions = {}) {
|
|
122
149
|
try {
|
|
123
150
|
return await send(document, variables, signal);
|
|
124
151
|
} catch (err) {
|
|
125
|
-
if (err instanceof StewardsRequestError && !signal?.aborted) options.reportFailure?.(err);
|
|
152
|
+
if (err instanceof StewardsRequestError && !signal?.aborted && !requestOptions.silent) options.reportFailure?.(err);
|
|
126
153
|
throw err;
|
|
127
154
|
}
|
|
128
155
|
} };
|
|
@@ -212,13 +239,16 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
212
239
|
code: error.code,
|
|
213
240
|
message: error.message,
|
|
214
241
|
...error.status !== void 0 ? { status: error.status } : {},
|
|
215
|
-
...error.quotaName ? { quotaName: error.quotaName } : {}
|
|
242
|
+
...error.quotaName ? { quotaName: error.quotaName } : {},
|
|
243
|
+
...error.reason ? { reason: error.reason } : {},
|
|
244
|
+
...error.i18nKey ? { i18nKey: error.i18nKey } : {},
|
|
245
|
+
...Object.keys(error.extensions).length > 0 ? { extensions: error.extensions } : {}
|
|
216
246
|
});
|
|
217
247
|
}
|
|
218
248
|
})
|
|
219
249
|
};
|
|
220
250
|
});
|
|
221
|
-
const { gatewayUrl, workspaceId, getAccessToken, getWorkspaceToken, sameOriginCredentials, onTokenExpired, theme } = config;
|
|
251
|
+
const { gatewayUrl, workspaceId, getAccessToken, getWorkspaceToken, sameOriginCredentials, onTokenExpired, theme, resolveTarget, navigate, hasPermission, viewerActorId, resolveActorName, translate, onUpgrade } = config;
|
|
222
252
|
const value = useMemo(() => ({
|
|
223
253
|
config: {
|
|
224
254
|
gatewayUrl,
|
|
@@ -228,7 +258,14 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
228
258
|
...sameOriginCredentials ? { sameOriginCredentials } : {},
|
|
229
259
|
...onTokenExpired ? { onTokenExpired } : {},
|
|
230
260
|
...onEvent ? { onEvent } : {},
|
|
231
|
-
...theme ? { theme } : {}
|
|
261
|
+
...theme ? { theme } : {},
|
|
262
|
+
...resolveTarget ? { resolveTarget } : {},
|
|
263
|
+
...navigate ? { navigate } : {},
|
|
264
|
+
...hasPermission ? { hasPermission } : {},
|
|
265
|
+
...viewerActorId !== void 0 ? { viewerActorId } : {},
|
|
266
|
+
...resolveActorName ? { resolveActorName } : {},
|
|
267
|
+
...translate ? { translate } : {},
|
|
268
|
+
...onUpgrade ? { onUpgrade } : {}
|
|
232
269
|
},
|
|
233
270
|
events,
|
|
234
271
|
...services
|
|
@@ -241,6 +278,13 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
241
278
|
onTokenExpired,
|
|
242
279
|
onEvent,
|
|
243
280
|
theme,
|
|
281
|
+
resolveTarget,
|
|
282
|
+
navigate,
|
|
283
|
+
hasPermission,
|
|
284
|
+
viewerActorId,
|
|
285
|
+
resolveActorName,
|
|
286
|
+
translate,
|
|
287
|
+
onUpgrade,
|
|
244
288
|
events,
|
|
245
289
|
services
|
|
246
290
|
]);
|
|
@@ -322,7 +366,7 @@ const RUN_SUMMARY = `
|
|
|
322
366
|
const STEWARD_DETAIL = `
|
|
323
367
|
id agentId ownerActorId status defaultDeskKind pendingApprovalCount
|
|
324
368
|
createdAt updatedAt
|
|
325
|
-
agent { id name capabilities }
|
|
369
|
+
agent { id name capabilities status llmModelId }
|
|
326
370
|
charter {
|
|
327
371
|
autonomyLevel charterText charterVersion allowedToolKeys
|
|
328
372
|
allowedConnectionIds timezone dryRunDefault
|
|
@@ -335,7 +379,7 @@ const STEWARD_DETAIL = `
|
|
|
335
379
|
const LIST_STEWARDS = `query ListBotmanorStewards($filter: BotmanorStewardFilterInput, $pagination: PaginationInput) {
|
|
336
380
|
listBotmanorStewards(filter: $filter, pagination: $pagination) {
|
|
337
381
|
id agentId status defaultDeskKind pendingApprovalCount
|
|
338
|
-
agent { id name }
|
|
382
|
+
agent { id name status }
|
|
339
383
|
charter { autonomyLevel budgetPerDay { credits } }
|
|
340
384
|
usageToday { credits }
|
|
341
385
|
lastRun { id status startedAt }
|
|
@@ -372,8 +416,16 @@ const CREATE_STEWARD = `mutation CreateBotmanorSteward($input: CreateBotmanorSte
|
|
|
372
416
|
const UPDATE_STEWARD_CHARTER = `mutation UpdateBotmanorStewardCharter($id: ID!, $input: UpdateBotmanorStewardCharterInput!) {
|
|
373
417
|
updateBotmanorStewardCharter(id: $id, input: $input) { ${STEWARD_DETAIL} }
|
|
374
418
|
}`;
|
|
375
|
-
const
|
|
376
|
-
|
|
419
|
+
const CANDIDATE = `id name description status capabilities llmModelId`;
|
|
420
|
+
/**
|
|
421
|
+
* The agents that can become a steward, one filtered list per status, so a
|
|
422
|
+
* workspace with many archived or training agents never pushes an active one
|
|
423
|
+
* off the first page (BOFF-18785).
|
|
424
|
+
*/
|
|
425
|
+
const LIST_PICKABLE_AGENTS = `query ListStewardPickableAgents($pagination: PaginationInput) {
|
|
426
|
+
active: listBotmanorAgents(filters: { status: ACTIVE }, pagination: $pagination) { ${CANDIDATE} }
|
|
427
|
+
draft: listBotmanorAgents(filters: { status: DRAFT }, pagination: $pagination) { ${CANDIDATE} }
|
|
428
|
+
paused: listBotmanorAgents(filters: { status: PAUSED }, pagination: $pagination) { ${CANDIDATE} }
|
|
377
429
|
}`;
|
|
378
430
|
const LIST_STEWARD_APPROVALS = `query ListBotmanorToolApprovals($filter: BotmanorToolApprovalFilterInput, $pagination: PaginationInput) {
|
|
379
431
|
listBotmanorToolApprovals(filter: $filter, pagination: $pagination) {
|
|
@@ -422,6 +474,48 @@ const GRANT_OWN_MACHINE = `mutation GrantStewardOwnMachine($input: GrantVibecont
|
|
|
422
474
|
const REVOKE_OWN_MACHINE_GRANT = `mutation RevokeStewardOwnMachineGrant($id: ID!) {
|
|
423
475
|
revokeVibecontrolsStewardGrant(id: $id) { ${OWN_MACHINE_GRANT} }
|
|
424
476
|
}`;
|
|
477
|
+
/**
|
|
478
|
+
* Guided-error fixes (BOFF-18785). The agent's status and model pick the
|
|
479
|
+
* right guidance when an older service does not send them with the error;
|
|
480
|
+
* publishing, requesting activation and activating are the inline fixes.
|
|
481
|
+
*/
|
|
482
|
+
const GET_AGENT_STATUS = `query GetStewardAgentStatus($id: ID!) {
|
|
483
|
+
getBotmanorAgent(id: $id) { id name status llmModelId }
|
|
484
|
+
}`;
|
|
485
|
+
/** Publish (or resume) an agent: `updateBotmanorAgent` with status ACTIVE. */
|
|
486
|
+
const PUBLISH_AGENT = `mutation PublishStewardAgent($id: ID!) {
|
|
487
|
+
updateBotmanorAgent(id: $id, input: { status: ACTIVE }) { id status llmModelId }
|
|
488
|
+
}`;
|
|
489
|
+
const REQUEST_AGENT_ACTIVATION = `mutation RequestStewardAgentActivation($agentId: ID!) {
|
|
490
|
+
requestBotmanorAgentActivation(agentId: $agentId) { id status }
|
|
491
|
+
}`;
|
|
492
|
+
/** One activation request's status: PENDING until a reviewer decides or it is withdrawn. */
|
|
493
|
+
const GET_AGENT_ACTIVATION_REQUEST = `query GetStewardAgentActivationRequest($id: ID!) {
|
|
494
|
+
getBotmanorAgentApprovalRequest(id: $id) { id status isStale }
|
|
495
|
+
}`;
|
|
496
|
+
const SET_STEWARD_STATUS = `mutation SetBotmanorStewardStatus($id: ID!, $status: BotmanorStewardStatus!) {
|
|
497
|
+
setBotmanorStewardStatus(id: $id, status: $status) { id status }
|
|
498
|
+
}`;
|
|
499
|
+
/** The plan's cloud desk minutes: no assignment means the plan has none. */
|
|
500
|
+
const CHECK_DESK_MINUTES = `query StewardDeskMinutes($workspaceId: ID!) {
|
|
501
|
+
checkWorkspaceQuota(quotaName: "botmanor.stewards.desk-minutes", workspaceId: $workspaceId) {
|
|
502
|
+
allowed assignmentId limitLeft noLimit
|
|
503
|
+
}
|
|
504
|
+
}`;
|
|
505
|
+
/**
|
|
506
|
+
* A run's structured failure (guided-error catalog section 1.2). A separate,
|
|
507
|
+
* silent query: a service that does not expose `failure` yet refuses the field,
|
|
508
|
+
* and the run view then reads the stop reason and the steps instead.
|
|
509
|
+
*/
|
|
510
|
+
const GET_STEWARD_RUN_FAILURE = `query GetBotmanorStewardRunFailure($id: ID!) {
|
|
511
|
+
getBotmanorStewardRun(id: $id) {
|
|
512
|
+
id
|
|
513
|
+
failure {
|
|
514
|
+
code message agentId toolKey connectionId machineId budgetLevel budgetKey
|
|
515
|
+
budgetCap stepCode
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}`;
|
|
425
519
|
|
|
426
520
|
// src/graphql/hooks.ts
|
|
427
521
|
function asError(err) {
|
|
@@ -464,12 +558,13 @@ function useStewardsQuery(document, variables, options = {}) {
|
|
|
464
558
|
variablesKey
|
|
465
559
|
]);
|
|
466
560
|
const skip = options.skip === true;
|
|
561
|
+
const silent = options.silent === true;
|
|
467
562
|
useEffect(() => {
|
|
468
563
|
if (skip) return void 0;
|
|
469
564
|
let active = true;
|
|
470
565
|
const controller = new AbortController();
|
|
471
566
|
const vars = JSON.parse(variablesKey);
|
|
472
|
-
client.request(document, vars, controller.signal).then((data) => {
|
|
567
|
+
client.request(document, vars, controller.signal, { silent }).then((data) => {
|
|
473
568
|
if (!active) return;
|
|
474
569
|
setResult({
|
|
475
570
|
key: requestKey,
|
|
@@ -496,6 +591,7 @@ function useStewardsQuery(document, variables, options = {}) {
|
|
|
496
591
|
variablesKey,
|
|
497
592
|
requestKey,
|
|
498
593
|
skip,
|
|
594
|
+
silent,
|
|
499
595
|
nonce
|
|
500
596
|
]);
|
|
501
597
|
const current = result?.key === requestKey ? result : void 0;
|
|
@@ -544,25 +640,6 @@ function useStewardsMutation(document) {
|
|
|
544
640
|
};
|
|
545
641
|
}
|
|
546
642
|
|
|
547
|
-
// src/theme/ScopedTheme.tsx
|
|
548
|
-
/** The SDK's only styling root: theme variables live on this element alone. */
|
|
549
|
-
function ScopedTheme({ theme, label, component, children }) {
|
|
550
|
-
return /* @__PURE__ */ jsx("section", {
|
|
551
|
-
"aria-label": label,
|
|
552
|
-
"data-botmanor-sdk": component,
|
|
553
|
-
style: {
|
|
554
|
-
...themeToStyle(theme),
|
|
555
|
-
background: themeVar("surface"),
|
|
556
|
-
color: themeVar("text"),
|
|
557
|
-
border: `1px solid ${themeVar("border")}`,
|
|
558
|
-
borderRadius: themeVar("radius"),
|
|
559
|
-
fontFamily: themeVar("fontFamily"),
|
|
560
|
-
padding: "16px"
|
|
561
|
-
},
|
|
562
|
-
children
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
643
|
// src/components/ui.tsx
|
|
567
644
|
/** Shared, token-only building blocks for the four SDK surfaces. */
|
|
568
645
|
const headingStyle = {
|
|
@@ -687,6 +764,452 @@ function humanize(value) {
|
|
|
687
764
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
688
765
|
}
|
|
689
766
|
|
|
767
|
+
// src/components/GuidedErrorNote.tsx
|
|
768
|
+
/** VibeControls in production, the default target of "Open VibeControls". */
|
|
769
|
+
const VIBECONTROLS_APP_URL = "https://app.vibecontrols.com";
|
|
770
|
+
/** The inline fixes the SDK runs itself; others fall back to a link. */
|
|
771
|
+
const SDK_MUTATIONS = /* @__PURE__ */ new Set([
|
|
772
|
+
"PUBLISH_AGENT",
|
|
773
|
+
"REQUEST_AGENT_ACTIVATION",
|
|
774
|
+
"ACTIVATE_STEWARD"
|
|
775
|
+
]);
|
|
776
|
+
const boxStyle = {
|
|
777
|
+
border: `1px solid ${themeVar("danger")}`,
|
|
778
|
+
borderRadius: themeVar("radius"),
|
|
779
|
+
margin: "8px 0 0",
|
|
780
|
+
padding: "8px 12px",
|
|
781
|
+
fontSize: "14px"
|
|
782
|
+
};
|
|
783
|
+
const lineStyle = { margin: "4px 0 0" };
|
|
784
|
+
const mutedLineStyle = {
|
|
785
|
+
...lineStyle,
|
|
786
|
+
color: themeVar("textMuted")
|
|
787
|
+
};
|
|
788
|
+
const linkStyle = {
|
|
789
|
+
color: themeVar("accent"),
|
|
790
|
+
fontSize: "13px",
|
|
791
|
+
fontWeight: 500
|
|
792
|
+
};
|
|
793
|
+
/**
|
|
794
|
+
* Where the SDK sends a guided action: the host's resolver when it gave one,
|
|
795
|
+
* else BotManor's own pages on app.botmanor.com and VibeControls.
|
|
796
|
+
*/
|
|
797
|
+
function useGuidedEnvironment(canRetry, mutations = SDK_MUTATIONS) {
|
|
798
|
+
const { config } = useStewardsSdk();
|
|
799
|
+
const { resolveTarget, hasPermission, viewerActorId, translate, onUpgrade } = config;
|
|
800
|
+
return useMemo(() => {
|
|
801
|
+
const href = (location) => {
|
|
802
|
+
if (location.kind === "href") return location.href;
|
|
803
|
+
if (location.kind === "route") return location.path;
|
|
804
|
+
return crossShellUrl(location.product === "vibecontrols" ? VIBECONTROLS_APP_URL : DEFAULT_BOTMANOR_APP_URL, location.product === "vibecontrols" ? "/" : location.path);
|
|
805
|
+
};
|
|
806
|
+
return {
|
|
807
|
+
shell: { kind: "other" },
|
|
808
|
+
locate: (target, params) => {
|
|
809
|
+
if (resolveTarget) {
|
|
810
|
+
const resolved = resolveTarget(target, params);
|
|
811
|
+
return resolved ? {
|
|
812
|
+
kind: "href",
|
|
813
|
+
href: resolved
|
|
814
|
+
} : void 0;
|
|
815
|
+
}
|
|
816
|
+
if (target === "VIBECONTROLS") return {
|
|
817
|
+
kind: "href",
|
|
818
|
+
href: `${VIBECONTROLS_APP_URL}/`
|
|
819
|
+
};
|
|
820
|
+
const path = botmanorPath(target, params);
|
|
821
|
+
return path ? {
|
|
822
|
+
kind: "href",
|
|
823
|
+
href: crossShellUrl(DEFAULT_BOTMANOR_APP_URL, path)
|
|
824
|
+
} : void 0;
|
|
825
|
+
},
|
|
826
|
+
mutations,
|
|
827
|
+
canRetry,
|
|
828
|
+
canUpgrade: !!onUpgrade || !!resolveTarget?.("BILLING_PLANS", {}),
|
|
829
|
+
...hasPermission ? { hasPermission } : {},
|
|
830
|
+
...viewerActorId !== void 0 ? { viewerActorId } : {},
|
|
831
|
+
...translate ? { t: translate } : {},
|
|
832
|
+
href
|
|
833
|
+
};
|
|
834
|
+
}, [
|
|
835
|
+
resolveTarget,
|
|
836
|
+
hasPermission,
|
|
837
|
+
viewerActorId,
|
|
838
|
+
translate,
|
|
839
|
+
onUpgrade,
|
|
840
|
+
canRetry,
|
|
841
|
+
mutations
|
|
842
|
+
]);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* An error, explained (BOFF-18785): what happened, why, the next step, up to
|
|
846
|
+
* two actions the viewer may take, and who can fix it when they cannot. A
|
|
847
|
+
* local validation error (no code) reads as its own message, as before.
|
|
848
|
+
*/
|
|
849
|
+
function GuidedErrorNote({ error, guided: given, context, onRetry, onFixed, tone = "error", canActivateSteward = true }) {
|
|
850
|
+
const [fixError, setFixError] = useState(void 0);
|
|
851
|
+
const fixFailed = !!fixError && fixError.for === (given ?? error);
|
|
852
|
+
const mounted = useRef(true);
|
|
853
|
+
useEffect(() => {
|
|
854
|
+
mounted.current = true;
|
|
855
|
+
return () => {
|
|
856
|
+
mounted.current = false;
|
|
857
|
+
};
|
|
858
|
+
}, []);
|
|
859
|
+
const isMounted = useCallback(() => mounted.current, []);
|
|
860
|
+
const subjectRef = useRef(given ?? error);
|
|
861
|
+
useEffect(() => {
|
|
862
|
+
subjectRef.current = given ?? error;
|
|
863
|
+
});
|
|
864
|
+
const isCurrent = useCallback((subject) => mounted.current && subjectRef.current === subject, []);
|
|
865
|
+
const [requestedFor, setRequestedFor] = useState(void 0);
|
|
866
|
+
const shownError = fixError && fixError.for === (given ?? error) ? fixError.error : error;
|
|
867
|
+
const base = useMemo(() => fixError && fixError.for === (given ?? error) ? describeGuidedError(fixError.error, context) : given ?? (error ? describeGuidedError(error, context) : void 0), [
|
|
868
|
+
given,
|
|
869
|
+
error,
|
|
870
|
+
fixError,
|
|
871
|
+
context
|
|
872
|
+
]);
|
|
873
|
+
const agentId = base?.params.agentId ? String(base.params.agentId) : void 0;
|
|
874
|
+
const needsAgent = base?.reason === "AGENT_NOT_ACTIVE" && !!agentId && (!context?.agent?.status || context.agent.status === "ACTIVE") && typeof extractGuidedSource(shownError)?.extensions?.agentStatus !== "string";
|
|
875
|
+
const fetchedAgent = useStewardsQuery("query GetStewardAgentStatus($id: ID!) {\n getBotmanorAgent(id: $id) { id name status llmModelId }\n}", { id: agentId ?? "" }, {
|
|
876
|
+
skip: !needsAgent,
|
|
877
|
+
silent: true
|
|
878
|
+
}).data?.getBotmanorAgent ?? void 0;
|
|
879
|
+
const guided = useMemo(() => {
|
|
880
|
+
if (!base || !needsAgent || !fetchedAgent || !shownError) return base;
|
|
881
|
+
return describeGuidedError(shownError, {
|
|
882
|
+
...context,
|
|
883
|
+
agent: fetchedAgent
|
|
884
|
+
}) ?? base;
|
|
885
|
+
}, [
|
|
886
|
+
base,
|
|
887
|
+
needsAgent,
|
|
888
|
+
fetchedAgent,
|
|
889
|
+
shownError,
|
|
890
|
+
context
|
|
891
|
+
]);
|
|
892
|
+
if (!guided) return null;
|
|
893
|
+
const guidedAgent = guided.params.agentId ? String(guided.params.agentId) : void 0;
|
|
894
|
+
const activationGuidance = guided.reason === "AGENT_NOT_ACTIVE" || guided.reason === "AGENT_APPROVAL_REQUIRED" || guided.reason === "ACTIVATION_ALREADY_PENDING" || guided.reason === "ACTIVATION_REQUEST_STALE";
|
|
895
|
+
if (requestedFor && activationGuidance && guidedAgent === requestedFor.agentId) return /* @__PURE__ */ jsx(RequestedNote, {
|
|
896
|
+
agentId: requestedFor.agentId,
|
|
897
|
+
...requestedFor.requestId ? { requestId: requestedFor.requestId } : {},
|
|
898
|
+
isCurrent: () => isCurrent(given ?? error),
|
|
899
|
+
onSettled: (published) => {
|
|
900
|
+
setRequestedFor(void 0);
|
|
901
|
+
if (published) Promise.resolve(onRetry?.());
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
if (guided.reason === "UNKNOWN" && !guided.code && guided.serverMessage) return /* @__PURE__ */ jsx(PlainNote, { message: guided.serverMessage });
|
|
905
|
+
return /* @__PURE__ */ jsx(GuidedBody, {
|
|
906
|
+
canActivateSteward,
|
|
907
|
+
guided,
|
|
908
|
+
tone,
|
|
909
|
+
onRetry,
|
|
910
|
+
onFixed: (mutation, params) => {
|
|
911
|
+
if (mutation === "REQUEST_AGENT_ACTIVATION" && params.agentId) setRequestedFor({
|
|
912
|
+
agentId: String(params.agentId),
|
|
913
|
+
...params.activationRequestId ? { requestId: String(params.activationRequestId) } : {}
|
|
914
|
+
});
|
|
915
|
+
setFixError(void 0);
|
|
916
|
+
onFixed?.(mutation);
|
|
917
|
+
},
|
|
918
|
+
...fixFailed && fixError ? { retryFix: {
|
|
919
|
+
mutation: fixError.mutation,
|
|
920
|
+
params: fixError.params
|
|
921
|
+
} } : {},
|
|
922
|
+
isMounted,
|
|
923
|
+
isCurrent: () => isCurrent(given ?? error),
|
|
924
|
+
onFixFailed: (err, mutation, params) => setFixError({
|
|
925
|
+
for: given ?? error,
|
|
926
|
+
error: err,
|
|
927
|
+
mutation,
|
|
928
|
+
params
|
|
929
|
+
})
|
|
930
|
+
}, `${guided.i18nKey}|${String(guided.params.agentId ?? "")}|${String(guided.params.stewardId ?? "")}`);
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* An activation request is waiting for a reviewer. "Check again" reads the
|
|
934
|
+
* agent: once it is published the note gives way to the screen (reloaded);
|
|
935
|
+
* while it is not, the note says it is still waiting.
|
|
936
|
+
*/
|
|
937
|
+
function RequestedNote({ agentId, requestId, isCurrent, onSettled }) {
|
|
938
|
+
const { client, config } = useStewardsSdk();
|
|
939
|
+
const t = config.translate ?? englishGuidedTranslate;
|
|
940
|
+
const [checking, setChecking] = useState(false);
|
|
941
|
+
const [stillWaiting, setStillWaiting] = useState(false);
|
|
942
|
+
const check = async () => {
|
|
943
|
+
setChecking(true);
|
|
944
|
+
try {
|
|
945
|
+
const agent = await client.request(GET_AGENT_STATUS, { id: agentId }, void 0, { silent: true });
|
|
946
|
+
const request = agent.getBotmanorAgent?.status !== "ACTIVE" && requestId ? await client.request(GET_AGENT_ACTIVATION_REQUEST, { id: requestId }, void 0, { silent: true }) : void 0;
|
|
947
|
+
if (!isCurrent()) return;
|
|
948
|
+
const published = agent.getBotmanorAgent?.status === "ACTIVE";
|
|
949
|
+
const open = request?.getBotmanorAgentApprovalRequest;
|
|
950
|
+
const pending = !request || open?.status === "PENDING" && !open.isStale;
|
|
951
|
+
if (published || !pending) onSettled(published);
|
|
952
|
+
else setStillWaiting(true);
|
|
953
|
+
} catch {
|
|
954
|
+
if (isCurrent()) setStillWaiting(true);
|
|
955
|
+
} finally {
|
|
956
|
+
setChecking(false);
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
960
|
+
role: "status",
|
|
961
|
+
style: {
|
|
962
|
+
...themeToStyle(config.theme),
|
|
963
|
+
...mutedLineStyle
|
|
964
|
+
},
|
|
965
|
+
children: [
|
|
966
|
+
stillWaiting ? t("guidedErrors.done.activationStillPending", "Still waiting for a reviewer to approve the agent.") : t("guidedErrors.done.activationRequested", "Activation requested. You can continue once a reviewer approves the agent."),
|
|
967
|
+
" ",
|
|
968
|
+
/* @__PURE__ */ jsx(Button, {
|
|
969
|
+
onClick: () => void check(),
|
|
970
|
+
disabled: checking,
|
|
971
|
+
children: t("guidedErrors.actions.checkAgain", "Check again")
|
|
972
|
+
})
|
|
973
|
+
]
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
function PlainNote({ message }) {
|
|
977
|
+
const { config } = useStewardsSdk();
|
|
978
|
+
return /* @__PURE__ */ jsx("p", {
|
|
979
|
+
role: "alert",
|
|
980
|
+
style: {
|
|
981
|
+
...themeToStyle(config.theme),
|
|
982
|
+
...lineStyle,
|
|
983
|
+
margin: "8px 0 0",
|
|
984
|
+
color: themeVar("danger"),
|
|
985
|
+
fontWeight: 500
|
|
986
|
+
},
|
|
987
|
+
children: message
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
/** The SDK's fixes without activating the steward. */
|
|
991
|
+
const SDK_MUTATIONS_NO_ACTIVATE = /* @__PURE__ */ new Set(["PUBLISH_AGENT", "REQUEST_AGENT_ACTIVATION"]);
|
|
992
|
+
function GuidedBody({ canActivateSteward, guided, tone, onRetry, onFixed, retryFix, onFixFailed, isMounted, isCurrent }) {
|
|
993
|
+
const { client, config } = useStewardsSdk();
|
|
994
|
+
const requestIdRef = useRef(void 0);
|
|
995
|
+
const env = useGuidedEnvironment(!!onRetry || !!retryFix, canActivateSteward ? SDK_MUTATIONS : SDK_MUTATIONS_NO_ACTIVATE);
|
|
996
|
+
const [busy, setBusy] = useState(false);
|
|
997
|
+
const retryRef = useRef(onRetry);
|
|
998
|
+
useEffect(() => {
|
|
999
|
+
retryRef.current = onRetry;
|
|
1000
|
+
});
|
|
1001
|
+
const waitUntil = useMemo(() => guided.retryAfterSeconds ? Date.now() + guided.retryAfterSeconds * 1e3 : 0, [guided]);
|
|
1002
|
+
const [now, setNow] = useState(() => Date.now());
|
|
1003
|
+
const waitLeft = Math.max(0, Math.ceil((waitUntil - now) / 1e3));
|
|
1004
|
+
useEffect(() => {
|
|
1005
|
+
if (waitLeft <= 0) return void 0;
|
|
1006
|
+
const timer = setTimeout(() => setNow(Date.now()), 1e3);
|
|
1007
|
+
return () => clearTimeout(timer);
|
|
1008
|
+
}, [waitLeft, now]);
|
|
1009
|
+
const [copied, setCopied] = useState(void 0);
|
|
1010
|
+
const extraParams = useMemo(() => {
|
|
1011
|
+
const ownerId = guided.params.ownerActorId;
|
|
1012
|
+
const machineOwnerId = guided.params.machineOwnerActorId;
|
|
1013
|
+
return {
|
|
1014
|
+
ownerName: ownerId !== void 0 ? config.resolveActorName?.(String(ownerId)) : void 0,
|
|
1015
|
+
machineOwner: machineOwnerId !== void 0 ? config.resolveActorName?.(String(machineOwnerId)) : void 0
|
|
1016
|
+
};
|
|
1017
|
+
}, [guided.params, config]);
|
|
1018
|
+
const t = env.t ?? englishGuidedTranslate;
|
|
1019
|
+
const text = guidedText(guided, t, extraParams);
|
|
1020
|
+
const plan = planGuidedActions(guided, {
|
|
1021
|
+
...env,
|
|
1022
|
+
extraParams
|
|
1023
|
+
});
|
|
1024
|
+
/** Runs one fix; false when it only queued something (an activation request). */
|
|
1025
|
+
const perform = useCallback(async (mutation, params) => {
|
|
1026
|
+
const agentId = params.agentId ? String(params.agentId) : void 0;
|
|
1027
|
+
const stewardId = params.stewardId ? String(params.stewardId) : void 0;
|
|
1028
|
+
if (mutation === "PUBLISH_AGENT" && agentId) {
|
|
1029
|
+
await client.request(PUBLISH_AGENT, { id: agentId });
|
|
1030
|
+
return true;
|
|
1031
|
+
}
|
|
1032
|
+
if (mutation === "REQUEST_AGENT_ACTIVATION" && agentId) {
|
|
1033
|
+
const made = await client.request(REQUEST_AGENT_ACTIVATION, { agentId });
|
|
1034
|
+
requestIdRef.current = made.requestBotmanorAgentActivation.id;
|
|
1035
|
+
return false;
|
|
1036
|
+
}
|
|
1037
|
+
if (mutation === "ACTIVATE_STEWARD" && stewardId) {
|
|
1038
|
+
await client.request(SET_STEWARD_STATUS, {
|
|
1039
|
+
id: stewardId,
|
|
1040
|
+
status: "ACTIVE"
|
|
1041
|
+
});
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
return false;
|
|
1045
|
+
}, [client]);
|
|
1046
|
+
const runFix = useCallback(async (mutation, params = guided.params) => {
|
|
1047
|
+
const interrupted = retryFix && retryFix.mutation !== mutation ? retryFix : void 0;
|
|
1048
|
+
setBusy(true);
|
|
1049
|
+
let step = {
|
|
1050
|
+
mutation,
|
|
1051
|
+
params
|
|
1052
|
+
};
|
|
1053
|
+
try {
|
|
1054
|
+
const continues = await perform(mutation, params);
|
|
1055
|
+
if (!isCurrent()) return;
|
|
1056
|
+
if (!continues) {
|
|
1057
|
+
onFixed?.(mutation, requestIdRef.current ? {
|
|
1058
|
+
...params,
|
|
1059
|
+
activationRequestId: requestIdRef.current
|
|
1060
|
+
} : params);
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
if (interrupted) {
|
|
1064
|
+
step = interrupted;
|
|
1065
|
+
const next = await perform(interrupted.mutation, interrupted.params);
|
|
1066
|
+
if (!isCurrent()) return;
|
|
1067
|
+
if (!next) {
|
|
1068
|
+
onFixed?.(interrupted.mutation, interrupted.params);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
onFixed?.(step.mutation, step.params);
|
|
1073
|
+
try {
|
|
1074
|
+
await retryRef.current?.();
|
|
1075
|
+
} catch {}
|
|
1076
|
+
} catch (err) {
|
|
1077
|
+
onFixFailed(err instanceof Error ? err : new Error(String(err)), step.mutation, step.params);
|
|
1078
|
+
} finally {
|
|
1079
|
+
if (isMounted()) setBusy(false);
|
|
1080
|
+
}
|
|
1081
|
+
}, [
|
|
1082
|
+
guided.params,
|
|
1083
|
+
retryFix,
|
|
1084
|
+
perform,
|
|
1085
|
+
onFixed,
|
|
1086
|
+
onFixFailed,
|
|
1087
|
+
isMounted,
|
|
1088
|
+
isCurrent
|
|
1089
|
+
]);
|
|
1090
|
+
const act = (planned) => {
|
|
1091
|
+
const { action } = planned;
|
|
1092
|
+
if (action.kind === "retry") {
|
|
1093
|
+
if (retryFix) runFix(retryFix.mutation, retryFix.params);
|
|
1094
|
+
else Promise.resolve(onRetry?.());
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
if (action.kind === "mutation" && action.mutation) {
|
|
1098
|
+
runFix(action.mutation);
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
if (action.kind === "upgrade" && config.onUpgrade) {
|
|
1102
|
+
config.onUpgrade(guided);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
if (planned.location) {
|
|
1106
|
+
const href = env.href(planned.location);
|
|
1107
|
+
if (href.startsWith("/") && config.navigate) config.navigate(href);
|
|
1108
|
+
else if (typeof window !== "undefined") window.location.assign(href);
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
const details = [
|
|
1112
|
+
guided.reason,
|
|
1113
|
+
guided.code,
|
|
1114
|
+
guided.traceId ? `trace ${guided.traceId}` : void 0
|
|
1115
|
+
].filter(Boolean).join(" · ");
|
|
1116
|
+
const copyDetails = () => {
|
|
1117
|
+
globalThis.navigator?.clipboard?.writeText(details).then(() => setCopied(details), () => void 0);
|
|
1118
|
+
};
|
|
1119
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1120
|
+
role: tone === "error" ? "alert" : "status",
|
|
1121
|
+
"data-guided-reason": guided.reason,
|
|
1122
|
+
...guided.variant ? { "data-guided-variant": guided.variant } : {},
|
|
1123
|
+
style: {
|
|
1124
|
+
...themeToStyle(config.theme),
|
|
1125
|
+
...boxStyle,
|
|
1126
|
+
...tone === "error" ? {} : { border: `1px solid ${themeVar("border")}` }
|
|
1127
|
+
},
|
|
1128
|
+
children: [
|
|
1129
|
+
/* @__PURE__ */ jsx("strong", {
|
|
1130
|
+
style: tone === "error" ? { color: themeVar("danger") } : void 0,
|
|
1131
|
+
children: text.title
|
|
1132
|
+
}),
|
|
1133
|
+
text.cause && text.cause !== text.title ? /* @__PURE__ */ jsx("p", {
|
|
1134
|
+
style: lineStyle,
|
|
1135
|
+
children: text.cause
|
|
1136
|
+
}) : null,
|
|
1137
|
+
text.next ? /* @__PURE__ */ jsx("p", {
|
|
1138
|
+
style: lineStyle,
|
|
1139
|
+
children: text.next
|
|
1140
|
+
}) : null,
|
|
1141
|
+
plan.askAdmin.map((line) => /* @__PURE__ */ jsx("p", {
|
|
1142
|
+
style: mutedLineStyle,
|
|
1143
|
+
children: line
|
|
1144
|
+
}, line)),
|
|
1145
|
+
plan.actions.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
1146
|
+
style: {
|
|
1147
|
+
alignItems: "center",
|
|
1148
|
+
display: "flex",
|
|
1149
|
+
flexWrap: "wrap",
|
|
1150
|
+
gap: "8px",
|
|
1151
|
+
marginTop: "8px"
|
|
1152
|
+
},
|
|
1153
|
+
children: plan.actions.map((planned, index) => planned.action.kind === "navigate" && planned.location ? /* @__PURE__ */ jsx("a", {
|
|
1154
|
+
href: env.href(planned.location),
|
|
1155
|
+
style: linkStyle,
|
|
1156
|
+
onClick: (e) => {
|
|
1157
|
+
const href = env.href(planned.location);
|
|
1158
|
+
if (e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey && href.startsWith("/") && config.navigate) {
|
|
1159
|
+
e.preventDefault();
|
|
1160
|
+
config.navigate(href);
|
|
1161
|
+
}
|
|
1162
|
+
},
|
|
1163
|
+
children: planned.label
|
|
1164
|
+
}, planned.action.id) : /* @__PURE__ */ jsx(Button, {
|
|
1165
|
+
kind: index === 0 ? "primary" : "secondary",
|
|
1166
|
+
disabled: busy || planned.action.kind === "retry" && waitLeft > 0,
|
|
1167
|
+
onClick: () => act(planned),
|
|
1168
|
+
children: planned.action.kind === "retry" && waitLeft > 0 ? t("guidedErrors.actions.retryIn", "{{label}} in {{seconds}}s", {
|
|
1169
|
+
label: planned.label,
|
|
1170
|
+
seconds: waitLeft
|
|
1171
|
+
}) : planned.label
|
|
1172
|
+
}, planned.action.id))
|
|
1173
|
+
}) : null,
|
|
1174
|
+
guided.traceId ? /* @__PURE__ */ jsx("p", {
|
|
1175
|
+
style: mutedLineStyle,
|
|
1176
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1177
|
+
type: "button",
|
|
1178
|
+
onClick: copyDetails,
|
|
1179
|
+
style: {
|
|
1180
|
+
...linkStyle,
|
|
1181
|
+
background: "transparent",
|
|
1182
|
+
border: 0,
|
|
1183
|
+
cursor: "pointer",
|
|
1184
|
+
padding: 0,
|
|
1185
|
+
fontWeight: 400
|
|
1186
|
+
},
|
|
1187
|
+
children: copied === details ? t("guidedErrors.actions.copied", "Copied") : t("guidedErrors.actions.copyDetails", "Copy details")
|
|
1188
|
+
})
|
|
1189
|
+
}) : null
|
|
1190
|
+
]
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// src/theme/ScopedTheme.tsx
|
|
1195
|
+
/** The SDK's only styling root: theme variables live on this element alone. */
|
|
1196
|
+
function ScopedTheme({ theme, label, component, children }) {
|
|
1197
|
+
return /* @__PURE__ */ jsx("section", {
|
|
1198
|
+
"aria-label": label,
|
|
1199
|
+
"data-botmanor-sdk": component,
|
|
1200
|
+
style: {
|
|
1201
|
+
...themeToStyle(theme),
|
|
1202
|
+
background: themeVar("surface"),
|
|
1203
|
+
color: themeVar("text"),
|
|
1204
|
+
border: `1px solid ${themeVar("border")}`,
|
|
1205
|
+
borderRadius: themeVar("radius"),
|
|
1206
|
+
fontFamily: themeVar("fontFamily"),
|
|
1207
|
+
padding: "16px"
|
|
1208
|
+
},
|
|
1209
|
+
children
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
|
|
690
1213
|
// src/components/StewardOwnMachineDesk.tsx
|
|
691
1214
|
/** Where the person manages their VibeControls machines, by default. */
|
|
692
1215
|
const DEFAULT_VIBECONTROLS_URL = "https://app.vibecontrols.com/";
|
|
@@ -1124,7 +1647,13 @@ function StewardOwnMachineDeskPanel({ stewardId, ownerActorId, vibecontrolsUrl =
|
|
|
1124
1647
|
onGrant: (agentId) => void onGrant(agentId),
|
|
1125
1648
|
onRevoke: (agentId) => void onRevoke(agentId)
|
|
1126
1649
|
}) : /* @__PURE__ */ jsx(Muted, { children: "Your role cannot see VibeControls machines in this workspace." }),
|
|
1127
|
-
/* @__PURE__ */ jsx(
|
|
1650
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
1651
|
+
error: actionError,
|
|
1652
|
+
context: {
|
|
1653
|
+
stewardId,
|
|
1654
|
+
ownerActorId
|
|
1655
|
+
}
|
|
1656
|
+
})
|
|
1128
1657
|
]
|
|
1129
1658
|
});
|
|
1130
1659
|
}
|
|
@@ -1187,7 +1716,7 @@ function GrantOptions({ stewardId, days, onDays, appsText, onAppsText }) {
|
|
|
1187
1716
|
function CurrentMachine({ loading, loaded, error, current, name, canClear, busy, onClear }) {
|
|
1188
1717
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1189
1718
|
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading the desk…" }) : null,
|
|
1190
|
-
/* @__PURE__ */ jsx(
|
|
1719
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, { error }),
|
|
1191
1720
|
current ? /* @__PURE__ */ jsxs("p", {
|
|
1192
1721
|
style: { margin: "8px 0 0" },
|
|
1193
1722
|
children: [
|
|
@@ -1210,7 +1739,7 @@ function CurrentMachine({ loading, loaded, error, current, name, canClear, busy,
|
|
|
1210
1739
|
function MachineList({ loading, listed, truncated, error, rows, ...actions }) {
|
|
1211
1740
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1212
1741
|
loading ? /* @__PURE__ */ jsx(Muted, { children: "Loading your machines…" }) : null,
|
|
1213
|
-
/* @__PURE__ */ jsx(
|
|
1742
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, { error }),
|
|
1214
1743
|
listed && rows.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: "You have no VibeControls machines in this workspace." }) : null,
|
|
1215
1744
|
truncated ? /* @__PURE__ */ jsx(Muted, { children: "Only the first machines in this workspace are listed." }) : null,
|
|
1216
1745
|
rows.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
@@ -1272,6 +1801,12 @@ function MachineRow({ row: { agent, granted, chosen }, unchecked, ownerActorId,
|
|
|
1272
1801
|
}
|
|
1273
1802
|
|
|
1274
1803
|
// src/components/StewardRunView.tsx
|
|
1804
|
+
/** Statuses after which a run's failure, if any, is known. */
|
|
1805
|
+
const UNFINISHED = /* @__PURE__ */ new Set([
|
|
1806
|
+
"FAILED",
|
|
1807
|
+
"STOPPED",
|
|
1808
|
+
"PAUSED_BUDGET"
|
|
1809
|
+
]);
|
|
1275
1810
|
const WAITING_REASON = {
|
|
1276
1811
|
WAITING_APPROVAL: "APPROVAL",
|
|
1277
1812
|
WAITING_TAKEOVER: "TAKEOVER",
|
|
@@ -1320,12 +1855,33 @@ function useRunTransitionEvents(runId, run) {
|
|
|
1320
1855
|
* while the run is active (the embed session is not a subscription actor) and
|
|
1321
1856
|
* emits `run.waiting`, `run.completed` and `run.failed` as the status changes.
|
|
1322
1857
|
*/
|
|
1323
|
-
function StewardRunView({ runId, pollIntervalMs = 3e3 }) {
|
|
1858
|
+
function StewardRunView({ runId, pollIntervalMs = 3e3, onRunAgain, onStewardChanged, deskKind, canUpdateSteward = true }) {
|
|
1324
1859
|
const { config } = useStewardsSdk();
|
|
1325
1860
|
const { data, error, loading, refetch } = useStewardsQuery(GET_STEWARD_RUN, { id: runId }, { pollMs: (d) => d.getBotmanorStewardRun && !isTerminalRunStatus(d.getBotmanorStewardRun.status) ? pollIntervalMs : false });
|
|
1326
1861
|
const cancel = useStewardsMutation(CANCEL_STEWARD_RUN);
|
|
1327
1862
|
const run = data?.getBotmanorStewardRun ?? void 0;
|
|
1328
1863
|
useRunTransitionEvents(runId, run);
|
|
1864
|
+
const unfinished = !!run && UNFINISHED.has(run.status);
|
|
1865
|
+
const failureQuery = useStewardsQuery(GET_STEWARD_RUN_FAILURE, { id: runId }, {
|
|
1866
|
+
skip: !unfinished,
|
|
1867
|
+
silent: true
|
|
1868
|
+
});
|
|
1869
|
+
const failure = failureQuery.data?.getBotmanorStewardRun?.failure ?? null;
|
|
1870
|
+
const guidedFailure = useMemo(() => run && !failureQuery.loading ? describeRunFailure({
|
|
1871
|
+
id: run.id,
|
|
1872
|
+
stewardId: run.stewardId,
|
|
1873
|
+
status: run.status,
|
|
1874
|
+
stopReason: run.stopReason,
|
|
1875
|
+
failure,
|
|
1876
|
+
steps: run.steps,
|
|
1877
|
+
stepCount: run.stepCount,
|
|
1878
|
+
...deskKind ? { deskKind } : {}
|
|
1879
|
+
}) : void 0, [
|
|
1880
|
+
run,
|
|
1881
|
+
failure,
|
|
1882
|
+
failureQuery.loading,
|
|
1883
|
+
deskKind
|
|
1884
|
+
]);
|
|
1329
1885
|
const onCancel = async () => {
|
|
1330
1886
|
if (await cancel.mutate({ id: runId })) refetch();
|
|
1331
1887
|
};
|
|
@@ -1339,7 +1895,22 @@ function StewardRunView({ runId, pollIntervalMs = 3e3 }) {
|
|
|
1339
1895
|
children: "Steward run"
|
|
1340
1896
|
}),
|
|
1341
1897
|
loading && !run ? /* @__PURE__ */ jsx(Muted, { children: "Loading the run…" }) : null,
|
|
1342
|
-
/* @__PURE__ */ jsx(
|
|
1898
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
1899
|
+
error,
|
|
1900
|
+
context: {
|
|
1901
|
+
runId,
|
|
1902
|
+
...run ? { stewardId: run.stewardId } : {}
|
|
1903
|
+
},
|
|
1904
|
+
onRetry: refetch
|
|
1905
|
+
}),
|
|
1906
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
1907
|
+
error: error ? void 0 : cancel.error,
|
|
1908
|
+
context: {
|
|
1909
|
+
runId,
|
|
1910
|
+
...run ? { stewardId: run.stewardId } : {}
|
|
1911
|
+
},
|
|
1912
|
+
...isStaleStateError(cancel.error) ? { onRetry: refetch } : {}
|
|
1913
|
+
}),
|
|
1343
1914
|
!loading && !error && !run ? /* @__PURE__ */ jsx(Muted, { children: "This run was not found." }) : null,
|
|
1344
1915
|
run ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1345
1916
|
/* @__PURE__ */ jsx(RunHeader, {
|
|
@@ -1347,6 +1918,16 @@ function StewardRunView({ runId, pollIntervalMs = 3e3 }) {
|
|
|
1347
1918
|
cancelling: cancel.loading,
|
|
1348
1919
|
onCancel: () => void onCancel()
|
|
1349
1920
|
}),
|
|
1921
|
+
guidedFailure ? /* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
1922
|
+
guided: guidedFailure,
|
|
1923
|
+
context: {
|
|
1924
|
+
runId,
|
|
1925
|
+
stewardId: run.stewardId
|
|
1926
|
+
},
|
|
1927
|
+
...onRunAgain ? { onRetry: onRunAgain } : {},
|
|
1928
|
+
...onStewardChanged ? { onFixed: onStewardChanged } : {},
|
|
1929
|
+
canActivateSteward: canUpdateSteward
|
|
1930
|
+
}) : null,
|
|
1350
1931
|
/* @__PURE__ */ jsx(RunSteps, { steps: run.steps }),
|
|
1351
1932
|
/* @__PURE__ */ jsx(RunApprovals, { approvals: run.approvals })
|
|
1352
1933
|
] }) : null
|
|
@@ -1360,7 +1941,8 @@ const subheadingStyle = {
|
|
|
1360
1941
|
};
|
|
1361
1942
|
function runTimeline(run) {
|
|
1362
1943
|
const finished = run.finishedAt ? `, finished ${formatDate(run.finishedAt)}` : "";
|
|
1363
|
-
const
|
|
1944
|
+
const label = stopReasonLabel(run.stopReason);
|
|
1945
|
+
const reason = label ? ` — ${label}` : "";
|
|
1364
1946
|
return `Started ${formatDate(run.startedAt)}${finished}${reason}`;
|
|
1365
1947
|
}
|
|
1366
1948
|
function runUsage(run) {
|
|
@@ -1461,11 +2043,14 @@ function StewardConsole({ stewardId, onSelectSteward, vibecontrolsUrl, ownMachin
|
|
|
1461
2043
|
});
|
|
1462
2044
|
}
|
|
1463
2045
|
function StewardList({ onSelect }) {
|
|
1464
|
-
const { data, error, loading } = useStewardsQuery(LIST_STEWARDS, { pagination: { limit: 50 } });
|
|
2046
|
+
const { data, error, loading, refetch } = useStewardsQuery(LIST_STEWARDS, { pagination: { limit: 50 } });
|
|
1465
2047
|
const stewards = data?.listBotmanorStewards;
|
|
1466
2048
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1467
2049
|
loading && !stewards ? /* @__PURE__ */ jsx(Muted, { children: "Loading stewards…" }) : null,
|
|
1468
|
-
/* @__PURE__ */ jsx(
|
|
2050
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2051
|
+
error,
|
|
2052
|
+
onRetry: refetch
|
|
2053
|
+
}),
|
|
1469
2054
|
stewards && stewards.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: "No stewards yet." }) : null,
|
|
1470
2055
|
stewards && stewards.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
1471
2056
|
style: listStyle,
|
|
@@ -1476,6 +2061,7 @@ function StewardList({ onSelect }) {
|
|
|
1476
2061
|
/* @__PURE__ */ jsx("strong", { children: s.agent?.name ?? s.agentId }),
|
|
1477
2062
|
" ",
|
|
1478
2063
|
/* @__PURE__ */ jsx(Badge, { children: humanize(s.status) }),
|
|
2064
|
+
s.agent?.status && s.agent.status !== "ACTIVE" ? /* @__PURE__ */ jsx(Badge, { children: agentStateLabel(s.agent.status) }) : null,
|
|
1479
2065
|
s.charter ? /* @__PURE__ */ jsx(Badge, { children: humanize(s.charter.autonomyLevel) }) : null,
|
|
1480
2066
|
s.pendingApprovalCount > 0 ? /* @__PURE__ */ jsxs(Badge, { children: [s.pendingApprovalCount, " awaiting approval"] }) : null,
|
|
1481
2067
|
" ",
|
|
@@ -1497,8 +2083,27 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl, ownMachineAccess })
|
|
|
1497
2083
|
pagination: { limit: 10 }
|
|
1498
2084
|
}, { pollMs: (d) => d.listBotmanorStewardRuns.some((r) => !isTerminalRunStatus(r.status)) ? 5e3 : false });
|
|
1499
2085
|
const [selectedRun, setSelectedRun] = useState(void 0);
|
|
1500
|
-
const
|
|
2086
|
+
const [confirmed, setConfirmed] = useState(void 0);
|
|
2087
|
+
const latestAnswer = useRef(steward.data);
|
|
2088
|
+
latestAnswer.current = steward.data;
|
|
2089
|
+
const loaded = steward.data?.getBotmanorSteward ?? void 0;
|
|
2090
|
+
const override = confirmed && confirmed.stewardId === stewardId && loaded?.id === stewardId && steward.data === confirmed.answer ? confirmed.status : void 0;
|
|
2091
|
+
if (confirmed && !override) setConfirmed(void 0);
|
|
2092
|
+
const detail = useMemo(() => loaded && override ? {
|
|
2093
|
+
...loaded,
|
|
2094
|
+
status: override
|
|
2095
|
+
} : loaded, [loaded, override]);
|
|
1501
2096
|
const notFound = !steward.loading && !steward.error && !detail;
|
|
2097
|
+
const context = useMemo(() => stewardContext(stewardId, detail), [stewardId, detail]);
|
|
2098
|
+
const onStatusChanged = (id, status) => {
|
|
2099
|
+
if (id !== stewardId) return;
|
|
2100
|
+
setConfirmed({
|
|
2101
|
+
stewardId: id,
|
|
2102
|
+
status,
|
|
2103
|
+
answer: latestAnswer.current
|
|
2104
|
+
});
|
|
2105
|
+
steward.refetch();
|
|
2106
|
+
};
|
|
1502
2107
|
const onStarted = (runId) => {
|
|
1503
2108
|
setSelectedRun(runId);
|
|
1504
2109
|
runs.refetch();
|
|
@@ -1512,31 +2117,189 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl, ownMachineAccess })
|
|
|
1512
2117
|
})
|
|
1513
2118
|
}) : null,
|
|
1514
2119
|
steward.loading && !detail ? /* @__PURE__ */ jsx(Muted, { children: "Loading the steward…" }) : null,
|
|
1515
|
-
/* @__PURE__ */ jsx(
|
|
2120
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2121
|
+
error: steward.error,
|
|
2122
|
+
context,
|
|
2123
|
+
onRetry: steward.refetch
|
|
2124
|
+
}),
|
|
1516
2125
|
notFound ? /* @__PURE__ */ jsx(Muted, { children: "This steward was not found." }) : null,
|
|
1517
2126
|
detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1518
2127
|
/* @__PURE__ */ jsx(StewardSummary, { detail }),
|
|
2128
|
+
/* @__PURE__ */ jsx(StatusActions, {
|
|
2129
|
+
detail,
|
|
2130
|
+
context,
|
|
2131
|
+
canUpdate: ownMachineAccess?.canUpdateSteward !== false,
|
|
2132
|
+
onChanged: onStatusChanged,
|
|
2133
|
+
onReload: steward.refetch
|
|
2134
|
+
}),
|
|
1519
2135
|
/* @__PURE__ */ jsx(OwnMachineSection, {
|
|
1520
2136
|
detail,
|
|
1521
2137
|
vibecontrolsUrl,
|
|
1522
2138
|
access: ownMachineAccess
|
|
1523
2139
|
}),
|
|
1524
|
-
|
|
2140
|
+
/* @__PURE__ */ jsx(AgentGuidance, {
|
|
2141
|
+
detail,
|
|
2142
|
+
context,
|
|
2143
|
+
canUpdate: ownMachineAccess?.canUpdateSteward !== false,
|
|
2144
|
+
onChanged: onStatusChanged,
|
|
2145
|
+
onReload: steward.refetch
|
|
2146
|
+
}),
|
|
2147
|
+
detail.status === "ACTIVE" && agentIsActive(detail) ? /* @__PURE__ */ jsx(StartRunForm, {
|
|
1525
2148
|
stewardId,
|
|
1526
|
-
|
|
1527
|
-
|
|
2149
|
+
context,
|
|
2150
|
+
canActivateSteward: ownMachineAccess?.canUpdateSteward !== false,
|
|
2151
|
+
onStarted,
|
|
2152
|
+
onStewardChanged: steward.refetch,
|
|
2153
|
+
onRunsChanged: runs.refetch
|
|
2154
|
+
}) : detail.status === "ARCHIVED" || !agentIsActive(detail) ? null : /* @__PURE__ */ jsx(Muted, { children: "Only an active steward can start a run." }),
|
|
1528
2155
|
/* @__PURE__ */ jsx(RecentRuns, {
|
|
1529
2156
|
runs: runs.data?.listBotmanorStewardRuns,
|
|
1530
2157
|
error: runs.error,
|
|
1531
|
-
onView: setSelectedRun
|
|
2158
|
+
onView: setSelectedRun,
|
|
2159
|
+
onRetry: runs.refetch
|
|
1532
2160
|
}),
|
|
1533
2161
|
selectedRun ? /* @__PURE__ */ jsx("div", {
|
|
1534
2162
|
style: { marginTop: "16px" },
|
|
1535
|
-
children: /* @__PURE__ */ jsx(StewardRunView, {
|
|
2163
|
+
children: /* @__PURE__ */ jsx(StewardRunView, {
|
|
2164
|
+
runId: selectedRun,
|
|
2165
|
+
...detail.status === "ACTIVE" && agentIsActive(detail) ? { onRunAgain: () => focusPrompt(stewardId) } : {},
|
|
2166
|
+
onStewardChanged: steward.refetch,
|
|
2167
|
+
deskKind: detail.defaultDeskKind,
|
|
2168
|
+
canUpdateSteward: ownMachineAccess?.canUpdateSteward !== false
|
|
2169
|
+
})
|
|
1536
2170
|
}) : null
|
|
1537
2171
|
] }) : null
|
|
1538
2172
|
] });
|
|
1539
2173
|
}
|
|
2174
|
+
/** The status a steward moves to from each status, with its button label (archiving stays in BotManor). */
|
|
2175
|
+
const NEXT_STATUS = {
|
|
2176
|
+
DRAFT: {
|
|
2177
|
+
to: "ACTIVE",
|
|
2178
|
+
label: "Activate steward"
|
|
2179
|
+
},
|
|
2180
|
+
ACTIVE: {
|
|
2181
|
+
to: "PAUSED",
|
|
2182
|
+
label: "Pause steward"
|
|
2183
|
+
},
|
|
2184
|
+
PAUSED: {
|
|
2185
|
+
to: "ACTIVE",
|
|
2186
|
+
label: "Resume steward"
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
/**
|
|
2190
|
+
* Activate a new (draft) steward, or pause and resume one (BOFF-18393). A
|
|
2191
|
+
* steward created here starts as a draft, and only an active steward can run,
|
|
2192
|
+
* so without this a person had to leave the app to finish setting it up.
|
|
2193
|
+
* Shown to a viewer with botmanor-steward:update (`canUpdateSteward`); without
|
|
2194
|
+
* an access answer the gateway decides.
|
|
2195
|
+
*/
|
|
2196
|
+
function StatusActions({ detail, context, canUpdate, onChanged, onReload }) {
|
|
2197
|
+
const change = useStewardsMutation(SET_STEWARD_STATUS);
|
|
2198
|
+
const next = NEXT_STATUS[detail.status];
|
|
2199
|
+
if (!next || !canUpdate) return null;
|
|
2200
|
+
if (next.to === "ACTIVE" && !agentIsActive(detail)) return null;
|
|
2201
|
+
const onClick = async () => {
|
|
2202
|
+
const result = await change.mutate({
|
|
2203
|
+
id: detail.id,
|
|
2204
|
+
status: next.to
|
|
2205
|
+
});
|
|
2206
|
+
if (result) onChanged(result.setBotmanorStewardStatus.id, result.setBotmanorStewardStatus.status);
|
|
2207
|
+
};
|
|
2208
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2209
|
+
style: { margin: "8px 0 0" },
|
|
2210
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
2211
|
+
onClick: () => void onClick(),
|
|
2212
|
+
disabled: change.loading,
|
|
2213
|
+
children: next.label
|
|
2214
|
+
}), /* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2215
|
+
error: change.error,
|
|
2216
|
+
context,
|
|
2217
|
+
...isStaleStateError(change.error) ? { onRetry: onReload } : isDefiniteRefusal(change.error) ? { onRetry: () => void onClick() } : {},
|
|
2218
|
+
onFixed: onReload
|
|
2219
|
+
})]
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* What blocks a steward whose agent is not published (or is gone), or that is
|
|
2224
|
+
* archived, with the fix (catalog A1, A3 and A5 prevention). After the agent
|
|
2225
|
+
* is published here, a draft or paused steward is activated.
|
|
2226
|
+
*/
|
|
2227
|
+
function AgentGuidance({ detail, context, canUpdate, onChanged, onReload }) {
|
|
2228
|
+
const { config } = useStewardsSdk();
|
|
2229
|
+
const activate = useStewardsMutation(SET_STEWARD_STATUS);
|
|
2230
|
+
const archived = detail.status === "ARCHIVED";
|
|
2231
|
+
const blocked = !detail.agent || !agentIsActive(detail);
|
|
2232
|
+
const preview = useMemo(() => {
|
|
2233
|
+
if (!archived && !blocked) return void 0;
|
|
2234
|
+
const reason = archived ? "STEWARD_ARCHIVED" : detail.agent ? "AGENT_NOT_ACTIVE" : "AGENT_UNAVAILABLE";
|
|
2235
|
+
return describeGuidedError({
|
|
2236
|
+
code: "BAD_USER_INPUT",
|
|
2237
|
+
extensions: {
|
|
2238
|
+
reason,
|
|
2239
|
+
stewardId: detail.id,
|
|
2240
|
+
agentId: detail.agentId
|
|
2241
|
+
}
|
|
2242
|
+
}, context);
|
|
2243
|
+
}, [
|
|
2244
|
+
archived,
|
|
2245
|
+
blocked,
|
|
2246
|
+
detail,
|
|
2247
|
+
context
|
|
2248
|
+
]);
|
|
2249
|
+
const canActivate = canUpdate && config.hasPermission?.(GUIDED_PERMISSIONS.STEWARD_UPDATE) !== false;
|
|
2250
|
+
const afterPublish = async (mutation) => {
|
|
2251
|
+
if (mutation !== "PUBLISH_AGENT" || archived || detail.status === "ACTIVE" || !canActivate) {
|
|
2252
|
+
onReload();
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
const result = await activate.mutate({
|
|
2256
|
+
id: detail.id,
|
|
2257
|
+
status: "ACTIVE"
|
|
2258
|
+
});
|
|
2259
|
+
if (result) onChanged(result.setBotmanorStewardStatus.id, result.setBotmanorStewardStatus.status);
|
|
2260
|
+
else onReload();
|
|
2261
|
+
};
|
|
2262
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [preview ? /* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2263
|
+
guided: preview,
|
|
2264
|
+
context,
|
|
2265
|
+
tone: "info",
|
|
2266
|
+
onRetry: onReload,
|
|
2267
|
+
onFixed: (mutation) => void afterPublish(mutation)
|
|
2268
|
+
}) : null, /* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2269
|
+
error: activate.error,
|
|
2270
|
+
context,
|
|
2271
|
+
...isStaleStateError(activate.error) ? { onRetry: onReload } : {},
|
|
2272
|
+
onFixed: onReload
|
|
2273
|
+
})] });
|
|
2274
|
+
}
|
|
2275
|
+
/** What the console knows about a steward and its agent, for guided errors. */
|
|
2276
|
+
function stewardContext(stewardId, detail) {
|
|
2277
|
+
return {
|
|
2278
|
+
stewardId,
|
|
2279
|
+
...detail ? {
|
|
2280
|
+
stewardStatus: detail.status,
|
|
2281
|
+
ownerActorId: detail.ownerActorId
|
|
2282
|
+
} : {},
|
|
2283
|
+
...detail?.agent ? { agent: {
|
|
2284
|
+
id: detail.agent.id,
|
|
2285
|
+
...detail.agent.status ? { status: detail.agent.status } : {},
|
|
2286
|
+
..."llmModelId" in detail.agent ? { llmModelId: detail.agent.llmModelId ?? null } : {}
|
|
2287
|
+
} } : detail ? { agent: { id: detail.agentId } } : {}
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
/** An agent whose status is not known (an older service) counts as active. */
|
|
2291
|
+
function agentIsActive(detail) {
|
|
2292
|
+
if (!detail.agent) return false;
|
|
2293
|
+
const status = detail.agent.status;
|
|
2294
|
+
return !status || status === "ACTIVE";
|
|
2295
|
+
}
|
|
2296
|
+
function agentStateLabel(status) {
|
|
2297
|
+
return `Agent: ${(AGENT_STATUS_SHORT_LABELS[status] ?? humanize(status)).toLowerCase()}`;
|
|
2298
|
+
}
|
|
2299
|
+
function focusPrompt(stewardId) {
|
|
2300
|
+
if (typeof document === "undefined") return;
|
|
2301
|
+
document.getElementById(`prompt-${stewardId}`)?.focus();
|
|
2302
|
+
}
|
|
1540
2303
|
/** The machine picker, for a steward whose desk kind is OWN_MACHINE. */
|
|
1541
2304
|
function OwnMachineSection({ detail, vibecontrolsUrl, access }) {
|
|
1542
2305
|
if (detail.defaultDeskKind !== "OWN_MACHINE") return null;
|
|
@@ -1566,6 +2329,7 @@ function StewardSummary({ detail }) {
|
|
|
1566
2329
|
" ",
|
|
1567
2330
|
/* @__PURE__ */ jsx(Badge, { children: humanize(detail.status) }),
|
|
1568
2331
|
" ",
|
|
2332
|
+
detail.agent?.status ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Badge, { children: agentStateLabel(detail.agent.status) }), " "] }) : null,
|
|
1569
2333
|
detail.charter ? /* @__PURE__ */ jsx(Badge, { children: humanize(detail.charter.autonomyLevel) }) : null,
|
|
1570
2334
|
" ",
|
|
1571
2335
|
/* @__PURE__ */ jsxs(Badge, { children: ["Desk ", humanize(detail.defaultDeskKind)] })
|
|
@@ -1579,19 +2343,22 @@ function StewardSummary({ detail }) {
|
|
|
1579
2343
|
* Prompt box that starts a run. Emits `run.started` and hands the new run id
|
|
1580
2344
|
* to the parent, which selects it and refreshes the run list.
|
|
1581
2345
|
*/
|
|
1582
|
-
function StartRunForm({ stewardId, onStarted }) {
|
|
2346
|
+
function StartRunForm({ stewardId, context, onStarted, onStewardChanged, onRunsChanged, canActivateSteward }) {
|
|
1583
2347
|
const { events } = useStewardsSdk();
|
|
1584
2348
|
const start = useStewardsMutation(RUN_STEWARD);
|
|
1585
2349
|
const [prompt, setPrompt] = useState("");
|
|
1586
2350
|
const onSubmit = async (e) => {
|
|
1587
|
-
e
|
|
2351
|
+
e?.preventDefault();
|
|
1588
2352
|
const text = prompt.trim();
|
|
1589
|
-
if (!text) return;
|
|
2353
|
+
if (!text || start.loading) return;
|
|
1590
2354
|
const result = await start.mutate({ input: {
|
|
1591
2355
|
stewardId,
|
|
1592
2356
|
prompt: text
|
|
1593
2357
|
} });
|
|
1594
|
-
if (!result)
|
|
2358
|
+
if (!result) {
|
|
2359
|
+
onRunsChanged();
|
|
2360
|
+
return;
|
|
2361
|
+
}
|
|
1595
2362
|
const run = result.runBotmanorSteward;
|
|
1596
2363
|
events.emit("run.started", {
|
|
1597
2364
|
runId: run.id,
|
|
@@ -1624,12 +2391,18 @@ function StartRunForm({ stewardId, onStarted }) {
|
|
|
1624
2391
|
children: "Run"
|
|
1625
2392
|
})
|
|
1626
2393
|
}),
|
|
1627
|
-
/* @__PURE__ */ jsx(
|
|
2394
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2395
|
+
error: start.error,
|
|
2396
|
+
context,
|
|
2397
|
+
...isDefiniteRefusal(start.error) && !isStaleStateError(start.error) ? { onRetry: () => void onSubmit() } : {},
|
|
2398
|
+
onFixed: onStewardChanged,
|
|
2399
|
+
canActivateSteward
|
|
2400
|
+
})
|
|
1628
2401
|
]
|
|
1629
2402
|
});
|
|
1630
2403
|
}
|
|
1631
2404
|
/** The steward's latest runs, each with a button that opens it below. */
|
|
1632
|
-
function RecentRuns({ runs, error, onView }) {
|
|
2405
|
+
function RecentRuns({ runs, error, onView, onRetry }) {
|
|
1633
2406
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1634
2407
|
/* @__PURE__ */ jsx("h3", {
|
|
1635
2408
|
style: {
|
|
@@ -1639,7 +2412,10 @@ function RecentRuns({ runs, error, onView }) {
|
|
|
1639
2412
|
},
|
|
1640
2413
|
children: "Recent runs"
|
|
1641
2414
|
}),
|
|
1642
|
-
/* @__PURE__ */ jsx(
|
|
2415
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2416
|
+
error,
|
|
2417
|
+
onRetry
|
|
2418
|
+
}),
|
|
1643
2419
|
runs && runs.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: "No runs yet." }) : null,
|
|
1644
2420
|
/* @__PURE__ */ jsx("ul", {
|
|
1645
2421
|
style: listStyle,
|
|
@@ -1678,6 +2454,43 @@ const DESKS = [
|
|
|
1678
2454
|
"CLOUD",
|
|
1679
2455
|
"OWN_MACHINE"
|
|
1680
2456
|
];
|
|
2457
|
+
/** Agents that can become a steward: drafts are published before the steward runs. */
|
|
2458
|
+
const PICKABLE_AGENT_STATUSES = /* @__PURE__ */ new Set([
|
|
2459
|
+
"ACTIVE",
|
|
2460
|
+
"DRAFT",
|
|
2461
|
+
"PAUSED"
|
|
2462
|
+
]);
|
|
2463
|
+
/** What the picker says next to an agent's name. */
|
|
2464
|
+
function agentPickerLabel(agent, alreadySteward) {
|
|
2465
|
+
if (alreadySteward) return `${agent.name} (already a steward)`;
|
|
2466
|
+
if (agent.status === "DRAFT") return `${agent.name} (draft, publish before running)`;
|
|
2467
|
+
if (agent.status === "PAUSED") return `${agent.name} (paused, resume before running)`;
|
|
2468
|
+
return agent.name;
|
|
2469
|
+
}
|
|
2470
|
+
/**
|
|
2471
|
+
* The picker's agents, sorted so published agents come first: active, draft
|
|
2472
|
+
* and paused agents only (training, archived and deleted agents cannot become
|
|
2473
|
+
* a steward), each marked when it is already a steward.
|
|
2474
|
+
*/
|
|
2475
|
+
function pickableAgents(agents, stewardAgentIds) {
|
|
2476
|
+
const order = (status) => status === "ACTIVE" ? 0 : status === "DRAFT" ? 1 : 2;
|
|
2477
|
+
return agents.filter((a) => PICKABLE_AGENT_STATUSES.has(a.status)).map((agent) => ({
|
|
2478
|
+
agent,
|
|
2479
|
+
alreadySteward: stewardAgentIds.has(agent.id)
|
|
2480
|
+
})).sort((a, b) => Number(a.alreadySteward) - Number(b.alreadySteward) || order(a.agent.status) - order(b.agent.status) || a.agent.name.localeCompare(b.agent.name));
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* What the desk picker says about desks that use the plan's desk minutes
|
|
2484
|
+
* (browser and cloud), from the plan: `notInPlan` (no assignment), `usedUp`,
|
|
2485
|
+
* `available`, or `unknown` when the viewer may not check the plan.
|
|
2486
|
+
*/
|
|
2487
|
+
function cloudDeskAvailability(check) {
|
|
2488
|
+
if (!check) return "unknown";
|
|
2489
|
+
if (check.noLimit) return "available";
|
|
2490
|
+
if (!check.assignmentId) return "notInPlan";
|
|
2491
|
+
if (!check.allowed || check.limitLeft != null && check.limitLeft <= 0) return "usedUp";
|
|
2492
|
+
return "available";
|
|
2493
|
+
}
|
|
1681
2494
|
/** Parses a non-negative credits value; empty means "no cap". `null` is invalid. */
|
|
1682
2495
|
function parseCredits(raw) {
|
|
1683
2496
|
const text = raw.trim();
|
|
@@ -1686,6 +2499,25 @@ function parseCredits(raw) {
|
|
|
1686
2499
|
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
1687
2500
|
}
|
|
1688
2501
|
/**
|
|
2502
|
+
* The daily budget to send when a charter is edited, or `undefined` to leave
|
|
2503
|
+
* it as it is. The service replaces the whole daily budget, so the other daily
|
|
2504
|
+
* limits (steps, desk minutes, wall time, connector spend) set elsewhere are
|
|
2505
|
+
* carried over, and a cleared credit field drops only the credit cap
|
|
2506
|
+
* (BOFF-18393). Nothing is sent when the credit cap did not change.
|
|
2507
|
+
*/
|
|
2508
|
+
function charterBudgetUpdate(current, credits) {
|
|
2509
|
+
if ((current?.credits ?? void 0) === credits) return void 0;
|
|
2510
|
+
const kept = {};
|
|
2511
|
+
if (current?.deskMinutes != null) kept.deskMinutes = current.deskMinutes;
|
|
2512
|
+
if (current?.steps != null) kept.steps = current.steps;
|
|
2513
|
+
if (current?.wallSeconds != null) kept.wallSeconds = current.wallSeconds;
|
|
2514
|
+
if (current?.connectorSpendMinor != null) kept.connectorSpendMinor = current.connectorSpendMinor;
|
|
2515
|
+
return credits === void 0 ? kept : {
|
|
2516
|
+
...kept,
|
|
2517
|
+
credits
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
/**
|
|
1689
2521
|
* Create a steward from an agent and a charter, or edit an existing charter:
|
|
1690
2522
|
* the charter text, the autonomy level and a daily credit budget. Duties and
|
|
1691
2523
|
* playbooks live in the full Stewards app.
|
|
@@ -1750,7 +2582,12 @@ function CharterFields(p) {
|
|
|
1750
2582
|
] });
|
|
1751
2583
|
}
|
|
1752
2584
|
function CreateForm({ agentId, onCreated }) {
|
|
1753
|
-
const
|
|
2585
|
+
const { config } = useStewardsSdk();
|
|
2586
|
+
const agents = useStewardsQuery(LIST_PICKABLE_AGENTS, { pagination: { limit: 100 } }, { skip: agentId !== void 0 });
|
|
2587
|
+
const stewards = useStewardsQuery(LIST_STEWARDS, { pagination: { limit: 100 } }, {
|
|
2588
|
+
skip: agentId !== void 0,
|
|
2589
|
+
silent: true
|
|
2590
|
+
});
|
|
1754
2591
|
const create = useStewardsMutation(CREATE_STEWARD);
|
|
1755
2592
|
const [pickedAgent, setPickedAgent] = useState("");
|
|
1756
2593
|
const [charterText, setCharterText] = useState("");
|
|
@@ -1760,8 +2597,21 @@ function CreateForm({ agentId, onCreated }) {
|
|
|
1760
2597
|
const [validation, setValidation] = useState();
|
|
1761
2598
|
const [createdId, setCreatedId] = useState();
|
|
1762
2599
|
const chosenAgent = agentId ?? pickedAgent;
|
|
2600
|
+
const stewardAgentIds = useMemo(() => new Set((stewards.data?.listBotmanorStewards ?? []).map((st) => st.agentId)), [stewards.data]);
|
|
2601
|
+
const options = useMemo(() => pickableAgents([
|
|
2602
|
+
...agents.data?.active ?? [],
|
|
2603
|
+
...agents.data?.draft ?? [],
|
|
2604
|
+
...agents.data?.paused ?? []
|
|
2605
|
+
], stewardAgentIds), [agents.data, stewardAgentIds]);
|
|
2606
|
+
const picked = options.find((o) => o.agent.id === chosenAgent)?.agent;
|
|
2607
|
+
const context = useMemo(() => picked ? { agent: {
|
|
2608
|
+
id: picked.id,
|
|
2609
|
+
status: picked.status,
|
|
2610
|
+
...picked.llmModelId !== void 0 ? { llmModelId: picked.llmModelId } : {}
|
|
2611
|
+
} } : chosenAgent ? { agent: { id: chosenAgent } } : {}, [picked, chosenAgent]);
|
|
2612
|
+
const workspaceId = config.workspaceId;
|
|
1763
2613
|
const onSubmit = async (e) => {
|
|
1764
|
-
e
|
|
2614
|
+
e?.preventDefault();
|
|
1765
2615
|
const parsed = parseCredits(credits);
|
|
1766
2616
|
if (!chosenAgent) return setValidation("Choose an agent.");
|
|
1767
2617
|
if (charterText.trim() === "") return setValidation("Write the charter first.");
|
|
@@ -1784,23 +2634,35 @@ function CreateForm({ agentId, onCreated }) {
|
|
|
1784
2634
|
onSubmit: (e) => void onSubmit(e),
|
|
1785
2635
|
noValidate: true,
|
|
1786
2636
|
children: [
|
|
1787
|
-
agentId ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
2637
|
+
agentId ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2638
|
+
/* @__PURE__ */ jsx(Field, {
|
|
2639
|
+
label: "Agent",
|
|
2640
|
+
htmlFor: "steward-agent",
|
|
2641
|
+
children: /* @__PURE__ */ jsxs("select", {
|
|
2642
|
+
id: "steward-agent",
|
|
2643
|
+
value: pickedAgent,
|
|
2644
|
+
onChange: (e) => setPickedAgent(e.target.value),
|
|
2645
|
+
style: fieldStyle,
|
|
2646
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
2647
|
+
value: "",
|
|
2648
|
+
children: "Choose an agent…"
|
|
2649
|
+
}), options.map(({ agent, alreadySteward }) => /* @__PURE__ */ jsx("option", {
|
|
2650
|
+
value: agent.id,
|
|
2651
|
+
disabled: alreadySteward,
|
|
2652
|
+
children: agentPickerLabel(agent, alreadySteward)
|
|
2653
|
+
}, agent.id))]
|
|
2654
|
+
})
|
|
2655
|
+
}),
|
|
2656
|
+
agents.data && options.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: "No agent can become a steward yet. Create an agent first, then come back." }) : null,
|
|
2657
|
+
picked ? /* @__PURE__ */ jsx(AgentStateNotice, {
|
|
2658
|
+
agent: picked,
|
|
2659
|
+
onChanged: agents.refetch
|
|
2660
|
+
}) : null,
|
|
2661
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2662
|
+
error: agents.error,
|
|
2663
|
+
onRetry: agents.refetch
|
|
1802
2664
|
})
|
|
1803
|
-
|
|
2665
|
+
] }),
|
|
1804
2666
|
/* @__PURE__ */ jsx(CharterFields, {
|
|
1805
2667
|
idPrefix: "create",
|
|
1806
2668
|
charterText,
|
|
@@ -1824,8 +2686,18 @@ function CreateForm({ agentId, onCreated }) {
|
|
|
1824
2686
|
}, d))
|
|
1825
2687
|
})
|
|
1826
2688
|
}),
|
|
2689
|
+
desk === "CLOUD" || desk === "BROWSER" ? /* @__PURE__ */ jsx(DeskMinutesHint, {
|
|
2690
|
+
workspaceId,
|
|
2691
|
+
desk,
|
|
2692
|
+
onChooseDesk: setDesk
|
|
2693
|
+
}) : null,
|
|
1827
2694
|
validation ? /* @__PURE__ */ jsx(ErrorNote, { error: new Error(validation) }) : null,
|
|
1828
|
-
/* @__PURE__ */ jsx(
|
|
2695
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2696
|
+
error: create.error,
|
|
2697
|
+
context,
|
|
2698
|
+
onRetry: () => void onSubmit(),
|
|
2699
|
+
onFixed: agents.refetch
|
|
2700
|
+
}),
|
|
1829
2701
|
/* @__PURE__ */ jsx("p", {
|
|
1830
2702
|
style: { margin: "16px 0 0" },
|
|
1831
2703
|
children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -1842,73 +2714,178 @@ function EditForm({ stewardId, onSaved }) {
|
|
|
1842
2714
|
const steward = useStewardsQuery(GET_STEWARD, { id: stewardId });
|
|
1843
2715
|
const detail = steward.data?.getBotmanorSteward;
|
|
1844
2716
|
if (steward.loading && !detail) return /* @__PURE__ */ jsx(Muted, { children: "Loading the charter…" });
|
|
1845
|
-
if (!detail?.charter) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(
|
|
2717
|
+
if (!detail?.charter) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2718
|
+
error: steward.error,
|
|
2719
|
+
context: { stewardId },
|
|
2720
|
+
onRetry: steward.refetch
|
|
2721
|
+
}), steward.error ? null : /* @__PURE__ */ jsx(Muted, { children: "This steward was not found." })] });
|
|
1846
2722
|
return /* @__PURE__ */ jsx(EditCharter, {
|
|
1847
2723
|
detail,
|
|
1848
|
-
onSaved
|
|
1849
|
-
|
|
2724
|
+
onSaved,
|
|
2725
|
+
onReload: steward.refetch,
|
|
2726
|
+
reloading: steward.loading,
|
|
2727
|
+
reloadError: steward.error
|
|
2728
|
+
}, detail.charter.charterVersion);
|
|
1850
2729
|
}
|
|
1851
|
-
function EditCharter({ detail, onSaved }) {
|
|
2730
|
+
function EditCharter({ detail, onSaved, onReload, reloading, reloadError }) {
|
|
1852
2731
|
const charter = detail.charter;
|
|
1853
2732
|
const update = useStewardsMutation(UPDATE_STEWARD_CHARTER);
|
|
2733
|
+
const [baseline, setBaseline] = useState({
|
|
2734
|
+
budget: charter?.budgetPerDay ?? null,
|
|
2735
|
+
version: charter?.charterVersion
|
|
2736
|
+
});
|
|
1854
2737
|
const [charterText, setCharterText] = useState(charter?.charterText ?? "");
|
|
1855
2738
|
const [autonomy, setAutonomy] = useState(charter?.autonomyLevel ?? "ASK");
|
|
1856
2739
|
const [credits, setCredits] = useState(charter?.budgetPerDay?.credits != null ? String(charter.budgetPerDay.credits) : "");
|
|
1857
2740
|
const [validation, setValidation] = useState();
|
|
1858
2741
|
const [saved, setSaved] = useState(false);
|
|
2742
|
+
const [conflict, setConflict] = useState(false);
|
|
2743
|
+
const refusedAsStale = update.error instanceof StewardsRequestError && update.error.code === "CONFLICT";
|
|
2744
|
+
if (refusedAsStale && !conflict) setConflict(true);
|
|
1859
2745
|
const onSubmit = async (e) => {
|
|
1860
|
-
e
|
|
2746
|
+
e?.preventDefault();
|
|
1861
2747
|
const parsed = parseCredits(credits);
|
|
1862
2748
|
if (charterText.trim() === "") return setValidation("The charter cannot be empty.");
|
|
1863
2749
|
if (parsed === null) return setValidation("The daily budget must be a number, 0 or more.");
|
|
1864
2750
|
setValidation(void 0);
|
|
1865
|
-
|
|
2751
|
+
setSaved(false);
|
|
2752
|
+
const budgetPerDay = charterBudgetUpdate(baseline.budget, parsed);
|
|
2753
|
+
const result = await update.mutate({
|
|
1866
2754
|
id: detail.id,
|
|
1867
2755
|
input: {
|
|
1868
2756
|
charterText: charterText.trim(),
|
|
1869
2757
|
autonomyLevel: autonomy,
|
|
1870
|
-
...
|
|
2758
|
+
...budgetPerDay !== void 0 ? { budgetPerDay } : {},
|
|
2759
|
+
...baseline.version !== void 0 ? { expectedCharterVersion: baseline.version } : {}
|
|
1871
2760
|
}
|
|
1872
|
-
})
|
|
2761
|
+
});
|
|
2762
|
+
if (result) {
|
|
2763
|
+
const after = result.updateBotmanorStewardCharter?.charter;
|
|
2764
|
+
if (after) setBaseline({
|
|
2765
|
+
budget: after.budgetPerDay ?? null,
|
|
2766
|
+
version: after.charterVersion
|
|
2767
|
+
});
|
|
1873
2768
|
setSaved(true);
|
|
1874
2769
|
onSaved?.(detail.id);
|
|
1875
2770
|
}
|
|
1876
2771
|
};
|
|
1877
|
-
return /* @__PURE__ */
|
|
2772
|
+
return /* @__PURE__ */ jsx("form", {
|
|
1878
2773
|
onSubmit: (e) => void onSubmit(e),
|
|
1879
2774
|
noValidate: true,
|
|
1880
|
-
children:
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2775
|
+
children: /* @__PURE__ */ jsxs("fieldset", {
|
|
2776
|
+
disabled: reloading,
|
|
2777
|
+
style: {
|
|
2778
|
+
border: 0,
|
|
2779
|
+
margin: 0,
|
|
2780
|
+
padding: 0,
|
|
2781
|
+
minWidth: 0
|
|
2782
|
+
},
|
|
2783
|
+
children: [
|
|
2784
|
+
/* @__PURE__ */ jsx(CharterFields, {
|
|
2785
|
+
idPrefix: "edit",
|
|
2786
|
+
charterText,
|
|
2787
|
+
setCharterText: (v) => {
|
|
2788
|
+
setSaved(false);
|
|
2789
|
+
setCharterText(v);
|
|
2790
|
+
},
|
|
2791
|
+
autonomy,
|
|
2792
|
+
setAutonomy: (v) => {
|
|
2793
|
+
setSaved(false);
|
|
2794
|
+
setAutonomy(v);
|
|
2795
|
+
},
|
|
2796
|
+
credits,
|
|
2797
|
+
setCredits: (v) => {
|
|
2798
|
+
setSaved(false);
|
|
2799
|
+
setCredits(v);
|
|
2800
|
+
}
|
|
2801
|
+
}),
|
|
2802
|
+
validation ? /* @__PURE__ */ jsx(ErrorNote, { error: new Error(validation) }) : null,
|
|
2803
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2804
|
+
error: refusedAsStale ? void 0 : update.error,
|
|
2805
|
+
context: {
|
|
2806
|
+
stewardId: detail.id,
|
|
2807
|
+
stewardStatus: detail.status,
|
|
2808
|
+
ownerActorId: detail.ownerActorId
|
|
2809
|
+
},
|
|
2810
|
+
...isDefiniteRefusal(update.error) ? { onRetry: () => void onSubmit() } : {}
|
|
2811
|
+
}),
|
|
2812
|
+
conflict ? /* @__PURE__ */ jsxs("div", {
|
|
2813
|
+
style: { margin: "8px 0 0" },
|
|
2814
|
+
children: [
|
|
2815
|
+
/* @__PURE__ */ jsx(Muted, { children: "This charter was changed elsewhere. Reload it to edit the latest version; your unsaved changes here are discarded." }),
|
|
2816
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, { error: reloadError }),
|
|
2817
|
+
/* @__PURE__ */ jsx(Button, {
|
|
2818
|
+
type: "button",
|
|
2819
|
+
onClick: onReload,
|
|
2820
|
+
children: "Reload charter"
|
|
2821
|
+
})
|
|
2822
|
+
]
|
|
2823
|
+
}) : null,
|
|
2824
|
+
saved ? /* @__PURE__ */ jsx(Muted, { children: "Charter saved." }) : null,
|
|
2825
|
+
/* @__PURE__ */ jsx("p", {
|
|
2826
|
+
style: { margin: "16px 0 0" },
|
|
2827
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2828
|
+
type: "submit",
|
|
2829
|
+
kind: "primary",
|
|
2830
|
+
disabled: update.loading || conflict,
|
|
2831
|
+
children: "Save charter"
|
|
2832
|
+
})
|
|
1909
2833
|
})
|
|
1910
|
-
|
|
1911
|
-
|
|
2834
|
+
]
|
|
2835
|
+
})
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* What a draft or paused agent needs before its steward can run (catalog A1
|
|
2840
|
+
* prevention): publish it here when the viewer may, choose a model first when
|
|
2841
|
+
* it has none, or open the agent (or ask its owner) otherwise.
|
|
2842
|
+
*/
|
|
2843
|
+
function AgentStateNotice({ agent, onChanged }) {
|
|
2844
|
+
const guided = useMemo(() => agent.status === "ACTIVE" ? void 0 : describeGuidedError({
|
|
2845
|
+
code: "BAD_USER_INPUT",
|
|
2846
|
+
extensions: {
|
|
2847
|
+
reason: "AGENT_NOT_ACTIVE",
|
|
2848
|
+
agentId: agent.id
|
|
2849
|
+
}
|
|
2850
|
+
}, { agent: {
|
|
2851
|
+
id: agent.id,
|
|
2852
|
+
status: agent.status,
|
|
2853
|
+
...agent.llmModelId !== void 0 ? { llmModelId: agent.llmModelId } : {}
|
|
2854
|
+
} }), [agent]);
|
|
2855
|
+
if (!guided) return null;
|
|
2856
|
+
const state = (AGENT_STATUS_SHORT_LABELS[agent.status] ?? humanize(agent.status)).toLowerCase();
|
|
2857
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Muted, { children: `This agent is ${state === "draft" ? "still a draft" : state}. You can create the steward now; it runs once the agent is published.` }), /* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2858
|
+
guided,
|
|
2859
|
+
tone: "info",
|
|
2860
|
+
onRetry: onChanged
|
|
2861
|
+
})] });
|
|
2862
|
+
}
|
|
2863
|
+
/**
|
|
2864
|
+
* Browser and cloud desks run on BotManor's machines and spend the plan's desk
|
|
2865
|
+
* minutes (a steward on either needs at least one minute left to start). On a
|
|
2866
|
+
* plan without them, or with none left, the hint says so and offers the desks
|
|
2867
|
+
* that use none: the person's own machine, or no desk.
|
|
2868
|
+
*/
|
|
2869
|
+
function DeskMinutesHint({ workspaceId, desk, onChooseDesk }) {
|
|
2870
|
+
const availability = cloudDeskAvailability(useStewardsQuery(CHECK_DESK_MINUTES, { workspaceId }, { silent: true }).data?.checkWorkspaceQuota);
|
|
2871
|
+
const kind = desk === "CLOUD" ? "cloud" : "browser";
|
|
2872
|
+
const message = availability === "notInPlan" ? `Desk minutes aren't part of this workspace's plan, so a steward on a ${kind} desk can't run. Choose your own machine instead, or no desk.` : availability === "usedUp" ? `This workspace's plan has no desk minutes left this month, so a steward on a ${kind} desk can't run now. Choose your own machine instead, or no desk.` : `A ${kind} desk uses the plan's desk minutes. If the plan has none, choose your own machine instead.`;
|
|
2873
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2874
|
+
role: "status",
|
|
2875
|
+
children: [/* @__PURE__ */ jsx(Muted, { children: message }), availability === "notInPlan" || availability === "usedUp" ? /* @__PURE__ */ jsxs("p", {
|
|
2876
|
+
style: {
|
|
2877
|
+
display: "flex",
|
|
2878
|
+
gap: "8px",
|
|
2879
|
+
margin: "8px 0 0"
|
|
2880
|
+
},
|
|
2881
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
2882
|
+
onClick: () => onChooseDesk("OWN_MACHINE"),
|
|
2883
|
+
children: "Use my own machine"
|
|
2884
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
2885
|
+
onClick: () => onChooseDesk("NONE"),
|
|
2886
|
+
children: "No desk"
|
|
2887
|
+
})]
|
|
2888
|
+
}) : null]
|
|
1912
2889
|
});
|
|
1913
2890
|
}
|
|
1914
2891
|
|
|
@@ -1976,7 +2953,14 @@ function ApprovalInbox({ stewardId, pollIntervalMs = 15e3 }) {
|
|
|
1976
2953
|
children: "Approvals"
|
|
1977
2954
|
}),
|
|
1978
2955
|
loading && !approvals ? /* @__PURE__ */ jsx(Muted, { children: "Loading approvals…" }) : null,
|
|
1979
|
-
/* @__PURE__ */ jsx(
|
|
2956
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2957
|
+
error,
|
|
2958
|
+
onRetry: refetch
|
|
2959
|
+
}),
|
|
2960
|
+
/* @__PURE__ */ jsx(GuidedErrorNote, {
|
|
2961
|
+
error: error ? void 0 : decide.error,
|
|
2962
|
+
...isStaleStateError(decide.error) ? { onRetry: refetch } : {}
|
|
2963
|
+
}),
|
|
1980
2964
|
approvals && approvals.length === 0 ? /* @__PURE__ */ jsx(Muted, { children: "Nothing is waiting for your approval." }) : null,
|
|
1981
2965
|
approvals && approvals.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
1982
2966
|
style: listStyle,
|
|
@@ -2042,4 +3026,4 @@ function ApprovalInbox({ stewardId, pollIntervalMs = 15e3 }) {
|
|
|
2042
3026
|
});
|
|
2043
3027
|
}
|
|
2044
3028
|
|
|
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 };
|
|
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 };
|