@tonyclaw/agent-inspector 3.0.12 → 3.0.14

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 (40) hide show
  1. package/.output/cli.js +72 -6
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/assets/{CompareDrawer-BxgmeTyv.js → CompareDrawer-DDfwHQUi.js} +1 -1
  4. package/.output/public/assets/{ProxyViewerContainer-CchT6T-4.js → ProxyViewerContainer-CbNsaoQw.js} +41 -41
  5. package/.output/public/assets/{ReplayDialog-CMHVUtVB.js → ReplayDialog-D-26DMBt.js} +1 -1
  6. package/.output/public/assets/{RequestAnatomy-CpqHIkD1.js → RequestAnatomy-B6zNFqNX.js} +1 -1
  7. package/.output/public/assets/{ResponseView-BvhBiQ5k.js → ResponseView-Ccy95rWI.js} +2 -2
  8. package/.output/public/assets/{StreamingChunkSequence-CcNvFNPp.js → StreamingChunkSequence-yIiscGuE.js} +1 -1
  9. package/.output/public/assets/{_sessionId-D5z6C77f.js → _sessionId-BnMB0zab.js} +1 -1
  10. package/.output/public/assets/index-49RC4dlD.js +1 -0
  11. package/.output/public/assets/{index-CXcH69lm.js → index-BbtAIxbg.js} +1 -1
  12. package/.output/public/assets/index-DXKupW0r.css +1 -0
  13. package/.output/public/assets/{json-viewer-DjRQ00mw.js → json-viewer-C838cVmD.js} +1 -1
  14. package/.output/public/assets/{main-CkKubKth.js → main-BfN4culo.js} +2 -2
  15. package/.output/server/_libs/lucide-react.mjs +33 -33
  16. package/.output/server/{_sessionId-IP7wEbnv.mjs → _sessionId-DoprmwZV.mjs} +3 -3
  17. package/.output/server/_ssr/{CompareDrawer-B4qTq3I9.mjs → CompareDrawer-YMLJNxXR.mjs} +3 -3
  18. package/.output/server/_ssr/{ProxyViewerContainer-CCIJ1EcB.mjs → ProxyViewerContainer-C62eZnva.mjs} +215 -24
  19. package/.output/server/_ssr/{ReplayDialog-BgxCdCxM.mjs → ReplayDialog-NmN7Ukjo.mjs} +3 -3
  20. package/.output/server/_ssr/{RequestAnatomy-De3QDi_x.mjs → RequestAnatomy-Dawm2qxe.mjs} +2 -2
  21. package/.output/server/_ssr/{ResponseView-Dvibk8g5.mjs → ResponseView-BHyAY83t.mjs} +3 -3
  22. package/.output/server/_ssr/{StreamingChunkSequence-oAsweEag.mjs → StreamingChunkSequence-C4qgcJbg.mjs} +2 -2
  23. package/.output/server/_ssr/{index-BIlK7gMO.mjs → index-B2Pf6W_T.mjs} +2 -2
  24. package/.output/server/_ssr/index.mjs +2 -2
  25. package/.output/server/_ssr/{json-viewer-Dgo4oRbs.mjs → json-viewer-u67BASf8.mjs} +3 -3
  26. package/.output/server/_ssr/{router-DY_2TxnZ.mjs → router-CZhFVMGN.mjs} +267 -111
  27. package/.output/server/_tanstack-start-manifest_v-Dk2HfOoe.mjs +4 -0
  28. package/.output/server/index.mjs +73 -73
  29. package/README.md +32 -9
  30. package/package.json +1 -1
  31. package/src/cli.ts +95 -11
  32. package/src/components/ecosystem/AgentLabDialog.tsx +221 -10
  33. package/src/lib/ecosystemContract.ts +21 -1
  34. package/src/proxy/ecosystemRegistry.ts +52 -0
  35. package/src/proxy/ecosystemTasks.ts +95 -1
  36. package/src/routes/api/ecosystem.packages.ts +2 -1
  37. package/src/routes/api/ecosystem.recipes.$recipeId.run.ts +16 -0
  38. package/.output/public/assets/index-BIgsQvaF.css +0 -1
  39. package/.output/public/assets/index-C57MERBU.js +0 -1
  40. package/.output/server/_tanstack-start-manifest_v-CYOwyBpv.mjs +0 -4
@@ -6,6 +6,7 @@ import {
6
6
  Copy,
7
7
  Download,
8
8
  FlaskConical,
9
+ History,
9
10
  Loader2,
10
11
  Network,
11
12
  PackageCheck,
@@ -18,8 +19,10 @@ import useSWR from "swr";
18
19
  import {
19
20
  EcosystemPackagesResponseSchema,
20
21
  EcosystemTaskResponseSchema,
22
+ EcosystemTasksResponseSchema,
21
23
  type EcosystemPackage,
22
24
  type EcosystemPackageState,
25
+ type EcosystemRecipe,
23
26
  type EcosystemRunnerPreset,
24
27
  type EcosystemTask,
25
28
  type EcosystemTaskAction,
@@ -101,6 +104,15 @@ async function fetchEcosystemTask(url: string) {
101
104
  );
102
105
  }
103
106
 
107
+ async function fetchEcosystemTasks(url: string) {
108
+ return fetchJson(
109
+ url,
110
+ EcosystemTasksResponseSchema,
111
+ undefined,
112
+ (response) => `Failed to load ecosystem tasks: ${String(response.status)}`,
113
+ );
114
+ }
115
+
104
116
  async function startEcosystemTask(
105
117
  packageId: string,
106
118
  action: EcosystemTaskAction,
@@ -114,6 +126,16 @@ async function startEcosystemTask(
114
126
  return response.task;
115
127
  }
116
128
 
129
+ async function startEcosystemRecipe(recipeId: string): Promise<EcosystemTask> {
130
+ const response = await fetchJson(
131
+ `/api/ecosystem/recipes/${encodeURIComponent(recipeId)}/run`,
132
+ EcosystemTaskResponseSchema,
133
+ { method: "POST" },
134
+ (result) => `Failed to start ecosystem recipe: ${String(result.status)}`,
135
+ );
136
+ return response.task;
137
+ }
138
+
117
139
  function stateLabel(state: EcosystemPackageState): string {
118
140
  switch (state) {
119
141
  case "installed":
@@ -164,6 +186,8 @@ function taskActionLabel(action: EcosystemTaskAction): string {
164
186
  return "Help";
165
187
  case "runner-presets":
166
188
  return "Presets";
189
+ case "recipe":
190
+ return "Recipe";
167
191
  }
168
192
  }
169
193
 
@@ -180,6 +204,18 @@ function taskStatusLabel(task: EcosystemTask): string {
180
204
  }
181
205
  }
182
206
 
207
+ function taskStatusClassName(status: EcosystemTask["status"]): string {
208
+ switch (status) {
209
+ case "queued":
210
+ case "running":
211
+ return "border-cyan-300/20 bg-cyan-300/8 text-cyan-100";
212
+ case "succeeded":
213
+ return "border-emerald-400/20 bg-emerald-400/8 text-emerald-100";
214
+ case "failed":
215
+ return "border-red-400/20 bg-red-400/8 text-red-100";
216
+ }
217
+ }
218
+
183
219
  function packagePrimaryAction(pkg: EcosystemPackage): EcosystemTaskAction | null {
184
220
  switch (pkg.state) {
185
221
  case "available":
@@ -292,15 +328,7 @@ function TaskConsole({ task }: { task: EcosystemTask | null }): JSX.Element | nu
292
328
  <div className="break-all font-mono text-[11px] text-white/35">{task.command}</div>
293
329
  </div>
294
330
  </div>
295
- <Badge
296
- variant="outline"
297
- className={cn(
298
- "shrink-0",
299
- task.status === "failed"
300
- ? "border-red-400/20 bg-red-400/8 text-red-100"
301
- : "border-cyan-300/20 bg-cyan-300/8 text-cyan-100",
302
- )}
303
- >
331
+ <Badge variant="outline" className={cn("shrink-0", taskStatusClassName(task.status))}>
304
332
  {task.status}
305
333
  </Badge>
306
334
  </div>
@@ -372,10 +400,110 @@ function RunnerPresetCard({ preset }: { preset: EcosystemRunnerPreset }): JSX.El
372
400
  );
373
401
  }
374
402
 
403
+ function RecipeCard({
404
+ recipe,
405
+ copied,
406
+ running,
407
+ onCopy,
408
+ onRun,
409
+ }: {
410
+ recipe: EcosystemRecipe;
411
+ copied: boolean;
412
+ running: boolean;
413
+ onCopy: (recipe: EcosystemRecipe) => void;
414
+ onRun: (recipe: EcosystemRecipe) => void;
415
+ }): JSX.Element {
416
+ return (
417
+ <div className="rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]">
418
+ <div className="flex flex-wrap items-start justify-between gap-3">
419
+ <div className="min-w-0">
420
+ <div className="flex min-w-0 items-start gap-2">
421
+ <FlaskConical className="size-4 shrink-0 text-cyan-200/75" />
422
+ <div className="text-sm font-semibold leading-snug">{recipe.title}</div>
423
+ </div>
424
+ <div className="mt-1 text-xs leading-5 text-muted-foreground">{recipe.description}</div>
425
+ </div>
426
+ <Badge variant="outline" className="border-white/10 bg-white/[0.04] text-white/55">
427
+ {recipe.runnable ? recipe.stage : "Template"}
428
+ </Badge>
429
+ </div>
430
+ <div className="mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]">
431
+ {recipe.command}
432
+ </div>
433
+ <div className="mt-3 flex items-center justify-between gap-2">
434
+ <span className="rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35">
435
+ {recipe.packageId}
436
+ </span>
437
+ <div className="flex items-center gap-2">
438
+ <Button type="button" size="sm" variant="outline" onClick={() => onCopy(recipe)}>
439
+ {copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
440
+ {copied ? "Copied" : "Copy"}
441
+ </Button>
442
+ {recipe.runnable && (
443
+ <Button
444
+ type="button"
445
+ size="sm"
446
+ variant="secondary"
447
+ disabled={running}
448
+ onClick={() => onRun(recipe)}
449
+ >
450
+ {running ? (
451
+ <Loader2 className="size-3.5 animate-spin" />
452
+ ) : (
453
+ <Rocket className="size-3.5" />
454
+ )}
455
+ {running ? "Running" : "Run"}
456
+ </Button>
457
+ )}
458
+ </div>
459
+ </div>
460
+ </div>
461
+ );
462
+ }
463
+
464
+ function RecentTaskRow({
465
+ task,
466
+ selected,
467
+ onSelect,
468
+ }: {
469
+ task: EcosystemTask;
470
+ selected: boolean;
471
+ onSelect: (task: EcosystemTask) => void;
472
+ }): JSX.Element {
473
+ const label = task.recipeId ?? taskActionLabel(task.action);
474
+ return (
475
+ <div className="flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]">
476
+ <div className="min-w-0">
477
+ <div className="flex min-w-0 items-center gap-2">
478
+ <History className="size-3.5 shrink-0 text-white/40" />
479
+ <div className="truncate text-xs font-semibold text-white/75">{label}</div>
480
+ <Badge variant="outline" className={cn("shrink-0", taskStatusClassName(task.status))}>
481
+ {task.status}
482
+ </Badge>
483
+ </div>
484
+ <div className="mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35">
485
+ <span>{task.packageId}</span>
486
+ <span>{new Date(task.createdAt).toLocaleTimeString()}</span>
487
+ {task.exitCode !== null && <span>exit {String(task.exitCode)}</span>}
488
+ </div>
489
+ </div>
490
+ <Button
491
+ type="button"
492
+ size="sm"
493
+ variant={selected ? "secondary" : "outline"}
494
+ onClick={() => onSelect(task)}
495
+ >
496
+ {selected ? "Open" : "View"}
497
+ </Button>
498
+ </div>
499
+ );
500
+ }
501
+
375
502
  export function AgentLabDialog({ currentSessionId, logCount }: AgentLabDialogProps): JSX.Element {
376
503
  const [open, setOpen] = useState(false);
377
504
  const [copied, setCopied] = useState(false);
378
505
  const [copiedPresets, setCopiedPresets] = useState(false);
506
+ const [copiedRecipeId, setCopiedRecipeId] = useState<string | null>(null);
379
507
  const [activeTaskId, setActiveTaskId] = useState<string | null>(null);
380
508
  const [taskError, setTaskError] = useState<string | null>(null);
381
509
  const response = useSWR("/api/ecosystem/packages", fetchEcosystemPackages, {
@@ -395,8 +523,14 @@ export function AgentLabDialog({ currentSessionId, logCount }: AgentLabDialogPro
395
523
  revalidateOnFocus: false,
396
524
  },
397
525
  );
526
+ const tasksResponse = useSWR(open ? "/api/ecosystem/tasks" : null, fetchEcosystemTasks, {
527
+ refreshInterval: 2500,
528
+ revalidateOnFocus: false,
529
+ });
398
530
  const packages = response.data?.packages ?? [];
399
531
  const runnerPresets = response.data?.runnerPresets ?? [];
532
+ const recipes = response.data?.recipes ?? [];
533
+ const recentTasks = (tasksResponse.data?.tasks ?? []).slice(0, 6);
400
534
  const installedCount = useMemo(
401
535
  () =>
402
536
  packages.filter((pkg) => pkg.state === "installed" || pkg.state === "update-available")
@@ -418,14 +552,33 @@ export function AgentLabDialog({ currentSessionId, logCount }: AgentLabDialogPro
418
552
  window.setTimeout(() => setCopiedPresets(false), 1200);
419
553
  });
420
554
  };
555
+ const copyRecipeCommand = (recipe: EcosystemRecipe): void => {
556
+ void copyTextToClipboard(recipe.command).then(() => {
557
+ setCopiedRecipeId(recipe.id);
558
+ window.setTimeout(() => setCopiedRecipeId(null), 1200);
559
+ });
560
+ };
561
+ const runRecipe = (recipe: EcosystemRecipe): void => {
562
+ setTaskError(null);
563
+ void startEcosystemRecipe(recipe.id)
564
+ .then((task) => {
565
+ setActiveTaskId(task.id);
566
+ void activeTaskResponse.mutate({ task }, { revalidate: true });
567
+ void tasksResponse.mutate();
568
+ })
569
+ .catch((error: unknown) => {
570
+ setTaskError(error instanceof Error ? error.message : "Failed to start ecosystem recipe");
571
+ });
572
+ };
421
573
 
422
574
  const activeTask = activeTaskResponse.data?.task ?? null;
423
575
 
424
576
  useEffect(() => {
425
577
  if (activeTask === null) return;
578
+ void tasksResponse.mutate();
426
579
  if (activeTask.status !== "succeeded") return;
427
580
  void response.mutate();
428
- }, [activeTask, response]);
581
+ }, [activeTask, response, tasksResponse]);
429
582
 
430
583
  const handleStartTask = (packageId: string, action: EcosystemTaskAction): void => {
431
584
  setTaskError(null);
@@ -433,6 +586,7 @@ export function AgentLabDialog({ currentSessionId, logCount }: AgentLabDialogPro
433
586
  .then((task) => {
434
587
  setActiveTaskId(task.id);
435
588
  void activeTaskResponse.mutate({ task }, { revalidate: true });
589
+ void tasksResponse.mutate();
436
590
  })
437
591
  .catch((error: unknown) => {
438
592
  setTaskError(error instanceof Error ? error.message : "Failed to start ecosystem task");
@@ -514,6 +668,40 @@ export function AgentLabDialog({ currentSessionId, logCount }: AgentLabDialogPro
514
668
  </section>
515
669
  </div>
516
670
 
671
+ <section className="mt-3">
672
+ <div className="mb-2 flex items-center justify-between gap-3">
673
+ <div className="text-sm font-semibold">Lab recipes</div>
674
+ <div className="hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex">
675
+ <Sparkles className="size-3.5" />
676
+ copy-ready workflows
677
+ </div>
678
+ </div>
679
+ <div className="grid gap-3 md:grid-cols-2">
680
+ {recipes.map((recipe) => (
681
+ <RecipeCard
682
+ key={recipe.id}
683
+ recipe={recipe}
684
+ copied={copiedRecipeId === recipe.id}
685
+ running={
686
+ activeTask !== null &&
687
+ activeTask.recipeId === recipe.id &&
688
+ (activeTask.status === "queued" || activeTask.status === "running")
689
+ }
690
+ onCopy={copyRecipeCommand}
691
+ onRun={runRecipe}
692
+ />
693
+ ))}
694
+ {response.isLoading &&
695
+ recipes.length === 0 &&
696
+ [0, 1].map((index) => (
697
+ <div
698
+ key={index}
699
+ className="h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"
700
+ />
701
+ ))}
702
+ </div>
703
+ </section>
704
+
517
705
  <section className="mt-3">
518
706
  <div className="mb-2 flex items-center justify-between gap-3">
519
707
  <div className="text-sm font-semibold">Runner presets</div>
@@ -574,6 +762,29 @@ export function AgentLabDialog({ currentSessionId, logCount }: AgentLabDialogPro
574
762
  {taskError}
575
763
  </div>
576
764
  )}
765
+ {recentTasks.length > 0 && (
766
+ <section className="mt-3">
767
+ <div className="mb-2 flex items-center justify-between gap-3">
768
+ <div className="text-sm font-semibold">Recent Lab runs</div>
769
+ <div className="hidden font-mono text-[11px] text-muted-foreground sm:block">
770
+ last {String(recentTasks.length)}
771
+ </div>
772
+ </div>
773
+ <div className="grid gap-2 md:grid-cols-2">
774
+ {recentTasks.map((task) => (
775
+ <RecentTaskRow
776
+ key={task.id}
777
+ task={task}
778
+ selected={activeTaskId === task.id}
779
+ onSelect={(selectedTask) => {
780
+ setActiveTaskId(selectedTask.id);
781
+ void activeTaskResponse.mutate({ task: selectedTask }, { revalidate: true });
782
+ }}
783
+ />
784
+ ))}
785
+ </div>
786
+ </section>
787
+ )}
577
788
  <TaskConsole task={activeTask} />
578
789
  </div>
579
790
  </DialogContent>
@@ -35,13 +35,31 @@ export const EcosystemRunnerPresetSchema = z.object({
35
35
  agentsDir: z.string(),
36
36
  });
37
37
 
38
+ export const EcosystemRecipeSchema = z.object({
39
+ id: z.string(),
40
+ title: z.string(),
41
+ stage: z.string(),
42
+ packageId: z.string(),
43
+ description: z.string(),
44
+ command: z.string(),
45
+ requiresSession: z.boolean(),
46
+ runnable: z.boolean(),
47
+ });
48
+
38
49
  export const EcosystemPackagesResponseSchema = z.object({
39
50
  checkedAt: z.string(),
40
51
  packages: z.array(EcosystemPackageSchema),
41
52
  runnerPresets: z.array(EcosystemRunnerPresetSchema),
53
+ recipes: z.array(EcosystemRecipeSchema),
42
54
  });
43
55
 
44
- export const EcosystemTaskActionSchema = z.enum(["install", "upgrade", "help", "runner-presets"]);
56
+ export const EcosystemTaskActionSchema = z.enum([
57
+ "install",
58
+ "upgrade",
59
+ "help",
60
+ "runner-presets",
61
+ "recipe",
62
+ ]);
45
63
 
46
64
  export const EcosystemTaskStatusSchema = z.enum(["queued", "running", "succeeded", "failed"]);
47
65
 
@@ -49,6 +67,7 @@ export const EcosystemTaskSchema = z.object({
49
67
  id: z.string(),
50
68
  packageId: z.string(),
51
69
  npmName: z.string(),
70
+ recipeId: z.string().nullable().default(null),
52
71
  action: EcosystemTaskActionSchema,
53
72
  status: EcosystemTaskStatusSchema,
54
73
  command: z.string(),
@@ -71,6 +90,7 @@ export const EcosystemTasksResponseSchema = z.object({
71
90
  export type EcosystemPackageState = z.infer<typeof EcosystemPackageStateSchema>;
72
91
  export type EcosystemPackage = z.infer<typeof EcosystemPackageSchema>;
73
92
  export type EcosystemRunnerPreset = z.infer<typeof EcosystemRunnerPresetSchema>;
93
+ export type EcosystemRecipe = z.infer<typeof EcosystemRecipeSchema>;
74
94
  export type EcosystemPackagesResponse = z.infer<typeof EcosystemPackagesResponseSchema>;
75
95
  export type EcosystemTaskAction = z.infer<typeof EcosystemTaskActionSchema>;
76
96
  export type EcosystemTaskStatus = z.infer<typeof EcosystemTaskStatusSchema>;
@@ -5,6 +5,7 @@ import packageJson from "../../package.json";
5
5
  import type {
6
6
  EcosystemPackage,
7
7
  EcosystemPackageState,
8
+ EcosystemRecipe,
8
9
  EcosystemRunnerPreset,
9
10
  } from "../lib/ecosystemContract";
10
11
  import { npmSpawnCommand } from "./platformCommands";
@@ -106,6 +107,53 @@ export const RUNNER_PRESETS: EcosystemRunnerPreset[] = [
106
107
  },
107
108
  ];
108
109
 
110
+ export const LAB_RECIPES: EcosystemRecipe[] = [
111
+ {
112
+ id: "inspector-mcp-smoke",
113
+ title: "Inspector MCP smoke",
114
+ stage: "Validate",
115
+ packageId: "eval-harness",
116
+ description: "Check that the running Inspector exposes the MCP tools eval-harness expects.",
117
+ command: "npx @tonyclaw/eval-harness check-inspector-mcp",
118
+ requiresSession: false,
119
+ runnable: true,
120
+ },
121
+ {
122
+ id: "session-evidence-smoke",
123
+ title: "Session evidence smoke",
124
+ stage: "Capture",
125
+ packageId: "eval-harness",
126
+ description:
127
+ "Create a lightweight Inspector evidence run from the latest captured logs or selected session.",
128
+ command:
129
+ 'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5',
130
+ requiresSession: false,
131
+ runnable: true,
132
+ },
133
+ {
134
+ id: "runner-presets-json",
135
+ title: "Runner presets JSON",
136
+ stage: "Connect",
137
+ packageId: "eval-harness",
138
+ description: "Export runner adapter baselines as machine-readable JSON for CI or docs.",
139
+ command: "npx @tonyclaw/eval-harness runner-presets --format json",
140
+ requiresSession: false,
141
+ runnable: true,
142
+ },
143
+ {
144
+ id: "local-smoke-batch",
145
+ title: "Local smoke batch",
146
+ stage: "Evaluate",
147
+ packageId: "eval-harness",
148
+ description:
149
+ "Run one short local Jenkins-like evaluation using explicit project/work directories.",
150
+ command:
151
+ "npx @tonyclaw/eval-harness run-once --smoke --project-source <project> --work-source <work> --count 1 --parallel 1",
152
+ requiresSession: false,
153
+ runnable: false,
154
+ },
155
+ ];
156
+
109
157
  const NPM_TIMEOUT_MS = 4000;
110
158
 
111
159
  function runNpm(args: readonly string[]): Promise<NpmResult> {
@@ -242,3 +290,7 @@ export async function listEcosystemPackages(): Promise<EcosystemPackage[]> {
242
290
  export function findEcosystemPackage(packageId: string): PackageDefinition | null {
243
291
  return ECOSYSTEM_PACKAGES.find((definition) => definition.id === packageId) ?? null;
244
292
  }
293
+
294
+ export function findEcosystemRecipe(recipeId: string): EcosystemRecipe | null {
295
+ return LAB_RECIPES.find((recipe) => recipe.id === recipeId) ?? null;
296
+ }
@@ -6,13 +6,14 @@ import type {
6
6
  EcosystemTaskAction,
7
7
  EcosystemTaskStatus,
8
8
  } from "../lib/ecosystemContract";
9
- import { findEcosystemPackage } from "./ecosystemRegistry";
9
+ import { findEcosystemPackage, findEcosystemRecipe } from "./ecosystemRegistry";
10
10
  import { npmCommand, npmSpawnCommand } from "./platformCommands";
11
11
 
12
12
  const MAX_TASKS = 50;
13
13
  const OUTPUT_LIMIT = 40_000;
14
14
  const INSTALL_TIMEOUT_MS = 120_000;
15
15
  const HELP_TIMEOUT_MS = 30_000;
16
+ const RECIPE_TIMEOUT_MS = 90_000;
16
17
 
17
18
  const tasks = new Map<string, EcosystemTask>();
18
19
 
@@ -47,7 +48,32 @@ function packageActionArgs(action: EcosystemTaskAction, npmName: string): string
47
48
  return ["exec", "--yes", npmName, "--", "--help"];
48
49
  case "runner-presets":
49
50
  return ["exec", "--yes", "@tonyclaw/eval-harness", "--", "runner-presets"];
51
+ case "recipe":
52
+ return ["exec", "--yes", npmName, "--", "--help"];
53
+ }
54
+ }
55
+
56
+ function recipeActionArgs(recipeId: string): string[] | null {
57
+ const execPrefix = ["exec", "--yes", "@tonyclaw/eval-harness", "--"];
58
+ switch (recipeId) {
59
+ case "inspector-mcp-smoke":
60
+ return [...execPrefix, "check-inspector-mcp"];
61
+ case "session-evidence-smoke":
62
+ return [
63
+ ...execPrefix,
64
+ "inspector-smoke",
65
+ "--title",
66
+ "TonyClaw Lab smoke",
67
+ "--latest-log-limit",
68
+ "5",
69
+ ];
70
+ case "runner-presets-json":
71
+ return [...execPrefix, "runner-presets", "--format", "json"];
72
+ case "local-smoke-batch":
73
+ return null;
50
74
  }
75
+
76
+ return null;
51
77
  }
52
78
 
53
79
  function packageActionTimeout(action: EcosystemTaskAction): number {
@@ -58,6 +84,8 @@ function packageActionTimeout(action: EcosystemTaskAction): number {
58
84
  case "help":
59
85
  case "runner-presets":
60
86
  return HELP_TIMEOUT_MS;
87
+ case "recipe":
88
+ return RECIPE_TIMEOUT_MS;
61
89
  }
62
90
  }
63
91
 
@@ -101,6 +129,7 @@ export function startEcosystemTask(
101
129
  id: randomUUID(),
102
130
  packageId: definition.id,
103
131
  npmName: definition.npmName,
132
+ recipeId: null,
104
133
  action,
105
134
  status: "queued",
106
135
  command: taskCommand(args),
@@ -151,3 +180,68 @@ export function startEcosystemTask(
151
180
 
152
181
  return task;
153
182
  }
183
+
184
+ export function startEcosystemRecipeTask(recipeId: string): EcosystemTask | null {
185
+ const recipe = findEcosystemRecipe(recipeId);
186
+ if (recipe === null) return null;
187
+ if (!recipe.runnable) return null;
188
+ const definition = findEcosystemPackage(recipe.packageId);
189
+ if (definition === null) return null;
190
+ const args = recipeActionArgs(recipe.id);
191
+ if (args === null) return null;
192
+
193
+ const task: EcosystemTask = {
194
+ id: randomUUID(),
195
+ packageId: definition.id,
196
+ npmName: definition.npmName,
197
+ recipeId: recipe.id,
198
+ action: "recipe",
199
+ status: "queued",
200
+ command: taskCommand(args),
201
+ output: "",
202
+ createdAt: nowIso(),
203
+ startedAt: null,
204
+ finishedAt: null,
205
+ exitCode: null,
206
+ error: null,
207
+ };
208
+ rememberTask(task);
209
+
210
+ const spawnCommand = npmSpawnCommand(args);
211
+ const child = spawn(spawnCommand.command, spawnCommand.args, {
212
+ windowsHide: true,
213
+ shell: false,
214
+ stdio: ["ignore", "pipe", "pipe"],
215
+ });
216
+ const timeout = setTimeout(() => {
217
+ child.kill();
218
+ appendTaskOutput(task, `\nTimed out after ${String(RECIPE_TIMEOUT_MS / 1000)}s.\n`);
219
+ }, RECIPE_TIMEOUT_MS);
220
+
221
+ task.status = "running";
222
+ task.startedAt = nowIso();
223
+ appendTaskOutput(task, `$ ${task.command}\n`);
224
+
225
+ child.stdout.on("data", (chunk: Buffer) => {
226
+ appendTaskOutput(task, chunk.toString("utf8"));
227
+ });
228
+ child.stderr.on("data", (chunk: Buffer) => {
229
+ appendTaskOutput(task, chunk.toString("utf8"));
230
+ });
231
+ child.on("error", (error) => {
232
+ clearTimeout(timeout);
233
+ appendTaskOutput(task, `\n${error.message}\n`);
234
+ completeTask(task, "failed", null, error.message);
235
+ });
236
+ child.on("close", (code) => {
237
+ clearTimeout(timeout);
238
+ if (task.status === "failed") return;
239
+ if (code === 0) {
240
+ completeTask(task, "succeeded", code, null);
241
+ return;
242
+ }
243
+ completeTask(task, "failed", code, `Command exited with code ${String(code ?? "unknown")}`);
244
+ });
245
+
246
+ return task;
247
+ }
@@ -1,5 +1,5 @@
1
1
  import { createFileRoute } from "@tanstack/react-router";
2
- import { listEcosystemPackages, RUNNER_PRESETS } from "../../proxy/ecosystemRegistry";
2
+ import { LAB_RECIPES, listEcosystemPackages, RUNNER_PRESETS } from "../../proxy/ecosystemRegistry";
3
3
 
4
4
  export const Route = createFileRoute("/api/ecosystem/packages")({
5
5
  server: {
@@ -9,6 +9,7 @@ export const Route = createFileRoute("/api/ecosystem/packages")({
9
9
  checkedAt: new Date().toISOString(),
10
10
  packages: await listEcosystemPackages(),
11
11
  runnerPresets: RUNNER_PRESETS,
12
+ recipes: LAB_RECIPES,
12
13
  });
13
14
  },
14
15
  },
@@ -0,0 +1,16 @@
1
+ import { createFileRoute } from "@tanstack/react-router";
2
+ import { startEcosystemRecipeTask } from "../../proxy/ecosystemTasks";
3
+
4
+ export const Route = createFileRoute("/api/ecosystem/recipes/$recipeId/run")({
5
+ server: {
6
+ handlers: {
7
+ POST: ({ params }: { params: { recipeId: string } }) => {
8
+ const task = startEcosystemRecipeTask(params.recipeId);
9
+ if (task === null) {
10
+ return Response.json({ error: "Unknown ecosystem recipe" }, { status: 404 });
11
+ }
12
+ return Response.json({ task });
13
+ },
14
+ },
15
+ },
16
+ });