@aigne/transport 0.13.0 → 0.14.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 +43 -0
- package/lib/cjs/http-client/base-client.d.ts +4 -2
- package/lib/cjs/http-client/base-client.js +44 -3
- package/lib/cjs/http-client/client-chat-model.d.ts +1 -0
- package/lib/cjs/http-client/client-chat-model.js +3 -0
- package/lib/dts/http-client/base-client.d.ts +4 -2
- package/lib/dts/http-client/client-chat-model.d.ts +1 -0
- package/lib/esm/http-client/base-client.d.ts +4 -2
- package/lib/esm/http-client/base-client.js +11 -3
- package/lib/esm/http-client/client-chat-model.d.ts +1 -0
- package/lib/esm/http-client/client-chat-model.js +3 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.14.0](https://github.com/AIGNE-io/aigne-framework/compare/transport-v0.13.1...transport-v0.14.0) (2025-08-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **transport:** add retry mechanism to HTTP client ([#364](https://github.com/AIGNE-io/aigne-framework/issues/364)) ([85dfab0](https://github.com/AIGNE-io/aigne-framework/commit/85dfab0d285199137edea47199c448247823258c))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **cli:** log only once in loadAIGNE ([#357](https://github.com/AIGNE-io/aigne-framework/issues/357)) ([6e6d968](https://github.com/AIGNE-io/aigne-framework/commit/6e6d96814fbc87f210522ae16daf94c1f84f311a))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* The following workspace dependencies were updated
|
|
19
|
+
* dependencies
|
|
20
|
+
* @aigne/openai bumped to 0.11.2
|
|
21
|
+
* devDependencies
|
|
22
|
+
* @aigne/agent-library bumped to 1.21.20
|
|
23
|
+
* @aigne/core bumped to 1.50.0
|
|
24
|
+
* @aigne/default-memory bumped to 1.1.2
|
|
25
|
+
* @aigne/test-utils bumped to 0.5.28
|
|
26
|
+
|
|
27
|
+
## [0.13.1](https://github.com/AIGNE-io/aigne-framework/compare/transport-v0.13.0...transport-v0.13.1) (2025-08-12)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **core:** add optional memory context toggle for AI agent ([#350](https://github.com/AIGNE-io/aigne-framework/issues/350)) ([92322cc](https://github.com/AIGNE-io/aigne-framework/commit/92322ccaf6f2b6e4440d47a7631589061c351d64))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Dependencies
|
|
36
|
+
|
|
37
|
+
* The following workspace dependencies were updated
|
|
38
|
+
* dependencies
|
|
39
|
+
* @aigne/openai bumped to 0.11.1
|
|
40
|
+
* devDependencies
|
|
41
|
+
* @aigne/agent-library bumped to 1.21.19
|
|
42
|
+
* @aigne/core bumped to 1.49.1
|
|
43
|
+
* @aigne/default-memory bumped to 1.1.1
|
|
44
|
+
* @aigne/test-utils bumped to 0.5.27
|
|
45
|
+
|
|
3
46
|
## [0.13.0](https://github.com/AIGNE-io/aigne-framework/compare/transport-v0.12.5...transport-v0.13.0) (2025-08-12)
|
|
4
47
|
|
|
5
48
|
|
|
@@ -9,7 +9,9 @@ export interface BaseClientInvokeOptions extends InvokeOptions {
|
|
|
9
9
|
* Additional fetch API options to customize the HTTP request.
|
|
10
10
|
* These options will be merged with the default options used by the client.
|
|
11
11
|
*/
|
|
12
|
-
fetchOptions?: Partial<RequestInit
|
|
12
|
+
fetchOptions?: Partial<RequestInit> & {
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
};
|
|
13
15
|
}
|
|
14
16
|
export interface BaseClientOptions {
|
|
15
17
|
url: string;
|
|
@@ -88,5 +90,5 @@ export declare class BaseClient {
|
|
|
88
90
|
*
|
|
89
91
|
* @private
|
|
90
92
|
*/
|
|
91
|
-
fetch(
|
|
93
|
+
fetch(url: string, init?: BaseClientInvokeOptions["fetchOptions"]): Promise<Response>;
|
|
92
94
|
}
|
|
@@ -1,9 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.BaseClient = void 0;
|
|
4
37
|
const event_stream_js_1 = require("@aigne/core/utils/event-stream.js");
|
|
38
|
+
const logger_js_1 = require("@aigne/core/utils/logger.js");
|
|
5
39
|
const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
|
|
6
40
|
const constants_js_1 = require("../constants.js");
|
|
41
|
+
const DEFAULT_MAX_RECONNECTS = 3;
|
|
7
42
|
/**
|
|
8
43
|
* Http client for interacting with a remote AIGNE server.
|
|
9
44
|
* BaseClient provides a client-side interface that matches the AIGNE API,
|
|
@@ -81,8 +116,14 @@ class BaseClient {
|
|
|
81
116
|
*
|
|
82
117
|
* @private
|
|
83
118
|
*/
|
|
84
|
-
async fetch(
|
|
85
|
-
const
|
|
119
|
+
async fetch(url, init) {
|
|
120
|
+
const { default: retry } = await Promise.resolve().then(() => __importStar(require("p-retry")));
|
|
121
|
+
const result = await retry(() => globalThis.fetch(url, init), {
|
|
122
|
+
retries: init?.maxRetries ?? DEFAULT_MAX_RECONNECTS,
|
|
123
|
+
onFailedAttempt: (error) => {
|
|
124
|
+
logger_js_1.logger.warn("Retrying fetch request due to error:", error);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
86
127
|
if (!result.ok) {
|
|
87
128
|
let message;
|
|
88
129
|
let resultText;
|
|
@@ -103,7 +144,7 @@ class BaseClient {
|
|
|
103
144
|
e.type = type;
|
|
104
145
|
throw e;
|
|
105
146
|
}
|
|
106
|
-
throw new Error(`Failed to fetch url ${
|
|
147
|
+
throw new Error(`Failed to fetch url ${url} with status ${result.status}: ${resultText}`);
|
|
107
148
|
}
|
|
108
149
|
return result;
|
|
109
150
|
}
|
|
@@ -9,7 +9,9 @@ export interface BaseClientInvokeOptions extends InvokeOptions {
|
|
|
9
9
|
* Additional fetch API options to customize the HTTP request.
|
|
10
10
|
* These options will be merged with the default options used by the client.
|
|
11
11
|
*/
|
|
12
|
-
fetchOptions?: Partial<RequestInit
|
|
12
|
+
fetchOptions?: Partial<RequestInit> & {
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
};
|
|
13
15
|
}
|
|
14
16
|
export interface BaseClientOptions {
|
|
15
17
|
url: string;
|
|
@@ -88,5 +90,5 @@ export declare class BaseClient {
|
|
|
88
90
|
*
|
|
89
91
|
* @private
|
|
90
92
|
*/
|
|
91
|
-
fetch(
|
|
93
|
+
fetch(url: string, init?: BaseClientInvokeOptions["fetchOptions"]): Promise<Response>;
|
|
92
94
|
}
|
|
@@ -9,7 +9,9 @@ export interface BaseClientInvokeOptions extends InvokeOptions {
|
|
|
9
9
|
* Additional fetch API options to customize the HTTP request.
|
|
10
10
|
* These options will be merged with the default options used by the client.
|
|
11
11
|
*/
|
|
12
|
-
fetchOptions?: Partial<RequestInit
|
|
12
|
+
fetchOptions?: Partial<RequestInit> & {
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
};
|
|
13
15
|
}
|
|
14
16
|
export interface BaseClientOptions {
|
|
15
17
|
url: string;
|
|
@@ -88,5 +90,5 @@ export declare class BaseClient {
|
|
|
88
90
|
*
|
|
89
91
|
* @private
|
|
90
92
|
*/
|
|
91
|
-
fetch(
|
|
93
|
+
fetch(url: string, init?: BaseClientInvokeOptions["fetchOptions"]): Promise<Response>;
|
|
92
94
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AgentResponseStreamParser, EventStreamParser } from "@aigne/core/utils/event-stream.js";
|
|
2
|
+
import { logger } from "@aigne/core/utils/logger.js";
|
|
2
3
|
import { omit, tryOrThrow } from "@aigne/core/utils/type-utils.js";
|
|
3
4
|
import { ChatModelName } from "../constants.js";
|
|
5
|
+
const DEFAULT_MAX_RECONNECTS = 3;
|
|
4
6
|
/**
|
|
5
7
|
* Http client for interacting with a remote AIGNE server.
|
|
6
8
|
* BaseClient provides a client-side interface that matches the AIGNE API,
|
|
@@ -78,8 +80,14 @@ export class BaseClient {
|
|
|
78
80
|
*
|
|
79
81
|
* @private
|
|
80
82
|
*/
|
|
81
|
-
async fetch(
|
|
82
|
-
const
|
|
83
|
+
async fetch(url, init) {
|
|
84
|
+
const { default: retry } = await import("p-retry");
|
|
85
|
+
const result = await retry(() => globalThis.fetch(url, init), {
|
|
86
|
+
retries: init?.maxRetries ?? DEFAULT_MAX_RECONNECTS,
|
|
87
|
+
onFailedAttempt: (error) => {
|
|
88
|
+
logger.warn("Retrying fetch request due to error:", error);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
83
91
|
if (!result.ok) {
|
|
84
92
|
let message;
|
|
85
93
|
let resultText;
|
|
@@ -100,7 +108,7 @@ export class BaseClient {
|
|
|
100
108
|
e.type = type;
|
|
101
109
|
throw e;
|
|
102
110
|
}
|
|
103
|
-
throw new Error(`Failed to fetch url ${
|
|
111
|
+
throw new Error(`Failed to fetch url ${url} with status ${result.status}: ${resultText}`);
|
|
104
112
|
}
|
|
105
113
|
return result;
|
|
106
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/transport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "AIGNE Transport SDK providing HTTP client and server implementations for communication between AIGNE components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -43,9 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"content-type": "^1.0.5",
|
|
46
|
+
"p-retry": "^6.2.1",
|
|
46
47
|
"raw-body": "^3.0.0",
|
|
47
48
|
"zod": "^3.25.67",
|
|
48
|
-
"@aigne/openai": "^0.11.
|
|
49
|
+
"@aigne/openai": "^0.11.2"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/bun": "^1.2.18",
|
|
@@ -60,10 +61,10 @@
|
|
|
60
61
|
"rimraf": "^6.0.1",
|
|
61
62
|
"typescript": "^5.8.3",
|
|
62
63
|
"uuid": "^11.1.0",
|
|
63
|
-
"@aigne/
|
|
64
|
-
"@aigne/
|
|
65
|
-
"@aigne/
|
|
66
|
-
"@aigne/default-memory": "^1.1.
|
|
64
|
+
"@aigne/test-utils": "^0.5.28",
|
|
65
|
+
"@aigne/agent-library": "^1.21.20",
|
|
66
|
+
"@aigne/core": "^1.50.0",
|
|
67
|
+
"@aigne/default-memory": "^1.1.2"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|
|
69
70
|
"lint": "tsc --noEmit",
|