@botmanor/fe-sdk 2026.1205.2 → 2026.1205.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +164 -39
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -372,6 +372,9 @@ const CREATE_STEWARD = `mutation CreateBotmanorSteward($input: CreateBotmanorSte
|
|
|
372
372
|
const UPDATE_STEWARD_CHARTER = `mutation UpdateBotmanorStewardCharter($id: ID!, $input: UpdateBotmanorStewardCharterInput!) {
|
|
373
373
|
updateBotmanorStewardCharter(id: $id, input: $input) { ${STEWARD_DETAIL} }
|
|
374
374
|
}`;
|
|
375
|
+
const SET_STEWARD_STATUS = `mutation SetBotmanorStewardStatus($id: ID!, $status: BotmanorStewardStatus!) {
|
|
376
|
+
setBotmanorStewardStatus(id: $id, status: $status) { id status }
|
|
377
|
+
}`;
|
|
375
378
|
const LIST_AGENT_CANDIDATES = `query ListStewardAgentCandidates($filters: BotmanorAgentFilterInput) {
|
|
376
379
|
listBotmanorAgents(filters: $filters) { id name description status capabilities }
|
|
377
380
|
}`;
|
|
@@ -1497,7 +1500,16 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl, ownMachineAccess })
|
|
|
1497
1500
|
pagination: { limit: 10 }
|
|
1498
1501
|
}, { pollMs: (d) => d.listBotmanorStewardRuns.some((r) => !isTerminalRunStatus(r.status)) ? 5e3 : false });
|
|
1499
1502
|
const [selectedRun, setSelectedRun] = useState(void 0);
|
|
1500
|
-
const
|
|
1503
|
+
const [confirmed, setConfirmed] = useState(void 0);
|
|
1504
|
+
const latestAnswer = useRef(steward.data);
|
|
1505
|
+
latestAnswer.current = steward.data;
|
|
1506
|
+
const loaded = steward.data?.getBotmanorSteward ?? void 0;
|
|
1507
|
+
const override = confirmed && confirmed.stewardId === stewardId && loaded?.id === stewardId && steward.data === confirmed.answer ? confirmed.status : void 0;
|
|
1508
|
+
if (confirmed && !override) setConfirmed(void 0);
|
|
1509
|
+
const detail = loaded && override ? {
|
|
1510
|
+
...loaded,
|
|
1511
|
+
status: override
|
|
1512
|
+
} : loaded;
|
|
1501
1513
|
const notFound = !steward.loading && !steward.error && !detail;
|
|
1502
1514
|
const onStarted = (runId) => {
|
|
1503
1515
|
setSelectedRun(runId);
|
|
@@ -1516,6 +1528,19 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl, ownMachineAccess })
|
|
|
1516
1528
|
notFound ? /* @__PURE__ */ jsx(Muted, { children: "This steward was not found." }) : null,
|
|
1517
1529
|
detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1518
1530
|
/* @__PURE__ */ jsx(StewardSummary, { detail }),
|
|
1531
|
+
/* @__PURE__ */ jsx(StatusActions, {
|
|
1532
|
+
detail,
|
|
1533
|
+
canUpdate: ownMachineAccess?.canUpdateSteward !== false,
|
|
1534
|
+
onChanged: (id, status) => {
|
|
1535
|
+
if (id !== stewardId) return;
|
|
1536
|
+
setConfirmed({
|
|
1537
|
+
stewardId: id,
|
|
1538
|
+
status,
|
|
1539
|
+
answer: latestAnswer.current
|
|
1540
|
+
});
|
|
1541
|
+
steward.refetch();
|
|
1542
|
+
}
|
|
1543
|
+
}),
|
|
1519
1544
|
/* @__PURE__ */ jsx(OwnMachineSection, {
|
|
1520
1545
|
detail,
|
|
1521
1546
|
vibecontrolsUrl,
|
|
@@ -1537,6 +1562,48 @@ function StewardPanel({ stewardId, onBack, vibecontrolsUrl, ownMachineAccess })
|
|
|
1537
1562
|
] }) : null
|
|
1538
1563
|
] });
|
|
1539
1564
|
}
|
|
1565
|
+
/** The status a steward moves to from each status, with its button label (archiving stays in BotManor). */
|
|
1566
|
+
const NEXT_STATUS = {
|
|
1567
|
+
DRAFT: {
|
|
1568
|
+
to: "ACTIVE",
|
|
1569
|
+
label: "Activate steward"
|
|
1570
|
+
},
|
|
1571
|
+
ACTIVE: {
|
|
1572
|
+
to: "PAUSED",
|
|
1573
|
+
label: "Pause steward"
|
|
1574
|
+
},
|
|
1575
|
+
PAUSED: {
|
|
1576
|
+
to: "ACTIVE",
|
|
1577
|
+
label: "Resume steward"
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
/**
|
|
1581
|
+
* Activate a new (draft) steward, or pause and resume one (BOFF-18393). A
|
|
1582
|
+
* steward created here starts as a draft, and only an active steward can run,
|
|
1583
|
+
* so without this a person had to leave the app to finish setting it up.
|
|
1584
|
+
* Shown to a viewer with botmanor-steward:update (`canUpdateSteward`); without
|
|
1585
|
+
* an access answer the gateway decides.
|
|
1586
|
+
*/
|
|
1587
|
+
function StatusActions({ detail, canUpdate, onChanged }) {
|
|
1588
|
+
const change = useStewardsMutation(SET_STEWARD_STATUS);
|
|
1589
|
+
const next = NEXT_STATUS[detail.status];
|
|
1590
|
+
if (!next || !canUpdate) return null;
|
|
1591
|
+
const onClick = async () => {
|
|
1592
|
+
const result = await change.mutate({
|
|
1593
|
+
id: detail.id,
|
|
1594
|
+
status: next.to
|
|
1595
|
+
});
|
|
1596
|
+
if (result) onChanged(result.setBotmanorStewardStatus.id, result.setBotmanorStewardStatus.status);
|
|
1597
|
+
};
|
|
1598
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1599
|
+
style: { margin: "8px 0 0" },
|
|
1600
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1601
|
+
onClick: () => void onClick(),
|
|
1602
|
+
disabled: change.loading,
|
|
1603
|
+
children: next.label
|
|
1604
|
+
}), /* @__PURE__ */ jsx(ErrorNote, { error: change.error })]
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1540
1607
|
/** The machine picker, for a steward whose desk kind is OWN_MACHINE. */
|
|
1541
1608
|
function OwnMachineSection({ detail, vibecontrolsUrl, access }) {
|
|
1542
1609
|
if (detail.defaultDeskKind !== "OWN_MACHINE") return null;
|
|
@@ -1686,6 +1753,25 @@ function parseCredits(raw) {
|
|
|
1686
1753
|
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
1687
1754
|
}
|
|
1688
1755
|
/**
|
|
1756
|
+
* The daily budget to send when a charter is edited, or `undefined` to leave
|
|
1757
|
+
* it as it is. The service replaces the whole daily budget, so the other daily
|
|
1758
|
+
* limits (steps, desk minutes, wall time, connector spend) set elsewhere are
|
|
1759
|
+
* carried over, and a cleared credit field drops only the credit cap
|
|
1760
|
+
* (BOFF-18393). Nothing is sent when the credit cap did not change.
|
|
1761
|
+
*/
|
|
1762
|
+
function charterBudgetUpdate(current, credits) {
|
|
1763
|
+
if ((current?.credits ?? void 0) === credits) return void 0;
|
|
1764
|
+
const kept = {};
|
|
1765
|
+
if (current?.deskMinutes != null) kept.deskMinutes = current.deskMinutes;
|
|
1766
|
+
if (current?.steps != null) kept.steps = current.steps;
|
|
1767
|
+
if (current?.wallSeconds != null) kept.wallSeconds = current.wallSeconds;
|
|
1768
|
+
if (current?.connectorSpendMinor != null) kept.connectorSpendMinor = current.connectorSpendMinor;
|
|
1769
|
+
return credits === void 0 ? kept : {
|
|
1770
|
+
...kept,
|
|
1771
|
+
credits
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1689
1775
|
* Create a steward from an agent and a charter, or edit an existing charter:
|
|
1690
1776
|
* the charter text, the autonomy level and a daily credit budget. Duties and
|
|
1691
1777
|
* playbooks live in the full Stewards app.
|
|
@@ -1845,70 +1931,109 @@ function EditForm({ stewardId, onSaved }) {
|
|
|
1845
1931
|
if (!detail?.charter) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ErrorNote, { error: steward.error }), steward.error ? null : /* @__PURE__ */ jsx(Muted, { children: "This steward was not found." })] });
|
|
1846
1932
|
return /* @__PURE__ */ jsx(EditCharter, {
|
|
1847
1933
|
detail,
|
|
1848
|
-
onSaved
|
|
1849
|
-
|
|
1934
|
+
onSaved,
|
|
1935
|
+
onReload: steward.refetch,
|
|
1936
|
+
reloading: steward.loading,
|
|
1937
|
+
reloadError: steward.error
|
|
1938
|
+
}, detail.charter.charterVersion);
|
|
1850
1939
|
}
|
|
1851
|
-
function EditCharter({ detail, onSaved }) {
|
|
1940
|
+
function EditCharter({ detail, onSaved, onReload, reloading, reloadError }) {
|
|
1852
1941
|
const charter = detail.charter;
|
|
1853
1942
|
const update = useStewardsMutation(UPDATE_STEWARD_CHARTER);
|
|
1943
|
+
const [baseline, setBaseline] = useState({
|
|
1944
|
+
budget: charter?.budgetPerDay ?? null,
|
|
1945
|
+
version: charter?.charterVersion
|
|
1946
|
+
});
|
|
1854
1947
|
const [charterText, setCharterText] = useState(charter?.charterText ?? "");
|
|
1855
1948
|
const [autonomy, setAutonomy] = useState(charter?.autonomyLevel ?? "ASK");
|
|
1856
1949
|
const [credits, setCredits] = useState(charter?.budgetPerDay?.credits != null ? String(charter.budgetPerDay.credits) : "");
|
|
1857
1950
|
const [validation, setValidation] = useState();
|
|
1858
1951
|
const [saved, setSaved] = useState(false);
|
|
1952
|
+
const [conflict, setConflict] = useState(false);
|
|
1953
|
+
if (update.error instanceof StewardsRequestError && update.error.code === "CONFLICT" && !conflict) setConflict(true);
|
|
1859
1954
|
const onSubmit = async (e) => {
|
|
1860
1955
|
e.preventDefault();
|
|
1861
1956
|
const parsed = parseCredits(credits);
|
|
1862
1957
|
if (charterText.trim() === "") return setValidation("The charter cannot be empty.");
|
|
1863
1958
|
if (parsed === null) return setValidation("The daily budget must be a number, 0 or more.");
|
|
1864
1959
|
setValidation(void 0);
|
|
1865
|
-
|
|
1960
|
+
setSaved(false);
|
|
1961
|
+
const budgetPerDay = charterBudgetUpdate(baseline.budget, parsed);
|
|
1962
|
+
const result = await update.mutate({
|
|
1866
1963
|
id: detail.id,
|
|
1867
1964
|
input: {
|
|
1868
1965
|
charterText: charterText.trim(),
|
|
1869
1966
|
autonomyLevel: autonomy,
|
|
1870
|
-
...
|
|
1967
|
+
...budgetPerDay !== void 0 ? { budgetPerDay } : {},
|
|
1968
|
+
...baseline.version !== void 0 ? { expectedCharterVersion: baseline.version } : {}
|
|
1871
1969
|
}
|
|
1872
|
-
})
|
|
1970
|
+
});
|
|
1971
|
+
if (result) {
|
|
1972
|
+
const after = result.updateBotmanorStewardCharter?.charter;
|
|
1973
|
+
if (after) setBaseline({
|
|
1974
|
+
budget: after.budgetPerDay ?? null,
|
|
1975
|
+
version: after.charterVersion
|
|
1976
|
+
});
|
|
1873
1977
|
setSaved(true);
|
|
1874
1978
|
onSaved?.(detail.id);
|
|
1875
1979
|
}
|
|
1876
1980
|
};
|
|
1877
|
-
return /* @__PURE__ */
|
|
1981
|
+
return /* @__PURE__ */ jsx("form", {
|
|
1878
1982
|
onSubmit: (e) => void onSubmit(e),
|
|
1879
1983
|
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
|
-
|
|
1984
|
+
children: /* @__PURE__ */ jsxs("fieldset", {
|
|
1985
|
+
disabled: reloading,
|
|
1986
|
+
style: {
|
|
1987
|
+
border: 0,
|
|
1988
|
+
margin: 0,
|
|
1989
|
+
padding: 0,
|
|
1990
|
+
minWidth: 0
|
|
1991
|
+
},
|
|
1992
|
+
children: [
|
|
1993
|
+
/* @__PURE__ */ jsx(CharterFields, {
|
|
1994
|
+
idPrefix: "edit",
|
|
1995
|
+
charterText,
|
|
1996
|
+
setCharterText: (v) => {
|
|
1997
|
+
setSaved(false);
|
|
1998
|
+
setCharterText(v);
|
|
1999
|
+
},
|
|
2000
|
+
autonomy,
|
|
2001
|
+
setAutonomy: (v) => {
|
|
2002
|
+
setSaved(false);
|
|
2003
|
+
setAutonomy(v);
|
|
2004
|
+
},
|
|
2005
|
+
credits,
|
|
2006
|
+
setCredits: (v) => {
|
|
2007
|
+
setSaved(false);
|
|
2008
|
+
setCredits(v);
|
|
2009
|
+
}
|
|
2010
|
+
}),
|
|
2011
|
+
validation ? /* @__PURE__ */ jsx(ErrorNote, { error: new Error(validation) }) : null,
|
|
2012
|
+
/* @__PURE__ */ jsx(ErrorNote, { error: update.error }),
|
|
2013
|
+
conflict ? /* @__PURE__ */ jsxs("div", {
|
|
2014
|
+
style: { margin: "8px 0 0" },
|
|
2015
|
+
children: [
|
|
2016
|
+
/* @__PURE__ */ jsx(Muted, { children: "This charter was changed elsewhere. Reload it to edit the latest version; your unsaved changes here are discarded." }),
|
|
2017
|
+
/* @__PURE__ */ jsx(ErrorNote, { error: reloadError }),
|
|
2018
|
+
/* @__PURE__ */ jsx(Button, {
|
|
2019
|
+
type: "button",
|
|
2020
|
+
onClick: onReload,
|
|
2021
|
+
children: "Reload charter"
|
|
2022
|
+
})
|
|
2023
|
+
]
|
|
2024
|
+
}) : null,
|
|
2025
|
+
saved ? /* @__PURE__ */ jsx(Muted, { children: "Charter saved." }) : null,
|
|
2026
|
+
/* @__PURE__ */ jsx("p", {
|
|
2027
|
+
style: { margin: "16px 0 0" },
|
|
2028
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2029
|
+
type: "submit",
|
|
2030
|
+
kind: "primary",
|
|
2031
|
+
disabled: update.loading || conflict,
|
|
2032
|
+
children: "Save charter"
|
|
2033
|
+
})
|
|
1909
2034
|
})
|
|
1910
|
-
|
|
1911
|
-
|
|
2035
|
+
]
|
|
2036
|
+
})
|
|
1912
2037
|
});
|
|
1913
2038
|
}
|
|
1914
2039
|
|