@sagentlab/navarch-runtime 0.1.147 → 0.1.149
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.cjs +2 -4
- package/dist/machine-store.cjs +5 -1
- package/dist/model-reference.cjs +25 -0
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.main = main;
|
|
7
7
|
const config_cjs_1 = require("./config.cjs");
|
|
8
8
|
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
const model_reference_cjs_1 = require("./model-reference.cjs");
|
|
9
10
|
const node_os_1 = __importDefault(require("node:os"));
|
|
10
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
12
|
const machine_store_cjs_1 = require("./machine-store.cjs");
|
|
@@ -126,10 +127,7 @@ function warnUnknownAdapters(config) {
|
|
|
126
127
|
/** Saved pins only apply to the adapter they were selected for. */
|
|
127
128
|
function modelFromFlags(flags, agentType, identity) {
|
|
128
129
|
const model = flags.model ?? (identity?.agent_type === agentType ? identity.model : undefined);
|
|
129
|
-
|
|
130
|
-
throw new Error("--model requires a non-empty model reference without whitespace.");
|
|
131
|
-
}
|
|
132
|
-
return model;
|
|
130
|
+
return model === undefined ? undefined : (0, model_reference_cjs_1.normalizeRuntimeModelReference)(model);
|
|
133
131
|
}
|
|
134
132
|
function parseArgs(argv) {
|
|
135
133
|
const [command, ...rest] = argv;
|
package/dist/machine-store.cjs
CHANGED
|
@@ -8,15 +8,19 @@ exports.loadMachineIdentity = loadMachineIdentity;
|
|
|
8
8
|
exports.resolveMachineIdentity = resolveMachineIdentity;
|
|
9
9
|
const node_fs_1 = require("node:fs");
|
|
10
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const model_reference_cjs_1 = require("./model-reference.cjs");
|
|
11
12
|
const agent_types_cjs_1 = require("./agent-types.cjs");
|
|
12
13
|
function storePath(configDir) {
|
|
13
14
|
return node_path_1.default.join(configDir, "machine.json");
|
|
14
15
|
}
|
|
15
16
|
/** Persists the machine's long-lived auth token to `<configDir>/machine.json`, mode 0600. */
|
|
16
17
|
async function saveMachineIdentity(configDir, identity) {
|
|
18
|
+
const normalized = identity.model === undefined
|
|
19
|
+
? identity
|
|
20
|
+
: { ...identity, model: (0, model_reference_cjs_1.normalizeRuntimeModelReference)(identity.model) };
|
|
17
21
|
await node_fs_1.promises.mkdir(configDir, { recursive: true, mode: 0o700 });
|
|
18
22
|
const file = storePath(configDir);
|
|
19
|
-
await node_fs_1.promises.writeFile(file, `${JSON.stringify(
|
|
23
|
+
await node_fs_1.promises.writeFile(file, `${JSON.stringify(normalized, null, 2)}\n`, { mode: 0o600 });
|
|
20
24
|
await node_fs_1.promises.chmod(file, 0o600);
|
|
21
25
|
}
|
|
22
26
|
async function loadMachineIdentity(configDir) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeModelReference = normalizeModelReference;
|
|
4
|
+
exports.normalizeRuntimeModelReference = normalizeRuntimeModelReference;
|
|
5
|
+
/** Mirrors normalizeModelReference in lib/navarch/execution-policy.ts for this standalone package. */
|
|
6
|
+
function normalizeModelReference(value) {
|
|
7
|
+
if (typeof value !== "string")
|
|
8
|
+
return null;
|
|
9
|
+
let model = value.trim();
|
|
10
|
+
const pairs = { '"': '"', "'": "'", "`": "`", "‘": "’", "“": "”" };
|
|
11
|
+
if (model.length >= 2 && pairs[model[0]] === model.at(-1)) {
|
|
12
|
+
model = model.slice(1, -1).trim();
|
|
13
|
+
}
|
|
14
|
+
if (!model || model.length > 500 || /[\u0000-\u001f\u007f'"`‘’“”]/.test(model))
|
|
15
|
+
return null;
|
|
16
|
+
return model;
|
|
17
|
+
}
|
|
18
|
+
/** Validate both new CLI pins and saved identities before use or persistence. */
|
|
19
|
+
function normalizeRuntimeModelReference(value) {
|
|
20
|
+
const model = normalizeModelReference(value);
|
|
21
|
+
if (!model || model === "true" || /\s/.test(model)) {
|
|
22
|
+
throw new Error("--model requires a non-empty model reference without whitespace or embedded quotes.");
|
|
23
|
+
}
|
|
24
|
+
return model;
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sagentlab/navarch-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.149",
|
|
4
4
|
"description": "Navarch machine-side session manager: claims delivery tasks and runs them through local coding agents.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -p tsconfig.json",
|
|
42
|
-
"typecheck": "
|
|
42
|
+
"typecheck": "bun check -p tsconfig.json",
|
|
43
43
|
"test": "vitest run",
|
|
44
44
|
"test:watch": "vitest",
|
|
45
45
|
"prepublishOnly": "npm run build && npm test",
|