@openviking/opencode-plugin 0.2.3 → 2026.9.9-1
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/INSTALL-ZH.md +25 -7
- package/INSTALL.md +27 -7
- package/README.md +52 -13
- package/index.mjs +10 -3
- package/lib/config.mjs +50 -8
- package/lib/mcp-config.mjs +2 -1
- package/lib/memory-recall.mjs +19 -7
- package/lib/memory-session.mjs +61 -18
- package/lib/runtime.mjs +1 -0
- package/lib/shared/batch-send.mjs +2 -3
- package/lib/shared/capture-utils.mjs +99 -21
- package/lib/shared/credentials.mjs +32 -0
- package/lib/shared/input-filters.mjs +219 -0
- package/lib/shared/mcp-proxy-config.mjs +124 -0
- package/lib/shared/mcp-proxy-core.mjs +60 -2
- package/lib/shared/pending-queue.mjs +13 -3
- package/lib/shared/recall-compress-core.mjs +206 -0
- package/lib/shared/recall-core.mjs +394 -18
- package/lib/shared/retryable.mjs +9 -0
- package/lib/shared/setup-wizard.mjs +14 -11
- package/lib/shared/uri-guard.mjs +28 -6
- package/lib/shared/workspace-identity.mjs +334 -0
- package/lib/shared/workspace-peer.mjs +126 -8
- package/lib/utils.mjs +8 -1
- package/lib/viking-uri-guard.mjs +1 -1
- package/package.json +3 -2
- package/servers/mcp-proxy.mjs +16 -39
- package/servers/mcp-proxy.test.mjs +2 -0
- package/lib/shared/async-writer.mjs +0 -78
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// GENERATED FROM examples/memory-plugin-shared/lib. DO NOT EDIT.
|
|
2
|
-
/**
|
|
3
|
-
* Async write-path helper for hook-based memory plugins.
|
|
4
|
-
*
|
|
5
|
-
* When `cfg.writePathAsync` is true and we're not already the worker, we:
|
|
6
|
-
* 1. Drain the parent's stdin (the hook payload)
|
|
7
|
-
* 2. Emit the harness-specific approve/no-op response on stdout immediately
|
|
8
|
-
* 3. Spawn a detached clone of ourselves with env OV_HOOK_WORKER=1
|
|
9
|
-
* 4. Feed the drained payload to the worker's stdin, unref, and exit
|
|
10
|
-
*
|
|
11
|
-
* The worker re-enters the same script, maybeDetach returns false (because
|
|
12
|
-
* OV_HOOK_WORKER=1), and the hook's normal synchronous code path reads its
|
|
13
|
-
* own stdin and runs the OV HTTP work with nobody waiting.
|
|
14
|
-
*
|
|
15
|
-
* Call this BEFORE the hook reads stdin itself. When it returns true, the
|
|
16
|
-
* caller must `return` out of main() immediately.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { spawn } from "node:child_process";
|
|
20
|
-
|
|
21
|
-
const WORKER_ENV = "OV_HOOK_WORKER";
|
|
22
|
-
|
|
23
|
-
export async function maybeDetach(cfg, { approve }) {
|
|
24
|
-
if (!cfg.writePathAsync) return false;
|
|
25
|
-
if (process.env[WORKER_ENV] === "1") return false;
|
|
26
|
-
|
|
27
|
-
// Drain parent stdin so we can forward to the worker.
|
|
28
|
-
let raw;
|
|
29
|
-
try {
|
|
30
|
-
const chunks = [];
|
|
31
|
-
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
32
|
-
raw = Buffer.concat(chunks);
|
|
33
|
-
} catch {
|
|
34
|
-
// stdin read failed - let the synchronous path handle it.
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let child;
|
|
39
|
-
try {
|
|
40
|
-
child = spawn(process.execPath, [process.argv[1]], {
|
|
41
|
-
detached: true,
|
|
42
|
-
stdio: ["pipe", "ignore", "ignore"],
|
|
43
|
-
env: { ...process.env, [WORKER_ENV]: "1" },
|
|
44
|
-
});
|
|
45
|
-
} catch {
|
|
46
|
-
// spawn failed - fall through to sync mode, but we've already drained
|
|
47
|
-
// stdin so hand the payload back via env var path below.
|
|
48
|
-
process.env.OPENVIKING_HOOK_STDIN_CACHE = raw.toString();
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Approve first, then write to the detached child. Ordering matters for
|
|
53
|
-
// harnesses that read stdout before waiting for the hook process to exit.
|
|
54
|
-
approve();
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
child.stdin.write(raw);
|
|
58
|
-
child.stdin.end();
|
|
59
|
-
} catch { /* worker may have already exited; nothing useful to recover */ }
|
|
60
|
-
child.unref();
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Fallback stdin reader used when the async path drained stdin but spawn
|
|
66
|
-
* failed; hooks should call this instead of reading stdin directly when
|
|
67
|
-
* possible so the sync fallback still works after a failed detach.
|
|
68
|
-
*/
|
|
69
|
-
export async function readHookStdin() {
|
|
70
|
-
if (process.env.OPENVIKING_HOOK_STDIN_CACHE) {
|
|
71
|
-
const cached = process.env.OPENVIKING_HOOK_STDIN_CACHE;
|
|
72
|
-
delete process.env.OPENVIKING_HOOK_STDIN_CACHE;
|
|
73
|
-
return cached;
|
|
74
|
-
}
|
|
75
|
-
const chunks = [];
|
|
76
|
-
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
77
|
-
return Buffer.concat(chunks).toString();
|
|
78
|
-
}
|