@raycast/api 1.50.5 → 1.51.1

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 +70 -111
  2. package/package.json +1 -1
  3. package/types/index.d.ts +70 -111
package/api.d.ts CHANGED
@@ -3,7 +3,6 @@
3
3
 
4
4
  import { ForwardRefExoticComponent } from 'react';
5
5
  import { FunctionComponent } from 'react';
6
- import { MutableRefObject } from 'react';
7
6
  import { PathLike } from 'fs';
8
7
  import { ReactElement } from 'react';
9
8
  import { ReactNode } from 'react';
@@ -436,6 +435,63 @@ declare enum ActionStyle {
436
435
  Destructive = "destructive"
437
436
  }
438
437
 
438
+ export declare namespace AI {
439
+ /**
440
+ * Returns a prompt completion.
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * import { Detail, AI, LaunchProps } from "@raycast/api";
445
+ * import { usePromise } from "@raycast/utils";
446
+ * import { useState } from "react";
447
+ *
448
+ * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
449
+ * const [data, setData] = useState("");
450
+ * const { isLoading } = usePromise(
451
+ * async (prompt) => {
452
+ * const stream = AI.ask(prompt);
453
+ * stream.on("data", (data) => {
454
+ * setData((x) => x + data);
455
+ * });
456
+ * await stream;
457
+ * },
458
+ * [props.arguments.prompt]
459
+ * );
460
+ *
461
+ * return <Detail isLoading={isLoading} markdown={data} />;
462
+ * }
463
+ * ```
464
+ */
465
+ export function ask(prompt: string, options?: AskOptions): Promise<string> & {
466
+ on(event: "data", listener: (chunk: string) => void): void;
467
+ };
468
+ export type AskOptions = {
469
+ /**
470
+ * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
471
+ * 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.
472
+ */
473
+ creativity?: Creativity;
474
+ /**
475
+ * The AI model to use to answer to the prompt.
476
+ */
477
+ model?: Model;
478
+ /**
479
+ * Abort signal to cancel the request.
480
+ */
481
+ signal?: AbortSignal;
482
+ };
483
+ /**
484
+ * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
485
+ * 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.
486
+ */
487
+ export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
488
+ /**
489
+ * The AI model to use to answer to the prompt.
490
+ * @defaultValue `"text-davinci-003"`
491
+ */
492
+ export type Model = "text-davinci-003" | "gpt-3.5-turbo";
493
+ }
494
+
439
495
  export declare namespace Alert {
440
496
  /**
441
497
  * The options to create an {@link Alert}.
@@ -1014,10 +1070,9 @@ export declare namespace Color {
1014
1070
  * - Keywords, e.g. `red`
1015
1071
  */
1016
1072
  export type Raw = string;
1017
- /** The standard colors. Use those colors for consistency.
1018
- *
1019
- * @remarks
1020
- * The colors automatically adapt to the Raycast theme (light or dark).
1073
+ /**
1074
+ * @deprecated `Color.Brown` isn't part of the custom themes and might look off
1075
+ * for some users. Use another color instead.
1021
1076
  */
1022
1077
  const Brown: Color.Dynamic;
1023
1078
  }
@@ -2157,8 +2212,13 @@ export declare interface Environment {
2157
2212
  * Indicates whether the command is a development command (vs. an installed command from the Store).
2158
2213
  */
2159
2214
  isDevelopment: boolean;
2215
+ /**
2216
+ * The appearance used by the Raycast application.
2217
+ */
2218
+ appearance: "light" | "dark";
2160
2219
  /**
2161
2220
  * The theme used by the Raycast application.
2221
+ * @deprecated Use `appearance` instead
2162
2222
  */
2163
2223
  theme: "light" | "dark";
2164
2224
  /**
@@ -2204,7 +2264,7 @@ export declare interface Environment {
2204
2264
  * console.log(`Assets path: ${environment.assetsPath}`);
2205
2265
  * console.log(`Support path: ${environment.supportPath}`);
2206
2266
  * console.log(`Is development mode: ${environment.isDevelopment}`);
2207
- * console.log(`Raycast theme: ${environment.theme}`);
2267
+ * console.log(`Raycast appearance: ${environment.appearance}`);
2208
2268
  * console.log(`Raycast launchType: ${environment.launchType}`);
2209
2269
  * console.log(`Raycast launchContext: ${environment.launchContext}`);
2210
2270
  * ```
@@ -3867,8 +3927,6 @@ declare interface FormValues_2 {
3867
3927
  [item: string]: any;
3868
3928
  }
3869
3929
 
3870
- declare type FunctionReturningPromise<T extends any[] = any[]> = (...args: T) => Promise<any>;
3871
-
3872
3930
  /**
3873
3931
  * Returns all applications that can open the file.
3874
3932
  *
@@ -6940,14 +6998,6 @@ export declare interface PreferenceValues {
6940
6998
  [name: string]: any;
6941
6999
  }
6942
7000
 
6943
- declare type PromiseOptions<T extends FunctionReturningPromise> = {
6944
- abortable?: MutableRefObject<AbortController | null | undefined>;
6945
- execute?: boolean;
6946
- onError?: (error: Error) => void | Promise<void>;
6947
- onData?: (data: Awaited<ReturnType<T>>) => void | Promise<void>;
6948
- onWillExecute?: (parameters: Parameters<T>) => void;
6949
- };
6950
-
6951
7001
  /**
6952
7002
  * See {@link Action.Push.Props}
6953
7003
  */
@@ -7902,65 +7952,8 @@ declare interface TrashProps {
7902
7952
  onTrash?: (paths: PathLike | PathLike[]) => void;
7903
7953
  }
7904
7954
 
7905
- /**
7906
- * The AI API is not stable, it will likely change in the future based the community's feedback.
7907
- * 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).
7908
- */
7909
- export declare namespace unstable_AI {
7910
- /**
7911
- * Returns a prompt completion.
7912
- *
7913
- * @example
7914
- * ```typescript
7915
- * import { Detail, unstable_AI, LaunchProps } from "@raycast/api";
7916
- * import { usePromise } from "@raycast/utils";
7917
- * import { useState } from "react";
7918
- *
7919
- * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
7920
- * const [data, setData] = useState("");
7921
- * const { isLoading } = usePromise(
7922
- * async (prompt) => {
7923
- * const stream = unstable_AI.ask(prompt);
7924
- * stream.on("data", (data) => {
7925
- * setData((x) => x + data);
7926
- * });
7927
- * await stream;
7928
- * },
7929
- * [props.arguments.prompt]
7930
- * );
7931
- *
7932
- * return <Detail isLoading={isLoading} markdown={data} />;
7933
- * }
7934
- * ```
7935
- */
7936
- export function ask(prompt: string, options?: AskOptions): Promise<string> & {
7937
- on(event: "data", listener: (chunk: string) => void): void;
7938
- };
7939
- export type AskOptions = {
7940
- /**
7941
- * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
7942
- * 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.
7943
- */
7944
- creativity?: Creativity;
7945
- /**
7946
- * The AI model to use to answer to the prompt.
7947
- */
7948
- model?: Model;
7949
- /**
7950
- * Abort signal to cancel the request.
7951
- */
7952
- signal?: AbortSignal;
7953
- };
7954
- /**
7955
- * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
7956
- * 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.
7957
- */
7958
- export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
7959
- /**
7960
- * @default `"text-davinci-003"``
7961
- */
7962
- export type Model = "text-davinci-003" | "gpt-3.5-turbo";
7963
- }
7955
+ /** @deprecated Use {@Link AI} directly */
7956
+ export declare const unstable_AI: typeof AI;
7964
7957
 
7965
7958
  /**
7966
7959
  * Update the values of properties declared in the manifest of a command.
@@ -8045,41 +8038,7 @@ export declare const useId: any;
8045
8038
  */
8046
8039
  export declare function useNavigation(): Navigation;
8047
8040
 
8048
- /**
8049
- * 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.
8050
- * 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).
8051
- *
8052
- * ---
8053
- *
8054
- * Stream a prompt completion.
8055
- *
8056
- * @example
8057
- * ```typescript
8058
- * import { Detail, useUnstableAI, LaunchProps } from "@raycast/api";
8059
- *
8060
- * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
8061
- * const { isLoading, data } = useUnstableAI(props.arguments.prompt);
8062
- *
8063
- * return <Detail isLoading={isLoading} markdown={data} />;
8064
- * }
8065
- * ```
8066
- */
8067
- export declare function useUnstableAI(prompt: string, options?: {
8068
- /**
8069
- * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
8070
- * 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.
8071
- */
8072
- creativity?: unstable_AI.Creativity;
8073
- /**
8074
- * The AI model to use to answer to the prompt.
8075
- */
8076
- model?: unstable_AI.Model;
8077
- stream?: boolean;
8078
- } & Omit<PromiseOptions<FunctionReturningPromise>, "abortable">): {
8079
- isLoading: boolean;
8080
- data: string;
8081
- error: Error;
8082
- revalidate: () => Promise<void>;
8083
- };
8041
+ /** @deprecated Use `useAI` from `@raycast/utils` */
8042
+ export declare const useUnstableAI: () => any;
8084
8043
 
8085
8044
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raycast/api",
3
- "version": "1.50.5",
3
+ "version": "1.51.1",
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,7 +3,6 @@
3
3
 
4
4
  import { ForwardRefExoticComponent } from 'react';
5
5
  import { FunctionComponent } from 'react';
6
- import { MutableRefObject } from 'react';
7
6
  import { PathLike } from 'fs';
8
7
  import { ReactElement } from 'react';
9
8
  import { ReactNode } from 'react';
@@ -432,6 +431,63 @@ declare enum ActionStyle {
432
431
  Destructive = "destructive"
433
432
  }
434
433
 
434
+ export declare namespace AI {
435
+ /**
436
+ * Returns a prompt completion.
437
+ *
438
+ * @example
439
+ * ```typescript
440
+ * import { Detail, AI, LaunchProps } from "@raycast/api";
441
+ * import { usePromise } from "@raycast/utils";
442
+ * import { useState } from "react";
443
+ *
444
+ * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
445
+ * const [data, setData] = useState("");
446
+ * const { isLoading } = usePromise(
447
+ * async (prompt) => {
448
+ * const stream = AI.ask(prompt);
449
+ * stream.on("data", (data) => {
450
+ * setData((x) => x + data);
451
+ * });
452
+ * await stream;
453
+ * },
454
+ * [props.arguments.prompt]
455
+ * );
456
+ *
457
+ * return <Detail isLoading={isLoading} markdown={data} />;
458
+ * }
459
+ * ```
460
+ */
461
+ export function ask(prompt: string, options?: AskOptions): Promise<string> & {
462
+ on(event: "data", listener: (chunk: string) => void): void;
463
+ };
464
+ export type AskOptions = {
465
+ /**
466
+ * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
467
+ * 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.
468
+ */
469
+ creativity?: Creativity;
470
+ /**
471
+ * The AI model to use to answer to the prompt.
472
+ */
473
+ model?: Model;
474
+ /**
475
+ * Abort signal to cancel the request.
476
+ */
477
+ signal?: AbortSignal;
478
+ };
479
+ /**
480
+ * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
481
+ * 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.
482
+ */
483
+ export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
484
+ /**
485
+ * The AI model to use to answer to the prompt.
486
+ * @defaultValue `"text-davinci-003"`
487
+ */
488
+ export type Model = "text-davinci-003" | "gpt-3.5-turbo";
489
+ }
490
+
435
491
  export declare namespace Alert {
436
492
  /**
437
493
  * The options to create an {@link Alert}.
@@ -1010,10 +1066,9 @@ export declare namespace Color {
1010
1066
  * - Keywords, e.g. `red`
1011
1067
  */
1012
1068
  export type Raw = string;
1013
- /** The standard colors. Use those colors for consistency.
1014
- *
1015
- * @remarks
1016
- * The colors automatically adapt to the Raycast theme (light or dark).
1069
+ /**
1070
+ * @deprecated `Color.Brown` isn't part of the custom themes and might look off
1071
+ * for some users. Use another color instead.
1017
1072
  */
1018
1073
  const Brown: Color.Dynamic;
1019
1074
  }
@@ -2153,8 +2208,13 @@ export declare interface Environment {
2153
2208
  * Indicates whether the command is a development command (vs. an installed command from the Store).
2154
2209
  */
2155
2210
  isDevelopment: boolean;
2211
+ /**
2212
+ * The appearance used by the Raycast application.
2213
+ */
2214
+ appearance: "light" | "dark";
2156
2215
  /**
2157
2216
  * The theme used by the Raycast application.
2217
+ * @deprecated Use `appearance` instead
2158
2218
  */
2159
2219
  theme: "light" | "dark";
2160
2220
  /**
@@ -2200,7 +2260,7 @@ export declare interface Environment {
2200
2260
  * console.log(`Assets path: ${environment.assetsPath}`);
2201
2261
  * console.log(`Support path: ${environment.supportPath}`);
2202
2262
  * console.log(`Is development mode: ${environment.isDevelopment}`);
2203
- * console.log(`Raycast theme: ${environment.theme}`);
2263
+ * console.log(`Raycast appearance: ${environment.appearance}`);
2204
2264
  * console.log(`Raycast launchType: ${environment.launchType}`);
2205
2265
  * console.log(`Raycast launchContext: ${environment.launchContext}`);
2206
2266
  * ```
@@ -3863,8 +3923,6 @@ declare interface FormValues_2 {
3863
3923
  [item: string]: any;
3864
3924
  }
3865
3925
 
3866
- declare type FunctionReturningPromise<T extends any[] = any[]> = (...args: T) => Promise<any>;
3867
-
3868
3926
  /**
3869
3927
  * Returns all applications that can open the file.
3870
3928
  *
@@ -6936,14 +6994,6 @@ export declare interface PreferenceValues {
6936
6994
  [name: string]: any;
6937
6995
  }
6938
6996
 
6939
- declare type PromiseOptions<T extends FunctionReturningPromise> = {
6940
- abortable?: MutableRefObject<AbortController | null | undefined>;
6941
- execute?: boolean;
6942
- onError?: (error: Error) => void | Promise<void>;
6943
- onData?: (data: Awaited<ReturnType<T>>) => void | Promise<void>;
6944
- onWillExecute?: (parameters: Parameters<T>) => void;
6945
- };
6946
-
6947
6997
  /**
6948
6998
  * See {@link Action.Push.Props}
6949
6999
  */
@@ -7898,65 +7948,8 @@ declare interface TrashProps {
7898
7948
  onTrash?: (paths: PathLike | PathLike[]) => void;
7899
7949
  }
7900
7950
 
7901
- /**
7902
- * The AI API is not stable, it will likely change in the future based the community's feedback.
7903
- * 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).
7904
- */
7905
- export declare namespace unstable_AI {
7906
- /**
7907
- * Returns a prompt completion.
7908
- *
7909
- * @example
7910
- * ```typescript
7911
- * import { Detail, unstable_AI, LaunchProps } from "@raycast/api";
7912
- * import { usePromise } from "@raycast/utils";
7913
- * import { useState } from "react";
7914
- *
7915
- * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
7916
- * const [data, setData] = useState("");
7917
- * const { isLoading } = usePromise(
7918
- * async (prompt) => {
7919
- * const stream = unstable_AI.ask(prompt);
7920
- * stream.on("data", (data) => {
7921
- * setData((x) => x + data);
7922
- * });
7923
- * await stream;
7924
- * },
7925
- * [props.arguments.prompt]
7926
- * );
7927
- *
7928
- * return <Detail isLoading={isLoading} markdown={data} />;
7929
- * }
7930
- * ```
7931
- */
7932
- export function ask(prompt: string, options?: AskOptions): Promise<string> & {
7933
- on(event: "data", listener: (chunk: string) => void): void;
7934
- };
7935
- export type AskOptions = {
7936
- /**
7937
- * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
7938
- * 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.
7939
- */
7940
- creativity?: Creativity;
7941
- /**
7942
- * The AI model to use to answer to the prompt.
7943
- */
7944
- model?: Model;
7945
- /**
7946
- * Abort signal to cancel the request.
7947
- */
7948
- signal?: AbortSignal;
7949
- };
7950
- /**
7951
- * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
7952
- * 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.
7953
- */
7954
- export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
7955
- /**
7956
- * @default `"text-davinci-003"``
7957
- */
7958
- export type Model = "text-davinci-003" | "gpt-3.5-turbo";
7959
- }
7951
+ /** @deprecated Use {@Link AI} directly */
7952
+ export declare const unstable_AI: typeof AI;
7960
7953
 
7961
7954
  /**
7962
7955
  * Update the values of properties declared in the manifest of a command.
@@ -8041,41 +8034,7 @@ export declare const useId: any;
8041
8034
  */
8042
8035
  export declare function useNavigation(): Navigation;
8043
8036
 
8044
- /**
8045
- * 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.
8046
- * 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).
8047
- *
8048
- * ---
8049
- *
8050
- * Stream a prompt completion.
8051
- *
8052
- * @example
8053
- * ```typescript
8054
- * import { Detail, useUnstableAI, LaunchProps } from "@raycast/api";
8055
- *
8056
- * export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
8057
- * const { isLoading, data } = useUnstableAI(props.arguments.prompt);
8058
- *
8059
- * return <Detail isLoading={isLoading} markdown={data} />;
8060
- * }
8061
- * ```
8062
- */
8063
- export declare function useUnstableAI(prompt: string, options?: {
8064
- /**
8065
- * Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
8066
- * 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.
8067
- */
8068
- creativity?: unstable_AI.Creativity;
8069
- /**
8070
- * The AI model to use to answer to the prompt.
8071
- */
8072
- model?: unstable_AI.Model;
8073
- stream?: boolean;
8074
- } & Omit<PromiseOptions<FunctionReturningPromise>, "abortable">): {
8075
- isLoading: boolean;
8076
- data: string;
8077
- error: Error;
8078
- revalidate: () => Promise<void>;
8079
- };
8037
+ /** @deprecated Use `useAI` from `@raycast/utils` */
8038
+ export declare const useUnstableAI: () => any;
8080
8039
 
8081
8040
  export { }