rename
This commit is contained in:
parent
1870f3f165
commit
368f9653cb
5 changed files with 25 additions and 27 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { ConfigYaml } from "./schemas/index.js";
|
||||
import { Assistant } from "./schemas/index.js";
|
||||
import { ModelRoles } from "./schemas/models.js";
|
||||
|
||||
type ModelYaml = NonNullable<ConfigYaml["models"]>[number];
|
||||
type ContextYaml = NonNullable<ConfigYaml["context"]>[number];
|
||||
type PromptYaml = NonNullable<ConfigYaml["prompts"]>[number];
|
||||
type ModelYaml = NonNullable<Assistant["models"]>[number];
|
||||
type ContextYaml = NonNullable<Assistant["context"]>[number];
|
||||
type PromptYaml = NonNullable<Assistant["prompts"]>[number];
|
||||
|
||||
function convertModel(
|
||||
m: ConfigJson["models"][number],
|
||||
|
|
@ -68,7 +68,7 @@ function convertCustomCommand(
|
|||
};
|
||||
}
|
||||
|
||||
function convertMcp(mcp: any): NonNullable<ConfigYaml["mcpServers"]>[number] {
|
||||
function convertMcp(mcp: any): NonNullable<Assistant["mcpServers"]>[number] {
|
||||
const { transport } = mcp;
|
||||
const { command, args, env } = transport;
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ function convertMcp(mcp: any): NonNullable<ConfigYaml["mcpServers"]>[number] {
|
|||
|
||||
function convertDoc(
|
||||
doc: NonNullable<ConfigJson["docs"]>[number],
|
||||
): NonNullable<ConfigYaml["docs"]>[number] {
|
||||
): NonNullable<Assistant["docs"]>[number] {
|
||||
return {
|
||||
name: doc.title,
|
||||
startUrl: doc.startUrl,
|
||||
|
|
@ -91,7 +91,7 @@ function convertDoc(
|
|||
};
|
||||
}
|
||||
|
||||
export function convertJsonToYamlConfig(configJson: ConfigJson): ConfigYaml {
|
||||
export function convertJsonToYamlConfig(configJson: ConfigJson): Assistant {
|
||||
// models
|
||||
const models = configJson.models.map((m) => convertModel(m, ["chat"]));
|
||||
const autocompleteModels = Array.isArray(configJson.tabAutocompleteModel)
|
||||
|
|
@ -126,7 +126,7 @@ export function convertJsonToYamlConfig(configJson: ConfigJson): ConfigYaml {
|
|||
// docs
|
||||
const docs = configJson.docs?.map(convertDoc);
|
||||
|
||||
const configYaml: ConfigYaml = {
|
||||
const configYaml: Assistant = {
|
||||
name: "Continue Config",
|
||||
version: "0.0.1",
|
||||
models,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
SecretLocation,
|
||||
} from "../interfaces/SecretResult.js";
|
||||
import { decodeFQSN, encodeFQSN, FQSN } from "../interfaces/slugs.js";
|
||||
import { ConfigYaml } from "../schemas/index.js";
|
||||
import { Assistant } from "../schemas/index.js";
|
||||
import {
|
||||
fillTemplateVariables,
|
||||
getTemplateVariables,
|
||||
|
|
@ -16,7 +16,7 @@ export async function clientRender(
|
|||
unrolledConfigContent: string,
|
||||
secretStore: SecretStore,
|
||||
platformClient?: PlatformClient,
|
||||
): Promise<ConfigYaml> {
|
||||
): Promise<Assistant> {
|
||||
// 1. First we need to get a list of all the FQSNs that are required to render the config
|
||||
const secrets = getTemplateVariables(unrolledConfigContent);
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ function getUnrenderedSecretLocation(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
function useProxyForUnrenderedSecrets(config: ConfigYaml): ConfigYaml {
|
||||
function useProxyForUnrenderedSecrets(config: Assistant): Assistant {
|
||||
if (config.models) {
|
||||
for (let i = 0; i < config.models.length; i++) {
|
||||
const apiKeyLocation = getUnrenderedSecretLocation(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ConfigYaml } from "../schemas/index.js";
|
||||
import { Assistant } from "../schemas/index.js";
|
||||
|
||||
export function mergePackages(
|
||||
current: ConfigYaml,
|
||||
incoming: ConfigYaml,
|
||||
): ConfigYaml {
|
||||
current: Assistant,
|
||||
incoming: Assistant,
|
||||
): Assistant {
|
||||
return {
|
||||
...current,
|
||||
models: [...(current.models ?? []), ...(incoming.models ?? [])],
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ import {
|
|||
decodeFullSlug,
|
||||
encodePackageSlug,
|
||||
} from "../interfaces/slugs.js";
|
||||
import { ConfigYaml, configYamlSchema } from "../schemas/index.js";
|
||||
import { Assistant, assistantSchema } from "../schemas/index.js";
|
||||
import { mergePackages } from "./merge.js";
|
||||
|
||||
export function parseConfigYaml(configYaml: string): ConfigYaml {
|
||||
export function parseConfigYaml(configYaml: string): Assistant {
|
||||
try {
|
||||
const parsed = YAML.parse(configYaml);
|
||||
const result = configYamlSchema.parse(parsed);
|
||||
const result = assistantSchema.parse(parsed);
|
||||
return result;
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to parse config yaml: ${e.message}`);
|
||||
|
|
@ -44,10 +44,10 @@ export function fillTemplateVariables(
|
|||
}
|
||||
|
||||
export async function unrollImportedPackage(
|
||||
pkgImport: NonNullable<ConfigYaml["packages"]>[number],
|
||||
pkgImport: NonNullable<Assistant["packages"]>[number],
|
||||
parentPackages: PackageSlug[],
|
||||
registry: Registry,
|
||||
): Promise<ConfigYaml> {
|
||||
): Promise<Assistant> {
|
||||
const { uses, with: params } = pkgImport;
|
||||
|
||||
const fullSlug = decodeFullSlug(uses);
|
||||
|
|
@ -121,7 +121,7 @@ export async function unrollPackageFromContent(
|
|||
params: Record<string, string> | undefined,
|
||||
packagePath: PackageSlug[],
|
||||
registry: Registry,
|
||||
): Promise<ConfigYaml> {
|
||||
): Promise<Assistant> {
|
||||
// Collect template data
|
||||
const templateData: TemplateData = {
|
||||
// params are passed from the parent package
|
||||
|
|
@ -160,7 +160,7 @@ export async function unrollPackageFromContent(
|
|||
export async function unrollAssistant(
|
||||
fullSlug: string,
|
||||
registry: Registry,
|
||||
): Promise<ConfigYaml> {
|
||||
): Promise<Assistant> {
|
||||
const packageSlug = decodeFullSlug(fullSlug);
|
||||
return await unrollImportedPackage(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ConfigYaml, configYamlSchema } from "./schemas/index.js";
|
||||
import { Assistant, assistantSchema } from "./schemas/index.js";
|
||||
|
||||
export interface ConfigValidationError {
|
||||
fatal: boolean;
|
||||
|
|
@ -11,13 +11,11 @@ export interface ConfigResult<T> {
|
|||
configLoadInterrupted: boolean;
|
||||
}
|
||||
|
||||
export function validateConfigYaml(
|
||||
config: ConfigYaml,
|
||||
): ConfigValidationError[] {
|
||||
export function validateConfigYaml(config: Assistant): ConfigValidationError[] {
|
||||
const errors: ConfigValidationError[] = [];
|
||||
|
||||
try {
|
||||
configYamlSchema.parse(config);
|
||||
assistantSchema.parse(config);
|
||||
} catch (e: any) {
|
||||
return [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue