Skip to content

Commit ab85c1a

Browse files
Sg312emir-karabeg
andauthored
feat(copilot): implement copilot (#850)
* Fix autolayout v1 * Nuke tool call history * Modal v1 * Preview v2 * more updates * Checkpoint * Checkpoint * Better preview * Big stuff * Chat ui * Ui * Update * Changes * Increase token limit for copilot * Preview layout fixes * Checkpoint * sse checkpoint * Checkpoint * Continuation logic * Checkpoint * Updates * UPdates * Updateds * Cleanup * Update * Diff checker * test * Checkpoint * Checkpoint * Checkpoint again * checkpoint again * Chat box output format * Auto open diff canvas * Checkpoint * Checkpoit * Cleaning? * Diff checkpoint * Checkpoint * Persist changes * Autolayout fixces * Color diff fixes * Opusss * Works?? * getting there * Fixes? * Fixes? * Chat fixes * Autolayout fixes * Subblock update diffs * Handle delete diffs * Edge diffs v1 * Deletion edge diff * It works, kinda * Fixes * Update * Docs changes * Prompt fixes and new tool * Persist color changes * Add serper to copilot tools * Get env vars copilot tool * Set env vars copilot tool * Copilot console tool * Promtps * Targeted v1 * Targeted v2 * Targeted updates better * Target fixes * diff works?? * Diff goes away when switching workflows * Fixes * Edge fixes * Remove brief error * Lint * Minor fix * Add abort controller * Prompting * Lint * Fix test * Fix lint * Update csp * Add route to send info to sim agent * Consolidated copilot * First refactor complete * Get user workflow now returns yaml * Checkpoint * Checkpoitn * Works * It works * Hi * Cumulative target edit * Checkpont * Checkpoint * Store updates * Checkpoitn * Smart title generation * Handle copilot aborts * Clean up old copilot code * Refactor tool names * Checkpoint * Remove old route * Fix chat loading * Scope copilot chat to workflow id * New chat fixes * Fix chat loading * Update get all blocks and tools * Make metadata better * Update docs * Conditional update * Yaml refactor * Set up yaml service client * Yaml service migration * Migrate diff engine to sim agent * Refactor diff engine * Fix autolayout problems and clean up code some more * improvement: copilot panel ui/ux * Lint * Cleaning * Fix autolayout * Fix chat output selector * Updated copilot * Small update * Checkpoint system v1 * Checkpoint ui * Copilot ui * Copilot ui * Checkpoint * Accept/reject state * Proper tool call display name updates * Fix tool call display updates * Streaming quality updates? * Abort on refresh/chat switch/workflow switch * Abort v2g * Perf updates * Ui updates * Smoother streaming * Handle edge diffs from sim agent properly * Enable text box while streaming, but keep send disabled * Fix set env var route * Add interrupt param * Add interrupt handler * Interrupt v1 * Interrupt ui update * Update icons * Ui fixes? * Simplify get user workflow tool * Run workflow v1 * Fix edit workflow * Run workflow e2e v1 * Run workflow v2 * Run workflow v3 * v1 of v3, bad code, needs refactro * Lint * Cleaning v1? * Checkpoitn * Fix backend processing of status * State updates * Closer * Icon update * More updates * Checkpoitn * Updates * Chat stays when tabbign * Fix get console logss * Markdown copilot * Fix tool naming for build workflow * Streaming improvements * Use logs for copilot run workflow * Progress * it works? * Fix chat loading * Getting there * Autoscroll to bottom of chat * Fix icons * Lint * Confirm route polling * Cleaning * Lint * Remove migrations * Remove journal entry 64 * Resolve merge conflicts * Db migration * Fix test and lint * Fix tsvector lint error * Fixes --------- Co-authored-by: Emir Karabeg <[email protected]>
1 parent 9c3bcba commit ab85c1a

File tree

151 files changed

+24041
-10097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+24041
-10097
lines changed

apps/docs/content/docs/yaml/blocks/api.mdx

Lines changed: 290 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,54 @@ properties:
3333
enum: [GET, POST, PUT, DELETE, PATCH]
3434
description: HTTP method for the request
3535
default: GET
36-
queryParams:
36+
params:
3737
type: array
38-
description: Query parameters as key-value pairs
38+
description: Query parameters as table entries
3939
items:
4040
type: object
41+
required:
42+
- id
43+
- cells
4144
properties:
42-
key:
45+
id:
4346
type: string
44-
description: Parameter name
45-
value:
46-
type: string
47-
description: Parameter value
47+
description: Unique identifier for the parameter entry
48+
cells:
49+
type: object
50+
required:
51+
- Key
52+
- Value
53+
properties:
54+
Key:
55+
type: string
56+
description: Parameter name
57+
Value:
58+
type: string
59+
description: Parameter value
4860
headers:
4961
type: array
50-
description: HTTP headers as key-value pairs
62+
description: HTTP headers as table entries
5163
items:
5264
type: object
65+
required:
66+
- id
67+
- cells
5368
properties:
54-
key:
55-
type: string
56-
description: Header name
57-
value:
69+
id:
5870
type: string
59-
description: Header value
71+
description: Unique identifier for the header entry
72+
cells:
73+
type: object
74+
required:
75+
- Key
76+
- Value
77+
properties:
78+
Key:
79+
type: string
80+
description: Header name
81+
Value:
82+
type: string
83+
description: Header value
6084
body:
6185
type: string
6286
description: Request body for POST/PUT/PATCH methods
@@ -99,15 +123,21 @@ user-api:
99123
url: "https://api.example.com/users/123"
100124
method: GET
101125
headers:
102-
- key: "Authorization"
103-
value: "Bearer {{API_TOKEN}}"
104-
- key: "Content-Type"
105-
value: "application/json"
126+
- id: header-1-uuid-here
127+
cells:
128+
Key: "Authorization"
129+
Value: "Bearer {{API_TOKEN}}"
130+
- id: header-2-uuid-here
131+
cells:
132+
Key: "Content-Type"
133+
Value: "application/json"
106134
connections:
107135
success: process-user-data
108136
error: handle-api-error
109137
```
110138
139+
140+
111141
### POST Request with Body
112142
113143
```yaml
@@ -118,10 +148,14 @@ create-ticket:
118148
url: "https://api.support.com/tickets"
119149
method: POST
120150
headers:
121-
- key: "Authorization"
122-
value: "Bearer {{SUPPORT_API_KEY}}"
123-
- key: "Content-Type"
124-
value: "application/json"
151+
- id: auth-header-uuid
152+
cells:
153+
Key: "Authorization"
154+
Value: "Bearer {{SUPPORT_API_KEY}}"
155+
- id: content-type-uuid
156+
cells:
157+
Key: "Content-Type"
158+
Value: "application/json"
125159
body: |
126160
{
127161
"title": "<agent.title>",
@@ -142,32 +176,249 @@ search-api:
142176
inputs:
143177
url: "https://api.store.com/products"
144178
method: GET
145-
queryParams:
146-
- key: "q"
147-
value: <start.searchTerm>
148-
- key: "limit"
149-
value: "10"
150-
- key: "category"
151-
value: <filter.category>
179+
params:
180+
- id: search-param-uuid
181+
cells:
182+
Key: "q"
183+
Value: <start.searchTerm>
184+
- id: limit-param-uuid
185+
cells:
186+
Key: "limit"
187+
Value: "10"
188+
- id: category-param-uuid
189+
cells:
190+
Key: "category"
191+
Value: <filter.category>
152192
headers:
153-
- key: "Authorization"
154-
value: "Bearer {{STORE_API_KEY}}"
193+
- id: auth-header-uuid
194+
cells:
195+
Key: "Authorization"
196+
Value: "Bearer {{STORE_API_KEY}}"
155197
connections:
156198
success: display-results
157199
```
158200
201+
## Parameter Format
202+
203+
Headers and params (query parameters) use the table format with the following structure:
204+
205+
```yaml
206+
headers:
207+
- id: unique-identifier-here
208+
cells:
209+
Key: "Content-Type"
210+
Value: "application/json"
211+
- id: another-unique-identifier
212+
cells:
213+
Key: "Authorization"
214+
Value: "Bearer {{API_TOKEN}}"
215+
216+
params:
217+
- id: param-identifier-here
218+
cells:
219+
Key: "limit"
220+
Value: "10"
221+
```
222+
223+
**Structure Details:**
224+
- `id`: Unique identifier for tracking the table row
225+
- `cells.Key`: The parameter/header name
226+
- `cells.Value`: The parameter/header value
227+
- This format allows for proper table management and UI state preservation
228+
159229
## Output References
160230

161-
After an API block executes, you can reference its outputs:
231+
After an API block executes, you can reference its outputs in subsequent blocks. The API block provides three main outputs:
232+
233+
### Available Outputs
234+
235+
| Output | Type | Description |
236+
|--------|------|-------------|
237+
| `data` | any | The response body/payload from the API |
238+
| `status` | number | HTTP status code (200, 404, 500, etc.) |
239+
| `headers` | object | Response headers returned by the server |
240+
241+
### Usage Examples
242+
243+
```yaml
244+
# Reference API response data
245+
process-data:
246+
type: function
247+
name: "Process API Data"
248+
inputs:
249+
code: |
250+
const responseData = <fetchuserdata.data>;
251+
const statusCode = <fetchuserdata.status>;
252+
const responseHeaders = <fetchuserdata.headers>;
253+
254+
if (statusCode === 200) {
255+
return {
256+
success: true,
257+
user: responseData,
258+
contentType: responseHeaders['content-type']
259+
};
260+
} else {
261+
return {
262+
success: false,
263+
error: `API call failed with status ${statusCode}`
264+
};
265+
}
266+
267+
# Use API data in an agent block
268+
analyze-response:
269+
type: agent
270+
name: "Analyze Response"
271+
inputs:
272+
userPrompt: |
273+
Analyze this API response:
274+
275+
Status: <fetchuserdata.status>
276+
Data: <fetchuserdata.data>
277+
278+
Provide insights about the response.
279+
280+
# Conditional logic based on status
281+
check-status:
282+
type: condition
283+
name: "Check API Status"
284+
inputs:
285+
condition: <fetchuserdata.status> === 200
286+
connections:
287+
true: success-handler
288+
false: error-handler
289+
```
290+
291+
### Practical Example
162292
163293
```yaml
164-
# In subsequent blocks
165-
next-block:
294+
user-api:
295+
type: api
296+
name: "Fetch User Data"
166297
inputs:
167-
data: <api-block-name.output> # Response data
168-
status: <api-block-name.status> # HTTP status code
169-
headers: <api-block-name.headers> # Response headers
170-
error: <api-block-name.error> # Error details (if any)
298+
url: "https://api.example.com/users/123"
299+
method: GET
300+
connections:
301+
success: process-response
302+
303+
process-response:
304+
type: function
305+
name: "Process Response"
306+
inputs:
307+
code: |
308+
const user = <fetchuserdata.data>;
309+
const status = <fetchuserdata.status>;
310+
311+
console.log(`API returned status: ${status}`);
312+
console.log(`User data:`, user);
313+
314+
return {
315+
userId: user.id,
316+
email: user.email,
317+
isActive: status === 200
318+
};
319+
```
320+
321+
### Error Handling
322+
323+
```yaml
324+
api-with-error-handling:
325+
type: api
326+
name: "API Call"
327+
inputs:
328+
url: "https://api.example.com/data"
329+
method: GET
330+
connections:
331+
success: check-response
332+
error: handle-error
333+
334+
check-response:
335+
type: condition
336+
name: "Check Response Status"
337+
inputs:
338+
condition: <apicall.status> >= 200 && <apicall.status> < 300
339+
connections:
340+
true: process-success
341+
false: handle-api-error
342+
343+
process-success:
344+
type: function
345+
name: "Process Success"
346+
inputs:
347+
code: |
348+
return {
349+
success: true,
350+
data: <apicall.data>,
351+
message: "API call successful"
352+
};
353+
354+
handle-api-error:
355+
type: function
356+
name: "Handle API Error"
357+
inputs:
358+
code: |
359+
return {
360+
success: false,
361+
status: <apicall.status>,
362+
error: "API call failed",
363+
data: <apicall.data>
364+
};
365+
```
366+
367+
## YAML String Escaping
368+
369+
When writing YAML, certain strings must be quoted to be properly parsed:
370+
371+
### Strings That Must Be Quoted
372+
373+
```yaml
374+
# URLs with hyphens, colons, special characters
375+
url: "https://api.example.com/users/123"
376+
url: "https://my-api.example.com/data"
377+
378+
# Header values with hyphens or special characters
379+
headers:
380+
- id: header-uuid
381+
cells:
382+
Key: "User-Agent"
383+
Value: "My-Application/1.0"
384+
- id: auth-uuid
385+
cells:
386+
Key: "Authorization"
387+
Value: "Bearer my-token-123"
388+
389+
# Parameter values with hyphens
390+
params:
391+
- id: param-uuid
392+
cells:
393+
Key: "sort-by"
394+
Value: "created-at"
395+
```
396+
397+
### When to Use Quotes
398+
399+
- ✅ **Always quote**: URLs, tokens, values with hyphens, colons, or special characters
400+
- ✅ **Always quote**: Values that start with numbers but should be strings
401+
- ✅ **Always quote**: Boolean-looking strings that should remain as strings
402+
- ❌ **Don't quote**: Simple alphanumeric strings without special characters
403+
404+
### Examples
405+
406+
```yaml
407+
# ✅ Correct
408+
url: "https://api.stripe.com/v1/charges"
409+
headers:
410+
- id: auth-header
411+
cells:
412+
Key: "Authorization"
413+
Value: "Bearer sk-test-123456789"
414+
415+
# ❌ Incorrect (may cause parsing errors)
416+
url: https://api.stripe.com/v1/charges
417+
headers:
418+
- id: auth-header
419+
cells:
420+
Key: Authorization
421+
Value: Bearer sk-test-123456789
171422
```
172423
173424
## Best Practices
@@ -176,4 +427,5 @@ next-block:
176427
- Include error handling with error connections
177428
- Set appropriate timeouts for your use case
178429
- Validate response status codes in subsequent blocks
179-
- Use meaningful block names for easier reference
430+
- Use meaningful block names for easier reference
431+
- **Always quote strings with special characters, URLs, and tokens**

0 commit comments

Comments
 (0)