@aigne/transport 0.11.2 → 0.12.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.0](https://github.com/AIGNE-io/aigne-framework/compare/transport-v0.11.2...transport-v0.12.0) (2025-08-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * allow inserting agent-hub credits manually ([#315](https://github.com/AIGNE-io/aigne-framework/issues/315)) ([e3e4d1f](https://github.com/AIGNE-io/aigne-framework/commit/e3e4d1ff0d9d3fef33bb41d85e99735d4dd76cb7))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/openai bumped to 0.10.12
16
+ * devDependencies
17
+ * @aigne/agent-library bumped to 1.21.12
18
+ * @aigne/core bumped to 1.44.0
19
+ * @aigne/default-memory bumped to 1.0.12
20
+ * @aigne/test-utils bumped to 0.5.20
21
+
3
22
  ## [0.11.2](https://github.com/AIGNE-io/aigne-framework/compare/transport-v0.11.1...transport-v0.11.2) (2025-08-05)
4
23
 
5
24
 
@@ -85,15 +85,20 @@ class BaseClient {
85
85
  const result = await globalThis.fetch(...args);
86
86
  if (!result.ok) {
87
87
  let message;
88
+ let resultText;
88
89
  try {
89
90
  const text = await result.text();
90
91
  const json = (0, type_utils_js_1.tryOrThrow)(() => JSON.parse(text));
91
- message = json?.error?.message || text;
92
+ resultText = text;
93
+ message = json?.error?.message;
92
94
  }
93
95
  catch {
94
96
  // ignore
95
97
  }
96
- throw new Error(`Failed to fetch url ${args[0]} with status ${result.status}: ${message}`);
98
+ if (message) {
99
+ throw new Error(message);
100
+ }
101
+ throw new Error(`Failed to fetch url ${args[0]} with status ${result.status}: ${resultText}`);
97
102
  }
98
103
  return result;
99
104
  }
@@ -1,6 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { AIGNE, InvokeOptions, UserContext } from "@aigne/core";
3
- import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
4
3
  import { z } from "zod";
5
4
  /**
6
5
  * Schema for validating agent invocation payloads.
@@ -94,8 +93,7 @@ export interface AIGNEHTTPServerOptions {
94
93
  */
95
94
  maximumBodySize?: string;
96
95
  }
97
- export interface AIGNEHTTPServerInvokeOptions<U extends UserContext = UserContext> extends Pick<InvokeOptions<U>, "returnProgressChunks" | "userContext" | "memories"> {
98
- callback?: (result: Record<string, unknown>) => PromiseOrValue<void>;
96
+ export interface AIGNEHTTPServerInvokeOptions<U extends UserContext = UserContext> extends Pick<InvokeOptions<U>, "returnProgressChunks" | "userContext" | "memories" | "hooks"> {
99
97
  }
100
98
  /**
101
99
  * AIGNEHTTPServer provides HTTP API access to AIGNE capabilities.
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AIGNEHTTPServer = exports.invokePayloadSchema = void 0;
7
7
  const node_http_1 = require("node:http");
8
8
  const event_stream_js_1 = require("@aigne/core/utils/event-stream.js");
9
- const stream_utils_js_1 = require("@aigne/core/utils/stream-utils.js");
10
9
  const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
11
10
  const content_type_1 = __importDefault(require("content-type"));
12
11
  const raw_body_1 = __importDefault(require("raw-body"));
@@ -83,7 +82,7 @@ class AIGNEHTTPServer {
83
82
  const result = await this._invoke(request, {
84
83
  userContext: opts?.userContext,
85
84
  memories: opts?.memories,
86
- callback: opts?.callback,
85
+ hooks: opts?.hooks,
87
86
  });
88
87
  if (response instanceof node_http_1.ServerResponse) {
89
88
  await this._writeResponse(result, response);
@@ -113,10 +112,10 @@ class AIGNEHTTPServer {
113
112
  returnProgressChunks: opts.returnProgressChunks,
114
113
  userContext: { ...opts.userContext, ...options.userContext },
115
114
  memories: [...(opts.memories ?? []), ...(options.memories ?? [])],
115
+ hooks: options.hooks,
116
116
  };
117
117
  if (!streaming) {
118
118
  const result = await aigne.invoke(agent, input, mergedOptions);
119
- options.callback?.(result);
120
119
  return new Response(JSON.stringify(result), {
121
120
  headers: { "Content-Type": "application/json" },
122
121
  });
@@ -126,12 +125,7 @@ class AIGNEHTTPServer {
126
125
  returnActiveAgent: false,
127
126
  streaming: true,
128
127
  });
129
- const newStream = (0, stream_utils_js_1.onAgentResponseStreamEnd)(stream, {
130
- onResult: async (result) => {
131
- options.callback?.(result);
132
- },
133
- });
134
- return new Response(new event_stream_js_1.AgentResponseStreamSSE(newStream), {
128
+ return new Response(new event_stream_js_1.AgentResponseStreamSSE(stream), {
135
129
  headers: {
136
130
  "Content-Type": "text/event-stream",
137
131
  "Cache-Control": "no-cache",
@@ -1,6 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { AIGNE, InvokeOptions, UserContext } from "@aigne/core";
3
- import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
4
3
  import { z } from "zod";
5
4
  /**
6
5
  * Schema for validating agent invocation payloads.
@@ -94,8 +93,7 @@ export interface AIGNEHTTPServerOptions {
94
93
  */
95
94
  maximumBodySize?: string;
96
95
  }
97
- export interface AIGNEHTTPServerInvokeOptions<U extends UserContext = UserContext> extends Pick<InvokeOptions<U>, "returnProgressChunks" | "userContext" | "memories"> {
98
- callback?: (result: Record<string, unknown>) => PromiseOrValue<void>;
96
+ export interface AIGNEHTTPServerInvokeOptions<U extends UserContext = UserContext> extends Pick<InvokeOptions<U>, "returnProgressChunks" | "userContext" | "memories" | "hooks"> {
99
97
  }
100
98
  /**
101
99
  * AIGNEHTTPServer provides HTTP API access to AIGNE capabilities.
@@ -82,15 +82,20 @@ export class BaseClient {
82
82
  const result = await globalThis.fetch(...args);
83
83
  if (!result.ok) {
84
84
  let message;
85
+ let resultText;
85
86
  try {
86
87
  const text = await result.text();
87
88
  const json = tryOrThrow(() => JSON.parse(text));
88
- message = json?.error?.message || text;
89
+ resultText = text;
90
+ message = json?.error?.message;
89
91
  }
90
92
  catch {
91
93
  // ignore
92
94
  }
93
- throw new Error(`Failed to fetch url ${args[0]} with status ${result.status}: ${message}`);
95
+ if (message) {
96
+ throw new Error(message);
97
+ }
98
+ throw new Error(`Failed to fetch url ${args[0]} with status ${result.status}: ${resultText}`);
94
99
  }
95
100
  return result;
96
101
  }
@@ -1,6 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { AIGNE, InvokeOptions, UserContext } from "@aigne/core";
3
- import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
4
3
  import { z } from "zod";
5
4
  /**
6
5
  * Schema for validating agent invocation payloads.
@@ -94,8 +93,7 @@ export interface AIGNEHTTPServerOptions {
94
93
  */
95
94
  maximumBodySize?: string;
96
95
  }
97
- export interface AIGNEHTTPServerInvokeOptions<U extends UserContext = UserContext> extends Pick<InvokeOptions<U>, "returnProgressChunks" | "userContext" | "memories"> {
98
- callback?: (result: Record<string, unknown>) => PromiseOrValue<void>;
96
+ export interface AIGNEHTTPServerInvokeOptions<U extends UserContext = UserContext> extends Pick<InvokeOptions<U>, "returnProgressChunks" | "userContext" | "memories" | "hooks"> {
99
97
  }
100
98
  /**
101
99
  * AIGNEHTTPServer provides HTTP API access to AIGNE capabilities.
@@ -1,6 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { AgentResponseStreamSSE } from "@aigne/core/utils/event-stream.js";
3
- import { onAgentResponseStreamEnd } from "@aigne/core/utils/stream-utils.js";
4
3
  import { checkArguments, isRecord, tryOrThrow } from "@aigne/core/utils/type-utils.js";
5
4
  import contentType from "content-type";
6
5
  import getRawBody from "raw-body";
@@ -77,7 +76,7 @@ export class AIGNEHTTPServer {
77
76
  const result = await this._invoke(request, {
78
77
  userContext: opts?.userContext,
79
78
  memories: opts?.memories,
80
- callback: opts?.callback,
79
+ hooks: opts?.hooks,
81
80
  });
82
81
  if (response instanceof ServerResponse) {
83
82
  await this._writeResponse(result, response);
@@ -107,10 +106,10 @@ export class AIGNEHTTPServer {
107
106
  returnProgressChunks: opts.returnProgressChunks,
108
107
  userContext: { ...opts.userContext, ...options.userContext },
109
108
  memories: [...(opts.memories ?? []), ...(options.memories ?? [])],
109
+ hooks: options.hooks,
110
110
  };
111
111
  if (!streaming) {
112
112
  const result = await aigne.invoke(agent, input, mergedOptions);
113
- options.callback?.(result);
114
113
  return new Response(JSON.stringify(result), {
115
114
  headers: { "Content-Type": "application/json" },
116
115
  });
@@ -120,12 +119,7 @@ export class AIGNEHTTPServer {
120
119
  returnActiveAgent: false,
121
120
  streaming: true,
122
121
  });
123
- const newStream = onAgentResponseStreamEnd(stream, {
124
- onResult: async (result) => {
125
- options.callback?.(result);
126
- },
127
- });
128
- return new Response(new AgentResponseStreamSSE(newStream), {
122
+ return new Response(new AgentResponseStreamSSE(stream), {
129
123
  headers: {
130
124
  "Content-Type": "text/event-stream",
131
125
  "Cache-Control": "no-cache",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/transport",
3
- "version": "0.11.2",
3
+ "version": "0.12.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"
@@ -45,7 +45,7 @@
45
45
  "content-type": "^1.0.5",
46
46
  "raw-body": "^3.0.0",
47
47
  "zod": "^3.25.67",
48
- "@aigne/openai": "^0.10.11"
48
+ "@aigne/openai": "^0.10.12"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/bun": "^1.2.18",
@@ -60,10 +60,10 @@
60
60
  "rimraf": "^6.0.1",
61
61
  "typescript": "^5.8.3",
62
62
  "uuid": "^11.1.0",
63
- "@aigne/agent-library": "^1.21.11",
64
- "@aigne/default-memory": "^1.0.11",
65
- "@aigne/core": "^1.43.1",
66
- "@aigne/test-utils": "^0.5.19"
63
+ "@aigne/core": "^1.44.0",
64
+ "@aigne/test-utils": "^0.5.20",
65
+ "@aigne/default-memory": "^1.0.12",
66
+ "@aigne/agent-library": "^1.21.12"
67
67
  },
68
68
  "scripts": {
69
69
  "lint": "tsc --noEmit",