opencode-codex-memory 0.9.9 → 0.9.11
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.
- package/README.md +2 -2
- package/dist/src/codex-interop.js +1 -1
- package/dist/src/phase2.js +2 -2
- package/dist/src/pipeline.js +2 -1
- package/dist/src/v2/model-readiness.d.ts +8 -0
- package/dist/src/v2/model-readiness.js +43 -0
- package/dist/src/v2/shim.js +14 -3
- package/dist/src/workspace.d.ts +1 -0
- package/dist/src/workspace.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
|
|
|
35
35
|
{
|
|
36
36
|
"$schema": "https://opencode.ai/config.json",
|
|
37
37
|
"plugins": [
|
|
38
|
-
{ "package": "opencode-codex-memory@0.9.
|
|
38
|
+
{ "package": "opencode-codex-memory@0.9.11" }
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
```
|
|
@@ -45,7 +45,7 @@ to your existing global `~/.config/opencode/opencode.jsonc` or `opencode.json`
|
|
|
45
45
|
```json
|
|
46
46
|
{
|
|
47
47
|
"$schema": "https://opencode.ai/config.json",
|
|
48
|
-
"plugin": ["opencode-codex-memory@0.9.
|
|
48
|
+
"plugin": ["opencode-codex-memory@0.9.11"]
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -36,7 +36,7 @@ import { readRegularFileNoFollow, safeResolveUnderRoot, writeRegularFileNoFollow
|
|
|
36
36
|
* artifacts-gone => resources removed (deletion is the forgetting signal in
|
|
37
37
|
* the workspace diff) while an unreachable source ROOT is a no-op, never a
|
|
38
38
|
* deletion signal. Resource files are nested under a subdirectory and carry
|
|
39
|
-
* no timestamp prefix, so extension-resource pruning (
|
|
39
|
+
* no timestamp prefix, so extension-resource pruning (14-day retention,
|
|
40
40
|
* top-level timestamped files only) never touches them — same retention
|
|
41
41
|
* exemption codex relies on for external_agent_import.
|
|
42
42
|
*/
|
package/dist/src/phase2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PHASE2_HEARTBEAT_SECONDS } from "./store.js";
|
|
2
2
|
import { checkRateLimit, isProviderCapacityError, noteProviderCapacityExhausted } from "./ratelimit.js";
|
|
3
|
-
import { ensureLayout, rebuildRawMemories, writeRolloutSummaries, pruneExtensionResources, writeWorkspaceDiff, validateConsolidationArtifactsForVersion, removeMemorySymlinks, } from "./workspace.js";
|
|
3
|
+
import { ensureLayout, rebuildRawMemories, writeRolloutSummaries, pruneExtensionResources, EXTENSION_RESOURCE_RETENTION_DAYS, writeWorkspaceDiff, validateConsolidationArtifactsForVersion, removeMemorySymlinks, } from "./workspace.js";
|
|
4
4
|
import { ensureBaseline, captureWorkspaceDiff, resetBaseline, DIFF_ARTIFACT } from "./git-baseline.js";
|
|
5
5
|
import { consolidateViaSubagent, getPluginInput, SubagentCancelledError, SubagentShutdownError, } from "./llm.js";
|
|
6
6
|
import { hostSessionLiveness, withHostTimeout } from "./host-client.js";
|
|
@@ -13,7 +13,7 @@ import { syncClaudeImport } from "./claude-import.js";
|
|
|
13
13
|
export const DEFAULT_PHASE2_OPTIONS = {
|
|
14
14
|
maxRaw: 256,
|
|
15
15
|
maxUnusedDays: 30,
|
|
16
|
-
extensionRetentionDays:
|
|
16
|
+
extensionRetentionDays: EXTENSION_RESOURCE_RETENTION_DAYS,
|
|
17
17
|
};
|
|
18
18
|
// Export runs only after a successful phase 2 (fresh, validated artifacts) and
|
|
19
19
|
// must never fail the run — Codex's workspace is best-effort foreign territory.
|
package/dist/src/pipeline.js
CHANGED
|
@@ -6,13 +6,14 @@ import { memoryDbPath } from "./paths.js";
|
|
|
6
6
|
import { withMemoryVersion, writeMemoryVersions } from "./memory-version.js";
|
|
7
7
|
import { isPluginShuttingDown } from "./lifecycle.js";
|
|
8
8
|
import { recordDiagnostic } from "./diagnostics.js";
|
|
9
|
+
import { EXTENSION_RESOURCE_RETENTION_DAYS } from "./workspace.js";
|
|
9
10
|
const extracting = new Set();
|
|
10
11
|
async function consolidate(store, bypassCooldown) {
|
|
11
12
|
try {
|
|
12
13
|
const result = await runPhase2(store, {
|
|
13
14
|
maxRaw: pluginOptions.max_raw_memories_for_consolidation,
|
|
14
15
|
maxUnusedDays: pluginOptions.max_unused_days,
|
|
15
|
-
extensionRetentionDays:
|
|
16
|
+
extensionRetentionDays: EXTENSION_RESOURCE_RETENTION_DAYS,
|
|
16
17
|
consolidationModel: pluginOptions.consolidation_model,
|
|
17
18
|
codexInterop: pluginOptions.codex_interop,
|
|
18
19
|
claudeImport: pluginOptions.claude_import,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ModelRef = {
|
|
2
|
+
providerID: string;
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
/** Only retry host selection failures: these occur before any inference. */
|
|
6
|
+
export declare function isModelSelectionUnavailable(error: unknown, model?: ModelRef): boolean;
|
|
7
|
+
export declare function retryModelSelection<T>(request: () => Promise<T>, model?: ModelRef, signal?: AbortSignal, delays?: readonly number[]): Promise<T>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
2
|
+
import { recordDiagnostic } from "../diagnostics.js";
|
|
3
|
+
// Startup provider registrations can lag service health. Bound the wait rather
|
|
4
|
+
// than silently changing models or indefinitely hiding a configuration error.
|
|
5
|
+
const RETRY_DELAYS_MS = [250, 500, 1_000, 2_000, 4_000, 8_000, 15_000, 15_000];
|
|
6
|
+
/** Only retry host selection failures: these occur before any inference. */
|
|
7
|
+
export function isModelSelectionUnavailable(error, model) {
|
|
8
|
+
const message = model
|
|
9
|
+
? `Model unavailable: ${model.providerID}/${model.id}`
|
|
10
|
+
: "No model specified and no supported model is available";
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
for (let current = error; current && !seen.has(current); current = current.cause ?? current.error) {
|
|
13
|
+
seen.add(current);
|
|
14
|
+
const tag = current._tag ?? current.name;
|
|
15
|
+
if (["InvalidRequestError", "Generate.ModelSelectionError"].includes(tag) && current.message === message)
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
export async function retryModelSelection(request, model, signal, delays = RETRY_DELAYS_MS) {
|
|
21
|
+
const label = model ? `${model.providerID}/${model.id}` : "host default model";
|
|
22
|
+
for (let attempt = 0;; attempt++) {
|
|
23
|
+
signal?.throwIfAborted();
|
|
24
|
+
try {
|
|
25
|
+
const result = await request();
|
|
26
|
+
if (attempt > 0)
|
|
27
|
+
recordDiagnostic("info", "model-readiness", `${label} available after ${attempt} startup retry(s)`);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (signal?.aborted || !isModelSelectionUnavailable(error, model))
|
|
32
|
+
throw error;
|
|
33
|
+
const delay = delays[attempt];
|
|
34
|
+
if (delay === undefined) {
|
|
35
|
+
recordDiagnostic("error", "model-readiness", `${label} still unavailable after ${attempt} startup retry(s)`);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
if (attempt === 0)
|
|
39
|
+
recordDiagnostic("warn", "model-readiness", `${label} not registered yet; waiting for model startup`);
|
|
40
|
+
await sleep(delay, undefined, signal ? { signal } : undefined);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/dist/src/v2/shim.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { memoryRoot } from "../paths.js";
|
|
2
2
|
import { consolidationPermissions } from "./agents.js";
|
|
3
|
+
import { retryModelSelection } from "./model-readiness.js";
|
|
3
4
|
import { invalidateOwnService, lastServiceFailure, ownServiceClient, serviceRequest } from "./service.js";
|
|
4
5
|
let v2ctx = null;
|
|
5
6
|
let discoveryStatus = null;
|
|
@@ -396,13 +397,23 @@ async function v2promptWithWait(sessionID, body, signal) {
|
|
|
396
397
|
throw new Error("sub-agent prompt cancelled");
|
|
397
398
|
const publicClient = await ownServiceClient();
|
|
398
399
|
if (typeof publicClient?.generate?.text === "function") {
|
|
399
|
-
const gen = await
|
|
400
|
+
const gen = und(await retryModelSelection(async () => {
|
|
401
|
+
const result = await serviceRequest(publicClient, () => publicClient.generate.text(payload, signal ? { signal } : undefined));
|
|
402
|
+
if (result?.error)
|
|
403
|
+
throw result.error;
|
|
404
|
+
return result;
|
|
405
|
+
}, payload.model, signal));
|
|
400
406
|
const outText = typeof gen?.text === "string" ? gen.text : JSON.stringify(gen);
|
|
401
407
|
return { data: { parts: [{ type: "text", text: outText }] } };
|
|
402
408
|
}
|
|
403
409
|
// ctx.generate.text ignores request-option signals. Race AbortSignal.
|
|
404
|
-
const
|
|
405
|
-
|
|
410
|
+
const gen = und(await retryModelSelection(async () => {
|
|
411
|
+
const genP = c.generate.text(payload);
|
|
412
|
+
const result = signal ? await raceAbort(genP, signal) : await genP;
|
|
413
|
+
if (result?.error)
|
|
414
|
+
throw result.error;
|
|
415
|
+
return result;
|
|
416
|
+
}, payload.model, signal));
|
|
406
417
|
const outText = typeof gen?.text === "string" ? gen.text : JSON.stringify(gen);
|
|
407
418
|
return { data: { parts: [{ type: "text", text: outText }] } };
|
|
408
419
|
}
|
package/dist/src/workspace.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MemoryVersion } from "./options.js";
|
|
2
2
|
import type { Stage1Output } from "./store.js";
|
|
3
3
|
import { type WorkspaceDiff } from "./git-baseline.js";
|
|
4
|
+
export declare const EXTENSION_RESOURCE_RETENTION_DAYS = 14;
|
|
4
5
|
/** Mirrors codex `remove_memory_symlinks` (workspace.rs): unlink every symlink in the tree, never follow. */
|
|
5
6
|
export declare function removeMemorySymlinks(root?: string): number;
|
|
6
7
|
export declare function ensureLayout(): void;
|
package/dist/src/workspace.js
CHANGED
|
@@ -10,6 +10,8 @@ const ROLLOUT_DIR = "rollout_summaries";
|
|
|
10
10
|
const EXTENSIONS_DIR = "extensions";
|
|
11
11
|
const SKILLS_DIR = "skills";
|
|
12
12
|
const ADHOC_NOTES_DIR = "extensions/ad_hoc/notes";
|
|
13
|
+
// codex memories/write/src/lib.rs extension_resources::RETENTION_DAYS.
|
|
14
|
+
export const EXTENSION_RESOURCE_RETENTION_DAYS = 14;
|
|
13
15
|
// Mirrors codex templates/extensions/ad_hoc/instructions.md: notes are
|
|
14
16
|
// permanent (never pruned, never deleted), authoritative as content but never
|
|
15
17
|
// instructions, and derived info carries an "[ad-hoc note]" provenance tag.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-codex-memory",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"description": "Persistent memory plugin for opencode — ports codex's two-phase memory system (extraction → consolidation → injection → citation feedback)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|