@weave-os/router 0.2.35 → 0.2.37
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/README.md +1 -1
- package/bin.js +1 -1
- package/cc-statusline.sh +66 -17
- package/codex-skills/fm/SKILL.md +2 -1
- package/codex-skills/force-model/SKILL.md +2 -1
- package/codex-skills/list-models/SKILL.md +28 -0
- package/codex-skills/rf/SKILL.md +2 -1
- package/codex-skills/router-feedback/SKILL.md +2 -1
- package/codex-skills/router-models/SKILL.md +1 -1
- package/codex-skills/ufm/SKILL.md +2 -1
- package/codex-skills/unforce-model/SKILL.md +2 -1
- package/codex-status.sh +95 -3
- package/commands/list-models.md +5 -0
- package/commands/models.md +1 -1
- package/commands/router-models.md +1 -1
- package/directives.tsv +1 -0
- package/install.sh +335 -88
- package/package.json +9 -2
- package/pi-router/README.md +7 -2
- package/pi-router/src/auto-model.ts +118 -0
- package/pi-router/src/config.ts +34 -28
- package/pi-router/src/dispatch.ts +2 -2
- package/pi-router/src/index.ts +5 -1
- package/pi-router/src/pricing.generated.ts +7 -2
- package/pi-router/src/routed-model.ts +5 -4
- package/skills/build/SKILL.md +71 -0
- package/skills/build/agents/build-implementer.md +13 -0
- package/skills/build/agents/build-researcher.md +11 -0
- package/skills/build/agents/build-reviewer.md +13 -0
- package/skills/build/agents/build-verifier.md +13 -0
- package/skills/build/references/client-controls.md +34 -0
- package/skills/build/references/pr-loop.md +10 -0
- package/skills/build/references/research-and-interview.md +24 -0
- package/skills/build/references/verification-and-review.md +20 -0
- package/skills/build/references/worker-contracts.md +71 -0
- package/skills/build/scripts/pin-coordinator.sh +3 -0
- package/uninstall.sh +55 -5
- package/windows.js +7 -3
package/install.sh
CHANGED
|
@@ -248,25 +248,6 @@ print_uninstall_hint() {
|
|
|
248
248
|
"$C_BOLD" "$C_RESET" "$C_CYAN" "$(uninstall_cmd)" "$C_RESET"
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
# offer_launch asks to start the client named in $1 (command in the remaining
|
|
252
|
-
# args) so a working interactive install ends in the product. The client runs
|
|
253
|
-
# as a child, not via exec, so the EXIT trap still removes the temp files.
|
|
254
|
-
offer_launch() {
|
|
255
|
-
local label="$1"; shift
|
|
256
|
-
[ "${WEAVE_SETUP_DEFER_LAUNCH:-}" != "1" ] && [ "$non_interactive" = "false" ] && [ "$quiet" != "true" ] \
|
|
257
|
-
&& [ -t 0 ] && [ -t 1 ] && command -v "${!#}" >/dev/null 2>&1 || return 0
|
|
258
|
-
local answer=""
|
|
259
|
-
printf "\n%sStart %s now?%s [Y/n] " "$C_BOLD" "$label" "$C_RESET" >/dev/tty
|
|
260
|
-
read -r answer </dev/tty || answer="n"
|
|
261
|
-
case "$answer" in
|
|
262
|
-
""|y|Y|yes|Yes) ;;
|
|
263
|
-
*) return 0 ;;
|
|
264
|
-
esac
|
|
265
|
-
local launch_status=0
|
|
266
|
-
"$@" </dev/tty || launch_status=$?
|
|
267
|
-
exit "$launch_status"
|
|
268
|
-
}
|
|
269
|
-
|
|
270
251
|
# ---------- banner ----------
|
|
271
252
|
#
|
|
272
253
|
# Print the WEAVE wordmark in brand orange. Skipped under --quiet or when
|
|
@@ -1343,9 +1324,10 @@ write_pi_models_config() {
|
|
|
1343
1324
|
| (if $name != "" then . + {"X-Weave-User-Name": $name } else . end)
|
|
1344
1325
|
')"
|
|
1345
1326
|
|
|
1346
|
-
#
|
|
1347
|
-
#
|
|
1348
|
-
# sync with
|
|
1327
|
+
# One "Weave Router" entry: the router picks the served model per request
|
|
1328
|
+
# from the organization's enabled models, so listing concrete models only
|
|
1329
|
+
# advertised choices pi never honored. Keep in sync with WEAVE_MODELS in
|
|
1330
|
+
# pi-router/src/config.ts, which replaces this list whenever the extension loads.
|
|
1349
1331
|
#
|
|
1350
1332
|
# baseUrl is the router ROOT (no /v1): pi's anthropic-messages provider uses
|
|
1351
1333
|
# @anthropic-ai/sdk, which appends /v1/messages itself. Unlike the codex block
|
|
@@ -1363,24 +1345,7 @@ write_pi_models_config() {
|
|
|
1363
1345
|
authHeader: false,
|
|
1364
1346
|
headers: $headers,
|
|
1365
1347
|
models: [
|
|
1366
|
-
{ id: "
|
|
1367
|
-
{ id: "claude-fable-5", name: "Claude Fable 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1368
|
-
{ id: "claude-opus-5-5", name: "Claude Opus 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1369
|
-
{ id: "claude-opus-5", name: "Claude Opus 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1370
|
-
{ id: "claude-sonnet-5-5", name: "Claude Sonnet 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1371
|
-
{ id: "claude-opus-4-7", name: "Claude Opus 4.7 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
|
|
1372
|
-
{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
|
|
1373
|
-
{ id: "claude-haiku-5-5", name: "Claude Haiku 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1374
|
-
{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 200000, maxTokens: 32000 },
|
|
1375
|
-
{ id: "gpt-6-astra", name: "GPT-6 Astra (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1376
|
-
{ id: "gpt-6-sol", name: "GPT-6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1377
|
-
{ id: "gpt-6.1-sol", name: "GPT-6.1 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1378
|
-
{ id: "gpt-6.1-terra", name: "GPT-6.1 Terra (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1379
|
-
{ id: "gpt-6-luna", name: "GPT-6 Luna (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1380
|
-
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1381
|
-
{ id: "grok-4.5", name: "Grok 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
|
|
1382
|
-
{ id: "grok-4.6", name: "Grok 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
|
|
1383
|
-
{ id: "grok-4.7", name: "Grok 4.7 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 }
|
|
1348
|
+
{ id: "auto", name: "Weave Router", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 }
|
|
1384
1349
|
]
|
|
1385
1350
|
}
|
|
1386
1351
|
')"
|
|
@@ -1398,10 +1363,11 @@ write_pi_models_config() {
|
|
|
1398
1363
|
chmod 600 "$config_file"
|
|
1399
1364
|
}
|
|
1400
1365
|
|
|
1401
|
-
# write_pi_settings_config makes
|
|
1402
|
-
#
|
|
1403
|
-
#
|
|
1404
|
-
#
|
|
1366
|
+
# write_pi_settings_config makes `weave/auto` pi's default and loads the npm
|
|
1367
|
+
# package named by $npm_package_name. defaultProvider is always set to "weave" —
|
|
1368
|
+
# the installer's job is to route via Weave; uninstall reverts it. defaultModel
|
|
1369
|
+
# is always "auto": it is the provider's only model, so any other value would
|
|
1370
|
+
# make pi fall back to a different provider. The
|
|
1405
1371
|
# npm package source is appended to `packages` idempotently — pi auto-installs
|
|
1406
1372
|
# missing packages on startup — and every known prior Weave package id
|
|
1407
1373
|
# (`@workweave/pi-router`, `@workweave/router`, `@weave-os/router`) except the
|
|
@@ -1422,12 +1388,12 @@ write_pi_settings_config() {
|
|
|
1422
1388
|
))
|
|
1423
1389
|
| (if (.packages | index($pkg)) then . else .packages += [$pkg] end)
|
|
1424
1390
|
| .defaultProvider = "weave"
|
|
1425
|
-
|
|
|
1391
|
+
| .defaultModel = "auto"
|
|
1426
1392
|
' "$settings_file")"
|
|
1427
1393
|
else
|
|
1428
1394
|
merged="$(jq -n --arg pkg "$pkg" '{
|
|
1429
1395
|
defaultProvider: "weave",
|
|
1430
|
-
defaultModel: "
|
|
1396
|
+
defaultModel: "auto",
|
|
1431
1397
|
packages: [$pkg]
|
|
1432
1398
|
}')"
|
|
1433
1399
|
fi
|
|
@@ -1600,7 +1566,7 @@ set_copilot_default_model() {
|
|
|
1600
1566
|
# are reused with the sigil and client names rewritten. Codex-only toggles and
|
|
1601
1567
|
# skills that depend on Codex session state are excluded.
|
|
1602
1568
|
copilot_skill_names() {
|
|
1603
|
-
weave_registry_skill_assets codex | grep -vxE 'disable-routing|router-session|router-models|models' || true
|
|
1569
|
+
weave_registry_skill_assets codex | grep -vxE 'disable-routing|router-session|list-models|router-models|models' || true
|
|
1604
1570
|
}
|
|
1605
1571
|
|
|
1606
1572
|
# install_copilot_skills installs each router directive as a Copilot skill.
|
|
@@ -1888,7 +1854,7 @@ if [ "$mode" = "setup" ]; then
|
|
|
1888
1854
|
chmod 600 "$setup_handoff"
|
|
1889
1855
|
fi
|
|
1890
1856
|
if [ "$setup_claude" = "true" ]; then
|
|
1891
|
-
WEAVE_SETUP_HANDOFF_FILE="$setup_handoff"
|
|
1857
|
+
WEAVE_SETUP_HANDOFF_FILE="$setup_handoff" bash "$0" "${setup_args[@]}" --claude \
|
|
1892
1858
|
|| { setup_status=$?; [ -z "$setup_handoff" ] || rm -f "$setup_handoff"; exit "$setup_status"; }
|
|
1893
1859
|
fi
|
|
1894
1860
|
if [ -n "$setup_handoff" ]; then
|
|
@@ -1900,10 +1866,9 @@ if [ "$mode" = "setup" ]; then
|
|
|
1900
1866
|
fi
|
|
1901
1867
|
if [ "$setup_codex" = "true" ]; then
|
|
1902
1868
|
WEAVE_SETUP_SHARED_KEY="$shared_key" WEAVE_SETUP_SHARED_EMAIL="$shared_email" \
|
|
1903
|
-
WEAVE_SETUP_IDENTITY_RESOLVED="$identity_resolved"
|
|
1869
|
+
WEAVE_SETUP_IDENTITY_RESOLVED="$identity_resolved" \
|
|
1904
1870
|
bash "$0" "${setup_args[@]}" --codex
|
|
1905
1871
|
fi
|
|
1906
|
-
[ -z "$shared_key" ] || [ -n "$install_dir" ] || offer_launch "Claude Code" claude
|
|
1907
1872
|
exit 0
|
|
1908
1873
|
fi
|
|
1909
1874
|
|
|
@@ -2257,6 +2222,7 @@ router-off||local-toggle|yes|yes|no|no|manual|command,skill
|
|
|
2257
2222
|
router-on||local-toggle|yes|yes|no|no|manual|command,skill
|
|
2258
2223
|
router-status||local-toggle|yes|yes|no|no|manual|command,skill
|
|
2259
2224
|
router-session||prompt|yes|yes|no|no|manual|command,skill
|
|
2225
|
+
list-models||prompt|yes|yes|no|no|manual|command,skill
|
|
2260
2226
|
router-models|models|local-toggle|yes|yes|no|no|manual|command,skill
|
|
2261
2227
|
disable-routing||local-toggle|no|yes|no|no|manual|skill
|
|
2262
2228
|
beta||prompt|yes|no|no|yes|manual|command
|
|
@@ -3091,7 +3057,7 @@ prepare_claude_context_window() {
|
|
|
3091
3057
|
model="${model:-sonnet}"
|
|
3092
3058
|
case "$model" in
|
|
3093
3059
|
*'[1m]') context_window=""; return 0 ;;
|
|
3094
|
-
sonnet|opus|fable|claude-sonnet-4-6|claude-sonnet-5|claude-sonnet-5-5|claude-haiku-5-5|claude-opus-4-6|claude-opus-4-7|claude-opus-4-8|claude-opus-5|claude-opus-5-5|claude-fable-5|claude-fable-5-1) ;;
|
|
3060
|
+
sonnet|opus|fable|claude-sonnet-4-6|claude-sonnet-5|claude-sonnet-5-5|claude-haiku-5-5|claude-opus-4-6|claude-opus-4-7|claude-opus-4-8|claude-opus-5|claude-opus-5-5|claude-fable-5|claude-fable-5-1|claude-fable-5-2) ;;
|
|
3095
3061
|
*) err "Cannot assert 1M support for '$model'. Select a supported Sonnet/Opus/Fable model first; leaving it unchanged."; return 1 ;;
|
|
3096
3062
|
esac
|
|
3097
3063
|
context_managed_model="${model}[1m]"
|
|
@@ -3197,7 +3163,7 @@ toggle_claude() {
|
|
|
3197
3163
|
# is never touched, so this stays out of `git diff`.
|
|
3198
3164
|
if [ -f "$local_settings_file" ]; then
|
|
3199
3165
|
jq '{env: (.env // {}), weave_auto_selected: (.model == "weave-auto" or .model == "weave-auto[1m]")}' "$local_settings_file" >"$parked"
|
|
3200
|
-
merged="$(jq '.env = ((.env // {} | del(.ANTHROPIC_CUSTOM_HEADERS)) + {ANTHROPIC_BASE_URL: "https://api.anthropic.com"}) | '"$CLAUDE_WEAVE_AUTO_STRIP_JQ" "$local_settings_file")"
|
|
3166
|
+
merged="$(jq '.env = ((.env // {} | del(.ANTHROPIC_CUSTOM_HEADERS, .CLAUDE_CODE_AUTO_MODE_SERVER)) + {ANTHROPIC_BASE_URL: "https://api.anthropic.com"}) | '"$CLAUDE_WEAVE_AUTO_STRIP_JQ" "$local_settings_file")"
|
|
3201
3167
|
else
|
|
3202
3168
|
printf '{"env":{}}\n' >"$parked"
|
|
3203
3169
|
merged='{"env":{"ANTHROPIC_BASE_URL":"https://api.anthropic.com"}}'
|
|
@@ -3219,9 +3185,9 @@ toggle_claude() {
|
|
|
3219
3185
|
else
|
|
3220
3186
|
# Park just the router-owned env keys, then strip them so Claude Code
|
|
3221
3187
|
# falls back to its own Anthropic login.
|
|
3222
|
-
jq '{env: ((.env // {}) | {ANTHROPIC_BASE_URL, ANTHROPIC_CUSTOM_HEADERS, ENABLE_TOOL_SEARCH} | with_entries(select(.value != null))), weave_auto_selected: (.model == "weave-auto" or .model == "weave-auto[1m]")}' "$settings_file" >"$parked"
|
|
3188
|
+
jq '{env: ((.env // {}) | {ANTHROPIC_BASE_URL, ANTHROPIC_CUSTOM_HEADERS, ENABLE_TOOL_SEARCH, CLAUDE_CODE_AUTO_MODE_SERVER} | with_entries(select(.value != null))), weave_auto_selected: (.model == "weave-auto" or .model == "weave-auto[1m]")}' "$settings_file" >"$parked"
|
|
3223
3189
|
chmod 600 "$parked"
|
|
3224
|
-
merged="$(jq '(.env // {}) |= del(.ANTHROPIC_BASE_URL, .ANTHROPIC_CUSTOM_HEADERS, .ENABLE_TOOL_SEARCH)
|
|
3190
|
+
merged="$(jq '(.env // {}) |= del(.ANTHROPIC_BASE_URL, .ANTHROPIC_CUSTOM_HEADERS, .ENABLE_TOOL_SEARCH, .CLAUDE_CODE_AUTO_MODE_SERVER)
|
|
3225
3191
|
| (if (.env // {} | length) == 0 then del(.env) else . end) | '"$CLAUDE_WEAVE_AUTO_STRIP_JQ" "$settings_file")"
|
|
3226
3192
|
printf '%s\n' "$merged" >"$settings_file"
|
|
3227
3193
|
fi
|
|
@@ -3564,9 +3530,11 @@ toggle_copilot() {
|
|
|
3564
3530
|
# refusal naming the dashboard.
|
|
3565
3531
|
|
|
3566
3532
|
# Public, unauthed catalog of everything the router can route to. Mounted in
|
|
3567
|
-
# both deployment modes, so it is the one listing that always works.
|
|
3568
|
-
|
|
3569
|
-
|
|
3533
|
+
# both deployment modes, so it is the one listing that always works. The scope
|
|
3534
|
+
# is explicit because the unscoped listing is a serving roster, which a managed
|
|
3535
|
+
# router cannot resolve without an admitted request.
|
|
3536
|
+
MODELS_CATALOG_PATH="/v1/router/models?scope=catalog"
|
|
3537
|
+
MODELS_DASHBOARD_URL="https://app.weaveos.com/organization/settings/weave-router/models"
|
|
3570
3538
|
|
|
3571
3539
|
# Set by models_api on every call.
|
|
3572
3540
|
models_http_status=""
|
|
@@ -4075,9 +4043,41 @@ run_login_claude() {
|
|
|
4075
4043
|
external_account_id="${account_uuid}:${organization_uuid}"
|
|
4076
4044
|
body="$(jq -nc --arg provider claude --arg account "$external_account_id" --arg token "$refresh_token" --arg label "$display_name" '{provider:$provider,external_account_id:$account,refresh_token:$token} | if $label != "" then .display_name = $label else . end')"
|
|
4077
4045
|
models_api POST "/v1/subscriptions/accounts" "$body" || models_fail "enrolling Claude subscription"
|
|
4046
|
+
forget_plan_warning claude
|
|
4078
4047
|
ok "Claude subscription enrolled."
|
|
4079
4048
|
}
|
|
4080
4049
|
|
|
4050
|
+
# A new login supersedes the statusline's cached "needs login" warning for
|
|
4051
|
+
# that provider in every install, without waiting for the next refresh. Each
|
|
4052
|
+
# edit holds the refresh's lock, so a fetch that predates the login cannot
|
|
4053
|
+
# land afterwards, and keeps the file's mtime, so the remaining providers'
|
|
4054
|
+
# warnings expire on their own schedule.
|
|
4055
|
+
forget_plan_warning() {
|
|
4056
|
+
local provider="$1" file lock plans owned tries
|
|
4057
|
+
for file in "${XDG_CACHE_HOME:-$HOME/.cache}"/weave-router/display-settings*.plans; do
|
|
4058
|
+
[ -f "$file" ] || continue
|
|
4059
|
+
lock="${file%.plans}.lock"
|
|
4060
|
+
owned=false tries=0
|
|
4061
|
+
while [ "$tries" -lt 10 ]; do
|
|
4062
|
+
if mkdir "$lock" 2>/dev/null; then owned=true; break; fi
|
|
4063
|
+
tries=$((tries + 1))
|
|
4064
|
+
sleep 1
|
|
4065
|
+
done
|
|
4066
|
+
plans="$(cat "$file" 2>/dev/null)"
|
|
4067
|
+
case " $plans " in
|
|
4068
|
+
*" $provider "*)
|
|
4069
|
+
plans="$(printf '%s' "$plans" | tr ' ' '\n' | grep -vx -- "$provider" | tr '\n' ' ' | sed 's/ *$//')" || true
|
|
4070
|
+
printf '%s' "$plans" >"$file.tmp.$$" 2>/dev/null \
|
|
4071
|
+
&& touch -r "$file" "$file.tmp.$$" 2>/dev/null \
|
|
4072
|
+
&& mv "$file.tmp.$$" "$file" 2>/dev/null
|
|
4073
|
+
rm -f "$file.tmp.$$" 2>/dev/null
|
|
4074
|
+
;;
|
|
4075
|
+
esac
|
|
4076
|
+
[ "$owned" = false ] || rmdir "$lock" 2>/dev/null
|
|
4077
|
+
done
|
|
4078
|
+
return 0
|
|
4079
|
+
}
|
|
4080
|
+
|
|
4081
4081
|
run_login_codex() {
|
|
4082
4082
|
local issuer device_response device_auth_id user_code interval authorization_response authorization_code verifier token_response refresh_token account_id display_name identity_token body attempts token_form
|
|
4083
4083
|
issuer="${WEAVE_CODEX_OAUTH_ISSUER:-https://auth.openai.com}"
|
|
@@ -4121,6 +4121,7 @@ run_login_codex() {
|
|
|
4121
4121
|
fi
|
|
4122
4122
|
body="$(jq -nc --arg provider codex --arg account "$account_id" --arg token "$refresh_token" --arg label "$display_name" '{provider:$provider,external_account_id:$account,refresh_token:$token} | if $label != "" then .display_name = $label else . end')"
|
|
4123
4123
|
models_api POST "/v1/subscriptions/accounts" "$body" || models_fail "enrolling Codex subscription"
|
|
4124
|
+
forget_plan_warning codex
|
|
4124
4125
|
ok "Codex subscription enrolled."
|
|
4125
4126
|
}
|
|
4126
4127
|
|
|
@@ -4811,7 +4812,7 @@ install_slash_commands() {
|
|
|
4811
4812
|
while IFS= read -r cmd; do
|
|
4812
4813
|
[ -f "$commands_src_dir/$cmd.md" ] || continue
|
|
4813
4814
|
case ",$cmd," in
|
|
4814
|
-
*,router-off,*|*,router-on,*|*,router-status,*|*,router-session,*|*,router-models,*|*,models,*)
|
|
4815
|
+
*,router-off,*|*,router-on,*|*,router-status,*|*,router-session,*|*,list-models,*|*,router-models,*|*,models,*)
|
|
4815
4816
|
[ "$target" = "claude" ] || continue ;;
|
|
4816
4817
|
esac
|
|
4817
4818
|
[ -n "$cmds" ] && cmds="$cmds "
|
|
@@ -5011,6 +5012,110 @@ $(weave_registry_skill_assets codex)
|
|
|
5011
5012
|
EOF
|
|
5012
5013
|
}
|
|
5013
5014
|
|
|
5015
|
+
# The build workflow skill is a resource tree (SKILL.md, references, scripts)
|
|
5016
|
+
# plus Claude Code agent definitions, so it is copied whole rather than through
|
|
5017
|
+
# the directive registry. It ships with the packaged installer and repo
|
|
5018
|
+
# checkouts; a standalone `curl | sh` install has no copy and skips it.
|
|
5019
|
+
build_skill_marker="<!-- weave-router managed build skill -->"
|
|
5020
|
+
build_skill_manifest=".weave-router-files"
|
|
5021
|
+
|
|
5022
|
+
build_skill_source_dir() {
|
|
5023
|
+
local candidate
|
|
5024
|
+
for candidate in "$script_dir/skills/build" "$script_dir/../skills/build"; do
|
|
5025
|
+
[ -f "$candidate/SKILL.md" ] || continue
|
|
5026
|
+
printf '%s' "$candidate"
|
|
5027
|
+
return 0
|
|
5028
|
+
done
|
|
5029
|
+
return 1
|
|
5030
|
+
}
|
|
5031
|
+
|
|
5032
|
+
# build_skill_entry_has_symlink reports whether any component of a manifest entry under the
|
|
5033
|
+
# skill dir is a symlink, so cleanup never follows a link out of the skill.
|
|
5034
|
+
build_skill_entry_has_symlink() {
|
|
5035
|
+
local path="$1" rel="$2"
|
|
5036
|
+
while [ -n "$rel" ]; do
|
|
5037
|
+
path="$path/${rel%%/*}"
|
|
5038
|
+
[ -L "$path" ] && return 0
|
|
5039
|
+
case "$rel" in */*) rel="${rel#*/}" ;; *) rel="" ;; esac
|
|
5040
|
+
done
|
|
5041
|
+
return 1
|
|
5042
|
+
}
|
|
5043
|
+
|
|
5044
|
+
# remove_build_skill_files deletes the files a previous install recorded in
|
|
5045
|
+
# the manifest, leaving anything the user added beside them.
|
|
5046
|
+
remove_build_skill_files() {
|
|
5047
|
+
local skill_dir="$1" rel
|
|
5048
|
+
if [ -L "$skill_dir/$build_skill_manifest" ]; then
|
|
5049
|
+
rm -f "$skill_dir/$build_skill_manifest"
|
|
5050
|
+
return 0
|
|
5051
|
+
fi
|
|
5052
|
+
[ -f "$skill_dir/$build_skill_manifest" ] || return 0
|
|
5053
|
+
while IFS= read -r rel; do
|
|
5054
|
+
case "$rel" in ""|/*|*..*) continue ;; esac
|
|
5055
|
+
if build_skill_entry_has_symlink "$skill_dir" "$rel"; then continue; fi
|
|
5056
|
+
rm -f "$skill_dir/$rel"
|
|
5057
|
+
done <"$skill_dir/$build_skill_manifest"
|
|
5058
|
+
rm -f "$skill_dir/$build_skill_manifest"
|
|
5059
|
+
rmdir "$skill_dir/references" "$skill_dir/scripts" 2>/dev/null || true
|
|
5060
|
+
}
|
|
5061
|
+
|
|
5062
|
+
install_build_skill() {
|
|
5063
|
+
local skills_dir="$1" agents_dir="${2:-}" src dst rel name agent_src agent_dst
|
|
5064
|
+
src="$(build_skill_source_dir)" || return 0
|
|
5065
|
+
dst="$skills_dir/build"
|
|
5066
|
+
if [ "$scope" = "project" ] || [ -n "$install_dir" ]; then
|
|
5067
|
+
refuse_if_symlink "$skills_dir"
|
|
5068
|
+
refuse_if_symlink "$dst"
|
|
5069
|
+
elif [ -L "$skills_dir" ] || [ -L "$dst" ]; then
|
|
5070
|
+
warn "Build skill path contains a symlink; leaving the build skill untouched."
|
|
5071
|
+
return 0
|
|
5072
|
+
fi
|
|
5073
|
+
if [ -e "$dst/SKILL.md" ] && { [ ! -f "$dst/SKILL.md" ] || ! grep -Fq "$build_skill_marker" "$dst/SKILL.md"; }; then
|
|
5074
|
+
warn "A user-owned build skill already exists at $dst; leaving it untouched."
|
|
5075
|
+
return 0
|
|
5076
|
+
fi
|
|
5077
|
+
remove_build_skill_files "$dst"
|
|
5078
|
+
mkdir -p "$dst"
|
|
5079
|
+
: >"$dst/$build_skill_manifest"
|
|
5080
|
+
while IFS= read -r rel; do
|
|
5081
|
+
if [ -L "$dst/$(dirname "$rel")" ] || [ -L "$dst/$rel" ]; then
|
|
5082
|
+
warn "Build skill file $dst/$rel is a symlink; leaving it untouched."
|
|
5083
|
+
continue
|
|
5084
|
+
fi
|
|
5085
|
+
mkdir -p "$dst/$(dirname "$rel")"
|
|
5086
|
+
cp "$src/$rel" "$dst/$rel"
|
|
5087
|
+
printf '%s\n' "$rel" >>"$dst/$build_skill_manifest"
|
|
5088
|
+
done <<EOS
|
|
5089
|
+
$(cd "$src" && find . -type f ! -path './agents/*' | sed 's#^\./##' | LC_ALL=C sort)
|
|
5090
|
+
EOS
|
|
5091
|
+
if [ ! -L "$dst/scripts" ] && [ ! -L "$dst/scripts/pin-coordinator.sh" ]; then
|
|
5092
|
+
chmod +x "$dst/scripts/pin-coordinator.sh"
|
|
5093
|
+
fi
|
|
5094
|
+
|
|
5095
|
+
if [ -n "$agents_dir" ] && [ -d "$src/agents" ]; then
|
|
5096
|
+
if [ "$scope" = "project" ] || [ -n "$install_dir" ]; then
|
|
5097
|
+
refuse_if_symlink "$agents_dir"
|
|
5098
|
+
elif [ -L "$agents_dir" ]; then
|
|
5099
|
+
warn "$agents_dir is a symlink; leaving build agents untouched."
|
|
5100
|
+
agents_dir=""
|
|
5101
|
+
fi
|
|
5102
|
+
fi
|
|
5103
|
+
if [ -n "$agents_dir" ] && [ -d "$src/agents" ]; then
|
|
5104
|
+
mkdir -p "$agents_dir"
|
|
5105
|
+
for agent_src in "$src"/agents/*.md; do
|
|
5106
|
+
[ -f "$agent_src" ] || continue
|
|
5107
|
+
name="$(basename "$agent_src" .md)"
|
|
5108
|
+
agent_dst="$agents_dir/$name.md"
|
|
5109
|
+
if [ -L "$agent_dst" ] || { [ -e "$agent_dst" ] && ! grep -Fq "<!-- weave-router managed agent: $name -->" "$agent_dst"; }; then
|
|
5110
|
+
warn "A user-owned agent already exists at $agent_dst; leaving it untouched."
|
|
5111
|
+
continue
|
|
5112
|
+
fi
|
|
5113
|
+
cp "$agent_src" "$agent_dst"
|
|
5114
|
+
done
|
|
5115
|
+
fi
|
|
5116
|
+
ok "Build skill installed at $dst"
|
|
5117
|
+
}
|
|
5118
|
+
|
|
5014
5119
|
# ---------- post-install verification (shared by every target) ----------
|
|
5015
5120
|
#
|
|
5016
5121
|
# Every client gets the same two probes — reach the router, then prove the key
|
|
@@ -5217,7 +5322,6 @@ print_next_steps() {
|
|
|
5217
5322
|
# finish_install closes a Claude Code or Codex run. Only a working first install
|
|
5218
5323
|
# gets onboarding; a failed check or an update must not invite the user in.
|
|
5219
5324
|
finish_install() {
|
|
5220
|
-
local label="$1"; shift
|
|
5221
5325
|
if [ "$mode" = "install" ] && [ "$quiet" != "true" ] && [ -z "$install_dir" ] && [ "$key_verdict" = "valid" ]; then
|
|
5222
5326
|
local pkg="npx $npm_package_name" flags="--$target" feedback="type /rf <what happened> in Claude Code"
|
|
5223
5327
|
[ "$scope" = "project" ] && flags="$flags --scope project"
|
|
@@ -5229,7 +5333,6 @@ finish_install() {
|
|
|
5229
5333
|
printf " %-14s %s\n" "Turn back on" "$pkg on $flags"
|
|
5230
5334
|
printf " %-14s %s\n" "Give feedback" "$feedback"
|
|
5231
5335
|
printf " %-14s %s\n" "Uninstall" "$(uninstall_cmd)"
|
|
5232
|
-
offer_launch "$label" "$@"
|
|
5233
5336
|
elif [ "$mode" != "update" ]; then
|
|
5234
5337
|
print_uninstall_hint
|
|
5235
5338
|
fi
|
|
@@ -5393,8 +5496,93 @@ helper_dir="$(cd "$(dirname "$0")" 2>/dev/null && pwd -P)"
|
|
|
5393
5496
|
disabled_marker="$helper_dir/.weave-router-disabled"
|
|
5394
5497
|
router_badge_sentinel=$''
|
|
5395
5498
|
|
|
5499
|
+
display_hidden_file() {
|
|
5500
|
+
printf '%s/display-hidden-%s' "$state_root" "$(printf '%s' "$helper_dir" | cksum | tr -c '0-9' '-')"
|
|
5501
|
+
}
|
|
5502
|
+
|
|
5503
|
+
write_display_headers() {
|
|
5504
|
+
printf 'header = "X-Weave-Router-Key: %s"\n' "$2" >"$1"
|
|
5505
|
+
case "$3" in
|
|
5506
|
+
''|*[!A-Za-z0-9@._+-]*) ;;
|
|
5507
|
+
*) printf 'header = "X-Weave-User-Email: %s"\n' "$3" >>"$1" ;;
|
|
5508
|
+
esac
|
|
5509
|
+
}
|
|
5510
|
+
|
|
5511
|
+
refresh_display_settings() {
|
|
5512
|
+
local base_url="$1" header_file="$2" max_time="$3" display_url display_body hidden="0" hidden_file
|
|
5513
|
+
hidden_file="$(display_hidden_file)"
|
|
5514
|
+
display_url="${WEAVE_CODEX_DISPLAY_SETTINGS_URL:-}"
|
|
5515
|
+
if [ -z "$display_url" ]; then
|
|
5516
|
+
display_url="${base_url%/}"
|
|
5517
|
+
case "$display_url" in
|
|
5518
|
+
file://*) ;;
|
|
5519
|
+
*) display_url="${display_url%/v1}/v1/display-settings" ;;
|
|
5520
|
+
esac
|
|
5521
|
+
fi
|
|
5522
|
+
display_body="$(curl -fsS --max-time "$max_time" --max-filesize 8192 -K "$header_file" "$display_url" 2>/dev/null)" || return 0
|
|
5523
|
+
[ "$(jq -r '.hide_terminal_surfaces // false' <<<"$display_body" 2>/dev/null)" = "true" ] && hidden="1"
|
|
5524
|
+
printf '%s' "$hidden" >"$hidden_file.tmp.$$" 2>/dev/null && mv "$hidden_file.tmp.$$" "$hidden_file" 2>/dev/null
|
|
5525
|
+
rm -f "$hidden_file.tmp.$$" 2>/dev/null
|
|
5526
|
+
}
|
|
5527
|
+
|
|
5528
|
+
# A cold cache fetches the setting once in the foreground, briefly, so a
|
|
5529
|
+
# subject whose surfaces are hidden never sees a branded first title.
|
|
5530
|
+
display_file_younger_than() {
|
|
5531
|
+
local mtime now
|
|
5532
|
+
[ -f "$1" ] || return 1
|
|
5533
|
+
mtime="$(stat -c %Y "$1" 2>/dev/null || stat -f %m "$1" 2>/dev/null)" || return 1
|
|
5534
|
+
now="$(date +%s 2>/dev/null)" || return 1
|
|
5535
|
+
[ $(( now - mtime )) -lt "$2" ]
|
|
5536
|
+
}
|
|
5537
|
+
|
|
5538
|
+
# A cold cache, or a hidden setting past its grace window, fetches in the
|
|
5539
|
+
# foreground; a merely stale setting refreshes in the background. Failed
|
|
5540
|
+
# fetches are rate-limited by the .refreshed stamp.
|
|
5541
|
+
prime_display_settings() {
|
|
5542
|
+
local hidden_file stamp
|
|
5543
|
+
hidden_file="$(display_hidden_file)"
|
|
5544
|
+
stamp="$hidden_file.refreshed"
|
|
5545
|
+
[ -f "$stamp" ] || [ ! -f "$hidden_file" ] || stamp="$hidden_file"
|
|
5546
|
+
display_file_younger_than "$stamp" "${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-300}" && return 0
|
|
5547
|
+
if [ -f "$hidden_file" ] && { [ "$(cat "$hidden_file" 2>/dev/null)" != "1" ] \
|
|
5548
|
+
|| display_file_younger_than "$hidden_file" "${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"; }; then
|
|
5549
|
+
touch "$hidden_file.refreshed" 2>/dev/null
|
|
5550
|
+
( exec </dev/null >/dev/null 2>&1; prime_display_settings_now ) &
|
|
5551
|
+
return 0
|
|
5552
|
+
fi
|
|
5553
|
+
prime_display_settings_now
|
|
5554
|
+
}
|
|
5555
|
+
|
|
5556
|
+
prime_display_settings_now() {
|
|
5557
|
+
local endpoint header_file
|
|
5558
|
+
endpoint="$(read_codex_endpoint)" || return 0
|
|
5559
|
+
[ -n "$endpoint" ] || return 0
|
|
5560
|
+
mkdir -p "$state_root" 2>/dev/null || return 0
|
|
5561
|
+
touch "$(display_hidden_file).refreshed" 2>/dev/null
|
|
5562
|
+
header_file="$(mktemp "$state_root/.headers.XXXXXX")" || return 0
|
|
5563
|
+
chmod 600 "$header_file"
|
|
5564
|
+
write_display_headers "$header_file" "$(printf '%s' "$endpoint" | sed -n 2p)" "$(printf '%s' "$endpoint" | sed -n 3p)"
|
|
5565
|
+
refresh_display_settings "$(printf '%s' "$endpoint" | sed -n 1p)" "$header_file" 2
|
|
5566
|
+
rm -f "$header_file"
|
|
5567
|
+
}
|
|
5568
|
+
|
|
5569
|
+
codex_surfaces_hidden() {
|
|
5570
|
+
local hidden_file
|
|
5571
|
+
prime_display_settings
|
|
5572
|
+
hidden_file="$(display_hidden_file)"
|
|
5573
|
+
if [ ! -f "$hidden_file" ]; then
|
|
5574
|
+
display_file_younger_than "$hidden_file.refreshed" "${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-300}"
|
|
5575
|
+
return
|
|
5576
|
+
fi
|
|
5577
|
+
[ "$(cat "$hidden_file" 2>/dev/null)" = "1" ] || return 1
|
|
5578
|
+
display_file_younger_than "$hidden_file" "${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"
|
|
5579
|
+
}
|
|
5580
|
+
|
|
5396
5581
|
emit_title() {
|
|
5397
5582
|
local title="$1"
|
|
5583
|
+
case "$title" in
|
|
5584
|
+
"Weave Router"*) if codex_surfaces_hidden; then title="Codex"; fi ;;
|
|
5585
|
+
esac
|
|
5398
5586
|
if [ -n "${WEAVE_CODEX_STATUS_TITLE_FILE:-}" ]; then
|
|
5399
5587
|
printf '%s\n' "$title" >"$WEAVE_CODEX_STATUS_TITLE_FILE"
|
|
5400
5588
|
elif { [ -t 2 ] || [ "${async_title_enabled:-0}" = "1" ]; } && [ -w /dev/tty ]; then
|
|
@@ -5612,7 +5800,12 @@ read_codex_endpoint() {
|
|
|
5612
5800
|
sub(/^.*=[[:space:]]*"/, "", v); sub(/"$/, "", v)
|
|
5613
5801
|
if (key == "") key = v
|
|
5614
5802
|
}
|
|
5615
|
-
|
|
5803
|
+
match($0, /"?X-Weave-User-Email"?[[:space:]]*=[[:space:]]*"[^"]*"/) {
|
|
5804
|
+
v = substr($0, RSTART, RLENGTH)
|
|
5805
|
+
sub(/^.*=[[:space:]]*"/, "", v); sub(/"$/, "", v)
|
|
5806
|
+
if (email == "") email = v
|
|
5807
|
+
}
|
|
5808
|
+
END { if (url != "" && key != "") printf "%s\n%s\n%s\n", url, key, email }
|
|
5616
5809
|
' "$config" 2>/dev/null || true
|
|
5617
5810
|
}
|
|
5618
5811
|
|
|
@@ -5625,10 +5818,11 @@ refresh_session_cost() {
|
|
|
5625
5818
|
[ "${WEAVE_CODEX_STATUS_SAVINGS:-1}" = "0" ] && [ "${WEAVE_CODEX_STATUS_CONTEXT:-1}" = "0" ] && return 0
|
|
5626
5819
|
command -v curl >/dev/null 2>&1 || return 0
|
|
5627
5820
|
|
|
5628
|
-
local endpoint base_url key active_file state_lock
|
|
5821
|
+
local endpoint base_url key email active_file state_lock
|
|
5629
5822
|
endpoint="$(read_codex_endpoint)" || return 0
|
|
5630
5823
|
base_url="$(printf '%s' "$endpoint" | sed -n 1p)"
|
|
5631
5824
|
key="$(printf '%s' "$endpoint" | sed -n 2p)"
|
|
5825
|
+
email="$(printf '%s' "$endpoint" | sed -n 3p)"
|
|
5632
5826
|
[ -n "$base_url" ] && [ -n "$key" ] || return 0
|
|
5633
5827
|
|
|
5634
5828
|
mkdir -p "$state_root" 2>/dev/null || return 0
|
|
@@ -5661,7 +5855,8 @@ refresh_session_cost() {
|
|
|
5661
5855
|
esac
|
|
5662
5856
|
header_file="$(mktemp "$state_root/.headers.XXXXXX")" || exit 0
|
|
5663
5857
|
chmod 600 "$header_file"
|
|
5664
|
-
|
|
5858
|
+
write_display_headers "$header_file" "$key" "$email"
|
|
5859
|
+
refresh_display_settings "$base_url" "$header_file" 5
|
|
5665
5860
|
if ! body="$(curl -fsS --max-time 5 --max-filesize 8192 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
5666
5861
|
rm -f "$header_file"
|
|
5667
5862
|
exit 0
|
|
@@ -6289,6 +6484,7 @@ if [ "$target" = "codex" ]; then
|
|
|
6289
6484
|
ok "Codex config written to $codex_config_file"
|
|
6290
6485
|
remove_obsolete_codex_prompt_wrappers "$codex_dir/prompts"
|
|
6291
6486
|
install_codex_prompt_skills
|
|
6487
|
+
install_build_skill "$codex_dir/skills"
|
|
6292
6488
|
|
|
6293
6489
|
# Project scope: ensure the per-teammate config (which holds the router key)
|
|
6294
6490
|
# is gitignored. The base URL is the same for every teammate, so a
|
|
@@ -6318,11 +6514,7 @@ if [ "$target" = "codex" ]; then
|
|
|
6318
6514
|
# point CODEX_HOME at the directory we wrote so Codex finds our config.
|
|
6319
6515
|
info "Run Codex with CODEX_HOME=$codex_dir codex so it picks up this config."
|
|
6320
6516
|
fi
|
|
6321
|
-
|
|
6322
|
-
finish_install "Codex" env CODEX_HOME="$codex_dir" codex
|
|
6323
|
-
else
|
|
6324
|
-
finish_install "Codex" codex
|
|
6325
|
-
fi
|
|
6517
|
+
finish_install
|
|
6326
6518
|
exit 0
|
|
6327
6519
|
fi
|
|
6328
6520
|
|
|
@@ -7125,7 +7317,7 @@ weave_sync_commands 2>/dev/null || true
|
|
|
7125
7317
|
# responses can land out of order, and the loser's mv would replace a newer
|
|
7126
7318
|
# setting with an older one AND stamp it fresh, pinning the gate on a stale
|
|
7127
7319
|
# value for a full TTL. Refreshes are therefore serialized per cache key on a
|
|
7128
|
-
#
|
|
7320
|
+
# directory mutex (flock is absent on macOS), held across both
|
|
7129
7321
|
# the fetch and the write. A refresh that finds the mutex held exits rather
|
|
7130
7322
|
# than queueing — the in-flight one is at least as fresh as anything it would
|
|
7131
7323
|
# fetch, so waiting only to overwrite it is the bug. The one path that is not
|
|
@@ -7142,21 +7334,33 @@ weave_hidden_gate() {
|
|
|
7142
7334
|
local cache="$cache_dir/display-settings${script_slug}"
|
|
7143
7335
|
local ttl="${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-3600}"
|
|
7144
7336
|
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
local now mtime fresh="false"
|
|
7337
|
+
local grace="${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"
|
|
7338
|
+
local now mtime fresh="false" stale_hidden="false"
|
|
7149
7339
|
now="$(date +%s 2>/dev/null)" || now=0
|
|
7340
|
+
|
|
7341
|
+
# Linked plans that need a fresh login. Only a refresh within the TTL is
|
|
7342
|
+
# trusted: an older list may name a plan that has since recovered.
|
|
7343
|
+
weave_disconnected_plans=""
|
|
7344
|
+
if [ -f "$cache.plans" ]; then
|
|
7345
|
+
mtime="$(stat -c %Y "$cache.plans" 2>/dev/null || stat -f %m "$cache.plans" 2>/dev/null)" || mtime=0
|
|
7346
|
+
if [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$ttl" ]; then
|
|
7347
|
+
weave_disconnected_plans="$(cat "$cache.plans" 2>/dev/null)"
|
|
7348
|
+
fi
|
|
7349
|
+
fi
|
|
7150
7350
|
if [ -f "$cache" ]; then
|
|
7151
7351
|
mtime="$(stat -c %Y "$cache" 2>/dev/null || stat -f %m "$cache" 2>/dev/null)" || mtime=0
|
|
7152
7352
|
if [ -n "${mtime:-}" ] && [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$ttl" ]; then
|
|
7153
7353
|
fresh="true"
|
|
7354
|
+
elif [ -n "${mtime:-}" ] && [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$grace" ] \
|
|
7355
|
+
&& [ "$(cat "$cache" 2>/dev/null)" = "1" ]; then
|
|
7356
|
+
stale_hidden="true"
|
|
7154
7357
|
fi
|
|
7155
7358
|
fi
|
|
7156
7359
|
|
|
7157
|
-
# Foreground decision:
|
|
7158
|
-
#
|
|
7159
|
-
#
|
|
7360
|
+
# Foreground decision: a fresh cache decides. A hidden cache past the TTL
|
|
7361
|
+
# stays hidden for the grace period while it refreshes, so an hourly expiry
|
|
7362
|
+
# never flashes routing details to someone who must not see them. Anything
|
|
7363
|
+
# else renders normally so an unreachable router cannot wedge it blank.
|
|
7160
7364
|
if [ "$fresh" = "true" ]; then
|
|
7161
7365
|
[ "$(cat "$cache" 2>/dev/null)" = "1" ]
|
|
7162
7366
|
return
|
|
@@ -7176,10 +7380,9 @@ weave_hidden_gate() {
|
|
|
7176
7380
|
(
|
|
7177
7381
|
exec </dev/null
|
|
7178
7382
|
|
|
7179
|
-
# Take the per-cache-key mutex, or bail.
|
|
7180
|
-
#
|
|
7181
|
-
#
|
|
7182
|
-
# reclaimed. Releasing from a trap covers every exit path below.
|
|
7383
|
+
# Take the per-cache-key mutex, or bail. Old locks are reclaimed so a
|
|
7384
|
+
# crashed holder cannot block refreshes forever. Releasing from a trap
|
|
7385
|
+
# covers every exit path below.
|
|
7183
7386
|
lock="$cache.lock"
|
|
7184
7387
|
if ! mkdir "$lock" 2>/dev/null; then
|
|
7185
7388
|
lock_mtime="$(stat -c %Y "$lock" 2>/dev/null || stat -f %m "$lock" 2>/dev/null)" || lock_mtime=0
|
|
@@ -7203,7 +7406,10 @@ weave_hidden_gate() {
|
|
|
7203
7406
|
rm -rf "$dead" 2>/dev/null
|
|
7204
7407
|
mkdir "$lock" 2>/dev/null || exit 0
|
|
7205
7408
|
fi
|
|
7206
|
-
|
|
7409
|
+
# Some mkdir implementations return success to both racing creators.
|
|
7410
|
+
# Shell noclobber supplies the exclusive claim independently of mkdir.
|
|
7411
|
+
(set -C; : > "$lock/owner") 2>/dev/null || exit 0
|
|
7412
|
+
trap 'rm -f "$lock/owner"; rmdir "$lock" 2>/dev/null' EXIT
|
|
7207
7413
|
|
|
7208
7414
|
self_dir="$(cd "$(dirname "$self")" 2>/dev/null && pwd)"
|
|
7209
7415
|
settings_base="$HOME"
|
|
@@ -7220,6 +7426,9 @@ weave_hidden_gate() {
|
|
|
7220
7426
|
if [ -z "$key" ] && [ -f "$local_settings" ]; then
|
|
7221
7427
|
key="$(jq -r '.env.ANTHROPIC_CUSTOM_HEADERS // "" | split("\n")[] | select(startswith("X-Weave-Router-Key:")) | sub("^X-Weave-Router-Key:[[:space:]]*";"")' "$local_settings" 2>/dev/null | head -n1)"
|
|
7222
7428
|
fi
|
|
7429
|
+
if [ -z "$key" ] && [ -n "${ANTHROPIC_CUSTOM_HEADERS:-}" ]; then
|
|
7430
|
+
key="$(printf '%s\n' "$ANTHROPIC_CUSTOM_HEADERS" | sed -n 's/^X-Weave-Router-Key:[[:space:]]*\([A-Za-z0-9_-]*\)[[:space:]]*$/\1/p' | head -n1)"
|
|
7431
|
+
fi
|
|
7223
7432
|
if [ -z "$base_url" ] && [ -f "$settings" ]; then
|
|
7224
7433
|
base_url="$(jq -r '.env.ANTHROPIC_BASE_URL // empty' "$settings" 2>/dev/null)"
|
|
7225
7434
|
fi
|
|
@@ -7232,6 +7441,12 @@ weave_hidden_gate() {
|
|
|
7232
7441
|
header_file="$(mktemp "$cache_dir/.headers.XXXXXX")" || exit 0
|
|
7233
7442
|
chmod 600 "$header_file"
|
|
7234
7443
|
printf 'header = "X-Weave-Router-Key: %s"\n' "$key" >"$header_file"
|
|
7444
|
+
custom_headers="${ANTHROPIC_CUSTOM_HEADERS:-}"
|
|
7445
|
+
for f in "$settings" "$local_settings"; do
|
|
7446
|
+
[ -n "$custom_headers" ] || [ ! -f "$f" ] || custom_headers="$(jq -r '.env.ANTHROPIC_CUSTOM_HEADERS // ""' "$f" 2>/dev/null)"
|
|
7447
|
+
done
|
|
7448
|
+
printf '%s\n' "$custom_headers" | grep -E '^X-Weave-User-(Email|Name):[[:space:]]*[A-Za-z0-9@._+ -]+$' \
|
|
7449
|
+
| sed 's/^\(.*\)$/header = "\1"/' >>"$header_file" 2>/dev/null || true
|
|
7235
7450
|
if ! body="$(curl -fsS --max-time 5 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
7236
7451
|
rm -f "$header_file"
|
|
7237
7452
|
exit 0
|
|
@@ -7249,7 +7464,18 @@ weave_hidden_gate() {
|
|
|
7249
7464
|
rm -f "$tmp" 2>/dev/null
|
|
7250
7465
|
) >/dev/null 2>&1 &
|
|
7251
7466
|
disown 2>/dev/null || true
|
|
7252
|
-
|
|
7467
|
+
# A cold cache waits briefly for its first refresh so a subject whose
|
|
7468
|
+
# surfaces are hidden does not see one full render before the cache exists.
|
|
7469
|
+
if [ ! -f "$cache" ] && [ ! -f "$cache.cold-waited" ]; then
|
|
7470
|
+
: >"$cache.cold-waited" 2>/dev/null
|
|
7471
|
+
local tries="${WEAVE_DISPLAY_SETTINGS_COLD_WAIT_TENTHS:-20}"
|
|
7472
|
+
while [ "$tries" -gt 0 ] && [ ! -f "$cache" ]; do
|
|
7473
|
+
sleep 0.1 2>/dev/null || break
|
|
7474
|
+
tries=$(( tries - 1 ))
|
|
7475
|
+
done
|
|
7476
|
+
[ "$(cat "$cache" 2>/dev/null)" = "1" ] && return 0
|
|
7477
|
+
fi
|
|
7478
|
+
[ "$stale_hidden" = "true" ]
|
|
7253
7479
|
}
|
|
7254
7480
|
|
|
7255
7481
|
if weave_hidden_gate </dev/null; then
|
|
@@ -7295,8 +7521,10 @@ prices='{
|
|
|
7295
7521
|
"input": {
|
|
7296
7522
|
"claude-fable-5": 0.01,
|
|
7297
7523
|
"claude-fable-5-1": 0.01,
|
|
7524
|
+
"claude-fable-5-2": 0.008,
|
|
7298
7525
|
"claude-haiku-4-5": 0.001,
|
|
7299
7526
|
"claude-haiku-5-5": 0.0001,
|
|
7527
|
+
"claude-mythos-5-2": 0.008,
|
|
7300
7528
|
"claude-opus-4-0": 0.015,
|
|
7301
7529
|
"claude-opus-4-1": 0.015,
|
|
7302
7530
|
"claude-opus-4-5": 0.005,
|
|
@@ -7360,6 +7588,7 @@ prices='{
|
|
|
7360
7588
|
"grok-4.6": 0.002,
|
|
7361
7589
|
"grok-4.7": 0.002,
|
|
7362
7590
|
"inclusionai/ling-3.0-flash": 0.00006,
|
|
7591
|
+
"meta/muse-spark-open": 0.00125,
|
|
7363
7592
|
"minimax/minimax-m2.7": 0.0003,
|
|
7364
7593
|
"minimax/minimax-m3": 0.0003,
|
|
7365
7594
|
"minimax/minimax-m3.1-flash": 0.00015,
|
|
@@ -7369,7 +7598,9 @@ prices='{
|
|
|
7369
7598
|
"moonshotai/kimi-k2.7": 0.00095,
|
|
7370
7599
|
"moonshotai/kimi-k3": 0.003,
|
|
7371
7600
|
"moonshotai/kimi-k3.1": 0.002,
|
|
7601
|
+
"muse-ember-1.0": 0.0001,
|
|
7372
7602
|
"muse-spark-1.3": 0.00125,
|
|
7603
|
+
"muse-wonder-1.0": 0.004,
|
|
7373
7604
|
"qwen/qwen3-235b-a22b-2507": 0.0002266,
|
|
7374
7605
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.00015,
|
|
7375
7606
|
"qwen/qwen3-coder": 0.0009,
|
|
@@ -7391,8 +7622,10 @@ prices='{
|
|
|
7391
7622
|
"output": {
|
|
7392
7623
|
"claude-fable-5": 0.05,
|
|
7393
7624
|
"claude-fable-5-1": 0.05,
|
|
7625
|
+
"claude-fable-5-2": 0.04,
|
|
7394
7626
|
"claude-haiku-4-5": 0.005,
|
|
7395
7627
|
"claude-haiku-5-5": 0.0005,
|
|
7628
|
+
"claude-mythos-5-2": 0.04,
|
|
7396
7629
|
"claude-opus-4-0": 0.075,
|
|
7397
7630
|
"claude-opus-4-1": 0.075,
|
|
7398
7631
|
"claude-opus-4-5": 0.025,
|
|
@@ -7456,6 +7689,7 @@ prices='{
|
|
|
7456
7689
|
"grok-4.6": 0.006,
|
|
7457
7690
|
"grok-4.7": 0.006,
|
|
7458
7691
|
"inclusionai/ling-3.0-flash": 0.00018,
|
|
7692
|
+
"meta/muse-spark-open": 0.00425,
|
|
7459
7693
|
"minimax/minimax-m2.7": 0.0012,
|
|
7460
7694
|
"minimax/minimax-m3": 0.0012,
|
|
7461
7695
|
"minimax/minimax-m3.1-flash": 0.0006,
|
|
@@ -7465,7 +7699,9 @@ prices='{
|
|
|
7465
7699
|
"moonshotai/kimi-k2.7": 0.004,
|
|
7466
7700
|
"moonshotai/kimi-k3": 0.015,
|
|
7467
7701
|
"moonshotai/kimi-k3.1": 0.01,
|
|
7702
|
+
"muse-ember-1.0": 0.0005,
|
|
7468
7703
|
"muse-spark-1.3": 0.00425,
|
|
7704
|
+
"muse-wonder-1.0": 0.02,
|
|
7469
7705
|
"qwen/qwen3-235b-a22b-2507": 0.0009064,
|
|
7470
7706
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.0006,
|
|
7471
7707
|
"qwen/qwen3-coder": 0.0027,
|
|
@@ -7487,8 +7723,10 @@ prices='{
|
|
|
7487
7723
|
"cache_read": {
|
|
7488
7724
|
"claude-fable-5": 0.1,
|
|
7489
7725
|
"claude-fable-5-1": 0.025,
|
|
7726
|
+
"claude-fable-5-2": 0.025,
|
|
7490
7727
|
"claude-haiku-4-5": 0.1,
|
|
7491
7728
|
"claude-haiku-5-5": 0.1,
|
|
7729
|
+
"claude-mythos-5-2": 0.025,
|
|
7492
7730
|
"claude-opus-4-0": 0.1,
|
|
7493
7731
|
"claude-opus-4-1": 0.1,
|
|
7494
7732
|
"claude-opus-4-5": 0.1,
|
|
@@ -7500,7 +7738,7 @@ prices='{
|
|
|
7500
7738
|
"claude-sonnet-4-5": 0.1,
|
|
7501
7739
|
"claude-sonnet-4-6": 0.1,
|
|
7502
7740
|
"claude-sonnet-5": 0.1,
|
|
7503
|
-
"claude-sonnet-5-5": 0.
|
|
7741
|
+
"claude-sonnet-5-5": 0.05,
|
|
7504
7742
|
"deepseek/deepseek-v4-flash": 0.1,
|
|
7505
7743
|
"deepseek/deepseek-v4-pro": 0.0862,
|
|
7506
7744
|
"deepseek/deepseek-v4-pro-0813": 0.0862,
|
|
@@ -7552,6 +7790,7 @@ prices='{
|
|
|
7552
7790
|
"grok-4.6": 0.25,
|
|
7553
7791
|
"grok-4.7": 0.25,
|
|
7554
7792
|
"inclusionai/ling-3.0-flash": 0.2,
|
|
7793
|
+
"meta/muse-spark-open": 0.12,
|
|
7555
7794
|
"minimax/minimax-m2.7": 0.2,
|
|
7556
7795
|
"minimax/minimax-m3": 0.2,
|
|
7557
7796
|
"minimax/minimax-m3.1-flash": 0.1,
|
|
@@ -7561,7 +7800,9 @@ prices='{
|
|
|
7561
7800
|
"moonshotai/kimi-k2.7": 0.2,
|
|
7562
7801
|
"moonshotai/kimi-k3": 0.1,
|
|
7563
7802
|
"moonshotai/kimi-k3.1": 0.1,
|
|
7803
|
+
"muse-ember-1.0": 0.04,
|
|
7564
7804
|
"muse-spark-1.3": 0.12,
|
|
7805
|
+
"muse-wonder-1.0": 0.05,
|
|
7565
7806
|
"qwen/qwen3-235b-a22b-2507": 0.5,
|
|
7566
7807
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.1684,
|
|
7567
7808
|
"qwen/qwen3-coder": 0.1684,
|
|
@@ -7903,8 +8144,8 @@ if [ -n "${weave_disconnected_plans:-}" ]; then
|
|
|
7903
8144
|
fi
|
|
7904
8145
|
for weave_plan in ${weave_disconnected_plans:-}; do
|
|
7905
8146
|
case "$weave_plan" in
|
|
7906
|
-
claude) status_text="$status_text · Claude plan
|
|
7907
|
-
codex) status_text="$status_text · Codex plan
|
|
8147
|
+
claude) status_text="$status_text · Claude plan needs login: npx @weave-os/router login claude$weave_login_scope" ;;
|
|
8148
|
+
codex) status_text="$status_text · Codex plan needs login: npx @weave-os/router login codex$weave_login_scope" ;;
|
|
7908
8149
|
esac
|
|
7909
8150
|
done
|
|
7910
8151
|
|
|
@@ -7978,6 +8219,11 @@ write_claude_settings() {
|
|
|
7978
8219
|
# Setting ANTHROPIC_BASE_URL makes Claude Code treat us as non-first-party.
|
|
7979
8220
|
# Force tool-search deferral to match first-party Claude Code; "auto" can inline
|
|
7980
8221
|
# every tool schema when the custom endpoint advertises a 200K context window.
|
|
8222
|
+
# Auto mode's server-side classifier only returns verdicts on Anthropic-served
|
|
8223
|
+
# turns; the first routed non-Anthropic turn makes Claude Code fall back for
|
|
8224
|
+
# the session and hold an action behind a "gateway isn't compatible" notice.
|
|
8225
|
+
# Opt out up front so it uses its own classifier requests from the start.
|
|
8226
|
+
# Project scope keeps the opt-out in settings.local.json so `off` can drop it.
|
|
7981
8227
|
local prompt_hook_scope=""
|
|
7982
8228
|
if [ -n "$install_dir" ]; then
|
|
7983
8229
|
prompt_hook_scope=" --dir $(printf '%q' "$install_dir")"
|
|
@@ -7994,7 +8240,7 @@ write_claude_settings() {
|
|
|
7994
8240
|
hooks: {UserPromptSubmit: [{hooks: [{type: "command", command: ("[ ! -x \"" + $sl + "\" ] || \"" + $sl + "\" --prompt-hook" + $prompt_hook_scope)}]}]}} else {} end)' >"$tmp_patch"
|
|
7995
8241
|
else
|
|
7996
8242
|
jq -n --arg attribution "$attribution" --arg url "$base_url" --arg header "$custom_headers" --arg sl "$statusline_path_for_settings" --arg prompt_hook_scope "$prompt_hook_scope" --arg statusline_install "$statusline_install" '{
|
|
7997
|
-
env: { ANTHROPIC_BASE_URL: $url, ANTHROPIC_CUSTOM_HEADERS: $header, ENABLE_TOOL_SEARCH: "true" }
|
|
8243
|
+
env: { ANTHROPIC_BASE_URL: $url, ANTHROPIC_CUSTOM_HEADERS: $header, ENABLE_TOOL_SEARCH: "true", CLAUDE_CODE_AUTO_MODE_SERVER: "0" }
|
|
7998
8244
|
} + (if $attribution == "true" then {attribution: {
|
|
7999
8245
|
commit: "Co-Authored-By: Weave Router <router@weaveos.com>",
|
|
8000
8246
|
pr: "🤖 Generated with [Weave Router](https://router.weaveos.com)"
|
|
@@ -8043,7 +8289,7 @@ write_claude_settings() {
|
|
|
8043
8289
|
|
|
8044
8290
|
if [ "$scope" = "project" ] && [ -z "$install_dir" ]; then
|
|
8045
8291
|
jq -n --arg header "$custom_headers" --arg router_url "$base_url" '{
|
|
8046
|
-
env: { ANTHROPIC_CUSTOM_HEADERS: $header, WEAVE_ROUTER_BASE_URL: $router_url }
|
|
8292
|
+
env: { ANTHROPIC_CUSTOM_HEADERS: $header, WEAVE_ROUTER_BASE_URL: $router_url, CLAUDE_CODE_AUTO_MODE_SERVER: "0" }
|
|
8047
8293
|
}' >"$tmp_patch"
|
|
8048
8294
|
if [ -f "$local_settings_file" ]; then
|
|
8049
8295
|
# Also strip ANTHROPIC_BASE_URL: `off` in project scope points this file
|
|
@@ -8096,6 +8342,7 @@ fi
|
|
|
8096
8342
|
|
|
8097
8343
|
# Slash command wrappers — see install_slash_commands() below for the why.
|
|
8098
8344
|
install_slash_commands "$settings_dir/commands"
|
|
8345
|
+
install_build_skill "$settings_dir/skills" "$settings_dir/agents"
|
|
8099
8346
|
|
|
8100
8347
|
# ---------- gitignore for project scope ----------
|
|
8101
8348
|
|
|
@@ -8128,4 +8375,4 @@ verify_install
|
|
|
8128
8375
|
# ---------- done ----------
|
|
8129
8376
|
|
|
8130
8377
|
announce_done "Claude Code"
|
|
8131
|
-
finish_install
|
|
8378
|
+
finish_install
|