dsh-oauth-login 0.2.4

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 (64) hide show
  1. package/INSTALL.md +59 -0
  2. package/INSTALL.zh.md +45 -0
  3. package/LICENSE +201 -0
  4. package/README.en.md +104 -0
  5. package/README.md +104 -0
  6. package/README.zh.md +3 -0
  7. package/SECURITY.md +33 -0
  8. package/cordis.patch.yml +5 -0
  9. package/docs/network-proxy.md +45 -0
  10. package/docs/openrouter-sync.md +84 -0
  11. package/docs/screenshots/01-providers-signed-out.png +0 -0
  12. package/docs/screenshots/03-copilot-signing-in.png +0 -0
  13. package/docs/screenshots/04-mixed-live-states.png +0 -0
  14. package/docs/screenshots/05-copilot-sign-in.gif +0 -0
  15. package/docs/screenshots/06-cli-status-store.png +0 -0
  16. package/lib/bin.d.ts +5 -0
  17. package/lib/bin.js +2132 -0
  18. package/lib/client.js +1915 -0
  19. package/lib/client.js.map +1 -0
  20. package/lib/index.d.ts +482 -0
  21. package/lib/index.js +3105 -0
  22. package/lib/invariant.d.ts +7 -0
  23. package/lib/invariant.js +8 -0
  24. package/package.json +180 -0
  25. package/src/adapter.ts +207 -0
  26. package/src/auth-routes.ts +654 -0
  27. package/src/auth.ts +76 -0
  28. package/src/bin.ts +185 -0
  29. package/src/catalog.ts +129 -0
  30. package/src/client/OpenRouterSyncStatus.tsx +66 -0
  31. package/src/client/PiLoginSettings.tsx +470 -0
  32. package/src/client/ProxySettings.tsx +123 -0
  33. package/src/client/SearchableModelSelect.tsx +595 -0
  34. package/src/client/draft-input.ts +12 -0
  35. package/src/client/index.tsx +71 -0
  36. package/src/client/locales.ts +176 -0
  37. package/src/client/login-input-copy.ts +34 -0
  38. package/src/client/login-window.ts +24 -0
  39. package/src/client/model-filter.ts +45 -0
  40. package/src/client/openrouter-store.ts +122 -0
  41. package/src/client/proxy-draft.ts +57 -0
  42. package/src/extra-models.ts +201 -0
  43. package/src/hosted-capture.ts +41 -0
  44. package/src/hosted-images.ts +154 -0
  45. package/src/http.ts +241 -0
  46. package/src/ids.ts +17 -0
  47. package/src/index.ts +183 -0
  48. package/src/invariant.ts +12 -0
  49. package/src/model-error-hint.ts +98 -0
  50. package/src/native-tools.ts +442 -0
  51. package/src/oauth-refresh.ts +49 -0
  52. package/src/openrouter-catalog.ts +245 -0
  53. package/src/openrouter-free.ts +76 -0
  54. package/src/openrouter-models.ts +155 -0
  55. package/src/openrouter-types.ts +40 -0
  56. package/src/plugin-config.ts +30 -0
  57. package/src/provider.ts +137 -0
  58. package/src/proxy-config.ts +61 -0
  59. package/src/proxy-store.ts +45 -0
  60. package/src/proxy-transport.ts +220 -0
  61. package/src/redact.ts +22 -0
  62. package/src/responses-tap.ts +97 -0
  63. package/src/session.ts +104 -0
  64. package/src/store.ts +234 -0
@@ -0,0 +1,84 @@
1
+ # OpenRouter model sync
2
+
3
+ ## Request and scope
4
+
5
+ Use the normal DSH OAuth plugin to discover current OpenRouter models and make
6
+ free models easy to select. Preserve the existing two-level composer menu,
7
+ search, reasoning selection, GLM key-input fix and all other providers. Do not
8
+ change DSH core, credentials, existing conversations, or the selected model.
9
+
10
+ ## Runtime contract
11
+
12
+ - After OpenRouter login: refresh the public Models API immediately.
13
+ - Startup: show the persisted catalog; refresh when older than 15 minutes.
14
+ - While signed in: one Host-owned timer refreshes every 15 minutes. Logout and
15
+ plugin disposal cancel the timer and in-flight refresh.
16
+ - Opening the menu reads cached metadata and asks for an async stale refresh.
17
+ - Manual refresh is coalesced across windows and has a 60-second cooldown.
18
+ - A network, empty-data or partial-response failure preserves the last-good
19
+ list and timestamp. Cache lives beside the plugin credential file in
20
+ .dsh-oauth-openrouter-models.json, with no tokens or keys.
21
+ - New models enter the actual pi-ai-backed DSH adapter, not only the menu.
22
+ - Full live catalogs replace obsolete builtin entries; missing current
23
+ selections are not silently changed to another model.
24
+
25
+ ## Price and safety contract
26
+
27
+ The free badge uses official prices, including extra unit costs. Missing or
28
+ invalid prices and conditional pricing overrides are not labelled free.
29
+ The expiration_date field means endpoint deprecation, not a promotion deadline.
30
+ Unknown promotion deadlines are not invented.
31
+
32
+ Free requests pin the model ID, set all supported provider price caps to zero,
33
+ disable provider/model fallbacks, disable known paid OpenRouter plugins, and
34
+ reject hosted tools or file/audio processing. Ordinary DSH function tools stay
35
+ available. A model previously advertised as free keeps its zero-price guard
36
+ even after a restart or price change. A promotion ending never opts the user
37
+ into a paid call. Explicit paid model variants remain separate choices.
38
+
39
+ Platform-enforced account/organization plugins can override per-request
40
+ settings. DSH cannot override those policies: users must disable forced paid
41
+ plugins in OpenRouter before relying on free inference. The UI states this
42
+ limit; it does not promise that all account-level services are free.
43
+
44
+ Official contracts:
45
+ [Models API](https://openrouter.ai/docs/guides/overview/models),
46
+ [price caps](https://openrouter.ai/docs/guides/routing/provider-selection#max-price),
47
+ [plugins](https://openrouter.ai/docs/guides/features/plugins),
48
+ [free router](https://openrouter.ai/docs/guides/routing/routers/free-router).
49
+
50
+ ## Native UI contract
51
+
52
+ Clarity-first, single-agent implementation. Keep the host's font, compact
53
+ menu density, theme tokens and two-level layout. No new font, imagery,
54
+ animation, dashboard or layout family. The visual cue is a small green
55
+ text badge, never color alone. A stale free badge becomes neutral and says
56
+ it is cached. Model names may truncate; price/safety state must not.
57
+
58
+ Show All / Free only (OpenRouter), tool capability, context size, last sync,
59
+ refresh feedback and a retry path. The OpenRouter settings card shares the
60
+ same client metadata store. A background update cannot steal keyboard focus
61
+ or change selection. Controls wrap at narrow widths; menu scrolling is
62
+ internal. No token/key values are needed for browser verification.
63
+
64
+ ## OKF decision bindings
65
+
66
+ | Active concept | Decision | Target | Verification |
67
+ | --- | --- | --- | --- |
68
+ | request-integrity | Normal DSH only; no core or selection mutation | Adapter, menu, deployment | Route tests; exact Host/PID verification |
69
+ | accessibility-usability | Text badges, named controls, stable focus | Filters, refresh, model rows | Keyboard/focus and screen-state tests |
70
+ | responsive-interaction | Wrap status/filters; bounded, scrollable menu | Composer popover | Desktop and narrow screenshots/geometry |
71
+ | state-language | Distinguish cached, stale, refreshing, failed and signed out | Shared sync status | Failure/cooldown tests and visible state review |
72
+ | typography-system | Keep native type; wrap critical status; separate model ID | Model metadata rows | Long-label and mixed Chinese/English rendering |
73
+
74
+ Support: existing DSH theme/source, web-product/content-model branches,
75
+ visual-verification and quality-gates. A compact feature contract is used
76
+ instead of introducing a separate design system for this existing component.
77
+
78
+ ## Acceptance
79
+
80
+ Unit checks cover parsing, free classification, cache restart, refresh
81
+ frequency/coalescing, logout races, real adapter resolution, and final outbound
82
+ payload guards. Rendered checks cover search/free filtering, manual refresh,
83
+ cached failure, focus, unchanged selection and narrow layout. dshx check,
84
+ artifact sync and running Host/UI evidence are separate delivery gates.
package/lib/bin.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ //#region src/bin.d.ts
2
+ /** Standalone credential CLI. Never reads or writes official CLI auth files. */
3
+ declare function run(argv: readonly string[]): Promise<number>;
4
+ //#endregion
5
+ export { run };