Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/i18n/README.ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ memory({ mode: "import", inputPath: "./memories.json" });

اختياريًا ثبّت متغير استدلال للنموذج بـ `"opencodeVariant": "xhigh"` (مثلًا لـ grok-4.7). يُطبَّق على استدعاءات LLM الداخلية للمكون الإضافي (ملخصات الالتقاط التلقائي، تعلّم الملف، تنظيف الملف)، بما في ذلك عندما يكون `opencodeModel` هو `"inherit"`، حتى يمكن للعمل الخلفي استخدام مستوى استدلال مختلف عن الجلسة التفاعلية.

نماذج الاستدلال البطيئة (أو مطالبات الملف الكبيرة جدًا) يمكن أن تتجاوز ميزانية المخرجات المنظمة الافتراضية البالغة 90 ثانية. عيّن `"opencodeTimeoutMs"` (بالمللي ثانية) لتمديدها لاستدعاءات المخرجات المنظمة الداخلية (ملخصات الالتقاط التلقائي، تعلّم الملف) — مثلًا `"opencodeTimeoutMs": 180000` لمدة 3 دقائق. تُقيَّد القيم إلى 10000..600000؛ يبقى الافتراضي 90000. تُحوَّل السلاسل الرقمية. يستخدم تنظيف الملف مهلة منفصلة أطول.
نماذج الاستدلال البطيئة (أو مطالبات الملف الكبيرة جدًا) يمكن أن تتجاوز ميزانية المخرجات المنظمة الافتراضية البالغة 90 ثانية. عيّن `"opencodeTimeoutMs"` (بالمللي ثانية) لتمديدها لاستدعاءات المخرجات المنظمة الداخلية (ملخصات الالتقاط التلقائي، تعلّم الملف) — مثلًا `"opencodeTimeoutMs": 180000` لمدة 3 دقائق. تُقيَّد القيم إلى 10000..600000؛ يبقى الافتراضي 90000. تُحوَّل السلاسل الرقمية.

مهل تنظيف الملف منفصلة: تنظيف API الخارجي/اليدوي افتراضيًا 60 ثانية عبر `"userProfileCleanupTimeoutMs"` (نفس التقييد 10000..600000؛ مثلًا `"userProfileCleanupTimeoutMs": 180000`). يحتفظ تنظيف جلسة OpenCode بميزانية ثابتة 300 ثانية. تُشتق مهلة خمول HTTP في Node كـ `max(userProfileCleanupTimeoutMs, 300000) + 30000`، ويسمح جلب واجهة الويب لـ `/ai-cleanup` حتى 630 ثانية حتى لا تقطع أي طبقة الموعد النهائي الخارجي المرفوع.

المزودون المدعومون: أي مزود يدرجه `opencode providers list` (مثل `anthropic`، `openai`، `github-copilot`، `openrouter`، ...).

Expand Down
4 changes: 3 additions & 1 deletion .github/i18n/README.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ Das Plugin stellt strukturierte Output-Requests an die Session-API von opencode,

Optional eine Reasoning-Variante des Modells mit `"opencodeVariant": "xhigh"` pinnen (z. B. für grok-4.7). Sie gilt für die internen LLM-Aufrufe des Plugins (Auto-Capture-Zusammenfassungen, Profil-Lernen, Profil-Cleanup), auch wenn `opencodeModel` `"inherit"` ist, sodass Hintergrundarbeit ein anderes Reasoning-Level als die interaktive Sitzung nutzen kann.

Langsame Reasoning-Modelle (oder sehr große Profil-Prompts) können das Standard-Budget von 90 s für strukturierte Ausgabe überschreiten. `"opencodeTimeoutMs"` (Millisekunden) setzen, um es für interne Structured-Output-Aufrufe (Auto-Capture-Zusammenfassungen, Profil-Lernen) zu verlängern — z. B. `"opencodeTimeoutMs": 180000` für 3 Minuten. Werte werden auf 10000..600000 geklemmt; der Standard bleibt 90000. Numerische Strings werden coerced. Profil-Cleanup nutzt ein separates, längeres Timeout.
Langsame Reasoning-Modelle (oder sehr große Profil-Prompts) können das Standard-Budget von 90 s für strukturierte Ausgabe überschreiten. `"opencodeTimeoutMs"` (Millisekunden) setzen, um es für interne Structured-Output-Aufrufe (Auto-Capture-Zusammenfassungen, Profil-Lernen) zu verlängern — z. B. `"opencodeTimeoutMs": 180000` für 3 Minuten. Werte werden auf 10000..600000 geklemmt; der Standard bleibt 90000. Numerische Strings werden coerced.

Profil-Cleanup-Timeouts sind separat: externes/manuelles API-Cleanup defaultet auf 60 s über `"userProfileCleanupTimeoutMs"` (gleiche Klemme 10000..600000; z. B. `"userProfileCleanupTimeoutMs": 180000`). OpenCode-Session-Cleanup behält ein festes 300-s-Budget. Das Node-HTTP-Idle-Timeout wird als `max(userProfileCleanupTimeoutMs, 300000) + 30000` abgeleitet, und der Web-UI-Fetch für `/ai-cleanup` erlaubt bis 630 s, damit keine Schicht ein erhöhtes externes Deadline unterbietet.

Unterstützte Provider: jeder von `opencode providers list` gelistete Provider (z. B. `anthropic`, `openai`, `github-copilot`, `openrouter`, ...).

Expand Down
4 changes: 3 additions & 1 deletion .github/i18n/README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ Le plugin émet des requêtes à sortie structurée vers l'API de session d'open

Optionnellement, épinglez une variante de raisonnement du modèle avec `"opencodeVariant": "xhigh"` (p. ex. pour grok-4.7). Elle s'applique aux appels LLM internes du plugin (résumés d'auto-capture, apprentissage du profil, nettoyage du profil), y compris quand `opencodeModel` vaut `"inherit"`, pour que le travail d'arrière-plan puisse utiliser un niveau de raisonnement différent de la session interactive.

Les modèles de raisonnement lents (ou les très gros prompts de profil) peuvent dépasser le budget de sortie structurée par défaut de 90 s. Définissez `"opencodeTimeoutMs"` (millisecondes) pour l'étendre pour les appels internes à sortie structurée (résumés d'auto-capture, apprentissage du profil) — p. ex. `"opencodeTimeoutMs": 180000` pour 3 minutes. Les valeurs sont bornées à 10000..600000 ; le défaut reste 90000. Les chaînes numériques sont converties. Le nettoyage du profil utilise un timeout séparé, plus long.
Les modèles de raisonnement lents (ou les très gros prompts de profil) peuvent dépasser le budget de sortie structurée par défaut de 90 s. Définissez `"opencodeTimeoutMs"` (millisecondes) pour l'étendre pour les appels internes à sortie structurée (résumés d'auto-capture, apprentissage du profil) — p. ex. `"opencodeTimeoutMs": 180000` pour 3 minutes. Les valeurs sont bornées à 10000..600000 ; le défaut reste 90000. Les chaînes numériques sont converties.

Les timeouts de nettoyage du profil sont séparés : le nettoyage API externe/manuel vaut 60 s par défaut via `"userProfileCleanupTimeoutMs"` (même borne 10000..600000 ; p. ex. `"userProfileCleanupTimeoutMs": 180000`). Le nettoyage via session OpenCode garde un budget fixe de 300 s. Le timeout d'inactivité HTTP Node est dérivé comme `max(userProfileCleanupTimeoutMs, 300000) + 30000`, et le fetch Web UI de `/ai-cleanup` autorise jusqu'à 630 s pour qu'aucune couche ne sous-coupe une échéance externe relevée.

Fournisseurs pris en charge : tout fournisseur listé par `opencode providers list` (p. ex. `anthropic`, `openai`, `github-copilot`, `openrouter`, ...).

Expand Down
4 changes: 3 additions & 1 deletion .github/i18n/README.nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ De plugin stuurt structured-output-verzoeken naar de session-API van opencode in

Optioneel kun je een model-reasoningvariant vastzetten met `"opencodeVariant": "xhigh"` (bijv. voor grok-4.7). Die wordt toegepast op de interne LLM-calls van de plugin (auto-capture-samenvattingen, profiel-leren, profielopschoning), ook wanneer `opencodeModel` `"inherit"` is, zodat achtergrondwerk een ander reasoningniveau kan gebruiken dan de interactieve sessie.

Trage reasoningmodellen (of zeer grote profielprompts) kunnen het standaard 90 s structured-output-budget overschrijden. Stel `"opencodeTimeoutMs"` (milliseconden) in om het te verlengen voor interne structured-output-calls (auto-capture-samenvattingen, profiel-leren) — bijv. `"opencodeTimeoutMs": 180000` voor 3 minuten. Waarden worden geclampt tot 10000..600000; de standaard blijft 90000. Numerieke strings worden gecoeerd. Profielopschoning gebruikt een aparte, langere timeout.
Trage reasoningmodellen (of zeer grote profielprompts) kunnen het standaard 90 s structured-output-budget overschrijden. Stel `"opencodeTimeoutMs"` (milliseconden) in om het te verlengen voor interne structured-output-calls (auto-capture-samenvattingen, profiel-leren) — bijv. `"opencodeTimeoutMs": 180000` voor 3 minuten. Waarden worden geclampt tot 10000..600000; de standaard blijft 90000. Numerieke strings worden gecoeerd.

Profielopschonings-timeouts zijn apart: externe/handmatige API-opschoning default naar 60 s via `"userProfileCleanupTimeoutMs"` (zelfde clamp 10000..600000; bijv. `"userProfileCleanupTimeoutMs": 180000`). OpenCode-sessie-opschoning houdt een vast 300 s-budget. De Node HTTP-idle-timeout wordt afgeleid als `max(userProfileCleanupTimeoutMs, 300000) + 30000`, en de Web UI-fetch voor `/ai-cleanup` staat tot 630 s toe zodat geen laag een verhoogde externe deadline ondermijnt.

Ondersteunde providers: elke provider uit `opencode providers list` (bijv. `anthropic`, `openai`, `github-copilot`, `openrouter`, ...).

Expand Down
4 changes: 3 additions & 1 deletion .github/i18n/README.tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ Eklenti, sağlayıcı uç noktalarını doğrudan çağırmak yerine yapılandı

İsteğe bağlı olarak `"opencodeVariant": "xhigh"` ile bir model muhakeme varyantını sabitleyin (örn. grok-4.7 için). Eklentinin dahili LLM çağrılarına uygulanır (otomatik yakalama özetleri, profil öğrenme, profil temizleme); `opencodeModel` `"inherit"` olsa bile, böylece arka plan çalışması etkileşimli oturumdan farklı bir muhakeme düzeyi kullanabilir.

Yavaş muhakeme modelleri (veya çok büyük profil prompt’ları) varsayılan 90 sn yapılandırılmış çıktı bütçesini aşabilir. Dahili yapılandırılmış çıktı çağrıları (otomatik yakalama özetleri, profil öğrenme) için uzatmak üzere `"opencodeTimeoutMs"` (milisaniye) ayarlayın — örn. 3 dakika için `"opencodeTimeoutMs": 180000`. Değerler 10000..600000’e sıkıştırılır; varsayılan 90000 kalır. Sayısal dizgeler zorlanır. Profil temizleme ayrı, daha uzun bir zaman aşımı kullanır.
Yavaş muhakeme modelleri (veya çok büyük profil prompt’ları) varsayılan 90 sn yapılandırılmış çıktı bütçesini aşabilir. Dahili yapılandırılmış çıktı çağrıları (otomatik yakalama özetleri, profil öğrenme) için uzatmak üzere `"opencodeTimeoutMs"` (milisaniye) ayarlayın — örn. 3 dakika için `"opencodeTimeoutMs": 180000`. Değerler 10000..600000’e sıkıştırılır; varsayılan 90000 kalır. Sayısal dizgeler zorlanır.

Profil temizleme zaman aşımları ayrıdır: harici/manuel API temizleme `"userProfileCleanupTimeoutMs"` ile varsayılan 60 sn’dir (aynı 10000..600000 sıkıştırma; örn. `"userProfileCleanupTimeoutMs": 180000`). OpenCode oturum temizliği sabit 300 sn bütçesini korur. Node HTTP boşta kalma zaman aşımı `max(userProfileCleanupTimeoutMs, 300000) + 30000` olarak türetilir ve Web UI `/ai-cleanup` fetch’i 630 sn’ye kadar izin verir; böylece hiçbir katman yükseltilmiş harici son tarihi altından kesmez.

Desteklenen sağlayıcılar: `opencode providers list` tarafından listelenen herhangi bir sağlayıcı (örn. `anthropic`, `openai`, `github-copilot`, `openrouter`, ...).

Expand Down
4 changes: 3 additions & 1 deletion .github/i18n/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ memory({ mode: "import", inputPath: "./memories.json" });

可选地用 `"opencodeVariant": "xhigh"` 固定模型推理变体(例如用于 grok-4.7)。它会应用于插件的内部 LLM 调用(自动捕获摘要、画像学习、画像清理),包括当 `opencodeModel` 为 `"inherit"` 时,以便后台工作可以使用与交互式会话不同的推理级别。

慢速推理模型(或非常大的画像提示)可能超过默认的 90 秒结构化输出预算。设置 `"opencodeTimeoutMs"`(毫秒)可为内部结构化输出调用(自动捕获摘要、画像学习)延长 — 例如 `"opencodeTimeoutMs": 180000` 表示 3 分钟。值钳制在 10000..600000;默认保持 90000。数字字符串会被强制转换。画像清理使用单独的、更长的超时。
慢速推理模型(或非常大的画像提示)可能超过默认的 90 秒结构化输出预算。设置 `"opencodeTimeoutMs"`(毫秒)可为内部结构化输出调用(自动捕获摘要、画像学习)延长 — 例如 `"opencodeTimeoutMs": 180000` 表示 3 分钟。值钳制在 10000..600000;默认保持 90000。数字字符串会被强制转换。

画像清理超时是单独的:外部/手动 API 清理默认 60 秒,通过 `"userProfileCleanupTimeoutMs"`(同样钳制在 10000..600000;例如 `"userProfileCleanupTimeoutMs": 180000`)。OpenCode 会话清理保持固定的 300 秒预算。Node HTTP 空闲超时按 `max(userProfileCleanupTimeoutMs, 300000) + 30000` 推导,Web UI 对 `/ai-cleanup` 的 fetch 最多允许 630 秒,这样任一层都不会低于提高后的外部截止时间。

支持的提供商:`opencode providers list` 列出的任何提供商(例如 `anthropic`、`openai`、`github-copilot`、`openrouter` 等)。

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ The plugin issues structured-output requests to opencode's session API instead o

Optionally pin a model reasoning variant with `"opencodeVariant": "xhigh"` (e.g. for grok-4.7). It is applied to the plugin's internal LLM calls (auto-capture summaries, profile learning, profile cleanup), including when `opencodeModel` is `"inherit"`, so background work can use a different reasoning level than the interactive session.

Slow reasoning models (or very large profile prompts) can exceed the default 90 s structured-output budget. Set `"opencodeTimeoutMs"` (milliseconds) to extend it for internal structured-output calls (auto-capture summaries, profile learning) — e.g. `"opencodeTimeoutMs": 180000` for 3 minutes. Values are clamped to 10000..600000; the default stays 90000. Numeric strings are coerced. Profile cleanup uses a separate, longer timeout.
Slow reasoning models (or very large profile prompts) can exceed the default 90 s structured-output budget. Set `"opencodeTimeoutMs"` (milliseconds) to extend it for internal structured-output calls (auto-capture summaries, profile learning) — e.g. `"opencodeTimeoutMs": 180000` for 3 minutes. Values are clamped to 10000..600000; the default stays 90000. Numeric strings are coerced.

Profile cleanup timeouts are separate: external/manual-API cleanup defaults to 60 s via `"userProfileCleanupTimeoutMs"` (same 10000..600000 clamp; e.g. `"userProfileCleanupTimeoutMs": 180000`). OpenCode-session cleanup keeps a fixed 300 s budget. The Node HTTP idle timeout is derived as `max(userProfileCleanupTimeoutMs, 300000) + 30000`, and the Web UI `/ai-cleanup` fetch allows up to 630 s so neither layer undercuts a raised external deadline.

Supported providers: any provider listed by `opencode providers list` (e.g. `anthropic`, `openai`, `github-copilot`, `openrouter`, ...).

Expand Down
4 changes: 4 additions & 0 deletions opencode-mem.example.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@
"userProfileAutoCleanupEnabled": true,
// Number of analyzed user prompts between automatic AI cleanup runs
"userProfileAutoCleanupInterval": 100,
// Abort deadline (ms) for external/manual-API profile cleanup (default 60000, clamped to 10000..600000).
// OpenCode-session cleanup keeps a separate longer timeout (300000). Node HTTP idle timeout
// is derived as max(this, opencode cleanup) + 30000 so the server never undercuts the provider call.
// "userProfileCleanupTimeoutMs": 180000,

// Enable LLM validation of existing preferences against recent behavior.
// When enabled, each analysis round checks if top-5 preferences still match recent prompts.
Expand Down
55 changes: 49 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ interface OpenCodeMemConfig {
/**
* Timeout in milliseconds for the plugin's internal structured-output LLM
* calls (auto-capture summaries, profile learning). Profile cleanup keeps
* its own longer timeout. Clamped to 10000..600000; non-number/non-finite
* values (and non-numeric strings) fall back to the 90000 default. Numeric
* strings like "180000" are coerced.
* its own longer timeout (see `userProfileCleanupTimeoutMs` for the external
* path). Clamped to 10000..600000; non-number/non-finite values (and
* non-numeric strings) fall back to the 90000 default. Numeric strings like
* "180000" are coerced.
*/
opencodeTimeoutMs?: number;
aiSessionRetentionDays?: number;
Expand Down Expand Up @@ -188,6 +189,12 @@ interface OpenCodeMemConfig {
userProfileMinEvidenceForRetention?: number;
userProfileAutoCleanupEnabled?: boolean;
userProfileAutoCleanupInterval?: number;
/**
* Abort deadline (ms) for external/manual-API profile cleanup. Default 60000,
* clamped to 10000..600000. OpenCode-session cleanup keeps its own longer
* timeout. The Node HTTP idle timeout is derived above this value.
*/
userProfileCleanupTimeoutMs?: number;
userProfileValidationEnabled?: boolean;
showAutoCaptureToasts?: boolean;
showUserProfileToasts?: boolean;
Expand Down Expand Up @@ -405,6 +412,7 @@ const DEFAULTS: Required<
userProfileMinEvidenceForRetention: 3,
userProfileAutoCleanupEnabled: true,
userProfileAutoCleanupInterval: 100,
userProfileCleanupTimeoutMs: 60_000,
userProfileValidationEnabled: false,
showAutoCaptureToasts: true,
showUserProfileToasts: true,
Expand Down Expand Up @@ -916,6 +924,10 @@ const CONFIG_TEMPLATE = `{
"userProfileAutoCleanupEnabled": true,
// Number of analyzed user prompts between automatic AI cleanup runs
"userProfileAutoCleanupInterval": 100,
// Abort deadline (ms) for external/manual-API profile cleanup (default 60000, clamped to 10000..600000).
// OpenCode-session cleanup keeps a separate longer timeout (300000). Node HTTP idle timeout
// is derived as max(this, opencode cleanup) + 30000 so the server never undercuts the provider call.
// "userProfileCleanupTimeoutMs": 180000,

// Enable LLM validation of existing preferences against recent behavior.
// When enabled, each analysis round checks if top-5 preferences still match recent prompts.
Expand Down Expand Up @@ -1184,16 +1196,44 @@ export const OPENCODE_TIMEOUT_MS_DEFAULT = 90_000;
* clamped to [OPENCODE_TIMEOUT_MS_MIN, OPENCODE_TIMEOUT_MS_MAX].
*/
export function normalizeOpencodeTimeoutMs(value: unknown): number {
return normalizeClampedTimeoutMs(value, {
min: OPENCODE_TIMEOUT_MS_MIN,
max: OPENCODE_TIMEOUT_MS_MAX,
fallback: OPENCODE_TIMEOUT_MS_DEFAULT,
});
}

export const USER_PROFILE_CLEANUP_TIMEOUT_MS_MIN = 10_000;
export const USER_PROFILE_CLEANUP_TIMEOUT_MS_MAX = 600_000;
export const USER_PROFILE_CLEANUP_TIMEOUT_MS_DEFAULT = 60_000;

/**
* External profile-cleanup abort deadline: non-number/non-finite values fall
* back to the default (numeric strings are coerced first), otherwise clamped
* to [USER_PROFILE_CLEANUP_TIMEOUT_MS_MIN, USER_PROFILE_CLEANUP_TIMEOUT_MS_MAX].
*/
export function normalizeUserProfileCleanupTimeoutMs(value: unknown): number {
return normalizeClampedTimeoutMs(value, {
min: USER_PROFILE_CLEANUP_TIMEOUT_MS_MIN,
max: USER_PROFILE_CLEANUP_TIMEOUT_MS_MAX,
fallback: USER_PROFILE_CLEANUP_TIMEOUT_MS_DEFAULT,
});
}

function normalizeClampedTimeoutMs(
value: unknown,
opts: { min: number; max: number; fallback: number }
): number {
let numeric = value;
if (typeof value === "string") {
const trimmed = value.trim();
if (trimmed.length === 0) return OPENCODE_TIMEOUT_MS_DEFAULT;
if (trimmed.length === 0) return opts.fallback;
numeric = Number(trimmed);
}
if (typeof numeric !== "number" || !Number.isFinite(numeric)) {
return OPENCODE_TIMEOUT_MS_DEFAULT;
return opts.fallback;
}
return Math.min(OPENCODE_TIMEOUT_MS_MAX, Math.max(OPENCODE_TIMEOUT_MS_MIN, numeric));
return Math.min(opts.max, Math.max(opts.min, numeric));
}

/**
Expand Down Expand Up @@ -1512,6 +1552,9 @@ function buildConfig(fileConfig: OpenCodeMemConfig) {
userProfileAutoCleanupEnabled:
fileConfig.userProfileAutoCleanupEnabled ?? DEFAULTS.userProfileAutoCleanupEnabled,
userProfileAutoCleanupInterval,
userProfileCleanupTimeoutMs: normalizeUserProfileCleanupTimeoutMs(
fileConfig.userProfileCleanupTimeoutMs
),
userProfileValidationEnabled:
fileConfig.userProfileValidationEnabled ?? DEFAULTS.userProfileValidationEnabled,
userProfileStaleDays: fileConfig.userProfileStaleDays ?? DEFAULTS.userProfileStaleDays,
Expand Down
Loading
Loading