@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/README.md
CHANGED
|
@@ -58,7 +58,7 @@ Codex installs `$router-status`, `$router-off`, `$router-on`, and
|
|
|
58
58
|
to the normal provider; Codex does not support third-party `/disable-routing`
|
|
59
59
|
slash commands. The shell equivalent is `npx @weave-os/router disable-routing`.
|
|
60
60
|
Cursor has no config file we own — toggle its base URL override in **Settings →
|
|
61
|
-
Models** instead
|
|
61
|
+
Models** instead, with a custom model named `weave-auto`.
|
|
62
62
|
|
|
63
63
|
Pick which models the router is allowed to route to:
|
|
64
64
|
|
package/bin.js
CHANGED
|
@@ -11,7 +11,7 @@ const packageName = JSON.parse(
|
|
|
11
11
|
readFileSync(path.join(__dirname, "package.json"), "utf8"),
|
|
12
12
|
).name;
|
|
13
13
|
|
|
14
|
-
const defaultEntrypointURL = "https://
|
|
14
|
+
const defaultEntrypointURL = "https://app.weaveos.com/start";
|
|
15
15
|
|
|
16
16
|
if (packageName === "@weave-os/router" && args.length === 0) {
|
|
17
17
|
openDefaultEntrypoint(defaultEntrypointURL);
|
package/cc-statusline.sh
CHANGED
|
@@ -360,7 +360,7 @@ weave_sync_commands 2>/dev/null || true
|
|
|
360
360
|
# responses can land out of order, and the loser's mv would replace a newer
|
|
361
361
|
# setting with an older one AND stamp it fresh, pinning the gate on a stale
|
|
362
362
|
# value for a full TTL. Refreshes are therefore serialized per cache key on a
|
|
363
|
-
#
|
|
363
|
+
# directory mutex (flock is absent on macOS), held across both
|
|
364
364
|
# the fetch and the write. A refresh that finds the mutex held exits rather
|
|
365
365
|
# than queueing — the in-flight one is at least as fresh as anything it would
|
|
366
366
|
# fetch, so waiting only to overwrite it is the bug. The one path that is not
|
|
@@ -377,21 +377,33 @@ weave_hidden_gate() {
|
|
|
377
377
|
local cache="$cache_dir/display-settings${script_slug}"
|
|
378
378
|
local ttl="${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-3600}"
|
|
379
379
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
local now mtime fresh="false"
|
|
380
|
+
local grace="${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"
|
|
381
|
+
local now mtime fresh="false" stale_hidden="false"
|
|
384
382
|
now="$(date +%s 2>/dev/null)" || now=0
|
|
383
|
+
|
|
384
|
+
# Linked plans that need a fresh login. Only a refresh within the TTL is
|
|
385
|
+
# trusted: an older list may name a plan that has since recovered.
|
|
386
|
+
weave_disconnected_plans=""
|
|
387
|
+
if [ -f "$cache.plans" ]; then
|
|
388
|
+
mtime="$(stat -c %Y "$cache.plans" 2>/dev/null || stat -f %m "$cache.plans" 2>/dev/null)" || mtime=0
|
|
389
|
+
if [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$ttl" ]; then
|
|
390
|
+
weave_disconnected_plans="$(cat "$cache.plans" 2>/dev/null)"
|
|
391
|
+
fi
|
|
392
|
+
fi
|
|
385
393
|
if [ -f "$cache" ]; then
|
|
386
394
|
mtime="$(stat -c %Y "$cache" 2>/dev/null || stat -f %m "$cache" 2>/dev/null)" || mtime=0
|
|
387
395
|
if [ -n "${mtime:-}" ] && [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$ttl" ]; then
|
|
388
396
|
fresh="true"
|
|
397
|
+
elif [ -n "${mtime:-}" ] && [ "$mtime" -gt 0 ] && [ $(( now - mtime )) -lt "$grace" ] \
|
|
398
|
+
&& [ "$(cat "$cache" 2>/dev/null)" = "1" ]; then
|
|
399
|
+
stale_hidden="true"
|
|
389
400
|
fi
|
|
390
401
|
fi
|
|
391
402
|
|
|
392
|
-
# Foreground decision:
|
|
393
|
-
#
|
|
394
|
-
#
|
|
403
|
+
# Foreground decision: a fresh cache decides. A hidden cache past the TTL
|
|
404
|
+
# stays hidden for the grace period while it refreshes, so an hourly expiry
|
|
405
|
+
# never flashes routing details to someone who must not see them. Anything
|
|
406
|
+
# else renders normally so an unreachable router cannot wedge it blank.
|
|
395
407
|
if [ "$fresh" = "true" ]; then
|
|
396
408
|
[ "$(cat "$cache" 2>/dev/null)" = "1" ]
|
|
397
409
|
return
|
|
@@ -411,10 +423,9 @@ weave_hidden_gate() {
|
|
|
411
423
|
(
|
|
412
424
|
exec </dev/null
|
|
413
425
|
|
|
414
|
-
# Take the per-cache-key mutex, or bail.
|
|
415
|
-
#
|
|
416
|
-
#
|
|
417
|
-
# reclaimed. Releasing from a trap covers every exit path below.
|
|
426
|
+
# Take the per-cache-key mutex, or bail. Old locks are reclaimed so a
|
|
427
|
+
# crashed holder cannot block refreshes forever. Releasing from a trap
|
|
428
|
+
# covers every exit path below.
|
|
418
429
|
lock="$cache.lock"
|
|
419
430
|
if ! mkdir "$lock" 2>/dev/null; then
|
|
420
431
|
lock_mtime="$(stat -c %Y "$lock" 2>/dev/null || stat -f %m "$lock" 2>/dev/null)" || lock_mtime=0
|
|
@@ -438,7 +449,10 @@ weave_hidden_gate() {
|
|
|
438
449
|
rm -rf "$dead" 2>/dev/null
|
|
439
450
|
mkdir "$lock" 2>/dev/null || exit 0
|
|
440
451
|
fi
|
|
441
|
-
|
|
452
|
+
# Some mkdir implementations return success to both racing creators.
|
|
453
|
+
# Shell noclobber supplies the exclusive claim independently of mkdir.
|
|
454
|
+
(set -C; : > "$lock/owner") 2>/dev/null || exit 0
|
|
455
|
+
trap 'rm -f "$lock/owner"; rmdir "$lock" 2>/dev/null' EXIT
|
|
442
456
|
|
|
443
457
|
self_dir="$(cd "$(dirname "$self")" 2>/dev/null && pwd)"
|
|
444
458
|
settings_base="$HOME"
|
|
@@ -455,6 +469,9 @@ weave_hidden_gate() {
|
|
|
455
469
|
if [ -z "$key" ] && [ -f "$local_settings" ]; then
|
|
456
470
|
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)"
|
|
457
471
|
fi
|
|
472
|
+
if [ -z "$key" ] && [ -n "${ANTHROPIC_CUSTOM_HEADERS:-}" ]; then
|
|
473
|
+
key="$(printf '%s\n' "$ANTHROPIC_CUSTOM_HEADERS" | sed -n 's/^X-Weave-Router-Key:[[:space:]]*\([A-Za-z0-9_-]*\)[[:space:]]*$/\1/p' | head -n1)"
|
|
474
|
+
fi
|
|
458
475
|
if [ -z "$base_url" ] && [ -f "$settings" ]; then
|
|
459
476
|
base_url="$(jq -r '.env.ANTHROPIC_BASE_URL // empty' "$settings" 2>/dev/null)"
|
|
460
477
|
fi
|
|
@@ -467,6 +484,12 @@ weave_hidden_gate() {
|
|
|
467
484
|
header_file="$(mktemp "$cache_dir/.headers.XXXXXX")" || exit 0
|
|
468
485
|
chmod 600 "$header_file"
|
|
469
486
|
printf 'header = "X-Weave-Router-Key: %s"\n' "$key" >"$header_file"
|
|
487
|
+
custom_headers="${ANTHROPIC_CUSTOM_HEADERS:-}"
|
|
488
|
+
for f in "$settings" "$local_settings"; do
|
|
489
|
+
[ -n "$custom_headers" ] || [ ! -f "$f" ] || custom_headers="$(jq -r '.env.ANTHROPIC_CUSTOM_HEADERS // ""' "$f" 2>/dev/null)"
|
|
490
|
+
done
|
|
491
|
+
printf '%s\n' "$custom_headers" | grep -E '^X-Weave-User-(Email|Name):[[:space:]]*[A-Za-z0-9@._+ -]+$' \
|
|
492
|
+
| sed 's/^\(.*\)$/header = "\1"/' >>"$header_file" 2>/dev/null || true
|
|
470
493
|
if ! body="$(curl -fsS --max-time 5 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
471
494
|
rm -f "$header_file"
|
|
472
495
|
exit 0
|
|
@@ -484,7 +507,18 @@ weave_hidden_gate() {
|
|
|
484
507
|
rm -f "$tmp" 2>/dev/null
|
|
485
508
|
) >/dev/null 2>&1 &
|
|
486
509
|
disown 2>/dev/null || true
|
|
487
|
-
|
|
510
|
+
# A cold cache waits briefly for its first refresh so a subject whose
|
|
511
|
+
# surfaces are hidden does not see one full render before the cache exists.
|
|
512
|
+
if [ ! -f "$cache" ] && [ ! -f "$cache.cold-waited" ]; then
|
|
513
|
+
: >"$cache.cold-waited" 2>/dev/null
|
|
514
|
+
local tries="${WEAVE_DISPLAY_SETTINGS_COLD_WAIT_TENTHS:-20}"
|
|
515
|
+
while [ "$tries" -gt 0 ] && [ ! -f "$cache" ]; do
|
|
516
|
+
sleep 0.1 2>/dev/null || break
|
|
517
|
+
tries=$(( tries - 1 ))
|
|
518
|
+
done
|
|
519
|
+
[ "$(cat "$cache" 2>/dev/null)" = "1" ] && return 0
|
|
520
|
+
fi
|
|
521
|
+
[ "$stale_hidden" = "true" ]
|
|
488
522
|
}
|
|
489
523
|
|
|
490
524
|
if weave_hidden_gate </dev/null; then
|
|
@@ -530,8 +564,10 @@ prices='{
|
|
|
530
564
|
"input": {
|
|
531
565
|
"claude-fable-5": 0.01,
|
|
532
566
|
"claude-fable-5-1": 0.01,
|
|
567
|
+
"claude-fable-5-2": 0.008,
|
|
533
568
|
"claude-haiku-4-5": 0.001,
|
|
534
569
|
"claude-haiku-5-5": 0.0001,
|
|
570
|
+
"claude-mythos-5-2": 0.008,
|
|
535
571
|
"claude-opus-4-0": 0.015,
|
|
536
572
|
"claude-opus-4-1": 0.015,
|
|
537
573
|
"claude-opus-4-5": 0.005,
|
|
@@ -595,6 +631,7 @@ prices='{
|
|
|
595
631
|
"grok-4.6": 0.002,
|
|
596
632
|
"grok-4.7": 0.002,
|
|
597
633
|
"inclusionai/ling-3.0-flash": 0.00006,
|
|
634
|
+
"meta/muse-spark-open": 0.00125,
|
|
598
635
|
"minimax/minimax-m2.7": 0.0003,
|
|
599
636
|
"minimax/minimax-m3": 0.0003,
|
|
600
637
|
"minimax/minimax-m3.1-flash": 0.00015,
|
|
@@ -604,7 +641,9 @@ prices='{
|
|
|
604
641
|
"moonshotai/kimi-k2.7": 0.00095,
|
|
605
642
|
"moonshotai/kimi-k3": 0.003,
|
|
606
643
|
"moonshotai/kimi-k3.1": 0.002,
|
|
644
|
+
"muse-ember-1.0": 0.0001,
|
|
607
645
|
"muse-spark-1.3": 0.00125,
|
|
646
|
+
"muse-wonder-1.0": 0.004,
|
|
608
647
|
"qwen/qwen3-235b-a22b-2507": 0.0002266,
|
|
609
648
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.00015,
|
|
610
649
|
"qwen/qwen3-coder": 0.0009,
|
|
@@ -626,8 +665,10 @@ prices='{
|
|
|
626
665
|
"output": {
|
|
627
666
|
"claude-fable-5": 0.05,
|
|
628
667
|
"claude-fable-5-1": 0.05,
|
|
668
|
+
"claude-fable-5-2": 0.04,
|
|
629
669
|
"claude-haiku-4-5": 0.005,
|
|
630
670
|
"claude-haiku-5-5": 0.0005,
|
|
671
|
+
"claude-mythos-5-2": 0.04,
|
|
631
672
|
"claude-opus-4-0": 0.075,
|
|
632
673
|
"claude-opus-4-1": 0.075,
|
|
633
674
|
"claude-opus-4-5": 0.025,
|
|
@@ -691,6 +732,7 @@ prices='{
|
|
|
691
732
|
"grok-4.6": 0.006,
|
|
692
733
|
"grok-4.7": 0.006,
|
|
693
734
|
"inclusionai/ling-3.0-flash": 0.00018,
|
|
735
|
+
"meta/muse-spark-open": 0.00425,
|
|
694
736
|
"minimax/minimax-m2.7": 0.0012,
|
|
695
737
|
"minimax/minimax-m3": 0.0012,
|
|
696
738
|
"minimax/minimax-m3.1-flash": 0.0006,
|
|
@@ -700,7 +742,9 @@ prices='{
|
|
|
700
742
|
"moonshotai/kimi-k2.7": 0.004,
|
|
701
743
|
"moonshotai/kimi-k3": 0.015,
|
|
702
744
|
"moonshotai/kimi-k3.1": 0.01,
|
|
745
|
+
"muse-ember-1.0": 0.0005,
|
|
703
746
|
"muse-spark-1.3": 0.00425,
|
|
747
|
+
"muse-wonder-1.0": 0.02,
|
|
704
748
|
"qwen/qwen3-235b-a22b-2507": 0.0009064,
|
|
705
749
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.0006,
|
|
706
750
|
"qwen/qwen3-coder": 0.0027,
|
|
@@ -722,8 +766,10 @@ prices='{
|
|
|
722
766
|
"cache_read": {
|
|
723
767
|
"claude-fable-5": 0.1,
|
|
724
768
|
"claude-fable-5-1": 0.025,
|
|
769
|
+
"claude-fable-5-2": 0.025,
|
|
725
770
|
"claude-haiku-4-5": 0.1,
|
|
726
771
|
"claude-haiku-5-5": 0.1,
|
|
772
|
+
"claude-mythos-5-2": 0.025,
|
|
727
773
|
"claude-opus-4-0": 0.1,
|
|
728
774
|
"claude-opus-4-1": 0.1,
|
|
729
775
|
"claude-opus-4-5": 0.1,
|
|
@@ -735,7 +781,7 @@ prices='{
|
|
|
735
781
|
"claude-sonnet-4-5": 0.1,
|
|
736
782
|
"claude-sonnet-4-6": 0.1,
|
|
737
783
|
"claude-sonnet-5": 0.1,
|
|
738
|
-
"claude-sonnet-5-5": 0.
|
|
784
|
+
"claude-sonnet-5-5": 0.05,
|
|
739
785
|
"deepseek/deepseek-v4-flash": 0.1,
|
|
740
786
|
"deepseek/deepseek-v4-pro": 0.0862,
|
|
741
787
|
"deepseek/deepseek-v4-pro-0813": 0.0862,
|
|
@@ -787,6 +833,7 @@ prices='{
|
|
|
787
833
|
"grok-4.6": 0.25,
|
|
788
834
|
"grok-4.7": 0.25,
|
|
789
835
|
"inclusionai/ling-3.0-flash": 0.2,
|
|
836
|
+
"meta/muse-spark-open": 0.12,
|
|
790
837
|
"minimax/minimax-m2.7": 0.2,
|
|
791
838
|
"minimax/minimax-m3": 0.2,
|
|
792
839
|
"minimax/minimax-m3.1-flash": 0.1,
|
|
@@ -796,7 +843,9 @@ prices='{
|
|
|
796
843
|
"moonshotai/kimi-k2.7": 0.2,
|
|
797
844
|
"moonshotai/kimi-k3": 0.1,
|
|
798
845
|
"moonshotai/kimi-k3.1": 0.1,
|
|
846
|
+
"muse-ember-1.0": 0.04,
|
|
799
847
|
"muse-spark-1.3": 0.12,
|
|
848
|
+
"muse-wonder-1.0": 0.05,
|
|
800
849
|
"qwen/qwen3-235b-a22b-2507": 0.5,
|
|
801
850
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.1684,
|
|
802
851
|
"qwen/qwen3-coder": 0.1684,
|
|
@@ -1138,8 +1187,8 @@ if [ -n "${weave_disconnected_plans:-}" ]; then
|
|
|
1138
1187
|
fi
|
|
1139
1188
|
for weave_plan in ${weave_disconnected_plans:-}; do
|
|
1140
1189
|
case "$weave_plan" in
|
|
1141
|
-
claude) status_text="$status_text · Claude plan
|
|
1142
|
-
codex) status_text="$status_text · Codex plan
|
|
1190
|
+
claude) status_text="$status_text · Claude plan needs login: npx @weave-os/router login claude$weave_login_scope" ;;
|
|
1191
|
+
codex) status_text="$status_text · Codex plan needs login: npx @weave-os/router login codex$weave_login_scope" ;;
|
|
1143
1192
|
esac
|
|
1144
1193
|
done
|
|
1145
1194
|
|
package/codex-skills/fm/SKILL.md
CHANGED
|
@@ -12,4 +12,5 @@ Do not send a user message and do not type a Codex slash command.
|
|
|
12
12
|
|
|
13
13
|
The script prints a leading-space `/force-model` line. The Weave Router reads that
|
|
14
14
|
exec output, pins the session, and continues this turn — so run the script once and
|
|
15
|
-
do not repeat its output as your answer.
|
|
15
|
+
do not repeat its output as your answer. The router renders its own
|
|
16
|
+
acknowledgment, so do not restate or reason about it; end the turn.
|
|
@@ -12,4 +12,5 @@ Do not send a user message and do not type a Codex slash command.
|
|
|
12
12
|
|
|
13
13
|
The script prints a leading-space `/force-model` line. The Weave Router reads that
|
|
14
14
|
exec output, pins the session, and continues this turn — so run the script once and
|
|
15
|
-
do not repeat its output as your answer.
|
|
15
|
+
do not repeat its output as your answer. The router renders its own
|
|
16
|
+
acknowledgment, so do not restate or reason about it; end the turn.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: list-models
|
|
3
|
+
description: "List the models this Codex session can pin through the Weave Router."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- weave-router managed list-models skill -->
|
|
7
|
+
|
|
8
|
+
# Weave Router forceable models
|
|
9
|
+
|
|
10
|
+
A bare `$list-models` is answered by the Weave Router itself: it replies with every
|
|
11
|
+
model `$force-model` accepts, grouped by provider, with `[x]` for models this
|
|
12
|
+
installation lets you force and `[ ]` for ones its policy refuses, plus the
|
|
13
|
+
shorthands (`opus`, `sol`, `luna`, …) that resolve to each one. When that reply is
|
|
14
|
+
already in the conversation, just present it; there is nothing to run.
|
|
15
|
+
|
|
16
|
+
If you are reading this instead, the router did not answer the directive (an older
|
|
17
|
+
router, or the directive was not the whole message). Run:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx --package @weave-os/router -y -- weave-router models --codex{{SCOPE}}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
and present the models it lists by exact id, grouped by provider. Models marked
|
|
24
|
+
`[ ]` there are excluded for this installation, so `$force-model` will not pin them
|
|
25
|
+
either; only `[x]` rows can be forced. That listing omits the shorthands.
|
|
26
|
+
|
|
27
|
+
Pin one with `$force-model <id or shorthand>`; add `:low`, `:medium`, `:high` or
|
|
28
|
+
`:max` to set reasoning effort, and `$unforce-model` returns to automatic routing.
|
package/codex-skills/rf/SKILL.md
CHANGED
|
@@ -12,4 +12,5 @@ Do not send a user message and do not type a Codex slash command.
|
|
|
12
12
|
|
|
13
13
|
The script prints a leading-space `/router-feedback` line. The Weave Router reads that
|
|
14
14
|
exec output, records the feedback, and continues this turn — so run the script once and
|
|
15
|
-
do not repeat its output as your answer.
|
|
15
|
+
do not repeat its output as your answer. The router renders its own
|
|
16
|
+
acknowledgment, so do not restate or reason about it; end the turn.
|
|
@@ -12,4 +12,5 @@ Do not send a user message and do not type a Codex slash command.
|
|
|
12
12
|
|
|
13
13
|
The script prints a leading-space `/router-feedback` line. The Weave Router reads that
|
|
14
14
|
exec output, records the feedback, and continues this turn — so run the script once and
|
|
15
|
-
do not repeat its output as your answer.
|
|
15
|
+
do not repeat its output as your answer. The router renders its own
|
|
16
|
+
acknowledgment, so do not restate or reason about it; end the turn.
|
|
@@ -43,7 +43,7 @@ Other things they might ask for:
|
|
|
43
43
|
|
|
44
44
|
If the command reports that this router doesn't expose model selection, that's a
|
|
45
45
|
Weave-hosted router: model selection belongs to the whole organization there, so
|
|
46
|
-
tell the user to change it at https://
|
|
46
|
+
tell the user to change it at https://app.weaveos.com/organization/settings/weave-router/models —
|
|
47
47
|
don't try to work around it. Its listing carries no on/off state, so present it
|
|
48
48
|
as a plain list; don't infer which models are enabled.
|
|
49
49
|
|
|
@@ -11,4 +11,5 @@ Do not send a user message and do not type a Codex slash command.
|
|
|
11
11
|
|
|
12
12
|
The script prints a leading-space `/unforce-model` line. The Weave Router reads that
|
|
13
13
|
exec output, clears the pin, and continues this turn — so run the script once and
|
|
14
|
-
do not repeat its output as your answer.
|
|
14
|
+
do not repeat its output as your answer. The router renders its own
|
|
15
|
+
acknowledgment, so do not restate or reason about it; end the turn.
|
|
@@ -11,4 +11,5 @@ Do not send a user message and do not type a Codex slash command.
|
|
|
11
11
|
|
|
12
12
|
The script prints a leading-space `/unforce-model` line. The Weave Router reads that
|
|
13
13
|
exec output, clears the pin, and continues this turn — so run the script once and
|
|
14
|
-
do not repeat its output as your answer.
|
|
14
|
+
do not repeat its output as your answer. The router renders its own
|
|
15
|
+
acknowledgment, so do not restate or reason about it; end the turn.
|
package/codex-status.sh
CHANGED
|
@@ -101,8 +101,93 @@ helper_dir="$(cd "$(dirname "$0")" 2>/dev/null && pwd -P)"
|
|
|
101
101
|
disabled_marker="$helper_dir/.weave-router-disabled"
|
|
102
102
|
router_badge_sentinel=$''
|
|
103
103
|
|
|
104
|
+
display_hidden_file() {
|
|
105
|
+
printf '%s/display-hidden-%s' "$state_root" "$(printf '%s' "$helper_dir" | cksum | tr -c '0-9' '-')"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
write_display_headers() {
|
|
109
|
+
printf 'header = "X-Weave-Router-Key: %s"\n' "$2" >"$1"
|
|
110
|
+
case "$3" in
|
|
111
|
+
''|*[!A-Za-z0-9@._+-]*) ;;
|
|
112
|
+
*) printf 'header = "X-Weave-User-Email: %s"\n' "$3" >>"$1" ;;
|
|
113
|
+
esac
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
refresh_display_settings() {
|
|
117
|
+
local base_url="$1" header_file="$2" max_time="$3" display_url display_body hidden="0" hidden_file
|
|
118
|
+
hidden_file="$(display_hidden_file)"
|
|
119
|
+
display_url="${WEAVE_CODEX_DISPLAY_SETTINGS_URL:-}"
|
|
120
|
+
if [ -z "$display_url" ]; then
|
|
121
|
+
display_url="${base_url%/}"
|
|
122
|
+
case "$display_url" in
|
|
123
|
+
file://*) ;;
|
|
124
|
+
*) display_url="${display_url%/v1}/v1/display-settings" ;;
|
|
125
|
+
esac
|
|
126
|
+
fi
|
|
127
|
+
display_body="$(curl -fsS --max-time "$max_time" --max-filesize 8192 -K "$header_file" "$display_url" 2>/dev/null)" || return 0
|
|
128
|
+
[ "$(jq -r '.hide_terminal_surfaces // false' <<<"$display_body" 2>/dev/null)" = "true" ] && hidden="1"
|
|
129
|
+
printf '%s' "$hidden" >"$hidden_file.tmp.$$" 2>/dev/null && mv "$hidden_file.tmp.$$" "$hidden_file" 2>/dev/null
|
|
130
|
+
rm -f "$hidden_file.tmp.$$" 2>/dev/null
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# A cold cache fetches the setting once in the foreground, briefly, so a
|
|
134
|
+
# subject whose surfaces are hidden never sees a branded first title.
|
|
135
|
+
display_file_younger_than() {
|
|
136
|
+
local mtime now
|
|
137
|
+
[ -f "$1" ] || return 1
|
|
138
|
+
mtime="$(stat -c %Y "$1" 2>/dev/null || stat -f %m "$1" 2>/dev/null)" || return 1
|
|
139
|
+
now="$(date +%s 2>/dev/null)" || return 1
|
|
140
|
+
[ $(( now - mtime )) -lt "$2" ]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# A cold cache, or a hidden setting past its grace window, fetches in the
|
|
144
|
+
# foreground; a merely stale setting refreshes in the background. Failed
|
|
145
|
+
# fetches are rate-limited by the .refreshed stamp.
|
|
146
|
+
prime_display_settings() {
|
|
147
|
+
local hidden_file stamp
|
|
148
|
+
hidden_file="$(display_hidden_file)"
|
|
149
|
+
stamp="$hidden_file.refreshed"
|
|
150
|
+
[ -f "$stamp" ] || [ ! -f "$hidden_file" ] || stamp="$hidden_file"
|
|
151
|
+
display_file_younger_than "$stamp" "${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-300}" && return 0
|
|
152
|
+
if [ -f "$hidden_file" ] && { [ "$(cat "$hidden_file" 2>/dev/null)" != "1" ] \
|
|
153
|
+
|| display_file_younger_than "$hidden_file" "${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"; }; then
|
|
154
|
+
touch "$hidden_file.refreshed" 2>/dev/null
|
|
155
|
+
( exec </dev/null >/dev/null 2>&1; prime_display_settings_now ) &
|
|
156
|
+
return 0
|
|
157
|
+
fi
|
|
158
|
+
prime_display_settings_now
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
prime_display_settings_now() {
|
|
162
|
+
local endpoint header_file
|
|
163
|
+
endpoint="$(read_codex_endpoint)" || return 0
|
|
164
|
+
[ -n "$endpoint" ] || return 0
|
|
165
|
+
mkdir -p "$state_root" 2>/dev/null || return 0
|
|
166
|
+
touch "$(display_hidden_file).refreshed" 2>/dev/null
|
|
167
|
+
header_file="$(mktemp "$state_root/.headers.XXXXXX")" || return 0
|
|
168
|
+
chmod 600 "$header_file"
|
|
169
|
+
write_display_headers "$header_file" "$(printf '%s' "$endpoint" | sed -n 2p)" "$(printf '%s' "$endpoint" | sed -n 3p)"
|
|
170
|
+
refresh_display_settings "$(printf '%s' "$endpoint" | sed -n 1p)" "$header_file" 2
|
|
171
|
+
rm -f "$header_file"
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
codex_surfaces_hidden() {
|
|
175
|
+
local hidden_file
|
|
176
|
+
prime_display_settings
|
|
177
|
+
hidden_file="$(display_hidden_file)"
|
|
178
|
+
if [ ! -f "$hidden_file" ]; then
|
|
179
|
+
display_file_younger_than "$hidden_file.refreshed" "${WEAVE_DISPLAY_SETTINGS_TTL_SECONDS:-300}"
|
|
180
|
+
return
|
|
181
|
+
fi
|
|
182
|
+
[ "$(cat "$hidden_file" 2>/dev/null)" = "1" ] || return 1
|
|
183
|
+
display_file_younger_than "$hidden_file" "${WEAVE_DISPLAY_SETTINGS_HIDDEN_GRACE_SECONDS:-604800}"
|
|
184
|
+
}
|
|
185
|
+
|
|
104
186
|
emit_title() {
|
|
105
187
|
local title="$1"
|
|
188
|
+
case "$title" in
|
|
189
|
+
"Weave Router"*) if codex_surfaces_hidden; then title="Codex"; fi ;;
|
|
190
|
+
esac
|
|
106
191
|
if [ -n "${WEAVE_CODEX_STATUS_TITLE_FILE:-}" ]; then
|
|
107
192
|
printf '%s\n' "$title" >"$WEAVE_CODEX_STATUS_TITLE_FILE"
|
|
108
193
|
elif { [ -t 2 ] || [ "${async_title_enabled:-0}" = "1" ]; } && [ -w /dev/tty ]; then
|
|
@@ -320,7 +405,12 @@ read_codex_endpoint() {
|
|
|
320
405
|
sub(/^.*=[[:space:]]*"/, "", v); sub(/"$/, "", v)
|
|
321
406
|
if (key == "") key = v
|
|
322
407
|
}
|
|
323
|
-
|
|
408
|
+
match($0, /"?X-Weave-User-Email"?[[:space:]]*=[[:space:]]*"[^"]*"/) {
|
|
409
|
+
v = substr($0, RSTART, RLENGTH)
|
|
410
|
+
sub(/^.*=[[:space:]]*"/, "", v); sub(/"$/, "", v)
|
|
411
|
+
if (email == "") email = v
|
|
412
|
+
}
|
|
413
|
+
END { if (url != "" && key != "") printf "%s\n%s\n%s\n", url, key, email }
|
|
324
414
|
' "$config" 2>/dev/null || true
|
|
325
415
|
}
|
|
326
416
|
|
|
@@ -333,10 +423,11 @@ refresh_session_cost() {
|
|
|
333
423
|
[ "${WEAVE_CODEX_STATUS_SAVINGS:-1}" = "0" ] && [ "${WEAVE_CODEX_STATUS_CONTEXT:-1}" = "0" ] && return 0
|
|
334
424
|
command -v curl >/dev/null 2>&1 || return 0
|
|
335
425
|
|
|
336
|
-
local endpoint base_url key active_file state_lock
|
|
426
|
+
local endpoint base_url key email active_file state_lock
|
|
337
427
|
endpoint="$(read_codex_endpoint)" || return 0
|
|
338
428
|
base_url="$(printf '%s' "$endpoint" | sed -n 1p)"
|
|
339
429
|
key="$(printf '%s' "$endpoint" | sed -n 2p)"
|
|
430
|
+
email="$(printf '%s' "$endpoint" | sed -n 3p)"
|
|
340
431
|
[ -n "$base_url" ] && [ -n "$key" ] || return 0
|
|
341
432
|
|
|
342
433
|
mkdir -p "$state_root" 2>/dev/null || return 0
|
|
@@ -369,7 +460,8 @@ refresh_session_cost() {
|
|
|
369
460
|
esac
|
|
370
461
|
header_file="$(mktemp "$state_root/.headers.XXXXXX")" || exit 0
|
|
371
462
|
chmod 600 "$header_file"
|
|
372
|
-
|
|
463
|
+
write_display_headers "$header_file" "$key" "$email"
|
|
464
|
+
refresh_display_settings "$base_url" "$header_file" 5
|
|
373
465
|
if ! body="$(curl -fsS --max-time 5 --max-filesize 8192 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
374
466
|
rm -f "$header_file"
|
|
375
467
|
exit 0
|
package/commands/models.md
CHANGED
|
@@ -38,7 +38,7 @@ Other things I might ask for:
|
|
|
38
38
|
|
|
39
39
|
If the command reports that this router doesn't expose model selection, that's
|
|
40
40
|
a Weave-hosted router: model selection belongs to the whole organization there,
|
|
41
|
-
so tell me to change it at https://
|
|
41
|
+
so tell me to change it at https://app.weaveos.com/organization/settings/weave-router/models —
|
|
42
42
|
don't try to work around it. Its listing carries no on/off state, so present it
|
|
43
43
|
as a plain list; don't infer which models are enabled.
|
|
44
44
|
|
|
@@ -38,7 +38,7 @@ Other things I might ask for:
|
|
|
38
38
|
|
|
39
39
|
If the command reports that this router doesn't expose model selection, that's
|
|
40
40
|
a Weave-hosted router: model selection belongs to the whole organization there,
|
|
41
|
-
so tell me to change it at https://
|
|
41
|
+
so tell me to change it at https://app.weaveos.com/organization/settings/weave-router/models —
|
|
42
42
|
don't try to work around it. Its listing carries no on/off state, so present it
|
|
43
43
|
as a plain list; don't infer which models are enabled.
|
|
44
44
|
|
package/directives.tsv
CHANGED
|
@@ -9,6 +9,7 @@ router-off||local-toggle|yes|yes|no|no|manual|command,skill
|
|
|
9
9
|
router-on||local-toggle|yes|yes|no|no|manual|command,skill
|
|
10
10
|
router-status||local-toggle|yes|yes|no|no|manual|command,skill
|
|
11
11
|
router-session||prompt|yes|yes|no|no|manual|command,skill
|
|
12
|
+
list-models||prompt|yes|yes|no|no|manual|command,skill
|
|
12
13
|
router-models|models|local-toggle|yes|yes|no|no|manual|command,skill
|
|
13
14
|
disable-routing||local-toggle|no|yes|no|no|manual|skill
|
|
14
15
|
beta||prompt|yes|no|no|yes|manual|command
|