@corenel/cli 0.4.3 → 0.4.4
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 +96 -8
- package/package.json +3 -3
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,41 @@ 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 `name:` and `workdir:`" };
|
|
22541
|
+
}
|
|
22542
|
+
const o = raw;
|
|
22543
|
+
const name = typeof o.name === "string" ? o.name : "";
|
|
22544
|
+
const workdir = typeof o.workdir === "string" ? o.workdir.trim() : "";
|
|
22545
|
+
if (!isValidSessionName(name)) {
|
|
22546
|
+
return {
|
|
22547
|
+
kind: "malformed",
|
|
22548
|
+
reason: `session.name ${JSON.stringify(name)} must be 1-32 characters of a-z, 0-9, "-" or "_"`
|
|
22549
|
+
};
|
|
22550
|
+
}
|
|
22551
|
+
if (!workdir) return { kind: "malformed", reason: "session.workdir is required" };
|
|
22552
|
+
return {
|
|
22553
|
+
kind: "binding",
|
|
22554
|
+
binding: {
|
|
22555
|
+
name,
|
|
22556
|
+
workdir,
|
|
22557
|
+
// Anything but an explicit `false` is true, matching how `enabled` is read
|
|
22558
|
+
// in store.ts — absent means the default, and the default is on.
|
|
22559
|
+
createIfMissing: o.createIfMissing !== false
|
|
22560
|
+
}
|
|
22561
|
+
};
|
|
22562
|
+
}
|
|
22563
|
+
|
|
22564
|
+
// ../crew/store.ts
|
|
22530
22565
|
var TRIGGER_TYPES = [
|
|
22531
22566
|
"manual",
|
|
22532
22567
|
"file-change",
|
|
@@ -22612,6 +22647,7 @@ async function loadCrewAgentAt(files, root, name, scope = "workspace") {
|
|
|
22612
22647
|
if (!isValidAgentName(name)) throw new Error(`invalid crew agent name: ${name}`);
|
|
22613
22648
|
const dir = `${root}/${name}`;
|
|
22614
22649
|
const { meta, body } = parseFrontmatter(await readOr(files, `${dir}/AGENT.md`));
|
|
22650
|
+
const session = parseSessionBinding(meta);
|
|
22615
22651
|
return {
|
|
22616
22652
|
name,
|
|
22617
22653
|
jobTitle: typeof meta.jobTitle === "string" ? meta.jobTitle : "",
|
|
@@ -22626,7 +22662,9 @@ async function loadCrewAgentAt(files, root, name, scope = "workspace") {
|
|
|
22626
22662
|
policy: parsePolicyYaml(await readOr(files, `${dir}/POLICY.yaml`), name),
|
|
22627
22663
|
settings: parseSettings(await readOr(files, `${dir}/settings.json`, "{}")),
|
|
22628
22664
|
budget: parseBudget(meta),
|
|
22629
|
-
canCall: parseCanCall(meta)
|
|
22665
|
+
canCall: parseCanCall(meta),
|
|
22666
|
+
...session.kind === "binding" ? { session: session.binding } : {},
|
|
22667
|
+
...session.kind === "malformed" ? { sessionError: session.reason } : {}
|
|
22630
22668
|
};
|
|
22631
22669
|
}
|
|
22632
22670
|
async function loadCrewAgentAtIfExists(files, root, name, scope = "workspace") {
|
|
@@ -22676,6 +22714,43 @@ function selfDirectionBlock(def) {
|
|
|
22676
22714
|
|
|
22677
22715
|
// ../crew/memory.ts
|
|
22678
22716
|
import { makeFactStore } from "@corenel/harness/memory/store";
|
|
22717
|
+
function agentMemoryRoot(crewRoot, agentName) {
|
|
22718
|
+
return `${crewRoot}/${agentName}/memory`;
|
|
22719
|
+
}
|
|
22720
|
+
function makeAgentMemoryProvider(getFiles, memoryRoot) {
|
|
22721
|
+
const store = makeFactStore(getFiles, memoryRoot);
|
|
22722
|
+
const toItem = (f) => ({
|
|
22723
|
+
id: f.name,
|
|
22724
|
+
name: f.name,
|
|
22725
|
+
type: f.type,
|
|
22726
|
+
description: f.description,
|
|
22727
|
+
text: f.body,
|
|
22728
|
+
tags: [],
|
|
22729
|
+
createdAt: f.created
|
|
22730
|
+
});
|
|
22731
|
+
return {
|
|
22732
|
+
async save(input) {
|
|
22733
|
+
return toItem(await store.save(input));
|
|
22734
|
+
},
|
|
22735
|
+
async read(name) {
|
|
22736
|
+
const hit = await store.read(name);
|
|
22737
|
+
return hit ? toItem(hit) : null;
|
|
22738
|
+
},
|
|
22739
|
+
async recall(query, limit) {
|
|
22740
|
+
return (await store.recall(query, limit)).map(toItem);
|
|
22741
|
+
},
|
|
22742
|
+
async list(limit) {
|
|
22743
|
+
return (await store.list(limit)).map(toItem);
|
|
22744
|
+
},
|
|
22745
|
+
async forget(name) {
|
|
22746
|
+
return store.forget(name);
|
|
22747
|
+
},
|
|
22748
|
+
async core() {
|
|
22749
|
+
const block = await store.core();
|
|
22750
|
+
return { items: block.facts.map(toItem), archivedCount: block.archivedCount };
|
|
22751
|
+
}
|
|
22752
|
+
};
|
|
22753
|
+
}
|
|
22679
22754
|
|
|
22680
22755
|
// ../crew/room/store.ts
|
|
22681
22756
|
import { flattenFiles as flattenFiles4 } from "@corenel/protocol";
|
|
@@ -22715,6 +22790,12 @@ function workspaceStateDir() {
|
|
|
22715
22790
|
const fromEnv = process.env.CORENEL_STATE_DIR;
|
|
22716
22791
|
return fromEnv && /^\.[A-Za-z0-9][A-Za-z0-9._-]*$/.test(fromEnv) ? fromEnv : stateDirName3();
|
|
22717
22792
|
}
|
|
22793
|
+
function guestCrewRoot() {
|
|
22794
|
+
return `${workspaceStateDir()}/${CREW_SEG}`;
|
|
22795
|
+
}
|
|
22796
|
+
function guestAgentMemoryRoot(agent) {
|
|
22797
|
+
return agentMemoryRoot(guestCrewRoot(), agent);
|
|
22798
|
+
}
|
|
22718
22799
|
function mutatingCeiling(tools, defaultLevel = "deny") {
|
|
22719
22800
|
const overrides = {};
|
|
22720
22801
|
for (const t of tools) if (!t.mutates) overrides[toolAddress(t)] = "allow";
|
|
@@ -22730,7 +22811,9 @@ function eventLine(e) {
|
|
|
22730
22811
|
}
|
|
22731
22812
|
async function runCrewAgentCli(opts) {
|
|
22732
22813
|
const files = new NodeFileService(opts.cwd);
|
|
22733
|
-
const root =
|
|
22814
|
+
const root = guestCrewRoot();
|
|
22815
|
+
const memoryRoot = guestAgentMemoryRoot(opts.agent);
|
|
22816
|
+
const memory = makeAgentMemoryProvider(() => files, memoryRoot);
|
|
22734
22817
|
const def = await loadCrewAgentAtIfExists(files, root, opts.agent, "workspace");
|
|
22735
22818
|
if (!def) {
|
|
22736
22819
|
opts.warn(`no such agent "${opts.agent}" under ${opts.cwd}/${root}`);
|
|
@@ -22748,7 +22831,7 @@ async function runCrewAgentCli(opts) {
|
|
|
22748
22831
|
}
|
|
22749
22832
|
registerGuard(tokenGuard(() => token));
|
|
22750
22833
|
const tools = allTools2();
|
|
22751
|
-
const extra = buildSystemExtra(def);
|
|
22834
|
+
const extra = buildSystemExtra(def, memoryRoot);
|
|
22752
22835
|
let system = extra;
|
|
22753
22836
|
try {
|
|
22754
22837
|
const base = await composeAgentSystem({
|
|
@@ -22791,7 +22874,7 @@ ${extra}` : base;
|
|
|
22791
22874
|
// Cause-aware refusal text -- see cli.ts's `run()` for why the kernel's
|
|
22792
22875
|
// own "denied by the user" default would be a lie on this path.
|
|
22793
22876
|
describePermissionDenial: nonInteractiveDenialMessage,
|
|
22794
|
-
toolCtx: nodeToolCtx(ac.signal, { files }),
|
|
22877
|
+
toolCtx: nodeToolCtx(ac.signal, { files, memory }),
|
|
22795
22878
|
policy: effectivePolicy,
|
|
22796
22879
|
signal: ac.signal,
|
|
22797
22880
|
onEvent: (e) => opts.emit(eventLine(e))
|
|
@@ -23803,9 +23886,14 @@ function isOnValue(value) {
|
|
|
23803
23886
|
return value === void 0 || !FALSY_FLAG_VALUES.has(value.toLowerCase());
|
|
23804
23887
|
}
|
|
23805
23888
|
function hasBooleanFlag(argv, name) {
|
|
23806
|
-
for (
|
|
23807
|
-
const parsed = classifyToken(
|
|
23808
|
-
if (!parsed
|
|
23889
|
+
for (let i = 0; i < argv.length; i++) {
|
|
23890
|
+
const parsed = classifyToken(argv[i]);
|
|
23891
|
+
if (!parsed) continue;
|
|
23892
|
+
if (parsed.value === void 0 && !isBooleanFlag(parsed.name)) {
|
|
23893
|
+
i++;
|
|
23894
|
+
continue;
|
|
23895
|
+
}
|
|
23896
|
+
if (parsed.name !== name) continue;
|
|
23809
23897
|
if (isOnValue(parsed.value)) return true;
|
|
23810
23898
|
}
|
|
23811
23899
|
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.4",
|
|
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": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@types/ws": "^8.5.13",
|
|
20
20
|
"tsx": "^4.19.2",
|
|
21
21
|
"typescript": "^5.9.3",
|
|
22
|
-
"@corenel/
|
|
23
|
-
"@corenel/
|
|
22
|
+
"@corenel/tools-node": "0.3.1",
|
|
23
|
+
"@corenel/crew": "0.0.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|