sarvam-agents-client 0.1.2 → 0.2.1
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/README.md +15 -0
- package/dist/apis/AgentConversationsApi.d.ts +44 -1
- package/dist/apis/AgentConversationsApi.js +104 -1
- package/dist/apis/AgentsApi.d.ts +77 -5
- package/dist/apis/AgentsApi.js +163 -5
- package/dist/apis/AppsApi.d.ts +43 -1
- package/dist/apis/AppsApi.js +108 -0
- package/dist/apis/ArtifactsApi.d.ts +31 -1
- package/dist/apis/ArtifactsApi.js +82 -0
- package/dist/apis/CustomAPIsApi.d.ts +124 -0
- package/dist/apis/CustomAPIsApi.js +305 -0
- package/dist/apis/ModelsApi.d.ts +26 -0
- package/dist/apis/ModelsApi.js +52 -0
- package/dist/apis/index.d.ts +2 -0
- package/dist/apis/index.js +2 -0
- package/dist/compose/agent.d.ts +44 -0
- package/dist/compose/agent.js +222 -0
- package/dist/compose/builtins.d.ts +4 -0
- package/dist/compose/builtins.js +22 -0
- package/dist/compose/deploy.d.ts +30 -0
- package/dist/compose/deploy.js +146 -0
- package/dist/compose/errors.d.ts +48 -0
- package/dist/compose/errors.js +68 -0
- package/dist/compose/events.d.ts +63 -0
- package/dist/compose/events.js +100 -0
- package/dist/compose/fingerprint.d.ts +6 -0
- package/dist/compose/fingerprint.js +83 -0
- package/dist/compose/index.d.ts +13 -0
- package/dist/compose/index.js +33 -0
- package/dist/compose/run.d.ts +100 -0
- package/dist/compose/run.js +536 -0
- package/dist/compose/runState.d.ts +26 -0
- package/dist/compose/runState.js +79 -0
- package/dist/compose/settingsTransport.d.ts +24 -0
- package/dist/compose/settingsTransport.js +280 -0
- package/dist/compose/tools.d.ts +17 -0
- package/dist/compose/tools.js +44 -0
- package/dist/compose/transport.d.ts +34 -0
- package/dist/compose/transport.js +2 -0
- package/dist/esm/apis/AgentConversationsApi.d.ts +44 -1
- package/dist/esm/apis/AgentConversationsApi.js +104 -1
- package/dist/esm/apis/AgentsApi.d.ts +77 -5
- package/dist/esm/apis/AgentsApi.js +163 -5
- package/dist/esm/apis/AppsApi.d.ts +43 -1
- package/dist/esm/apis/AppsApi.js +109 -1
- package/dist/esm/apis/ArtifactsApi.d.ts +31 -1
- package/dist/esm/apis/ArtifactsApi.js +83 -1
- package/dist/esm/apis/CustomAPIsApi.d.ts +124 -0
- package/dist/esm/apis/CustomAPIsApi.js +301 -0
- package/dist/esm/apis/ModelsApi.d.ts +26 -0
- package/dist/esm/apis/ModelsApi.js +48 -0
- package/dist/esm/apis/index.d.ts +2 -0
- package/dist/esm/apis/index.js +2 -0
- package/dist/esm/compose/agent.d.ts +44 -0
- package/dist/esm/compose/agent.js +218 -0
- package/dist/esm/compose/builtins.d.ts +4 -0
- package/dist/esm/compose/builtins.js +18 -0
- package/dist/esm/compose/deploy.d.ts +30 -0
- package/dist/esm/compose/deploy.js +137 -0
- package/dist/esm/compose/errors.d.ts +48 -0
- package/dist/esm/compose/errors.js +53 -0
- package/dist/esm/compose/events.d.ts +63 -0
- package/dist/esm/compose/events.js +97 -0
- package/dist/esm/compose/fingerprint.d.ts +6 -0
- package/dist/esm/compose/fingerprint.js +78 -0
- package/dist/esm/compose/index.d.ts +13 -0
- package/dist/esm/compose/index.js +8 -0
- package/dist/esm/compose/run.d.ts +100 -0
- package/dist/esm/compose/run.js +530 -0
- package/dist/esm/compose/runState.d.ts +26 -0
- package/dist/esm/compose/runState.js +75 -0
- package/dist/esm/compose/settingsTransport.d.ts +24 -0
- package/dist/esm/compose/settingsTransport.js +276 -0
- package/dist/esm/compose/tools.d.ts +17 -0
- package/dist/esm/compose/tools.js +34 -0
- package/dist/esm/compose/transport.d.ts +34 -0
- package/dist/esm/compose/transport.js +1 -0
- package/dist/esm/models/AgentChannelRef.d.ts +1 -0
- package/dist/esm/models/AgentChannelRef.js +2 -1
- package/dist/esm/models/AgentConversationDetail.d.ts +15 -2
- package/dist/esm/models/AgentConversationDetail.js +6 -4
- package/dist/esm/models/AgentConversationView.d.ts +11 -5
- package/dist/esm/models/AgentConversationView.js +4 -4
- package/dist/esm/models/AgentCreate.d.ts +8 -0
- package/dist/esm/models/AgentCreate.js +2 -0
- package/dist/esm/models/AgentCustomApiList.d.ts +33 -0
- package/dist/esm/models/AgentCustomApiList.js +44 -0
- package/dist/esm/models/AgentResource.d.ts +14 -0
- package/dist/esm/models/AgentResource.js +4 -0
- package/dist/esm/models/AgentSettingsResponse.d.ts +53 -0
- package/dist/esm/models/AgentSettingsResponse.js +52 -0
- package/dist/esm/models/AgentUpdate.d.ts +8 -0
- package/dist/esm/models/AgentUpdate.js +2 -0
- package/dist/esm/models/AppAccountView.d.ts +88 -0
- package/dist/esm/models/AppAccountView.js +79 -0
- package/dist/esm/models/AppAccountsView.d.ts +66 -0
- package/dist/esm/models/AppAccountsView.js +60 -0
- package/dist/esm/models/AppResource.d.ts +36 -0
- package/dist/esm/models/AppResource.js +12 -0
- package/dist/esm/models/AppResourceCheckView.d.ts +74 -0
- package/dist/esm/models/AppResourceCheckView.js +63 -0
- package/dist/esm/models/AppResourceView.d.ts +68 -0
- package/dist/esm/models/AppResourceView.js +67 -0
- package/dist/esm/models/AppResourcesView.d.ts +54 -0
- package/dist/esm/models/AppResourcesView.js +56 -0
- package/dist/esm/models/AppToolsResponse.d.ts +14 -0
- package/dist/esm/models/AppToolsResponse.js +4 -0
- package/dist/esm/models/AppView.d.ts +42 -0
- package/dist/esm/models/AppView.js +14 -0
- package/dist/esm/models/ArtifactVersionResponse.d.ts +94 -0
- package/dist/esm/models/ArtifactVersionResponse.js +80 -0
- package/dist/esm/models/AttachedAgent.d.ts +44 -0
- package/dist/esm/models/AttachedAgent.js +49 -0
- package/dist/esm/models/Auth.d.ts +30 -0
- package/dist/esm/models/Auth.js +52 -0
- package/dist/esm/models/BindCustomApiBody.d.ts +32 -0
- package/dist/esm/models/BindCustomApiBody.js +43 -0
- package/dist/esm/models/ConversationArtifact.d.ts +14 -0
- package/dist/esm/models/ConversationArtifact.js +9 -0
- package/dist/esm/models/CustomApi.d.ts +102 -0
- package/dist/esm/models/CustomApi.js +90 -0
- package/dist/esm/models/CustomApiBasicAuth.d.ts +51 -0
- package/dist/esm/models/CustomApiBasicAuth.js +57 -0
- package/dist/esm/models/CustomApiBearerAuth.d.ts +45 -0
- package/dist/esm/models/CustomApiBearerAuth.js +53 -0
- package/dist/esm/models/CustomApiCreate.d.ts +57 -0
- package/dist/esm/models/CustomApiCreate.js +56 -0
- package/dist/esm/models/CustomApiHeader.d.ts +44 -0
- package/dist/esm/models/CustomApiHeader.js +47 -0
- package/dist/esm/models/CustomApiHeadersAuth.d.ts +46 -0
- package/dist/esm/models/CustomApiHeadersAuth.js +54 -0
- package/dist/esm/models/CustomApiList.d.ts +64 -0
- package/dist/esm/models/CustomApiList.js +64 -0
- package/dist/esm/models/CustomApiName.d.ts +44 -0
- package/dist/esm/models/CustomApiName.js +49 -0
- package/dist/esm/models/CustomApiUpdate.d.ts +58 -0
- package/dist/esm/models/CustomApiUpdate.js +50 -0
- package/dist/esm/models/CustomApiUpdateAuth.d.ts +30 -0
- package/dist/esm/models/CustomApiUpdateAuth.js +52 -0
- package/dist/esm/models/ErrorDetailItem.d.ts +5 -0
- package/dist/esm/models/ListModels403Response.d.ts +23 -0
- package/dist/esm/models/ListModels403Response.js +45 -0
- package/dist/esm/models/ModelEndpointView.d.ts +38 -0
- package/dist/esm/models/ModelEndpointView.js +45 -0
- package/dist/esm/models/ModelView.d.ts +69 -0
- package/dist/esm/models/ModelView.js +56 -0
- package/dist/esm/models/ModelsResponse.d.ts +33 -0
- package/dist/esm/models/ModelsResponse.js +44 -0
- package/dist/esm/models/SettingsIssueView.d.ts +44 -0
- package/dist/esm/models/SettingsIssueView.js +51 -0
- package/dist/esm/models/VersionCommitBody.d.ts +44 -0
- package/dist/esm/models/VersionCommitBody.js +51 -0
- package/dist/esm/models/VersionUploadUrlBody.d.ts +32 -0
- package/dist/esm/models/VersionUploadUrlBody.js +43 -0
- package/dist/esm/models/index.d.ts +28 -0
- package/dist/esm/models/index.js +28 -0
- package/dist/models/AgentChannelRef.d.ts +1 -0
- package/dist/models/AgentChannelRef.js +2 -1
- package/dist/models/AgentConversationDetail.d.ts +15 -2
- package/dist/models/AgentConversationDetail.js +6 -4
- package/dist/models/AgentConversationView.d.ts +11 -5
- package/dist/models/AgentConversationView.js +4 -4
- package/dist/models/AgentCreate.d.ts +8 -0
- package/dist/models/AgentCreate.js +2 -0
- package/dist/models/AgentCustomApiList.d.ts +33 -0
- package/dist/models/AgentCustomApiList.js +51 -0
- package/dist/models/AgentResource.d.ts +14 -0
- package/dist/models/AgentResource.js +4 -0
- package/dist/models/AgentSettingsResponse.d.ts +53 -0
- package/dist/models/AgentSettingsResponse.js +59 -0
- package/dist/models/AgentUpdate.d.ts +8 -0
- package/dist/models/AgentUpdate.js +2 -0
- package/dist/models/AppAccountView.d.ts +88 -0
- package/dist/models/AppAccountView.js +87 -0
- package/dist/models/AppAccountsView.d.ts +66 -0
- package/dist/models/AppAccountsView.js +68 -0
- package/dist/models/AppResource.d.ts +36 -0
- package/dist/models/AppResource.js +12 -0
- package/dist/models/AppResourceCheckView.d.ts +74 -0
- package/dist/models/AppResourceCheckView.js +71 -0
- package/dist/models/AppResourceView.d.ts +68 -0
- package/dist/models/AppResourceView.js +74 -0
- package/dist/models/AppResourcesView.d.ts +54 -0
- package/dist/models/AppResourcesView.js +64 -0
- package/dist/models/AppToolsResponse.d.ts +14 -0
- package/dist/models/AppToolsResponse.js +4 -0
- package/dist/models/AppView.d.ts +42 -0
- package/dist/models/AppView.js +14 -0
- package/dist/models/ArtifactVersionResponse.d.ts +94 -0
- package/dist/models/ArtifactVersionResponse.js +88 -0
- package/dist/models/AttachedAgent.d.ts +44 -0
- package/dist/models/AttachedAgent.js +56 -0
- package/dist/models/Auth.d.ts +30 -0
- package/dist/models/Auth.js +58 -0
- package/dist/models/BindCustomApiBody.d.ts +32 -0
- package/dist/models/BindCustomApiBody.js +50 -0
- package/dist/models/ConversationArtifact.d.ts +14 -0
- package/dist/models/ConversationArtifact.js +10 -0
- package/dist/models/CustomApi.d.ts +102 -0
- package/dist/models/CustomApi.js +98 -0
- package/dist/models/CustomApiBasicAuth.d.ts +51 -0
- package/dist/models/CustomApiBasicAuth.js +65 -0
- package/dist/models/CustomApiBearerAuth.d.ts +45 -0
- package/dist/models/CustomApiBearerAuth.js +61 -0
- package/dist/models/CustomApiCreate.d.ts +57 -0
- package/dist/models/CustomApiCreate.js +63 -0
- package/dist/models/CustomApiHeader.d.ts +44 -0
- package/dist/models/CustomApiHeader.js +54 -0
- package/dist/models/CustomApiHeadersAuth.d.ts +46 -0
- package/dist/models/CustomApiHeadersAuth.js +62 -0
- package/dist/models/CustomApiList.d.ts +64 -0
- package/dist/models/CustomApiList.js +71 -0
- package/dist/models/CustomApiName.d.ts +44 -0
- package/dist/models/CustomApiName.js +56 -0
- package/dist/models/CustomApiUpdate.d.ts +58 -0
- package/dist/models/CustomApiUpdate.js +57 -0
- package/dist/models/CustomApiUpdateAuth.d.ts +30 -0
- package/dist/models/CustomApiUpdateAuth.js +58 -0
- package/dist/models/ErrorDetailItem.d.ts +5 -0
- package/dist/models/ListModels403Response.d.ts +23 -0
- package/dist/models/ListModels403Response.js +51 -0
- package/dist/models/ModelEndpointView.d.ts +38 -0
- package/dist/models/ModelEndpointView.js +52 -0
- package/dist/models/ModelView.d.ts +69 -0
- package/dist/models/ModelView.js +63 -0
- package/dist/models/ModelsResponse.d.ts +33 -0
- package/dist/models/ModelsResponse.js +51 -0
- package/dist/models/SettingsIssueView.d.ts +44 -0
- package/dist/models/SettingsIssueView.js +58 -0
- package/dist/models/VersionCommitBody.d.ts +44 -0
- package/dist/models/VersionCommitBody.js +58 -0
- package/dist/models/VersionUploadUrlBody.d.ts +32 -0
- package/dist/models/VersionUploadUrlBody.js +50 -0
- package/dist/models/index.d.ts +28 -0
- package/dist/models/index.js +28 -0
- package/package.json +15 -2
- package/src/apis/AgentConversationsApi.ts +172 -3
- package/src/apis/AgentsApi.ts +242 -7
- package/src/apis/AppsApi.ts +174 -3
- package/src/apis/ArtifactsApi.ts +144 -0
- package/src/apis/ClarifyApi.ts +3 -3
- package/src/apis/CollectionsApi.ts +3 -3
- package/src/apis/ConversationsApi.ts +3 -3
- package/src/apis/CronsApi.ts +3 -3
- package/src/apis/CustomAPIsApi.ts +471 -0
- package/src/apis/MessagesApi.ts +3 -3
- package/src/apis/ModelsApi.ts +70 -0
- package/src/apis/QueueApi.ts +3 -3
- package/src/apis/ResponsesApi.ts +3 -3
- package/src/apis/SkillsApi.ts +3 -3
- package/src/apis/index.ts +2 -0
- package/src/compose/agent.ts +254 -0
- package/src/compose/builtins.ts +19 -0
- package/src/compose/deploy.ts +168 -0
- package/src/compose/errors.ts +66 -0
- package/src/compose/events.ts +122 -0
- package/src/compose/fingerprint.ts +74 -0
- package/src/compose/index.ts +13 -0
- package/src/compose/run.ts +601 -0
- package/src/compose/runState.ts +95 -0
- package/src/compose/settingsTransport.ts +299 -0
- package/src/compose/tools.ts +42 -0
- package/src/compose/transport.ts +48 -0
- package/src/models/AgentChannelRef.ts +2 -1
- package/src/models/AgentConversationDetail.ts +21 -5
- package/src/models/AgentConversationView.ts +15 -8
- package/src/models/AgentCreate.ts +8 -0
- package/src/models/AgentCustomApiList.ts +74 -0
- package/src/models/AgentResource.ts +16 -0
- package/src/models/AgentSettingsResponse.ts +99 -0
- package/src/models/AgentUpdate.ts +8 -0
- package/src/models/AppAccountView.ts +143 -0
- package/src/models/AppAccountsView.ts +118 -0
- package/src/models/AppResource.ts +48 -0
- package/src/models/AppResourceCheckView.ts +117 -0
- package/src/models/AppResourceView.ts +120 -0
- package/src/models/AppResourcesView.ts +102 -0
- package/src/models/AppToolsResponse.ts +16 -0
- package/src/models/AppView.ts +56 -0
- package/src/models/ArtifactVersionResponse.ts +155 -0
- package/src/models/AttachedAgent.ts +83 -0
- package/src/models/Auth.ts +84 -0
- package/src/models/BindCustomApiBody.ts +66 -0
- package/src/models/ConversationArtifact.ts +19 -0
- package/src/models/CustomApi.ts +175 -0
- package/src/models/CustomApiBasicAuth.ts +94 -0
- package/src/models/CustomApiBearerAuth.ts +85 -0
- package/src/models/CustomApiCreate.ts +108 -0
- package/src/models/CustomApiHeader.ts +82 -0
- package/src/models/CustomApiHeadersAuth.ts +93 -0
- package/src/models/CustomApiList.ts +120 -0
- package/src/models/CustomApiName.ts +83 -0
- package/src/models/CustomApiUpdate.ts +106 -0
- package/src/models/CustomApiUpdateAuth.ts +84 -0
- package/src/models/ErrorDetailItem.ts +5 -0
- package/src/models/ListModels403Response.ts +73 -0
- package/src/models/ModelEndpointView.ts +74 -0
- package/src/models/ModelView.ts +122 -0
- package/src/models/ModelsResponse.ts +74 -0
- package/src/models/SettingsIssueView.ts +84 -0
- package/src/models/VersionCommitBody.ts +84 -0
- package/src/models/VersionUploadUrlBody.ts +66 -0
- package/src/models/index.ts +28 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Sarvam Agents API
|
|
5
|
+
* Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 0.1.0
|
|
8
|
+
* Contact: support@sarvam.ai
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
import * as runtime from '../runtime.js';
|
|
15
|
+
import { AgentCustomApiListFromJSON, BindCustomApiBodyToJSON, CustomApiFromJSON, CustomApiCreateToJSON, CustomApiListFromJSON, CustomApiUpdateToJSON, } from '../models/index.js';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export class CustomAPIsApi extends runtime.BaseAPI {
|
|
20
|
+
/**
|
|
21
|
+
* Attach one of the caller\'s own Custom APIs to an agent they own.
|
|
22
|
+
* Bind Custom Api
|
|
23
|
+
*/
|
|
24
|
+
async bindCustomApiRaw(requestParameters, initOverrides) {
|
|
25
|
+
if (requestParameters['agentId'] == null) {
|
|
26
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling bindCustomApi().');
|
|
27
|
+
}
|
|
28
|
+
if (requestParameters['bindCustomApiBody'] == null) {
|
|
29
|
+
throw new runtime.RequiredError('bindCustomApiBody', 'Required parameter "bindCustomApiBody" was null or undefined when calling bindCustomApi().');
|
|
30
|
+
}
|
|
31
|
+
const queryParameters = {};
|
|
32
|
+
const headerParameters = {};
|
|
33
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
34
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
35
|
+
const token = this.configuration.accessToken;
|
|
36
|
+
const tokenString = await token("bearerAuth", []);
|
|
37
|
+
if (tokenString) {
|
|
38
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const response = await this.request({
|
|
42
|
+
path: `/v1/agents/{agentId}/custom-apis`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])),
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: headerParameters,
|
|
45
|
+
query: queryParameters,
|
|
46
|
+
body: BindCustomApiBodyToJSON(requestParameters['bindCustomApiBody']),
|
|
47
|
+
}, initOverrides);
|
|
48
|
+
return new runtime.VoidApiResponse(response);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Attach one of the caller\'s own Custom APIs to an agent they own.
|
|
52
|
+
* Bind Custom Api
|
|
53
|
+
*/
|
|
54
|
+
async bindCustomApi(requestParameters, initOverrides) {
|
|
55
|
+
await this.bindCustomApiRaw(requestParameters, initOverrides);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a Custom API; with ``enabledForChats`` (default) it is also attached to the caller\'s personal chats. Never attached to other agents. If that attach hits the personal-chat rules, the API is still saved, disabled, with ``enabledForChatsError`` saying why.
|
|
59
|
+
* Create Custom Api
|
|
60
|
+
*/
|
|
61
|
+
async createCustomApiRaw(requestParameters, initOverrides) {
|
|
62
|
+
if (requestParameters['customApiCreate'] == null) {
|
|
63
|
+
throw new runtime.RequiredError('customApiCreate', 'Required parameter "customApiCreate" was null or undefined when calling createCustomApi().');
|
|
64
|
+
}
|
|
65
|
+
const queryParameters = {};
|
|
66
|
+
const headerParameters = {};
|
|
67
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
68
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
69
|
+
const token = this.configuration.accessToken;
|
|
70
|
+
const tokenString = await token("bearerAuth", []);
|
|
71
|
+
if (tokenString) {
|
|
72
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const response = await this.request({
|
|
76
|
+
path: `/v2/custom-apis`,
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: headerParameters,
|
|
79
|
+
query: queryParameters,
|
|
80
|
+
body: CustomApiCreateToJSON(requestParameters['customApiCreate']),
|
|
81
|
+
}, initOverrides);
|
|
82
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => CustomApiFromJSON(jsonValue));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a Custom API; with ``enabledForChats`` (default) it is also attached to the caller\'s personal chats. Never attached to other agents. If that attach hits the personal-chat rules, the API is still saved, disabled, with ``enabledForChatsError`` saying why.
|
|
86
|
+
* Create Custom Api
|
|
87
|
+
*/
|
|
88
|
+
async createCustomApi(requestParameters, initOverrides) {
|
|
89
|
+
const response = await this.createCustomApiRaw(requestParameters, initOverrides);
|
|
90
|
+
return await response.value();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Delete the API and every attachment (agents and personal chats).
|
|
94
|
+
* Delete Custom Api
|
|
95
|
+
*/
|
|
96
|
+
async deleteCustomApiRaw(requestParameters, initOverrides) {
|
|
97
|
+
if (requestParameters['customApiId'] == null) {
|
|
98
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling deleteCustomApi().');
|
|
99
|
+
}
|
|
100
|
+
const queryParameters = {};
|
|
101
|
+
const headerParameters = {};
|
|
102
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
103
|
+
const token = this.configuration.accessToken;
|
|
104
|
+
const tokenString = await token("bearerAuth", []);
|
|
105
|
+
if (tokenString) {
|
|
106
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const response = await this.request({
|
|
110
|
+
path: `/v2/custom-apis/{customApiId}`.replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
111
|
+
method: 'DELETE',
|
|
112
|
+
headers: headerParameters,
|
|
113
|
+
query: queryParameters,
|
|
114
|
+
}, initOverrides);
|
|
115
|
+
return new runtime.VoidApiResponse(response);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Delete the API and every attachment (agents and personal chats).
|
|
119
|
+
* Delete Custom Api
|
|
120
|
+
*/
|
|
121
|
+
async deleteCustomApi(requestParameters, initOverrides) {
|
|
122
|
+
await this.deleteCustomApiRaw(requestParameters, initOverrides);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get Custom Api
|
|
126
|
+
*/
|
|
127
|
+
async getCustomApiRaw(requestParameters, initOverrides) {
|
|
128
|
+
if (requestParameters['customApiId'] == null) {
|
|
129
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling getCustomApi().');
|
|
130
|
+
}
|
|
131
|
+
const queryParameters = {};
|
|
132
|
+
const headerParameters = {};
|
|
133
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
134
|
+
const token = this.configuration.accessToken;
|
|
135
|
+
const tokenString = await token("bearerAuth", []);
|
|
136
|
+
if (tokenString) {
|
|
137
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const response = await this.request({
|
|
141
|
+
path: `/v2/custom-apis/{customApiId}`.replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
142
|
+
method: 'GET',
|
|
143
|
+
headers: headerParameters,
|
|
144
|
+
query: queryParameters,
|
|
145
|
+
}, initOverrides);
|
|
146
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => CustomApiFromJSON(jsonValue));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get Custom Api
|
|
150
|
+
*/
|
|
151
|
+
async getCustomApi(requestParameters, initOverrides) {
|
|
152
|
+
const response = await this.getCustomApiRaw(requestParameters, initOverrides);
|
|
153
|
+
return await response.value();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Names of the Custom APIs attached to an agent — for any viewer of it. The host is filled only for the caller\'s own APIs.
|
|
157
|
+
* List Agent Custom Apis
|
|
158
|
+
*/
|
|
159
|
+
async listAgentCustomApisRaw(requestParameters, initOverrides) {
|
|
160
|
+
if (requestParameters['agentId'] == null) {
|
|
161
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling listAgentCustomApis().');
|
|
162
|
+
}
|
|
163
|
+
const queryParameters = {};
|
|
164
|
+
const headerParameters = {};
|
|
165
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
166
|
+
const token = this.configuration.accessToken;
|
|
167
|
+
const tokenString = await token("bearerAuth", []);
|
|
168
|
+
if (tokenString) {
|
|
169
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const response = await this.request({
|
|
173
|
+
path: `/v1/agents/{agentId}/custom-apis`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])),
|
|
174
|
+
method: 'GET',
|
|
175
|
+
headers: headerParameters,
|
|
176
|
+
query: queryParameters,
|
|
177
|
+
}, initOverrides);
|
|
178
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => AgentCustomApiListFromJSON(jsonValue));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Names of the Custom APIs attached to an agent — for any viewer of it. The host is filled only for the caller\'s own APIs.
|
|
182
|
+
* List Agent Custom Apis
|
|
183
|
+
*/
|
|
184
|
+
async listAgentCustomApis(requestParameters, initOverrides) {
|
|
185
|
+
const response = await this.listAgentCustomApisRaw(requestParameters, initOverrides);
|
|
186
|
+
return await response.value();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The caller\'s own Custom APIs, newest first. ``q`` matches name, description or host; ``scope`` is ignored (the list is owner-only).
|
|
190
|
+
* List Custom Apis
|
|
191
|
+
*/
|
|
192
|
+
async listCustomApisRaw(requestParameters, initOverrides) {
|
|
193
|
+
const queryParameters = {};
|
|
194
|
+
if (requestParameters['scope'] != null) {
|
|
195
|
+
queryParameters['scope'] = requestParameters['scope'];
|
|
196
|
+
}
|
|
197
|
+
if (requestParameters['q'] != null) {
|
|
198
|
+
queryParameters['q'] = requestParameters['q'];
|
|
199
|
+
}
|
|
200
|
+
if (requestParameters['limit'] != null) {
|
|
201
|
+
queryParameters['limit'] = requestParameters['limit'];
|
|
202
|
+
}
|
|
203
|
+
if (requestParameters['offset'] != null) {
|
|
204
|
+
queryParameters['offset'] = requestParameters['offset'];
|
|
205
|
+
}
|
|
206
|
+
const headerParameters = {};
|
|
207
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
208
|
+
const token = this.configuration.accessToken;
|
|
209
|
+
const tokenString = await token("bearerAuth", []);
|
|
210
|
+
if (tokenString) {
|
|
211
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const response = await this.request({
|
|
215
|
+
path: `/v2/custom-apis`,
|
|
216
|
+
method: 'GET',
|
|
217
|
+
headers: headerParameters,
|
|
218
|
+
query: queryParameters,
|
|
219
|
+
}, initOverrides);
|
|
220
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => CustomApiListFromJSON(jsonValue));
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The caller\'s own Custom APIs, newest first. ``q`` matches name, description or host; ``scope`` is ignored (the list is owner-only).
|
|
224
|
+
* List Custom Apis
|
|
225
|
+
*/
|
|
226
|
+
async listCustomApis(requestParameters = {}, initOverrides) {
|
|
227
|
+
const response = await this.listCustomApisRaw(requestParameters, initOverrides);
|
|
228
|
+
return await response.value();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Unbind Custom Api
|
|
232
|
+
*/
|
|
233
|
+
async unbindCustomApiRaw(requestParameters, initOverrides) {
|
|
234
|
+
if (requestParameters['agentId'] == null) {
|
|
235
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling unbindCustomApi().');
|
|
236
|
+
}
|
|
237
|
+
if (requestParameters['customApiId'] == null) {
|
|
238
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling unbindCustomApi().');
|
|
239
|
+
}
|
|
240
|
+
const queryParameters = {};
|
|
241
|
+
const headerParameters = {};
|
|
242
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
243
|
+
const token = this.configuration.accessToken;
|
|
244
|
+
const tokenString = await token("bearerAuth", []);
|
|
245
|
+
if (tokenString) {
|
|
246
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const response = await this.request({
|
|
250
|
+
path: `/v1/agents/{agentId}/custom-apis/{customApiId}`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])).replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
251
|
+
method: 'DELETE',
|
|
252
|
+
headers: headerParameters,
|
|
253
|
+
query: queryParameters,
|
|
254
|
+
}, initOverrides);
|
|
255
|
+
return new runtime.VoidApiResponse(response);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Unbind Custom Api
|
|
259
|
+
*/
|
|
260
|
+
async unbindCustomApi(requestParameters, initOverrides) {
|
|
261
|
+
await this.unbindCustomApiRaw(requestParameters, initOverrides);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Edit details and/or replace credentials. Attachments are kept.
|
|
265
|
+
* Update Custom Api
|
|
266
|
+
*/
|
|
267
|
+
async updateCustomApiRaw(requestParameters, initOverrides) {
|
|
268
|
+
if (requestParameters['customApiId'] == null) {
|
|
269
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling updateCustomApi().');
|
|
270
|
+
}
|
|
271
|
+
if (requestParameters['customApiUpdate'] == null) {
|
|
272
|
+
throw new runtime.RequiredError('customApiUpdate', 'Required parameter "customApiUpdate" was null or undefined when calling updateCustomApi().');
|
|
273
|
+
}
|
|
274
|
+
const queryParameters = {};
|
|
275
|
+
const headerParameters = {};
|
|
276
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
277
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
278
|
+
const token = this.configuration.accessToken;
|
|
279
|
+
const tokenString = await token("bearerAuth", []);
|
|
280
|
+
if (tokenString) {
|
|
281
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const response = await this.request({
|
|
285
|
+
path: `/v2/custom-apis/{customApiId}`.replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
286
|
+
method: 'PATCH',
|
|
287
|
+
headers: headerParameters,
|
|
288
|
+
query: queryParameters,
|
|
289
|
+
body: CustomApiUpdateToJSON(requestParameters['customApiUpdate']),
|
|
290
|
+
}, initOverrides);
|
|
291
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => CustomApiFromJSON(jsonValue));
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Edit details and/or replace credentials. Attachments are kept.
|
|
295
|
+
* Update Custom Api
|
|
296
|
+
*/
|
|
297
|
+
async updateCustomApi(requestParameters, initOverrides) {
|
|
298
|
+
const response = await this.updateCustomApiRaw(requestParameters, initOverrides);
|
|
299
|
+
return await response.value();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sarvam Agents API
|
|
3
|
+
* Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 0.1.0
|
|
6
|
+
* Contact: support@sarvam.ai
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import * as runtime from '../runtime.js';
|
|
13
|
+
import type { ModelsResponse } from '../models/index.js';
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export declare class ModelsApi extends runtime.BaseAPI {
|
|
18
|
+
/**
|
|
19
|
+
* List Models
|
|
20
|
+
*/
|
|
21
|
+
listModelsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ModelsResponse>>;
|
|
22
|
+
/**
|
|
23
|
+
* List Models
|
|
24
|
+
*/
|
|
25
|
+
listModels(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelsResponse>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Sarvam Agents API
|
|
5
|
+
* Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 0.1.0
|
|
8
|
+
* Contact: support@sarvam.ai
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
import * as runtime from '../runtime.js';
|
|
15
|
+
import { ModelsResponseFromJSON, } from '../models/index.js';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export class ModelsApi extends runtime.BaseAPI {
|
|
20
|
+
/**
|
|
21
|
+
* List Models
|
|
22
|
+
*/
|
|
23
|
+
async listModelsRaw(initOverrides) {
|
|
24
|
+
const queryParameters = {};
|
|
25
|
+
const headerParameters = {};
|
|
26
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
27
|
+
const token = this.configuration.accessToken;
|
|
28
|
+
const tokenString = await token("bearerAuth", []);
|
|
29
|
+
if (tokenString) {
|
|
30
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const response = await this.request({
|
|
34
|
+
path: `/v1/models`,
|
|
35
|
+
method: 'GET',
|
|
36
|
+
headers: headerParameters,
|
|
37
|
+
query: queryParameters,
|
|
38
|
+
}, initOverrides);
|
|
39
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => ModelsResponseFromJSON(jsonValue));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* List Models
|
|
43
|
+
*/
|
|
44
|
+
async listModels(initOverrides) {
|
|
45
|
+
const response = await this.listModelsRaw(initOverrides);
|
|
46
|
+
return await response.value();
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/esm/apis/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from './ClarifyApi.js';
|
|
|
6
6
|
export * from './CollectionsApi.js';
|
|
7
7
|
export * from './ConversationsApi.js';
|
|
8
8
|
export * from './CronsApi.js';
|
|
9
|
+
export * from './CustomAPIsApi.js';
|
|
9
10
|
export * from './MessagesApi.js';
|
|
11
|
+
export * from './ModelsApi.js';
|
|
10
12
|
export * from './QueueApi.js';
|
|
11
13
|
export * from './ResponsesApi.js';
|
|
12
14
|
export * from './SkillsApi.js';
|
package/dist/esm/apis/index.js
CHANGED
|
@@ -8,7 +8,9 @@ export * from './ClarifyApi.js';
|
|
|
8
8
|
export * from './CollectionsApi.js';
|
|
9
9
|
export * from './ConversationsApi.js';
|
|
10
10
|
export * from './CronsApi.js';
|
|
11
|
+
export * from './CustomAPIsApi.js';
|
|
11
12
|
export * from './MessagesApi.js';
|
|
13
|
+
export * from './ModelsApi.js';
|
|
12
14
|
export * from './QueueApi.js';
|
|
13
15
|
export * from './ResponsesApi.js';
|
|
14
16
|
export * from './SkillsApi.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BuiltinTool } from "./tools.js";
|
|
2
|
+
export interface ModelSettings {
|
|
3
|
+
temperature?: number;
|
|
4
|
+
topP?: number;
|
|
5
|
+
maxTokens?: number;
|
|
6
|
+
toolChoice?: "auto" | "none";
|
|
7
|
+
reasoning?: {
|
|
8
|
+
effort: "off" | "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface Limits {
|
|
12
|
+
maxTurns?: number;
|
|
13
|
+
maxToolCallsPerTurn?: number;
|
|
14
|
+
maxTokensPerTurn?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AgentOptions {
|
|
17
|
+
name: string;
|
|
18
|
+
instructions?: string;
|
|
19
|
+
model?: string;
|
|
20
|
+
/** Catalog endpoint to serve `model` from (agent.json `endpoint`). */
|
|
21
|
+
endpoint?: string;
|
|
22
|
+
modelSettings?: ModelSettings;
|
|
23
|
+
fallbackModels?: string[];
|
|
24
|
+
/** Exact list of built-ins to keep on; omit to keep the server default (all on). */
|
|
25
|
+
tools?: BuiltinTool[];
|
|
26
|
+
limits?: Limits;
|
|
27
|
+
metadata?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
export declare class Agent {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly instructions: string;
|
|
32
|
+
readonly model?: string;
|
|
33
|
+
readonly endpoint?: string;
|
|
34
|
+
readonly modelSettings?: ModelSettings;
|
|
35
|
+
readonly fallbackModels?: string[];
|
|
36
|
+
readonly tools?: readonly BuiltinTool[];
|
|
37
|
+
readonly limits?: Limits;
|
|
38
|
+
readonly metadata?: Record<string, string>;
|
|
39
|
+
constructor(rawOpts: AgentOptions);
|
|
40
|
+
private check;
|
|
41
|
+
private baseSettings;
|
|
42
|
+
specHash(): string;
|
|
43
|
+
toSettings(): Record<string, unknown>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { NotSupportedError, UserError } from "./errors.js";
|
|
2
|
+
import { settingsFingerprint } from "./fingerprint.js";
|
|
3
|
+
import { BUILTIN_NAMES, checkWebSearchOptions } from "./builtins.js";
|
|
4
|
+
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
5
|
+
const REASONING = ["off", "none", "low", "medium", "high", "xhigh", "max"];
|
|
6
|
+
const TOOL_CHOICES = ["auto", "none"];
|
|
7
|
+
function deepFreeze(value) {
|
|
8
|
+
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
9
|
+
Object.freeze(value);
|
|
10
|
+
for (const key of Object.keys(value))
|
|
11
|
+
deepFreeze(value[key]);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function clone(value) {
|
|
16
|
+
return value === undefined ? value : JSON.parse(JSON.stringify(value));
|
|
17
|
+
}
|
|
18
|
+
function isPositiveInt(n) {
|
|
19
|
+
return typeof n === "number" && Number.isInteger(n) && n >= 1;
|
|
20
|
+
}
|
|
21
|
+
function isFiniteNumber(n) {
|
|
22
|
+
return typeof n === "number" && Number.isFinite(n);
|
|
23
|
+
}
|
|
24
|
+
/** Runs on the raw options, before the JSON clone turns NaN/Infinity into null. */
|
|
25
|
+
function checkNumbers(opts) {
|
|
26
|
+
const ms = opts.modelSettings;
|
|
27
|
+
if (ms !== undefined && ms !== null) {
|
|
28
|
+
if (ms.temperature !== undefined && !(isFiniteNumber(ms.temperature) && ms.temperature >= 0 && ms.temperature <= 2)) {
|
|
29
|
+
throw new UserError("modelSettings.temperature: must be a number between 0 and 2");
|
|
30
|
+
}
|
|
31
|
+
if (ms.topP !== undefined && !(isFiniteNumber(ms.topP) && ms.topP > 0 && ms.topP <= 1)) {
|
|
32
|
+
throw new UserError("modelSettings.topP: must be a number > 0 and <= 1");
|
|
33
|
+
}
|
|
34
|
+
if (ms.maxTokens !== undefined && !isPositiveInt(ms.maxTokens)) {
|
|
35
|
+
throw new UserError("modelSettings.maxTokens: must be an integer >= 1");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const limits = opts.limits;
|
|
39
|
+
if (limits !== undefined && limits !== null) {
|
|
40
|
+
for (const key of ["maxTurns", "maxToolCallsPerTurn", "maxTokensPerTurn"]) {
|
|
41
|
+
if (limits[key] !== undefined && !isPositiveInt(limits[key])) {
|
|
42
|
+
throw new UserError(`limits.${key}: must be an integer >= 1`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Drops null-valued own keys (shallow copy); a non-object (null/undefined) becomes undefined. */
|
|
48
|
+
function dropNulls(value) {
|
|
49
|
+
if (value === null || value === undefined || typeof value !== "object")
|
|
50
|
+
return undefined;
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const key of Object.keys(value)) {
|
|
53
|
+
const v = value[key];
|
|
54
|
+
if (v !== null && v !== undefined)
|
|
55
|
+
out[key] = v;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/** JS callers spreading JSON configs pass null for unset fields; null means unset everywhere (like Python's None). */
|
|
60
|
+
function normalize(raw) {
|
|
61
|
+
const opts = dropNulls(raw);
|
|
62
|
+
if (opts.modelSettings !== undefined)
|
|
63
|
+
opts.modelSettings = dropNulls(opts.modelSettings);
|
|
64
|
+
if (opts.limits !== undefined)
|
|
65
|
+
opts.limits = dropNulls(opts.limits);
|
|
66
|
+
return opts;
|
|
67
|
+
}
|
|
68
|
+
const LIMIT_KEYS = [
|
|
69
|
+
["maxTurns", "max_turns"],
|
|
70
|
+
["maxToolCallsPerTurn", "max_tool_calls_per_turn"],
|
|
71
|
+
["maxTokensPerTurn", "max_tokens_per_turn"],
|
|
72
|
+
];
|
|
73
|
+
export class Agent {
|
|
74
|
+
constructor(rawOpts) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const opts = normalize(rawOpts);
|
|
77
|
+
for (const tool of (_a = opts.tools) !== null && _a !== void 0 ? _a : []) {
|
|
78
|
+
if (tool instanceof Agent) {
|
|
79
|
+
throw new NotSupportedError("sub-agents in tools are not supported yet (field: tools)");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
checkNumbers(opts);
|
|
83
|
+
this.name = opts.name;
|
|
84
|
+
this.instructions = (_b = opts.instructions) !== null && _b !== void 0 ? _b : "";
|
|
85
|
+
this.model = opts.model;
|
|
86
|
+
this.endpoint = opts.endpoint;
|
|
87
|
+
this.modelSettings = clone(opts.modelSettings);
|
|
88
|
+
this.fallbackModels = clone(opts.fallbackModels);
|
|
89
|
+
this.tools = clone(opts.tools);
|
|
90
|
+
this.limits = clone(opts.limits);
|
|
91
|
+
this.metadata = clone(opts.metadata);
|
|
92
|
+
this.check();
|
|
93
|
+
deepFreeze(this);
|
|
94
|
+
}
|
|
95
|
+
check() {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
if (typeof this.name !== "string" || !SLUG.test(this.name)) {
|
|
98
|
+
throw new UserError(`name: ${JSON.stringify(this.name)} must match ${SLUG.source}`);
|
|
99
|
+
}
|
|
100
|
+
for (const [key, value] of [["model", this.model], ["endpoint", this.endpoint]]) {
|
|
101
|
+
if (value !== undefined && (typeof value !== "string" || value === "")) {
|
|
102
|
+
throw new UserError(`${key}: must be a non-empty string`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (this.endpoint !== undefined && this.model === undefined) {
|
|
106
|
+
throw new UserError("endpoint: needs model; set the model this endpoint serves");
|
|
107
|
+
}
|
|
108
|
+
const ms = this.modelSettings;
|
|
109
|
+
if (ms !== undefined) {
|
|
110
|
+
if (ms.reasoning !== undefined && REASONING.indexOf(ms.reasoning.effort) === -1) {
|
|
111
|
+
throw new UserError(`modelSettings.reasoning: ${JSON.stringify(ms.reasoning.effort)} must be one of ${REASONING.join(", ")}`);
|
|
112
|
+
}
|
|
113
|
+
if (ms.toolChoice !== undefined && TOOL_CHOICES.indexOf(ms.toolChoice) === -1) {
|
|
114
|
+
throw new UserError(`modelSettings.toolChoice: ${JSON.stringify(ms.toolChoice)} must be one of ${TOOL_CHOICES.join(", ")}`);
|
|
115
|
+
}
|
|
116
|
+
if (ms.temperature !== undefined && !(ms.temperature >= 0 && ms.temperature <= 2)) {
|
|
117
|
+
throw new UserError("modelSettings.temperature: must be between 0 and 2");
|
|
118
|
+
}
|
|
119
|
+
if (ms.topP !== undefined && !(ms.topP > 0 && ms.topP <= 1)) {
|
|
120
|
+
throw new UserError("modelSettings.topP: must be > 0 and <= 1");
|
|
121
|
+
}
|
|
122
|
+
if (ms.maxTokens !== undefined && !isPositiveInt(ms.maxTokens)) {
|
|
123
|
+
throw new UserError("modelSettings.maxTokens: must be an integer >= 1");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (this.limits !== undefined) {
|
|
127
|
+
for (const [key] of LIMIT_KEYS) {
|
|
128
|
+
const value = this.limits[key];
|
|
129
|
+
if (value !== undefined && !isPositiveInt(value)) {
|
|
130
|
+
throw new UserError(`limits.${key}: must be an integer >= 1`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (this.metadata !== undefined) {
|
|
135
|
+
const bad = Object.keys(this.metadata).filter((k) => k.indexOf("sdk_") === 0).sort();
|
|
136
|
+
if (bad.length > 0) {
|
|
137
|
+
throw new UserError(`metadata: keys starting with 'sdk_' are reserved (${bad.join(", ")})`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const names = ((_a = this.tools) !== null && _a !== void 0 ? _a : []).map((t) => t.name);
|
|
141
|
+
for (const n of names) {
|
|
142
|
+
if (BUILTIN_NAMES.indexOf(n) === -1) {
|
|
143
|
+
throw new UserError(`tools: unknown built-in tool ${JSON.stringify(n)} (known: ${BUILTIN_NAMES.join(", ")})`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const dupes = Array.from(new Set(names.filter((n, i) => names.indexOf(n) !== i))).sort();
|
|
147
|
+
if (dupes.length > 0) {
|
|
148
|
+
throw new UserError(`tools: duplicate built-in tool(s): ${dupes.join(", ")}`);
|
|
149
|
+
}
|
|
150
|
+
for (const t of (_b = this.tools) !== null && _b !== void 0 ? _b : []) {
|
|
151
|
+
if (t.options === undefined || Object.keys(t.options).length === 0)
|
|
152
|
+
continue;
|
|
153
|
+
if (t.name !== "web_search")
|
|
154
|
+
throw new UserError(`tools: ${t.name} takes no options`);
|
|
155
|
+
checkWebSearchOptions(t.options);
|
|
156
|
+
}
|
|
157
|
+
if (names.indexOf("code_mode") !== -1 && names.indexOf("sandbox") === -1) {
|
|
158
|
+
throw new UserError("tools: codeMode needs sandbox; add sandbox() to tools");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
baseSettings() {
|
|
162
|
+
const out = { version: 1 };
|
|
163
|
+
if (this.model !== undefined)
|
|
164
|
+
out["model"] = this.model;
|
|
165
|
+
if (this.endpoint !== undefined)
|
|
166
|
+
out["endpoint"] = this.endpoint;
|
|
167
|
+
const ms = this.modelSettings;
|
|
168
|
+
if (ms !== undefined) {
|
|
169
|
+
if (ms.reasoning !== undefined)
|
|
170
|
+
out["reasoning"] = ms.reasoning.effort;
|
|
171
|
+
if (ms.temperature !== undefined)
|
|
172
|
+
out["temperature"] = ms.temperature;
|
|
173
|
+
if (ms.topP !== undefined)
|
|
174
|
+
out["top_p"] = ms.topP;
|
|
175
|
+
if (ms.maxTokens !== undefined)
|
|
176
|
+
out["max_output_tokens"] = ms.maxTokens;
|
|
177
|
+
if (ms.toolChoice !== undefined)
|
|
178
|
+
out["tool_choice"] = ms.toolChoice;
|
|
179
|
+
}
|
|
180
|
+
if (this.fallbackModels !== undefined && this.fallbackModels.length > 0) {
|
|
181
|
+
out["fallback"] = clone(this.fallbackModels);
|
|
182
|
+
}
|
|
183
|
+
if (this.limits !== undefined) {
|
|
184
|
+
const limits = {};
|
|
185
|
+
for (const [key, wire] of LIMIT_KEYS) {
|
|
186
|
+
const value = this.limits[key];
|
|
187
|
+
if (value !== undefined)
|
|
188
|
+
limits[wire] = value;
|
|
189
|
+
}
|
|
190
|
+
if (Object.keys(limits).length > 0)
|
|
191
|
+
out["limits"] = limits;
|
|
192
|
+
}
|
|
193
|
+
if (this.tools !== undefined) {
|
|
194
|
+
// Built-ins are on by default, so an exact list writes every unlisted one as off.
|
|
195
|
+
const tools = {};
|
|
196
|
+
for (const n of BUILTIN_NAMES) {
|
|
197
|
+
const t = this.tools.find((x) => x.name === n);
|
|
198
|
+
tools[n] = t === undefined ? false
|
|
199
|
+
: t.options !== undefined && Object.keys(t.options).length > 0 ? clone(t.options) : true;
|
|
200
|
+
}
|
|
201
|
+
out["builtin_tools"] = tools;
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
specHash() {
|
|
206
|
+
const settings = this.baseSettings();
|
|
207
|
+
if (this.metadata !== undefined && Object.keys(this.metadata).length > 0) {
|
|
208
|
+
settings["metadata"] = { ...this.metadata };
|
|
209
|
+
}
|
|
210
|
+
return settingsFingerprint(this.instructions, settings);
|
|
211
|
+
}
|
|
212
|
+
toSettings() {
|
|
213
|
+
var _a;
|
|
214
|
+
const out = this.baseSettings();
|
|
215
|
+
out["metadata"] = { ...((_a = this.metadata) !== null && _a !== void 0 ? _a : {}), sdk_name: this.name, sdk_hash: this.specHash() };
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The agent.json builtin_tools switches, in schema order. */
|
|
2
|
+
export declare const BUILTIN_NAMES: readonly ["web_search", "sandbox", "code_mode", "todo", "schedules", "clarify", "subagents"];
|
|
3
|
+
/** The server's web search rules, for options built by hand (`{ name: "web_search", options }`). */
|
|
4
|
+
export declare function checkWebSearchOptions(options: Record<string, unknown>): void;
|