@weave-os/router 0.2.23 → 0.2.24
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/LICENSE +201 -89
- package/NOTICE +16 -0
- package/README.md +18 -5
- package/cc-statusline.sh +21 -0
- package/codex-status.sh +24 -1
- package/install.sh +201 -39
- package/opencode-weave/README.md +9 -0
- package/opencode-weave/src/classifier-thread.ts +145 -0
- package/opencode-weave/src/index.ts +46 -12
- package/package.json +4 -3
- package/pi-router/src/pricing.generated.ts +8 -1
- package/uninstall.sh +8 -0
package/install.sh
CHANGED
|
@@ -680,14 +680,44 @@ strip_weave_codex_hooks() {
|
|
|
680
680
|
rm -f "$tmp" 2>/dev/null || true
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
# codex_existing_option finds a Codex setting before the managed block is
|
|
684
|
+
# replaced. Codex can save a selection inside our old block or immediately
|
|
685
|
+
# after it, where TOML incorrectly scopes it to the preceding table.
|
|
686
|
+
codex_existing_option() {
|
|
687
|
+
local config_file="$1" option="$2"
|
|
688
|
+
[ -f "$config_file" ] || return 0
|
|
689
|
+
awk -v begin="$WEAVE_CODEX_BEGIN_MARKER" -v end="$WEAVE_CODEX_END_MARKER" -v key="$option" '
|
|
690
|
+
BEGIN { option_pattern = "^[[:space:]]*" key "[[:space:]]*=" }
|
|
691
|
+
$0 == begin { in_managed = 1; managed_top = 1; after_managed = 0; next }
|
|
692
|
+
$0 == end { in_managed = 0; after_managed = 1; next }
|
|
693
|
+
/^[[:space:]]*\[/ {
|
|
694
|
+
in_section = 1
|
|
695
|
+
if (in_managed) managed_top = 0
|
|
696
|
+
else after_managed = 0
|
|
697
|
+
in_weave_provider = ($0 ~ /^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*\][[:space:]]*(#.*)?$/)
|
|
698
|
+
next
|
|
699
|
+
}
|
|
700
|
+
$0 ~ option_pattern {
|
|
701
|
+
if (!in_managed && !in_section) outside = $0
|
|
702
|
+
else if (!in_managed && (after_managed || in_weave_provider)) misplaced = $0
|
|
703
|
+
else if (in_managed && managed_top) managed = $0
|
|
704
|
+
}
|
|
705
|
+
END {
|
|
706
|
+
if (outside != "") print "T" outside
|
|
707
|
+
else if (misplaced != "") print "S" misplaced
|
|
708
|
+
else if (managed != "") print "B" managed
|
|
709
|
+
}
|
|
710
|
+
' "$config_file"
|
|
711
|
+
}
|
|
712
|
+
|
|
683
713
|
# write_codex_config writes a managed [model_providers.weave] block to the
|
|
684
714
|
# Codex CLI's config.toml. Sets `model_provider = "weave"` at the top level so
|
|
685
715
|
# Codex picks the routed provider by default. The provider requires OpenAI
|
|
686
716
|
# authentication, preserving the user's ChatGPT plan credential while the
|
|
687
717
|
# router key is sent independently. The router applies OAuth only to its
|
|
688
718
|
# native gpt-5.6 Sol/Terra/Luna family; all other routed models use WorkWeave
|
|
689
|
-
# deployment or BYOK credentials.
|
|
690
|
-
# markers so
|
|
719
|
+
# deployment or BYOK credentials. The model choice stays outside the managed
|
|
720
|
+
# markers so Codex can update it without a reinstall resetting it. We strip any
|
|
691
721
|
# top-level `model_provider = ...` declaration OUTSIDE the markers before
|
|
692
722
|
# appending so the file doesn't end up with a duplicate key (TOML rejects
|
|
693
723
|
# that). Inline `model_provider` keys inside `[profiles.*]` sections stay
|
|
@@ -701,6 +731,24 @@ write_codex_config() {
|
|
|
701
731
|
local block_email="${4:-}"
|
|
702
732
|
local block_name="${5:-}"
|
|
703
733
|
|
|
734
|
+
if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ]; then
|
|
735
|
+
local capture_url="${WEAVE_CAPTURE_PROXY_URL:-http://127.0.0.1:41984}"
|
|
736
|
+
if ! [[ "$capture_url" =~ ^http://(127\.0\.0\.1|localhost):[0-9]+$ ]]; then
|
|
737
|
+
err "Classifier opt-in requires a loopback WEAVE_CAPTURE_PROXY_URL"
|
|
738
|
+
return 1
|
|
739
|
+
fi
|
|
740
|
+
block_url="$capture_url"
|
|
741
|
+
if ! command -v jq >/dev/null 2>&1; then
|
|
742
|
+
err "Classifier opt-in requires jq to verify the capture proxy"
|
|
743
|
+
return 1
|
|
744
|
+
fi
|
|
745
|
+
if ! curl -fsS --max-time 2 "$capture_url/healthz" | jq -e --arg upstream "$2" \
|
|
746
|
+
'.classifier_enabled == true and .upstream == $upstream' >/dev/null; then
|
|
747
|
+
err "Classifier capture proxy is unavailable or targets a different router"
|
|
748
|
+
return 1
|
|
749
|
+
fi
|
|
750
|
+
fi
|
|
751
|
+
|
|
704
752
|
# Escape `\` and `"` for TOML basic strings. Order matters: replace
|
|
705
753
|
# backslashes first so the quotes we add next aren't double-escaped. A
|
|
706
754
|
# display name like `John "J" Doe` would otherwise produce invalid TOML and
|
|
@@ -734,11 +782,21 @@ write_codex_config() {
|
|
|
734
782
|
# Tag the client so telemetry can attribute traffic to Codex vs other CLIs
|
|
735
783
|
# that share the same router key. The router otherwise has to guess from
|
|
736
784
|
# User-Agent.
|
|
737
|
-
headers_parts="${headers_parts}, \"X-App\" = \"codex\""
|
|
785
|
+
headers_parts="${headers_parts}, \"X-App\" = \"codex\", \"X-Weave-Codex-Native-Model-Pin\" = \"1\""
|
|
738
786
|
# No strategy header: pinning one here freezes installed clients on whatever
|
|
739
787
|
# policy was current at install time, so a deployment-default change never
|
|
740
788
|
# reaches them. Every endpoint, hosted or self-hosted, uses its own default.
|
|
741
789
|
local headers_line="http_headers = { ${headers_parts} }"
|
|
790
|
+
local codex_model_line='model = "weave-auto"' codex_effort_line="" saved_option
|
|
791
|
+
saved_option="$(codex_existing_option "$config_file" model)"
|
|
792
|
+
case "${saved_option:0:1}" in
|
|
793
|
+
T) codex_model_line="" ;;
|
|
794
|
+
S|B) codex_model_line="${saved_option:1}" ;;
|
|
795
|
+
esac
|
|
796
|
+
saved_option="$(codex_existing_option "$config_file" model_reasoning_effort)"
|
|
797
|
+
case "${saved_option:0:1}" in
|
|
798
|
+
S|B) codex_effort_line="${saved_option:1}" ;;
|
|
799
|
+
esac
|
|
742
800
|
|
|
743
801
|
local hook_feature_line="features.hooks = true"
|
|
744
802
|
local hook_block=""
|
|
@@ -757,6 +815,10 @@ write_codex_config() {
|
|
|
757
815
|
if [ -f "$config_file" ] && grep -q '^\[features\]$' "$config_file"; then
|
|
758
816
|
hook_feature_line=""
|
|
759
817
|
fi
|
|
818
|
+
if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ] && [ "$codex_hooks_enabled" != "true" ]; then
|
|
819
|
+
err "Classifier opt-in requires managed Codex lifecycle hooks; existing hook configuration is incompatible"
|
|
820
|
+
return 1
|
|
821
|
+
fi
|
|
760
822
|
if [ "$codex_hooks_enabled" = "true" ]; then
|
|
761
823
|
# UserPromptSubmit is registered only when OUR hook is actually on disk.
|
|
762
824
|
# Existence alone is the wrong test: install_codex_directive_script leaves
|
|
@@ -790,6 +852,22 @@ type = "command"
|
|
|
790
852
|
command = "${esc_status}"
|
|
791
853
|
TOML
|
|
792
854
|
)${directive_hook_block}"
|
|
855
|
+
if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ]; then
|
|
856
|
+
hook_block="${hook_block}$(cat <<TOML
|
|
857
|
+
|
|
858
|
+
[[hooks.PreToolUse]]
|
|
859
|
+
matcher = "spawn_agent"
|
|
860
|
+
[[hooks.PreToolUse.hooks]]
|
|
861
|
+
type = "command"
|
|
862
|
+
command = "${esc_status}"
|
|
863
|
+
|
|
864
|
+
[[hooks.PreCompact]]
|
|
865
|
+
[[hooks.PreCompact.hooks]]
|
|
866
|
+
type = "command"
|
|
867
|
+
command = "${esc_status}"
|
|
868
|
+
TOML
|
|
869
|
+
)"
|
|
870
|
+
fi
|
|
793
871
|
fi
|
|
794
872
|
local block
|
|
795
873
|
block="$(cat <<TOML
|
|
@@ -809,7 +887,10 @@ ${headers_line}
|
|
|
809
887
|
${hook_block}
|
|
810
888
|
${WEAVE_CODEX_END_MARKER}
|
|
811
889
|
TOML
|
|
812
|
-
)"
|
|
890
|
+
)"
|
|
891
|
+
local codex_insertion="$block"
|
|
892
|
+
[ -z "$codex_effort_line" ] || codex_insertion="${codex_effort_line}"$'\n'"${codex_insertion}"
|
|
893
|
+
[ -z "$codex_model_line" ] || codex_insertion="${codex_model_line}"$'\n'"${codex_insertion}"
|
|
813
894
|
|
|
814
895
|
if [ -f "$config_file" ]; then
|
|
815
896
|
local tmp; tmp="$(mktemp -t weave-codex.XXXXXX)"
|
|
@@ -829,10 +910,11 @@ TOML
|
|
|
829
910
|
# refused to start with "duplicate key" while the installer reported
|
|
830
911
|
# success.
|
|
831
912
|
awk -v begin="$WEAVE_CODEX_BEGIN_MARKER" -v end="$WEAVE_CODEX_END_MARKER" '
|
|
832
|
-
$0 == begin { skip = 1; next }
|
|
833
|
-
$0 == end { skip = 0; next }
|
|
913
|
+
$0 == begin { skip = 1; after_managed = 0; next }
|
|
914
|
+
$0 == end { skip = 0; after_managed = 1; next }
|
|
834
915
|
skip { next }
|
|
835
916
|
/^[[:space:]]*\[/ {
|
|
917
|
+
after_managed = 0
|
|
836
918
|
in_section = 1
|
|
837
919
|
if ($0 ~ /^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*(\.[^]]*)?\][[:space:]]*(#.*)?$/) {
|
|
838
920
|
in_weave_provider = 1
|
|
@@ -841,6 +923,9 @@ TOML
|
|
|
841
923
|
in_weave_provider = 0
|
|
842
924
|
}
|
|
843
925
|
in_weave_provider { next }
|
|
926
|
+
after_managed && /^[[:space:]]*(model|model_reasoning_effort)[[:space:]]*=/ { next }
|
|
927
|
+
!in_section && /^[[:space:]]*#[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave".*weave-router: off/ { next }
|
|
928
|
+
!in_section && /^[[:space:]]*#[[:space:]]*model[[:space:]]*=[[:space:]]*"weave-auto".*weave-router: off/ { next }
|
|
844
929
|
!in_section && /^[[:space:]]*model_provider[[:space:]]*=/ { next }
|
|
845
930
|
{ print }
|
|
846
931
|
' "$config_file" >"$tmp"
|
|
@@ -876,7 +961,7 @@ EOF
|
|
|
876
961
|
if [ "$first_section" -gt 1 ]; then
|
|
877
962
|
head -n "$((first_section - 1))" "$tmp"
|
|
878
963
|
fi
|
|
879
|
-
printf "%s\n" "$
|
|
964
|
+
printf "%s\n" "$codex_insertion"
|
|
880
965
|
tail -n "+${first_section}" "$tmp"
|
|
881
966
|
} >"$config_file"
|
|
882
967
|
else
|
|
@@ -884,11 +969,11 @@ EOF
|
|
|
884
969
|
# already at top-level. Our block ends with its own [section], so
|
|
885
970
|
# appending is safe (no bare keys follow).
|
|
886
971
|
cp "$tmp" "$config_file"
|
|
887
|
-
printf "\n%s\n" "$
|
|
972
|
+
printf "\n%s\n" "$codex_insertion" >>"$config_file"
|
|
888
973
|
fi
|
|
889
974
|
rm -f "$tmp"
|
|
890
975
|
else
|
|
891
|
-
printf "%s\n" "$
|
|
976
|
+
printf "%s\n" "$codex_insertion" >"$config_file"
|
|
892
977
|
fi
|
|
893
978
|
|
|
894
979
|
# If the user already has a [features] table, place our managed hook
|
|
@@ -1025,19 +1110,20 @@ write_opencode_config() {
|
|
|
1025
1110
|
# config; ChatGPT tokens live in opencode's own auth store), so 644 is fine.
|
|
1026
1111
|
# Source is bundled alongside install.sh by the npm prepack
|
|
1027
1112
|
# (scripts/copy-installer.js), same as commands/ + pi-router/.
|
|
1028
|
-
local plugin_dir plugin_spec plugin_src plugin_arg=""
|
|
1113
|
+
local plugin_dir plugin_spec plugin_src plugin_directives_src plugin_classifier_src plugin_arg=""
|
|
1029
1114
|
plugin_dir="$(cd "$(dirname "$config_file")" && pwd)/.weave"
|
|
1030
1115
|
plugin_spec="$plugin_dir/opencode-weave.ts"
|
|
1031
1116
|
plugin_src="$script_dir/opencode-weave/src/index.ts"
|
|
1032
1117
|
plugin_directives_src="$script_dir/opencode-weave/src/directives.ts"
|
|
1033
|
-
|
|
1118
|
+
plugin_classifier_src="$script_dir/opencode-weave/src/classifier-thread.ts"
|
|
1119
|
+
if [ -f "$plugin_src" ] && [ -f "$plugin_directives_src" ] && [ -f "$plugin_classifier_src" ]; then
|
|
1034
1120
|
mkdir -p "$plugin_dir"
|
|
1035
1121
|
cp "$plugin_src" "$plugin_spec"
|
|
1036
1122
|
chmod 644 "$plugin_spec"
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1123
|
+
cp "$plugin_directives_src" "$plugin_dir/directives.ts"
|
|
1124
|
+
chmod 644 "$plugin_dir/directives.ts"
|
|
1125
|
+
cp "$plugin_classifier_src" "$plugin_dir/classifier-thread.ts"
|
|
1126
|
+
chmod 644 "$plugin_dir/classifier-thread.ts"
|
|
1041
1127
|
plugin_arg="$plugin_spec"
|
|
1042
1128
|
else
|
|
1043
1129
|
warn "opencode subscription plugin source not found at $plugin_src — skipping the Claude login + subscription routing. (Use a packaged 'npx $npm_package_name' install.)"
|
|
@@ -1175,11 +1261,14 @@ write_pi_models_config() {
|
|
|
1175
1261
|
models: [
|
|
1176
1262
|
{ id: "claude-fable-5-1", name: "Claude Fable 5.1 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1177
1263
|
{ id: "claude-fable-5", name: "Claude Fable 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1264
|
+
{ id: "claude-opus-5-5", name: "Claude Opus 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1178
1265
|
{ id: "claude-opus-5", name: "Claude Opus 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
|
|
1179
1266
|
{ id: "claude-opus-4-7", name: "Claude Opus 4.7 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
|
|
1180
1267
|
{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
|
|
1181
1268
|
{ id: "claude-haiku-4-5", name: "Claude Haiku 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 200000, maxTokens: 32000 },
|
|
1182
1269
|
{ id: "gpt-6-astra", name: "GPT-6 Astra (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1270
|
+
{ id: "gpt-6-sol", name: "GPT-6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1271
|
+
{ id: "gpt-6-luna", name: "GPT-6 Luna (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1183
1272
|
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
|
|
1184
1273
|
{ id: "grok-4.5", name: "Grok 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
|
|
1185
1274
|
{ id: "grok-4.6", name: "Grok 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
|
|
@@ -2483,8 +2572,7 @@ prepare_claude_context_window() {
|
|
|
2483
2572
|
if [ "$scope" = "project" ] && [ -z "$install_dir" ]; then
|
|
2484
2573
|
context_settings_file="$local_settings_file"
|
|
2485
2574
|
fi
|
|
2486
|
-
|
|
2487
|
-
refuse_if_symlink "$context_state_file"
|
|
2575
|
+
refuse_if_symlink "$settings_dir/.weave-context-window.json"
|
|
2488
2576
|
[ -n "$context_window" ] || return 0
|
|
2489
2577
|
|
|
2490
2578
|
local source model="" disabled="${CLAUDE_CODE_DISABLE_1M_CONTEXT:-}" env_model="${ANTHROPIC_MODEL:-}"
|
|
@@ -2506,7 +2594,7 @@ prepare_claude_context_window() {
|
|
|
2506
2594
|
model="${model:-sonnet}"
|
|
2507
2595
|
case "$model" in
|
|
2508
2596
|
*'[1m]') context_window=""; return 0 ;;
|
|
2509
|
-
sonnet|opus|fable|claude-sonnet-4-6|claude-sonnet-5|claude-opus-4-6|claude-opus-4-7|claude-opus-4-8|claude-opus-5|claude-fable-5|claude-fable-5-1) ;;
|
|
2597
|
+
sonnet|opus|fable|claude-sonnet-4-6|claude-sonnet-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) ;;
|
|
2510
2598
|
*) err "Cannot assert 1M support for '$model'. Select a supported Sonnet/Opus/Fable model first; leaving it unchanged."; return 1 ;;
|
|
2511
2599
|
esac
|
|
2512
2600
|
context_managed_model="${model}[1m]"
|
|
@@ -2530,7 +2618,7 @@ apply_claude_context_window() {
|
|
|
2530
2618
|
if .model == $s.managed then
|
|
2531
2619
|
if $s.had_model then .model = $s.original else del(.model) end
|
|
2532
2620
|
else . end
|
|
2533
|
-
elif ($action == "install" or $action == "on"
|
|
2621
|
+
elif ($action == "install" or $action == "on") and has("model") == $s.had_model and .model == $s.original then .model = $s.managed
|
|
2534
2622
|
else . end
|
|
2535
2623
|
' "$active")"
|
|
2536
2624
|
fi
|
|
@@ -2705,12 +2793,16 @@ toggle_claude() {
|
|
|
2705
2793
|
toggle_codex() {
|
|
2706
2794
|
local f="$codex_config_file" state="absent" tmp
|
|
2707
2795
|
if [ -f "$f" ]; then
|
|
2708
|
-
state="$(awk
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
END{
|
|
2796
|
+
state="$(awk '
|
|
2797
|
+
/^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*\]/ { has_weave = 1 }
|
|
2798
|
+
/^[[:space:]]*\[/ { in_section = 1 }
|
|
2799
|
+
!in_section && /^[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"[[:space:]]*$/ { active_weave = 1 }
|
|
2800
|
+
!in_section && /^[[:space:]]*model_provider[[:space:]]*=/ { has_active_provider = 1 }
|
|
2801
|
+
END {
|
|
2802
|
+
if (!has_weave) print "absent"
|
|
2803
|
+
else if (active_weave) print "on"
|
|
2804
|
+
else print (has_active_provider ? "absent" : "off")
|
|
2805
|
+
}
|
|
2714
2806
|
' "$f")"
|
|
2715
2807
|
fi
|
|
2716
2808
|
|
|
@@ -2726,10 +2818,12 @@ toggle_codex() {
|
|
|
2726
2818
|
if [ "$state" = "absent" ]; then info "Codex isn't configured for the router. Run the installer first."; return 0; fi
|
|
2727
2819
|
if [ "$state" = "off" ]; then ok "Codex is already off — nothing to do."; return 0; fi
|
|
2728
2820
|
tmp="$(mktemp -t weave-codex-toggle.XXXXXX)"
|
|
2729
|
-
awk
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2821
|
+
awk '
|
|
2822
|
+
/^[[:space:]]*\[/ { in_section = 1 }
|
|
2823
|
+
!in_section && /^[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"[[:space:]]*$/ {
|
|
2824
|
+
print "# " $0 " # weave-router: off (run on to re-enable)"; next
|
|
2825
|
+
}
|
|
2826
|
+
!in_section && /^[[:space:]]*model[[:space:]]*=[[:space:]]*"weave-auto"[[:space:]]*$/ {
|
|
2733
2827
|
print "# " $0 " # weave-router: off (run on to re-enable)"; next
|
|
2734
2828
|
}
|
|
2735
2829
|
{print}
|
|
@@ -2744,13 +2838,39 @@ toggle_codex() {
|
|
|
2744
2838
|
if [ "$state" = "absent" ]; then warn "No managed Weave block in $f. Run the installer to set up Codex."; return 0; fi
|
|
2745
2839
|
if [ "$state" = "on" ]; then ok "Codex is already on — nothing to do."; return 0; fi
|
|
2746
2840
|
tmp="$(mktemp -t weave-codex-toggle.XXXXXX)"
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2841
|
+
local has_top_model="false"
|
|
2842
|
+
if awk '
|
|
2843
|
+
/^[[:space:]]*\[/ { in_section = 1 }
|
|
2844
|
+
!in_section && /^[[:space:]]*model[[:space:]]*=/ { found = 1 }
|
|
2845
|
+
END { exit(found ? 0 : 1) }
|
|
2846
|
+
' "$f"; then
|
|
2847
|
+
has_top_model="true"
|
|
2848
|
+
fi
|
|
2849
|
+
awk -v has_top_model="$has_top_model" '
|
|
2850
|
+
function add_missing_settings() {
|
|
2851
|
+
if (!restored_provider) print "model_provider = \"weave\""
|
|
2852
|
+
if (has_top_model != "true" && !restored_model) print "model = \"weave-auto\""
|
|
2853
|
+
}
|
|
2854
|
+
/^[[:space:]]*\[/ {
|
|
2855
|
+
if (!in_section) add_missing_settings()
|
|
2856
|
+
in_section = 1
|
|
2857
|
+
}
|
|
2858
|
+
!in_section && /^[[:space:]]*#[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave".*weave-router: off/ {
|
|
2859
|
+
if (!restored_provider) {
|
|
2860
|
+
print "model_provider = \"weave\""
|
|
2861
|
+
restored_provider = 1
|
|
2862
|
+
}
|
|
2863
|
+
next
|
|
2864
|
+
}
|
|
2865
|
+
!in_section && /^[[:space:]]*#[[:space:]]*model[[:space:]]*=[[:space:]]*"weave-auto".*weave-router: off/ {
|
|
2866
|
+
if (has_top_model != "true" && !restored_model) {
|
|
2867
|
+
print "model = \"weave-auto\""
|
|
2868
|
+
restored_model = 1
|
|
2869
|
+
}
|
|
2870
|
+
next
|
|
2752
2871
|
}
|
|
2753
2872
|
{print}
|
|
2873
|
+
END { if (!in_section) add_missing_settings() }
|
|
2754
2874
|
' "$f" >"$tmp" && mv "$tmp" "$f"
|
|
2755
2875
|
chmod 600 "$f"
|
|
2756
2876
|
if [ -f "$codex_status_file" ] && grep -Fq '<!-- weave-router managed codex status -->' "$codex_status_file"; then
|
|
@@ -4133,6 +4253,9 @@ set -euo pipefail
|
|
|
4133
4253
|
# WEAVE_STATUSLINE_UPDATE and WEAVE_STATUSLINE_UPDATE_INTERVAL_DAYS variables
|
|
4134
4254
|
# remain accepted as aliases for users who configure both clients together.
|
|
4135
4255
|
weave_self_refresh() {
|
|
4256
|
+
# The published helper may predate classifier lifecycle forwarding. Do not
|
|
4257
|
+
# replace the hook implementation underneath an opted-in session.
|
|
4258
|
+
[ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ] && return 0
|
|
4136
4259
|
[ "${WEAVE_CODEX_STATUS_UPDATE:-${WEAVE_STATUSLINE_UPDATE:-1}}" = "0" ] && return 0
|
|
4137
4260
|
command -v curl >/dev/null 2>&1 || return 0
|
|
4138
4261
|
|
|
@@ -4199,9 +4322,10 @@ emit_title() {
|
|
|
4199
4322
|
local title="$1"
|
|
4200
4323
|
if [ -n "${WEAVE_CODEX_STATUS_TITLE_FILE:-}" ]; then
|
|
4201
4324
|
printf '%s\n' "$title" >"$WEAVE_CODEX_STATUS_TITLE_FILE"
|
|
4202
|
-
elif [ -w /dev/tty ]; then
|
|
4325
|
+
elif [ -t 2 ] && [ -w /dev/tty ]; then
|
|
4203
4326
|
printf '\033]0;%s\007' "$title" >/dev/tty
|
|
4204
4327
|
fi
|
|
4328
|
+
return 0
|
|
4205
4329
|
}
|
|
4206
4330
|
|
|
4207
4331
|
safe_session_id() {
|
|
@@ -4429,6 +4553,21 @@ command -v jq >/dev/null 2>&1 || exit 0
|
|
|
4429
4553
|
jq -e . >/dev/null 2>&1 <<<"$payload" || exit 0
|
|
4430
4554
|
|
|
4431
4555
|
hook_event_name="$(jq -r '.hook_event_name // ""' <<<"$payload")"
|
|
4556
|
+
if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ] && [ -n "${WEAVE_CAPTURE_HOOK_TOKEN:-}" ]; then
|
|
4557
|
+
classifier_hook_url="${WEAVE_CAPTURE_HOOK_URL:-http://127.0.0.1:41984/classifier/hook}"
|
|
4558
|
+
if [[ "$classifier_hook_url" =~ ^http://(127\.0\.0\.1|localhost|\[::1\]):[0-9]+/classifier/hook$ ]]; then
|
|
4559
|
+
case "$hook_event_name" in
|
|
4560
|
+
SessionStart|PreToolUse|PreCompact)
|
|
4561
|
+
# Send lifecycle identifiers only. A failed hook cannot enroll a thread;
|
|
4562
|
+
# the opted-in capture proxy rejects its inference request instead.
|
|
4563
|
+
jq -c '{hook_event_name,session_id,source,tool_name}' <<<"$payload" |
|
|
4564
|
+
curl -fsS --max-time 2 -H 'Content-Type: application/json' \
|
|
4565
|
+
-H "X-Weave-Capture-Hook-Token: $WEAVE_CAPTURE_HOOK_TOKEN" \
|
|
4566
|
+
--data-binary @- "$classifier_hook_url" >/dev/null 2>&1 || true
|
|
4567
|
+
;;
|
|
4568
|
+
esac
|
|
4569
|
+
fi
|
|
4570
|
+
fi
|
|
4432
4571
|
if [ "$hook_event_name" = "SessionStart" ]; then
|
|
4433
4572
|
if [ -f "$disabled_marker" ]; then
|
|
4434
4573
|
emit_title "Codex · direct"
|
|
@@ -4438,6 +4577,10 @@ if [ "$hook_event_name" = "SessionStart" ]; then
|
|
|
4438
4577
|
exit 0
|
|
4439
4578
|
fi
|
|
4440
4579
|
|
|
4580
|
+
if [ "$hook_event_name" = "PreToolUse" ] || [ "$hook_event_name" = "PreCompact" ]; then
|
|
4581
|
+
exit 0
|
|
4582
|
+
fi
|
|
4583
|
+
|
|
4441
4584
|
if [ -f "$disabled_marker" ]; then
|
|
4442
4585
|
exit 0
|
|
4443
4586
|
fi
|
|
@@ -4858,8 +5001,7 @@ if [ "$target" = "opencode" ]; then
|
|
|
4858
5001
|
for entry in \
|
|
4859
5002
|
"opencode.json" \
|
|
4860
5003
|
".weave/" \
|
|
4861
|
-
".weave-parked.json"
|
|
4862
|
-
".opencode/commands/*.weave-router"
|
|
5004
|
+
".weave-parked.json"
|
|
4863
5005
|
do
|
|
4864
5006
|
if [ ! -f "$gitignore" ] || ! grep -qxF "$entry" "$gitignore"; then
|
|
4865
5007
|
printf '%s\n' "$entry" >>"$gitignore"
|
|
@@ -5444,12 +5586,14 @@ prices='{
|
|
|
5444
5586
|
"claude-opus-4-7": 0.005,
|
|
5445
5587
|
"claude-opus-4-8": 0.005,
|
|
5446
5588
|
"claude-opus-5": 0.005,
|
|
5589
|
+
"claude-opus-5-5": 0.004,
|
|
5447
5590
|
"claude-sonnet-4-5": 0.003,
|
|
5448
5591
|
"claude-sonnet-4-6": 0.003,
|
|
5449
5592
|
"claude-sonnet-5": 0.003,
|
|
5450
5593
|
"deepseek/deepseek-v4-flash": 0.0001134,
|
|
5451
5594
|
"deepseek/deepseek-v4-pro": 0.00174,
|
|
5452
5595
|
"deepseek/deepseek-v4-pro-0813": 0.00174,
|
|
5596
|
+
"deepseek/deepseek-v4.1-flash": 0.00022,
|
|
5453
5597
|
"gemini-2.0-flash": 0.0001,
|
|
5454
5598
|
"gemini-2.0-flash-lite": 0.000075,
|
|
5455
5599
|
"gemini-2.5-flash": 0.0003,
|
|
@@ -5488,9 +5632,12 @@ prices='{
|
|
|
5488
5632
|
"gpt-5.6-sol-pro": 0.004,
|
|
5489
5633
|
"gpt-5.6-terra": 0.002,
|
|
5490
5634
|
"gpt-6-astra": 0.01,
|
|
5635
|
+
"gpt-6-luna": 0.0001,
|
|
5636
|
+
"gpt-6-sol": 0.002,
|
|
5491
5637
|
"grok-4.5": 0.002,
|
|
5492
5638
|
"grok-4.6": 0.002,
|
|
5493
5639
|
"grok-4.7": 0.002,
|
|
5640
|
+
"inclusionai/ling-3.0-flash": 0.00006,
|
|
5494
5641
|
"minimax/minimax-m2.7": 0.0003,
|
|
5495
5642
|
"minimax/minimax-m3": 0.0003,
|
|
5496
5643
|
"mistralai/mistral-small-2603": 0.0002,
|
|
@@ -5509,6 +5656,8 @@ prices='{
|
|
|
5509
5656
|
"qwen/qwen3.7-plus": 0.0004,
|
|
5510
5657
|
"qwen/qwen3.8-max": 0.002,
|
|
5511
5658
|
"xiaomi/mimo-v2.5-pro": 0.001,
|
|
5659
|
+
"xiaomi/mimo-v2.6-flash": 0.00014,
|
|
5660
|
+
"xiaomi/mimo-v2.6-pro": 0.000435,
|
|
5512
5661
|
"z-ai/glm-5": 0.001,
|
|
5513
5662
|
"z-ai/glm-5.1": 0.0014,
|
|
5514
5663
|
"z-ai/glm-5.2": 0.0014,
|
|
@@ -5526,12 +5675,14 @@ prices='{
|
|
|
5526
5675
|
"claude-opus-4-7": 0.025,
|
|
5527
5676
|
"claude-opus-4-8": 0.025,
|
|
5528
5677
|
"claude-opus-5": 0.025,
|
|
5678
|
+
"claude-opus-5-5": 0.02,
|
|
5529
5679
|
"claude-sonnet-4-5": 0.015,
|
|
5530
5680
|
"claude-sonnet-4-6": 0.015,
|
|
5531
5681
|
"claude-sonnet-5": 0.015,
|
|
5532
5682
|
"deepseek/deepseek-v4-flash": 0.0002791,
|
|
5533
5683
|
"deepseek/deepseek-v4-pro": 0.00348,
|
|
5534
5684
|
"deepseek/deepseek-v4-pro-0813": 0.00348,
|
|
5685
|
+
"deepseek/deepseek-v4.1-flash": 0.00066,
|
|
5535
5686
|
"gemini-2.0-flash": 0.0004,
|
|
5536
5687
|
"gemini-2.0-flash-lite": 0.0003,
|
|
5537
5688
|
"gemini-2.5-flash": 0.0012,
|
|
@@ -5570,9 +5721,12 @@ prices='{
|
|
|
5570
5721
|
"gpt-5.6-sol-pro": 0.02,
|
|
5571
5722
|
"gpt-5.6-terra": 0.012,
|
|
5572
5723
|
"gpt-6-astra": 0.05,
|
|
5724
|
+
"gpt-6-luna": 0.0005,
|
|
5725
|
+
"gpt-6-sol": 0.01,
|
|
5573
5726
|
"grok-4.5": 0.006,
|
|
5574
5727
|
"grok-4.6": 0.006,
|
|
5575
5728
|
"grok-4.7": 0.006,
|
|
5729
|
+
"inclusionai/ling-3.0-flash": 0.00018,
|
|
5576
5730
|
"minimax/minimax-m2.7": 0.0012,
|
|
5577
5731
|
"minimax/minimax-m3": 0.0012,
|
|
5578
5732
|
"mistralai/mistral-small-2603": 0.0006,
|
|
@@ -5591,6 +5745,8 @@ prices='{
|
|
|
5591
5745
|
"qwen/qwen3.7-plus": 0.0016,
|
|
5592
5746
|
"qwen/qwen3.8-max": 0.006,
|
|
5593
5747
|
"xiaomi/mimo-v2.5-pro": 0.003,
|
|
5748
|
+
"xiaomi/mimo-v2.6-flash": 0.00028,
|
|
5749
|
+
"xiaomi/mimo-v2.6-pro": 0.00087,
|
|
5594
5750
|
"z-ai/glm-5": 0.0032,
|
|
5595
5751
|
"z-ai/glm-5.1": 0.0044,
|
|
5596
5752
|
"z-ai/glm-5.2": 0.0044,
|
|
@@ -5608,12 +5764,14 @@ prices='{
|
|
|
5608
5764
|
"claude-opus-4-7": 0.1,
|
|
5609
5765
|
"claude-opus-4-8": 0.1,
|
|
5610
5766
|
"claude-opus-5": 0.1,
|
|
5767
|
+
"claude-opus-5-5": 0.05,
|
|
5611
5768
|
"claude-sonnet-4-5": 0.1,
|
|
5612
5769
|
"claude-sonnet-4-6": 0.1,
|
|
5613
5770
|
"claude-sonnet-5": 0.1,
|
|
5614
5771
|
"deepseek/deepseek-v4-flash": 0.2,
|
|
5615
5772
|
"deepseek/deepseek-v4-pro": 0.11494252873563218,
|
|
5616
5773
|
"deepseek/deepseek-v4-pro-0813": 0.11494252873563218,
|
|
5774
|
+
"deepseek/deepseek-v4.1-flash": 0.031818181818181815,
|
|
5617
5775
|
"gemini-2.0-flash": 0.25,
|
|
5618
5776
|
"gemini-2.0-flash-lite": 0.25,
|
|
5619
5777
|
"gemini-2.5-flash": 0.1,
|
|
@@ -5652,9 +5810,12 @@ prices='{
|
|
|
5652
5810
|
"gpt-5.6-sol-pro": 0.1,
|
|
5653
5811
|
"gpt-5.6-terra": 0.1,
|
|
5654
5812
|
"gpt-6-astra": 0.1,
|
|
5813
|
+
"gpt-6-luna": 0.1,
|
|
5814
|
+
"gpt-6-sol": 0.1,
|
|
5655
5815
|
"grok-4.5": 0.25,
|
|
5656
5816
|
"grok-4.6": 0.25,
|
|
5657
5817
|
"grok-4.7": 0.25,
|
|
5818
|
+
"inclusionai/ling-3.0-flash": 0.2,
|
|
5658
5819
|
"minimax/minimax-m2.7": 0.2,
|
|
5659
5820
|
"minimax/minimax-m3": 0.2,
|
|
5660
5821
|
"mistralai/mistral-small-2603": 0.1,
|
|
@@ -5673,6 +5834,8 @@ prices='{
|
|
|
5673
5834
|
"qwen/qwen3.7-plus": 0.2,
|
|
5674
5835
|
"qwen/qwen3.8-max": 0.125,
|
|
5675
5836
|
"xiaomi/mimo-v2.5-pro": 0.1,
|
|
5837
|
+
"xiaomi/mimo-v2.6-flash": 0.02,
|
|
5838
|
+
"xiaomi/mimo-v2.6-pro": 0.00827586,
|
|
5676
5839
|
"z-ai/glm-5": 0.2,
|
|
5677
5840
|
"z-ai/glm-5.1": 0.18571428571428572,
|
|
5678
5841
|
"z-ai/glm-5.2": 0.18571428571428572,
|
|
@@ -6077,8 +6240,7 @@ if [ "$scope" = "project" ] && [ -z "$install_dir" ] && [ -n "${git_root:-}" ];
|
|
|
6077
6240
|
".claude/settings.local.json" \
|
|
6078
6241
|
".claude/.credentials.json" \
|
|
6079
6242
|
".claude/cc-statusline.sh" \
|
|
6080
|
-
".claude/cc-statusline.sh.weave-router"
|
|
6081
|
-
".claude/commands/*.weave-router"
|
|
6243
|
+
".claude/cc-statusline.sh.weave-router"
|
|
6082
6244
|
do
|
|
6083
6245
|
[[ "$entry" == .claude/cc-statusline.sh* ]] && [ "$statusline_install" != "true" ] && continue
|
|
6084
6246
|
if [ ! -f "$gitignore" ] || ! grep -qxF "$entry" "$gitignore"; then
|
package/opencode-weave/README.md
CHANGED
|
@@ -76,6 +76,15 @@ are not a replacement for these plugin logins.
|
|
|
76
76
|
|
|
77
77
|
## Env overrides (self-host + tests)
|
|
78
78
|
|
|
79
|
+
- `WEAVE_OPENCODE_LLM_CLASSIFIER=1` — enroll only sessions created while this
|
|
80
|
+
plugin is running. The plugin stores a separate handshake UUID and router
|
|
81
|
+
ticket for each parent/child session under OpenCode's data directory. An
|
|
82
|
+
enrollment failure or missing new-session event blocks inference while the
|
|
83
|
+
opt-in is set; resume an older session with the opt-in unset. Classifier
|
|
84
|
+
sessions cannot compact or change router origins; start
|
|
85
|
+
a new session instead. Requires a router deployment with the exact release
|
|
86
|
+
and installation explicitly allowlisted. Deploy the router's non-retryable
|
|
87
|
+
client-failure response before enabling this opt-in on developer machines.
|
|
79
88
|
- `WEAVE_CODEX_OAUTH_ISSUER` — OpenAI auth issuer.
|
|
80
89
|
- `WEAVE_ANTHROPIC_OAUTH_AUTHORIZE` / `WEAVE_ANTHROPIC_OAUTH_TOKEN` — Anthropic
|
|
81
90
|
OAuth authorize host / token endpoint.
|