Agent extension api (#5281)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -11,3 +11,13 @@ export async function safeJsonParse<T>(
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function errorMessage(err: Error | unknown, default_value?: string) {
|
||||
if (err instanceof Error) {
|
||||
return err.message;
|
||||
} else if (typeof err === 'object' && err !== null && 'message' in err) {
|
||||
return String(err.message);
|
||||
} else {
|
||||
return default_value || String(err);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Import the proper type from ConfigContext
|
||||
import { getApiUrl } from '../config';
|
||||
import { safeJsonParse } from './jsonUtils';
|
||||
import { safeJsonParse } from './conversionUtils';
|
||||
|
||||
export interface ModelCostInfo {
|
||||
input_token_cost: number; // Cost per token for input (in USD)
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import log from './logger';
|
||||
import { safeJsonParse } from './jsonUtils';
|
||||
import { safeJsonParse } from './conversionUtils';
|
||||
|
||||
interface GitHubRelease {
|
||||
tag_name: string;
|
||||
|
||||
Reference in New Issue
Block a user