@aigne/core 1.18.5 → 1.18.6

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
@@ -5,6 +5,14 @@
5
5
 
6
6
  * add user context support ([#131](https://github.com/AIGNE-io/aigne-framework/issues/131)) ([4dd9d20](https://github.com/AIGNE-io/aigne-framework/commit/4dd9d20953f6ac33933723db56efd9b44bafeb02))
7
7
 
8
+ ## [1.18.6](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.18.5...core-v1.18.6) (2025-06-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **core:** add async generator polyfill for ReadableStream on safari ([#158](https://github.com/AIGNE-io/aigne-framework/issues/158)) ([70ef026](https://github.com/AIGNE-io/aigne-framework/commit/70ef026f413726c369f6a0781efc7f0333735406))
14
+ * **core:** exclude nested skills from final tool list in invokable skill ([#156](https://github.com/AIGNE-io/aigne-framework/issues/156)) ([91645f1](https://github.com/AIGNE-io/aigne-framework/commit/91645f12e79110a00f8f2db8ebc19401ddbd5a80))
15
+
8
16
  ## [1.18.5](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.18.4...core-v1.18.5) (2025-06-06)
9
17
 
10
18
 
@@ -10,3 +10,4 @@ export * from "./aigne/index.js";
10
10
  export * from "./memory/index.js";
11
11
  export * from "./prompt/prompt-builder.js";
12
12
  export * from "./prompt/template.js";
13
+ export * from "./utils/stream-utils.js";
package/lib/cjs/index.js CHANGED
@@ -26,3 +26,4 @@ __exportStar(require("./aigne/index.js"), exports);
26
26
  __exportStar(require("./memory/index.js"), exports);
27
27
  __exportStar(require("./prompt/prompt-builder.js"), exports);
28
28
  __exportStar(require("./prompt/template.js"), exports);
29
+ __exportStar(require("./utils/stream-utils.js"), exports);
@@ -128,8 +128,7 @@ class PromptBuilder {
128
128
  const toolAgents = (0, type_utils_js_1.unique)((options.context?.skills ?? [])
129
129
  .concat(options.agent?.skills ?? [])
130
130
  .concat(options.agent?.memoryAgentsAsTools ? options.agent.memories : [])
131
- // TODO: support nested tools?
132
- .flatMap((i) => (i.isInvokable ? i.skills.concat(i) : i.skills)), (i) => i.name);
131
+ .flatMap((i) => (i.isInvokable ? i : i.skills)), (i) => i.name);
133
132
  const tools = toolAgents.map((i) => ({
134
133
  type: "function",
135
134
  function: {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ReadableStream.prototype.values ??= function ({ preventCancel = false } = {}) {
4
+ const reader = this.getReader();
5
+ return {
6
+ async next() {
7
+ try {
8
+ const result = await reader.read();
9
+ if (result.done) {
10
+ reader.releaseLock();
11
+ }
12
+ return result;
13
+ }
14
+ catch (e) {
15
+ reader.releaseLock();
16
+ throw e;
17
+ }
18
+ },
19
+ async return(value) {
20
+ if (!preventCancel) {
21
+ const cancelPromise = reader.cancel(value);
22
+ reader.releaseLock();
23
+ await cancelPromise;
24
+ }
25
+ else {
26
+ reader.releaseLock();
27
+ }
28
+ return { done: true, value };
29
+ },
30
+ [Symbol.asyncIterator]() {
31
+ return this;
32
+ },
33
+ async [Symbol.asyncDispose]() {
34
+ reader.releaseLock();
35
+ },
36
+ };
37
+ };
38
+ ReadableStream.prototype[Symbol.asyncIterator] ??= ReadableStream.prototype.values;
@@ -1,6 +1,7 @@
1
1
  import { type AgentProcessAsyncGenerator, type AgentResponseChunk, type AgentResponseStream, type Message } from "../agents/agent.js";
2
2
  import type { MESSAGE_KEY } from "../prompt/prompt-builder.js";
3
3
  import { type PromiseOrValue } from "./type-utils.js";
4
+ import "./stream-polyfill.js";
4
5
  export declare function objectToAgentResponseStream<T extends Message>(json: T): AgentResponseStream<T>;
5
6
  export declare function mergeAgentResponseChunk<T extends Message>(output: T, chunk: AgentResponseChunk<T>): T;
6
7
  export declare function agentResponseStreamToObject<T extends Message>(stream: AgentResponseStream<T> | AgentProcessAsyncGenerator<T>): Promise<T>;
@@ -18,6 +18,7 @@ exports.readAllString = readAllString;
18
18
  const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
19
19
  const agent_js_1 = require("../agents/agent.js");
20
20
  const type_utils_js_1 = require("./type-utils.js");
21
+ require("./stream-polyfill.js");
21
22
  function objectToAgentResponseStream(json) {
22
23
  return new ReadableStream({
23
24
  pull(controller) {
@@ -10,3 +10,4 @@ export * from "./aigne/index.js";
10
10
  export * from "./memory/index.js";
11
11
  export * from "./prompt/prompt-builder.js";
12
12
  export * from "./prompt/template.js";
13
+ export * from "./utils/stream-utils.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { type AgentProcessAsyncGenerator, type AgentResponseChunk, type AgentResponseStream, type Message } from "../agents/agent.js";
2
2
  import type { MESSAGE_KEY } from "../prompt/prompt-builder.js";
3
3
  import { type PromiseOrValue } from "./type-utils.js";
4
+ import "./stream-polyfill.js";
4
5
  export declare function objectToAgentResponseStream<T extends Message>(json: T): AgentResponseStream<T>;
5
6
  export declare function mergeAgentResponseChunk<T extends Message>(output: T, chunk: AgentResponseChunk<T>): T;
6
7
  export declare function agentResponseStreamToObject<T extends Message>(stream: AgentResponseStream<T> | AgentProcessAsyncGenerator<T>): Promise<T>;
@@ -10,3 +10,4 @@ export * from "./aigne/index.js";
10
10
  export * from "./memory/index.js";
11
11
  export * from "./prompt/prompt-builder.js";
12
12
  export * from "./prompt/template.js";
13
+ export * from "./utils/stream-utils.js";
package/lib/esm/index.js CHANGED
@@ -10,3 +10,4 @@ export * from "./aigne/index.js";
10
10
  export * from "./memory/index.js";
11
11
  export * from "./prompt/prompt-builder.js";
12
12
  export * from "./prompt/template.js";
13
+ export * from "./utils/stream-utils.js";
@@ -123,8 +123,7 @@ export class PromptBuilder {
123
123
  const toolAgents = unique((options.context?.skills ?? [])
124
124
  .concat(options.agent?.skills ?? [])
125
125
  .concat(options.agent?.memoryAgentsAsTools ? options.agent.memories : [])
126
- // TODO: support nested tools?
127
- .flatMap((i) => (i.isInvokable ? i.skills.concat(i) : i.skills)), (i) => i.name);
126
+ .flatMap((i) => (i.isInvokable ? i : i.skills)), (i) => i.name);
128
127
  const tools = toolAgents.map((i) => ({
129
128
  type: "function",
130
129
  function: {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ ReadableStream.prototype.values ??= function ({ preventCancel = false } = {}) {
2
+ const reader = this.getReader();
3
+ return {
4
+ async next() {
5
+ try {
6
+ const result = await reader.read();
7
+ if (result.done) {
8
+ reader.releaseLock();
9
+ }
10
+ return result;
11
+ }
12
+ catch (e) {
13
+ reader.releaseLock();
14
+ throw e;
15
+ }
16
+ },
17
+ async return(value) {
18
+ if (!preventCancel) {
19
+ const cancelPromise = reader.cancel(value);
20
+ reader.releaseLock();
21
+ await cancelPromise;
22
+ }
23
+ else {
24
+ reader.releaseLock();
25
+ }
26
+ return { done: true, value };
27
+ },
28
+ [Symbol.asyncIterator]() {
29
+ return this;
30
+ },
31
+ async [Symbol.asyncDispose]() {
32
+ reader.releaseLock();
33
+ },
34
+ };
35
+ };
36
+ ReadableStream.prototype[Symbol.asyncIterator] ??= ReadableStream.prototype.values;
37
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { type AgentProcessAsyncGenerator, type AgentResponseChunk, type AgentResponseStream, type Message } from "../agents/agent.js";
2
2
  import type { MESSAGE_KEY } from "../prompt/prompt-builder.js";
3
3
  import { type PromiseOrValue } from "./type-utils.js";
4
+ import "./stream-polyfill.js";
4
5
  export declare function objectToAgentResponseStream<T extends Message>(json: T): AgentResponseStream<T>;
5
6
  export declare function mergeAgentResponseChunk<T extends Message>(output: T, chunk: AgentResponseChunk<T>): T;
6
7
  export declare function agentResponseStreamToObject<T extends Message>(stream: AgentResponseStream<T> | AgentProcessAsyncGenerator<T>): Promise<T>;
@@ -1,6 +1,7 @@
1
1
  import equal from "fast-deep-equal";
2
2
  import { isEmptyChunk, } from "../agents/agent.js";
3
3
  import { omitBy } from "./type-utils.js";
4
+ import "./stream-polyfill.js";
4
5
  export function objectToAgentResponseStream(json) {
5
6
  return new ReadableStream({
6
7
  pull(controller) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.18.5",
3
+ "version": "1.18.6",
4
4
  "description": "AIGNE core library for building AI-powered applications",
5
5
  "publishConfig": {
6
6
  "access": "public"