sarvam-agents-client 0.3.0 → 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.
Files changed (125) hide show
  1. package/README.md +16 -1
  2. package/dist/apis/FunctionToolsApi.d.ts +33 -0
  3. package/dist/apis/FunctionToolsApi.js +65 -0
  4. package/dist/apis/index.d.ts +1 -0
  5. package/dist/apis/index.js +1 -0
  6. package/dist/compose/agent.d.ts +16 -3
  7. package/dist/compose/agent.js +76 -7
  8. package/dist/compose/errors.d.ts +5 -1
  9. package/dist/compose/errors.js +4 -1
  10. package/dist/compose/events.d.ts +4 -0
  11. package/dist/compose/events.js +34 -0
  12. package/dist/compose/functionTool.d.ts +101 -0
  13. package/dist/compose/functionTool.js +420 -0
  14. package/dist/compose/index.d.ts +5 -2
  15. package/dist/compose/index.js +3 -1
  16. package/dist/compose/output.d.ts +11 -0
  17. package/dist/compose/output.js +32 -7
  18. package/dist/compose/run.d.ts +5 -1
  19. package/dist/compose/run.js +118 -25
  20. package/dist/compose/runState.d.ts +26 -1
  21. package/dist/compose/runState.js +30 -0
  22. package/dist/compose/settingsTransport.d.ts +20 -1
  23. package/dist/compose/settingsTransport.js +295 -3
  24. package/dist/compose/transport.d.ts +18 -1
  25. package/dist/esm/apis/FunctionToolsApi.d.ts +33 -0
  26. package/dist/esm/apis/FunctionToolsApi.js +61 -0
  27. package/dist/esm/apis/index.d.ts +1 -0
  28. package/dist/esm/apis/index.js +1 -0
  29. package/dist/esm/compose/agent.d.ts +16 -3
  30. package/dist/esm/compose/agent.js +76 -7
  31. package/dist/esm/compose/errors.d.ts +5 -1
  32. package/dist/esm/compose/errors.js +4 -1
  33. package/dist/esm/compose/events.d.ts +4 -0
  34. package/dist/esm/compose/events.js +33 -0
  35. package/dist/esm/compose/functionTool.d.ts +101 -0
  36. package/dist/esm/compose/functionTool.js +406 -0
  37. package/dist/esm/compose/index.d.ts +5 -2
  38. package/dist/esm/compose/index.js +1 -0
  39. package/dist/esm/compose/output.d.ts +11 -0
  40. package/dist/esm/compose/output.js +30 -9
  41. package/dist/esm/compose/run.d.ts +5 -1
  42. package/dist/esm/compose/run.js +118 -25
  43. package/dist/esm/compose/runState.d.ts +26 -1
  44. package/dist/esm/compose/runState.js +31 -1
  45. package/dist/esm/compose/settingsTransport.d.ts +20 -1
  46. package/dist/esm/compose/settingsTransport.js +298 -7
  47. package/dist/esm/compose/transport.d.ts +18 -1
  48. package/dist/esm/models/AgentConversationDetail.d.ts +7 -0
  49. package/dist/esm/models/AgentConversationDetail.js +3 -0
  50. package/dist/esm/models/ClarifyBody.d.ts +6 -0
  51. package/dist/esm/models/ClarifyBody.js +2 -0
  52. package/dist/esm/models/ConversationDetail.d.ts +7 -0
  53. package/dist/esm/models/ConversationDetail.js +3 -0
  54. package/dist/esm/models/ErrorDetail.d.ts +1 -0
  55. package/dist/esm/models/ErrorDetail.js +2 -1
  56. package/dist/esm/models/FunctionResultBody.d.ts +44 -0
  57. package/dist/esm/models/FunctionResultBody.js +49 -0
  58. package/dist/esm/models/QueueMessageInput.d.ts +23 -0
  59. package/dist/esm/models/QueueMessageInput.js +14 -0
  60. package/dist/esm/models/RequiredAction.d.ts +77 -0
  61. package/dist/esm/models/RequiredAction.js +69 -0
  62. package/dist/esm/models/ResponseDetail.d.ts +8 -0
  63. package/dist/esm/models/ResponseDetail.js +2 -0
  64. package/dist/esm/models/ResponseInput.d.ts +23 -0
  65. package/dist/esm/models/ResponseInput.js +14 -0
  66. package/dist/esm/models/ToolResults200Response.d.ts +38 -0
  67. package/dist/esm/models/ToolResults200Response.js +47 -0
  68. package/dist/esm/models/ToolResultsBody.d.ts +39 -0
  69. package/dist/esm/models/ToolResultsBody.js +48 -0
  70. package/dist/esm/models/index.d.ts +4 -0
  71. package/dist/esm/models/index.js +4 -0
  72. package/dist/esm/streaming.d.ts +14 -2
  73. package/dist/esm/streaming.js +26 -4
  74. package/dist/models/AgentConversationDetail.d.ts +7 -0
  75. package/dist/models/AgentConversationDetail.js +3 -0
  76. package/dist/models/ClarifyBody.d.ts +6 -0
  77. package/dist/models/ClarifyBody.js +2 -0
  78. package/dist/models/ConversationDetail.d.ts +7 -0
  79. package/dist/models/ConversationDetail.js +3 -0
  80. package/dist/models/ErrorDetail.d.ts +1 -0
  81. package/dist/models/ErrorDetail.js +2 -1
  82. package/dist/models/FunctionResultBody.d.ts +44 -0
  83. package/dist/models/FunctionResultBody.js +56 -0
  84. package/dist/models/QueueMessageInput.d.ts +23 -0
  85. package/dist/models/QueueMessageInput.js +15 -1
  86. package/dist/models/RequiredAction.d.ts +77 -0
  87. package/dist/models/RequiredAction.js +77 -0
  88. package/dist/models/ResponseDetail.d.ts +8 -0
  89. package/dist/models/ResponseDetail.js +2 -0
  90. package/dist/models/ResponseInput.d.ts +23 -0
  91. package/dist/models/ResponseInput.js +15 -0
  92. package/dist/models/ToolResults200Response.d.ts +38 -0
  93. package/dist/models/ToolResults200Response.js +54 -0
  94. package/dist/models/ToolResultsBody.d.ts +39 -0
  95. package/dist/models/ToolResultsBody.js +55 -0
  96. package/dist/models/index.d.ts +4 -0
  97. package/dist/models/index.js +4 -0
  98. package/dist/streaming.d.ts +14 -2
  99. package/dist/streaming.js +27 -4
  100. package/package.json +1 -1
  101. package/src/apis/FunctionToolsApi.ts +102 -0
  102. package/src/apis/index.ts +1 -0
  103. package/src/compose/agent.ts +87 -9
  104. package/src/compose/errors.ts +7 -1
  105. package/src/compose/events.ts +30 -0
  106. package/src/compose/functionTool.ts +441 -0
  107. package/src/compose/index.ts +5 -2
  108. package/src/compose/output.ts +30 -9
  109. package/src/compose/run.ts +115 -18
  110. package/src/compose/runState.ts +44 -5
  111. package/src/compose/settingsTransport.ts +293 -7
  112. package/src/compose/transport.ts +24 -1
  113. package/src/models/AgentConversationDetail.ts +15 -0
  114. package/src/models/ClarifyBody.ts +8 -0
  115. package/src/models/ConversationDetail.ts +15 -0
  116. package/src/models/ErrorDetail.ts +2 -1
  117. package/src/models/FunctionResultBody.ts +83 -0
  118. package/src/models/QueueMessageInput.ts +28 -0
  119. package/src/models/RequiredAction.ts +128 -0
  120. package/src/models/ResponseDetail.ts +8 -0
  121. package/src/models/ResponseInput.ts +30 -0
  122. package/src/models/ToolResults200Response.ts +75 -0
  123. package/src/models/ToolResultsBody.ts +83 -0
  124. package/src/models/index.ts +4 -0
  125. package/src/streaming.ts +39 -3
@@ -19,6 +19,16 @@ export const QueueMessageInputDeliveryEnum = {
19
19
  Queue: 'queue',
20
20
  Now: 'now'
21
21
  };
22
+ /**
23
+ * @export
24
+ */
25
+ export const QueueMessageInputSurfaceEnum = {
26
+ Builder: 'builder',
27
+ Playground: 'playground',
28
+ Tests: 'tests',
29
+ Evals: 'evals',
30
+ Cowork: 'cowork'
31
+ };
22
32
  /**
23
33
  * Check if a given object implements the QueueMessageInput interface.
24
34
  */
@@ -39,6 +49,8 @@ export function QueueMessageInputFromJSONTyped(json, ignoreDiscriminator) {
39
49
  'delivery': json['delivery'] == null ? undefined : json['delivery'],
40
50
  'agentId': json['agentId'] == null ? undefined : json['agentId'],
41
51
  'retryOf': json['retryOf'] == null ? undefined : json['retryOf'],
52
+ 'surface': json['surface'] == null ? undefined : json['surface'],
53
+ 'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
42
54
  };
43
55
  }
44
56
  export function QueueMessageInputToJSON(json) {
@@ -53,5 +65,7 @@ export function QueueMessageInputToJSONTyped(value, ignoreDiscriminator = false)
53
65
  'delivery': value['delivery'],
54
66
  'agentId': value['agentId'],
55
67
  'retryOf': value['retryOf'],
68
+ 'surface': value['surface'],
69
+ 'endUserId': value['endUserId'],
56
70
  };
57
71
  }
@@ -0,0 +1,77 @@
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
+ * One function call the app must run before the turn can continue.
14
+ * @export
15
+ * @interface RequiredAction
16
+ */
17
+ export interface RequiredAction {
18
+ /**
19
+ *
20
+ * @type {string}
21
+ * @memberof RequiredAction
22
+ */
23
+ type?: RequiredActionTypeEnum;
24
+ /**
25
+ *
26
+ * @type {string}
27
+ * @memberof RequiredAction
28
+ */
29
+ requestId: string;
30
+ /**
31
+ *
32
+ * @type {string}
33
+ * @memberof RequiredAction
34
+ */
35
+ toolCallId: string;
36
+ /**
37
+ *
38
+ * @type {string}
39
+ * @memberof RequiredAction
40
+ */
41
+ name: string;
42
+ /**
43
+ *
44
+ * @type {{ [key: string]: any; }}
45
+ * @memberof RequiredAction
46
+ */
47
+ arguments: {
48
+ [key: string]: any;
49
+ };
50
+ /**
51
+ *
52
+ * @type {Date}
53
+ * @memberof RequiredAction
54
+ */
55
+ createdAt: Date;
56
+ /**
57
+ *
58
+ * @type {Date}
59
+ * @memberof RequiredAction
60
+ */
61
+ expiresAt?: Date | null;
62
+ }
63
+ /**
64
+ * @export
65
+ */
66
+ export declare const RequiredActionTypeEnum: {
67
+ readonly FunctionCall: "function_call";
68
+ };
69
+ export type RequiredActionTypeEnum = typeof RequiredActionTypeEnum[keyof typeof RequiredActionTypeEnum];
70
+ /**
71
+ * Check if a given object implements the RequiredAction interface.
72
+ */
73
+ export declare function instanceOfRequiredAction(value: object): value is RequiredAction;
74
+ export declare function RequiredActionFromJSON(json: any): RequiredAction;
75
+ export declare function RequiredActionFromJSONTyped(json: any, ignoreDiscriminator: boolean): RequiredAction;
76
+ export declare function RequiredActionToJSON(json: any): RequiredAction;
77
+ export declare function RequiredActionToJSONTyped(value?: RequiredAction | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,69 @@
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 RequiredActionTypeEnum = {
18
+ FunctionCall: 'function_call'
19
+ };
20
+ /**
21
+ * Check if a given object implements the RequiredAction interface.
22
+ */
23
+ export function instanceOfRequiredAction(value) {
24
+ if (!('requestId' in value) || value['requestId'] === undefined)
25
+ return false;
26
+ if (!('toolCallId' in value) || value['toolCallId'] === undefined)
27
+ return false;
28
+ if (!('name' in value) || value['name'] === undefined)
29
+ return false;
30
+ if (!('arguments' in value) || value['arguments'] === undefined)
31
+ return false;
32
+ if (!('createdAt' in value) || value['createdAt'] === undefined)
33
+ return false;
34
+ return true;
35
+ }
36
+ export function RequiredActionFromJSON(json) {
37
+ return RequiredActionFromJSONTyped(json, false);
38
+ }
39
+ export function RequiredActionFromJSONTyped(json, ignoreDiscriminator) {
40
+ if (json == null) {
41
+ return json;
42
+ }
43
+ return {
44
+ 'type': json['type'] == null ? undefined : json['type'],
45
+ 'requestId': json['requestId'],
46
+ 'toolCallId': json['toolCallId'],
47
+ 'name': json['name'],
48
+ 'arguments': json['arguments'],
49
+ 'createdAt': (new Date(json['createdAt'])),
50
+ 'expiresAt': json['expiresAt'] == null ? undefined : (new Date(json['expiresAt'])),
51
+ };
52
+ }
53
+ export function RequiredActionToJSON(json) {
54
+ return RequiredActionToJSONTyped(json, false);
55
+ }
56
+ export function RequiredActionToJSONTyped(value, ignoreDiscriminator = false) {
57
+ if (value == null) {
58
+ return value;
59
+ }
60
+ return {
61
+ 'type': value['type'],
62
+ 'requestId': value['requestId'],
63
+ 'toolCallId': value['toolCallId'],
64
+ 'name': value['name'],
65
+ 'arguments': value['arguments'],
66
+ 'createdAt': ((value['createdAt']).toISOString()),
67
+ 'expiresAt': value['expiresAt'] == null ? undefined : (value['expiresAt'].toISOString()),
68
+ };
69
+ }
@@ -34,6 +34,14 @@ export interface ResponseDetail {
34
34
  * @memberof ResponseDetail
35
35
  */
36
36
  output: Array<UIMessage>;
37
+ /**
38
+ *
39
+ * @type {{ [key: string]: any; }}
40
+ * @memberof ResponseDetail
41
+ */
42
+ usage?: {
43
+ [key: string]: any;
44
+ } | null;
37
45
  /**
38
46
  *
39
47
  * @type {any}
@@ -44,6 +44,7 @@ export function ResponseDetailFromJSONTyped(json, ignoreDiscriminator) {
44
44
  'responseId': json['responseId'],
45
45
  'status': json['status'],
46
46
  'output': (json['output'].map(UIMessageFromJSON)),
47
+ 'usage': json['usage'] == null ? undefined : json['usage'],
47
48
  'structuredOutput': json['structuredOutput'] == null ? undefined : json['structuredOutput'],
48
49
  'outputErrors': json['outputErrors'] == null ? undefined : json['outputErrors'],
49
50
  'outputCitations': json['outputCitations'] == null ? undefined : json['outputCitations'],
@@ -62,6 +63,7 @@ export function ResponseDetailToJSONTyped(value, ignoreDiscriminator = false) {
62
63
  'responseId': value['responseId'],
63
64
  'status': value['status'],
64
65
  'output': (value['output'].map(UIMessageToJSON)),
66
+ 'usage': value['usage'],
65
67
  'structuredOutput': value['structuredOutput'],
66
68
  'outputErrors': value['outputErrors'],
67
69
  'outputCitations': value['outputCitations'],
@@ -58,7 +58,30 @@ export interface ResponseInput {
58
58
  * @memberof ResponseInput
59
59
  */
60
60
  retryOf?: string | null;
61
+ /**
62
+ *
63
+ * @type {string}
64
+ * @memberof ResponseInput
65
+ */
66
+ surface?: ResponseInputSurfaceEnum | null;
67
+ /**
68
+ *
69
+ * @type {string}
70
+ * @memberof ResponseInput
71
+ */
72
+ endUserId?: string | null;
61
73
  }
74
+ /**
75
+ * @export
76
+ */
77
+ export declare const ResponseInputSurfaceEnum: {
78
+ readonly Builder: "builder";
79
+ readonly Playground: "playground";
80
+ readonly Tests: "tests";
81
+ readonly Evals: "evals";
82
+ readonly Cowork: "cowork";
83
+ };
84
+ export type ResponseInputSurfaceEnum = typeof ResponseInputSurfaceEnum[keyof typeof ResponseInputSurfaceEnum];
62
85
  /**
63
86
  * Check if a given object implements the ResponseInput interface.
64
87
  */
@@ -12,6 +12,16 @@
12
12
  * Do not edit the class manually.
13
13
  */
14
14
  import { InputMessageFromJSON, InputMessageToJSON, } from './InputMessage.js';
15
+ /**
16
+ * @export
17
+ */
18
+ export const ResponseInputSurfaceEnum = {
19
+ Builder: 'builder',
20
+ Playground: 'playground',
21
+ Tests: 'tests',
22
+ Evals: 'evals',
23
+ Cowork: 'cowork'
24
+ };
15
25
  /**
16
26
  * Check if a given object implements the ResponseInput interface.
17
27
  */
@@ -37,6 +47,8 @@ export function ResponseInputFromJSONTyped(json, ignoreDiscriminator) {
37
47
  'agentId': json['agentId'] == null ? undefined : json['agentId'],
38
48
  'regenerateAfter': json['regenerateAfter'] == null ? undefined : json['regenerateAfter'],
39
49
  'retryOf': json['retryOf'] == null ? undefined : json['retryOf'],
50
+ 'surface': json['surface'] == null ? undefined : json['surface'],
51
+ 'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
40
52
  };
41
53
  }
42
54
  export function ResponseInputToJSON(json) {
@@ -54,5 +66,7 @@ export function ResponseInputToJSONTyped(value, ignoreDiscriminator = false) {
54
66
  'agentId': value['agentId'],
55
67
  'regenerateAfter': value['regenerateAfter'],
56
68
  'retryOf': value['retryOf'],
69
+ 'surface': value['surface'],
70
+ 'endUserId': value['endUserId'],
57
71
  };
58
72
  }
@@ -0,0 +1,38 @@
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
+ *
14
+ * @export
15
+ * @interface ToolResults200Response
16
+ */
17
+ export interface ToolResults200Response {
18
+ /**
19
+ *
20
+ * @type {boolean}
21
+ * @memberof ToolResults200Response
22
+ */
23
+ accepted: boolean | null;
24
+ /**
25
+ *
26
+ * @type {boolean}
27
+ * @memberof ToolResults200Response
28
+ */
29
+ duplicate: boolean | null;
30
+ }
31
+ /**
32
+ * Check if a given object implements the ToolResults200Response interface.
33
+ */
34
+ export declare function instanceOfToolResults200Response(value: object): value is ToolResults200Response;
35
+ export declare function ToolResults200ResponseFromJSON(json: any): ToolResults200Response;
36
+ export declare function ToolResults200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ToolResults200Response;
37
+ export declare function ToolResults200ResponseToJSON(json: any): ToolResults200Response;
38
+ export declare function ToolResults200ResponseToJSONTyped(value?: ToolResults200Response | null, ignoreDiscriminator?: boolean): any;
@@ -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 ToolResults200Response interface.
16
+ */
17
+ export function instanceOfToolResults200Response(value) {
18
+ if (!('accepted' in value) || value['accepted'] === undefined)
19
+ return false;
20
+ if (!('duplicate' in value) || value['duplicate'] === undefined)
21
+ return false;
22
+ return true;
23
+ }
24
+ export function ToolResults200ResponseFromJSON(json) {
25
+ return ToolResults200ResponseFromJSONTyped(json, false);
26
+ }
27
+ export function ToolResults200ResponseFromJSONTyped(json, ignoreDiscriminator) {
28
+ if (json == null) {
29
+ return json;
30
+ }
31
+ return {
32
+ 'accepted': json['accepted'],
33
+ 'duplicate': json['duplicate'],
34
+ };
35
+ }
36
+ export function ToolResults200ResponseToJSON(json) {
37
+ return ToolResults200ResponseToJSONTyped(json, false);
38
+ }
39
+ export function ToolResults200ResponseToJSONTyped(value, ignoreDiscriminator = false) {
40
+ if (value == null) {
41
+ return value;
42
+ }
43
+ return {
44
+ 'accepted': value['accepted'],
45
+ 'duplicate': value['duplicate'],
46
+ };
47
+ }
@@ -0,0 +1,39 @@
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 { FunctionResultBody } from './FunctionResultBody.js';
13
+ /**
14
+ *
15
+ * @export
16
+ * @interface ToolResultsBody
17
+ */
18
+ export interface ToolResultsBody {
19
+ /**
20
+ *
21
+ * @type {string}
22
+ * @memberof ToolResultsBody
23
+ */
24
+ requestId: string;
25
+ /**
26
+ *
27
+ * @type {Array<FunctionResultBody>}
28
+ * @memberof ToolResultsBody
29
+ */
30
+ results: Array<FunctionResultBody>;
31
+ }
32
+ /**
33
+ * Check if a given object implements the ToolResultsBody interface.
34
+ */
35
+ export declare function instanceOfToolResultsBody(value: object): value is ToolResultsBody;
36
+ export declare function ToolResultsBodyFromJSON(json: any): ToolResultsBody;
37
+ export declare function ToolResultsBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ToolResultsBody;
38
+ export declare function ToolResultsBodyToJSON(json: any): ToolResultsBody;
39
+ export declare function ToolResultsBodyToJSONTyped(value?: ToolResultsBody | null, ignoreDiscriminator?: boolean): any;
@@ -0,0 +1,48 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Sarvam Agents API
5
+ * Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
6
+ *
7
+ * The version of the OpenAPI document: 0.1.0
8
+ * Contact: support@sarvam.ai
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+ import { FunctionResultBodyFromJSON, FunctionResultBodyToJSON, } from './FunctionResultBody.js';
15
+ /**
16
+ * Check if a given object implements the ToolResultsBody interface.
17
+ */
18
+ export function instanceOfToolResultsBody(value) {
19
+ if (!('requestId' in value) || value['requestId'] === undefined)
20
+ return false;
21
+ if (!('results' in value) || value['results'] === undefined)
22
+ return false;
23
+ return true;
24
+ }
25
+ export function ToolResultsBodyFromJSON(json) {
26
+ return ToolResultsBodyFromJSONTyped(json, false);
27
+ }
28
+ export function ToolResultsBodyFromJSONTyped(json, ignoreDiscriminator) {
29
+ if (json == null) {
30
+ return json;
31
+ }
32
+ return {
33
+ 'requestId': json['requestId'],
34
+ 'results': (json['results'].map(FunctionResultBodyFromJSON)),
35
+ };
36
+ }
37
+ export function ToolResultsBodyToJSON(json) {
38
+ return ToolResultsBodyToJSONTyped(json, false);
39
+ }
40
+ export function ToolResultsBodyToJSONTyped(value, ignoreDiscriminator = false) {
41
+ if (value == null) {
42
+ return value;
43
+ }
44
+ return {
45
+ 'requestId': value['requestId'],
46
+ 'results': (value['results'].map(FunctionResultBodyToJSON)),
47
+ };
48
+ }
@@ -99,6 +99,7 @@ export * from './FileQueuedResponse.js';
99
99
  export * from './FileRawResponse.js';
100
100
  export * from './FileRead.js';
101
101
  export * from './FileWriteBody.js';
102
+ export * from './FunctionResultBody.js';
102
103
  export * from './HTTPValidationError.js';
103
104
  export * from './HighlightRange.js';
104
105
  export * from './InlineCreateSkillBody.js';
@@ -129,6 +130,7 @@ export * from './QueueMessageInput.js';
129
130
  export * from './QueueMessageResult.js';
130
131
  export * from './QueuedTurnView.js';
131
132
  export * from './Reason.js';
133
+ export * from './RequiredAction.js';
132
134
  export * from './Requiredscope.js';
133
135
  export * from './Resourcetype.js';
134
136
  export * from './ResponseCompleteFileUpload.js';
@@ -152,6 +154,8 @@ export * from './StopResponse.js';
152
154
  export * from './TemplateConnectorTag.js';
153
155
  export * from './TemplateWorksWith.js';
154
156
  export * from './TextPart.js';
157
+ export * from './ToolResults200Response.js';
158
+ export * from './ToolResultsBody.js';
155
159
  export * from './TriggerCronBody.js';
156
160
  export * from './TriggerResponse.js';
157
161
  export * from './UIMessage.js';
@@ -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';
@@ -131,6 +132,7 @@ export * from './QueueMessageInput.js';
131
132
  export * from './QueueMessageResult.js';
132
133
  export * from './QueuedTurnView.js';
133
134
  export * from './Reason.js';
135
+ export * from './RequiredAction.js';
134
136
  export * from './Requiredscope.js';
135
137
  export * from './Resourcetype.js';
136
138
  export * from './ResponseCompleteFileUpload.js';
@@ -154,6 +156,8 @@ export * from './StopResponse.js';
154
156
  export * from './TemplateConnectorTag.js';
155
157
  export * from './TemplateWorksWith.js';
156
158
  export * from './TextPart.js';
159
+ export * from './ToolResults200Response.js';
160
+ export * from './ToolResultsBody.js';
157
161
  export * from './TriggerCronBody.js';
158
162
  export * from './TriggerResponse.js';
159
163
  export * from './UIMessage.js';
@@ -14,10 +14,10 @@
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
- import type { ClarifyBody, ResponseInput } from "./models/index.js";
20
+ import type { ClarifyBody, ResponseInput, ToolResultsBody } from "./models/index.js";
21
21
  import type { Configuration } from "./runtime.js";
22
22
  /** One event's JSON payload. */
23
23
  export interface StreamEvent {
@@ -40,6 +40,9 @@ export declare function iterSse(chunks: AsyncIterable<Uint8Array>): AsyncGenerat
40
40
  export declare class ResponseStream implements AsyncIterable<StreamEvent> {
41
41
  responseId: string | null;
42
42
  lastEventId: string | null;
43
+ /** `postToolResults` only: the server already had these results (a repeat with the same idempotency key), so
44
+ * this stream is empty; follow the turn with `reconnect`. */
45
+ duplicate: boolean;
43
46
  private readonly body;
44
47
  private readonly controller;
45
48
  private readonly idleTimeoutMs;
@@ -66,3 +69,12 @@ export declare function reconnect(config: Configuration, conversationId: string,
66
69
  * `body.requestId` comes from that event; put your answers in `body.answers`.
67
70
  */
68
71
  export declare function answerClarify(config: Configuration, conversationId: string, body: ClarifyBody, options?: StreamOptions): Promise<ResponseStream>;
72
+ /**
73
+ * Answer the agent's function calls (a `data-function-call-request` event) and stream the rest of the reply.
74
+ * `body.requestId` comes from that event, with one result per call. Send the same `idempotencyKey` when you retry a
75
+ * post: a repeat the server already has resolves to an empty stream with `duplicate` set, and the turn can be followed
76
+ * with `reconnect`.
77
+ */
78
+ export declare function postToolResults(config: Configuration, conversationId: string, body: ToolResultsBody, options?: StreamOptions & {
79
+ idempotencyKey?: string;
80
+ }): Promise<ResponseStream>;
@@ -14,10 +14,11 @@
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
  import { ClarifyApi } from "./apis/ClarifyApi.js";
21
+ import { FunctionToolsApi } from "./apis/FunctionToolsApi.js";
21
22
  import { ResponsesApi } from "./apis/ResponsesApi.js";
22
23
  export const DEFAULT_IDLE_TIMEOUT_MS = 60000;
23
24
  /** Parse a server-sent-events body into [last event id, payload] pairs. */
@@ -77,6 +78,9 @@ export async function* iterSse(chunks) {
77
78
  /** Async iterator over a reply's events. Call `close()` if you stop early. */
78
79
  export class ResponseStream {
79
80
  constructor(body, controller, idleTimeoutMs, responseId = null, lastEventId = null) {
81
+ /** `postToolResults` only: the server already had these results (a repeat with the same idempotency key), so
82
+ * this stream is empty; follow the turn with `reconnect`. */
83
+ this.duplicate = false;
80
84
  this.body = body;
81
85
  this.controller = controller;
82
86
  this.idleTimeoutMs = idleTimeoutMs;
@@ -138,15 +142,24 @@ export class ResponseStream {
138
142
  this.controller.abort();
139
143
  }
140
144
  }
141
- async function open(call, options, responseId = null, lastEventId = null) {
142
- var _a, _b;
145
+ async function open(call, options, responseId = null, lastEventId = null, jsonIsDuplicate = false) {
146
+ var _a, _b, _c, _d, _e;
143
147
  const controller = new AbortController();
144
148
  (_a = options.signal) === null || _a === void 0 ? void 0 : _a.addEventListener("abort", () => controller.abort(options.signal.reason), { once: true });
145
149
  // Non-2xx responses throw ResponseError here, like every other generated method.
146
150
  const response = await call({ signal: controller.signal });
151
+ const contentType = ((_b = response.raw.headers.get("content-type")) !== null && _b !== void 0 ? _b : "").split(";")[0].trim().toLowerCase();
152
+ if (jsonIsDuplicate && contentType === "application/json") {
153
+ await ((_c = response.raw.body) === null || _c === void 0 ? void 0 : _c.cancel().catch(() => undefined));
154
+ const empty = new ReadableStream({ start: (c) => c.close() });
155
+ const stream = new ResponseStream(empty, controller, (_d = options.idleTimeoutMs) !== null && _d !== void 0 ? _d : DEFAULT_IDLE_TIMEOUT_MS);
156
+ stream.duplicate = true;
157
+ stream.close();
158
+ return stream;
159
+ }
147
160
  if (!response.raw.body)
148
161
  throw new Error("response has no body to stream");
149
- return new ResponseStream(response.raw.body, controller, (_b = options.idleTimeoutMs) !== null && _b !== void 0 ? _b : DEFAULT_IDLE_TIMEOUT_MS, responseId, lastEventId);
162
+ return new ResponseStream(response.raw.body, controller, (_e = options.idleTimeoutMs) !== null && _e !== void 0 ? _e : DEFAULT_IDLE_TIMEOUT_MS, responseId, lastEventId);
150
163
  }
151
164
  /** Send a message (POST /v1/responses) and stream the reply. Same body as `ResponsesApi.createResponse`. */
152
165
  export function streamResponse(config, body, options = {}) {
@@ -169,3 +182,12 @@ export function reconnect(config, conversationId, responseId, lastEventId = null
169
182
  export function answerClarify(config, conversationId, body, options = {}) {
170
183
  return open((init) => new ClarifyApi(config).clarifyRaw({ conversationId, clarifyBody: body }, init), options);
171
184
  }
185
+ /**
186
+ * Answer the agent's function calls (a `data-function-call-request` event) and stream the rest of the reply.
187
+ * `body.requestId` comes from that event, with one result per call. Send the same `idempotencyKey` when you retry a
188
+ * post: a repeat the server already has resolves to an empty stream with `duplicate` set, and the turn can be followed
189
+ * with `reconnect`.
190
+ */
191
+ export function postToolResults(config, conversationId, body, options = {}) {
192
+ return open((init) => new FunctionToolsApi(config).toolResultsRaw({ conversationId, toolResultsBody: body, idempotencyKey: options.idempotencyKey }, init), options, null, null, true);
193
+ }
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import type { UIMessage } from './UIMessage.js';
13
13
  import type { FieldHighlight } from './FieldHighlight.js';
14
+ import type { RequiredAction } from './RequiredAction.js';
14
15
  import type { QueuedTurnView } from './QueuedTurnView.js';
15
16
  /**
16
17
  *
@@ -134,6 +135,12 @@ export interface AgentConversationDetail {
134
135
  * @memberof AgentConversationDetail
135
136
  */
136
137
  queuedTurns?: Array<QueuedTurnView>;
138
+ /**
139
+ *
140
+ * @type {Array<RequiredAction>}
141
+ * @memberof AgentConversationDetail
142
+ */
143
+ requiredActions?: Array<RequiredAction>;
137
144
  /**
138
145
  *
139
146
  * @type {boolean}
@@ -20,6 +20,7 @@ exports.AgentConversationDetailToJSON = AgentConversationDetailToJSON;
20
20
  exports.AgentConversationDetailToJSONTyped = AgentConversationDetailToJSONTyped;
21
21
  const UIMessage_js_1 = require("./UIMessage.js");
22
22
  const FieldHighlight_js_1 = require("./FieldHighlight.js");
23
+ const RequiredAction_js_1 = require("./RequiredAction.js");
23
24
  const QueuedTurnView_js_1 = require("./QueuedTurnView.js");
24
25
  /**
25
26
  * Check if a given object implements the AgentConversationDetail interface.
@@ -86,6 +87,7 @@ function AgentConversationDetailFromJSONTyped(json, ignoreDiscriminator) {
86
87
  'hasMore': json['hasMore'] == null ? undefined : json['hasMore'],
87
88
  'nextBeforeCursor': json['nextBeforeCursor'] == null ? undefined : json['nextBeforeCursor'],
88
89
  'queuedTurns': json['queuedTurns'] == null ? undefined : (json['queuedTurns'].map(QueuedTurnView_js_1.QueuedTurnViewFromJSON)),
90
+ 'requiredActions': json['requiredActions'] == null ? undefined : (json['requiredActions'].map(RequiredAction_js_1.RequiredActionFromJSON)),
89
91
  'isMine': json['isMine'] == null ? undefined : json['isMine'],
90
92
  'panjaWsId': json['panjaWsId'],
91
93
  'readOnly': json['readOnly'] == null ? undefined : json['readOnly'],
@@ -119,6 +121,7 @@ function AgentConversationDetailToJSONTyped(value, ignoreDiscriminator = false)
119
121
  'hasMore': value['hasMore'],
120
122
  'nextBeforeCursor': value['nextBeforeCursor'],
121
123
  'queuedTurns': value['queuedTurns'] == null ? undefined : (value['queuedTurns'].map(QueuedTurnView_js_1.QueuedTurnViewToJSON)),
124
+ 'requiredActions': value['requiredActions'] == null ? undefined : (value['requiredActions'].map(RequiredAction_js_1.RequiredActionToJSON)),
122
125
  'isMine': value['isMine'],
123
126
  'panjaWsId': value['panjaWsId'],
124
127
  'readOnly': value['readOnly'],
@@ -35,6 +35,12 @@ export interface ClarifyBody {
35
35
  answers?: {
36
36
  [key: string]: any;
37
37
  };
38
+ /**
39
+ *
40
+ * @type {string}
41
+ * @memberof ClarifyBody
42
+ */
43
+ endUserId?: string | null;
38
44
  }
39
45
  /**
40
46
  * Check if a given object implements the ClarifyBody interface.