p_sync: FileSyncer + CLI + Local File Usage#30
p_sync: FileSyncer + CLI + Local File Usage#30AlePouroullis wants to merge 24 commits intomasterfrom
Conversation
…pt idioms - Rename SyncClient to FileSyncer and update client options to match Python SDK - Add useLocalFiles, localFilesDirectory, and cacheSize options - Update pull method to return [successful, failed] arrays - Improve TypeScript terminology in docstrings (array vs tuple/list) - Fix type errors and error handling Makes the codebase more consistent with Python SDK while improving TypeScript idioms and type safety.
- Create new unified `overloadClient` function that handles both log and call methods - Simplify client initialization by directly overloading parent class instances - Replace SyncClient with direct FileSyncer instance for cleaner file handling - Standardize tracing context, local file handling, and evaluation context across all client types
| const LogType = { | ||
| SUCCESS: "\x1b[92m", // green | ||
| ERROR: "\x1b[91m", // red | ||
| INFO: "\x1b[96m", // cyan | ||
| WARN: "\x1b[93m", // yellow | ||
| RESET: "\x1b[0m", | ||
| } as const; | ||
|
|
||
| function log(message: string, type: keyof typeof LogType): void { | ||
| console.log(`${LogType[type]}${message}${LogType.RESET}`); | ||
| } |
| .description("Pull Prompt and Agent files from Humanloop to your local filesystem") | ||
| .addHelpText( | ||
| "after", | ||
| "\nThis command will:\n" + |
There was a problem hiding this comment.
Add a screnshot on PR conversation showing how the help menu is printed
| ): T { | ||
| const originalLog = client.log.bind(client); | ||
|
|
||
| const _overloadedLog = async ( |
There was a problem hiding this comment.
does typing work ok? think this guard was in place for a reason
| * For example, an invalid path format (absolute paths, leading/trailing slashes, etc.) | ||
| * or a file not being found. | ||
| */ | ||
| function handleLocalFiles<T extends LogRequestType>( |
There was a problem hiding this comment.
There's some similar logic in resolve File in eval.run(...). Modifying it now could take a while, but do add it in the Linear project for milestone 2
| // If file_type is already specified in request, prioritize user-provided value | ||
| if (fileType in request && typeof request[fileType as keyof T] !== "string") { | ||
| console.warn( | ||
| `Ignoring local file for \`${filePath}\` as ${fileType} parameters were directly provided. ` + |
| /** | ||
| * Normalize a path to the standard Humanloop API format. | ||
| * | ||
| * This function is primarily used when interacting with the Humanloop API to ensure paths |
There was a problem hiding this comment.
Why not use a standard library
https://nodejs.org/api/path.html#pathnormalizepath
| const LogType = { | ||
| DEBUG: "\x1b[90m", // gray | ||
| INFO: "\x1b[96m", // cyan | ||
| WARN: "\x1b[93m", // yellow | ||
| ERROR: "\x1b[91m", // red | ||
| RESET: "\x1b[0m", | ||
| } as const; |
There was a problem hiding this comment.
This can also go in the common logging module mentioned earlier
andreibratu
left a comment
There was a problem hiding this comment.
logic looks good - i think we can use libraries in two places + i have some questions
Command example output
npx humanloop --helpnpx humanloop pull --helpnpx humanloop pull