Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions __tests__/integration/agents.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from "node-fetch";

export const BASE_URL = process.env.DEPLOYMENT_URL
? process.env.DEPLOYMENT_URL
: "http://localhost:3000";
Expand Down
1 change: 0 additions & 1 deletion __tests__/integration/tools.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'node-fetch';
import { BASE_URL } from './agents.test';

beforeEach(async () => {
Expand Down
19 changes: 0 additions & 19 deletions app/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import dotenv from 'dotenv';
import ftsMetadata from '@/app/data/fts.json';
import { isNearNetworkId, NearNetworkId } from '@/lib/types';

dotenv.config();

Expand All @@ -19,21 +17,4 @@ export const OPENAI_API_KEY = getMandatoryEnv('OPENAI_API_KEY');///
export const ANTHROPIC_API_KEY = getMandatoryEnv('ANTHROPIC_API_KEY');///
export const XAI_API_KEY = getMandatoryEnv('XAI_API_KEY');///

export const NEAR_RPC_URL = getMandatoryEnv('NEAR_RPC_URL');//?
export const NEAR_NETWORK_ID = ((): NearNetworkId => {
const id = getMandatoryEnv('NEAR_NETWORK_ID');//?
if (!isNearNetworkId(id))
throw new Error('NEAR_NETWORK_ID needs to be `testnet` or `mainnet`');
return id;
})();

export const PIMLICO_KEY = getMandatoryEnv('PIMLICO_KEY');

export const UNKEY_API_ID = getMandatoryEnv('UNKEY_API_ID');

export const IS_TESTNET = NEAR_NETWORK_ID === 'testnet';
export const BITTE_WALLET = 'wallet.bitte.ai';
export const BITTE_WALLET_URL = IS_TESTNET
? `https://testnet.${BITTE_WALLET}`
: `https://${BITTE_WALLET}`;
export const FTS_METADATA = ftsMetadata;
476 changes: 0 additions & 476 deletions app/data/fts.json

This file was deleted.

1 change: 0 additions & 1 deletion jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { jest } from '@jest/globals';
import fetch from 'node-fetch';

// Set default timeout for all tests (useful for integration tests that make real HTTP calls)
jest.setTimeout(30000);
Expand Down
75 changes: 0 additions & 75 deletions lib/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { OpenAI } from 'openai';
import { DEFAULT_MODEL } from '@/lib/constants';
import type {
BitteAssistantConfig,
BitteMetadata,
BitteOpenAPISpec,
BitteToolExecutor,
PluginToolSpec,
} from '@/lib/types';
import { errorString } from './error';
Expand Down Expand Up @@ -175,79 +173,6 @@ export const generateAssistantFromOpenAPISpec = async ({
return assistantObject;
};

export const createExecutor = (
tool: PluginToolSpec,
metadata?: BitteMetadata
): BitteToolExecutor => {
return async (args) => {
try {
const { baseUrl, path, httpMethod } = tool.execution;
const fullBaseUrl = baseUrl.startsWith('http')
? baseUrl
: `https://${baseUrl}`;

// Build URL with path parameters
let url = `${fullBaseUrl}${path}`;
const remainingArgs = { ...args };

url = url.replace(/\{(\w+)\}/g, (_, key) => {
if (remainingArgs[key] === undefined) {
throw new Error(`Missing required path parameter: ${key}`);
}
const value = remainingArgs[key];
delete remainingArgs[key];
return encodeURIComponent(String(value));
});

// Setup request
const headers: HeadersInit = {
...(metadata && { 'mb-metadata': JSON.stringify(metadata) }),
};

const method = httpMethod.toUpperCase();
const fetchOptions: RequestInit = { method, headers };

// Handle query parameters
const queryParams = new URLSearchParams();
Object.entries(remainingArgs)
.filter(([_key, value]) => value != null)
.forEach(([key, value]) => queryParams.append(key, String(value)));

const queryString = queryParams.toString();
if (queryString) {
url += (url.includes('?') ? '&' : '?') + queryString;
}

// Handle request body
if (['POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'].includes(method)) {
headers['Content-Type'] = 'application/json';
fetchOptions.body = JSON.stringify(remainingArgs);
}

// Execute request
const response = await fetch(url, fetchOptions);

if (!response.ok) {
throw new Error(
`HTTP error during plugin tool execution: ${response.status} ${response.statusText}`
);
}
// Parse response based on content type
const contentType = response.headers.get('Content-Type') || '';
const data = await (contentType.includes('application/json')
? response.json()
: contentType.includes('text')
? response.text()
: response.blob());

return { data };
} catch (error) {
return { error: errorString(error) };
}
};
};

// converts pluginUrl to pluginId
export const processPluginId = (
urlParam: string | null
): { pluginId?: string; error?: string } => {
Expand Down
175 changes: 0 additions & 175 deletions lib/portfolio.ts

This file was deleted.

Loading