@zenera/engine 1.1.53 → 1.1.54

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/engine.js CHANGED
@@ -21,6 +21,9 @@ export async function openEngine(opts) {
21
21
  const logger = opts.logger ?? stderrLogger;
22
22
  const onIssue = opts.onIssue ?? ((issue) => logger.warn(describeIssue(issue)));
23
23
  const user = resolveUser(opts.user);
24
+ // The machine's plugins are imported before the project's env file is read: a plugin may
25
+ // configure itself from the environment when imported, and that must be the host's.
26
+ const machinePlugins = opts.envPlugins === false ? [] : await envPlugins(logger);
24
27
  // Before the keyring, so the project's own file wins over the machine's
25
28
  // keys, and before the load, so `${VAR}` in agents.yaml can name anything
26
29
  // in it. The real environment still beats both.
@@ -29,7 +32,7 @@ export async function openEngine(opts) {
29
32
  logger.warn(`${env.path} sets ${env.refused.join(', ')} — ignored: who a run acts for, and ` +
30
33
  'which plugins load, are the host’s to say (zen run --as <user> to try one)');
31
34
  }
32
- const hostPlugins = mergePlugins(opts.plugins ?? [], opts.envPlugins === false ? [] : await envPlugins(logger));
35
+ const hostPlugins = mergePlugins(opts.plugins ?? [], machinePlugins);
33
36
  const keys = await KeyStore.open();
34
37
  keys.materialize();
35
38
  assertUsable(keys);
package/dist/plugins.d.ts CHANGED
@@ -11,7 +11,8 @@ export interface PluginContext {
11
11
  dir: string;
12
12
  name: string;
13
13
  };
14
- session: SessionPaths;
14
+ /** the session the run belongs to; absent when tools are only listed (`zen check`) */
15
+ session?: SessionPaths;
15
16
  logger: Logger;
16
17
  }
17
18
  export interface ZenPlugin {
@@ -45,4 +46,13 @@ export declare function envPlugins(logger: Logger): Promise<ZenPlugin[]>;
45
46
  export declare function importPlugins(list: string | undefined, logger: Logger): Promise<ZenPlugin[]>;
46
47
  /** The host's plugins and the machine's, the host's winning where both name one. */
47
48
  export declare function mergePlugins(given: readonly ZenPlugin[], machine: readonly ZenPlugin[]): ZenPlugin[];
49
+ /**
50
+ * The tools the machine's plugins add, for checking a project rather than
51
+ * running it: the plugins are asked with no user and no session, and closed
52
+ * again. A plugin that fails or clashes is a warning, and adds nothing.
53
+ */
54
+ export declare function machinePluginTools(project: {
55
+ dir: string;
56
+ name: string;
57
+ }, builtins: readonly AnyTool[], logger: Logger): Promise<AnyTool[]>;
48
58
  //# sourceMappingURL=plugins.d.ts.map
package/dist/plugins.js CHANGED
@@ -137,4 +137,26 @@ export function mergePlugins(given, machine) {
137
137
  const names = new Set(given.map((p) => p.name));
138
138
  return [...given, ...machine.filter((p) => !names.has(p.name))];
139
139
  }
140
+ /**
141
+ * The tools the machine's plugins add, for checking a project rather than
142
+ * running it: the plugins are asked with no user and no session, and closed
143
+ * again. A plugin that fails or clashes is a warning, and adds nothing.
144
+ */
145
+ export async function machinePluginTools(project, builtins, logger) {
146
+ const tools = [];
147
+ for (const plugin of await envPlugins(logger)) {
148
+ try {
149
+ const loaded = await loadPlugins([plugin], { project, logger }, [
150
+ ...builtins,
151
+ ...tools,
152
+ ]);
153
+ await loaded.close();
154
+ tools.push(...loaded.tools);
155
+ }
156
+ catch (err) {
157
+ logger.warn(`${PLUGINS_ENV}: ${message(err)} — its tools are left out`);
158
+ }
159
+ }
160
+ return tools;
161
+ }
140
162
  //# sourceMappingURL=plugins.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenera/engine",
3
- "version": "1.1.53",
3
+ "version": "1.1.54",
4
4
  "description": "Runs a @zenera/neo project on this machine: keyring, sandbox, sessions and the record each turn leaves behind.",
5
5
  "keywords": [
6
6
  "agents",
@@ -45,6 +45,6 @@
45
45
  "prepack": "tsc -b"
46
46
  },
47
47
  "dependencies": {
48
- "@zenera/neo": "^1.1.53"
48
+ "@zenera/neo": "^1.1.54"
49
49
  }
50
50
  }