@sanity/assist 4.1.0 → 4.3.0

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 CHANGED
@@ -214,7 +214,16 @@ function isImage(schemaType) {
214
214
  return isType(schemaType, "image");
215
215
  }
216
216
  function getDescriptionFieldOption(schemaType) {
217
- return schemaType ? schemaType.options?.aiAssist?.imageDescriptionField || getDescriptionFieldOption(schemaType.type) : void 0;
217
+ if (!schemaType)
218
+ return;
219
+ const descriptionField = schemaType.options?.aiAssist?.imageDescriptionField;
220
+ return typeof descriptionField == "string" ? {
221
+ path: descriptionField,
222
+ updateOnImageChange: !0
223
+ } : descriptionField ? {
224
+ path: descriptionField.path,
225
+ updateOnImageChange: descriptionField.updateOnImageChange ?? !0
226
+ } : getDescriptionFieldOption(schemaType.type);
218
227
  }
219
228
  function getImageInstructionFieldOption(schemaType) {
220
229
  return schemaType ? schemaType.options?.aiAssist?.imageInstructionField || getImageInstructionFieldOption(schemaType.type) : void 0;
@@ -408,10 +417,10 @@ function getFieldRefs(schemaType, parent, depth = 0) {
408
417
  }
409
418
  function getSyntheticFields(schemaType, parent, depth = 0) {
410
419
  return depth >= maxDepth ? [] : schemaType.of.filter((itemType) => !isType(itemType, "block")).flatMap((itemType) => {
411
- const segment = { _key: itemType.name }, title = itemType.title ?? itemType.name, path = [...parent.path, segment], fieldRef = {
420
+ const segment = { _key: itemType.name }, title = itemType.title ?? itemType.name, path = parent ? [...parent.path, segment] : [segment], fieldRef = {
412
421
  key: patchableKey(sanity.pathToString(path)),
413
422
  path,
414
- title: [parent.title, title].join(" / "),
423
+ title: parent ? [parent.title, title].join(" / ") : title,
415
424
  schemaType: itemType,
416
425
  icon: getTypeIcon(itemType),
417
426
  synthetic: !0
@@ -592,7 +601,6 @@ function serializeInlineOf(blockSchemaType, schema, options2) {
592
601
  if (!(!childrenType || !sanity.isArraySchemaType(childrenType)))
593
602
  return arrayOf(
594
603
  {
595
- ...childrenType,
596
604
  of: childrenType.of.filter((t) => !isType(t, "span"))
597
605
  },
598
606
  schema,
@@ -816,6 +824,8 @@ function useRunInstructionApi(apiClient) {
816
824
  const NO_INPUT = {}, RunInstructionContext = react.createContext({
817
825
  runInstruction: () => {
818
826
  },
827
+ getUserInput: async () => {
828
+ },
819
829
  instructionLoading: !1
820
830
  });
821
831
  function useRunInstruction() {
@@ -825,7 +835,18 @@ function isUserInputBlock(block) {
825
835
  return block._type === userInputTypeName;
826
836
  }
827
837
  function RunInstructionProvider(props) {
828
- const { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { runInstruction: runInstructionRequest, loading } = useRunInstructionApi(apiClient), id = react.useId(), [inputs, setInputs] = react.useState(NO_INPUT), [runRequest, setRunRequest] = react.useState(), runInstruction = react.useCallback(
838
+ const { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { runInstruction: runInstructionRequest, loading } = useRunInstructionApi(apiClient), id = react.useId(), [inputs, setInputs] = react.useState(NO_INPUT), [runRequest, setRunRequest] = react.useState(), [resolveUserInput, setResolveUserInput] = react.useState(), getUserInput = react.useCallback(async ({ title, inputs: inputs2 }) => {
839
+ const userInputBlocks = inputs2.map((input, i) => ({
840
+ _type: userInputTypeName,
841
+ _key: input.id ?? `${i}`,
842
+ message: input.title,
843
+ description: input.description
844
+ }));
845
+ if (userInputBlocks.length)
846
+ return setRunRequest({ dialogTitle: title, userInputBlocks }), new Promise((resolve) => {
847
+ setResolveUserInput(() => resolve);
848
+ });
849
+ }, []), runInstruction = react.useCallback(
829
850
  (req) => {
830
851
  if (loading)
831
852
  return;
@@ -847,21 +868,35 @@ function RunInstructionProvider(props) {
847
868
  },
848
869
  [runInstructionRequest, loading]
849
870
  ), close = react.useCallback(() => {
850
- setRunRequest(void 0), setInputs(NO_INPUT);
851
- }, []), runWithInput = react.useCallback(() => {
852
- if (runRequest) {
853
- const { instruction: instruction2, userTexts, ...request } = runRequest;
854
- runInstructionRequest({
855
- ...request,
856
- instructionKey: instruction2._key,
857
- userTexts: Object.entries(inputs).map(([key, value]) => ({
858
- blockKey: key,
859
- userInput: value
860
- }))
861
- });
862
- }
871
+ setRunRequest(void 0), setInputs(NO_INPUT), resolveUserInput && resolveUserInput(void 0), setResolveUserInput(void 0);
872
+ }, [resolveUserInput]), runWithInput = react.useCallback(() => {
873
+ if (runRequest)
874
+ if ("instruction" in runRequest) {
875
+ const { instruction: instruction2, userTexts, ...request } = runRequest;
876
+ runInstructionRequest({
877
+ ...request,
878
+ instructionKey: instruction2._key,
879
+ userTexts: Object.entries(inputs).map(([key, value]) => ({
880
+ blockKey: key,
881
+ userInput: value
882
+ }))
883
+ });
884
+ } else {
885
+ const userInputs = Object.values(inputs).map((input, i) => {
886
+ const userInputBlock = runRequest.userInputBlocks[i];
887
+ return {
888
+ input: {
889
+ id: userInputBlock._key,
890
+ title: userInputBlock.message ?? "",
891
+ description: userInputBlock.description
892
+ },
893
+ result: input
894
+ };
895
+ });
896
+ resolveUserInput?.(userInputs), setResolveUserInput(void 0);
897
+ }
863
898
  close();
864
- }, [close, runInstructionRequest, runRequest, inputs]), open = !!runRequest, runDisabled = react.useMemo(
899
+ }, [close, runInstructionRequest, runRequest, inputs, resolveUserInput]), open = !!runRequest, runDisabled = react.useMemo(
865
900
  () => (runRequest?.userInputBlocks?.length ?? 0) > Object.entries(inputs).filter(([, value]) => !!value).length,
866
901
  [runRequest?.userInputBlocks, inputs]
867
902
  ), runButton = /* @__PURE__ */ jsxRuntime.jsx(
@@ -875,7 +910,7 @@ function RunInstructionProvider(props) {
875
910
  disabled: runDisabled
876
911
  }
877
912
  ), contextValue = react.useMemo(
878
- () => ({ runInstruction, instructionLoading: loading }),
913
+ () => ({ runInstruction, getUserInput, instructionLoading: loading }),
879
914
  [runInstruction, loading]
880
915
  );
881
916
  return /* @__PURE__ */ jsxRuntime.jsxs(RunInstructionContext.Provider, { value: contextValue, children: [
@@ -886,7 +921,7 @@ function RunInstructionProvider(props) {
886
921
  open,
887
922
  onClose: close,
888
923
  width: 1,
889
- header: getInstructionTitle(runRequest?.instruction),
924
+ header: "dialogTitle" in runRequest ? runRequest.dialogTitle : getInstructionTitle(runRequest?.instruction),
890
925
  footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsxRuntime.jsx(
891
926
  ui.Tooltip,
892
927
  {
@@ -984,7 +1019,7 @@ function useAssistDocumentContextValue(documentId, documentType) {
984
1019
  } = structure.useDocumentPane(), { draft, published, version } = editState || {}, assistableDocumentId = selectedReleaseId ? sanity.getVersionId(documentId, selectedReleaseId) : documentSchemaType.liveEdit ? documentId : sanity.getDraftId(documentId), documentIsNew = selectedReleaseId ? !version?._id : !draft?._id && !published?._id, documentIsAssistable = selectedReleaseId ? !!version : isDocAssistable(documentSchemaType, published, draft), { params } = useAiPaneRouter(), selectedPath = params[fieldPathParam], assistDocument = useStudioAssistDocument({
985
1020
  documentId: assistableDocumentId,
986
1021
  schemaType: documentSchemaType
987
- });
1022
+ }), { syntheticTasks, addSyntheticTask, removeSyntheticTask } = useSyntheticTasks(assistableDocumentId);
988
1023
  return react.useMemo(() => {
989
1024
  const base = {
990
1025
  assistableDocumentId,
@@ -995,7 +1030,10 @@ function useAssistDocumentContextValue(documentId, documentType) {
995
1030
  closeInspector,
996
1031
  inspector,
997
1032
  documentOnChange,
998
- selectedPath
1033
+ selectedPath,
1034
+ syntheticTasks,
1035
+ addSyntheticTask,
1036
+ removeSyntheticTask
999
1037
  };
1000
1038
  return assistDocument ? {
1001
1039
  ...base,
@@ -1012,9 +1050,26 @@ function useAssistDocumentContextValue(documentId, documentType) {
1012
1050
  closeInspector,
1013
1051
  inspector,
1014
1052
  documentOnChange,
1015
- selectedPath
1053
+ selectedPath,
1054
+ syntheticTasks,
1055
+ addSyntheticTask,
1056
+ removeSyntheticTask
1016
1057
  ]);
1017
1058
  }
1059
+ function useSyntheticTasks(assistableDocumentId) {
1060
+ const [syntheticTasks, setSyntheticTasks] = react.useState(() => []), addSyntheticTask = react.useCallback((task) => {
1061
+ setSyntheticTasks((current) => [...current, task]);
1062
+ }, []), removeSyntheticTask = react.useCallback((task) => {
1063
+ setSyntheticTasks((current) => current.filter((t) => task._key !== t._key));
1064
+ }, []);
1065
+ return react.useEffect(() => {
1066
+ setSyntheticTasks([]);
1067
+ }, [assistableDocumentId]), {
1068
+ syntheticTasks,
1069
+ addSyntheticTask,
1070
+ removeSyntheticTask
1071
+ };
1072
+ }
1018
1073
  function AssistDocumentContextProvider(props) {
1019
1074
  const { documentId, documentType } = props, value = useAssistDocumentContextValue(documentId, documentType);
1020
1075
  return /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentContext.Provider, { value, children: props.children });
@@ -1109,49 +1164,14 @@ const fadeIn = styledComponents.keyframes`
1109
1164
  }, ref) {
1110
1165
  return /* @__PURE__ */ jsxRuntime.jsx(FadeInDiv, { ref, style: { animationDuration: `${durationMs}ms` }, children });
1111
1166
  }), purple = {
1112
- 50: {
1113
- title: "Purple 50",
1114
- hex: "#f8f5ff"
1115
- },
1116
- 100: {
1117
- title: "Purple 100",
1118
- hex: "#f1ebff"
1119
- },
1120
- 200: {
1121
- title: "Purple 200",
1122
- hex: "#ece1fe"
1123
- },
1124
- 300: {
1125
- title: "Purple 300",
1126
- hex: "#ccb1fc"
1127
- },
1128
1167
  400: {
1129
- title: "Purple 400",
1130
1168
  hex: "#b087f7"
1131
1169
  },
1132
1170
  500: {
1133
- title: "Purple 500",
1134
1171
  hex: "#8f57ef"
1135
1172
  },
1136
1173
  600: {
1137
- title: "Purple 600",
1138
1174
  hex: "#721fe5"
1139
- },
1140
- 700: {
1141
- title: "Purple 700",
1142
- hex: "#4c1a9e"
1143
- },
1144
- 800: {
1145
- title: "Purple 800",
1146
- hex: "#2f1862"
1147
- },
1148
- 900: {
1149
- title: "Purple 900",
1150
- hex: "#23173f"
1151
- },
1152
- 950: {
1153
- title: "Purple 950",
1154
- hex: "#181128"
1155
1175
  }
1156
1176
  }, Root = styledComponents.styled.span`
1157
1177
  display: block;
@@ -2567,8 +2587,8 @@ function ImageContextProvider(props) {
2567
2587
  ), isShowingOlderRevision = !!structure.usePaneRouter().params?.rev;
2568
2588
  react.useEffect(() => {
2569
2589
  const descriptionField = getDescriptionFieldOption(schemaType);
2570
- assetRef && assistableDocumentId && descriptionField && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly && (setAssetRefState(assetRef), canUseAssist(status) && generateCaption({
2571
- path: sanity.pathToString([...path, descriptionField]),
2590
+ assetRef && assistableDocumentId && descriptionField?.updateOnImageChange && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly && (setAssetRefState(assetRef), canUseAssist(status) && generateCaption({
2591
+ path: sanity.pathToString([...path, descriptionField.path]),
2572
2592
  documentId: assistableDocumentId
2573
2593
  }));
2574
2594
  }, [
@@ -2586,7 +2606,7 @@ function ImageContextProvider(props) {
2586
2606
  const context = react.useMemo(() => {
2587
2607
  const descriptionField = getDescriptionFieldOption(schemaType), imageInstructionField = getImageInstructionFieldOption(schemaType);
2588
2608
  return {
2589
- imageDescriptionPath: descriptionField ? sanity.pathToString([...path, descriptionField]) : void 0,
2609
+ imageDescriptionPath: descriptionField?.path ? sanity.pathToString([...path, descriptionField.path]) : void 0,
2590
2610
  imageInstructionPath: imageInstructionField ? sanity.pathToString([...path, imageInstructionField]) : void 0,
2591
2611
  assetRef
2592
2612
  };
@@ -2792,6 +2812,129 @@ function PrivateIcon() {
2792
2812
  }
2793
2813
  );
2794
2814
  }
2815
+ function getRandomValues(typedArray) {
2816
+ const crypto = typeof window < "u" && "crypto" in window ? window.crypto : globalThis.crypto;
2817
+ if (!crypto || !crypto.getRandomValues)
2818
+ throw new Error("WebCrypto not available in this environment");
2819
+ return crypto.getRandomValues(typedArray);
2820
+ }
2821
+ function whatwgRNG(length = 16) {
2822
+ const rnds8 = new Uint8Array(length);
2823
+ return getRandomValues(rnds8), rnds8;
2824
+ }
2825
+ const getByteHexTable = /* @__PURE__ */ (() => {
2826
+ let table;
2827
+ return () => {
2828
+ if (table)
2829
+ return table;
2830
+ table = [];
2831
+ for (let i = 0; i < 256; ++i)
2832
+ table[i] = (i + 256).toString(16).substring(1);
2833
+ return table;
2834
+ };
2835
+ })();
2836
+ function randomKey(length) {
2837
+ const table = getByteHexTable();
2838
+ return whatwgRNG(length).reduce((str, n) => str + table[n], "").slice(0, length);
2839
+ }
2840
+ function defineAssistFieldAction(action) {
2841
+ return {
2842
+ ...action,
2843
+ type: "action"
2844
+ };
2845
+ }
2846
+ function defineFieldActionDivider() {
2847
+ return {
2848
+ type: "divider"
2849
+ };
2850
+ }
2851
+ function defineAssistFieldActionGroup(group) {
2852
+ return {
2853
+ ...group,
2854
+ type: "group"
2855
+ };
2856
+ }
2857
+ function useCustomFieldActions(props) {
2858
+ const {
2859
+ config: { fieldActions }
2860
+ } = useAiAssistanceConfig(), { addSyntheticTask, removeSyntheticTask } = useAssistDocumentContext(), schemaId = sanity.useWorkspaceSchemaId(), { push: pushToast } = ui.useToast(), configActions = fieldActions?.useFieldActions?.({
2861
+ ...props,
2862
+ schemaId,
2863
+ path: props.path
2864
+ });
2865
+ return react.useMemo(() => {
2866
+ const title = fieldActions?.title, customActions = configActions?.map((node) => createSafeNode({
2867
+ node,
2868
+ pushToast,
2869
+ addSyntheticTask,
2870
+ removeSyntheticTask
2871
+ })), onlyGroups = customActions?.length && customActions?.every((node) => node.type === "group");
2872
+ return (customActions?.length ? onlyGroups ? customActions : [
2873
+ {
2874
+ type: "group",
2875
+ title: title || "Custom actions",
2876
+ children: customActions,
2877
+ expanded: !0
2878
+ }
2879
+ ] : []) ?? [];
2880
+ }, [configActions, fieldActions, pushToast]);
2881
+ }
2882
+ function createSafeNode(args) {
2883
+ const { node } = args;
2884
+ switch (node.type) {
2885
+ case "action":
2886
+ return createSafeAction({ ...args, action: node });
2887
+ case "group":
2888
+ return {
2889
+ ...node,
2890
+ renderAsButton: !1,
2891
+ expanded: !0,
2892
+ children: node.children?.map((child) => createSafeNode({ ...args, node: child }))
2893
+ };
2894
+ case "divider":
2895
+ default:
2896
+ return node;
2897
+ }
2898
+ }
2899
+ function createSafeAction(args) {
2900
+ const { action, pushToast, addSyntheticTask, removeSyntheticTask } = args;
2901
+ return {
2902
+ ...action,
2903
+ onAction: () => {
2904
+ async function runAction() {
2905
+ const task = {
2906
+ _type: instructionTaskTypeName,
2907
+ _key: randomKey(12),
2908
+ started: (/* @__PURE__ */ new Date()).toISOString(),
2909
+ presence: [
2910
+ {
2911
+ _type: fieldPresenceTypeName,
2912
+ _key: randomKey(12),
2913
+ path: documentRootKey,
2914
+ started: (/* @__PURE__ */ new Date()).toISOString()
2915
+ }
2916
+ ]
2917
+ };
2918
+ try {
2919
+ addSyntheticTask(task);
2920
+ const actionResult = action.onAction?.();
2921
+ actionResult instanceof Promise && await actionResult;
2922
+ } catch (err) {
2923
+ console.error("Failed to execute action", action, err), pushToast({
2924
+ title: "Failed to execute action",
2925
+ description: err?.message,
2926
+ status: "error"
2927
+ });
2928
+ } finally {
2929
+ removeSyntheticTask(task);
2930
+ }
2931
+ }
2932
+ runAction();
2933
+ },
2934
+ renderAsButton: !1,
2935
+ selected: !1
2936
+ };
2937
+ }
2795
2938
  const assistFieldActions = {
2796
2939
  name: "sanity-assist-actions",
2797
2940
  useAction(props) {
@@ -2806,7 +2949,7 @@ const assistFieldActions = {
2806
2949
  documentSchemaType,
2807
2950
  selectedPath,
2808
2951
  assistableDocumentId
2809
- } = useAssistDocumentContext(), { value: docValue, formState } = structure.useDocumentPane(), formStateRef = react.useRef(formState);
2952
+ } = useAssistDocumentContext(), { value: docValue, formState } = structure.useDocumentPane(), docValueRef = react.useRef(docValue), formStateRef = react.useRef(formState);
2810
2953
  formStateRef.current = formState;
2811
2954
  const currentUser = sanity.useCurrentUser(), isHidden = !assistDocument, pathKey = usePathKey(props.path), typePath = useTypePath(docValue, pathKey), assistDocumentId2 = assistDocument?._id, { requestRunInstruction } = useRequestRunInstruction({
2812
2955
  documentOnChange,
@@ -2868,7 +3011,6 @@ const assistFieldActions = {
2868
3011
  isPrivate: !!(instruction2.userId && instruction2.userId === currentUser?.id),
2869
3012
  onInstructionAction,
2870
3013
  hidden: isHidden,
2871
- documentIsNew: !!documentIsNew,
2872
3014
  assistSupported
2873
3015
  })
2874
3016
  ) || [],
@@ -2886,7 +3028,23 @@ const assistFieldActions = {
2886
3028
  imageCaptionAction,
2887
3029
  translateAction,
2888
3030
  imageGenAction
2889
- ]), instructionsLength = instructions?.length || 0, manageInstructionsItem = react.useMemo(
3031
+ ]), getDocumentValue = react.useCallback(() => docValueRef.current, []), getConditionalPaths = react.useCallback(() => (formStateRef.current ? getConditionalMembers(formStateRef.current) : []).flatMap(
3032
+ (cm) => {
3033
+ const path = sanity.stringToPath(cm.path);
3034
+ return path.some((s) => typeof s == "number") ? [] : {
3035
+ ...cm,
3036
+ path
3037
+ };
3038
+ }
3039
+ ), []), customActions = useCustomFieldActions({
3040
+ actionType: props.path.length ? "field" : "document",
3041
+ documentIdForAction: assistableDocumentId,
3042
+ schemaType,
3043
+ documentSchemaType,
3044
+ path: props.path,
3045
+ getDocumentValue,
3046
+ getConditionalPaths
3047
+ }), manageInstructionsItem = react.useMemo(
2890
3048
  () => ({
2891
3049
  type: "action",
2892
3050
  icon: icons.ControlsIcon,
@@ -2903,6 +3061,7 @@ const assistFieldActions = {
2903
3061
  children: [
2904
3062
  runInstructionsGroup,
2905
3063
  translateAction,
3064
+ ...customActions,
2906
3065
  assistSupported && manageInstructionsItem
2907
3066
  ].filter((c) => !!c).filter((c) => c.type === "group" ? c.children.length : !0),
2908
3067
  expanded: !1,
@@ -2916,7 +3075,8 @@ const assistFieldActions = {
2916
3075
  assistSupported,
2917
3076
  imageCaptionAction,
2918
3077
  translateAction,
2919
- imageGenAction
3078
+ imageGenAction,
3079
+ customActions
2920
3080
  ]
2921
3081
  ), emptyAction = react.useMemo(
2922
3082
  () => ({
@@ -2930,7 +3090,7 @@ const assistFieldActions = {
2930
3090
  }),
2931
3091
  [assistSupported, manageInstructions, isSelected]
2932
3092
  );
2933
- return instructionsLength === 0 && !imageCaptionAction && !translateAction && !imageGenAction ? emptyAction : group;
3093
+ return !instructions?.length && !imageCaptionAction && !translateAction && !imageGenAction && !customActions.length ? emptyAction : group;
2934
3094
  }
2935
3095
  };
2936
3096
  function instructionItem(props) {
@@ -2951,21 +3111,19 @@ function createAssistDocumentPresence(documentId) {
2951
3111
  };
2952
3112
  }
2953
3113
  function AssistDocumentPresence() {
2954
- const { assistDocument } = useAssistDocumentContext(), anyPresence = react.useMemo(() => {
2955
- const anyPresence2 = assistDocument?.tasks?.filter((run) => !run.ended && !run.reason)?.flatMap((run) => run.presence ?? []).find((f) => f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4);
3114
+ const { assistDocument, syntheticTasks } = useAssistDocumentContext(), anyPresence = react.useMemo(() => {
3115
+ const anyPresence2 = [...assistDocument?.tasks ?? [], ...syntheticTasks ?? []].filter((run) => !run.ended && !run.reason)?.flatMap((run) => run.presence ?? []).find((f) => f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4);
2956
3116
  if (anyPresence2)
2957
3117
  return aiPresence(anyPresence2, []);
2958
3118
  const anyRun = assistDocument?.tasks?.filter((run) => !run.ended && !run.reason)?.find((f) => f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4);
2959
3119
  return anyRun ? aiPresence(
2960
3120
  {
2961
3121
  started: anyRun.started,
2962
- path: documentRootKey,
2963
- _key: anyRun._key,
2964
- _type: fieldPresenceTypeName
3122
+ _key: anyRun._key
2965
3123
  },
2966
3124
  []
2967
3125
  ) : void 0;
2968
- }, [assistDocument?.tasks]);
3126
+ }, [assistDocument?.tasks, syntheticTasks]);
2969
3127
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 2, align: "center", children: anyPresence && /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: anyPresence }) }) }) });
2970
3128
  }
2971
3129
  function BackToInstructionListLink() {
@@ -3359,31 +3517,6 @@ function Selectable({
3359
3517
  /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { marginTop: 1, onClick: handleChange, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { style: { cursor: "default" }, size: 1, children: title }) })
3360
3518
  ] });
3361
3519
  }
3362
- function getRandomValues(typedArray) {
3363
- const crypto = typeof window < "u" && "crypto" in window ? window.crypto : globalThis.crypto;
3364
- if (!crypto || !crypto.getRandomValues)
3365
- throw new Error("WebCrypto not available in this environment");
3366
- return crypto.getRandomValues(typedArray);
3367
- }
3368
- function whatwgRNG(length = 16) {
3369
- const rnds8 = new Uint8Array(length);
3370
- return getRandomValues(rnds8), rnds8;
3371
- }
3372
- const getByteHexTable = /* @__PURE__ */ (() => {
3373
- let table;
3374
- return () => {
3375
- if (table)
3376
- return table;
3377
- table = [];
3378
- for (let i = 0; i < 256; ++i)
3379
- table[i] = (i + 256).toString(16).substring(1);
3380
- return table;
3381
- };
3382
- })();
3383
- function randomKey(length) {
3384
- const table = getByteHexTable();
3385
- return whatwgRNG(length).reduce((str, n) => str + table[n], "").slice(0, length);
3386
- }
3387
3520
  const PteMods = styledComponents.styled(ui.Box)`
3388
3521
  & [data-testid='pt-editor__toolbar-card'] > div > div:last-child {
3389
3522
  display: none;
@@ -4084,8 +4217,16 @@ function SchemaEntry({ schemaStub }) {
4084
4217
  const out = react.useMemo(() => JSON.stringify(schemaStub, null, 2), [schemaStub]);
4085
4218
  return /* @__PURE__ */ jsxRuntime.jsx("pre", { children: out });
4086
4219
  }
4220
+ function useUserInput() {
4221
+ const { getUserInput } = useRunInstruction();
4222
+ return getUserInput;
4223
+ }
4087
4224
  exports.SchemaTypeTool = SchemaTypeTool;
4088
4225
  exports.assist = assist;
4089
4226
  exports.contextDocumentTypeName = contextDocumentTypeName;
4090
4227
  exports.defaultLanguageOutputs = defaultLanguageOutputs;
4228
+ exports.defineAssistFieldAction = defineAssistFieldAction;
4229
+ exports.defineAssistFieldActionGroup = defineAssistFieldActionGroup;
4230
+ exports.defineFieldActionDivider = defineFieldActionDivider;
4231
+ exports.useUserInput = useUserInput;
4091
4232
  //# sourceMappingURL=index.js.map