@mojoaar/opencode-mimir 0.25.0 → 0.26.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/dist/index.js CHANGED
@@ -113,7 +113,13 @@ export default Plugin.define({
113
113
  if (text.length < MIN_TRANSCRIPT)
114
114
  return;
115
115
  compacted.add(event.sessionID);
116
- const sent = await callTool('memory_learn', { repo: repo ?? undefined, transcript: text, hint: LEARN_HINT }, { ...config, timeoutMs: 4000 }).catch(() => null);
116
+ const sent = await callTool('memory_learn', {
117
+ repo: repo ?? undefined,
118
+ transcript: text,
119
+ hint: LEARN_HINT,
120
+ client: 'opencode',
121
+ session: event.sessionID,
122
+ }, { ...config, timeoutMs: 4000 }).catch(() => null);
117
123
  // Nothing is written to event.system here: this request's prompt becomes
118
124
  // the summary that replaces the conversation. A failure gives the session
119
125
  // its one chance back, so an outage does not use the compaction up.
@@ -129,7 +135,13 @@ export default Plugin.define({
129
135
  const text = snapshots.get(sessionID) ?? '';
130
136
  let notice = NOTHING_TO_SEND;
131
137
  if (text.length >= MIN_TRANSCRIPT) {
132
- const sent = await callTool('memory_learn', { repo: repo ?? undefined, transcript: text, hint: LEARN_NOW_HINT }, { ...config, timeoutMs: 4000 }).catch(() => null);
138
+ const sent = await callTool('memory_learn', {
139
+ repo: repo ?? undefined,
140
+ transcript: text,
141
+ hint: LEARN_NOW_HINT,
142
+ client: 'opencode',
143
+ session: sessionID,
144
+ }, { ...config, timeoutMs: 4000 }).catch(() => null);
133
145
  const queued = sent?.ok ? sent.result.queued : undefined;
134
146
  if (!sent?.ok)
135
147
  notice = UNREACHABLE;
package/dist/tools.js CHANGED
@@ -80,8 +80,16 @@ function rememberTool(repo) {
80
80
  required: ['path', 'body'],
81
81
  additionalProperties: false,
82
82
  },
83
- async execute(input) {
84
- const result = await callTool('memory_write', { path: input.path, body: input.body, kind: input.kind, repo: repo ?? undefined }, { timeoutMs: 8000 });
83
+ // `client` and `session` are provenance, so history can say who wrote it.
84
+ async execute(input, context) {
85
+ const result = await callTool('memory_write', {
86
+ path: input.path,
87
+ body: input.body,
88
+ kind: input.kind,
89
+ repo: repo ?? undefined,
90
+ client: 'opencode',
91
+ session: context?.sessionID,
92
+ }, { timeoutMs: 8000 });
85
93
  if (!result.ok)
86
94
  return { content: `Could not store that (${result.error}).` };
87
95
  const written = result.result;
@@ -130,8 +138,14 @@ function learnTool(repo) {
130
138
  required: ['transcript'],
131
139
  additionalProperties: false,
132
140
  },
133
- async execute(input) {
134
- const result = await callTool('memory_learn', { transcript: input?.transcript, hint: input?.hint, repo: repo ?? undefined }, { timeoutMs: 8000 });
141
+ async execute(input, context) {
142
+ const result = await callTool('memory_learn', {
143
+ transcript: input?.transcript,
144
+ hint: input?.hint,
145
+ repo: repo ?? undefined,
146
+ client: 'opencode',
147
+ session: context?.sessionID,
148
+ }, { timeoutMs: 8000 });
135
149
  if (!result.ok)
136
150
  return { content: `Could not hand that over (${result.error}).` };
137
151
  const queued = result.result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojoaar/opencode-mimir",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Mimir long-term memory for OpenCode sessions",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -124,7 +124,13 @@ export default Plugin.define({
124
124
 
125
125
  const sent = await callTool(
126
126
  'memory_learn',
127
- { repo: repo ?? undefined, transcript: text, hint: LEARN_HINT },
127
+ {
128
+ repo: repo ?? undefined,
129
+ transcript: text,
130
+ hint: LEARN_HINT,
131
+ client: 'opencode',
132
+ session: event.sessionID,
133
+ },
128
134
  { ...config, timeoutMs: 4000 },
129
135
  ).catch(() => null)
130
136
 
@@ -145,7 +151,13 @@ export default Plugin.define({
145
151
  if (text.length >= MIN_TRANSCRIPT) {
146
152
  const sent = await callTool(
147
153
  'memory_learn',
148
- { repo: repo ?? undefined, transcript: text, hint: LEARN_NOW_HINT },
154
+ {
155
+ repo: repo ?? undefined,
156
+ transcript: text,
157
+ hint: LEARN_NOW_HINT,
158
+ client: 'opencode',
159
+ session: sessionID,
160
+ },
149
161
  { ...config, timeoutMs: 4000 },
150
162
  ).catch(() => null)
151
163
  const queued = sent?.ok ? (sent.result as { queued?: boolean }).queued : undefined
package/src/tools.ts CHANGED
@@ -114,10 +114,18 @@ function rememberTool(repo: string | null): ToolDefinition {
114
114
  required: ['path', 'body'],
115
115
  additionalProperties: false,
116
116
  },
117
- async execute(input) {
117
+ // `client` and `session` are provenance, so history can say who wrote it.
118
+ async execute(input, context) {
118
119
  const result = await callTool(
119
120
  'memory_write',
120
- { path: input.path, body: input.body, kind: input.kind, repo: repo ?? undefined },
121
+ {
122
+ path: input.path,
123
+ body: input.body,
124
+ kind: input.kind,
125
+ repo: repo ?? undefined,
126
+ client: 'opencode',
127
+ session: context?.sessionID,
128
+ },
121
129
  { timeoutMs: 8000 },
122
130
  )
123
131
  if (!result.ok) return { content: `Could not store that (${result.error}).` }
@@ -173,10 +181,16 @@ function learnTool(repo: string | null): ToolDefinition {
173
181
  required: ['transcript'],
174
182
  additionalProperties: false,
175
183
  },
176
- async execute(input) {
184
+ async execute(input, context) {
177
185
  const result = await callTool(
178
186
  'memory_learn',
179
- { transcript: input?.transcript, hint: input?.hint, repo: repo ?? undefined },
187
+ {
188
+ transcript: input?.transcript,
189
+ hint: input?.hint,
190
+ repo: repo ?? undefined,
191
+ client: 'opencode',
192
+ session: context?.sessionID,
193
+ },
180
194
  { timeoutMs: 8000 },
181
195
  )
182
196
  if (!result.ok) return { content: `Could not hand that over (${result.error}).` }