handhold-sdk 1.0.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 (50) hide show
  1. package/README.md +427 -0
  2. package/dist/d44f1fe8001e32f8e74d.svg +3056 -0
  3. package/dist/fonts/Phosphor.ttf +0 -0
  4. package/dist/fonts/Phosphor.woff +0 -0
  5. package/dist/fonts/Phosphor.woff2 +0 -0
  6. package/dist/handhold.min.js +1 -0
  7. package/package.json +114 -0
  8. package/src/HandHold.js +1599 -0
  9. package/src/agent/VENDOR.md +203 -0
  10. package/src/agent/agent/AgentLoop.js +366 -0
  11. package/src/agent/agent/prompts.js +163 -0
  12. package/src/agent/agent/tools.js +148 -0
  13. package/src/agent/controller.js +235 -0
  14. package/src/agent/dom/actions.js +456 -0
  15. package/src/agent/dom/domTree.js +1761 -0
  16. package/src/agent/dom/redact.js +98 -0
  17. package/src/agent/dom/serializer.js +332 -0
  18. package/src/agent/dom/utils.js +99 -0
  19. package/src/agent/index.js +169 -0
  20. package/src/agent/llm/connector.js +143 -0
  21. package/src/agent/package.json +3 -0
  22. package/src/agent/policy/PolicyGuard.js +172 -0
  23. package/src/agent/site/manifest.js +145 -0
  24. package/src/agent/ui/ChatWidget.js +219 -0
  25. package/src/agent-mode/AgentMode.js +429 -0
  26. package/src/api/APIClient.js +258 -0
  27. package/src/core/Config.js +207 -0
  28. package/src/core/UiState.js +83 -0
  29. package/src/core/defaults.js +20 -0
  30. package/src/events.js +59 -0
  31. package/src/index.js +77 -0
  32. package/src/intent/ActionVerbMap.js +324 -0
  33. package/src/intent/IntentExtractor.js +317 -0
  34. package/src/observers/ElementScanner.js +284 -0
  35. package/src/observers/NavigationObserver.js +182 -0
  36. package/src/observers/PageObserver.js +293 -0
  37. package/src/session/SessionManager.js +402 -0
  38. package/src/session/SessionStorage.js +148 -0
  39. package/src/ui/HelpWidget.js +1189 -0
  40. package/src/ui/UICoach.js +1725 -0
  41. package/src/ui/components/Button.css +137 -0
  42. package/src/ui/components/Button.js +102 -0
  43. package/src/ui/widget.css +599 -0
  44. package/src/utils/Logger.js +132 -0
  45. package/src/utils/MarkdownRenderer.js +39 -0
  46. package/src/utils/domUtils.js +350 -0
  47. package/src/utils/eventBus.js +102 -0
  48. package/src/utils/index.js +8 -0
  49. package/src/utils/stringUtils.js +202 -0
  50. package/types/index.d.ts +538 -0
@@ -0,0 +1,137 @@
1
+ .handhold-btn {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ cursor: pointer;
6
+ border: 2px solid transparent;
7
+ border-radius: 14px;
8
+ font-family: inherit;
9
+ font-size: 14px;
10
+ font-weight: 600;
11
+ transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
12
+ box-sizing: border-box;
13
+ text-decoration: none;
14
+ line-height: 1.5;
15
+ margin: 0;
16
+ appearance: none;
17
+ -webkit-appearance: none;
18
+ }
19
+
20
+ .handhold-btn:disabled {
21
+ opacity: 0.6;
22
+ cursor: not-allowed;
23
+ pointer-events: none;
24
+ }
25
+
26
+ /* Variants */
27
+
28
+ .handhold-btn-primary {
29
+ background: var(--hh-primary);
30
+ color: var(--hh-primary-fg);
31
+ border-color: transparent;
32
+ }
33
+ .handhold-btn-primary:hover {
34
+ background: var(--hh-primary-dark);
35
+ transform: none;
36
+ box-shadow: none;
37
+ }
38
+
39
+ .handhold-btn-secondary {
40
+ background: transparent;
41
+ color: var(--hh-muted-fg);
42
+ border-color: transparent;
43
+ }
44
+ .handhold-btn-secondary:hover {
45
+ background: var(--hh-secondary);
46
+ color: var(--hh-fg);
47
+ }
48
+
49
+ .handhold-btn-success {
50
+ background: #FFFFFF;
51
+ color: #1e293b;
52
+ border-color: #e2e8f0;
53
+ }
54
+ .handhold-btn-success:hover {
55
+ background: #f8fafc;
56
+ border-color: #cbd5e1;
57
+ }
58
+
59
+ .handhold-btn-outline {
60
+ background: #FFFFFF;
61
+ border-color: var(--hh-border);
62
+ color: var(--hh-fg);
63
+ }
64
+ .handhold-btn-outline:hover {
65
+ border-color: var(--hh-primary);
66
+ color: var(--hh-primary);
67
+ }
68
+
69
+ .handhold-btn-ghost {
70
+ background: transparent;
71
+ border-color: transparent;
72
+ color: var(--hh-muted);
73
+ }
74
+ .handhold-btn-ghost:hover {
75
+ background: var(--hh-secondary);
76
+ color: var(--hh-fg);
77
+ }
78
+
79
+ .handhold-btn-fab {
80
+ border-radius: 50%;
81
+ background: var(--hh-bg);
82
+ color: var(--hh-fg);
83
+ border-color: var(--hh-border);
84
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
85
+ }
86
+ .handhold-btn-fab:hover {
87
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
88
+ color: var(--hh-primary);
89
+ border-color: var(--hh-primary);
90
+ }
91
+
92
+ /* Sizes */
93
+
94
+ .handhold-btn-size-small {
95
+ padding: 8px 16px;
96
+ font-size: 13px;
97
+ border-radius: 12px;
98
+ }
99
+
100
+ .handhold-btn-size-medium {
101
+ padding: 12px 24px;
102
+ font-size: 14px;
103
+ border-radius: 14px;
104
+ }
105
+
106
+ .handhold-btn-size-large {
107
+ padding: 16px 32px;
108
+ font-size: 16px;
109
+ border-radius: 16px;
110
+ }
111
+
112
+ .handhold-btn-size-icon {
113
+ width: 32px;
114
+ height: 32px;
115
+ padding: 0;
116
+ border-radius: 6px;
117
+ }
118
+
119
+ .handhold-btn-size-icon-lg {
120
+ width: 56px;
121
+ height: 56px;
122
+ padding: 0;
123
+ border-radius: 6px;
124
+ }
125
+
126
+ /* Inner Layout */
127
+ .handhold-btn-icon-wrapper {
128
+ display: flex;
129
+ align-items: center;
130
+ justify-content: center;
131
+ font-size: 1.2em;
132
+ line-height: 1;
133
+ }
134
+
135
+ .handhold-btn-label.with-icon {
136
+ margin-left: 8px;
137
+ }
@@ -0,0 +1,102 @@
1
+ import './Button.css';
2
+
3
+ export const ButtonVariant = {
4
+ PRIMARY: 'primary',
5
+ SECONDARY: 'secondary',
6
+ SUCCESS: 'success',
7
+ OUTLINE: 'outline',
8
+ GHOST: 'ghost',
9
+ FAB: 'fab'
10
+ };
11
+
12
+ export const ButtonSize = {
13
+ SMALL: 'small',
14
+ MEDIUM: 'medium',
15
+ LARGE: 'large',
16
+ ICON: 'icon', // 32px square
17
+ ICON_LG: 'icon-lg' // 56px square
18
+ };
19
+
20
+ export class Button {
21
+ /**
22
+ * Create a button component
23
+ * @param {Object} options
24
+ * @param {string} options.text - Button text
25
+ * @param {string} options.icon - Icon HTML (SVG or <i class="ph...">)
26
+ * @param {string} options.variant - ButtonVariant
27
+ * @param {string} options.size - ButtonSize
28
+ * @param {string} options.className - Additional classes
29
+ * @param {Object} options.attributes - HTML attributes (aria-label, data-*, etc.)
30
+ * @param {Function} options.onClick - Click handler (only if using create())
31
+ */
32
+ constructor({
33
+ text = '',
34
+ icon = null,
35
+ variant = ButtonVariant.PRIMARY,
36
+ size = ButtonSize.MEDIUM,
37
+ className = '',
38
+ attributes = {},
39
+ onClick = null
40
+ } = {}) {
41
+ this.text = text;
42
+ this.icon = icon;
43
+ this.variant = variant;
44
+ this.size = size;
45
+ this.className = className;
46
+ this.attributes = attributes;
47
+ this.onClick = onClick;
48
+ }
49
+
50
+ /**
51
+ * Render button as HTML string
52
+ * @returns {string}
53
+ */
54
+ render() {
55
+ const classNames = [
56
+ 'handhold-btn',
57
+ `handhold-btn-${this.variant}`,
58
+ `handhold-btn-size-${this.size}`,
59
+ this.className
60
+ ].filter(Boolean).join(' ');
61
+
62
+ const attrs = Object.entries(this.attributes)
63
+ .map(([key, value]) => {
64
+ if (value === null || value === undefined) return '';
65
+ return `${key}="${value}"`;
66
+ })
67
+ .join(' ');
68
+
69
+ // Determine content layout
70
+ let content = '';
71
+ if (this.icon) {
72
+ content += `<span class="handhold-btn-icon-wrapper">${this.icon}</span>`;
73
+ }
74
+ if (this.text) {
75
+ // Add margin if icon exists
76
+ const textClass = this.icon ? 'handhold-btn-label with-icon' : 'handhold-btn-label';
77
+ content += `<span class="${textClass}">${this.text}</span>`;
78
+ }
79
+
80
+ return `
81
+ <button class="${classNames}" ${attrs}>
82
+ ${content}
83
+ </button>
84
+ `;
85
+ }
86
+
87
+ /**
88
+ * Create button as DOM Element
89
+ * @returns {HTMLButtonElement}
90
+ */
91
+ create() {
92
+ const wrapper = document.createElement('div');
93
+ wrapper.innerHTML = this.render();
94
+ const button = wrapper.firstElementChild;
95
+
96
+ if (this.onClick) {
97
+ button.addEventListener('click', this.onClick);
98
+ }
99
+
100
+ return button;
101
+ }
102
+ }