@zenera/neo 1.3.4 → 1.3.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/project/load.js +59 -3
- package/package.json +2 -2
package/dist/project/load.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
// packages/neo/src/project/load.ts
|
|
2
|
+
//
|
|
3
|
+
// Turning a project folder (`agents.yaml`, `agents/*instructions.md`, `agents/prompts/`, skills,
|
|
4
|
+
// assets, memory) into an `AgentRegistry` and a runner. Also where house rules are discovered and
|
|
5
|
+
// gated by their `requires:` frontmatter (`CAPABILITIES`, `tools:<group>`).
|
|
6
|
+
// Main: `loadProject(dir, opts)` -> `AgentProject`; also `readProjectConfig`, `projectRegistry`,
|
|
7
|
+
// `memoryDir`, `skillDirs`, `skillMounts`, `assetsDir`.
|
|
8
|
+
// Used by (through `project/index.ts` and `@zenera/neo`): the engine (`engine.ts` loads every run,
|
|
9
|
+
// `projects.ts`, `audit.ts`); the CLI (`validate.ts`, `batch.ts`, `release.ts`, `container.ts`,
|
|
10
|
+
// `ask.ts`, `seed.ts`, commands); the server (`store.ts`, `status.ts`, `memory.ts`);
|
|
11
|
+
// `@zenera/meta` (`prepare.ts`); and SDK users directly.
|
|
12
|
+
// `packages/cli/src/validate.ts` mirrors its constants and capabilities on purpose: keep the two in
|
|
13
|
+
// step. Tests: test/project.test.ts.
|
|
1
14
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
15
|
import { basename, join, relative, resolve, sep } from 'node:path';
|
|
3
16
|
import { Agent, AgentRegistry } from "../agent.js";
|
|
@@ -223,9 +236,9 @@ function readHouseRules(root) {
|
|
|
223
236
|
const { data, body } = frontmatter(readFileSync(path, 'utf8'));
|
|
224
237
|
const requires = toList(data.requires);
|
|
225
238
|
for (const cap of requires) {
|
|
226
|
-
if (!(cap
|
|
239
|
+
if (!capability(cap)) {
|
|
227
240
|
throw new Error(`${rel}: unknown capability "${cap}" in requires: ` +
|
|
228
|
-
`(known: ${Object.keys(CAPABILITIES).join(', ')})`);
|
|
241
|
+
`(known: ${[...Object.keys(CAPABILITIES), `${TOOLS_CAPABILITY}<group>`].join(', ')})`);
|
|
229
242
|
}
|
|
230
243
|
}
|
|
231
244
|
// One object per document, shared by every agent it reaches, so the
|
|
@@ -327,6 +340,49 @@ const CAPABILITIES = {
|
|
|
327
340
|
workspace: (spec) => hasFileTools(spec),
|
|
328
341
|
'workspace-write': (spec) => hasFileWriteTools(spec),
|
|
329
342
|
};
|
|
343
|
+
/**
|
|
344
|
+
* `tools:<group>`: the agent's `tools:` grants at least one tool of that group.
|
|
345
|
+
* The one open-ended entry, because groups come from plugins this package
|
|
346
|
+
* cannot list. It is still decided from `agents.yaml` alone, so a bare name
|
|
347
|
+
* counts as the group's when it carries the group's prefix (`mcp_call` for
|
|
348
|
+
* `mcp`) - the convention plugin tools are named by.
|
|
349
|
+
*/
|
|
350
|
+
const TOOLS_CAPABILITY = 'tools:';
|
|
351
|
+
function grantsGroup(selectors, group) {
|
|
352
|
+
let whole = false;
|
|
353
|
+
const named = new Set();
|
|
354
|
+
for (const raw of selectors ?? []) {
|
|
355
|
+
const drop = raw.startsWith('-');
|
|
356
|
+
const selector = (drop ? raw.slice(1) : raw).trim();
|
|
357
|
+
if (selector === '*' || selector === `${group}:*`) {
|
|
358
|
+
whole = !drop;
|
|
359
|
+
named.clear();
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
const colon = selector.lastIndexOf(':');
|
|
363
|
+
const name = colon >= 0 ? selector.slice(colon + 1) : selector;
|
|
364
|
+
const inGroup = colon >= 0 ? selector.slice(0, colon) === group : name.startsWith(`${group}_`);
|
|
365
|
+
if (!inGroup) {
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (drop) {
|
|
369
|
+
named.delete(name);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
named.add(name);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
// A whole group less some names still grants the rest: no selector can
|
|
376
|
+
// withdraw every tool of a group without knowing what the group holds.
|
|
377
|
+
return whole || named.size > 0;
|
|
378
|
+
}
|
|
379
|
+
function capability(cap) {
|
|
380
|
+
if (cap.startsWith(TOOLS_CAPABILITY)) {
|
|
381
|
+
const group = cap.slice(TOOLS_CAPABILITY.length);
|
|
382
|
+
return group ? (spec) => grantsGroup(spec.tools, group) : undefined;
|
|
383
|
+
}
|
|
384
|
+
return Object.hasOwn(CAPABILITIES, cap) ? CAPABILITIES[cap] : undefined;
|
|
385
|
+
}
|
|
330
386
|
/**
|
|
331
387
|
* The document as this agent gets it, or `undefined` when its conditions rule
|
|
332
388
|
* the agent out. Several run-time conditions are met by meeting all of them.
|
|
@@ -334,7 +390,7 @@ const CAPABILITIES = {
|
|
|
334
390
|
function ruleFor(rule, spec) {
|
|
335
391
|
const gates = [];
|
|
336
392
|
for (const cap of rule.requires) {
|
|
337
|
-
const resolved =
|
|
393
|
+
const resolved = capability(cap)(spec);
|
|
338
394
|
if (!resolved) {
|
|
339
395
|
return undefined;
|
|
340
396
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenera/neo",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "A multi-agent runtime for Node.js: agents, models, tools, skills, memory and an append-only trajectory.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"prepack": "tsc -b"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@zenera/sandbox": "^1.3.
|
|
65
|
+
"@zenera/sandbox": "^1.3.6",
|
|
66
66
|
"graphology": "^0.26.0",
|
|
67
67
|
"yaml": "^2.9.1",
|
|
68
68
|
"zod": "^4.6.7"
|