@aigne/core 1.43.0 → 1.44.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
@@ -12,6 +12,25 @@
12
12
  * dependencies
13
13
  * @aigne/observability bumped to 0.1.0
14
14
 
15
+ ## [1.44.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.43.1...core-v1.44.0) (2025-08-05)
16
+
17
+
18
+ ### Features
19
+
20
+ * 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))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **cli:** improve CLI prompts and output handling ([#318](https://github.com/AIGNE-io/aigne-framework/issues/318)) ([681ee79](https://github.com/AIGNE-io/aigne-framework/commit/681ee79e9b18aed5a977a0a418c2d9df20a7297c))
26
+
27
+ ## [1.43.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.43.0...core-v1.43.1) (2025-08-05)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **core:** filter empty memory content ([#312](https://github.com/AIGNE-io/aigne-framework/issues/312)) ([39dd77a](https://github.com/AIGNE-io/aigne-framework/commit/39dd77a68154d51c7a132adccd9f21b8bc461be0))
33
+
15
34
  ## [1.43.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.42.0...core-v1.43.0) (2025-08-04)
16
35
 
17
36
 
package/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @aigne/core
2
2
 
3
+ <p align="center">
4
+ <picture>
5
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo-dark.svg" media="(prefers-color-scheme: dark)">
6
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" media="(prefers-color-scheme: light)">
7
+ <img src="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" alt="AIGNE Logo" width="400" />
8
+ </picture>
9
+ </p>
10
+
3
11
  [![GitHub star chart](https://img.shields.io/github/stars/AIGNE-io/aigne-framework?style=flat-square)](https://star-history.com/#AIGNE-io/aigne-framework)
4
12
  [![Open Issues](https://img.shields.io/github/issues-raw/AIGNE-io/aigne-framework?style=flat-square)](https://github.com/AIGNE-io/aigne-framework/issues)
5
13
  [![codecov](https://codecov.io/gh/AIGNE-io/aigne-framework/graph/badge.svg?token=DO07834RQL)](https://codecov.io/gh/AIGNE-io/aigne-framework)
@@ -450,14 +450,14 @@ class Agent {
450
450
  let finalOutput = this.includeInputInOutput ? { ...input, ...parsedOutput } : parsedOutput;
451
451
  await this.postprocess(input, finalOutput, options);
452
452
  logger_js_1.logger.debug("Invoke agent %s succeed with output: %O", this.name, finalOutput);
453
- if (!this.disableEvents)
454
- context.emit("agentSucceed", { agent: this, output: finalOutput });
455
453
  let o = await this.callHooks("onSuccess", { input, output: finalOutput }, options);
456
454
  if (o?.output)
457
455
  finalOutput = o.output;
458
456
  o = await this.callHooks("onEnd", { input, output: finalOutput }, options);
459
457
  if (o?.output)
460
458
  finalOutput = o.output;
459
+ if (!this.disableEvents)
460
+ context.emit("agentSucceed", { agent: this, output: finalOutput });
461
461
  return finalOutput;
462
462
  }
463
463
  /**
@@ -381,4 +381,8 @@ export interface ChatModelOutputUsage {
381
381
  * Number of output tokens
382
382
  */
383
383
  outputTokens: number;
384
+ /**
385
+ * AIGNE Hub credit usage
386
+ */
387
+ aigneHubCredits?: number;
384
388
  }
@@ -214,6 +214,7 @@ const chatModelOutputToolCallSchema = zod_1.z.object({
214
214
  const chatModelOutputUsageSchema = zod_1.z.object({
215
215
  inputTokens: zod_1.z.number(),
216
216
  outputTokens: zod_1.z.number(),
217
+ aigneHubCredits: zod_1.z.number().optional(),
217
218
  });
218
219
  const chatModelOutputSchema = zod_1.z.object({
219
220
  text: zod_1.z.string().optional(),
@@ -11,4 +11,6 @@ export * from "./aigne/index.js";
11
11
  export * from "./memory/index.js";
12
12
  export * from "./prompt/prompt-builder.js";
13
13
  export * from "./prompt/template.js";
14
+ export * from "./utils/json-utils.js";
15
+ export * from "./utils/role-utils.js";
14
16
  export * from "./utils/stream-utils.js";
package/lib/cjs/index.js CHANGED
@@ -27,4 +27,6 @@ __exportStar(require("./aigne/index.js"), exports);
27
27
  __exportStar(require("./memory/index.js"), exports);
28
28
  __exportStar(require("./prompt/prompt-builder.js"), exports);
29
29
  __exportStar(require("./prompt/template.js"), exports);
30
+ __exportStar(require("./utils/json-utils.js"), exports);
31
+ __exportStar(require("./utils/role-utils.js"), exports);
30
32
  __exportStar(require("./utils/stream-utils.js"), exports);
@@ -110,7 +110,12 @@ class PromptBuilder {
110
110
  const stringOrStringify = (value) => typeof value === "string" ? value : (0, yaml_1.stringify)(value);
111
111
  for (const { content } of memories) {
112
112
  if ((0, type_utils_js_1.isRecord)(content) && "input" in content && "output" in content) {
113
- messages.push({ role: "user", content: stringOrStringify(content.input) }, { role: "agent", content: stringOrStringify(content.output) });
113
+ if (!(0, type_utils_js_1.isNil)(content.input) && content.input !== "") {
114
+ messages.push({ role: "user", content: stringOrStringify(content.input) });
115
+ }
116
+ if (!(0, type_utils_js_1.isNil)(content.output) && content.output !== "") {
117
+ messages.push({ role: "agent", content: stringOrStringify(content.output) });
118
+ }
114
119
  }
115
120
  else {
116
121
  other.push(content);
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Safely parses JSON text using jaison library which handles malformed JSON better than JSON.parse
3
+ *
4
+ * @param text - The text to parse as JSON
5
+ * @returns Parsed JSON object or null if parsing fails
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const result = safeParseJSON('{"key": "value"}');
10
+ * console.log(result); // { key: "value" }
11
+ *
12
+ * const malformed = safeParseJSON('{"key": "value"'); // Missing closing brace
13
+ * console.log(malformed); // null
14
+ * ```
15
+ */
16
+ export declare function safeParseJSON(text: string): any;
17
+ /**
18
+ * Safely stringifies a value to JSON, handling errors gracefully
19
+ *
20
+ * @param value - The value to stringify
21
+ * @param space - Optional spacing for pretty printing
22
+ * @returns JSON string or null if stringification fails
23
+ */
24
+ export declare function safeStringifyJSON(value: any, space?: number): string | null;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.safeParseJSON = safeParseJSON;
7
+ exports.safeStringifyJSON = safeStringifyJSON;
8
+ const jaison_1 = __importDefault(require("jaison"));
9
+ /**
10
+ * Safely parses JSON text using jaison library which handles malformed JSON better than JSON.parse
11
+ *
12
+ * @param text - The text to parse as JSON
13
+ * @returns Parsed JSON object or null if parsing fails
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const result = safeParseJSON('{"key": "value"}');
18
+ * console.log(result); // { key: "value" }
19
+ *
20
+ * const malformed = safeParseJSON('{"key": "value"'); // Missing closing brace
21
+ * console.log(malformed); // null
22
+ * ```
23
+ */
24
+ function safeParseJSON(text) {
25
+ if (!text)
26
+ return null;
27
+ try {
28
+ return (0, jaison_1.default)(text);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ /**
35
+ * Safely stringifies a value to JSON, handling errors gracefully
36
+ *
37
+ * @param value - The value to stringify
38
+ * @param space - Optional spacing for pretty printing
39
+ * @returns JSON string or null if stringification fails
40
+ */
41
+ function safeStringifyJSON(value, space) {
42
+ try {
43
+ return JSON.stringify(value, null, space);
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ }
@@ -1,4 +1,5 @@
1
1
  export declare enum LogLevel {
2
+ SILENT = "silent",
2
3
  ERROR = "error",
3
4
  WARN = "warn",
4
5
  INFO = "info",
@@ -9,6 +9,7 @@ const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
9
9
  const debug_1 = __importDefault(require("debug"));
10
10
  var LogLevel;
11
11
  (function (LogLevel) {
12
+ LogLevel["SILENT"] = "silent";
12
13
  LogLevel["ERROR"] = "error";
13
14
  LogLevel["WARN"] = "warn";
14
15
  LogLevel["INFO"] = "info";
@@ -76,5 +77,5 @@ class Logger {
76
77
  exports.Logger = Logger;
77
78
  exports.logger = new Logger({
78
79
  ns: "aigne:core",
79
- level: LogLevel.INFO,
80
+ level: LogLevel.SILENT,
80
81
  });
@@ -0,0 +1,31 @@
1
+ import type { Role } from "../agents/chat-model.js";
2
+ /**
3
+ * Standard role mapping for most chat model providers
4
+ * Maps AIGNE framework roles to common provider role names
5
+ */
6
+ export declare const STANDARD_ROLE_MAP: {
7
+ [key in Role]: string;
8
+ };
9
+ /**
10
+ * Creates a role mapper function for a specific provider
11
+ *
12
+ * @param roleMap - Custom role mapping for the provider
13
+ * @returns Function that maps AIGNE roles to provider roles
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // For standard providers (OpenAI, Anthropic, etc.)
18
+ * const mapRole = createRoleMapper(STANDARD_ROLE_MAP);
19
+ *
20
+ * // For providers with different role names
21
+ * const customMap = { ...STANDARD_ROLE_MAP, agent: "bot" };
22
+ * const customMapper = createRoleMapper(customMap);
23
+ * ```
24
+ */
25
+ export declare function createRoleMapper<T extends string>(roleMap: {
26
+ [key in Role]: T;
27
+ }): (role: Role) => T;
28
+ /**
29
+ * Standard role mapper using the default role mapping
30
+ */
31
+ export declare const mapStandardRole: (role: Role) => string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapStandardRole = exports.STANDARD_ROLE_MAP = void 0;
4
+ exports.createRoleMapper = createRoleMapper;
5
+ /**
6
+ * Standard role mapping for most chat model providers
7
+ * Maps AIGNE framework roles to common provider role names
8
+ */
9
+ exports.STANDARD_ROLE_MAP = {
10
+ system: "system",
11
+ user: "user",
12
+ agent: "assistant",
13
+ tool: "tool",
14
+ };
15
+ /**
16
+ * Creates a role mapper function for a specific provider
17
+ *
18
+ * @param roleMap - Custom role mapping for the provider
19
+ * @returns Function that maps AIGNE roles to provider roles
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // For standard providers (OpenAI, Anthropic, etc.)
24
+ * const mapRole = createRoleMapper(STANDARD_ROLE_MAP);
25
+ *
26
+ * // For providers with different role names
27
+ * const customMap = { ...STANDARD_ROLE_MAP, agent: "bot" };
28
+ * const customMapper = createRoleMapper(customMap);
29
+ * ```
30
+ */
31
+ function createRoleMapper(roleMap) {
32
+ return (role) => roleMap[role];
33
+ }
34
+ /**
35
+ * Standard role mapper using the default role mapping
36
+ */
37
+ exports.mapStandardRole = createRoleMapper(exports.STANDARD_ROLE_MAP);
@@ -381,4 +381,8 @@ export interface ChatModelOutputUsage {
381
381
  * Number of output tokens
382
382
  */
383
383
  outputTokens: number;
384
+ /**
385
+ * AIGNE Hub credit usage
386
+ */
387
+ aigneHubCredits?: number;
384
388
  }
@@ -11,4 +11,6 @@ export * from "./aigne/index.js";
11
11
  export * from "./memory/index.js";
12
12
  export * from "./prompt/prompt-builder.js";
13
13
  export * from "./prompt/template.js";
14
+ export * from "./utils/json-utils.js";
15
+ export * from "./utils/role-utils.js";
14
16
  export * from "./utils/stream-utils.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Safely parses JSON text using jaison library which handles malformed JSON better than JSON.parse
3
+ *
4
+ * @param text - The text to parse as JSON
5
+ * @returns Parsed JSON object or null if parsing fails
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const result = safeParseJSON('{"key": "value"}');
10
+ * console.log(result); // { key: "value" }
11
+ *
12
+ * const malformed = safeParseJSON('{"key": "value"'); // Missing closing brace
13
+ * console.log(malformed); // null
14
+ * ```
15
+ */
16
+ export declare function safeParseJSON(text: string): any;
17
+ /**
18
+ * Safely stringifies a value to JSON, handling errors gracefully
19
+ *
20
+ * @param value - The value to stringify
21
+ * @param space - Optional spacing for pretty printing
22
+ * @returns JSON string or null if stringification fails
23
+ */
24
+ export declare function safeStringifyJSON(value: any, space?: number): string | null;
@@ -1,4 +1,5 @@
1
1
  export declare enum LogLevel {
2
+ SILENT = "silent",
2
3
  ERROR = "error",
3
4
  WARN = "warn",
4
5
  INFO = "info",
@@ -0,0 +1,31 @@
1
+ import type { Role } from "../agents/chat-model.js";
2
+ /**
3
+ * Standard role mapping for most chat model providers
4
+ * Maps AIGNE framework roles to common provider role names
5
+ */
6
+ export declare const STANDARD_ROLE_MAP: {
7
+ [key in Role]: string;
8
+ };
9
+ /**
10
+ * Creates a role mapper function for a specific provider
11
+ *
12
+ * @param roleMap - Custom role mapping for the provider
13
+ * @returns Function that maps AIGNE roles to provider roles
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // For standard providers (OpenAI, Anthropic, etc.)
18
+ * const mapRole = createRoleMapper(STANDARD_ROLE_MAP);
19
+ *
20
+ * // For providers with different role names
21
+ * const customMap = { ...STANDARD_ROLE_MAP, agent: "bot" };
22
+ * const customMapper = createRoleMapper(customMap);
23
+ * ```
24
+ */
25
+ export declare function createRoleMapper<T extends string>(roleMap: {
26
+ [key in Role]: T;
27
+ }): (role: Role) => T;
28
+ /**
29
+ * Standard role mapper using the default role mapping
30
+ */
31
+ export declare const mapStandardRole: (role: Role) => string;
@@ -405,14 +405,14 @@ export class Agent {
405
405
  let finalOutput = this.includeInputInOutput ? { ...input, ...parsedOutput } : parsedOutput;
406
406
  await this.postprocess(input, finalOutput, options);
407
407
  logger.debug("Invoke agent %s succeed with output: %O", this.name, finalOutput);
408
- if (!this.disableEvents)
409
- context.emit("agentSucceed", { agent: this, output: finalOutput });
410
408
  let o = await this.callHooks("onSuccess", { input, output: finalOutput }, options);
411
409
  if (o?.output)
412
410
  finalOutput = o.output;
413
411
  o = await this.callHooks("onEnd", { input, output: finalOutput }, options);
414
412
  if (o?.output)
415
413
  finalOutput = o.output;
414
+ if (!this.disableEvents)
415
+ context.emit("agentSucceed", { agent: this, output: finalOutput });
416
416
  return finalOutput;
417
417
  }
418
418
  /**
@@ -381,4 +381,8 @@ export interface ChatModelOutputUsage {
381
381
  * Number of output tokens
382
382
  */
383
383
  outputTokens: number;
384
+ /**
385
+ * AIGNE Hub credit usage
386
+ */
387
+ aigneHubCredits?: number;
384
388
  }
@@ -210,6 +210,7 @@ const chatModelOutputToolCallSchema = z.object({
210
210
  const chatModelOutputUsageSchema = z.object({
211
211
  inputTokens: z.number(),
212
212
  outputTokens: z.number(),
213
+ aigneHubCredits: z.number().optional(),
213
214
  });
214
215
  const chatModelOutputSchema = z.object({
215
216
  text: z.string().optional(),
@@ -11,4 +11,6 @@ export * from "./aigne/index.js";
11
11
  export * from "./memory/index.js";
12
12
  export * from "./prompt/prompt-builder.js";
13
13
  export * from "./prompt/template.js";
14
+ export * from "./utils/json-utils.js";
15
+ export * from "./utils/role-utils.js";
14
16
  export * from "./utils/stream-utils.js";
package/lib/esm/index.js CHANGED
@@ -11,4 +11,6 @@ export * from "./aigne/index.js";
11
11
  export * from "./memory/index.js";
12
12
  export * from "./prompt/prompt-builder.js";
13
13
  export * from "./prompt/template.js";
14
+ export * from "./utils/json-utils.js";
15
+ export * from "./utils/role-utils.js";
14
16
  export * from "./utils/stream-utils.js";
@@ -4,7 +4,7 @@ import { ZodObject } from "zod";
4
4
  import { zodToJsonSchema } from "zod-to-json-schema";
5
5
  import { Agent } from "../agents/agent.js";
6
6
  import { outputSchemaToResponseFormatSchema } from "../utils/json-schema.js";
7
- import { isRecord, unique } from "../utils/type-utils.js";
7
+ import { isNil, isRecord, unique } from "../utils/type-utils.js";
8
8
  import { MEMORY_MESSAGE_TEMPLATE } from "./prompts/memory-message-template.js";
9
9
  import { STRUCTURED_STREAM_INSTRUCTIONS } from "./prompts/structured-stream-instructions.js";
10
10
  import { AgentMessageTemplate, ChatMessagesTemplate, PromptTemplate, SystemMessageTemplate, UserMessageTemplate, } from "./template.js";
@@ -107,7 +107,12 @@ export class PromptBuilder {
107
107
  const stringOrStringify = (value) => typeof value === "string" ? value : stringify(value);
108
108
  for (const { content } of memories) {
109
109
  if (isRecord(content) && "input" in content && "output" in content) {
110
- messages.push({ role: "user", content: stringOrStringify(content.input) }, { role: "agent", content: stringOrStringify(content.output) });
110
+ if (!isNil(content.input) && content.input !== "") {
111
+ messages.push({ role: "user", content: stringOrStringify(content.input) });
112
+ }
113
+ if (!isNil(content.output) && content.output !== "") {
114
+ messages.push({ role: "agent", content: stringOrStringify(content.output) });
115
+ }
111
116
  }
112
117
  else {
113
118
  other.push(content);
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Safely parses JSON text using jaison library which handles malformed JSON better than JSON.parse
3
+ *
4
+ * @param text - The text to parse as JSON
5
+ * @returns Parsed JSON object or null if parsing fails
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const result = safeParseJSON('{"key": "value"}');
10
+ * console.log(result); // { key: "value" }
11
+ *
12
+ * const malformed = safeParseJSON('{"key": "value"'); // Missing closing brace
13
+ * console.log(malformed); // null
14
+ * ```
15
+ */
16
+ export declare function safeParseJSON(text: string): any;
17
+ /**
18
+ * Safely stringifies a value to JSON, handling errors gracefully
19
+ *
20
+ * @param value - The value to stringify
21
+ * @param space - Optional spacing for pretty printing
22
+ * @returns JSON string or null if stringification fails
23
+ */
24
+ export declare function safeStringifyJSON(value: any, space?: number): string | null;
@@ -0,0 +1,41 @@
1
+ import jaison from "jaison";
2
+ /**
3
+ * Safely parses JSON text using jaison library which handles malformed JSON better than JSON.parse
4
+ *
5
+ * @param text - The text to parse as JSON
6
+ * @returns Parsed JSON object or null if parsing fails
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const result = safeParseJSON('{"key": "value"}');
11
+ * console.log(result); // { key: "value" }
12
+ *
13
+ * const malformed = safeParseJSON('{"key": "value"'); // Missing closing brace
14
+ * console.log(malformed); // null
15
+ * ```
16
+ */
17
+ export function safeParseJSON(text) {
18
+ if (!text)
19
+ return null;
20
+ try {
21
+ return jaison(text);
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ }
27
+ /**
28
+ * Safely stringifies a value to JSON, handling errors gracefully
29
+ *
30
+ * @param value - The value to stringify
31
+ * @param space - Optional spacing for pretty printing
32
+ * @returns JSON string or null if stringification fails
33
+ */
34
+ export function safeStringifyJSON(value, space) {
35
+ try {
36
+ return JSON.stringify(value, null, space);
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ }
@@ -1,4 +1,5 @@
1
1
  export declare enum LogLevel {
2
+ SILENT = "silent",
2
3
  ERROR = "error",
3
4
  WARN = "warn",
4
5
  INFO = "info",
@@ -2,6 +2,7 @@ import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
2
2
  import debug from "debug";
3
3
  export var LogLevel;
4
4
  (function (LogLevel) {
5
+ LogLevel["SILENT"] = "silent";
5
6
  LogLevel["ERROR"] = "error";
6
7
  LogLevel["WARN"] = "warn";
7
8
  LogLevel["INFO"] = "info";
@@ -68,5 +69,5 @@ export class Logger {
68
69
  }
69
70
  export const logger = new Logger({
70
71
  ns: "aigne:core",
71
- level: LogLevel.INFO,
72
+ level: LogLevel.SILENT,
72
73
  });
@@ -0,0 +1,31 @@
1
+ import type { Role } from "../agents/chat-model.js";
2
+ /**
3
+ * Standard role mapping for most chat model providers
4
+ * Maps AIGNE framework roles to common provider role names
5
+ */
6
+ export declare const STANDARD_ROLE_MAP: {
7
+ [key in Role]: string;
8
+ };
9
+ /**
10
+ * Creates a role mapper function for a specific provider
11
+ *
12
+ * @param roleMap - Custom role mapping for the provider
13
+ * @returns Function that maps AIGNE roles to provider roles
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // For standard providers (OpenAI, Anthropic, etc.)
18
+ * const mapRole = createRoleMapper(STANDARD_ROLE_MAP);
19
+ *
20
+ * // For providers with different role names
21
+ * const customMap = { ...STANDARD_ROLE_MAP, agent: "bot" };
22
+ * const customMapper = createRoleMapper(customMap);
23
+ * ```
24
+ */
25
+ export declare function createRoleMapper<T extends string>(roleMap: {
26
+ [key in Role]: T;
27
+ }): (role: Role) => T;
28
+ /**
29
+ * Standard role mapper using the default role mapping
30
+ */
31
+ export declare const mapStandardRole: (role: Role) => string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Standard role mapping for most chat model providers
3
+ * Maps AIGNE framework roles to common provider role names
4
+ */
5
+ export const STANDARD_ROLE_MAP = {
6
+ system: "system",
7
+ user: "user",
8
+ agent: "assistant",
9
+ tool: "tool",
10
+ };
11
+ /**
12
+ * Creates a role mapper function for a specific provider
13
+ *
14
+ * @param roleMap - Custom role mapping for the provider
15
+ * @returns Function that maps AIGNE roles to provider roles
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // For standard providers (OpenAI, Anthropic, etc.)
20
+ * const mapRole = createRoleMapper(STANDARD_ROLE_MAP);
21
+ *
22
+ * // For providers with different role names
23
+ * const customMap = { ...STANDARD_ROLE_MAP, agent: "bot" };
24
+ * const customMapper = createRoleMapper(customMap);
25
+ * ```
26
+ */
27
+ export function createRoleMapper(roleMap) {
28
+ return (role) => roleMap[role];
29
+ }
30
+ /**
31
+ * Standard role mapper using the default role mapping
32
+ */
33
+ export const mapStandardRole = createRoleMapper(STANDARD_ROLE_MAP);
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.43.0",
3
+ "version": "1.44.0",
4
4
  "description": "AIGNE core library for building AI-powered applications",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
9
- "homepage": "https://github.com/AIGNE-io/aigne-framework",
9
+ "homepage": "https://www.aigne.io/framework",
10
10
  "license": "Elastic-2.0",
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/AIGNE-io/aigne-framework"
14
14
  },
15
+ "bugs": {
16
+ "url": "https://github.com/AIGNE-io/aigne-framework/issues"
17
+ },
15
18
  "files": [
16
19
  "lib/cjs",
17
20
  "lib/dts",
@@ -74,6 +77,7 @@
74
77
  "eventsource-parser": "^3.0.3",
75
78
  "fast-deep-equal": "^3.1.3",
76
79
  "immer": "^10.1.1",
80
+ "jaison": "^2.0.2",
77
81
  "jsonata": "^2.0.6",
78
82
  "mustache": "^4.2.0",
79
83
  "nanoid": "^5.1.5",