@context-use/openclaw-memory 0.1.0-beta.32 → 0.1.0-beta.523
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/bootstrap.js +50 -26
- package/dist/index.js +949 -97
- package/dist/remove-worker.js +1299 -0
- package/dist/setup-prompt.js +7 -3
- package/dist/setup-runtime.js +16 -0
- package/dist/setup.js +663 -175
- package/openclaw.plugin.json +3 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// package.json
|
|
3
3
|
var package_default = {
|
|
4
4
|
name: "@context-use/openclaw-memory",
|
|
5
|
-
version: "0.1.0-beta.
|
|
5
|
+
version: "0.1.0-beta.523",
|
|
6
6
|
description: "Context Use as OpenClaw's sole durable personal memory",
|
|
7
7
|
type: "module",
|
|
8
8
|
license: "MIT",
|
|
@@ -83,13 +83,16 @@ ${openclawConnectCommand(serverUrl)}
|
|
|
83
83
|
|
|
84
84
|
Follow the plugin's instructions: give me the authorization URL and ask me to return the final localhost redirect URL. When I send it back, finish connecting. Let the plugin manage configuration and gateway refresh.
|
|
85
85
|
|
|
86
|
-
After authorization,
|
|
86
|
+
After authorization, tell me to start a new session with /new so the gateway can finish applying the memory settings. Verify openclaw context-use status in that new session before confirming that memory is active.`;
|
|
87
|
+
}
|
|
88
|
+
var OPENCLAW_REMOVAL_PROMPT = `Remove the Context Use memory plugin using ${OPENCLAW_INSTALL_COMMAND} remove in this OpenClaw profile. This also works if authorization was never completed or the plugin is disabled. Let the plugin restore its configuration changes, clear its credentials and refresh the gateway. Preserve my remote memories and conversation history. Removal runs separately: end this turn once it is queued, then check ${OPENCLAW_INSTALL_COMMAND} status in a new turn. Do not poll from the requesting turn, schedule retries, stop the gateway, or reinstall to finish removal. Verify that a fresh conversation uses the restored memory provider.`;
|
|
89
|
+
function openclawReconnectPrompt(serverUrl) {
|
|
90
|
+
return `Reauthorize my Context Use memory plugin for ${serverUrl}. Run ${OPENCLAW_INSTALL_COMMAND} reconnect '${serverUrl.replaceAll("'", "'\\''")}' in the same OpenClaw profile. Give me the new authorization URL and ask me to return the final localhost redirect URL. Pass that URL to ${OPENCLAW_INSTALL_COMMAND} authorize through standard input. Let the plugin manage configuration and gateway refresh. After authorization, tell me to start a new session with /new, then verify status in that new session before confirming that memory is active.`;
|
|
87
91
|
}
|
|
88
|
-
var OPENCLAW_REMOVAL_PROMPT = `Remove the Context Use memory plugin using ${OPENCLAW_INSTALL_COMMAND} remove in this OpenClaw profile. This also works if authorization was never completed or the plugin is disabled. Let the plugin restore its configuration changes, clear its credentials and refresh the gateway. Preserve my remote memories and conversation history. Verify that a fresh conversation uses the restored memory provider.`;
|
|
89
92
|
|
|
90
93
|
// src/bootstrap.ts
|
|
91
|
-
import {
|
|
92
|
-
import {
|
|
94
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
95
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
93
96
|
import { satisfies as satisfies2 } from "semver";
|
|
94
97
|
|
|
95
98
|
// src/contract.ts
|
|
@@ -107,7 +110,10 @@ var OPENCLAW_VERSION_RANGE = package_default.peerDependencies.openclaw;
|
|
|
107
110
|
var CALLBACK_URL = "http://127.0.0.1:49187/context-use/callback";
|
|
108
111
|
var REQUEST_TIMEOUT_MS = 30000;
|
|
109
112
|
var AUTHORIZATION_TIMEOUT_MS = 600000;
|
|
113
|
+
var AUTHORIZATION_SCOPE = "mcp offline_access";
|
|
110
114
|
var toolName = (name) => `context_use_${name}`;
|
|
115
|
+
var FINISH_LEARNING_TOOL = toolName("finish_learning");
|
|
116
|
+
var SAVE_ATTACHMENT_TOOL = toolName("save_learning_attachment");
|
|
111
117
|
var PluginConfigSchema = z.strictObject({
|
|
112
118
|
agentId: z.string().regex(/^[a-z0-9][a-z0-9_-]*$/),
|
|
113
119
|
serverUrl: z.url()
|
|
@@ -154,10 +160,17 @@ import { resolve } from "node:path";
|
|
|
154
160
|
import { z as z2 } from "zod";
|
|
155
161
|
|
|
156
162
|
// src/host-command.ts
|
|
157
|
-
import { execFile } from "node:child_process";
|
|
163
|
+
import { execFile, spawn } from "node:child_process";
|
|
158
164
|
import { promisify } from "node:util";
|
|
159
165
|
var execute = promisify(execFile);
|
|
160
166
|
var HOST_TIMEOUT_MS = 120000;
|
|
167
|
+
async function runSetupCommand(input) {
|
|
168
|
+
const child = spawn(process.execPath, [...input.runtime ? ["--import", input.runtime] : [], input.script, ...input.args], { stdio: "inherit" });
|
|
169
|
+
return await new Promise((resolve, reject) => {
|
|
170
|
+
child.once("error", reject);
|
|
171
|
+
child.once("exit", (code) => resolve(code ?? 1));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
161
174
|
async function openclaw(args) {
|
|
162
175
|
const result = await execute("openclaw", args, {
|
|
163
176
|
timeout: HOST_TIMEOUT_MS,
|
|
@@ -204,6 +217,7 @@ async function refreshGateway() {
|
|
|
204
217
|
// src/package-installation.ts
|
|
205
218
|
import { execFile as execFile2 } from "node:child_process";
|
|
206
219
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
220
|
+
import { createRequire } from "node:module";
|
|
207
221
|
import { tmpdir } from "node:os";
|
|
208
222
|
import { dirname, join, resolve as resolve2 } from "node:path";
|
|
209
223
|
import { fileURLToPath } from "node:url";
|
|
@@ -211,14 +225,27 @@ import { promisify as promisify2 } from "node:util";
|
|
|
211
225
|
import { z as z3 } from "zod";
|
|
212
226
|
var execute2 = promisify2(execFile2);
|
|
213
227
|
var INSTALL_TIMEOUT_MS = 120000;
|
|
214
|
-
async function
|
|
228
|
+
async function pluginInventory() {
|
|
215
229
|
const inventory = z3.object({
|
|
216
230
|
plugins: z3.array(z3.object({
|
|
217
231
|
id: z3.string(),
|
|
218
|
-
rootDir: z3.string()
|
|
232
|
+
rootDir: z3.string(),
|
|
233
|
+
origin: z3.string().optional()
|
|
219
234
|
}))
|
|
220
|
-
}).parse(JSON.parse(await openclaw(["plugins", "list", "--json"])));
|
|
221
|
-
return inventory.plugins
|
|
235
|
+
}).parse(JSON.parse(await openclaw(["--log-level", "silent", "plugins", "list", "--json"])));
|
|
236
|
+
return inventory.plugins;
|
|
237
|
+
}
|
|
238
|
+
async function installedPlugin() {
|
|
239
|
+
return (await pluginInventory()).find((plugin) => plugin.id === PLUGIN_ID);
|
|
240
|
+
}
|
|
241
|
+
async function hostSdkAnchor() {
|
|
242
|
+
const plugins = await pluginInventory();
|
|
243
|
+
for (const plugin of plugins.filter((entry) => entry.origin === "bundled")) {
|
|
244
|
+
try {
|
|
245
|
+
return createRequire(join(plugin.rootDir, "package.json")).resolve("openclaw/plugin-sdk/config-mutation");
|
|
246
|
+
} catch {}
|
|
247
|
+
}
|
|
248
|
+
throw new ConnectionError("Could not locate the OpenClaw SDK. Run openclaw plugins doctor and retry.");
|
|
222
249
|
}
|
|
223
250
|
async function installPackage() {
|
|
224
251
|
const existing = await installedPlugin();
|
|
@@ -253,16 +280,20 @@ async function installPackage() {
|
|
|
253
280
|
|
|
254
281
|
// src/usage.ts
|
|
255
282
|
var SETUP_USAGE = `context-use-openclaw connect <instance-url> [agent-id=main]
|
|
283
|
+
context-use-openclaw reconnect [instance-url] [agent-id]
|
|
256
284
|
context-use-openclaw authorize
|
|
257
285
|
context-use-openclaw status
|
|
258
286
|
context-use-openclaw disconnect
|
|
259
|
-
context-use-openclaw remove
|
|
287
|
+
context-use-openclaw remove [--wait]
|
|
260
288
|
context-use-openclaw refresh
|
|
261
289
|
|
|
262
290
|
Connect installs the plugin and starts browser authorization. Pass the returned URL to authorize
|
|
263
291
|
through standard input. After installation, these commands also work through openclaw context-use.
|
|
264
|
-
|
|
265
|
-
|
|
292
|
+
Reconnect starts fresh authorization, using the saved URL when omitted. Connect with a different URL
|
|
293
|
+
also starts fresh authorization. Use the same OpenClaw profile for every command. Remove restores your settings and uninstalls the
|
|
294
|
+
plugin while preserving remote memories and conversation history. Remove runs in the background: end
|
|
295
|
+
the requesting agent turn, then check status in a new turn. Use --wait only from a terminal outside
|
|
296
|
+
an agent turn. Status, remove and refresh also work after uninstall through the npm helper.`;
|
|
266
297
|
|
|
267
298
|
// src/bootstrap.ts
|
|
268
299
|
async function main(args) {
|
|
@@ -284,19 +315,12 @@ async function main(args) {
|
|
|
284
315
|
await refreshGateway();
|
|
285
316
|
return;
|
|
286
317
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
const child = spawn(process.execPath, [join2(installed.rootDir, "dist/setup.js"), ...args], {
|
|
295
|
-
stdio: "inherit"
|
|
296
|
-
});
|
|
297
|
-
process.exitCode = await new Promise((resolve3, reject) => {
|
|
298
|
-
child.once("error", reject);
|
|
299
|
-
child.once("exit", (code) => resolve3(code ?? 1));
|
|
318
|
+
const directory = dirname2(fileURLToPath2(import.meta.url));
|
|
319
|
+
process.env.CONTEXT_USE_OPENCLAW_SDK = await hostSdkAnchor();
|
|
320
|
+
process.exitCode = await runSetupCommand({
|
|
321
|
+
script: join2(directory, "setup.js"),
|
|
322
|
+
runtime: join2(directory, "setup-runtime.js"),
|
|
323
|
+
args
|
|
300
324
|
});
|
|
301
325
|
}
|
|
302
326
|
try {
|