@integrity-labs/agt-cli 0.28.1224 → 0.28.1226
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/bin/agt.js +6 -6
- package/dist/{chunk-LBEB7SZN.js → chunk-DKTSGG7Q.js} +71 -1
- package/dist/{chunk-LBEB7SZN.js.map → chunk-DKTSGG7Q.js.map} +1 -1
- package/dist/{chunk-3QWPLCMX.js → chunk-GBPHP6FI.js} +7 -3
- package/dist/chunk-GBPHP6FI.js.map +1 -0
- package/dist/{chunk-C6VRK3J2.js → chunk-M53VVKTM.js} +2 -2
- package/dist/{chunk-EZOHUWIF.js → chunk-SIVBDXES.js} +5 -5
- package/dist/{chunk-4HPJCR5S.js → chunk-XF6SM5RR.js} +7 -4
- package/dist/chunk-XF6SM5RR.js.map +1 -0
- package/dist/{claude-code-updater-F7A6PTT6.js → claude-code-updater-QFDDREKD.js} +3 -3
- package/dist/{claude-pair-runtime-4X7ST7J3.js → claude-pair-runtime-3YHQHU45.js} +3 -3
- package/dist/lib/manager-worker.js +168 -30
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +3 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/slack-channel.js +3 -0
- package/dist/mcp/telegram-channel.js +3 -0
- package/dist/{persistent-session-OG2MVQUR.js → persistent-session-DBAPNU35.js} +4 -4
- package/dist/{responsiveness-probe-HOXQTWME.js → responsiveness-probe-6S34EWLC.js} +4 -4
- package/dist/{session-auth-dead-GQGLYVIG.js → session-auth-dead-TDTU2CHO.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-3QWPLCMX.js.map +0 -1
- package/dist/chunk-4HPJCR5S.js.map +0 -1
- /package/dist/{chunk-C6VRK3J2.js.map → chunk-M53VVKTM.js.map} +0 -0
- /package/dist/{chunk-EZOHUWIF.js.map → chunk-SIVBDXES.js.map} +0 -0
- /package/dist/{claude-code-updater-F7A6PTT6.js.map → claude-code-updater-QFDDREKD.js.map} +0 -0
- /package/dist/{claude-pair-runtime-4X7ST7J3.js.map → claude-pair-runtime-3YHQHU45.js.map} +0 -0
- /package/dist/{persistent-session-OG2MVQUR.js.map → persistent-session-DBAPNU35.js.map} +0 -0
- /package/dist/{responsiveness-probe-HOXQTWME.js.map → responsiveness-probe-6S34EWLC.js.map} +0 -0
- /package/dist/{session-auth-dead-GQGLYVIG.js.map → session-auth-dead-TDTU2CHO.js.map} +0 -0
|
@@ -54619,6 +54619,9 @@ var MAINTENANCE_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
|
54619
54619
|
"skill_install",
|
|
54620
54620
|
"skill_propose_revision",
|
|
54621
54621
|
"skill_publish_to_marketplace",
|
|
54622
|
+
// ENG-11733 PR 2: a manager agent publishing/rejecting a dreamt fragment.
|
|
54623
|
+
"skill_review_decide",
|
|
54624
|
+
"skill_promote_lesson",
|
|
54622
54625
|
"skill_update",
|
|
54623
54626
|
"submit_performance_review",
|
|
54624
54627
|
"workflow_run_end",
|
package/dist/mcp/index.js
CHANGED
|
@@ -47819,6 +47819,9 @@ var MAINTENANCE_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
|
47819
47819
|
"skill_install",
|
|
47820
47820
|
"skill_propose_revision",
|
|
47821
47821
|
"skill_publish_to_marketplace",
|
|
47822
|
+
// ENG-11733 PR 2: a manager agent publishing/rejecting a dreamt fragment.
|
|
47823
|
+
"skill_review_decide",
|
|
47824
|
+
"skill_promote_lesson",
|
|
47822
47825
|
"skill_update",
|
|
47823
47826
|
"submit_performance_review",
|
|
47824
47827
|
"workflow_run_end",
|
|
@@ -31023,6 +31023,9 @@ var MAINTENANCE_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
|
31023
31023
|
"skill_install",
|
|
31024
31024
|
"skill_propose_revision",
|
|
31025
31025
|
"skill_publish_to_marketplace",
|
|
31026
|
+
// ENG-11733 PR 2: a manager agent publishing/rejecting a dreamt fragment.
|
|
31027
|
+
"skill_review_decide",
|
|
31028
|
+
"skill_promote_lesson",
|
|
31026
31029
|
"skill_update",
|
|
31027
31030
|
"submit_performance_review",
|
|
31028
31031
|
"workflow_run_end",
|
|
@@ -31220,6 +31220,9 @@ var MAINTENANCE_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
|
31220
31220
|
"skill_install",
|
|
31221
31221
|
"skill_propose_revision",
|
|
31222
31222
|
"skill_publish_to_marketplace",
|
|
31223
|
+
// ENG-11733 PR 2: a manager agent publishing/rejecting a dreamt fragment.
|
|
31224
|
+
"skill_review_decide",
|
|
31225
|
+
"skill_promote_lesson",
|
|
31223
31226
|
"skill_update",
|
|
31224
31227
|
"submit_performance_review",
|
|
31225
31228
|
"workflow_run_end",
|
|
@@ -68,12 +68,12 @@ import {
|
|
|
68
68
|
writeDirectChatSessionState,
|
|
69
69
|
writeEgressAllowlist,
|
|
70
70
|
writePersistentClaudeWrapper
|
|
71
|
-
} from "./chunk-
|
|
72
|
-
import "./chunk-
|
|
71
|
+
} from "./chunk-XF6SM5RR.js";
|
|
72
|
+
import "./chunk-GBPHP6FI.js";
|
|
73
73
|
import "./chunk-HYQ7VOC3.js";
|
|
74
74
|
import "./chunk-6HBXEJHO.js";
|
|
75
75
|
import "./chunk-XWVM4KPK.js";
|
|
76
|
-
import "./chunk-
|
|
76
|
+
import "./chunk-DKTSGG7Q.js";
|
|
77
77
|
import "./chunk-AIUIMEUS.js";
|
|
78
78
|
import "./chunk-DGUM43GV.js";
|
|
79
79
|
export {
|
|
@@ -147,4 +147,4 @@ export {
|
|
|
147
147
|
writeEgressAllowlist,
|
|
148
148
|
writePersistentClaudeWrapper
|
|
149
149
|
};
|
|
150
|
-
//# sourceMappingURL=persistent-session-
|
|
150
|
+
//# sourceMappingURL=persistent-session-DBAPNU35.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
paneLogPath
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-XF6SM5RR.js";
|
|
4
|
+
import "./chunk-GBPHP6FI.js";
|
|
5
5
|
import "./chunk-HYQ7VOC3.js";
|
|
6
6
|
import "./chunk-6HBXEJHO.js";
|
|
7
7
|
import "./chunk-XWVM4KPK.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-DKTSGG7Q.js";
|
|
9
9
|
import "./chunk-AIUIMEUS.js";
|
|
10
10
|
import "./chunk-DGUM43GV.js";
|
|
11
11
|
|
|
@@ -804,4 +804,4 @@ export {
|
|
|
804
804
|
readAndResetSlackReplyBindingClassifications,
|
|
805
805
|
readAndResetSlackReplyTargetClassifications
|
|
806
806
|
};
|
|
807
|
-
//# sourceMappingURL=responsiveness-probe-
|
|
807
|
+
//# sourceMappingURL=responsiveness-probe-6S34EWLC.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sessionTranscriptDir
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-GBPHP6FI.js";
|
|
4
|
+
import "./chunk-DKTSGG7Q.js";
|
|
5
5
|
import "./chunk-DGUM43GV.js";
|
|
6
6
|
|
|
7
7
|
// src/lib/session-auth-dead.ts
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
decideSessionAuthState,
|
|
206
206
|
probeSessionAuth
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=session-auth-dead-
|
|
208
|
+
//# sourceMappingURL=session-auth-dead-TDTU2CHO.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/daily-session.ts"],"sourcesContent":["/**\n * ENG-4642: per-agent / per-day Claude session pinning.\n *\n * The persistent-session manager kills the tmux session on every spawn\n * (clean slate) and starts a fresh `claude` invocation. Pre-this-module,\n * that meant a new conversation every restart — operators lost context\n * any time the manager respawned.\n *\n * Goal: each calendar day is a fresh conversation, but every spawn\n * inside that day reuses the same conversation. We achieve this by\n * generating a stable UUID up front (Claude CLI accepts\n * `--session-id <uuid>` for the first spawn, `--resume <uuid>` for\n * subsequent ones) and persisting it to a tiny per-agent JSON file.\n *\n * Storage: `~/.augmented/<codeName>/daily-session.json` — same root the\n * persistent-session manager already owns via getProjectDir(). Schema:\n *\n * { \"date\": \"YYYY-MM-DD\", \"sessionId\": \"<uuid>\", \"history\": [...] }\n *\n * `history` keeps the last few days' entries so an operator can debug\n * which session was bound to which day. We trim to 7 days so the file\n * doesn't grow unbounded.\n *\n * Day boundary: defaults to host-local date (server timezone). Callers\n * may pass an IANA timezone (e.g. `Australia/Melbourne`) and the\n * rollover will fire at that zone's midnight instead — see ENG-5371.\n * The manager passes the agent's resolved `agentTimezone` (same source\n * as ENG-5363's channel MCP `TZ` env var: `teamSettings.timezone`,\n * defaulting to UTC) so the daily rollover lines up with what an\n * operator in the agent's timezone calls \"today\".\n *\n * Failure mode: if the on-disk JSONL Claude writes for the resumed\n * session is missing (host moved, profile wiped, claude version\n * incompatibility), `--resume` would fail and the agent would land on\n * the login picker. Callers verify the JSONL exists via\n * `sessionFileExists()` before choosing `--resume`; if it's gone we\n * fall back to `--session-id` (treat the stored UUID as fresh, claude\n * will materialise the JSONL on first turn).\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { encodeClaudeProjectPath } from '@augmented/core';\n\nconst HISTORY_DAYS = 7;\n\ninterface DailySessionEntry {\n date: string; // YYYY-MM-DD\n sessionId: string; // UUID v4\n startedAt: string; // ISO 8601\n}\n\ninterface DailySessionFile {\n current: DailySessionEntry | null;\n history: DailySessionEntry[];\n}\n\nexport interface DailySessionResult {\n sessionId: string;\n /** `true` when this call generated a new UUID (first spawn of a new day or first ever). */\n isNew: boolean;\n}\n\nfunction profileDir(codeName: string): string {\n return join(homedir(), '.augmented', codeName);\n}\n\nfunction dailySessionPath(codeName: string): string {\n return join(profileDir(codeName), 'daily-session.json');\n}\n\nexport function todayLocalIso(now: Date = new Date(), timezone?: string): string {\n // ENG-5371: when an IANA timezone is supplied (e.g. Australia/Melbourne),\n // compute the date in that zone via Intl.DateTimeFormat. Falling back to\n // Date getters preserves the original host-local behaviour for callers\n // (and tests) that don't supply a timezone — important for\n // backward-compatibility with the ENG-4642 contract.\n if (timezone) {\n try {\n const fmt = new Intl.DateTimeFormat('en-CA', {\n timeZone: timezone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n });\n // en-CA renders as `YYYY-MM-DD` already — no parts assembly needed.\n // Wrapped in try/catch in case the timezone string is invalid, in\n // which case we fall through to host-local rather than throw.\n return fmt.format(now);\n } catch {\n // Invalid IANA zone — fall back to host-local.\n }\n }\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, '0');\n const d = String(now.getDate()).padStart(2, '0');\n return `${y}-${m}-${d}`;\n}\n\nfunction readFile(codeName: string): DailySessionFile {\n const path = dailySessionPath(codeName);\n if (!existsSync(path)) return { current: null, history: [] };\n try {\n const raw = readFileSync(path, 'utf-8');\n const parsed = JSON.parse(raw) as Partial<DailySessionFile>;\n return {\n current: parsed.current ?? null,\n history: Array.isArray(parsed.history) ? parsed.history : [],\n };\n } catch {\n // Corrupt file — start fresh rather than crashing the manager.\n return { current: null, history: [] };\n }\n}\n\nfunction writeFile(codeName: string, data: DailySessionFile): void {\n const dir = profileDir(codeName);\n mkdirSync(dir, { recursive: true });\n // Atomic write: tmp + rename. A reader catching us mid-writeFileSync\n // would otherwise see truncated JSON and the corrupt-file branch in\n // readFile() would silently treat the agent as fresh state, losing\n // today's UUID and forcing a rollover the operator didn't ask for.\n // PID + randomUUID in the tmp suffix so two managers (or a respawn\n // racing with its predecessor) can't collide on the temp path and\n // have one rename remove the file the other is about to rename.\n // Mirrors the pattern in restart-flags.ts.\n const finalPath = dailySessionPath(codeName);\n const tmpPath = `${finalPath}.${process.pid}.${randomUUID()}.tmp`;\n writeFileSync(tmpPath, JSON.stringify(data, null, 2), 'utf-8');\n renameSync(tmpPath, finalPath);\n}\n\nfunction trimHistory(\n history: DailySessionEntry[],\n now: Date,\n timezone?: string,\n): DailySessionEntry[] {\n // Keep newest first, drop entries older than HISTORY_DAYS by date.\n // Take the injected `now` so callers with a frozen clock (tests\n // walking the day forward) don't get inconsistent cutoffs against\n // `new Date()`. The cutoff is computed in the same timezone as the\n // current entry's date string so equality comparisons hold across DST.\n const cutoff = new Date(now);\n cutoff.setDate(cutoff.getDate() - HISTORY_DAYS);\n const cutoffIso = todayLocalIso(cutoff, timezone);\n return history.filter((h) => h.date >= cutoffIso).slice(0, HISTORY_DAYS);\n}\n\n/**\n * Resolve the session UUID this agent should use right now. Generates\n * (and persists) a new UUID on the first call of a new local day, or\n * when the file is missing/corrupt; otherwise returns the day's\n * existing UUID. Idempotent within the same day.\n *\n * Concurrency: the read-then-write here is not under a file lock.\n * In our deployment the manager runs supervised, one process per\n * host (`agt manager start --supervise` / runSupervisorLoop), so\n * concurrent invocation for the same `codeName` is bounded to the\n * sub-second respawn window when the supervisor restarts the\n * worker. The atomic tmp+rename in writeFile() guarantees we never\n * read torn JSON, so the worst-case under a respawn race is two\n * managers minting different UUIDs and one rename winning — both\n * processes converge on the winner's UUID on the next supervisor\n * tick (which re-reads the file). We've taken that trade-off\n * over a proper inter-process lock because a stale lockfile (from\n * a SIGKILL'd manager) would block all subsequent runs and need\n * its own recovery path; the lossy outcome of a UUID race is one\n * tick of conversation churn, not a permanent block.\n */\nexport function getOrCreateDailySession(\n codeName: string,\n now: Date = new Date(),\n timezone?: string,\n): DailySessionResult {\n const today = todayLocalIso(now, timezone);\n const file = readFile(codeName);\n\n if (file.current && file.current.date === today) {\n return { sessionId: file.current.sessionId, isNew: false };\n }\n\n // Roll over: yesterday's (or older) entry moves to history, new one\n // takes its place.\n const next: DailySessionEntry = {\n date: today,\n sessionId: randomUUID(),\n startedAt: now.toISOString(),\n };\n const history = trimHistory(\n [...(file.current ? [file.current] : []), ...file.history],\n now,\n timezone,\n );\n writeFile(codeName, { current: next, history });\n return { sessionId: next.sessionId, isNew: true };\n}\n\n/**\n * Record the UUID a caller just spawned with so the day-rollover\n * marker (`current.date`) advances to today.\n *\n * ENG-5431: a spawn that bypasses `getOrCreateDailySession` (today the\n * AGT_DISABLE_SESSION_RESUME path, which mints a fresh `randomUUID()`;\n * under ENG-5397 it was every spawn) never writes `daily-session.json`,\n * so `isStaleForToday()` keeps returning true once the previous\n * `current.date` falls behind — re-firing the day-rollover restart on\n * every supervisor tick. Calling this after each spawn keeps the\n * marker in lockstep with the actual running session. On the ENG-6039\n * resume/fresh paths it's an idempotent no-op.\n *\n * Idempotent: re-calling with the same (date, sessionId) is a no-op\n * write of the same content. Different sessionId on the same date\n * just overwrites `current.sessionId` (the old one moves to history).\n */\nexport function markDailySessionSpawn(\n codeName: string,\n sessionId: string,\n now: Date = new Date(),\n timezone?: string,\n): void {\n const today = todayLocalIso(now, timezone);\n const file = readFile(codeName);\n if (file.current && file.current.date === today && file.current.sessionId === sessionId) {\n return;\n }\n const next: DailySessionEntry = {\n date: today,\n sessionId,\n startedAt: now.toISOString(),\n };\n const history = trimHistory(\n [...(file.current ? [file.current] : []), ...file.history],\n now,\n timezone,\n );\n writeFile(codeName, { current: next, history });\n}\n\n/**\n * Reset the day's pin — used as a recovery hatch after `--resume` is\n * rejected by claude (corrupt state, version mismatch). Writes a new\n * UUID for today, demotes the old one to history.\n */\nexport function rotateDailySession(\n codeName: string,\n now: Date = new Date(),\n timezone?: string,\n): string {\n const today = todayLocalIso(now, timezone);\n const file = readFile(codeName);\n const next: DailySessionEntry = {\n date: today,\n sessionId: randomUUID(),\n startedAt: now.toISOString(),\n };\n const history = trimHistory(\n [...(file.current ? [file.current] : []), ...file.history],\n now,\n timezone,\n );\n writeFile(codeName, { current: next, history });\n return next.sessionId;\n}\n\n/**\n * Encode an absolute project dir the way Claude Code stores it under\n * ~/.claude/projects/.\n *\n * ENG-8201 (Slice 1) moved the rule itself to `@augmented/core`\n * (`encodeClaudeProjectPath`) so the channel MCP servers can locate the same\n * transcript directory without a second copy of it — see that function for the\n * encoding rules and the ENG-4659 incident that produced them. This stays as a\n * local alias so the module's callers (and `_internals`) read unchanged.\n */\nconst encodeProjectPath = encodeClaudeProjectPath;\n\n/**\n * Check whether claude has actually written a session JSONL for this\n * UUID. If the file is missing the `--resume` would fail and put the\n * agent on the login picker; callers should fall back to `--session-id`\n * instead. See encodeProjectPath() for the encoding rules.\n */\nexport function sessionFileExists(\n projectDir: string,\n sessionId: string,\n): boolean {\n const path = join(\n homedir(),\n '.claude',\n 'projects',\n encodeProjectPath(projectDir),\n `${sessionId}.jsonl`,\n );\n return existsSync(path);\n}\n\n/**\n * Directory under ~/.claude/projects/ where Claude Code stores every session\n * transcript for the given project dir. All of an agent's sessions —\n * persistent respawns (one pinned UUID per agent-tz day, ENG-6039, plus\n * rotations), scheduled tasks, and direct-chat invocations — share this one\n * directory because they all run with the same cwd (getProjectDir). The\n * token-usage monitor enumerates it.\n */\nexport function sessionTranscriptDir(projectDir: string): string {\n return join(homedir(), '.claude', 'projects', encodeProjectPath(projectDir));\n}\n\nexport function sessionFilePath(projectDir: string, sessionId: string): string {\n return join(sessionTranscriptDir(projectDir), `${sessionId}.jsonl`);\n}\n\n/**\n * ENG-6238: age (s) of the current session's transcript JSONL — the wedge\n * detector's \"is the model actually producing tokens right now\" signal. The\n * transcript grows as the model streams turns/tool calls, so a fresh mtime\n * means real work is happening, where pane.log can be kept fresh by a frozen\n * but animated spinner. Returns null when there's no session id or the file\n * can't be stat'd (the detector then degrades to the pane-age fallback).\n */\nexport function transcriptActivityAgeSeconds(\n projectDir: string,\n sessionId: string | null,\n now: Date = new Date(),\n): number | null {\n if (!sessionId) return null;\n try {\n const mtimeMs = statSync(sessionFilePath(projectDir, sessionId)).mtimeMs;\n return Math.max(0, Math.floor((now.getTime() - mtimeMs) / 1000));\n } catch {\n return null;\n }\n}\n\n/**\n * ENG-6294: age (s) of the freshest sub-agent transcript for the current\n * session, or null when there is none. Claude Code writes each sub-agent's\n * transcript to `<transcriptDir>/<sessionId>/subagents/agent-<id>.jsonl` —\n * so while a `run_in_background` worker grinds, ITS jsonl keeps growing even\n * though the parent ended its turn and the main `<sessionId>.jsonl` goes\n * static. A fresh mtime here means the session has a background task doing\n * real work and must not read as wedged (the ENG-6274 dispatch flow's\n * signature is exactly quiet-pane + stale-main-transcript + queued inbound).\n */\nexport function subagentActivityAgeSeconds(\n projectDir: string,\n sessionId: string | null,\n now: Date = new Date(),\n): number | null {\n if (!sessionId) return null;\n const dir = join(sessionTranscriptDir(projectDir), sessionId, 'subagents');\n try {\n let freshestMtimeMs: number | null = null;\n for (const name of readdirSync(dir)) {\n if (!name.endsWith('.jsonl')) continue;\n try {\n const mtimeMs = statSync(join(dir, name)).mtimeMs;\n if (freshestMtimeMs === null || mtimeMs > freshestMtimeMs) freshestMtimeMs = mtimeMs;\n } catch {\n // file vanished between readdir and stat — skip it\n }\n }\n if (freshestMtimeMs === null) return null;\n return Math.max(0, Math.floor((now.getTime() - freshestMtimeMs) / 1000));\n } catch {\n return null; // no subagents dir for this session\n }\n}\n\n/**\n * Is the agent's session JSONL idle — i.e. has it not been written for\n * at least `idleSeconds`? Claude appends to the file on every turn\n * (tool calls, assistant messages, user messages) so a stale mtime is\n * a reliable proxy for \"nothing in flight\". Returns true if the file\n * is missing (no in-flight work to interrupt) or if its mtime is\n * older than the threshold.\n *\n * Used by the scheduled-rollover gate so we don't kill a tmux session\n * mid-task at the day boundary — defer the rollover one tick at a\n * time until the agent is between turns.\n */\nexport function isAgentIdle(\n projectDir: string,\n sessionId: string,\n idleSeconds = 60,\n now: Date = new Date(),\n): boolean {\n const path = sessionFilePath(projectDir, sessionId);\n if (!existsSync(path)) return true;\n try {\n const mtimeMs = statSync(path).mtimeMs;\n return now.getTime() - mtimeMs >= idleSeconds * 1000;\n } catch {\n // stat failed (race, permissions). Treat as non-idle to err on the\n // side of NOT interrupting a possibly-running task.\n return false;\n }\n}\n\n/**\n * Cheap \"should we roll over?\" check for the supervisor tick. Reads\n * the persisted current entry and compares its date against today's.\n * Does NOT mint a new UUID — the caller decides what to do with the\n * answer (typically: kill the tmux session iff isAgentIdle is true,\n * letting the next tick respawn fresh via getOrCreateDailySession).\n */\nexport function isStaleForToday(\n codeName: string,\n now: Date = new Date(),\n timezone?: string,\n): boolean {\n const file = readFile(codeName);\n if (!file.current) return false; // never seeded — nothing to roll\n return file.current.date !== todayLocalIso(now, timezone);\n}\n\n/**\n * Minutes elapsed since the local (agent-timezone) start of today, i.e. how\n * far past midnight we are in the agent's day. ENG-7548: the scheduled\n * day-rollover gate defers while an agent is mid-task; a perpetually-busy\n * agent never presents an idle window, so the rollover would defer\n * indefinitely. The caller uses this \"how overdue is today's rollover\"\n * measure to bound the defer — once it exceeds a grace period the rollover is\n * forced even if the agent looks busy. Timezone-aware via Intl (hourCycle\n * 'h23' so midnight is 00, not 24); falls back to host-local on an invalid\n * zone, mirroring todayLocalIso().\n */\nexport function minutesSinceLocalMidnight(\n now: Date = new Date(),\n timezone?: string,\n): number {\n if (timezone) {\n try {\n const fmt = new Intl.DateTimeFormat('en-GB', {\n timeZone: timezone,\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n });\n const parts = fmt.formatToParts(now);\n const hh = Number(parts.find((p) => p.type === 'hour')?.value ?? '0');\n const mm = Number(parts.find((p) => p.type === 'minute')?.value ?? '0');\n if (Number.isFinite(hh) && Number.isFinite(mm)) return hh * 60 + mm;\n } catch {\n // Invalid IANA zone — fall back to host-local.\n }\n }\n return now.getHours() * 60 + now.getMinutes();\n}\n\n/**\n * Read-only accessor for the current entry, returns null when the\n * file doesn't exist or has no current entry. Useful to grab the\n * sessionId for the idle check without triggering a roll-over write.\n */\nexport function peekCurrentSession(codeName: string): {\n date: string;\n sessionId: string;\n startedAt: string;\n} | null {\n return readFile(codeName).current;\n}\n\n/**\n * ENG-11817: the session this agent ran before the current one. Every rotation\n * (day rollover, a forced fresh start, a missing transcript) demotes the old id to\n * `history`, newest first, so this is the session a restart just replaced. Null\n * when there is no history.\n */\nexport function peekPreviousSession(codeName: string): { sessionId: string; startedAt: string } | null {\n const previous = readFile(codeName).history[0];\n return previous && typeof previous.sessionId === 'string' ? { sessionId: previous.sessionId, startedAt: previous.startedAt } : null;\n}\n\n/**\n * ENG-9566: snapshot of the per-agent session pin, for archiving on drain.\n *\n * WHY THIS IS ARCHIVED AT ALL. `resolveSessionSpawnDecision` only `--resume`s a\n * conversation when a transcript exists for *today's pinned UUID*. That pin\n * lives here, at `~/.augmented/<codeName>/daily-session.json`, and it is swept\n * by none of the three archivers: agt-session-archiver.sh covers\n * `/root/.claude/projects` plus a `-maxdepth 1 -type f -name 'manager.log-*'`\n * sweep of `/root/.augmented` (whose comment excludes per-agent subdirectories\n * explicitly), and the drain flush covers `~/.claude/projects`. So a destination\n * host that restored every transcript byte-for-byte would still mint a fresh\n * `randomUUID()` and treat all of them as orphans. Archiving the pin alongside\n * the transcripts is what makes a restored conversation resumable at all.\n *\n * Under the id-keyed layout `~/.augmented/<codeName>` is a symlink to the real\n * `~/.augmented/<agentId>` dir, so reading through the codename path lands on\n * the same file either way — no layout branch is needed here.\n *\n * `raw` is kept verbatim so a later schema change loses nothing; the two parsed\n * fields are the convenience a restore actually reads. A corrupt or unreadable\n * file keeps `present: true` and nulls the parsed fields rather than reporting\n * absence — \"unparseable\" and \"never existed\" are different problems for\n * whoever debugs a failed restore, and collapsing them hides the first.\n */\nexport interface DailySessionPinSnapshot {\n /** Absolute path the pin was read from (recorded for debugging a restore). */\n path: string;\n /** The file exists. False means this agent has no pin at all. */\n present: boolean;\n /** Verbatim file contents; null when present but unreadable. */\n raw: string | null;\n /** Parsed `current.date` (YYYY-MM-DD in the agent's timezone), if any. */\n currentDate: string | null;\n /** Parsed `current.sessionId` — the UUID a destination must `--resume`. */\n currentSessionId: string | null;\n}\n\nexport function readDailySessionPin(codeName: string): DailySessionPinSnapshot {\n const path = dailySessionPath(codeName);\n if (!existsSync(path)) {\n return { path, present: false, raw: null, currentDate: null, currentSessionId: null };\n }\n let raw: string;\n try {\n raw = readFileSync(path, 'utf-8');\n } catch {\n // Unreadable (permissions, or a teardown race) — present but uncaptured.\n return { path, present: true, raw: null, currentDate: null, currentSessionId: null };\n }\n try {\n const parsed = JSON.parse(raw) as Partial<DailySessionFile>;\n const current = parsed.current ?? null;\n return {\n path,\n present: true,\n raw,\n currentDate: current?.date ?? null,\n currentSessionId: current?.sessionId ?? null,\n };\n } catch {\n // Corrupt JSON: keep the bytes so a human can still recover the UUID.\n return { path, present: true, raw, currentDate: null, currentSessionId: null };\n }\n}\n\n// Exported for unit tests — keep the surface small.\nexport const _internals = { todayLocalIso, dailySessionPath, profileDir, encodeProjectPath };\n"],"mappings":";;;;;AAwCA,SAAS,kBAAkB;AAC3B,SAAS,YAAY,WAAW,cAAc,aAAa,YAAY,UAAU,qBAAqB;AACtG,SAAS,eAAe;AACxB,SAAS,YAAY;AAGrB,IAAM,eAAe;AAmBrB,SAAS,WAAW,UAA0B;AAC5C,SAAO,KAAK,QAAQ,GAAG,cAAc,QAAQ;AAC/C;AAEA,SAAS,iBAAiB,UAA0B;AAClD,SAAO,KAAK,WAAW,QAAQ,GAAG,oBAAoB;AACxD;AAEO,SAAS,cAAc,MAAY,oBAAI,KAAK,GAAG,UAA2B;AAM/E,MAAI,UAAU;AACZ,QAAI;AACF,YAAM,MAAM,IAAI,KAAK,eAAe,SAAS;AAAA,QAC3C,UAAU;AAAA,QACV,MAAM;AAAA,QACN,OAAO;AAAA,QACP,KAAK;AAAA,MACP,CAAC;AAID,aAAO,IAAI,OAAO,GAAG;AAAA,IACvB,QAAQ;AAAA,IAER;AAAA,EACF;AACA,QAAM,IAAI,IAAI,YAAY;AAC1B,QAAM,IAAI,OAAO,IAAI,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,QAAM,IAAI,OAAO,IAAI,QAAQ,CAAC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