@toothfairyai/sdk 0.6.2 → 0.6.4

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.
Files changed (38) hide show
  1. package/README.md +171 -75
  2. package/build/agent_functions/AgentFunctionManager.d.ts +41 -7
  3. package/build/agent_functions/AgentFunctionManager.d.ts.map +1 -1
  4. package/build/agent_functions/AgentFunctionManager.js +56 -13
  5. package/build/agent_functions/AgentFunctionManager.js.map +1 -1
  6. package/build/benchmarks/BenchmarkManager.d.ts +21 -6
  7. package/build/benchmarks/BenchmarkManager.d.ts.map +1 -1
  8. package/build/benchmarks/BenchmarkManager.js +34 -11
  9. package/build/benchmarks/BenchmarkManager.js.map +1 -1
  10. package/build/billing/BillingManager.d.ts +1 -0
  11. package/build/billing/BillingManager.d.ts.map +1 -1
  12. package/build/billing/BillingManager.js +4 -1
  13. package/build/billing/BillingManager.js.map +1 -1
  14. package/build/channels/ChannelManager.d.ts +17 -6
  15. package/build/channels/ChannelManager.d.ts.map +1 -1
  16. package/build/channels/ChannelManager.js +55 -11
  17. package/build/channels/ChannelManager.js.map +1 -1
  18. package/build/charting_settings/ChartingSettingsManager.d.ts +9 -3
  19. package/build/charting_settings/ChartingSettingsManager.d.ts.map +1 -1
  20. package/build/charting_settings/ChartingSettingsManager.js +4 -4
  21. package/build/charting_settings/ChartingSettingsManager.js.map +1 -1
  22. package/build/embeddings_settings/EmbeddingsSettingsManager.d.ts +9 -3
  23. package/build/embeddings_settings/EmbeddingsSettingsManager.d.ts.map +1 -1
  24. package/build/embeddings_settings/EmbeddingsSettingsManager.js +4 -4
  25. package/build/embeddings_settings/EmbeddingsSettingsManager.js.map +1 -1
  26. package/build/hooks/HookManager.d.ts +20 -6
  27. package/build/hooks/HookManager.d.ts.map +1 -1
  28. package/build/hooks/HookManager.js +43 -11
  29. package/build/hooks/HookManager.js.map +1 -1
  30. package/build/scheduled_jobs/ScheduledJobManager.d.ts +32 -6
  31. package/build/scheduled_jobs/ScheduledJobManager.d.ts.map +1 -1
  32. package/build/scheduled_jobs/ScheduledJobManager.js +49 -11
  33. package/build/scheduled_jobs/ScheduledJobManager.js.map +1 -1
  34. package/build/sites/SiteManager.d.ts +10 -5
  35. package/build/sites/SiteManager.d.ts.map +1 -1
  36. package/build/sites/SiteManager.js +23 -10
  37. package/build/sites/SiteManager.js.map +1 -1
  38. package/package.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,40 @@
2
2
 
3
3
  Official TypeScript SDK for the ToothFairyAI API - A comprehensive toolkit for building AI-powered applications with chat, document processing, agent management, and more.
4
4
 
5
+ **Status**: Production Ready | **Version**: 0.6.4
6
+
7
+ ## Test Results
8
+
9
+ The SDK includes comprehensive verification tests ensuring all managers and methods are properly implemented:
10
+
11
+ ```
12
+ Test Suites: 1 passed, 1 total
13
+ Tests: 62 passed, 62 total
14
+
15
+ ✓ SDK Structure (3 tests)
16
+ - Client initialization with proper parameters
17
+ - All 24 managers accessible
18
+ - Expected methods on each manager
19
+
20
+ ✓ Method Signatures (17 tests)
21
+ - Agent, Chat, Document, Entity, Streaming, Billing managers
22
+
23
+ ✓ Error Handling (5 tests)
24
+ - Missing API key/workspace ID validation
25
+ - ToothFairyError properties and inheritance
26
+
27
+ ✓ SDK Completeness (27 tests)
28
+ - Core files present
29
+ - All 24 manager directories with manager files
30
+ - Proper export structure
31
+
32
+ ✓ Type Definitions (4 tests)
33
+ - AgentMode, EntityType, DocumentType, StreamEventType
34
+
35
+ ✓ Client Methods (6 tests)
36
+ - testConnection, getHealth, getStreamingUrl, getWorkspaceId, getConfig, request, aiRequest
37
+ ```
38
+
5
39
  ## Installation
6
40
 
7
41
  ```bash
@@ -697,26 +731,33 @@ const cloned = await client.prompts.clone('prompt-id', 'user-123', {
697
731
  #### Create an Agent Function
698
732
 
699
733
  ```typescript
700
- const func = await client.agentFunctions.create({
701
- id: 'function-1',
702
- name: 'Weather API',
734
+ // Create a GET function
735
+ const getFunc = await client.agentFunctions.create('Weather API', {
736
+ description: 'Get current weather data for a location',
703
737
  url: 'https://api.weather.com/current',
704
- model: 'gpt-4',
705
738
  requestType: 'GET',
706
739
  authorisationType: 'bearer',
707
740
  authorisationKey: 'your-token',
708
- description: 'Get current weather data',
709
741
  parameters: [
710
742
  { name: 'location', type: 'string', required: true }
711
743
  ]
712
744
  });
745
+
746
+ // Create a POST function with headers
747
+ const postFunc = await client.agentFunctions.create('Create Order', {
748
+ description: 'Create a new order in the system',
749
+ url: 'https://api.example.com/orders',
750
+ requestType: 'POST',
751
+ authorisationType: 'apikey',
752
+ headers: [{ key: 'Content-Type', value: 'application/json' }],
753
+ staticArgs: [{ key: 'source', value: 'chatbot' }]
754
+ });
713
755
  ```
714
756
 
715
757
  #### Update Agent Function
716
758
 
717
759
  ```typescript
718
- const func = await client.agentFunctions.update({
719
- id: 'function-1',
760
+ const func = await client.agentFunctions.update('function-id', {
720
761
  name: 'Updated Function Name',
721
762
  url: 'https://new-url.com'
722
763
  });
@@ -725,13 +766,13 @@ const func = await client.agentFunctions.update({
725
766
  #### Delete Agent Function
726
767
 
727
768
  ```typescript
728
- await client.agentFunctions.delete('function-1');
769
+ await client.agentFunctions.delete('function-id');
729
770
  ```
730
771
 
731
772
  #### Get Agent Function
732
773
 
733
774
  ```typescript
734
- const func = await client.agentFunctions.get('function-1');
775
+ const func = await client.agentFunctions.get('function-id');
735
776
  console.log(`Name: ${func.name}`);
736
777
  console.log(`URL: ${func.url}`);
737
778
  ```
@@ -739,23 +780,40 @@ console.log(`URL: ${func.url}`);
739
780
  #### List Agent Functions
740
781
 
741
782
  ```typescript
742
- const functions = await client.agentFunctions.list(20);
783
+ const functions = await client.agentFunctions.list(20, 0);
743
784
  for (const func of functions.items) {
744
785
  console.log(`${func.name}`);
745
786
  }
746
787
  ```
747
788
 
789
+ #### Search Agent Functions
790
+
791
+ ```typescript
792
+ const results = await client.agentFunctions.search('weather');
793
+ for (const func of results) {
794
+ console.log(`${func.name}`);
795
+ }
796
+ ```
797
+
748
798
  ### Authorisations
749
799
 
750
800
  #### Create an Authorisation
751
801
 
752
802
  ```typescript
753
- const auth = await client.authorisations.create({
754
- id: 'auth-1',
755
- name: 'GitHub OAuth',
756
- type: 'oauth',
757
- tokenSecret: 'encrypted-token',
758
- description: 'GitHub OAuth token for API access',
803
+ // API Key authorisation
804
+ const apiKeyAuth = await client.authorisations.create('External API Key', 'apikey', {
805
+ description: 'API key for external service',
806
+ tokenSecret: 'your-api-key-value'
807
+ });
808
+
809
+ // Bearer token authorisation
810
+ const bearerAuth = await client.authorisations.create('Service Token', 'bearer', {
811
+ tokenSecret: 'your-bearer-token'
812
+ });
813
+
814
+ // OAuth authorisation
815
+ const oauthAuth = await client.authorisations.create('GitHub OAuth', 'oauth', {
816
+ description: 'GitHub OAuth for API access',
759
817
  scope: 'repo,user',
760
818
  grantType: 'authorization_code',
761
819
  clientId: 'github-client-id',
@@ -768,23 +826,22 @@ const auth = await client.authorisations.create({
768
826
  #### Update Authorisation
769
827
 
770
828
  ```typescript
771
- const auth = await client.authorisations.update({
772
- id: 'auth-1',
829
+ const auth = await client.authorisations.update('auth-id', {
773
830
  name: 'Updated Auth Name',
774
- scope: 'repo,user,admin'
831
+ description: 'New description'
775
832
  });
776
833
  ```
777
834
 
778
835
  #### Delete Authorisation
779
836
 
780
837
  ```typescript
781
- await client.authorisations.delete('auth-1');
838
+ await client.authorisations.delete('auth-id');
782
839
  ```
783
840
 
784
841
  #### Get Authorisation
785
842
 
786
843
  ```typescript
787
- const auth = await client.authorisations.get('auth-1');
844
+ const auth = await client.authorisations.get('auth-id');
788
845
  console.log(`Name: ${auth.name}`);
789
846
  console.log(`Type: ${auth.type}`);
790
847
  ```
@@ -792,23 +849,35 @@ console.log(`Type: ${auth.type}`);
792
849
  #### List Authorisations
793
850
 
794
851
  ```typescript
795
- const auths = await client.authorisations.list(20);
852
+ const auths = await client.authorisations.list(20, 0);
796
853
  for (const auth of auths.items) {
797
854
  console.log(`${auth.name} (${auth.type})`);
798
855
  }
799
856
  ```
800
857
 
858
+ #### Get Authorisations by Type
859
+
860
+ ```typescript
861
+ const apiKeys = await client.authorisations.getByType('apikey');
862
+ const oauthAuths = await client.authorisations.getByType('oauth');
863
+ ```
864
+
865
+ #### Search Authorisations
866
+
867
+ ```typescript
868
+ const results = await client.authorisations.search('github');
869
+ for (const auth of results) {
870
+ console.log(`${auth.name}`);
871
+ }
872
+ ```
873
+
801
874
  ### Channels
802
875
 
803
876
  #### Create a Channel
804
877
 
805
878
  ```typescript
806
- const channel = await client.channels.create({
807
- id: 'channel-1',
808
- name: 'SMS Channel',
809
- channel: 'sms',
810
- provider: 'twilio',
811
- senderid: '+1234567890',
879
+ const channel = await client.channels.create('SMS Channel', 'sms', 'twilio', {
880
+ senderId: '+1234567890',
812
881
  description: 'SMS notifications via Twilio',
813
882
  isActive: true
814
883
  });
@@ -817,8 +886,7 @@ const channel = await client.channels.create({
817
886
  #### Update Channel
818
887
 
819
888
  ```typescript
820
- const channel = await client.channels.update({
821
- id: 'channel-1',
889
+ const channel = await client.channels.update('channel-id', {
822
890
  name: 'Updated Channel',
823
891
  isActive: false
824
892
  });
@@ -827,13 +895,13 @@ const channel = await client.channels.update({
827
895
  #### Delete Channel
828
896
 
829
897
  ```typescript
830
- await client.channels.delete('channel-1');
898
+ await client.channels.delete('channel-id');
831
899
  ```
832
900
 
833
901
  #### Get Channel
834
902
 
835
903
  ```typescript
836
- const channel = await client.channels.get('channel-1');
904
+ const channel = await client.channels.get('channel-id');
837
905
  console.log(`Name: ${channel.name}`);
838
906
  console.log(`Provider: ${channel.provider}`);
839
907
  ```
@@ -841,7 +909,7 @@ console.log(`Provider: ${channel.provider}`);
841
909
  #### List Channels
842
910
 
843
911
  ```typescript
844
- const channels = await client.channels.list(20);
912
+ const channels = await client.channels.list(20, 0);
845
913
  for (const channel of channels.items) {
846
914
  console.log(`${channel.name} (${channel.provider})`);
847
915
  }
@@ -861,12 +929,28 @@ console.log(`Host: ${connection.host}`);
861
929
  #### List Connections
862
930
 
863
931
  ```typescript
864
- const connections = await client.connections.list(20);
932
+ const connections = await client.connections.list(20, 0);
865
933
  for (const conn of connections.items) {
866
934
  console.log(`${conn.name} (${conn.type})`);
867
935
  }
868
936
  ```
869
937
 
938
+ #### Get Connections by Type
939
+
940
+ ```typescript
941
+ const postgresConns = await client.connections.getByType('postgres');
942
+ const mysqlConns = await client.connections.getByType('mysql');
943
+ ```
944
+
945
+ #### Search Connections
946
+
947
+ ```typescript
948
+ const results = await client.connections.search('database');
949
+ for (const conn of results) {
950
+ console.log(`${conn.name}`);
951
+ }
952
+ ```
953
+
870
954
  #### Delete Connection
871
955
 
872
956
  ```typescript
@@ -923,7 +1007,7 @@ console.log(`Status: ${site.status}`);
923
1007
  #### List Sites
924
1008
 
925
1009
  ```typescript
926
- const sites = await client.sites.list(20);
1010
+ const sites = await client.sites.list(20, 0);
927
1011
  for (const site of sites.items) {
928
1012
  console.log(`${site.name} - ${site.url}`);
929
1013
  }
@@ -932,8 +1016,7 @@ for (const site of sites.items) {
932
1016
  #### Update Site
933
1017
 
934
1018
  ```typescript
935
- const site = await client.sites.update({
936
- id: 'site-id',
1019
+ const site = await client.sites.update('site-id', {
937
1020
  name: 'Updated Site',
938
1021
  status: 'active',
939
1022
  allowedPaths: ['/docs', '/blog']
@@ -951,9 +1034,7 @@ await client.sites.delete('site-id');
951
1034
  #### Create a Benchmark
952
1035
 
953
1036
  ```typescript
954
- const benchmark = await client.benchmarks.create({
955
- id: 'benchmark-1',
956
- name: 'Customer Support Test',
1037
+ const benchmark = await client.benchmarks.create('Customer Support Test', {
957
1038
  description: 'Test agent performance on customer support queries',
958
1039
  questions: [
959
1040
  {
@@ -970,8 +1051,7 @@ const benchmark = await client.benchmarks.create({
970
1051
  #### Update Benchmark
971
1052
 
972
1053
  ```typescript
973
- const benchmark = await client.benchmarks.update({
974
- id: 'benchmark-1',
1054
+ const benchmark = await client.benchmarks.update('benchmark-id', {
975
1055
  name: 'Updated Benchmark',
976
1056
  description: 'New description'
977
1057
  });
@@ -980,13 +1060,13 @@ const benchmark = await client.benchmarks.update({
980
1060
  #### Delete Benchmark
981
1061
 
982
1062
  ```typescript
983
- await client.benchmarks.delete('benchmark-1');
1063
+ await client.benchmarks.delete('benchmark-id');
984
1064
  ```
985
1065
 
986
1066
  #### Get Benchmark
987
1067
 
988
1068
  ```typescript
989
- const benchmark = await client.benchmarks.get('benchmark-1');
1069
+ const benchmark = await client.benchmarks.get('benchmark-id');
990
1070
  console.log(`Name: ${benchmark.name}`);
991
1071
  console.log(`Questions: ${benchmark.questions?.length}`);
992
1072
  ```
@@ -994,7 +1074,7 @@ console.log(`Questions: ${benchmark.questions?.length}`);
994
1074
  #### List Benchmarks
995
1075
 
996
1076
  ```typescript
997
- const benchmarks = await client.benchmarks.list(20);
1077
+ const benchmarks = await client.benchmarks.list(20, 0);
998
1078
  for (const benchmark of benchmarks.items) {
999
1079
  console.log(`${benchmark.name}`);
1000
1080
  }
@@ -1005,14 +1085,11 @@ for (const benchmark of benchmarks.items) {
1005
1085
  #### Create a Hook
1006
1086
 
1007
1087
  ```typescript
1008
- const hook = await client.hooks.create({
1009
- id: 'hook-1',
1010
- name: 'Data Processing Hook',
1011
- functionName: 'process_data',
1088
+ const hook = await client.hooks.create('Data Processing Hook', 'process_data', {
1012
1089
  customExecutionCode: 'def process_data(data): return data.upper()',
1013
1090
  customExecutionInstructions: 'Process incoming data',
1014
1091
  availableLibraries: 'pandas,numpy',
1015
- allowExternalAPI: true,
1092
+ allowExternalApi: true,
1016
1093
  hardcodedScript: false
1017
1094
  });
1018
1095
  ```
@@ -1020,8 +1097,7 @@ const hook = await client.hooks.create({
1020
1097
  #### Update Hook
1021
1098
 
1022
1099
  ```typescript
1023
- const hook = await client.hooks.update({
1024
- id: 'hook-1',
1100
+ const hook = await client.hooks.update('hook-id', {
1025
1101
  name: 'Updated Hook',
1026
1102
  customExecutionCode: 'def process_data(data): return data.lower()'
1027
1103
  });
@@ -1030,13 +1106,13 @@ const hook = await client.hooks.update({
1030
1106
  #### Delete Hook
1031
1107
 
1032
1108
  ```typescript
1033
- await client.hooks.delete('hook-1');
1109
+ await client.hooks.delete('hook-id');
1034
1110
  ```
1035
1111
 
1036
1112
  #### Get Hook
1037
1113
 
1038
1114
  ```typescript
1039
- const hook = await client.hooks.get('hook-1');
1115
+ const hook = await client.hooks.get('hook-id');
1040
1116
  console.log(`Name: ${hook.name}`);
1041
1117
  console.log(`Function: ${hook.functionName}`);
1042
1118
  ```
@@ -1044,7 +1120,7 @@ console.log(`Function: ${hook.functionName}`);
1044
1120
  #### List Hooks
1045
1121
 
1046
1122
  ```typescript
1047
- const hooks = await client.hooks.list(20);
1123
+ const hooks = await client.hooks.list(20, 0);
1048
1124
  for (const hook of hooks.items) {
1049
1125
  console.log(`${hook.name}`);
1050
1126
  }
@@ -1055,12 +1131,10 @@ for (const hook of hooks.items) {
1055
1131
  #### Create a Scheduled Job
1056
1132
 
1057
1133
  ```typescript
1058
- const job = await client.scheduledJobs.create({
1059
- id: 'job-1',
1060
- name: 'Daily Report',
1134
+ const job = await client.scheduledJobs.create('Daily Report', {
1061
1135
  description: 'Generate daily report at 9 AM',
1062
- agentID: 'agent-id',
1063
- customPromptID: 'prompt-id',
1136
+ agentId: 'agent-id',
1137
+ customPromptId: 'prompt-id',
1064
1138
  forcedPrompt: 'Generate a daily summary report',
1065
1139
  schedule: {
1066
1140
  frequency: 'DAILY',
@@ -1076,8 +1150,7 @@ const job = await client.scheduledJobs.create({
1076
1150
  #### Update Scheduled Job
1077
1151
 
1078
1152
  ```typescript
1079
- const job = await client.scheduledJobs.update({
1080
- id: 'job-1',
1153
+ const job = await client.scheduledJobs.update('job-id', {
1081
1154
  name: 'Updated Job',
1082
1155
  isActive: false,
1083
1156
  schedule: {
@@ -1091,13 +1164,13 @@ const job = await client.scheduledJobs.update({
1091
1164
  #### Delete Scheduled Job
1092
1165
 
1093
1166
  ```typescript
1094
- await client.scheduledJobs.delete('job-1');
1167
+ await client.scheduledJobs.delete('job-id');
1095
1168
  ```
1096
1169
 
1097
1170
  #### Get Scheduled Job
1098
1171
 
1099
1172
  ```typescript
1100
- const job = await client.scheduledJobs.get('job-1');
1173
+ const job = await client.scheduledJobs.get('job-id');
1101
1174
  console.log(`Name: ${job.name}`);
1102
1175
  console.log(`Status: ${job.status}`);
1103
1176
  console.log(`Schedule: ${JSON.stringify(job.schedule)}`);
@@ -1106,7 +1179,7 @@ console.log(`Schedule: ${JSON.stringify(job.schedule)}`);
1106
1179
  #### List Scheduled Jobs
1107
1180
 
1108
1181
  ```typescript
1109
- const jobs = await client.scheduledJobs.list(20);
1182
+ const jobs = await client.scheduledJobs.list(20, 0);
1110
1183
  for (const job of jobs.items) {
1111
1184
  console.log(`${job.name} (${job.status})`);
1112
1185
  }
@@ -1114,20 +1187,41 @@ for (const job of jobs.items) {
1114
1187
 
1115
1188
  ### Secrets
1116
1189
 
1190
+ Secrets are linked to authorisations. You must first create an authorisation, then create a secret for it.
1191
+
1117
1192
  #### Create a Secret
1118
1193
 
1119
1194
  ```typescript
1120
- const secret = await client.secrets.create({
1121
- id: 'secret-1',
1122
- name: 'API Key',
1123
- description: 'External API key for service X'
1195
+ // First, create an authorisation
1196
+ const auth = await client.authorisations.create('External Service Auth', 'apikey', {
1197
+ description: 'Authorisation for external service'
1124
1198
  });
1199
+
1200
+ // Then create a secret linked to that authorisation
1201
+ const secret = await client.secrets.create(auth.id, 'your-secret-api-key-12345');
1202
+ console.log(`Secret created: ${secret.name}`);
1203
+ ```
1204
+
1205
+ #### Get a Secret
1206
+
1207
+ ```typescript
1208
+ const secret = await client.secrets.get('secret-id');
1209
+ console.log(`Secret: ${secret.name}`);
1210
+ ```
1211
+
1212
+ #### List Secrets
1213
+
1214
+ ```typescript
1215
+ const secrets = await client.secrets.list(20, 0);
1216
+ for (const secret of secrets.items) {
1217
+ console.log(`${secret.name}`);
1218
+ }
1125
1219
  ```
1126
1220
 
1127
1221
  #### Delete Secret
1128
1222
 
1129
1223
  ```typescript
1130
- await client.secrets.delete('secret-1');
1224
+ await client.secrets.delete('secret-id');
1131
1225
  ```
1132
1226
 
1133
1227
  ### Dictionary
@@ -1169,13 +1263,12 @@ for (const emb of embeddings) {
1169
1263
 
1170
1264
  ```typescript
1171
1265
  // Get charting settings
1172
- const settings = await client.chartingSettings.get('settings-id');
1266
+ const settings = await client.chartingSettings.get();
1173
1267
  console.log(`Primary Color: ${settings.primaryColor}`);
1174
1268
  console.log(`Secondary Color: ${settings.secondaryColor}`);
1175
1269
 
1176
1270
  // Update charting settings
1177
1271
  const updated = await client.chartingSettings.update({
1178
- id: 'settings-id',
1179
1272
  primaryColor: '#FF5733',
1180
1273
  secondaryColor: '#33FF57',
1181
1274
  lineColor: '#3357FF'
@@ -1186,13 +1279,12 @@ const updated = await client.chartingSettings.update({
1186
1279
 
1187
1280
  ```typescript
1188
1281
  // Get embeddings settings
1189
- const settings = await client.embeddingsSettings.get('settings-id');
1282
+ const settings = await client.embeddingsSettings.get();
1190
1283
  console.log(`Max Chunk Words: ${settings.maxChunkWords}`);
1191
1284
  console.log(`Chunking Strategy: ${settings.chunkingStrategy}`);
1192
1285
 
1193
1286
  // Update embeddings settings
1194
1287
  const updated = await client.embeddingsSettings.update({
1195
- id: 'settings-id',
1196
1288
  maxChunkWords: 1000,
1197
1289
  chunkingStrategy: 'summary',
1198
1290
  imageExtractionStrategy: 'safe'
@@ -1204,10 +1296,14 @@ const updated = await client.embeddingsSettings.update({
1204
1296
  #### Get Monthly Costs
1205
1297
 
1206
1298
  ```typescript
1207
- const costs = await client.billing.getMonthCosts();
1299
+ // Using get() method (like Python SDK)
1300
+ const costs = await client.billing.get();
1208
1301
  console.log(`API Usage: ${JSON.stringify(costs.apiUsage)}`);
1209
1302
  console.log(`Training Usage: ${JSON.stringify(costs.trainingUsage)}`);
1210
1303
  console.log(`Total Cost: $${costs.apiUsage?.totalCostUSD || 0}`);
1304
+
1305
+ // Or using getMonthCosts() alias
1306
+ const costs2 = await client.billing.getMonthCosts();
1211
1307
  ```
1212
1308
 
1213
1309
  ### Streams
@@ -1,14 +1,48 @@
1
- import { AgentFunction, AgentFunctionCreateData, AgentFunctionUpdateData, ListResponse } from "../types";
2
- import { IToothFairyClient } from "../client";
1
+ import { AgentFunction, ListResponse } from '../types';
2
+ import { IToothFairyClient } from '../client';
3
+ export interface FunctionParameter {
4
+ name: string;
5
+ type: string;
6
+ required?: boolean;
7
+ description?: string;
8
+ }
9
+ export interface FunctionHeader {
10
+ key: string;
11
+ value: string;
12
+ }
13
+ export interface StaticArg {
14
+ key: string;
15
+ value: string;
16
+ }
3
17
  export declare class AgentFunctionManager {
4
18
  private client;
5
19
  constructor(client: IToothFairyClient);
6
- create(data: AgentFunctionCreateData): Promise<AgentFunction>;
7
- update(data: AgentFunctionUpdateData): Promise<AgentFunction>;
8
- delete(id: string): Promise<{
20
+ create(name: string, options: {
21
+ description: string;
22
+ url?: string;
23
+ requestType?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
24
+ authorisationType?: string;
25
+ authorisationKey?: string;
26
+ parameters?: FunctionParameter[];
27
+ headers?: FunctionHeader[];
28
+ staticArgs?: StaticArg[];
29
+ }): Promise<AgentFunction>;
30
+ update(agentFunctionId: string, options?: {
31
+ name?: string;
32
+ description?: string;
33
+ url?: string;
34
+ requestType?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
35
+ authorisationType?: string;
36
+ authorisationKey?: string;
37
+ parameters?: FunctionParameter[];
38
+ headers?: FunctionHeader[];
39
+ staticArgs?: StaticArg[];
40
+ }): Promise<AgentFunction>;
41
+ delete(agentFunctionId: string): Promise<{
9
42
  success: boolean;
10
43
  }>;
11
- get(id: string): Promise<AgentFunction>;
12
- list(limit?: number): Promise<ListResponse<AgentFunction>>;
44
+ get(agentFunctionId: string): Promise<AgentFunction>;
45
+ list(limit?: number, offset?: number): Promise<ListResponse<AgentFunction>>;
46
+ search(searchTerm: string): Promise<AgentFunction[]>;
13
47
  }
14
48
  //# sourceMappingURL=AgentFunctionManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentFunctionManager.d.ts","sourceRoot":"","sources":["../../src/agent_functions/AgentFunctionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,qBAAa,oBAAoB;IACnB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IAEvC,MAAM,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI7D,MAAM,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI7D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAOjD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;CAiBjE"}
1
+ {"version":3,"file":"AgentFunctionManager.d.ts","sourceRoot":"","sources":["../../src/agent_functions/AgentFunctionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAKD,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAmCD,qBAAa,oBAAoB;IACnB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IASvC,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;QAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3B,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;KAC1B,GACA,OAAO,CAAC,aAAa,CAAC;IAsCnB,MAAM,CACV,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;QAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3B,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;KACrB,GACL,OAAO,CAAC,aAAa,CAAC;IAenB,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAW9D,GAAG,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAWpD,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAkC3E,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAO3D"}
@@ -5,29 +5,72 @@ class AgentFunctionManager {
5
5
  constructor(client) {
6
6
  this.client = client;
7
7
  }
8
- async create(data) {
9
- return this.client.request("POST", "function/create", data);
8
+ async create(name, options) {
9
+ const data = {
10
+ name,
11
+ description: options.description
12
+ };
13
+ if (options.url !== undefined) {
14
+ data.url = options.url;
15
+ }
16
+ if (options.requestType !== undefined) {
17
+ data.requestType = options.requestType;
18
+ }
19
+ if (options.authorisationType !== undefined) {
20
+ data.authorisationType = options.authorisationType;
21
+ }
22
+ if (options.authorisationKey !== undefined) {
23
+ data.authorisationKey = options.authorisationKey;
24
+ }
25
+ if (options.parameters !== undefined) {
26
+ data.parameters = options.parameters;
27
+ }
28
+ if (options.headers !== undefined) {
29
+ data.headers = options.headers;
30
+ }
31
+ if (options.staticArgs !== undefined) {
32
+ data.staticArgs = options.staticArgs;
33
+ }
34
+ return this.client.request('POST', 'function/create', data);
10
35
  }
11
- async update(data) {
12
- return this.client.request("POST", "function/update", data);
36
+ async update(agentFunctionId, options = {}) {
37
+ const data = {
38
+ id: agentFunctionId,
39
+ ...options
40
+ };
41
+ return this.client.request('POST', 'function/update', data);
13
42
  }
14
- async delete(id) {
15
- return this.client.request("DELETE", `function/delete/${id}`);
43
+ async delete(agentFunctionId) {
44
+ await this.client.request('DELETE', `function/delete/${agentFunctionId}`);
45
+ return { success: true };
16
46
  }
17
- async get(id) {
18
- return this.client.request("GET", `function/get/${id}`);
47
+ async get(agentFunctionId) {
48
+ return this.client.request('GET', `function/get/${agentFunctionId}`);
19
49
  }
20
- async list(limit) {
50
+ async list(limit, offset) {
21
51
  const params = {};
22
- if (limit)
52
+ if (limit !== undefined) {
23
53
  params.limit = limit;
24
- const response = await this.client.request("GET", "function/list", null, { params });
54
+ }
55
+ if (offset !== undefined) {
56
+ params.offset = offset;
57
+ }
58
+ const response = await this.client.request('GET', 'function/list', null, { params });
59
+ const items = Array.isArray(response)
60
+ ? response
61
+ : (response && 'items' in response ? response.items : []);
25
62
  return {
26
- items: Array.isArray(response) ? response : [],
27
- total: Array.isArray(response) ? response.length : 0,
63
+ items,
64
+ total: items.length,
28
65
  limit,
66
+ offset
29
67
  };
30
68
  }
69
+ async search(searchTerm) {
70
+ const result = await this.list();
71
+ const searchLower = searchTerm.toLowerCase();
72
+ return result.items.filter(func => func.name.toLowerCase().includes(searchLower));
73
+ }
31
74
  }
32
75
  exports.AgentFunctionManager = AgentFunctionManager;
33
76
  //# sourceMappingURL=AgentFunctionManager.js.map