@burdenoff/microfe-stewards 2026.1201.2 → 2026.1201.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.
Files changed (46) hide show
  1. package/dist/dev/liveDeskMocks.d.ts +2 -0
  2. package/dist/dev/shellGateway.d.ts +9 -0
  3. package/dist/dev/shellPermissions.d.ts +9 -0
  4. package/dist/generated/global-types.d.ts +398 -7
  5. package/dist/generated/wspace-operations.d.ts +183 -0
  6. package/dist/generated/wspace-operations.js +107 -39
  7. package/dist/generated/wspace-operations.js.map +1 -1
  8. package/dist/generated/wspace-types.d.ts +1789 -15
  9. package/dist/generated/wspace-types.js +7 -5
  10. package/dist/generated/wspace-types.js.map +1 -1
  11. package/dist/stewards/components/ControlBanner.d.ts +7 -0
  12. package/dist/stewards/components/ControlBanner.js +21 -0
  13. package/dist/stewards/components/ControlBanner.js.map +1 -0
  14. package/dist/stewards/components/LiveDeskPanel.d.ts +17 -0
  15. package/dist/stewards/components/LiveDeskPanel.js +120 -0
  16. package/dist/stewards/components/LiveDeskPanel.js.map +1 -0
  17. package/dist/stewards/i18n/en.d.ts +46 -0
  18. package/dist/stewards/i18n/en.js +46 -0
  19. package/dist/stewards/i18n/en.js.map +1 -1
  20. package/dist/stewards/live/DeskCanvas.d.ts +20 -0
  21. package/dist/stewards/live/DeskCanvas.js +95 -0
  22. package/dist/stewards/live/DeskCanvas.js.map +1 -0
  23. package/dist/stewards/live/DeskStreamConnection.d.ts +123 -0
  24. package/dist/stewards/live/DeskStreamConnection.js +239 -0
  25. package/dist/stewards/live/DeskStreamConnection.js.map +1 -0
  26. package/dist/stewards/live/backoff.d.ts +2 -0
  27. package/dist/stewards/live/backoff.js +8 -0
  28. package/dist/stewards/live/backoff.js.map +1 -0
  29. package/dist/stewards/live/browserConnection.d.ts +20 -0
  30. package/dist/stewards/live/browserConnection.js +40 -0
  31. package/dist/stewards/live/browserConnection.js.map +1 -0
  32. package/dist/stewards/live/describeStream.d.ts +15 -0
  33. package/dist/stewards/live/describeStream.js +78 -0
  34. package/dist/stewards/live/describeStream.js.map +1 -0
  35. package/dist/stewards/live/mintPass.d.ts +9 -0
  36. package/dist/stewards/live/mintPass.js +59 -0
  37. package/dist/stewards/live/mintPass.js.map +1 -0
  38. package/dist/stewards/live/protocol.d.ts +81 -0
  39. package/dist/stewards/live/protocol.js +88 -0
  40. package/dist/stewards/live/protocol.js.map +1 -0
  41. package/dist/stewards/live/useDeskStream.d.ts +17 -0
  42. package/dist/stewards/live/useDeskStream.js +25 -0
  43. package/dist/stewards/live/useDeskStream.js.map +1 -0
  44. package/dist/stewards/pages/StewardRunPage.js +26 -20
  45. package/dist/stewards/pages/StewardRunPage.js.map +1 -1
  46. package/package.json +1 -1
@@ -0,0 +1,59 @@
1
+ import { CreateBotmanorStewardDeskControlDocument as e, CreateBotmanorStewardLiveViewDocument as t } from "../../generated/wspace-operations.js";
2
+ import { BotmanorStewardDeskHolder as n } from "../../generated/wspace-types.js";
3
+ import { MintError as r } from "./DeskStreamConnection.js";
4
+ import { CombinedGraphQLErrors as i } from "@apollo/client";
5
+ // src/stewards/live/mintPass.ts
6
+ var a = /* @__PURE__ */ new Set([
7
+ "FORBIDDEN",
8
+ "UNAUTHORIZED",
9
+ "FEATURE_DISABLED",
10
+ "BAD_USER_INPUT",
11
+ "NOT_FOUND",
12
+ "CONFLICT"
13
+ ]);
14
+ function o(e) {
15
+ let t = e instanceof Error ? e.message : "Could not get a live view pass";
16
+ if (i.is(e)) {
17
+ let n = e.errors.map((e) => e.extensions?.code), i = n.some((e) => e === "FORBIDDEN" || e === "UNAUTHORIZED"), o = n.some((e) => typeof e == "string" && a.has(e));
18
+ return new r(t, {
19
+ retryable: !o,
20
+ forbidden: i
21
+ });
22
+ }
23
+ return new r(t, { retryable: !0 });
24
+ }
25
+ function s(e) {
26
+ let t = Date.parse(e.expiresAt);
27
+ return {
28
+ token: e.token,
29
+ relayPath: e.relayPath,
30
+ mode: e.mode === "CONTROL" ? "control" : "view",
31
+ expiresAtMs: Number.isFinite(t) ? t : 0,
32
+ holder: e.heldBy === n.Person ? "person" : "steward"
33
+ };
34
+ }
35
+ function c(n, r) {
36
+ return async (i) => {
37
+ try {
38
+ if (i === "control") {
39
+ let { data: t } = await n.mutate({
40
+ mutation: e,
41
+ variables: { runId: r }
42
+ });
43
+ if (!t) throw Error("No pass returned");
44
+ return s(t.createBotmanorStewardDeskControl);
45
+ }
46
+ let { data: a } = await n.mutate({
47
+ mutation: t,
48
+ variables: { runId: r }
49
+ });
50
+ if (!a) throw Error("No pass returned");
51
+ return s(a.createBotmanorStewardLiveView);
52
+ } catch (e) {
53
+ throw o(e);
54
+ }
55
+ };
56
+ }
57
+ export { c as createPassMinter };
58
+
59
+ //# sourceMappingURL=mintPass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mintPass.js","names":["FINAL_CODES","toMintError","message","error","CombinedGraphQLErrors","codes","forbidden","c","final","MintError","toPass","expiresAtMs","payload","BotmanorStewardDeskHolder","createPassMinter","mode","client","CreateBotmanorStewardDeskControlDocument","data","CreateBotmanorStewardLiveViewDocument"],"sources":["../../../src/stewards/live/mintPass.ts"],"sourcesContent":["import type { ApolloClient } from '@apollo/client';\nimport { CombinedGraphQLErrors } from '@apollo/client';\nimport {\n CreateBotmanorStewardDeskControlDocument,\n CreateBotmanorStewardLiveViewDocument,\n type CreateBotmanorStewardDeskControlMutation,\n type CreateBotmanorStewardLiveViewMutation,\n} from '../../generated/wspace-operations';\nimport { BotmanorStewardDeskHolder } from '../../generated/wspace-types';\nimport { MintError, type StreamPass } from './DeskStreamConnection';\nimport type { StreamMode } from './protocol';\n\n/** GraphQL error codes where asking again cannot succeed: refusals, not hiccups. */\nconst FINAL_CODES = new Set([\n 'FORBIDDEN',\n 'UNAUTHORIZED',\n 'FEATURE_DISABLED',\n 'BAD_USER_INPUT',\n 'NOT_FOUND',\n 'CONFLICT',\n]);\n\nfunction toMintError(error: unknown): MintError {\n const message = error instanceof Error ? error.message : 'Could not get a live view pass';\n if (CombinedGraphQLErrors.is(error)) {\n const codes = error.errors.map((e) => e.extensions?.code);\n const forbidden = codes.some((c) => c === 'FORBIDDEN' || c === 'UNAUTHORIZED');\n const final = codes.some((c) => typeof c === 'string' && FINAL_CODES.has(c));\n return new MintError(message, { retryable: !final, forbidden });\n }\n // A network failure while minting is worth another try.\n return new MintError(message, { retryable: true });\n}\n\ntype PassPayload =\n | CreateBotmanorStewardLiveViewMutation['createBotmanorStewardLiveView']\n | CreateBotmanorStewardDeskControlMutation['createBotmanorStewardDeskControl'];\n\nfunction toPass(payload: PassPayload): StreamPass {\n const expiresAtMs = Date.parse(payload.expiresAt);\n return {\n token: payload.token,\n relayPath: payload.relayPath,\n mode: payload.mode === 'CONTROL' ? 'control' : 'view',\n expiresAtMs: Number.isFinite(expiresAtMs) ? expiresAtMs : 0,\n holder: payload.heldBy === BotmanorStewardDeskHolder.Person ? 'person' : 'steward',\n };\n}\n\n/**\n * Mints a one-use pass for the relay: `createBotmanorStewardDeskControl` for control (the caller\n * must have taken the run over) and `createBotmanorStewardLiveView` for watching. Mutations are\n * never cached, so a pass is never replayed from the Apollo cache.\n */\nexport function createPassMinter(client: ApolloClient, runId: string) {\n return async (mode: StreamMode): Promise<StreamPass> => {\n try {\n if (mode === 'control') {\n const { data } = await client.mutate<CreateBotmanorStewardDeskControlMutation>({\n mutation: CreateBotmanorStewardDeskControlDocument,\n variables: { runId },\n });\n if (!data) throw new Error('No pass returned');\n return toPass(data.createBotmanorStewardDeskControl);\n }\n const { data } = await client.mutate<CreateBotmanorStewardLiveViewMutation>({\n mutation: CreateBotmanorStewardLiveViewDocument,\n variables: { runId },\n });\n if (!data) throw new Error('No pass returned');\n return toPass(data.createBotmanorStewardLiveView);\n } catch (error) {\n throw toMintError(error);\n }\n };\n}\n"],"mappings":";;;;;AAaA,IAAMA,oBAAc,IAAI,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAASC,EA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
+ /**
2
+ * Wire contract of the gateway's `/steward-desk` relay (BOFF-16552), as the viewer sees it.
3
+ * Source of truth: wspace-public-gateway `docs/steward-desk-relay.md` and `src/steward-desk/relay.ts`.
4
+ *
5
+ * Credentials travel in the first client frame because a browser WebSocket cannot set headers.
6
+ * Everything after `ready` is opaque desk traffic. The relay never inspects it, and neither does
7
+ * this module: input frames are built here and written to the socket, never stored or logged.
8
+ */
9
+ /** The exact text the relay treats as a keepalive; any other client frame is desk input. */
10
+ export declare const KEEPALIVE_FRAME = "{\"type\":\"keepalive\"}";
11
+ export type StreamMode = 'view' | 'control';
12
+ /** Why a stream is not running, as the UI explains it. */
13
+ export type StreamEndReason = 'leaseEnded' | 'idle' | 'forbidden' | 'notFound' | 'signIn' | 'badRequest' | 'tooMany' | 'unavailable' | 'mintFailed';
14
+ /** What the viewer does after a close code. */
15
+ export type CloseAction = {
16
+ kind: 'ended';
17
+ reason: StreamEndReason;
18
+ } | {
19
+ kind: 'failed';
20
+ reason: StreamEndReason;
21
+ } | {
22
+ kind: 'renewOrSignIn';
23
+ } | {
24
+ kind: 'reconnect';
25
+ };
26
+ /** Map a relay close code to the next step. Unknown and abnormal codes reconnect with backoff. */
27
+ export declare function classifyClose(code: number): CloseAction;
28
+ /**
29
+ * `wss://<gateway host><relayPath>`. The relay path comes from the API, so it is checked before a
30
+ * credential is sent to it: it must be an absolute path on the gateway, never another host.
31
+ * Returns null for anything else.
32
+ */
33
+ export declare function buildRelayUrl(gatewayBaseUrl: string, relayPath: string): string | null;
34
+ export interface ConnectCredentials {
35
+ token: string;
36
+ authorization: string;
37
+ workspaceAuthorization: string;
38
+ }
39
+ /** The first frame. Built at send time so the pass is not kept around afterwards. */
40
+ export declare function connectFrame(credentials: ConnectCredentials): string;
41
+ export interface ReadyFrame {
42
+ mode: StreamMode;
43
+ expiresAt: number;
44
+ }
45
+ /** The relay's `ready` message, or null when the text is anything else. */
46
+ export declare function parseReady(text: string): ReadyFrame | null;
47
+ /** Longest binary frame the viewer will decode, matching the relay's own ceiling. */
48
+ export declare const MAX_FRAME_BYTES: number;
49
+ export type ImageMime = 'image/png' | 'image/jpeg' | 'image/webp';
50
+ /** The image type of a binary frame from its leading bytes, or null when it is not an image. */
51
+ export declare function sniffImageMime(bytes: Uint8Array): ImageMime | null;
52
+ export type PointerAction = 'move' | 'down' | 'up';
53
+ export type DeskInput = {
54
+ type: 'pointer';
55
+ action: PointerAction;
56
+ x: number;
57
+ y: number;
58
+ button: number;
59
+ } | {
60
+ type: 'wheel';
61
+ x: number;
62
+ y: number;
63
+ dx: number;
64
+ dy: number;
65
+ } | {
66
+ type: 'key';
67
+ action: 'down' | 'up';
68
+ key: string;
69
+ code: string;
70
+ };
71
+ /** A position inside the rendered screen, as a fraction of its width and height. */
72
+ export declare function normalisePoint(rect: {
73
+ left: number;
74
+ top: number;
75
+ width: number;
76
+ height: number;
77
+ }, clientX: number, clientY: number): {
78
+ x: number;
79
+ y: number;
80
+ };
81
+ export declare function encodeInput(input: DeskInput): string;
@@ -0,0 +1,88 @@
1
+ // src/stewards/live/protocol.ts
2
+ var e = {
3
+ BAD_REQUEST: 4400,
4
+ UNAUTHORIZED: 4401,
5
+ FORBIDDEN: 4403,
6
+ NOT_FOUND: 4404,
7
+ IDLE: 4408,
8
+ LEASE_ENDED: 4410,
9
+ TOO_MANY: 4429,
10
+ UNAVAILABLE: 4503,
11
+ GATEWAY_RESTART: 1012
12
+ }, t = "{\"type\":\"keepalive\"}";
13
+ function n(t) {
14
+ switch (t) {
15
+ case e.LEASE_ENDED: return {
16
+ kind: "ended",
17
+ reason: "leaseEnded"
18
+ };
19
+ case e.IDLE: return {
20
+ kind: "ended",
21
+ reason: "idle"
22
+ };
23
+ case e.FORBIDDEN: return {
24
+ kind: "failed",
25
+ reason: "forbidden"
26
+ };
27
+ case e.NOT_FOUND: return {
28
+ kind: "failed",
29
+ reason: "notFound"
30
+ };
31
+ case e.BAD_REQUEST: return {
32
+ kind: "failed",
33
+ reason: "badRequest"
34
+ };
35
+ case e.UNAUTHORIZED: return { kind: "renewOrSignIn" };
36
+ default: return { kind: "reconnect" };
37
+ }
38
+ }
39
+ function r(e, t) {
40
+ if (!/^\/[A-Za-z0-9._~\-/]*$/.test(t) || t.includes("//") || t.split("/").some((e) => e === ".." || e === ".")) return null;
41
+ let n;
42
+ try {
43
+ n = new URL(e);
44
+ } catch {
45
+ return null;
46
+ }
47
+ return n.protocol !== "https:" && n.protocol !== "http:" ? null : `${n.protocol === "https:" ? "wss:" : "ws:"}//${n.host}${t}`;
48
+ }
49
+ function i(e) {
50
+ return JSON.stringify({
51
+ type: "connect",
52
+ ...e
53
+ });
54
+ }
55
+ function a(e) {
56
+ let t;
57
+ try {
58
+ t = JSON.parse(e);
59
+ } catch {
60
+ return null;
61
+ }
62
+ if (typeof t != "object" || !t) return null;
63
+ let { type: n, mode: r, expiresAt: i } = t;
64
+ return n !== "ready" || r !== "view" && r !== "control" || typeof i != "number" || !Number.isFinite(i) ? null : {
65
+ mode: r,
66
+ expiresAt: i
67
+ };
68
+ }
69
+ var o = 16777216;
70
+ function s(e) {
71
+ return e.length >= 8 && e[0] === 137 && e[1] === 80 && e[2] === 78 && e[3] === 71 ? "image/png" : e.length >= 3 && e[0] === 255 && e[1] === 216 && e[2] === 255 ? "image/jpeg" : e.length >= 12 && e[0] === 82 && e[1] === 73 && e[2] === 70 && e[3] === 70 && e[8] === 87 && e[9] === 69 && e[10] === 66 && e[11] === 80 ? "image/webp" : null;
72
+ }
73
+ var c = (e) => Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
74
+ function l(e, t, n) {
75
+ return e.width <= 0 || e.height <= 0 ? {
76
+ x: 0,
77
+ y: 0
78
+ } : {
79
+ x: c((t - e.left) / e.width),
80
+ y: c((n - e.top) / e.height)
81
+ };
82
+ }
83
+ function u(e) {
84
+ return JSON.stringify(e);
85
+ }
86
+ export { t as KEEPALIVE_FRAME, o as MAX_FRAME_BYTES, r as buildRelayUrl, n as classifyClose, i as connectFrame, u as encodeInput, l as normalisePoint, a as parseReady, s as sniffImageMime };
87
+
88
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","names":["RELAY_CLOSE","KEEPALIVE_FRAME","classifyClose","code","buildRelayUrl","relayPath","segment","base","gatewayBaseUrl","connectFrame","credentials","parseReady","value","text","type","mode","expiresAt","MAX_FRAME_BYTES","sniffImageMime","bytes","clamp01","n","normalisePoint","rect","clientX","clientY","encodeInput","input"],"sources":["../../../src/stewards/live/protocol.ts"],"sourcesContent":["/**\n * Wire contract of the gateway's `/steward-desk` relay (BOFF-16552), as the viewer sees it.\n * Source of truth: wspace-public-gateway `docs/steward-desk-relay.md` and `src/steward-desk/relay.ts`.\n *\n * Credentials travel in the first client frame because a browser WebSocket cannot set headers.\n * Everything after `ready` is opaque desk traffic. The relay never inspects it, and neither does\n * this module: input frames are built here and written to the socket, never stored or logged.\n */\n\n/** Close codes the relay uses. 1012 is a gateway restart. */\nconst RELAY_CLOSE = {\n BAD_REQUEST: 4400,\n UNAUTHORIZED: 4401,\n FORBIDDEN: 4403,\n NOT_FOUND: 4404,\n IDLE: 4408,\n LEASE_ENDED: 4410,\n TOO_MANY: 4429,\n UNAVAILABLE: 4503,\n GATEWAY_RESTART: 1012,\n} as const;\n\n/** The exact text the relay treats as a keepalive; any other client frame is desk input. */\nexport const KEEPALIVE_FRAME = '{\"type\":\"keepalive\"}';\n\nexport type StreamMode = 'view' | 'control';\n\n/** Why a stream is not running, as the UI explains it. */\nexport type StreamEndReason =\n | 'leaseEnded'\n | 'idle'\n | 'forbidden'\n | 'notFound'\n | 'signIn'\n | 'badRequest'\n | 'tooMany'\n | 'unavailable'\n | 'mintFailed';\n\n/** What the viewer does after a close code. */\nexport type CloseAction =\n | { kind: 'ended'; reason: StreamEndReason }\n | { kind: 'failed'; reason: StreamEndReason }\n | { kind: 'renewOrSignIn' }\n | { kind: 'reconnect' };\n\n/** Map a relay close code to the next step. Unknown and abnormal codes reconnect with backoff. */\nexport function classifyClose(code: number): CloseAction {\n switch (code) {\n case RELAY_CLOSE.LEASE_ENDED:\n return { kind: 'ended', reason: 'leaseEnded' };\n case RELAY_CLOSE.IDLE:\n return { kind: 'ended', reason: 'idle' };\n case RELAY_CLOSE.FORBIDDEN:\n return { kind: 'failed', reason: 'forbidden' };\n case RELAY_CLOSE.NOT_FOUND:\n return { kind: 'failed', reason: 'notFound' };\n case RELAY_CLOSE.BAD_REQUEST:\n return { kind: 'failed', reason: 'badRequest' };\n case RELAY_CLOSE.UNAUTHORIZED:\n return { kind: 'renewOrSignIn' };\n default:\n // 4429, 4503, 1006 (dropped), 1011, 1012 (gateway restart) and anything unknown.\n return { kind: 'reconnect' };\n }\n}\n\n/**\n * `wss://<gateway host><relayPath>`. The relay path comes from the API, so it is checked before a\n * credential is sent to it: it must be an absolute path on the gateway, never another host.\n * Returns null for anything else.\n */\nexport function buildRelayUrl(gatewayBaseUrl: string, relayPath: string): string | null {\n if (!/^\\/[A-Za-z0-9._~\\-/]*$/.test(relayPath) || relayPath.includes('//')) return null;\n if (relayPath.split('/').some((segment) => segment === '..' || segment === '.')) return null;\n let base: URL;\n try {\n base = new URL(gatewayBaseUrl);\n } catch {\n return null;\n }\n if (base.protocol !== 'https:' && base.protocol !== 'http:') return null;\n const protocol = base.protocol === 'https:' ? 'wss:' : 'ws:';\n return `${protocol}//${base.host}${relayPath}`;\n}\n\nexport interface ConnectCredentials {\n token: string;\n authorization: string;\n workspaceAuthorization: string;\n}\n\n/** The first frame. Built at send time so the pass is not kept around afterwards. */\nexport function connectFrame(credentials: ConnectCredentials): string {\n return JSON.stringify({ type: 'connect', ...credentials });\n}\n\nexport interface ReadyFrame {\n mode: StreamMode;\n expiresAt: number;\n}\n\n/** The relay's `ready` message, or null when the text is anything else. */\nexport function parseReady(text: string): ReadyFrame | null {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n return null;\n }\n if (typeof value !== 'object' || value === null) return null;\n const { type, mode, expiresAt } = value as Record<string, unknown>;\n if (type !== 'ready' || (mode !== 'view' && mode !== 'control')) return null;\n if (typeof expiresAt !== 'number' || !Number.isFinite(expiresAt)) return null;\n return { mode, expiresAt };\n}\n\n// ---------------------------------------------------------------------------\n// Desk frames and input\n//\n// The relay passes desk frames through untouched, so the format is agreed with the desk plugin\n// (BOFF-16145). This viewer renders a binary frame as one screen image (PNG, JPEG or WebP) and\n// ignores text frames it does not know. Input goes the other way as small JSON messages with\n// pointer positions normalised to 0..1 of the screen, so they do not depend on the image size.\n// ---------------------------------------------------------------------------\n\n/** Longest binary frame the viewer will decode, matching the relay's own ceiling. */\nexport const MAX_FRAME_BYTES = 16 * 1024 * 1024;\n\nexport type ImageMime = 'image/png' | 'image/jpeg' | 'image/webp';\n\n/** The image type of a binary frame from its leading bytes, or null when it is not an image. */\nexport function sniffImageMime(bytes: Uint8Array): ImageMime | null {\n if (\n bytes.length >= 8 &&\n bytes[0] === 0x89 &&\n bytes[1] === 0x50 &&\n bytes[2] === 0x4e &&\n bytes[3] === 0x47\n ) {\n return 'image/png';\n }\n if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff) {\n return 'image/jpeg';\n }\n if (\n bytes.length >= 12 &&\n bytes[0] === 0x52 && // R\n bytes[1] === 0x49 && // I\n bytes[2] === 0x46 && // F\n bytes[3] === 0x46 && // F\n bytes[8] === 0x57 && // W\n bytes[9] === 0x45 && // E\n bytes[10] === 0x42 && // B\n bytes[11] === 0x50 // P\n ) {\n return 'image/webp';\n }\n return null;\n}\n\nexport type PointerAction = 'move' | 'down' | 'up';\n\nexport type DeskInput =\n | { type: 'pointer'; action: PointerAction; x: number; y: number; button: number }\n | { type: 'wheel'; x: number; y: number; dx: number; dy: number }\n | { type: 'key'; action: 'down' | 'up'; key: string; code: string };\n\nconst clamp01 = (n: number): number => (Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : 0);\n\n/** A position inside the rendered screen, as a fraction of its width and height. */\nexport function normalisePoint(\n rect: { left: number; top: number; width: number; height: number },\n clientX: number,\n clientY: number\n): { x: number; y: number } {\n if (rect.width <= 0 || rect.height <= 0) return { x: 0, y: 0 };\n return {\n x: clamp01((clientX - rect.left) / rect.width),\n y: clamp01((clientY - rect.top) / rect.height),\n };\n}\n\nexport function encodeInput(input: DeskInput): string {\n return JSON.stringify(input);\n}\n"],"mappings":";AAUA,IAAMA,IAAc;CAClB,aAAa;CACb,cAAc;CACd,WAAW;CACX,WAAW;CACX,MAAM;CACN,aAAa;CACb,UAAU;CACV,aAAa;CACb,iBAAiB;AACnB,GAGaC,IAAkB;AAwB/B,SAAgBC,EAAc,GAA2B;CACvD,QAAQC,GAAR;EACE,KAAKH,EAAY,aACf,OAAO;GAAE,MAAM;GAAS,QAAQ;EAAa;EAC/C,KAAKA,EAAY,MACf,OAAO;GAAE,MAAM;GAAS,QAAQ;EAAO;EACzC,KAAKA,EAAY,WACf,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAY;EAC/C,KAAKA,EAAY,WACf,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAW;EAC9C,KAAKA,EAAY,aACf,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAa;EAChD,KAAKA,EAAY,cACf,OAAO,EAAE,MAAM,gBAAgB;EACjC,SAEE,OAAO,EAAE,MAAM,YAAY;CAC/B;AACF;AAOA,SAAgBI,EAAc,GAAwB,GAAkC;CAEtF,IADI,CAAC,yBAAyB,KAAKC,CAAS,KAAKA,EAAU,SAAS,IAAI,KACpEA,EAAU,MAAM,GAAG,CAAC,CAAC,MAAM,MAAYC,MAAY,QAAQA,MAAY,GAAG,GAAG,OAAO;CACxF,IAAIC;CACJ,IAAI;EACF,IAAO,IAAI,IAAIC,CAAc;CAC/B,QAAQ;EACN,OAAO;CACT;CAGA,OAFID,EAAK,aAAa,YAAYA,EAAK,aAAa,UAAgB,OAE7D,GADUA,EAAK,aAAa,WAAW,SAAS,MACpC,IAAIA,EAAK,OAAOF;AAC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AAO,KAAK,UAAUC,CAAK;AAC7B"}
@@ -0,0 +1,17 @@
1
+ import { FrameSink } from './browserConnection';
2
+ import { StreamState } from './DeskStreamConnection';
3
+ import { StreamMode } from './protocol';
4
+ export type { FrameSink };
5
+ export interface DeskStream {
6
+ state: StreamState;
7
+ start: (mode: StreamMode) => void;
8
+ stop: () => void;
9
+ /** Write one input frame; false when the stream is not live control. */
10
+ send: (frame: string) => boolean;
11
+ /** Where desk frames go (the canvas). Frames are not kept in React state. */
12
+ setFrameSink: (sink: FrameSink | null) => void;
13
+ }
14
+ /**
15
+ * Thin React binding over `DeskStreamConnection`: one connection per run, closed on unmount.
16
+ */
17
+ export declare function useDeskStream(runId: string): DeskStream;
@@ -0,0 +1,25 @@
1
+ import { createBrowserConnection as e } from "./browserConnection.js";
2
+ import { INITIAL_STREAM_STATE as t } from "./DeskStreamConnection.js";
3
+ import { useEffect as n, useMemo as r, useSyncExternalStore as i } from "react";
4
+ import { useApolloClient as a } from "@apollo/client/react";
5
+ import { useAuthTokenOrNull as o } from "@burdenoff/fe-libs/shared/providers/shell";
6
+ // src/stewards/live/useDeskStream.ts
7
+ function s(s) {
8
+ let c = a(), l = o(), u = r(() => e(c, s), [c, s]);
9
+ n(() => {
10
+ u.setSession(l);
11
+ }, [u, l]), n(() => () => u.connection.stop(), [u]);
12
+ let { connection: d } = u;
13
+ return {
14
+ state: i(d.subscribe, d.getState, () => t),
15
+ ...r(() => ({
16
+ start: (e) => d.start(e),
17
+ stop: () => d.stop(),
18
+ send: (e) => d.send(e),
19
+ setFrameSink: u.setFrameSink
20
+ }), [d, u])
21
+ };
22
+ }
23
+ export { s as useDeskStream };
24
+
25
+ //# sourceMappingURL=useDeskStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeskStream.js","names":["useDeskStream","client","useApolloClient","auth","useAuthTokenOrNull","bundle","useMemo","createBrowserConnection","runId","useEffect","useSyncExternalStore","connection","INITIAL_STREAM_STATE","mode","frame"],"sources":["../../../src/stewards/live/useDeskStream.ts"],"sourcesContent":["import { useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\nimport { useAuthTokenOrNull } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { createBrowserConnection, type FrameSink } from './browserConnection';\nimport { INITIAL_STREAM_STATE, type StreamState } from './DeskStreamConnection';\nimport type { StreamMode } from './protocol';\n\nexport type { FrameSink };\n\nexport interface DeskStream {\n state: StreamState;\n start: (mode: StreamMode) => void;\n stop: () => void;\n /** Write one input frame; false when the stream is not live control. */\n send: (frame: string) => boolean;\n /** Where desk frames go (the canvas). Frames are not kept in React state. */\n setFrameSink: (sink: FrameSink | null) => void;\n}\n\n/**\n * Thin React binding over `DeskStreamConnection`: one connection per run, closed on unmount.\n */\nexport function useDeskStream(runId: string): DeskStream {\n const client = useApolloClient();\n const auth = useAuthTokenOrNull();\n const bundle = useMemo(() => createBrowserConnection(client, runId), [client, runId]);\n\n useEffect(() => {\n bundle.setSession(auth);\n }, [bundle, auth]);\n useEffect(() => () => bundle.connection.stop(), [bundle]);\n\n const { connection } = bundle;\n const state = useSyncExternalStore(\n connection.subscribe,\n connection.getState,\n () => INITIAL_STREAM_STATE\n );\n // Stable identities: the panel's connect effect depends on `start` and `stop`.\n const actions = useMemo(\n () => ({\n start: (mode: StreamMode) => connection.start(mode),\n stop: () => connection.stop(),\n send: (frame: string) => connection.send(frame),\n setFrameSink: bundle.setFrameSink,\n }),\n [connection, bundle]\n );\n return { state, ...actions };\n}\n"],"mappings":";;;;;;AAsBA,SAAgBA,EAAc,GAA2B;CACvD,IAAMC,IAASC,EAAgB,GACzBC,IAAOC,EAAmB,GAC1BC,IAASC,QAAcC,EAAwBN,GAAQO,CAAK,GAAG,CAACP,GAAQO,CAAK,CAAC;CAKpF,AAHAC,QAAgB;EACd,EAAO,WAAWN,CAAI;CACxB,GAAG,CAACE,GAAQF,CAAI,CAAC,GACjBM,cAAsBJ,EAAO,WAAW,KAAK,GAAG,CAACA,CAAM,CAAC;CAExD,IAAM,EAAE,kBAAeA;CAgBvB,OAAO;EAAE,OAfKK,EACZC,EAAW,WACXA,EAAW,gBACLC,CAYC;EAAO,GATAN,SACP;GACL,QAAQ,MAAqBK,EAAW,MAAME,CAAI;GAClD,YAAYF,EAAW,KAAK;GAC5B,OAAO,MAAkBA,EAAW,KAAKG,CAAK;GAC9C,cAAcT,EAAO;EACvB,IACA,CAACM,GAAYN,CAAM,CAEF;CAAQ;AAC7B"}
@@ -1,25 +1,26 @@
1
1
  import { useBotmanorStewardRunUpdatedSubscription as e, useCancelBotmanorStewardRunMutation as t, useGetBotmanorStewardQuery as n, useGetBotmanorStewardRunQuery as r, useGetStewardStepScreenshotUrlQuery as i, useListBotmanorStewardRunsQuery as a, useRunBotmanorStewardMutation as o } from "../../generated/wspace-operations.js";
2
2
  import { BotmanorExecutionStepVerdict as s, BotmanorStewardStatus as c } from "../../generated/wspace-types.js";
3
3
  import { RUN_STATUS_TONE as ee, VERDICT_TONE as l, budgetRatio as u, enumLabel as d, isRunFinished as f } from "../components/stewardLabels.js";
4
+ import { LiveDeskPanel as te } from "../components/LiveDeskPanel.js";
4
5
  import { Alert as p, Badge as m, Button as h, Card as g, ProgressBar as _, StateMessage as v } from "../components/ui.js";
5
6
  import { useStewardsT as y } from "../i18n/useStewardsT.js";
6
- import { useStewardAbilities as te } from "../permissions/useStewardPermissions.js";
7
- import { useStewardsContext as ne } from "../providers/StewardsProvider.js";
7
+ import { useStewardAbilities as ne } from "../permissions/useStewardPermissions.js";
8
+ import { useStewardsContext as re } from "../providers/StewardsProvider.js";
8
9
  import { clockTime as b } from "../utils/dates.js";
9
- import { isForbiddenError as re } from "../utils/errors.js";
10
+ import { isForbiddenError as ie } from "../utils/errors.js";
10
11
  import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
11
- import { useEffect as ie, useState as w } from "react";
12
- import { useParams as ae } from "react-router";
12
+ import { useEffect as ae, useState as w } from "react";
13
+ import { useParams as oe } from "react-router";
13
14
  // src/stewards/pages/StewardRunPage.tsx
14
- var oe = 3e3;
15
- function se(e) {
15
+ var se = 3e3;
16
+ function ce(e) {
16
17
  return {
17
18
  allowed: e.filter((e) => e.verdict === s.Allowed || e.verdict === s.Approved).length,
18
19
  asked: e.filter((e) => e.verdict === s.Asked).length,
19
20
  denied: e.filter((e) => e.verdict === s.Denied).length
20
21
  };
21
22
  }
22
- function ce(e) {
23
+ function le(e) {
23
24
  return e.find((e) => e.trustLevelAfter !== e.trustLevelBefore);
24
25
  }
25
26
  var T = 900;
@@ -46,7 +47,7 @@ function E({ fileId: e }) {
46
47
  onError: () => r(!0)
47
48
  });
48
49
  }
49
- function le({ step: e, timeZone: t }) {
50
+ function ue({ step: e, timeZone: t }) {
50
51
  let n = y(), r = e.argumentsRedacted, i = typeof r == "object" && !!r && Object.keys(r).length > 0;
51
52
  return /* @__PURE__ */ C("div", {
52
53
  className: "grid grid-cols-1 gap-4 xl:grid-cols-2",
@@ -138,23 +139,23 @@ function le({ step: e, timeZone: t }) {
138
139
  });
139
140
  }
140
141
  function D() {
141
- let i = y(), { runId: s = "" } = ae(), { navigate: T, pathTo: E } = ne(), { canExecute: D } = te(), [O, k] = w(null), A = r({
142
+ let i = y(), { runId: s = "" } = oe(), { navigate: T, pathTo: E } = re(), { canExecute: D } = ne(), [O, k] = w(null), A = r({
142
143
  variables: { id: s },
143
144
  skip: !s,
144
145
  fetchPolicy: "cache-and-network"
145
146
  }), j = A.data?.getBotmanorStewardRun ?? void 0, M = j?.stewardId, N = n({
146
147
  variables: { id: M ?? "" },
147
148
  skip: !M
148
- }).data?.getBotmanorSteward ?? void 0, P = j ? f(j.status) : !1, ue = e({
149
+ }).data?.getBotmanorSteward ?? void 0, P = j ? f(j.status) : !1, de = e({
149
150
  variables: { stewardId: M ?? "" },
150
151
  skip: !M || P
151
- }), { startPolling: F, stopPolling: I } = A, L = !!j && !P && !!ue.error;
152
- ie(() => (L ? F(oe) : I(), () => I()), [
152
+ }), { startPolling: F, stopPolling: I } = A, L = !!j && !P && !!de.error;
153
+ ae(() => (L ? F(se) : I(), () => I()), [
153
154
  L,
154
155
  F,
155
156
  I
156
157
  ]);
157
- let [de, R] = t(), [fe, z] = o(), [pe, B] = w(!1), V = a({
158
+ let [fe, R] = t(), [pe, z] = o(), [me, B] = w(!1), V = a({
158
159
  variables: {
159
160
  filter: { stewardId: M ?? "" },
160
161
  pagination: { limit: 20 }
@@ -165,7 +166,7 @@ function D() {
165
166
  if (A.error && !j) return /* @__PURE__ */ S("div", {
166
167
  className: "p-6",
167
168
  children: /* @__PURE__ */ S(v, {
168
- kind: re(A.error) ? "forbidden" : "error",
169
+ kind: ie(A.error) ? "forbidden" : "error",
169
170
  title: i("stewards.run.loadError"),
170
171
  body: A.error.message,
171
172
  action: /* @__PURE__ */ S(h, {
@@ -189,8 +190,8 @@ function D() {
189
190
  })
190
191
  })
191
192
  });
192
- let H = N?.charter.timezone ?? "UTC", U = j.steps, W = U.find((e) => e.id === O) ?? U[U.length - 1], G = se(U), K = ce(U), q = N?.charter.budgetPerRun.credits ?? null, J = N?.charter.budgetPerRun.steps ?? null, Y = j.budgetUsed.credits ?? 0, X = j.execution?.input ?? "", Z = (V.data?.listBotmanorStewardRuns ?? []).some((e) => e.id !== j.id && !f(e.status)), Q = N?.status !== c.Active || Z || V.loading, $ = (e) => {
193
- B(!1), fe({ variables: { input: {
193
+ let H = N?.charter.timezone ?? "UTC", U = j.steps, W = U.find((e) => e.id === O) ?? U[U.length - 1], G = ce(U), K = le(U), q = N?.charter.budgetPerRun.credits ?? null, J = N?.charter.budgetPerRun.steps ?? null, Y = j.budgetUsed.credits ?? 0, X = j.execution?.input ?? "", Z = (V.data?.listBotmanorStewardRuns ?? []).some((e) => e.id !== j.id && !f(e.status)), Q = N?.status !== c.Active || Z || V.loading, $ = (e) => {
194
+ B(!1), pe({ variables: { input: {
194
195
  stewardId: j.stewardId,
195
196
  prompt: X,
196
197
  dryRun: e
@@ -258,7 +259,7 @@ function D() {
258
259
  children: [!P && /* @__PURE__ */ S(h, {
259
260
  variant: "danger",
260
261
  disabled: R.loading,
261
- onClick: () => void de({ variables: { id: j.id } }).catch(() => void 0),
262
+ onClick: () => void fe({ variables: { id: j.id } }).catch(() => void 0),
262
263
  children: R.loading ? i("stewards.run.stopping") : i("stewards.run.stopRun")
263
264
  }), P && X !== "" && /* @__PURE__ */ C(x, { children: [!j.dryRun && /* @__PURE__ */ S(h, {
264
265
  variant: "primary",
@@ -282,7 +283,7 @@ function D() {
282
283
  role: "status",
283
284
  children: i(Z ? "stewards.run.retryBlockedActive" : "stewards.run.retryBlockedStatus")
284
285
  }),
285
- pe && /* @__PURE__ */ C(p, { children: [/* @__PURE__ */ S("p", {
286
+ me && /* @__PURE__ */ C(p, { children: [/* @__PURE__ */ S("p", {
286
287
  className: "mb-2",
287
288
  children: i("stewards.run.retryLiveConfirm")
288
289
  }), /* @__PURE__ */ C("div", {
@@ -306,6 +307,11 @@ function D() {
306
307
  role: "status",
307
308
  children: i(L ? "stewards.run.polling" : "stewards.run.live")
308
309
  }),
310
+ !P && /* @__PURE__ */ S(te, {
311
+ runId: j.id,
312
+ status: j.status,
313
+ canExecute: D
314
+ }),
309
315
  /* @__PURE__ */ C("div", {
310
316
  className: "grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4",
311
317
  children: [
@@ -459,7 +465,7 @@ function D() {
459
465
  tool: W.toolKey ?? d(i, "stepKind", W.kind)
460
466
  }) : i("stewards.run.stepsHeading"),
461
467
  className: "xl:col-span-3",
462
- children: W ? /* @__PURE__ */ S(le, {
468
+ children: W ? /* @__PURE__ */ S(ue, {
463
469
  step: W,
464
470
  timeZone: H
465
471
  }) : /* @__PURE__ */ S("p", {