instar 1.2.58 → 1.2.60
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 +31 -0
- package/.claude/skills/autonomous/scripts/setup-autonomous.sh +25 -0
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +19 -0
- package/dist/commands/server.js.map +1 -1
- package/dist/core/PostUpdateMigrator.js +2 -2
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/monitoring/HumanAsDetectorLog.d.ts +123 -0
- package/dist/monitoring/HumanAsDetectorLog.d.ts.map +1 -0
- package/dist/monitoring/HumanAsDetectorLog.js +237 -0
- package/dist/monitoring/HumanAsDetectorLog.js.map +1 -0
- package/dist/server/CapabilityIndex.d.ts.map +1 -1
- package/dist/server/CapabilityIndex.js +3 -0
- package/dist/server/CapabilityIndex.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +67 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +61 -61
- package/upgrades/1.2.59.md +67 -0
- package/upgrades/1.2.60.md +57 -0
- package/upgrades/side-effects/goal-native-delegation.md +76 -0
- package/upgrades/side-effects/human-as-detector.md +43 -0
|
@@ -146,6 +146,7 @@ DURATION_SECONDS=$(fm_get duration_seconds)
|
|
|
146
146
|
STARTED_AT=$(fm_get started_at)
|
|
147
147
|
COMPLETION_PROMISE=$(fm_get completion_promise)
|
|
148
148
|
COMPLETION_CONDITION=$(fm_get completion_condition)
|
|
149
|
+
GOAL_MODE=$(fm_get goal_mode) # "native" = the framework's own /goal loop drives completion
|
|
149
150
|
|
|
150
151
|
# Validate recorded session_id is a real UUID. Claude sometimes writes a custom
|
|
151
152
|
# string instead of $CLAUDE_CODE_SESSION_ID; non-UUID values are treated as
|
|
@@ -228,6 +229,36 @@ if [[ "$OWNER" != "true" ]]; then
|
|
|
228
229
|
exit 0
|
|
229
230
|
fi
|
|
230
231
|
|
|
232
|
+
# ── Native /goal delegation: the framework's own /goal loop owns completion. ──
|
|
233
|
+
# instar injected "/goal <condition>" at start (goal_mode=native), so we DEFER the
|
|
234
|
+
# continue/stop decision to native /goal's own Stop hook (we approve/exit; its hook
|
|
235
|
+
# blocks until the condition is met — block wins over approve, so it stays in control).
|
|
236
|
+
# instar still owns its terminal STOP concerns (emergency-stop, duration) and enforces
|
|
237
|
+
# them by CLEARING native /goal first (inject "/goal clear" via the server).
|
|
238
|
+
if [[ "$GOAL_MODE" == "native" ]]; then
|
|
239
|
+
native_goal_clear() {
|
|
240
|
+
local port auth
|
|
241
|
+
port=$(python3 -c "import json;print(json.load(open('.instar/config.json')).get('port',4040))" 2>/dev/null || echo 4040)
|
|
242
|
+
auth=$(python3 -c "import json;print(json.load(open('.instar/config.json')).get('authToken',''))" 2>/dev/null || echo "")
|
|
243
|
+
jq -nc --arg t "$REPORT_TOPIC" '{topicId:$t}' \
|
|
244
|
+
| curl -s -m 10 -H "Authorization: Bearer $auth" -H 'Content-Type: application/json' \
|
|
245
|
+
--data-binary @- "http://localhost:${port}/autonomous/native-goal/clear" >/dev/null 2>&1 || true
|
|
246
|
+
}
|
|
247
|
+
if [[ -f ".instar/autonomous-emergency-stop" ]]; then
|
|
248
|
+
native_goal_clear; rm -f "$STATE_FILE"
|
|
249
|
+
echo "[autonomous] emergency stop — native /goal cleared" >&2; exit 0
|
|
250
|
+
fi
|
|
251
|
+
if [[ "$DURATION_SECONDS" =~ ^[0-9]+$ ]] && [[ $DURATION_SECONDS -gt 0 ]]; then
|
|
252
|
+
NG_START=$(date -u -j -f "%Y-%m-%dT%H:%M:%SZ" "$STARTED_AT" +%s 2>/dev/null || date -d "$STARTED_AT" +%s 2>/dev/null || echo 0)
|
|
253
|
+
if [[ "$NG_START" =~ ^[0-9]+$ ]] && [[ $NG_START -gt 0 ]] && [[ $(( $(date +%s) - NG_START )) -ge $DURATION_SECONDS ]]; then
|
|
254
|
+
native_goal_clear; rm -f "$STATE_FILE"
|
|
255
|
+
echo "[autonomous] duration expired — native /goal cleared" >&2; exit 0
|
|
256
|
+
fi
|
|
257
|
+
fi
|
|
258
|
+
# Not terminal → let native /goal decide completion. Approve (its hook keeps control).
|
|
259
|
+
exit 0
|
|
260
|
+
fi
|
|
261
|
+
|
|
231
262
|
# ── This IS the autonomous session. Terminal checks first. ────────────
|
|
232
263
|
|
|
233
264
|
# Validate iteration
|
|
@@ -197,6 +197,31 @@ To complete, ALL of these must be true:
|
|
|
197
197
|
- Then output: <promise>$COMPLETION_PROMISE</promise>
|
|
198
198
|
EOF
|
|
199
199
|
|
|
200
|
+
# ── Native /goal delegation: where the framework has a native /goal loop, hand the
|
|
201
|
+
# condition to it (instar injects "/goal <condition>" via the server → SessionManager
|
|
202
|
+
# send-keys) and mark goal_mode:native so the stop-hook defers completion to it. Only
|
|
203
|
+
# with a condition + a per-topic job + Claude Code >= 2.1.139. Best-effort: on any miss
|
|
204
|
+
# we leave goal_mode empty and instar's own independent evaluator drives (Phase 1).
|
|
205
|
+
if [[ -n "$COMPLETION_CONDITION" ]] && [[ -n "$REPORT_TOPIC" ]]; then
|
|
206
|
+
CLAUDE_VER=$(claude --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "")
|
|
207
|
+
NATIVE_GOAL_OK="false"
|
|
208
|
+
if [[ -n "$CLAUDE_VER" ]]; then
|
|
209
|
+
# /goal requires Claude Code >= 2.1.139.
|
|
210
|
+
if [[ "$(printf '%s\n2.1.139\n' "$CLAUDE_VER" | sort -V | head -1)" == "2.1.139" ]]; then
|
|
211
|
+
NATIVE_GOAL_OK="true"
|
|
212
|
+
fi
|
|
213
|
+
fi
|
|
214
|
+
if [[ "$NATIVE_GOAL_OK" == "true" ]]; then
|
|
215
|
+
NG_PORT=$(python3 -c "import json;print(json.load(open('.instar/config.json')).get('port',4040))" 2>/dev/null || echo 4040)
|
|
216
|
+
NG_AUTH=$(python3 -c "import json;print(json.load(open('.instar/config.json')).get('authToken',''))" 2>/dev/null || echo "")
|
|
217
|
+
jq -nc --arg t "$REPORT_TOPIC" --arg c "$COMPLETION_CONDITION" '{topicId:$t,condition:$c}' \
|
|
218
|
+
| curl -s -m 8 -H "Authorization: Bearer $NG_AUTH" -H 'Content-Type: application/json' \
|
|
219
|
+
--data-binary @- "http://localhost:${NG_PORT}/autonomous/native-goal/set" >/dev/null 2>&1 \
|
|
220
|
+
&& echo " Native /goal: handed condition to Claude Code's /goal loop" \
|
|
221
|
+
|| echo " Native /goal: unavailable — using instar's own completion evaluator"
|
|
222
|
+
fi
|
|
223
|
+
fi
|
|
224
|
+
|
|
200
225
|
echo "🔄 Autonomous mode activated!"
|
|
201
226
|
echo ""
|
|
202
227
|
echo "Goal: $GOAL"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiqDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA60LtE;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
|
@@ -71,6 +71,7 @@ import { AutonomousEvolution } from '../core/AutonomousEvolution.js';
|
|
|
71
71
|
import { DispatchScopeEnforcer } from '../core/DispatchScopeEnforcer.js';
|
|
72
72
|
import { TrustRecovery } from '../core/TrustRecovery.js';
|
|
73
73
|
import { DegradationReporter } from '../monitoring/DegradationReporter.js';
|
|
74
|
+
import { HumanAsDetectorLog, observeInboundMessage } from '../monitoring/HumanAsDetectorLog.js';
|
|
74
75
|
import { resolveStableNodeBinary } from '../utils/resolveNodeBinary.js';
|
|
75
76
|
import { SelfKnowledgeTree } from '../knowledge/SelfKnowledgeTree.js';
|
|
76
77
|
import { CoverageAuditor } from '../knowledge/CoverageAuditor.js';
|
|
@@ -1911,6 +1912,15 @@ export async function startServer(options) {
|
|
|
1911
1912
|
agentName: config.projectName,
|
|
1912
1913
|
instarVersion: startupVersion,
|
|
1913
1914
|
});
|
|
1915
|
+
// HumanAsDetectorLog — treats a human-caught coherence break (a correction,
|
|
1916
|
+
// a "you already said", a "why didn't you catch this") as evidence that some
|
|
1917
|
+
// automated guardian failed. Configured early; the inbound-message observe()
|
|
1918
|
+
// is chained onto telegram.onMessageLogged once telegram is up (see below).
|
|
1919
|
+
const humanAsDetectorLog = HumanAsDetectorLog.getInstance();
|
|
1920
|
+
humanAsDetectorLog.configure({
|
|
1921
|
+
stateDir: config.stateDir,
|
|
1922
|
+
agentName: config.projectName,
|
|
1923
|
+
});
|
|
1914
1924
|
// Clean up stale Telegram temp files on startup
|
|
1915
1925
|
cleanupTelegramTempFiles();
|
|
1916
1926
|
// Pre-flight: ensure better-sqlite3 bindings are compiled for the current Node.js version.
|
|
@@ -5343,6 +5353,15 @@ export async function startServer(options) {
|
|
|
5343
5353
|
platformUserId: entry.telegramUserId?.toString(),
|
|
5344
5354
|
});
|
|
5345
5355
|
};
|
|
5356
|
+
// Human-as-Detector: observe inbound HUMAN messages for coherence-break
|
|
5357
|
+
// corrections — a correction the user had to make is evidence a guardian
|
|
5358
|
+
// failed. Chains the prior callback; best-effort (observe never throws).
|
|
5359
|
+
const beforeHadCallback = telegram.onMessageLogged;
|
|
5360
|
+
telegram.onMessageLogged = (entry) => {
|
|
5361
|
+
if (beforeHadCallback)
|
|
5362
|
+
beforeHadCallback(entry);
|
|
5363
|
+
observeInboundMessage(humanAsDetectorLog, entry);
|
|
5364
|
+
};
|
|
5346
5365
|
presenceProxy.start();
|
|
5347
5366
|
// ── PromiseBeacon ────────────────────────────────────────────────
|
|
5348
5367
|
// Watches beacon-enabled commitments and emits ⏳ heartbeats so the
|