@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.cjs
CHANGED
|
@@ -43,7 +43,6 @@ __export(index_exports, {
|
|
|
43
43
|
AuthSchemeTypes: () => AuthSchemeTypes,
|
|
44
44
|
BaseAgenticProvider: () => BaseAgenticProvider,
|
|
45
45
|
BaseNonAgenticProvider: () => BaseNonAgenticProvider,
|
|
46
|
-
BaseTelemetryTransport: () => BaseTelemetryTransport,
|
|
47
46
|
BasicWithJwtConnectionDataSchema: () => BasicWithJwtConnectionDataSchema,
|
|
48
47
|
BillcomAuthConnectionDataSchema: () => BillcomAuthConnectionDataSchema,
|
|
49
48
|
Composio: () => Composio,
|
|
@@ -68,7 +67,6 @@ __export(index_exports, {
|
|
|
68
67
|
ConnectionRequestFailedError: () => ConnectionRequestFailedError,
|
|
69
68
|
ConnectionRequestTimeoutError: () => ConnectionRequestTimeoutError,
|
|
70
69
|
ConnectionStatuses: () => ConnectionStatuses,
|
|
71
|
-
ConsoleTelemetryTransport: () => ConsoleTelemetryTransport,
|
|
72
70
|
CreateAuthConfigParamsSchema: () => CreateAuthConfigParamsSchema,
|
|
73
71
|
CreateAuthConfigResponseSchema: () => CreateAuthConfigResponseSchema,
|
|
74
72
|
CreateComposioManagedAuthConfigParamsSchema: () => CreateComposioManagedAuthConfigParamsSchema,
|
|
@@ -106,6 +104,7 @@ __export(index_exports, {
|
|
|
106
104
|
ToolSchema: () => ToolSchema,
|
|
107
105
|
ToolkitAuthConfigDetailsSchema: () => ToolkitAuthConfigDetailsSchema,
|
|
108
106
|
ToolkitAuthFieldSchema: () => ToolkitAuthFieldSchema,
|
|
107
|
+
ToolkitAuthFieldsResponseSchema: () => ToolkitAuthFieldsResponseSchema,
|
|
109
108
|
ToolkitCategorySchema: () => ToolkitCategorySchema,
|
|
110
109
|
ToolkitErrorCodes: () => ToolkitErrorCodes,
|
|
111
110
|
ToolkitMangedByEnumSchema: () => ToolkitMangedByEnumSchema,
|
|
@@ -155,6 +154,9 @@ var JSONSchemaProperty = import_zod.z.object({
|
|
|
155
154
|
type: JSONSchemaType.optional(),
|
|
156
155
|
description: import_zod.z.string().optional(),
|
|
157
156
|
anyOf: import_zod.z.lazy(() => import_zod.z.array(JSONSchemaProperty)).optional(),
|
|
157
|
+
oneOf: import_zod.z.lazy(() => import_zod.z.array(JSONSchemaProperty)).optional(),
|
|
158
|
+
allOf: import_zod.z.lazy(() => import_zod.z.array(JSONSchemaProperty)).optional(),
|
|
159
|
+
not: import_zod.z.lazy(() => JSONSchemaProperty).optional(),
|
|
158
160
|
title: import_zod.z.string().optional(),
|
|
159
161
|
default: import_zod.z.any().optional(),
|
|
160
162
|
properties: import_zod.z.lazy(() => import_zod.z.record(import_zod.z.string(), JSONSchemaProperty)).optional(),
|
|
@@ -164,6 +166,9 @@ var JSONSchemaProperty = import_zod.z.object({
|
|
|
164
166
|
var ParametersSchema = import_zod.z.object({
|
|
165
167
|
type: import_zod.z.literal("object"),
|
|
166
168
|
anyOf: import_zod.z.array(JSONSchemaProperty).optional(),
|
|
169
|
+
oneOf: import_zod.z.array(JSONSchemaProperty).optional(),
|
|
170
|
+
allOf: import_zod.z.array(JSONSchemaProperty).optional(),
|
|
171
|
+
not: JSONSchemaProperty.optional(),
|
|
167
172
|
properties: import_zod.z.record(import_zod.z.string(), JSONSchemaProperty),
|
|
168
173
|
required: import_zod.z.array(import_zod.z.string()).optional(),
|
|
169
174
|
title: import_zod.z.string().optional(),
|
|
@@ -708,13 +713,6 @@ var TELEMETRY_EVENTS = {
|
|
|
708
713
|
CLI_INVOKED: "CLI_INVOKED"
|
|
709
714
|
};
|
|
710
715
|
|
|
711
|
-
// src/utils/constants.ts
|
|
712
|
-
var COMPOSIO_DIR = ".composio";
|
|
713
|
-
var USER_DATA_FILE_NAME = "user_data.json";
|
|
714
|
-
var DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
715
|
-
var TELEMETRY_URL = "https://app.composio.dev";
|
|
716
|
-
var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
|
|
717
|
-
|
|
718
716
|
// src/telemetry/BatchProcessor.ts
|
|
719
717
|
var BatchProcessor = class {
|
|
720
718
|
batch = [];
|
|
@@ -748,126 +746,78 @@ var BatchProcessor = class {
|
|
|
748
746
|
}
|
|
749
747
|
};
|
|
750
748
|
|
|
751
|
-
// src/telemetry/transports/BrowserTransport.ts
|
|
752
|
-
var BrowserTelemetryTransport = class {
|
|
753
|
-
send(payload) {
|
|
754
|
-
if (typeof window === "undefined") {
|
|
755
|
-
return Promise.reject(
|
|
756
|
-
new Error("BrowserTelemetryTransport can only be used in browser environments")
|
|
757
|
-
);
|
|
758
|
-
}
|
|
759
|
-
return new Promise((resolve) => {
|
|
760
|
-
try {
|
|
761
|
-
const xhr = new XMLHttpRequest();
|
|
762
|
-
xhr.open(payload.method, payload.url, true);
|
|
763
|
-
xhr.setRequestHeader("Content-Type", "application/json");
|
|
764
|
-
Object.entries(payload.headers || {}).forEach(([key, value]) => {
|
|
765
|
-
xhr.setRequestHeader(key, value);
|
|
766
|
-
});
|
|
767
|
-
xhr.onload = function() {
|
|
768
|
-
resolve();
|
|
769
|
-
};
|
|
770
|
-
xhr.send(JSON.stringify(payload.data));
|
|
771
|
-
} catch (error) {
|
|
772
|
-
logger_default.error("Error sending error to telemetry", error);
|
|
773
|
-
resolve();
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
|
|
779
|
-
// src/telemetry/transports/ProcessTransport.ts
|
|
780
|
-
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
781
|
-
var ProcessTelemetryTransport = class {
|
|
782
|
-
send(payload) {
|
|
783
|
-
if (typeof window !== "undefined") {
|
|
784
|
-
return Promise.reject(
|
|
785
|
-
new Error("ProcessTelemetryTransport can only be used in Node.js environments")
|
|
786
|
-
);
|
|
787
|
-
}
|
|
788
|
-
return new Promise((resolve) => {
|
|
789
|
-
try {
|
|
790
|
-
const url = new URL(payload.url);
|
|
791
|
-
const protocol = url.protocol === "https:" ? "https" : "http";
|
|
792
|
-
const port = url.port || (url.protocol === "https:" ? 443 : 80);
|
|
793
|
-
const args = [
|
|
794
|
-
"-e",
|
|
795
|
-
`
|
|
796
|
-
const http = require('${protocol}');
|
|
797
|
-
const options = {
|
|
798
|
-
hostname: '${url.hostname}',
|
|
799
|
-
path: '${url.pathname}${url.search}',
|
|
800
|
-
port: ${port},
|
|
801
|
-
method: '${payload.method}',
|
|
802
|
-
headers: ${JSON.stringify(payload.headers)}
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
const req = http.request(options, (res) => {
|
|
806
|
-
res.on('data', () => {});
|
|
807
|
-
res.on('end', () => {
|
|
808
|
-
process.exit(0);
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
req.on('error', () => {
|
|
813
|
-
process.exit(0);
|
|
814
|
-
});
|
|
815
|
-
|
|
816
|
-
req.write(JSON.stringify(${JSON.stringify(payload.data)}));
|
|
817
|
-
req.end();
|
|
818
|
-
`
|
|
819
|
-
];
|
|
820
|
-
import("child_process").then(({ spawn }) => {
|
|
821
|
-
spawn("node", args, {
|
|
822
|
-
stdio: "ignore",
|
|
823
|
-
detached: false,
|
|
824
|
-
shell: false
|
|
825
|
-
}).unref();
|
|
826
|
-
resolve();
|
|
827
|
-
}).catch((error) => {
|
|
828
|
-
logger_default.error("Error sending telemetry", error);
|
|
829
|
-
resolve();
|
|
830
|
-
});
|
|
831
|
-
logger_default.debug(import_chalk3.default.yellow("Process Telemetry"), JSON.stringify(payload, null, 2));
|
|
832
|
-
} catch (error) {
|
|
833
|
-
logger_default.error("Error sending telemetry", error);
|
|
834
|
-
resolve();
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
|
|
840
749
|
// src/utils/uuid.ts
|
|
841
750
|
var import_uuid = require("uuid");
|
|
842
751
|
function getRandomUUID() {
|
|
843
752
|
return (0, import_uuid.v4)();
|
|
844
753
|
}
|
|
845
754
|
|
|
846
|
-
// src/telemetry/
|
|
755
|
+
// src/services/telemetry/TelemetryService.ts
|
|
756
|
+
var TELEMETRY_URL = "https://telemetry.composio.dev/v1";
|
|
847
757
|
var TelemetryService = class {
|
|
758
|
+
/**
|
|
759
|
+
* Sends a metric to the Telemetry API.
|
|
760
|
+
* @param payload - The payload to send to the Telemetry API.
|
|
761
|
+
* @returns The response from the Telemetry API.
|
|
762
|
+
*/
|
|
763
|
+
static async sendMetric(payload) {
|
|
764
|
+
return fetch(`${TELEMETRY_URL}/metrics/invocations`, {
|
|
765
|
+
method: "POST",
|
|
766
|
+
headers: {
|
|
767
|
+
"Content-Type": "application/json"
|
|
768
|
+
},
|
|
769
|
+
body: JSON.stringify(payload)
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Sends an error log to the Telemetry API.
|
|
774
|
+
* @param payload - The payload to send to the Telemetry API.
|
|
775
|
+
* @returns The response from the Telemetry API.
|
|
776
|
+
*/
|
|
777
|
+
static async sendErrorLog(payload) {
|
|
778
|
+
return fetch(`${TELEMETRY_URL}/errors`, {
|
|
779
|
+
method: "POST",
|
|
780
|
+
headers: {
|
|
781
|
+
"Content-Type": "application/json"
|
|
782
|
+
},
|
|
783
|
+
body: JSON.stringify(payload)
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
// src/telemetry/Telemetry.ts
|
|
789
|
+
var TelemetryTransport = class {
|
|
848
790
|
telemetryMetadata;
|
|
849
|
-
transport;
|
|
850
791
|
isTelemetryDisabled = true;
|
|
851
|
-
|
|
852
|
-
|
|
792
|
+
telemetrySource;
|
|
793
|
+
telemetrySourceName = "typescript-sdk";
|
|
794
|
+
telemetryServiceName = "sdk";
|
|
795
|
+
telemetryLanguage = "typescript";
|
|
796
|
+
batchProcessor = new BatchProcessor(200, 10, async (data) => {
|
|
797
|
+
logger_default.debug("Sending batch of telemetry metrics", data);
|
|
798
|
+
await TelemetryService.sendMetric(data);
|
|
853
799
|
});
|
|
854
|
-
setup(metadata
|
|
800
|
+
setup(metadata) {
|
|
855
801
|
this.telemetryMetadata = metadata;
|
|
856
802
|
this.isTelemetryDisabled = false;
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
this.
|
|
860
|
-
|
|
861
|
-
this.
|
|
862
|
-
this.telemetryMetadata
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
this.telemetryMetadata.transport = "process";
|
|
866
|
-
}
|
|
867
|
-
this.sendTelemetry([
|
|
803
|
+
this.telemetrySource = {
|
|
804
|
+
name: this.telemetrySourceName,
|
|
805
|
+
service: this.telemetryServiceName,
|
|
806
|
+
language: this.telemetryLanguage,
|
|
807
|
+
version: this.telemetryMetadata?.version,
|
|
808
|
+
platform: this.telemetryMetadata?.isBrowser ? "browser" : "node"
|
|
809
|
+
};
|
|
810
|
+
this.sendMetric([
|
|
868
811
|
{
|
|
869
|
-
|
|
870
|
-
|
|
812
|
+
functionName: TELEMETRY_EVENTS.SDK_INITIALIZED,
|
|
813
|
+
durationMs: 0,
|
|
814
|
+
timestamp: Date.now() / 1e3,
|
|
815
|
+
props: {},
|
|
816
|
+
source: this.telemetrySource,
|
|
817
|
+
metadata: {
|
|
818
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
819
|
+
},
|
|
820
|
+
error: void 0
|
|
871
821
|
}
|
|
872
822
|
]);
|
|
873
823
|
}
|
|
@@ -891,12 +841,19 @@ var TelemetryService = class {
|
|
|
891
841
|
const originalMethod = instance[name];
|
|
892
842
|
instance[name] = async (...args) => {
|
|
893
843
|
const telemetryPayload = {
|
|
894
|
-
|
|
895
|
-
|
|
844
|
+
functionName: `${instrumentedClassName}.${name}`,
|
|
845
|
+
durationMs: 0,
|
|
846
|
+
timestamp: Date.now() / 1e3,
|
|
847
|
+
props: {
|
|
896
848
|
fileName: instrumentedClassName,
|
|
897
849
|
method: name,
|
|
898
850
|
params: args
|
|
899
|
-
}
|
|
851
|
+
},
|
|
852
|
+
metadata: {
|
|
853
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
854
|
+
},
|
|
855
|
+
error: void 0,
|
|
856
|
+
source: this.telemetrySource
|
|
900
857
|
};
|
|
901
858
|
this.batchProcessor.pushItem(telemetryPayload);
|
|
902
859
|
try {
|
|
@@ -905,7 +862,7 @@ var TelemetryService = class {
|
|
|
905
862
|
if (error instanceof Error) {
|
|
906
863
|
if (!error.errorId) {
|
|
907
864
|
error.errorId = getRandomUUID();
|
|
908
|
-
this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
|
|
865
|
+
await this.prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args);
|
|
909
866
|
}
|
|
910
867
|
}
|
|
911
868
|
throw error;
|
|
@@ -919,11 +876,11 @@ var TelemetryService = class {
|
|
|
919
876
|
* @returns true if the telemetry should be sent, false otherwise
|
|
920
877
|
*/
|
|
921
878
|
shouldSendTelemetry() {
|
|
922
|
-
const
|
|
879
|
+
const telemetryDisabledEnvironments = ["test", "ci"];
|
|
923
880
|
const nodeEnv = (getEnvVariable("NODE_ENV", "development") || "").toLowerCase();
|
|
924
|
-
const
|
|
881
|
+
const isDisabledEnvironment = telemetryDisabledEnvironments.includes(nodeEnv);
|
|
925
882
|
const isTelemetryDisabledByEnv = getEnvVariable("TELEMETRY_DISABLED", "false") === "true";
|
|
926
|
-
return
|
|
883
|
+
return !this.isTelemetryDisabled && !isTelemetryDisabledByEnv && !isDisabledEnvironment;
|
|
927
884
|
}
|
|
928
885
|
/**
|
|
929
886
|
* Prepare and send the error telemetry.
|
|
@@ -934,78 +891,78 @@ var TelemetryService = class {
|
|
|
934
891
|
* @param {string} instrumentedClassName - The class name of the instrumented class.
|
|
935
892
|
* @param {string} name - The name of the method that threw the error.
|
|
936
893
|
*/
|
|
937
|
-
prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
|
|
894
|
+
async prepareAndSendErrorTelemetry(error, instrumentedClassName, name, args) {
|
|
895
|
+
const telemetryPayload = {
|
|
896
|
+
functionName: `${instrumentedClassName}.${name}`,
|
|
897
|
+
durationMs: 0,
|
|
898
|
+
timestamp: Date.now() / 1e3,
|
|
899
|
+
props: {
|
|
900
|
+
fileName: instrumentedClassName,
|
|
901
|
+
method: name,
|
|
902
|
+
params: args
|
|
903
|
+
},
|
|
904
|
+
metadata: {
|
|
905
|
+
provider: this.telemetryMetadata?.provider ?? "openai"
|
|
906
|
+
},
|
|
907
|
+
source: this.telemetrySource
|
|
908
|
+
};
|
|
938
909
|
if (error instanceof import_client2.ComposioError) {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
910
|
+
telemetryPayload.error = {
|
|
911
|
+
errorId: error.errorId,
|
|
912
|
+
name: error.name,
|
|
913
|
+
message: error.message,
|
|
914
|
+
stack: error.stack
|
|
945
915
|
};
|
|
946
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
947
916
|
} else if (error instanceof ComposioError) {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
possible_fix: error.possibleFixes?.join("\n"),
|
|
955
|
-
description: `Original Call : ${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
917
|
+
telemetryPayload.error = {
|
|
918
|
+
errorId: error.errorId,
|
|
919
|
+
name: error.name,
|
|
920
|
+
code: error.code,
|
|
921
|
+
message: error.message,
|
|
922
|
+
stack: error.stack
|
|
956
923
|
};
|
|
957
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
958
924
|
} else if (error instanceof Error) {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
description: `Original Call : ${this.telemetryMetadata?.source}:${instrumentedClassName}.${name}(${JSON.stringify(args)})`
|
|
925
|
+
telemetryPayload.error = {
|
|
926
|
+
errorId: error.errorId,
|
|
927
|
+
name: error.name ?? "Unknown error",
|
|
928
|
+
message: error.message,
|
|
929
|
+
stack: error.stack
|
|
965
930
|
};
|
|
966
|
-
this.sendErrorTelemetry(telemetryPayload);
|
|
967
931
|
}
|
|
932
|
+
await this.sendErrorTelemetry(telemetryPayload);
|
|
968
933
|
}
|
|
969
934
|
/**
|
|
970
935
|
* Send the telemetry payload to the server.
|
|
971
936
|
* @param payload - the telemetry payload to send
|
|
972
937
|
* @returns
|
|
973
938
|
*/
|
|
974
|
-
async
|
|
939
|
+
async sendMetric(payload) {
|
|
975
940
|
if (!this.shouldSendTelemetry()) {
|
|
941
|
+
logger_default.debug("Telemetry is disabled, skipping metric telemetry", payload);
|
|
976
942
|
return;
|
|
977
943
|
}
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
url,
|
|
985
|
-
method: "POST",
|
|
986
|
-
headers: { "Content-Type": "application/json" }
|
|
987
|
-
};
|
|
988
|
-
this.transport.send(reqPayload);
|
|
944
|
+
try {
|
|
945
|
+
logger_default.debug("SDK Metric", payload);
|
|
946
|
+
await TelemetryService.sendMetric(payload);
|
|
947
|
+
} catch (error) {
|
|
948
|
+
logger_default.error("Error sending metric telemetry", error);
|
|
949
|
+
}
|
|
989
950
|
}
|
|
990
951
|
// @TODO: check if this will send the error telemetry to the server
|
|
991
952
|
async sendErrorTelemetry(payload) {
|
|
992
953
|
if (!this.shouldSendTelemetry()) {
|
|
954
|
+
logger_default.debug("Telemetry is disabled, skipping metric telemetry", payload);
|
|
993
955
|
return;
|
|
994
956
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
url,
|
|
1002
|
-
method: "POST",
|
|
1003
|
-
headers: { "Content-Type": "application/json" }
|
|
1004
|
-
};
|
|
1005
|
-
this.transport.send(reqPayload);
|
|
957
|
+
try {
|
|
958
|
+
logger_default.debug("SDK Error Telemetry", payload);
|
|
959
|
+
await TelemetryService.sendErrorLog(payload);
|
|
960
|
+
} catch (error) {
|
|
961
|
+
logger_default.error("Error sending error telemetry", error);
|
|
962
|
+
}
|
|
1006
963
|
}
|
|
1007
964
|
};
|
|
1008
|
-
var telemetry = new
|
|
965
|
+
var telemetry = new TelemetryTransport();
|
|
1009
966
|
|
|
1010
967
|
// src/errors/AuthConfigErrors.ts
|
|
1011
968
|
var AuthConfigErrorCodes = {
|
|
@@ -2076,7 +2033,8 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = {
|
|
|
2076
2033
|
schema
|
|
2077
2034
|
);
|
|
2078
2035
|
}
|
|
2079
|
-
|
|
2036
|
+
const zodSchema = (0, import_json_schema_to_zod.jsonSchemaToZod)(schema);
|
|
2037
|
+
return zodSchema;
|
|
2080
2038
|
} catch (error) {
|
|
2081
2039
|
throw new JsonSchemaToZodError("Failed to convert JSON Schema to Zod Schema", {
|
|
2082
2040
|
cause: error
|
|
@@ -2725,6 +2683,14 @@ var ToolkitRetrieveCategoriesResponseSchema = import_zod7.z.object({
|
|
|
2725
2683
|
nextCursor: import_zod7.z.string().nullable(),
|
|
2726
2684
|
totalPages: import_zod7.z.number()
|
|
2727
2685
|
});
|
|
2686
|
+
var ToolkitAuthFieldsResponseSchema = import_zod7.z.object({
|
|
2687
|
+
authScheme: AuthSchemeEnum,
|
|
2688
|
+
fields: import_zod7.z.array(
|
|
2689
|
+
ToolkitAuthFieldSchema.extend({
|
|
2690
|
+
required: import_zod7.z.boolean().optional()
|
|
2691
|
+
})
|
|
2692
|
+
)
|
|
2693
|
+
});
|
|
2728
2694
|
|
|
2729
2695
|
// src/models/AuthConfigs.ts
|
|
2730
2696
|
var AuthConfigs = class {
|
|
@@ -3581,6 +3547,89 @@ var Toolkits = class {
|
|
|
3581
3547
|
}
|
|
3582
3548
|
return this.getToolkits(arg);
|
|
3583
3549
|
}
|
|
3550
|
+
async getAuthConfigFields(toolkitSlug, authScheme, authConfigType, requiredOnly) {
|
|
3551
|
+
const toolkit = await this.getToolkitBySlug(toolkitSlug);
|
|
3552
|
+
if (!toolkit.authConfigDetails) {
|
|
3553
|
+
throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
|
|
3554
|
+
meta: {
|
|
3555
|
+
toolkitSlug
|
|
3556
|
+
}
|
|
3557
|
+
});
|
|
3558
|
+
}
|
|
3559
|
+
if (toolkit.authConfigDetails.length > 1 && !authScheme) {
|
|
3560
|
+
logger_default.warn(
|
|
3561
|
+
`Multiple auth configs found for ${toolkitSlug}, please specify the auth scheme to get details of specific auth scheme. Selecting the first scheme by default.`,
|
|
3562
|
+
{
|
|
3563
|
+
meta: {
|
|
3564
|
+
toolkitSlug
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
);
|
|
3568
|
+
}
|
|
3569
|
+
const authConfig = authScheme ? toolkit.authConfigDetails.find((authConfig2) => authConfig2.mode === authScheme) : toolkit.authConfigDetails[0];
|
|
3570
|
+
if (!authConfig) {
|
|
3571
|
+
throw new ComposioAuthConfigNotFoundError("No auth config found for toolkit", {
|
|
3572
|
+
meta: {
|
|
3573
|
+
toolkitSlug,
|
|
3574
|
+
authScheme
|
|
3575
|
+
}
|
|
3576
|
+
});
|
|
3577
|
+
}
|
|
3578
|
+
const requiredFields = authConfig.fields[authConfigType].required.map((field) => ({
|
|
3579
|
+
...field,
|
|
3580
|
+
required: true
|
|
3581
|
+
}));
|
|
3582
|
+
if (requiredOnly) {
|
|
3583
|
+
return {
|
|
3584
|
+
authScheme: AuthSchemeEnum.parse(authConfig.mode),
|
|
3585
|
+
fields: requiredFields
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
const optionalFields = authConfig.fields[authConfigType].optional.map((field) => ({
|
|
3589
|
+
...field,
|
|
3590
|
+
required: false
|
|
3591
|
+
}));
|
|
3592
|
+
return {
|
|
3593
|
+
authScheme: AuthSchemeEnum.parse(authConfig.mode),
|
|
3594
|
+
fields: [...requiredFields, ...optionalFields]
|
|
3595
|
+
};
|
|
3596
|
+
}
|
|
3597
|
+
/**
|
|
3598
|
+
* Retrieves the fields required for creating an auth config for a toolkit.
|
|
3599
|
+
* @param toolkitSlug - The slug of the toolkit to retrieve the fields for
|
|
3600
|
+
* @param authScheme - The auth scheme to retrieve the fields for
|
|
3601
|
+
* @param requiredOnly - Whether to only return the required fields
|
|
3602
|
+
* @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for creating an auth config
|
|
3603
|
+
*/
|
|
3604
|
+
async getAuthConfigCreationFields(toolkitSlug, {
|
|
3605
|
+
authScheme,
|
|
3606
|
+
requiredOnly = false
|
|
3607
|
+
} = {}) {
|
|
3608
|
+
return this.getAuthConfigFields(
|
|
3609
|
+
toolkitSlug,
|
|
3610
|
+
authScheme ?? null,
|
|
3611
|
+
"authConfigCreation",
|
|
3612
|
+
requiredOnly
|
|
3613
|
+
);
|
|
3614
|
+
}
|
|
3615
|
+
/**
|
|
3616
|
+
* Retrieves the fields required for initiating a connected account for a toolkit.
|
|
3617
|
+
* @param toolkitSlug - The slug of the toolkit to retrieve the fields for
|
|
3618
|
+
* @param authScheme - The auth scheme to retrieve the fields for
|
|
3619
|
+
* @param requiredOnly - Whether to only return the required fields
|
|
3620
|
+
* @returns {Promise<ToolkitAuthFieldsResponse>} The fields required for initiating a connected account
|
|
3621
|
+
*/
|
|
3622
|
+
async getConnectedAccountInitiationFields(toolkitSlug, {
|
|
3623
|
+
authScheme,
|
|
3624
|
+
requiredOnly = false
|
|
3625
|
+
} = {}) {
|
|
3626
|
+
return this.getAuthConfigFields(
|
|
3627
|
+
toolkitSlug,
|
|
3628
|
+
authScheme ?? null,
|
|
3629
|
+
"connectedAccountInitiation",
|
|
3630
|
+
requiredOnly
|
|
3631
|
+
);
|
|
3632
|
+
}
|
|
3584
3633
|
/**
|
|
3585
3634
|
* Retrieves all toolkit categories available in the Composio SDK.
|
|
3586
3635
|
*
|
|
@@ -4319,6 +4368,12 @@ var Triggers = class {
|
|
|
4319
4368
|
}
|
|
4320
4369
|
};
|
|
4321
4370
|
|
|
4371
|
+
// src/utils/constants.ts
|
|
4372
|
+
var COMPOSIO_DIR = ".composio";
|
|
4373
|
+
var USER_DATA_FILE_NAME = "user_data.json";
|
|
4374
|
+
var DEFAULT_BASE_URL = "https://backend.composio.dev";
|
|
4375
|
+
var IS_DEVELOPMENT_OR_CI = process.env.DEVELOPMENT || process.env.CI || false;
|
|
4376
|
+
|
|
4322
4377
|
// src/utils/sdk.ts
|
|
4323
4378
|
var userDataPath = () => {
|
|
4324
4379
|
try {
|
|
@@ -4835,7 +4890,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
4835
4890
|
};
|
|
4836
4891
|
|
|
4837
4892
|
// package.json
|
|
4838
|
-
var version = "0.1.
|
|
4893
|
+
var version = "0.1.19";
|
|
4839
4894
|
|
|
4840
4895
|
// src/composio.ts
|
|
4841
4896
|
var Composio = class _Composio {
|
|
@@ -4872,7 +4927,6 @@ var Composio = class _Composio {
|
|
|
4872
4927
|
* @param {boolean} [config.allowTracking=true] - Whether to allow anonymous usage analytics
|
|
4873
4928
|
* @param {boolean} [config.allowTracing=true] - Whether to allow request tracing for debugging
|
|
4874
4929
|
* @param {TProvider} [config.provider] - The provider to use for this Composio instance (defaults to OpenAIProvider)
|
|
4875
|
-
* @param {BaseTelemetryTransport} [config.telemetryTransport] - Custom telemetry transport implementation
|
|
4876
4930
|
*
|
|
4877
4931
|
* @example
|
|
4878
4932
|
* ```typescript
|
|
@@ -4918,23 +4972,21 @@ var Composio = class _Composio {
|
|
|
4918
4972
|
this.authConfigs = new AuthConfigs(this.client);
|
|
4919
4973
|
this.connectedAccounts = new ConnectedAccounts(this.client);
|
|
4920
4974
|
if (this.config.allowTracking) {
|
|
4921
|
-
telemetry.setup(
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
config?.telemetryTransport
|
|
4937
|
-
);
|
|
4975
|
+
telemetry.setup({
|
|
4976
|
+
apiKey: apiKeyParsed ?? "",
|
|
4977
|
+
baseUrl: baseURLParsed ?? "",
|
|
4978
|
+
frameworkRuntime: this.provider?.name ?? "unknown",
|
|
4979
|
+
isAgentic: this.provider?._isAgentic || false,
|
|
4980
|
+
source: "composio-sdk-typescript",
|
|
4981
|
+
version,
|
|
4982
|
+
sdkType: "Typescript-V3",
|
|
4983
|
+
isBrowser: typeof window !== "undefined",
|
|
4984
|
+
provider: this.provider?.name ?? "openai",
|
|
4985
|
+
// @TODO: Users might want to pass their own session id
|
|
4986
|
+
// @TODO: We shouldn't be doing this as people might always have one session id throughout the process in server
|
|
4987
|
+
sessionId: this.config.allowTracing ? getRandomUUID() : void 0
|
|
4988
|
+
// @TODO: get the session id
|
|
4989
|
+
});
|
|
4938
4990
|
}
|
|
4939
4991
|
telemetry.instrument(this);
|
|
4940
4992
|
telemetry.instrument(this.provider);
|
|
@@ -5003,17 +5055,6 @@ var ComposioProvider = class extends BaseNonAgenticProvider {
|
|
|
5003
5055
|
}
|
|
5004
5056
|
};
|
|
5005
5057
|
|
|
5006
|
-
// src/telemetry/TelemetryTransport.ts
|
|
5007
|
-
var import_chalk4 = __toESM(require("chalk"), 1);
|
|
5008
|
-
var BaseTelemetryTransport = class {
|
|
5009
|
-
};
|
|
5010
|
-
var ConsoleTelemetryTransport = class {
|
|
5011
|
-
send(payload) {
|
|
5012
|
-
logger_default.debug(import_chalk4.default.yellow("telemetry"), JSON.stringify(payload, null, 2));
|
|
5013
|
-
return Promise.resolve();
|
|
5014
|
-
}
|
|
5015
|
-
};
|
|
5016
|
-
|
|
5017
5058
|
// src/models/AuthScheme.ts
|
|
5018
5059
|
var AuthScheme = class {
|
|
5019
5060
|
/**
|
|
@@ -5195,7 +5236,6 @@ var AuthScheme = class {
|
|
|
5195
5236
|
AuthSchemeTypes,
|
|
5196
5237
|
BaseAgenticProvider,
|
|
5197
5238
|
BaseNonAgenticProvider,
|
|
5198
|
-
BaseTelemetryTransport,
|
|
5199
5239
|
BasicWithJwtConnectionDataSchema,
|
|
5200
5240
|
BillcomAuthConnectionDataSchema,
|
|
5201
5241
|
Composio,
|
|
@@ -5220,7 +5260,6 @@ var AuthScheme = class {
|
|
|
5220
5260
|
ConnectionRequestFailedError,
|
|
5221
5261
|
ConnectionRequestTimeoutError,
|
|
5222
5262
|
ConnectionStatuses,
|
|
5223
|
-
ConsoleTelemetryTransport,
|
|
5224
5263
|
CreateAuthConfigParamsSchema,
|
|
5225
5264
|
CreateAuthConfigResponseSchema,
|
|
5226
5265
|
CreateComposioManagedAuthConfigParamsSchema,
|
|
@@ -5258,6 +5297,7 @@ var AuthScheme = class {
|
|
|
5258
5297
|
ToolSchema,
|
|
5259
5298
|
ToolkitAuthConfigDetailsSchema,
|
|
5260
5299
|
ToolkitAuthFieldSchema,
|
|
5300
|
+
ToolkitAuthFieldsResponseSchema,
|
|
5261
5301
|
ToolkitCategorySchema,
|
|
5262
5302
|
ToolkitErrorCodes,
|
|
5263
5303
|
ToolkitMangedByEnumSchema,
|