instar 1.3.128 → 1.3.130
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/.claude/skills/autonomous/hooks/autonomous-stop-hook.sh +36 -0
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +12 -4
- package/dist/commands/server.js.map +1 -1
- package/dist/config/ConfigDefaults.d.ts.map +1 -1
- package/dist/config/ConfigDefaults.js +4 -0
- package/dist/config/ConfigDefaults.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +29 -5
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/installCodexHooks.d.ts +7 -0
- package/dist/core/installCodexHooks.d.ts.map +1 -1
- package/dist/core/installCodexHooks.js +30 -2
- package/dist/core/installCodexHooks.js.map +1 -1
- package/dist/core/types.d.ts +19 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/monitoring/SessionReaper.d.ts +39 -0
- package/dist/monitoring/SessionReaper.d.ts.map +1 -1
- package/dist/monitoring/SessionReaper.js +104 -0
- package/dist/monitoring/SessionReaper.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +7 -5
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +12 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +62 -62
- package/src/scaffold/templates.ts +7 -5
- package/upgrades/1.3.129.md +55 -0
- package/upgrades/1.3.130.md +74 -0
- package/upgrades/side-effects/codex-autonomous-loop-driver.md +91 -0
- package/upgrades/side-effects/sessionreaper-cpu-aware-and-decision-audit.md +122 -0
|
@@ -30,6 +30,14 @@ set -uo pipefail # NOTE: -e intentionally omitted; field lookups for optional
|
|
|
30
30
|
# Read hook input from stdin
|
|
31
31
|
HOOK_INPUT=$(cat)
|
|
32
32
|
|
|
33
|
+
# ── Framework arg: --codex marks the codex (vs Claude) registration of this shared
|
|
34
|
+
# hook (installCodexHooks adds it to .codex/hooks.json as `… --codex`). Claude invokes
|
|
35
|
+
# the hook with NO args, so IS_CODEX stays 0 and the entire Claude path below is
|
|
36
|
+
# byte-for-byte unchanged. Under codex it lets us (a) anchor via this script's own path
|
|
37
|
+
# (codex doesn't set CLAUDE_PROJECT_DIR) and (b) self-gate on the codexLoopDriver flag. ──
|
|
38
|
+
IS_CODEX=0
|
|
39
|
+
for _arg in "$@"; do [[ "$_arg" == "--codex" ]] && IS_CODEX=1; done
|
|
40
|
+
|
|
33
41
|
# ── Anchor to the agent home, NOT the session's CWD ───────────────────
|
|
34
42
|
# All state paths below are relative (.instar/autonomous/<topic>.local.md, the
|
|
35
43
|
# registry, the legacy file). The Stop hook inherits the session's working
|
|
@@ -45,6 +53,34 @@ HOOK_INPUT=$(cat)
|
|
|
45
53
|
# when unset (e.g. an isolated test harness) we stay in the caller's CWD.
|
|
46
54
|
if [[ -n "${CLAUDE_PROJECT_DIR:-}" ]] && [[ -d "${CLAUDE_PROJECT_DIR}/.instar" ]]; then
|
|
47
55
|
cd "$CLAUDE_PROJECT_DIR" || true
|
|
56
|
+
elif [[ "$IS_CODEX" == "1" ]]; then
|
|
57
|
+
# Codex doesn't set CLAUDE_PROJECT_DIR. Derive the agent home from THIS script's own
|
|
58
|
+
# absolute path — installed at <home>/.claude/skills/autonomous/hooks/autonomous-stop-hook.sh
|
|
59
|
+
# — so the relative state paths resolve regardless of the codex session's CWD (the same
|
|
60
|
+
# worktree-strand class the Claude anchor above guards against).
|
|
61
|
+
_SD="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
62
|
+
_AH="$(cd "${_SD}/../../../.." 2>/dev/null && pwd)"
|
|
63
|
+
if [[ -n "${_AH:-}" ]] && [[ -d "${_AH}/.instar" ]]; then cd "$_AH" || true; fi
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# ── Codex dark-launch gate ────────────────────────────────────────────
|
|
67
|
+
# The codex loop driver ships DARK: when invoked from codex, only proceed if
|
|
68
|
+
# autonomousSessions.codexLoopDriver.enabled is true. Otherwise approve (exit 0) so a
|
|
69
|
+
# normal codex stop is unaffected — this is the instant-rollback flag (flip it off and
|
|
70
|
+
# the standing hook is a no-op again, no redeploy). Claude (IS_CODEX=0) skips this.
|
|
71
|
+
if [[ "$IS_CODEX" == "1" ]]; then
|
|
72
|
+
CODEX_LOOP_ENABLED=$(python3 -c "
|
|
73
|
+
import json
|
|
74
|
+
try:
|
|
75
|
+
c = json.load(open('.instar/config.json'))
|
|
76
|
+
a = (c.get('autonomousSessions') or {}).get('codexLoopDriver') or {}
|
|
77
|
+
print('1' if a.get('enabled') else '0')
|
|
78
|
+
except Exception:
|
|
79
|
+
print('0')
|
|
80
|
+
" 2>/dev/null || echo "0")
|
|
81
|
+
if [[ "$CODEX_LOOP_ENABLED" != "1" ]]; then
|
|
82
|
+
exit 0
|
|
83
|
+
fi
|
|
48
84
|
fi
|
|
49
85
|
|
|
50
86
|
REGISTRY_FILE=".instar/topic-session-registry.json"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwvDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwvDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAi/OtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
|
package/dist/commands/server.js
CHANGED
|
@@ -7995,7 +7995,7 @@ export async function startServer(options) {
|
|
|
7995
7995
|
// for v1 (advisory; spawn-denial-primary is a tracked follow-up) — and note
|
|
7996
7996
|
// an over-eager tier can only reap a GENUINELY-idle session sooner, never a
|
|
7997
7997
|
// working one (the classifier protects working sessions regardless of tier).
|
|
7998
|
-
const { SessionReaper,
|
|
7998
|
+
const { SessionReaper, computePressure, reaperAuditSink } = await import('../monitoring/SessionReaper.js');
|
|
7999
7999
|
const _os = await import('node:os');
|
|
8000
8000
|
const _resolveTopic = (tmuxSession) => {
|
|
8001
8001
|
const t = telegram?.getTopicForSession(tmuxSession);
|
|
@@ -8069,13 +8069,21 @@ export async function startServer(options) {
|
|
|
8069
8069
|
pressure: () => {
|
|
8070
8070
|
const total = _os.totalmem();
|
|
8071
8071
|
const freePct = total > 0 ? (_os.freemem() / total) * 100 : 100;
|
|
8072
|
-
|
|
8073
|
-
|
|
8072
|
+
// CPU pressure: 1-min load average ÷ core count. The overall tier is the
|
|
8073
|
+
// WORST of memory and CPU, so a CPU-bound box (the common case) raises
|
|
8074
|
+
// pressure even when free memory is fine. cores unknown ⇒ memory-only.
|
|
8075
|
+
const cores = _os.cpus()?.length ?? 0;
|
|
8076
|
+
const loadPerCore = cores > 0 ? _os.loadavg()[0] / cores : null;
|
|
8077
|
+
const rcfg = config.monitoring?.sessionReaper;
|
|
8078
|
+
return computePressure({ freePct, loadPerCore }, {
|
|
8079
|
+
cpuModerateLoadPerCore: rcfg?.cpuModerateLoadPerCore ?? 1.0,
|
|
8080
|
+
cpuCriticalLoadPerCore: rcfg?.cpuCriticalLoadPerCore ?? 1.5,
|
|
8081
|
+
});
|
|
8074
8082
|
},
|
|
8075
8083
|
terminate: (id, reason) => sessionManager.terminateSession(id, reason),
|
|
8076
8084
|
markReaping: (id) => sessionManager.markReaping(id),
|
|
8077
8085
|
clearReaping: (id) => sessionManager.clearReaping(id),
|
|
8078
|
-
audit:
|
|
8086
|
+
audit: reaperAuditSink(config.stateDir),
|
|
8079
8087
|
}, config.monitoring?.sessionReaper);
|
|
8080
8088
|
sessionReaper.start();
|
|
8081
8089
|
// ── Unkillability backstop (UNIFIED-SESSION-LIFECYCLE §P5) ───────────────
|