@ai-setting/roy-agent-core 1.7.5 → 1.7.6
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/env/index.js
CHANGED
|
@@ -68,7 +68,7 @@ import"../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
|
68
68
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
69
69
|
import {
|
|
70
70
|
PluginComponent
|
|
71
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
71
|
+
} from "../shared/@ai-setting/roy-agent-core-mfxwnyhs.js";
|
|
72
72
|
import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
73
73
|
import {
|
|
74
74
|
McpComponent
|
package/dist/env/plugin/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EventBusNotificationChannel,
|
|
3
3
|
PluginComponent
|
|
4
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "../../shared/@ai-setting/roy-agent-core-mfxwnyhs.js";
|
|
5
5
|
import {
|
|
6
6
|
BasePlugin
|
|
7
7
|
} from "../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
package/dist/index.js
CHANGED
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
} from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
189
189
|
import {
|
|
190
190
|
PluginComponent
|
|
191
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
191
|
+
} from "./shared/@ai-setting/roy-agent-core-mfxwnyhs.js";
|
|
192
192
|
import {
|
|
193
193
|
BasePlugin
|
|
194
194
|
} from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
@@ -18,6 +18,9 @@ import {
|
|
|
18
18
|
createLogger,
|
|
19
19
|
init_logger
|
|
20
20
|
} from "./roy-agent-core-kaq037np.js";
|
|
21
|
+
import {
|
|
22
|
+
__require
|
|
23
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
21
24
|
|
|
22
25
|
// src/env/plugin/event-bus-notification-channel.ts
|
|
23
26
|
init_logger();
|
|
@@ -71,8 +74,35 @@ init_global_hook_manager();
|
|
|
71
74
|
init_logger();
|
|
72
75
|
init_context();
|
|
73
76
|
import { existsSync, readFileSync } from "node:fs";
|
|
74
|
-
import { join } from "node:path";
|
|
77
|
+
import { join, dirname } from "node:path";
|
|
75
78
|
import { homedir } from "node:os";
|
|
79
|
+
function readActualVersion(resolvedPath) {
|
|
80
|
+
let dir = dirname(resolvedPath);
|
|
81
|
+
const root = dirname(dir);
|
|
82
|
+
while (dir !== root) {
|
|
83
|
+
const pkgPath = join(dir, "package.json");
|
|
84
|
+
if (existsSync(pkgPath)) {
|
|
85
|
+
try {
|
|
86
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
87
|
+
return pkg.version ?? null;
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
dir = dirname(dir);
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function checkVersionDrift(declaredVersion, resolvedPath, logger2) {
|
|
97
|
+
const actual = readActualVersion(resolvedPath);
|
|
98
|
+
const drifted = actual !== null && actual !== declaredVersion;
|
|
99
|
+
if (drifted && logger2) {
|
|
100
|
+
const pkgName = resolvedPath.includes("/node_modules/") ? resolvedPath.split("/node_modules/").pop() ?? resolvedPath : resolvedPath;
|
|
101
|
+
logger2.warn(`⚠️ Plugin '${pkgName}' version mismatch: declared ${declaredVersion} vs loaded ${actual} (path: ${resolvedPath})`);
|
|
102
|
+
}
|
|
103
|
+
return { declared: declaredVersion, actual, resolvedPath, drifted };
|
|
104
|
+
}
|
|
105
|
+
|
|
76
106
|
class PluginComponent extends BaseComponent {
|
|
77
107
|
name = "plugin";
|
|
78
108
|
version = "1.0.0";
|
|
@@ -127,22 +157,29 @@ class PluginComponent extends BaseComponent {
|
|
|
127
157
|
this.logger.info(`[PluginComponent] Loading ${allPlugins.length} installed plugin(s) from all configs`);
|
|
128
158
|
for (const entry of allPlugins) {
|
|
129
159
|
try {
|
|
130
|
-
await this.loadPluginFromPackage(entry.packageName);
|
|
160
|
+
await this.loadPluginFromPackage(entry.packageName, entry.version);
|
|
131
161
|
} catch (err) {
|
|
132
162
|
this.logger.error(`[PluginComponent] Failed to load plugin '${entry.packageName}': ${err}`);
|
|
133
163
|
}
|
|
134
164
|
}
|
|
135
165
|
}
|
|
136
|
-
async loadPluginFromPackage(packageName) {
|
|
166
|
+
async loadPluginFromPackage(packageName, declaredVersion) {
|
|
137
167
|
let pluginModule;
|
|
168
|
+
let resolvedPath = null;
|
|
138
169
|
try {
|
|
139
170
|
pluginModule = await import(packageName);
|
|
171
|
+
try {
|
|
172
|
+
const { createRequire } = await import("node:module");
|
|
173
|
+
const req = createRequire(import.meta.url);
|
|
174
|
+
resolvedPath = req.resolve(packageName);
|
|
175
|
+
} catch {}
|
|
140
176
|
} catch (_err) {
|
|
141
177
|
const projectPluginPath = join(process.cwd(), ".roy", "plugins", packageName);
|
|
142
178
|
if (existsSync(projectPluginPath)) {
|
|
143
179
|
this.logger.debug(`[PluginComponent] Falling back to project plugin path: ${projectPluginPath}`);
|
|
144
180
|
try {
|
|
145
181
|
pluginModule = await import(projectPluginPath);
|
|
182
|
+
resolvedPath = projectPluginPath;
|
|
146
183
|
} catch (err2) {
|
|
147
184
|
this.logger.warn(`[PluginComponent] Could not import plugin '${packageName}' from project path: ${err2}`);
|
|
148
185
|
return;
|
|
@@ -153,6 +190,7 @@ class PluginComponent extends BaseComponent {
|
|
|
153
190
|
this.logger.debug(`[PluginComponent] Falling back to global plugin path: ${globalPluginPath}`);
|
|
154
191
|
try {
|
|
155
192
|
pluginModule = await import(globalPluginPath);
|
|
193
|
+
resolvedPath = globalPluginPath;
|
|
156
194
|
} catch (err3) {
|
|
157
195
|
this.logger.warn(`[PluginComponent] Could not import plugin '${packageName}' from global path: ${err3}`);
|
|
158
196
|
return;
|
|
@@ -163,6 +201,11 @@ class PluginComponent extends BaseComponent {
|
|
|
163
201
|
}
|
|
164
202
|
}
|
|
165
203
|
}
|
|
204
|
+
if (declaredVersion && resolvedPath) {
|
|
205
|
+
checkVersionDrift(declaredVersion, resolvedPath, {
|
|
206
|
+
warn: (msg) => this.logger.warn(`[PluginComponent] ${msg}`)
|
|
207
|
+
});
|
|
208
|
+
}
|
|
166
209
|
const tryCreateInstance = (candidate, exportKind) => {
|
|
167
210
|
if (!candidate)
|
|
168
211
|
return;
|