context_drop 0.1.4 → 0.3.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. checksums.yaml +4 -4
  2. data/README.md +330 -116
  3. data/Rakefile +110 -1
  4. data/SPEC.md +74 -26
  5. data/app/assets/javascripts/context_drop/context_drop.js +6329 -682
  6. data/app/controllers/context_drop/agent_controller.rb +170 -0
  7. data/app/controllers/context_drop/application_controller.rb +52 -3
  8. data/app/controllers/context_drop/configs_controller.rb +12 -2
  9. data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +15 -11
  10. data/app/controllers/context_drop/feedbacks_controller.rb +396 -20
  11. data/app/controllers/context_drop/mcp_controller.rb +2 -1
  12. data/app/helpers/context_drop/widget_helper.rb +11 -1
  13. data/app/javascript/context_drop/__tests__/api-client.test.ts +255 -0
  14. data/app/javascript/context_drop/__tests__/widget.test.ts +1015 -89
  15. data/app/javascript/context_drop/api-client.ts +422 -19
  16. data/app/javascript/context_drop/element-picker.ts +186 -34
  17. data/app/javascript/context_drop/icons.ts +28 -0
  18. data/app/javascript/context_drop/markdown.ts +146 -0
  19. data/app/javascript/context_drop/sanitizer.ts +413 -2
  20. data/app/javascript/context_drop/screenshot.ts +103 -9
  21. data/app/javascript/context_drop/styles.ts +1705 -248
  22. data/app/javascript/context_drop/types.ts +243 -6
  23. data/app/javascript/context_drop/widget.ts +3318 -294
  24. data/app/models/context_drop/feedback.rb +88 -8
  25. data/app/services/context_drop/ownership_token.rb +114 -0
  26. data/app/views/context_drop/dashboard/feedbacks/index.html.erb +13 -0
  27. data/app/views/context_drop/dashboard/feedbacks/show.html.erb +19 -0
  28. data/app/views/layouts/context_drop/application.html.erb +6 -0
  29. data/config/routes.rb +22 -0
  30. data/db/migrate/20261112000004_add_environment_to_context_drop_feedbacks.rb +10 -0
  31. data/db/migrate/20261113000005_add_deleted_at_to_context_drop_feedbacks.rb +11 -0
  32. data/lib/context_drop/agent/key_store.rb +290 -0
  33. data/lib/context_drop/agent/llm_client.rb +413 -0
  34. data/lib/context_drop/agent/orchestrator.rb +314 -0
  35. data/lib/context_drop/agent/workspace_sandbox.rb +499 -0
  36. data/lib/context_drop/configuration.rb +242 -3
  37. data/lib/context_drop/mcp/dispatcher.rb +71 -29
  38. data/lib/context_drop/mcp/environment_router.rb +115 -0
  39. data/lib/context_drop/mcp/prompts/investigate_feedback.rb +90 -9
  40. data/lib/context_drop/mcp/remote_client.rb +120 -0
  41. data/lib/context_drop/mcp/server.rb +9 -2
  42. data/lib/context_drop/mcp/tools/get_feedback.rb +62 -5
  43. data/lib/context_drop/mcp/tools/get_feedback_attachment.rb +29 -4
  44. data/lib/context_drop/mcp/tools/list_environments.rb +60 -0
  45. data/lib/context_drop/mcp/tools/list_feedbacks.rb +195 -23
  46. data/lib/context_drop/mcp/tools/update_feedback_status.rb +48 -5
  47. data/lib/context_drop/version.rb +1 -1
  48. data/lib/context_drop.rb +8 -2
  49. data/lib/generators/context_drop/install/templates/initializer.rb.tt +29 -2
  50. metadata +14 -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,13 +37,24 @@ 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;
57
+ existing_attachment_id?: number | string;
43
58
  attachment_type: "image" | "screenshot";
44
59
  label: string;
45
60
  preview_url: string;
@@ -51,28 +66,53 @@ export interface PendingAttachmentItem {
51
66
  metadata: Record<string, unknown>;
52
67
  }
53
68
 
69
+ export interface SessionFeedbackAttachmentItem {
70
+ id: string;
71
+ server_id?: number | string;
72
+ label: string;
73
+ preview_url: string;
74
+ attachment_type: "image" | "screenshot";
75
+ filename?: string | null;
76
+ signed_blob_id?: string;
77
+ data_url?: string;
78
+ element_reference_ref?: string | null;
79
+ metadata?: Record<string, unknown>;
80
+ }
81
+
54
82
  export interface SessionFeedbackEntry {
55
83
  id: number | string;
56
84
  message: string;
85
+ rawMessage?: string;
57
86
  createdAt: string;
87
+ rawCreatedAt?: string;
88
+ rawUpdatedAt?: string;
89
+ isEdited?: boolean;
90
+ status?: string;
91
+ ownershipToken?: string;
58
92
  elements: ElementReferenceSnapshot[];
59
- attachments: Array<{
60
- id: string;
61
- label: string;
62
- preview_url: string;
63
- attachment_type: "image" | "screenshot";
64
- }>;
93
+ attachments: SessionFeedbackAttachmentItem[];
94
+ }
95
+
96
+ export interface ContextDropApiClientOptions {
97
+ credentials?: RequestCredentials;
98
+ headers?: Record<string, string>;
65
99
  }
66
100
 
67
101
  export interface WidgetConfig {
68
102
  enabled: boolean;
103
+ environment?: string;
69
104
  position: WidgetPosition;
70
105
  placeholder: string;
71
106
  csrf_token?: string | null;
107
+ agent?: {
108
+ enabled: boolean;
109
+ };
72
110
  features: {
73
111
  element_selection: boolean;
112
+ selection_mode?: SelectionMode;
74
113
  screenshot_capture: boolean;
75
114
  element_capture_padding: number;
115
+ smart_capture_padding?: number;
76
116
  };
77
117
  limits: {
78
118
  max_attachments: number;
@@ -102,10 +142,207 @@ export interface FeedbackSubmissionPayload {
102
142
  }>;
103
143
  }
104
144
 
145
+ export interface OwnFeedbackAttachment {
146
+ id: number | string;
147
+ attachment_type: "image" | "screenshot";
148
+ filename: string | null;
149
+ content_type?: string | null;
150
+ byte_size?: number | null;
151
+ element_reference_ref?: string | null;
152
+ metadata?: Record<string, unknown>;
153
+ created_at?: string;
154
+ }
155
+
156
+ export interface OwnFeedbackRecord {
157
+ id: number;
158
+ environment?: string;
159
+ message: string;
160
+ page_url?: string;
161
+ status: string;
162
+ metadata?: Record<string, unknown>;
163
+ attachments_count: number;
164
+ element_references_count: number;
165
+ element_references: ElementReferenceSnapshot[];
166
+ attachments: OwnFeedbackAttachment[];
167
+ created_at: string;
168
+ updated_at: string;
169
+ ownership_token?: string;
170
+ }
171
+
172
+ export interface OwnFeedbackListResponse {
173
+ total_count: number;
174
+ feedbacks: OwnFeedbackRecord[];
175
+ }
176
+
177
+ export interface FeedbackAttachmentUpdateInput {
178
+ existing_id?: number | string;
179
+ attachment_type?: "image" | "screenshot";
180
+ filename?: string;
181
+ signed_blob_id?: string;
182
+ data_url?: string;
183
+ element_reference_ref?: string;
184
+ metadata?: Record<string, unknown>;
185
+ }
186
+
187
+ export interface FeedbackUpdatePayload {
188
+ message: string;
189
+ metadata?: Record<string, unknown>;
190
+ element_references: ElementReferenceSnapshot[];
191
+ attachments: FeedbackAttachmentUpdateInput[];
192
+ }
193
+
194
+ export interface FeedbackUpdateResponse {
195
+ id: number;
196
+ environment?: string;
197
+ status: string;
198
+ attachments_count: number;
199
+ element_references_count: number;
200
+ created_at: string;
201
+ updated_at: string;
202
+ ownership_token?: string;
203
+ feedback?: OwnFeedbackRecord;
204
+ }
205
+
206
+ export interface FeedbackDeleteResponse {
207
+ id: number;
208
+ deleted: boolean;
209
+ deleted_at: string;
210
+ }
211
+
105
212
  export interface FeedbackSubmissionResponse {
106
213
  id: number;
214
+ environment?: string;
107
215
  status: string;
108
216
  attachments_count: number;
109
217
  element_references_count: number;
110
218
  created_at: string;
219
+ updated_at?: string;
220
+ ownership_token?: string;
221
+ feedback?: OwnFeedbackRecord;
222
+ }
223
+
224
+ export interface AgentProviderInfo {
225
+ id: string;
226
+ label: string;
227
+ configured: boolean;
228
+ source: "vault" | "env" | "local_no_key" | null;
229
+ env_var_hint: string;
230
+ masked_key: string | null;
231
+ model: string;
232
+ default_model: string;
233
+ models: string[];
234
+ supports_base_url: boolean;
235
+ base_url?: string | null;
236
+ }
237
+
238
+ export interface AgentEnvironmentInfo {
239
+ name: string;
240
+ type: string;
241
+ host_env?: string;
242
+ url?: string;
243
+ }
244
+
245
+ export interface AgentStatusResponse {
246
+ enabled: boolean;
247
+ environment: string;
248
+ workspace_name: string;
249
+ mcp_environments: AgentEnvironmentInfo[];
250
+ active_provider: string;
251
+ providers: AgentProviderInfo[];
252
+ }
253
+
254
+ export interface AgentKeysUpdatePayload {
255
+ provider: string;
256
+ api_key?: string;
257
+ model?: string;
258
+ base_url?: string;
259
+ make_active?: boolean;
260
+ }
261
+
262
+ export interface AgentKeysUpdateResponse {
263
+ active_provider: string;
264
+ providers: AgentProviderInfo[];
265
+ }
266
+
267
+ export interface AgentToolTrace {
268
+ name: string;
269
+ summary: string;
270
+ status: "ok" | "error";
271
+ }
272
+
273
+ export interface ProposedFileEdit {
274
+ id: string;
275
+ path: string;
276
+ summary: string;
277
+ is_new_file: boolean;
278
+ diff: string;
279
+ added_lines: number;
280
+ removed_lines: number;
281
+ status: "pending" | "applied" | "rejected" | "reverted";
282
+ created_at: string;
283
+ }
284
+
285
+ export interface AgentChatTurnInput {
286
+ role: "user" | "assistant";
287
+ content: string;
288
+ }
289
+
290
+ export interface AgentChatRequestPayload {
291
+ messages: AgentChatTurnInput[];
292
+ page_url: string;
293
+ element_references: ElementReferenceSnapshot[];
294
+ attachments: Array<{
295
+ attachment_type: "image" | "screenshot";
296
+ filename: string;
297
+ data_url?: string;
298
+ }>;
299
+ provider?: string;
300
+ model?: string;
301
+ }
302
+
303
+ export interface AgentChatResponse {
304
+ reply: string;
305
+ provider: string;
306
+ model: string;
307
+ tool_calls: AgentToolTrace[];
308
+ proposed_edits: ProposedFileEdit[];
309
+ }
310
+
311
+ export interface AgentChatMessage {
312
+ id: string;
313
+ role: "user" | "assistant";
314
+ content: string;
315
+ createdAt: string;
316
+ elements?: ElementReferenceSnapshot[];
317
+ attachments?: Array<{
318
+ id: string;
319
+ label: string;
320
+ preview_url: string;
321
+ attachment_type: "image" | "screenshot";
322
+ }>;
323
+ toolCalls?: AgentToolTrace[];
324
+ proposedEdits?: ProposedFileEdit[];
325
+ provider?: string;
326
+ model?: string;
327
+ }
328
+
329
+ export interface CrossEnvFeedbackItem {
330
+ id: number | string;
331
+ qualified_id?: string;
332
+ environment: string;
333
+ message: string;
334
+ page_url: string;
335
+ status: string;
336
+ primary_selector?: string | null;
337
+ element_references_count: number;
338
+ attachments_count: number;
339
+ created_at: string;
340
+ }
341
+
342
+ export interface CrossEnvFeedbackListResponse {
343
+ environment_filter?: string;
344
+ total_count: number;
345
+ environments_queried?: string[];
346
+ errors?: Array<{ environment: string; error: string }>;
347
+ feedbacks: CrossEnvFeedbackItem[];
111
348
  }