@composio/core 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +244 -204
- package/dist/index.d.cts +489 -377
- package/dist/index.d.ts +489 -377
- package/dist/index.js +243 -202
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -28,6 +28,9 @@ var JSONSchemaProperty = z.object({
|
|
|
28
28
|
type: JSONSchemaType.optional(),
|
|
29
29
|
description: z.string().optional(),
|
|
30
30
|
anyOf: z.lazy(() => z.array(JSONSchemaProperty)).optional(),
|
|
31
|
+
oneOf: z.lazy(() => z.array(JSONSchemaProperty)).optional(),
|
|
32
|
+
allOf: z.lazy(() => z.array(JSONSchemaProperty)).optional(),
|
|
33
|
+
not: z.lazy(() => JSONSchemaProperty).optional(),
|
|
31
34
|
title: z.string().optional(),
|
|
32
35
|
default: z.any().optional(),
|
|
33
36
|
properties: z.lazy(() => z.record(z.string(), JSONSchemaProperty)).optional(),
|
|
@@ -37,6 +40,9 @@ var JSONSchemaProperty = z.object({
|
|
|
37
40
|
var ParametersSchema = z.object({
|
|
38
41
|
type: z.literal("object"),
|
|
39
42
|
anyOf: z.array(JSONSchemaProperty).optional(),
|
|
43
|
+
oneOf: z.array(JSONSchemaProperty).optional(),
|
|
44
|
+
allOf: z.array(JSONSchemaProperty).optional(),
|
|
45
|
+
not: JSONSchemaProperty.optional(),
|
|
40
46
|
properties: z.record(z.string(), JSONSchemaProperty),
|
|
41
47
|
required: z.array(z.string()).optional(),
|
|
42
48
|
title: z.string().optional(),
|
|
@@ -581,13 +587,6 @@ var TELEMETRY_EVENTS = {
|
|
|
581
587
|
CLI_INVOKED: "CLI_INVOKED"
|
|
582
588
|
};
|
|
583
589
|
|
|
584
|
-
// src/utils/constants.ts
|
|
585
|
-
var COMPOSIO_DIR = ".composio";
|
|
586
|
-
var USER_DATA_FILE_NAME = "user_data.json";
|
|
587
|
-
var DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
588
|
-
var TELEMETRY_URL = "https://app.composio.dev";
|
|
589
|
-
var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
|
|
590
|
-
|
|
591
590
|
// src/telemetry/BatchProcessor.ts
|
|
592
591
|
var BatchProcessor = class {
|
|
593
592
|
batch = [];
|
|
@@ -621,126 +620,78 @@ var BatchProcessor = class {
|
|
|
621
620
|
}
|
|
622
621
|
};
|
|
623
622
|
|
|
624
|
-
// src/telemetry/transports/BrowserTransport.ts
|
|
625
|
-
var BrowserTelemetryTransport = class {
|
|
626
|
-
send(payload) {
|
|
627
|
-
if (typeof window === "undefined") {
|
|
628
|
-
return Promise.reject(
|
|
629
|
-
new Error("BrowserTelemetryTransport can only be used in browser environments")
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
return new Promise((resolve) => {
|
|
633
|
-
try {
|
|
634
|
-
const xhr = new XMLHttpRequest();
|
|
635
|
-
xhr.open(payload.method, payload.url, true);
|
|
636
|
-
xhr.setRequestHeader("Content-Type", "application/json");
|
|
637
|
-
Object.entries(payload.headers || {}).forEach(([key, value]) => {
|
|
638
|
-
xhr.setRequestHeader(key, value);
|
|
639
|
-
});
|
|
640
|
-
xhr.onload = function() {
|
|
641
|
-
resolve();
|
|
642
|
-
};
|
|
643
|
-
xhr.send(JSON.stringify(payload.data));
|
|
644
|
-
} catch (error) {
|
|
645
|
-
logger_default.error("Error sending error to telemetry", error);
|
|
646
|
-
resolve();
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
// src/telemetry/transports/ProcessTransport.ts
|
|
653
|
-
import chalk3 from "chalk";
|
|
654
|
-
var ProcessTelemetryTransport = class {
|
|
655
|
-
send(payload) {
|
|
656
|
-
if (typeof window !== "undefined") {
|
|
657
|
-
return Promise.reject(
|
|
658
|
-
new Error("ProcessTelemetryTransport can only be used in Node.js environments")
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
return new Promise((resolve) => {
|
|
662
|
-
try {
|
|
663
|
-
const url = new URL(payload.url);
|
|
664
|
-
const protocol = url.protocol === "https:" ? "https" : "http";
|
|
665
|
-
const port = url.port || (url.protocol === "https:" ? 443 : 80);
|
|
666
|
-
const args = [
|
|
667
|
-
"-e",
|
|
668
|
-
`
|
|
669
|
-
const http = require('${protocol}');
|
|
670
|
-
const options = {
|
|
671
|
-
hostname: '${url.hostname}',
|
|
672
|
-
path: '${url.pathname}${url.search}',
|
|
673
|
-
port: ${port},
|
|
674
|
-
method: '${payload.method}',
|
|
675
|
-
headers: ${JSON.stringify(payload.headers)}
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
const req = http.request(options, (res) => {
|
|
679
|
-
res.on('data', () => {});
|
|
680
|
-
res.on('end', () => {
|
|
681
|
-
process.exit(0);
|
|
682
|
-
});
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
req.on('error', () => {
|
|
686
|
-
process.exit(0);
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
req.write(JSON.stringify(${JSON.stringify(payload.data)}));
|
|
690
|
-
req.end();
|
|
691
|
-
`
|
|
692
|
-
];
|
|
693
|
-
import("child_process").then(({ spawn }) => {
|
|
694
|
-
spawn("node", args, {
|
|
695
|
-
stdio: "ignore",
|
|
696
|
-
detached: false,
|
|
697
|
-
shell: false
|
|
698
|
-
}).unref();
|
|
699
|
-
resolve();
|
|
700
|
-
}).catch((error) => {
|
|
701
|
-
logger_default.error("Error sending telemetry", error);
|
|
702
|
-
resolve();
|
|
703
|
-
});
|
|
704
|
-
logger_default.debug(chalk3.yellow("Process Telemetry"), JSON.stringify(payload, null, 2));
|
|
705
|
-
} catch (error) {
|
|
706
|
-
logger_default.error("Error sending telemetry", error);
|
|
707
|
-
resolve();
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
|
|
713
623
|
// src/utils/uuid.ts
|
|
714
624
|
import { v4 as uuidv4 } from "uuid";
|
|
715
625
|
function getRandomUUID() {
|
|
716
626
|
return uuidv4();
|
|
717
627
|
}
|
|
718
628
|
|
|
719
|
-
// src/telemetry/
|
|
629
|
+
// src/services/telemetry/TelemetryService.ts
|
|
630
|
+
var TELEMETRY_URL = "https://telemetry.composio.dev/v1";
|
|
720
631
|
var TelemetryService = class {
|
|
632
|
+
/**
|
|
633
|
+
* Sends a metric to the Telemetry API.
|
|
634
|
+
* @param payload - The payload to send to the Telemetry API.
|
|
635
|
+
* @returns The response from the Telemetry API.
|
|
636
|
+
*/
|
|
637
|
+
static async sendMetric(payload) {
|
|
638
|
+
return fetch(`${TELEMETRY_URL}/metrics/invocations`, {
|
|
639
|
+
method: "POST",
|
|
640
|
+
headers: {
|
|
641
|
+
"Content-Type": "application/json"
|
|
642
|
+
},
|
|
643
|
+
body: JSON.stringify(payload)
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Sends an error log to the Telemetry API.
|
|
648
|
+
* @param payload - The payload to send to the Telemetry API.
|
|
649
|
+
* @returns The response from the Telemetry API.
|
|
650
|
+
*/
|
|
651
|
+
static async sendErrorLog(payload) {
|
|
652
|
+
return fetch(`${TELEMETRY_URL}/errors`, {
|
|
653
|
+
method: "POST",
|
|
654
|
+
headers: {
|
|
655
|
+
"Content-Type": "application/json"
|
|
656
|
+
},
|
|
657
|
+
body: JSON.stringify(payload)
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// src/telemetry/Telemetry.ts
|
|
663
|
+
var TelemetryTransport = class {
|
|
721
664
|
telemetryMetadata;
|
|
722
|
-
transport;
|
|
723
665
|
isTelemetryDisabled = true;
|
|
724
|
-
|
|
725
|
-
|
|
666
|
+
telemetrySource;
|
|
667
|
+
telemetrySourceName = "typescript-sdk";
|
|
668
|
+
telemetryServiceName = "sdk";
|
|
669
|
+
telemetryLanguage = "typescript";
|
|
670
|
+
batchProcessor = new BatchProcessor(200, 10, async (data) => {
|
|
671
|
+
logger_default.debug("Sending batch of telemetry metrics", data);
|
|
672
|
+
await TelemetryService.sendMetric(data);
|
|
726
673
|
});
|
|
727
|
-
setup(metadata
|
|
674
|
+
setup(metadata) {
|
|
728
675
|
this.telemetryMetadata = metadata;
|
|
729
676
|
this.isTelemetryDisabled = false;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
this.
|
|
733
|
-
|
|
734
|
-
this.
|
|
735
|
-
this.telemetryMetadata
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
this.telemetryMetadata.transport = "process";
|
|
739
|
-
}
|
|
740
|
-
this.sendTelemetry([
|
|
677
|
+
this.telemetrySource = {
|
|
678
|
+
name: this.telemetrySourceName,
|
|
679
|
+
service: this.telemetryServiceName,
|
|
680
|
+
language: this.telemetryLanguage,
|
|
681
|
+
version: this.telemetryMetadata?.version,
|
|
682
|
+
platform: this.telemetryMetadata?.isBrowser ? "browser" : "node"
|
|
683
|
+
};
|
|
684
|
+
this.sendMetric([
|
|
741
685
|
{
|
|
742
|
-
|
|
743
|
-
|
|
686
|
+
functionName: TELEMETRY_EVENTS.SDK_INITIALIZED,
|
|
687
|
+
durationMs: 0,
|
|
688
|
+
timestamp: Date.now() / 1e3,
|
|
689
|
+
props: {},
|
|
690
|
+
source: this.telemetrySource,
|
|
691
|
+
metadata: {
|
|
692
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
693
|
+
},
|
|
694
|
+
error: void 0
|
|
744
695
|
}
|
|
745
696
|
]);
|
|
746
697
|
}
|
|
@@ -764,12 +715,19 @@ var TelemetryService = class {
|
|
|
764
715
|
const originalMethod = instance[name];
|
|
765
716
|
instance[name] = async (...args) => {
|
|
766
717
|
const telemetryPayload = {
|
|
767
|
-
|
|
768
|
-
|
|
718
|
+
functionName: `${instrumentedClassName}.${name}`,
|
|
719
|
+
durationMs: 0,
|
|
720
|
+
timestamp: Date.now() / 1e3,
|
|
721
|
+
props: {
|
|
769
722
|
fileName: instrumentedClassName,
|
|
770
723
|
method: name,
|
|
771
724
|
params: args
|
|
772
|
-
}
|
|
725
|
+
},
|
|
726
|
+
metadata: {
|
|
727
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
728
|
+
},
|
|
729
|
+
error: void 0,
|
|
730
|
+
source: this.telemetrySource
|
|
773
731
|
};
|
|
774
732
|
this.batchProcessor.pushItem(telemetryPayload);
|
|
775
733
|
try {
|
|
@@ -778,7 +736,7 @@ var TelemetryService = class {
|
|
|
778
736
|
if (error instanceof Error) {
|
|
779
737
|
if (!error.errorId) {
|
|
780
738
|
error.errorId = getRandomUUID();
|
|
781
|
-
this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
|
|
739
|
+
await this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
|
|
782
740
|
}
|
|
783
741
|
}
|
|
784
742
|
throw error;
|
|
@@ -792,11 +750,11 @@ var TelemetryService = class {
|
|
|
792
750
|
* @returns true if the telemetry should be sent, false otherwise
|
|
793
751
|
*/
|
|
794
752
|
shouldSendTelemetry() {
|
|
795
|
-
const
|
|
753
|
+
const telemetryDisabledEnvironments = ["test", "ci"];
|
|
796
754
|
const nodeEnv = (getEnvVariable("NODE_ENV", "development") || "").toLowerCase();
|
|
797
|
-
const
|
|
755
|
+
const isDisabledEnvironment = telemetryDisabledEnvironments.includes(nodeEnv);
|
|
798
756
|
const isTelemetryDisabledByEnv = getEnvVariable("TELEMETRY_DISABLED", "false") === "true";
|
|
799
|
-
return
|
|
757
|
+
return !this.isTelemetryDisabled && !isTelemetryDisabledByEnv && !isDisabledEnvironment;
|
|
800
758
|
}
|
|
801
759
|
/**
|
|
802
760
|
* Prepare and send the error telemetry.
|
|
@@ -807,78 +765,78 @@ var TelemetryService = class {
|
|
|
807
765
|
* @param {string} instrumentedClassName - The class name of the instrumented class.
|
|
808
766
|
* @param {string} name - The name of the method that threw the error.
|
|
809
767
|
*/
|
|
810
|
-
prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
|
|
768
|
+
async prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
|
|
769
|
+
const telemetryPayload = {
|
|
770
|
+
functionName: `${instrumentedClassName}.${name}`,
|
|
771
|
+
durationMs: 0,
|
|
772
|
+
timestamp: Date.now() / 1e3,
|
|
773
|
+
props: {
|
|
774
|
+
fileName: instrumentedClassName,
|
|
775
|
+
method: name,
|
|
776
|
+
params: args
|
|
777
|
+
},
|
|
778
|
+
metadata: {
|
|
779
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
780
|
+
},
|
|
781
|
+
source: this.telemetrySource
|
|
782
|
+
};
|
|
811
783
|
if (error instanceof ComposioClientError) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
784
|
+
telemetryPayload.error = {
|
|
785
|
+
errorId: error.errorId,
|
|
786
|
+
name: error.name,
|
|
787
|
+
message: error.message,
|
|
788
|
+
stack: error.stack
|
|
818
789
|
};
|
|
819
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
820
790
|
} else if (error instanceof ComposioError) {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
possible_fix: error.possibleFixes?.join("\n"),
|
|
828
|
-
description: `Original Call : ${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
791
|
+
telemetryPayload.error = {
|
|
792
|
+
errorId: error.errorId,
|
|
793
|
+
name: error.name,
|
|
794
|
+
code: error.code,
|
|
795
|
+
message: error.message,
|
|
796
|
+
stack: error.stack
|
|
829
797
|
};
|
|
830
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
831
798
|
} else if (error instanceof Error) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
799
|
+
telemetryPayload.error = {
|
|
800
|
+
errorId: error.errorId,
|
|
801
|
+
name: error.name ?? "Unknown error",
|
|
802
|
+
message: error.message,
|
|
803
|
+
stack: error.stack
|
|
838
804
|
};
|
|
839
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
840
805
|
}
|
|
806
|
+
await this.sendErrorTelemetry(telemetryPayload);
|
|
841
807
|
}
|
|
842
808
|
/**
|
|
843
809
|
* Send the telemetry payload to the server.
|
|
844
810
|
* @param payload - the telemetry payload to send
|
|
845
811
|
* @returns
|
|
846
812
|
*/
|
|
847
|
-
async
|
|
813
|
+
async sendMetric(payload) {
|
|
848
814
|
if (!this.shouldSendTelemetry()) {
|
|
815
|
+
logger_default.debug("Telemetry is disabled, skipping metric telemetry", payload);
|
|
849
816
|
return;
|
|
850
817
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
url,
|
|
858
|
-
method: "POST",
|
|
859
|
-
headers: { "Content-Type": "application/json" }
|
|
860
|
-
};
|
|
861
|
-
this.transport.send(reqPayload);
|
|
818
|
+
try {
|
|
819
|
+
logger_default.debug("SDK Metric", payload);
|
|
820
|
+
await TelemetryService.sendMetric(payload);
|
|
821
|
+
} catch (error) {
|
|
822
|
+
logger_default.error("Error sending metric telemetry", error);
|
|
823
|
+
}
|
|
862
824
|
}
|
|
863
825
|
// @TODO: check if this will send the error telemetry to the server
|
|
864
826
|
async sendErrorTelemetry(payload) {
|
|
865
827
|
if (!this.shouldSendTelemetry()) {
|
|
828
|
+
logger_default.debug("Telemetry is disabled, skipping metric telemetry", payload);
|
|
866
829
|
return;
|
|
867
830
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
url,
|
|
875
|
-
method: "POST",
|
|
876
|
-
headers: { "Content-Type": "application/json" }
|
|
877
|
-
};
|
|
878
|
-
this.transport.send(reqPayload);
|
|
831
|
+
try {
|
|
832
|
+
logger_default.debug("SDK Error Telemetry", payload);
|
|
833
|
+
await TelemetryService.sendErrorLog(payload);
|
|
834
|
+
} catch (error) {
|
|
835
|
+
logger_default.error("Error sending error telemetry", error);
|
|
836
|
+
}
|
|
879
837
|
}
|
|
880
838
|
};
|
|
881
|
-
var telemetry = new
|
|
839
|
+
var telemetry = new TelemetryTransport();
|
|
882
840
|
|
|
883
841
|
// src/errors/AuthConfigErrors.ts
|
|
884
842
|
var AuthConfigErrorCodes = {
|
|
@@ -1949,7 +1907,8 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = {
|
|
|
1949
1907
|
schema
|
|
1950
1908
|
);
|
|
1951
1909
|
}
|
|
1952
|
-
|
|
1910
|
+
const zodSchema = jsonSchemaToZod(schema);
|
|
1911
|
+
return zodSchema;
|
|
1953
1912
|
} catch (error) {
|
|
1954
1913
|
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
1955
1914
|
cause: error
|
|
@@ -2598,6 +2557,14 @@ var ToolkitRetrieveCategoriesResponseSchema = z5.object({
|
|
|
2598
2557
|
nextCursor: z5.string().nullable(),
|
|
2599
2558
|
totalPages: z5.number()
|
|
2600
2559
|
});
|
|
2560
|
+
var ToolkitAuthFieldsResponseSchema = z5.object({
|
|
2561
|
+
authScheme: AuthSchemeEnum,
|
|
2562
|
+
fields: z5.array(
|
|
2563
|
+
ToolkitAuthFieldSchema.extend({
|
|
2564
|
+
required: z5.boolean().optional()
|
|
2565
|
+
})
|
|
2566
|
+
)
|
|
2567
|
+
});
|
|
2601
2568
|
|
|
2602
2569
|
// src/models/AuthConfigs.ts
|
|
2603
2570
|
var AuthConfigs = class {
|
|
@@ -3454,6 +3421,89 @@ var Toolkits = class {
|
|
|
3454
3421
|
}
|
|
3455
3422
|
return this.getToolkits(arg);
|
|
3456
3423
|
}
|
|
3424
|
+
async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
|
|
3425
|
+
const toolkit = await this.getToolkitBySlug(toolkitSlug);
|
|
3426
|
+
if (!toolkit.authConfigDetails) {
|
|
3427
|
+
throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
|
|
3428
|
+
meta: {
|
|
3429
|
+
toolkitSlug
|
|
3430
|
+
}
|
|
3431
|
+
});
|
|
3432
|
+
}
|
|
3433
|
+
if (toolkit.authConfigDetails.length > 1 && !authScheme) {
|
|
3434
|
+
logger_default.warn(
|
|
3435
|
+
`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`,
|
|
3436
|
+
{
|
|
3437
|
+
meta: {
|
|
3438
|
+
toolkitSlug
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
);
|
|
3442
|
+
}
|
|
3443
|
+
const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig2) => authConfig2.mode === authScheme) : toolkit.authConfigDetails[0];
|
|
3444
|
+
if (!authConfig) {
|
|
3445
|
+
throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
|
|
3446
|
+
meta: {
|
|
3447
|
+
toolkitSlug,
|
|
3448
|
+
authScheme
|
|
3449
|
+
}
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3452
|
+
const requiredFields = authConfig.fields[authConfigType].required.map((field) => ({
|
|
3453
|
+
...field,
|
|
3454
|
+
required: true
|
|
3455
|
+
}));
|
|
3456
|
+
if (requiredOnly) {
|
|
3457
|
+
return {
|
|
3458
|
+
authScheme: AuthSchemeEnum.parse(authConfig.mode),
|
|
3459
|
+
fields: requiredFields
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
const optionalFields = authConfig.fields[authConfigType].optional.map((field) => ({
|
|
3463
|
+
...field,
|
|
3464
|
+
required: false
|
|
3465
|
+
}));
|
|
3466
|
+
return {
|
|
3467
|
+
authScheme: AuthSchemeEnum.parse(authConfig.mode),
|
|
3468
|
+
fields: [...requiredFields, ...optionalFields]
|
|
3469
|
+
};
|
|
3470
|
+
}
|
|
3471
|
+
/**
|
|
3472
|
+
* Retrieves the fields required for creating an auth config for a toolkit.
|
|
3473
|
+
* @param toolkitSlug - The slug of the toolkit to retrieve the fields for
|
|
3474
|
+
* @param authScheme - The auth scheme to retrieve the fields for
|
|
3475
|
+
* @param requiredOnly - Whether to only return the required fields
|
|
3476
|
+
* @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for creating an auth config
|
|
3477
|
+
*/
|
|
3478
|
+
async getAuthConfigCreationFields(toolkitSlug, {
|
|
3479
|
+
authScheme,
|
|
3480
|
+
requiredOnly = false
|
|
3481
|
+
} = {}) {
|
|
3482
|
+
return this.getAuthConfigFields(
|
|
3483
|
+
toolkitSlug,
|
|
3484
|
+
authScheme ?? null,
|
|
3485
|
+
"authConfigCreation",
|
|
3486
|
+
requiredOnly
|
|
3487
|
+
);
|
|
3488
|
+
}
|
|
3489
|
+
/**
|
|
3490
|
+
* Retrieves the fields required for initiating a connected account for a toolkit.
|
|
3491
|
+
* @param toolkitSlug - The slug of the toolkit to retrieve the fields for
|
|
3492
|
+
* @param authScheme - The auth scheme to retrieve the fields for
|
|
3493
|
+
* @param requiredOnly - Whether to only return the required fields
|
|
3494
|
+
* @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for initiating a connected account
|
|
3495
|
+
*/
|
|
3496
|
+
async getConnectedAccountInitiationFields(toolkitSlug, {
|
|
3497
|
+
authScheme,
|
|
3498
|
+
requiredOnly = false
|
|
3499
|
+
} = {}) {
|
|
3500
|
+
return this.getAuthConfigFields(
|
|
3501
|
+
toolkitSlug,
|
|
3502
|
+
authScheme ?? null,
|
|
3503
|
+
"connectedAccountInitiation",
|
|
3504
|
+
requiredOnly
|
|
3505
|
+
);
|
|
3506
|
+
}
|
|
3457
3507
|
/**
|
|
3458
3508
|
* Retrieves all toolkit categories available in the Composio SDK.
|
|
3459
3509
|
*
|
|
@@ -4192,6 +4242,12 @@ var Triggers = class {
|
|
|
4192
4242
|
}
|
|
4193
4243
|
};
|
|
4194
4244
|
|
|
4245
|
+
// src/utils/constants.ts
|
|
4246
|
+
var COMPOSIO_DIR = ".composio";
|
|
4247
|
+
var USER_DATA_FILE_NAME = "user_data.json";
|
|
4248
|
+
var DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
4249
|
+
var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
|
|
4250
|
+
|
|
4195
4251
|
// src/utils/sdk.ts
|
|
4196
4252
|
var userDataPath = () => {
|
|
4197
4253
|
try {
|
|
@@ -4708,7 +4764,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4708
4764
|
};
|
|
4709
4765
|
|
|
4710
4766
|
// package.json
|
|
4711
|
-
var version = "0.1.
|
|
4767
|
+
var version = "0.1.19";
|
|
4712
4768
|
|
|
4713
4769
|
// src/composio.ts
|
|
4714
4770
|
var Composio = class _Composio {
|
|
@@ -4745,7 +4801,6 @@ var Composio = class _Composio {
|
|
|
4745
4801
|
* @param {boolean} [config.allowTracking=true] - Whether to allow anonymous usage analytics
|
|
4746
4802
|
* @param {boolean} [config.allowTracing=true] - Whether to allow request tracing for debugging
|
|
4747
4803
|
* @param {TProvider} [config.provider] - The provider to use for this Composio instance (defaults to OpenAIProvider)
|
|
4748
|
-
* @param {BaseTelemetryTransport} [config.telemetryTransport] - Custom telemetry transport implementation
|
|
4749
4804
|
*
|
|
4750
4805
|
* @example
|
|
4751
4806
|
* ```typescript
|
|
@@ -4791,23 +4846,21 @@ var Composio = class _Composio {
|
|
|
4791
4846
|
this.authConfigs = new AuthConfigs(this.client);
|
|
4792
4847
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
4793
4848
|
if (this.config.allowTracking) {
|
|
4794
|
-
telemetry.setup(
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
config?.telemetryTransport
|
|
4810
|
-
);
|
|
4849
|
+
telemetry.setup({
|
|
4850
|
+
apiKey: apiKeyParsed ?? "",
|
|
4851
|
+
baseUrl: baseURLParsed ?? "",
|
|
4852
|
+
frameworkRuntime: this.provider?.name ?? "unknown",
|
|
4853
|
+
isAgentic: this.provider?._isAgentic || false,
|
|
4854
|
+
source: "composio-sdk-typescript",
|
|
4855
|
+
version,
|
|
4856
|
+
sdkType: "Typescript-V3",
|
|
4857
|
+
isBrowser: typeof window !== "undefined",
|
|
4858
|
+
provider: this.provider?.name ?? "openai",
|
|
4859
|
+
// @TODO: Users might want to pass their own session id
|
|
4860
|
+
// @TODO: We shouldn't be doing this as people might always have one session id throughout the process in server
|
|
4861
|
+
sessionId: this.config.allowTracing ? getRandomUUID() : void 0
|
|
4862
|
+
// @TODO: get the session id
|
|
4863
|
+
});
|
|
4811
4864
|
}
|
|
4812
4865
|
telemetry.instrument(this);
|
|
4813
4866
|
telemetry.instrument(this.provider);
|
|
@@ -4876,17 +4929,6 @@ var ComposioProvider = class extends BaseNonAgenticProvider {
|
|
|
4876
4929
|
}
|
|
4877
4930
|
};
|
|
4878
4931
|
|
|
4879
|
-
// src/telemetry/TelemetryTransport.ts
|
|
4880
|
-
import chalk4 from "chalk";
|
|
4881
|
-
var BaseTelemetryTransport = class {
|
|
4882
|
-
};
|
|
4883
|
-
var ConsoleTelemetryTransport = class {
|
|
4884
|
-
send(payload) {
|
|
4885
|
-
logger_default.debug(chalk4.yellow("telemetry"), JSON.stringify(payload, null, 2));
|
|
4886
|
-
return Promise.resolve();
|
|
4887
|
-
}
|
|
4888
|
-
};
|
|
4889
|
-
|
|
4890
4932
|
// src/models/AuthScheme.ts
|
|
4891
4933
|
var AuthScheme = class {
|
|
4892
4934
|
/**
|
|
@@ -5067,7 +5109,6 @@ export {
|
|
|
5067
5109
|
AuthSchemeTypes,
|
|
5068
5110
|
BaseAgenticProvider,
|
|
5069
5111
|
BaseNonAgenticProvider,
|
|
5070
|
-
BaseTelemetryTransport,
|
|
5071
5112
|
BasicWithJwtConnectionDataSchema,
|
|
5072
5113
|
BillcomAuthConnectionDataSchema,
|
|
5073
5114
|
Composio,
|
|
@@ -5092,7 +5133,6 @@ export {
|
|
|
5092
5133
|
ConnectionRequestFailedError,
|
|
5093
5134
|
ConnectionRequestTimeoutError,
|
|
5094
5135
|
ConnectionStatuses,
|
|
5095
|
-
ConsoleTelemetryTransport,
|
|
5096
5136
|
CreateAuthConfigParamsSchema,
|
|
5097
5137
|
CreateAuthConfigResponseSchema,
|
|
5098
5138
|
CreateComposioManagedAuthConfigParamsSchema,
|
|
@@ -5130,6 +5170,7 @@ export {
|
|
|
5130
5170
|
ToolSchema,
|
|
5131
5171
|
ToolkitAuthConfigDetailsSchema,
|
|
5132
5172
|
ToolkitAuthFieldSchema,
|
|
5173
|
+
ToolkitAuthFieldsResponseSchema,
|
|
5133
5174
|
ToolkitCategorySchema,
|
|
5134
5175
|
ToolkitErrorCodes,
|
|
5135
5176
|
ToolkitMangedByEnumSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"@composio/json-schema-to-zod": "0.1.6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@composio/client": "0.1.0-alpha.
|
|
34
|
-
"@composio/json-schema-to-zod": "0.1.
|
|
35
|
-
"zod-to-json-schema": "^3.24.5",
|
|
33
|
+
"@composio/client": "0.1.0-alpha.22",
|
|
34
|
+
"@composio/json-schema-to-zod": "0.1.7",
|
|
36
35
|
"chalk": "^5.4.1",
|
|
37
36
|
"openai": "^4.94.0",
|
|
38
37
|
"pusher-js": "^8.4.0",
|
|
39
38
|
"semver": "^7.7.2",
|
|
40
39
|
"uuid": "^11.1.0",
|
|
41
|
-
"zod": "^3.24.2"
|
|
40
|
+
"zod": "^3.24.2",
|
|
41
|
+
"zod-to-json-schema": "^3.24.5"
|
|
42
42
|
},
|
|
43
43
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
44
44
|
"scripts": {
|