@caupulican/pi-adaptative 0.80.59 → 0.80.61

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/core/agent-session.d.ts +6 -0
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +42 -6
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/extension-metadata.d.ts +20 -0
  7. package/dist/core/extension-metadata.d.ts.map +1 -0
  8. package/dist/core/extension-metadata.js +115 -0
  9. package/dist/core/extension-metadata.js.map +1 -0
  10. package/dist/core/extensions/runner.d.ts +1 -0
  11. package/dist/core/extensions/runner.d.ts.map +1 -1
  12. package/dist/core/extensions/runner.js +3 -0
  13. package/dist/core/extensions/runner.js.map +1 -1
  14. package/dist/core/memory/providers/transcript-recall.d.ts +27 -0
  15. package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -0
  16. package/dist/core/memory/providers/transcript-recall.js +154 -0
  17. package/dist/core/memory/providers/transcript-recall.js.map +1 -0
  18. package/dist/core/memory/transcript-index.d.ts +22 -0
  19. package/dist/core/memory/transcript-index.d.ts.map +1 -0
  20. package/dist/core/memory/transcript-index.js +85 -0
  21. package/dist/core/memory/transcript-index.js.map +1 -0
  22. package/dist/core/resource-loader.d.ts +26 -0
  23. package/dist/core/resource-loader.d.ts.map +1 -1
  24. package/dist/core/resource-loader.js +53 -14
  25. package/dist/core/resource-loader.js.map +1 -1
  26. package/dist/core/system-prompt.d.ts +3 -0
  27. package/dist/core/system-prompt.d.ts.map +1 -1
  28. package/dist/core/system-prompt.js +54 -7
  29. package/dist/core/system-prompt.js.map +1 -1
  30. package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
  31. package/dist/modes/interactive/components/profile-resource-editor.js +6 -2
  32. package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
  33. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  34. package/dist/modes/interactive/interactive-mode.js +6 -3
  35. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  36. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  37. package/dist/modes/rpc/rpc-mode.js +1 -1
  38. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  39. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  40. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  41. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  42. package/examples/extensions/sandbox/package-lock.json +2 -2
  43. package/examples/extensions/sandbox/package.json +1 -1
  44. package/examples/extensions/with-deps/package-lock.json +2 -2
  45. package/examples/extensions/with-deps/package.json +1 -1
  46. package/examples/sdk/12-full-control.ts +3 -0
  47. package/npm-shrinkwrap.json +12 -12
  48. package/package.json +4 -4
@@ -34,6 +34,7 @@ import { emitSessionShutdownEvent } from "./extensions/runner.js";
34
34
  import { decideDemand, ReflectionEngine, } from "./learning/reflection-engine.js";
35
35
  import { MemoryManager } from "./memory/memory-manager.js";
36
36
  import { FileStoreProvider } from "./memory/providers/file-store.js";
37
+ import { TranscriptRecallProvider } from "./memory/providers/transcript-recall.js";
37
38
  import { compactToolResultDetailsForRetention } from "./message-retention.js";
38
39
  import { resolveProfileModelSettings } from "./model-resolver.js";
39
40
  import { expandPromptTemplate } from "./prompt-templates.js";
@@ -777,7 +778,7 @@ export class AgentSession {
777
778
  }
778
779
  /** File-based prompt templates */
779
780
  get promptTemplates() {
780
- return this._resourceLoader.getPrompts().prompts;
781
+ return this._resourceLoader.getActivePrompts();
781
782
  }
782
783
  _normalizePromptSnippet(text) {
783
784
  if (!text)
@@ -886,7 +887,9 @@ export class AgentSession {
886
887
  ...loaderAppendSystemPrompt,
887
888
  ].filter((part) => Boolean(part));
888
889
  const appendSystemPrompt = appendSystemPromptParts.length > 0 ? appendSystemPromptParts.join("\n\n") : undefined;
889
- const loadedSkills = this._resourceLoader.getSkills().skills;
890
+ // Only surface skills the active profile permits — the agent must not be told about (or able
891
+ // to invoke) a skill its profile blocks.
892
+ const loadedSkills = this._resourceLoader.getActiveSkills();
890
893
  const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
891
894
  this._baseSystemPromptOptions = {
892
895
  cwd: this._cwd,
@@ -897,6 +900,7 @@ export class AgentSession {
897
900
  selectedTools: validToolNames,
898
901
  toolSnippets,
899
902
  promptGuidelines,
903
+ extensions: [...this._extensionRunner.activeExtensions],
900
904
  };
901
905
  return buildSystemPrompt(this._baseSystemPromptOptions);
902
906
  }
@@ -957,6 +961,18 @@ export class AgentSession {
957
961
  }
958
962
  return this._promptUnserialized(text, options);
959
963
  }
964
+ /**
965
+ * Zero-I/O gate for cross-session recall (R3): skip trivial turns (short acks, slash commands) so
966
+ * recall only runs when it could plausibly help. The provider's similarity cutoff is the real
967
+ * filter — this just avoids the index query on turns that obviously don't warrant it.
968
+ */
969
+ _shouldAttemptRecall(text) {
970
+ const t = text.trim();
971
+ if (t.length < 12 || t.startsWith("/"))
972
+ return false;
973
+ const words = t.split(/\s+/).filter((w) => w.length >= 3);
974
+ return words.length >= 3;
975
+ }
960
976
  async _promptUnserialized(text, options) {
961
977
  const expandPromptTemplates = options?.expandPromptTemplates ?? true;
962
978
  const processSlashCommands = options?.processSlashCommands ?? expandPromptTemplates;
@@ -1040,8 +1056,23 @@ export class AgentSession {
1040
1056
  if (lastAssistant) {
1041
1057
  await this._checkCompaction(lastAssistant, false);
1042
1058
  }
1043
- // Build messages array (custom message if any, then user message)
1059
+ // Build messages array (recall page, then custom message if any, then user message)
1044
1060
  messages = [];
1061
+ // R3: cross-session similarity recall. For a substantive turn, ask the memory providers to
1062
+ // prefetch a relevant <memory_context> page from past sessions and prepend it as data ahead of
1063
+ // the user message. Best-effort and gated: trivial turns are skipped, and providers return ""
1064
+ // (no page) when nothing is relevant — so it stays net-negative and the GC packs stale pages.
1065
+ if (this._shouldAttemptRecall(expandedText)) {
1066
+ try {
1067
+ const recall = await this._memoryManager.prefetch(expandedText);
1068
+ if (recall) {
1069
+ messages.push({ role: "user", content: [{ type: "text", text: recall }], timestamp: Date.now() });
1070
+ }
1071
+ }
1072
+ catch {
1073
+ // recall must never break a turn
1074
+ }
1075
+ }
1045
1076
  // Add user message
1046
1077
  const userContent = [{ type: "text", text: expandedText }];
1047
1078
  if (currentImages) {
@@ -1133,9 +1164,11 @@ export class AgentSession {
1133
1164
  const spaceIndex = text.indexOf(" ");
1134
1165
  const skillName = spaceIndex === -1 ? text.slice(7) : text.slice(7, spaceIndex);
1135
1166
  const args = spaceIndex === -1 ? "" : text.slice(spaceIndex + 1).trim();
1136
- const skill = this.resourceLoader.getSkills().skills.find((s) => s.name === skillName);
1167
+ // Resolve only against profile-active skills so a `/skill:` the active profile blocks cannot be
1168
+ // expanded/invoked — by the user OR the agent — even if it loaded before a runtime profile switch.
1169
+ const skill = this.resourceLoader.getActiveSkills().find((s) => s.name === skillName);
1137
1170
  if (!skill)
1138
- return text; // Unknown skill, pass through
1171
+ return text; // Unknown or profile-blocked skill, pass through unchanged
1139
1172
  try {
1140
1173
  const content = readFileSync(skill.filePath, "utf-8");
1141
1174
  const body = stripResourceProfileBlocks(stripFrontmatter(content)).trim();
@@ -2031,7 +2064,7 @@ export class AgentSession {
2031
2064
  source: "prompt",
2032
2065
  sourceInfo: template.sourceInfo,
2033
2066
  }));
2034
- const skills = this._resourceLoader.getSkills().skills.map((skill) => ({
2067
+ const skills = this._resourceLoader.getActiveSkills().map((skill) => ({
2035
2068
  name: `skill:${skill.name}`,
2036
2069
  description: skill.description,
2037
2070
  source: "skill",
@@ -2197,6 +2230,9 @@ export class AgentSession {
2197
2230
  await this._memoryManager.shutdownAll().catch(() => { });
2198
2231
  const manager = new MemoryManager();
2199
2232
  manager.registerProvider(new FileStoreProvider());
2233
+ // Bundled read-only cross-session recall (R3): indexes past-session transcripts and answers
2234
+ // prefetch() with a <memory_context> page. Never writes.
2235
+ manager.registerProvider(new TranscriptRecallProvider());
2200
2236
  for (const provider of this._pendingMemoryProviders) {
2201
2237
  try {
2202
2238
  manager.registerProvider(provider);