opencode-lore 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +20 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-lore",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Three-tier memory architecture for OpenCode — distillation, not summarization",
package/src/index.ts CHANGED
@@ -312,23 +312,28 @@ export const LorePlugin: Plugin = async (ctx) => {
312
312
  rawBudget: result.rawBudget,
313
313
  updatedAt: Date.now(),
314
314
  };
315
- const url = new URL(
316
- `/session/${sessionID}/message/${lastUserMsg.info.id}/part/${statsPart.id}`,
317
- ctx.serverUrl,
318
- );
319
- const updatedPart = {
320
- ...(statsPart as Record<string, unknown>),
321
- metadata: {
322
- ...((statsPart as { metadata?: Record<string, unknown> }).metadata ?? {}),
323
- lore: loreMeta,
315
+ // Use the SDK's internal HTTP client so the request goes through
316
+ // the same base URL, custom fetch, and interceptors that OpenCode
317
+ // configured — no dependency on ctx.serverUrl being reachable.
318
+ const httpClient = (ctx.client as any)._client;
319
+ httpClient.patch({
320
+ url: "/session/{sessionID}/message/{messageID}/part/{partID}",
321
+ path: {
322
+ sessionID,
323
+ messageID: lastUserMsg.info.id,
324
+ partID: statsPart.id,
325
+ },
326
+ body: {
327
+ ...(statsPart as Record<string, unknown>),
328
+ metadata: {
329
+ ...((statsPart as { metadata?: Record<string, unknown> }).metadata ?? {}),
330
+ lore: loreMeta,
331
+ },
324
332
  },
325
- };
326
- fetch(url, {
327
- method: "PATCH",
328
333
  headers: { "Content-Type": "application/json" },
329
- body: JSON.stringify(updatedPart),
330
- }).catch((e: unknown) => {
331
- console.error("[lore] failed to write gradient stats to part metadata:", e);
334
+ }).catch(() => {
335
+ // Non-critical: gradient stats metadata is for UI display only.
336
+ // Server may not be reachable (e.g. TUI-only mode). Silently ignore.
332
337
  });
333
338
  }
334
339
  },