upgraded all npm packages and fixed related issues (#4072)

This commit is contained in:
Zane
2025-08-18 15:12:44 -07:00
committed by GitHub
parent 818486da10
commit a14f087d20
51 changed files with 3686 additions and 3311 deletions
+1 -8
View File
@@ -64,6 +64,7 @@ module.exports = [
setTimeout: 'readonly',
clearInterval: 'readonly',
setInterval: 'readonly',
clearTimeout: 'readonly',
CustomEvent: 'readonly',
HTMLElement: 'readonly',
HTMLInputElement: 'readonly',
@@ -130,14 +131,6 @@ module.exports = [
}],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/ban-types': ['error', {
types: {
Object: {
message: 'Use object instead',
fixWith: 'object',
},
},
}],
'@typescript-eslint/no-var-requires': 'warn', // Downgrade to warning for Electron main process
'no-undef': 'error',
'no-useless-catch': 'warn',
+1979 -3058
View File
File diff suppressed because it is too large Load Diff
+68 -70
View File
@@ -39,104 +39,102 @@
"start-alpha-gui": "ALPHA=true npm run start-gui"
},
"dependencies": {
"@ai-sdk/openai": "^0.0.72",
"@ai-sdk/ui-utils": "^1.0.2",
"@hey-api/client-fetch": "^0.8.1",
"@ai-sdk/openai": "^2.0.14",
"@ai-sdk/ui-utils": "^1.2.11",
"@mcp-ui/client": "~5.6.2",
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-avatar": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.7",
"@radix-ui/react-icons": "^1.3.1",
"@radix-ui/react-popover": "^1.1.6",
"@radix-ui/react-radio-group": "^1.2.3",
"@radix-ui/react-scroll-area": "^1.2.9",
"@radix-ui/react-select": "^2.1.7",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.1",
"@radix-ui/themes": "^3.1.5",
"@radix-ui/react-accordion": "^1.2.12",
"@radix-ui/react-avatar": "^1.1.10",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-icons": "^1.3.2",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-radio-group": "^1.3.8",
"@radix-ui/react-scroll-area": "^1.2.10",
"@radix-ui/react-select": "^2.2.6",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/themes": "^3.2.1",
"@types/react-router-dom": "^5.3.3",
"ai": "^3.4.33",
"class-variance-authority": "^0.7.0",
"ai": "^5.0.14",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"compare-versions": "^6.1.1",
"cors": "^2.8.5",
"cronstrue": "^2.48.0",
"cronstrue": "^3.2.0",
"date-fns": "^4.1.0",
"dotenv": "^16.4.5",
"electron-log": "^5.2.2",
"dotenv": "^17.2.1",
"electron-log": "^5.4.2",
"electron-squirrel-startup": "^1.0.1",
"electron-updater": "^6.6.2",
"electron-window-state": "^5.0.3",
"express": "^4.21.1",
"express": "^5.1.0",
"gsap": "^3.13.0",
"lodash": "^4.17.21",
"lucide-react": "^0.475.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
"react-markdown": "^9.0.1",
"react-router-dom": "^7.6.2",
"react-select": "^5.9.0",
"lucide-react": "^0.539.0",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-icons": "^5.5.0",
"react-markdown": "^10.1.0",
"react-router-dom": "^7.8.0",
"react-select": "^5.10.2",
"react-syntax-highlighter": "^15.6.1",
"react-toastify": "^10.0.0",
"react-toastify": "^11.0.5",
"remark-gfm": "^4.0.1",
"split-type": "^0.3.4",
"tailwind-merge": "^2.5.4",
"swr": "^2.3.6",
"tailwind-merge": "^3.3.1",
"tailwindcss-animate": "^1.0.7",
"tw-animate-css": "^1.3.4",
"tw-animate-css": "^1.3.6",
"unist-util-visit": "^5.0.0",
"uuid": "^11.1.0"
},
"devDependencies": {
"@electron-forge/cli": "^7.5.0",
"@electron-forge/maker-deb": "^7.5.0",
"@electron-forge/maker-rpm": "^7.5.0",
"@electron-forge/maker-squirrel": "^7.5.0",
"@electron-forge/maker-zip": "^7.5.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.5.0",
"@electron-forge/cli": "^7.8.3",
"@electron-forge/maker-deb": "^7.8.3",
"@electron-forge/maker-rpm": "^7.8.3",
"@electron-forge/maker-squirrel": "^7.8.3",
"@electron-forge/maker-zip": "^7.8.3",
"@electron-forge/plugin-auto-unpack-natives": "^7.8.3",
"@electron-forge/plugin-fuses": "^7.5.0",
"@electron-forge/plugin-vite": "^7.5.0",
"@electron-forge/plugin-vite": "^7.8.3",
"@electron/fuses": "^1.8.0",
"@electron/remote": "^2.1.2",
"@eslint/js": "^8.56.0",
"@hey-api/openapi-ts": "^0.64.4",
"@modelcontextprotocol/sdk": "^1.8.0",
"@playwright/test": "^1.51.1",
"@electron/remote": "^2.1.3",
"@eslint/js": "^9.33.0",
"@hey-api/openapi-ts": "^0.80.10",
"@modelcontextprotocol/sdk": "^1.17.3",
"@playwright/test": "^1.54.2",
"@tailwindcss/line-clamp": "^0.4.4",
"@tailwindcss/typography": "^0.5.15",
"@tailwindcss/vite": "^4.1.10",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/cors": "^2.8.17",
"@types/electron": "^1.4.38",
"@tailwindcss/typography": "^0.5.16",
"@tailwindcss/vite": "^4.1.12",
"@testing-library/jest-dom": "^6.7.0",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/cors": "^2.8.19",
"@types/electron-squirrel-startup": "^1.0.2",
"@types/electron-window-state": "^2.0.34",
"@types/express": "^5.0.0",
"@types/lodash": "^4.17.16",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/express": "^5.0.3",
"@types/lodash": "^4.17.20",
"@types/react": "^19.1.10",
"@types/react-dom": "^19.1.7",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/yauzl": "^2.10.3",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.3.3",
"@typescript-eslint/eslint-plugin": "^8.39.1",
"@typescript-eslint/parser": "^8.39.1",
"@vitejs/plugin-react": "^5.0.0",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"autoprefixer": "^10.4.20",
"electron": "33.1.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.0",
"jsdom": "^25.0.1",
"autoprefixer": "^10.4.21",
"electron": "37.2.6",
"eslint": "^9.33.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"husky": "^9.1.7",
"jsdom": "^26.1.0",
"knip": "^5.62.0",
"lint-staged": "^15.4.1",
"postcss": "^8.4.47",
"prettier": "^3.4.2",
"tailwindcss": "^4.1.10",
"typescript": "~5.5.0",
"vite": "^6.3.4",
"lint-staged": "^16.1.5",
"postcss": "^8.5.6",
"prettier": "^3.6.2",
"tailwindcss": "^4.1.12",
"typescript": "~5.9.2",
"vite": "^7.1.2",
"vitest": "^3.2.4"
},
"keywords": [],
+4 -3
View File
@@ -266,7 +266,8 @@ const PairRouteWrapper = ({
}
// If we have a recipe config but resetChat is false and we already have a recipe,
// do nothing - just continue with the existing chat state
}, [location.state, setChat, setPairChat]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.state]);
return (
<Pair
@@ -908,12 +909,12 @@ export default function App() {
await validateConfig({ throwOnError: true });
// If validation passes, try reading again
await readAllConfig({ throwOnError: true });
} catch (validateError) {
} catch {
console.log('Config validation failed, attempting recovery...');
try {
await recoverConfig({ throwOnError: true });
await readAllConfig({ throwOnError: true });
} catch (recoverError) {
} catch {
console.warn('Config recovery failed, reinitializing...');
await initConfig();
}
+1 -1
View File
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { ClientOptions } from './types.gen';
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client';
/**
* The `createClientConfig()` function will be called on client initialization
+199
View File
@@ -0,0 +1,199 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { Client, Config, ResolvedRequestOptions } from './types.gen';
import {
buildUrl,
createConfig,
createInterceptors,
getParseAs,
mergeConfigs,
mergeHeaders,
setAuthParams,
} from './utils.gen';
type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
body?: any;
headers: ReturnType<typeof mergeHeaders>;
};
export const createClient = (config: Config = {}): Client => {
let _config = mergeConfigs(createConfig(), config);
const getConfig = (): Config => ({ ..._config });
const setConfig = (config: Config): Config => {
_config = mergeConfigs(_config, config);
return getConfig();
};
const interceptors = createInterceptors<
Request,
Response,
unknown,
ResolvedRequestOptions
>();
const request: Client['request'] = async (options) => {
const opts = {
..._config,
...options,
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
headers: mergeHeaders(_config.headers, options.headers),
serializedBody: undefined,
};
if (opts.security) {
await setAuthParams({
...opts,
security: opts.security,
});
}
if (opts.requestValidator) {
await opts.requestValidator(opts);
}
if (opts.body && opts.bodySerializer) {
opts.serializedBody = opts.bodySerializer(opts.body);
}
// remove Content-Type header if body is empty to avoid sending invalid requests
if (opts.serializedBody === undefined || opts.serializedBody === '') {
opts.headers.delete('Content-Type');
}
const url = buildUrl(opts);
const requestInit: ReqInit = {
redirect: 'follow',
...opts,
body: opts.serializedBody,
};
let request = new Request(url, requestInit);
for (const fn of interceptors.request._fns) {
if (fn) {
request = await fn(request, opts);
}
}
// fetch must be assigned here, otherwise it would throw the error:
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
const _fetch = opts.fetch!;
let response = await _fetch(request);
for (const fn of interceptors.response._fns) {
if (fn) {
response = await fn(response, request, opts);
}
}
const result = {
request,
response,
};
if (response.ok) {
if (
response.status === 204 ||
response.headers.get('Content-Length') === '0'
) {
return opts.responseStyle === 'data'
? {}
: {
data: {},
...result,
};
}
const parseAs =
(opts.parseAs === 'auto'
? getParseAs(response.headers.get('Content-Type'))
: opts.parseAs) ?? 'json';
let data: any;
switch (parseAs) {
case 'arrayBuffer':
case 'blob':
case 'formData':
case 'json':
case 'text':
data = await response[parseAs]();
break;
case 'stream':
return opts.responseStyle === 'data'
? response.body
: {
data: response.body,
...result,
};
}
if (parseAs === 'json') {
if (opts.responseValidator) {
await opts.responseValidator(data);
}
if (opts.responseTransformer) {
data = await opts.responseTransformer(data);
}
}
return opts.responseStyle === 'data'
? data
: {
data,
...result,
};
}
const textError = await response.text();
let jsonError: unknown;
try {
jsonError = JSON.parse(textError);
} catch {
// noop
}
const error = jsonError ?? textError;
let finalError = error;
for (const fn of interceptors.error._fns) {
if (fn) {
finalError = (await fn(error, response, request, opts)) as string;
}
}
finalError = finalError || ({} as string);
if (opts.throwOnError) {
throw finalError;
}
// TODO: we probably want to return error and improve types
return opts.responseStyle === 'data'
? undefined
: {
error: finalError,
...result,
};
};
return {
buildUrl,
connect: (options) => request({ ...options, method: 'CONNECT' }),
delete: (options) => request({ ...options, method: 'DELETE' }),
get: (options) => request({ ...options, method: 'GET' }),
getConfig,
head: (options) => request({ ...options, method: 'HEAD' }),
interceptors,
options: (options) => request({ ...options, method: 'OPTIONS' }),
patch: (options) => request({ ...options, method: 'PATCH' }),
post: (options) => request({ ...options, method: 'POST' }),
put: (options) => request({ ...options, method: 'PUT' }),
request,
setConfig,
trace: (options) => request({ ...options, method: 'TRACE' }),
};
};
+25
View File
@@ -0,0 +1,25 @@
// This file is auto-generated by @hey-api/openapi-ts
export type { Auth } from '../core/auth.gen';
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
export {
formDataBodySerializer,
jsonBodySerializer,
urlSearchParamsBodySerializer,
} from '../core/bodySerializer.gen';
export { buildClientParams } from '../core/params.gen';
export { createClient } from './client.gen';
export type {
Client,
ClientOptions,
Config,
CreateClientConfig,
Options,
OptionsLegacyParser,
RequestOptions,
RequestResult,
ResolvedRequestOptions,
ResponseStyle,
TDataShape,
} from './types.gen';
export { createConfig, mergeHeaders } from './utils.gen';
+232
View File
@@ -0,0 +1,232 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { Auth } from '../core/auth.gen';
import type {
Client as CoreClient,
Config as CoreConfig,
} from '../core/types.gen';
import type { Middleware } from './utils.gen';
export type ResponseStyle = 'data' | 'fields';
export interface Config<T extends ClientOptions = ClientOptions>
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
CoreConfig {
/**
* Base URL for all requests made by this client.
*/
baseUrl?: T['baseUrl'];
/**
* Fetch API implementation. You can use this option to provide a custom
* fetch instance.
*
* @default globalThis.fetch
*/
fetch?: (request: Request) => ReturnType<typeof fetch>;
/**
* Please don't use the Fetch client for Next.js applications. The `next`
* options won't have any effect.
*
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
*/
next?: never;
/**
* Return the response data parsed in a specified format. By default, `auto`
* will infer the appropriate method from the `Content-Type` response header.
* You can override this behavior with any of the {@link Body} methods.
* Select `stream` if you don't want to parse response data at all.
*
* @default 'auto'
*/
parseAs?:
| 'arrayBuffer'
| 'auto'
| 'blob'
| 'formData'
| 'json'
| 'stream'
| 'text';
/**
* Should we return only data or multiple fields (data, error, response, etc.)?
*
* @default 'fields'
*/
responseStyle?: ResponseStyle;
/**
* Throw an error instead of returning it in the response?
*
* @default false
*/
throwOnError?: T['throwOnError'];
}
export interface RequestOptions<
TResponseStyle extends ResponseStyle = 'fields',
ThrowOnError extends boolean = boolean,
Url extends string = string,
> extends Config<{
responseStyle: TResponseStyle;
throwOnError: ThrowOnError;
}> {
/**
* Any body that you want to add to your request.
*
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
*/
body?: unknown;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
/**
* Security mechanism(s) to use for the request.
*/
security?: ReadonlyArray<Auth>;
url: Url;
}
export interface ResolvedRequestOptions<
TResponseStyle extends ResponseStyle = 'fields',
ThrowOnError extends boolean = boolean,
Url extends string = string,
> extends RequestOptions<TResponseStyle, ThrowOnError, Url> {
serializedBody?: string;
}
export type RequestResult<
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = boolean,
TResponseStyle extends ResponseStyle = 'fields',
> = ThrowOnError extends true
? Promise<
TResponseStyle extends 'data'
? TData extends Record<string, unknown>
? TData[keyof TData]
: TData
: {
data: TData extends Record<string, unknown>
? TData[keyof TData]
: TData;
request: Request;
response: Response;
}
>
: Promise<
TResponseStyle extends 'data'
?
| (TData extends Record<string, unknown>
? TData[keyof TData]
: TData)
| undefined
: (
| {
data: TData extends Record<string, unknown>
? TData[keyof TData]
: TData;
error: undefined;
}
| {
data: undefined;
error: TError extends Record<string, unknown>
? TError[keyof TError]
: TError;
}
) & {
request: Request;
response: Response;
}
>;
export interface ClientOptions {
baseUrl?: string;
responseStyle?: ResponseStyle;
throwOnError?: boolean;
}
type MethodFn = <
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = false,
TResponseStyle extends ResponseStyle = 'fields',
>(
options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'>,
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
type RequestFn = <
TData = unknown,
TError = unknown,
ThrowOnError extends boolean = false,
TResponseStyle extends ResponseStyle = 'fields',
>(
options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'> &
Pick<Required<RequestOptions<TResponseStyle, ThrowOnError>>, 'method'>,
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
type BuildUrlFn = <
TData extends {
body?: unknown;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
url: string;
},
>(
options: Pick<TData, 'url'> & Options<TData>,
) => string;
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
};
/**
* The `createClientConfig()` function will be called on client initialization
* and the returned object will become the client's initial configuration.
*
* You may want to initialize your client this way instead of calling
* `setConfig()`. This is useful for example if you're using Next.js
* to ensure your client always has the correct values.
*/
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
override?: Config<ClientOptions & T>,
) => Config<Required<ClientOptions> & T>;
export interface TDataShape {
body?: unknown;
headers?: unknown;
path?: unknown;
query?: unknown;
url: string;
}
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
export type Options<
TData extends TDataShape = TDataShape,
ThrowOnError extends boolean = boolean,
TResponseStyle extends ResponseStyle = 'fields',
> = OmitKeys<
RequestOptions<TResponseStyle, ThrowOnError>,
'body' | 'path' | 'query' | 'url'
> &
Omit<TData, 'url'>;
export type OptionsLegacyParser<
TData = unknown,
ThrowOnError extends boolean = boolean,
TResponseStyle extends ResponseStyle = 'fields',
> = TData extends { body?: any }
? TData extends { headers?: any }
? OmitKeys<
RequestOptions<TResponseStyle, ThrowOnError>,
'body' | 'headers' | 'url'
> &
TData
: OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'url'> &
TData &
Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'headers'>
: TData extends { headers?: any }
? OmitKeys<
RequestOptions<TResponseStyle, ThrowOnError>,
'headers' | 'url'
> &
TData &
Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'body'>
: OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'url'> & TData;
+419
View File
@@ -0,0 +1,419 @@
// This file is auto-generated by @hey-api/openapi-ts
import { getAuthToken } from '../core/auth.gen';
import type {
QuerySerializer,
QuerySerializerOptions,
} from '../core/bodySerializer.gen';
import { jsonBodySerializer } from '../core/bodySerializer.gen';
import {
serializeArrayParam,
serializeObjectParam,
serializePrimitiveParam,
} from '../core/pathSerializer.gen';
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
interface PathSerializer {
path: Record<string, unknown>;
url: string;
}
const PATH_PARAM_RE = /\{[^{}]+\}/g;
type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
type MatrixStyle = 'label' | 'matrix' | 'simple';
type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
let url = _url;
const matches = _url.match(PATH_PARAM_RE);
if (matches) {
for (const match of matches) {
let explode = false;
let name = match.substring(1, match.length - 1);
let style: ArraySeparatorStyle = 'simple';
if (name.endsWith('*')) {
explode = true;
name = name.substring(0, name.length - 1);
}
if (name.startsWith('.')) {
name = name.substring(1);
style = 'label';
} else if (name.startsWith(';')) {
name = name.substring(1);
style = 'matrix';
}
const value = path[name];
if (value === undefined || value === null) {
continue;
}
if (Array.isArray(value)) {
url = url.replace(
match,
serializeArrayParam({ explode, name, style, value }),
);
continue;
}
if (typeof value === 'object') {
url = url.replace(
match,
serializeObjectParam({
explode,
name,
style,
value: value as Record<string, unknown>,
valueOnly: true,
}),
);
continue;
}
if (style === 'matrix') {
url = url.replace(
match,
`;${serializePrimitiveParam({
name,
value: value as string,
})}`,
);
continue;
}
const replaceValue = encodeURIComponent(
style === 'label' ? `.${value as string}` : (value as string),
);
url = url.replace(match, replaceValue);
}
}
return url;
};
export const createQuerySerializer = <T = unknown>({
allowReserved,
array,
object,
}: QuerySerializerOptions = {}) => {
const querySerializer = (queryParams: T) => {
const search: string[] = [];
if (queryParams && typeof queryParams === 'object') {
for (const name in queryParams) {
const value = queryParams[name];
if (value === undefined || value === null) {
continue;
}
if (Array.isArray(value)) {
const serializedArray = serializeArrayParam({
allowReserved,
explode: true,
name,
style: 'form',
value,
...array,
});
if (serializedArray) search.push(serializedArray);
} else if (typeof value === 'object') {
const serializedObject = serializeObjectParam({
allowReserved,
explode: true,
name,
style: 'deepObject',
value: value as Record<string, unknown>,
...object,
});
if (serializedObject) search.push(serializedObject);
} else {
const serializedPrimitive = serializePrimitiveParam({
allowReserved,
name,
value: value as string,
});
if (serializedPrimitive) search.push(serializedPrimitive);
}
}
}
return search.join('&');
};
return querySerializer;
};
/**
* Infers parseAs value from provided Content-Type header.
*/
export const getParseAs = (
contentType: string | null,
): Exclude<Config['parseAs'], 'auto'> => {
if (!contentType) {
// If no Content-Type header is provided, the best we can do is return the raw response body,
// which is effectively the same as the 'stream' option.
return 'stream';
}
const cleanContent = contentType.split(';')[0]?.trim();
if (!cleanContent) {
return;
}
if (
cleanContent.startsWith('application/json') ||
cleanContent.endsWith('+json')
) {
return 'json';
}
if (cleanContent === 'multipart/form-data') {
return 'formData';
}
if (
['application/', 'audio/', 'image/', 'video/'].some((type) =>
cleanContent.startsWith(type),
)
) {
return 'blob';
}
if (cleanContent.startsWith('text/')) {
return 'text';
}
return;
};
export const setAuthParams = async ({
security,
...options
}: Pick<Required<RequestOptions>, 'security'> &
Pick<RequestOptions, 'auth' | 'query'> & {
headers: Headers;
}) => {
for (const auth of security) {
const token = await getAuthToken(auth, options.auth);
if (!token) {
continue;
}
const name = auth.name ?? 'Authorization';
switch (auth.in) {
case 'query':
if (!options.query) {
options.query = {};
}
options.query[name] = token;
break;
case 'cookie':
options.headers.append('Cookie', `${name}=${token}`);
break;
case 'header':
default:
options.headers.set(name, token);
break;
}
return;
}
};
export const buildUrl: Client['buildUrl'] = (options) => {
const url = getUrl({
baseUrl: options.baseUrl as string,
path: options.path,
query: options.query,
querySerializer:
typeof options.querySerializer === 'function'
? options.querySerializer
: createQuerySerializer(options.querySerializer),
url: options.url,
});
return url;
};
export const getUrl = ({
baseUrl,
path,
query,
querySerializer,
url: _url,
}: {
baseUrl?: string;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
querySerializer: QuerySerializer;
url: string;
}) => {
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
let url = (baseUrl ?? '') + pathUrl;
if (path) {
url = defaultPathSerializer({ path, url });
}
let search = query ? querySerializer(query) : '';
if (search.startsWith('?')) {
search = search.substring(1);
}
if (search) {
url += `?${search}`;
}
return url;
};
export const mergeConfigs = (a: Config, b: Config): Config => {
const config = { ...a, ...b };
if (config.baseUrl?.endsWith('/')) {
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
}
config.headers = mergeHeaders(a.headers, b.headers);
return config;
};
export const mergeHeaders = (
...headers: Array<Required<Config>['headers'] | undefined>
): Headers => {
const mergedHeaders = new Headers();
for (const header of headers) {
if (!header || typeof header !== 'object') {
continue;
}
const iterator =
header instanceof Headers ? header.entries() : Object.entries(header);
for (const [key, value] of iterator) {
if (value === null) {
mergedHeaders.delete(key);
} else if (Array.isArray(value)) {
for (const v of value) {
mergedHeaders.append(key, v as string);
}
} else if (value !== undefined) {
// assume object headers are meant to be JSON stringified, i.e. their
// content value in OpenAPI specification is 'application/json'
mergedHeaders.set(
key,
typeof value === 'object' ? JSON.stringify(value) : (value as string),
);
}
}
}
return mergedHeaders;
};
type ErrInterceptor<Err, Res, Req, Options> = (
error: Err,
response: Res,
request: Req,
options: Options,
) => Err | Promise<Err>;
type ReqInterceptor<Req, Options> = (
request: Req,
options: Options,
) => Req | Promise<Req>;
type ResInterceptor<Res, Req, Options> = (
response: Res,
request: Req,
options: Options,
) => Res | Promise<Res>;
class Interceptors<Interceptor> {
_fns: (Interceptor | null)[];
constructor() {
this._fns = [];
}
clear() {
this._fns = [];
}
getInterceptorIndex(id: number | Interceptor): number {
if (typeof id === 'number') {
return this._fns[id] ? id : -1;
} else {
return this._fns.indexOf(id);
}
}
exists(id: number | Interceptor) {
const index = this.getInterceptorIndex(id);
return !!this._fns[index];
}
eject(id: number | Interceptor) {
const index = this.getInterceptorIndex(id);
if (this._fns[index]) {
this._fns[index] = null;
}
}
update(id: number | Interceptor, fn: Interceptor) {
const index = this.getInterceptorIndex(id);
if (this._fns[index]) {
this._fns[index] = fn;
return id;
} else {
return false;
}
}
use(fn: Interceptor) {
this._fns = [...this._fns, fn];
return this._fns.length - 1;
}
}
// `createInterceptors()` response, meant for external use as it does not
// expose internals
export interface Middleware<Req, Res, Err, Options> {
error: Pick<
Interceptors<ErrInterceptor<Err, Res, Req, Options>>,
'eject' | 'use'
>;
request: Pick<Interceptors<ReqInterceptor<Req, Options>>, 'eject' | 'use'>;
response: Pick<
Interceptors<ResInterceptor<Res, Req, Options>>,
'eject' | 'use'
>;
}
// do not add `Middleware` as return type so we can use _fns internally
export const createInterceptors = <Req, Res, Err, Options>() => ({
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
request: new Interceptors<ReqInterceptor<Req, Options>>(),
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
});
const defaultQuerySerializer = createQuerySerializer({
allowReserved: false,
array: {
explode: true,
style: 'form',
},
object: {
explode: true,
style: 'deepObject',
},
});
const defaultHeaders = {
'Content-Type': 'application/json',
};
export const createConfig = <T extends ClientOptions = ClientOptions>(
override: Config<Omit<ClientOptions, keyof T> & T> = {},
): Config<Omit<ClientOptions, keyof T> & T> => ({
...jsonBodySerializer,
headers: defaultHeaders,
parseAs: 'auto',
querySerializer: defaultQuerySerializer,
...override,
});
+42
View File
@@ -0,0 +1,42 @@
// This file is auto-generated by @hey-api/openapi-ts
export type AuthToken = string | undefined;
export interface Auth {
/**
* Which part of the request do we use to send the auth?
*
* @default 'header'
*/
in?: 'header' | 'query' | 'cookie';
/**
* Header or query parameter name.
*
* @default 'Authorization'
*/
name?: string;
scheme?: 'basic' | 'bearer';
type: 'apiKey' | 'http';
}
export const getAuthToken = async (
auth: Auth,
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
): Promise<string | undefined> => {
const token =
typeof callback === 'function' ? await callback(auth) : callback;
if (!token) {
return;
}
if (auth.scheme === 'bearer') {
return `Bearer ${token}`;
}
if (auth.scheme === 'basic') {
return `Basic ${btoa(token)}`;
}
return token;
};
@@ -0,0 +1,92 @@
// This file is auto-generated by @hey-api/openapi-ts
import type {
ArrayStyle,
ObjectStyle,
SerializerOptions,
} from './pathSerializer.gen';
export type QuerySerializer = (query: Record<string, unknown>) => string;
export type BodySerializer = (body: any) => any;
export interface QuerySerializerOptions {
allowReserved?: boolean;
array?: SerializerOptions<ArrayStyle>;
object?: SerializerOptions<ObjectStyle>;
}
const serializeFormDataPair = (
data: FormData,
key: string,
value: unknown,
): void => {
if (typeof value === 'string' || value instanceof Blob) {
data.append(key, value);
} else if (value instanceof Date) {
data.append(key, value.toISOString());
} else {
data.append(key, JSON.stringify(value));
}
};
const serializeUrlSearchParamsPair = (
data: URLSearchParams,
key: string,
value: unknown,
): void => {
if (typeof value === 'string') {
data.append(key, value);
} else {
data.append(key, JSON.stringify(value));
}
};
export const formDataBodySerializer = {
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
body: T,
): FormData => {
const data = new FormData();
Object.entries(body).forEach(([key, value]) => {
if (value === undefined || value === null) {
return;
}
if (Array.isArray(value)) {
value.forEach((v) => serializeFormDataPair(data, key, v));
} else {
serializeFormDataPair(data, key, value);
}
});
return data;
},
};
export const jsonBodySerializer = {
bodySerializer: <T>(body: T): string =>
JSON.stringify(body, (_key, value) =>
typeof value === 'bigint' ? value.toString() : value,
),
};
export const urlSearchParamsBodySerializer = {
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
body: T,
): string => {
const data = new URLSearchParams();
Object.entries(body).forEach(([key, value]) => {
if (value === undefined || value === null) {
return;
}
if (Array.isArray(value)) {
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
} else {
serializeUrlSearchParamsPair(data, key, value);
}
});
return data.toString();
},
};
+153
View File
@@ -0,0 +1,153 @@
// This file is auto-generated by @hey-api/openapi-ts
type Slot = 'body' | 'headers' | 'path' | 'query';
export type Field =
| {
in: Exclude<Slot, 'body'>;
/**
* Field name. This is the name we want the user to see and use.
*/
key: string;
/**
* Field mapped name. This is the name we want to use in the request.
* If omitted, we use the same value as `key`.
*/
map?: string;
}
| {
in: Extract<Slot, 'body'>;
/**
* Key isn't required for bodies.
*/
key?: string;
map?: string;
};
export interface Fields {
allowExtra?: Partial<Record<Slot, boolean>>;
args?: ReadonlyArray<Field>;
}
export type FieldsConfig = ReadonlyArray<Field | Fields>;
const extraPrefixesMap: Record<string, Slot> = {
$body_: 'body',
$headers_: 'headers',
$path_: 'path',
$query_: 'query',
};
const extraPrefixes = Object.entries(extraPrefixesMap);
type KeyMap = Map<
string,
{
in: Slot;
map?: string;
}
>;
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
if (!map) {
map = new Map();
}
for (const config of fields) {
if ('in' in config) {
if (config.key) {
map.set(config.key, {
in: config.in,
map: config.map,
});
}
} else if (config.args) {
buildKeyMap(config.args, map);
}
}
return map;
};
interface Params {
body: unknown;
headers: Record<string, unknown>;
path: Record<string, unknown>;
query: Record<string, unknown>;
}
const stripEmptySlots = (params: Params) => {
for (const [slot, value] of Object.entries(params)) {
if (value && typeof value === 'object' && !Object.keys(value).length) {
delete params[slot as Slot];
}
}
};
export const buildClientParams = (
args: ReadonlyArray<unknown>,
fields: FieldsConfig,
) => {
const params: Params = {
body: {},
headers: {},
path: {},
query: {},
};
const map = buildKeyMap(fields);
let config: FieldsConfig[number] | undefined;
for (const [index, arg] of args.entries()) {
if (fields[index]) {
config = fields[index];
}
if (!config) {
continue;
}
if ('in' in config) {
if (config.key) {
const field = map.get(config.key)!;
const name = field.map || config.key;
(params[field.in] as Record<string, unknown>)[name] = arg;
} else {
params.body = arg;
}
} else {
for (const [key, value] of Object.entries(arg ?? {})) {
const field = map.get(key);
if (field) {
const name = field.map || key;
(params[field.in] as Record<string, unknown>)[name] = value;
} else {
const extra = extraPrefixes.find(([prefix]) =>
key.startsWith(prefix),
);
if (extra) {
const [prefix, slot] = extra;
(params[slot] as Record<string, unknown>)[
key.slice(prefix.length)
] = value;
} else {
for (const [slot, allowed] of Object.entries(
config.allowExtra ?? {},
)) {
if (allowed) {
(params[slot as Slot] as Record<string, unknown>)[key] = value;
break;
}
}
}
}
}
}
}
stripEmptySlots(params);
return params;
};
@@ -0,0 +1,181 @@
// This file is auto-generated by @hey-api/openapi-ts
interface SerializeOptions<T>
extends SerializePrimitiveOptions,
SerializerOptions<T> {}
interface SerializePrimitiveOptions {
allowReserved?: boolean;
name: string;
}
export interface SerializerOptions<T> {
/**
* @default true
*/
explode: boolean;
style: T;
}
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
type MatrixStyle = 'label' | 'matrix' | 'simple';
export type ObjectStyle = 'form' | 'deepObject';
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
value: string;
}
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
switch (style) {
case 'label':
return '.';
case 'matrix':
return ';';
case 'simple':
return ',';
default:
return '&';
}
};
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
switch (style) {
case 'form':
return ',';
case 'pipeDelimited':
return '|';
case 'spaceDelimited':
return '%20';
default:
return ',';
}
};
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
switch (style) {
case 'label':
return '.';
case 'matrix':
return ';';
case 'simple':
return ',';
default:
return '&';
}
};
export const serializeArrayParam = ({
allowReserved,
explode,
name,
style,
value,
}: SerializeOptions<ArraySeparatorStyle> & {
value: unknown[];
}) => {
if (!explode) {
const joinedValues = (
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
).join(separatorArrayNoExplode(style));
switch (style) {
case 'label':
return `.${joinedValues}`;
case 'matrix':
return `;${name}=${joinedValues}`;
case 'simple':
return joinedValues;
default:
return `${name}=${joinedValues}`;
}
}
const separator = separatorArrayExplode(style);
const joinedValues = value
.map((v) => {
if (style === 'label' || style === 'simple') {
return allowReserved ? v : encodeURIComponent(v as string);
}
return serializePrimitiveParam({
allowReserved,
name,
value: v as string,
});
})
.join(separator);
return style === 'label' || style === 'matrix'
? separator + joinedValues
: joinedValues;
};
export const serializePrimitiveParam = ({
allowReserved,
name,
value,
}: SerializePrimitiveParam) => {
if (value === undefined || value === null) {
return '';
}
if (typeof value === 'object') {
throw new Error(
'Deeply-nested arrays/objects arent supported. Provide your own `querySerializer()` to handle these.',
);
}
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
};
export const serializeObjectParam = ({
allowReserved,
explode,
name,
style,
value,
valueOnly,
}: SerializeOptions<ObjectSeparatorStyle> & {
value: Record<string, unknown> | Date;
valueOnly?: boolean;
}) => {
if (value instanceof Date) {
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
}
if (style !== 'deepObject' && !explode) {
let values: string[] = [];
Object.entries(value).forEach(([key, v]) => {
values = [
...values,
key,
allowReserved ? (v as string) : encodeURIComponent(v as string),
];
});
const joinedValues = values.join(',');
switch (style) {
case 'form':
return `${name}=${joinedValues}`;
case 'label':
return `.${joinedValues}`;
case 'matrix':
return `;${name}=${joinedValues}`;
default:
return joinedValues;
}
}
const separator = separatorObjectExplode(style);
const joinedValues = Object.entries(value)
.map(([key, v]) =>
serializePrimitiveParam({
allowReserved,
name: style === 'deepObject' ? `${name}[${key}]` : key,
value: v as string,
}),
)
.join(separator);
return style === 'label' || style === 'matrix'
? separator + joinedValues
: joinedValues;
};
+120
View File
@@ -0,0 +1,120 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { Auth, AuthToken } from './auth.gen';
import type {
BodySerializer,
QuerySerializer,
QuerySerializerOptions,
} from './bodySerializer.gen';
export interface Client<
RequestFn = never,
Config = unknown,
MethodFn = never,
BuildUrlFn = never,
> {
/**
* Returns the final request URL.
*/
buildUrl: BuildUrlFn;
connect: MethodFn;
delete: MethodFn;
get: MethodFn;
getConfig: () => Config;
head: MethodFn;
options: MethodFn;
patch: MethodFn;
post: MethodFn;
put: MethodFn;
request: RequestFn;
setConfig: (config: Config) => Config;
trace: MethodFn;
}
export interface Config {
/**
* Auth token or a function returning auth token. The resolved value will be
* added to the request payload as defined by its `security` array.
*/
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
/**
* A function for serializing request body parameter. By default,
* {@link JSON.stringify()} will be used.
*/
bodySerializer?: BodySerializer | null;
/**
* An object containing any HTTP headers that you want to pre-populate your
* `Headers` object with.
*
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
*/
headers?:
| RequestInit['headers']
| Record<
string,
| string
| number
| boolean
| (string | number | boolean)[]
| null
| undefined
| unknown
>;
/**
* The request method.
*
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
*/
method?:
| 'CONNECT'
| 'DELETE'
| 'GET'
| 'HEAD'
| 'OPTIONS'
| 'PATCH'
| 'POST'
| 'PUT'
| 'TRACE';
/**
* A function for serializing request query parameters. By default, arrays
* will be exploded in form style, objects will be exploded in deepObject
* style, and reserved characters are percent-encoded.
*
* This method will have no effect if the native `paramsSerializer()` Axios
* API function is used.
*
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
*/
querySerializer?: QuerySerializer | QuerySerializerOptions;
/**
* A function validating request data. This is useful if you want to ensure
* the request conforms to the desired shape, so it can be safely sent to
* the server.
*/
requestValidator?: (data: unknown) => Promise<unknown>;
/**
* A function transforming response data before it's returned. This is useful
* for post-processing data, e.g. converting ISO strings into Date objects.
*/
responseTransformer?: (data: unknown) => Promise<unknown>;
/**
* A function validating response data. This is useful if you want to ensure
* the response conforms to the desired shape, so it can be safely passed to
* the transformers and returned to the user.
*/
responseValidator?: (data: unknown) => Promise<unknown>;
}
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
? true
: [T] extends [never | undefined]
? [undefined] extends [T]
? false
: true
: false;
export type OmitNever<T extends Record<string, unknown>> = {
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true
? never
: K]: T[K];
};
+54 -54
View File
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
import type { AddSubRecipesData, AddSubRecipesResponse2, ExtendPromptData, ExtendPromptResponse2, UpdateSessionConfigData, UpdateSessionConfigResponse, GetToolsData, GetToolsResponse, UpdateAgentProviderData, UpdateRouterToolSelectorData, UpdateRouterToolSelectorResponse, ReadAllConfigData, ReadAllConfigResponse, BackupConfigData, BackupConfigResponse, GetExtensionsData, GetExtensionsResponse, AddExtensionData, AddExtensionResponse, RemoveExtensionData, RemoveExtensionResponse, InitConfigData, InitConfigResponse, UpsertPermissionsData, UpsertPermissionsResponse, ProvidersData, ProvidersResponse2, ReadConfigData, RecoverConfigData, RecoverConfigResponse, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse, ValidateConfigData, ValidateConfigResponse, ConfirmPermissionData, ManageContextData, ManageContextResponse, CreateRecipeData, CreateRecipeResponse2, DecodeRecipeData, DecodeRecipeResponse2, EncodeRecipeData, EncodeRecipeResponse2, CreateScheduleData, CreateScheduleResponse, DeleteScheduleData, DeleteScheduleResponse, ListSchedulesData, ListSchedulesResponse2, UpdateScheduleData, UpdateScheduleResponse, InspectRunningJobData, InspectRunningJobResponse, KillRunningJobData, PauseScheduleData, PauseScheduleResponse, RunNowHandlerData, RunNowHandlerResponse, SessionsHandlerData, SessionsHandlerResponse, UnpauseScheduleData, UnpauseScheduleResponse, ListSessionsData, ListSessionsResponse, GetSessionHistoryData, GetSessionHistoryResponse } from './types.gen';
import type { Options as ClientOptions, TDataShape, Client } from './client';
import type { AddSubRecipesData, AddSubRecipesResponses, AddSubRecipesErrors, ExtendPromptData, ExtendPromptResponses, ExtendPromptErrors, UpdateSessionConfigData, UpdateSessionConfigResponses, UpdateSessionConfigErrors, GetToolsData, GetToolsResponses, GetToolsErrors, UpdateAgentProviderData, UpdateAgentProviderResponses, UpdateAgentProviderErrors, UpdateRouterToolSelectorData, UpdateRouterToolSelectorResponses, UpdateRouterToolSelectorErrors, ReadAllConfigData, ReadAllConfigResponses, BackupConfigData, BackupConfigResponses, BackupConfigErrors, GetExtensionsData, GetExtensionsResponses, GetExtensionsErrors, AddExtensionData, AddExtensionResponses, AddExtensionErrors, RemoveExtensionData, RemoveExtensionResponses, RemoveExtensionErrors, InitConfigData, InitConfigResponses, InitConfigErrors, UpsertPermissionsData, UpsertPermissionsResponses, UpsertPermissionsErrors, ProvidersData, ProvidersResponses, ReadConfigData, ReadConfigResponses, ReadConfigErrors, RecoverConfigData, RecoverConfigResponses, RecoverConfigErrors, RemoveConfigData, RemoveConfigResponses, RemoveConfigErrors, UpsertConfigData, UpsertConfigResponses, UpsertConfigErrors, ValidateConfigData, ValidateConfigResponses, ValidateConfigErrors, ConfirmPermissionData, ConfirmPermissionResponses, ConfirmPermissionErrors, ManageContextData, ManageContextResponses, ManageContextErrors, CreateRecipeData, CreateRecipeResponses, CreateRecipeErrors, DecodeRecipeData, DecodeRecipeResponses, DecodeRecipeErrors, EncodeRecipeData, EncodeRecipeResponses, EncodeRecipeErrors, CreateScheduleData, CreateScheduleResponses, CreateScheduleErrors, DeleteScheduleData, DeleteScheduleResponses, DeleteScheduleErrors, ListSchedulesData, ListSchedulesResponses, ListSchedulesErrors, UpdateScheduleData, UpdateScheduleResponses, UpdateScheduleErrors, InspectRunningJobData, InspectRunningJobResponses, InspectRunningJobErrors, KillRunningJobData, KillRunningJobResponses, PauseScheduleData, PauseScheduleResponses, PauseScheduleErrors, RunNowHandlerData, RunNowHandlerResponses, RunNowHandlerErrors, SessionsHandlerData, SessionsHandlerResponses, SessionsHandlerErrors, UnpauseScheduleData, UnpauseScheduleResponses, UnpauseScheduleErrors, ListSessionsData, ListSessionsResponses, ListSessionsErrors, GetSessionHistoryData, GetSessionHistoryResponses, GetSessionHistoryErrors } from './types.gen';
import { client as _heyApiClient } from './client.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
@@ -19,192 +19,192 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
};
export const addSubRecipes = <ThrowOnError extends boolean = false>(options: Options<AddSubRecipesData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<AddSubRecipesResponse2, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<AddSubRecipesResponses, AddSubRecipesErrors, ThrowOnError>({
url: '/agent/add_sub_recipes',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const extendPrompt = <ThrowOnError extends boolean = false>(options: Options<ExtendPromptData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<ExtendPromptResponse2, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<ExtendPromptResponses, ExtendPromptErrors, ThrowOnError>({
url: '/agent/prompt',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const updateSessionConfig = <ThrowOnError extends boolean = false>(options: Options<UpdateSessionConfigData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<UpdateSessionConfigResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<UpdateSessionConfigResponses, UpdateSessionConfigErrors, ThrowOnError>({
url: '/agent/session_config',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const getTools = <ThrowOnError extends boolean = false>(options?: Options<GetToolsData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<GetToolsResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<GetToolsResponses, GetToolsErrors, ThrowOnError>({
url: '/agent/tools',
...options
});
};
export const updateAgentProvider = <ThrowOnError extends boolean = false>(options: Options<UpdateAgentProviderData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<UpdateAgentProviderResponses, UpdateAgentProviderErrors, ThrowOnError>({
url: '/agent/update_provider',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const updateRouterToolSelector = <ThrowOnError extends boolean = false>(options?: Options<UpdateRouterToolSelectorData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).post<UpdateRouterToolSelectorResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).post<UpdateRouterToolSelectorResponses, UpdateRouterToolSelectorErrors, ThrowOnError>({
url: '/agent/update_router_tool_selector',
...options
});
};
export const readAllConfig = <ThrowOnError extends boolean = false>(options?: Options<ReadAllConfigData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<ReadAllConfigResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<ReadAllConfigResponses, unknown, ThrowOnError>({
url: '/config',
...options
});
};
export const backupConfig = <ThrowOnError extends boolean = false>(options?: Options<BackupConfigData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).post<BackupConfigResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).post<BackupConfigResponses, BackupConfigErrors, ThrowOnError>({
url: '/config/backup',
...options
});
};
export const getExtensions = <ThrowOnError extends boolean = false>(options?: Options<GetExtensionsData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<GetExtensionsResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<GetExtensionsResponses, GetExtensionsErrors, ThrowOnError>({
url: '/config/extensions',
...options
});
};
export const addExtension = <ThrowOnError extends boolean = false>(options: Options<AddExtensionData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<AddExtensionResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<AddExtensionResponses, AddExtensionErrors, ThrowOnError>({
url: '/config/extensions',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const removeExtension = <ThrowOnError extends boolean = false>(options: Options<RemoveExtensionData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).delete<RemoveExtensionResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).delete<RemoveExtensionResponses, RemoveExtensionErrors, ThrowOnError>({
url: '/config/extensions/{name}',
...options
});
};
export const initConfig = <ThrowOnError extends boolean = false>(options?: Options<InitConfigData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).post<InitConfigResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).post<InitConfigResponses, InitConfigErrors, ThrowOnError>({
url: '/config/init',
...options
});
};
export const upsertPermissions = <ThrowOnError extends boolean = false>(options: Options<UpsertPermissionsData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<UpsertPermissionsResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<UpsertPermissionsResponses, UpsertPermissionsErrors, ThrowOnError>({
url: '/config/permissions',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const providers = <ThrowOnError extends boolean = false>(options?: Options<ProvidersData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<ProvidersResponse2, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<ProvidersResponses, unknown, ThrowOnError>({
url: '/config/providers',
...options
});
};
export const readConfig = <ThrowOnError extends boolean = false>(options: Options<ReadConfigData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<ReadConfigResponses, ReadConfigErrors, ThrowOnError>({
url: '/config/read',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const recoverConfig = <ThrowOnError extends boolean = false>(options?: Options<RecoverConfigData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).post<RecoverConfigResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).post<RecoverConfigResponses, RecoverConfigErrors, ThrowOnError>({
url: '/config/recover',
...options
});
};
export const removeConfig = <ThrowOnError extends boolean = false>(options: Options<RemoveConfigData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<RemoveConfigResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<RemoveConfigResponses, RemoveConfigErrors, ThrowOnError>({
url: '/config/remove',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const upsertConfig = <ThrowOnError extends boolean = false>(options: Options<UpsertConfigData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<UpsertConfigResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<UpsertConfigResponses, UpsertConfigErrors, ThrowOnError>({
url: '/config/upsert',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const validateConfig = <ThrowOnError extends boolean = false>(options?: Options<ValidateConfigData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<ValidateConfigResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<ValidateConfigResponses, ValidateConfigErrors, ThrowOnError>({
url: '/config/validate',
...options
});
};
export const confirmPermission = <ThrowOnError extends boolean = false>(options: Options<ConfirmPermissionData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<ConfirmPermissionResponses, ConfirmPermissionErrors, ThrowOnError>({
url: '/confirm',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const manageContext = <ThrowOnError extends boolean = false>(options: Options<ManageContextData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<ManageContextResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<ManageContextResponses, ManageContextErrors, ThrowOnError>({
url: '/context/manage',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
@@ -213,125 +213,125 @@ export const manageContext = <ThrowOnError extends boolean = false>(options: Opt
* Create a Recipe configuration from the current session
*/
export const createRecipe = <ThrowOnError extends boolean = false>(options: Options<CreateRecipeData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<CreateRecipeResponse2, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<CreateRecipeResponses, CreateRecipeErrors, ThrowOnError>({
url: '/recipes/create',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const decodeRecipe = <ThrowOnError extends boolean = false>(options: Options<DecodeRecipeData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<DecodeRecipeResponse2, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<DecodeRecipeResponses, DecodeRecipeErrors, ThrowOnError>({
url: '/recipes/decode',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const encodeRecipe = <ThrowOnError extends boolean = false>(options: Options<EncodeRecipeData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<EncodeRecipeResponse2, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<EncodeRecipeResponses, EncodeRecipeErrors, ThrowOnError>({
url: '/recipes/encode',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const createSchedule = <ThrowOnError extends boolean = false>(options: Options<CreateScheduleData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<CreateScheduleResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<CreateScheduleResponses, CreateScheduleErrors, ThrowOnError>({
url: '/schedule/create',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const deleteSchedule = <ThrowOnError extends boolean = false>(options: Options<DeleteScheduleData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).delete<DeleteScheduleResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).delete<DeleteScheduleResponses, DeleteScheduleErrors, ThrowOnError>({
url: '/schedule/delete/{id}',
...options
});
};
export const listSchedules = <ThrowOnError extends boolean = false>(options?: Options<ListSchedulesData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<ListSchedulesResponse2, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<ListSchedulesResponses, ListSchedulesErrors, ThrowOnError>({
url: '/schedule/list',
...options
});
};
export const updateSchedule = <ThrowOnError extends boolean = false>(options: Options<UpdateScheduleData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).put<UpdateScheduleResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).put<UpdateScheduleResponses, UpdateScheduleErrors, ThrowOnError>({
url: '/schedule/{id}',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
...options.headers
}
});
};
export const inspectRunningJob = <ThrowOnError extends boolean = false>(options: Options<InspectRunningJobData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).get<InspectRunningJobResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).get<InspectRunningJobResponses, InspectRunningJobErrors, ThrowOnError>({
url: '/schedule/{id}/inspect',
...options
});
};
export const killRunningJob = <ThrowOnError extends boolean = false>(options: Options<KillRunningJobData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<unknown, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<KillRunningJobResponses, unknown, ThrowOnError>({
url: '/schedule/{id}/kill',
...options
});
};
export const pauseSchedule = <ThrowOnError extends boolean = false>(options: Options<PauseScheduleData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<PauseScheduleResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<PauseScheduleResponses, PauseScheduleErrors, ThrowOnError>({
url: '/schedule/{id}/pause',
...options
});
};
export const runNowHandler = <ThrowOnError extends boolean = false>(options: Options<RunNowHandlerData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<RunNowHandlerResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<RunNowHandlerResponses, RunNowHandlerErrors, ThrowOnError>({
url: '/schedule/{id}/run_now',
...options
});
};
export const sessionsHandler = <ThrowOnError extends boolean = false>(options: Options<SessionsHandlerData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).get<SessionsHandlerResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).get<SessionsHandlerResponses, SessionsHandlerErrors, ThrowOnError>({
url: '/schedule/{id}/sessions',
...options
});
};
export const unpauseSchedule = <ThrowOnError extends boolean = false>(options: Options<UnpauseScheduleData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<UnpauseScheduleResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).post<UnpauseScheduleResponses, UnpauseScheduleErrors, ThrowOnError>({
url: '/schedule/{id}/unpause',
...options
});
};
export const listSessions = <ThrowOnError extends boolean = false>(options?: Options<ListSessionsData, ThrowOnError>) => {
return (options?.client ?? _heyApiClient).get<ListSessionsResponse, unknown, ThrowOnError>({
return (options?.client ?? _heyApiClient).get<ListSessionsResponses, ListSessionsErrors, ThrowOnError>({
url: '/sessions',
...options
});
};
export const getSessionHistory = <ThrowOnError extends boolean = false>(options: Options<GetSessionHistoryData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).get<GetSessionHistoryResponse, unknown, ThrowOnError>({
return (options.client ?? _heyApiClient).get<GetSessionHistoryResponses, GetSessionHistoryErrors, ThrowOnError>({
url: '/sessions/{session_id}',
...options
});
+3 -1
View File
@@ -59,7 +59,9 @@ export type ConfigKeyQuery = {
};
export type ConfigResponse = {
config: {};
config: {
[key: string]: unknown;
};
};
export type Content = RawTextContent | RawImageContent | RawEmbeddedResource | Annotated;
+1 -1
View File
@@ -107,7 +107,7 @@ export default function ChatInput({
// Derived state - chatState != Idle means we're in some form of loading state
const isLoading = chatState !== ChatState.Idle;
const { alerts, addAlert, clearAlerts } = useAlerts();
const dropdownRef = useRef<HTMLDivElement>(null);
const dropdownRef = useRef<HTMLDivElement | null>(null);
const toolCount = useToolCount();
const { isLoadingCompaction, handleManualCompaction } = useChatContextManager();
const { getProviders, read } = useConfig();
@@ -14,7 +14,6 @@ interface FlappyGooseProps {
}
const FlappyGoose: React.FC<FlappyGooseProps> = ({ onClose }) => {
// eslint-disable-next-line no-undef
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const [gameOver, setGameOver] = useState(false);
const [displayScore, setDisplayScore] = useState(0);
+3 -1
View File
@@ -42,7 +42,7 @@ export default function GooseMessage({
appendMessage,
isStreaming = false,
}: GooseMessageProps) {
const contentRef = useRef<HTMLDivElement>(null);
const contentRef = useRef<HTMLDivElement | null>(null);
// Track which tool confirmations we've already handled to prevent infinite loops
const handledToolConfirmations = useRef<Set<string>>(new Set());
@@ -228,6 +228,7 @@ export default function GooseMessage({
</div>
{/* TODO(alexhancock): Re-enable link previews once styled well again */}
{/* eslint-disable-next-line no-constant-binary-expression */}
{false && urls.length > 0 && (
<div className="flex flex-wrap mt-[16px]">
{urls.map((url, index) => (
@@ -238,6 +239,7 @@ export default function GooseMessage({
{/* enable or disable prompts here */}
{/* NOTE from alexhancock on 1/14/2025 - disabling again temporarily due to non-determinism in when the forms show up */}
{/* eslint-disable-next-line no-constant-binary-expression */}
{false && metadata && (
<div className="flex mt-[16px]">
<GooseResponseForm message={displayText} metadata={metadata || null} append={append} />
@@ -102,7 +102,7 @@ const AppSidebar: React.FC<SidebarProps> = ({ currentPath }) => {
const timer = setTimeout(() => {
// setIsVisible(true);
}, 100);
// eslint-disable-next-line no-undef
return () => clearTimeout(timer);
}, []);
+17 -17
View File
@@ -108,25 +108,25 @@ export default function MarkdownContent({ content, className = '' }: MarkdownCon
}, [content]);
return (
<div className="w-full overflow-x-hidden">
<div
className={`w-full overflow-x-hidden prose prose-sm text-text-default dark:prose-invert max-w-full word-breakfont-sans
prose-pre:p-0 prose-pre:m-0 !p-0
prose-code:break-all prose-code:whitespace-pre-wrapprose-code:font-sans
prose-table:table prose-table:w-full
prose-blockquote:text-inherit
prose-td:border prose-td:border-border-default prose-td:p-2
prose-th:border prose-th:border-border-default prose-th:p-2
prose-thead:bg-background-default
prose-h1:text-2xl prose-h1:font-normal prose-h1:mb-5 prose-h1:mt-0prose-h1:font-sans
prose-h2:text-xl prose-h2:font-normal prose-h2:mb-4 prose-h2:mt-4prose-h2:font-sans
prose-h3:text-lg prose-h3:font-normal prose-h3:mb-3 prose-h3:mt-3prose-h3:font-sans
prose-p:mt-0 prose-p:mb-2prose-p:font-sans
prose-ol:my-2prose-ol:font-sans
prose-ul:mt-0 prose-ul:mb-3prose-ul:font-sans
prose-li:m-0prose-li:font-sans ${className}`}
>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
className={`prose prose-sm text-text-default dark:prose-invert w-full max-w-full word-break font-sans
prose-pre:p-0 prose-pre:m-0 !p-0
prose-code:break-all prose-code:whitespace-pre-wrap prose-code:font-sans
prose-table:table prose-table:w-full
prose-blockquote:text-inherit
prose-td:border prose-td:border-border-default prose-td:p-2
prose-th:border prose-th:border-border-default prose-th:p-2
prose-thead:bg-background-default
prose-h1:text-2xl prose-h1:font-normal prose-h1:mb-5 prose-h1:mt-0 prose-h1:font-sans
prose-h2:text-xl prose-h2:font-normal prose-h2:mb-4 prose-h2:mt-4 prose-h2:font-sans
prose-h3:text-lg prose-h3:font-normal prose-h3:mb-3 prose-h3:mt-3 prose-h3:font-sans
prose-p:mt-0 prose-p:mb-2 prose-p:font-sans
prose-ol:my-2 prose-ol:font-sans
prose-ul:mt-0 prose-ul:mb-3 prose-ul:font-sans
prose-li:m-0 prose-li:font-sans
${className}`}
components={{
a: ({ ...props }) => <a {...props} target="_blank" rel="noopener noreferrer" />,
code: MarkdownCode,
@@ -5,7 +5,7 @@ import { Copy } from './icons';
interface MessageCopyLinkProps {
text: string;
contentRef: React.RefObject<HTMLElement>;
contentRef: React.RefObject<HTMLDivElement | null>;
}
export default function MessageCopyLink({ text, contentRef }: MessageCopyLinkProps) {
@@ -115,9 +115,9 @@ export const ModelAndProviderProvider: React.FC<ModelAndProviderProviderProps> =
try {
model = (await read('GOOSE_MODEL', false)) as string;
provider = (await read('GOOSE_PROVIDER', false)) as string;
} catch (error) {
} catch {
console.error(`Failed to read GOOSE_MODEL or GOOSE_PROVIDER from config`);
throw error;
throw new Error('Failed to read GOOSE_MODEL or GOOSE_PROVIDER from config');
}
if (!model || !provider) {
console.log('[getCurrentModelAndProvider] Checking app environment as fallback');
@@ -136,7 +136,7 @@ export const ModelAndProviderProvider: React.FC<ModelAndProviderProviderProps> =
try {
metadata = await getProviderMetadata(String(gooseProvider), getProviders);
} catch (error) {
} catch {
return { model: gooseModel, provider: gooseProvider };
}
const providerDisplayName = metadata.display_name;
@@ -148,7 +148,7 @@ export const ModelAndProviderProvider: React.FC<ModelAndProviderProviderProps> =
try {
const currentModelName = (await read('GOOSE_MODEL', false)) as string;
return getModelDisplayName(currentModelName);
} catch (error) {
} catch {
return 'Select Model';
}
}, [read]);
@@ -163,7 +163,7 @@ export const ModelAndProviderProvider: React.FC<ModelAndProviderProviderProps> =
// Fall back to regular provider display name lookup
const { provider } = await getCurrentModelAndProviderForDisplay();
return provider;
} catch (error) {
} catch {
return '';
}
}, [read, getCurrentModelAndProviderForDisplay]);
@@ -173,8 +173,8 @@ export const ModelAndProviderProvider: React.FC<ModelAndProviderProviderProps> =
const { model, provider } = await getCurrentModelAndProvider();
setCurrentModel(model);
setCurrentProvider(provider);
} catch (error) {
console.error('Failed to refresh current model and provider:', error);
} catch (_error) {
console.error('Failed to refresh current model and provider:', _error);
}
}, [getCurrentModelAndProvider]);
@@ -75,7 +75,7 @@ export default function ProgressiveMessageList({
const contextManager = useChatContextManager();
hasContextHandlerContent = contextManager.hasContextHandlerContent;
getContextHandlerType = contextManager.getContextHandlerType;
} catch (error) {
} catch {
// Context manager not available (e.g., in session history view)
// This is fine, we'll just skip context handler functionality
hasContextHandlerContent = undefined;
@@ -88,7 +88,6 @@ export default function RecipesView({ _onLoadRecipe }: RecipesViewProps = {}) {
}, 50);
}, 300); // Show skeleton for at least 300ms
// eslint-disable-next-line no-undef
return () => clearTimeout(timer);
}
return () => void 0;
+2 -1
View File
@@ -13,7 +13,7 @@ interface UserMessageProps {
}
export default function UserMessage({ message }: UserMessageProps) {
const contentRef = useRef<HTMLDivElement>(null);
const contentRef = useRef<HTMLDivElement | null>(null);
// Extract text content from the message
const textContent = getTextContent(message);
@@ -63,6 +63,7 @@ export default function UserMessage({ message }: UserMessageProps) {
</div>
{/* TODO(alexhancock): Re-enable link previews once styled well again */}
{/* eslint-disable-next-line no-constant-binary-expression */}
{false && urls.length > 0 && (
<div className="flex flex-wrap mt-2">
{urls.map((url, index) => (
@@ -11,7 +11,7 @@ export const WaveformVisualizer: React.FC<WaveformVisualizerProps> = ({
isRecording,
}) => {
const canvasRef = useRef<HTMLCanvasElement>(null);
const animationRef = useRef<number>();
const animationRef = useRef<number | null>(null);
useEffect(() => {
if (!canvasRef.current || !analyser || !isRecording) return;
@@ -4,8 +4,6 @@ import { cn } from '../../utils';
import { Alert, AlertType } from '../alerts';
import { AlertBox } from '../alerts';
const { clearTimeout } = window;
interface AlertPopoverProps {
alerts: Alert[];
}
@@ -17,7 +15,7 @@ export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) {
const [popoverPosition, setPopoverPosition] = useState({ top: 0, left: 0 });
const [shouldShowIndicator, setShouldShowIndicator] = useState(false); // Stable indicator state
const previousAlertsRef = useRef<Alert[]>([]);
const hideTimerRef = useRef<ReturnType<typeof setTimeout>>();
const hideTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
const popoverRef = useRef<HTMLDivElement>(null);
@@ -113,7 +113,7 @@ export function CostTracker({ inputTokens = 0, outputTokens = 0, sessionCosts }:
}
setIsLoading(false);
}
} catch (error) {
} catch {
setHasAttemptedFetch(true);
// Only set pricing failed if we're not dealing with a known free provider
const freeProviders = ['ollama', 'local', 'localhost'];
@@ -20,7 +20,7 @@ interface SearchBarProps {
currentIndex: number;
};
/** Optional ref for the search input element */
inputRef?: React.RefObject<HTMLInputElement>;
inputRef?: React.RefObject<HTMLInputElement | null>;
/** Initial search term */
initialSearchTerm?: string;
}
@@ -41,7 +41,7 @@ export const SearchBar: React.FC<SearchBarProps> = ({
const [isExiting, setIsExiting] = useState(false);
const internalInputRef = React.useRef<HTMLInputElement>(null);
const inputRef = externalInputRef || internalInputRef;
const debouncedSearchRef = useRef<ReturnType<typeof debounce>>();
const debouncedSearchRef = useRef<ReturnType<typeof debounce> | null>(null);
// Create debounced search function
useEffect(() => {
@@ -44,7 +44,7 @@ export const SearchView: React.FC<PropsWithChildren<SearchViewProps>> = ({
count: number;
} | null>(null);
const searchInputRef = React.useRef<HTMLInputElement>(null);
const searchInputRef = useRef<HTMLInputElement | null>(null);
const highlighterRef = React.useRef<SearchHighlighter | null>(null);
const containerRef = React.useRef<SearchContainerElement | null>(null);
const lastSearchRef = React.useRef<{ term: string; caseSensitive: boolean }>({
@@ -1,6 +1,8 @@
// /Users/mnovich/Development/goose-1.0/ui/desktop/src/components/icons/TrashIcon.tsx
interface IconProps extends React.SVGProps<globalThis.SVGSVGElement> {}
interface IconProps {
className?: string;
}
export const TrashIcon: React.FC<IconProps> = (props) => (
<svg
+4 -3
View File
@@ -76,7 +76,8 @@ export default function Pair({
// Clear the location state to prevent re-processing
window.history.replaceState({}, '', '/pair');
}
}, [location.state, chat.id, setChat]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.state, chat.id]);
// Handle initial message from hub page
useEffect(() => {
@@ -117,7 +118,8 @@ export default function Pair({
window.history.replaceState({}, '', '/pair');
}
}
}, [location.state, hasProcessedInitialInput, initialMessage, chat, setChat]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.state, hasProcessedInitialInput, initialMessage]);
// Auto-submit the initial message after it's been set and component is ready
useEffect(() => {
@@ -153,7 +155,6 @@ export default function Pair({
}
}, 500); // Give more time for the component to fully mount
// eslint-disable-next-line no-undef
return () => clearTimeout(timer);
}
@@ -317,7 +317,7 @@ export const CreateScheduleModal: React.FC<CreateScheduleModalProps> = ({
'Invalid deep link format. Please use a goose://bot or goose://recipe link.'
);
}
} catch (error) {
} catch {
setParsedRecipe(null);
setInternalValidationError(
'Failed to parse deep link. Please ensure using a goose://bot or goose://recipe link and try again.'
@@ -395,7 +395,7 @@ export const CreateScheduleModal: React.FC<CreateScheduleModalProps> = ({
return `${dateObj.getMinutes()} ${dateObj.getHours()} ${dateObj.getDate()} ${
dateObj.getMonth() + 1
} *`;
} catch (e) {
} catch {
return "Error parsing date/time for 'once'.";
}
}
@@ -450,7 +450,7 @@ export const CreateScheduleModal: React.FC<CreateScheduleModalProps> = ({
} else {
setReadableCronExpression(cronstrue.toString(cron));
}
} catch (e) {
} catch {
setReadableCronExpression('Could not parse cron string.');
}
}, [
@@ -238,7 +238,7 @@ export const EditScheduleModal: React.FC<EditScheduleModalProps> = ({
return `${dateObj.getMinutes()} ${dateObj.getHours()} ${dateObj.getDate()} ${
dateObj.getMonth() + 1
} *`;
} catch (e) {
} catch {
return "Error parsing date/time for 'once'.";
}
}
@@ -293,7 +293,7 @@ export const EditScheduleModal: React.FC<EditScheduleModalProps> = ({
} else {
setReadableCronExpression(cronstrue.toString(cron));
}
} catch (e) {
} catch {
setReadableCronExpression('Could not parse cron string.');
}
}, [
@@ -251,7 +251,7 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
const actionButtons = showActionButtons ? (
<>
<Tooltip>
<TooltipTrigger>
<TooltipTrigger asChild>
<Button
onClick={handleShare}
disabled={!canShare || isSharing}
@@ -91,7 +91,7 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
} else {
setPricingStatus('error');
}
} catch (error) {
} catch {
setPricingStatus('error');
}
};
@@ -121,7 +121,7 @@ export default function AppSettingsSection({ scrollToSection }: AppSettingsSecti
} else {
setPricingStatus('error');
}
} catch (error) {
} catch {
setPricingStatus('error');
} finally {
setIsRefreshing(false);
@@ -37,7 +37,7 @@ export default function ExtensionItem({
// Call the actual toggle function that performs the async operation
await onToggle(ext);
// Success case is handled by the useEffect below when extension.enabled changes
} catch (error) {
} catch {
// If there was an error, revert the visual state
console.log('Toggle failed, reverting visual state');
setVisuallyEnabled(!newState);
@@ -22,7 +22,7 @@ import { toastSuccess, toastError } from '../../../../toasts';
import ViewRecipeModal from '../../../ViewRecipeModal';
interface ModelsBottomBarProps {
dropdownRef: React.RefObject<HTMLDivElement>;
dropdownRef: React.RefObject<HTMLDivElement | null>;
setView: (view: View) => void;
alerts: Alert[];
recipeConfig?: Recipe | null;
+3 -3
View File
@@ -48,10 +48,10 @@ const checkServerStatus = async (
log.info(`Server is ready after ${attempt} attempts`);
return true;
}
} catch (error) {
} catch {
// Expected error when server isn't ready yet
if (attempt === maxAttempts) {
log.error(`Server failed to respond after ${maxAttempts} attempts:`, error);
log.error(`Server failed to respond after ${maxAttempts} attempts`);
}
}
await new Promise((resolve) => setTimeout(resolve, interval));
@@ -123,7 +123,7 @@ export const startGoosed = async (
log.warn(`Provided path is not a directory, falling back to home directory`);
dir = homeDir;
}
} catch (error) {
} catch {
log.warn(`Directory does not exist, falling back to home directory`);
dir = homeDir;
}
+2 -2
View File
@@ -27,8 +27,8 @@ export const useCostTracking = ({
}>({});
const { currentModel, currentProvider } = useModelAndProvider();
const prevModelRef = useRef<string | undefined>();
const prevProviderRef = useRef<string | undefined>();
const prevModelRef = useRef<string | undefined>(undefined);
const prevProviderRef = useRef<string | undefined>(undefined);
// Handle model changes and accumulate costs
useEffect(() => {
+1 -1
View File
@@ -24,7 +24,7 @@ export const useFileDrop = () => {
readers.forEach((reader) => {
try {
reader.abort();
} catch (error) {
} catch {
// Reader might already be done, ignore errors
}
});
+1 -1
View File
@@ -545,7 +545,7 @@ export function useMessageStream({
}
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[api, processMessageStream, mutateChatState, setError, onResponse, onError, maxSteps]
);
+41 -39
View File
@@ -4,7 +4,6 @@ import {
App,
BrowserWindow,
dialog,
Event,
globalShortcut,
ipcMain,
Menu,
@@ -16,7 +15,6 @@ import {
Tray,
} from 'electron';
import { Buffer } from 'node:buffer';
import { MouseUpEvent } from './types/electron';
import fs from 'node:fs/promises';
import fsSync from 'node:fs';
import started from 'electron-squirrel-startup';
@@ -74,8 +72,8 @@ async function decodeRecipeMain(deeplink: string, port: number): Promise<Recipe
const data = await response.json();
return data.recipe;
}
} catch (error) {
console.error('Failed to decode recipe:', error);
} catch {
console.error('Failed to decode recipe');
}
return null;
}
@@ -177,8 +175,8 @@ if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
detached: true,
stdio: 'ignore',
});
} catch (error) {
console.warn('[Main] Could not reset protocol handler:', error);
} catch {
console.warn('[Main] Could not reset protocol handler');
}
}
} else {
@@ -385,13 +383,17 @@ app.on('open-file', async (event, filePath) => {
await handleFileOpen(filePath);
});
// Handle multiple files/folders
app.on('open-files', async (event: Event, filePaths: string[]) => {
event.preventDefault();
for (const filePath of filePaths) {
await handleFileOpen(filePath);
}
});
// Handle multiple files/folders (macOS only)
if (process.platform === 'darwin') {
// Use type assertion for non-standard Electron event
// eslint-disable-next-line @typescript-eslint/no-explicit-any
app.on('open-files' as any, async (event: any, filePaths: string[]) => {
event.preventDefault();
for (const filePath of filePaths) {
await handleFileOpen(filePath);
}
});
}
async function handleFileOpen(filePath: string) {
try {
@@ -419,8 +421,8 @@ async function handleFileOpen(filePath: string) {
newWindow.focus();
newWindow.moveTop();
}
} catch (error) {
console.error('Failed to handle file open:', error);
} catch {
console.error('Failed to handle file open');
// Show user-friendly error notification
new Notification({
@@ -710,7 +712,9 @@ const createChat = async (
});
// Handle new-window events (alternative approach for external links)
mainWindow.webContents.on('new-window', (event, url) => {
// Use type assertion for non-standard Electron event
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mainWindow.webContents.on('new-window' as any, function (event: any, url: string) {
event.preventDefault();
shell.openExternal(url);
});
@@ -773,7 +777,10 @@ const createChat = async (
}
});
mainWindow.webContents.on('mouse-up', (_event: MouseUpEvent, mouseButton: number) => {
// Handle mouse back button (button 3)
// Use type assertion for non-standard Electron event
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mainWindow.webContents.on('mouse-up' as any, function (_event: any, mouseButton: number) {
// MouseButton 3 is the back button.
if (mouseButton === 3) {
mainWindow.webContents.send('mouse-back-button-clicked');
@@ -1020,7 +1027,7 @@ const openDirectoryDialog = async (
} else if (stats.isFile()) {
dirToAdd = path.dirname(selectedPath);
}
} catch (error) {
} catch {
console.warn(`Could not stat selected path, using parent directory`);
dirToAdd = path.dirname(selectedPath); // Fallback to parent directory
}
@@ -1176,11 +1183,11 @@ ipcMain.handle('set-dock-icon', async (_event, show: boolean) => {
saveSettings(settings);
if (show) {
await app.dock.show();
app.dock?.show();
} else {
// Only hide the dock if we have a menu bar icon to maintain accessibility
if (settings.showMenuBarIcon) {
app.dock.hide();
app.dock?.hide();
setTimeout(() => {
focusWindow();
}, 50);
@@ -1220,7 +1227,7 @@ ipcMain.handle('open-notifications-settings', async () => {
try {
spawn('gnome-control-center', ['notifications']);
return true;
} catch (gnomeError) {
} catch {
console.log('GNOME control center not found, trying other options');
}
@@ -1228,7 +1235,7 @@ ipcMain.handle('open-notifications-settings', async () => {
try {
spawn('systemsettings5', ['kcm_notifications']);
return true;
} catch (kdeError) {
} catch {
console.log('KDE systemsettings5 not found, trying other options');
}
@@ -1236,7 +1243,7 @@ ipcMain.handle('open-notifications-settings', async () => {
try {
spawn('xfce4-settings-manager', ['--socket-id=notifications']);
return true;
} catch (xfceError) {
} catch {
console.log('XFCE settings manager not found, trying other options');
}
@@ -1244,7 +1251,7 @@ ipcMain.handle('open-notifications-settings', async () => {
try {
spawn('gnome-control-center');
return true;
} catch (fallbackError) {
} catch {
console.warn('Could not find a suitable settings application for Linux');
return false;
}
@@ -1344,6 +1351,7 @@ ipcMain.handle('select-file-or-directory', async (_event, defaultPath?: string)
} else {
dialogOptions.defaultPath = path.dirname(expandedPath);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
// If path doesn't exist, fall back to home directory and log error
console.error(`Default path does not exist: ${expandedPath}, falling back to home directory`);
@@ -1651,22 +1659,16 @@ ipcMain.handle('read-file', (_event, filePath) => {
});
});
ipcMain.handle('write-file', (_event, filePath, content) => {
return new Promise((resolve) => {
ipcMain.handle('write-file', async (_event, filePath, content) => {
try {
// Expand tilde to home directory
const expandedPath = expandTilde(filePath);
// Create a write stream to the file
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fsNode = require('fs'); // Using require for fs in this specific handler from original
try {
fsNode.writeFileSync(expandedPath, content, { encoding: 'utf8' });
resolve(true);
} catch (error) {
console.error('Error writing to file:', error);
resolve(false);
}
});
await fs.writeFile(expandedPath, content, { encoding: 'utf8' });
return true;
} catch (error) {
console.error('Error writing to file:', error);
return false;
}
});
// Enhanced file operations
@@ -1820,7 +1822,7 @@ app.whenReady().then(async () => {
// Handle dock icon visibility (macOS only)
if (process.platform === 'darwin' && !settings.showDockIcon && settings.showMenuBarIcon) {
app.dock.hide();
app.dock?.hide();
}
// Parse command line arguments
+2 -2
View File
@@ -201,7 +201,7 @@ export async function fetchAndCachePricing(
// Model not found in pricing data
return { costInfo: null, error: 'model_not_found' };
}
} catch (error) {
} catch {
// This is a real API/network error
return null;
}
@@ -231,7 +231,7 @@ export async function refreshPricing(): Promise<boolean> {
});
return response.ok;
} catch (error) {
} catch {
return false;
}
}
-1
View File
@@ -165,7 +165,6 @@ export class GitHubUpdater {
const chunks: Uint8Array[] = [];
let downloadedSize = 0;
// eslint-disable-next-line no-constant-condition
while (true) {
const { done, value } = await reader.read();
if (done) break;
+1 -1
View File
@@ -156,7 +156,7 @@ export async function pullOllamaModel(
if (onProgress) {
onProgress(progress);
}
} catch (e) {
} catch {
// Ignore parse errors
}
}
+2 -2
View File
@@ -30,7 +30,7 @@ export function loadRecentDirs(): string[] {
}
return stats.isDirectory();
} catch (error) {
} catch {
// Directory doesn't exist or can't be accessed - don't log full path for security
console.warn(`Removing inaccessible recent directory`);
return false;
@@ -66,7 +66,7 @@ export function addRecentDir(dir: string): void {
console.warn(`Cannot add recent directory: not a directory`);
return;
}
} catch (error) {
} catch {
console.warn(`Cannot add recent directory: path does not exist or cannot be accessed`);
return;
}
-7
View File
@@ -45,13 +45,6 @@ declare module '*.md?raw' {
export default value;
}
// Extend CSS properties to include Electron-specific properties
declare namespace React {
interface CSSProperties {
WebkitAppRegion?: 'drag' | 'no-drag';
}
}
// Extend Window interface to include global recipe creation flag
declare global {
interface Window {
+2 -2
View File
@@ -20,8 +20,8 @@
"noFallthroughCasesInSwitch": true,
/* Electron/Node.js specific */
"types": ["node", "electron"],
"typeRoots": ["./node_modules/@types", "./src/types"],
"types": ["node"],
"typeRoots": ["./node_modules/@types", "./src/types", "./node_modules/electron"],
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
+2 -1
View File
@@ -6,7 +6,8 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"types": ["node", "electron"],
"types": ["node"],
"typeRoots": ["./node_modules/@types", "./node_modules/electron"],
"target": "ES2020",
"esModuleInterop": true,
"resolveJsonModule": true,