@standardagents/code 0.11.3 → 0.11.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/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -579,14 +579,24 @@ var ApiClient = class {
|
|
|
579
579
|
// Backed by the instance's /api/users/me/kv store. This is where the machine
|
|
580
580
|
// registry lives: which machines (laptops / VPS daemons) belong to this
|
|
581
581
|
// account, and which projects each machine has.
|
|
582
|
-
/**
|
|
583
|
-
|
|
582
|
+
/**
|
|
583
|
+
* Read one value from the signed-in user's account-wide KV (null if absent).
|
|
584
|
+
* A missing key is a 200 `{value: null}` from the instance, so any THROWN
|
|
585
|
+
* error is a transport/server failure, never "not found". `strict` rethrows
|
|
586
|
+
* those failures — required by read-modify-write callers (the machine
|
|
587
|
+
* registry), where treating a failed read as "no record yet" would overwrite
|
|
588
|
+
* the real record with a fresh empty one (this wiped a machine's whole
|
|
589
|
+
* project list during a deploy window). Non-strict callers (pollers,
|
|
590
|
+
* display overlays) keep the lenient null.
|
|
591
|
+
*/
|
|
592
|
+
async userKvGet(key, opts) {
|
|
584
593
|
try {
|
|
585
594
|
const res = await this.json(
|
|
586
595
|
`/api/users/me/kv?key=${encodeURIComponent(key)}`
|
|
587
596
|
);
|
|
588
597
|
return res?.value ?? null;
|
|
589
|
-
} catch {
|
|
598
|
+
} catch (error) {
|
|
599
|
+
if (opts?.strict) throw error;
|
|
590
600
|
return null;
|
|
591
601
|
}
|
|
592
602
|
}
|
|
@@ -6429,10 +6439,10 @@ var PRODUCTION_ENDPOINT = "https://api.standardcode.ai";
|
|
|
6429
6439
|
function readVersion() {
|
|
6430
6440
|
try {
|
|
6431
6441
|
const pkg = JSON.parse(fs5.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
6432
|
-
|
|
6442
|
+
if (typeof pkg.version === "string" && pkg.version) return pkg.version;
|
|
6433
6443
|
} catch {
|
|
6434
|
-
return "";
|
|
6435
6444
|
}
|
|
6445
|
+
return "0.11.5" ;
|
|
6436
6446
|
}
|
|
6437
6447
|
function isLocalHost(host) {
|
|
6438
6448
|
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host.endsWith(".local") || host.endsWith(".localhost") || /^10\./.test(host) || /^192\.168\./.test(host) || /^172\.(1[6-9]|2\d|3[01])\./.test(host);
|
|
@@ -6587,8 +6597,8 @@ function parseMachineRecord(value) {
|
|
|
6587
6597
|
updated_at: typeof r.updated_at === "number" ? r.updated_at : 0
|
|
6588
6598
|
};
|
|
6589
6599
|
}
|
|
6590
|
-
async function loadRawMachine(api, machineId) {
|
|
6591
|
-
return parseMachineRecord(await api.userKvGet(machineKey(machineId)));
|
|
6600
|
+
async function loadRawMachine(api, machineId, opts) {
|
|
6601
|
+
return parseMachineRecord(await api.userKvGet(machineKey(machineId), opts));
|
|
6592
6602
|
}
|
|
6593
6603
|
async function loadMachines(api) {
|
|
6594
6604
|
const entries = await api.userKvList(KEY_PREFIX);
|
|
@@ -6715,7 +6725,7 @@ function newRecord(identity) {
|
|
|
6715
6725
|
};
|
|
6716
6726
|
}
|
|
6717
6727
|
async function updateOwnMachineRecord(api, identity, mutate) {
|
|
6718
|
-
const existing = await loadRawMachine(api, identity.machine_id);
|
|
6728
|
+
const existing = await loadRawMachine(api, identity.machine_id, { strict: true });
|
|
6719
6729
|
const record2 = existing ?? newRecord(identity);
|
|
6720
6730
|
record2.hostname = os8.hostname();
|
|
6721
6731
|
record2.platform = process.platform;
|
|
@@ -8309,6 +8319,7 @@ function printUsage() {
|
|
|
8309
8319
|
" standardcode [options] [dir]",
|
|
8310
8320
|
"",
|
|
8311
8321
|
`${c4.bold}Options${c4.reset}`,
|
|
8322
|
+
" -v, --version Print the Standard Code version and exit.",
|
|
8312
8323
|
" -e, --endpoint [url] Use a different Standard Agents instance for this run",
|
|
8313
8324
|
" (default: https://api.standardcode.ai).",
|
|
8314
8325
|
" If url is omitted, prompt for it.",
|
|
@@ -8485,6 +8496,11 @@ ${indent}${c4.dim}\u2026 +${hidden} more line${hidden === 1 ? "" : "s"}${c4.rese
|
|
|
8485
8496
|
return `${indent}${c4.yellow}\u26D4 ${rest}${c4.reset}`;
|
|
8486
8497
|
}
|
|
8487
8498
|
async function main() {
|
|
8499
|
+
if (process.argv.slice(2).some((arg) => arg === "-v" || arg === "--version")) {
|
|
8500
|
+
stdout.write(`${readVersion() || "unknown"}
|
|
8501
|
+
`);
|
|
8502
|
+
return;
|
|
8503
|
+
}
|
|
8488
8504
|
if (process.argv[2] === "daemon") {
|
|
8489
8505
|
await runDaemonCommand(process.argv.slice(3));
|
|
8490
8506
|
return;
|