viagen 0.0.46 → 0.0.48

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 (2) hide show
  1. package/dist/index.js +119 -30
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -110,7 +110,7 @@ function registerHealthRoutes(server, env, errorRef) {
110
110
  );
111
111
  }
112
112
  });
113
- const currentVersion = true ? "0.0.46" : "0.0.0";
113
+ const currentVersion = true ? "0.0.48" : "0.0.0";
114
114
  debug("health", `version resolved: ${currentVersion}`);
115
115
  let versionCache = null;
116
116
  server.middlewares.use("/via/version", (_req, res) => {
@@ -2455,16 +2455,14 @@ function buildUiHtml(opts) {
2455
2455
  <div class="header">
2456
2456
  <div style="display:flex;align-items:center;gap:0;">
2457
2457
  <h1><span class="status-dot" id="status-dot"></span> via <span class="session-timer" id="session-timer"></span></h1>
2458
- <div style="display:flex;gap:4px;align-items:center;">
2459
- <button class="btn icon-btn" id="view-preview" title="Preview app" style="display:none;">
2460
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>
2461
- </button>
2462
- <button class="btn icon-btn" id="view-toggle" title="Toggle view">
2463
- <svg id="view-toggle-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></svg>
2464
- </button>
2465
- </div>
2466
2458
  </div>
2467
2459
  <div style="display:flex;gap:4px;align-items:center;">
2460
+ <button class="btn icon-btn" id="view-preview" title="Preview app" style="display:none;">
2461
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>
2462
+ </button>
2463
+ <button class="btn icon-btn" id="view-toggle" title="Toggle view">
2464
+ <svg id="view-toggle-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></svg>
2465
+ </button>
2468
2466
  <button class="btn icon-btn" id="sound-btn" title="Toggle completion sound">
2469
2467
  <svg id="sound-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></svg>
2470
2468
  </button>
@@ -18411,39 +18409,116 @@ import {
18411
18409
  createSdkMcpServer,
18412
18410
  tool
18413
18411
  } from "@anthropic-ai/claude-agent-sdk";
18414
- import { updateTask } from "viagen-sdk/sandbox";
18415
- function createViagenTools() {
18416
- return createSdkMcpServer({
18417
- name: "viagen",
18418
- tools: [
18412
+ import {
18413
+ updateTask,
18414
+ listTasks,
18415
+ getTask,
18416
+ createTask
18417
+ } from "viagen-sdk/sandbox";
18418
+ function createViagenTools(config2) {
18419
+ const tools = [
18420
+ tool(
18421
+ "viagen_update_task",
18422
+ "Report task status back to the viagen platform. Use status 'review' after creating a PR (ready for human review) or 'completed' when the task is fully done.",
18423
+ {
18424
+ status: external_exports.enum(["review", "completed"]).describe(
18425
+ "'review' = PR created, ready for review. 'completed' = task fully done."
18426
+ ),
18427
+ prUrl: external_exports.string().optional().describe("Full URL of the pull request, if one was created."),
18428
+ result: external_exports.string().describe("Brief one-line summary of what was done."),
18429
+ inputTokens: external_exports.number().optional().describe("Total input tokens used."),
18430
+ outputTokens: external_exports.number().optional().describe("Total output tokens used."),
18431
+ costUsd: external_exports.number().optional().describe("Total cost in USD.")
18432
+ },
18433
+ async (args) => {
18434
+ await updateTask({
18435
+ status: args.status,
18436
+ prUrl: args.prUrl,
18437
+ result: args.result,
18438
+ inputTokens: args.inputTokens,
18439
+ outputTokens: args.outputTokens,
18440
+ costUsd: args.costUsd
18441
+ });
18442
+ return {
18443
+ content: [
18444
+ {
18445
+ type: "text",
18446
+ text: `Task status updated to '${args.status}'.`
18447
+ }
18448
+ ]
18449
+ };
18450
+ }
18451
+ )
18452
+ ];
18453
+ if (config2) {
18454
+ tools.push(
18455
+ tool(
18456
+ "viagen_list_tasks",
18457
+ "List tasks in the current project. Optionally filter by status.",
18458
+ {
18459
+ status: external_exports.enum(["ready", "running", "validating", "completed", "timed_out"]).optional().describe("Filter tasks by status.")
18460
+ },
18461
+ async (args) => {
18462
+ const tasks = await listTasks({ status: args.status });
18463
+ return {
18464
+ content: [
18465
+ {
18466
+ type: "text",
18467
+ text: JSON.stringify(tasks, null, 2)
18468
+ }
18469
+ ]
18470
+ };
18471
+ }
18472
+ )
18473
+ );
18474
+ tools.push(
18475
+ tool(
18476
+ "viagen_get_task",
18477
+ "Get full details of a specific task by ID.",
18478
+ {
18479
+ taskId: external_exports.string().describe("The task ID to retrieve.")
18480
+ },
18481
+ async (args) => {
18482
+ const task = await getTask(args.taskId);
18483
+ return {
18484
+ content: [
18485
+ {
18486
+ type: "text",
18487
+ text: JSON.stringify(task, null, 2)
18488
+ }
18489
+ ]
18490
+ };
18491
+ }
18492
+ )
18493
+ );
18494
+ tools.push(
18419
18495
  tool(
18420
- "viagen_update_task",
18421
- "Report task status back to the viagen platform. Use status 'review' after creating a PR (ready for human review) or 'completed' when the task is fully done.",
18496
+ "viagen_create_task",
18497
+ "Create a new task in the current project. Use this to create follow-up work.",
18422
18498
  {
18423
- status: external_exports.enum(["review", "completed"]).describe(
18424
- "'review' = PR created, ready for review. 'completed' = task fully done."
18425
- ),
18426
- prUrl: external_exports.string().optional().describe("Full URL of the pull request, if one was created."),
18427
- result: external_exports.string().describe("Brief one-line summary of what was done.")
18499
+ prompt: external_exports.string().describe("The task prompt / instructions."),
18500
+ branch: external_exports.string().optional().describe("Git branch name for the task."),
18501
+ type: external_exports.enum(["task", "plan"]).optional().describe("Task type: 'task' for code changes, 'plan' for implementation plans.")
18428
18502
  },
18429
18503
  async (args) => {
18430
- await updateTask({
18431
- status: args.status,
18432
- prUrl: args.prUrl,
18433
- result: args.result
18504
+ const task = await createTask({
18505
+ prompt: args.prompt,
18506
+ branch: args.branch,
18507
+ type: args.type
18434
18508
  });
18435
18509
  return {
18436
18510
  content: [
18437
18511
  {
18438
18512
  type: "text",
18439
- text: `Task status updated to '${args.status}'.`
18513
+ text: JSON.stringify(task, null, 2)
18440
18514
  }
18441
18515
  ]
18442
18516
  };
18443
18517
  }
18444
18518
  )
18445
- ]
18446
- });
18519
+ );
18520
+ }
18521
+ return createSdkMcpServer({ name: "viagen", tools });
18447
18522
  }
18448
18523
  var PLAN_MODE_DISALLOWED_TOOLS = ["Edit", "NotebookEdit"];
18449
18524
  var planModeCanUseTool = async (toolName, input) => {
@@ -18472,6 +18547,15 @@ Constraints:
18472
18547
  - Only create new files inside the plans/ directory.
18473
18548
  - Your plan should include: context, proposed changes (with file paths and descriptions), implementation order, and potential risks.
18474
18549
  `;
18550
+ var TASK_TOOLS_PROMPT = `
18551
+ You have access to viagen platform tools for task management:
18552
+ - viagen_list_tasks: List tasks in this project (optionally filter by status)
18553
+ - viagen_get_task: Get full details of a specific task
18554
+ - viagen_create_task: Create follow-up tasks for work you identify
18555
+ - viagen_update_task: Report your current task status ('review' or 'completed')
18556
+
18557
+ Use these to understand project context and create follow-up work when appropriate.
18558
+ `;
18475
18559
 
18476
18560
  // src/sandbox.ts
18477
18561
  import { randomUUID } from "crypto";
@@ -18865,9 +18949,12 @@ ${payload.err.frame || ""}`
18865
18949
  const resolvedModel = env["VIAGEN_MODEL"] || opts.model;
18866
18950
  debug("server", `creating ChatSession (model: ${resolvedModel})`);
18867
18951
  let mcpServers;
18868
- if (env["VIAGEN_CALLBACK_URL"] && env["VIAGEN_AUTH_TOKEN"] && env["VIAGEN_TASK_ID"]) {
18952
+ const hasSandboxContext = !!(env["VIAGEN_CALLBACK_URL"] && env["VIAGEN_AUTH_TOKEN"] && env["VIAGEN_TASK_ID"]);
18953
+ if (hasSandboxContext) {
18869
18954
  debug("server", "creating viagen MCP tools (sandbox mode)");
18870
- const viagenMcp = createViagenTools();
18955
+ const viagenMcp = createViagenTools(
18956
+ env["VIAGEN_PROJECT_ID"] ? { projectId: env["VIAGEN_PROJECT_ID"] } : void 0
18957
+ );
18871
18958
  mcpServers = { [viagenMcp.name]: viagenMcp };
18872
18959
  }
18873
18960
  const isPlanMode = env["VIAGEN_TASK_TYPE"] === "plan";
@@ -18875,6 +18962,8 @@ ${payload.err.frame || ""}`
18875
18962
  if (isPlanMode) {
18876
18963
  debug("server", "plan mode active \u2014 restricting tools");
18877
18964
  systemPrompt = PLAN_SYSTEM_PROMPT;
18965
+ } else if (hasSandboxContext && env["VIAGEN_PROJECT_ID"]) {
18966
+ systemPrompt = (systemPrompt || "") + TASK_TOOLS_PROMPT;
18878
18967
  }
18879
18968
  const chatSession = new ChatSession({
18880
18969
  env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viagen",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "Vite dev server plugin that exposes endpoints for chatting with Claude Code SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "@vercel/sandbox": "^1",
45
45
  "lucide-react": "^0.564.0",
46
46
  "simple-git": "^3.31.1",
47
- "viagen-sdk": "^0.0.8"
47
+ "viagen-sdk": "^0.0.10"
48
48
  },
49
49
  "license": "MIT",
50
50
  "repository": {