@eleboucher/opencode-memini 0.3.8 → 0.4.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 +1 -1
- package/memini.js +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ Pass options inline via the `[name, options]` form:
|
|
|
50
50
|
| `recall` | `MEMINI_RECALL` | on | `false` disables recall-before-turn |
|
|
51
51
|
| `capture` | `MEMINI_CAPTURE` | on | `false` disables capture-after-turn |
|
|
52
52
|
| `recall_limit` | `MEMINI_RECALL_LIMIT` | `5` | max memories injected per turn |
|
|
53
|
-
| `timeout_ms` | `MEMINI_TIMEOUT_MS` | `
|
|
53
|
+
| `timeout_ms` | `MEMINI_TIMEOUT_MS` | `30000` | per-request timeout |
|
|
54
54
|
| `fallback_on_error` | `MEMINI_FALLBACK` | on | `false` surfaces errors instead of degrading silently |
|
|
55
55
|
| — | `MEMINI_API_KEY` | — | bearer token, if memini needs auth (env only — secret) |
|
|
56
56
|
| — | `MEMINI_REQUIRE_HTTPS` | — | `1` refuses to send the token over plaintext HTTP |
|
package/memini.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
const DEFAULT_BASE_URL = "http://localhost:8080";
|
|
20
|
-
const DEFAULT_TIMEOUT_MS =
|
|
20
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
21
21
|
const DEFAULT_RECALL_LIMIT = 5;
|
|
22
22
|
const DEFAULT_NAMESPACE = "opencode";
|
|
23
23
|
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
@@ -162,22 +162,25 @@ function createClient(cfg, log) {
|
|
|
162
162
|
|
|
163
163
|
// extractLastTurn returns the latest user and assistant text from the message
|
|
164
164
|
// list returned by client.session.messages ([{info, parts}, ...]), plus the id
|
|
165
|
-
// of the assistant message (for dedup).
|
|
165
|
+
// of the assistant message (for dedup). Iterates in reverse to short-circuit.
|
|
166
|
+
// Exported for testing.
|
|
166
167
|
export function extractLastTurn(messages) {
|
|
167
168
|
let userText = "";
|
|
168
169
|
let assistantText = "";
|
|
169
170
|
let assistantID = "";
|
|
170
171
|
if (!Array.isArray(messages)) return { userText, assistantText, assistantID };
|
|
171
|
-
for (const entry of messages) {
|
|
172
|
+
for (const entry of [...messages].reverse()) {
|
|
172
173
|
const info = entry && entry.info;
|
|
173
174
|
if (!info) continue;
|
|
174
175
|
const text = extractPartsText(entry.parts);
|
|
175
176
|
if (!text) continue;
|
|
176
|
-
if (info.role === "user"
|
|
177
|
-
|
|
177
|
+
if (info.role === "user" && !userText) {
|
|
178
|
+
userText = text;
|
|
179
|
+
} else if (info.role === "assistant" && !assistantText) {
|
|
178
180
|
assistantText = text;
|
|
179
181
|
assistantID = info.id || "";
|
|
180
182
|
}
|
|
183
|
+
if (userText && assistantText) break;
|
|
181
184
|
}
|
|
182
185
|
return { userText, assistantText, assistantID };
|
|
183
186
|
}
|