sarvam-agents-client 0.5.4 → 0.5.5
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 +80 -0
- package/dist/apis/ConversationsApi.d.ts +15 -1
- package/dist/apis/ConversationsApi.js +36 -0
- package/dist/apis/FunctionToolsApi.d.ts +3 -3
- package/dist/apis/FunctionToolsApi.js +2 -1
- package/dist/apis/ResponsesApi.d.ts +3 -3
- package/dist/apis/ResponsesApi.js +4 -0
- package/dist/esm/apis/ConversationsApi.d.ts +15 -1
- package/dist/esm/apis/ConversationsApi.js +37 -1
- package/dist/esm/apis/FunctionToolsApi.d.ts +3 -3
- package/dist/esm/apis/FunctionToolsApi.js +3 -2
- package/dist/esm/apis/ResponsesApi.d.ts +3 -3
- package/dist/esm/apis/ResponsesApi.js +5 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/models/ResponseAccepted.d.ts +57 -0
- package/dist/esm/models/ResponseAccepted.js +57 -0
- package/dist/esm/models/ResponseStatusError.d.ts +38 -0
- package/dist/esm/models/ResponseStatusError.js +47 -0
- package/dist/esm/models/ResponseStatusView.d.ts +99 -0
- package/dist/esm/models/ResponseStatusView.js +79 -0
- package/dist/esm/models/ToolResultsAccepted.d.ts +52 -0
- package/dist/esm/models/ToolResultsAccepted.js +55 -0
- package/dist/esm/models/ToolResultsBody.d.ts +6 -0
- package/dist/esm/models/ToolResultsBody.js +2 -0
- package/dist/esm/models/index.d.ts +4 -0
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/polling.d.ts +122 -0
- package/dist/esm/polling.js +249 -0
- package/dist/esm/streaming.d.ts +5 -2
- package/dist/esm/streaming.js +9 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/models/ResponseAccepted.d.ts +57 -0
- package/dist/models/ResponseAccepted.js +65 -0
- package/dist/models/ResponseStatusError.d.ts +38 -0
- package/dist/models/ResponseStatusError.js +54 -0
- package/dist/models/ResponseStatusView.d.ts +99 -0
- package/dist/models/ResponseStatusView.js +87 -0
- package/dist/models/ToolResultsAccepted.d.ts +52 -0
- package/dist/models/ToolResultsAccepted.js +63 -0
- package/dist/models/ToolResultsBody.d.ts +6 -0
- package/dist/models/ToolResultsBody.js +2 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +4 -0
- package/dist/polling.d.ts +122 -0
- package/dist/polling.js +258 -0
- package/dist/streaming.d.ts +5 -2
- package/dist/streaming.js +9 -5
- package/package.json +1 -1
- package/src/apis/ConversationsApi.ts +58 -0
- package/src/apis/FunctionToolsApi.ts +7 -3
- package/src/apis/ResponsesApi.ts +9 -2
- package/src/index.ts +3 -1
- package/src/models/ResponseAccepted.ts +101 -0
- package/src/models/ResponseStatusError.ts +75 -0
- package/src/models/ResponseStatusView.ts +164 -0
- package/src/models/ToolResultsAccepted.ts +94 -0
- package/src/models/ToolResultsBody.ts +8 -0
- package/src/models/index.ts +4 -0
- package/src/polling.ts +339 -0
- package/src/streaming.ts +12 -5
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
* Check if a given object implements the ResponseStatusError interface.
|
|
16
|
+
*/
|
|
17
|
+
export function instanceOfResponseStatusError(value) {
|
|
18
|
+
if (!('code' in value) || value['code'] === undefined)
|
|
19
|
+
return false;
|
|
20
|
+
if (!('message' in value) || value['message'] === undefined)
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
export function ResponseStatusErrorFromJSON(json) {
|
|
25
|
+
return ResponseStatusErrorFromJSONTyped(json, false);
|
|
26
|
+
}
|
|
27
|
+
export function ResponseStatusErrorFromJSONTyped(json, ignoreDiscriminator) {
|
|
28
|
+
if (json == null) {
|
|
29
|
+
return json;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
'code': json['code'],
|
|
33
|
+
'message': json['message'],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function ResponseStatusErrorToJSON(json) {
|
|
37
|
+
return ResponseStatusErrorToJSONTyped(json, false);
|
|
38
|
+
}
|
|
39
|
+
export function ResponseStatusErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
40
|
+
if (value == null) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
'code': value['code'],
|
|
45
|
+
'message': value['message'],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 type { ResponseStatusError } from './ResponseStatusError.js';
|
|
13
|
+
import type { RequiredAction } from './RequiredAction.js';
|
|
14
|
+
/**
|
|
15
|
+
* The status of one response, without its output. Poll it every 1–2
|
|
16
|
+
* seconds while it is ``in_progress``; once it is ``completed``,
|
|
17
|
+
* ``failed`` or ``stopped``, read the output once from
|
|
18
|
+
* ``GET /v1/conversations/{conversationId}/responses/{responseId}``.
|
|
19
|
+
* @export
|
|
20
|
+
* @interface ResponseStatusView
|
|
21
|
+
*/
|
|
22
|
+
export interface ResponseStatusView {
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @memberof ResponseStatusView
|
|
27
|
+
*/
|
|
28
|
+
id: string;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @memberof ResponseStatusView
|
|
33
|
+
*/
|
|
34
|
+
object?: ResponseStatusViewObjectEnum;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @type {string}
|
|
38
|
+
* @memberof ResponseStatusView
|
|
39
|
+
*/
|
|
40
|
+
conversationId: string;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {string}
|
|
44
|
+
* @memberof ResponseStatusView
|
|
45
|
+
*/
|
|
46
|
+
status: ResponseStatusViewStatusEnum;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @type {Array<RequiredAction>}
|
|
50
|
+
* @memberof ResponseStatusView
|
|
51
|
+
*/
|
|
52
|
+
requiredActions?: Array<RequiredAction>;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @type {{ [key: string]: any; }}
|
|
56
|
+
* @memberof ResponseStatusView
|
|
57
|
+
*/
|
|
58
|
+
usage?: {
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
} | null;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @type {ResponseStatusError}
|
|
64
|
+
* @memberof ResponseStatusView
|
|
65
|
+
*/
|
|
66
|
+
error?: ResponseStatusError | null;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @type {Date}
|
|
70
|
+
* @memberof ResponseStatusView
|
|
71
|
+
*/
|
|
72
|
+
createdAt?: Date | null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @export
|
|
76
|
+
*/
|
|
77
|
+
export declare const ResponseStatusViewObjectEnum: {
|
|
78
|
+
readonly Response: "response";
|
|
79
|
+
};
|
|
80
|
+
export type ResponseStatusViewObjectEnum = typeof ResponseStatusViewObjectEnum[keyof typeof ResponseStatusViewObjectEnum];
|
|
81
|
+
/**
|
|
82
|
+
* @export
|
|
83
|
+
*/
|
|
84
|
+
export declare const ResponseStatusViewStatusEnum: {
|
|
85
|
+
readonly InProgress: "in_progress";
|
|
86
|
+
readonly RequiresAction: "requires_action";
|
|
87
|
+
readonly Completed: "completed";
|
|
88
|
+
readonly Failed: "failed";
|
|
89
|
+
readonly Stopped: "stopped";
|
|
90
|
+
};
|
|
91
|
+
export type ResponseStatusViewStatusEnum = typeof ResponseStatusViewStatusEnum[keyof typeof ResponseStatusViewStatusEnum];
|
|
92
|
+
/**
|
|
93
|
+
* Check if a given object implements the ResponseStatusView interface.
|
|
94
|
+
*/
|
|
95
|
+
export declare function instanceOfResponseStatusView(value: object): value is ResponseStatusView;
|
|
96
|
+
export declare function ResponseStatusViewFromJSON(json: any): ResponseStatusView;
|
|
97
|
+
export declare function ResponseStatusViewFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResponseStatusView;
|
|
98
|
+
export declare function ResponseStatusViewToJSON(json: any): ResponseStatusView;
|
|
99
|
+
export declare function ResponseStatusViewToJSONTyped(value?: ResponseStatusView | null, ignoreDiscriminator?: boolean): any;
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { ResponseStatusErrorFromJSON, ResponseStatusErrorToJSON, } from './ResponseStatusError.js';
|
|
15
|
+
import { RequiredActionFromJSON, RequiredActionToJSON, } from './RequiredAction.js';
|
|
16
|
+
/**
|
|
17
|
+
* @export
|
|
18
|
+
*/
|
|
19
|
+
export const ResponseStatusViewObjectEnum = {
|
|
20
|
+
Response: 'response'
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @export
|
|
24
|
+
*/
|
|
25
|
+
export const ResponseStatusViewStatusEnum = {
|
|
26
|
+
InProgress: 'in_progress',
|
|
27
|
+
RequiresAction: 'requires_action',
|
|
28
|
+
Completed: 'completed',
|
|
29
|
+
Failed: 'failed',
|
|
30
|
+
Stopped: 'stopped'
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Check if a given object implements the ResponseStatusView interface.
|
|
34
|
+
*/
|
|
35
|
+
export function instanceOfResponseStatusView(value) {
|
|
36
|
+
if (!('id' in value) || value['id'] === undefined)
|
|
37
|
+
return false;
|
|
38
|
+
if (!('conversationId' in value) || value['conversationId'] === undefined)
|
|
39
|
+
return false;
|
|
40
|
+
if (!('status' in value) || value['status'] === undefined)
|
|
41
|
+
return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
export function ResponseStatusViewFromJSON(json) {
|
|
45
|
+
return ResponseStatusViewFromJSONTyped(json, false);
|
|
46
|
+
}
|
|
47
|
+
export function ResponseStatusViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
48
|
+
if (json == null) {
|
|
49
|
+
return json;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
'id': json['id'],
|
|
53
|
+
'object': json['object'] == null ? undefined : json['object'],
|
|
54
|
+
'conversationId': json['conversationId'],
|
|
55
|
+
'status': json['status'],
|
|
56
|
+
'requiredActions': json['requiredActions'] == null ? undefined : (json['requiredActions'].map(RequiredActionFromJSON)),
|
|
57
|
+
'usage': json['usage'] == null ? undefined : json['usage'],
|
|
58
|
+
'error': json['error'] == null ? undefined : ResponseStatusErrorFromJSON(json['error']),
|
|
59
|
+
'createdAt': json['createdAt'] == null ? undefined : (new Date(json['createdAt'])),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function ResponseStatusViewToJSON(json) {
|
|
63
|
+
return ResponseStatusViewToJSONTyped(json, false);
|
|
64
|
+
}
|
|
65
|
+
export function ResponseStatusViewToJSONTyped(value, ignoreDiscriminator = false) {
|
|
66
|
+
if (value == null) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
'id': value['id'],
|
|
71
|
+
'object': value['object'],
|
|
72
|
+
'conversationId': value['conversationId'],
|
|
73
|
+
'status': value['status'],
|
|
74
|
+
'requiredActions': value['requiredActions'] == null ? undefined : (value['requiredActions'].map(RequiredActionToJSON)),
|
|
75
|
+
'usage': value['usage'],
|
|
76
|
+
'error': ResponseStatusErrorToJSON(value['error']),
|
|
77
|
+
'createdAt': value['createdAt'] == null ? undefined : (value['createdAt'].toISOString()),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
/**
|
|
13
|
+
* ``202`` for ``stream: false``: the results reached the agent and the
|
|
14
|
+
* turn goes on; poll its status.
|
|
15
|
+
* @export
|
|
16
|
+
* @interface ToolResultsAccepted
|
|
17
|
+
*/
|
|
18
|
+
export interface ToolResultsAccepted {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @memberof ToolResultsAccepted
|
|
23
|
+
*/
|
|
24
|
+
conversationId: string;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {string}
|
|
28
|
+
* @memberof ToolResultsAccepted
|
|
29
|
+
*/
|
|
30
|
+
responseId: string;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @type {string}
|
|
34
|
+
* @memberof ToolResultsAccepted
|
|
35
|
+
*/
|
|
36
|
+
status?: ToolResultsAcceptedStatusEnum;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @export
|
|
40
|
+
*/
|
|
41
|
+
export declare const ToolResultsAcceptedStatusEnum: {
|
|
42
|
+
readonly InProgress: "in_progress";
|
|
43
|
+
};
|
|
44
|
+
export type ToolResultsAcceptedStatusEnum = typeof ToolResultsAcceptedStatusEnum[keyof typeof ToolResultsAcceptedStatusEnum];
|
|
45
|
+
/**
|
|
46
|
+
* Check if a given object implements the ToolResultsAccepted interface.
|
|
47
|
+
*/
|
|
48
|
+
export declare function instanceOfToolResultsAccepted(value: object): value is ToolResultsAccepted;
|
|
49
|
+
export declare function ToolResultsAcceptedFromJSON(json: any): ToolResultsAccepted;
|
|
50
|
+
export declare function ToolResultsAcceptedFromJSONTyped(json: any, ignoreDiscriminator: boolean): ToolResultsAccepted;
|
|
51
|
+
export declare function ToolResultsAcceptedToJSON(json: any): ToolResultsAccepted;
|
|
52
|
+
export declare function ToolResultsAcceptedToJSONTyped(value?: ToolResultsAccepted | null, ignoreDiscriminator?: boolean): any;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
* @export
|
|
16
|
+
*/
|
|
17
|
+
export const ToolResultsAcceptedStatusEnum = {
|
|
18
|
+
InProgress: 'in_progress'
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Check if a given object implements the ToolResultsAccepted interface.
|
|
22
|
+
*/
|
|
23
|
+
export function instanceOfToolResultsAccepted(value) {
|
|
24
|
+
if (!('conversationId' in value) || value['conversationId'] === undefined)
|
|
25
|
+
return false;
|
|
26
|
+
if (!('responseId' in value) || value['responseId'] === undefined)
|
|
27
|
+
return false;
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
export function ToolResultsAcceptedFromJSON(json) {
|
|
31
|
+
return ToolResultsAcceptedFromJSONTyped(json, false);
|
|
32
|
+
}
|
|
33
|
+
export function ToolResultsAcceptedFromJSONTyped(json, ignoreDiscriminator) {
|
|
34
|
+
if (json == null) {
|
|
35
|
+
return json;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
'conversationId': json['conversationId'],
|
|
39
|
+
'responseId': json['responseId'],
|
|
40
|
+
'status': json['status'] == null ? undefined : json['status'],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function ToolResultsAcceptedToJSON(json) {
|
|
44
|
+
return ToolResultsAcceptedToJSONTyped(json, false);
|
|
45
|
+
}
|
|
46
|
+
export function ToolResultsAcceptedToJSONTyped(value, ignoreDiscriminator = false) {
|
|
47
|
+
if (value == null) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
'conversationId': value['conversationId'],
|
|
52
|
+
'responseId': value['responseId'],
|
|
53
|
+
'status': value['status'],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -28,6 +28,12 @@ export interface ToolResultsBody {
|
|
|
28
28
|
* @memberof ToolResultsBody
|
|
29
29
|
*/
|
|
30
30
|
results: Array<FunctionResultBody>;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
* @memberof ToolResultsBody
|
|
35
|
+
*/
|
|
36
|
+
stream?: boolean;
|
|
31
37
|
}
|
|
32
38
|
/**
|
|
33
39
|
* Check if a given object implements the ToolResultsBody interface.
|
|
@@ -32,6 +32,7 @@ export function ToolResultsBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
32
32
|
return {
|
|
33
33
|
'requestId': json['requestId'],
|
|
34
34
|
'results': (json['results'].map(FunctionResultBodyFromJSON)),
|
|
35
|
+
'stream': json['stream'] == null ? undefined : json['stream'],
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
export function ToolResultsBodyToJSON(json) {
|
|
@@ -44,5 +45,6 @@ export function ToolResultsBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
44
45
|
return {
|
|
45
46
|
'requestId': value['requestId'],
|
|
46
47
|
'results': (value['results'].map(FunctionResultBodyToJSON)),
|
|
48
|
+
'stream': value['stream'],
|
|
47
49
|
};
|
|
48
50
|
}
|
|
@@ -149,10 +149,13 @@ export * from './Reason.js';
|
|
|
149
149
|
export * from './RequiredAction.js';
|
|
150
150
|
export * from './Requiredscope.js';
|
|
151
151
|
export * from './Resourcetype.js';
|
|
152
|
+
export * from './ResponseAccepted.js';
|
|
152
153
|
export * from './ResponseCompleteFileUpload.js';
|
|
153
154
|
export * from './ResponseDetail.js';
|
|
154
155
|
export * from './ResponseInput.js';
|
|
155
156
|
export * from './ResponseRotateTriggerSecret.js';
|
|
157
|
+
export * from './ResponseStatusError.js';
|
|
158
|
+
export * from './ResponseStatusView.js';
|
|
156
159
|
export * from './RotatedSecret.js';
|
|
157
160
|
export * from './RotatedSigningSecret.js';
|
|
158
161
|
export * from './RotatedWebhookSecretView.js';
|
|
@@ -178,6 +181,7 @@ export * from './TemplateConnectorTag.js';
|
|
|
178
181
|
export * from './TemplateWorksWith.js';
|
|
179
182
|
export * from './TextPart.js';
|
|
180
183
|
export * from './ToolResults200Response.js';
|
|
184
|
+
export * from './ToolResultsAccepted.js';
|
|
181
185
|
export * from './ToolResultsBody.js';
|
|
182
186
|
export * from './TriggerCronBody.js';
|
|
183
187
|
export * from './TriggerDryRun.js';
|
package/dist/esm/models/index.js
CHANGED
|
@@ -151,10 +151,13 @@ export * from './Reason.js';
|
|
|
151
151
|
export * from './RequiredAction.js';
|
|
152
152
|
export * from './Requiredscope.js';
|
|
153
153
|
export * from './Resourcetype.js';
|
|
154
|
+
export * from './ResponseAccepted.js';
|
|
154
155
|
export * from './ResponseCompleteFileUpload.js';
|
|
155
156
|
export * from './ResponseDetail.js';
|
|
156
157
|
export * from './ResponseInput.js';
|
|
157
158
|
export * from './ResponseRotateTriggerSecret.js';
|
|
159
|
+
export * from './ResponseStatusError.js';
|
|
160
|
+
export * from './ResponseStatusView.js';
|
|
158
161
|
export * from './RotatedSecret.js';
|
|
159
162
|
export * from './RotatedSigningSecret.js';
|
|
160
163
|
export * from './RotatedWebhookSecretView.js';
|
|
@@ -180,6 +183,7 @@ export * from './TemplateConnectorTag.js';
|
|
|
180
183
|
export * from './TemplateWorksWith.js';
|
|
181
184
|
export * from './TextPart.js';
|
|
182
185
|
export * from './ToolResults200Response.js';
|
|
186
|
+
export * from './ToolResultsAccepted.js';
|
|
183
187
|
export * from './ToolResultsBody.js';
|
|
184
188
|
export * from './TriggerCronBody.js';
|
|
185
189
|
export * from './TriggerDryRun.js';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a turn without holding a stream open: start it, then poll its status.
|
|
3
|
+
*
|
|
4
|
+
* Hand-written (listed in .openapi-generator-ignore, so regeneration keeps it). Sending `stream: false` makes
|
|
5
|
+
* `POST /v1/responses` answer `202` as soon as the turn has started; the turn runs on the server whether or not you
|
|
6
|
+
* are connected. Poll `GET /v1/conversations/{id}/responses/{id}/status` until it ends, then read the reply once:
|
|
7
|
+
*
|
|
8
|
+
* const accepted = await startResponse(config, body); // body: the same ResponseInput as for streaming
|
|
9
|
+
* const status = await waitForResponse(config, accepted.conversationId, accepted.responseId);
|
|
10
|
+
* if (status.status === "completed") {
|
|
11
|
+
* const reply = await new ConversationsApi(config).getResponse({
|
|
12
|
+
* conversationId: accepted.conversationId, responseId: accepted.responseId });
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* `waitForResponse` also returns on `requires_action`: the agent called one of your function tools and waits for the
|
|
16
|
+
* results. Answer `status.requiredActions` with `submitToolResults` and wait again on the same response id.
|
|
17
|
+
*
|
|
18
|
+
* Needs a server with non-streaming responses. One that predates them streams the turn instead; these helpers then
|
|
19
|
+
* cancel that stream and throw `PollingUnsupportedError` (the turn still runs to the end on the server, and its reply
|
|
20
|
+
* lands in the conversation's history). A server without the recovery that polling needs answers `503`
|
|
21
|
+
* (`ResponseError`): send that turn with `stream: true`.
|
|
22
|
+
*/
|
|
23
|
+
import { type ResponseAccepted, type ResponseInput, type ResponseStatusView, type ResponseStatusViewStatusEnum, type ToolResultsBody } from "./models/index.js";
|
|
24
|
+
import { type Configuration } from "./runtime.js";
|
|
25
|
+
/** The server is built for one status read every 1-2 seconds per response. */
|
|
26
|
+
export declare const DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
27
|
+
/**
|
|
28
|
+
* Each request's timeout (default 30 s, as in the Python SDK). Every call here returns quickly: the start answers once
|
|
29
|
+
* the turn has started, and a status read never waits on the turn.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
|
|
32
|
+
/**
|
|
33
|
+
* Statuses that will not change again. `requires_action` also stops `waitForResponse`, but it is not an end: the
|
|
34
|
+
* turn goes on once the results arrive.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ENDED_STATUSES: ReadonlySet<ResponseStatusViewStatusEnum>;
|
|
37
|
+
/**
|
|
38
|
+
* The server streamed the turn instead of accepting `stream: false`: it predates non-streaming responses.
|
|
39
|
+
* The turn was started anyway and runs to the end on the server; its reply lands in the conversation's history.
|
|
40
|
+
* Send with `stream: true` (`streamResponse`) on this server.
|
|
41
|
+
*/
|
|
42
|
+
export declare class PollingUnsupportedError extends Error {
|
|
43
|
+
name: string;
|
|
44
|
+
constructor();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Past `maxWaitMs` the response was still running; it keeps running on the server. `lastStatus` is the last status
|
|
48
|
+
* read, or `null` when no read finished within `maxWaitMs`.
|
|
49
|
+
*/
|
|
50
|
+
export declare class PollTimeoutError extends Error {
|
|
51
|
+
readonly responseId: string;
|
|
52
|
+
readonly lastStatus: ResponseStatusView | null;
|
|
53
|
+
name: string;
|
|
54
|
+
constructor(responseId: string, lastStatus: ResponseStatusView | null);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* What `submitToolResults` got back. `duplicate` is true when the server already had these results (a retry with the
|
|
58
|
+
* same `idempotencyKey`); it did nothing new, and `responseId` is `null`. Either way the turn goes on under the
|
|
59
|
+
* response id you were polling.
|
|
60
|
+
*/
|
|
61
|
+
export type ToolResultsSubmitted = {
|
|
62
|
+
readonly conversationId: string;
|
|
63
|
+
readonly responseId: string;
|
|
64
|
+
readonly duplicate: false;
|
|
65
|
+
} | {
|
|
66
|
+
readonly conversationId: string;
|
|
67
|
+
readonly responseId: null;
|
|
68
|
+
readonly duplicate: true;
|
|
69
|
+
};
|
|
70
|
+
export interface PollOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Your own signal, e.g. to cancel from a UI. When it aborts, the call rejects with its `reason` (an `AbortError`
|
|
73
|
+
* `DOMException` when it has none), whether a request or a wait was in flight.
|
|
74
|
+
*/
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
/** Each request's timeout (default 30 s); past it the call rejects with a `TimeoutError` `DOMException`. */
|
|
77
|
+
timeoutMs?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface WaitOptions extends PollOptions {
|
|
80
|
+
/** Time between status reads (default 1000 ms). */
|
|
81
|
+
intervalMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Bound on the whole wait, status reads included (default none): past it this throws `PollTimeoutError`. A read
|
|
84
|
+
* still running at the deadline is cut short.
|
|
85
|
+
*/
|
|
86
|
+
maxWaitMs?: number;
|
|
87
|
+
/** Called with every status read, e.g. to show progress. */
|
|
88
|
+
onStatus?: (status: ResponseStatusView) => void;
|
|
89
|
+
}
|
|
90
|
+
export interface SubmitToolResultsOptions extends PollOptions {
|
|
91
|
+
/** Send the same key when you retry a post: a repeat the server already has comes back with `duplicate: true`. */
|
|
92
|
+
idempotencyKey?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Send a message (`POST /v1/responses`) with `stream: false` and resolve once the turn has started.
|
|
96
|
+
*
|
|
97
|
+
* `body` is the same `ResponseInput` as for streaming; `stream` is set to false on a copy (yours is not changed).
|
|
98
|
+
* Throws `ResponseError` when the server refuses the turn (`409` while another response runs or messages wait, `503`
|
|
99
|
+
* where polling is not available); nothing is left behind then. Unlike the streaming helpers, this request has a
|
|
100
|
+
* timeout (`timeoutMs`, default 30 s): it never carries a stream.
|
|
101
|
+
*
|
|
102
|
+
* Sending the same `message.id` again resolves to the turn its first send started (`duplicate: true`), so a send
|
|
103
|
+
* whose answer was lost can be retried as it is; while that first send is still starting, the retry gets `409` with
|
|
104
|
+
* reason `RESPONSE_STARTING` (send it again in a moment).
|
|
105
|
+
*/
|
|
106
|
+
export declare function startResponse(config: Configuration, body: ResponseInput, options?: PollOptions): Promise<ResponseAccepted>;
|
|
107
|
+
/** One status read (`GET /v1/conversations/{id}/responses/{id}/status`); never includes the reply. */
|
|
108
|
+
export declare function getStatus(config: Configuration, conversationId: string, responseId: string, options?: PollOptions): Promise<ResponseStatusView>;
|
|
109
|
+
/**
|
|
110
|
+
* Poll a response's status every `intervalMs` until it is anything but `in_progress` (today: `completed`, `failed`,
|
|
111
|
+
* `stopped` or `requires_action`), and return that status. Past `maxWaitMs` this throws `PollTimeoutError` and the
|
|
112
|
+
* turn goes on running on the server; poll again or stop it (`ResponsesApi.stopResponse`).
|
|
113
|
+
*/
|
|
114
|
+
export declare function waitForResponse(config: Configuration, conversationId: string, responseId: string, options?: WaitOptions): Promise<ResponseStatusView>;
|
|
115
|
+
/**
|
|
116
|
+
* Answer a `requires_action` status (`POST /v1/conversations/{id}/tool-results` with `stream: false`).
|
|
117
|
+
*
|
|
118
|
+
* `body.requestId` comes from the status's `requiredActions`, with one result per call; `stream` is set to false on a
|
|
119
|
+
* copy. Send the same `idempotencyKey` when you retry a post (a `503` forwarded nothing: retry it). Then wait on the
|
|
120
|
+
* same response id again.
|
|
121
|
+
*/
|
|
122
|
+
export declare function submitToolResults(config: Configuration, conversationId: string, body: ToolResultsBody, options?: SubmitToolResultsOptions): Promise<ToolResultsSubmitted>;
|