@agenr/agenr-plugin 1.8.0 → 1.8.1

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.
@@ -2737,7 +2737,7 @@ async function extractClaimKeyDecision(entry, llm, config, options = {}) {
2737
2737
  async function getEntityHints(db) {
2738
2738
  return db.getDistinctClaimKeyPrefixes();
2739
2739
  }
2740
- async function runBatchClaimExtraction(results, ports, config, _concurrency = 10, onWarning, onDiagnostic) {
2740
+ async function runBatchClaimExtraction(results, ports, config, concurrency = 10, onWarning, onDiagnostic) {
2741
2741
  if (!config.enabled) {
2742
2742
  return /* @__PURE__ */ new Map();
2743
2743
  }
@@ -2746,8 +2746,12 @@ async function runBatchClaimExtraction(results, ports, config, _concurrency = 10
2746
2746
  const extractedEntries = /* @__PURE__ */ new Map();
2747
2747
  const diagnostics = /* @__PURE__ */ new Map();
2748
2748
  const retryEntries = [];
2749
- for (const result of results) {
2750
- for (const entry of result.entries) {
2749
+ const stageSize = normalizeClaimExtractionConcurrency(concurrency);
2750
+ const orderedEntries = results.flatMap((result) => result.entries);
2751
+ for (let stageStart = 0; stageStart < orderedEntries.length; stageStart += stageSize) {
2752
+ const stageEntries = orderedEntries.slice(stageStart, stageStart + stageSize);
2753
+ const stageRequests = [];
2754
+ for (const entry of stageEntries) {
2751
2755
  if (entry.claim_key) {
2752
2756
  recordClaimKeyHint(hintState, entry.claim_key);
2753
2757
  continue;
@@ -2765,7 +2769,18 @@ async function runBatchClaimExtraction(results, ports, config, _concurrency = 10
2765
2769
  });
2766
2770
  continue;
2767
2771
  }
2768
- const decision = await extractBatchClaimKeyDecision(entry, llm, config, hintState, onWarning);
2772
+ stageRequests.push({
2773
+ entry,
2774
+ hintSnapshot: buildClaimExtractionHintSnapshot(hintState, entry)
2775
+ });
2776
+ }
2777
+ const stageDecisions = await Promise.all(
2778
+ stageRequests.map(async ({ entry, hintSnapshot }) => ({
2779
+ entry,
2780
+ decision: await extractBatchClaimKeyDecision(entry, llm, config, hintSnapshot, onWarning)
2781
+ }))
2782
+ );
2783
+ for (const { entry, decision } of stageDecisions) {
2769
2784
  diagnostics.set(entry, decision.diagnostic);
2770
2785
  if (decision.result?.claimKey) {
2771
2786
  applyClaimExtractionResultToEntry(entry, decision.result);
@@ -2777,18 +2792,26 @@ async function runBatchClaimExtraction(results, ports, config, _concurrency = 10
2777
2792
  }
2778
2793
  }
2779
2794
  if (retryEntries.length > 0 && extractedEntries.size > 0) {
2780
- for (const entry of retryEntries) {
2781
- if (entry.claim_key) {
2782
- continue;
2783
- }
2784
- const decision = await extractBatchClaimKeyDecision(entry, llm, config, hintState, onWarning);
2785
- diagnostics.set(entry, decision.diagnostic);
2786
- if (!decision.result?.claimKey) {
2787
- continue;
2795
+ for (let stageStart = 0; stageStart < retryEntries.length; stageStart += stageSize) {
2796
+ const stageRequests = retryEntries.slice(stageStart, stageStart + stageSize).filter((entry) => !entry.claim_key).map((entry) => ({
2797
+ entry,
2798
+ hintSnapshot: buildClaimExtractionHintSnapshot(hintState, entry)
2799
+ }));
2800
+ const stageDecisions = await Promise.all(
2801
+ stageRequests.map(async ({ entry, hintSnapshot }) => ({
2802
+ entry,
2803
+ decision: await extractBatchClaimKeyDecision(entry, llm, config, hintSnapshot, onWarning)
2804
+ }))
2805
+ );
2806
+ for (const { entry, decision } of stageDecisions) {
2807
+ diagnostics.set(entry, decision.diagnostic);
2808
+ if (!decision.result?.claimKey) {
2809
+ continue;
2810
+ }
2811
+ applyClaimExtractionResultToEntry(entry, decision.result);
2812
+ recordClaimKeyHint(hintState, decision.result.claimKey);
2813
+ extractedEntries.set(entry, decision.result);
2788
2814
  }
2789
- applyClaimExtractionResultToEntry(entry, decision.result);
2790
- recordClaimKeyHint(hintState, decision.result.claimKey);
2791
- extractedEntries.set(entry, decision.result);
2792
2815
  }
2793
2816
  }
2794
2817
  for (const result of results) {
@@ -2801,7 +2824,20 @@ async function runBatchClaimExtraction(results, ports, config, _concurrency = 10
2801
2824
  }
2802
2825
  return extractedEntries;
2803
2826
  }
2804
- async function extractBatchClaimKeyDecision(entry, llm, config, hintState, onWarning) {
2827
+ function normalizeClaimExtractionConcurrency(value) {
2828
+ if (!Number.isInteger(value) || value <= 0) {
2829
+ return 10;
2830
+ }
2831
+ return value;
2832
+ }
2833
+ function buildClaimExtractionHintSnapshot(hintState, entry) {
2834
+ return {
2835
+ hints: buildEntryHints(hintState, entry),
2836
+ supportClaimKeys: [...hintState.supportClaimKeys],
2837
+ entityPrefixStats: hintState.entityPrefixStats
2838
+ };
2839
+ }
2840
+ async function extractBatchClaimKeyDecision(entry, llm, config, hintSnapshot, onWarning) {
2805
2841
  try {
2806
2842
  return await extractClaimKeyDecision(
2807
2843
  {
@@ -2814,10 +2850,10 @@ async function extractBatchClaimKeyDecision(entry, llm, config, hintState, onWar
2814
2850
  llm,
2815
2851
  config,
2816
2852
  {
2817
- hints: buildEntryHints(hintState, entry),
2853
+ hints: hintSnapshot.hints,
2818
2854
  onWarning,
2819
- supportClaimKeys: [...hintState.supportClaimKeys],
2820
- entityPrefixStats: hintState.entityPrefixStats
2855
+ supportClaimKeys: hintSnapshot.supportClaimKeys,
2856
+ entityPrefixStats: hintSnapshot.entityPrefixStats
2821
2857
  }
2822
2858
  );
2823
2859
  } catch {
@@ -3735,7 +3771,7 @@ async function maybeExtractClaimKeys(preparedEntries, options) {
3735
3771
  db: claimExtraction.db
3736
3772
  },
3737
3773
  claimExtraction.config,
3738
- 1,
3774
+ claimExtraction.config.concurrency ?? 10,
3739
3775
  options.onWarning,
3740
3776
  (entry, diagnostic) => {
3741
3777
  const preparedEntry = preparedEntries.find((candidate) => candidate.input === entry);
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  parseTuiSessionKey,
8
8
  readOpenClawSessionsStore,
9
9
  storeEntriesDetailed
10
- } from "./chunk-6CEKKEFZ.js";
10
+ } from "./chunk-O45JQ6O3.js";
11
11
  import {
12
12
  EMBEDDING_DIMENSIONS,
13
13
  ENTRY_TYPES,
@@ -1055,7 +1055,7 @@ function registerAgenrOpenClawTools(api, servicesPromise, logger) {
1055
1055
  var openclaw_plugin_default = {
1056
1056
  id: "agenr",
1057
1057
  name: "agenr",
1058
- version: "1.8.0",
1058
+ version: "1.8.1",
1059
1059
  description: "agenr memory plugin for OpenClaw",
1060
1060
  kind: "memory",
1061
1061
  contracts: {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "agenr",
3
3
  "name": "agenr",
4
- "version": "1.8.0",
4
+ "version": "1.8.1",
5
5
  "description": "agenr memory plugin for OpenClaw",
6
6
  "kind": "memory",
7
7
  "contracts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenr/agenr-plugin",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "agenr memory plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "exports": {