@agentconnect/ui 0.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 (68) hide show
  1. package/README.md +63 -0
  2. package/dist/client.d.ts +15 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +22 -0
  5. package/dist/components/connect.d.ts +79 -0
  6. package/dist/components/connect.d.ts.map +1 -0
  7. package/dist/components/connect.js +1110 -0
  8. package/dist/components/index.d.ts +8 -0
  9. package/dist/components/index.d.ts.map +1 -0
  10. package/dist/components/index.js +7 -0
  11. package/dist/components/login-button.d.ts +16 -0
  12. package/dist/components/login-button.d.ts.map +1 -0
  13. package/dist/components/login-button.js +69 -0
  14. package/dist/components/model-picker.d.ts +16 -0
  15. package/dist/components/model-picker.d.ts.map +1 -0
  16. package/dist/components/model-picker.js +61 -0
  17. package/dist/components/provider-status.d.ts +10 -0
  18. package/dist/components/provider-status.d.ts.map +1 -0
  19. package/dist/components/provider-status.js +42 -0
  20. package/dist/constants.d.ts +33 -0
  21. package/dist/constants.d.ts.map +1 -0
  22. package/dist/constants.js +156 -0
  23. package/dist/index.d.ts +11 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +13 -0
  26. package/dist/register.d.ts +9 -0
  27. package/dist/register.d.ts.map +1 -0
  28. package/dist/register.js +25 -0
  29. package/dist/styles/base.d.ts +5 -0
  30. package/dist/styles/base.d.ts.map +1 -0
  31. package/dist/styles/base.js +49 -0
  32. package/dist/styles/buttons.d.ts +6 -0
  33. package/dist/styles/buttons.d.ts.map +1 -0
  34. package/dist/styles/buttons.js +206 -0
  35. package/dist/styles/cards.d.ts +5 -0
  36. package/dist/styles/cards.d.ts.map +1 -0
  37. package/dist/styles/cards.js +212 -0
  38. package/dist/styles/index.d.ts +20 -0
  39. package/dist/styles/index.d.ts.map +1 -0
  40. package/dist/styles/index.js +42 -0
  41. package/dist/styles/inputs.d.ts +5 -0
  42. package/dist/styles/inputs.d.ts.map +1 -0
  43. package/dist/styles/inputs.js +79 -0
  44. package/dist/styles/panels.d.ts +5 -0
  45. package/dist/styles/panels.d.ts.map +1 -0
  46. package/dist/styles/panels.js +184 -0
  47. package/dist/styles/responsive.d.ts +5 -0
  48. package/dist/styles/responsive.d.ts.map +1 -0
  49. package/dist/styles/responsive.js +62 -0
  50. package/dist/styles/utilities.d.ts +5 -0
  51. package/dist/styles/utilities.d.ts.map +1 -0
  52. package/dist/styles/utilities.js +86 -0
  53. package/dist/types.d.ts +137 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +4 -0
  56. package/dist/utils/dom.d.ts +24 -0
  57. package/dist/utils/dom.d.ts.map +1 -0
  58. package/dist/utils/dom.js +42 -0
  59. package/dist/utils/html.d.ts +8 -0
  60. package/dist/utils/html.d.ts.map +1 -0
  61. package/dist/utils/html.js +11 -0
  62. package/dist/utils/index.d.ts +7 -0
  63. package/dist/utils/index.d.ts.map +1 -0
  64. package/dist/utils/index.js +6 -0
  65. package/dist/utils/storage.d.ts +29 -0
  66. package/dist/utils/storage.d.ts.map +1 -0
  67. package/dist/utils/storage.js +110 -0
  68. package/package.json +40 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * localStorage utility functions with safe fallbacks.
3
+ */
4
+ import { DEFAULT_LOCAL_CONFIG, STORAGE_KEYS } from '../constants';
5
+ /**
6
+ * Check if localStorage is available.
7
+ */
8
+ function isStorageAvailable() {
9
+ return typeof localStorage !== 'undefined';
10
+ }
11
+ /**
12
+ * Read local provider configuration from storage.
13
+ */
14
+ export function readLocalConfig(key = STORAGE_KEYS.localConfig) {
15
+ if (!isStorageAvailable()) {
16
+ return { ...DEFAULT_LOCAL_CONFIG };
17
+ }
18
+ try {
19
+ const raw = localStorage.getItem(key);
20
+ if (!raw)
21
+ return { ...DEFAULT_LOCAL_CONFIG };
22
+ const parsed = JSON.parse(raw);
23
+ return {
24
+ baseUrl: typeof parsed.baseUrl === 'string' ? parsed.baseUrl : '',
25
+ apiKey: typeof parsed.apiKey === 'string' ? parsed.apiKey : '',
26
+ model: typeof parsed.model === 'string' ? parsed.model : '',
27
+ models: Array.isArray(parsed.models)
28
+ ? parsed.models.filter((m) => typeof m === 'string')
29
+ : [],
30
+ };
31
+ }
32
+ catch {
33
+ return { ...DEFAULT_LOCAL_CONFIG };
34
+ }
35
+ }
36
+ /**
37
+ * Persist local provider configuration to storage.
38
+ */
39
+ export function persistLocalConfig(config, key = STORAGE_KEYS.localConfig) {
40
+ if (!isStorageAvailable())
41
+ return;
42
+ try {
43
+ localStorage.setItem(key, JSON.stringify(config));
44
+ }
45
+ catch {
46
+ // Storage quota exceeded or other error
47
+ }
48
+ }
49
+ /**
50
+ * Read the last selection from storage.
51
+ */
52
+ export function readSelection(key = STORAGE_KEYS.lastSelection) {
53
+ if (!isStorageAvailable())
54
+ return null;
55
+ try {
56
+ const raw = localStorage.getItem(key);
57
+ if (!raw)
58
+ return null;
59
+ const parsed = JSON.parse(raw);
60
+ if (parsed?.provider && parsed?.model) {
61
+ const reasoningEffort = typeof parsed.reasoningEffort === 'string' && parsed.reasoningEffort
62
+ ? parsed.reasoningEffort
63
+ : null;
64
+ return {
65
+ provider: parsed.provider,
66
+ model: parsed.model,
67
+ reasoningEffort,
68
+ scopeId: buildScopeId(parsed.provider, parsed.model, reasoningEffort),
69
+ };
70
+ }
71
+ return null;
72
+ }
73
+ catch {
74
+ return null;
75
+ }
76
+ }
77
+ /**
78
+ * Save the current selection to storage.
79
+ */
80
+ export function saveSelection(selection, key = STORAGE_KEYS.lastSelection) {
81
+ if (!isStorageAvailable())
82
+ return;
83
+ try {
84
+ localStorage.setItem(key, JSON.stringify(selection));
85
+ }
86
+ catch {
87
+ // Storage quota exceeded or other error
88
+ }
89
+ }
90
+ /**
91
+ * Clear the saved selection from storage.
92
+ */
93
+ export function clearSelection(key = STORAGE_KEYS.lastSelection) {
94
+ if (!isStorageAvailable())
95
+ return;
96
+ try {
97
+ localStorage.removeItem(key);
98
+ }
99
+ catch {
100
+ // Ignore errors
101
+ }
102
+ }
103
+ /**
104
+ * Build a unique scope ID from provider, model, and reasoning effort.
105
+ */
106
+ export function buildScopeId(provider, model, reasoningEffort) {
107
+ if (!reasoningEffort)
108
+ return `${provider}:${model}`;
109
+ return `${provider}:${model}:${reasoningEffort}`;
110
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@agentconnect/ui",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "homepage": "https://github.com/rayzhudev/agent-connect",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rayzhudev/agent-connect.git",
10
+ "directory": "packages/ui"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/rayzhudev/agent-connect/issues"
14
+ },
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.js",
20
+ "types": "./dist/index.d.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "dev": "tsc --watch"
29
+ },
30
+ "dependencies": {
31
+ "@agentconnect/sdk": "workspace:*"
32
+ },
33
+ "devDependencies": {
34
+ "typescript": "^5.6.2"
35
+ },
36
+ "sideEffects": false,
37
+ "engines": {
38
+ "node": ">=20"
39
+ }
40
+ }