@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/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
|
@@ -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
|
|
@@ -457,6 +469,9 @@ weave_hidden_gate() {
|
|
|
457
469
|
if [ -z "$key" ] && [ -f "$local_settings" ]; then
|
|
458
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)"
|
|
459
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
|
|
460
475
|
if [ -z "$base_url" ] && [ -f "$settings" ]; then
|
|
461
476
|
base_url="$(jq -r '.env.ANTHROPIC_BASE_URL // empty' "$settings" 2>/dev/null)"
|
|
462
477
|
fi
|
|
@@ -469,6 +484,12 @@ weave_hidden_gate() {
|
|
|
469
484
|
header_file="$(mktemp "$cache_dir/.headers.XXXXXX")" || exit 0
|
|
470
485
|
chmod 600 "$header_file"
|
|
471
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
|
|
472
493
|
if ! body="$(curl -fsS --max-time 5 -K "$header_file" "$url" 2>/dev/null)"; then
|
|
473
494
|
rm -f "$header_file"
|
|
474
495
|
exit 0
|
|
@@ -486,7 +507,18 @@ weave_hidden_gate() {
|
|
|
486
507
|
rm -f "$tmp" 2>/dev/null
|
|
487
508
|
) >/dev/null 2>&1 &
|
|
488
509
|
disown 2>/dev/null || true
|
|
489
|
-
|
|
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" ]
|
|
490
522
|
}
|
|
491
523
|
|
|
492
524
|
if weave_hidden_gate </dev/null; then
|
|
@@ -532,8 +564,10 @@ prices='{
|
|
|
532
564
|
"input": {
|
|
533
565
|
"claude-fable-5": 0.01,
|
|
534
566
|
"claude-fable-5-1": 0.01,
|
|
567
|
+
"claude-fable-5-2": 0.008,
|
|
535
568
|
"claude-haiku-4-5": 0.001,
|
|
536
569
|
"claude-haiku-5-5": 0.0001,
|
|
570
|
+
"claude-mythos-5-2": 0.008,
|
|
537
571
|
"claude-opus-4-0": 0.015,
|
|
538
572
|
"claude-opus-4-1": 0.015,
|
|
539
573
|
"claude-opus-4-5": 0.005,
|
|
@@ -597,6 +631,7 @@ prices='{
|
|
|
597
631
|
"grok-4.6": 0.002,
|
|
598
632
|
"grok-4.7": 0.002,
|
|
599
633
|
"inclusionai/ling-3.0-flash": 0.00006,
|
|
634
|
+
"meta/muse-spark-open": 0.00125,
|
|
600
635
|
"minimax/minimax-m2.7": 0.0003,
|
|
601
636
|
"minimax/minimax-m3": 0.0003,
|
|
602
637
|
"minimax/minimax-m3.1-flash": 0.00015,
|
|
@@ -606,7 +641,9 @@ prices='{
|
|
|
606
641
|
"moonshotai/kimi-k2.7": 0.00095,
|
|
607
642
|
"moonshotai/kimi-k3": 0.003,
|
|
608
643
|
"moonshotai/kimi-k3.1": 0.002,
|
|
644
|
+
"muse-ember-1.0": 0.0001,
|
|
609
645
|
"muse-spark-1.3": 0.00125,
|
|
646
|
+
"muse-wonder-1.0": 0.004,
|
|
610
647
|
"qwen/qwen3-235b-a22b-2507": 0.0002266,
|
|
611
648
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.00015,
|
|
612
649
|
"qwen/qwen3-coder": 0.0009,
|
|
@@ -628,8 +665,10 @@ prices='{
|
|
|
628
665
|
"output": {
|
|
629
666
|
"claude-fable-5": 0.05,
|
|
630
667
|
"claude-fable-5-1": 0.05,
|
|
668
|
+
"claude-fable-5-2": 0.04,
|
|
631
669
|
"claude-haiku-4-5": 0.005,
|
|
632
670
|
"claude-haiku-5-5": 0.0005,
|
|
671
|
+
"claude-mythos-5-2": 0.04,
|
|
633
672
|
"claude-opus-4-0": 0.075,
|
|
634
673
|
"claude-opus-4-1": 0.075,
|
|
635
674
|
"claude-opus-4-5": 0.025,
|
|
@@ -693,6 +732,7 @@ prices='{
|
|
|
693
732
|
"grok-4.6": 0.006,
|
|
694
733
|
"grok-4.7": 0.006,
|
|
695
734
|
"inclusionai/ling-3.0-flash": 0.00018,
|
|
735
|
+
"meta/muse-spark-open": 0.00425,
|
|
696
736
|
"minimax/minimax-m2.7": 0.0012,
|
|
697
737
|
"minimax/minimax-m3": 0.0012,
|
|
698
738
|
"minimax/minimax-m3.1-flash": 0.0006,
|
|
@@ -702,7 +742,9 @@ prices='{
|
|
|
702
742
|
"moonshotai/kimi-k2.7": 0.004,
|
|
703
743
|
"moonshotai/kimi-k3": 0.015,
|
|
704
744
|
"moonshotai/kimi-k3.1": 0.01,
|
|
745
|
+
"muse-ember-1.0": 0.0005,
|
|
705
746
|
"muse-spark-1.3": 0.00425,
|
|
747
|
+
"muse-wonder-1.0": 0.02,
|
|
706
748
|
"qwen/qwen3-235b-a22b-2507": 0.0009064,
|
|
707
749
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.0006,
|
|
708
750
|
"qwen/qwen3-coder": 0.0027,
|
|
@@ -724,8 +766,10 @@ prices='{
|
|
|
724
766
|
"cache_read": {
|
|
725
767
|
"claude-fable-5": 0.1,
|
|
726
768
|
"claude-fable-5-1": 0.025,
|
|
769
|
+
"claude-fable-5-2": 0.025,
|
|
727
770
|
"claude-haiku-4-5": 0.1,
|
|
728
771
|
"claude-haiku-5-5": 0.1,
|
|
772
|
+
"claude-mythos-5-2": 0.025,
|
|
729
773
|
"claude-opus-4-0": 0.1,
|
|
730
774
|
"claude-opus-4-1": 0.1,
|
|
731
775
|
"claude-opus-4-5": 0.1,
|
|
@@ -737,7 +781,7 @@ prices='{
|
|
|
737
781
|
"claude-sonnet-4-5": 0.1,
|
|
738
782
|
"claude-sonnet-4-6": 0.1,
|
|
739
783
|
"claude-sonnet-5": 0.1,
|
|
740
|
-
"claude-sonnet-5-5": 0.
|
|
784
|
+
"claude-sonnet-5-5": 0.05,
|
|
741
785
|
"deepseek/deepseek-v4-flash": 0.1,
|
|
742
786
|
"deepseek/deepseek-v4-pro": 0.0862,
|
|
743
787
|
"deepseek/deepseek-v4-pro-0813": 0.0862,
|
|
@@ -789,6 +833,7 @@ prices='{
|
|
|
789
833
|
"grok-4.6": 0.25,
|
|
790
834
|
"grok-4.7": 0.25,
|
|
791
835
|
"inclusionai/ling-3.0-flash": 0.2,
|
|
836
|
+
"meta/muse-spark-open": 0.12,
|
|
792
837
|
"minimax/minimax-m2.7": 0.2,
|
|
793
838
|
"minimax/minimax-m3": 0.2,
|
|
794
839
|
"minimax/minimax-m3.1-flash": 0.1,
|
|
@@ -798,7 +843,9 @@ prices='{
|
|
|
798
843
|
"moonshotai/kimi-k2.7": 0.2,
|
|
799
844
|
"moonshotai/kimi-k3": 0.1,
|
|
800
845
|
"moonshotai/kimi-k3.1": 0.1,
|
|
846
|
+
"muse-ember-1.0": 0.04,
|
|
801
847
|
"muse-spark-1.3": 0.12,
|
|
848
|
+
"muse-wonder-1.0": 0.05,
|
|
802
849
|
"qwen/qwen3-235b-a22b-2507": 0.5,
|
|
803
850
|
"qwen/qwen3-30b-a3b-instruct-2507": 0.1684,
|
|
804
851
|
"qwen/qwen3-coder": 0.1684,
|
|
@@ -1140,8 +1187,8 @@ if [ -n "${weave_disconnected_plans:-}" ]; then
|
|
|
1140
1187
|
fi
|
|
1141
1188
|
for weave_plan in ${weave_disconnected_plans:-}; do
|
|
1142
1189
|
case "$weave_plan" in
|
|
1143
|
-
claude) status_text="$status_text · Claude plan
|
|
1144
|
-
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" ;;
|
|
1145
1192
|
esac
|
|
1146
1193
|
done
|
|
1147
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/desktop-shim.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"use strict";
|
|
10
10
|
|
|
11
11
|
const { execFile } = require("node:child_process");
|
|
12
|
+
const crypto = require("node:crypto");
|
|
12
13
|
const fs = require("node:fs");
|
|
13
14
|
const http = require("node:http");
|
|
14
15
|
const https = require("node:https");
|
|
@@ -43,10 +44,12 @@ function loadConfig(file) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
return {
|
|
47
|
+
connectedMarker: `${file}.connected`,
|
|
46
48
|
host: parsed.listen_host || "127.0.0.1",
|
|
47
49
|
port: Number(parsed.listen_port ?? 47821),
|
|
48
50
|
router: new URL(parsed.router_base_url),
|
|
49
51
|
routerKey: typeof parsed.router_key === "string" ? parsed.router_key : "",
|
|
52
|
+
reportTimeoutMs: Number(parsed.report_timeout_ms ?? 5000),
|
|
50
53
|
anthropic: new URL(parsed.anthropic_origin || `https://${INTERCEPT_HOST}`),
|
|
51
54
|
cert: fs.readFileSync(parsed.cert_file),
|
|
52
55
|
key: fs.readFileSync(parsed.key_file),
|
|
@@ -101,6 +104,47 @@ function pacFile(port) {
|
|
|
101
104
|
`;
|
|
102
105
|
}
|
|
103
106
|
|
|
107
|
+
// reportConnected tells the router, once per router key, that Desktop's traffic
|
|
108
|
+
// reached it. Desktop shares the Claude Code key, so the router can't tell a
|
|
109
|
+
// Desktop connection from the key's first use. The marker is written only after
|
|
110
|
+
// the router accepts the report, so a failed report is retried on a later call.
|
|
111
|
+
function reportConnected(cfg) {
|
|
112
|
+
if (!cfg.routerKey || cfg.connectedReport) return;
|
|
113
|
+
const fingerprint = crypto.createHash("sha256").update(cfg.routerKey).digest("hex");
|
|
114
|
+
try {
|
|
115
|
+
if (fs.readFileSync(cfg.connectedMarker, "utf8").trim() === fingerprint) {
|
|
116
|
+
cfg.connectedReport = "done";
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
} catch {}
|
|
120
|
+
cfg.connectedReport = "pending";
|
|
121
|
+
const target = cfg.router;
|
|
122
|
+
const body = JSON.stringify({ action: "connected", harness: "claude_desktop" });
|
|
123
|
+
const client = target.protocol === "http:" ? http : https;
|
|
124
|
+
const req = client.request({
|
|
125
|
+
protocol: target.protocol,
|
|
126
|
+
hostname: target.hostname,
|
|
127
|
+
port: target.port || (target.protocol === "http:" ? 80 : 443),
|
|
128
|
+
method: "POST",
|
|
129
|
+
path: `${target.pathname.replace(/\/+$/, "")}/v1/client-events`,
|
|
130
|
+
headers: { "content-type": "application/json", "content-length": Buffer.byteLength(body), [ROUTER_KEY_HEADER]: cfg.routerKey },
|
|
131
|
+
timeout: cfg.reportTimeoutMs,
|
|
132
|
+
}, (res) => {
|
|
133
|
+
res.resume();
|
|
134
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
135
|
+
try {
|
|
136
|
+
fs.writeFileSync(cfg.connectedMarker, `${fingerprint}\n`, { mode: 0o600 });
|
|
137
|
+
} catch {}
|
|
138
|
+
cfg.connectedReport = "done";
|
|
139
|
+
} else {
|
|
140
|
+
cfg.connectedReport = undefined;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
req.on("timeout", () => req.destroy(new Error("connected report timed out")));
|
|
144
|
+
req.on("error", () => { cfg.connectedReport = undefined; });
|
|
145
|
+
req.end(body);
|
|
146
|
+
}
|
|
147
|
+
|
|
104
148
|
function forward(cfg, req, res) {
|
|
105
149
|
const toRouter = routesToRouter(req);
|
|
106
150
|
const target = toRouter ? cfg.router : cfg.anthropic;
|
|
@@ -123,6 +167,7 @@ function forward(cfg, req, res) {
|
|
|
123
167
|
headers,
|
|
124
168
|
},
|
|
125
169
|
(upstreamRes) => {
|
|
170
|
+
if (toRouter && upstreamRes.statusCode >= 200 && upstreamRes.statusCode < 300) reportConnected(cfg);
|
|
126
171
|
const out = {};
|
|
127
172
|
for (const [name, value] of Object.entries(upstreamRes.headers)) {
|
|
128
173
|
if (!HOP_BY_HOP.has(name)) out[name] = value;
|
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
|