@composio/core 0.1.18 → 0.1.20
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 +282 -206
- package/dist/index.d.cts +537 -377
- package/dist/index.d.ts +537 -377
- package/dist/index.js +281 -204
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -25,21 +25,63 @@ var JSONSchemaType = z.enum([
|
|
|
25
25
|
"null"
|
|
26
26
|
]);
|
|
27
27
|
var JSONSchemaProperty = z.object({
|
|
28
|
-
type: JSONSchemaType.optional(),
|
|
28
|
+
type: z.union([JSONSchemaType, z.array(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(),
|
|
36
|
+
nullable: z.boolean().optional(),
|
|
33
37
|
properties: z.lazy(() => z.record(z.string(), JSONSchemaProperty)).optional(),
|
|
34
38
|
required: z.array(z.string()).optional(),
|
|
35
|
-
items: z.lazy(() => JSONSchemaProperty).optional()
|
|
39
|
+
items: z.lazy(() => z.union([JSONSchemaProperty, z.array(JSONSchemaProperty)])).optional(),
|
|
40
|
+
enum: z.array(z.any()).optional(),
|
|
41
|
+
const: z.any().optional(),
|
|
42
|
+
minimum: z.number().optional(),
|
|
43
|
+
maximum: z.number().optional(),
|
|
44
|
+
exclusiveMinimum: z.number().optional(),
|
|
45
|
+
exclusiveMaximum: z.number().optional(),
|
|
46
|
+
multipleOf: z.number().optional(),
|
|
47
|
+
minLength: z.number().optional(),
|
|
48
|
+
maxLength: z.number().optional(),
|
|
49
|
+
pattern: z.string().optional(),
|
|
50
|
+
format: z.string().optional(),
|
|
51
|
+
minItems: z.number().optional(),
|
|
52
|
+
maxItems: z.number().optional(),
|
|
53
|
+
uniqueItems: z.boolean().optional(),
|
|
54
|
+
minProperties: z.number().optional(),
|
|
55
|
+
maxProperties: z.number().optional(),
|
|
56
|
+
patternProperties: z.lazy(() => z.record(z.string(), JSONSchemaProperty)).optional(),
|
|
57
|
+
additionalProperties: z.union([z.boolean(), z.lazy(() => JSONSchemaProperty)]).optional(),
|
|
58
|
+
examples: z.array(z.any()).optional(),
|
|
59
|
+
readOnly: z.boolean().optional(),
|
|
60
|
+
writeOnly: z.boolean().optional(),
|
|
61
|
+
if: z.lazy(() => JSONSchemaProperty).optional(),
|
|
62
|
+
then: z.lazy(() => JSONSchemaProperty).optional(),
|
|
63
|
+
else: z.lazy(() => JSONSchemaProperty).optional(),
|
|
64
|
+
$ref: z.string().optional(),
|
|
65
|
+
definitions: z.record(
|
|
66
|
+
z.string(),
|
|
67
|
+
z.lazy(() => JSONSchemaProperty)
|
|
68
|
+
).optional(),
|
|
69
|
+
$defs: z.record(
|
|
70
|
+
z.string(),
|
|
71
|
+
z.lazy(() => JSONSchemaProperty)
|
|
72
|
+
).optional()
|
|
36
73
|
});
|
|
37
74
|
var ParametersSchema = z.object({
|
|
38
75
|
type: z.literal("object"),
|
|
39
76
|
anyOf: z.array(JSONSchemaProperty).optional(),
|
|
77
|
+
oneOf: z.array(JSONSchemaProperty).optional(),
|
|
78
|
+
allOf: z.array(JSONSchemaProperty).optional(),
|
|
79
|
+
not: JSONSchemaProperty.optional(),
|
|
40
80
|
properties: z.record(z.string(), JSONSchemaProperty),
|
|
41
81
|
required: z.array(z.string()).optional(),
|
|
42
82
|
title: z.string().optional(),
|
|
83
|
+
default: z.any().optional(),
|
|
84
|
+
nullable: z.boolean().optional(),
|
|
43
85
|
description: z.string().optional(),
|
|
44
86
|
additionalProperties: z.boolean().default(false).optional()
|
|
45
87
|
});
|
|
@@ -581,13 +623,6 @@ var TELEMETRY_EVENTS = {
|
|
|
581
623
|
CLI_INVOKED: "CLI_INVOKED"
|
|
582
624
|
};
|
|
583
625
|
|
|
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
626
|
// src/telemetry/BatchProcessor.ts
|
|
592
627
|
var BatchProcessor = class {
|
|
593
628
|
batch = [];
|
|
@@ -621,126 +656,78 @@ var BatchProcessor = class {
|
|
|
621
656
|
}
|
|
622
657
|
};
|
|
623
658
|
|
|
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
659
|
// src/utils/uuid.ts
|
|
714
660
|
import { v4 as uuidv4 } from "uuid";
|
|
715
661
|
function getRandomUUID() {
|
|
716
662
|
return uuidv4();
|
|
717
663
|
}
|
|
718
664
|
|
|
719
|
-
// src/telemetry/
|
|
665
|
+
// src/services/telemetry/TelemetryService.ts
|
|
666
|
+
var TELEMETRY_URL = "https://telemetry.composio.dev/v1";
|
|
720
667
|
var TelemetryService = class {
|
|
668
|
+
/**
|
|
669
|
+
* Sends a metric to the Telemetry API.
|
|
670
|
+
* @param payload - The payload to send to the Telemetry API.
|
|
671
|
+
* @returns The response from the Telemetry API.
|
|
672
|
+
*/
|
|
673
|
+
static async sendMetric(payload) {
|
|
674
|
+
return fetch(`${TELEMETRY_URL}/metrics/invocations`, {
|
|
675
|
+
method: "POST",
|
|
676
|
+
headers: {
|
|
677
|
+
"Content-Type": "application/json"
|
|
678
|
+
},
|
|
679
|
+
body: JSON.stringify(payload)
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Sends an error log to the Telemetry API.
|
|
684
|
+
* @param payload - The payload to send to the Telemetry API.
|
|
685
|
+
* @returns The response from the Telemetry API.
|
|
686
|
+
*/
|
|
687
|
+
static async sendErrorLog(payload) {
|
|
688
|
+
return fetch(`${TELEMETRY_URL}/errors`, {
|
|
689
|
+
method: "POST",
|
|
690
|
+
headers: {
|
|
691
|
+
"Content-Type": "application/json"
|
|
692
|
+
},
|
|
693
|
+
body: JSON.stringify(payload)
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/telemetry/Telemetry.ts
|
|
699
|
+
var TelemetryTransport = class {
|
|
721
700
|
telemetryMetadata;
|
|
722
|
-
transport;
|
|
723
701
|
isTelemetryDisabled = true;
|
|
724
|
-
|
|
725
|
-
|
|
702
|
+
telemetrySource;
|
|
703
|
+
telemetrySourceName = "typescript-sdk";
|
|
704
|
+
telemetryServiceName = "sdk";
|
|
705
|
+
telemetryLanguage = "typescript";
|
|
706
|
+
batchProcessor = new BatchProcessor(200, 10, async (data) => {
|
|
707
|
+
logger_default.debug("Sending batch of telemetry metrics", data);
|
|
708
|
+
await TelemetryService.sendMetric(data);
|
|
726
709
|
});
|
|
727
|
-
setup(metadata
|
|
710
|
+
setup(metadata) {
|
|
728
711
|
this.telemetryMetadata = metadata;
|
|
729
712
|
this.isTelemetryDisabled = false;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
this.
|
|
733
|
-
|
|
734
|
-
this.
|
|
735
|
-
this.telemetryMetadata
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
this.telemetryMetadata.transport = "process";
|
|
739
|
-
}
|
|
740
|
-
this.sendTelemetry([
|
|
713
|
+
this.telemetrySource = {
|
|
714
|
+
name: this.telemetrySourceName,
|
|
715
|
+
service: this.telemetryServiceName,
|
|
716
|
+
language: this.telemetryLanguage,
|
|
717
|
+
version: this.telemetryMetadata?.version,
|
|
718
|
+
platform: this.telemetryMetadata?.isBrowser ? "browser" : "node"
|
|
719
|
+
};
|
|
720
|
+
this.sendMetric([
|
|
741
721
|
{
|
|
742
|
-
|
|
743
|
-
|
|
722
|
+
functionName: TELEMETRY_EVENTS.SDK_INITIALIZED,
|
|
723
|
+
durationMs: 0,
|
|
724
|
+
timestamp: Date.now() / 1e3,
|
|
725
|
+
props: {},
|
|
726
|
+
source: this.telemetrySource,
|
|
727
|
+
metadata: {
|
|
728
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
729
|
+
},
|
|
730
|
+
error: void 0
|
|
744
731
|
}
|
|
745
732
|
]);
|
|
746
733
|
}
|
|
@@ -764,12 +751,19 @@ var TelemetryService = class {
|
|
|
764
751
|
const originalMethod = instance[name];
|
|
765
752
|
instance[name] = async (...args) => {
|
|
766
753
|
const telemetryPayload = {
|
|
767
|
-
|
|
768
|
-
|
|
754
|
+
functionName: `${instrumentedClassName}.${name}`,
|
|
755
|
+
durationMs: 0,
|
|
756
|
+
timestamp: Date.now() / 1e3,
|
|
757
|
+
props: {
|
|
769
758
|
fileName: instrumentedClassName,
|
|
770
759
|
method: name,
|
|
771
760
|
params: args
|
|
772
|
-
}
|
|
761
|
+
},
|
|
762
|
+
metadata: {
|
|
763
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
764
|
+
},
|
|
765
|
+
error: void 0,
|
|
766
|
+
source: this.telemetrySource
|
|
773
767
|
};
|
|
774
768
|
this.batchProcessor.pushItem(telemetryPayload);
|
|
775
769
|
try {
|
|
@@ -778,7 +772,7 @@ var TelemetryService = class {
|
|
|
778
772
|
if (error instanceof Error) {
|
|
779
773
|
if (!error.errorId) {
|
|
780
774
|
error.errorId = getRandomUUID();
|
|
781
|
-
this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
|
|
775
|
+
await this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
|
|
782
776
|
}
|
|
783
777
|
}
|
|
784
778
|
throw error;
|
|
@@ -792,11 +786,11 @@ var TelemetryService = class {
|
|
|
792
786
|
* @returns true if the telemetry should be sent, false otherwise
|
|
793
787
|
*/
|
|
794
788
|
shouldSendTelemetry() {
|
|
795
|
-
const
|
|
789
|
+
const telemetryDisabledEnvironments = ["test", "ci"];
|
|
796
790
|
const nodeEnv = (getEnvVariable("NODE_ENV", "development") || "").toLowerCase();
|
|
797
|
-
const
|
|
791
|
+
const isDisabledEnvironment = telemetryDisabledEnvironments.includes(nodeEnv);
|
|
798
792
|
const isTelemetryDisabledByEnv = getEnvVariable("TELEMETRY_DISABLED", "false") === "true";
|
|
799
|
-
return
|
|
793
|
+
return !this.isTelemetryDisabled && !isTelemetryDisabledByEnv && !isDisabledEnvironment;
|
|
800
794
|
}
|
|
801
795
|
/**
|
|
802
796
|
* Prepare and send the error telemetry.
|
|
@@ -807,78 +801,78 @@ var TelemetryService = class {
|
|
|
807
801
|
* @param {string} instrumentedClassName - The class name of the instrumented class.
|
|
808
802
|
* @param {string} name - The name of the method that threw the error.
|
|
809
803
|
*/
|
|
810
|
-
prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
|
|
804
|
+
async prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
|
|
805
|
+
const telemetryPayload = {
|
|
806
|
+
functionName: `${instrumentedClassName}.${name}`,
|
|
807
|
+
durationMs: 0,
|
|
808
|
+
timestamp: Date.now() / 1e3,
|
|
809
|
+
props: {
|
|
810
|
+
fileName: instrumentedClassName,
|
|
811
|
+
method: name,
|
|
812
|
+
params: args
|
|
813
|
+
},
|
|
814
|
+
metadata: {
|
|
815
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
816
|
+
},
|
|
817
|
+
source: this.telemetrySource
|
|
818
|
+
};
|
|
811
819
|
if (error instanceof ComposioClientError) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
820
|
+
telemetryPayload.error = {
|
|
821
|
+
errorId: error.errorId,
|
|
822
|
+
name: error.name,
|
|
823
|
+
message: error.message,
|
|
824
|
+
stack: error.stack
|
|
818
825
|
};
|
|
819
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
820
826
|
} 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)})`
|
|
827
|
+
telemetryPayload.error = {
|
|
828
|
+
errorId: error.errorId,
|
|
829
|
+
name: error.name,
|
|
830
|
+
code: error.code,
|
|
831
|
+
message: error.message,
|
|
832
|
+
stack: error.stack
|
|
829
833
|
};
|
|
830
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
831
834
|
} else if (error instanceof Error) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
835
|
+
telemetryPayload.error = {
|
|
836
|
+
errorId: error.errorId,
|
|
837
|
+
name: error.name ?? "Unknown error",
|
|
838
|
+
message: error.message,
|
|
839
|
+
stack: error.stack
|
|
838
840
|
};
|
|
839
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
840
841
|
}
|
|
842
|
+
await this.sendErrorTelemetry(telemetryPayload);
|
|
841
843
|
}
|
|
842
844
|
/**
|
|
843
845
|
* Send the telemetry payload to the server.
|
|
844
846
|
* @param payload - the telemetry payload to send
|
|
845
847
|
* @returns
|
|
846
848
|
*/
|
|
847
|
-
async
|
|
849
|
+
async sendMetric(payload) {
|
|
848
850
|
if (!this.shouldSendTelemetry()) {
|
|
851
|
+
logger_default.debug("Telemetry is disabled, skipping metric telemetry", payload);
|
|
849
852
|
return;
|
|
850
853
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
url,
|
|
858
|
-
method: "POST",
|
|
859
|
-
headers: { "Content-Type": "application/json" }
|
|
860
|
-
};
|
|
861
|
-
this.transport.send(reqPayload);
|
|
854
|
+
try {
|
|
855
|
+
logger_default.debug("SDK Metric", payload);
|
|
856
|
+
await TelemetryService.sendMetric(payload);
|
|
857
|
+
} catch (error) {
|
|
858
|
+
logger_default.error("Error sending metric telemetry", error);
|
|
859
|
+
}
|
|
862
860
|
}
|
|
863
861
|
// @TODO: check if this will send the error telemetry to the server
|
|
864
862
|
async sendErrorTelemetry(payload) {
|
|
865
863
|
if (!this.shouldSendTelemetry()) {
|
|
864
|
+
logger_default.debug("Telemetry is disabled, skipping metric telemetry", payload);
|
|
866
865
|
return;
|
|
867
866
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
url,
|
|
875
|
-
method: "POST",
|
|
876
|
-
headers: { "Content-Type": "application/json" }
|
|
877
|
-
};
|
|
878
|
-
this.transport.send(reqPayload);
|
|
867
|
+
try {
|
|
868
|
+
logger_default.debug("SDK Error Telemetry", payload);
|
|
869
|
+
await TelemetryService.sendErrorLog(payload);
|
|
870
|
+
} catch (error) {
|
|
871
|
+
logger_default.error("Error sending error telemetry", error);
|
|
872
|
+
}
|
|
879
873
|
}
|
|
880
874
|
};
|
|
881
|
-
var telemetry = new
|
|
875
|
+
var telemetry = new TelemetryTransport();
|
|
882
876
|
|
|
883
877
|
// src/errors/AuthConfigErrors.ts
|
|
884
878
|
var AuthConfigErrorCodes = {
|
|
@@ -1949,7 +1943,8 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = {
|
|
|
1949
1943
|
schema
|
|
1950
1944
|
);
|
|
1951
1945
|
}
|
|
1952
|
-
|
|
1946
|
+
const zodSchema = jsonSchemaToZod(schema);
|
|
1947
|
+
return zodSchema;
|
|
1953
1948
|
} catch (error) {
|
|
1954
1949
|
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
1955
1950
|
cause: error
|
|
@@ -2598,6 +2593,14 @@ var ToolkitRetrieveCategoriesResponseSchema = z5.object({
|
|
|
2598
2593
|
nextCursor: z5.string().nullable(),
|
|
2599
2594
|
totalPages: z5.number()
|
|
2600
2595
|
});
|
|
2596
|
+
var ToolkitAuthFieldsResponseSchema = z5.object({
|
|
2597
|
+
authScheme: AuthSchemeEnum,
|
|
2598
|
+
fields: z5.array(
|
|
2599
|
+
ToolkitAuthFieldSchema.extend({
|
|
2600
|
+
required: z5.boolean().optional()
|
|
2601
|
+
})
|
|
2602
|
+
)
|
|
2603
|
+
});
|
|
2601
2604
|
|
|
2602
2605
|
// src/models/AuthConfigs.ts
|
|
2603
2606
|
var AuthConfigs = class {
|
|
@@ -3454,6 +3457,89 @@ var Toolkits = class {
|
|
|
3454
3457
|
}
|
|
3455
3458
|
return this.getToolkits(arg);
|
|
3456
3459
|
}
|
|
3460
|
+
async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
|
|
3461
|
+
const toolkit = await this.getToolkitBySlug(toolkitSlug);
|
|
3462
|
+
if (!toolkit.authConfigDetails) {
|
|
3463
|
+
throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
|
|
3464
|
+
meta: {
|
|
3465
|
+
toolkitSlug
|
|
3466
|
+
}
|
|
3467
|
+
});
|
|
3468
|
+
}
|
|
3469
|
+
if (toolkit.authConfigDetails.length > 1 && !authScheme) {
|
|
3470
|
+
logger_default.warn(
|
|
3471
|
+
`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`,
|
|
3472
|
+
{
|
|
3473
|
+
meta: {
|
|
3474
|
+
toolkitSlug
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
);
|
|
3478
|
+
}
|
|
3479
|
+
const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig2) => authConfig2.mode === authScheme) : toolkit.authConfigDetails[0];
|
|
3480
|
+
if (!authConfig) {
|
|
3481
|
+
throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
|
|
3482
|
+
meta: {
|
|
3483
|
+
toolkitSlug,
|
|
3484
|
+
authScheme
|
|
3485
|
+
}
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
const requiredFields = authConfig.fields[authConfigType].required.map((field) => ({
|
|
3489
|
+
...field,
|
|
3490
|
+
required: true
|
|
3491
|
+
}));
|
|
3492
|
+
if (requiredOnly) {
|
|
3493
|
+
return {
|
|
3494
|
+
authScheme: AuthSchemeEnum.parse(authConfig.mode),
|
|
3495
|
+
fields: requiredFields
|
|
3496
|
+
};
|
|
3497
|
+
}
|
|
3498
|
+
const optionalFields = authConfig.fields[authConfigType].optional.map((field) => ({
|
|
3499
|
+
...field,
|
|
3500
|
+
required: false
|
|
3501
|
+
}));
|
|
3502
|
+
return {
|
|
3503
|
+
authScheme: AuthSchemeEnum.parse(authConfig.mode),
|
|
3504
|
+
fields: [...requiredFields, ...optionalFields]
|
|
3505
|
+
};
|
|
3506
|
+
}
|
|
3507
|
+
/**
|
|
3508
|
+
* Retrieves the fields required for creating an auth config for a toolkit.
|
|
3509
|
+
* @param toolkitSlug - The slug of the toolkit to retrieve the fields for
|
|
3510
|
+
* @param authScheme - The auth scheme to retrieve the fields for
|
|
3511
|
+
* @param requiredOnly - Whether to only return the required fields
|
|
3512
|
+
* @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for creating an auth config
|
|
3513
|
+
*/
|
|
3514
|
+
async getAuthConfigCreationFields(toolkitSlug, {
|
|
3515
|
+
authScheme,
|
|
3516
|
+
requiredOnly = false
|
|
3517
|
+
} = {}) {
|
|
3518
|
+
return this.getAuthConfigFields(
|
|
3519
|
+
toolkitSlug,
|
|
3520
|
+
authScheme ?? null,
|
|
3521
|
+
"authConfigCreation",
|
|
3522
|
+
requiredOnly
|
|
3523
|
+
);
|
|
3524
|
+
}
|
|
3525
|
+
/**
|
|
3526
|
+
* Retrieves the fields required for initiating a connected account for a toolkit.
|
|
3527
|
+
* @param toolkitSlug - The slug of the toolkit to retrieve the fields for
|
|
3528
|
+
* @param authScheme - The auth scheme to retrieve the fields for
|
|
3529
|
+
* @param requiredOnly - Whether to only return the required fields
|
|
3530
|
+
* @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for initiating a connected account
|
|
3531
|
+
*/
|
|
3532
|
+
async getConnectedAccountInitiationFields(toolkitSlug, {
|
|
3533
|
+
authScheme,
|
|
3534
|
+
requiredOnly = false
|
|
3535
|
+
} = {}) {
|
|
3536
|
+
return this.getAuthConfigFields(
|
|
3537
|
+
toolkitSlug,
|
|
3538
|
+
authScheme ?? null,
|
|
3539
|
+
"connectedAccountInitiation",
|
|
3540
|
+
requiredOnly
|
|
3541
|
+
);
|
|
3542
|
+
}
|
|
3457
3543
|
/**
|
|
3458
3544
|
* Retrieves all toolkit categories available in the Composio SDK.
|
|
3459
3545
|
*
|
|
@@ -4192,6 +4278,12 @@ var Triggers = class {
|
|
|
4192
4278
|
}
|
|
4193
4279
|
};
|
|
4194
4280
|
|
|
4281
|
+
// src/utils/constants.ts
|
|
4282
|
+
var COMPOSIO_DIR = ".composio";
|
|
4283
|
+
var USER_DATA_FILE_NAME = "user_data.json";
|
|
4284
|
+
var DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
4285
|
+
var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
|
|
4286
|
+
|
|
4195
4287
|
// src/utils/sdk.ts
|
|
4196
4288
|
var userDataPath = () => {
|
|
4197
4289
|
try {
|
|
@@ -4708,7 +4800,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4708
4800
|
};
|
|
4709
4801
|
|
|
4710
4802
|
// package.json
|
|
4711
|
-
var version = "0.1.
|
|
4803
|
+
var version = "0.1.20";
|
|
4712
4804
|
|
|
4713
4805
|
// src/composio.ts
|
|
4714
4806
|
var Composio = class _Composio {
|
|
@@ -4745,7 +4837,6 @@ var Composio = class _Composio {
|
|
|
4745
4837
|
* @param {boolean} [config.allowTracking=true] - Whether to allow anonymous usage analytics
|
|
4746
4838
|
* @param {boolean} [config.allowTracing=true] - Whether to allow request tracing for debugging
|
|
4747
4839
|
* @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
4840
|
*
|
|
4750
4841
|
* @example
|
|
4751
4842
|
* ```typescript
|
|
@@ -4791,23 +4882,21 @@ var Composio = class _Composio {
|
|
|
4791
4882
|
this.authConfigs = new AuthConfigs(this.client);
|
|
4792
4883
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
4793
4884
|
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
|
-
);
|
|
4885
|
+
telemetry.setup({
|
|
4886
|
+
apiKey: apiKeyParsed ?? "",
|
|
4887
|
+
baseUrl: baseURLParsed ?? "",
|
|
4888
|
+
frameworkRuntime: this.provider?.name ?? "unknown",
|
|
4889
|
+
isAgentic: this.provider?._isAgentic || false,
|
|
4890
|
+
source: "composio-sdk-typescript",
|
|
4891
|
+
version,
|
|
4892
|
+
sdkType: "Typescript-V3",
|
|
4893
|
+
isBrowser: typeof window !== "undefined",
|
|
4894
|
+
provider: this.provider?.name ?? "openai",
|
|
4895
|
+
// @TODO: Users might want to pass their own session id
|
|
4896
|
+
// @TODO: We shouldn't be doing this as people might always have one session id throughout the process in server
|
|
4897
|
+
sessionId: this.config.allowTracing ? getRandomUUID() : void 0
|
|
4898
|
+
// @TODO: get the session id
|
|
4899
|
+
});
|
|
4811
4900
|
}
|
|
4812
4901
|
telemetry.instrument(this);
|
|
4813
4902
|
telemetry.instrument(this.provider);
|
|
@@ -4876,17 +4965,6 @@ var ComposioProvider = class extends BaseNonAgenticProvider {
|
|
|
4876
4965
|
}
|
|
4877
4966
|
};
|
|
4878
4967
|
|
|
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
4968
|
// src/models/AuthScheme.ts
|
|
4891
4969
|
var AuthScheme = class {
|
|
4892
4970
|
/**
|
|
@@ -5067,7 +5145,6 @@ export {
|
|
|
5067
5145
|
AuthSchemeTypes,
|
|
5068
5146
|
BaseAgenticProvider,
|
|
5069
5147
|
BaseNonAgenticProvider,
|
|
5070
|
-
BaseTelemetryTransport,
|
|
5071
5148
|
BasicWithJwtConnectionDataSchema,
|
|
5072
5149
|
BillcomAuthConnectionDataSchema,
|
|
5073
5150
|
Composio,
|
|
@@ -5092,7 +5169,6 @@ export {
|
|
|
5092
5169
|
ConnectionRequestFailedError,
|
|
5093
5170
|
ConnectionRequestTimeoutError,
|
|
5094
5171
|
ConnectionStatuses,
|
|
5095
|
-
ConsoleTelemetryTransport,
|
|
5096
5172
|
CreateAuthConfigParamsSchema,
|
|
5097
5173
|
CreateAuthConfigResponseSchema,
|
|
5098
5174
|
CreateComposioManagedAuthConfigParamsSchema,
|
|
@@ -5130,6 +5206,7 @@ export {
|
|
|
5130
5206
|
ToolSchema,
|
|
5131
5207
|
ToolkitAuthConfigDetailsSchema,
|
|
5132
5208
|
ToolkitAuthFieldSchema,
|
|
5209
|
+
ToolkitAuthFieldsResponseSchema,
|
|
5133
5210
|
ToolkitCategorySchema,
|
|
5134
5211
|
ToolkitErrorCodes,
|
|
5135
5212
|
ToolkitMangedByEnumSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
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.8",
|
|
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": {
|