Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

1.6 KB
Raw Blame
import { z } from 'zod';
import {
  projectIdSchema,
  projectRevisionIdSchema,
  materialDependenciesSchema,
  type MaterialDependency,
  type ProjectRevision,
} from './projects';
import type { MaterialLibraryPayload } from './material-library';

export interface WorkspaceBinding {
  project?: ProjectRevision;
  materialDependencies: MaterialDependency[];
  materialResources: MaterialLibraryPayload;
}
export const workspaceSelectionSchema = z
  .object({
    projectId: projectIdSchema
      .nullable()
      .optional()
      .describe('Project; omit for the configured default, null for standalone.'),
    projectRevision: projectRevisionIdSchema.optional().describe('Exact project revision.'),
    materialDependencies: materialDependenciesSchema
      .optional()
      .describe('Pins for this call; each replaces the project pin of its resourceId.'),
  })
  .strict()
  .superRefine((selection, ctx) => {
    if (selection.projectId === null && selection.projectRevision !== undefined)
      ctx.addIssue({
        code: 'custom',
        path: ['projectRevision'],
        message: 'projectRevision cannot be combined with standalone projectId: null.',
      });
  });
export type WorkspaceSelection = z.infer<typeof workspaceSelectionSchema>;
/** A host snapshots optional project context and exact material pins per operation. */
export interface WorkspacePort {
  run<T>(selection: WorkspaceSelection, execute: () => Promise<T>): Promise<T>;
  current(): WorkspaceBinding | undefined;
  /** The project an omitted `projectId` selects, when the host configured one. */
  configured?(): string | undefined;
}