@weave-os/router 0.2.36 → 0.2.38
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/bin.js +1 -1
- package/cc-statusline.sh +58 -11
- 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/desktop-shim.js +45 -0
- package/directives.tsv +1 -0
- package/install.sh +384 -85
- package/package.json +2 -1
- 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 +131 -74
- package/windows.js +3 -2
package/install.sh
CHANGED
|
@@ -248,27 +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. It
|
|
254
|
-
# inherits the terminal stdin: Bun-based clients crash with EINVAL on macOS
|
|
255
|
-
# when stdin is /dev/tty, which kqueue can't watch.
|
|
256
|
-
offer_launch() {
|
|
257
|
-
local label="$1"; shift
|
|
258
|
-
[ "${WEAVE_SETUP_DEFER_LAUNCH:-}" != "1" ] && [ "$non_interactive" = "false" ] && [ "$quiet" != "true" ] \
|
|
259
|
-
&& [ -t 0 ] && [ -t 1 ] && command -v "${!#}" >/dev/null 2>&1 || return 0
|
|
260
|
-
local answer=""
|
|
261
|
-
printf "\n%sStart %s now?%s [Y/n] " "$C_BOLD" "$label" "$C_RESET" >/dev/tty
|
|
262
|
-
read -r answer </dev/tty || answer="n"
|
|
263
|
-
case "$answer" in
|
|
264
|
-
""|y|Y|yes|Yes) ;;
|
|
265
|
-
*) return 0 ;;
|
|
266
|
-
esac
|
|
267
|
-
local launch_status=0
|
|
268
|
-
"$@" || launch_status=$?
|
|
269
|
-
exit "$launch_status"
|
|
270
|
-
}
|
|
271
|
-
|
|
272
251
|
# ---------- banner ----------
|
|
273
252
|
#
|
|
274
253
|
# Print the WEAVE wordmark in brand orange. Skipped under --quiet or when
|
|
@@ -623,8 +602,8 @@ normalize_name() {
|
|
|
623
602
|
|
|
624
603
|
# resolve_user_email picks the email to plant in router request headers so the
|
|
625
604
|
# router can attribute traffic to a person even on shared API keys. Priority:
|
|
626
|
-
# explicit --email → WEAVE_USER_EMAIL env override →
|
|
627
|
-
# interactive prompt (pre-filled with whatever we found). In --non-interactive
|
|
605
|
+
# explicit --email → WEAVE_USER_EMAIL env override → the email already installed
|
|
606
|
+
# for this target → git config user.email → interactive prompt (pre-filled with whatever we found). In --non-interactive
|
|
628
607
|
# mode we never prompt, so unset/invalid means we ship no header (router treats
|
|
629
608
|
# that as account_uuid-only, same as today). Echoes the validated email on stdout.
|
|
630
609
|
resolve_user_email() {
|
|
@@ -647,6 +626,9 @@ resolve_user_email() {
|
|
|
647
626
|
warn "WEAVE_USER_EMAIL=\"$WEAVE_USER_EMAIL\" is not a valid email; ignoring."
|
|
648
627
|
fi
|
|
649
628
|
fi
|
|
629
|
+
if [ -z "$candidate" ]; then
|
|
630
|
+
candidate="$(normalize_email "$(read_installed_header X-Weave-User-Email)")"
|
|
631
|
+
fi
|
|
650
632
|
if [ -z "$candidate" ]; then
|
|
651
633
|
local git_email
|
|
652
634
|
git_email="$(git config --global user.email 2>/dev/null || true)"
|
|
@@ -1345,9 +1327,10 @@ write_pi_models_config() {
|
|
|
1345
1327
|
| (if $name != "" then . + {"X-Weave-User-Name": $name } else . end)
|
|
1346
1328
|
')"
|
|
1347
1329
|
|
|
1348
|
-
#
|
|
1349
|
-
#
|
|
1350
|
-
# sync with
|
|
1330
|
+
# One "Weave Router" entry: the router picks the served model per request
|
|
1331
|
+
# from the organization's enabled models, so listing concrete models only
|
|
1332
|
+
# advertised choices pi never honored. Keep in sync with WEAVE_MODELS in
|
|
1333
|
+
# pi-router/src/config.ts, which replaces this list whenever the extension loads.
|
|
1351
1334
|
#
|
|
1352
1335
|
# baseUrl is the router ROOT (no /v1): pi's anthropic-messages provider uses
|
|
1353
1336
|
# @anthropic-ai/sdk, which appends /v1/messages itself. Unlike the codex block
|
|
@@ -1365,24 +1348,7 @@ write_pi_models_config() {
|
|
|
1365
1348
|
authHeader: false,
|
|
1366
1349
|
headers: $headers,
|
|
1367
1350
|
models: [
|
|
1368
|
-
{ id: "
|
|
1369
|
-
{ id: "claude-fable-5", name: "Claude Fable 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1370
|
-
{ id: "claude-opus-5-5", name: "Claude Opus 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1371
|
-
{ id: "claude-opus-5", name: "Claude Opus 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1372
|
-
{ id: "claude-sonnet-5-5", name: "Claude Sonnet 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1373
|
-
{ id: "claude-opus-4-7", name: "Claude Opus 4.7 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
|
|
1374
|
-
{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
|
|
1375
|
-
{ id: "claude-haiku-5-5", name: "Claude Haiku 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1376
|
-
{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 200000, maxTokens: 32000 },
|
|
1377
|
-
{ id: "gpt-6-astra", name: "GPT-6 Astra (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1378
|
-
{ id: "gpt-6-sol", name: "GPT-6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1379
|
-
{ id: "gpt-6.1-sol", name: "GPT-6.1 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1380
|
-
{ id: "gpt-6.1-terra", name: "GPT-6.1 Terra (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1381
|
-
{ id: "gpt-6-luna", name: "GPT-6 Luna (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1382
|
-
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1383
|
-
{ id: "grok-4.5", name: "Grok 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
|
|
1384
|
-
{ id: "grok-4.6", name: "Grok 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
|
|
1385
|
-
{ id: "grok-4.7", name: "Grok 4.7 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 }
|
|
1351
|
+
{ id: "auto", name: "Weave Router", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 }
|
|
1386
1352
|
]
|
|
1387
1353
|
}
|
|
1388
1354
|
')"
|
|
@@ -1400,10 +1366,11 @@ write_pi_models_config() {
|
|
|
1400
1366
|
chmod 600 "$config_file"
|
|
1401
1367
|
}
|
|
1402
1368
|
|
|
1403
|
-
# write_pi_settings_config makes
|
|
1404
|
-
#
|
|
1405
|
-
#
|
|
1406
|
-
#
|
|
1369
|
+
# write_pi_settings_config makes `weave/auto` pi's default and loads the npm
|
|
1370
|
+
# package named by $npm_package_name. defaultProvider is always set to "weave" —
|
|
1371
|
+
# the installer's job is to route via Weave; uninstall reverts it. defaultModel
|
|
1372
|
+
# is always "auto": it is the provider's only model, so any other value would
|
|
1373
|
+
# make pi fall back to a different provider. The
|
|
1407
1374
|
# npm package source is appended to `packages` idempotently — pi auto-installs
|
|
1408
1375
|
# missing packages on startup — and every known prior Weave package id
|
|
1409
1376
|
# (`@workweave/pi-router`, `@workweave/router`, `@weave-os/router`) except the
|
|
@@ -1424,12 +1391,12 @@ write_pi_settings_config() {
|
|
|
1424
1391
|
))
|
|
1425
1392
|
| (if (.packages | index($pkg)) then . else .packages += [$pkg] end)
|
|
1426
1393
|
| .defaultProvider = "weave"
|
|
1427
|
-
|
|
|
1394
|
+
| .defaultModel = "auto"
|
|
1428
1395
|
' "$settings_file")"
|
|
1429
1396
|
else
|
|
1430
1397
|
merged="$(jq -n --arg pkg "$pkg" '{
|
|
1431
1398
|
defaultProvider: "weave",
|
|
1432
|
-
defaultModel: "
|
|
1399
|
+
defaultModel: "auto",
|
|
1433
1400
|
packages: [$pkg]
|
|
1434
1401
|
}')"
|
|
1435
1402
|
fi
|
|
@@ -1500,10 +1467,10 @@ install_lsp_servers() {
|
|
|
1500
1467
|
}
|
|
1501
1468
|
|
|
1502
1469
|
# resolve_user_name mirrors resolve_user_email but for display name. Priority:
|
|
1503
|
-
# WEAVE_USER_NAME env override → git config user.name →
|
|
1504
|
-
# prompt for name independently: if email prompting yielded
|
|
1505
|
-
# almost certainly will too, and a second prompt is noise. Echoes
|
|
1506
|
-
# validated name on stdout.
|
|
1470
|
+
# WEAVE_USER_NAME env override → installed name → git config user.name →
|
|
1471
|
+
# empty. We don't prompt for name independently: if email prompting yielded
|
|
1472
|
+
# nothing, name almost certainly will too, and a second prompt is noise. Echoes
|
|
1473
|
+
# the validated name on stdout.
|
|
1507
1474
|
resolve_user_name() {
|
|
1508
1475
|
local candidate=""
|
|
1509
1476
|
if [ -n "${WEAVE_USER_NAME:-}" ]; then
|
|
@@ -1512,6 +1479,9 @@ resolve_user_name() {
|
|
|
1512
1479
|
warn "WEAVE_USER_NAME=\"$WEAVE_USER_NAME\" is not a usable name; ignoring."
|
|
1513
1480
|
fi
|
|
1514
1481
|
fi
|
|
1482
|
+
if [ -z "$candidate" ]; then
|
|
1483
|
+
candidate="$(normalize_name "$(read_installed_header X-Weave-User-Name)")"
|
|
1484
|
+
fi
|
|
1515
1485
|
if [ -z "$candidate" ]; then
|
|
1516
1486
|
local git_name
|
|
1517
1487
|
git_name="$(git config --global user.name 2>/dev/null || true)"
|
|
@@ -1602,7 +1572,7 @@ set_copilot_default_model() {
|
|
|
1602
1572
|
# are reused with the sigil and client names rewritten. Codex-only toggles and
|
|
1603
1573
|
# skills that depend on Codex session state are excluded.
|
|
1604
1574
|
copilot_skill_names() {
|
|
1605
|
-
weave_registry_skill_assets codex | grep -vxE 'disable-routing|router-session|router-models|models' || true
|
|
1575
|
+
weave_registry_skill_assets codex | grep -vxE 'disable-routing|router-session|list-models|router-models|models' || true
|
|
1606
1576
|
}
|
|
1607
1577
|
|
|
1608
1578
|
# install_copilot_skills installs each router directive as a Copilot skill.
|
|
@@ -1890,7 +1860,7 @@ if [ "$mode" = "setup" ]; then
|
|
|
1890
1860
|
chmod 600 "$setup_handoff"
|
|
1891
1861
|
fi
|
|
1892
1862
|
if [ "$setup_claude" = "true" ]; then
|
|
1893
|
-
WEAVE_SETUP_HANDOFF_FILE="$setup_handoff"
|
|
1863
|
+
WEAVE_SETUP_HANDOFF_FILE="$setup_handoff" bash "$0" "${setup_args[@]}" --claude \
|
|
1894
1864
|
|| { setup_status=$?; [ -z "$setup_handoff" ] || rm -f "$setup_handoff"; exit "$setup_status"; }
|
|
1895
1865
|
fi
|
|
1896
1866
|
if [ -n "$setup_handoff" ]; then
|
|
@@ -1902,10 +1872,9 @@ if [ "$mode" = "setup" ]; then
|
|
|
1902
1872
|
fi
|
|
1903
1873
|
if [ "$setup_codex" = "true" ]; then
|
|
1904
1874
|
WEAVE_SETUP_SHARED_KEY="$shared_key" WEAVE_SETUP_SHARED_EMAIL="$shared_email" \
|
|
1905
|
-
WEAVE_SETUP_IDENTITY_RESOLVED="$identity_resolved"
|
|
1875
|
+
WEAVE_SETUP_IDENTITY_RESOLVED="$identity_resolved" \
|
|
1906
1876
|
bash "$0" "${setup_args[@]}" --codex
|
|
1907
1877
|
fi
|
|
1908
|
-
[ -z "$shared_key" ] || [ -n "$install_dir" ] || offer_launch "Claude Code" claude
|
|
1909
1878
|
exit 0
|
|
1910
1879
|
fi
|
|
1911
1880
|
|
|
@@ -2259,6 +2228,7 @@ router-off||local-toggle|yes|yes|no|no|manual|command,skill
|
|
|
2259
2228
|
router-on||local-toggle|yes|yes|no|no|manual|command,skill
|
|
2260
2229
|
router-status||local-toggle|yes|yes|no|no|manual|command,skill
|
|
2261
2230
|
router-session||prompt|yes|yes|no|no|manual|command,skill
|
|
2231
|
+
list-models||prompt|yes|yes|no|no|manual|command,skill
|
|
2262
2232
|
router-models|models|local-toggle|yes|yes|no|no|manual|command,skill
|
|
2263
2233
|
disable-routing||local-toggle|no|yes|no|no|manual|skill
|
|
2264
2234
|
beta||prompt|yes|no|no|yes|manual|command
|
|
@@ -2775,6 +2745,61 @@ read_installed_key() {
|
|
|
2775
2745
|
esac
|
|
2776
2746
|
}
|
|
2777
2747
|
|
|
2748
|
+
# read_installed_header prints the value of identity header $1 (for example
|
|
2749
|
+
# X-Weave-User-Email) from this target's managed config, or nothing. Reading it
|
|
2750
|
+
# back keeps a re-run or `update` from dropping the identity an earlier install
|
|
2751
|
+
# planted when nothing else on the machine (git config, env) supplies one.
|
|
2752
|
+
read_installed_header() {
|
|
2753
|
+
local header="$1" candidate value=""
|
|
2754
|
+
case "$target" in
|
|
2755
|
+
claude)
|
|
2756
|
+
while IFS= read -r candidate; do
|
|
2757
|
+
[ -n "$candidate" ] || continue
|
|
2758
|
+
value="$(json_get "$candidate" '.env.ANTHROPIC_CUSTOM_HEADERS' \
|
|
2759
|
+
| sed -n "s/^[[:space:]]*${header}:[[:space:]]*//p" | head -n 1)"
|
|
2760
|
+
[ -n "$value" ] && break
|
|
2761
|
+
done <<<"$(models_key_file_order)"
|
|
2762
|
+
;;
|
|
2763
|
+
codex)
|
|
2764
|
+
key_source_is_own "$codex_config_file" || return 0
|
|
2765
|
+
value="$(awk -v header="$header" '
|
|
2766
|
+
/^[[:space:]]*\[/ {
|
|
2767
|
+
in_provider = ($0 ~ /^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*(\.[^]]*)?\][[:space:]]*(#.*)?$/)
|
|
2768
|
+
next
|
|
2769
|
+
}
|
|
2770
|
+
in_provider && match($0, "\"?" header "\"?[[:space:]]*=[[:space:]]*\"([^\"\\\\]|\\\\.)*\"") {
|
|
2771
|
+
hdr = substr($0, RSTART, RLENGTH)
|
|
2772
|
+
sub(/^[^=]*=[[:space:]]*"/, "", hdr)
|
|
2773
|
+
sub(/"$/, "", hdr)
|
|
2774
|
+
# Undo toml_escape so the writer does not escape the value twice.
|
|
2775
|
+
value = ""
|
|
2776
|
+
for (i = 1; i <= length(hdr); i++) {
|
|
2777
|
+
c = substr(hdr, i, 1)
|
|
2778
|
+
if (c == "\\") { i++; c = substr(hdr, i, 1) }
|
|
2779
|
+
value = value c
|
|
2780
|
+
}
|
|
2781
|
+
print value
|
|
2782
|
+
exit
|
|
2783
|
+
}
|
|
2784
|
+
' "$codex_config_file" 2>/dev/null || true)"
|
|
2785
|
+
;;
|
|
2786
|
+
opencode)
|
|
2787
|
+
key_source_is_own "$opencode_config_file" || return 0
|
|
2788
|
+
value="$(json_get "$opencode_config_file" ".provider.weave.options.headers[\"$header\"]")"
|
|
2789
|
+
;;
|
|
2790
|
+
pi)
|
|
2791
|
+
key_source_is_own "$pi_models_file" || return 0
|
|
2792
|
+
value="$(json_get "$pi_models_file" ".providers.weave.headers[\"$header\"]")"
|
|
2793
|
+
;;
|
|
2794
|
+
copilot)
|
|
2795
|
+
key_source_is_own "$copilot_providers_file" || return 0
|
|
2796
|
+
value="$(jq -r --arg h "$header" '[(.providers // [])[] | select(.name == "weave") | .headers[$h] // empty][0] // empty' \
|
|
2797
|
+
"$copilot_providers_file" 2>/dev/null || true)"
|
|
2798
|
+
;;
|
|
2799
|
+
esac
|
|
2800
|
+
printf '%s' "$value"
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2778
2803
|
# resolve_installed_base_url prints the router endpoint this Claude Code install
|
|
2779
2804
|
# already points at, or nothing when none of its files carry a router-shaped
|
|
2780
2805
|
# one. The parked sidecar comes first: `off` moves the router URL there and
|
|
@@ -3093,7 +3118,7 @@ prepare_claude_context_window() {
|
|
|
3093
3118
|
model="${model:-sonnet}"
|
|
3094
3119
|
case "$model" in
|
|
3095
3120
|
*'[1m]') context_window=""; return 0 ;;
|
|
3096
|
-
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) ;;
|
|
3121
|
+
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) ;;
|
|
3097
3122
|
*) err "Cannot assert 1M support for '$model'. Select a supported Sonnet/Opus/Fable model first; leaving it unchanged."; return 1 ;;
|
|
3098
3123
|
esac
|
|
3099
3124
|
context_managed_model="${model}[1m]"
|
|
@@ -3566,9 +3591,11 @@ toggle_copilot() {
|
|
|
3566
3591
|
# refusal naming the dashboard.
|
|
3567
3592
|
|
|
3568
3593
|
# Public, unauthed catalog of everything the router can route to. Mounted in
|
|
3569
|
-
# both deployment modes, so it is the one listing that always works.
|
|
3570
|
-
|
|
3571
|
-
|
|
3594
|
+
# both deployment modes, so it is the one listing that always works. The scope
|
|
3595
|
+
# is explicit because the unscoped listing is a serving roster, which a managed
|
|
3596
|
+
# router cannot resolve without an admitted request.
|
|
3597
|
+
MODELS_CATALOG_PATH="/v1/router/models?scope=catalog"
|
|
3598
|
+
MODELS_DASHBOARD_URL="https://app.weaveos.com/organization/settings/weave-router/models"
|
|
3572
3599
|
|
|
3573
3600
|
# Set by models_api on every call.
|
|
3574
3601
|
models_http_status=""
|
|
@@ -4077,9 +4104,41 @@ run_login_claude() {
|
|
|
4077
4104
|
external_account_id="${account_uuid}:${organization_uuid}"
|
|
4078
4105
|
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')"
|
|
4079
4106
|
models_api POST "/v1/subscriptions/accounts" "$body" || models_fail "enrolling Claude subscription"
|
|
4107
|
+
forget_plan_warning claude
|
|
4080
4108
|
ok "Claude subscription enrolled."
|
|
4081
4109
|
}
|
|
4082
4110
|
|
|
4111
|
+
# A new login supersedes the statusline's cached "needs login" warning for
|
|
4112
|
+
# that provider in every install, without waiting for the next refresh. Each
|
|
4113
|
+
# edit holds the refresh's lock, so a fetch that predates the login cannot
|
|
4114
|
+
# land afterwards, and keeps the file's mtime, so the remaining providers'
|
|
4115
|
+
# warnings expire on their own schedule.
|
|
4116
|
+
forget_plan_warning() {
|
|
4117
|
+
local provider="$1" file lock plans owned tries
|
|
4118
|
+
for file in "${XDG_CACHE_HOME:-$HOME/.cache}"/weave-router/display-settings*.plans; do
|
|
4119
|
+
[ -f "$file" ] || continue
|
|
4120
|
+
lock="${file%.plans}.lock"
|
|
4121
|
+
owned=false tries=0
|
|
4122
|
+
while [ "$tries" -lt 10 ]; do
|
|
4123
|
+
if mkdir "$lock" 2>/dev/null; then owned=true; break; fi
|
|
4124
|
+
tries=$((tries + 1))
|
|
4125
|
+
sleep 1
|
|
4126
|
+
done
|
|
4127
|
+
plans="$(cat "$file" 2>/dev/null)"
|
|
4128
|
+
case " $plans " in
|
|
4129
|
+
*" $provider "*)
|
|
4130
|
+
plans="$(printf '%s' "$plans" | tr ' ' '\n' | grep -vx -- "$provider" | tr '\n' ' ' | sed 's/ *$//')" || true
|
|
4131
|
+
printf '%s' "$plans" >"$file.tmp.$$" 2>/dev/null \
|
|
4132
|
+
&& touch -r "$file" "$file.tmp.$$" 2>/dev/null \
|
|
4133
|
+
&& mv "$file.tmp.$$" "$file" 2>/dev/null
|
|
4134
|
+
rm -f "$file.tmp.$$" 2>/dev/null
|
|
4135
|
+
;;
|
|
4136
|
+
esac
|
|
4137
|
+
[ "$owned" = false ] || rmdir "$lock" 2>/dev/null
|
|
4138
|
+
done
|
|
4139
|
+
return 0
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4083
4142
|
run_login_codex() {
|
|
4084
4143
|
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
|
|
4085
4144
|
issuer="${WEAVE_CODEX_OAUTH_ISSUER:-https://auth.openai.com}"
|
|
@@ -4123,6 +4182,7 @@ run_login_codex() {
|
|
|
4123
4182
|
fi
|
|
4124
4183
|
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')"
|
|
4125
4184
|
models_api POST "/v1/subscriptions/accounts" "$body" || models_fail "enrolling Codex subscription"
|
|
4185
|
+
forget_plan_warning codex
|
|
4126
4186
|
ok "Codex subscription enrolled."
|
|
4127
4187
|
}
|
|
4128
4188
|
|
|
@@ -4813,7 +4873,7 @@ install_slash_commands() {
|
|
|
4813
4873
|
while IFS= read -r cmd; do
|
|
4814
4874
|
[ -f "$commands_src_dir/$cmd.md" ] || continue
|
|
4815
4875
|
case ",$cmd," in
|
|
4816
|
-
*,router-off,*|*,router-on,*|*,router-status,*|*,router-session,*|*,router-models,*|*,models,*)
|
|
4876
|
+
*,router-off,*|*,router-on,*|*,router-status,*|*,router-session,*|*,list-models,*|*,router-models,*|*,models,*)
|
|
4817
4877
|
[ "$target" = "claude" ] || continue ;;
|
|
4818
4878
|
esac
|
|
4819
4879
|
[ -n "$cmds" ] && cmds="$cmds "
|
|
@@ -5013,6 +5073,110 @@ $(weave_registry_skill_assets codex)
|
|
|
5013
5073
|
EOF
|
|
5014
5074
|
}
|
|
5015
5075
|
|
|
5076
|
+
# The build workflow skill is a resource tree (SKILL.md, references, scripts)
|
|
5077
|
+
# plus Claude Code agent definitions, so it is copied whole rather than through
|
|
5078
|
+
# the directive registry. It ships with the packaged installer and repo
|
|
5079
|
+
# checkouts; a standalone `curl | sh` install has no copy and skips it.
|
|
5080
|
+
build_skill_marker="<!-- weave-router managed build skill -->"
|
|
5081
|
+
build_skill_manifest=".weave-router-files"
|
|
5082
|
+
|
|
5083
|
+
build_skill_source_dir() {
|
|
5084
|
+
local candidate
|
|
5085
|
+
for candidate in "$script_dir/skills/build" "$script_dir/../skills/build"; do
|
|
5086
|
+
[ -f "$candidate/SKILL.md" ] || continue
|
|
5087
|
+
printf '%s' "$candidate"
|
|
5088
|
+
return 0
|
|
5089
|
+
done
|
|
5090
|
+
return 1
|
|
5091
|
+
}
|
|
5092
|
+
|
|
5093
|
+
# build_skill_entry_has_symlink reports whether any component of a manifest entry under the
|
|
5094
|
+
# skill dir is a symlink, so cleanup never follows a link out of the skill.
|
|
5095
|
+
build_skill_entry_has_symlink() {
|
|
5096
|
+
local path="$1" rel="$2"
|
|
5097
|
+
while [ -n "$rel" ]; do
|
|
5098
|
+
path="$path/${rel%%/*}"
|
|
5099
|
+
[ -L "$path" ] && return 0
|
|
5100
|
+
case "$rel" in */*) rel="${rel#*/}" ;; *) rel="" ;; esac
|
|
5101
|
+
done
|
|
5102
|
+
return 1
|
|
5103
|
+
}
|
|
5104
|
+
|
|
5105
|
+
# remove_build_skill_files deletes the files a previous install recorded in
|
|
5106
|
+
# the manifest, leaving anything the user added beside them.
|
|
5107
|
+
remove_build_skill_files() {
|
|
5108
|
+
local skill_dir="$1" rel
|
|
5109
|
+
if [ -L "$skill_dir/$build_skill_manifest" ]; then
|
|
5110
|
+
rm -f "$skill_dir/$build_skill_manifest"
|
|
5111
|
+
return 0
|
|
5112
|
+
fi
|
|
5113
|
+
[ -f "$skill_dir/$build_skill_manifest" ] || return 0
|
|
5114
|
+
while IFS= read -r rel; do
|
|
5115
|
+
case "$rel" in ""|/*|*..*) continue ;; esac
|
|
5116
|
+
if build_skill_entry_has_symlink "$skill_dir" "$rel"; then continue; fi
|
|
5117
|
+
rm -f "$skill_dir/$rel"
|
|
5118
|
+
done <"$skill_dir/$build_skill_manifest"
|
|
5119
|
+
rm -f "$skill_dir/$build_skill_manifest"
|
|
5120
|
+
rmdir "$skill_dir/references" "$skill_dir/scripts" 2>/dev/null || true
|
|
5121
|
+
}
|
|
5122
|
+
|
|
5123
|
+
install_build_skill() {
|
|
5124
|
+
local skills_dir="$1" agents_dir="${2:-}" src dst rel name agent_src agent_dst
|
|
5125
|
+
src="$(build_skill_source_dir)" || return 0
|
|
5126
|
+
dst="$skills_dir/build"
|
|
5127
|
+
if [ "$scope" = "project" ] || [ -n "$install_dir" ]; then
|
|
5128
|
+
refuse_if_symlink "$skills_dir"
|
|
5129
|
+
refuse_if_symlink "$dst"
|
|
5130
|
+
elif [ -L "$skills_dir" ] || [ -L "$dst" ]; then
|
|
5131
|
+
warn "Build skill path contains a symlink; leaving the build skill untouched."
|
|
5132
|
+
return 0
|
|
5133
|
+
fi
|
|
5134
|
+
if [ -e "$dst/SKILL.md" ] && { [ ! -f "$dst/SKILL.md" ] || ! grep -Fq "$build_skill_marker" "$dst/SKILL.md"; }; then
|
|
5135
|
+
warn "A user-owned build skill already exists at $dst; leaving it untouched."
|
|
5136
|
+
return 0
|
|
5137
|
+
fi
|
|
5138
|
+
remove_build_skill_files "$dst"
|
|
5139
|
+
mkdir -p "$dst"
|
|
5140
|
+
: >"$dst/$build_skill_manifest"
|
|
5141
|
+
while IFS= read -r rel; do
|
|
5142
|
+
if [ -L "$dst/$(dirname "$rel")" ] || [ -L "$dst/$rel" ]; then
|
|
5143
|
+
warn "Build skill file $dst/$rel is a symlink; leaving it untouched."
|
|
5144
|
+
continue
|
|
5145
|
+
fi
|
|
5146
|
+
mkdir -p "$dst/$(dirname "$rel")"
|
|
5147
|
+
cp "$src/$rel" "$dst/$rel"
|
|
5148
|
+
printf '%s\n' "$rel" >>"$dst/$build_skill_manifest"
|
|
5149
|
+
done <<EOS
|
|
5150
|
+
$(cd "$src" && find . -type f ! -path './agents/*' | sed 's#^\./##' | LC_ALL=C sort)
|
|
5151
|
+
EOS
|
|
5152
|
+
if [ ! -L "$dst/scripts" ] && [ ! -L "$dst/scripts/pin-coordinator.sh" ]; then
|
|
5153
|
+
chmod +x "$dst/scripts/pin-coordinator.sh"
|
|
5154
|
+
fi
|
|
5155
|
+
|
|
5156
|
+
if [ -n "$agents_dir" ] && [ -d "$src/agents" ]; then
|
|
5157
|
+
if [ "$scope" = "project" ] || [ -n "$install_dir" ]; then
|
|
5158
|
+
refuse_if_symlink "$agents_dir"
|
|
5159
|
+
elif [ -L "$agents_dir" ]; then
|
|
5160
|
+
warn "$agents_dir is a symlink; leaving build agents untouched."
|
|
5161
|
+
agents_dir=""
|
|
5162
|
+
fi
|
|
5163
|
+
fi
|
|
5164
|
+
if [ -n "$agents_dir" ] && [ -d "$src/agents" ]; then
|
|
5165
|
+
mkdir -p "$agents_dir"
|
|
5166
|
+
for agent_src in "$src"/agents/*.md; do
|
|
5167
|
+
[ -f "$agent_src" ] || continue
|
|
5168
|
+
name="$(basename "$agent_src" .md)"
|
|
5169
|
+
agent_dst="$agents_dir/$name.md"
|
|
5170
|
+
if [ -L "$agent_dst" ] || { [ -e "$agent_dst" ] && ! grep -Fq "<!-- weave-router managed agent: $name -->" "$agent_dst"; }; then
|
|
5171
|
+
warn "A user-owned agent already exists at $agent_dst; leaving it untouched."
|
|
5172
|
+
continue
|
|
5173
|
+
fi
|
|
5174
|
+
cp "$agent_src" "$agent_dst"
|
|
5175
|
+
done
|
|
5176
|
+
fi
|
|
5177
|
+
ok "Build skill installed at $dst"
|
|
5178
|
+
}
|
|
5179
|
+
|
|
5016
5180
|
# ---------- post-install verification (shared by every target) ----------
|
|
5017
5181
|
#
|
|
5018
5182
|
# Every client gets the same two probes — reach the router, then prove the key
|
|
@@ -5219,7 +5383,6 @@ print_next_steps() {
|
|
|
5219
5383
|
# finish_install closes a Claude Code or Codex run. Only a working first install
|
|
5220
5384
|
# gets onboarding; a failed check or an update must not invite the user in.
|
|
5221
5385
|
finish_install() {
|
|
5222
|
-
local label="$1"; shift
|
|
5223
5386
|
if [ "$mode" = "install" ] && [ "$quiet" != "true" ] && [ -z "$install_dir" ] && [ "$key_verdict" = "valid" ]; then
|
|
5224
5387
|
local pkg="npx $npm_package_name" flags="--$target" feedback="type /rf <what happened> in Claude Code"
|
|
5225
5388
|
[ "$scope" = "project" ] && flags="$flags --scope project"
|
|
@@ -5231,7 +5394,6 @@ finish_install() {
|
|
|
5231
5394
|
printf " %-14s %s\n" "Turn back on" "$pkg on $flags"
|
|
5232
5395
|
printf " %-14s %s\n" "Give feedback" "$feedback"
|
|
5233
5396
|
printf " %-14s %s\n" "Uninstall" "$(uninstall_cmd)"
|
|
5234
|
-
offer_launch "$label" "$@"
|
|
5235
5397
|
elif [ "$mode" != "update" ]; then
|
|
5236
5398
|
print_uninstall_hint
|
|
5237
5399
|
fi
|
|
@@ -5395,8 +5557,93 @@ helper_dir="$(cd "$(dirname "$0")" 2>/dev/null && pwd -P)"
|
|
|
5395
5557
|
disabled_marker="$helper_dir/.weave-router-disabled"
|
|
5396
5558
|
router_badge_sentinel=$''
|
|
5397
5559
|
|
|
5560
|
+
display_hidden_file() {
|
|
5561
|
+
printf '%s/display-hidden-%s' "$state_root" "$(printf '%s' "$helper_dir" | cksum | tr -c '0-9' '-')"
|
|
5562
|
+
}
|
|
5563
|
+
|
|
5564
|
+
write_display_headers() {
|
|
5565
|
+
printf 'header = "X-Weave-Router-Key: %s"\n' "$2" >"$1"
|
|
5566
|
+
case "$3" in
|
|
5567
|
+
''|*[!A-Za-z0-9@._+-]*) ;;
|
|
5568
|
+
*) printf 'header = "X-Weave-User-Email: %s"\n' "$3" >>"$1" ;;
|
|
5569
|
+
esac
|
|
5570
|
+
}
|
|
5571
|
+
|
|
5572
|
+
refresh_display_settings() {
|
|
5573
|
+
local base_url="$1" header_file="$2" max_time="$3" display_url display_body hidden="0" hidden_file
|
|
5574
|
+
hidden_file="$(display_hidden_file)"
|
|
5575
|
+
display_url="${WEAVE_CODEX_DISPLAY_SETTINGS_URL:-}"
|
|
5576
|
+
if [ -z "$display_url" ]; then
|
|
5577
|
+
display_url="${base_url%/}"
|
|
5578
|
+
case "$display_url" in
|
|
5579
|
+
file://*) ;;
|
|
5580
|
+
*) display_url="${display_url%/v1}/v1/display-settings" ;;
|
|
5581
|
+
esac
|
|
5582
|
+
fi
|
|
5583
|
+
display_body="$(curl -fsS --max-time "$max_time" --max-filesize 8192 -K "$header_file" "$display_url" 2>/dev/null)" || return 0
|
|
5584
|
+
[ "$(jq -r '.hide_terminal_surfaces // false' <<<"$display_body" 2>/dev/null)" = "true" ] && hidden="1"
|
|
5585
|
+
printf '%s' "$hidden" >"$hidden_file.tmp.$$" 2>/dev/null && mv "$hidden_file.tmp.$$" "$hidden_file" 2>/dev/null
|
|
5586
|
+
rm -f "$hidden_file.tmp.$$" 2>/dev/null
|
|
5587
|
+
}
|
|
5588
|
+
|
|
5589
|
+
# A cold cache fetches the setting once in the foreground, briefly, so a
|
|
5590
|
+
# subject whose surfaces are hidden never sees a branded first title.
|
|
5591
|
+
display_file_younger_than() {
|
|
5592
|
+
local mtime now
|
|
5593
|
+
[ -f "$1" ] || return 1
|
|
5594
|
+
mtime="$(stat -c %Y "$1" 2>/dev/null || stat -f %m "$1" 2>/dev/null)" || return 1
|
|
5595
|
+
now="$(date +%s 2>/dev/null)" || return 1
|
|
5596
|
+
[ $(( now - mtime )) -lt "$2" ]
|
|
5597
|
+
}
|
|
5598
|
+
|
|
5599
|
+
# A cold cache, or a hidden setting past its grace window, fetches in the
|
|
5600
|
+
# foreground; a merely stale setting refreshes in the background. Failed
|
|
5601
|
+
# fetches are rate-limited by the .refreshed stamp.
|
|
5602
|
+
prime_display_settings() {
|
|
5603
|
+
local hidden_file stamp
|
|
5604
|
+
hidden_file="$(display_hidden_file)"
|
|
5605
|
+
stamp="$hidden_file.refreshed"
|
|
5606
|
+
[ -f "$stamp" ] || [ ! -f "$hidden_file" ] || stamp="$hidden_file"
|
|
5607
|
+
display_file_younger_than "$stamp" "${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-300}" && return 0
|
|
5608
|
+
if [ -f "$hidden_file" ] && { [ "$(cat "$hidden_file" 2>/dev/null)" != "1" ] \
|
|
5609
|
+
|| display_file_younger_than "$hidden_file" "${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"; }; then
|
|
5610
|
+
touch "$hidden_file.refreshed" 2>/dev/null
|
|
5611
|
+
( exec </dev/null >/dev/null 2>&1; prime_display_settings_now ) &
|
|
5612
|
+
return 0
|
|
5613
|
+
fi
|
|
5614
|
+
prime_display_settings_now
|
|
5615
|
+
}
|
|
5616
|
+
|
|
5617
|
+
prime_display_settings_now() {
|
|
5618
|
+
local endpoint header_file
|
|
5619
|
+
endpoint="$(read_codex_endpoint)" || return 0
|
|
5620
|
+
[ -n "$endpoint" ] || return 0
|
|
5621
|
+
mkdir -p "$state_root" 2>/dev/null || return 0
|
|
5622
|
+
touch "$(display_hidden_file).refreshed" 2>/dev/null
|
|
5623
|
+
header_file="$(mktemp "$state_root/.headers.XXXXXX")" || return 0
|
|
5624
|
+
chmod 600 "$header_file"
|
|
5625
|
+
write_display_headers "$header_file" "$(printf '%s' "$endpoint" | sed -n 2p)" "$(printf '%s' "$endpoint" | sed -n 3p)"
|
|
5626
|
+
refresh_display_settings "$(printf '%s' "$endpoint" | sed -n 1p)" "$header_file" 2
|
|
5627
|
+
rm -f "$header_file"
|
|
5628
|
+
}
|
|
5629
|
+
|
|
5630
|
+
codex_surfaces_hidden() {
|
|
5631
|
+
local hidden_file
|
|
5632
|
+
prime_display_settings
|
|
5633
|
+
hidden_file="$(display_hidden_file)"
|
|
5634
|
+
if [ ! -f "$hidden_file" ]; then
|
|
5635
|
+
display_file_younger_than "$hidden_file.refreshed" "${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-300}"
|
|
5636
|
+
return
|
|
5637
|
+
fi
|
|
5638
|
+
[ "$(cat "$hidden_file" 2>/dev/null)" = "1" ] || return 1
|
|
5639
|
+
display_file_younger_than "$hidden_file" "${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"
|
|
5640
|
+
}
|
|
5641
|
+
|
|
5398
5642
|
emit_title() {
|
|
5399
5643
|
local title="$1"
|
|
5644
|
+
case "$title" in
|
|
5645
|
+
"Weave Router"*) if codex_surfaces_hidden; then title="Codex"; fi ;;
|
|
5646
|
+
esac
|
|
5400
5647
|
if [ -n "${WEAVE_CODEX_STATUS_TITLE_FILE:-}" ]; then
|
|
5401
5648
|
printf '%s\n' "$title" >"$WEAVE_CODEX_STATUS_TITLE_FILE"
|
|
5402
5649
|
elif { [ -t 2 ] || [ "${async_title_enabled:-0}" = "1" ]; } && [ -w /dev/tty ]; then
|
|
@@ -5614,7 +5861,12 @@ read_codex_endpoint() {
|
|
|
5614
5861
|
sub(/^.*=[[:space:]]*"/, "", v); sub(/"$/, "", v)
|
|
5615
5862
|
if (key == "") key = v
|
|
5616
5863
|
}
|
|
5617
|
-
|
|
5864
|
+
match($0, /"?X-Weave-User-Email"?[[:space:]]*=[[:space:]]*"[^"]*"/) {
|
|
5865
|
+
v = substr($0, RSTART, RLENGTH)
|
|
5866
|
+
sub(/^.*=[[:space:]]*"/, "", v); sub(/"$/, "", v)
|
|
5867
|
+
if (email == "") email = v
|
|
5868
|
+
}
|
|
5869
|
+
END { if (url != "" && key != "") printf "%s\n%s\n%s\n", url, key, email }
|
|
5618
5870
|
' "$config" 2>/dev/null || true
|
|
5619
5871
|
}
|
|
5620
5872
|
|
|
@@ -5627,10 +5879,11 @@ refresh_session_cost() {
|
|
|
5627
5879
|
[ "${WEAVE_CODEX_STATUS_SAVINGS:-1}" = "0" ] && [ "${WEAVE_CODEX_STATUS_CONTEXT:-1}" = "0" ] && return 0
|
|
5628
5880
|
command -v curl >/dev/null 2>&1 || return 0
|
|
5629
5881
|
|
|
5630
|
-
local endpoint base_url key active_file state_lock
|
|
5882
|
+
local endpoint base_url key email active_file state_lock
|
|
5631
5883
|
endpoint="$(read_codex_endpoint)" || return 0
|
|
5632
5884
|
base_url="$(printf '%s' "$endpoint" | sed -n 1p)"
|
|
5633
5885
|
key="$(printf '%s' "$endpoint" | sed -n 2p)"
|
|
5886
|
+
email="$(printf '%s' "$endpoint" | sed -n 3p)"
|
|
5634
5887
|
[ -n "$base_url" ] && [ -n "$key" ] || return 0
|
|
5635
5888
|
|
|
5636
5889
|
mkdir -p "$state_root" 2>/dev/null || return 0
|
|
@@ -5663,7 +5916,8 @@ refresh_session_cost() {
|
|
|
5663
5916
|
esac
|
|
5664
5917
|
header_file="$(mktemp "$state_root/.headers.XXXXXX")" || exit 0
|
|
5665
5918
|
chmod 600 "$header_file"
|
|
5666
|
-
|
|
5919
|
+
write_display_headers "$header_file" "$key" "$email"
|
|
5920
|
+
refresh_display_settings "$base_url" "$header_file" 5
|
|
5667
5921
|
if ! body="$(curl -fsS --max-time 5 --max-filesize 8192 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
5668
5922
|
rm -f "$header_file"
|
|
5669
5923
|
exit 0
|
|
@@ -6291,6 +6545,7 @@ if [ "$target" = "codex" ]; then
|
|
|
6291
6545
|
ok "Codex config written to $codex_config_file"
|
|
6292
6546
|
remove_obsolete_codex_prompt_wrappers "$codex_dir/prompts"
|
|
6293
6547
|
install_codex_prompt_skills
|
|
6548
|
+
install_build_skill "$codex_dir/skills"
|
|
6294
6549
|
|
|
6295
6550
|
# Project scope: ensure the per-teammate config (which holds the router key)
|
|
6296
6551
|
# is gitignored. The base URL is the same for every teammate, so a
|
|
@@ -6320,11 +6575,7 @@ if [ "$target" = "codex" ]; then
|
|
|
6320
6575
|
# point CODEX_HOME at the directory we wrote so Codex finds our config.
|
|
6321
6576
|
info "Run Codex with CODEX_HOME=$codex_dir codex so it picks up this config."
|
|
6322
6577
|
fi
|
|
6323
|
-
|
|
6324
|
-
finish_install "Codex" env CODEX_HOME="$codex_dir" codex
|
|
6325
|
-
else
|
|
6326
|
-
finish_install "Codex" codex
|
|
6327
|
-
fi
|
|
6578
|
+
finish_install
|
|
6328
6579
|
exit 0
|
|
6329
6580
|
fi
|
|
6330
6581
|
|
|
@@ -7144,21 +7395,33 @@ weave_hidden_gate() {
|
|
|
7144
7395
|
local cache="$cache_dir/display-settings${script_slug}"
|
|
7145
7396
|
local ttl="${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-3600}"
|
|
7146
7397
|
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
local now mtime fresh="false"
|
|
7398
|
+
local grace="${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"
|
|
7399
|
+
local now mtime fresh="false" stale_hidden="false"
|
|
7151
7400
|
now="$(date +%s 2>/dev/null)" || now=0
|
|
7401
|
+
|
|
7402
|
+
# Linked plans that need a fresh login. Only a refresh within the TTL is
|
|
7403
|
+
# trusted: an older list may name a plan that has since recovered.
|
|
7404
|
+
weave_disconnected_plans=""
|
|
7405
|
+
if [ -f "$cache.plans" ]; then
|
|
7406
|
+
mtime="$(stat -c %Y "$cache.plans" 2>/dev/null || stat -f %m "$cache.plans" 2>/dev/null)" || mtime=0
|
|
7407
|
+
if [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$ttl" ]; then
|
|
7408
|
+
weave_disconnected_plans="$(cat "$cache.plans" 2>/dev/null)"
|
|
7409
|
+
fi
|
|
7410
|
+
fi
|
|
7152
7411
|
if [ -f "$cache" ]; then
|
|
7153
7412
|
mtime="$(stat -c %Y "$cache" 2>/dev/null || stat -f %m "$cache" 2>/dev/null)" || mtime=0
|
|
7154
7413
|
if [ -n "${mtime:-}" ] && [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$ttl" ]; then
|
|
7155
7414
|
fresh="true"
|
|
7415
|
+
elif [ -n "${mtime:-}" ] && [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$grace" ] \
|
|
7416
|
+
&& [ "$(cat "$cache" 2>/dev/null)" = "1" ]; then
|
|
7417
|
+
stale_hidden="true"
|
|
7156
7418
|
fi
|
|
7157
7419
|
fi
|
|
7158
7420
|
|
|
7159
|
-
# Foreground decision:
|
|
7160
|
-
#
|
|
7161
|
-
#
|
|
7421
|
+
# Foreground decision: a fresh cache decides. A hidden cache past the TTL
|
|
7422
|
+
# stays hidden for the grace period while it refreshes, so an hourly expiry
|
|
7423
|
+
# never flashes routing details to someone who must not see them. Anything
|
|
7424
|
+
# else renders normally so an unreachable router cannot wedge it blank.
|
|
7162
7425
|
if [ "$fresh" = "true" ]; then
|
|
7163
7426
|
[ "$(cat "$cache" 2>/dev/null)" = "1" ]
|
|
7164
7427
|
return
|
|
@@ -7224,6 +7487,9 @@ weave_hidden_gate() {
|
|
|
7224
7487
|
if [ -z "$key" ] && [ -f "$local_settings" ]; then
|
|
7225
7488
|
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)"
|
|
7226
7489
|
fi
|
|
7490
|
+
if [ -z "$key" ] && [ -n "${ANTHROPIC_CUSTOM_HEADERS:-}" ]; then
|
|
7491
|
+
key="$(printf '%s\n' "$ANTHROPIC_CUSTOM_HEADERS" | sed -n 's/^X-Weave-Router-Key:[[:space:]]*\([A-Za-z0-9_-]*\)[[:space:]]*$/\1/p' | head -n1)"
|
|
7492
|
+
fi
|
|
7227
7493
|
if [ -z "$base_url" ] && [ -f "$settings" ]; then
|
|
7228
7494
|
base_url="$(jq -r '.env.ANTHROPIC_BASE_URL // empty' "$settings" 2>/dev/null)"
|
|
7229
7495
|
fi
|
|
@@ -7236,6 +7502,12 @@ weave_hidden_gate() {
|
|
|
7236
7502
|
header_file="$(mktemp "$cache_dir/.headers.XXXXXX")" || exit 0
|
|
7237
7503
|
chmod 600 "$header_file"
|
|
7238
7504
|
printf 'header = "X-Weave-Router-Key: %s"\n' "$key" >"$header_file"
|
|
7505
|
+
custom_headers="${ANTHROPIC_CUSTOM_HEADERS:-}"
|
|
7506
|
+
for f in "$settings" "$local_settings"; do
|
|
7507
|
+
[ -n "$custom_headers" ] || [ ! -f "$f" ] || custom_headers="$(jq -r '.env.ANTHROPIC_CUSTOM_HEADERS // ""' "$f" 2>/dev/null)"
|
|
7508
|
+
done
|
|
7509
|
+
printf '%s\n' "$custom_headers" | grep -E '^X-Weave-User-(Email|Name):[[:space:]]*[A-Za-z0-9@._+ -]+$' \
|
|
7510
|
+
| sed 's/^\(.*\)$/header = "\1"/' >>"$header_file" 2>/dev/null || true
|
|
7239
7511
|
if ! body="$(curl -fsS --max-time 5 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
7240
7512
|
rm -f "$header_file"
|
|
7241
7513
|
exit 0
|
|
@@ -7253,7 +7525,18 @@ weave_hidden_gate() {
|
|
|
7253
7525
|
rm -f "$tmp" 2>/dev/null
|
|
7254
7526
|
) >/dev/null 2>&1 &
|
|
7255
7527
|
disown 2>/dev/null || true
|
|
7256
|
-
|
|
7528
|
+
# A cold cache waits briefly for its first refresh so a subject whose
|
|
7529
|
+
# surfaces are hidden does not see one full render before the cache exists.
|
|
7530
|
+
if [ ! -f "$cache" ] && [ ! -f "$cache.cold-waited" ]; then
|
|
7531
|
+
: >"$cache.cold-waited" 2>/dev/null
|
|
7532
|
+
local tries="${WEAVE_DISPLAY_SETTINGS_COLD_WAIT_TENTHS:-20}"
|
|
7533
|
+
while [ "$tries" -gt 0 ] && [ ! -f "$cache" ]; do
|
|
7534
|
+
sleep 0.1 2>/dev/null || break
|
|
7535
|
+
tries=$(( tries - 1 ))
|
|
7536
|
+
done
|
|
7537
|
+
[ "$(cat "$cache" 2>/dev/null)" = "1" ] && return 0
|
|
7538
|
+
fi
|
|
7539
|
+
[ "$stale_hidden" = "true" ]
|
|
7257
7540
|
}
|
|
7258
7541
|
|
|
7259
7542
|
if weave_hidden_gate </dev/null; then
|
|
@@ -7299,8 +7582,10 @@ prices='{
|
|
|
7299
7582
|
"input": {
|
|
7300
7583
|
"claude-fable-5": 0.01,
|
|
7301
7584
|
"claude-fable-5-1": 0.01,
|
|
7585
|
+
"claude-fable-5-2": 0.008,
|
|
7302
7586
|
"claude-haiku-4-5": 0.001,
|
|
7303
7587
|
"claude-haiku-5-5": 0.0001,
|
|
7588
|
+
"claude-mythos-5-2": 0.008,
|
|
7304
7589
|
"claude-opus-4-0": 0.015,
|
|
7305
7590
|
"claude-opus-4-1": 0.015,
|
|
7306
7591
|
"claude-opus-4-5": 0.005,
|
|
@@ -7364,6 +7649,7 @@ prices='{
|
|
|
7364
7649
|
"grok-4.6": 0.002,
|
|
7365
7650
|
"grok-4.7": 0.002,
|
|
7366
7651
|
"inclusionai/ling-3.0-flash": 0.00006,
|
|
7652
|
+
"meta/muse-spark-open": 0.00125,
|
|
7367
7653
|
"minimax/minimax-m2.7": 0.0003,
|
|
7368
7654
|
"minimax/minimax-m3": 0.0003,
|
|
7369
7655
|
"minimax/minimax-m3.1-flash": 0.00015,
|
|
@@ -7373,7 +7659,9 @@ prices='{
|
|
|
7373
7659
|
"moonshotai/kimi-k2.7": 0.00095,
|
|
7374
7660
|
"moonshotai/kimi-k3": 0.003,
|
|
7375
7661
|
"moonshotai/kimi-k3.1": 0.002,
|
|
7662
|
+
"muse-ember-1.0": 0.0001,
|
|
7376
7663
|
"muse-spark-1.3": 0.00125,
|
|
7664
|
+
"muse-wonder-1.0": 0.004,
|
|
7377
7665
|
"qwen/qwen3-235b-a22b-2507": 0.0002266,
|
|
7378
7666
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.00015,
|
|
7379
7667
|
"qwen/qwen3-coder": 0.0009,
|
|
@@ -7395,8 +7683,10 @@ prices='{
|
|
|
7395
7683
|
"output": {
|
|
7396
7684
|
"claude-fable-5": 0.05,
|
|
7397
7685
|
"claude-fable-5-1": 0.05,
|
|
7686
|
+
"claude-fable-5-2": 0.04,
|
|
7398
7687
|
"claude-haiku-4-5": 0.005,
|
|
7399
7688
|
"claude-haiku-5-5": 0.0005,
|
|
7689
|
+
"claude-mythos-5-2": 0.04,
|
|
7400
7690
|
"claude-opus-4-0": 0.075,
|
|
7401
7691
|
"claude-opus-4-1": 0.075,
|
|
7402
7692
|
"claude-opus-4-5": 0.025,
|
|
@@ -7460,6 +7750,7 @@ prices='{
|
|
|
7460
7750
|
"grok-4.6": 0.006,
|
|
7461
7751
|
"grok-4.7": 0.006,
|
|
7462
7752
|
"inclusionai/ling-3.0-flash": 0.00018,
|
|
7753
|
+
"meta/muse-spark-open": 0.00425,
|
|
7463
7754
|
"minimax/minimax-m2.7": 0.0012,
|
|
7464
7755
|
"minimax/minimax-m3": 0.0012,
|
|
7465
7756
|
"minimax/minimax-m3.1-flash": 0.0006,
|
|
@@ -7469,7 +7760,9 @@ prices='{
|
|
|
7469
7760
|
"moonshotai/kimi-k2.7": 0.004,
|
|
7470
7761
|
"moonshotai/kimi-k3": 0.015,
|
|
7471
7762
|
"moonshotai/kimi-k3.1": 0.01,
|
|
7763
|
+
"muse-ember-1.0": 0.0005,
|
|
7472
7764
|
"muse-spark-1.3": 0.00425,
|
|
7765
|
+
"muse-wonder-1.0": 0.02,
|
|
7473
7766
|
"qwen/qwen3-235b-a22b-2507": 0.0009064,
|
|
7474
7767
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.0006,
|
|
7475
7768
|
"qwen/qwen3-coder": 0.0027,
|
|
@@ -7491,8 +7784,10 @@ prices='{
|
|
|
7491
7784
|
"cache_read": {
|
|
7492
7785
|
"claude-fable-5": 0.1,
|
|
7493
7786
|
"claude-fable-5-1": 0.025,
|
|
7787
|
+
"claude-fable-5-2": 0.025,
|
|
7494
7788
|
"claude-haiku-4-5": 0.1,
|
|
7495
7789
|
"claude-haiku-5-5": 0.1,
|
|
7790
|
+
"claude-mythos-5-2": 0.025,
|
|
7496
7791
|
"claude-opus-4-0": 0.1,
|
|
7497
7792
|
"claude-opus-4-1": 0.1,
|
|
7498
7793
|
"claude-opus-4-5": 0.1,
|
|
@@ -7504,7 +7799,7 @@ prices='{
|
|
|
7504
7799
|
"claude-sonnet-4-5": 0.1,
|
|
7505
7800
|
"claude-sonnet-4-6": 0.1,
|
|
7506
7801
|
"claude-sonnet-5": 0.1,
|
|
7507
|
-
"claude-sonnet-5-5": 0.
|
|
7802
|
+
"claude-sonnet-5-5": 0.05,
|
|
7508
7803
|
"deepseek/deepseek-v4-flash": 0.1,
|
|
7509
7804
|
"deepseek/deepseek-v4-pro": 0.0862,
|
|
7510
7805
|
"deepseek/deepseek-v4-pro-0813": 0.0862,
|
|
@@ -7556,6 +7851,7 @@ prices='{
|
|
|
7556
7851
|
"grok-4.6": 0.25,
|
|
7557
7852
|
"grok-4.7": 0.25,
|
|
7558
7853
|
"inclusionai/ling-3.0-flash": 0.2,
|
|
7854
|
+
"meta/muse-spark-open": 0.12,
|
|
7559
7855
|
"minimax/minimax-m2.7": 0.2,
|
|
7560
7856
|
"minimax/minimax-m3": 0.2,
|
|
7561
7857
|
"minimax/minimax-m3.1-flash": 0.1,
|
|
@@ -7565,7 +7861,9 @@ prices='{
|
|
|
7565
7861
|
"moonshotai/kimi-k2.7": 0.2,
|
|
7566
7862
|
"moonshotai/kimi-k3": 0.1,
|
|
7567
7863
|
"moonshotai/kimi-k3.1": 0.1,
|
|
7864
|
+
"muse-ember-1.0": 0.04,
|
|
7568
7865
|
"muse-spark-1.3": 0.12,
|
|
7866
|
+
"muse-wonder-1.0": 0.05,
|
|
7569
7867
|
"qwen/qwen3-235b-a22b-2507": 0.5,
|
|
7570
7868
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.1684,
|
|
7571
7869
|
"qwen/qwen3-coder": 0.1684,
|
|
@@ -7907,8 +8205,8 @@ if [ -n "${weave_disconnected_plans:-}" ]; then
|
|
|
7907
8205
|
fi
|
|
7908
8206
|
for weave_plan in ${weave_disconnected_plans:-}; do
|
|
7909
8207
|
case "$weave_plan" in
|
|
7910
|
-
claude) status_text="$status_text · Claude plan
|
|
7911
|
-
codex) status_text="$status_text · Codex plan
|
|
8208
|
+
claude) status_text="$status_text · Claude plan needs login: npx @weave-os/router login claude$weave_login_scope" ;;
|
|
8209
|
+
codex) status_text="$status_text · Codex plan needs login: npx @weave-os/router login codex$weave_login_scope" ;;
|
|
7912
8210
|
esac
|
|
7913
8211
|
done
|
|
7914
8212
|
|
|
@@ -8105,6 +8403,7 @@ fi
|
|
|
8105
8403
|
|
|
8106
8404
|
# Slash command wrappers — see install_slash_commands() below for the why.
|
|
8107
8405
|
install_slash_commands "$settings_dir/commands"
|
|
8406
|
+
install_build_skill "$settings_dir/skills" "$settings_dir/agents"
|
|
8108
8407
|
|
|
8109
8408
|
# ---------- gitignore for project scope ----------
|
|
8110
8409
|
|
|
@@ -8137,4 +8436,4 @@ verify_install
|
|
|
8137
8436
|
# ---------- done ----------
|
|
8138
8437
|
|
|
8139
8438
|
announce_done "Claude Code"
|
|
8140
|
-
finish_install
|
|
8439
|
+
finish_install
|