@corenel/cli 0.4.1 → 0.4.2
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 +197 -42
- package/package.json +11 -6
package/dist/cli.js
CHANGED
|
@@ -18832,7 +18832,7 @@ var NodeFileService = class {
|
|
|
18832
18832
|
out.push({ name: e.name, path, kind: "directory", children: await walk(absChild) });
|
|
18833
18833
|
} else {
|
|
18834
18834
|
const st = await fs.stat(absChild).catch(() => null);
|
|
18835
|
-
out.push({ name: e.name, path, kind: "file", size: st?.size, ext: extOf(e.name) });
|
|
18835
|
+
out.push({ name: e.name, path, kind: "file", size: st?.size, mtime: st?.mtimeMs, ext: extOf(e.name) });
|
|
18836
18836
|
}
|
|
18837
18837
|
}
|
|
18838
18838
|
return out;
|
|
@@ -18845,7 +18845,7 @@ var NodeFileService = class {
|
|
|
18845
18845
|
async stat(path) {
|
|
18846
18846
|
try {
|
|
18847
18847
|
const st = await fs.stat(this.abs(path));
|
|
18848
|
-
return { path: normalizeFilePath(path), kind: st.isDirectory() ? "directory" : "file", size: st.size, ext: extOf(path) };
|
|
18848
|
+
return { path: normalizeFilePath(path), kind: st.isDirectory() ? "directory" : "file", size: st.size, mtime: st.mtimeMs, ext: extOf(path) };
|
|
18849
18849
|
} catch {
|
|
18850
18850
|
return null;
|
|
18851
18851
|
}
|
|
@@ -18910,7 +18910,7 @@ var NodeFileService = class {
|
|
|
18910
18910
|
import { promises as fs2 } from "node:fs";
|
|
18911
18911
|
import { homedir } from "node:os";
|
|
18912
18912
|
import { join as join2 } from "node:path";
|
|
18913
|
-
import { stateDirName } from "@corenel/protocol";
|
|
18913
|
+
import { stateDirName, DEFAULT_API_BASE } from "@corenel/protocol";
|
|
18914
18914
|
function corenelDir(base = homedir()) {
|
|
18915
18915
|
return join2(base, stateDirName());
|
|
18916
18916
|
}
|
|
@@ -18920,34 +18920,142 @@ function sidecarDir(base = homedir()) {
|
|
|
18920
18920
|
function authTokenPath(base = homedir()) {
|
|
18921
18921
|
return join2(corenelDir(base), "token");
|
|
18922
18922
|
}
|
|
18923
|
-
|
|
18924
|
-
|
|
18925
|
-
|
|
18923
|
+
function credentialDir(stateDir) {
|
|
18924
|
+
return stateDir ?? corenelDir();
|
|
18925
|
+
}
|
|
18926
|
+
function tokenFilePath(stateDir) {
|
|
18927
|
+
return join2(credentialDir(stateDir), "token");
|
|
18928
|
+
}
|
|
18929
|
+
function credentialFilePath(stateDir) {
|
|
18930
|
+
return join2(credentialDir(stateDir), "auth.json");
|
|
18931
|
+
}
|
|
18932
|
+
var TOKEN_ENV = "CORENEL_TOKEN";
|
|
18933
|
+
var API_BASE_ENV = "CORENEL_API_BASE";
|
|
18934
|
+
async function writeAuthToken(token, stateDir) {
|
|
18935
|
+
const dir = credentialDir(stateDir);
|
|
18936
|
+
const path = tokenFilePath(stateDir);
|
|
18937
|
+
await fs2.mkdir(dir, { recursive: true, mode: 448 });
|
|
18938
|
+
await fs2.writeFile(path, token.trim() + "\n", { mode: 384 });
|
|
18926
18939
|
try {
|
|
18927
|
-
await fs2.chmod(
|
|
18940
|
+
await fs2.chmod(path, 384);
|
|
18928
18941
|
} catch {
|
|
18929
18942
|
}
|
|
18930
18943
|
try {
|
|
18931
|
-
await fs2.chmod(
|
|
18944
|
+
await fs2.chmod(dir, 448);
|
|
18945
|
+
} catch {
|
|
18946
|
+
}
|
|
18947
|
+
}
|
|
18948
|
+
async function writeLoginCredential(token, opts = {}) {
|
|
18949
|
+
const cred = {
|
|
18950
|
+
accessToken: token.trim(),
|
|
18951
|
+
...opts.account ? { account: opts.account } : {},
|
|
18952
|
+
...opts.apiBase ? { apiBase: opts.apiBase } : {}
|
|
18953
|
+
};
|
|
18954
|
+
const path = credentialFilePath(opts.stateDir);
|
|
18955
|
+
await fs2.mkdir(credentialDir(opts.stateDir), { recursive: true, mode: 448 });
|
|
18956
|
+
await fs2.writeFile(path, `${JSON.stringify(cred, null, 2)}
|
|
18957
|
+
`, { mode: 384 });
|
|
18958
|
+
try {
|
|
18959
|
+
await fs2.chmod(path, 384);
|
|
18932
18960
|
} catch {
|
|
18933
18961
|
}
|
|
18962
|
+
await writeAuthToken(cred.accessToken, opts.stateDir);
|
|
18934
18963
|
}
|
|
18935
|
-
async function readAuthToken() {
|
|
18964
|
+
async function readAuthToken(stateDir) {
|
|
18936
18965
|
try {
|
|
18937
|
-
const t = (await fs2.readFile(
|
|
18966
|
+
const t = (await fs2.readFile(tokenFilePath(stateDir), "utf8")).trim();
|
|
18938
18967
|
return t || null;
|
|
18939
18968
|
} catch {
|
|
18940
18969
|
return null;
|
|
18941
18970
|
}
|
|
18942
18971
|
}
|
|
18943
|
-
async function clearAuthToken() {
|
|
18972
|
+
async function clearAuthToken(stateDir) {
|
|
18944
18973
|
try {
|
|
18945
|
-
await fs2.rm(
|
|
18974
|
+
await fs2.rm(tokenFilePath(stateDir), { force: true });
|
|
18946
18975
|
} catch {
|
|
18947
18976
|
}
|
|
18948
18977
|
}
|
|
18949
|
-
function
|
|
18950
|
-
|
|
18978
|
+
async function readCredentialFile(stateDir) {
|
|
18979
|
+
let raw;
|
|
18980
|
+
try {
|
|
18981
|
+
raw = await fs2.readFile(credentialFilePath(stateDir), "utf8");
|
|
18982
|
+
} catch {
|
|
18983
|
+
return null;
|
|
18984
|
+
}
|
|
18985
|
+
try {
|
|
18986
|
+
const parsed = JSON.parse(raw);
|
|
18987
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
18988
|
+
const c = parsed;
|
|
18989
|
+
if (typeof c.accessToken !== "string" || !c.accessToken) return null;
|
|
18990
|
+
return {
|
|
18991
|
+
accessToken: c.accessToken,
|
|
18992
|
+
...typeof c.refreshToken === "string" ? { refreshToken: c.refreshToken } : {},
|
|
18993
|
+
...typeof c.expiresAt === "number" ? { expiresAt: c.expiresAt } : {},
|
|
18994
|
+
...typeof c.account === "string" ? { account: c.account } : {},
|
|
18995
|
+
...typeof c.apiBase === "string" && c.apiBase ? { apiBase: c.apiBase } : {}
|
|
18996
|
+
};
|
|
18997
|
+
} catch {
|
|
18998
|
+
return null;
|
|
18999
|
+
}
|
|
19000
|
+
}
|
|
19001
|
+
async function clearAllCredentials(stateDir) {
|
|
19002
|
+
await clearAuthToken(stateDir);
|
|
19003
|
+
try {
|
|
19004
|
+
await fs2.rm(credentialFilePath(stateDir), { force: true });
|
|
19005
|
+
} catch {
|
|
19006
|
+
}
|
|
19007
|
+
}
|
|
19008
|
+
async function resolveNodeCredential(opts = {}) {
|
|
19009
|
+
const env = opts.env ?? process.env;
|
|
19010
|
+
const now = opts.now ?? Date.now;
|
|
19011
|
+
const stateDir = opts.stateDir;
|
|
19012
|
+
const fromEnv = env[TOKEN_ENV]?.trim();
|
|
19013
|
+
if (fromEnv) return { token: fromEnv, source: "env" };
|
|
19014
|
+
const cred = await readCredentialFile(stateDir);
|
|
19015
|
+
const fileToken = await readAuthToken(stateDir);
|
|
19016
|
+
if (fileToken) {
|
|
19017
|
+
const same = cred && cred.accessToken === fileToken ? cred : null;
|
|
19018
|
+
return withExpiry({ token: fileToken, source: "token-file", path: tokenFilePath(stateDir) }, same, now);
|
|
19019
|
+
}
|
|
19020
|
+
if (cred) {
|
|
19021
|
+
return withExpiry(
|
|
19022
|
+
{ token: cred.accessToken, source: "credential-file", path: credentialFilePath(stateDir) },
|
|
19023
|
+
cred,
|
|
19024
|
+
now
|
|
19025
|
+
);
|
|
19026
|
+
}
|
|
19027
|
+
return { token: null, source: "none" };
|
|
19028
|
+
}
|
|
19029
|
+
function withExpiry(base, cred, now) {
|
|
19030
|
+
if (!cred) return base;
|
|
19031
|
+
const expired = typeof cred.expiresAt === "number" && cred.expiresAt <= now();
|
|
19032
|
+
return {
|
|
19033
|
+
...base,
|
|
19034
|
+
...typeof cred.expiresAt === "number" ? { expiresAt: cred.expiresAt } : {},
|
|
19035
|
+
...expired ? { expired: true } : {},
|
|
19036
|
+
...cred.account ? { account: cred.account } : {},
|
|
19037
|
+
...cred.apiBase ? { apiBase: cred.apiBase } : {}
|
|
19038
|
+
};
|
|
19039
|
+
}
|
|
19040
|
+
async function resolveApiBase(opts = {}) {
|
|
19041
|
+
const explicit = opts.explicit?.trim();
|
|
19042
|
+
if (explicit) return { base: explicit, source: "explicit" };
|
|
19043
|
+
const fromEnv = (opts.env ?? process.env)[API_BASE_ENV]?.trim();
|
|
19044
|
+
if (fromEnv) return { base: fromEnv, source: "env" };
|
|
19045
|
+
const cred = await resolveNodeCredential({
|
|
19046
|
+
env: {},
|
|
19047
|
+
...opts.stateDir ? { stateDir: opts.stateDir } : {}
|
|
19048
|
+
});
|
|
19049
|
+
if (cred.apiBase) return { base: cred.apiBase, source: "credential" };
|
|
19050
|
+
return { base: DEFAULT_API_BASE, source: "default" };
|
|
19051
|
+
}
|
|
19052
|
+
function maskToken(token) {
|
|
19053
|
+
const t = token.trim();
|
|
19054
|
+
if (t.length <= 8) return "****";
|
|
19055
|
+
return `${t.slice(0, 4)}\u2026${t.slice(-2)} (${t.length} chars)`;
|
|
19056
|
+
}
|
|
19057
|
+
function nodeAuthToken(stateDir) {
|
|
19058
|
+
return { getToken: async () => (await resolveNodeCredential(stateDir ? { stateDir } : {})).token };
|
|
18951
19059
|
}
|
|
18952
19060
|
|
|
18953
19061
|
// ../../node_modules/.pnpm/@prompd+core@0.5.0-beta.10/node_modules/@prompd/core/dist/index.js
|
|
@@ -22048,7 +22156,7 @@ function configWorkspaceRoot(base) {
|
|
|
22048
22156
|
// src/cli.ts
|
|
22049
22157
|
import { FileRecallStore, UNATTACHED_SESSION } from "@corenel/harness/sessions/fileRecallStore";
|
|
22050
22158
|
import { stateDirName as stateDirName6 } from "@corenel/protocol";
|
|
22051
|
-
import { PermissionService as
|
|
22159
|
+
import { PermissionService as PermissionService4 } from "@corenel/harness/guardrail/permission-service";
|
|
22052
22160
|
|
|
22053
22161
|
// src/nodeContext.ts
|
|
22054
22162
|
import { ROOT_NODE_ID } from "@corenel/protocol";
|
|
@@ -22209,7 +22317,7 @@ import { runAgent } from "@corenel/harness/core/loop";
|
|
|
22209
22317
|
import { createChatClient, setGatewayBase } from "@corenel/harness/providers/gateway";
|
|
22210
22318
|
|
|
22211
22319
|
// src/apiBase.ts
|
|
22212
|
-
|
|
22320
|
+
import { DEFAULT_API_BASE as DEFAULT_API_BASE2 } from "@corenel/protocol";
|
|
22213
22321
|
var InvalidApiBaseError = class extends Error {
|
|
22214
22322
|
constructor(value, why) {
|
|
22215
22323
|
super(`invalid API base ${JSON.stringify(value)} -- ${why}`);
|
|
@@ -22223,8 +22331,13 @@ function isLoopback(hostname) {
|
|
|
22223
22331
|
return h === "localhost" || h === "127.0.0.1" || h === "::1" || h.endsWith(".localhost");
|
|
22224
22332
|
}
|
|
22225
22333
|
var warnedCleartext = false;
|
|
22226
|
-
function apiBase(explicit) {
|
|
22227
|
-
const
|
|
22334
|
+
async function apiBase(explicit, opts = {}) {
|
|
22335
|
+
const resolved = await resolveApiBase({
|
|
22336
|
+
explicit,
|
|
22337
|
+
env: opts.env ?? process.env,
|
|
22338
|
+
...opts.stateDir ? { stateDir: opts.stateDir } : {}
|
|
22339
|
+
});
|
|
22340
|
+
const value = resolved.base;
|
|
22228
22341
|
let url;
|
|
22229
22342
|
try {
|
|
22230
22343
|
url = new URL(value);
|
|
@@ -22454,7 +22567,7 @@ async function loadCrewAgentAtIfExists(files, root, name, scope = "workspace") {
|
|
|
22454
22567
|
import { saveCustomPolicy } from "@corenel/harness/guardrail";
|
|
22455
22568
|
import { allTools } from "@corenel/harness/tools/builtins";
|
|
22456
22569
|
import { makeCallAgentTool } from "@corenel/harness/tools/callAgent";
|
|
22457
|
-
function buildSystemExtra(def) {
|
|
22570
|
+
function buildSystemExtra(def, memoryLocation) {
|
|
22458
22571
|
const parts = [];
|
|
22459
22572
|
if (def.jobTitle?.trim()) parts.push(`--- Role ---
|
|
22460
22573
|
${def.jobTitle.trim()}`);
|
|
@@ -22464,12 +22577,57 @@ ${def.soul.trim()}`);
|
|
|
22464
22577
|
${def.persona.trim()}`);
|
|
22465
22578
|
if (def.instructions.trim()) parts.push(`--- Instructions ---
|
|
22466
22579
|
${def.instructions.trim()}`);
|
|
22580
|
+
const location = memoryLocation ?? "memory/";
|
|
22581
|
+
const dir = location.replace(/\/+$/, "");
|
|
22582
|
+
const index = `${dir}/MEMORY.md`;
|
|
22583
|
+
parts.push(
|
|
22584
|
+
`--- Memory ---
|
|
22585
|
+
You keep durable notes in your own memory folder, \`${dir}/\`, one Markdown file per note, alongside \`${index}\`, an index you maintain for yourself.
|
|
22586
|
+
Read \`${index}\` at the start of a run to recall what you already know, and call recall_memory to look up one note by name. If you can call save_memory, use it for what is worth knowing on a later run, and keep \`${index}\` current as you do. If a file tool you have takes a \`root\` argument, you can pass \`${dir}/\` as \`root\` to read and edit those files directly.`
|
|
22587
|
+
);
|
|
22588
|
+
const selfDirection = selfDirectionBlock(def);
|
|
22589
|
+
if (selfDirection) parts.push(selfDirection);
|
|
22467
22590
|
return parts.join("\n\n");
|
|
22468
22591
|
}
|
|
22592
|
+
function selfDirectionBlock(def) {
|
|
22593
|
+
const trigger = def.triggers?.find((t) => t.type === "self-directed");
|
|
22594
|
+
if (!trigger) return null;
|
|
22595
|
+
const raw = trigger.config?.fallbackMs;
|
|
22596
|
+
const fallbackMs = typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? raw : null;
|
|
22597
|
+
const consequence = fallbackMs == null ? "If this run ends without that call, nothing will wake it again and your work stops here until someone starts you by hand." : `If this run ends without that call you will be woken anyway, about ${Math.round(fallbackMs / 6e4)} minutes from now -- but that is a backstop for a run that could not schedule itself, not a substitute for choosing when you should next run.`;
|
|
22598
|
+
return `--- Self-direction ---
|
|
22599
|
+
You run on your own schedule. You will not run again unless you call \`schedule_self\` with the time you should next wake, before this run ends.
|
|
22600
|
+
${consequence}
|
|
22601
|
+
So decide, before you finish, whether there is more to do and when it should happen.`;
|
|
22602
|
+
}
|
|
22603
|
+
|
|
22604
|
+
// ../crew/memory.ts
|
|
22605
|
+
import { flattenFiles as flattenFiles4 } from "@corenel/protocol";
|
|
22606
|
+
import { parseFact, renderFact, slugify, uniqueSlug, FACT_INDEX } from "@corenel/harness/core/factFile";
|
|
22607
|
+
|
|
22608
|
+
// ../crew/room/store.ts
|
|
22609
|
+
import { flattenFiles as flattenFiles5 } from "@corenel/protocol";
|
|
22610
|
+
import { encodeLine, foldSession } from "@corenel/harness/sessions/jsonl";
|
|
22611
|
+
import { FINDINGS_FILE, encodeFindingLine, foldFindings } from "@corenel/harness/rooms/findings";
|
|
22612
|
+
|
|
22613
|
+
// ../crew/room/prompt.ts
|
|
22614
|
+
import { MAX_ROOM_FINDINGS, renderFindings } from "@corenel/harness/rooms/findings";
|
|
22615
|
+
|
|
22616
|
+
// ../crew/room/turn.ts
|
|
22617
|
+
import { readRoomOutcome } from "@corenel/harness/tools/roomTools";
|
|
22618
|
+
|
|
22619
|
+
// ../crew/room/turnRuntime.ts
|
|
22620
|
+
import { PermissionService } from "@corenel/harness/guardrail";
|
|
22621
|
+
import { BudgetMeter, mergeSignals } from "@corenel/harness/core/budget";
|
|
22622
|
+
import { makeRoomTools, ROOM_TOOL_NAMES } from "@corenel/harness/tools/roomTools";
|
|
22623
|
+
|
|
22624
|
+
// ../crew/room/engine.ts
|
|
22625
|
+
import { describeParticipants, resolveAddressee } from "@corenel/harness/tools/roomTools";
|
|
22626
|
+
import { planFindingEdit, planFindingEdits } from "@corenel/harness/rooms/findings";
|
|
22469
22627
|
|
|
22470
22628
|
// src/runAgent.ts
|
|
22471
22629
|
import { stateDirName as stateDirName3 } from "@corenel/protocol";
|
|
22472
|
-
import { PermissionService } from "@corenel/harness/guardrail/permission-service";
|
|
22630
|
+
import { PermissionService as PermissionService2 } from "@corenel/harness/guardrail/permission-service";
|
|
22473
22631
|
import { STANDARD_POLICY } from "@corenel/harness/guardrail/builtins";
|
|
22474
22632
|
import { toolAddress } from "@corenel/harness/tools/namespaces";
|
|
22475
22633
|
|
|
@@ -22508,7 +22666,7 @@ async function runCrewAgentCli(opts) {
|
|
|
22508
22666
|
opts.warn(`agent "${opts.agent}" is disabled; enable it before running`);
|
|
22509
22667
|
return 2;
|
|
22510
22668
|
}
|
|
22511
|
-
setGatewayBase(apiBase(opts.base));
|
|
22669
|
+
setGatewayBase(await apiBase(opts.base));
|
|
22512
22670
|
const token = await nodeAuthToken().getToken();
|
|
22513
22671
|
if (!token) {
|
|
22514
22672
|
opts.warn("not signed in: set CORENEL_TOKEN, or run `corenel login` on this machine");
|
|
@@ -22543,7 +22701,7 @@ ${extra}` : base;
|
|
|
22543
22701
|
if (operatorUnattended === "park" && !unattendedAllow) {
|
|
22544
22702
|
opts.warn(`corenel: policy "${effectivePolicy.name}" asks to park an unattended action, but run-agent cannot wait -- refusing.`);
|
|
22545
22703
|
}
|
|
22546
|
-
const permission = new
|
|
22704
|
+
const permission = new PermissionService2({
|
|
22547
22705
|
policy: effectivePolicy,
|
|
22548
22706
|
ceiling: mutatingCeiling(tools, "ask"),
|
|
22549
22707
|
...unattendedAllow ? { prompt: { ask: async () => "allow" } } : {}
|
|
@@ -22819,16 +22977,13 @@ function version(read = (p) => readFileSync2(p, "utf8")) {
|
|
|
22819
22977
|
|
|
22820
22978
|
// src/auth.ts
|
|
22821
22979
|
function hintOf(token) {
|
|
22822
|
-
|
|
22823
|
-
if (t.length <= 8) return "****";
|
|
22824
|
-
return `${t.slice(0, 4)}\u2026${t.slice(-2)} (${t.length} chars)`;
|
|
22980
|
+
return maskToken(token);
|
|
22825
22981
|
}
|
|
22826
|
-
async function authState(
|
|
22827
|
-
const
|
|
22828
|
-
|
|
22829
|
-
|
|
22830
|
-
|
|
22831
|
-
return { source: "none", path };
|
|
22982
|
+
async function authState(resolve2 = (env2) => resolveNodeCredential({ env: env2 }), env = process.env) {
|
|
22983
|
+
const r = await resolve2(env);
|
|
22984
|
+
if (!r.token) return { source: "none", path: authTokenPath() };
|
|
22985
|
+
const source = r.source === "env" ? "env" : "file";
|
|
22986
|
+
return { source, path: r.path ?? authTokenPath(), hint: hintOf(r.token) };
|
|
22832
22987
|
}
|
|
22833
22988
|
function describeAuth(s, base) {
|
|
22834
22989
|
if (s.source === "none") {
|
|
@@ -22846,12 +23001,12 @@ function describeAuth(s, base) {
|
|
|
22846
23001
|
].filter(Boolean).join("\n");
|
|
22847
23002
|
}
|
|
22848
23003
|
async function runAuth(out = (s) => process.stdout.write(s)) {
|
|
22849
|
-
out(`${describeAuth(await authState(), apiBase())}
|
|
23004
|
+
out(`${describeAuth(await authState(), await apiBase())}
|
|
22850
23005
|
`);
|
|
22851
23006
|
}
|
|
22852
23007
|
async function runLogout(out = (s) => process.stdout.write(s)) {
|
|
22853
23008
|
const before = await authState();
|
|
22854
|
-
await
|
|
23009
|
+
await clearAllCredentials();
|
|
22855
23010
|
if (before.source === "file") out(`Signed out. Removed ${before.path}
|
|
22856
23011
|
`);
|
|
22857
23012
|
else out("Nothing to forget \u2014 no stored token.\n");
|
|
@@ -22892,7 +23047,7 @@ async function checkToken(base, token, f = fetch) {
|
|
|
22892
23047
|
return { name: "token", status: "ok", detail: `accepted by ${base} (${res.status})` };
|
|
22893
23048
|
}
|
|
22894
23049
|
async function collectChecks(f = fetch, modelId = DEFAULT_MODEL) {
|
|
22895
|
-
const base = apiBase();
|
|
23050
|
+
const base = await apiBase();
|
|
22896
23051
|
const checks = [
|
|
22897
23052
|
{ name: "binary", status: "ok", detail: selfPath() },
|
|
22898
23053
|
{ name: "version", status: "ok", detail: `@corenel/cli ${version()}` },
|
|
@@ -22900,7 +23055,7 @@ async function collectChecks(f = fetch, modelId = DEFAULT_MODEL) {
|
|
|
22900
23055
|
{
|
|
22901
23056
|
name: "api",
|
|
22902
23057
|
status: "ok",
|
|
22903
|
-
detail: base ===
|
|
23058
|
+
detail: base === DEFAULT_API_BASE2 ? base : `${base} (overridden; default is ${DEFAULT_API_BASE2})`
|
|
22904
23059
|
}
|
|
22905
23060
|
];
|
|
22906
23061
|
try {
|
|
@@ -22917,7 +23072,7 @@ async function collectChecks(f = fetch, modelId = DEFAULT_MODEL) {
|
|
|
22917
23072
|
status: auth.source === "none" ? "warn" : "ok",
|
|
22918
23073
|
detail: auth.source === "none" ? "no" : `yes, from ${auth.source === "env" ? "CORENEL_TOKEN" : auth.path} (${auth.hint})`
|
|
22919
23074
|
});
|
|
22920
|
-
checks.push(await checkToken(base, await
|
|
23075
|
+
checks.push(await checkToken(base, (await resolveNodeCredential()).token, f));
|
|
22921
23076
|
const sidecar = findSidecarEntry();
|
|
22922
23077
|
checks.push({
|
|
22923
23078
|
name: "sidecar",
|
|
@@ -22948,7 +23103,7 @@ ${failed.length} problem${failed.length > 1 ? "s" : ""} above.
|
|
|
22948
23103
|
|
|
22949
23104
|
// src/repl.ts
|
|
22950
23105
|
import { createInterface } from "node:readline";
|
|
22951
|
-
import { PermissionService as
|
|
23106
|
+
import { PermissionService as PermissionService3 } from "@corenel/harness/guardrail/permission-service";
|
|
22952
23107
|
import { STANDARD_POLICY as STANDARD_POLICY2 } from "@corenel/harness/guardrail/builtins";
|
|
22953
23108
|
import { TermSession } from "@corenel/term/session";
|
|
22954
23109
|
import { describeToolCall, formatOrd } from "@corenel/term/describe";
|
|
@@ -23126,7 +23281,7 @@ async function runRepl(deps) {
|
|
|
23126
23281
|
}
|
|
23127
23282
|
};
|
|
23128
23283
|
rl.on("SIGINT", onSigint);
|
|
23129
|
-
const permission = new
|
|
23284
|
+
const permission = new PermissionService3({
|
|
23130
23285
|
policy: deps.policy ?? STANDARD_POLICY2,
|
|
23131
23286
|
prompt: {
|
|
23132
23287
|
ask: async (req) => {
|
|
@@ -23804,7 +23959,7 @@ async function resolvePolicy(opts) {
|
|
|
23804
23959
|
// src/cli.ts
|
|
23805
23960
|
var EXIT_POLICY_PARK_REFUSED = 3;
|
|
23806
23961
|
async function agentSetup(argv) {
|
|
23807
|
-
setGatewayBase2(apiBase(flag(argv, "base", "")));
|
|
23962
|
+
setGatewayBase2(await apiBase(flag(argv, "base", "")));
|
|
23808
23963
|
const token = await nodeAuthToken().getToken();
|
|
23809
23964
|
if (!token) {
|
|
23810
23965
|
process.stderr.write("corenel: not signed in.\n Run `corenel login`, or set CORENEL_TOKEN=<token> (a gateway bearer token), then try again.\n");
|
|
@@ -23890,7 +24045,7 @@ async function run(argv) {
|
|
|
23890
24045
|
process.exitCode = EXIT_POLICY_PARK_REFUSED;
|
|
23891
24046
|
return;
|
|
23892
24047
|
}
|
|
23893
|
-
const permission = new
|
|
24048
|
+
const permission = new PermissionService4({
|
|
23894
24049
|
policy,
|
|
23895
24050
|
ceiling: mutatingCeiling(tools, "ask"),
|
|
23896
24051
|
...unattendedAllow ? { prompt: { ask: async () => "allow" } } : {}
|
|
@@ -24089,8 +24244,8 @@ async function main() {
|
|
|
24089
24244
|
break;
|
|
24090
24245
|
}
|
|
24091
24246
|
case "login": {
|
|
24092
|
-
const base = apiBase(flag(rest, "base", ""));
|
|
24093
|
-
await deviceLogin({ base, store:
|
|
24247
|
+
const base = await apiBase(flag(rest, "base", ""));
|
|
24248
|
+
await deviceLogin({ base, store: (token) => writeLoginCredential(token, { apiBase: base }) });
|
|
24094
24249
|
process.stdout.write(`
|
|
24095
24250
|
Logged in. Token saved to ${authTokenPath()}
|
|
24096
24251
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corenel/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
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/protocol": "0.
|
|
14
|
-
"@corenel/term": "0.2.
|
|
12
|
+
"@corenel/harness": "0.6.0",
|
|
13
|
+
"@corenel/protocol": "0.6.0",
|
|
14
|
+
"@corenel/term": "0.2.2"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"esbuild": "^0.21.5",
|
|
@@ -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.0",
|
|
23
|
+
"@corenel/crew": "0.0.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=18"
|
|
35
35
|
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/Prompd/prompd-web.git",
|
|
39
|
+
"directory": "packages/cli"
|
|
40
|
+
},
|
|
36
41
|
"scripts": {
|
|
37
42
|
"typecheck": "tsc --noEmit",
|
|
38
43
|
"prestart": "pnpm --filter @corenel/protocol build && pnpm --filter @corenel/harness build && pnpm --filter @corenel/term build",
|