@aigne/core 1.50.1 → 1.51.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/lib/cjs/agents/agent.d.ts +3 -0
- package/lib/cjs/agents/agent.js +2 -0
- package/lib/cjs/agents/chat-model.js +2 -0
- package/lib/cjs/aigne/usage.d.ts +2 -0
- package/lib/cjs/aigne/usage.js +14 -0
- package/lib/cjs/loader/agent-yaml.d.ts +2 -1
- package/lib/cjs/loader/agent-yaml.js +1 -0
- package/lib/dts/agents/agent.d.ts +3 -0
- package/lib/dts/aigne/usage.d.ts +2 -0
- package/lib/dts/loader/agent-yaml.d.ts +2 -1
- package/lib/esm/agents/agent.d.ts +3 -0
- package/lib/esm/agents/agent.js +2 -0
- package/lib/esm/agents/chat-model.js +2 -0
- package/lib/esm/aigne/usage.d.ts +2 -0
- package/lib/esm/aigne/usage.js +13 -0
- package/lib/esm/loader/agent-yaml.d.ts +2 -1
- package/lib/esm/loader/agent-yaml.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.51.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.50.1...core-v1.51.0) (2025-08-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **cli:** support hide or collapse task for agents in CLI ([#381](https://github.com/AIGNE-io/aigne-framework/issues/381)) ([05b372d](https://github.com/AIGNE-io/aigne-framework/commit/05b372d431a862f7cdfa2a90bb4b7b2379bf97ab))
|
|
9
|
+
|
|
3
10
|
## [1.50.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.50.0...core-v1.50.1) (2025-08-16)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -33,6 +33,7 @@ export type SubscribeTopic = string | string[];
|
|
|
33
33
|
* @template O The agent output message type
|
|
34
34
|
*/
|
|
35
35
|
export type PublishTopic<O extends Message> = string | string[] | ((output: O) => PromiseOrValue<Nullish<string | string[]>>);
|
|
36
|
+
export type TaskRenderMode = "hide" | "collapse";
|
|
36
37
|
/**
|
|
37
38
|
* Configuration options for an agent
|
|
38
39
|
*
|
|
@@ -73,6 +74,7 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
|
|
|
73
74
|
*/
|
|
74
75
|
description?: string;
|
|
75
76
|
taskTitle?: string | ((input: I) => PromiseOrValue<string | undefined>);
|
|
77
|
+
taskRenderMode?: TaskRenderMode;
|
|
76
78
|
/**
|
|
77
79
|
* Zod schema defining the input message structure
|
|
78
80
|
*
|
|
@@ -259,6 +261,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
259
261
|
readonly description?: string;
|
|
260
262
|
taskTitle?: string | ((input: Message) => PromiseOrValue<string | undefined>);
|
|
261
263
|
renderTaskTitle(input: I): Promise<string | undefined>;
|
|
264
|
+
taskRenderMode?: TaskRenderMode;
|
|
262
265
|
private readonly _inputSchema?;
|
|
263
266
|
defaultInput?: Partial<{
|
|
264
267
|
[key in keyof I]: {
|
package/lib/cjs/agents/agent.js
CHANGED
|
@@ -111,6 +111,7 @@ class Agent {
|
|
|
111
111
|
this.alias = options.alias;
|
|
112
112
|
this.description = options.description;
|
|
113
113
|
this.taskTitle = options.taskTitle;
|
|
114
|
+
this.taskRenderMode = options.taskRenderMode;
|
|
114
115
|
if (inputSchema)
|
|
115
116
|
checkAgentInputOutputSchema(inputSchema);
|
|
116
117
|
if (outputSchema)
|
|
@@ -209,6 +210,7 @@ class Agent {
|
|
|
209
210
|
return;
|
|
210
211
|
return nunjucks_1.default.renderString(s, { ...input });
|
|
211
212
|
}
|
|
213
|
+
taskRenderMode;
|
|
212
214
|
_inputSchema;
|
|
213
215
|
defaultInput;
|
|
214
216
|
_outputSchema;
|
|
@@ -138,6 +138,8 @@ class ChatModel extends agent_js_1.Agent {
|
|
|
138
138
|
if (usage) {
|
|
139
139
|
options.context.usage.outputTokens += usage.outputTokens;
|
|
140
140
|
options.context.usage.inputTokens += usage.inputTokens;
|
|
141
|
+
if (usage.aigneHubCredits)
|
|
142
|
+
options.context.usage.aigneHubCredits += usage.aigneHubCredits;
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
}
|
package/lib/cjs/aigne/usage.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export interface ContextUsage {
|
|
5
5
|
inputTokens: number;
|
|
6
6
|
outputTokens: number;
|
|
7
|
+
aigneHubCredits: number;
|
|
7
8
|
agentCalls: number;
|
|
8
9
|
duration: number;
|
|
9
10
|
}
|
|
@@ -19,3 +20,4 @@ export interface ContextLimits {
|
|
|
19
20
|
maxAgentInvokes?: number;
|
|
20
21
|
timeout?: number;
|
|
21
22
|
}
|
|
23
|
+
export declare function mergeContextUsage(usage: ContextUsage, additional: Partial<ContextUsage>): void;
|
package/lib/cjs/aigne/usage.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newEmptyContextUsage = newEmptyContextUsage;
|
|
4
|
+
exports.mergeContextUsage = mergeContextUsage;
|
|
4
5
|
/**
|
|
5
6
|
* @hidden
|
|
6
7
|
*/
|
|
@@ -8,7 +9,20 @@ function newEmptyContextUsage() {
|
|
|
8
9
|
return {
|
|
9
10
|
inputTokens: 0,
|
|
10
11
|
outputTokens: 0,
|
|
12
|
+
aigneHubCredits: 0,
|
|
11
13
|
agentCalls: 0,
|
|
12
14
|
duration: 0,
|
|
13
15
|
};
|
|
14
16
|
}
|
|
17
|
+
function mergeContextUsage(usage, additional) {
|
|
18
|
+
if (additional.inputTokens)
|
|
19
|
+
usage.inputTokens += additional.inputTokens;
|
|
20
|
+
if (additional.outputTokens)
|
|
21
|
+
usage.outputTokens += additional.outputTokens;
|
|
22
|
+
if (additional.aigneHubCredits)
|
|
23
|
+
usage.aigneHubCredits += additional.aigneHubCredits;
|
|
24
|
+
if (additional.agentCalls)
|
|
25
|
+
usage.agentCalls += additional.agentCalls;
|
|
26
|
+
if (additional.duration)
|
|
27
|
+
usage.duration += additional.duration;
|
|
28
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZodType } from "zod";
|
|
2
|
-
import type { AgentHooks, FunctionAgentFn } from "../agents/agent.js";
|
|
2
|
+
import type { AgentHooks, FunctionAgentFn, TaskRenderMode } from "../agents/agent.js";
|
|
3
3
|
import { AIAgentToolChoice } from "../agents/ai-agent.js";
|
|
4
4
|
import { ProcessMode, type ReflectionMode } from "../agents/team-agent.js";
|
|
5
5
|
export interface HooksSchema {
|
|
@@ -21,6 +21,7 @@ export interface BaseAgentSchema {
|
|
|
21
21
|
name?: string;
|
|
22
22
|
description?: string;
|
|
23
23
|
taskTitle?: string;
|
|
24
|
+
taskRenderMode?: TaskRenderMode;
|
|
24
25
|
inputSchema?: ZodType<Record<string, any>>;
|
|
25
26
|
defaultInput?: Record<string, any>;
|
|
26
27
|
outputSchema?: ZodType<Record<string, any>>;
|
|
@@ -36,6 +36,7 @@ async function parseAgentFile(path, data) {
|
|
|
36
36
|
alias: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
|
|
37
37
|
description: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
38
38
|
taskTitle: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
39
|
+
taskRenderMode: (0, schema_js_1.optionalize)(zod_1.z.union([zod_1.z.literal("hide"), zod_1.z.literal("collapse")])),
|
|
39
40
|
inputSchema: (0, schema_js_1.optionalize)((0, schema_js_1.inputOutputSchema)({ path })).transform((v) => v ? (0, json_schema_to_zod_1.jsonSchemaToZod)(v) : undefined),
|
|
40
41
|
defaultInput: (0, schema_js_1.optionalize)(schema_js_1.defaultInputSchema),
|
|
41
42
|
outputSchema: (0, schema_js_1.optionalize)((0, schema_js_1.inputOutputSchema)({ path })).transform((v) => v ? (0, json_schema_to_zod_1.jsonSchemaToZod)(v) : undefined),
|
|
@@ -33,6 +33,7 @@ export type SubscribeTopic = string | string[];
|
|
|
33
33
|
* @template O The agent output message type
|
|
34
34
|
*/
|
|
35
35
|
export type PublishTopic<O extends Message> = string | string[] | ((output: O) => PromiseOrValue<Nullish<string | string[]>>);
|
|
36
|
+
export type TaskRenderMode = "hide" | "collapse";
|
|
36
37
|
/**
|
|
37
38
|
* Configuration options for an agent
|
|
38
39
|
*
|
|
@@ -73,6 +74,7 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
|
|
|
73
74
|
*/
|
|
74
75
|
description?: string;
|
|
75
76
|
taskTitle?: string | ((input: I) => PromiseOrValue<string | undefined>);
|
|
77
|
+
taskRenderMode?: TaskRenderMode;
|
|
76
78
|
/**
|
|
77
79
|
* Zod schema defining the input message structure
|
|
78
80
|
*
|
|
@@ -259,6 +261,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
259
261
|
readonly description?: string;
|
|
260
262
|
taskTitle?: string | ((input: Message) => PromiseOrValue<string | undefined>);
|
|
261
263
|
renderTaskTitle(input: I): Promise<string | undefined>;
|
|
264
|
+
taskRenderMode?: TaskRenderMode;
|
|
262
265
|
private readonly _inputSchema?;
|
|
263
266
|
defaultInput?: Partial<{
|
|
264
267
|
[key in keyof I]: {
|
package/lib/dts/aigne/usage.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export interface ContextUsage {
|
|
5
5
|
inputTokens: number;
|
|
6
6
|
outputTokens: number;
|
|
7
|
+
aigneHubCredits: number;
|
|
7
8
|
agentCalls: number;
|
|
8
9
|
duration: number;
|
|
9
10
|
}
|
|
@@ -19,3 +20,4 @@ export interface ContextLimits {
|
|
|
19
20
|
maxAgentInvokes?: number;
|
|
20
21
|
timeout?: number;
|
|
21
22
|
}
|
|
23
|
+
export declare function mergeContextUsage(usage: ContextUsage, additional: Partial<ContextUsage>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZodType } from "zod";
|
|
2
|
-
import type { AgentHooks, FunctionAgentFn } from "../agents/agent.js";
|
|
2
|
+
import type { AgentHooks, FunctionAgentFn, TaskRenderMode } from "../agents/agent.js";
|
|
3
3
|
import { AIAgentToolChoice } from "../agents/ai-agent.js";
|
|
4
4
|
import { ProcessMode, type ReflectionMode } from "../agents/team-agent.js";
|
|
5
5
|
export interface HooksSchema {
|
|
@@ -21,6 +21,7 @@ export interface BaseAgentSchema {
|
|
|
21
21
|
name?: string;
|
|
22
22
|
description?: string;
|
|
23
23
|
taskTitle?: string;
|
|
24
|
+
taskRenderMode?: TaskRenderMode;
|
|
24
25
|
inputSchema?: ZodType<Record<string, any>>;
|
|
25
26
|
defaultInput?: Record<string, any>;
|
|
26
27
|
outputSchema?: ZodType<Record<string, any>>;
|
|
@@ -33,6 +33,7 @@ export type SubscribeTopic = string | string[];
|
|
|
33
33
|
* @template O The agent output message type
|
|
34
34
|
*/
|
|
35
35
|
export type PublishTopic<O extends Message> = string | string[] | ((output: O) => PromiseOrValue<Nullish<string | string[]>>);
|
|
36
|
+
export type TaskRenderMode = "hide" | "collapse";
|
|
36
37
|
/**
|
|
37
38
|
* Configuration options for an agent
|
|
38
39
|
*
|
|
@@ -73,6 +74,7 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
|
|
|
73
74
|
*/
|
|
74
75
|
description?: string;
|
|
75
76
|
taskTitle?: string | ((input: I) => PromiseOrValue<string | undefined>);
|
|
77
|
+
taskRenderMode?: TaskRenderMode;
|
|
76
78
|
/**
|
|
77
79
|
* Zod schema defining the input message structure
|
|
78
80
|
*
|
|
@@ -259,6 +261,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
259
261
|
readonly description?: string;
|
|
260
262
|
taskTitle?: string | ((input: Message) => PromiseOrValue<string | undefined>);
|
|
261
263
|
renderTaskTitle(input: I): Promise<string | undefined>;
|
|
264
|
+
taskRenderMode?: TaskRenderMode;
|
|
262
265
|
private readonly _inputSchema?;
|
|
263
266
|
defaultInput?: Partial<{
|
|
264
267
|
[key in keyof I]: {
|
package/lib/esm/agents/agent.js
CHANGED
|
@@ -63,6 +63,7 @@ export class Agent {
|
|
|
63
63
|
this.alias = options.alias;
|
|
64
64
|
this.description = options.description;
|
|
65
65
|
this.taskTitle = options.taskTitle;
|
|
66
|
+
this.taskRenderMode = options.taskRenderMode;
|
|
66
67
|
if (inputSchema)
|
|
67
68
|
checkAgentInputOutputSchema(inputSchema);
|
|
68
69
|
if (outputSchema)
|
|
@@ -161,6 +162,7 @@ export class Agent {
|
|
|
161
162
|
return;
|
|
162
163
|
return nunjucks.renderString(s, { ...input });
|
|
163
164
|
}
|
|
165
|
+
taskRenderMode;
|
|
164
166
|
_inputSchema;
|
|
165
167
|
defaultInput;
|
|
166
168
|
_outputSchema;
|
|
@@ -135,6 +135,8 @@ export class ChatModel extends Agent {
|
|
|
135
135
|
if (usage) {
|
|
136
136
|
options.context.usage.outputTokens += usage.outputTokens;
|
|
137
137
|
options.context.usage.inputTokens += usage.inputTokens;
|
|
138
|
+
if (usage.aigneHubCredits)
|
|
139
|
+
options.context.usage.aigneHubCredits += usage.aigneHubCredits;
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
}
|
package/lib/esm/aigne/usage.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export interface ContextUsage {
|
|
5
5
|
inputTokens: number;
|
|
6
6
|
outputTokens: number;
|
|
7
|
+
aigneHubCredits: number;
|
|
7
8
|
agentCalls: number;
|
|
8
9
|
duration: number;
|
|
9
10
|
}
|
|
@@ -19,3 +20,4 @@ export interface ContextLimits {
|
|
|
19
20
|
maxAgentInvokes?: number;
|
|
20
21
|
timeout?: number;
|
|
21
22
|
}
|
|
23
|
+
export declare function mergeContextUsage(usage: ContextUsage, additional: Partial<ContextUsage>): void;
|
package/lib/esm/aigne/usage.js
CHANGED
|
@@ -5,7 +5,20 @@ export function newEmptyContextUsage() {
|
|
|
5
5
|
return {
|
|
6
6
|
inputTokens: 0,
|
|
7
7
|
outputTokens: 0,
|
|
8
|
+
aigneHubCredits: 0,
|
|
8
9
|
agentCalls: 0,
|
|
9
10
|
duration: 0,
|
|
10
11
|
};
|
|
11
12
|
}
|
|
13
|
+
export function mergeContextUsage(usage, additional) {
|
|
14
|
+
if (additional.inputTokens)
|
|
15
|
+
usage.inputTokens += additional.inputTokens;
|
|
16
|
+
if (additional.outputTokens)
|
|
17
|
+
usage.outputTokens += additional.outputTokens;
|
|
18
|
+
if (additional.aigneHubCredits)
|
|
19
|
+
usage.aigneHubCredits += additional.aigneHubCredits;
|
|
20
|
+
if (additional.agentCalls)
|
|
21
|
+
usage.agentCalls += additional.agentCalls;
|
|
22
|
+
if (additional.duration)
|
|
23
|
+
usage.duration += additional.duration;
|
|
24
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZodType } from "zod";
|
|
2
|
-
import type { AgentHooks, FunctionAgentFn } from "../agents/agent.js";
|
|
2
|
+
import type { AgentHooks, FunctionAgentFn, TaskRenderMode } from "../agents/agent.js";
|
|
3
3
|
import { AIAgentToolChoice } from "../agents/ai-agent.js";
|
|
4
4
|
import { ProcessMode, type ReflectionMode } from "../agents/team-agent.js";
|
|
5
5
|
export interface HooksSchema {
|
|
@@ -21,6 +21,7 @@ export interface BaseAgentSchema {
|
|
|
21
21
|
name?: string;
|
|
22
22
|
description?: string;
|
|
23
23
|
taskTitle?: string;
|
|
24
|
+
taskRenderMode?: TaskRenderMode;
|
|
24
25
|
inputSchema?: ZodType<Record<string, any>>;
|
|
25
26
|
defaultInput?: Record<string, any>;
|
|
26
27
|
outputSchema?: ZodType<Record<string, any>>;
|
|
@@ -32,6 +32,7 @@ export async function parseAgentFile(path, data) {
|
|
|
32
32
|
alias: optionalize(z.array(z.string())),
|
|
33
33
|
description: optionalize(z.string()),
|
|
34
34
|
taskTitle: optionalize(z.string()),
|
|
35
|
+
taskRenderMode: optionalize(z.union([z.literal("hide"), z.literal("collapse")])),
|
|
35
36
|
inputSchema: optionalize(inputOutputSchema({ path })).transform((v) => v ? jsonSchemaToZod(v) : undefined),
|
|
36
37
|
defaultInput: optionalize(defaultInputSchema),
|
|
37
38
|
outputSchema: optionalize(inputOutputSchema({ path })).transform((v) => v ? jsonSchemaToZod(v) : undefined),
|