Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pilot/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OAuth providers
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

# Session encryption
SESSION_SECRET=

# Environment
ENVIRONMENT=development
9 changes: 9 additions & 0 deletions pilot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.svelte-kit
build
.wrangler
.env
.env.*
!.env.example
.dev.vars
package-lock.json
14 changes: 14 additions & 0 deletions pilot/Dockerfile.sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM docker.io/cloudflare/sandbox:0.7.4

# Install Claude Code and serve globally
RUN npm install -g @anthropic-ai/claude-code serve

# Set up git config
RUN git config --global user.name "TaskYou Agent" && \
git config --global user.email "agent@taskyou.dev"

# Initialize workspace
RUN mkdir -p /root/worktrees /workspace

# Expose port for web app previews
EXPOSE 8080
39 changes: 39 additions & 0 deletions pilot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "taskyou-pilot",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build && node scripts/postbuild.js",
"preview": "wrangler dev",
"deploy": "npm run build && wrangler deploy",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"test": "vitest"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250129.0",
"@sveltejs/adapter-cloudflare": "^7.2.7",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@tailwindcss/vite": "^4.0.0",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"tailwindcss": "^4.0.0",
"typescript": "^5.0.0",
"vite": "^5.0.0",
"vitest": "^2.0.0",
"wrangler": "^4.65.0"
},
"dependencies": {
"@ai-sdk/anthropic": "^3.0.44",
"@cloudflare/ai-chat": "^0.1.1",
"@cloudflare/sandbox": "^0.7.4",
"agents": "^0.5.0",
"ai": "^6.0.87",
"basecoat-css": "^0.3.11",
"lucide-svelte": "^0.460.0",
"marked": "^17.0.2",
"zod": "^4.3.6"
}
}
9 changes: 9 additions & 0 deletions pilot/sandbox-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Initialization script for taskyou sandbox containers
# This runs inside each user's isolated container

echo "TaskYou sandbox initialized"
echo "Container ready for task execution"

# Keep the container running
exec sleep infinity
59 changes: 59 additions & 0 deletions pilot/scripts/postbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Post-build: Wrap SvelteKit worker with custom entry point
// - Adds routeAgentRequest() for agent WebSocket/HTTP handling
// - Adds proxyToSandbox() for sandbox preview URL routing
// - Re-exports TaskYouAgent, TaskExecutionWorkflow, and Sandbox for wrangler bindings
// - SvelteKit handles everything else (auth, CRUD, static assets)

import { readFileSync, writeFileSync, existsSync } from 'fs';

const workerFile = 'worker-entry.js';

if (!existsSync(workerFile)) {
console.error(`✗ ${workerFile} not found - did vite build run?`);
process.exit(1);
}

let content = readFileSync(workerFile, 'utf8');

// Check if already patched
if (content.includes('routeAgentRequest')) {
console.log('✓ worker-entry.js already patched');
process.exit(0);
}

// Add agent + sandbox imports at the top of the file
const imports = `
import { routeAgentRequest } from "agents";
import { proxyToSandbox } from "@cloudflare/sandbox";
`;

content = imports + content;

// Wrap the existing fetch handler with sandbox proxy + agent routing
content = content.replace(
'async fetch(req, env2, ctx) {',
`async fetch(req, env2, ctx) {
// Route agent WebSocket/HTTP requests before SvelteKit
const agentResponse = await routeAgentRequest(req, env2);
if (agentResponse) return agentResponse;

// Proxy sandbox preview URLs (after agent routing)
// Only relevant with custom domains for preview URL subdomains
try {
const sandboxResponse = await proxyToSandbox(req, env2);
if (sandboxResponse && sandboxResponse.status !== 404) return sandboxResponse;
} catch (e) {
// Sandbox proxy not available — continue to SvelteKit
}`
);

// Add DO, Workflow, and Sandbox class re-exports at the end
content += `
// Re-export agent classes for Durable Object, Workflow, and Container bindings
export { TaskYouAgent } from "./src/lib/server/agent.ts";
export { TaskExecutionWorkflow } from "./src/lib/server/workflow.ts";
export { Sandbox } from "@cloudflare/sandbox";
`;

writeFileSync(workerFile, content);
console.log('✓ Patched worker-entry.js with proxyToSandbox + routeAgentRequest + exports');
Loading