@remnic/plugin-openclaw 1.0.14 → 1.0.15

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.
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-5LE4HTVL.js";
4
4
  import {
5
5
  FallbackLlmClient
6
- } from "./chunk-RQCTMECT.js";
6
+ } from "./chunk-BCKAR3OK.js";
7
7
  import "./chunk-3A5ELHTT.js";
8
8
  import {
9
9
  log
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-5LE4HTVL.js";
17
17
  import {
18
18
  FallbackLlmClient
19
- } from "./chunk-RQCTMECT.js";
19
+ } from "./chunk-BCKAR3OK.js";
20
20
  import "./chunk-3A5ELHTT.js";
21
21
  import "./chunk-7UZNLMW5.js";
22
22
  import "./chunk-6OJAU466.js";
@@ -40,6 +40,17 @@ function buildChatCompletionTokenLimit(model, maxTokens, options) {
40
40
  }
41
41
  return { max_tokens: safeMaxTokens };
42
42
  }
43
+ function supportsTemperature(model, options) {
44
+ const normalized = normalizedModel(model);
45
+ if (options?.assumeOpenAI === true && matchesModelFamily(normalized, /^gpt-5(?:$|[-.])/)) {
46
+ return false;
47
+ }
48
+ return true;
49
+ }
50
+ function buildChatCompletionTemperature(model, temperature, options) {
51
+ if (!supportsTemperature(model, options)) return {};
52
+ return { temperature };
53
+ }
43
54
 
44
55
  // ../remnic-core/src/resolve-provider-secret.ts
45
56
  import path from "path";
@@ -255,6 +266,20 @@ function loadModelsJsonProviders() {
255
266
  }
256
267
 
257
268
  // ../remnic-core/src/fallback-llm.ts
269
+ var PROVIDER_ALIASES = {
270
+ "openai-codex": ["codex"],
271
+ codex: ["openai-codex"],
272
+ "claude-cli": ["anthropic"]
273
+ };
274
+ var LEGACY_PROVIDER_IDS = /* @__PURE__ */ new Set(["openai-codex", "claude-cli"]);
275
+ var BUILT_IN_PROVIDER_FALLBACKS = {
276
+ anthropic: {
277
+ baseUrl: "https://api.anthropic.com/v1",
278
+ api: "anthropic-messages",
279
+ apiKey: "secretref-managed",
280
+ models: []
281
+ }
282
+ };
258
283
  var FallbackLlmClient = class {
259
284
  gatewayConfig;
260
285
  runtimeContext;
@@ -412,14 +437,59 @@ var FallbackLlmClient = class {
412
437
  log.warn(`fallback LLM: invalid model format: ${modelString}`);
413
438
  return null;
414
439
  }
415
- const providerId = parts[0];
440
+ const requestedProviderId = parts[0];
416
441
  const modelId = parts.slice(1).join("/");
417
- const providerConfig = providers[providerId] ?? this.resolveFromModelsJson(providerId);
442
+ const resolvedProvider = this.resolveProviderConfig(requestedProviderId, providers);
443
+ const providerConfig = resolvedProvider?.config;
418
444
  if (!providerConfig) {
419
- log.warn(`fallback LLM: provider not found: ${providerId}`);
445
+ log.warn(
446
+ `fallback LLM: provider not found: ${requestedProviderId} (tried: ${this.providerResolutionCandidates(requestedProviderId).join(", ")})`
447
+ );
420
448
  return null;
421
449
  }
422
- return { providerId, modelId, providerConfig, modelString };
450
+ return {
451
+ providerId: resolvedProvider.providerId,
452
+ modelId,
453
+ providerConfig,
454
+ modelString
455
+ };
456
+ }
457
+ resolveProviderConfig(providerId, providers) {
458
+ const candidates = this.providerResolutionCandidates(providerId);
459
+ const aliasCandidates = candidates.filter((candidate) => candidate !== providerId);
460
+ const fallbackCandidates = LEGACY_PROVIDER_IDS.has(providerId) ? [...aliasCandidates, providerId] : [providerId, ...aliasCandidates];
461
+ for (const candidate of candidates) {
462
+ const config = providers[candidate];
463
+ if (config) {
464
+ if (candidate !== providerId) {
465
+ log.debug(`fallback LLM: provider "${providerId}" resolved via alias "${candidate}"`);
466
+ }
467
+ return { providerId: candidate, config };
468
+ }
469
+ }
470
+ for (const candidate of fallbackCandidates) {
471
+ const config = this.resolveFromModelsJson(candidate);
472
+ if (config) {
473
+ if (candidate !== providerId) {
474
+ log.debug(`fallback LLM: provider "${providerId}" resolved via models.json alias "${candidate}"`);
475
+ }
476
+ return { providerId: candidate, config };
477
+ }
478
+ const builtInConfig = BUILT_IN_PROVIDER_FALLBACKS[candidate];
479
+ if (builtInConfig) {
480
+ if (candidate === providerId) {
481
+ log.debug(`fallback LLM: provider "${providerId}" resolved from built-in defaults`);
482
+ return { providerId, config: builtInConfig };
483
+ }
484
+ log.debug(`fallback LLM: provider "${providerId}" resolved via built-in alias "${candidate}"`);
485
+ return { providerId: candidate, config: builtInConfig };
486
+ }
487
+ }
488
+ return null;
489
+ }
490
+ providerResolutionCandidates(providerId) {
491
+ const candidates = [providerId, ...PROVIDER_ALIASES[providerId] ?? []];
492
+ return [...new Set(candidates)];
423
493
  }
424
494
  /**
425
495
  * Look up a provider from the gateway's materialized models.json, which
@@ -540,7 +610,9 @@ var FallbackLlmClient = class {
540
610
  const body = {
541
611
  model: modelId,
542
612
  messages,
543
- temperature: options.temperature ?? 0.3,
613
+ ...buildChatCompletionTemperature(modelId, options.temperature ?? 0.3, {
614
+ assumeOpenAI
615
+ }),
544
616
  ...buildChatCompletionTokenLimit(modelId, options.maxTokens ?? 4096, {
545
617
  assumeOpenAI
546
618
  })
@@ -593,7 +665,9 @@ var FallbackLlmClient = class {
593
665
  model: modelId,
594
666
  input,
595
667
  max_output_tokens: Math.max(0, Math.floor(options.maxTokens ?? 4096)),
596
- temperature: options.temperature ?? 0.3
668
+ ...buildChatCompletionTemperature(modelId, options.temperature ?? 0.3, {
669
+ assumeOpenAI: shouldAssumeOpenAiChatCompletions(config.baseUrl)
670
+ })
597
671
  };
598
672
  if (instructions.length > 0) {
599
673
  body.instructions = instructions;
@@ -831,7 +831,7 @@ var CompoundingEngine = class {
831
831
  let promotionCandidates = this.config.compoundingSemanticEnabled ? this.derivePromotionCandidates(outcomeSummary, mistakes.registry, rubrics) : [];
832
832
  if (this.config.cmcConsolidationEnabled) {
833
833
  try {
834
- const { deriveCausalPromotionCandidates, materializeAfterCausalConsolidation } = await import("./causal-consolidation-YI53C2AO.js");
834
+ const { deriveCausalPromotionCandidates, materializeAfterCausalConsolidation } = await import("./causal-consolidation-K65BZXWS.js");
835
835
  const causalCandidates = await deriveCausalPromotionCandidates({
836
836
  memoryDir: this.config.memoryDir,
837
837
  causalTrajectoryStoreDir: this.config.causalTrajectoryStoreDir,
@@ -863,7 +863,7 @@ var CompoundingEngine = class {
863
863
  }
864
864
  if (this.config.calibrationEnabled) {
865
865
  try {
866
- const { runCalibrationConsolidation } = await import("./calibration-WCHOK6DX.js");
866
+ const { runCalibrationConsolidation } = await import("./calibration-WBEDZUR3.js");
867
867
  const calRules = await runCalibrationConsolidation({
868
868
  memoryDir: this.config.memoryDir,
869
869
  gatewayConfig: this.config.gatewayConfig,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CompoundingEngine,
3
3
  defaultTierMigrationCycleBudget
4
- } from "./chunk-OAE7AQ6R.js";
4
+ } from "./chunk-URJUGPZW.js";
5
5
  import "./chunk-EXDYWXMB.js";
6
6
  import "./chunk-7UZNLMW5.js";
7
7
  import "./chunk-6OJAU466.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FallbackLlmClient
3
- } from "./chunk-RQCTMECT.js";
3
+ } from "./chunk-BCKAR3OK.js";
4
4
  import "./chunk-3A5ELHTT.js";
5
5
  import "./chunk-UFU5GGGA.js";
6
6
  import "./chunk-I6B2W2IY.js";
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ import {
115
115
  CompoundingEngine,
116
116
  SharedContextManager,
117
117
  defaultTierMigrationCycleBudget
118
- } from "./chunk-OAE7AQ6R.js";
118
+ } from "./chunk-URJUGPZW.js";
119
119
  import {
120
120
  ZodError,
121
121
  external_exports
@@ -132,7 +132,7 @@ import {
132
132
  buildChatCompletionTokenLimit,
133
133
  findGatewayRuntimeModules,
134
134
  shouldAssumeOpenAiChatCompletions
135
- } from "./chunk-RQCTMECT.js";
135
+ } from "./chunk-BCKAR3OK.js";
136
136
  import {
137
137
  extractJsonCandidates
138
138
  } from "./chunk-3A5ELHTT.js";
@@ -23197,6 +23197,53 @@ var LATEST_STATE_CUES = /* @__PURE__ */ new Set([
23197
23197
  "changed",
23198
23198
  "change"
23199
23199
  ]);
23200
+ var STRUCTURED_PLAN_FIELD_CUES = /* @__PURE__ */ new Set([
23201
+ "accommodation",
23202
+ "attraction",
23203
+ "breakfast",
23204
+ "current city",
23205
+ "dinner",
23206
+ "flight",
23207
+ "flights",
23208
+ "hotel",
23209
+ "lunch",
23210
+ "restaurant",
23211
+ "restaurants",
23212
+ "transportation",
23213
+ "traveler",
23214
+ "travelers"
23215
+ ]);
23216
+ var STRUCTURED_PLAN_DEPENDENCY_CUES = /* @__PURE__ */ new Set([
23217
+ "comparison",
23218
+ "constraint",
23219
+ "constraints",
23220
+ "dependency",
23221
+ "dependencies",
23222
+ "join",
23223
+ "same",
23224
+ "shared"
23225
+ ]);
23226
+ var BENCHMARK_ABILITY_CUES = /* @__PURE__ */ new Map([
23227
+ ["information extraction", "ability=information_extraction"],
23228
+ ["knowledge update", "ability=knowledge_update"],
23229
+ ["multi session reasoning", "ability=multi_session_reasoning"],
23230
+ ["multi-session reasoning", "ability=multi_session_reasoning"],
23231
+ ["instruction following", "ability=instruction_following"]
23232
+ ]);
23233
+ var BENCHMARK_ANCHOR_VALUE_STOPWORDS = /* @__PURE__ */ new Set([
23234
+ "a",
23235
+ "about",
23236
+ "an",
23237
+ "for",
23238
+ "from",
23239
+ "in",
23240
+ "on",
23241
+ "the",
23242
+ "to",
23243
+ "use",
23244
+ "using",
23245
+ "with"
23246
+ ]);
23200
23247
  var RELATIVE_TEMPORAL_CUES = [
23201
23248
  "as of",
23202
23249
  "most recent",
@@ -23269,6 +23316,7 @@ var SPEAKER_NAME_STOPWORDS = /* @__PURE__ */ new Set([
23269
23316
  "In",
23270
23317
  "Is",
23271
23318
  "It",
23319
+ "Join",
23272
23320
  "Of",
23273
23321
  "On",
23274
23322
  "Or",
@@ -23334,6 +23382,8 @@ async function buildExplicitCueRecallSection(options) {
23334
23382
  sessionId: options.sessionId,
23335
23383
  query,
23336
23384
  maxReferences,
23385
+ includeBenchmarkAnchorCues: options.includeBenchmarkAnchorCues,
23386
+ includeStructuredPlanCues: options.includeStructuredPlanCues,
23337
23387
  evidenceItems,
23338
23388
  seenTurns
23339
23389
  });
@@ -23386,7 +23436,10 @@ async function collectTurnReferenceEvidence(options) {
23386
23436
  }
23387
23437
  }
23388
23438
  async function collectLexicalCueEvidence(options) {
23389
- const cues = collectLexicalCues(options.query).slice(0, options.maxReferences);
23439
+ const cues = collectLexicalCues(options.query, {
23440
+ includeBenchmarkAnchorCues: options.includeBenchmarkAnchorCues,
23441
+ includeStructuredPlanCues: options.includeStructuredPlanCues
23442
+ }).slice(0, options.maxReferences);
23390
23443
  const preferLatest = hasLatestStateIntent(options.query);
23391
23444
  for (const cue of cues) {
23392
23445
  const results = sortLexicalCueResults(
@@ -23468,7 +23521,7 @@ function collectExplicitTurnReferences(query) {
23468
23521
  }
23469
23522
  return [...references.values()].sort((left, right) => left.number - right.number);
23470
23523
  }
23471
- function collectLexicalCues(query) {
23524
+ function collectLexicalCues(query, options = {}) {
23472
23525
  const cues = /* @__PURE__ */ new Set();
23473
23526
  for (const match of query.matchAll(/\b[A-Za-z][A-Za-z0-9]{0,12}\d+:\d+\b/g)) {
23474
23527
  cues.add(match[0]);
@@ -23482,6 +23535,16 @@ function collectLexicalCues(query) {
23482
23535
  for (const cue of collectQuestionSlotCues(query)) {
23483
23536
  cues.add(cue);
23484
23537
  }
23538
+ if (options.includeBenchmarkAnchorCues) {
23539
+ for (const cue of collectBenchmarkAnchorCues(query)) {
23540
+ cues.add(cue);
23541
+ }
23542
+ }
23543
+ if (options.includeStructuredPlanCues) {
23544
+ for (const cue of collectStructuredPlanCues(query)) {
23545
+ cues.add(cue);
23546
+ }
23547
+ }
23485
23548
  for (const match of query.matchAll(/\b(?:session|source|chat|plan|task|event|file|tool)[_-][A-Za-z0-9][A-Za-z0-9_.:-]{0,80}\b/gi)) {
23486
23549
  cues.add(match[0]);
23487
23550
  }
@@ -23511,22 +23574,156 @@ function collectQuestionSlotCues(query) {
23511
23574
  }
23512
23575
  return [...cues].sort((left, right) => left.localeCompare(right));
23513
23576
  }
23514
- function collectTemporalLexicalCues(query) {
23577
+ function collectBenchmarkAnchorCues(query) {
23515
23578
  const cues = /* @__PURE__ */ new Set();
23516
23579
  const normalizedQuery = query.toLowerCase().replace(/\s+/g, " ");
23517
- for (const cue of RELATIVE_TEMPORAL_CUES) {
23518
- let searchFrom = 0;
23519
- while (searchFrom < normalizedQuery.length) {
23520
- const index = normalizedQuery.indexOf(cue, searchFrom);
23521
- if (index < 0) {
23580
+ for (const [phrase, cue] of BENCHMARK_ABILITY_CUES) {
23581
+ if (containsBoundedPhrase(normalizedQuery, phrase)) {
23582
+ cues.add(cue);
23583
+ }
23584
+ }
23585
+ const tokens = tokenizeAnchorQuery(query);
23586
+ for (let index = 0; index < tokens.length; index += 1) {
23587
+ let prefix = normalizeBenchmarkAnchorPrefix(tokens[index]);
23588
+ if (!prefix) {
23589
+ continue;
23590
+ }
23591
+ let valueIndex = index + 1;
23592
+ if (prefix === "source" && tokens[valueIndex]?.toLowerCase() === "chat") {
23593
+ prefix = "source_chat";
23594
+ valueIndex += 1;
23595
+ }
23596
+ const maybeIdLabel = tokens[valueIndex]?.toLowerCase();
23597
+ if (maybeIdLabel === "id" || maybeIdLabel === "ids") {
23598
+ valueIndex += 1;
23599
+ }
23600
+ let consumedValue = false;
23601
+ for (let currentValueIndex = valueIndex; currentValueIndex < tokens.length; currentValueIndex += 1) {
23602
+ const rawValue = tokens[currentValueIndex];
23603
+ const normalizedValue = rawValue?.toLowerCase();
23604
+ if (!rawValue || normalizeBenchmarkAnchorPrefix(rawValue)) {
23605
+ break;
23606
+ }
23607
+ if (normalizedValue === "and" || normalizedValue === "or") {
23608
+ continue;
23609
+ }
23610
+ if (BENCHMARK_ANCHOR_VALUE_STOPWORDS.has(normalizedValue)) {
23522
23611
  break;
23523
23612
  }
23524
- const afterIndex = index + cue.length;
23525
- if (isTemporalCueBoundary(normalizedQuery[index - 1]) && isTemporalCueBoundary(normalizedQuery[afterIndex])) {
23526
- cues.add(cue);
23613
+ if (!isBenchmarkAnchorValue(rawValue)) {
23527
23614
  break;
23528
23615
  }
23529
- searchFrom = afterIndex;
23616
+ addBenchmarkAnchorCues(cues, prefix, rawValue);
23617
+ consumedValue = true;
23618
+ index = currentValueIndex;
23619
+ }
23620
+ if (!consumedValue) {
23621
+ continue;
23622
+ }
23623
+ }
23624
+ return [...cues].sort((left, right) => left.localeCompare(right));
23625
+ }
23626
+ function addBenchmarkAnchorCues(cues, prefix, rawValue) {
23627
+ cues.add(`${prefix}_id=${rawValue}`);
23628
+ cues.add(`${prefix}-${rawValue}`);
23629
+ if (prefix === "source_chat") {
23630
+ cues.add(`chat_id=${rawValue}`);
23631
+ }
23632
+ }
23633
+ function isBenchmarkAnchorValue(token) {
23634
+ for (const char of token) {
23635
+ if (isAsciiDigitChar(char)) {
23636
+ return true;
23637
+ }
23638
+ }
23639
+ return false;
23640
+ }
23641
+ function isAsciiDigitChar(char) {
23642
+ const code = char.charCodeAt(0);
23643
+ return code >= 48 && code <= 57;
23644
+ }
23645
+ function normalizeBenchmarkAnchorPrefix(token) {
23646
+ switch (token?.toLowerCase()) {
23647
+ case "ability":
23648
+ case "chat":
23649
+ case "plan":
23650
+ case "rubric":
23651
+ case "source":
23652
+ return token.toLowerCase();
23653
+ default:
23654
+ return void 0;
23655
+ }
23656
+ }
23657
+ function tokenizeAnchorQuery(query) {
23658
+ const tokens = [];
23659
+ let current = "";
23660
+ const push = () => {
23661
+ const token = trimTrailingAnchorTokenPunctuation(current);
23662
+ if (token.length > 0) {
23663
+ tokens.push(token);
23664
+ }
23665
+ current = "";
23666
+ };
23667
+ for (const char of query) {
23668
+ if (isAsciiLetterOrDigit(char) || char === "_" || char === "-" || char === "." || char === ":") {
23669
+ current += char;
23670
+ continue;
23671
+ }
23672
+ push();
23673
+ }
23674
+ push();
23675
+ return tokens;
23676
+ }
23677
+ function trimTrailingAnchorTokenPunctuation(token) {
23678
+ let end = token.length;
23679
+ while (end > 0) {
23680
+ const char = token[end - 1];
23681
+ if (char !== "." && char !== ":" && char !== ";" && char !== "!" && char !== "?") {
23682
+ break;
23683
+ }
23684
+ end -= 1;
23685
+ }
23686
+ return token.slice(0, end);
23687
+ }
23688
+ function collectStructuredPlanCues(query) {
23689
+ const cues = /* @__PURE__ */ new Set();
23690
+ const normalizedQuery = query.toLowerCase().replace(/\s+/g, " ");
23691
+ for (const cue of STRUCTURED_PLAN_FIELD_CUES) {
23692
+ if (containsBoundedPhrase(normalizedQuery, cue)) {
23693
+ cues.add(cue);
23694
+ }
23695
+ }
23696
+ if (cues.size === 0) {
23697
+ return [];
23698
+ }
23699
+ for (const cue of STRUCTURED_PLAN_DEPENDENCY_CUES) {
23700
+ if (containsBoundedPhrase(normalizedQuery, cue)) {
23701
+ cues.add(cue);
23702
+ }
23703
+ }
23704
+ return [...cues].sort((left, right) => left.localeCompare(right));
23705
+ }
23706
+ function containsBoundedPhrase(normalizedHaystack, phrase) {
23707
+ let searchFrom = 0;
23708
+ while (searchFrom < normalizedHaystack.length) {
23709
+ const index = normalizedHaystack.indexOf(phrase, searchFrom);
23710
+ if (index < 0) {
23711
+ return false;
23712
+ }
23713
+ const afterIndex = index + phrase.length;
23714
+ if (isTemporalCueBoundary(normalizedHaystack[index - 1]) && isTemporalCueBoundary(normalizedHaystack[afterIndex])) {
23715
+ return true;
23716
+ }
23717
+ searchFrom = afterIndex;
23718
+ }
23719
+ return false;
23720
+ }
23721
+ function collectTemporalLexicalCues(query) {
23722
+ const cues = /* @__PURE__ */ new Set();
23723
+ const normalizedQuery = query.toLowerCase().replace(/\s+/g, " ");
23724
+ for (const cue of RELATIVE_TEMPORAL_CUES) {
23725
+ if (containsBoundedPhrase(normalizedQuery, cue)) {
23726
+ cues.add(cue);
23530
23727
  }
23531
23728
  }
23532
23729
  return [...cues].sort((left, right) => left.localeCompare(right));
@@ -34725,7 +34922,7 @@ ${doc.content}` : doc.content,
34725
34922
  );
34726
34923
  return result;
34727
34924
  }
34728
- const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-WCWNGIQ3.js");
34925
+ const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-7PHTDZ4M.js");
34729
34926
  const useGateway = this.config.modelSource === "gateway";
34730
34927
  const modelSetting = this.config.semanticConsolidationModel;
34731
34928
  if (modelSetting === "fast" && this.fastLlm && !useGateway) {
@@ -37488,7 +37685,7 @@ ${lines.join("\n\n")}`;
37488
37685
  return null;
37489
37686
  }
37490
37687
  try {
37491
- const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-WCHOK6DX.js");
37688
+ const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-WBEDZUR3.js");
37492
37689
  const rules = await getCalibrationRulesForRecall(this.config.memoryDir);
37493
37690
  if (rules.length === 0) {
37494
37691
  recordRecallSectionMetric({
@@ -63774,7 +63971,7 @@ async function runSemanticRulePromoteCliCommand(options) {
63774
63971
  });
63775
63972
  }
63776
63973
  async function runCompoundingPromoteCliCommand(options) {
63777
- const { CompoundingEngine: CompoundingEngine2 } = await import("./engine-BIYI3P4J.js");
63974
+ const { CompoundingEngine: CompoundingEngine2 } = await import("./engine-KJWHWWLM.js");
63778
63975
  const config = parseConfig({
63779
63976
  memoryDir: options.memoryDir,
63780
63977
  qmdEnabled: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnic/plugin-openclaw",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "OpenClaw adapter for Remnic memory — thin wrapper delegating to @remnic/core",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "openai": "^6.0.0",
28
- "@remnic/core": "^1.1.5"
28
+ "@remnic/core": "^1.1.7"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "openclaw": ">=2026.4.8"