sarvam-agents-client 0.1.1 → 0.2.0
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 +40 -0
- package/dist/compose/agent.js +191 -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 +29 -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 +40 -0
- package/dist/esm/compose/agent.js +187 -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 +19 -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/CollectionCreate.d.ts +4 -5
- package/dist/esm/models/CollectionCreate.js +3 -2
- package/dist/esm/models/CollectionResource.d.ts +13 -0
- package/dist/esm/models/CollectionResource.js +5 -0
- package/dist/esm/models/CollectionUpdate.d.ts +4 -5
- package/dist/esm/models/CollectionUpdate.js +3 -2
- 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/FieldDefinition.d.ts +63 -0
- package/dist/esm/models/FieldDefinition.js +55 -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 +29 -0
- package/dist/esm/models/index.js +29 -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/CollectionCreate.d.ts +4 -5
- package/dist/models/CollectionCreate.js +3 -2
- package/dist/models/CollectionResource.d.ts +13 -0
- package/dist/models/CollectionResource.js +5 -0
- package/dist/models/CollectionUpdate.d.ts +4 -5
- package/dist/models/CollectionUpdate.js +3 -2
- 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/FieldDefinition.d.ts +63 -0
- package/dist/models/FieldDefinition.js +62 -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 +29 -0
- package/dist/models/index.js +29 -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 +223 -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 +27 -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/CollectionCreate.ts +13 -5
- package/src/models/CollectionResource.ts +23 -0
- package/src/models/CollectionUpdate.ts +13 -5
- 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/FieldDefinition.ts +108 -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 +29 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* Sarvam Agents API
|
|
6
|
+
* 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.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 0.1.0
|
|
9
|
+
* Contact: support@sarvam.ai
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CustomAPIsApi = void 0;
|
|
17
|
+
const runtime = require("../runtime.js");
|
|
18
|
+
const index_js_1 = require("../models/index.js");
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
class CustomAPIsApi extends runtime.BaseAPI {
|
|
23
|
+
/**
|
|
24
|
+
* Attach one of the caller\'s own Custom APIs to an agent they own.
|
|
25
|
+
* Bind Custom Api
|
|
26
|
+
*/
|
|
27
|
+
async bindCustomApiRaw(requestParameters, initOverrides) {
|
|
28
|
+
if (requestParameters['agentId'] == null) {
|
|
29
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling bindCustomApi().');
|
|
30
|
+
}
|
|
31
|
+
if (requestParameters['bindCustomApiBody'] == null) {
|
|
32
|
+
throw new runtime.RequiredError('bindCustomApiBody', 'Required parameter "bindCustomApiBody" was null or undefined when calling bindCustomApi().');
|
|
33
|
+
}
|
|
34
|
+
const queryParameters = {};
|
|
35
|
+
const headerParameters = {};
|
|
36
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
37
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
38
|
+
const token = this.configuration.accessToken;
|
|
39
|
+
const tokenString = await token("bearerAuth", []);
|
|
40
|
+
if (tokenString) {
|
|
41
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const response = await this.request({
|
|
45
|
+
path: `/v1/agents/{agentId}/custom-apis`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])),
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: headerParameters,
|
|
48
|
+
query: queryParameters,
|
|
49
|
+
body: (0, index_js_1.BindCustomApiBodyToJSON)(requestParameters['bindCustomApiBody']),
|
|
50
|
+
}, initOverrides);
|
|
51
|
+
return new runtime.VoidApiResponse(response);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Attach one of the caller\'s own Custom APIs to an agent they own.
|
|
55
|
+
* Bind Custom Api
|
|
56
|
+
*/
|
|
57
|
+
async bindCustomApi(requestParameters, initOverrides) {
|
|
58
|
+
await this.bindCustomApiRaw(requestParameters, initOverrides);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 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.
|
|
62
|
+
* Create Custom Api
|
|
63
|
+
*/
|
|
64
|
+
async createCustomApiRaw(requestParameters, initOverrides) {
|
|
65
|
+
if (requestParameters['customApiCreate'] == null) {
|
|
66
|
+
throw new runtime.RequiredError('customApiCreate', 'Required parameter "customApiCreate" was null or undefined when calling createCustomApi().');
|
|
67
|
+
}
|
|
68
|
+
const queryParameters = {};
|
|
69
|
+
const headerParameters = {};
|
|
70
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
71
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
72
|
+
const token = this.configuration.accessToken;
|
|
73
|
+
const tokenString = await token("bearerAuth", []);
|
|
74
|
+
if (tokenString) {
|
|
75
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const response = await this.request({
|
|
79
|
+
path: `/v2/custom-apis`,
|
|
80
|
+
method: 'POST',
|
|
81
|
+
headers: headerParameters,
|
|
82
|
+
query: queryParameters,
|
|
83
|
+
body: (0, index_js_1.CustomApiCreateToJSON)(requestParameters['customApiCreate']),
|
|
84
|
+
}, initOverrides);
|
|
85
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.CustomApiFromJSON)(jsonValue));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 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.
|
|
89
|
+
* Create Custom Api
|
|
90
|
+
*/
|
|
91
|
+
async createCustomApi(requestParameters, initOverrides) {
|
|
92
|
+
const response = await this.createCustomApiRaw(requestParameters, initOverrides);
|
|
93
|
+
return await response.value();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Delete the API and every attachment (agents and personal chats).
|
|
97
|
+
* Delete Custom Api
|
|
98
|
+
*/
|
|
99
|
+
async deleteCustomApiRaw(requestParameters, initOverrides) {
|
|
100
|
+
if (requestParameters['customApiId'] == null) {
|
|
101
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling deleteCustomApi().');
|
|
102
|
+
}
|
|
103
|
+
const queryParameters = {};
|
|
104
|
+
const headerParameters = {};
|
|
105
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
106
|
+
const token = this.configuration.accessToken;
|
|
107
|
+
const tokenString = await token("bearerAuth", []);
|
|
108
|
+
if (tokenString) {
|
|
109
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const response = await this.request({
|
|
113
|
+
path: `/v2/custom-apis/{customApiId}`.replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
114
|
+
method: 'DELETE',
|
|
115
|
+
headers: headerParameters,
|
|
116
|
+
query: queryParameters,
|
|
117
|
+
}, initOverrides);
|
|
118
|
+
return new runtime.VoidApiResponse(response);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Delete the API and every attachment (agents and personal chats).
|
|
122
|
+
* Delete Custom Api
|
|
123
|
+
*/
|
|
124
|
+
async deleteCustomApi(requestParameters, initOverrides) {
|
|
125
|
+
await this.deleteCustomApiRaw(requestParameters, initOverrides);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get Custom Api
|
|
129
|
+
*/
|
|
130
|
+
async getCustomApiRaw(requestParameters, initOverrides) {
|
|
131
|
+
if (requestParameters['customApiId'] == null) {
|
|
132
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling getCustomApi().');
|
|
133
|
+
}
|
|
134
|
+
const queryParameters = {};
|
|
135
|
+
const headerParameters = {};
|
|
136
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
137
|
+
const token = this.configuration.accessToken;
|
|
138
|
+
const tokenString = await token("bearerAuth", []);
|
|
139
|
+
if (tokenString) {
|
|
140
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const response = await this.request({
|
|
144
|
+
path: `/v2/custom-apis/{customApiId}`.replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
145
|
+
method: 'GET',
|
|
146
|
+
headers: headerParameters,
|
|
147
|
+
query: queryParameters,
|
|
148
|
+
}, initOverrides);
|
|
149
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.CustomApiFromJSON)(jsonValue));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get Custom Api
|
|
153
|
+
*/
|
|
154
|
+
async getCustomApi(requestParameters, initOverrides) {
|
|
155
|
+
const response = await this.getCustomApiRaw(requestParameters, initOverrides);
|
|
156
|
+
return await response.value();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 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.
|
|
160
|
+
* List Agent Custom Apis
|
|
161
|
+
*/
|
|
162
|
+
async listAgentCustomApisRaw(requestParameters, initOverrides) {
|
|
163
|
+
if (requestParameters['agentId'] == null) {
|
|
164
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling listAgentCustomApis().');
|
|
165
|
+
}
|
|
166
|
+
const queryParameters = {};
|
|
167
|
+
const headerParameters = {};
|
|
168
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
169
|
+
const token = this.configuration.accessToken;
|
|
170
|
+
const tokenString = await token("bearerAuth", []);
|
|
171
|
+
if (tokenString) {
|
|
172
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const response = await this.request({
|
|
176
|
+
path: `/v1/agents/{agentId}/custom-apis`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])),
|
|
177
|
+
method: 'GET',
|
|
178
|
+
headers: headerParameters,
|
|
179
|
+
query: queryParameters,
|
|
180
|
+
}, initOverrides);
|
|
181
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.AgentCustomApiListFromJSON)(jsonValue));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 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.
|
|
185
|
+
* List Agent Custom Apis
|
|
186
|
+
*/
|
|
187
|
+
async listAgentCustomApis(requestParameters, initOverrides) {
|
|
188
|
+
const response = await this.listAgentCustomApisRaw(requestParameters, initOverrides);
|
|
189
|
+
return await response.value();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The caller\'s own Custom APIs, newest first. ``q`` matches name, description or host; ``scope`` is ignored (the list is owner-only).
|
|
193
|
+
* List Custom Apis
|
|
194
|
+
*/
|
|
195
|
+
async listCustomApisRaw(requestParameters, initOverrides) {
|
|
196
|
+
const queryParameters = {};
|
|
197
|
+
if (requestParameters['scope'] != null) {
|
|
198
|
+
queryParameters['scope'] = requestParameters['scope'];
|
|
199
|
+
}
|
|
200
|
+
if (requestParameters['q'] != null) {
|
|
201
|
+
queryParameters['q'] = requestParameters['q'];
|
|
202
|
+
}
|
|
203
|
+
if (requestParameters['limit'] != null) {
|
|
204
|
+
queryParameters['limit'] = requestParameters['limit'];
|
|
205
|
+
}
|
|
206
|
+
if (requestParameters['offset'] != null) {
|
|
207
|
+
queryParameters['offset'] = requestParameters['offset'];
|
|
208
|
+
}
|
|
209
|
+
const headerParameters = {};
|
|
210
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
211
|
+
const token = this.configuration.accessToken;
|
|
212
|
+
const tokenString = await token("bearerAuth", []);
|
|
213
|
+
if (tokenString) {
|
|
214
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const response = await this.request({
|
|
218
|
+
path: `/v2/custom-apis`,
|
|
219
|
+
method: 'GET',
|
|
220
|
+
headers: headerParameters,
|
|
221
|
+
query: queryParameters,
|
|
222
|
+
}, initOverrides);
|
|
223
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.CustomApiListFromJSON)(jsonValue));
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The caller\'s own Custom APIs, newest first. ``q`` matches name, description or host; ``scope`` is ignored (the list is owner-only).
|
|
227
|
+
* List Custom Apis
|
|
228
|
+
*/
|
|
229
|
+
async listCustomApis(requestParameters = {}, initOverrides) {
|
|
230
|
+
const response = await this.listCustomApisRaw(requestParameters, initOverrides);
|
|
231
|
+
return await response.value();
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Unbind Custom Api
|
|
235
|
+
*/
|
|
236
|
+
async unbindCustomApiRaw(requestParameters, initOverrides) {
|
|
237
|
+
if (requestParameters['agentId'] == null) {
|
|
238
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling unbindCustomApi().');
|
|
239
|
+
}
|
|
240
|
+
if (requestParameters['customApiId'] == null) {
|
|
241
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling unbindCustomApi().');
|
|
242
|
+
}
|
|
243
|
+
const queryParameters = {};
|
|
244
|
+
const headerParameters = {};
|
|
245
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
246
|
+
const token = this.configuration.accessToken;
|
|
247
|
+
const tokenString = await token("bearerAuth", []);
|
|
248
|
+
if (tokenString) {
|
|
249
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const response = await this.request({
|
|
253
|
+
path: `/v1/agents/{agentId}/custom-apis/{customApiId}`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])).replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
254
|
+
method: 'DELETE',
|
|
255
|
+
headers: headerParameters,
|
|
256
|
+
query: queryParameters,
|
|
257
|
+
}, initOverrides);
|
|
258
|
+
return new runtime.VoidApiResponse(response);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Unbind Custom Api
|
|
262
|
+
*/
|
|
263
|
+
async unbindCustomApi(requestParameters, initOverrides) {
|
|
264
|
+
await this.unbindCustomApiRaw(requestParameters, initOverrides);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Edit details and/or replace credentials. Attachments are kept.
|
|
268
|
+
* Update Custom Api
|
|
269
|
+
*/
|
|
270
|
+
async updateCustomApiRaw(requestParameters, initOverrides) {
|
|
271
|
+
if (requestParameters['customApiId'] == null) {
|
|
272
|
+
throw new runtime.RequiredError('customApiId', 'Required parameter "customApiId" was null or undefined when calling updateCustomApi().');
|
|
273
|
+
}
|
|
274
|
+
if (requestParameters['customApiUpdate'] == null) {
|
|
275
|
+
throw new runtime.RequiredError('customApiUpdate', 'Required parameter "customApiUpdate" was null or undefined when calling updateCustomApi().');
|
|
276
|
+
}
|
|
277
|
+
const queryParameters = {};
|
|
278
|
+
const headerParameters = {};
|
|
279
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
280
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
281
|
+
const token = this.configuration.accessToken;
|
|
282
|
+
const tokenString = await token("bearerAuth", []);
|
|
283
|
+
if (tokenString) {
|
|
284
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const response = await this.request({
|
|
288
|
+
path: `/v2/custom-apis/{customApiId}`.replace(`{${"customApiId"}}`, runtime.encodePathParam('customApiId', requestParameters['customApiId'])),
|
|
289
|
+
method: 'PATCH',
|
|
290
|
+
headers: headerParameters,
|
|
291
|
+
query: queryParameters,
|
|
292
|
+
body: (0, index_js_1.CustomApiUpdateToJSON)(requestParameters['customApiUpdate']),
|
|
293
|
+
}, initOverrides);
|
|
294
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.CustomApiFromJSON)(jsonValue));
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Edit details and/or replace credentials. Attachments are kept.
|
|
298
|
+
* Update Custom Api
|
|
299
|
+
*/
|
|
300
|
+
async updateCustomApi(requestParameters, initOverrides) {
|
|
301
|
+
const response = await this.updateCustomApiRaw(requestParameters, initOverrides);
|
|
302
|
+
return await response.value();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.CustomAPIsApi = CustomAPIsApi;
|
|
@@ -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,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* Sarvam Agents API
|
|
6
|
+
* 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.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 0.1.0
|
|
9
|
+
* Contact: support@sarvam.ai
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ModelsApi = void 0;
|
|
17
|
+
const runtime = require("../runtime.js");
|
|
18
|
+
const index_js_1 = require("../models/index.js");
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
class ModelsApi extends runtime.BaseAPI {
|
|
23
|
+
/**
|
|
24
|
+
* List Models
|
|
25
|
+
*/
|
|
26
|
+
async listModelsRaw(initOverrides) {
|
|
27
|
+
const queryParameters = {};
|
|
28
|
+
const headerParameters = {};
|
|
29
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
30
|
+
const token = this.configuration.accessToken;
|
|
31
|
+
const tokenString = await token("bearerAuth", []);
|
|
32
|
+
if (tokenString) {
|
|
33
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const response = await this.request({
|
|
37
|
+
path: `/v1/models`,
|
|
38
|
+
method: 'GET',
|
|
39
|
+
headers: headerParameters,
|
|
40
|
+
query: queryParameters,
|
|
41
|
+
}, initOverrides);
|
|
42
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.ModelsResponseFromJSON)(jsonValue));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* List Models
|
|
46
|
+
*/
|
|
47
|
+
async listModels(initOverrides) {
|
|
48
|
+
const response = await this.listModelsRaw(initOverrides);
|
|
49
|
+
return await response.value();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ModelsApi = ModelsApi;
|
package/dist/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/apis/index.js
CHANGED
|
@@ -24,7 +24,9 @@ __exportStar(require("./ClarifyApi.js"), exports);
|
|
|
24
24
|
__exportStar(require("./CollectionsApi.js"), exports);
|
|
25
25
|
__exportStar(require("./ConversationsApi.js"), exports);
|
|
26
26
|
__exportStar(require("./CronsApi.js"), exports);
|
|
27
|
+
__exportStar(require("./CustomAPIsApi.js"), exports);
|
|
27
28
|
__exportStar(require("./MessagesApi.js"), exports);
|
|
29
|
+
__exportStar(require("./ModelsApi.js"), exports);
|
|
28
30
|
__exportStar(require("./QueueApi.js"), exports);
|
|
29
31
|
__exportStar(require("./ResponsesApi.js"), exports);
|
|
30
32
|
__exportStar(require("./SkillsApi.js"), exports);
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
modelSettings?: ModelSettings;
|
|
21
|
+
fallbackModels?: string[];
|
|
22
|
+
tools?: BuiltinTool[];
|
|
23
|
+
limits?: Limits;
|
|
24
|
+
metadata?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export declare class Agent {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly instructions: string;
|
|
29
|
+
readonly model?: string;
|
|
30
|
+
readonly modelSettings?: ModelSettings;
|
|
31
|
+
readonly fallbackModels?: string[];
|
|
32
|
+
readonly tools: readonly BuiltinTool[];
|
|
33
|
+
readonly limits?: Limits;
|
|
34
|
+
readonly metadata?: Record<string, string>;
|
|
35
|
+
constructor(rawOpts: AgentOptions);
|
|
36
|
+
private check;
|
|
37
|
+
private baseSettings;
|
|
38
|
+
specHash(): string;
|
|
39
|
+
toSettings(): Record<string, unknown>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Agent = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
const fingerprint_js_1 = require("./fingerprint.js");
|
|
6
|
+
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
7
|
+
const REASONING = ["off", "none", "low", "medium", "high", "xhigh", "max"];
|
|
8
|
+
const TOOL_CHOICES = ["auto", "none"];
|
|
9
|
+
function deepFreeze(value) {
|
|
10
|
+
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
11
|
+
Object.freeze(value);
|
|
12
|
+
for (const key of Object.keys(value))
|
|
13
|
+
deepFreeze(value[key]);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function clone(value) {
|
|
18
|
+
return value === undefined ? value : JSON.parse(JSON.stringify(value));
|
|
19
|
+
}
|
|
20
|
+
function isPositiveInt(n) {
|
|
21
|
+
return typeof n === "number" && Number.isInteger(n) && n >= 1;
|
|
22
|
+
}
|
|
23
|
+
function isFiniteNumber(n) {
|
|
24
|
+
return typeof n === "number" && Number.isFinite(n);
|
|
25
|
+
}
|
|
26
|
+
/** Runs on the raw options, before the JSON clone turns NaN/Infinity into null. */
|
|
27
|
+
function checkNumbers(opts) {
|
|
28
|
+
const ms = opts.modelSettings;
|
|
29
|
+
if (ms !== undefined && ms !== null) {
|
|
30
|
+
if (ms.temperature !== undefined && !(isFiniteNumber(ms.temperature) && ms.temperature >= 0 && ms.temperature <= 2)) {
|
|
31
|
+
throw new errors_js_1.UserError("modelSettings.temperature: must be a number between 0 and 2");
|
|
32
|
+
}
|
|
33
|
+
if (ms.topP !== undefined && !(isFiniteNumber(ms.topP) && ms.topP > 0 && ms.topP <= 1)) {
|
|
34
|
+
throw new errors_js_1.UserError("modelSettings.topP: must be a number > 0 and <= 1");
|
|
35
|
+
}
|
|
36
|
+
if (ms.maxTokens !== undefined && !isPositiveInt(ms.maxTokens)) {
|
|
37
|
+
throw new errors_js_1.UserError("modelSettings.maxTokens: must be an integer >= 1");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const limits = opts.limits;
|
|
41
|
+
if (limits !== undefined && limits !== null) {
|
|
42
|
+
for (const key of ["maxTurns", "maxToolCallsPerTurn", "maxTokensPerTurn"]) {
|
|
43
|
+
if (limits[key] !== undefined && !isPositiveInt(limits[key])) {
|
|
44
|
+
throw new errors_js_1.UserError(`limits.${key}: must be an integer >= 1`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Drops null-valued own keys (shallow copy); a non-object (null/undefined) becomes undefined. */
|
|
50
|
+
function dropNulls(value) {
|
|
51
|
+
if (value === null || value === undefined || typeof value !== "object")
|
|
52
|
+
return undefined;
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const key of Object.keys(value)) {
|
|
55
|
+
const v = value[key];
|
|
56
|
+
if (v !== null && v !== undefined)
|
|
57
|
+
out[key] = v;
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** JS callers spreading JSON configs pass null for unset fields; null means unset everywhere (like Python's None). */
|
|
62
|
+
function normalize(raw) {
|
|
63
|
+
const opts = dropNulls(raw);
|
|
64
|
+
if (opts.modelSettings !== undefined)
|
|
65
|
+
opts.modelSettings = dropNulls(opts.modelSettings);
|
|
66
|
+
if (opts.limits !== undefined)
|
|
67
|
+
opts.limits = dropNulls(opts.limits);
|
|
68
|
+
return opts;
|
|
69
|
+
}
|
|
70
|
+
const LIMIT_KEYS = [
|
|
71
|
+
["maxTurns", "max_turns"],
|
|
72
|
+
["maxToolCallsPerTurn", "max_tool_calls_per_turn"],
|
|
73
|
+
["maxTokensPerTurn", "max_tokens_per_turn"],
|
|
74
|
+
];
|
|
75
|
+
class Agent {
|
|
76
|
+
constructor(rawOpts) {
|
|
77
|
+
var _a, _b, _c;
|
|
78
|
+
const opts = normalize(rawOpts);
|
|
79
|
+
for (const tool of (_a = opts.tools) !== null && _a !== void 0 ? _a : []) {
|
|
80
|
+
if (tool instanceof Agent) {
|
|
81
|
+
throw new errors_js_1.NotSupportedError("sub-agents in tools are not supported yet (field: tools)");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
checkNumbers(opts);
|
|
85
|
+
this.name = opts.name;
|
|
86
|
+
this.instructions = (_b = opts.instructions) !== null && _b !== void 0 ? _b : "";
|
|
87
|
+
this.model = opts.model;
|
|
88
|
+
this.modelSettings = clone(opts.modelSettings);
|
|
89
|
+
this.fallbackModels = clone(opts.fallbackModels);
|
|
90
|
+
this.tools = clone((_c = opts.tools) !== null && _c !== void 0 ? _c : []);
|
|
91
|
+
this.limits = clone(opts.limits);
|
|
92
|
+
this.metadata = clone(opts.metadata);
|
|
93
|
+
this.check();
|
|
94
|
+
deepFreeze(this);
|
|
95
|
+
}
|
|
96
|
+
check() {
|
|
97
|
+
if (typeof this.name !== "string" || !SLUG.test(this.name)) {
|
|
98
|
+
throw new errors_js_1.UserError(`name: ${JSON.stringify(this.name)} must match ${SLUG.source}`);
|
|
99
|
+
}
|
|
100
|
+
const ms = this.modelSettings;
|
|
101
|
+
if (ms !== undefined) {
|
|
102
|
+
if (ms.reasoning !== undefined && REASONING.indexOf(ms.reasoning.effort) === -1) {
|
|
103
|
+
throw new errors_js_1.UserError(`modelSettings.reasoning: ${JSON.stringify(ms.reasoning.effort)} must be one of ${REASONING.join(", ")}`);
|
|
104
|
+
}
|
|
105
|
+
if (ms.toolChoice !== undefined && TOOL_CHOICES.indexOf(ms.toolChoice) === -1) {
|
|
106
|
+
throw new errors_js_1.UserError(`modelSettings.toolChoice: ${JSON.stringify(ms.toolChoice)} must be one of ${TOOL_CHOICES.join(", ")}`);
|
|
107
|
+
}
|
|
108
|
+
if (ms.temperature !== undefined && !(ms.temperature >= 0 && ms.temperature <= 2)) {
|
|
109
|
+
throw new errors_js_1.UserError("modelSettings.temperature: must be between 0 and 2");
|
|
110
|
+
}
|
|
111
|
+
if (ms.topP !== undefined && !(ms.topP > 0 && ms.topP <= 1)) {
|
|
112
|
+
throw new errors_js_1.UserError("modelSettings.topP: must be > 0 and <= 1");
|
|
113
|
+
}
|
|
114
|
+
if (ms.maxTokens !== undefined && !isPositiveInt(ms.maxTokens)) {
|
|
115
|
+
throw new errors_js_1.UserError("modelSettings.maxTokens: must be an integer >= 1");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (this.limits !== undefined) {
|
|
119
|
+
for (const [key] of LIMIT_KEYS) {
|
|
120
|
+
const value = this.limits[key];
|
|
121
|
+
if (value !== undefined && !isPositiveInt(value)) {
|
|
122
|
+
throw new errors_js_1.UserError(`limits.${key}: must be an integer >= 1`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (this.metadata !== undefined) {
|
|
127
|
+
const bad = Object.keys(this.metadata).filter((k) => k.indexOf("sdk_") === 0).sort();
|
|
128
|
+
if (bad.length > 0) {
|
|
129
|
+
throw new errors_js_1.UserError(`metadata: keys starting with 'sdk_' are reserved (${bad.join(", ")})`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const names = this.tools.map((t) => t.name);
|
|
133
|
+
const dupes = Array.from(new Set(names.filter((n, i) => names.indexOf(n) !== i))).sort();
|
|
134
|
+
if (dupes.length > 0) {
|
|
135
|
+
throw new errors_js_1.UserError(`tools: duplicate built-in tool(s): ${dupes.join(", ")}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
baseSettings() {
|
|
139
|
+
const out = { version: 1 };
|
|
140
|
+
if (this.model !== undefined)
|
|
141
|
+
out["model"] = this.model;
|
|
142
|
+
const ms = this.modelSettings;
|
|
143
|
+
if (ms !== undefined) {
|
|
144
|
+
if (ms.reasoning !== undefined)
|
|
145
|
+
out["reasoning"] = ms.reasoning.effort;
|
|
146
|
+
if (ms.temperature !== undefined)
|
|
147
|
+
out["temperature"] = ms.temperature;
|
|
148
|
+
if (ms.topP !== undefined)
|
|
149
|
+
out["top_p"] = ms.topP;
|
|
150
|
+
if (ms.maxTokens !== undefined)
|
|
151
|
+
out["max_output_tokens"] = ms.maxTokens;
|
|
152
|
+
if (ms.toolChoice !== undefined)
|
|
153
|
+
out["tool_choice"] = ms.toolChoice;
|
|
154
|
+
}
|
|
155
|
+
if (this.fallbackModels !== undefined && this.fallbackModels.length > 0) {
|
|
156
|
+
out["fallback"] = clone(this.fallbackModels);
|
|
157
|
+
}
|
|
158
|
+
if (this.limits !== undefined) {
|
|
159
|
+
const limits = {};
|
|
160
|
+
for (const [key, wire] of LIMIT_KEYS) {
|
|
161
|
+
const value = this.limits[key];
|
|
162
|
+
if (value !== undefined)
|
|
163
|
+
limits[wire] = value;
|
|
164
|
+
}
|
|
165
|
+
if (Object.keys(limits).length > 0)
|
|
166
|
+
out["limits"] = limits;
|
|
167
|
+
}
|
|
168
|
+
if (this.tools.length > 0) {
|
|
169
|
+
const tools = {};
|
|
170
|
+
for (const t of this.tools) {
|
|
171
|
+
tools[t.name] = t.options !== undefined && Object.keys(t.options).length > 0 ? clone(t.options) : true;
|
|
172
|
+
}
|
|
173
|
+
out["builtin_tools"] = tools;
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
specHash() {
|
|
178
|
+
const settings = this.baseSettings();
|
|
179
|
+
if (this.metadata !== undefined && Object.keys(this.metadata).length > 0) {
|
|
180
|
+
settings["metadata"] = { ...this.metadata };
|
|
181
|
+
}
|
|
182
|
+
return (0, fingerprint_js_1.settingsFingerprint)(this.instructions, settings);
|
|
183
|
+
}
|
|
184
|
+
toSettings() {
|
|
185
|
+
var _a;
|
|
186
|
+
const out = this.baseSettings();
|
|
187
|
+
out["metadata"] = { ...((_a = this.metadata) !== null && _a !== void 0 ? _a : {}), sdk_name: this.name, sdk_hash: this.specHash() };
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.Agent = Agent;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** deploy()/undeploy(): upsert a hosted agent by name, with fingerprint-based drift detection, and the deploy cache. */
|
|
2
|
+
import type { Configuration } from "../runtime.js";
|
|
3
|
+
import type { Agent } from "./agent.js";
|
|
4
|
+
import type { Transport } from "./transport.js";
|
|
5
|
+
export interface Deployment {
|
|
6
|
+
agentId: string;
|
|
7
|
+
action: "created" | "updated" | "unchanged";
|
|
8
|
+
}
|
|
9
|
+
/** Set (or clear, with null) the client used when deploy/undeploy/run get no client. */
|
|
10
|
+
export declare function setDefaultClient(config: Configuration | null): void;
|
|
11
|
+
export declare function getDefaultClient(): Configuration | null;
|
|
12
|
+
export declare function resolveTransport(client?: Configuration, transport?: Transport): Transport;
|
|
13
|
+
export declare function deploy(agent: Agent, opts?: {
|
|
14
|
+
client?: Configuration;
|
|
15
|
+
transport?: Transport;
|
|
16
|
+
strict?: boolean;
|
|
17
|
+
adopt?: string;
|
|
18
|
+
}): Promise<Deployment>;
|
|
19
|
+
export declare function undeploy(name: string, opts?: {
|
|
20
|
+
client?: Configuration;
|
|
21
|
+
transport?: Transport;
|
|
22
|
+
}): Promise<boolean>;
|
|
23
|
+
/** Drop cached deployments of agent `name` (any owner); called by deploy() and undeploy(). */
|
|
24
|
+
export declare function forget(name: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* The server id for `agent`, deploying it first unless this owner already deployed this exact definition.
|
|
27
|
+
* Keyed by name, as the server is: a variant with the same name redeploys, chained after any in-flight deploy so
|
|
28
|
+
* deploys of one name never overlap.
|
|
29
|
+
*/
|
|
30
|
+
export declare function agentIdFor(agent: Agent, transport: Transport, owner: object): Promise<string>;
|