@mantyx/sdk 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-QMUVI3Y3.js → chunk-5NKXV5XZ.js} +30 -6
- package/dist/{chunk-QMUVI3Y3.js.map → chunk-5NKXV5XZ.js.map} +1 -1
- package/dist/index.cjs +30 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/a2a-server.js
CHANGED
|
@@ -1019,11 +1019,23 @@ var MantyxClient = class {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
1021
1021
|
async postToolResult(runId, toolUseId, payload) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1022
|
+
const path = `/agent-runs/${encodeURIComponent(runId)}/tool-results`;
|
|
1023
|
+
const body = { toolUseId, ...payload };
|
|
1024
|
+
for (let attempt = 0; attempt < TOOL_RESULT_POST_MAX_ATTEMPTS; attempt++) {
|
|
1025
|
+
try {
|
|
1026
|
+
await this.request({
|
|
1027
|
+
method: "POST",
|
|
1028
|
+
path,
|
|
1029
|
+
body
|
|
1030
|
+
});
|
|
1031
|
+
return;
|
|
1032
|
+
} catch (err) {
|
|
1033
|
+
if (attempt === TOOL_RESULT_POST_MAX_ATTEMPTS - 1 || !isToolResultPostRetryable(err)) {
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
await sleep(toolResultPostBackoffMs(attempt));
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1027
1039
|
}
|
|
1028
1040
|
async cancelRun(runId) {
|
|
1029
1041
|
await this.request({
|
|
@@ -1862,6 +1874,18 @@ function parseRunOutput(result, validator) {
|
|
|
1862
1874
|
function sleep(ms) {
|
|
1863
1875
|
return new Promise((r) => setTimeout(r, ms));
|
|
1864
1876
|
}
|
|
1877
|
+
var TOOL_RESULT_POST_MAX_ATTEMPTS = 6;
|
|
1878
|
+
function toolResultPostBackoffMs(attempt) {
|
|
1879
|
+
return Math.min(500 * 2 ** attempt, 8e3);
|
|
1880
|
+
}
|
|
1881
|
+
function isToolResultPostRetryable(err) {
|
|
1882
|
+
if (err instanceof MantyxNetworkError) return true;
|
|
1883
|
+
if (err instanceof MantyxError && typeof err.status === "number") {
|
|
1884
|
+
if (err.status === 429) return true;
|
|
1885
|
+
if (err.status >= 500) return true;
|
|
1886
|
+
}
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1865
1889
|
function parseRunTokens(value) {
|
|
1866
1890
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1867
1891
|
const v = value;
|
|
@@ -1958,4 +1982,4 @@ export {
|
|
|
1958
1982
|
AgentSession,
|
|
1959
1983
|
parseRunOutput
|
|
1960
1984
|
};
|
|
1961
|
-
//# sourceMappingURL=chunk-
|
|
1985
|
+
//# sourceMappingURL=chunk-5NKXV5XZ.js.map
|