Skip to content

Commit

Permalink
feat: update types with BE and release rc for v0.5 (#1082)
Browse files Browse the repository at this point in the history
Co-authored-by: Apoorv Taneja <purutaneja.com@gmail.com>
  • Loading branch information
himanshu-dixit and plxity authored Dec 27, 2024
1 parent 563d2af commit 0378f58
Show file tree
Hide file tree
Showing 53 changed files with 3,840 additions and 1,499 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Install Dependencies
run: |
pnpm install @ai-sdk/openai ai composio-core dotenv zod
pnpm install @ai-sdk/openai ai composio-core dotenv zod @langchain/openai @langchain/core langchain
- name: Run Tests
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion js/examples/market_research_agent/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lead-outreach-agent",
"name": "market-research-agent",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion js/examples/meeting_brief_agent/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/examples/newsletter_twitter_threads/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lead-generator-agent",
"name": "newsletter-twitter-threads",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion js/examples/scheduling-agent/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vercel",
"name": "scheduling-agent",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion js/examples/vercel/nextjs-vercel-demo/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vercel",
"name": "nextjs-vercel-demo",
"version": "0.1.0",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion js/package.dist.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "composio-core",
"version": "0.4.4-beta",
"version": "0.5.0-rc.1",
"description": "",
"main": "index.js",
"scripts": {},
Expand Down
4 changes: 2 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "composio-core",
"version": "0.5.0-rc",
"version": "0.5.0-rc.1",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"run:sample": "ts-node sample.ts",
"prettier": "prettier --write 'src/**/*.{ts,js,cjs}'",
"prettier:check": "prettier --check 'src/**/*.{ts,js,mjs,cjs}'",
"build": "rollup -c rollup.config.mjs && ./setup_cli.sh",
"build": "rollup -c rollup.config.mjs && ./bundle_package.sh",
"lint": "eslint 'src/**/*.{ts,js}' --ignore-pattern 'src/sdk/client/**'",
"format": "pnpm lint && pnpm prettier"
},
Expand Down
6 changes: 4 additions & 2 deletions js/src/cli/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import chalk from "chalk";
import { Command } from "commander";
import inquirer from "inquirer";
import open from "open";
import { z } from "zod";
import { Composio } from "../sdk";
import { GetConnectorInfoResDTO, GetConnectorListResDTO } from "../sdk/client";
import { ZAuthMode } from "../sdk/types/integration";

type TInputField = {
name: string;
Expand Down Expand Up @@ -348,7 +350,7 @@ export default class AddCommand {

const integration = await composioClient.integrations.create({
appId: app.appId as string,
authScheme: authMode,
authScheme: authMode as unknown as z.infer<typeof ZAuthMode>,
useComposioAuth: false,
name: integrationName,
authConfig,
Expand Down Expand Up @@ -435,7 +437,7 @@ export default class AddCommand {
const composioClient = new Composio({});
const integration = await composioClient.integrations.create({
appId: app.appId,
authScheme: authMode,
authScheme: authMode as unknown as z.infer<typeof ZAuthMode>,
useComposioAuth,
name,
authConfig: config,
Expand Down
4 changes: 2 additions & 2 deletions js/src/cli/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export default class ConnectionsCommand {

private async handleAction(options: { active: boolean }): Promise<void> {
getOpenAPIClient();
const { data, error } = await client.connections.getConnections({
const { data, error } = await client.connections.listConnections({
query: options.active ? { status: "ACTIVE" } : {},
throwOnError: false,
});

if (error) {
console.log(chalk.red((error as Error).message));
console.log(chalk.red(error.message));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/frameworks/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { ComposioToolSet as BaseComposioToolSet } from "../sdk/base.toolset";
import { COMPOSIO_BASE_URL } from "../sdk/client/core/OpenAPI";
import { TELEMETRY_LOGGER } from "../sdk/utils/telemetry";
import { TELEMETRY_EVENTS } from "../sdk/utils/telemetry/events";
import { Optional, Sequence } from "../types/base";
import { ZToolSchemaFilter } from "../types/base_toolset";
import { Optional, Sequence } from "../types/util";

/**
* CloudflareToolSet provides integration with Cloudflare Workers AI
Expand Down
25 changes: 13 additions & 12 deletions js/src/frameworks/langchain.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { beforeAll, describe, expect, it } from "@jest/globals";
import { z } from "zod";
import { getTestConfig } from "../../config/getTestConfig";
import { ActionExecuteResponse } from "../sdk/models/actions";
import { LangchainToolSet } from "./langchain";

describe("Apps class tests", () => {
Expand Down Expand Up @@ -45,17 +46,17 @@ describe("Apps class tests", () => {
owner: z.string(),
repo: z.string(),
}),
callback: async (inputParams, authCredentials, executeRequest) => {
try {
const res = await executeRequest({
endpoint: `/user/starred/${inputParams.owner}/${inputParams.repo}`,
method: "PUT",
parameters: [],
});
return res;
} catch (_e) {
return {};
}
callback: async (
inputParams,
_authCredentials,
executeRequest
): Promise<ActionExecuteResponse> => {
const res = await executeRequest({
endpoint: `/user/starred/${inputParams.owner}/${inputParams.repo}`,
method: "PUT",
parameters: [],
});
return res;
},
});

Expand All @@ -69,6 +70,6 @@ describe("Apps class tests", () => {
connectedAccountId: "9442cab3-d54f-4903-976c-ee67ef506c9b",
});

expect(actionOuput).toHaveProperty("successfull", true);
expect(actionOuput).toHaveProperty("successful", true);
});
});
3 changes: 2 additions & 1 deletion js/src/frameworks/langchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { ComposioToolSet as BaseComposioToolSet } from "../sdk/base.toolset";
import { COMPOSIO_BASE_URL } from "../sdk/client/core/OpenAPI";
import { TELEMETRY_LOGGER } from "../sdk/utils/telemetry";
import { TELEMETRY_EVENTS } from "../sdk/utils/telemetry/events";
import type { Optional, Sequence } from "../types/base";
import { ZToolSchemaFilter } from "../types/base_toolset";
import type { Optional, Sequence } from "../types/util";
import { jsonSchemaToModel } from "../utils/shared";

type ToolSchema = {
name: string;
description: string;
Expand Down
2 changes: 1 addition & 1 deletion js/src/frameworks/langgraph.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { COMPOSIO_BASE_URL } from "../sdk/client/core/OpenAPI";
import type { Optional } from "../types/base";
import type { Optional } from "../types/util";
import { LangchainToolSet as BaseComposioToolSet } from "./langchain";

export class LangGraphToolSet extends BaseComposioToolSet {
Expand Down
2 changes: 1 addition & 1 deletion js/src/frameworks/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { TELEMETRY_LOGGER } from "../sdk/utils/telemetry";
import { TELEMETRY_EVENTS } from "../sdk/utils/telemetry/events";
import logger from "../utils/logger";

import { Optional, Sequence } from "../types/base";
import { ZToolSchemaFilter } from "../types/base_toolset";
import { Optional, Sequence } from "../types/util";

export class OpenAIToolSet extends BaseComposioToolSet {
static FRAMEWORK_NAME = "openai";
Expand Down
6 changes: 3 additions & 3 deletions js/src/frameworks/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from "zod";
import { ComposioToolSet as BaseComposioToolSet } from "../sdk/base.toolset";
import { TELEMETRY_LOGGER } from "../sdk/utils/telemetry";
import { TELEMETRY_EVENTS } from "../sdk/utils/telemetry/events";
import { TRawActionData } from "../types/base_toolset";
import { RawActionData } from "../types/base_toolset";
import { jsonSchemaToModel } from "../utils/shared";
type Optional<T> = T | null;

Expand Down Expand Up @@ -37,7 +37,7 @@ export class VercelAIToolSet extends BaseComposioToolSet {
);
}

private generateVercelTool(schema: TRawActionData) {
private generateVercelTool(schema: RawActionData) {
const parameters = jsonSchemaToModel(schema.parameters);
return tool({
description: schema.description,
Expand All @@ -62,7 +62,7 @@ export class VercelAIToolSet extends BaseComposioToolSet {
useCase?: Optional<string>;
usecaseLimit?: Optional<number>;
filterByAvailableApps?: Optional<boolean>;
}): Promise<{ [key: string]: TRawActionData }> {
}): Promise<{ [key: string]: RawActionData }> {
TELEMETRY_LOGGER.manualTelemetry(TELEMETRY_EVENTS.SDK_METHOD_INVOKED, {
method: "getTools",
file: this.fileName,
Expand Down
8 changes: 8 additions & 0 deletions js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ import { OpenAIToolSet } from "./frameworks/openai";
import { VercelAIToolSet } from "./frameworks/vercel";
import { Composio } from "./sdk/index";
import { ConnectionRequest } from "./sdk/models/connectedAccounts";
import { ComposioError } from "./sdk/utils/errors/src/composioError";
import { COMPOSIO_SDK_ERROR_CODES } from "./sdk/utils/errors/src/constants";
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { APPS, ACTIONS } = require("./constants");

export {
// Constants
ACTIONS,
APPS,
COMPOSIO_SDK_ERROR_CODES,
// Frameworks
CloudflareToolSet,
// SDK
Composio,
// Classes
ComposioError,
ConnectionRequest,
LangGraphToolSet,
LangchainToolSet,
Expand Down
10 changes: 5 additions & 5 deletions js/src/sdk/actionRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("ActionRegistry", () => {
});

const callback = async (_params: Record<string, unknown>) => {
return { success: true };
return { data: { success: true }, successful: true };
};

const options = {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("ActionRegistry", () => {
description: "This is a test action",
inputParams: params,
callback: async function () {
return { success: true };
return { data: { success: true }, successful: true };
},
};

Expand All @@ -91,7 +91,7 @@ describe("ActionRegistry", () => {
});

const callback = async (_params: Record<string, unknown>) => {
return { success: true };
return { data: { success: true }, successful: true };
};

const options = {
Expand All @@ -109,7 +109,7 @@ describe("ActionRegistry", () => {
{}
);

expect(result).toEqual({ success: true });
expect(result).toEqual({ data: { success: true }, successful: true });
});

it("should throw an error if action does not exist", async () => {
Expand All @@ -124,7 +124,7 @@ describe("ActionRegistry", () => {
});

const callback = async (_params: Record<string, unknown>) => {
return { success: true };
return { data: { success: true }, successful: true };
};

const options = {
Expand Down
Loading

0 comments on commit 0378f58

Please sign in to comment.