@raycast/api 1.48.7 → 1.48.8

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 (3) hide show
  1. package/api.d.ts +25 -18
  2. package/package.json +1 -1
  3. package/types/index.d.ts +25 -18
package/api.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { ForwardRefExoticComponent } from 'react';
5
5
  import { FunctionComponent } from 'react';
6
+ import { MutableRefObject } from 'react';
6
7
  import { PathLike } from 'fs';
7
8
  import { ReactElement } from 'react';
8
9
  import { ReactNode } from 'react';
@@ -3851,6 +3852,8 @@ declare interface FormValues_2 {
3851
3852
  [item: string]: any;
3852
3853
  }
3853
3854
 
3855
+ declare type FunctionReturningPromise<T extends any[] = any[]> = (...args: T) => Promise<any>;
3856
+
3854
3857
  /**
3855
3858
  * Returns all applications that can open the file.
3856
3859
  *
@@ -6921,6 +6924,14 @@ export declare interface PreferenceValues {
6921
6924
  [name: string]: any;
6922
6925
  }
6923
6926
 
6927
+ declare type PromiseOptions<T extends FunctionReturningPromise> = {
6928
+ abortable?: MutableRefObject<AbortController | null | undefined>;
6929
+ execute?: boolean;
6930
+ onError?: (error: Error) => void | Promise<void>;
6931
+ onData?: (data: Awaited<ReturnType<T>>) => void | Promise<void>;
6932
+ onWillExecute?: (parameters: Parameters<T>) => void;
6933
+ };
6934
+
6924
6935
  /**
6925
6936
  * See {@link Action.Push.Props}
6926
6937
  */
@@ -7889,24 +7900,24 @@ export declare namespace unstable_AI {
7889
7900
  * import { usePromise } from "@raycast/utils";
7890
7901
  * import { useState } from "react";
7891
7902
  *
7892
- * export default function Command(props: LaunchProps<{ arguments: { instruction: string } }>) {
7903
+ * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
7893
7904
  * const [data, setData] = useState("");
7894
7905
  * const { isLoading } = usePromise(
7895
- * async (instruction) => {
7896
- * const stream = unstable_AI.ask(instruction);
7906
+ * async (prompt) => {
7907
+ * const stream = unstable_AI.ask(prompt);
7897
7908
  * stream.on("data", (data) => {
7898
7909
  * setData((x) => x + data);
7899
7910
  * });
7900
7911
  * await stream;
7901
7912
  * },
7902
- * [props.arguments.instruction]
7913
+ * [props.arguments.prompt]
7903
7914
  * );
7904
7915
  *
7905
7916
  * return <Detail isLoading={isLoading} markdown={data} />;
7906
7917
  * }
7907
7918
  * ```
7908
7919
  */
7909
- export function ask(instruction: string, options?: AnswerOptions): Promise<string> & {
7920
+ export function ask(prompt: string, options?: AnswerOptions): Promise<string> & {
7910
7921
  on(event: "data", listener: (chunk: string) => void): void;
7911
7922
  };
7912
7923
  export type AnswerOptions = {
@@ -7921,14 +7932,9 @@ export declare namespace unstable_AI {
7921
7932
  };
7922
7933
  /**
7923
7934
  * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
7935
+ * If a number is passed, it needs to be in the range 0-2. For larger values, 2 will be used. For lower values, 0 will be used.
7924
7936
  */
7925
- export enum Creativity {
7926
- None = 0,
7927
- Low = 0.25,
7928
- Medium = 0.5,
7929
- High = 0.75,
7930
- Maximum = 1
7931
- }
7937
+ export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
7932
7938
  }
7933
7939
 
7934
7940
  /**
@@ -8015,27 +8021,28 @@ export declare const useId: any;
8015
8021
  export declare function useNavigation(): Navigation;
8016
8022
 
8017
8023
  /**
8018
- * The AI API is not stable and should move to @raycast/utils eventually, it will likely change in the future based the community's feedback.
8024
+ * The AI API is not stable and should move to the "@raycast/utils" package eventually, it will likely change in the future based the community's feedback.
8019
8025
  * If you have any feedback, concerns, or use-cases that aren't covered by the API, please reach out to us on the [Raycast Community Slack](https://raycast.com/community).
8020
8026
  *
8021
8027
  * ---
8022
8028
  *
8023
- * Stream an instruction completion.
8029
+ * Stream a prompt completion.
8024
8030
  *
8025
8031
  * @example
8026
8032
  * ```typescript
8027
8033
  * import { Detail, useUnstableAI, LaunchProps } from "@raycast/api";
8028
8034
  *
8029
- * export default function Command(props: LaunchProps<{ arguments: { instruction: string } }>) {
8030
- * const { isLoading, data } = useUnstableAI(props.arguments.instruction);
8035
+ * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
8036
+ * const { isLoading, data } = useUnstableAI(props.arguments.prompt);
8031
8037
  *
8032
8038
  * return <Detail isLoading={isLoading} markdown={data} />;
8033
8039
  * }
8034
8040
  * ```
8035
8041
  */
8036
- export declare function useUnstableAI(instruction: string, options?: {
8042
+ export declare function useUnstableAI(prompt: string, options?: {
8037
8043
  creativity?: unstable_AI.Creativity;
8038
- }): {
8044
+ stream?: boolean;
8045
+ } & Omit<PromiseOptions<FunctionReturningPromise>, "abortable">): {
8039
8046
  isLoading: boolean;
8040
8047
  data: string;
8041
8048
  error: Error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raycast/api",
3
- "version": "1.48.7",
3
+ "version": "1.48.8",
4
4
  "description": "Build extensions for Raycast with React and Node.js.",
5
5
  "author": "Raycast Technologies Ltd.",
6
6
  "homepage": "https://developers.raycast.com",
package/types/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { ForwardRefExoticComponent } from 'react';
5
5
  import { FunctionComponent } from 'react';
6
+ import { MutableRefObject } from 'react';
6
7
  import { PathLike } from 'fs';
7
8
  import { ReactElement } from 'react';
8
9
  import { ReactNode } from 'react';
@@ -3847,6 +3848,8 @@ declare interface FormValues_2 {
3847
3848
  [item: string]: any;
3848
3849
  }
3849
3850
 
3851
+ declare type FunctionReturningPromise<T extends any[] = any[]> = (...args: T) => Promise<any>;
3852
+
3850
3853
  /**
3851
3854
  * Returns all applications that can open the file.
3852
3855
  *
@@ -6917,6 +6920,14 @@ export declare interface PreferenceValues {
6917
6920
  [name: string]: any;
6918
6921
  }
6919
6922
 
6923
+ declare type PromiseOptions<T extends FunctionReturningPromise> = {
6924
+ abortable?: MutableRefObject<AbortController | null | undefined>;
6925
+ execute?: boolean;
6926
+ onError?: (error: Error) => void | Promise<void>;
6927
+ onData?: (data: Awaited<ReturnType<T>>) => void | Promise<void>;
6928
+ onWillExecute?: (parameters: Parameters<T>) => void;
6929
+ };
6930
+
6920
6931
  /**
6921
6932
  * See {@link Action.Push.Props}
6922
6933
  */
@@ -7885,24 +7896,24 @@ export declare namespace unstable_AI {
7885
7896
  * import { usePromise } from "@raycast/utils";
7886
7897
  * import { useState } from "react";
7887
7898
  *
7888
- * export default function Command(props: LaunchProps<{ arguments: { instruction: string } }>) {
7899
+ * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
7889
7900
  * const [data, setData] = useState("");
7890
7901
  * const { isLoading } = usePromise(
7891
- * async (instruction) => {
7892
- * const stream = unstable_AI.ask(instruction);
7902
+ * async (prompt) => {
7903
+ * const stream = unstable_AI.ask(prompt);
7893
7904
  * stream.on("data", (data) => {
7894
7905
  * setData((x) => x + data);
7895
7906
  * });
7896
7907
  * await stream;
7897
7908
  * },
7898
- * [props.arguments.instruction]
7909
+ * [props.arguments.prompt]
7899
7910
  * );
7900
7911
  *
7901
7912
  * return <Detail isLoading={isLoading} markdown={data} />;
7902
7913
  * }
7903
7914
  * ```
7904
7915
  */
7905
- export function ask(instruction: string, options?: AnswerOptions): Promise<string> & {
7916
+ export function ask(prompt: string, options?: AnswerOptions): Promise<string> & {
7906
7917
  on(event: "data", listener: (chunk: string) => void): void;
7907
7918
  };
7908
7919
  export type AnswerOptions = {
@@ -7917,14 +7928,9 @@ export declare namespace unstable_AI {
7917
7928
  };
7918
7929
  /**
7919
7930
  * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
7931
+ * If a number is passed, it needs to be in the range 0-2. For larger values, 2 will be used. For lower values, 0 will be used.
7920
7932
  */
7921
- export enum Creativity {
7922
- None = 0,
7923
- Low = 0.25,
7924
- Medium = 0.5,
7925
- High = 0.75,
7926
- Maximum = 1
7927
- }
7933
+ export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
7928
7934
  }
7929
7935
 
7930
7936
  /**
@@ -8011,27 +8017,28 @@ export declare const useId: any;
8011
8017
  export declare function useNavigation(): Navigation;
8012
8018
 
8013
8019
  /**
8014
- * The AI API is not stable and should move to @raycast/utils eventually, it will likely change in the future based the community's feedback.
8020
+ * The AI API is not stable and should move to the "@raycast/utils" package eventually, it will likely change in the future based the community's feedback.
8015
8021
  * If you have any feedback, concerns, or use-cases that aren't covered by the API, please reach out to us on the [Raycast Community Slack](https://raycast.com/community).
8016
8022
  *
8017
8023
  * ---
8018
8024
  *
8019
- * Stream an instruction completion.
8025
+ * Stream a prompt completion.
8020
8026
  *
8021
8027
  * @example
8022
8028
  * ```typescript
8023
8029
  * import { Detail, useUnstableAI, LaunchProps } from "@raycast/api";
8024
8030
  *
8025
- * export default function Command(props: LaunchProps<{ arguments: { instruction: string } }>) {
8026
- * const { isLoading, data } = useUnstableAI(props.arguments.instruction);
8031
+ * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
8032
+ * const { isLoading, data } = useUnstableAI(props.arguments.prompt);
8027
8033
  *
8028
8034
  * return <Detail isLoading={isLoading} markdown={data} />;
8029
8035
  * }
8030
8036
  * ```
8031
8037
  */
8032
- export declare function useUnstableAI(instruction: string, options?: {
8038
+ export declare function useUnstableAI(prompt: string, options?: {
8033
8039
  creativity?: unstable_AI.Creativity;
8034
- }): {
8040
+ stream?: boolean;
8041
+ } & Omit<PromiseOptions<FunctionReturningPromise>, "abortable">): {
8035
8042
  isLoading: boolean;
8036
8043
  data: string;
8037
8044
  error: Error;