-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[vibe-coding-platform] Implement Workflow DevKit #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
VaguelySerious
wants to merge
15
commits into
main
Choose a base branch
from
peter/pre-tidy-for-workflows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,176
−700
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e318a80
Implement Workflow DevKit
pranaygp 1769cce
Add Haiku model
VaguelySerious a6bef74
[vibe-coding-platform] Tidy code to prepare for workflow use
VaguelySerious 3a3b39a
Small tidy
VaguelySerious fadc628
Remove unused imports
VaguelySerious 1ad8d9b
Merge branch 'peter/pre-tidy-for-workflows' into pranaygp/11-06-imple…
VaguelySerious cbcfdc6
Package upgrade
VaguelySerious 0ab2ffd
Merge branch 'pranaygp/11-06-implement_workflow_devkit' into peter/pr…
VaguelySerious 20bc2f0
Vastly simplify
VaguelySerious 0563a1f
Clean up
VaguelySerious 0dc9f84
Clean up
VaguelySerious 7dc57c3
Fix
VaguelySerious 83b1c85
Comment out tools
VaguelySerious 5221f7d
WIP
VaguelySerious f2131fa
Re-extract tools
VaguelySerious File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| Use this tool to create a new Vercel Sandbox — an ephemeral, isolated Linux container that serves as your development environment for the current session. This sandbox provides a secure workspace where you can upload files, install dependencies, run commands, start development servers, and preview web apps. Each sandbox is uniquely identified and must be referenced for all subsequent operations (e.g., file generation, command execution, or URL access). | ||
| export default `Use this tool to create a new Vercel Sandbox — an ephemeral, isolated Linux container that serves as your development environment for the current session. This sandbox provides a secure workspace where you can upload files, install dependencies, run commands, start development servers, and preview web apps. Each sandbox is uniquely identified and must be referenced for all subsequent operations (e.g., file generation, command execution, or URL access). | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Markdown files aren't supported by workflow compiler plugin, so we had to rename all of the prompts to typescript files |
||
|
|
||
| ## When to Use This Tool | ||
|
|
||
|
|
@@ -13,17 +13,17 @@ Use this tool **once per session** when: | |
|
|
||
| After creation, the sandbox allows you to: | ||
|
|
||
| - Upload and manage files via `Generate Files` | ||
| - Execute shell commands with `Run Command` and `Wait Command` | ||
| - Access running servers through public URLs using `Get Sandbox URL` | ||
| - Upload and manage files via \`Generate Files\` | ||
| - Execute shell commands with \`Run Command\` and \`Wait Command\` | ||
| - Access running servers through public URLs using \`Get Sandbox URL\` | ||
|
|
||
| Each sandbox mimics a real-world development environment and supports rapid iteration and testing without polluting the local system. The base system is Amazon Linux 2023 with the following additional packages: | ||
|
|
||
| ``` | ||
| \`\`\` | ||
| bind-utils bzip2 findutils git gzip iputils libicu libjpeg libpng ncurses-libs openssl openssl-libs pnpm procps tar unzip which whois zstd | ||
| ``` | ||
| \`\`\` | ||
|
|
||
| You can install additional packages using the `dnf` package manager. You can NEVER use port 8080 as it is reserved for internal applications. When requested, you need to use a different port. | ||
| You can install additional packages using the \`dnf\` package manager. You can NEVER use port 8080 as it is reserved for internal applications. When requested, you need to use a different port. | ||
|
|
||
| ## Best Practices | ||
|
|
||
|
|
@@ -36,7 +36,7 @@ You can install additional packages using the `dnf` package manager. You can NEV | |
|
|
||
| <example> | ||
| User: Can we start fresh? I want to rebuild the project from scratch. | ||
| Assistant: Got it — I’ll create a new sandbox so we can start clean. | ||
| Assistant: Got it — I'll create a new sandbox so we can start clean. | ||
| *Calls Create Sandbox* | ||
| </example> | ||
|
|
||
|
|
@@ -48,8 +48,9 @@ Skip using this tool when: | |
| 2. You only need to upload files (use Generate Files) | ||
| 3. You want to execute or wait for a command (use Run Command / Wait Command) | ||
| 4. You want to preview the application (use Get Sandbox URL) | ||
| 5. The user hasn’t asked to reset the environment | ||
| 5. The user hasn't asked to reset the environment | ||
|
|
||
| ## Summary | ||
|
|
||
| Use Create Sandbox to initialize a secure, temporary development environment — but **only once per session**. Treat the sandbox as the core workspace for all follow-up actions unless the user explicitly asks to discard and start anew. | ||
| ` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,75 +1,83 @@ | ||
| import type { UIMessageStreamWriter, UIMessage } from 'ai' | ||
| import type { UIMessageChunk } from 'ai' | ||
| import type { DataPart } from '../messages/data-parts' | ||
| import { Sandbox } from '@vercel/sandbox' | ||
| import { getRichError } from './get-rich-error' | ||
| import { tool } from 'ai' | ||
| import description from './create-sandbox.md' | ||
| import description from './create-sandbox.prompt' | ||
| import z from 'zod/v3' | ||
| import { getWritable } from 'workflow' | ||
|
|
||
| interface Params { | ||
| writer: UIMessageStreamWriter<UIMessage<never, DataPart>> | ||
| } | ||
| const inputSchema = z.object({ | ||
| timeout: z | ||
| .number() | ||
| .min(600000) | ||
| .max(2700000) | ||
| .optional() | ||
| .describe( | ||
| 'Maximum time in milliseconds the Vercel Sandbox will remain active before automatically shutting down. Minimum 600000ms (10 minutes), maximum 2700000ms (45 minutes). Defaults to 600000ms (10 minutes). The sandbox will terminate all running processes when this timeout is reached.' | ||
| ), | ||
| ports: z | ||
| .array(z.number()) | ||
| .max(2) | ||
| .optional() | ||
| .describe( | ||
| 'Array of network ports to expose and make accessible from outside the Vercel Sandbox. These ports allow web servers, APIs, or other services running inside the Vercel Sandbox to be reached externally. Common ports include 3000 (Next.js), 8000 (Python servers), 5000 (Flask), etc.' | ||
| ), | ||
| }) | ||
|
|
||
| export const createSandbox = ({ writer }: Params) => | ||
| tool({ | ||
| description, | ||
| inputSchema: z.object({ | ||
| timeout: z | ||
| .number() | ||
| .min(600000) | ||
| .max(2700000) | ||
| .optional() | ||
| .describe( | ||
| 'Maximum time in milliseconds the Vercel Sandbox will remain active before automatically shutting down. Minimum 600000ms (10 minutes), maximum 2700000ms (45 minutes). Defaults to 600000ms (10 minutes). The sandbox will terminate all running processes when this timeout is reached.' | ||
| ), | ||
| ports: z | ||
| .array(z.number()) | ||
| .max(2) | ||
| .optional() | ||
| .describe( | ||
| 'Array of network ports to expose and make accessible from outside the Vercel Sandbox. These ports allow web servers, APIs, or other services running inside the Vercel Sandbox to be reached externally. Common ports include 3000 (Next.js), 8000 (Python servers), 5000 (Flask), etc.' | ||
| ), | ||
| }), | ||
| execute: async ({ timeout, ports }, { toolCallId }) => { | ||
| writer.write({ | ||
| id: toolCallId, | ||
| type: 'data-create-sandbox', | ||
| data: { status: 'loading' }, | ||
| }) | ||
| async function executeCreateSandbox( | ||
| { timeout, ports }: z.infer<typeof inputSchema>, | ||
| { toolCallId }: { toolCallId: string } | ||
| ) { | ||
| 'use step' | ||
|
|
||
| const writeable = getWritable<UIMessageChunk<never, DataPart>>() | ||
| const writer = writeable.getWriter() | ||
| writer.write({ | ||
| id: toolCallId, | ||
| type: 'data-create-sandbox', | ||
| data: { status: 'loading' }, | ||
| }) | ||
|
|
||
| try { | ||
| const sandbox = await Sandbox.create({ | ||
| timeout: timeout ?? 600000, | ||
| ports, | ||
| }) | ||
| try { | ||
| const sandbox = await Sandbox.create({ | ||
| timeout: timeout ?? 600000, | ||
| ports, | ||
| }) | ||
|
|
||
| writer.write({ | ||
| id: toolCallId, | ||
| type: 'data-create-sandbox', | ||
| data: { sandboxId: sandbox.sandboxId, status: 'done' }, | ||
| }) | ||
| writer.write({ | ||
| id: toolCallId, | ||
| type: 'data-create-sandbox', | ||
| data: { sandboxId: sandbox.sandboxId, status: 'done' }, | ||
| }) | ||
|
|
||
| return ( | ||
| `Sandbox created with ID: ${sandbox.sandboxId}.` + | ||
| `\nYou can now upload files, run commands, and access services on the exposed ports.` | ||
| ) | ||
| } catch (error) { | ||
| const richError = getRichError({ | ||
| action: 'Creating Sandbox', | ||
| error, | ||
| }) | ||
| return ( | ||
| `Sandbox created with ID: ${sandbox.sandboxId}.` + | ||
| `\nYou can now upload files, run commands, and access services on the exposed ports.` | ||
| ) | ||
| } catch (error) { | ||
| const richError = getRichError({ | ||
| action: 'Creating Sandbox', | ||
| error, | ||
| }) | ||
|
|
||
| writer.write({ | ||
| id: toolCallId, | ||
| type: 'data-create-sandbox', | ||
| data: { | ||
| error: { message: richError.error.message }, | ||
| status: 'error', | ||
| }, | ||
| }) | ||
| writer.write({ | ||
| id: toolCallId, | ||
| type: 'data-create-sandbox', | ||
| data: { | ||
| error: { message: richError.error.message }, | ||
| status: 'error', | ||
| }, | ||
| }) | ||
|
|
||
| console.log('Error creating Sandbox:', richError.error) | ||
| return richError.message | ||
| } | ||
| }, | ||
| console.log('Error creating Sandbox:', richError.error) | ||
| return richError.message | ||
| } | ||
| } | ||
|
|
||
| export const createSandbox = () => | ||
| tool({ | ||
| description, | ||
| inputSchema, | ||
| execute: executeCreateSandbox, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Haiku while I was at it