sarvam-agents-client 0.3.0 → 0.3.2

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 (135) hide show
  1. package/README.md +98 -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 +20 -3
  7. package/dist/compose/agent.js +84 -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 +6 -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 +28 -1
  23. package/dist/compose/settingsTransport.js +389 -7
  24. package/dist/compose/transport.d.ts +18 -1
  25. package/dist/compose/webhook.d.ts +19 -0
  26. package/dist/compose/webhook.js +184 -0
  27. package/dist/esm/apis/FunctionToolsApi.d.ts +33 -0
  28. package/dist/esm/apis/FunctionToolsApi.js +61 -0
  29. package/dist/esm/apis/index.d.ts +1 -0
  30. package/dist/esm/apis/index.js +1 -0
  31. package/dist/esm/compose/agent.d.ts +20 -3
  32. package/dist/esm/compose/agent.js +84 -7
  33. package/dist/esm/compose/errors.d.ts +5 -1
  34. package/dist/esm/compose/errors.js +4 -1
  35. package/dist/esm/compose/events.d.ts +4 -0
  36. package/dist/esm/compose/events.js +33 -0
  37. package/dist/esm/compose/functionTool.d.ts +101 -0
  38. package/dist/esm/compose/functionTool.js +406 -0
  39. package/dist/esm/compose/index.d.ts +6 -2
  40. package/dist/esm/compose/index.js +1 -0
  41. package/dist/esm/compose/output.d.ts +11 -0
  42. package/dist/esm/compose/output.js +30 -9
  43. package/dist/esm/compose/run.d.ts +5 -1
  44. package/dist/esm/compose/run.js +118 -25
  45. package/dist/esm/compose/runState.d.ts +26 -1
  46. package/dist/esm/compose/runState.js +31 -1
  47. package/dist/esm/compose/settingsTransport.d.ts +28 -1
  48. package/dist/esm/compose/settingsTransport.js +392 -11
  49. package/dist/esm/compose/transport.d.ts +18 -1
  50. package/dist/esm/compose/webhook.d.ts +19 -0
  51. package/dist/esm/compose/webhook.js +177 -0
  52. package/dist/esm/models/AgentConversationDetail.d.ts +7 -0
  53. package/dist/esm/models/AgentConversationDetail.js +3 -0
  54. package/dist/esm/models/ClarifyBody.d.ts +6 -0
  55. package/dist/esm/models/ClarifyBody.js +2 -0
  56. package/dist/esm/models/ConversationDetail.d.ts +7 -0
  57. package/dist/esm/models/ConversationDetail.js +3 -0
  58. package/dist/esm/models/ErrorDetail.d.ts +1 -0
  59. package/dist/esm/models/ErrorDetail.js +2 -1
  60. package/dist/esm/models/FunctionResultBody.d.ts +44 -0
  61. package/dist/esm/models/FunctionResultBody.js +49 -0
  62. package/dist/esm/models/QueueMessageInput.d.ts +23 -0
  63. package/dist/esm/models/QueueMessageInput.js +14 -0
  64. package/dist/esm/models/RequiredAction.d.ts +77 -0
  65. package/dist/esm/models/RequiredAction.js +69 -0
  66. package/dist/esm/models/ResponseDetail.d.ts +8 -0
  67. package/dist/esm/models/ResponseDetail.js +2 -0
  68. package/dist/esm/models/ResponseInput.d.ts +23 -0
  69. package/dist/esm/models/ResponseInput.js +14 -0
  70. package/dist/esm/models/ToolResults200Response.d.ts +38 -0
  71. package/dist/esm/models/ToolResults200Response.js +47 -0
  72. package/dist/esm/models/ToolResultsBody.d.ts +39 -0
  73. package/dist/esm/models/ToolResultsBody.js +48 -0
  74. package/dist/esm/models/index.d.ts +4 -0
  75. package/dist/esm/models/index.js +4 -0
  76. package/dist/esm/streaming.d.ts +14 -2
  77. package/dist/esm/streaming.js +26 -4
  78. package/dist/esm/webhooks.d.ts +203 -0
  79. package/dist/esm/webhooks.js +215 -0
  80. package/dist/models/AgentConversationDetail.d.ts +7 -0
  81. package/dist/models/AgentConversationDetail.js +3 -0
  82. package/dist/models/ClarifyBody.d.ts +6 -0
  83. package/dist/models/ClarifyBody.js +2 -0
  84. package/dist/models/ConversationDetail.d.ts +7 -0
  85. package/dist/models/ConversationDetail.js +3 -0
  86. package/dist/models/ErrorDetail.d.ts +1 -0
  87. package/dist/models/ErrorDetail.js +2 -1
  88. package/dist/models/FunctionResultBody.d.ts +44 -0
  89. package/dist/models/FunctionResultBody.js +56 -0
  90. package/dist/models/QueueMessageInput.d.ts +23 -0
  91. package/dist/models/QueueMessageInput.js +15 -1
  92. package/dist/models/RequiredAction.d.ts +77 -0
  93. package/dist/models/RequiredAction.js +77 -0
  94. package/dist/models/ResponseDetail.d.ts +8 -0
  95. package/dist/models/ResponseDetail.js +2 -0
  96. package/dist/models/ResponseInput.d.ts +23 -0
  97. package/dist/models/ResponseInput.js +15 -0
  98. package/dist/models/ToolResults200Response.d.ts +38 -0
  99. package/dist/models/ToolResults200Response.js +54 -0
  100. package/dist/models/ToolResultsBody.d.ts +39 -0
  101. package/dist/models/ToolResultsBody.js +55 -0
  102. package/dist/models/index.d.ts +4 -0
  103. package/dist/models/index.js +4 -0
  104. package/dist/streaming.d.ts +14 -2
  105. package/dist/streaming.js +27 -4
  106. package/dist/webhooks.d.ts +203 -0
  107. package/dist/webhooks.js +224 -0
  108. package/package.json +9 -1
  109. package/src/apis/FunctionToolsApi.ts +102 -0
  110. package/src/apis/index.ts +1 -0
  111. package/src/compose/agent.ts +96 -9
  112. package/src/compose/errors.ts +7 -1
  113. package/src/compose/events.ts +30 -0
  114. package/src/compose/functionTool.ts +441 -0
  115. package/src/compose/index.ts +6 -2
  116. package/src/compose/output.ts +30 -9
  117. package/src/compose/run.ts +115 -18
  118. package/src/compose/runState.ts +44 -5
  119. package/src/compose/settingsTransport.ts +379 -8
  120. package/src/compose/transport.ts +24 -1
  121. package/src/compose/webhook.ts +181 -0
  122. package/src/models/AgentConversationDetail.ts +15 -0
  123. package/src/models/ClarifyBody.ts +8 -0
  124. package/src/models/ConversationDetail.ts +15 -0
  125. package/src/models/ErrorDetail.ts +2 -1
  126. package/src/models/FunctionResultBody.ts +83 -0
  127. package/src/models/QueueMessageInput.ts +28 -0
  128. package/src/models/RequiredAction.ts +128 -0
  129. package/src/models/ResponseDetail.ts +8 -0
  130. package/src/models/ResponseInput.ts +30 -0
  131. package/src/models/ToolResults200Response.ts +75 -0
  132. package/src/models/ToolResultsBody.ts +83 -0
  133. package/src/models/index.ts +4 -0
  134. package/src/streaming.ts +39 -3
  135. package/src/webhooks.ts +390 -0
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Sarvam Agents API
6
+ * Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
7
+ *
8
+ * The version of the OpenAPI document: 0.1.0
9
+ * Contact: support@sarvam.ai
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.RequiredActionTypeEnum = void 0;
17
+ exports.instanceOfRequiredAction = instanceOfRequiredAction;
18
+ exports.RequiredActionFromJSON = RequiredActionFromJSON;
19
+ exports.RequiredActionFromJSONTyped = RequiredActionFromJSONTyped;
20
+ exports.RequiredActionToJSON = RequiredActionToJSON;
21
+ exports.RequiredActionToJSONTyped = RequiredActionToJSONTyped;
22
+ /**
23
+ * @export
24
+ */
25
+ exports.RequiredActionTypeEnum = {
26
+ FunctionCall: 'function_call'
27
+ };
28
+ /**
29
+ * Check if a given object implements the RequiredAction interface.
30
+ */
31
+ function instanceOfRequiredAction(value) {
32
+ if (!('requestId' in value) || value['requestId'] === undefined)
33
+ return false;
34
+ if (!('toolCallId' in value) || value['toolCallId'] === undefined)
35
+ return false;
36
+ if (!('name' in value) || value['name'] === undefined)
37
+ return false;
38
+ if (!('arguments' in value) || value['arguments'] === undefined)
39
+ return false;
40
+ if (!('createdAt' in value) || value['createdAt'] === undefined)
41
+ return false;
42
+ return true;
43
+ }
44
+ function RequiredActionFromJSON(json) {
45
+ return RequiredActionFromJSONTyped(json, false);
46
+ }
47
+ function RequiredActionFromJSONTyped(json, ignoreDiscriminator) {
48
+ if (json == null) {
49
+ return json;
50
+ }
51
+ return {
52
+ 'type': json['type'] == null ? undefined : json['type'],
53
+ 'requestId': json['requestId'],
54
+ 'toolCallId': json['toolCallId'],
55
+ 'name': json['name'],
56
+ 'arguments': json['arguments'],
57
+ 'createdAt': (new Date(json['createdAt'])),
58
+ 'expiresAt': json['expiresAt'] == null ? undefined : (new Date(json['expiresAt'])),
59
+ };
60
+ }
61
+ function RequiredActionToJSON(json) {
62
+ return RequiredActionToJSONTyped(json, false);
63
+ }
64
+ function RequiredActionToJSONTyped(value, ignoreDiscriminator = false) {
65
+ if (value == null) {
66
+ return value;
67
+ }
68
+ return {
69
+ 'type': value['type'],
70
+ 'requestId': value['requestId'],
71
+ 'toolCallId': value['toolCallId'],
72
+ 'name': value['name'],
73
+ 'arguments': value['arguments'],
74
+ 'createdAt': ((value['createdAt']).toISOString()),
75
+ 'expiresAt': value['expiresAt'] == null ? undefined : (value['expiresAt'].toISOString()),
76
+ };
77
+ }
@@ -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}
@@ -52,6 +52,7 @@ function ResponseDetailFromJSONTyped(json, ignoreDiscriminator) {
52
52
  'responseId': json['responseId'],
53
53
  'status': json['status'],
54
54
  'output': (json['output'].map(UIMessage_js_1.UIMessageFromJSON)),
55
+ 'usage': json['usage'] == null ? undefined : json['usage'],
55
56
  'structuredOutput': json['structuredOutput'] == null ? undefined : json['structuredOutput'],
56
57
  'outputErrors': json['outputErrors'] == null ? undefined : json['outputErrors'],
57
58
  'outputCitations': json['outputCitations'] == null ? undefined : json['outputCitations'],
@@ -70,6 +71,7 @@ function ResponseDetailToJSONTyped(value, ignoreDiscriminator = false) {
70
71
  'responseId': value['responseId'],
71
72
  'status': value['status'],
72
73
  'output': (value['output'].map(UIMessage_js_1.UIMessageToJSON)),
74
+ 'usage': value['usage'],
73
75
  'structuredOutput': value['structuredOutput'],
74
76
  'outputErrors': value['outputErrors'],
75
77
  '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
  */
@@ -13,12 +13,23 @@
13
13
  * Do not edit the class manually.
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ResponseInputSurfaceEnum = void 0;
16
17
  exports.instanceOfResponseInput = instanceOfResponseInput;
17
18
  exports.ResponseInputFromJSON = ResponseInputFromJSON;
18
19
  exports.ResponseInputFromJSONTyped = ResponseInputFromJSONTyped;
19
20
  exports.ResponseInputToJSON = ResponseInputToJSON;
20
21
  exports.ResponseInputToJSONTyped = ResponseInputToJSONTyped;
21
22
  const InputMessage_js_1 = require("./InputMessage.js");
23
+ /**
24
+ * @export
25
+ */
26
+ exports.ResponseInputSurfaceEnum = {
27
+ Builder: 'builder',
28
+ Playground: 'playground',
29
+ Tests: 'tests',
30
+ Evals: 'evals',
31
+ Cowork: 'cowork'
32
+ };
22
33
  /**
23
34
  * Check if a given object implements the ResponseInput interface.
24
35
  */
@@ -44,6 +55,8 @@ function ResponseInputFromJSONTyped(json, ignoreDiscriminator) {
44
55
  'agentId': json['agentId'] == null ? undefined : json['agentId'],
45
56
  'regenerateAfter': json['regenerateAfter'] == null ? undefined : json['regenerateAfter'],
46
57
  'retryOf': json['retryOf'] == null ? undefined : json['retryOf'],
58
+ 'surface': json['surface'] == null ? undefined : json['surface'],
59
+ 'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
47
60
  };
48
61
  }
49
62
  function ResponseInputToJSON(json) {
@@ -61,5 +74,7 @@ function ResponseInputToJSONTyped(value, ignoreDiscriminator = false) {
61
74
  'agentId': value['agentId'],
62
75
  'regenerateAfter': value['regenerateAfter'],
63
76
  'retryOf': value['retryOf'],
77
+ 'surface': value['surface'],
78
+ 'endUserId': value['endUserId'],
64
79
  };
65
80
  }
@@ -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,54 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Sarvam Agents API
6
+ * Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
7
+ *
8
+ * The version of the OpenAPI document: 0.1.0
9
+ * Contact: support@sarvam.ai
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.instanceOfToolResults200Response = instanceOfToolResults200Response;
17
+ exports.ToolResults200ResponseFromJSON = ToolResults200ResponseFromJSON;
18
+ exports.ToolResults200ResponseFromJSONTyped = ToolResults200ResponseFromJSONTyped;
19
+ exports.ToolResults200ResponseToJSON = ToolResults200ResponseToJSON;
20
+ exports.ToolResults200ResponseToJSONTyped = ToolResults200ResponseToJSONTyped;
21
+ /**
22
+ * Check if a given object implements the ToolResults200Response interface.
23
+ */
24
+ function instanceOfToolResults200Response(value) {
25
+ if (!('accepted' in value) || value['accepted'] === undefined)
26
+ return false;
27
+ if (!('duplicate' in value) || value['duplicate'] === undefined)
28
+ return false;
29
+ return true;
30
+ }
31
+ function ToolResults200ResponseFromJSON(json) {
32
+ return ToolResults200ResponseFromJSONTyped(json, false);
33
+ }
34
+ function ToolResults200ResponseFromJSONTyped(json, ignoreDiscriminator) {
35
+ if (json == null) {
36
+ return json;
37
+ }
38
+ return {
39
+ 'accepted': json['accepted'],
40
+ 'duplicate': json['duplicate'],
41
+ };
42
+ }
43
+ function ToolResults200ResponseToJSON(json) {
44
+ return ToolResults200ResponseToJSONTyped(json, false);
45
+ }
46
+ function ToolResults200ResponseToJSONTyped(value, ignoreDiscriminator = false) {
47
+ if (value == null) {
48
+ return value;
49
+ }
50
+ return {
51
+ 'accepted': value['accepted'],
52
+ 'duplicate': value['duplicate'],
53
+ };
54
+ }
@@ -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,55 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Sarvam Agents API
6
+ * Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
7
+ *
8
+ * The version of the OpenAPI document: 0.1.0
9
+ * Contact: support@sarvam.ai
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.instanceOfToolResultsBody = instanceOfToolResultsBody;
17
+ exports.ToolResultsBodyFromJSON = ToolResultsBodyFromJSON;
18
+ exports.ToolResultsBodyFromJSONTyped = ToolResultsBodyFromJSONTyped;
19
+ exports.ToolResultsBodyToJSON = ToolResultsBodyToJSON;
20
+ exports.ToolResultsBodyToJSONTyped = ToolResultsBodyToJSONTyped;
21
+ const FunctionResultBody_js_1 = require("./FunctionResultBody.js");
22
+ /**
23
+ * Check if a given object implements the ToolResultsBody interface.
24
+ */
25
+ function instanceOfToolResultsBody(value) {
26
+ if (!('requestId' in value) || value['requestId'] === undefined)
27
+ return false;
28
+ if (!('results' in value) || value['results'] === undefined)
29
+ return false;
30
+ return true;
31
+ }
32
+ function ToolResultsBodyFromJSON(json) {
33
+ return ToolResultsBodyFromJSONTyped(json, false);
34
+ }
35
+ function ToolResultsBodyFromJSONTyped(json, ignoreDiscriminator) {
36
+ if (json == null) {
37
+ return json;
38
+ }
39
+ return {
40
+ 'requestId': json['requestId'],
41
+ 'results': (json['results'].map(FunctionResultBody_js_1.FunctionResultBodyFromJSON)),
42
+ };
43
+ }
44
+ function ToolResultsBodyToJSON(json) {
45
+ return ToolResultsBodyToJSONTyped(json, false);
46
+ }
47
+ function ToolResultsBodyToJSONTyped(value, ignoreDiscriminator = false) {
48
+ if (value == null) {
49
+ return value;
50
+ }
51
+ return {
52
+ 'requestId': value['requestId'],
53
+ 'results': (value['results'].map(FunctionResultBody_js_1.FunctionResultBodyToJSON)),
54
+ };
55
+ }
@@ -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';
@@ -117,6 +117,7 @@ __exportStar(require("./FileQueuedResponse.js"), exports);
117
117
  __exportStar(require("./FileRawResponse.js"), exports);
118
118
  __exportStar(require("./FileRead.js"), exports);
119
119
  __exportStar(require("./FileWriteBody.js"), exports);
120
+ __exportStar(require("./FunctionResultBody.js"), exports);
120
121
  __exportStar(require("./HTTPValidationError.js"), exports);
121
122
  __exportStar(require("./HighlightRange.js"), exports);
122
123
  __exportStar(require("./InlineCreateSkillBody.js"), exports);
@@ -147,6 +148,7 @@ __exportStar(require("./QueueMessageInput.js"), exports);
147
148
  __exportStar(require("./QueueMessageResult.js"), exports);
148
149
  __exportStar(require("./QueuedTurnView.js"), exports);
149
150
  __exportStar(require("./Reason.js"), exports);
151
+ __exportStar(require("./RequiredAction.js"), exports);
150
152
  __exportStar(require("./Requiredscope.js"), exports);
151
153
  __exportStar(require("./Resourcetype.js"), exports);
152
154
  __exportStar(require("./ResponseCompleteFileUpload.js"), exports);
@@ -170,6 +172,8 @@ __exportStar(require("./StopResponse.js"), exports);
170
172
  __exportStar(require("./TemplateConnectorTag.js"), exports);
171
173
  __exportStar(require("./TemplateWorksWith.js"), exports);
172
174
  __exportStar(require("./TextPart.js"), exports);
175
+ __exportStar(require("./ToolResults200Response.js"), exports);
176
+ __exportStar(require("./ToolResultsBody.js"), exports);
173
177
  __exportStar(require("./TriggerCronBody.js"), exports);
174
178
  __exportStar(require("./TriggerResponse.js"), exports);
175
179
  __exportStar(require("./UIMessage.js"), exports);
@@ -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>;
package/dist/streaming.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * const again = await reconnect(config, conversationId, stream.responseId!, stream.lastEventId);
16
16
  *
17
17
  * Each item is the event's JSON payload (`type` is `start`, `text-delta`, `data-file-shared`,
18
- * `data-clarify-request`, `data-stopped`, `error`, `finish`, ...). The stream keeps `lastEventId` and `responseId`
18
+ * `data-clarify-request`, `data-function-call-request`, `data-stopped`, `error`, `finish`, ...). The stream keeps `lastEventId` and `responseId`
19
19
  * up to date, the two values `reconnect` needs.
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -24,7 +24,9 @@ exports.iterSse = iterSse;
24
24
  exports.streamResponse = streamResponse;
25
25
  exports.reconnect = reconnect;
26
26
  exports.answerClarify = answerClarify;
27
+ exports.postToolResults = postToolResults;
27
28
  const ClarifyApi_js_1 = require("./apis/ClarifyApi.js");
29
+ const FunctionToolsApi_js_1 = require("./apis/FunctionToolsApi.js");
28
30
  const ResponsesApi_js_1 = require("./apis/ResponsesApi.js");
29
31
  exports.DEFAULT_IDLE_TIMEOUT_MS = 60000;
30
32
  /** Parse a server-sent-events body into [last event id, payload] pairs. */
@@ -84,6 +86,9 @@ async function* iterSse(chunks) {
84
86
  /** Async iterator over a reply's events. Call `close()` if you stop early. */
85
87
  class ResponseStream {
86
88
  constructor(body, controller, idleTimeoutMs, responseId = null, lastEventId = null) {
89
+ /** `postToolResults` only: the server already had these results (a repeat with the same idempotency key), so
90
+ * this stream is empty; follow the turn with `reconnect`. */
91
+ this.duplicate = false;
87
92
  this.body = body;
88
93
  this.controller = controller;
89
94
  this.idleTimeoutMs = idleTimeoutMs;
@@ -146,15 +151,24 @@ class ResponseStream {
146
151
  }
147
152
  }
148
153
  exports.ResponseStream = ResponseStream;
149
- async function open(call, options, responseId = null, lastEventId = null) {
150
- var _a, _b;
154
+ async function open(call, options, responseId = null, lastEventId = null, jsonIsDuplicate = false) {
155
+ var _a, _b, _c, _d, _e;
151
156
  const controller = new AbortController();
152
157
  (_a = options.signal) === null || _a === void 0 ? void 0 : _a.addEventListener("abort", () => controller.abort(options.signal.reason), { once: true });
153
158
  // Non-2xx responses throw ResponseError here, like every other generated method.
154
159
  const response = await call({ signal: controller.signal });
160
+ const contentType = ((_b = response.raw.headers.get("content-type")) !== null && _b !== void 0 ? _b : "").split(";")[0].trim().toLowerCase();
161
+ if (jsonIsDuplicate && contentType === "application/json") {
162
+ await ((_c = response.raw.body) === null || _c === void 0 ? void 0 : _c.cancel().catch(() => undefined));
163
+ const empty = new ReadableStream({ start: (c) => c.close() });
164
+ const stream = new ResponseStream(empty, controller, (_d = options.idleTimeoutMs) !== null && _d !== void 0 ? _d : exports.DEFAULT_IDLE_TIMEOUT_MS);
165
+ stream.duplicate = true;
166
+ stream.close();
167
+ return stream;
168
+ }
155
169
  if (!response.raw.body)
156
170
  throw new Error("response has no body to stream");
157
- return new ResponseStream(response.raw.body, controller, (_b = options.idleTimeoutMs) !== null && _b !== void 0 ? _b : exports.DEFAULT_IDLE_TIMEOUT_MS, responseId, lastEventId);
171
+ return new ResponseStream(response.raw.body, controller, (_e = options.idleTimeoutMs) !== null && _e !== void 0 ? _e : exports.DEFAULT_IDLE_TIMEOUT_MS, responseId, lastEventId);
158
172
  }
159
173
  /** Send a message (POST /v1/responses) and stream the reply. Same body as `ResponsesApi.createResponse`. */
160
174
  function streamResponse(config, body, options = {}) {
@@ -177,3 +191,12 @@ function reconnect(config, conversationId, responseId, lastEventId = null, optio
177
191
  function answerClarify(config, conversationId, body, options = {}) {
178
192
  return open((init) => new ClarifyApi_js_1.ClarifyApi(config).clarifyRaw({ conversationId, clarifyBody: body }, init), options);
179
193
  }
194
+ /**
195
+ * Answer the agent's function calls (a `data-function-call-request` event) and stream the rest of the reply.
196
+ * `body.requestId` comes from that event, with one result per call. Send the same `idempotencyKey` when you retry a
197
+ * post: a repeat the server already has resolves to an empty stream with `duplicate` set, and the turn can be followed
198
+ * with `reconnect`.
199
+ */
200
+ function postToolResults(config, conversationId, body, options = {}) {
201
+ return open((init) => new FunctionToolsApi_js_1.FunctionToolsApi(config).toolResultsRaw({ conversationId, toolResultsBody: body, idempotencyKey: options.idempotencyKey }, init), options, null, null, true);
202
+ }