instar 1.2.58 → 1.2.59
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/core/PostUpdateMigrator.js +2 -2
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/server/CapabilityIndex.d.ts.map +1 -1
- package/dist/server/CapabilityIndex.js +2 -0
- package/dist/server/CapabilityIndex.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +54 -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/side-effects/goal-native-delegation.md +76 -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"
|
|
@@ -1151,8 +1151,8 @@ export class PostUpdateMigrator {
|
|
|
1151
1151
|
// Marker = the latest capability signature (bumped each time the bundled hook/
|
|
1152
1152
|
// setup gains a feature, so prior installs upgrade): now the independent
|
|
1153
1153
|
// completion evaluator (mirrors /goal). Absent from multi-session-only installs.
|
|
1154
|
-
upgrade('.claude/skills/autonomous/hooks/autonomous-stop-hook.sh', '
|
|
1155
|
-
upgrade('.claude/skills/autonomous/scripts/setup-autonomous.sh', '
|
|
1154
|
+
upgrade('.claude/skills/autonomous/hooks/autonomous-stop-hook.sh', 'Native /goal delegation', 'Autonomous Mode Stop Hook', 'skills/autonomous/hooks/autonomous-stop-hook.sh (topic-keyed + multi-session + completion evaluator + native /goal)');
|
|
1155
|
+
upgrade('.claude/skills/autonomous/scripts/setup-autonomous.sh', 'native-goal/set', 'autonomous-state.local.md', 'skills/autonomous/scripts/setup-autonomous.sh (per-topic + completion-condition + native /goal)');
|
|
1156
1156
|
}
|
|
1157
1157
|
/**
|
|
1158
1158
|
* Deploy any missing built-in skills (e.g., guardian job skills added after initial setup).
|