context_drop 0.1.3 → 0.2.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +218 -49
  3. data/SPEC.md +74 -26
  4. data/app/assets/javascripts/context_drop/context_drop.js +5227 -652
  5. data/app/controllers/context_drop/agent_controller.rb +170 -0
  6. data/app/controllers/context_drop/configs_controller.rb +2 -1
  7. data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +62 -2
  8. data/app/controllers/context_drop/feedbacks_controller.rb +13 -3
  9. data/app/controllers/context_drop/mcp_controller.rb +2 -1
  10. data/app/helpers/context_drop/dashboard_helper.rb +52 -0
  11. data/app/helpers/context_drop/widget_helper.rb +11 -1
  12. data/app/javascript/context_drop/__tests__/widget.test.ts +731 -92
  13. data/app/javascript/context_drop/api-client.ts +130 -11
  14. data/app/javascript/context_drop/element-picker.ts +247 -30
  15. data/app/javascript/context_drop/icons.ts +24 -0
  16. data/app/javascript/context_drop/markdown.ts +146 -0
  17. data/app/javascript/context_drop/sanitizer.ts +413 -2
  18. data/app/javascript/context_drop/screenshot.ts +102 -8
  19. data/app/javascript/context_drop/styles.ts +1528 -252
  20. data/app/javascript/context_drop/types.ts +147 -0
  21. data/app/javascript/context_drop/widget.ts +2629 -288
  22. data/app/models/context_drop/feedback.rb +34 -5
  23. data/app/views/context_drop/dashboard/feedbacks/index.html.erb +166 -60
  24. data/app/views/context_drop/dashboard/feedbacks/show.html.erb +178 -47
  25. data/app/views/layouts/context_drop/application.html.erb +416 -70
  26. data/config/routes.rb +11 -0
  27. data/db/migrate/20261112000004_add_environment_to_context_drop_feedbacks.rb +10 -0
  28. data/lib/context_drop/agent/key_store.rb +290 -0
  29. data/lib/context_drop/agent/llm_client.rb +413 -0
  30. data/lib/context_drop/agent/orchestrator.rb +314 -0
  31. data/lib/context_drop/agent/workspace_sandbox.rb +499 -0
  32. data/lib/context_drop/configuration.rb +216 -3
  33. data/lib/context_drop/mcp/dispatcher.rb +71 -29
  34. data/lib/context_drop/mcp/environment_router.rb +115 -0
  35. data/lib/context_drop/mcp/prompts/investigate_feedback.rb +87 -8
  36. data/lib/context_drop/mcp/remote_client.rb +120 -0
  37. data/lib/context_drop/mcp/server.rb +9 -2
  38. data/lib/context_drop/mcp/tools/get_feedback.rb +50 -4
  39. data/lib/context_drop/mcp/tools/get_feedback_attachment.rb +26 -4
  40. data/lib/context_drop/mcp/tools/list_environments.rb +60 -0
  41. data/lib/context_drop/mcp/tools/list_feedbacks.rb +174 -22
  42. data/lib/context_drop/mcp/tools/update_feedback_status.rb +45 -4
  43. data/lib/context_drop/version.rb +1 -1
  44. data/lib/context_drop.rb +8 -2
  45. data/lib/generators/context_drop/install/templates/initializer.rb.tt +29 -2
  46. metadata +13 -2
@@ -1,5 +1,9 @@
1
1
  export type WidgetPosition = "bottom_right" | "bottom_left" | "top_right" | "top_left";
2
2
 
3
+ export type WidgetSurfaceMode = "agent" | "feedback";
4
+
5
+ export type SelectionMode = "smart" | "verbose";
6
+
3
7
  export interface BoundingRectSnapshot {
4
8
  x: number;
5
9
  y: number;
@@ -33,11 +37,21 @@ export interface ElementCandidateInfo {
33
37
  selector: string;
34
38
  domPath: string;
35
39
  textPreview: string | null;
40
+ friendlyLabel?: string;
41
+ componentKind?: string;
36
42
  rect: BoundingRectSnapshot;
37
43
  relation: ElementCandidateRelation;
38
44
  depth: number;
39
45
  }
40
46
 
47
+ export interface SmartComponentDescription {
48
+ element: Element;
49
+ label: string;
50
+ kind: string;
51
+ name: string | null;
52
+ promotedFromLeaf: boolean;
53
+ }
54
+
41
55
  export interface PendingAttachmentItem {
42
56
  id: string;
43
57
  attachment_type: "image" | "screenshot";
@@ -66,13 +80,19 @@ export interface SessionFeedbackEntry {
66
80
 
67
81
  export interface WidgetConfig {
68
82
  enabled: boolean;
83
+ environment?: string;
69
84
  position: WidgetPosition;
70
85
  placeholder: string;
71
86
  csrf_token?: string | null;
87
+ agent?: {
88
+ enabled: boolean;
89
+ };
72
90
  features: {
73
91
  element_selection: boolean;
92
+ selection_mode?: SelectionMode;
74
93
  screenshot_capture: boolean;
75
94
  element_capture_padding: number;
95
+ smart_capture_padding?: number;
76
96
  };
77
97
  limits: {
78
98
  max_attachments: number;
@@ -104,8 +124,135 @@ export interface FeedbackSubmissionPayload {
104
124
 
105
125
  export interface FeedbackSubmissionResponse {
106
126
  id: number;
127
+ environment?: string;
107
128
  status: string;
108
129
  attachments_count: number;
109
130
  element_references_count: number;
110
131
  created_at: string;
111
132
  }
133
+
134
+ export interface AgentProviderInfo {
135
+ id: string;
136
+ label: string;
137
+ configured: boolean;
138
+ source: "vault" | "env" | "local_no_key" | null;
139
+ env_var_hint: string;
140
+ masked_key: string | null;
141
+ model: string;
142
+ default_model: string;
143
+ models: string[];
144
+ supports_base_url: boolean;
145
+ base_url?: string | null;
146
+ }
147
+
148
+ export interface AgentEnvironmentInfo {
149
+ name: string;
150
+ type: string;
151
+ host_env?: string;
152
+ url?: string;
153
+ }
154
+
155
+ export interface AgentStatusResponse {
156
+ enabled: boolean;
157
+ environment: string;
158
+ workspace_name: string;
159
+ mcp_environments: AgentEnvironmentInfo[];
160
+ active_provider: string;
161
+ providers: AgentProviderInfo[];
162
+ }
163
+
164
+ export interface AgentKeysUpdatePayload {
165
+ provider: string;
166
+ api_key?: string;
167
+ model?: string;
168
+ base_url?: string;
169
+ make_active?: boolean;
170
+ }
171
+
172
+ export interface AgentKeysUpdateResponse {
173
+ active_provider: string;
174
+ providers: AgentProviderInfo[];
175
+ }
176
+
177
+ export interface AgentToolTrace {
178
+ name: string;
179
+ summary: string;
180
+ status: "ok" | "error";
181
+ }
182
+
183
+ export interface ProposedFileEdit {
184
+ id: string;
185
+ path: string;
186
+ summary: string;
187
+ is_new_file: boolean;
188
+ diff: string;
189
+ added_lines: number;
190
+ removed_lines: number;
191
+ status: "pending" | "applied" | "rejected" | "reverted";
192
+ created_at: string;
193
+ }
194
+
195
+ export interface AgentChatTurnInput {
196
+ role: "user" | "assistant";
197
+ content: string;
198
+ }
199
+
200
+ export interface AgentChatRequestPayload {
201
+ messages: AgentChatTurnInput[];
202
+ page_url: string;
203
+ element_references: ElementReferenceSnapshot[];
204
+ attachments: Array<{
205
+ attachment_type: "image" | "screenshot";
206
+ filename: string;
207
+ data_url?: string;
208
+ }>;
209
+ provider?: string;
210
+ model?: string;
211
+ }
212
+
213
+ export interface AgentChatResponse {
214
+ reply: string;
215
+ provider: string;
216
+ model: string;
217
+ tool_calls: AgentToolTrace[];
218
+ proposed_edits: ProposedFileEdit[];
219
+ }
220
+
221
+ export interface AgentChatMessage {
222
+ id: string;
223
+ role: "user" | "assistant";
224
+ content: string;
225
+ createdAt: string;
226
+ elements?: ElementReferenceSnapshot[];
227
+ attachments?: Array<{
228
+ id: string;
229
+ label: string;
230
+ preview_url: string;
231
+ attachment_type: "image" | "screenshot";
232
+ }>;
233
+ toolCalls?: AgentToolTrace[];
234
+ proposedEdits?: ProposedFileEdit[];
235
+ provider?: string;
236
+ model?: string;
237
+ }
238
+
239
+ export interface CrossEnvFeedbackItem {
240
+ id: number | string;
241
+ qualified_id?: string;
242
+ environment: string;
243
+ message: string;
244
+ page_url: string;
245
+ status: string;
246
+ primary_selector?: string | null;
247
+ element_references_count: number;
248
+ attachments_count: number;
249
+ created_at: string;
250
+ }
251
+
252
+ export interface CrossEnvFeedbackListResponse {
253
+ environment_filter?: string;
254
+ total_count: number;
255
+ environments_queried?: string[];
256
+ errors?: Array<{ environment: string; error: string }>;
257
+ feedbacks: CrossEnvFeedbackItem[];
258
+ }