Files
TORCH/src/utils.mjs
T
google-labs-jules[bot]andPR0M3TH3AN 754a1c2ce1 feat: support platform and model info in nostr lock events
This change enables agents to report their execution platform (e.g., Jules, Codex, Goose) and model (e.g., DeepSeek 3.2) in the Nostr lock events.

Key changes:
- Updated `torch-lock` CLI to accept `--platform` and `--model` arguments.
- Implemented `detectPlatform` utility to infer platform from environment variables if not provided.
- Updated `src/lib.mjs` to include these fields in the event content.
- Updated `scripts/agent/run-scheduler-cycle.mjs` to propagate `--model` and `AGENT_MODEL`.
- Updated `dashboard/index.html` to display the model information on the lock card.
- Fixed a regression in `scripts/validate-scheduler-flow-parity.mjs` and `test/scheduler-ratchet.test.mjs` caused by argument string matching.
- Deleted `repro_test.mjs` temporary file.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-15 20:18:59 +00:00

37 lines
1.4 KiB
JavaScript

export function todayDateStr() {
return new Date().toISOString().slice(0, 10);
}
export function nowUnix() {
return Math.floor(Date.now() / 1000);
}
export function getIsoWeekStr(dateInput) {
// Parse input to ensure we work with a Date object
// If dateInput is YYYY-MM-DD string, new Date() treats it as UTC.
const d = dateInput ? new Date(dateInput) : new Date();
// If valid date, use UTC components to avoid local timezone issues
if (isNaN(d.getTime())) return '';
// Copy date so we don't mutate the original if passed by reference (though new Date() handles that)
const date = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
// ISO week date system: Thursday determines the year
// day: 0 (Sun) -> 6 (Sat). We want 1 (Mon) -> 7 (Sun)
const day = date.getUTCDay() || 7;
date.setUTCDate(date.getUTCDate() + 4 - day);
const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1));
const weekNo = Math.ceil((((date - yearStart) / 86400000) + 1) / 7);
return `${date.getUTCFullYear()}-W${String(weekNo).padStart(2, '0')}`;
}
export function detectPlatform() {
if (process.env.JULES_API_KEY || process.env.JULES_SESSION_ID) return 'jules';
if (process.env.CODEX_API_KEY || process.env.CODEX_SESSION_ID) return 'codex';
if (process.env.GOOSE_API_KEY || process.env.GOOSE_SESSION_ID) return 'goose';
return null;
}