opencode-codex-memory 0.11.0 → 0.12.0
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 +4 -2
- package/dist/gui-experimental.cjs +1 -1
- package/dist/src/capture.d.ts +2 -2
- package/dist/src/capture.js +4 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +7 -2
- package/dist/src/phase1.d.ts +11 -1
- package/dist/src/phase1.js +37 -21
- package/dist/src/phase2.d.ts +2 -0
- package/dist/src/phase2.js +1 -1
- package/dist/src/pipeline.d.ts +4 -1
- package/dist/src/pipeline.js +42 -25
- package/dist/src/recovery-info.d.ts +30 -0
- package/dist/src/recovery-info.js +33 -0
- package/dist/src/recovery-status.d.ts +10 -0
- package/dist/src/recovery-status.js +54 -0
- package/dist/src/retry.d.ts +14 -0
- package/dist/src/retry.js +147 -0
- package/dist/src/store.d.ts +11 -3
- package/dist/src/store.js +72 -17
- package/dist/src/v2/panel-messages.d.ts +52 -0
- package/dist/src/v2/panel-messages.js +198 -0
- package/dist/src/v2/panel-status.d.ts +6 -4
- package/dist/src/v2/panel-status.js +21 -12
- package/dist/src/v2/plugin.js +21 -2
- package/dist/src/v2/status-rpc.d.ts +94 -0
- package/dist/src/v2/status-rpc.js +70 -2
- package/dist/src/v2/status.js +50 -28
- package/dist/src/v2/tools.js +3 -2
- package/dist/src/v2/tui.js +576 -108
- package/dist/tools/control.d.ts +1 -0
- package/dist/tools/control.js +81 -4
- package/package.json +7 -7
package/dist/src/v2/status.js
CHANGED
|
@@ -5,6 +5,8 @@ import { isPhase2InFlight } from "../phase2.js";
|
|
|
5
5
|
import { isPluginShuttingDown } from "../lifecycle.js";
|
|
6
6
|
import { activeProviderCapacityBackoffs } from "../ratelimit.js";
|
|
7
7
|
import { codexInteropBlockReason } from "../codex-interop.js";
|
|
8
|
+
import { redact } from "../redact.js";
|
|
9
|
+
import { recoveryNotices } from "../recovery-status.js";
|
|
8
10
|
import { injectionTotals, sessionInjection } from "./injection.js";
|
|
9
11
|
import { memoryRoot } from "../paths.js";
|
|
10
12
|
import { readMigrationStatus } from "../migration.js";
|
|
@@ -17,6 +19,8 @@ export function readMemoryStatus(sessionID, minConsolidatedThreads) {
|
|
|
17
19
|
const store = withMemoryVersion(sessionVersion, () => new MemoryStore());
|
|
18
20
|
const options = pluginOptions;
|
|
19
21
|
const now = Date.now();
|
|
22
|
+
const writeVersions = writeMemoryVersions();
|
|
23
|
+
const consolidating = isPhase2InFlight();
|
|
20
24
|
const staleBeforeSec = Math.floor(now / 1000) - options.max_rollout_age_days * 86_400;
|
|
21
25
|
const snapshots = existingMemoryStores().map((pipelineStore) => ({
|
|
22
26
|
version: pipelineStore.version,
|
|
@@ -24,6 +28,7 @@ export function readMemoryStatus(sessionID, minConsolidatedThreads) {
|
|
|
24
28
|
phase1: pipelineStore.stage1JobSnapshot(staleBeforeSec),
|
|
25
29
|
phase2: pipelineStore.phase2JobSnapshot(),
|
|
26
30
|
}));
|
|
31
|
+
const activeWriters = snapshots.filter((pipeline) => writeVersions.includes(pipeline.version));
|
|
27
32
|
const nextRetry = (times) => {
|
|
28
33
|
const future = times.filter((time) => time != null && time * 1000 > now);
|
|
29
34
|
return future.length ? Math.min(...future) * 1000 : null;
|
|
@@ -35,61 +40,77 @@ export function readMemoryStatus(sessionID, minConsolidatedThreads) {
|
|
|
35
40
|
return {
|
|
36
41
|
version: pipeline.version,
|
|
37
42
|
stage1Count: pipeline.stage1Count,
|
|
38
|
-
extracting: pipeline.phase1.
|
|
43
|
+
extracting: pipeline.phase1.active_claims,
|
|
39
44
|
phase2Status: pipeline.phase2?.status ?? null,
|
|
40
|
-
lastError: pipeline.phase2?.last_error
|
|
45
|
+
lastError: pipeline.phase2?.last_error ? redact(pipeline.phase2.last_error) : null,
|
|
41
46
|
phase2CooldownUntil: cooldown !== null && cooldown > now ? cooldown : null,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
...(pipeline.phase2?.status === "running" && pipeline.phase2.lease_until != null
|
|
48
|
+
? { phase2LeaseUntil: pipeline.phase2.lease_until * 1000 }
|
|
49
|
+
: {}),
|
|
50
|
+
phase1RetryAt: nextRetry([pipeline.phase1.next_retry_at]),
|
|
45
51
|
phase2RetryAt: nextRetry([pipeline.phase2?.retry_at]),
|
|
46
52
|
};
|
|
47
53
|
});
|
|
48
|
-
const active = pipelines.filter((pipeline) =>
|
|
54
|
+
const active = pipelines.filter((pipeline) => writeVersions.includes(pipeline.version));
|
|
49
55
|
const phase2 = store.phase2JobSnapshot();
|
|
50
56
|
const session = sessionInjection(sessionID);
|
|
51
57
|
const total = injectionTotals();
|
|
52
58
|
const retryAt = nextRetry([
|
|
53
|
-
...activeProviderCapacityBackoffs().map((backoff) => backoff.retry_at),
|
|
59
|
+
...activeProviderCapacityBackoffs(now).map((backoff) => backoff.retry_at),
|
|
54
60
|
...active.flatMap((pipeline) => [pipeline.phase1RetryAt, pipeline.phase2RetryAt].map((time) => (time === null ? null : time / 1000))),
|
|
55
61
|
]);
|
|
56
62
|
const warnings = [...getConfigWarnings()];
|
|
63
|
+
const notices = [];
|
|
64
|
+
const notice = (entry) => {
|
|
65
|
+
notices.push(entry.detail ? { ...entry, detail: redact(entry.detail).slice(0, 400) } : entry);
|
|
66
|
+
};
|
|
67
|
+
for (const detail of warnings)
|
|
68
|
+
notice({ kind: "configuration", detail });
|
|
57
69
|
const discoveryWarning = getV2DiscoveryStatus()?.warning;
|
|
58
|
-
if (options.generate_memories && discoveryWarning)
|
|
70
|
+
if (options.generate_memories && discoveryWarning) {
|
|
59
71
|
warnings.push(discoveryWarning);
|
|
72
|
+
notice({ kind: "discovery", detail: discoveryWarning });
|
|
73
|
+
}
|
|
60
74
|
const health = getAgentHealth();
|
|
61
75
|
if (options.generate_memories && health.observed) {
|
|
62
76
|
// V2 extraction is sessionless; only the consolidator agent is used.
|
|
63
|
-
|
|
77
|
+
for (const detail of health.agents.memorize.issues) {
|
|
78
|
+
warnings.push(`memorize: ${detail}`);
|
|
79
|
+
notice({ kind: "consolidator_setup", detail });
|
|
80
|
+
}
|
|
64
81
|
}
|
|
65
82
|
if (phase2?.last_error)
|
|
66
83
|
warnings.push("Consolidation failed; see memory_inspect for details.");
|
|
67
84
|
for (const pipeline of active) {
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
const { version, lastError } = pipeline;
|
|
86
|
+
if (!lastError)
|
|
87
|
+
continue;
|
|
88
|
+
if (version !== sessionVersion)
|
|
89
|
+
warnings.push(`${version}: consolidation failed; see memory_inspect.`);
|
|
70
90
|
}
|
|
71
|
-
for (const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
warnings.push(`${prefix}Extraction retry (${count} ${count === 1 ? "job" : "jobs"})${error ? `: ${error.last_error.slice(0, 200)}` : "."}`);
|
|
91
|
+
for (const { version, phase1 } of activeWriters) {
|
|
92
|
+
const prefix = `${version}: `;
|
|
93
|
+
const { backoff, due, provider_capacity: capacity } = phase1.by_failure_class;
|
|
94
|
+
const waitingError = phase1.recent_errors.find((error) => error.failure_class === "backoff");
|
|
95
|
+
if (backoff > 0) {
|
|
96
|
+
warnings.push(`${prefix}Extraction retry (${backoff} ${backoff === 1 ? "job" : "jobs"})${waitingError ? `: ${redact(waitingError.last_error).slice(0, 200)}` : "."}`);
|
|
78
97
|
}
|
|
79
|
-
if (
|
|
98
|
+
if (due > 0)
|
|
80
99
|
warnings.push(`${prefix}Some extraction jobs are due to retry.`);
|
|
81
|
-
if (phase1.
|
|
100
|
+
if (phase1.latest_exhausted)
|
|
82
101
|
warnings.push(`${prefix}Some extraction jobs exhausted their retries.`);
|
|
83
|
-
|
|
84
|
-
if (phase1.by_failure_class.provider_capacity > 0)
|
|
102
|
+
if (capacity > 0)
|
|
85
103
|
warnings.push(`${prefix}Some extraction jobs hit provider capacity limits.`);
|
|
86
104
|
}
|
|
105
|
+
notices.push(...recoveryNotices(activeWriters, now));
|
|
87
106
|
let codexImport = false;
|
|
88
107
|
if (options.codex_interop.import) {
|
|
89
|
-
for (const version of
|
|
108
|
+
for (const version of writeVersions) {
|
|
90
109
|
const reason = withMemoryVersion(version, () => codexInteropBlockReason(options.codex_interop));
|
|
91
|
-
if (reason)
|
|
110
|
+
if (reason) {
|
|
92
111
|
warnings.push(`Codex import disabled (${version}): ${reason}`);
|
|
112
|
+
notice({ kind: "codex_import", version, detail: reason });
|
|
113
|
+
}
|
|
93
114
|
else
|
|
94
115
|
codexImport = true;
|
|
95
116
|
}
|
|
@@ -97,14 +118,14 @@ export function readMemoryStatus(sessionID, minConsolidatedThreads) {
|
|
|
97
118
|
// A `running` row this process does not own is either another opencode
|
|
98
119
|
// instance's live job or an orphaned lease (e.g. a server restart killed the
|
|
99
120
|
// owner mid-run). Neither is "consolidating" here; surface it instead.
|
|
100
|
-
const foreignLease = !
|
|
101
|
-
if (foreignLease) {
|
|
102
|
-
warnings.push(`Consolidation lease held by another process until ${new Date(
|
|
121
|
+
const foreignLease = !consolidating && phase2?.status === "running" ? nextRetry([phase2.lease_until]) : null;
|
|
122
|
+
if (foreignLease !== null) {
|
|
123
|
+
warnings.push(`Consolidation lease held by another process until ${new Date(foreignLease).toLocaleTimeString()}.`);
|
|
103
124
|
}
|
|
104
125
|
let activity = "idle";
|
|
105
126
|
if (isPluginShuttingDown())
|
|
106
127
|
activity = "stopping";
|
|
107
|
-
else if (
|
|
128
|
+
else if (consolidating)
|
|
108
129
|
activity = "consolidating";
|
|
109
130
|
else if (active.some((pipeline) => pipeline.extracting > 0))
|
|
110
131
|
activity = "extracting";
|
|
@@ -130,6 +151,7 @@ export function readMemoryStatus(sessionID, minConsolidatedThreads) {
|
|
|
130
151
|
lastSuccessAt: phase2?.success_finished_at != null ? phase2.success_finished_at * 1000 : null,
|
|
131
152
|
retryAt,
|
|
132
153
|
warnings,
|
|
154
|
+
notices,
|
|
133
155
|
sessionMode: sessionID ? store.getMemoryMode(sessionID) : null,
|
|
134
156
|
memoryRoot: memoryRoot(sessionVersion),
|
|
135
157
|
injected: {
|
package/dist/src/v2/tools.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { tool } from "@opencode-ai/plugin";
|
|
13
13
|
import { memory_read, memory_search, memory_list, memory_add_note } from "../../tools/memory.js";
|
|
14
|
-
import { memory_inspect, memory_mode } from "../../tools/control.js";
|
|
14
|
+
import { memory_inspect, memory_mode, memory_retry } from "../../tools/control.js";
|
|
15
15
|
import { pluginOptions } from "../options.js";
|
|
16
16
|
import { getV2DiscoveryStatus } from "./shim.js";
|
|
17
17
|
function adaptTool(name, v1, ask) {
|
|
@@ -67,8 +67,9 @@ const ALL_MEMORY_TOOLS = [
|
|
|
67
67
|
["memory_add_note", memory_add_note],
|
|
68
68
|
["memory_inspect", memory_inspect],
|
|
69
69
|
["memory_mode", memory_mode],
|
|
70
|
+
["memory_retry", memory_retry],
|
|
70
71
|
];
|
|
71
|
-
const CONTROL_ONLY = new Set(["memory_inspect", "memory_mode"]);
|
|
72
|
+
const CONTROL_ONLY = new Set(["memory_inspect", "memory_mode", "memory_retry"]);
|
|
72
73
|
/**
|
|
73
74
|
* Same gating as the V1 entry: the read/search/list/add-note tools require
|
|
74
75
|
* BOTH use_memories and dedicated_tools (codex MemoriesExtension); the
|