@inkeep/agents-cli 0.58.10 → 0.58.13
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.
- package/dist/agents-cli/package.js +3 -2
- package/dist/agents-cli/package.js.map +1 -0
- package/dist/api.js +7 -11
- package/dist/api.js.map +1 -0
- package/dist/commands/add-ui.js +2 -1
- package/dist/commands/add-ui.js.map +1 -0
- package/dist/commands/add.js +2 -1
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/config.js +2 -1
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/dev.js +2 -1
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.js +2 -1
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list-agents.js +2 -1
- package/dist/commands/list-agents.js.map +1 -0
- package/dist/commands/login.js +2 -1
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.js +2 -1
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/profile.js +2 -1
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/pull-v4/component-parser.js +2 -1
- package/dist/commands/pull-v4/component-parser.js.map +1 -0
- package/dist/commands/pull-v4/component-registry.js +2 -1
- package/dist/commands/pull-v4/component-registry.js.map +1 -0
- package/dist/commands/pull-v4/generators/agent-generator.helpers.js +186 -0
- package/dist/commands/pull-v4/generators/agent-generator.helpers.js.map +1 -0
- package/dist/commands/pull-v4/generators/agent-generator.js +70 -209
- package/dist/commands/pull-v4/generators/agent-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/artifact-component-generator.js +13 -16
- package/dist/commands/pull-v4/generators/artifact-component-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/context-config-generator.js +38 -24
- package/dist/commands/pull-v4/generators/context-config-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/credential-generator.js +14 -10
- package/dist/commands/pull-v4/generators/credential-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/data-component-generator.js +10 -12
- package/dist/commands/pull-v4/generators/data-component-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/environment-generator.js +11 -91
- package/dist/commands/pull-v4/generators/environment-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/external-agent-generator.js +22 -39
- package/dist/commands/pull-v4/generators/external-agent-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/function-tool-generator.js +19 -31
- package/dist/commands/pull-v4/generators/function-tool-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/mcp-tool-generator.js +30 -71
- package/dist/commands/pull-v4/generators/mcp-tool-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/project-generator.js +64 -31
- package/dist/commands/pull-v4/generators/project-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/skill-generator.js +4 -1
- package/dist/commands/pull-v4/generators/skill-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/status-component-generator.js +19 -19
- package/dist/commands/pull-v4/generators/status-component-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/sub-agent-generator.helpers.js +84 -0
- package/dist/commands/pull-v4/generators/sub-agent-generator.helpers.js.map +1 -0
- package/dist/commands/pull-v4/generators/sub-agent-generator.js +82 -113
- package/dist/commands/pull-v4/generators/sub-agent-generator.js.map +1 -0
- package/dist/commands/pull-v4/generators/trigger-generator.js +21 -30
- package/dist/commands/pull-v4/generators/trigger-generator.js.map +1 -0
- package/dist/commands/pull-v4/introspect/demo-project.js +1616 -0
- package/dist/commands/pull-v4/introspect/demo-project.js.map +1 -0
- package/dist/commands/pull-v4/introspect/index.js +17 -16
- package/dist/commands/pull-v4/introspect/index.js.map +1 -0
- package/dist/commands/pull-v4/introspect/test-helpers.js +5 -3
- package/dist/commands/pull-v4/introspect/test-helpers.js.map +1 -0
- package/dist/commands/pull-v4/introspect-generator.js +606 -93
- package/dist/commands/pull-v4/introspect-generator.js.map +1 -0
- package/dist/commands/pull-v4/module-merge.js +2 -1
- package/dist/commands/pull-v4/module-merge.js.map +1 -0
- package/dist/commands/pull-v4/scheduled-trigger-generator.js +16 -17
- package/dist/commands/pull-v4/scheduled-trigger-generator.js.map +1 -0
- package/dist/commands/pull-v4/utils.js +90 -28
- package/dist/commands/pull-v4/utils.js.map +1 -0
- package/dist/commands/push.js +2 -1
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/status.js +2 -1
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/update.js +2 -1
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/whoami.js +2 -1
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -0
- package/dist/env.js +2 -1
- package/dist/env.js.map +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/instrumentation.js +2 -1
- package/dist/instrumentation.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/css.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/css.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/json.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/json.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/line.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/line.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/word.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/word.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/patch/create.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/patch/create.js.map +1 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/util/string.js +2 -1
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/util/string.js.map +1 -0
- package/dist/utils/background-version-check.js +2 -1
- package/dist/utils/background-version-check.js.map +1 -0
- package/dist/utils/ci-environment.js +2 -1
- package/dist/utils/ci-environment.js.map +1 -0
- package/dist/utils/cli-pipeline.js +2 -1
- package/dist/utils/cli-pipeline.js.map +1 -0
- package/dist/utils/config.js +2 -1
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/credentials.js +2 -1
- package/dist/utils/credentials.js.map +1 -0
- package/dist/utils/environment-loader.js +2 -1
- package/dist/utils/environment-loader.js.map +1 -0
- package/dist/utils/file-finder.js +2 -1
- package/dist/utils/file-finder.js.map +1 -0
- package/dist/utils/json-comparator.js +2 -1
- package/dist/utils/json-comparator.js.map +1 -0
- package/dist/utils/json-comparison.js +2 -1
- package/dist/utils/json-comparison.js.map +1 -0
- package/dist/utils/mcp-runner.js +2 -1
- package/dist/utils/mcp-runner.js.map +1 -0
- package/dist/utils/model-config.js +2 -1
- package/dist/utils/model-config.js.map +1 -0
- package/dist/utils/package-manager.js +2 -1
- package/dist/utils/package-manager.js.map +1 -0
- package/dist/utils/profile-config.js +2 -1
- package/dist/utils/profile-config.js.map +1 -0
- package/dist/utils/profiles/profile-manager.js +2 -1
- package/dist/utils/profiles/profile-manager.js.map +1 -0
- package/dist/utils/profiles/types.js +2 -1
- package/dist/utils/profiles/types.js.map +1 -0
- package/dist/utils/project-directory.js +2 -1
- package/dist/utils/project-directory.js.map +1 -0
- package/dist/utils/project-loader.js +2 -1
- package/dist/utils/project-loader.js.map +1 -0
- package/dist/utils/schema-introspection.js +2 -1
- package/dist/utils/schema-introspection.js.map +1 -0
- package/dist/utils/templates.js +2 -1
- package/dist/utils/templates.js.map +1 -0
- package/dist/utils/tsx-loader.js +2 -1
- package/dist/utils/tsx-loader.js.map +1 -0
- package/dist/utils/version-check.js +2 -1
- package/dist/utils/version-check.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-config.js","names":[],"sources":["../../src/utils/profile-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport dotenv from 'dotenv';\nimport { getCredentialExpiryInfo, loadCredentials } from './credentials';\nimport { LOCAL_REMOTE, ProfileManager, type ResolvedProfile } from './profiles';\n\nexport interface ProfileConfig {\n profileName: string;\n tenantId?: string;\n agentsApiUrl: string;\n manageUiUrl: string;\n environment: string;\n credentialKey: string;\n accessToken?: string;\n isAuthenticated: boolean;\n authExpiry?: string;\n}\n\nexport interface ProfileConfigOptions {\n profileName?: string;\n quiet?: boolean;\n projectDir?: string;\n}\n\nexport async function resolveProfileConfig(\n options: ProfileConfigOptions = {}\n): Promise<ProfileConfig> {\n const profileManager = new ProfileManager();\n let profile: ResolvedProfile;\n let profileName: string;\n\n try {\n if (options.profileName) {\n const foundProfile = profileManager.getProfile(options.profileName);\n if (!foundProfile) {\n console.error(chalk.red(`Profile '${options.profileName}' not found.`));\n console.log(chalk.gray('Run \"inkeep profile list\" to see available profiles.'));\n process.exit(1);\n }\n profile = foundProfile;\n profileName = options.profileName;\n } else {\n profile = profileManager.getActiveProfile();\n profileName = profile.name;\n }\n } catch {\n // No profile configured - return defaults for backward compatibility\n return {\n profileName: 'default',\n agentsApiUrl: LOCAL_REMOTE.api,\n manageUiUrl: LOCAL_REMOTE.manageUi,\n environment: 'development',\n credentialKey: 'auth-credentials',\n isAuthenticated: false,\n };\n }\n\n // Load credentials for this profile\n const credentials = await loadCredentials(profile.credential);\n let accessToken: string | undefined;\n let isAuthenticated = false;\n let authExpiry: string | undefined;\n\n if (credentials) {\n const expiryInfo = getCredentialExpiryInfo(credentials);\n if (!expiryInfo.isExpired) {\n accessToken = credentials.accessToken;\n isAuthenticated = true;\n authExpiry = expiryInfo.expiresIn;\n }\n }\n\n // Load environment file if specified and project dir is available\n if (options.projectDir && profile.environment) {\n const envFile = join(options.projectDir, `.env.${profile.environment}`);\n if (existsSync(envFile)) {\n dotenv.config({ path: envFile });\n }\n }\n\n return {\n profileName,\n tenantId: credentials?.organizationId,\n agentsApiUrl: profile.remote.api,\n manageUiUrl: profile.remote.manageUi,\n environment: profile.environment,\n credentialKey: profile.credential,\n accessToken,\n isAuthenticated,\n authExpiry,\n };\n}\n\nexport function logProfileConfig(config: ProfileConfig, quiet: boolean = false): void {\n if (quiet) return;\n\n console.log(chalk.gray(`Using profile: ${chalk.cyan(config.profileName)}`));\n console.log(chalk.gray(` Remote: ${config.agentsApiUrl}`));\n console.log(chalk.gray(` Environment: ${config.environment}`));\n\n if (config.isAuthenticated) {\n const expiryText = config.authExpiry ? ` (expires in ${config.authExpiry})` : '';\n console.log(chalk.gray(` Auth: ${chalk.green('authenticated')}${expiryText}`));\n } else {\n console.log(chalk.gray(` Auth: ${chalk.yellow('not authenticated')}`));\n }\n}\n\nexport function getAuthHeaders(config: ProfileConfig): Record<string, string> {\n const headers: Record<string, string> = {};\n\n if (config.accessToken) {\n headers.Authorization = `Bearer ${config.accessToken}`;\n }\n\n return headers;\n}\n"],"mappings":";;;;;;;;;;AAyBA,eAAsB,qBACpB,UAAgC,EAAE,EACV;CACxB,MAAM,iBAAiB,IAAI,gBAAgB;CAC3C,IAAI;CACJ,IAAI;AAEJ,KAAI;AACF,M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iBAAiB;EAC1B,MAAM,aAAa,OAAO,aAAa,gBAAgB,OAAO,WAAW,KAAK;AAC9E,UAAQ,IAAI,MAAM,KAAK,WAAW,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;OAE/E,SAAQ,IAAI,MAAM,KAAK,WAAW,MAAM,OAAO,oBAAoB,GAAG,CAAC;;AAI3E,SAAgB,eAAe,QAA+C;CAC5E,MAAM,UAAkC,EAAE;AAE1C,KAAI,OAAO,YACT,SAAQ,gBAAgB,UAAU,OAAO;AAG3C,QAAO"}
|
|
@@ -216,4 +216,5 @@ var ProfileManager = class {
|
|
|
216
216
|
const profileManager = new ProfileManager();
|
|
217
217
|
|
|
218
218
|
//#endregion
|
|
219
|
-
export { ProfileError, ProfileManager, profileManager };
|
|
219
|
+
export { ProfileError, ProfileManager, profileManager };
|
|
220
|
+
//# sourceMappingURL=profile-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-manager.js","names":[],"sources":["../../../src/utils/profiles/profile-manager.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';\nimport { homedir, tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport { getLogger } from '@inkeep/agents-core';\nimport * as yaml from 'yaml';\nimport type { ZodError } from 'zod';\nimport {\n CLOUD_REMOTE,\n DEFAULT_PROFILES_CONFIG,\n type Profile,\n type ProfilesConfig,\n profileNameSchema,\n profilesConfigSchema,\n type ResolvedProfile,\n type ResolvedRemoteUrls,\n} from './types';\n\nconst logger = getLogger('profile-manager');\n\n/**\n * Error thrown when profile operations fail\n */\nexport class ProfileError extends Error {\n constructor(\n message: string,\n public readonly code:\n | 'FILE_NOT_FOUND'\n | 'PARSE_ERROR'\n | 'VALIDATION_ERROR'\n | 'PROFILE_NOT_FOUND'\n | 'PROFILE_EXISTS'\n | 'ACTIVE_PROFILE_DELETE'\n | 'WRITE_ERROR'\n ) {\n super(message);\n this.name = 'ProfileError';\n }\n}\n\n/**\n * Format Zod errors into a human-readable message\n * Compatible with both Zod v3 (errors) and Zod v4 (issues)\n */\nfunction formatZodErrors(error: ZodError): string {\n // Zod v4 uses 'issues', v3 uses 'errors'\n const issues = (error as any).issues ?? (error as any).errors ?? [];\n if (!Array.isArray(issues) || issues.length === 0) {\n return error.message || 'Validation failed';\n }\n return issues\n .map((err: { path?: (string | number)[]; message?: string }) => {\n const path = err.path && err.path.length > 0 ? `at '${err.path.join('.')}'` : '';\n return `${path}: ${err.message || 'Invalid value'}`.trim();\n })\n .join('\\n ');\n}\n\n/**\n * ProfileManager - handles loading, saving, and managing CLI profiles\n *\n * Profiles are stored in ~/.inkeep/profiles.yaml and allow users to switch\n * between different Inkeep deployments (cloud, local, self-hosted).\n */\nexport class ProfileManager {\n private profilesDir: string;\n private profilesPath: string;\n\n constructor(options?: { profilesDir?: string }) {\n this.profilesDir = options?.profilesDir ?? join(homedir(), '.inkeep');\n this.profilesPath = join(this.profilesDir, 'profiles.yaml');\n }\n\n /**\n * Get the path to the profiles.yaml file\n * Creates the ~/.inkeep directory if it doesn't exist\n */\n getProfilePath(): string {\n if (!existsSync(this.profilesDir)) {\n logger.info({ dir: this.profilesDir }, 'Creating profiles directory');\n mkdirSync(this.profilesDir, { recursive: true });\n }\n return this.profilesPath;\n }\n\n /**\n * Check if the profiles file exists\n */\n profilesFileExists(): boolean {\n return existsSync(this.profilesPath);\n }\n\n /**\n * Load and validate profiles from YAML file\n * Creates default config if file doesn't exist\n */\n loadProfiles(): ProfilesConfig {\n const profilePath = this.getProfilePath();\n\n if (!existsSync(profilePath)) {\n logger.info({}, 'Profiles file not found, creating default');\n this.saveProfiles(DEFAULT_PROFILES_CONFIG);\n return DEFAULT_PROFILES_CONFIG;\n }\n\n let content: string;\n try {\n content = readFileSync(profilePath, 'utf-8');\n } catch (error) {\n throw new ProfileError(\n `Failed to read profiles file: ${profilePath}\\n${error instanceof Error ? error.message : String(error)}`,\n 'FILE_NOT_FOUND'\n );\n }\n\n let parsed: unknown;\n try {\n parsed = yaml.parse(content);\n } catch (error) {\n throw new ProfileError(\n `Failed to parse profiles.yaml: ${error instanceof Error ? error.message : String(error)}`,\n 'PARSE_ERROR'\n );\n }\n\n const result = profilesConfigSchema.safeParse(parsed);\n if (!result.success) {\n throw new ProfileError(\n `Invalid profiles.yaml:\\n ${formatZodErrors(result.error)}`,\n 'VALIDATION_ERROR'\n );\n }\n\n const config = result.data;\n\n // Validate that activeProfile exists in profiles\n if (!config.profiles[config.activeProfile]) {\n throw new ProfileError(\n `Active profile '${config.activeProfile}' does not exist in profiles`,\n 'VALIDATION_ERROR'\n );\n }\n\n logger.info({ activeProfile: config.activeProfile }, 'Profiles loaded');\n return config;\n }\n\n /**\n * Save profiles to YAML file atomically (write to temp, then rename)\n */\n saveProfiles(profiles: ProfilesConfig): void {\n // Validate before saving\n const result = profilesConfigSchema.safeParse(profiles);\n if (!result.success) {\n throw new ProfileError(\n `Invalid profiles configuration:\\n ${formatZodErrors(result.error)}`,\n 'VALIDATION_ERROR'\n );\n }\n\n // Validate activeProfile exists\n if (!profiles.profiles[profiles.activeProfile]) {\n throw new ProfileError(\n `Active profile '${profiles.activeProfile}' does not exist in profiles`,\n 'VALIDATION_ERROR'\n );\n }\n\n const profilePath = this.getProfilePath();\n const tempPath = join(tmpdir(), `inkeep-profiles-${Date.now()}.yaml`);\n\n const yamlContent = yaml.stringify(profiles, {\n indent: 2,\n lineWidth: 0, // Don't wrap lines\n });\n\n try {\n // Write to temp file first\n writeFileSync(tempPath, yamlContent, 'utf-8');\n\n // Atomic rename\n renameSync(tempPath, profilePath);\n\n logger.info({ path: profilePath }, 'Profiles saved');\n } catch (error) {\n // Clean up temp file if it exists\n try {\n if (existsSync(tempPath)) {\n require('node:fs').unlinkSync(tempPath);\n }\n } catch {\n // Ignore cleanup errors\n }\n\n throw new ProfileError(\n `Failed to save profiles: ${error instanceof Error ? error.message : String(error)}`,\n 'WRITE_ERROR'\n );\n }\n }\n\n /**\n * Get the currently active profile configuration\n */\n getActiveProfile(): ResolvedProfile {\n const config = this.loadProfiles();\n const profileName = config.activeProfile;\n const profile = config.profiles[profileName];\n\n if (!profile) {\n throw new ProfileError(\n `Active profile '${profileName}' not found in profiles`,\n 'PROFILE_NOT_FOUND'\n );\n }\n\n return {\n name: profileName,\n remote: this.resolveRemoteUrls(profile),\n credential: profile.credential,\n environment: profile.environment,\n };\n }\n\n /**\n * Resolve remote URLs from profile configuration\n * If remote is 'cloud', returns baked-in cloud URLs\n * Otherwise returns the explicit URLs\n */\n resolveRemoteUrls(profile: Profile): ResolvedRemoteUrls {\n if (profile.remote === 'cloud') {\n return { ...CLOUD_REMOTE };\n }\n return { ...profile.remote };\n }\n\n /**\n * Get a specific profile by name\n */\n getProfile(name: string): ResolvedProfile | null {\n const config = this.loadProfiles();\n const profile = config.profiles[name];\n\n if (!profile) {\n return null;\n }\n\n return {\n name,\n remote: this.resolveRemoteUrls(profile),\n credential: profile.credential,\n environment: profile.environment,\n };\n }\n\n /**\n * List all profiles with their resolved URLs\n */\n listProfiles(): { profiles: ResolvedProfile[]; activeProfile: string } {\n const config = this.loadProfiles();\n const profiles = Object.entries(config.profiles).map(([name, profile]) => ({\n name,\n remote: this.resolveRemoteUrls(profile),\n credential: profile.credential,\n environment: profile.environment,\n }));\n\n return {\n profiles,\n activeProfile: config.activeProfile,\n };\n }\n\n /**\n * Add a new profile\n */\n addProfile(name: string, profile: Profile): void {\n // Validate profile name\n const nameResult = profileNameSchema.safeParse(name);\n if (!nameResult.success) {\n throw new ProfileError(\n `Invalid profile name: ${formatZodErrors(nameResult.error)}`,\n 'VALIDATION_ERROR'\n );\n }\n\n const config = this.loadProfiles();\n\n if (config.profiles[name]) {\n throw new ProfileError(`Profile '${name}' already exists`, 'PROFILE_EXISTS');\n }\n\n config.profiles[name] = profile;\n this.saveProfiles(config);\n\n logger.info({ name }, 'Profile added');\n }\n\n /**\n * Set the active profile\n */\n setActiveProfile(name: string): void {\n const config = this.loadProfiles();\n\n if (!config.profiles[name]) {\n throw new ProfileError(`Profile '${name}' does not exist`, 'PROFILE_NOT_FOUND');\n }\n\n config.activeProfile = name;\n this.saveProfiles(config);\n\n logger.info({ name }, 'Active profile set');\n }\n\n /**\n * Remove a profile\n * Cannot remove the currently active profile\n */\n removeProfile(name: string): void {\n const config = this.loadProfiles();\n\n if (!config.profiles[name]) {\n throw new ProfileError(`Profile '${name}' does not exist`, 'PROFILE_NOT_FOUND');\n }\n\n if (config.activeProfile === name) {\n throw new ProfileError(\n `Cannot remove active profile '${name}'. Switch to a different profile first.`,\n 'ACTIVE_PROFILE_DELETE'\n );\n }\n\n delete config.profiles[name];\n this.saveProfiles(config);\n\n logger.info({ name }, 'Profile removed');\n }\n\n /**\n * Check if a credential reference exists in the keychain\n * Returns true if it exists, false otherwise\n * This is a warning check - missing credentials don't block operations\n */\n async checkCredentialExists(credentialRef: string): Promise<boolean> {\n try {\n const { KeyChainStore } = await import('@inkeep/agents-core/credential-stores');\n const store = new KeyChainStore('auth', 'inkeep-cli');\n const value = await store.get(credentialRef);\n return value !== null;\n } catch {\n // If keychain is not available, assume credential might be set later\n return false;\n }\n }\n}\n\n// Export singleton instance for convenience\nexport const profileManager: ProfileManager = new ProfileManager();\n"],"mappings":";;;;;;;;;AAiBA,MAAM,SAAS,UAAU,kBAAkB;;;;AAK3C,IAAa,eAAb,cAAkC,MAAM;CACtC,YACE,SACA,AAAgB,MAQhB;AACA,QAAM,QAAQ;EATE;AAUhB,OAAK,OAAO;;;;;;;AAQhB,SAAS,gBAAgB,OAAyB;CAEhD,MAAM,SAAU,MAAc,UAAW,MAAc,UAAU,EAAE;AACnE,KAAI,CAAC,MAAM,QAAQ,OAAO,IAAI,OAAO,WAAW,EAC9C,QAAO,MAAM,WAAW;AAE1B,QAAO,OACJ,KAAK,QAA0D;AAE9D,SAAO,GADM,IAAI,QAAQ,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,GAC/D,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K,EAAE,MAAM,EAAE,kBAAkB;;;;;;;CAQ1C,MAAM,sBAAsB,eAAyC;AACnE,MAAI;GACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAGvC,UADc,MADA,IAAI,cAAc,QAAQ,aAAa,CAC3B,IAAI,cAAc,KAC3B;UACX;AAEN,UAAO;;;;AAMb,MAAa,iBAAiC,IAAI,gBAAgB"}
|
|
@@ -64,4 +64,5 @@ const LOCAL_REMOTE = {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
|
-
export { CLOUD_REMOTE, DEFAULT_CLOUD_PROFILE, DEFAULT_PROFILES_CONFIG, LOCAL_REMOTE, explicitRemoteSchema, profileNameSchema, profileSchema, profilesConfigSchema, remoteSchema };
|
|
67
|
+
export { CLOUD_REMOTE, DEFAULT_CLOUD_PROFILE, DEFAULT_PROFILES_CONFIG, LOCAL_REMOTE, explicitRemoteSchema, profileNameSchema, profileSchema, profilesConfigSchema, remoteSchema };
|
|
68
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/profiles/types.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Baked-in URLs for Inkeep Cloud deployment\n */\nexport const CLOUD_REMOTE = {\n api: 'https://api.agents.inkeep.com',\n manageUi: 'https://app.inkeep.com',\n} as const;\n\n/**\n * Schema for explicit remote URLs (custom/local deployments)\n */\nexport const explicitRemoteSchema: z.ZodType<ExplicitRemote> = z.object({\n api: z.string().url('api must be a valid URL'),\n manageUi: z.string().url('manageUi must be a valid URL'),\n});\n\n/**\n * Schema for remote configuration - either 'cloud' shorthand or explicit URLs\n */\nexport const remoteSchema: z.ZodType<RemoteConfig> = z.union([\n z.literal('cloud'),\n explicitRemoteSchema,\n]);\n\n/**\n * Profile name validation - alphanumeric + hyphens only\n */\nexport const profileNameSchema: z.ZodType<string> = z\n .string()\n .min(1, 'Profile name cannot be empty')\n .max(64, 'Profile name too long (max 64 characters)')\n .regex(/^[a-z0-9-]+$/, 'Profile name must be lowercase alphanumeric with hyphens only');\n\n/**\n * Schema for a single profile configuration\n */\nexport const profileSchema: z.ZodType<Profile> = z.object({\n remote: remoteSchema,\n credential: z.string().min(1, 'Credential reference cannot be empty'),\n environment: z.string().min(1, 'Environment cannot be empty'),\n});\n\n/**\n * Schema for the entire profiles.yaml configuration\n * Note: We use z.record(z.string(), profileSchema) for Zod v4 compatibility\n * Profile name validation is done separately in addProfile\n */\nexport const profilesConfigSchema: z.ZodType<ProfilesConfig> = z.object({\n activeProfile: z.string().min(1, 'activeProfile cannot be empty'),\n profiles: z.record(z.string(), profileSchema),\n});\n\n/**\n * Explicit remote URLs type\n */\nexport interface ExplicitRemote {\n api: string;\n manageUi: string;\n}\n\n/**\n * Remote configuration type - either 'cloud' or explicit URLs\n */\nexport type RemoteConfig = 'cloud' | ExplicitRemote;\n\n/**\n * Single profile configuration type\n */\nexport interface Profile {\n remote: RemoteConfig;\n credential: string;\n environment: string;\n}\n\n/**\n * Full profiles configuration type\n */\nexport interface ProfilesConfig {\n activeProfile: string;\n profiles: Record<string, Profile>;\n}\n\n/**\n * Resolved remote URLs - always explicit, never 'cloud'\n */\nexport interface ResolvedRemoteUrls {\n api: string;\n manageUi: string;\n}\n\n/**\n * Profile with resolved URLs for easy consumption\n */\nexport interface ResolvedProfile {\n name: string;\n remote: ResolvedRemoteUrls;\n credential: string;\n environment: string;\n}\n\n/**\n * Default cloud profile configuration\n */\nexport const DEFAULT_CLOUD_PROFILE: Profile = {\n remote: 'cloud',\n credential: 'inkeep-cloud',\n environment: 'production',\n};\n\n/**\n * Default profiles.yaml content when creating for the first time\n */\nexport const DEFAULT_PROFILES_CONFIG: ProfilesConfig = {\n activeProfile: 'cloud',\n profiles: {\n cloud: DEFAULT_CLOUD_PROFILE,\n },\n};\n\n/**\n * Baked-in URLs for local development deployment\n */\nexport const LOCAL_REMOTE = {\n api: 'http://localhost:3002',\n manageUi: 'http://localhost:3000',\n} as const;\n"],"mappings":";;;;;;AAKA,MAAa,eAAe;CAC1B,KAAK;CACL,UAAU;CACX;;;;AAKD,MAAa,uBAAkD,EAAE,OAAO;CACtE,KAAK,EAAE,QAAQ,CAAC,IAAI,0BAA0B;CAC9C,UAAU,EAAE,QAAQ,CAAC,IAAI,+BAA+B;CACzD,CAAC;;;;AAKF,MAAa,eAAwC,EAAE,MAAM,CAC3D,EAAE,QAAQ,QAAQ,EAClB,qBACD,CAAC;;;;AAKF,MAAa,oBAAuC,EACjD,QAAQ,CACR,IAAI,GAAG,+BAA+B,CACtC,IAAI,IAAI,4CAA4C,CACpD,MAAM,gBAAgB,gEAAgE;;;;AAKzF,MAAa,gBAAoC,EAAE,OAAO;CACxD,QAAQ;CACR,YAAY,EAAE,QAAQ,CAAC,IAAI,GAAG,uCAAuC;CACrE,aAAa,EAAE,QAAQ,CAAC,IAAI,GAAG,8BAA8B;CAC9D,CAAC;;;;;;AAOF,MAAa,uBAAkD,EAAE,OAAO;CACtE,eAAe,EAAE,QAAQ,CAAC,IAAI,GAAG,gCAAgC;CACjE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc;CAC9C,CAAC;;;;AAqDF,MAAa,wBAAiC;CAC5C,QAAQ;CACR,YAAY;CACZ,aAAa;CACd;;;;AAKD,MAAa,0BAA0C;CACrD,eAAe;CACf,UAAU,EACR,OAAO,uBACR;CACF;;;;AAKD,MAAa,eAAe;CAC1B,KAAK;CACL,UAAU;CACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-directory.js","names":[],"sources":["../../src/utils/project-directory.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { findUp } from 'find-up';\n\n/**\n * Find project directory by looking for inkeep.config.ts\n * @param projectId - Optional project ID or path to look for\n * @param configPath - Optional specific config file path to use\n * @returns Path to project directory or null if not found\n */\nexport async function findProjectDirectory(\n projectId?: string,\n configPath?: string\n): Promise<string | null> {\n // If a specific config path is provided, use its directory\n if (configPath) {\n const absoluteConfigPath = resolve(process.cwd(), configPath);\n if (existsSync(absoluteConfigPath)) {\n return resolve(absoluteConfigPath, '..');\n }\n }\n\n if (projectId) {\n // Check if projectId is a path\n if (projectId.includes('/') || projectId.includes('\\\\')) {\n const projectPath = resolve(process.cwd(), projectId);\n if (existsSync(join(projectPath, 'inkeep.config.ts'))) {\n return projectPath;\n }\n } else {\n // Look for directory with projectId name in current directory\n const projectPath = join(process.cwd(), projectId);\n if (existsSync(join(projectPath, 'inkeep.config.ts'))) {\n return projectPath;\n }\n }\n return null;\n }\n\n // Use find-up to look for inkeep.config.ts starting from current directory\n const foundConfigPath = await findUp('inkeep.config.ts');\n\n if (foundConfigPath) {\n // Return the directory containing the config file\n return resolve(foundConfigPath, '..');\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;AAUA,eAAsB,qBACpB,WACA,YACwB;AAExB,KAAI,YAAY;EACd,MAAM,qBAAqB,QAAQ,QAAQ,KAAK,EAAE,WAAW;AAC7D,MAAI,WAAW,mBAAmB,CAChC,QAAO,QAAQ,oBAAoB,KAAK;;AAI5C,KAAI,WAAW;AAEb,MAAI,UAAU,SAAS,IAAI,IAAI,UAAU,SAAS,KAAK,EAAE;GACvD,MAAM,cAAc,QAAQ,QAAQ,KAAK,EAAE,UAAU;AACrD,OAAI,WAAW,KAAK,aAAa,mBAAmB,CAAC,CACnD,QAAO;SAEJ;GAEL,MAAM,cAAc,KAAK,QAAQ,KAAK,EAAE,UAAU;AAClD,OAAI,WAAW,KAAK,aAAa,mBAAmB,CAAC,CACnD,QAAO;;AAGX,SAAO;;CAIT,MAAM,kBAAkB,MAAM,OAAO,mBAAmB;AAExD,KAAI,gBAEF,QAAO,QAAQ,iBAAiB,KAAK;AAGvC,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-loader.js","names":[],"sources":["../../src/utils/project-loader.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { Project } from '@inkeep/agents-sdk';\nimport { importWithTypeScriptSupport } from './tsx-loader';\n\n/**\n * Load and validate project from index.ts\n *\n * This utility is shared between push and pull commands to ensure\n * consistent project loading behavior across the CLI.\n *\n * @param projectDir - The directory containing the index.ts file\n * @returns The loaded Project instance\n * @throws Error if index.ts not found or no valid project export found\n */\nexport async function loadProject(projectDir: string): Promise<Project> {\n const indexPath = join(projectDir, 'index.ts');\n\n if (!existsSync(indexPath)) {\n throw new Error(`index.ts not found in project directory: ${projectDir}`);\n }\n\n // Import the module with TypeScript support\n const module = await importWithTypeScriptSupport(indexPath);\n\n // Find the first export with __type = \"project\"\n const exports = Object.keys(module);\n for (const exportKey of exports) {\n const value = module[exportKey];\n if (value && typeof value === 'object' && value.__type === 'project') {\n return value as Project;\n }\n }\n\n throw new Error(\n 'No project export found in index.ts. Expected an export with __type = \"project\"'\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,eAAsB,YAAY,YAAsC;CACtE,MAAM,YAAY,KAAK,YAAY,WAAW;AAE9C,KAAI,CAAC,WAAW,UAAU,CACxB,OAAM,IAAI,MAAM,4CAA4C,aAAa;CAI3E,MAAM,SAAS,MAAM,4BAA4B,UAAU;CAG3D,MAAM,UAAU,OAAO,KAAK,OAAO;AACnC,MAAK,MAAM,aAAa,SAAS;EAC/B,MAAM,QAAQ,OAAO;AACrB,MAAI,SAAS,OAAO,UAAU,YAAY,MAAM,WAAW,UACzD,QAAO;;AAIX,OAAM,IAAI,MACR,oFACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-introspection.js","names":[],"sources":["../../src/utils/schema-introspection.ts"],"sourcesContent":["/**\n * Schema Introspection Utilities\n *\n * Utilities to extract required fields and other metadata from Zod schemas.\n * This ensures CLI generators stay in sync with the actual validation schemas.\n */\n\nimport { z } from 'zod';\n\n/**\n * Simple utility to get required fields by attempting validation with empty object\n * and analyzing which fields are reported as missing\n */\nfunction getRequiredFieldsFromValidation(schema: z.ZodType): string[] {\n try {\n // Try to parse an empty object to see what's required\n schema.parse({});\n return []; // If it passes, nothing is required\n } catch (error) {\n if (error instanceof z.ZodError) {\n // Extract field names from validation errors\n return error.issues\n .filter((err: z.ZodIssue) => err.code === 'invalid_type' && err.expected !== 'undefined')\n .map((err: z.ZodIssue) => err.path[0])\n .filter((field: any): field is string => typeof field === 'string')\n .filter((field: string, index: number, arr: string[]) => arr.indexOf(field) === index); // Remove duplicates\n }\n return [];\n }\n}\n\n/**\n * Extract required field names from a Zod object schema\n */\nexport function getRequiredFields(schema: z.ZodType): string[] {\n // Use validation-based approach - much simpler and more reliable\n return getRequiredFieldsFromValidation(schema);\n}\n\n/**\n * Get a human-readable summary of schema requirements\n */\nexport function getSchemaInfo(schema: z.ZodType): {\n requiredFields: string[];\n optionalFields: string[];\n allFields: string[];\n} {\n const requiredFields = getRequiredFields(schema);\n\n // Get all fields from the shape if available\n let allFields: string[] = [];\n\n if ('shape' in schema && schema.shape) {\n allFields = Object.keys(schema.shape);\n }\n\n const optionalFields = allFields.filter((field) => !requiredFields.includes(field));\n\n return { requiredFields, optionalFields, allFields };\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,gCAAgC,QAA6B;AACpE,KAAI;AAEF,SAAO,MAAM,EAAE,CAAC;AAChB,SAAO,EAAE;UACF,OAAO;AACd,MAAI,iBAAiB,EAAE,SAErB,QAAO,MAAM,OACV,QAAQ,QAAoB,IAAI,SAAS,kBAAkB,IAAI,aAAa,YAAY,CACxF,KAAK,QAAoB,IAAI,KAAK,GAAG,CACrC,QAAQ,UAAgC,OAAO,UAAU,SAAS,CAClE,QAAQ,OAAe,OAAe,QAAkB,IAAI,QAAQ,MAAM,KAAK,MAAM;AAE1F,SAAO,EAAE;;;;;;AAOb,SAAgB,kBAAkB,QAA6B;AAE7D,QAAO,gCAAgC,OAAO;;;;;AAMhD,SAAgB,cAAc,QAI5B;CACA,MAAM,iBAAiB,kBAAkB,OAAO;CAGhD,IAAI,YAAsB,EAAE;AAE5B,KAAI,WAAW,UAAU,OAAO,MAC9B,aAAY,OAAO,KAAK,OAAO,MAAM;AAKvC,QAAO;EAAE;EAAgB,gBAFF,UAAU,QAAQ,UAAU,CAAC,eAAe,SAAS,MAAM,CAAC;EAE1C;EAAW"}
|
package/dist/utils/templates.js
CHANGED
|
@@ -193,4 +193,5 @@ async function getAvailableTemplates(templatePath = "template-projects", local)
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
//#endregion
|
|
196
|
-
export { cloneTemplate, cloneTemplateLocal, getAvailableTemplates, replaceContentInFiles, replaceObjectProperties };
|
|
196
|
+
export { cloneTemplate, cloneTemplateLocal, getAvailableTemplates, replaceContentInFiles, replaceObjectProperties };
|
|
197
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","names":[],"sources":["../../src/utils/templates.ts"],"sourcesContent":["import path from 'node:path';\nimport degit from 'degit';\nimport fs from 'fs-extra';\n\nexport interface ContentReplacement {\n /** Relative file path within the cloned template */\n filePath: string;\n /** Object property replacements - key is the property path, value is the replacement content */\n replacements: Record<string, any>;\n}\n\n//Duplicating function here so we dont have to add a dependency on the agents-cli package\nexport async function cloneTemplate(\n templatePath: string,\n targetPath: string,\n replacements?: ContentReplacement[]\n): Promise<void> {\n await fs.mkdir(targetPath, { recursive: true });\n\n const templatePathSuffix = templatePath.replace('https://github.com/', '');\n const emitter = degit(templatePathSuffix);\n try {\n await emitter.clone(targetPath);\n\n // Apply content replacements if provided\n if (replacements && replacements.length > 0) {\n await replaceContentInFiles(targetPath, replacements);\n }\n } catch (error) {\n console.log(`❌ Error cloning template: ${error}`);\n process.exit(1);\n }\n}\n\nexport async function cloneTemplateLocal(\n templatePath: string,\n targetPath: string,\n replacements?: ContentReplacement[]\n): Promise<void> {\n await fs.mkdir(targetPath, { recursive: true });\n\n try {\n await fs.copy(templatePath, targetPath, {\n overwrite: true,\n errorOnExist: false,\n });\n\n if (replacements?.length) {\n await replaceContentInFiles(targetPath, replacements);\n }\n } catch (error) {\n console.error(`Failed to clone template from ${templatePath}:`, error);\n process.exit(1);\n }\n}\n\n/**\n * Replace content in cloned template files\n */\nexport async function replaceContentInFiles(\n targetPath: string,\n replacements: ContentReplacement[]\n): Promise<void> {\n for (const replacement of replacements) {\n const filePath = path.join(targetPath, replacement.filePath);\n\n // Check if file exists\n if (!(await fs.pathExists(filePath))) {\n console.warn(`Warning: File ${filePath} not found, skipping replacements`);\n continue;\n }\n\n // Read the file content\n const content = await fs.readFile(filePath, 'utf-8');\n\n // Apply replacements\n const updatedContent = await replaceObjectProperties(content, replacement.replacements);\n\n // Write back to file\n await fs.writeFile(filePath, updatedContent, 'utf-8');\n }\n}\n\n/**\n * Replace object properties in TypeScript code content\n */\nexport async function replaceObjectProperties(\n content: string,\n replacements: Record<string, any>\n): Promise<string> {\n let updatedContent = content;\n for (const [propertyPath, replacement] of Object.entries(replacements)) {\n updatedContent = replaceObjectProperty(updatedContent, propertyPath, replacement);\n }\n\n return updatedContent;\n}\n\n/**\n * Replace a specific object property in TypeScript code\n * This implementation uses line-by-line parsing for better accuracy\n * If the property doesn't exist, it will be added to the object\n */\nfunction replaceObjectProperty(content: string, propertyPath: string, replacement: any): string {\n // Check if this is a single-line object format first (object all on one line)\n const singleLineMatch = content.match(\n new RegExp(`^(.+{[^{}]*${propertyPath}\\\\s*:\\\\s*{[^{}]*}[^{}]*}.*)$`, 'm')\n );\n if (singleLineMatch) {\n // For single-line objects, handle replacement inline\n const singleLinePattern = new RegExp(`((^|\\\\s|{)${propertyPath}\\\\s*:\\\\s*)({[^}]*})`);\n return content.replace(\n singleLinePattern,\n `$1${JSON.stringify(replacement).replace(/\"/g, \"'\").replace(/:/g, ': ').replace(/,/g, ', ')}`\n );\n }\n\n // Convert replacement to formatted JSON string with proper indentation\n const replacementStr = JSON.stringify(replacement, null, 2).replace(/\"/g, \"'\"); // Use single quotes for consistency with TS\n\n const lines = content.split('\\n');\n const result: string[] = [];\n let inTargetProperty = false;\n let braceCount = 0;\n let targetPropertyIndent = '';\n let foundProperty = false;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const trimmedLine = line.trim();\n\n // Skip if we're currently inside the target property\n if (inTargetProperty) {\n // Count braces to track nesting\n for (const char of line) {\n if (char === '{') braceCount++;\n if (char === '}') braceCount--;\n }\n\n // When braceCount reaches 0, we've found the end of the property\n if (braceCount <= 0) {\n // Check if there's a trailing comma on this line or the original property line\n const hasTrailingComma =\n line.includes(',') ||\n (i + 1 < lines.length &&\n lines[i + 1].trim().startsWith('}') === false &&\n lines[i + 1].trim() !== '');\n\n // Add the replacement with proper indentation\n const indentedReplacement = replacementStr\n .split('\\n')\n .map((replacementLine, index) => {\n if (index === 0) {\n return `${targetPropertyIndent}${propertyPath}: ${replacementLine}`;\n }\n return `${targetPropertyIndent}${replacementLine}`;\n })\n .join('\\n');\n\n result.push(`${indentedReplacement}${hasTrailingComma ? ',' : ''}`);\n inTargetProperty = false;\n foundProperty = true;\n continue;\n }\n // Skip all lines while inside the target property\n continue;\n }\n\n // Check if this line contains the target property at the right level\n const propertyPattern = new RegExp(`(^|\\\\s+)${propertyPath}\\\\s*:`);\n if (trimmedLine.startsWith(`${propertyPath}:`) || propertyPattern.test(line)) {\n inTargetProperty = true;\n braceCount = 0;\n // For single-line objects, use base indentation plus 2 spaces for properties\n if (line.includes(' = { ')) {\n // Single-line format: use base indentation\n targetPropertyIndent = `${line.match(/^\\s*/)?.[0] || ''} `;\n } else {\n // Multi-line format: calculate from property position\n const propertyMatch = line.match(new RegExp(`(.*?)(^|\\\\s+)${propertyPath}\\\\s*:`));\n targetPropertyIndent = propertyMatch ? propertyMatch[1] : line.match(/^\\s*/)?.[0] || '';\n }\n\n // Count braces in the current line\n for (const char of line) {\n if (char === '{') braceCount++;\n if (char === '}') braceCount--;\n }\n\n // If the property definition is on a single line (braceCount = 0)\n if (braceCount <= 0) {\n const hasTrailingComma = line.includes(',');\n const indentedReplacement = replacementStr\n .split('\\n')\n .map((replacementLine, index) => {\n if (index === 0) {\n return `${targetPropertyIndent}${propertyPath}: ${replacementLine}`;\n }\n return `${targetPropertyIndent}${replacementLine}`;\n })\n .join('\\n');\n\n result.push(`${indentedReplacement}${hasTrailingComma ? ',' : ''}`);\n inTargetProperty = false;\n foundProperty = true;\n continue;\n }\n // Continue to next iteration to process multi-line property\n continue;\n }\n\n // If we're not in the target property, keep the line as-is\n result.push(line);\n }\n\n // If property wasn't found, try to inject it into the object\n if (!foundProperty) {\n return injectPropertyIntoObject(result.join('\\n'), propertyPath, replacement);\n }\n\n return result.join('\\n');\n}\n\n/**\n * Inject a new property into a TypeScript object when the property doesn't exist\n */\nfunction injectPropertyIntoObject(content: string, propertyPath: string, replacement: any): string {\n const replacementStr = JSON.stringify(replacement, null, 2).replace(/\"/g, \"'\"); // Use single quotes for consistency with TS\n\n const lines = content.split('\\n');\n const result: string[] = [];\n\n // Find the main object definition (looking for patterns like project({...})\n let foundObjectStart = false;\n let objectDepth = 0;\n let insertionPoint = -1;\n let baseIndent = '';\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const trimmedLine = line.trim();\n\n // Look for object patterns like \"project({\", \"= {\", etc.\n if (\n !foundObjectStart &&\n (trimmedLine.includes('({') || trimmedLine.endsWith(' = {') || line.includes(' = { '))\n ) {\n foundObjectStart = true;\n baseIndent = line.match(/^\\s*/)?.[0] || '';\n objectDepth = 0;\n\n // Count braces on this line\n for (const char of line) {\n if (char === '{') objectDepth++;\n if (char === '}') objectDepth--;\n }\n } else if (foundObjectStart) {\n // Track brace depth\n for (const char of line) {\n if (char === '{') objectDepth++;\n if (char === '}') objectDepth--;\n }\n\n // If we're at the end of the main object, this is our insertion point\n if (objectDepth === 0 && trimmedLine.startsWith('}')) {\n insertionPoint = i;\n break;\n }\n }\n }\n\n // If we found an insertion point, add the property\n if (insertionPoint !== -1) {\n const propertyIndent = `${baseIndent} `; // Add 2 spaces for property indent\n\n // Check if we need a comma before our property\n let needsCommaPrefix = false;\n if (insertionPoint > 0) {\n const prevLine = lines[insertionPoint - 1].trim();\n needsCommaPrefix = prevLine !== '' && !prevLine.endsWith(',') && !prevLine.startsWith('}');\n }\n\n // Format the property to inject\n const indentedReplacement = replacementStr\n .split('\\n')\n .map((replacementLine, index) => {\n if (index === 0) {\n return `${propertyIndent}${propertyPath}: ${replacementLine}`;\n }\n return `${propertyIndent}${replacementLine}`;\n })\n .join('\\n');\n\n // Insert the property before the closing brace\n for (let i = 0; i < lines.length; i++) {\n if (i === insertionPoint) {\n result.push(indentedReplacement);\n }\n\n // Add comma to previous line if needed and we're at the right position\n if (i === insertionPoint - 1 && needsCommaPrefix) {\n result.push(`${lines[i]},`);\n } else {\n result.push(lines[i]);\n }\n }\n\n return result.join('\\n');\n }\n\n // If we couldn't find a suitable injection point, warn and return original\n console.warn(`Could not inject property \"${propertyPath}\" - no suitable object found in content`);\n return content;\n}\n\nexport async function getAvailableTemplates(\n templatePath: string = 'template-projects',\n local: string | undefined\n): Promise<string[]> {\n // Fetch the list of templates from the repo\n\n if (local && local.length > 0) {\n const fullTemplatePath = path.join(local, templatePath);\n const items = await fs.readdir(fullTemplatePath);\n const directories = [];\n for (const item of items) {\n const stat = await fs.stat(path.join(fullTemplatePath, item));\n if (stat.isDirectory()) {\n directories.push(item);\n }\n }\n return directories;\n }\n\n const response = await fetch(\n `https://api.github.com/repos/inkeep/agents/contents/agents-cookbook/${templatePath}`\n );\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch templates. Please check your internet connection and try again.`\n );\n }\n\n let contents: any;\n try {\n contents = await response.json();\n } catch (error) {\n throw new Error(\n `Failed to parse templates response. Please check your internet connection and try again. ${error}`\n );\n }\n\n if (!Array.isArray(contents)) {\n throw new Error(\n 'Unexpected response format from templates. Please check your internet connection and try again'\n );\n }\n\n return contents.filter((item: any) => item.type === 'dir').map((item: any) => item.name);\n}\n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ACvD,MAAM,QAAQ,MAAM,GAAG,QAAQ,iBAAiB;EAChD,MAAM,cAAc,EAAE;AACtB,OAAK,MAAM,QAAQ,MAEjB,MADa,MAAM,GAAG,KAAK,KAAK,KAAK,kBAAkB,KAAK,CAAC,EACpD,aAAa,CACpB,aAAY,KAAK,KAAK;AAG1B,SAAO;;CAGT,MAAM,WAAW,MAAM,MACrB,uEAAuE,eACxE;AAED,KAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MACR,kFACD;CAGH,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,SAAS,MAAM;UACzB,OAAO;AACd,QAAM,IAAI,MACR,4FAA4F,QAC7F;;AAGH,KAAI,CAAC,MAAM,QAAQ,SAAS,CAC1B,OAAM,IAAI,MACR,iGACD;AAGH,QAAO,SAAS,QAAQ,SAAc,KAAK,SAAS,MAAM,CAAC,KAAK,SAAc,KAAK,KAAK"}
|
package/dist/utils/tsx-loader.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsx-loader.js","names":[],"sources":["../../src/utils/tsx-loader.ts"],"sourcesContent":["import { extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { register } from 'tsx/esm/api';\n\n/**\n * Dynamically imports a file with TypeScript support\n * Registers tsx loader for .ts files automatically\n */\nexport async function importWithTypeScriptSupport(filePath: string): Promise<any> {\n const ext = extname(filePath);\n\n // For TypeScript files, register tsx loader\n if (ext === '.ts') {\n try {\n const unregister = register();\n\n try {\n // Import the TypeScript file\n const fileUrl = pathToFileURL(filePath).href;\n const module = await import(fileUrl);\n return module;\n } finally {\n // Clean up the registration\n unregister();\n }\n } catch (error) {\n // Check if this is a tsx registration error vs a module execution error\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (\n errorMessage.includes('Dynamic require') ||\n errorMessage.includes('tsx') ||\n errorMessage.includes('register')\n ) {\n throw new Error(\n `Failed to load TypeScript file ${filePath}. ` +\n `Make sure tsx is installed: ${errorMessage}`\n );\n }\n\n // If it's not a tsx-related error, it's likely an error from the loaded module\n // Re-throw the original error to preserve the actual issue\n throw error;\n }\n }\n\n // For JavaScript files, import directly\n const fileUrl = pathToFileURL(filePath).href;\n return await import(fileUrl);\n}\n"],"mappings":";;;;;;;;;AAQA,eAAsB,4BAA4B,UAAgC;AAIhF,KAHY,QAAQ,SAAS,KAGjB,MACV,KAAI;EACF,MAAM,aAAa,UAAU;AAE7B,MAAI;AAIF,UADe,MAAM,OADL,cAAc,SAAS,CAAC;YAGhC;AAER,eAAY;;UAEP,OAAO;EAEd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAE3E,MACE,aAAa,SAAS,kBAAkB,IACxC,aAAa,SAAS,MAAM,IAC5B,aAAa,SAAS,WAAW,CAEjC,OAAM,IAAI,MACR,kCAAkC,SAAS,gCACV,eAClC;AAKH,QAAM;;AAMV,QAAO,MAAM,OADG,cAAc,SAAS,CAAC"}
|
|
@@ -67,4 +67,5 @@ async function checkForUpdate() {
|
|
|
67
67
|
const PACKAGE_CHANGELOG = "https://github.com/inkeep/agents/blob/main/agents-cli/CHANGELOG.md";
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
|
-
export { DEFAULT_PACKAGE_NAME, PACKAGE_CHANGELOG, PACKAGE_VERSION, checkForUpdate, compareVersions, getLatestVersion };
|
|
70
|
+
export { DEFAULT_PACKAGE_NAME, PACKAGE_CHANGELOG, PACKAGE_VERSION, checkForUpdate, compareVersions, getLatestVersion };
|
|
71
|
+
//# sourceMappingURL=version-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-check.js","names":["pkgJson.name","pkgJson.version"],"sources":["../../src/utils/version-check.ts"],"sourcesContent":["import pkgJson from '../../package.json' with { type: 'json' };\n\n/**\n * The default package name for version checks and updates\n */\nexport const DEFAULT_PACKAGE_NAME = pkgJson.name;\n\nexport interface VersionInfo {\n current: string;\n latest: string;\n needsUpdate: boolean;\n}\n\n/**\n * Get the current installed version from package.json\n */\nexport const PACKAGE_VERSION = pkgJson.version;\n\n/**\n * Fetch the latest version from npm registry\n */\nexport async function getLatestVersion(\n packageName: string = DEFAULT_PACKAGE_NAME\n): Promise<string> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000); // 10s timeout\n\n try {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {\n signal: controller.signal,\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch latest version: ${response.statusText}`);\n }\n const data = await response.json();\n return data.version;\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n throw new Error('Unable to check for updates: Request timed out after 10 seconds');\n }\n throw new Error(\n `Unable to check for updates: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n } finally {\n clearTimeout(timeoutId);\n }\n}\n\n/**\n * Compare two semver versions\n * Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n *\n * Note: This is a simplified semver comparison that handles basic major.minor.patch versions.\n * It does NOT handle pre-release versions (e.g., 1.0.0-beta.1) or build metadata (e.g., 1.0.0+build.1).\n * Pre-release tags and build metadata will be stripped before comparison.\n *\n * For the Inkeep CLI use case, this is sufficient as we only publish stable releases.\n */\nexport function compareVersions(v1: string, v2: string): number {\n // Strip pre-release and build metadata for comparison\n // Examples: \"1.0.0-beta.1\" -> \"1.0.0\", \"1.0.0+build.1\" -> \"1.0.0\"\n const cleanV1 = v1.split('-')[0].split('+')[0];\n const cleanV2 = v2.split('-')[0].split('+')[0];\n\n const parts1 = cleanV1.split('.').map(Number);\n const parts2 = cleanV2.split('.').map(Number);\n\n for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {\n const part1 = parts1[i] || 0;\n const part2 = parts2[i] || 0;\n\n if (part1 < part2) return -1;\n if (part1 > part2) return 1;\n }\n\n return 0;\n}\n\n/**\n * Check if an update is available\n */\nexport async function checkForUpdate(): Promise<VersionInfo> {\n const current = PACKAGE_VERSION;\n const latest = await getLatestVersion();\n const needsUpdate = compareVersions(current, latest) < 0;\n\n return {\n current,\n latest,\n needsUpdate,\n };\n}\n\n/**\n * Get the changelog URL for the package\n */\nexport const PACKAGE_CHANGELOG =\n 'https://github.com/inkeep/agents/blob/main/agents-cli/CHANGELOG.md';\n"],"mappings":";;;;;;AAKA,MAAa,uBAAuBA;;;;AAWpC,MAAa,kBAAkBC;;;;AAK/B,eAAsB,iBACpB,cAAsB,sBACL;CACjB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,YAAY,iBAAiB,WAAW,OAAO,EAAE,IAAM;AAE7D,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,8BAA8B,YAAY,UAAU,EAC/E,QAAQ,WAAW,QACpB,CAAC;AACF,MAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MAAM,mCAAmC,SAAS,aAAa;AAG3E,UADa,MAAM,SAAS,MAAM,EACtB;UACL,OAAO;AACd,MAAI,iBAAiB,SAAS,MAAM,SAAS,aAC3C,OAAM,IAAI,MAAM,kEAAkE;AAEpF,QAAM,IAAI,MACR,gCAAgC,iBAAiB,QAAQ,MAAM,UAAU,kBAC1E;WACO;AACR,eAAa,UAAU;;;;;;;;;;;;;AAc3B,SAAgB,gBAAgB,IAAY,IAAoB;CAG9D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC;CAC5C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC;CAE5C,MAAM,SAAS,QAAQ,MAAM,IAAI,CAAC,IAAI,OAAO;CAC7C,MAAM,SAAS,QAAQ,MAAM,IAAI,CAAC,IAAI,OAAO;AAE7C,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,OAAO,QAAQ,OAAO,OAAO,EAAE,KAAK;EAC/D,MAAM,QAAQ,OAAO,MAAM;EAC3B,MAAM,QAAQ,OAAO,MAAM;AAE3B,MAAI,QAAQ,MAAO,QAAO;AAC1B,MAAI,QAAQ,MAAO,QAAO;;AAG5B,QAAO;;;;;AAMT,eAAsB,iBAAuC;CAC3D,MAAM,UAAU;CAChB,MAAM,SAAS,MAAM,kBAAkB;AAGvC,QAAO;EACL;EACA;EACA,aALkB,gBAAgB,SAAS,OAAO,GAAG;EAMtD;;;;;AAMH,MAAa,oBACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.13",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"tsx": "^4.20.5",
|
|
38
38
|
"yaml": "^2.7.0",
|
|
39
39
|
"zod": "^4.3.6",
|
|
40
|
-
"@inkeep/agents-core": "^0.58.
|
|
41
|
-
"@inkeep/agents-sdk": "^0.58.
|
|
40
|
+
"@inkeep/agents-core": "^0.58.13",
|
|
41
|
+
"@inkeep/agents-sdk": "^0.58.13"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"diff": "^8.0.3",
|