llm-switcher 1.1.0

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.
Files changed (51) hide show
  1. package/.gitattributes +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +587 -0
  4. package/README.vi.md +585 -0
  5. package/blindfold/blindfold.mjs +633 -0
  6. package/blindfold/make-certs.sh +88 -0
  7. package/blindfold/wsframe.mjs +176 -0
  8. package/codex-catalog-template.json +1 -0
  9. package/config.example.json +84 -0
  10. package/contract-exclusions.json +41 -0
  11. package/contract.mjs +561 -0
  12. package/docs/LLM-RESPONSE-MATRIX.md +165 -0
  13. package/docs/TOKEN-OPTIMIZER-INTEROP.md +110 -0
  14. package/docs/codex-blindfold.md +214 -0
  15. package/docs/cross-platform.md +136 -0
  16. package/docs/diagrams/blindfold-request-routing.html +14972 -0
  17. package/docs/diagrams/blindfold-request-routing.sequence.json +175 -0
  18. package/docs/diagrams/blindfold-switch-lifecycle.html +14958 -0
  19. package/docs/diagrams/blindfold-switch-lifecycle.lifecycle.json +159 -0
  20. package/docs/diagrams/codex-model-name-resolution.html +15005 -0
  21. package/docs/diagrams/codex-model-name-resolution.workflow.json +71 -0
  22. package/docs/response-matrix.json +1131 -0
  23. package/formats.mjs +2308 -0
  24. package/mcp.mjs +340 -0
  25. package/package.json +36 -0
  26. package/proxy.mjs +1743 -0
  27. package/service.mjs +132 -0
  28. package/shim.mjs +292 -0
  29. package/skills/llm-switcher/SKILL.md +88 -0
  30. package/state.mjs +978 -0
  31. package/switch +5 -0
  32. package/switch.cmd +2 -0
  33. package/switch.mjs +930 -0
  34. package/tests/blindfold.test.mjs +307 -0
  35. package/tests/blindfold.wire.test.mjs +170 -0
  36. package/tests/contract/run.test.mjs +214 -0
  37. package/tests/contract-check.test.mjs +458 -0
  38. package/tests/contract-lab.test.mjs +755 -0
  39. package/tests/datadir.test.mjs +37 -0
  40. package/tests/formats.test.mjs +794 -0
  41. package/tests/gateway.e2e.test.mjs +999 -0
  42. package/tests/helpers.mjs +24 -0
  43. package/tests/lifecycle.test.mjs +416 -0
  44. package/tests/live-optimizer-interop.mjs +205 -0
  45. package/tests/mcp.test.mjs +91 -0
  46. package/tests/service.test.mjs +69 -0
  47. package/tests/shim.test.mjs +228 -0
  48. package/tests/state.test.mjs +675 -0
  49. package/tests/switch.test.mjs +156 -0
  50. package/tests/wsframe.test.mjs +154 -0
  51. package/ui.html +2234 -0
@@ -0,0 +1,175 @@
1
+ {
2
+ "schema_version": 1,
3
+ "diagram_type": "sequence",
4
+ "meta": {
5
+ "title": "Codex Request Routing Through Blindfold",
6
+ "output": "docs/diagrams/blindfold-request-routing.html",
7
+ "viewBox": [
8
+ 1060,
9
+ 480
10
+ ],
11
+ "column_fit": "spread",
12
+ "quality_profile": "showcase"
13
+ },
14
+ "participants": [
15
+ {
16
+ "id": "codex",
17
+ "type": "external",
18
+ "label": "Codex CLI",
19
+ "sublabel": "official endpoint"
20
+ },
21
+ {
22
+ "id": "blindfold",
23
+ "type": "security",
24
+ "label": "Blindfold",
25
+ "sublabel": "CONNECT proxy, port 3457"
26
+ },
27
+ {
28
+ "id": "gateway",
29
+ "type": "backend",
30
+ "label": "Gateway",
31
+ "sublabel": "llm-switcher, port 3456"
32
+ },
33
+ {
34
+ "id": "upstream",
35
+ "type": "cloud",
36
+ "label": "Provider",
37
+ "sublabel": "9Router upstream"
38
+ }
39
+ ],
40
+ "segments": [
41
+ {
42
+ "from": 152,
43
+ "to": 232,
44
+ "label": "Tunnel setup"
45
+ },
46
+ {
47
+ "from": 242,
48
+ "to": 404,
49
+ "label": "Codex API call"
50
+ }
51
+ ],
52
+ "messages": [
53
+ {
54
+ "id": "connect",
55
+ "from": "codex",
56
+ "to": "blindfold",
57
+ "y": 162,
58
+ "label": "CONNECT chatgpt.com:443",
59
+ "variant": "emphasis"
60
+ },
61
+ {
62
+ "id": "established",
63
+ "from": "blindfold",
64
+ "to": "codex",
65
+ "y": 190,
66
+ "label": "200 Connection Established",
67
+ "variant": "return"
68
+ },
69
+ {
70
+ "id": "handshake",
71
+ "from": "codex",
72
+ "to": "blindfold",
73
+ "y": 218,
74
+ "label": "TLS: leaf trusted via CODEX_CA_CERTIFICATE",
75
+ "variant": "security"
76
+ },
77
+ {
78
+ "id": "api-call",
79
+ "from": "codex",
80
+ "to": "blindfold",
81
+ "y": 252,
82
+ "label": "POST /backend-api/codex/responses",
83
+ "variant": "emphasis"
84
+ },
85
+ {
86
+ "id": "forward",
87
+ "from": "blindfold",
88
+ "to": "gateway",
89
+ "y": 280,
90
+ "label": "normalized path, Host set to loopback",
91
+ "variant": "security"
92
+ },
93
+ {
94
+ "id": "upstream-call",
95
+ "from": "gateway",
96
+ "to": "upstream",
97
+ "y": 308,
98
+ "label": "slot model, real provider key",
99
+ "variant": "emphasis"
100
+ },
101
+ {
102
+ "id": "upstream-stream",
103
+ "from": "upstream",
104
+ "to": "gateway",
105
+ "y": 336,
106
+ "label": "stream",
107
+ "variant": "return"
108
+ },
109
+ {
110
+ "id": "echo",
111
+ "from": "gateway",
112
+ "to": "blindfold",
113
+ "y": 364,
114
+ "label": "echoes the requested model name",
115
+ "variant": "return"
116
+ },
117
+ {
118
+ "id": "api-reply",
119
+ "from": "blindfold",
120
+ "to": "codex",
121
+ "y": 392,
122
+ "label": "response",
123
+ "variant": "return"
124
+ }
125
+ ],
126
+ "activations": [
127
+ {
128
+ "participant": "blindfold",
129
+ "from": 156,
130
+ "to": 398,
131
+ "type": "security"
132
+ },
133
+ {
134
+ "participant": "gateway",
135
+ "from": 275,
136
+ "to": 370,
137
+ "type": "backend"
138
+ },
139
+ {
140
+ "participant": "upstream",
141
+ "from": 303,
142
+ "to": 342,
143
+ "type": "cloud"
144
+ }
145
+ ],
146
+ "cards": [
147
+ {
148
+ "dot": "emerald",
149
+ "title": "Why the CLI stays quiet",
150
+ "items": [
151
+ "Codex keeps its official endpoint, so no base URL override exists",
152
+ "Without that override the CLI prints no warning on its /model screen",
153
+ "Its config.toml is never edited"
154
+ ]
155
+ },
156
+ {
157
+ "dot": "rose",
158
+ "title": "Where each request goes",
159
+ "items": [
160
+ "Path under /backend-api/codex/ - the local gateway",
161
+ "Any other path on chatgpt.com - a new TLS session to the real host",
162
+ "Another public host - a raw byte tunnel; a local address is refused"
163
+ ]
164
+ },
165
+ {
166
+ "dot": "orange",
167
+ "title": "The routing decision",
168
+ "items": [
169
+ "The path is normalized before the prefix test, never after",
170
+ "A dot-segment escape is passed through, not routed to the gateway",
171
+ "Only chatgpt.com is decrypted, sign-in and token refresh included"
172
+ ]
173
+ }
174
+ ]
175
+ }