fix: require a model, default to empty value during onboarding
and add a WORKSPACE_PATH constant to make tracking that path easier
This commit is contained in:
@@ -3,6 +3,7 @@ import { join } from 'node:path';
|
||||
import { Command } from 'commander';
|
||||
import pc from 'picocolors';
|
||||
import { ConfigSchema, type Config } from '../config/types.ts';
|
||||
import { WORKSPACE_PATH } from '../config/constants.ts'
|
||||
import { ensureWorkspace, resolvePath, checkWorkspaceEmpty, syncTemplates } from './utils.ts';
|
||||
|
||||
function logCreated(item: string) {
|
||||
@@ -15,9 +16,14 @@ export function onboardCommand(program: Command): void {
|
||||
.description('Initialize a new nanobot workspace with config and templates')
|
||||
.action(async (rawPath?: string) => {
|
||||
try {
|
||||
const defaultConfig: Config = ConfigSchema.parse({});
|
||||
const defaultConfig: Config = ConfigSchema.parse({
|
||||
agent: {
|
||||
provider: '',
|
||||
model: '',
|
||||
}
|
||||
});
|
||||
|
||||
const targetPath = resolvePath(rawPath ?? defaultConfig.agent.workspacePath);
|
||||
const targetPath = resolvePath(rawPath ?? WORKSPACE_PATH);
|
||||
const configPath = join(targetPath, 'config.json');
|
||||
|
||||
console.info(pc.blue('Initializing nanobot workspace...'));
|
||||
|
||||
1
src/config/constants.ts
Normal file
1
src/config/constants.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const WORKSPACE_PATH = '~/.config/nanobot'
|
||||
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import pc from 'picocolors'
|
||||
import { type Config, ConfigSchema } from './types.ts';
|
||||
import { WORKSPACE_PATH } from './constants.ts'
|
||||
|
||||
const DEFAULT_CONFIG_PATH = resolve(homedir(), '.config', 'nanobot', 'config.json');
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { WORKSPACE_PATH } from './constants.ts'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mattermost
|
||||
@@ -41,7 +42,7 @@ export type ChannelsConfig = z.infer<typeof ChannelsConfigSchema>;
|
||||
|
||||
export const AgentConfigSchema = z.object({
|
||||
model: z.string().default('anthropic/claude-sonnet-4-5'),
|
||||
workspacePath: z.string().default('~/.config/nanobot'),
|
||||
workspacePath: z.string().default(WORKSPACE_PATH),
|
||||
maxTokens: z.number().int().default(4096),
|
||||
contextWindowTokens: z.number().int().default(65536),
|
||||
temperature: z.number().default(0.7),
|
||||
@@ -113,14 +114,7 @@ export type HeartbeatConfig = z.infer<typeof HeartbeatConfigSchema>;
|
||||
|
||||
export const ConfigSchema = z.object({
|
||||
providers: ProvidersConfigSchema.default(() => ({})),
|
||||
agent: AgentConfigSchema.default(() => ({
|
||||
model: 'anthropic/claude-sonnet-4-5',
|
||||
workspacePath: '~/.config/nanobot',
|
||||
maxTokens: 4096,
|
||||
contextWindowTokens: 65536,
|
||||
temperature: 0.7,
|
||||
maxToolIterations: 40,
|
||||
})),
|
||||
agent: AgentConfigSchema,
|
||||
heartbeat: HeartbeatConfigSchema.default(() => ({ enabled: false, intervalMinutes: 30 })),
|
||||
channels: ChannelsConfigSchema.default(() => ({ sendProgress: true, sendToolHints: true })),
|
||||
tools: ToolsConfigSchema.default(() => ({
|
||||
|
||||
Reference in New Issue
Block a user