sarvam-agents-client 0.2.3 → 0.3.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 +16 -1
- package/dist/apis/AgentsApi.d.ts +4 -4
- package/dist/apis/AgentsApi.js +4 -4
- package/dist/apis/AppsApi.d.ts +1 -0
- package/dist/apis/AppsApi.js +3 -0
- package/dist/apis/FunctionToolsApi.d.ts +33 -0
- package/dist/apis/FunctionToolsApi.js +65 -0
- package/dist/apis/QueueApi.d.ts +1 -0
- package/dist/apis/QueueApi.js +3 -0
- package/dist/apis/ResponsesApi.d.ts +2 -0
- package/dist/apis/ResponsesApi.js +6 -0
- package/dist/apis/index.d.ts +1 -0
- package/dist/apis/index.js +1 -0
- package/dist/compose/agent.d.ts +26 -6
- package/dist/compose/agent.js +84 -7
- package/dist/compose/deploy.d.ts +3 -2
- package/dist/compose/errors.d.ts +22 -1
- package/dist/compose/errors.js +21 -1
- package/dist/compose/events.d.ts +38 -0
- package/dist/compose/events.js +59 -2
- package/dist/compose/functionTool.d.ts +101 -0
- package/dist/compose/functionTool.js +420 -0
- package/dist/compose/index.d.ts +7 -3
- package/dist/compose/index.js +3 -1
- package/dist/compose/output.d.ts +40 -0
- package/dist/compose/output.js +476 -0
- package/dist/compose/run.d.ts +44 -15
- package/dist/compose/run.js +164 -21
- package/dist/compose/runState.d.ts +28 -2
- package/dist/compose/runState.js +30 -0
- package/dist/compose/settingsTransport.d.ts +23 -3
- package/dist/compose/settingsTransport.js +295 -3
- package/dist/compose/transport.d.ts +21 -3
- package/dist/esm/apis/AgentsApi.d.ts +4 -4
- package/dist/esm/apis/AgentsApi.js +4 -4
- package/dist/esm/apis/AppsApi.d.ts +1 -0
- package/dist/esm/apis/AppsApi.js +3 -0
- package/dist/esm/apis/FunctionToolsApi.d.ts +33 -0
- package/dist/esm/apis/FunctionToolsApi.js +61 -0
- package/dist/esm/apis/QueueApi.d.ts +1 -0
- package/dist/esm/apis/QueueApi.js +3 -0
- package/dist/esm/apis/ResponsesApi.d.ts +2 -0
- package/dist/esm/apis/ResponsesApi.js +6 -0
- package/dist/esm/apis/index.d.ts +1 -0
- package/dist/esm/apis/index.js +1 -0
- package/dist/esm/compose/agent.d.ts +26 -6
- package/dist/esm/compose/agent.js +84 -7
- package/dist/esm/compose/deploy.d.ts +3 -2
- package/dist/esm/compose/errors.d.ts +22 -1
- package/dist/esm/compose/errors.js +21 -1
- package/dist/esm/compose/events.d.ts +38 -0
- package/dist/esm/compose/events.js +58 -2
- package/dist/esm/compose/functionTool.d.ts +101 -0
- package/dist/esm/compose/functionTool.js +406 -0
- package/dist/esm/compose/index.d.ts +7 -3
- package/dist/esm/compose/index.js +1 -0
- package/dist/esm/compose/output.d.ts +40 -0
- package/dist/esm/compose/output.js +466 -0
- package/dist/esm/compose/run.d.ts +44 -15
- package/dist/esm/compose/run.js +165 -22
- package/dist/esm/compose/runState.d.ts +28 -2
- package/dist/esm/compose/runState.js +31 -1
- package/dist/esm/compose/settingsTransport.d.ts +23 -3
- package/dist/esm/compose/settingsTransport.js +298 -7
- package/dist/esm/compose/transport.d.ts +21 -3
- package/dist/esm/models/AgentConversationDetail.d.ts +7 -0
- package/dist/esm/models/AgentConversationDetail.js +3 -0
- package/dist/esm/models/AppResource.d.ts +29 -0
- package/dist/esm/models/AppResource.js +16 -0
- package/dist/esm/models/AppToolsResponse.d.ts +3 -4
- package/dist/esm/models/AppToolsResponse.js +3 -2
- package/dist/esm/models/AppView.d.ts +48 -0
- package/dist/esm/models/AppView.js +23 -0
- package/dist/esm/models/ClarifyBody.d.ts +6 -0
- package/dist/esm/models/ClarifyBody.js +2 -0
- package/dist/esm/models/ConversationDetail.d.ts +7 -0
- package/dist/esm/models/ConversationDetail.js +3 -0
- package/dist/esm/models/ErrorDetail.d.ts +1 -0
- package/dist/esm/models/ErrorDetail.js +2 -1
- package/dist/esm/models/FunctionResultBody.d.ts +44 -0
- package/dist/esm/models/FunctionResultBody.js +49 -0
- package/dist/esm/models/McpSecurityAppealView.d.ts +50 -0
- package/dist/esm/models/McpSecurityAppealView.js +47 -0
- package/dist/esm/models/McpSecurityView.d.ts +105 -0
- package/dist/esm/models/McpSecurityView.js +66 -0
- package/dist/esm/models/MessagesResponse.d.ts +6 -0
- package/dist/esm/models/MessagesResponse.js +2 -0
- package/dist/esm/models/QueueMessageInput.d.ts +23 -0
- package/dist/esm/models/QueueMessageInput.js +14 -0
- package/dist/esm/models/RequiredAction.d.ts +77 -0
- package/dist/esm/models/RequiredAction.js +69 -0
- package/dist/esm/models/ResponseDetail.d.ts +40 -0
- package/dist/esm/models/ResponseDetail.js +12 -0
- package/dist/esm/models/ResponseInput.d.ts +23 -0
- package/dist/esm/models/ResponseInput.js +14 -0
- package/dist/esm/models/ToolResults200Response.d.ts +38 -0
- package/dist/esm/models/ToolResults200Response.js +47 -0
- package/dist/esm/models/ToolResultsBody.d.ts +39 -0
- package/dist/esm/models/ToolResultsBody.js +48 -0
- package/dist/esm/models/index.d.ts +6 -0
- package/dist/esm/models/index.js +6 -0
- package/dist/esm/streaming.d.ts +14 -2
- package/dist/esm/streaming.js +26 -4
- package/dist/models/AgentConversationDetail.d.ts +7 -0
- package/dist/models/AgentConversationDetail.js +3 -0
- package/dist/models/AppResource.d.ts +29 -0
- package/dist/models/AppResource.js +17 -1
- package/dist/models/AppToolsResponse.d.ts +3 -4
- package/dist/models/AppToolsResponse.js +3 -2
- package/dist/models/AppView.d.ts +48 -0
- package/dist/models/AppView.js +24 -1
- package/dist/models/ClarifyBody.d.ts +6 -0
- package/dist/models/ClarifyBody.js +2 -0
- package/dist/models/ConversationDetail.d.ts +7 -0
- package/dist/models/ConversationDetail.js +3 -0
- package/dist/models/ErrorDetail.d.ts +1 -0
- package/dist/models/ErrorDetail.js +2 -1
- package/dist/models/FunctionResultBody.d.ts +44 -0
- package/dist/models/FunctionResultBody.js +56 -0
- package/dist/models/McpSecurityAppealView.d.ts +50 -0
- package/dist/models/McpSecurityAppealView.js +54 -0
- package/dist/models/McpSecurityView.d.ts +105 -0
- package/dist/models/McpSecurityView.js +73 -0
- package/dist/models/MessagesResponse.d.ts +6 -0
- package/dist/models/MessagesResponse.js +2 -0
- package/dist/models/QueueMessageInput.d.ts +23 -0
- package/dist/models/QueueMessageInput.js +15 -1
- package/dist/models/RequiredAction.d.ts +77 -0
- package/dist/models/RequiredAction.js +77 -0
- package/dist/models/ResponseDetail.d.ts +40 -0
- package/dist/models/ResponseDetail.js +12 -0
- package/dist/models/ResponseInput.d.ts +23 -0
- package/dist/models/ResponseInput.js +15 -0
- package/dist/models/ToolResults200Response.d.ts +38 -0
- package/dist/models/ToolResults200Response.js +54 -0
- package/dist/models/ToolResultsBody.d.ts +39 -0
- package/dist/models/ToolResultsBody.js +55 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +6 -0
- package/dist/streaming.d.ts +14 -2
- package/dist/streaming.js +27 -4
- package/package.json +4 -3
- package/src/apis/AgentsApi.ts +4 -4
- package/src/apis/AppsApi.ts +5 -0
- package/src/apis/FunctionToolsApi.ts +102 -0
- package/src/apis/QueueApi.ts +5 -0
- package/src/apis/ResponsesApi.ts +10 -0
- package/src/apis/index.ts +1 -0
- package/src/compose/agent.ts +108 -15
- package/src/compose/deploy.ts +6 -5
- package/src/compose/errors.ts +35 -2
- package/src/compose/events.ts +79 -1
- package/src/compose/functionTool.ts +441 -0
- package/src/compose/index.ts +7 -3
- package/src/compose/output.ts +436 -0
- package/src/compose/run.ts +208 -39
- package/src/compose/runState.ts +46 -6
- package/src/compose/settingsTransport.ts +297 -10
- package/src/compose/transport.ts +27 -3
- package/src/models/AgentConversationDetail.ts +15 -0
- package/src/models/AppResource.ts +42 -0
- package/src/models/AppToolsResponse.ts +11 -4
- package/src/models/AppView.ts +73 -0
- package/src/models/ClarifyBody.ts +8 -0
- package/src/models/ConversationDetail.ts +15 -0
- package/src/models/ErrorDetail.ts +2 -1
- package/src/models/FunctionResultBody.ts +83 -0
- package/src/models/McpSecurityAppealView.ts +89 -0
- package/src/models/McpSecurityView.ts +169 -0
- package/src/models/MessagesResponse.ts +8 -0
- package/src/models/QueueMessageInput.ts +28 -0
- package/src/models/RequiredAction.ts +128 -0
- package/src/models/ResponseDetail.ts +48 -0
- package/src/models/ResponseInput.ts +30 -0
- package/src/models/ToolResults200Response.ts +75 -0
- package/src/models/ToolResultsBody.ts +83 -0
- package/src/models/index.ts +6 -0
- package/src/streaming.ts +39 -3
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
|
|
15
|
+
import { mapValues } from '../runtime.js';
|
|
16
|
+
/**
|
|
17
|
+
* One function call the app must run before the turn can continue.
|
|
18
|
+
* @export
|
|
19
|
+
* @interface RequiredAction
|
|
20
|
+
*/
|
|
21
|
+
export interface RequiredAction {
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @memberof RequiredAction
|
|
26
|
+
*/
|
|
27
|
+
type?: RequiredActionTypeEnum;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @memberof RequiredAction
|
|
32
|
+
*/
|
|
33
|
+
requestId: string;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @memberof RequiredAction
|
|
38
|
+
*/
|
|
39
|
+
toolCallId: string;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @type {string}
|
|
43
|
+
* @memberof RequiredAction
|
|
44
|
+
*/
|
|
45
|
+
name: string;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @type {{ [key: string]: any; }}
|
|
49
|
+
* @memberof RequiredAction
|
|
50
|
+
*/
|
|
51
|
+
arguments: { [key: string]: any; };
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @type {Date}
|
|
55
|
+
* @memberof RequiredAction
|
|
56
|
+
*/
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @type {Date}
|
|
61
|
+
* @memberof RequiredAction
|
|
62
|
+
*/
|
|
63
|
+
expiresAt?: Date | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @export
|
|
69
|
+
*/
|
|
70
|
+
export const RequiredActionTypeEnum = {
|
|
71
|
+
FunctionCall: 'function_call'
|
|
72
|
+
} as const;
|
|
73
|
+
export type RequiredActionTypeEnum = typeof RequiredActionTypeEnum[keyof typeof RequiredActionTypeEnum];
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check if a given object implements the RequiredAction interface.
|
|
78
|
+
*/
|
|
79
|
+
export function instanceOfRequiredAction(value: object): value is RequiredAction {
|
|
80
|
+
if (!('requestId' in value) || value['requestId'] === undefined) return false;
|
|
81
|
+
if (!('toolCallId' in value) || value['toolCallId'] === undefined) return false;
|
|
82
|
+
if (!('name' in value) || value['name'] === undefined) return false;
|
|
83
|
+
if (!('arguments' in value) || value['arguments'] === undefined) return false;
|
|
84
|
+
if (!('createdAt' in value) || value['createdAt'] === undefined) return false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function RequiredActionFromJSON(json: any): RequiredAction {
|
|
89
|
+
return RequiredActionFromJSONTyped(json, false);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function RequiredActionFromJSONTyped(json: any, ignoreDiscriminator: boolean): RequiredAction {
|
|
93
|
+
if (json == null) {
|
|
94
|
+
return json;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
|
|
98
|
+
'type': json['type'] == null ? undefined : json['type'],
|
|
99
|
+
'requestId': json['requestId'],
|
|
100
|
+
'toolCallId': json['toolCallId'],
|
|
101
|
+
'name': json['name'],
|
|
102
|
+
'arguments': json['arguments'],
|
|
103
|
+
'createdAt': (new Date(json['createdAt'])),
|
|
104
|
+
'expiresAt': json['expiresAt'] == null ? undefined : (new Date(json['expiresAt'])),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function RequiredActionToJSON(json: any): RequiredAction {
|
|
109
|
+
return RequiredActionToJSONTyped(json, false);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function RequiredActionToJSONTyped(value?: RequiredAction | null, ignoreDiscriminator: boolean = false): any {
|
|
113
|
+
if (value == null) {
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
|
|
119
|
+
'type': value['type'],
|
|
120
|
+
'requestId': value['requestId'],
|
|
121
|
+
'toolCallId': value['toolCallId'],
|
|
122
|
+
'name': value['name'],
|
|
123
|
+
'arguments': value['arguments'],
|
|
124
|
+
'createdAt': ((value['createdAt']).toISOString()),
|
|
125
|
+
'expiresAt': value['expiresAt'] == null ? undefined : ((value['expiresAt'] as any).toISOString()),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
@@ -45,6 +45,42 @@ export interface ResponseDetail {
|
|
|
45
45
|
* @memberof ResponseDetail
|
|
46
46
|
*/
|
|
47
47
|
output: Array<UIMessage>;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @type {{ [key: string]: any; }}
|
|
51
|
+
* @memberof ResponseDetail
|
|
52
|
+
*/
|
|
53
|
+
usage?: { [key: string]: any; } | null;
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @type {any}
|
|
57
|
+
* @memberof ResponseDetail
|
|
58
|
+
*/
|
|
59
|
+
structuredOutput?: any | null;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @type {Array<string>}
|
|
63
|
+
* @memberof ResponseDetail
|
|
64
|
+
*/
|
|
65
|
+
outputErrors?: Array<string> | null;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @type {Array<{ [key: string]: any; }>}
|
|
69
|
+
* @memberof ResponseDetail
|
|
70
|
+
*/
|
|
71
|
+
outputCitations?: Array<{ [key: string]: any; }> | null;
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @memberof ResponseDetail
|
|
76
|
+
*/
|
|
77
|
+
outputNote?: string | null;
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @type {string}
|
|
81
|
+
* @memberof ResponseDetail
|
|
82
|
+
*/
|
|
83
|
+
outputSkipped?: string | null;
|
|
48
84
|
}
|
|
49
85
|
|
|
50
86
|
|
|
@@ -83,6 +119,12 @@ export function ResponseDetailFromJSONTyped(json: any, ignoreDiscriminator: bool
|
|
|
83
119
|
'responseId': json['responseId'],
|
|
84
120
|
'status': json['status'],
|
|
85
121
|
'output': ((json['output'] as Array<any>).map(UIMessageFromJSON)),
|
|
122
|
+
'usage': json['usage'] == null ? undefined : json['usage'],
|
|
123
|
+
'structuredOutput': json['structuredOutput'] == null ? undefined : json['structuredOutput'],
|
|
124
|
+
'outputErrors': json['outputErrors'] == null ? undefined : json['outputErrors'],
|
|
125
|
+
'outputCitations': json['outputCitations'] == null ? undefined : json['outputCitations'],
|
|
126
|
+
'outputNote': json['outputNote'] == null ? undefined : json['outputNote'],
|
|
127
|
+
'outputSkipped': json['outputSkipped'] == null ? undefined : json['outputSkipped'],
|
|
86
128
|
};
|
|
87
129
|
}
|
|
88
130
|
|
|
@@ -100,6 +142,12 @@ export function ResponseDetailToJSONTyped(value?: ResponseDetail | null, ignoreD
|
|
|
100
142
|
'responseId': value['responseId'],
|
|
101
143
|
'status': value['status'],
|
|
102
144
|
'output': ((value['output'] as Array<any>).map(UIMessageToJSON)),
|
|
145
|
+
'usage': value['usage'],
|
|
146
|
+
'structuredOutput': value['structuredOutput'],
|
|
147
|
+
'outputErrors': value['outputErrors'],
|
|
148
|
+
'outputCitations': value['outputCitations'],
|
|
149
|
+
'outputNote': value['outputNote'],
|
|
150
|
+
'outputSkipped': value['outputSkipped'],
|
|
103
151
|
};
|
|
104
152
|
}
|
|
105
153
|
|
|
@@ -69,8 +69,34 @@ export interface ResponseInput {
|
|
|
69
69
|
* @memberof ResponseInput
|
|
70
70
|
*/
|
|
71
71
|
retryOf?: string | null;
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @memberof ResponseInput
|
|
76
|
+
*/
|
|
77
|
+
surface?: ResponseInputSurfaceEnum | null;
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @type {string}
|
|
81
|
+
* @memberof ResponseInput
|
|
82
|
+
*/
|
|
83
|
+
endUserId?: string | null;
|
|
72
84
|
}
|
|
73
85
|
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @export
|
|
89
|
+
*/
|
|
90
|
+
export const ResponseInputSurfaceEnum = {
|
|
91
|
+
Builder: 'builder',
|
|
92
|
+
Playground: 'playground',
|
|
93
|
+
Tests: 'tests',
|
|
94
|
+
Evals: 'evals',
|
|
95
|
+
Cowork: 'cowork'
|
|
96
|
+
} as const;
|
|
97
|
+
export type ResponseInputSurfaceEnum = typeof ResponseInputSurfaceEnum[keyof typeof ResponseInputSurfaceEnum];
|
|
98
|
+
|
|
99
|
+
|
|
74
100
|
/**
|
|
75
101
|
* Check if a given object implements the ResponseInput interface.
|
|
76
102
|
*/
|
|
@@ -97,6 +123,8 @@ export function ResponseInputFromJSONTyped(json: any, ignoreDiscriminator: boole
|
|
|
97
123
|
'agentId': json['agentId'] == null ? undefined : json['agentId'],
|
|
98
124
|
'regenerateAfter': json['regenerateAfter'] == null ? undefined : json['regenerateAfter'],
|
|
99
125
|
'retryOf': json['retryOf'] == null ? undefined : json['retryOf'],
|
|
126
|
+
'surface': json['surface'] == null ? undefined : json['surface'],
|
|
127
|
+
'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
|
|
100
128
|
};
|
|
101
129
|
}
|
|
102
130
|
|
|
@@ -118,6 +146,8 @@ export function ResponseInputToJSONTyped(value?: ResponseInput | null, ignoreDis
|
|
|
118
146
|
'agentId': value['agentId'],
|
|
119
147
|
'regenerateAfter': value['regenerateAfter'],
|
|
120
148
|
'retryOf': value['retryOf'],
|
|
149
|
+
'surface': value['surface'],
|
|
150
|
+
'endUserId': value['endUserId'],
|
|
121
151
|
};
|
|
122
152
|
}
|
|
123
153
|
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
15
|
+
import { mapValues } from '../runtime.js';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @interface ToolResults200Response
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolResults200Response {
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
* @memberof ToolResults200Response
|
|
26
|
+
*/
|
|
27
|
+
accepted: boolean | null;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {boolean}
|
|
31
|
+
* @memberof ToolResults200Response
|
|
32
|
+
*/
|
|
33
|
+
duplicate: boolean | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if a given object implements the ToolResults200Response interface.
|
|
38
|
+
*/
|
|
39
|
+
export function instanceOfToolResults200Response(value: object): value is ToolResults200Response {
|
|
40
|
+
if (!('accepted' in value) || value['accepted'] === undefined) return false;
|
|
41
|
+
if (!('duplicate' in value) || value['duplicate'] === undefined) return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function ToolResults200ResponseFromJSON(json: any): ToolResults200Response {
|
|
46
|
+
return ToolResults200ResponseFromJSONTyped(json, false);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ToolResults200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ToolResults200Response {
|
|
50
|
+
if (json == null) {
|
|
51
|
+
return json;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
|
|
55
|
+
'accepted': json['accepted'],
|
|
56
|
+
'duplicate': json['duplicate'],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function ToolResults200ResponseToJSON(json: any): ToolResults200Response {
|
|
61
|
+
return ToolResults200ResponseToJSONTyped(json, false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function ToolResults200ResponseToJSONTyped(value?: ToolResults200Response | null, ignoreDiscriminator: boolean = false): any {
|
|
65
|
+
if (value == null) {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
|
|
71
|
+
'accepted': value['accepted'],
|
|
72
|
+
'duplicate': value['duplicate'],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
|
|
15
|
+
import { mapValues } from '../runtime.js';
|
|
16
|
+
import type { FunctionResultBody } from './FunctionResultBody.js';
|
|
17
|
+
import {
|
|
18
|
+
FunctionResultBodyFromJSON,
|
|
19
|
+
FunctionResultBodyFromJSONTyped,
|
|
20
|
+
FunctionResultBodyToJSON,
|
|
21
|
+
FunctionResultBodyToJSONTyped,
|
|
22
|
+
} from './FunctionResultBody.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
* @interface ToolResultsBody
|
|
28
|
+
*/
|
|
29
|
+
export interface ToolResultsBody {
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @memberof ToolResultsBody
|
|
34
|
+
*/
|
|
35
|
+
requestId: string;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {Array<FunctionResultBody>}
|
|
39
|
+
* @memberof ToolResultsBody
|
|
40
|
+
*/
|
|
41
|
+
results: Array<FunctionResultBody>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if a given object implements the ToolResultsBody interface.
|
|
46
|
+
*/
|
|
47
|
+
export function instanceOfToolResultsBody(value: object): value is ToolResultsBody {
|
|
48
|
+
if (!('requestId' in value) || value['requestId'] === undefined) return false;
|
|
49
|
+
if (!('results' in value) || value['results'] === undefined) return false;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function ToolResultsBodyFromJSON(json: any): ToolResultsBody {
|
|
54
|
+
return ToolResultsBodyFromJSONTyped(json, false);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function ToolResultsBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ToolResultsBody {
|
|
58
|
+
if (json == null) {
|
|
59
|
+
return json;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
|
|
63
|
+
'requestId': json['requestId'],
|
|
64
|
+
'results': ((json['results'] as Array<any>).map(FunctionResultBodyFromJSON)),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function ToolResultsBodyToJSON(json: any): ToolResultsBody {
|
|
69
|
+
return ToolResultsBodyToJSONTyped(json, false);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function ToolResultsBodyToJSONTyped(value?: ToolResultsBody | null, ignoreDiscriminator: boolean = false): any {
|
|
73
|
+
if (value == null) {
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
|
|
79
|
+
'requestId': value['requestId'],
|
|
80
|
+
'results': ((value['results'] as Array<any>).map(FunctionResultBodyToJSON)),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
package/src/models/index.ts
CHANGED
|
@@ -101,6 +101,7 @@ export * from './FileQueuedResponse.js';
|
|
|
101
101
|
export * from './FileRawResponse.js';
|
|
102
102
|
export * from './FileRead.js';
|
|
103
103
|
export * from './FileWriteBody.js';
|
|
104
|
+
export * from './FunctionResultBody.js';
|
|
104
105
|
export * from './HTTPValidationError.js';
|
|
105
106
|
export * from './HighlightRange.js';
|
|
106
107
|
export * from './InlineCreateSkillBody.js';
|
|
@@ -108,6 +109,8 @@ export * from './InputMessage.js';
|
|
|
108
109
|
export * from './InstructionsBody.js';
|
|
109
110
|
export * from './InstructionsResponse.js';
|
|
110
111
|
export * from './ListModels403Response.js';
|
|
112
|
+
export * from './McpSecurityAppealView.js';
|
|
113
|
+
export * from './McpSecurityView.js';
|
|
111
114
|
export * from './MessagePart.js';
|
|
112
115
|
export * from './MessagesResponse.js';
|
|
113
116
|
export * from './MintUploadUrl403Response.js';
|
|
@@ -129,6 +132,7 @@ export * from './QueueMessageInput.js';
|
|
|
129
132
|
export * from './QueueMessageResult.js';
|
|
130
133
|
export * from './QueuedTurnView.js';
|
|
131
134
|
export * from './Reason.js';
|
|
135
|
+
export * from './RequiredAction.js';
|
|
132
136
|
export * from './Requiredscope.js';
|
|
133
137
|
export * from './Resourcetype.js';
|
|
134
138
|
export * from './ResponseCompleteFileUpload.js';
|
|
@@ -152,6 +156,8 @@ export * from './StopResponse.js';
|
|
|
152
156
|
export * from './TemplateConnectorTag.js';
|
|
153
157
|
export * from './TemplateWorksWith.js';
|
|
154
158
|
export * from './TextPart.js';
|
|
159
|
+
export * from './ToolResults200Response.js';
|
|
160
|
+
export * from './ToolResultsBody.js';
|
|
155
161
|
export * from './TriggerCronBody.js';
|
|
156
162
|
export * from './TriggerResponse.js';
|
|
157
163
|
export * from './UIMessage.js';
|
package/src/streaming.ts
CHANGED
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
* const again = await reconnect(config, conversationId, stream.responseId!, stream.lastEventId);
|
|
15
15
|
*
|
|
16
16
|
* Each item is the event's JSON payload (`type` is `start`, `text-delta`, `data-file-shared`,
|
|
17
|
-
* `data-clarify-request`, `data-stopped`, `error`, `finish`, ...). The stream keeps `lastEventId` and `responseId`
|
|
17
|
+
* `data-clarify-request`, `data-function-call-request`, `data-stopped`, `error`, `finish`, ...). The stream keeps `lastEventId` and `responseId`
|
|
18
18
|
* up to date, the two values `reconnect` needs.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { ClarifyApi } from "./apis/ClarifyApi.js";
|
|
22
|
+
import { FunctionToolsApi } from "./apis/FunctionToolsApi.js";
|
|
22
23
|
import { ResponsesApi } from "./apis/ResponsesApi.js";
|
|
23
|
-
import type { ClarifyBody, ResponseInput } from "./models/index.js";
|
|
24
|
+
import type { ClarifyBody, ResponseInput, ToolResultsBody } from "./models/index.js";
|
|
24
25
|
import type { ApiResponse, Configuration } from "./runtime.js";
|
|
25
26
|
|
|
26
27
|
/** One event's JSON payload. */
|
|
@@ -97,6 +98,9 @@ export async function* iterSse(
|
|
|
97
98
|
export class ResponseStream implements AsyncIterable<StreamEvent> {
|
|
98
99
|
responseId: string | null;
|
|
99
100
|
lastEventId: string | null;
|
|
101
|
+
/** `postToolResults` only: the server already had these results (a repeat with the same idempotency key), so
|
|
102
|
+
* this stream is empty; follow the turn with `reconnect`. */
|
|
103
|
+
duplicate = false;
|
|
100
104
|
private readonly body: ReadableStream<Uint8Array>;
|
|
101
105
|
private readonly controller: AbortController;
|
|
102
106
|
private readonly idleTimeoutMs: number;
|
|
@@ -165,15 +169,25 @@ export class ResponseStream implements AsyncIterable<StreamEvent> {
|
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
async function open(
|
|
168
|
-
call: (init: RequestInit) => Promise<ApiResponse<
|
|
172
|
+
call: (init: RequestInit) => Promise<ApiResponse<unknown>>,
|
|
169
173
|
options: StreamOptions,
|
|
170
174
|
responseId: string | null = null,
|
|
171
175
|
lastEventId: string | null = null,
|
|
176
|
+
jsonIsDuplicate = false,
|
|
172
177
|
): Promise<ResponseStream> {
|
|
173
178
|
const controller = new AbortController();
|
|
174
179
|
options.signal?.addEventListener("abort", () => controller.abort(options.signal!.reason), { once: true });
|
|
175
180
|
// Non-2xx responses throw ResponseError here, like every other generated method.
|
|
176
181
|
const response = await call({ signal: controller.signal });
|
|
182
|
+
const contentType = (response.raw.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
|
|
183
|
+
if (jsonIsDuplicate && contentType === "application/json") {
|
|
184
|
+
await response.raw.body?.cancel().catch(() => undefined);
|
|
185
|
+
const empty = new ReadableStream<Uint8Array>({ start: (c) => c.close() });
|
|
186
|
+
const stream = new ResponseStream(empty, controller, options.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS);
|
|
187
|
+
stream.duplicate = true;
|
|
188
|
+
stream.close();
|
|
189
|
+
return stream;
|
|
190
|
+
}
|
|
177
191
|
if (!response.raw.body) throw new Error("response has no body to stream");
|
|
178
192
|
return new ResponseStream(
|
|
179
193
|
response.raw.body,
|
|
@@ -231,3 +245,25 @@ export function answerClarify(
|
|
|
231
245
|
): Promise<ResponseStream> {
|
|
232
246
|
return open((init) => new ClarifyApi(config).clarifyRaw({ conversationId, clarifyBody: body }, init), options);
|
|
233
247
|
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Answer the agent's function calls (a `data-function-call-request` event) and stream the rest of the reply.
|
|
251
|
+
* `body.requestId` comes from that event, with one result per call. Send the same `idempotencyKey` when you retry a
|
|
252
|
+
* post: a repeat the server already has resolves to an empty stream with `duplicate` set, and the turn can be followed
|
|
253
|
+
* with `reconnect`.
|
|
254
|
+
*/
|
|
255
|
+
export function postToolResults(
|
|
256
|
+
config: Configuration,
|
|
257
|
+
conversationId: string,
|
|
258
|
+
body: ToolResultsBody,
|
|
259
|
+
options: StreamOptions & { idempotencyKey?: string } = {},
|
|
260
|
+
): Promise<ResponseStream> {
|
|
261
|
+
return open(
|
|
262
|
+
(init) => new FunctionToolsApi(config).toolResultsRaw(
|
|
263
|
+
{ conversationId, toolResultsBody: body, idempotencyKey: options.idempotencyKey }, init),
|
|
264
|
+
options,
|
|
265
|
+
null,
|
|
266
|
+
null,
|
|
267
|
+
true,
|
|
268
|
+
);
|
|
269
|
+
}
|