@caupulican/pi-adaptative 0.80.4 → 0.80.5

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.
@@ -20,6 +20,7 @@ import { createCompactionSummaryMessage } from "../../core/messages.js";
20
20
  import { defaultModelPerProvider, findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
21
21
  import { DefaultPackageManager } from "../../core/package-manager.js";
22
22
  import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "../../core/provider-display-names.js";
23
+ import { getPendingReloadBlockers } from "../../core/reload-blockers.js";
23
24
  import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
24
25
  import { SessionManager } from "../../core/session-manager.js";
25
26
  import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
@@ -3719,6 +3720,9 @@ export class InteractiveMode {
3719
3720
  const promptPath = path.join(dir, `${runId}.prompt.md`);
3720
3721
  const outFd = fs.openSync(logPath, "a");
3721
3722
  const kind = options.promptKind ?? "auto";
3723
+ const sessionDir = path.join(dir, "sessions");
3724
+ const sessionId = `auto-learn-${kind}-${runId}`;
3725
+ fs.mkdirSync(sessionDir, { recursive: true });
3722
3726
  const prompt = this.buildAutoLearnPrompt(reason, settings, {
3723
3727
  kind,
3724
3728
  turnDigest: options.turnDigest,
@@ -3731,6 +3735,10 @@ export class InteractiveMode {
3731
3735
  `Auto Learn ${runId}`,
3732
3736
  "--model",
3733
3737
  modelPattern,
3738
+ "--session-dir",
3739
+ sessionDir,
3740
+ "--session-id",
3741
+ sessionId,
3734
3742
  prompt,
3735
3743
  ];
3736
3744
  const child = spawn(spawnTarget.command, args, {
@@ -3763,6 +3771,8 @@ export class InteractiveMode {
3763
3771
  expiresAt: now + settings.leaseMinutes * 60 * 1000,
3764
3772
  cwd: this.sessionManager.getCwd(),
3765
3773
  logPath,
3774
+ sessionDir,
3775
+ sessionId,
3766
3776
  promptPath,
3767
3777
  kind,
3768
3778
  autonomyMode: this.settingsManager.getAutonomySettings().mode,
@@ -3949,13 +3959,30 @@ export class InteractiveMode {
3949
3959
  const cooldownText = decision.cooldownRemainingMs > 0 ? `${Math.ceil(decision.cooldownRemainingMs / 60000)}m remaining` : "ready";
3950
3960
  const runLines = runs.length
3951
3961
  ? runs
3952
- .map(([id, run]) => `- ${id}: ${run.model}, kind=${run.kind ?? "auto"}, authority=${run.authority ?? "unknown"}, pid=${run.pid ?? "?"}, log=${run.logPath}`)
3962
+ .map(([id, run]) => {
3963
+ const session = [
3964
+ run.sessionId ? `session=${run.sessionId}` : "",
3965
+ run.sessionDir ? `sessionDir=${run.sessionDir}` : "",
3966
+ ]
3967
+ .filter(Boolean)
3968
+ .join(", ");
3969
+ const sessionText = session ? `, ${session}` : "";
3970
+ return `- ${id}: ${run.model}, kind=${run.kind ?? "auto"}, authority=${run.authority ?? "unknown"}, pid=${run.pid ?? "?"}${sessionText}, log=${run.logPath}`;
3971
+ })
3953
3972
  .join("\n")
3954
3973
  : "- none";
3974
+ const reloadBlockers = getPendingReloadBlockers({
3975
+ ownPid: process.pid,
3976
+ ownSessionId: this.sessionManager.getSessionId(),
3977
+ ownSessionFile: this.sessionManager.getSessionFile(),
3978
+ });
3979
+ const reloadBlockerLines = reloadBlockers.pending
3980
+ ? reloadBlockers.descriptions.map((description) => `- ${description}`).join("\n")
3981
+ : "- none";
3955
3982
  const reflectionLast = state.lastReflectionByTenant?.[this.getAutoLearnTenantKey()] ?? 0;
3956
3983
  const reflectionCooldownRemainingMs = Math.max(0, reflectionLast + settings.reflectionCooldownMinutes * 60 * 1000 - Date.now());
3957
3984
  const reflectionCooldownText = reflectionCooldownRemainingMs > 0 ? `${Math.ceil(reflectionCooldownRemainingMs / 60000)}m remaining` : "ready";
3958
- return `Auto Learn status\nEnabled: ${settings.enabled}\nModel: ${settings.model}\nNext decision: ${decision.shouldRun ? "ready" : decision.reason}\nMessages: ${decision.messageCount}/${settings.longSessionMessages}\nContext: ${contextText}/${settings.longSessionContextPercent}%\nCooldown: ${cooldownText}\nReflection review: ${settings.reflectionReview ? "enabled" : "disabled"} (tool trigger ${settings.reflectionMinToolCalls}, cooldown ${reflectionCooldownText})\nRunning leases: ${runs.length}/${settings.maxConcurrentLearners}\nRuns:\n${runLines}`;
3985
+ return `Auto Learn status\nEnabled: ${settings.enabled}\nModel: ${settings.model}\nNext decision: ${decision.shouldRun ? "ready" : decision.reason}\nMessages: ${decision.messageCount}/${settings.longSessionMessages}\nContext: ${contextText}/${settings.longSessionContextPercent}%\nCooldown: ${cooldownText}\nReflection review: ${settings.reflectionReview ? "enabled" : "disabled"} (tool trigger ${settings.reflectionMinToolCalls}, cooldown ${reflectionCooldownText})\nRunning leases: ${runs.length}/${settings.maxConcurrentLearners}\nPi auto-reload blockers: ${reloadBlockers.pending ? reloadBlockers.reason : "none"}\n${reloadBlockerLines}\nRuns:\n${runLines}`;
3959
3986
  }
3960
3987
  formatAutonomyStatus() {
3961
3988
  const autonomy = this.settingsManager.getAutonomySettings();