@agentica/core 0.36.4 → 0.38.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.
@@ -17,6 +17,7 @@ const events_1 = require("./factory/events");
17
17
  const orchestrate_1 = require("./orchestrate");
18
18
  const transformHistory_1 = require("./transformers/transformHistory");
19
19
  const __map_take_1 = require("./utils/__map_take");
20
+ const assertExecuteFailure_1 = require("./utils/assertExecuteFailure");
20
21
  const request_1 = require("./utils/request");
21
22
  /**
22
23
  * Micro AI chatbot.
@@ -104,7 +105,7 @@ class MicroAgentica {
104
105
  */
105
106
  conversate(content_1) {
106
107
  return __awaiter(this, arguments, void 0, function* (content, options = {}) {
107
- var _a, _b, _c, _d;
108
+ var _a, _b, _c;
108
109
  const histories = [];
109
110
  const dispatch = (event) => __awaiter(this, void 0, void 0, function* () {
110
111
  try {
@@ -141,13 +142,21 @@ class MicroAgentica {
141
142
  abortSignal: options.abortSignal,
142
143
  });
143
144
  const executes = yield (0, orchestrate_1.call)(ctx, this.operations_.array);
144
- if (executes.length
145
- && ((_b = (_a = this.props.config) === null || _a === void 0 ? void 0 : _a.executor) === null || _b === void 0 ? void 0 : _b.describe) !== null
146
- && ((_d = (_c = this.props.config) === null || _c === void 0 ? void 0 : _c.executor) === null || _d === void 0 ? void 0 : _d.describe) !== false) {
147
- yield (0, orchestrate_1.describe)(ctx, executes);
145
+ // eslint-disable-next-line
146
+ if (executes.length && !!((_b = (_a = this.props.config) === null || _a === void 0 ? void 0 : _a.executor) === null || _b === void 0 ? void 0 : _b.describe)) {
147
+ const func = typeof this.props.config.executor.describe === "function"
148
+ ? this.props.config.executor.describe
149
+ : orchestrate_1.describe;
150
+ yield func(ctx, executes);
148
151
  }
149
152
  const completed = yield Promise.all(histories.map((h) => __awaiter(this, void 0, void 0, function* () { return h(); })));
150
153
  this.histories_.push(...completed);
154
+ // throw exception about failed execution
155
+ if (((_c = this.props.config) === null || _c === void 0 ? void 0 : _c.throw) !== false) {
156
+ for (const execute of executes) {
157
+ (0, assertExecuteFailure_1.assertExecuteFailure)(execute);
158
+ }
159
+ }
151
160
  return completed;
152
161
  });
153
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MicroAgentica.js","sourceRoot":"","sources":["../src/MicroAgentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAiC;AAejC,qEAAkE;AAClE,4FAAyF;AACzF,6CAA0D;AAC1D,+CAA+C;AAC/C,sEAAmE;AACnE,mDAAgD;AAChD,6CAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,aAAa;IAWxB;;kEAE8D;IAC9D;;;;OAIG;IACH,YAAoC,KAA0B;;QAA1B,UAAK,GAAL,KAAK,CAAqB;QAC5D,IAAI,CAAC,WAAW,GAAG,qDAAyB,CAAC,OAAO,CAAC;YACnD,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,CAAC,MAAA,KAAK,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CACpD,IAAA,mCAAgB,EAAC;YACf,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK;YAClC,OAAO,EAAE,KAAK;SACf,CAAyB,CAC3B,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;YACrD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,YAAY,uCAAkB;gBACnD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;gBACvB,CAAC,CAAC,IAAI,uCAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;YACjD,CAAC,CAAC,uCAAkB,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5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C;IAEa,QAAQ,CACpB,KAAY;;YAEZ,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAO,QAAQ,EAAE,EAAE;oBACrC,IAAI,CAAC;wBACH,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;oBACxB,CAAC;oBACD,WAAM,CAAC;wBACL,WAAW;oBACb,CAAC;gBACH,CAAC,CAAA,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AA9SD,sCA8SC"}
package/lib/index.mjs CHANGED
@@ -925,20 +925,27 @@ function parse(str) {
925
925
  }
926
926
 
927
927
  function stringifyValidateFailure(failure) {
928
- return stringify({
928
+ const usedErrors = new Set;
929
+ const jsonOutput = stringify({
929
930
  value: failure.data,
930
931
  errors: failure.errors,
931
932
  path: "$input",
932
933
  tab: 0,
933
934
  inArray: false,
934
- inToJson: false
935
+ inToJson: false,
936
+ usedErrors
935
937
  });
938
+ const unmappableErrors = failure.errors.filter((e => !usedErrors.has(e)));
939
+ if (unmappableErrors.length > 0) {
940
+ return `\`\`\`json\n${jsonOutput}\n\`\`\`\n\n**Unmappable validation errors:**\n\n\`\`\`json\n${JSON.stringify(unmappableErrors, null, 2)}\n\`\`\``;
941
+ }
942
+ return `\`\`\`json\n${jsonOutput}\n\`\`\``;
936
943
  }
937
944
 
938
945
  function stringify(props) {
939
- const {value, errors, path, tab, inArray, inToJson} = props;
946
+ const {value, errors, path, tab, inArray, inToJson, usedErrors} = props;
940
947
  const indent = " ".repeat(tab);
941
- const errorComment = getErrorComment(path, errors);
948
+ const errorComment = getErrorComment(path, errors, usedErrors);
942
949
  if (inArray && value === undefined) {
943
950
  return `${indent}undefined${errorComment}`;
944
951
  }
@@ -956,7 +963,8 @@ function stringify(props) {
956
963
  path: itemPath,
957
964
  tab: tab + 1,
958
965
  inArray: true,
959
- inToJson: false
966
+ inToJson: false,
967
+ usedErrors
960
968
  });
961
969
  if (index < value.length - 1) {
962
970
  const itemLines = itemStr.split("\n");
@@ -983,7 +991,8 @@ function stringify(props) {
983
991
  path,
984
992
  tab,
985
993
  inArray,
986
- inToJson: true
994
+ inToJson: true,
995
+ usedErrors
987
996
  });
988
997
  }
989
998
  const existingEntries = Object.entries(value).filter((([_, val]) => val !== undefined));
@@ -999,7 +1008,7 @@ function stringify(props) {
999
1008
  const propIndent = " ".repeat(tab + 1);
1000
1009
  const val = missingKeys.includes(key) ? undefined : value[key];
1001
1010
  if (val === undefined || val === null || typeof val === "boolean" || typeof val === "number" || typeof val === "string") {
1002
- const propErrorComment = getErrorComment(propPath, errors);
1011
+ const propErrorComment = getErrorComment(propPath, errors, usedErrors);
1003
1012
  const valueStr = val === undefined ? `${propIndent}"${key}": undefined` : `${propIndent}"${key}": ${JSON.stringify(val)}`;
1004
1013
  const withComma = index < array.length - 1 ? `${valueStr},` : valueStr;
1005
1014
  const line = withComma + propErrorComment;
@@ -1012,7 +1021,8 @@ function stringify(props) {
1012
1021
  path: propPath,
1013
1022
  tab: tab + 1,
1014
1023
  inArray: false,
1015
- inToJson: false
1024
+ inToJson: false,
1025
+ usedErrors
1016
1026
  });
1017
1027
  const valStrWithoutIndent = valStr.trimStart();
1018
1028
  if (index < array.length - 1) {
@@ -1039,11 +1049,12 @@ function stringify(props) {
1039
1049
  return `${indent}${valStr}${errorComment}`;
1040
1050
  }
1041
1051
 
1042
- function getErrorComment(path, errors) {
1052
+ function getErrorComment(path, errors, usedErrors) {
1043
1053
  const pathErrors = errors.filter((e => e.path === path));
1044
1054
  if (pathErrors.length === 0) {
1045
1055
  return "";
1046
1056
  }
1057
+ pathErrors.forEach((e => usedErrors.add(e)));
1047
1058
  return ` // ❌ ${JSON.stringify(pathErrors.map((e => ({
1048
1059
  path: e.path,
1049
1060
  expected: e.expected,
@@ -1647,9 +1658,9 @@ async function correctTypeError(ctx, callEvent, validateEvent, previousValidatio
1647
1658
  toolCall: {
1648
1659
  id: callEvent.id,
1649
1660
  arguments: JSON.stringify(callEvent.arguments),
1650
- result: [ "🚨 VALIDATION FAILURE: Your function arguments do not conform to the required schema.", "", "The validation errors below represent computed absolute truth from rigorous type validation.", "Each error is marked with ❌ comments showing the exact location, expected type, and actual value.", "", "You must fix ALL errors to achieve 100% schema compliance.", "", "```json", JsonUtil.stringifyValidateFailure(validateEvent.result), "```" ].join("\n")
1661
+ result: [ "🚨 VALIDATION FAILURE: Your function arguments do not conform to the required schema.", "", "The validation errors below represent computed absolute truth from rigorous type validation.", "Each error is marked with ❌ comments showing the exact location, expected type, and actual value.", "", "You must fix ALL errors to achieve 100% schema compliance.", "", JsonUtil.stringifyValidateFailure(validateEvent.result) ].join("\n")
1651
1662
  },
1652
- systemPrompt: ctx.config?.systemPrompt?.validate?.(previousValidationErrors.slice(0, -1)) ?? [ AgenticaSystemPrompt.VALIDATE, ...previousValidationErrors.length > 1 ? [ "", AgenticaSystemPrompt.VALIDATE_REPEATED.replace("${{HISTORICAL_ERRORS}}", previousValidationErrors.slice(0, -1).map(((ve, i) => [ `### ${i + 1}. Previous Validation Error`, "", "```json", JsonUtil.stringifyValidateFailure(ve.result), "```" ].join("\n"))).join("\n\n")) ] : [] ].join("\n"),
1663
+ systemPrompt: ctx.config?.systemPrompt?.validate?.(previousValidationErrors.slice(0, -1)) ?? [ AgenticaSystemPrompt.VALIDATE, ...previousValidationErrors.length > 1 ? [ "", AgenticaSystemPrompt.VALIDATE_REPEATED.replace("${{HISTORICAL_ERRORS}}", previousValidationErrors.slice(0, -1).map(((ve, i) => [ `### ${i + 1}. Previous Validation Error`, "", JsonUtil.stringifyValidateFailure(ve.result) ].join("\n"))).join("\n\n")) ] : [] ].join("\n"),
1653
1664
  life,
1654
1665
  previousValidationErrors
1655
1666
  });
@@ -45327,6 +45338,19 @@ var index = Object.freeze({
45327
45338
  select
45328
45339
  });
45329
45340
 
45341
+ function assertExecuteFailure(failure) {
45342
+ if (failure.success === true) {
45343
+ return;
45344
+ } else if (failure.value instanceof Error) {
45345
+ throw failure.value;
45346
+ } else if (typeof failure.value === "object" && failure.value !== null) {
45347
+ const error = new Error("Error from execute failure");
45348
+ Object.assign(error, failure.value);
45349
+ throw error;
45350
+ }
45351
+ throw failure.value;
45352
+ }
45353
+
45330
45354
  class MicroAgentica {
45331
45355
  constructor(props) {
45332
45356
  this.props = props;
@@ -45379,11 +45403,17 @@ class MicroAgentica {
45379
45403
  abortSignal: options.abortSignal
45380
45404
  });
45381
45405
  const executes = await call(ctx, this.operations_.array);
45382
- if (executes.length && this.props.config?.executor?.describe !== null && this.props.config?.executor?.describe !== false) {
45383
- await describe(ctx, executes);
45406
+ if (executes.length && !!this.props.config?.executor?.describe) {
45407
+ const func = typeof this.props.config.executor.describe === "function" ? this.props.config.executor.describe : describe;
45408
+ await func(ctx, executes);
45384
45409
  }
45385
45410
  const completed = await Promise.all(histories.map((async h => h())));
45386
45411
  this.histories_.push(...completed);
45412
+ if (this.props.config?.throw !== false) {
45413
+ for (const execute of executes) {
45414
+ assertExecuteFailure(execute);
45415
+ }
45416
+ }
45387
45417
  return completed;
45388
45418
  }
45389
45419
  getConfig() {