@burdenoff/fluidgrids-fe-sdk 2026.1028.3 → 2026.1028.5

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.
@@ -1,9 +1,10 @@
1
1
  import { buildNodeDisplayMap, ExecutionStatusBadge, formatRunVersion, NodeTimeline, RunLogViewer } from './chunk-SSJIK6WS.js';
2
2
  import { useExecution, useExecutionActions, useAutoRefresh } from './chunk-UUUDSVC7.js';
3
- import { EntityTagPicker } from './chunk-MODO24HY.js';
3
+ import { useRunPolicyDecisions, RunPolicyDecisions } from './chunk-VUVTOUQ5.js';
4
+ import { EntityTagPicker, useWorkflowProposal, WorkflowProposalCard } from './chunk-JAKWVVVQ.js';
4
5
  import { throwIfResultError, useFluidGridsPermission, FLUIDGRIDS_PERMISSIONS } from './chunk-5LKZ4PNK.js';
5
6
  import { getFluidGridsConfig } from './chunk-CY6KX4RG.js';
6
- import { RunLogsDocument, RunLogAppendedDocument, ExplainRunDocument, WorkflowProposalDocument, ProposeRunFixDocument, ProposeWorkflowChangeDocument, ApplyWorkflowProposalDocument, RejectWorkflowProposalDocument, CancelWorkflowProposalDocument } from './chunk-JBLYBD2B.js';
7
+ import { RunLogsDocument, RunLogAppendedDocument, ExplainRunDocument } from './chunk-JBLYBD2B.js';
7
8
  import { useTr } from './chunk-UULVIT25.js';
8
9
  import { getFluidGridsClient, getFluidGridsClientSafe } from './chunk-NTWG3CJX.js';
9
10
  import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
@@ -800,400 +801,6 @@ function RunQueuedBanner({
800
801
  }
801
802
  );
802
803
  }
803
- var PROPOSAL_POLL_INTERVAL_MS = 3e3;
804
- var PROPOSAL_MAX_WAIT_MS = 6 * 60 * 1e3;
805
- function messageOf(error) {
806
- return error instanceof Error ? error.message : String(error);
807
- }
808
- function isProposalRunning(status) {
809
- return status === "PROCESSING";
810
- }
811
- function useWorkflowProposal() {
812
- const [proposal, setProposal] = useState(null);
813
- const [isWorking, setIsWorking] = useState(false);
814
- const [isDeciding, setIsDeciding] = useState(false);
815
- const [error, setError] = useState(null);
816
- const [timedOut, setTimedOut] = useState(false);
817
- const runRef = useRef(0);
818
- const timerRef = useRef(null);
819
- const clearTimer = useCallback(() => {
820
- if (timerRef.current) clearTimeout(timerRef.current);
821
- timerRef.current = null;
822
- }, []);
823
- useEffect(
824
- () => () => {
825
- runRef.current++;
826
- clearTimer();
827
- },
828
- [clearTimer]
829
- );
830
- const reset = useCallback(() => {
831
- runRef.current++;
832
- clearTimer();
833
- setProposal(null);
834
- setIsWorking(false);
835
- setIsDeciding(false);
836
- setError(null);
837
- setTimedOut(false);
838
- }, [clearTimer]);
839
- const poll = useCallback(
840
- async (run, id, startedAt) => {
841
- if (run !== runRef.current) return;
842
- try {
843
- const result = throwIfResultError(
844
- await getFluidGridsClient().query({
845
- query: WorkflowProposalDocument,
846
- variables: { id },
847
- fetchPolicy: "network-only"
848
- })
849
- );
850
- if (run !== runRef.current) return;
851
- const next = result.data?.workflowProposal ?? null;
852
- if (next) setProposal(next);
853
- const status = next ? String(next.status) : void 0;
854
- if (isProposalRunning(status)) {
855
- if (Date.now() - startedAt < PROPOSAL_MAX_WAIT_MS) {
856
- timerRef.current = setTimeout(
857
- () => void poll(run, id, startedAt),
858
- PROPOSAL_POLL_INTERVAL_MS
859
- );
860
- return;
861
- }
862
- setTimedOut(true);
863
- }
864
- setIsWorking(false);
865
- } catch (pollError) {
866
- if (run !== runRef.current) return;
867
- setError(messageOf(pollError));
868
- setIsWorking(false);
869
- }
870
- },
871
- []
872
- );
873
- const start = useCallback(
874
- async (input) => {
875
- const run = ++runRef.current;
876
- clearTimer();
877
- setProposal(null);
878
- setError(null);
879
- setTimedOut(false);
880
- setIsWorking(true);
881
- try {
882
- const client = getFluidGridsClient();
883
- let started;
884
- if (input.kind === "runFix") {
885
- const result = throwIfResultError(
886
- await client.mutate({
887
- mutation: ProposeRunFixDocument,
888
- variables: {
889
- input: {
890
- runId: input.runId,
891
- ...input.prompt ? { prompt: input.prompt } : {}
892
- }
893
- }
894
- })
895
- );
896
- started = result.data?.proposeRunFix;
897
- } else {
898
- const result = throwIfResultError(
899
- await client.mutate({
900
- mutation: ProposeWorkflowChangeDocument,
901
- variables: {
902
- input: {
903
- prompt: input.prompt,
904
- ...input.workflowKey ? { workflowKey: input.workflowKey } : {},
905
- ...input.baseVersion ? { baseVersion: input.baseVersion } : {}
906
- }
907
- }
908
- })
909
- );
910
- started = result.data?.proposeWorkflowChange;
911
- }
912
- if (!started?.id) throw new Error("The proposal did not start");
913
- if (run !== runRef.current) return;
914
- setProposal(started);
915
- const id = started.id;
916
- timerRef.current = setTimeout(
917
- () => void poll(run, id, Date.now()),
918
- PROPOSAL_POLL_INTERVAL_MS
919
- );
920
- } catch (startError) {
921
- if (run !== runRef.current) return;
922
- setError(messageOf(startError));
923
- setIsWorking(false);
924
- }
925
- },
926
- [clearTimer, poll]
927
- );
928
- const decide = useCallback(
929
- async (action) => {
930
- const id = proposal?.id;
931
- if (!id) return null;
932
- const run = runRef.current;
933
- setIsDeciding(true);
934
- setError(null);
935
- try {
936
- const client = getFluidGridsClient();
937
- let next;
938
- if (action === "apply") {
939
- const result = throwIfResultError(
940
- await client.mutate({ mutation: ApplyWorkflowProposalDocument, variables: { id } })
941
- );
942
- next = result.data?.applyWorkflowProposal;
943
- } else if (action === "reject") {
944
- const result = throwIfResultError(
945
- await client.mutate({ mutation: RejectWorkflowProposalDocument, variables: { id } })
946
- );
947
- next = result.data?.rejectWorkflowProposal;
948
- } else {
949
- clearTimer();
950
- const result = throwIfResultError(
951
- await client.mutate({ mutation: CancelWorkflowProposalDocument, variables: { id } })
952
- );
953
- next = result.data?.cancelWorkflowProposal;
954
- setIsWorking(false);
955
- }
956
- if (run === runRef.current && next) setProposal(next);
957
- return next ?? null;
958
- } catch (decideError) {
959
- if (run === runRef.current) setError(messageOf(decideError));
960
- return null;
961
- } finally {
962
- if (run === runRef.current) setIsDeciding(false);
963
- }
964
- },
965
- [clearTimer, proposal?.id]
966
- );
967
- const apply = useCallback(() => decide("apply"), [decide]);
968
- const reject = useCallback(async () => {
969
- await decide("reject");
970
- }, [decide]);
971
- const cancel = useCallback(async () => {
972
- await decide("cancel");
973
- }, [decide]);
974
- return {
975
- proposal,
976
- isWorking,
977
- isDeciding,
978
- error,
979
- timedOut,
980
- start,
981
- apply,
982
- reject,
983
- cancel,
984
- reset
985
- };
986
- }
987
- var STATUS_TONE = {
988
- PROCESSING: "secondary",
989
- PROPOSED: "default",
990
- APPLIED: "default",
991
- REJECTED: "outline",
992
- STALE: "outline",
993
- CANCELLED: "outline",
994
- FAILED: "destructive"
995
- };
996
- function edgeLabel(edge) {
997
- const from = edge.sourceHandle ? `${edge.source} (${edge.sourceHandle})` : edge.source;
998
- return `${from} \u2192 ${edge.target}`;
999
- }
1000
- function ChangeList({
1001
- title,
1002
- icon,
1003
- items,
1004
- testId
1005
- }) {
1006
- if (items.length === 0) return null;
1007
- return /* @__PURE__ */ jsxs("div", { "data-testid": testId, children: [
1008
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-secondary", children: [
1009
- /* @__PURE__ */ jsx(Icon, { icon, width: 14 }),
1010
- title,
1011
- " (",
1012
- items.length,
1013
- ")"
1014
- ] }),
1015
- /* @__PURE__ */ jsx("ul", { className: "mt-1 space-y-0.5 text-sm text-text-primary", children: items.map((item) => /* @__PURE__ */ jsx("li", { className: "truncate", children: item }, item)) })
1016
- ] });
1017
- }
1018
- function nodeLine(node, withFields) {
1019
- const base = `${node.label} \xB7 ${node.type}`;
1020
- return withFields && node.fields.length > 0 ? `${base} \u2014 ${node.fields.join(", ")}` : base;
1021
- }
1022
- function WorkflowProposalCard({
1023
- proposal,
1024
- isDeciding = false,
1025
- onOpenWorkflow,
1026
- onApply,
1027
- onReject,
1028
- onCancel
1029
- }) {
1030
- const tr = useTr();
1031
- const status = String(proposal.status);
1032
- const diff = proposal.diff;
1033
- const warnings = proposal.validation?.warnings ?? [];
1034
- const errors = proposal.validation?.valid === false ? proposal.validation.errors : [];
1035
- return /* @__PURE__ */ jsxs(
1036
- "section",
1037
- {
1038
- className: "rounded-lg border border-border-secondary bg-background-secondary p-4",
1039
- "data-testid": "workflow-proposal-card",
1040
- "data-status": status,
1041
- children: [
1042
- /* @__PURE__ */ jsxs("header", { className: "flex flex-wrap items-center gap-2", children: [
1043
- /* @__PURE__ */ jsx(
1044
- Icon,
1045
- {
1046
- icon: "mdi:creation-outline",
1047
- width: 18,
1048
- className: "text-text-secondary"
1049
- }
1050
- ),
1051
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-text-primary", children: proposal.name ?? tr("fluidgrids.ai.proposal.title", "AI proposal") }),
1052
- /* @__PURE__ */ jsx(
1053
- Badge,
1054
- {
1055
- variant: STATUS_TONE[status] ?? "outline",
1056
- "data-testid": "workflow-proposal-status",
1057
- children: status
1058
- }
1059
- ),
1060
- proposal.baseVersion && /* @__PURE__ */ jsx("span", { className: "text-xs text-text-secondary", children: tr(
1061
- "fluidgrids.ai.proposal.against",
1062
- "against version {{version}}",
1063
- {
1064
- version: proposal.baseVersion
1065
- }
1066
- ) })
1067
- ] }),
1068
- status === "PROCESSING" && /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center gap-2 text-sm text-text-secondary", children: [
1069
- /* @__PURE__ */ jsx(Icon, { icon: "mdi:loading", width: 16, className: "animate-spin" }),
1070
- tr("fluidgrids.ai.proposal.working", "Working ({{stage}})\u2026", {
1071
- stage: proposal.progress?.stage ?? "prompting"
1072
- }),
1073
- onCancel && /* @__PURE__ */ jsx(
1074
- Button$1,
1075
- {
1076
- size: "sm",
1077
- variant: "ghost",
1078
- onClick: onCancel,
1079
- disabled: isDeciding,
1080
- children: tr("fluidgrids.ai.proposal.cancel", "Cancel")
1081
- }
1082
- )
1083
- ] }),
1084
- proposal.explanation && /* @__PURE__ */ jsx(
1085
- "p",
1086
- {
1087
- className: "mt-3 text-sm text-text-primary",
1088
- "data-testid": "workflow-proposal-explanation",
1089
- children: proposal.explanation
1090
- }
1091
- ),
1092
- proposal.message && status !== "PROPOSED" && status !== "PROCESSING" && status !== "APPLIED" && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-text-secondary", children: proposal.message }),
1093
- diff && /* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-2", "data-testid": "workflow-proposal-diff", children: [
1094
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-text-primary", children: diff.summary }),
1095
- /* @__PURE__ */ jsx(
1096
- ChangeList,
1097
- {
1098
- testId: "workflow-proposal-added",
1099
- icon: "mdi:plus-circle-outline",
1100
- title: tr("fluidgrids.ai.proposal.added", "Added nodes"),
1101
- items: diff.addedNodes.map((node) => nodeLine(node, false))
1102
- }
1103
- ),
1104
- /* @__PURE__ */ jsx(
1105
- ChangeList,
1106
- {
1107
- testId: "workflow-proposal-changed",
1108
- icon: "mdi:pencil-circle-outline",
1109
- title: tr("fluidgrids.ai.proposal.changed", "Changed nodes"),
1110
- items: diff.changedNodes.map((node) => nodeLine(node, true))
1111
- }
1112
- ),
1113
- /* @__PURE__ */ jsx(
1114
- ChangeList,
1115
- {
1116
- testId: "workflow-proposal-removed",
1117
- icon: "mdi:minus-circle-outline",
1118
- title: tr("fluidgrids.ai.proposal.removed", "Removed nodes"),
1119
- items: diff.removedNodes.map((node) => nodeLine(node, false))
1120
- }
1121
- ),
1122
- /* @__PURE__ */ jsx(
1123
- ChangeList,
1124
- {
1125
- testId: "workflow-proposal-edges",
1126
- icon: "mdi:vector-line",
1127
- title: tr(
1128
- "fluidgrids.ai.proposal.connections",
1129
- "Connection changes"
1130
- ),
1131
- items: [
1132
- ...diff.addedEdges.map((edge) => `+ ${edgeLabel(edge)}`),
1133
- ...diff.removedEdges.map((edge) => `\u2212 ${edgeLabel(edge)}`)
1134
- ]
1135
- }
1136
- )
1137
- ] }),
1138
- errors.length > 0 && /* @__PURE__ */ jsx("ul", { className: "mt-3 space-y-1 text-sm text-[var(--color-status-error-text)]", children: errors.map((message) => /* @__PURE__ */ jsx("li", { children: message }, message)) }),
1139
- warnings.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-3", "data-testid": "workflow-proposal-warnings", children: [
1140
- /* @__PURE__ */ jsx("div", { className: "text-xs font-medium uppercase tracking-wide text-text-secondary", children: tr("fluidgrids.ai.proposal.todo", "Still to set up") }),
1141
- /* @__PURE__ */ jsx("ul", { className: "mt-1 space-y-0.5 text-sm text-text-secondary", children: warnings.map((warning) => /* @__PURE__ */ jsx("li", { children: warning }, warning)) })
1142
- ] }),
1143
- status === "PROPOSED" && (onApply || onReject) && /* @__PURE__ */ jsxs("div", { className: "mt-4 flex flex-wrap items-center gap-2", children: [
1144
- onApply && /* @__PURE__ */ jsx(
1145
- Button$1,
1146
- {
1147
- size: "sm",
1148
- onClick: onApply,
1149
- disabled: isDeciding,
1150
- "data-testid": "workflow-proposal-apply",
1151
- children: proposal.baseVersion ? tr(
1152
- "fluidgrids.ai.proposal.applyVersion",
1153
- "Apply as a new draft version"
1154
- ) : tr(
1155
- "fluidgrids.ai.proposal.applyNew",
1156
- "Create as a draft workflow"
1157
- )
1158
- }
1159
- ),
1160
- onReject && /* @__PURE__ */ jsx(
1161
- Button$1,
1162
- {
1163
- size: "sm",
1164
- variant: "outline",
1165
- onClick: onReject,
1166
- disabled: isDeciding,
1167
- children: tr("fluidgrids.ai.proposal.reject", "Reject")
1168
- }
1169
- ),
1170
- /* @__PURE__ */ jsx("span", { className: "text-xs text-text-secondary", children: tr(
1171
- "fluidgrids.ai.proposal.neverActivates",
1172
- "Nothing goes live: the result is a draft you can review, run as a test and activate yourself."
1173
- ) })
1174
- ] }),
1175
- status === "APPLIED" && proposal.appliedWorkflowKey && proposal.appliedVersion && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-1", children: [
1176
- onOpenWorkflow && /* @__PURE__ */ jsx(
1177
- Button$1,
1178
- {
1179
- size: "sm",
1180
- variant: "outline",
1181
- "data-testid": "workflow-proposal-open",
1182
- onClick: () => onOpenWorkflow(
1183
- proposal.appliedWorkflowKey ?? "",
1184
- proposal.appliedVersion ?? ""
1185
- ),
1186
- children: tr("fluidgrids.ai.proposal.open", "Open draft {{version}}", {
1187
- version: proposal.appliedVersion
1188
- })
1189
- }
1190
- ),
1191
- proposal.restoreHint && /* @__PURE__ */ jsx("p", { className: "text-xs text-text-secondary", children: proposal.restoreHint })
1192
- ] })
1193
- ]
1194
- }
1195
- );
1196
- }
1197
804
  function RunAiAssistPanel({
1198
805
  runId,
1199
806
  status,
@@ -1346,6 +953,9 @@ function ExecutionDetailPage() {
1346
953
  } = useRunHumanRequests(runId, {
1347
954
  pollIntervalMs: runCanChange ? 1e4 : 0
1348
955
  });
956
+ const { decisions: policyDecisions, decide: decidePolicyApproval } = useRunPolicyDecisions(runId, {
957
+ pollIntervalMs: runCanChange ? 1e4 : 0
958
+ });
1349
959
  const awaitingPerson = humanRequests.some(
1350
960
  (request) => request.status === "PENDING"
1351
961
  );
@@ -1931,6 +1541,17 @@ function ExecutionDetailPage() {
1931
1541
  /* @__PURE__ */ jsx(RunQueuedBanner, { status: execution.status, context: execution.context }),
1932
1542
  /* @__PURE__ */ jsx(RunDataPrunedNotice, { dataPrunedAt: execution.dataPrunedAt }),
1933
1543
  /* @__PURE__ */ jsx(RunHumanRequests, { requests: humanRequests }),
1544
+ /* @__PURE__ */ jsx(
1545
+ RunPolicyDecisions,
1546
+ {
1547
+ decisions: policyDecisions,
1548
+ waiting: execution.status === "WAITING",
1549
+ onDecide: async (id, approve) => {
1550
+ await decidePolicyApproval(id, approve);
1551
+ await Promise.all([refetch(), refetchHumanRequests()]);
1552
+ }
1553
+ }
1554
+ ),
1934
1555
  /* @__PURE__ */ jsx("div", { className: "border-b border-border-secondary mb-6", children: /* @__PURE__ */ jsx("nav", { className: "flex gap-4 -mb-px", children: tabs.map((tab) => /* @__PURE__ */ jsxs(
1935
1556
  "button",
1936
1557
  {
@@ -1,5 +1,5 @@
1
1
  import { isGuidedTourIntent, pickGuidedTour, withoutGuidedTourIntent, isCreateIntent, CreateWorkflowRefusalDialog, decideMissingWorkflow } from './chunk-CSBKB5EX.js';
2
- import { useInstalledNodes, buildNodeCheck, FlowBuilderPage, buildRequiredNodeTypes } from './chunk-227PQY53.js';
2
+ import { useInstalledNodes, buildNodeCheck, FlowBuilderPage, buildRequiredNodeTypes } from './chunk-JH6YDVT5.js';
3
3
  import { useLazyWorkflowDefinition, useCreateWorkflow } from './chunk-63BP6O6E.js';
4
4
  import { useFlowStore, refetchStoreNodes, BILLING_PLANS_PATH, mergeStickyNotes, blankWorkflowCreateInput, classifyCreateRefusal } from './chunk-5LKZ4PNK.js';
5
5
  import { useTr } from './chunk-UULVIT25.js';