@weave-os/router 0.2.23 → 0.2.25

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/install.sh CHANGED
@@ -131,8 +131,7 @@ router_key_header="X-Weave-Router-Key"
131
131
  # provider block into opencode.json. Each target carries its own
132
132
  # credential-passthrough story in the router: Claude Code's logged-in
133
133
  # Anthropic key flows through unchanged, Codex's ChatGPT credential flows
134
- # through its native provider, and opencode uses the Responses API plus
135
- # dedicated subscription headers. target_explicit tracks whether
134
+ # through its native provider, and opencode uses the Responses API. target_explicit tracks whether
136
135
  # --claude / --codex / --opencode was passed so an interactive run can
137
136
  # prompt for the choice.
138
137
  target="claude"
@@ -680,14 +679,44 @@ strip_weave_codex_hooks() {
680
679
  rm -f "$tmp" 2>/dev/null || true
681
680
  }
682
681
 
682
+ # codex_existing_option finds a Codex setting before the managed block is
683
+ # replaced. Codex can save a selection inside our old block or immediately
684
+ # after it, where TOML incorrectly scopes it to the preceding table.
685
+ codex_existing_option() {
686
+ local config_file="$1" option="$2"
687
+ [ -f "$config_file" ] || return 0
688
+ awk -v begin="$WEAVE_CODEX_BEGIN_MARKER" -v end="$WEAVE_CODEX_END_MARKER" -v key="$option" '
689
+ BEGIN { option_pattern = "^[[:space:]]*" key "[[:space:]]*=" }
690
+ $0 == begin { in_managed = 1; managed_top = 1; after_managed = 0; next }
691
+ $0 == end { in_managed = 0; after_managed = 1; next }
692
+ /^[[:space:]]*\[/ {
693
+ in_section = 1
694
+ if (in_managed) managed_top = 0
695
+ else after_managed = 0
696
+ in_weave_provider = ($0 ~ /^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*\][[:space:]]*(#.*)?$/)
697
+ next
698
+ }
699
+ $0 ~ option_pattern {
700
+ if (!in_managed && !in_section) outside = $0
701
+ else if (!in_managed && (after_managed || in_weave_provider)) misplaced = $0
702
+ else if (in_managed && managed_top) managed = $0
703
+ }
704
+ END {
705
+ if (outside != "") print "T" outside
706
+ else if (misplaced != "") print "S" misplaced
707
+ else if (managed != "") print "B" managed
708
+ }
709
+ ' "$config_file"
710
+ }
711
+
683
712
  # write_codex_config writes a managed [model_providers.weave] block to the
684
713
  # Codex CLI's config.toml. Sets `model_provider = "weave"` at the top level so
685
714
  # Codex picks the routed provider by default. The provider requires OpenAI
686
715
  # authentication, preserving the user's ChatGPT plan credential while the
687
716
  # router key is sent independently. The router applies OAuth only to its
688
717
  # native gpt-5.6 Sol/Terra/Luna family; all other routed models use WorkWeave
689
- # deployment or BYOK credentials. Both settings live inside the managed-block
690
- # markers so uninstall removes them cleanly. We strip any
718
+ # deployment or BYOK credentials. The model choice stays outside the managed
719
+ # markers so Codex can update it without a reinstall resetting it. We strip any
691
720
  # top-level `model_provider = ...` declaration OUTSIDE the markers before
692
721
  # appending so the file doesn't end up with a duplicate key (TOML rejects
693
722
  # that). Inline `model_provider` keys inside `[profiles.*]` sections stay
@@ -701,6 +730,24 @@ write_codex_config() {
701
730
  local block_email="${4:-}"
702
731
  local block_name="${5:-}"
703
732
 
733
+ if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ]; then
734
+ local capture_url="${WEAVE_CAPTURE_PROXY_URL:-http://127.0.0.1:41984}"
735
+ if ! [[ "$capture_url" =~ ^http://(127\.0\.0\.1|localhost):[0-9]+$ ]]; then
736
+ err "Classifier opt-in requires a loopback WEAVE_CAPTURE_PROXY_URL"
737
+ return 1
738
+ fi
739
+ block_url="$capture_url"
740
+ if ! command -v jq >/dev/null 2>&1; then
741
+ err "Classifier opt-in requires jq to verify the capture proxy"
742
+ return 1
743
+ fi
744
+ if ! curl -fsS --max-time 2 "$capture_url/healthz" | jq -e --arg upstream "$2" \
745
+ '.classifier_enabled == true and .upstream == $upstream' >/dev/null; then
746
+ err "Classifier capture proxy is unavailable or targets a different router"
747
+ return 1
748
+ fi
749
+ fi
750
+
704
751
  # Escape `\` and `"` for TOML basic strings. Order matters: replace
705
752
  # backslashes first so the quotes we add next aren't double-escaped. A
706
753
  # display name like `John "J" Doe` would otherwise produce invalid TOML and
@@ -734,11 +781,21 @@ write_codex_config() {
734
781
  # Tag the client so telemetry can attribute traffic to Codex vs other CLIs
735
782
  # that share the same router key. The router otherwise has to guess from
736
783
  # User-Agent.
737
- headers_parts="${headers_parts}, \"X-App\" = \"codex\""
784
+ headers_parts="${headers_parts}, \"X-App\" = \"codex\", \"X-Weave-Codex-Native-Model-Pin\" = \"1\""
738
785
  # No strategy header: pinning one here freezes installed clients on whatever
739
786
  # policy was current at install time, so a deployment-default change never
740
787
  # reaches them. Every endpoint, hosted or self-hosted, uses its own default.
741
788
  local headers_line="http_headers = { ${headers_parts} }"
789
+ local codex_model_line='model = "weave-auto"' codex_effort_line="" saved_option
790
+ saved_option="$(codex_existing_option "$config_file" model)"
791
+ case "${saved_option:0:1}" in
792
+ T) codex_model_line="" ;;
793
+ S|B) codex_model_line="${saved_option:1}" ;;
794
+ esac
795
+ saved_option="$(codex_existing_option "$config_file" model_reasoning_effort)"
796
+ case "${saved_option:0:1}" in
797
+ S|B) codex_effort_line="${saved_option:1}" ;;
798
+ esac
742
799
 
743
800
  local hook_feature_line="features.hooks = true"
744
801
  local hook_block=""
@@ -757,6 +814,10 @@ write_codex_config() {
757
814
  if [ -f "$config_file" ] && grep -q '^\[features\]$' "$config_file"; then
758
815
  hook_feature_line=""
759
816
  fi
817
+ if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ] && [ "$codex_hooks_enabled" != "true" ]; then
818
+ err "Classifier opt-in requires managed Codex lifecycle hooks; existing hook configuration is incompatible"
819
+ return 1
820
+ fi
760
821
  if [ "$codex_hooks_enabled" = "true" ]; then
761
822
  # UserPromptSubmit is registered only when OUR hook is actually on disk.
762
823
  # Existence alone is the wrong test: install_codex_directive_script leaves
@@ -790,6 +851,22 @@ type = "command"
790
851
  command = "${esc_status}"
791
852
  TOML
792
853
  )${directive_hook_block}"
854
+ if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ]; then
855
+ hook_block="${hook_block}$(cat <<TOML
856
+
857
+ [[hooks.PreToolUse]]
858
+ matcher = "spawn_agent"
859
+ [[hooks.PreToolUse.hooks]]
860
+ type = "command"
861
+ command = "${esc_status}"
862
+
863
+ [[hooks.PreCompact]]
864
+ [[hooks.PreCompact.hooks]]
865
+ type = "command"
866
+ command = "${esc_status}"
867
+ TOML
868
+ )"
869
+ fi
793
870
  fi
794
871
  local block
795
872
  block="$(cat <<TOML
@@ -809,7 +886,10 @@ ${headers_line}
809
886
  ${hook_block}
810
887
  ${WEAVE_CODEX_END_MARKER}
811
888
  TOML
812
- )"
889
+ )"
890
+ local codex_insertion="$block"
891
+ [ -z "$codex_effort_line" ] || codex_insertion="${codex_effort_line}"$'\n'"${codex_insertion}"
892
+ [ -z "$codex_model_line" ] || codex_insertion="${codex_model_line}"$'\n'"${codex_insertion}"
813
893
 
814
894
  if [ -f "$config_file" ]; then
815
895
  local tmp; tmp="$(mktemp -t weave-codex.XXXXXX)"
@@ -829,10 +909,11 @@ TOML
829
909
  # refused to start with "duplicate key" while the installer reported
830
910
  # success.
831
911
  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 }
912
+ $0 == begin { skip = 1; after_managed = 0; next }
913
+ $0 == end { skip = 0; after_managed = 1; next }
834
914
  skip { next }
835
915
  /^[[:space:]]*\[/ {
916
+ after_managed = 0
836
917
  in_section = 1
837
918
  if ($0 ~ /^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*(\.[^]]*)?\][[:space:]]*(#.*)?$/) {
838
919
  in_weave_provider = 1
@@ -841,6 +922,9 @@ TOML
841
922
  in_weave_provider = 0
842
923
  }
843
924
  in_weave_provider { next }
925
+ after_managed && /^[[:space:]]*(model|model_reasoning_effort)[[:space:]]*=/ { next }
926
+ !in_section && /^[[:space:]]*#[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave".*weave-router: off/ { next }
927
+ !in_section && /^[[:space:]]*#[[:space:]]*model[[:space:]]*=[[:space:]]*"weave-auto".*weave-router: off/ { next }
844
928
  !in_section && /^[[:space:]]*model_provider[[:space:]]*=/ { next }
845
929
  { print }
846
930
  ' "$config_file" >"$tmp"
@@ -876,7 +960,7 @@ EOF
876
960
  if [ "$first_section" -gt 1 ]; then
877
961
  head -n "$((first_section - 1))" "$tmp"
878
962
  fi
879
- printf "%s\n" "$block"
963
+ printf "%s\n" "$codex_insertion"
880
964
  tail -n "+${first_section}" "$tmp"
881
965
  } >"$config_file"
882
966
  else
@@ -884,11 +968,11 @@ EOF
884
968
  # already at top-level. Our block ends with its own [section], so
885
969
  # appending is safe (no bare keys follow).
886
970
  cp "$tmp" "$config_file"
887
- printf "\n%s\n" "$block" >>"$config_file"
971
+ printf "\n%s\n" "$codex_insertion" >>"$config_file"
888
972
  fi
889
973
  rm -f "$tmp"
890
974
  else
891
- printf "%s\n" "$block" >"$config_file"
975
+ printf "%s\n" "$codex_insertion" >"$config_file"
892
976
  fi
893
977
 
894
978
  # If the user already has a [features] table, place our managed hook
@@ -914,26 +998,16 @@ EOF
914
998
  chmod 600 "$config_file"
915
999
  }
916
1000
 
917
- # write_opencode_config merges the managed Weave provider(s) into opencode's
918
- # opencode.json plus the bundled subscription plugin:
1001
+ # write_opencode_config merges the managed Weave provider into opencode's
1002
+ # opencode.json and registers the bundled routing hooks. Subscription
1003
+ # enrollment is handled by the router's login command, so opencode only needs
1004
+ # this provider and its router key:
919
1005
  # - provider.weave : OpenAI/Responses-shaped (@ai-sdk/openai → /v1/responses).
920
1006
  # The single request provider. The router routes every
921
- # turn across all models the caller's subscriptions +
922
- # Weave key can pay for, and bills the plan matching the
923
- # model it served. The default.
924
- # - provider.weave-claude : login-only storage for a Claude (Pro/Max) subscription
925
- # (no models, never serves requests). Written only when
926
- # the bundled plugin is present, since the Claude login
927
- # method lives in the plugin. The `weave` loader reads
928
- # this slot and attaches the Claude sub.
929
- # The plugin (src bundled at $script_dir/opencode-weave/src/index.ts) is dropped
930
- # into $opencode_dir/.weave/ and registered via opencode.json's `plugin` array
931
- # by absolute path — scope-independent (no reliance on an auto-load dir). It owns
932
- # both the ChatGPT (on `weave`) and Claude (on `weave-claude`) logins and attaches
933
- # whichever subscriptions are connected to every request via the router's
934
- # dedicated X-Weave-*-Subscription headers. Re-running rewrites the blocks
935
- # in-place via jq (and strips the legacy `weave-codex` provider); uninstall
936
- # strips them.
1007
+ # turn across the models the router can serve. The default.
1008
+ # Re-running rewrites the block in-place via jq and strips the legacy
1009
+ # `weave-codex` provider. The plugin is retained for lifecycle/classifier and
1010
+ # directive hooks, but has no login or subscription-header transport.
937
1011
  #
938
1012
  # Usage: write_opencode_config <config_file_path> <base_url> <api_key> [user_email] [user_name]
939
1013
  write_opencode_config() {
@@ -944,10 +1018,8 @@ write_opencode_config() {
944
1018
  local block_name="${5:-}"
945
1019
 
946
1020
  # Build the headers object piecewise so empty email/name vanish from the
947
- # final JSON. opencode forwards the `headers` map verbatim to the upstream
948
- # provider, so the router sees the same X-Weave-* triplet here that it
949
- # would from Claude Code or Codex. The X-App tag lets router telemetry
950
- # attribute traffic to opencode specifically.
1021
+ # final JSON. The X-App tag lets router telemetry attribute traffic to
1022
+ # opencode specifically.
951
1023
  local headers_json
952
1024
  headers_json="$(jq -n \
953
1025
  --arg key "$block_key" \
@@ -971,9 +1043,7 @@ write_opencode_config() {
971
1043
  # /v1/responses surface (the canonical inbound — the router translates to
972
1044
  # Anthropic/OSS as it routes, and ships verbatim to the Codex backend for GPT
973
1045
  # turns). apiKey is the router key as a parse-time placeholder; the router
974
- # authenticates off X-Weave-Router-Key (planted in headers) and the plugin's
975
- # loader attaches subscriptions via the dedicated X-Weave-*-Subscription
976
- # headers, so the apiKey value is never used upstream.
1046
+ # authenticates off X-Weave-Router-Key (planted in headers).
977
1047
  local block
978
1048
  block="$(jq -n \
979
1049
  --arg url "$block_url/v1" \
@@ -981,7 +1051,7 @@ write_opencode_config() {
981
1051
  --argjson headers "$headers_json" '
982
1052
  {
983
1053
  npm: "@ai-sdk/openai",
984
- name: "Weave Router — Codex plan",
1054
+ name: "Weave Router",
985
1055
  options: { apiKey: $key, baseURL: $url, headers: $headers },
986
1056
  models: {
987
1057
  auto: {
@@ -995,52 +1065,27 @@ write_opencode_config() {
995
1065
  }
996
1066
  ')"
997
1067
 
998
- # Login-only storage provider for a Claude (Pro/Max) subscription. It serves
999
- # no requests (no models), so its npm/baseURL are inert — opencode just needs
1000
- # it registered so the plugin's Claude login method has a home and `opencode
1001
- # auth login` lists it. The `weave` loader reads this slot off disk and
1002
- # attaches the Claude sub. Reuses the same router key + identity headers.
1003
- local claude_block
1004
- claude_block="$(jq -n \
1005
- --arg url "$block_url/v1" \
1006
- --arg key "$block_key" \
1007
- --argjson headers "$headers_json" '
1008
- {
1009
- npm: "@ai-sdk/openai",
1010
- name: "Weave Router — Claude plan",
1011
- options: { apiKey: $key, baseURL: $url, headers: $headers },
1012
- models: {}
1013
- }
1014
- ')"
1015
-
1016
- # Drop the Codex-subscription plugin next to the config and capture the
1017
- # absolute path we'll register in opencode.json's `plugin` array (so it loads
1018
- # regardless of scope). $config_file's dir is the already-created
1019
- # opencode_dir, so the `cd … && pwd` canonicalization is safe — uninstall.sh
1020
- # must canonicalize identically so the array entry matches on removal.
1021
- #
1022
- # Only register the path when the bundled source is actually present and
1023
- # copied: registering a path with no file on disk makes opencode fail to load
1024
- # a missing plugin. The plugin holds no secrets (router key lives in the
1025
- # config; ChatGPT tokens live in opencode's own auth store), so 644 is fine.
1026
- # Source is bundled alongside install.sh by the npm prepack
1027
- # (scripts/copy-installer.js), same as commands/ + pi-router/.
1028
- local plugin_dir plugin_spec plugin_src plugin_arg=""
1068
+ # Drop the routing plugin next to the config and register its absolute path
1069
+ # so it loads regardless of OpenCode scope. It contains lifecycle,
1070
+ # classifier, and directive hooks; managed subscription enrollment lives in
1071
+ # the router's login command and is never transported in request headers.
1072
+ local plugin_dir plugin_spec plugin_src plugin_directives_src plugin_classifier_src plugin_arg=""
1029
1073
  plugin_dir="$(cd "$(dirname "$config_file")" && pwd)/.weave"
1030
1074
  plugin_spec="$plugin_dir/opencode-weave.ts"
1031
1075
  plugin_src="$script_dir/opencode-weave/src/index.ts"
1032
1076
  plugin_directives_src="$script_dir/opencode-weave/src/directives.ts"
1033
- if [ -f "$plugin_src" ]; then
1077
+ plugin_classifier_src="$script_dir/opencode-weave/src/classifier-thread.ts"
1078
+ if [ -f "$plugin_src" ] && [ -f "$plugin_directives_src" ] && [ -f "$plugin_classifier_src" ]; then
1034
1079
  mkdir -p "$plugin_dir"
1035
1080
  cp "$plugin_src" "$plugin_spec"
1036
1081
  chmod 644 "$plugin_spec"
1037
- if [ -f "$plugin_directives_src" ]; then
1038
- cp "$plugin_directives_src" "$plugin_dir/directives.ts"
1039
- chmod 644 "$plugin_dir/directives.ts"
1040
- fi
1082
+ cp "$plugin_directives_src" "$plugin_dir/directives.ts"
1083
+ chmod 644 "$plugin_dir/directives.ts"
1084
+ cp "$plugin_classifier_src" "$plugin_dir/classifier-thread.ts"
1085
+ chmod 644 "$plugin_dir/classifier-thread.ts"
1041
1086
  plugin_arg="$plugin_spec"
1042
1087
  else
1043
- warn "opencode subscription plugin source not found at $plugin_src — skipping the Claude login + subscription routing. (Use a packaged 'npx $npm_package_name' install.)"
1088
+ warn "opencode routing plugin source not found at $plugin_src — skipping lifecycle and classifier hooks. (Use a packaged 'npx $npm_package_name' install.)"
1044
1089
  fi
1045
1090
 
1046
1091
  # Installing must actually activate the router. Preserve a prior direct model
@@ -1067,46 +1112,39 @@ write_opencode_config() {
1067
1112
  # file (other providers, mcp, agent settings) untouched. The managed model is
1068
1113
  # always weave/auto; a prior direct choice was parked above for exact restore.
1069
1114
  #
1070
- # The weave-claude login provider AND the plugin entry are written together
1071
- # only when the bundled plugin was present and copied ($plugin non-empty): the
1072
- # Claude login method lives in the plugin, so registering the provider without
1073
- # it (e.g. the `curl | sh` path, which carries no plugin source) would leave a
1074
- # non-working login — instead we omit it (and strip any stale one). The legacy
1075
- # `weave-codex` provider is always stripped: the single Responses `weave`
1076
- # provider supersedes it.
1115
+ # Legacy subscription providers are always stripped: the single Responses
1116
+ # `weave` provider supersedes them. Register the routing plugin when its
1117
+ # bundled source is available, while removing stale duplicate registrations.
1077
1118
  local merged
1078
1119
  if [ -f "$config_file" ]; then
1079
1120
  merged="$(jq \
1080
1121
  --argjson block "$block" \
1081
- --argjson claude "$claude_block" \
1082
1122
  --arg plugin "$plugin_arg" \
1083
- --arg pluginspec "$plugin_spec" '
1123
+ '
1084
1124
  .provider = ((.provider // {}) | .weave = $block)
1085
1125
  | (.provider |= del(."weave-codex"))
1086
- | (if $plugin != "" then .provider["weave-claude"] = $claude else .provider |= del(."weave-claude") end)
1087
- # Register the managed plugin path when we installed it; otherwise strip a
1088
- # stale entry left by a prior install (the provider was just removed, so a
1089
- # lingering plugin reference would be dead weight).
1126
+ | (.provider |= del(."weave-claude"))
1090
1127
  | (if $plugin != ""
1091
- then .plugin = ((.plugin // []) | if index($plugin) then . else . + [$plugin] end)
1128
+ then .plugin = ((.plugin // []) | map(select((tostring | endswith("/opencode-weave.ts")) | not)) + [$plugin])
1092
1129
  else (if (.plugin | type) == "array"
1093
- then (.plugin -= [$pluginspec]) | (if (.plugin | length) == 0 then del(.plugin) else . end)
1130
+ then .plugin |= map(select((tostring | endswith("/opencode-weave.ts")) | not))
1094
1131
  else . end)
1095
1132
  end)
1133
+ | (if (.plugin | type) == "array" and (.plugin | length) == 0 then del(.plugin) else . end)
1096
1134
  | .model = "weave/auto"
1097
1135
  | (.["$schema"] //= "https://opencode.ai/config.json")
1098
1136
  ' "$config_file")"
1099
1137
  else
1100
1138
  merged="$(jq -n \
1101
1139
  --argjson block "$block" \
1102
- --argjson claude "$claude_block" \
1103
- --arg plugin "$plugin_arg" '
1140
+ --arg plugin "$plugin_arg" \
1141
+ '
1104
1142
  {
1105
1143
  "$schema": "https://opencode.ai/config.json",
1106
1144
  model: "weave/auto",
1107
1145
  provider: { weave: $block }
1108
1146
  }
1109
- | (if $plugin != "" then .provider["weave-claude"] = $claude | .plugin = [$plugin] else . end)
1147
+ | (if $plugin != "" then .plugin = [$plugin] else . end)
1110
1148
  ')"
1111
1149
  fi
1112
1150
  printf '%s\n' "$merged" >"$config_file"
@@ -1175,11 +1213,14 @@ write_pi_models_config() {
1175
1213
  models: [
1176
1214
  { id: "claude-fable-5-1", name: "Claude Fable 5.1 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
1177
1215
  { id: "claude-fable-5", name: "Claude Fable 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
1216
+ { id: "claude-opus-5-5", name: "Claude Opus 5.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
1178
1217
  { id: "claude-opus-5", name: "Claude Opus 5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 128000 },
1179
1218
  { id: "claude-opus-4-7", name: "Claude Opus 4.7 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
1180
1219
  { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1000000, maxTokens: 64000 },
1181
1220
  { id: "claude-haiku-4-5", name: "Claude Haiku 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 200000, maxTokens: 32000 },
1182
1221
  { id: "gpt-6-astra", name: "GPT-6 Astra (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
1222
+ { id: "gpt-6-sol", name: "GPT-6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
1223
+ { id: "gpt-6-luna", name: "GPT-6 Luna (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
1183
1224
  { id: "gpt-5.6-sol", name: "GPT-5.6 Sol (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 1050000, maxTokens: 128000 },
1184
1225
  { id: "grok-4.5", name: "Grok 4.5 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
1185
1226
  { id: "grok-4.6", name: "Grok 4.6 (via Weave Router)", reasoning: true, input: ["text","image"], contextWindow: 500000, maxTokens: 131072 },
@@ -1764,7 +1805,8 @@ if [ "$target" = "claude" ] || [ "$target" = "opencode" ] || [ "$target" = "pi"
1764
1805
  require_cmd jq "macOS: 'brew install jq' · Debian/Ubuntu: 'sudo apt install jq'"
1765
1806
  fi
1766
1807
  # curl is used by the install/update paths' health/validate probes and by every
1767
- # `models` call; the on/off/status toggles never hit the network.
1808
+ # `models` call. The on/off toggles only ping the router best-effort after a
1809
+ # real state change (see report_client_event) and skip it when curl is absent.
1768
1810
  if [ "$mode" = "install" ] || [ "$mode" = "update" ] || [ "$mode" = "models" ]; then
1769
1811
  require_cmd curl "macOS/Linux: usually preinstalled — check your package manager"
1770
1812
  fi
@@ -2466,6 +2508,60 @@ models_endpoint_is_trusted() {
2466
2508
  return 1
2467
2509
  }
2468
2510
 
2511
+ # report_client_event ACTION tells this install's router that a state-changing
2512
+ # off/on just succeeded, so the router can log and export a lifecycle event.
2513
+ # Strictly best-effort: the toggle has already been applied, users legitimately
2514
+ # turn routing off *because* the router is unreachable, and nothing here may
2515
+ # change the exit status. Everything -- resolution included -- runs in a
2516
+ # subshell with errexit off, so no failure escapes into the caller; the POST
2517
+ # itself is detached with a short timeout and its output discarded.
2518
+ #
2519
+ # Endpoint and key come from the installed config (never the hosted defaults),
2520
+ # via the same readers `models` uses, so a self-hosted install reports to its
2521
+ # own router. For Claude Code that means the parked sidecar while off, since
2522
+ # the live settings point at Anthropic then. An explicit --base-url wins over
2523
+ # the on-disk endpoint, as it does for `models`; otherwise the same trust gate
2524
+ # applies and a checkout-supplied endpoint never receives the key. The key
2525
+ # rides in a mode-600 header file, not argv.
2526
+ report_client_event() {
2527
+ local action="$1"
2528
+ (
2529
+ set +e
2530
+ endpoint="" key="" base_src="" key_src="" headers="" body="" harness=""
2531
+ command -v curl >/dev/null 2>&1 || exit 0
2532
+ if [ "$base_url_explicit" = "true" ]; then
2533
+ endpoint="${base_url%/}"
2534
+ else
2535
+ endpoint="$(resolve_installed_endpoint)"
2536
+ fi
2537
+ [ -n "$endpoint" ] || exit 0
2538
+ key="$(read_installed_key)"
2539
+ [ -n "$key" ] || exit 0
2540
+ if [ "$target" = "claude" ]; then
2541
+ base_src="$(resolve_installed_base_source "$endpoint")"
2542
+ key_src="$(resolve_installed_key_source)"
2543
+ else
2544
+ base_src="$(models_config_file_for_target)"
2545
+ key_src="$base_src"
2546
+ fi
2547
+ models_endpoint_is_trusted "$endpoint" "$base_src" "$key_src" || exit 0
2548
+ headers="$(mktemp)" || exit 0
2549
+ chmod 600 "$headers" || { rm -f "$headers"; exit 0; }
2550
+ printf '%s: %s\n' "$router_key_header" "$key" >"$headers" || { rm -f "$headers"; exit 0; }
2551
+ # The router keys harnesses the way minted keys do: Claude Code is claude_code.
2552
+ harness="$target"
2553
+ [ "$target" = "claude" ] && harness="claude_code"
2554
+ body="$(printf '{"action":"%s","harness":"%s"}' "$action" "$harness")"
2555
+ (
2556
+ trap 'rm -f "$headers"' EXIT
2557
+ curl -sS --max-time 2 -X POST -H 'Content-Type: application/json' \
2558
+ --header "@$headers" --data-binary "$body" -o /dev/null \
2559
+ "$endpoint/v1/client-events"
2560
+ ) >/dev/null 2>&1 </dev/null &
2561
+ ) >/dev/null 2>&1 || true
2562
+ return 0
2563
+ }
2564
+
2469
2565
  # gitignore_add appends an entry to the repo .gitignore in project scope so a
2470
2566
  # parked sidecar (which may carry the router key header) never gets committed.
2471
2567
  # No-op for user scope and --dir, matching how install handles its own ignores.
@@ -2483,8 +2579,7 @@ prepare_claude_context_window() {
2483
2579
  if [ "$scope" = "project" ] && [ -z "$install_dir" ]; then
2484
2580
  context_settings_file="$local_settings_file"
2485
2581
  fi
2486
- context_state_file="$settings_dir/.weave-context-window.json"
2487
- refuse_if_symlink "$context_state_file"
2582
+ refuse_if_symlink "$settings_dir/.weave-context-window.json"
2488
2583
  [ -n "$context_window" ] || return 0
2489
2584
 
2490
2585
  local source model="" disabled="${CLAUDE_CODE_DISABLE_1M_CONTEXT:-}" env_model="${ANTHROPIC_MODEL:-}"
@@ -2506,7 +2601,7 @@ prepare_claude_context_window() {
2506
2601
  model="${model:-sonnet}"
2507
2602
  case "$model" in
2508
2603
  *'[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) ;;
2604
+ 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
2605
  *) err "Cannot assert 1M support for '$model'. Select a supported Sonnet/Opus/Fable model first; leaving it unchanged."; return 1 ;;
2511
2606
  esac
2512
2607
  context_managed_model="${model}[1m]"
@@ -2530,7 +2625,7 @@ apply_claude_context_window() {
2530
2625
  if .model == $s.managed then
2531
2626
  if $s.had_model then .model = $s.original else del(.model) end
2532
2627
  else . end
2533
- elif ($action == "install" or $action == "on" or $context_window != "") and has("model") == $s.had_model and .model == $s.original then .model = $s.managed
2628
+ elif ($action == "install" or $action == "on") and has("model") == $s.had_model and .model == $s.original then .model = $s.managed
2534
2629
  else . end
2535
2630
  ' "$active")"
2536
2631
  fi
@@ -2634,6 +2729,7 @@ toggle_claude() {
2634
2729
  printf '%s\n' "$merged" >"$settings_file"
2635
2730
  fi
2636
2731
  ok "Claude Code is ${C_BOLD}off${C_RESET} (direct to Anthropic). Restart Claude Code for it to take effect."
2732
+ report_client_event off
2637
2733
  ;;
2638
2734
  on)
2639
2735
  if [ "$parked_present" != "true" ]; then
@@ -2658,6 +2754,7 @@ toggle_claude() {
2658
2754
  printf '%s\n' "$merged" >"$local_settings_file"
2659
2755
  chmod 600 "$local_settings_file"
2660
2756
  ok "Claude Code is ${C_BOLD}on${C_RESET} (routing through the Weave Router). Restart Claude Code for it to take effect."
2757
+ report_client_event on
2661
2758
  else
2662
2759
  warn "Claude Code is off and the parked router key is missing (its sidecar was deleted). Re-run the installer to restore the router key — leaving the current direct-to-Anthropic setup in place so requests don't fail auth."
2663
2760
  fi
@@ -2698,6 +2795,7 @@ toggle_claude() {
2698
2795
  apply_claude_context_window on "$active"
2699
2796
  rm -f "$parked"
2700
2797
  ok "Claude Code is ${C_BOLD}on${C_RESET} (routing through the Weave Router). Restart Claude Code for it to take effect."
2798
+ report_client_event on
2701
2799
  ;;
2702
2800
  esac
2703
2801
  }
@@ -2705,12 +2803,16 @@ toggle_claude() {
2705
2803
  toggle_codex() {
2706
2804
  local f="$codex_config_file" state="absent" tmp
2707
2805
  if [ -f "$f" ]; then
2708
- state="$(awk -v b="$WEAVE_CODEX_BEGIN_MARKER" -v e="$WEAVE_CODEX_END_MARKER" '
2709
- $0==b{inblk=1; next}
2710
- $0==e{inblk=0; next}
2711
- inblk && /^[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"/ {st="on"}
2712
- inblk && /^[[:space:]]*#[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"/ {if(st=="")st="off"}
2713
- END{print (st==""?"absent":st)}
2806
+ state="$(awk '
2807
+ /^[[:space:]]*\[[[:space:]]*model_providers[[:space:]]*\.[[:space:]]*weave[[:space:]]*\]/ { has_weave = 1 }
2808
+ /^[[:space:]]*\[/ { in_section = 1 }
2809
+ !in_section && /^[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"[[:space:]]*$/ { active_weave = 1 }
2810
+ !in_section && /^[[:space:]]*model_provider[[:space:]]*=/ { has_active_provider = 1 }
2811
+ END {
2812
+ if (!has_weave) print "absent"
2813
+ else if (active_weave) print "on"
2814
+ else print (has_active_provider ? "absent" : "off")
2815
+ }
2714
2816
  ' "$f")"
2715
2817
  fi
2716
2818
 
@@ -2726,10 +2828,12 @@ toggle_codex() {
2726
2828
  if [ "$state" = "absent" ]; then info "Codex isn't configured for the router. Run the installer first."; return 0; fi
2727
2829
  if [ "$state" = "off" ]; then ok "Codex is already off — nothing to do."; return 0; fi
2728
2830
  tmp="$(mktemp -t weave-codex-toggle.XXXXXX)"
2729
- awk -v b="$WEAVE_CODEX_BEGIN_MARKER" -v e="$WEAVE_CODEX_END_MARKER" '
2730
- $0==b{inblk=1; print; next}
2731
- $0==e{inblk=0; print; next}
2732
- inblk && /^[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"[[:space:]]*$/ {
2831
+ awk '
2832
+ /^[[:space:]]*\[/ { in_section = 1 }
2833
+ !in_section && /^[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"[[:space:]]*$/ {
2834
+ print "# " $0 " # weave-router: off (run on to re-enable)"; next
2835
+ }
2836
+ !in_section && /^[[:space:]]*model[[:space:]]*=[[:space:]]*"weave-auto"[[:space:]]*$/ {
2733
2837
  print "# " $0 " # weave-router: off (run on to re-enable)"; next
2734
2838
  }
2735
2839
  {print}
@@ -2739,24 +2843,52 @@ toggle_codex() {
2739
2843
  "$codex_status_file" --off >/dev/null 2>&1 || true
2740
2844
  fi
2741
2845
  ok "Codex is ${C_BOLD}off${C_RESET} (default provider). Takes effect on your next 'codex' run."
2846
+ report_client_event off
2742
2847
  ;;
2743
2848
  on)
2744
2849
  if [ "$state" = "absent" ]; then warn "No managed Weave block in $f. Run the installer to set up Codex."; return 0; fi
2745
2850
  if [ "$state" = "on" ]; then ok "Codex is already on — nothing to do."; return 0; fi
2746
2851
  tmp="$(mktemp -t weave-codex-toggle.XXXXXX)"
2747
- awk -v b="$WEAVE_CODEX_BEGIN_MARKER" -v e="$WEAVE_CODEX_END_MARKER" '
2748
- $0==b{inblk=1; print; next}
2749
- $0==e{inblk=0; print; next}
2750
- inblk && /^[[:space:]]*#[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave"/ {
2751
- print "model_provider = \"weave\""; next
2852
+ local has_top_model="false"
2853
+ if awk '
2854
+ /^[[:space:]]*\[/ { in_section = 1 }
2855
+ !in_section && /^[[:space:]]*model[[:space:]]*=/ { found = 1 }
2856
+ END { exit(found ? 0 : 1) }
2857
+ ' "$f"; then
2858
+ has_top_model="true"
2859
+ fi
2860
+ awk -v has_top_model="$has_top_model" '
2861
+ function add_missing_settings() {
2862
+ if (!restored_provider) print "model_provider = \"weave\""
2863
+ if (has_top_model != "true" && !restored_model) print "model = \"weave-auto\""
2864
+ }
2865
+ /^[[:space:]]*\[/ {
2866
+ if (!in_section) add_missing_settings()
2867
+ in_section = 1
2868
+ }
2869
+ !in_section && /^[[:space:]]*#[[:space:]]*model_provider[[:space:]]*=[[:space:]]*"weave".*weave-router: off/ {
2870
+ if (!restored_provider) {
2871
+ print "model_provider = \"weave\""
2872
+ restored_provider = 1
2873
+ }
2874
+ next
2875
+ }
2876
+ !in_section && /^[[:space:]]*#[[:space:]]*model[[:space:]]*=[[:space:]]*"weave-auto".*weave-router: off/ {
2877
+ if (has_top_model != "true" && !restored_model) {
2878
+ print "model = \"weave-auto\""
2879
+ restored_model = 1
2880
+ }
2881
+ next
2752
2882
  }
2753
2883
  {print}
2884
+ END { if (!in_section) add_missing_settings() }
2754
2885
  ' "$f" >"$tmp" && mv "$tmp" "$f"
2755
2886
  chmod 600 "$f"
2756
2887
  if [ -f "$codex_status_file" ] && grep -Fq '<!-- weave-router managed codex status -->' "$codex_status_file"; then
2757
2888
  "$codex_status_file" --on >/dev/null 2>&1 || true
2758
2889
  fi
2759
2890
  ok "Codex is ${C_BOLD}on${C_RESET} (routing through the Weave Router). Takes effect on your next 'codex' run."
2891
+ report_client_event on
2760
2892
  ;;
2761
2893
  esac
2762
2894
  }
@@ -2813,6 +2945,7 @@ toggle_opencode() {
2813
2945
  else
2814
2946
  ok "opencode is ${C_BOLD}off${C_RESET} — choose a direct model with /models. Takes effect on your next opencode run."
2815
2947
  fi
2948
+ report_client_event off
2816
2949
  ;;
2817
2950
  on)
2818
2951
  if [ "$on" = "true" ]; then ok "opencode is already on — nothing to do."; return 0; fi
@@ -2838,6 +2971,7 @@ toggle_opencode() {
2838
2971
  chmod 600 "$parked"
2839
2972
  gitignore_add ".weave-parked.json"
2840
2973
  ok "opencode is ${C_BOLD}on${C_RESET} (default model $router_model via the Weave Router). Takes effect on your next opencode run."
2974
+ report_client_event on
2841
2975
  ;;
2842
2976
  esac
2843
2977
  }
@@ -3471,6 +3605,27 @@ if [ "$mode" = "models" ] || [ "$mode" = "accounts" ] || [ "$mode" = "login" ] |
3471
3605
  # Editing model selection needs the endpoint and key of one specific install,
3472
3606
  # never the hosted defaults: a self-hosted user pointing at their own router
3473
3607
  # would otherwise silently edit the hosted one's installation.
3608
+ # Login enrollment is client-independent. When no Claude/Codex endpoint is
3609
+ # configured, prefer the managed OpenCode config as the source for the
3610
+ # router endpoint; the provider operand still selects the account to enroll.
3611
+ if [ "$mode" = "login" ] && [ "$target" != "opencode" ] && [ "$base_url_explicit" != "true" ]; then
3612
+ login_target="$target"
3613
+ login_target_base="$(resolve_installed_endpoint)"
3614
+ if [ -z "$login_target_base" ]; then
3615
+ target="opencode"
3616
+ if [ -n "$install_dir" ]; then
3617
+ opencode_dir="$install_dir"
3618
+ elif [ "$scope" = "project" ]; then
3619
+ opencode_dir="$settings_base"
3620
+ else
3621
+ opencode_dir="${XDG_CONFIG_HOME:-$settings_base/.config}/opencode"
3622
+ fi
3623
+ opencode_config_file="$opencode_dir/opencode.json"
3624
+ if [ -z "$(resolve_installed_endpoint)" ]; then
3625
+ target="$login_target"
3626
+ fi
3627
+ fi
3628
+ fi
3474
3629
  if [ "$base_url_explicit" != "true" ]; then
3475
3630
  models_base="$(resolve_installed_endpoint)"
3476
3631
  if [ -z "$models_base" ] && { [ "$mode" = "accounts" ] || [ "$mode" = "status" ]; } && [ "$target" = "claude" ]; then
@@ -3508,6 +3663,33 @@ if [ "$mode" = "models" ] || [ "$mode" = "accounts" ] || [ "$mode" = "login" ] |
3508
3663
  models_key_source="$(models_config_file_for_target)"
3509
3664
  fi
3510
3665
  fi
3666
+ # Managed enrollment is client-independent. If an OpenCode-only install is
3667
+ # the first router config on the machine, login claude|codex still needs to
3668
+ # find its endpoint and key even though the provider operand initially makes
3669
+ # the lookup target Claude or Codex. Reuse the OpenCode key in that case, but
3670
+ # only when it pairs with the endpoint already resolved above: the endpoint
3671
+ # is either an explicit --base-url or the selected client's own install, and
3672
+ # a key from one router must never be sent to another.
3673
+ if [ "$mode" = "login" ] && [ "$target" != "opencode" ] && [ -z "$api_key" ]; then
3674
+ login_target="$target"
3675
+ target="opencode"
3676
+ if [ -n "$install_dir" ]; then
3677
+ opencode_dir="$install_dir"
3678
+ elif [ "$scope" = "project" ]; then
3679
+ opencode_dir="$settings_base"
3680
+ else
3681
+ opencode_dir="${XDG_CONFIG_HOME:-$settings_base/.config}/opencode"
3682
+ fi
3683
+ opencode_config_file="$opencode_dir/opencode.json"
3684
+ opencode_key="$(read_installed_key)"
3685
+ opencode_base="$(resolve_installed_endpoint)"
3686
+ if [ -n "$opencode_key" ] && { [ "$base_url_explicit" = "true" ] || [ "$(strip_trailing_slashes "$opencode_base")" = "$(strip_trailing_slashes "$base_url")" ]; }; then
3687
+ api_key="$opencode_key"
3688
+ models_key_source="$opencode_config_file"
3689
+ fi
3690
+ target="$login_target"
3691
+ fi
3692
+
3511
3693
  if [ -z "$api_key" ]; then
3512
3694
  err "No router key found for $target in this scope. Re-run 'npx $npm_package_name --$target', or export WEAVE_ROUTER_KEY."
3513
3695
  exit 1
@@ -4133,6 +4315,9 @@ set -euo pipefail
4133
4315
  # WEAVE_STATUSLINE_UPDATE and WEAVE_STATUSLINE_UPDATE_INTERVAL_DAYS variables
4134
4316
  # remain accepted as aliases for users who configure both clients together.
4135
4317
  weave_self_refresh() {
4318
+ # The published helper may predate classifier lifecycle forwarding. Do not
4319
+ # replace the hook implementation underneath an opted-in session.
4320
+ [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ] && return 0
4136
4321
  [ "${WEAVE_CODEX_STATUS_UPDATE:-${WEAVE_STATUSLINE_UPDATE:-1}}" = "0" ] && return 0
4137
4322
  command -v curl >/dev/null 2>&1 || return 0
4138
4323
 
@@ -4199,9 +4384,10 @@ emit_title() {
4199
4384
  local title="$1"
4200
4385
  if [ -n "${WEAVE_CODEX_STATUS_TITLE_FILE:-}" ]; then
4201
4386
  printf '%s\n' "$title" >"$WEAVE_CODEX_STATUS_TITLE_FILE"
4202
- elif [ -w /dev/tty ]; then
4387
+ elif [ -t 2 ] && [ -w /dev/tty ]; then
4203
4388
  printf '\033]0;%s\007' "$title" >/dev/tty
4204
4389
  fi
4390
+ return 0
4205
4391
  }
4206
4392
 
4207
4393
  safe_session_id() {
@@ -4429,6 +4615,21 @@ command -v jq >/dev/null 2>&1 || exit 0
4429
4615
  jq -e . >/dev/null 2>&1 <<<"$payload" || exit 0
4430
4616
 
4431
4617
  hook_event_name="$(jq -r '.hook_event_name // ""' <<<"$payload")"
4618
+ if [ "${WEAVE_CAPTURE_LLM_CLASSIFIER:-}" = "1" ] && [ -n "${WEAVE_CAPTURE_HOOK_TOKEN:-}" ]; then
4619
+ classifier_hook_url="${WEAVE_CAPTURE_HOOK_URL:-http://127.0.0.1:41984/classifier/hook}"
4620
+ if [[ "$classifier_hook_url" =~ ^http://(127\.0\.0\.1|localhost|\[::1\]):[0-9]+/classifier/hook$ ]]; then
4621
+ case "$hook_event_name" in
4622
+ SessionStart|PreToolUse|PreCompact)
4623
+ # Send lifecycle identifiers only. A failed hook cannot enroll a thread;
4624
+ # the opted-in capture proxy rejects its inference request instead.
4625
+ jq -c '{hook_event_name,session_id,source,tool_name}' <<<"$payload" |
4626
+ curl -fsS --max-time 2 -H 'Content-Type: application/json' \
4627
+ -H "X-Weave-Capture-Hook-Token: $WEAVE_CAPTURE_HOOK_TOKEN" \
4628
+ --data-binary @- "$classifier_hook_url" >/dev/null 2>&1 || true
4629
+ ;;
4630
+ esac
4631
+ fi
4632
+ fi
4432
4633
  if [ "$hook_event_name" = "SessionStart" ]; then
4433
4634
  if [ -f "$disabled_marker" ]; then
4434
4635
  emit_title "Codex · direct"
@@ -4438,6 +4639,10 @@ if [ "$hook_event_name" = "SessionStart" ]; then
4438
4639
  exit 0
4439
4640
  fi
4440
4641
 
4642
+ if [ "$hook_event_name" = "PreToolUse" ] || [ "$hook_event_name" = "PreCompact" ]; then
4643
+ exit 0
4644
+ fi
4645
+
4441
4646
  if [ -f "$disabled_marker" ]; then
4442
4647
  exit 0
4443
4648
  fi
@@ -4858,8 +5063,7 @@ if [ "$target" = "opencode" ]; then
4858
5063
  for entry in \
4859
5064
  "opencode.json" \
4860
5065
  ".weave/" \
4861
- ".weave-parked.json" \
4862
- ".opencode/commands/*.weave-router"
5066
+ ".weave-parked.json"
4863
5067
  do
4864
5068
  if [ ! -f "$gitignore" ] || ! grep -qxF "$entry" "$gitignore"; then
4865
5069
  printf '%s\n' "$entry" >>"$gitignore"
@@ -4889,15 +5093,13 @@ if [ "$target" = "opencode" ]; then
4889
5093
  verify_install
4890
5094
 
4891
5095
  announce_done "opencode"
4892
- # Surface the optional subscription-routing path only when this run actually
4893
- # registered the weave-claude login provider (which is written together with
4894
- # the plugin). Gate on its presence in the written config (authoritative)
4895
- # rather than a plugin file on disk — a leftover plugin from a prior install
4896
- # can outlive a plugin-less re-install that stripped the provider, which would
4897
- # make these instructions misleading.
4898
- if jq -e '(.provider // {}) | has("weave-claude")' "$opencode_config_file" >/dev/null 2>&1; then
4899
- info "Optional: connect your AI plans so they pay for the matching turns. Run ${C_BOLD}opencode auth login${C_RESET} → ${C_BOLD}Weave Router — Codex plan${C_RESET} for ${C_BOLD}ChatGPT Pro/Plus${C_RESET} (GPT/Codex turns) and/or ${C_BOLD}Weave Router — Claude plan${C_RESET} for ${C_BOLD}Claude Pro/Max${C_RESET} (Claude turns). The router still routes every turn; your Weave key pays for the rest."
5096
+ enrollment_args=""
5097
+ if [ -n "$install_dir" ]; then
5098
+ enrollment_args=" --dir $(printf '%q' "$install_dir")"
5099
+ elif [ "$scope" = "project" ]; then
5100
+ enrollment_args=" --scope project"
4900
5101
  fi
5102
+ info "To enroll managed subscriptions, run ${C_BOLD}npx $npm_package_name login claude${enrollment_args}${C_RESET} and/or ${C_BOLD}npx $npm_package_name login codex${enrollment_args}${C_RESET}."
4901
5103
  if [ -n "$install_dir" ]; then
4902
5104
  # --dir installs land outside opencode's discovery roots, so the caller
4903
5105
  # has to point opencode at the file explicitly.
@@ -5444,12 +5646,14 @@ prices='{
5444
5646
  "claude-opus-4-7": 0.005,
5445
5647
  "claude-opus-4-8": 0.005,
5446
5648
  "claude-opus-5": 0.005,
5649
+ "claude-opus-5-5": 0.004,
5447
5650
  "claude-sonnet-4-5": 0.003,
5448
5651
  "claude-sonnet-4-6": 0.003,
5449
5652
  "claude-sonnet-5": 0.003,
5450
5653
  "deepseek/deepseek-v4-flash": 0.0001134,
5451
5654
  "deepseek/deepseek-v4-pro": 0.00174,
5452
5655
  "deepseek/deepseek-v4-pro-0813": 0.00174,
5656
+ "deepseek/deepseek-v4.1-flash": 0.00022,
5453
5657
  "gemini-2.0-flash": 0.0001,
5454
5658
  "gemini-2.0-flash-lite": 0.000075,
5455
5659
  "gemini-2.5-flash": 0.0003,
@@ -5488,9 +5692,12 @@ prices='{
5488
5692
  "gpt-5.6-sol-pro": 0.004,
5489
5693
  "gpt-5.6-terra": 0.002,
5490
5694
  "gpt-6-astra": 0.01,
5695
+ "gpt-6-luna": 0.0001,
5696
+ "gpt-6-sol": 0.002,
5491
5697
  "grok-4.5": 0.002,
5492
5698
  "grok-4.6": 0.002,
5493
5699
  "grok-4.7": 0.002,
5700
+ "inclusionai/ling-3.0-flash": 0.00006,
5494
5701
  "minimax/minimax-m2.7": 0.0003,
5495
5702
  "minimax/minimax-m3": 0.0003,
5496
5703
  "mistralai/mistral-small-2603": 0.0002,
@@ -5509,6 +5716,8 @@ prices='{
5509
5716
  "qwen/qwen3.7-plus": 0.0004,
5510
5717
  "qwen/qwen3.8-max": 0.002,
5511
5718
  "xiaomi/mimo-v2.5-pro": 0.001,
5719
+ "xiaomi/mimo-v2.6-flash": 0.00014,
5720
+ "xiaomi/mimo-v2.6-pro": 0.000435,
5512
5721
  "z-ai/glm-5": 0.001,
5513
5722
  "z-ai/glm-5.1": 0.0014,
5514
5723
  "z-ai/glm-5.2": 0.0014,
@@ -5526,12 +5735,14 @@ prices='{
5526
5735
  "claude-opus-4-7": 0.025,
5527
5736
  "claude-opus-4-8": 0.025,
5528
5737
  "claude-opus-5": 0.025,
5738
+ "claude-opus-5-5": 0.02,
5529
5739
  "claude-sonnet-4-5": 0.015,
5530
5740
  "claude-sonnet-4-6": 0.015,
5531
5741
  "claude-sonnet-5": 0.015,
5532
5742
  "deepseek/deepseek-v4-flash": 0.0002791,
5533
5743
  "deepseek/deepseek-v4-pro": 0.00348,
5534
5744
  "deepseek/deepseek-v4-pro-0813": 0.00348,
5745
+ "deepseek/deepseek-v4.1-flash": 0.00066,
5535
5746
  "gemini-2.0-flash": 0.0004,
5536
5747
  "gemini-2.0-flash-lite": 0.0003,
5537
5748
  "gemini-2.5-flash": 0.0012,
@@ -5570,9 +5781,12 @@ prices='{
5570
5781
  "gpt-5.6-sol-pro": 0.02,
5571
5782
  "gpt-5.6-terra": 0.012,
5572
5783
  "gpt-6-astra": 0.05,
5784
+ "gpt-6-luna": 0.0005,
5785
+ "gpt-6-sol": 0.01,
5573
5786
  "grok-4.5": 0.006,
5574
5787
  "grok-4.6": 0.006,
5575
5788
  "grok-4.7": 0.006,
5789
+ "inclusionai/ling-3.0-flash": 0.00018,
5576
5790
  "minimax/minimax-m2.7": 0.0012,
5577
5791
  "minimax/minimax-m3": 0.0012,
5578
5792
  "mistralai/mistral-small-2603": 0.0006,
@@ -5591,6 +5805,8 @@ prices='{
5591
5805
  "qwen/qwen3.7-plus": 0.0016,
5592
5806
  "qwen/qwen3.8-max": 0.006,
5593
5807
  "xiaomi/mimo-v2.5-pro": 0.003,
5808
+ "xiaomi/mimo-v2.6-flash": 0.00028,
5809
+ "xiaomi/mimo-v2.6-pro": 0.00087,
5594
5810
  "z-ai/glm-5": 0.0032,
5595
5811
  "z-ai/glm-5.1": 0.0044,
5596
5812
  "z-ai/glm-5.2": 0.0044,
@@ -5608,12 +5824,14 @@ prices='{
5608
5824
  "claude-opus-4-7": 0.1,
5609
5825
  "claude-opus-4-8": 0.1,
5610
5826
  "claude-opus-5": 0.1,
5827
+ "claude-opus-5-5": 0.05,
5611
5828
  "claude-sonnet-4-5": 0.1,
5612
5829
  "claude-sonnet-4-6": 0.1,
5613
5830
  "claude-sonnet-5": 0.1,
5614
5831
  "deepseek/deepseek-v4-flash": 0.2,
5615
5832
  "deepseek/deepseek-v4-pro": 0.11494252873563218,
5616
5833
  "deepseek/deepseek-v4-pro-0813": 0.11494252873563218,
5834
+ "deepseek/deepseek-v4.1-flash": 0.031818181818181815,
5617
5835
  "gemini-2.0-flash": 0.25,
5618
5836
  "gemini-2.0-flash-lite": 0.25,
5619
5837
  "gemini-2.5-flash": 0.1,
@@ -5652,9 +5870,12 @@ prices='{
5652
5870
  "gpt-5.6-sol-pro": 0.1,
5653
5871
  "gpt-5.6-terra": 0.1,
5654
5872
  "gpt-6-astra": 0.1,
5873
+ "gpt-6-luna": 0.1,
5874
+ "gpt-6-sol": 0.1,
5655
5875
  "grok-4.5": 0.25,
5656
5876
  "grok-4.6": 0.25,
5657
5877
  "grok-4.7": 0.25,
5878
+ "inclusionai/ling-3.0-flash": 0.2,
5658
5879
  "minimax/minimax-m2.7": 0.2,
5659
5880
  "minimax/minimax-m3": 0.2,
5660
5881
  "mistralai/mistral-small-2603": 0.1,
@@ -5673,6 +5894,8 @@ prices='{
5673
5894
  "qwen/qwen3.7-plus": 0.2,
5674
5895
  "qwen/qwen3.8-max": 0.125,
5675
5896
  "xiaomi/mimo-v2.5-pro": 0.1,
5897
+ "xiaomi/mimo-v2.6-flash": 0.02,
5898
+ "xiaomi/mimo-v2.6-pro": 0.00827586,
5676
5899
  "z-ai/glm-5": 0.2,
5677
5900
  "z-ai/glm-5.1": 0.18571428571428572,
5678
5901
  "z-ai/glm-5.2": 0.18571428571428572,
@@ -5980,7 +6203,7 @@ write_claude_settings() {
5980
6203
  jq -n --arg url "$base_url" --arg sl "$statusline_path_for_settings" --arg statusline_install "$statusline_install" '{
5981
6204
  env: { ANTHROPIC_BASE_URL: $url, ENABLE_TOOL_SEARCH: "true" },
5982
6205
  attribution: {
5983
- commit: "Co-Authored-By: Weave Router <router@workweave.ai>",
6206
+ commit: "Co-Authored-By: Weave Router <router@weaveos.com>",
5984
6207
  pr: "🤖 Generated with [Weave Router](https://router.workweave.ai)"
5985
6208
  }
5986
6209
  } + (if $statusline_install == "true" then {statusLine: { type: "command", command: $sl }} else {} end)' >"$tmp_patch"
@@ -5988,7 +6211,7 @@ write_claude_settings() {
5988
6211
  jq -n --arg url "$base_url" --arg header "$custom_headers" --arg sl "$statusline_path_for_settings" --arg statusline_install "$statusline_install" '{
5989
6212
  env: { ANTHROPIC_BASE_URL: $url, ANTHROPIC_CUSTOM_HEADERS: $header, ENABLE_TOOL_SEARCH: "true" },
5990
6213
  attribution: {
5991
- commit: "Co-Authored-By: Weave Router <router@workweave.ai>",
6214
+ commit: "Co-Authored-By: Weave Router <router@weaveos.com>",
5992
6215
  pr: "🤖 Generated with [Weave Router](https://router.workweave.ai)"
5993
6216
  }
5994
6217
  } + (if $statusline_install == "true" then {statusLine: { type: "command", command: $sl }} else {} end)' >"$tmp_patch"
@@ -6077,8 +6300,7 @@ if [ "$scope" = "project" ] && [ -z "$install_dir" ] && [ -n "${git_root:-}" ];
6077
6300
  ".claude/settings.local.json" \
6078
6301
  ".claude/.credentials.json" \
6079
6302
  ".claude/cc-statusline.sh" \
6080
- ".claude/cc-statusline.sh.weave-router" \
6081
- ".claude/commands/*.weave-router"
6303
+ ".claude/cc-statusline.sh.weave-router"
6082
6304
  do
6083
6305
  [[ "$entry" == .claude/cc-statusline.sh* ]] && [ "$statusline_install" != "true" ] && continue
6084
6306
  if [ ! -f "$gitignore" ] || ! grep -qxF "$entry" "$gitignore"; then