om-memory-system 5.10.1 → 6.1.0-next.237
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/dist/adapters/opencode/auto-capture-host.d.ts +2 -2
- package/dist/adapters/opencode/auto-capture-host.js +5 -15
- package/dist/adapters/opencode/auto-capture-summary.js +9 -6
- package/dist/adapters/opencode/backfill-models.js +1 -1
- package/dist/adapters/opencode/backfill-startup.js +5 -4
- package/dist/adapters/opencode/conversation.d.ts +5 -1
- package/dist/adapters/opencode/conversation.js +23 -23
- package/dist/adapters/opencode/import-command.d.ts +0 -12
- package/dist/adapters/opencode/import-command.js +1 -17
- package/dist/adapters/opencode/internal-capture-sessions.d.ts +0 -3
- package/dist/adapters/opencode/internal-capture-sessions.js +0 -26
- package/dist/adapters/opencode/memory-tool.d.ts +3 -4
- package/dist/adapters/opencode/memory-tool.js +8 -50
- package/dist/adapters/opencode/opencode-host.d.ts +27 -0
- package/dist/adapters/opencode/opencode-host.js +30 -0
- package/dist/adapters/opencode/opencode-import-models.d.ts +2 -2
- package/dist/adapters/opencode/opencode-import-models.js +8 -10
- package/dist/adapters/opencode/opencode-provider.d.ts +23 -62
- package/dist/adapters/opencode/opencode-provider.js +75 -378
- package/dist/adapters/opencode/package-skills.d.ts +1 -6
- package/dist/adapters/opencode/package-skills.js +2 -17
- package/dist/adapters/opencode/profile-learning.d.ts +1 -2
- package/dist/adapters/opencode/profile-learning.js +15 -19
- package/dist/adapters/opencode/profile-llm-client.d.ts +3 -2
- package/dist/adapters/opencode/profile-llm-client.js +8 -17
- package/dist/adapters/opencode/profile-model.d.ts +2 -18
- package/dist/adapters/opencode/profile-model.js +18 -69
- package/dist/adapters/opencode/prompt-model.d.ts +9 -0
- package/dist/adapters/opencode/prompt-model.js +21 -0
- package/dist/adapters/opencode/skills-tool.d.ts +3 -3
- package/dist/adapters/opencode/skills-tool.js +4 -30
- package/dist/adapters/opencode/toast.d.ts +11 -0
- package/dist/adapters/opencode/toast.js +11 -0
- package/dist/adapters/opencode/user-prompt.d.ts +2 -2
- package/dist/adapters/opencode/user-prompt.js +4 -5
- package/dist/config-template.d.ts +1 -1
- package/dist/config-template.js +2 -6
- package/dist/config.d.ts +0 -9
- package/dist/config.js +0 -9
- package/dist/core/retrieval.d.ts +0 -21
- package/dist/core/retrieval.js +0 -29
- package/dist/importer/handled-lookup.d.ts +17 -0
- package/dist/importer/handled-lookup.js +13 -0
- package/dist/importer/importer.js +3 -3
- package/dist/importer/ledger.d.ts +9 -0
- package/dist/importer/ledger.js +21 -0
- package/dist/importer/opencode-reader.d.ts +1 -1
- package/dist/importer/opencode-reader.js +88 -34
- package/dist/importer/opencode-v2-units.d.ts +16 -0
- package/dist/importer/opencode-v2-units.js +93 -0
- package/dist/importer/settings-models.d.ts +11 -6
- package/dist/importer/settings-models.js +15 -11
- package/dist/plugin.d.ts +0 -3
- package/dist/plugin.js +1 -7
- package/dist/services/global-config-writer.js +2 -3
- package/dist/services/settings-snapshot.js +6 -6
- package/dist/services/turso/vector-search.js +4 -2
- package/dist/shared/api/schemas.d.ts +1 -1
- package/dist/utils/memory-limits.d.ts +0 -1
- package/dist/utils/memory-limits.js +0 -1
- package/dist/v2/adapter.d.ts +16 -84
- package/dist/v2/adapter.js +17 -88
- package/dist/v2/memory-bridge.js +1 -1
- package/dist/v2/plugin.js +27 -16
- package/dist/v2/session-events.d.ts +30 -0
- package/dist/v2/session-events.js +130 -0
- package/dist/v2/startup.d.ts +14 -0
- package/dist/v2/startup.js +210 -0
- package/dist/v2/tools.d.ts +106 -0
- package/dist/v2/tools.js +89 -0
- package/dist/web/assets/index-DBSeQOs6.js +171 -0
- package/dist/web/index.html +1 -1
- package/package.json +2 -14
- package/dist/adapters/opencode/in-process-client.d.ts +0 -2
- package/dist/adapters/opencode/in-process-client.js +0 -16
- package/dist/adapters/opencode/opencode-diagnostics.d.ts +0 -7
- package/dist/adapters/opencode/opencode-diagnostics.js +0 -37
- package/dist/adapters/opencode/opencode-host-config.d.ts +0 -13
- package/dist/adapters/opencode/opencode-host-config.js +0 -53
- package/dist/adapters/opencode/opencode-sdk-client.d.ts +0 -6
- package/dist/adapters/opencode/opencode-sdk-client.js +0 -38
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -620
- package/dist/v2/legacy-client.d.ts +0 -15
- package/dist/v2/legacy-client.js +0 -275
- package/dist/web/assets/index-DQgI670D.js +0 -171
package/dist/v2/legacy-client.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { markInProcessClient } from "../adapters/opencode/in-process-client.js";
|
|
4
|
-
function textFromParts(parts = []) {
|
|
5
|
-
return parts
|
|
6
|
-
.filter((part) => part.type === "text")
|
|
7
|
-
.map((part) => part.text ?? "")
|
|
8
|
-
.join("\n");
|
|
9
|
-
}
|
|
10
|
-
function parseJson(text) {
|
|
11
|
-
const trimmed = text.trim();
|
|
12
|
-
const fenced = trimmed.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i)?.[1];
|
|
13
|
-
const candidate = fenced ?? trimmed;
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(candidate);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
const start = candidate.indexOf("{");
|
|
19
|
-
const end = candidate.lastIndexOf("}");
|
|
20
|
-
if (start >= 0 && end > start) {
|
|
21
|
-
return JSON.parse(candidate.slice(start, end + 1));
|
|
22
|
-
}
|
|
23
|
-
throw new Error("Model did not return a JSON object");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function legacyMessage(message, sessionID) {
|
|
27
|
-
if (message.type === "user" || message.type === "synthetic" || message.type === "system") {
|
|
28
|
-
return {
|
|
29
|
-
info: { id: message.id, sessionID, role: "user", agent: message.agent },
|
|
30
|
-
parts: [
|
|
31
|
-
{
|
|
32
|
-
id: `${message.id}-text`,
|
|
33
|
-
sessionID,
|
|
34
|
-
messageID: message.id,
|
|
35
|
-
type: "text",
|
|
36
|
-
text: message.text ?? "",
|
|
37
|
-
synthetic: message.type !== "user",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (message.type === "assistant") {
|
|
43
|
-
return {
|
|
44
|
-
info: {
|
|
45
|
-
id: message.id,
|
|
46
|
-
sessionID,
|
|
47
|
-
role: "assistant",
|
|
48
|
-
agent: message.agent,
|
|
49
|
-
mode: message.agent,
|
|
50
|
-
},
|
|
51
|
-
parts: (message.content ?? []).map((part, index) => ({
|
|
52
|
-
id: part.id ?? `${message.id}-${index}`,
|
|
53
|
-
sessionID,
|
|
54
|
-
messageID: message.id,
|
|
55
|
-
...part,
|
|
56
|
-
})),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (message.type === "compaction") {
|
|
60
|
-
return {
|
|
61
|
-
info: {
|
|
62
|
-
id: message.id,
|
|
63
|
-
sessionID,
|
|
64
|
-
role: "assistant",
|
|
65
|
-
summary: true,
|
|
66
|
-
mode: "compaction",
|
|
67
|
-
},
|
|
68
|
-
parts: [],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
info: { id: message.id ?? randomUUID(), sessionID, role: "assistant" },
|
|
73
|
-
parts: [],
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function sessionIDFrom(input) {
|
|
77
|
-
return input?.sessionID ?? input?.path?.id;
|
|
78
|
-
}
|
|
79
|
-
function bodyFrom(input) {
|
|
80
|
-
return input?.body ?? input ?? {};
|
|
81
|
-
}
|
|
82
|
-
function schemaPrompt(body) {
|
|
83
|
-
const sections = [body.system, textFromParts(body.parts)];
|
|
84
|
-
if (body.format?.type === "json_schema" && body.format.schema) {
|
|
85
|
-
sections.push([
|
|
86
|
-
"Return only one JSON object matching this JSON Schema.",
|
|
87
|
-
"Do not wrap the JSON in Markdown.",
|
|
88
|
-
JSON.stringify(body.format.schema),
|
|
89
|
-
].join("\n"));
|
|
90
|
-
}
|
|
91
|
-
return sections.filter(Boolean).join("\n\n");
|
|
92
|
-
}
|
|
93
|
-
function toastFallback(input) {
|
|
94
|
-
const body = bodyFrom(input);
|
|
95
|
-
const message = [body.title, body.message].filter(Boolean).join(": ");
|
|
96
|
-
if (message) {
|
|
97
|
-
const method = body.variant === "error" ? "error" : body.variant === "warning" ? "warn" : "info";
|
|
98
|
-
console[method](`[omms] ${message}`);
|
|
99
|
-
}
|
|
100
|
-
return { data: false };
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Adapts the released OpenCode v2 plugin context to the V1 client shape used
|
|
104
|
-
* by the shared omms implementation.
|
|
105
|
-
*/
|
|
106
|
-
export function createLegacyClient(ctx) {
|
|
107
|
-
const generatedSessions = new Set();
|
|
108
|
-
const client = {
|
|
109
|
-
app: { log: async () => ({ data: true }) },
|
|
110
|
-
provider: {
|
|
111
|
-
list: async () => {
|
|
112
|
-
const models = await ctx.model.list();
|
|
113
|
-
const connected = [
|
|
114
|
-
...new Set(models.data.map((model) => model.providerID).filter(Boolean)),
|
|
115
|
-
];
|
|
116
|
-
// The Settings page lists each connected provider's models from `all`, as
|
|
117
|
-
// the V1 SDK's provider list returns them.
|
|
118
|
-
const all = connected.map((id) => ({
|
|
119
|
-
id,
|
|
120
|
-
models: Object.fromEntries(models.data
|
|
121
|
-
.filter((model) => model.providerID === id)
|
|
122
|
-
.map((model) => [model.id, { name: model.name || model.id }])),
|
|
123
|
-
}));
|
|
124
|
-
return { data: { connected, all } };
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
tui: {
|
|
128
|
-
showToast: async (input) => toastFallback(input),
|
|
129
|
-
appendPrompt: async () => ({ data: false }),
|
|
130
|
-
submitPrompt: async () => ({ data: false }),
|
|
131
|
-
},
|
|
132
|
-
session: {
|
|
133
|
-
get: async (input) => {
|
|
134
|
-
const sessionID = sessionIDFrom(input);
|
|
135
|
-
if (!sessionID)
|
|
136
|
-
throw new Error("session id required");
|
|
137
|
-
return { data: await ctx.session.get({ sessionID }) };
|
|
138
|
-
},
|
|
139
|
-
messages: async (input) => {
|
|
140
|
-
const sessionID = sessionIDFrom(input);
|
|
141
|
-
if (!sessionID)
|
|
142
|
-
throw new Error("session id required");
|
|
143
|
-
return {
|
|
144
|
-
data: (await ctx.session.context({ sessionID })).map((message) => legacyMessage(message, sessionID)),
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
create: async () => {
|
|
148
|
-
// OpenCode v2's plugin Generate API is intentionally sessionless.
|
|
149
|
-
// Keep a synthetic id so the existing structured-output lifecycle can
|
|
150
|
-
// retain its create/prompt/delete contract without polluting history.
|
|
151
|
-
const id = randomUUID();
|
|
152
|
-
generatedSessions.add(id);
|
|
153
|
-
return { data: { id } };
|
|
154
|
-
},
|
|
155
|
-
prompt: async (input) => {
|
|
156
|
-
const sessionID = sessionIDFrom(input);
|
|
157
|
-
if (!sessionID)
|
|
158
|
-
throw new Error("session id required");
|
|
159
|
-
const body = bodyFrom(input);
|
|
160
|
-
if (generatedSessions.has(sessionID)) {
|
|
161
|
-
const model = body.model?.providerID && body.model?.modelID
|
|
162
|
-
? { providerID: body.model.providerID, id: body.model.modelID }
|
|
163
|
-
: undefined;
|
|
164
|
-
const generated = await ctx.generate.text({
|
|
165
|
-
prompt: schemaPrompt(body),
|
|
166
|
-
...(model ? { model } : {}),
|
|
167
|
-
});
|
|
168
|
-
const text = generated?.text ?? "";
|
|
169
|
-
const structured = body.format?.type === "json_schema" ? parseJson(text) : undefined;
|
|
170
|
-
return {
|
|
171
|
-
data: {
|
|
172
|
-
info: {
|
|
173
|
-
id: randomUUID(),
|
|
174
|
-
role: "assistant",
|
|
175
|
-
structured_output: structured,
|
|
176
|
-
structured,
|
|
177
|
-
},
|
|
178
|
-
parts: [{ type: "text", text }],
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
const text = textFromParts(body.parts);
|
|
183
|
-
if (body.noReply) {
|
|
184
|
-
const data = await ctx.session.synthetic({
|
|
185
|
-
sessionID,
|
|
186
|
-
text,
|
|
187
|
-
description: "memory context",
|
|
188
|
-
metadata: body.parts?.[0]?.metadata,
|
|
189
|
-
});
|
|
190
|
-
return { data, response: new Response(null, { status: 200 }) };
|
|
191
|
-
}
|
|
192
|
-
const data = await ctx.session.prompt({
|
|
193
|
-
sessionID,
|
|
194
|
-
text,
|
|
195
|
-
delivery: "queue",
|
|
196
|
-
metadata: body.parts?.[0]?.metadata,
|
|
197
|
-
});
|
|
198
|
-
return { data, response: new Response(null, { status: 200 }) };
|
|
199
|
-
},
|
|
200
|
-
abort: async (input) => {
|
|
201
|
-
const sessionID = sessionIDFrom(input);
|
|
202
|
-
if (sessionID && generatedSessions.has(sessionID)) {
|
|
203
|
-
generatedSessions.delete(sessionID);
|
|
204
|
-
return { data: true };
|
|
205
|
-
}
|
|
206
|
-
if (sessionID) {
|
|
207
|
-
const result = await ctx.session.interrupt({ sessionID });
|
|
208
|
-
return { data: result.interrupted };
|
|
209
|
-
}
|
|
210
|
-
return { data: false };
|
|
211
|
-
},
|
|
212
|
-
delete: async (input) => {
|
|
213
|
-
const sessionID = sessionIDFrom(input);
|
|
214
|
-
if (sessionID)
|
|
215
|
-
generatedSessions.delete(sessionID);
|
|
216
|
-
return { data: true };
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
return markInProcessClient(client);
|
|
221
|
-
}
|
|
222
|
-
export function legacyToolResult(value) {
|
|
223
|
-
if (typeof value === "string")
|
|
224
|
-
return { content: value };
|
|
225
|
-
if (value && typeof value === "object" && typeof value.output === "string") {
|
|
226
|
-
return { content: value.output, metadata: value.metadata };
|
|
227
|
-
}
|
|
228
|
-
return { content: JSON.stringify(value ?? null) };
|
|
229
|
-
}
|
|
230
|
-
export function toLegacyEvent(raw) {
|
|
231
|
-
const envelope = raw?.payload ?? raw;
|
|
232
|
-
const source = envelope?.type === "sync" && envelope.syncEvent ? envelope.syncEvent : envelope;
|
|
233
|
-
const rawType = typeof source?.type === "string" ? source.type.replace(/\.1$/, "") : source?.type;
|
|
234
|
-
const data = source?.data ?? {};
|
|
235
|
-
// OpenCode 2.0.14 ends a turn with `session.execution.succeeded` and emits no
|
|
236
|
-
// `session.idle`; some builds report idleness through `session.status`. The
|
|
237
|
-
// V1 capture path listens for `session.idle`, so both map onto it.
|
|
238
|
-
// Subscribed events carry their payload in `data`; bus-style ones in `properties`.
|
|
239
|
-
const payload = source?.data ?? source?.properties ?? {};
|
|
240
|
-
if (rawType === "session.execution.succeeded" ||
|
|
241
|
-
(rawType === "session.status" && payload?.status?.type === "idle")) {
|
|
242
|
-
return { type: "session.idle", properties: { sessionID: payload.sessionID } };
|
|
243
|
-
}
|
|
244
|
-
const type = rawType === "session.compaction.ended" ? "session.compacted" : rawType;
|
|
245
|
-
if (source && typeof source === "object" && "properties" in source) {
|
|
246
|
-
return { type, properties: source.properties };
|
|
247
|
-
}
|
|
248
|
-
if (type === "session.created" || type === "session.updated") {
|
|
249
|
-
return { type, properties: { info: data.session ?? data.info ?? data } };
|
|
250
|
-
}
|
|
251
|
-
return { type, properties: data };
|
|
252
|
-
}
|
|
253
|
-
export async function eventBelongsToLocation(ctx, raw) {
|
|
254
|
-
const directory = raw?.location?.directory ??
|
|
255
|
-
raw?.directory ??
|
|
256
|
-
raw?.payload?.location?.directory ??
|
|
257
|
-
raw?.payload?.directory ??
|
|
258
|
-
raw?.data?.info?.directory;
|
|
259
|
-
if (typeof directory === "string") {
|
|
260
|
-
return resolve(directory) === resolve(ctx.location.directory);
|
|
261
|
-
}
|
|
262
|
-
const data = raw?.data ?? raw?.payload?.data ?? raw?.properties;
|
|
263
|
-
const sessionID = data?.sessionID ?? data?.session?.id ?? data?.info?.id;
|
|
264
|
-
if (!sessionID)
|
|
265
|
-
return false;
|
|
266
|
-
try {
|
|
267
|
-
const session = await ctx.session.get({ sessionID });
|
|
268
|
-
const sessionDirectory = session?.location?.directory ?? session?.directory ?? session?.data?.directory;
|
|
269
|
-
return (typeof sessionDirectory === "string" &&
|
|
270
|
-
resolve(sessionDirectory) === resolve(ctx.location.directory));
|
|
271
|
-
}
|
|
272
|
-
catch {
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
}
|