@corenel/cli 0.4.3 → 0.4.5
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/cli.js +93 -8
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -22250,7 +22250,7 @@ function previewWrite(files) {
|
|
|
22250
22250
|
}
|
|
22251
22251
|
function nodeToolCtx(signal, opts = {}) {
|
|
22252
22252
|
const base = {
|
|
22253
|
-
memory: inMemoryMemory(),
|
|
22253
|
+
memory: opts.memory ?? inMemoryMemory(),
|
|
22254
22254
|
kv: inMemoryKv(),
|
|
22255
22255
|
search: nullSearch,
|
|
22256
22256
|
confirm: async () => true,
|
|
@@ -22527,6 +22527,38 @@ function isValidAgentName(name) {
|
|
|
22527
22527
|
// ../crew/store.ts
|
|
22528
22528
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
22529
22529
|
import { flattenFiles as flattenFiles3 } from "@corenel/protocol";
|
|
22530
|
+
|
|
22531
|
+
// ../crew/sessionBinding.ts
|
|
22532
|
+
var SESSION_NAME_RE = /^[a-z0-9_-]{1,32}$/;
|
|
22533
|
+
function isValidSessionName(name) {
|
|
22534
|
+
return SESSION_NAME_RE.test(name);
|
|
22535
|
+
}
|
|
22536
|
+
function parseSessionBinding(meta) {
|
|
22537
|
+
const raw = meta.session;
|
|
22538
|
+
if (raw === void 0) return { kind: "absent" };
|
|
22539
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
22540
|
+
return { kind: "malformed", reason: "session: must be a block with a `name:`" };
|
|
22541
|
+
}
|
|
22542
|
+
const o = raw;
|
|
22543
|
+
const name = typeof o.name === "string" ? o.name : "";
|
|
22544
|
+
if (!isValidSessionName(name)) {
|
|
22545
|
+
return {
|
|
22546
|
+
kind: "malformed",
|
|
22547
|
+
reason: `session.name ${JSON.stringify(name)} must be 1-32 characters of a-z, 0-9, "-" or "_"`
|
|
22548
|
+
};
|
|
22549
|
+
}
|
|
22550
|
+
return {
|
|
22551
|
+
kind: "binding",
|
|
22552
|
+
binding: {
|
|
22553
|
+
name,
|
|
22554
|
+
// Anything but an explicit `false` is true, matching how `enabled` is read
|
|
22555
|
+
// in store.ts — absent means the default, and the default is on.
|
|
22556
|
+
createIfMissing: o.createIfMissing !== false
|
|
22557
|
+
}
|
|
22558
|
+
};
|
|
22559
|
+
}
|
|
22560
|
+
|
|
22561
|
+
// ../crew/store.ts
|
|
22530
22562
|
var TRIGGER_TYPES = [
|
|
22531
22563
|
"manual",
|
|
22532
22564
|
"file-change",
|
|
@@ -22612,6 +22644,7 @@ async function loadCrewAgentAt(files, root, name, scope = "workspace") {
|
|
|
22612
22644
|
if (!isValidAgentName(name)) throw new Error(`invalid crew agent name: ${name}`);
|
|
22613
22645
|
const dir = `${root}/${name}`;
|
|
22614
22646
|
const { meta, body } = parseFrontmatter(await readOr(files, `${dir}/AGENT.md`));
|
|
22647
|
+
const session = parseSessionBinding(meta);
|
|
22615
22648
|
return {
|
|
22616
22649
|
name,
|
|
22617
22650
|
jobTitle: typeof meta.jobTitle === "string" ? meta.jobTitle : "",
|
|
@@ -22626,7 +22659,9 @@ async function loadCrewAgentAt(files, root, name, scope = "workspace") {
|
|
|
22626
22659
|
policy: parsePolicyYaml(await readOr(files, `${dir}/POLICY.yaml`), name),
|
|
22627
22660
|
settings: parseSettings(await readOr(files, `${dir}/settings.json`, "{}")),
|
|
22628
22661
|
budget: parseBudget(meta),
|
|
22629
|
-
canCall: parseCanCall(meta)
|
|
22662
|
+
canCall: parseCanCall(meta),
|
|
22663
|
+
...session.kind === "binding" ? { session: session.binding } : {},
|
|
22664
|
+
...session.kind === "malformed" ? { sessionError: session.reason } : {}
|
|
22630
22665
|
};
|
|
22631
22666
|
}
|
|
22632
22667
|
async function loadCrewAgentAtIfExists(files, root, name, scope = "workspace") {
|
|
@@ -22676,6 +22711,43 @@ function selfDirectionBlock(def) {
|
|
|
22676
22711
|
|
|
22677
22712
|
// ../crew/memory.ts
|
|
22678
22713
|
import { makeFactStore } from "@corenel/harness/memory/store";
|
|
22714
|
+
function agentMemoryRoot(crewRoot, agentName) {
|
|
22715
|
+
return `${crewRoot}/${agentName}/memory`;
|
|
22716
|
+
}
|
|
22717
|
+
function makeAgentMemoryProvider(getFiles, memoryRoot) {
|
|
22718
|
+
const store = makeFactStore(getFiles, memoryRoot);
|
|
22719
|
+
const toItem = (f) => ({
|
|
22720
|
+
id: f.name,
|
|
22721
|
+
name: f.name,
|
|
22722
|
+
type: f.type,
|
|
22723
|
+
description: f.description,
|
|
22724
|
+
text: f.body,
|
|
22725
|
+
tags: [],
|
|
22726
|
+
createdAt: f.created
|
|
22727
|
+
});
|
|
22728
|
+
return {
|
|
22729
|
+
async save(input) {
|
|
22730
|
+
return toItem(await store.save(input));
|
|
22731
|
+
},
|
|
22732
|
+
async read(name) {
|
|
22733
|
+
const hit = await store.read(name);
|
|
22734
|
+
return hit ? toItem(hit) : null;
|
|
22735
|
+
},
|
|
22736
|
+
async recall(query, limit) {
|
|
22737
|
+
return (await store.recall(query, limit)).map(toItem);
|
|
22738
|
+
},
|
|
22739
|
+
async list(limit) {
|
|
22740
|
+
return (await store.list(limit)).map(toItem);
|
|
22741
|
+
},
|
|
22742
|
+
async forget(name) {
|
|
22743
|
+
return store.forget(name);
|
|
22744
|
+
},
|
|
22745
|
+
async core() {
|
|
22746
|
+
const block = await store.core();
|
|
22747
|
+
return { items: block.facts.map(toItem), archivedCount: block.archivedCount };
|
|
22748
|
+
}
|
|
22749
|
+
};
|
|
22750
|
+
}
|
|
22679
22751
|
|
|
22680
22752
|
// ../crew/room/store.ts
|
|
22681
22753
|
import { flattenFiles as flattenFiles4 } from "@corenel/protocol";
|
|
@@ -22715,6 +22787,12 @@ function workspaceStateDir() {
|
|
|
22715
22787
|
const fromEnv = process.env.CORENEL_STATE_DIR;
|
|
22716
22788
|
return fromEnv && /^\.[A-Za-z0-9][A-Za-z0-9._-]*$/.test(fromEnv) ? fromEnv : stateDirName3();
|
|
22717
22789
|
}
|
|
22790
|
+
function guestCrewRoot() {
|
|
22791
|
+
return `${workspaceStateDir()}/${CREW_SEG}`;
|
|
22792
|
+
}
|
|
22793
|
+
function guestAgentMemoryRoot(agent) {
|
|
22794
|
+
return agentMemoryRoot(guestCrewRoot(), agent);
|
|
22795
|
+
}
|
|
22718
22796
|
function mutatingCeiling(tools, defaultLevel = "deny") {
|
|
22719
22797
|
const overrides = {};
|
|
22720
22798
|
for (const t of tools) if (!t.mutates) overrides[toolAddress(t)] = "allow";
|
|
@@ -22730,7 +22808,9 @@ function eventLine(e) {
|
|
|
22730
22808
|
}
|
|
22731
22809
|
async function runCrewAgentCli(opts) {
|
|
22732
22810
|
const files = new NodeFileService(opts.cwd);
|
|
22733
|
-
const root =
|
|
22811
|
+
const root = guestCrewRoot();
|
|
22812
|
+
const memoryRoot = guestAgentMemoryRoot(opts.agent);
|
|
22813
|
+
const memory = makeAgentMemoryProvider(() => files, memoryRoot);
|
|
22734
22814
|
const def = await loadCrewAgentAtIfExists(files, root, opts.agent, "workspace");
|
|
22735
22815
|
if (!def) {
|
|
22736
22816
|
opts.warn(`no such agent "${opts.agent}" under ${opts.cwd}/${root}`);
|
|
@@ -22748,7 +22828,7 @@ async function runCrewAgentCli(opts) {
|
|
|
22748
22828
|
}
|
|
22749
22829
|
registerGuard(tokenGuard(() => token));
|
|
22750
22830
|
const tools = allTools2();
|
|
22751
|
-
const extra = buildSystemExtra(def);
|
|
22831
|
+
const extra = buildSystemExtra(def, memoryRoot);
|
|
22752
22832
|
let system = extra;
|
|
22753
22833
|
try {
|
|
22754
22834
|
const base = await composeAgentSystem({
|
|
@@ -22791,7 +22871,7 @@ ${extra}` : base;
|
|
|
22791
22871
|
// Cause-aware refusal text -- see cli.ts's `run()` for why the kernel's
|
|
22792
22872
|
// own "denied by the user" default would be a lie on this path.
|
|
22793
22873
|
describePermissionDenial: nonInteractiveDenialMessage,
|
|
22794
|
-
toolCtx: nodeToolCtx(ac.signal, { files }),
|
|
22874
|
+
toolCtx: nodeToolCtx(ac.signal, { files, memory }),
|
|
22795
22875
|
policy: effectivePolicy,
|
|
22796
22876
|
signal: ac.signal,
|
|
22797
22877
|
onEvent: (e) => opts.emit(eventLine(e))
|
|
@@ -23803,9 +23883,14 @@ function isOnValue(value) {
|
|
|
23803
23883
|
return value === void 0 || !FALSY_FLAG_VALUES.has(value.toLowerCase());
|
|
23804
23884
|
}
|
|
23805
23885
|
function hasBooleanFlag(argv, name) {
|
|
23806
|
-
for (
|
|
23807
|
-
const parsed = classifyToken(
|
|
23808
|
-
if (!parsed
|
|
23886
|
+
for (let i = 0; i < argv.length; i++) {
|
|
23887
|
+
const parsed = classifyToken(argv[i]);
|
|
23888
|
+
if (!parsed) continue;
|
|
23889
|
+
if (parsed.value === void 0 && !isBooleanFlag(parsed.name)) {
|
|
23890
|
+
i++;
|
|
23891
|
+
continue;
|
|
23892
|
+
}
|
|
23893
|
+
if (parsed.name !== name) continue;
|
|
23809
23894
|
if (isOnValue(parsed.value)) return true;
|
|
23810
23895
|
}
|
|
23811
23896
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corenel/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Corenel CLI — runs the harness in node, in-proc, no transport. The headless proof the kernel is host-agnostic. (corenel run/ask/chat/login + start --sidecar to follow.)",
|
|
6
6
|
"bin": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"openai": "^4.77.0",
|
|
11
11
|
"ws": "^8.18.0",
|
|
12
|
-
"@corenel/harness": "0.
|
|
13
|
-
"@corenel/
|
|
14
|
-
"@corenel/
|
|
12
|
+
"@corenel/harness": "0.7.0",
|
|
13
|
+
"@corenel/protocol": "0.7.0",
|
|
14
|
+
"@corenel/term": "0.2.4"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"esbuild": "^0.21.5",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"tsx": "^4.19.2",
|
|
21
21
|
"typescript": "^5.9.3",
|
|
22
22
|
"@corenel/crew": "0.0.0",
|
|
23
|
-
"@corenel/tools-node": "0.3.
|
|
23
|
+
"@corenel/tools-node": "0.3.2"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|