Commit Graph

18 Commits

Author SHA1 Message Date
Harry 4fa55bcdf5 feat: support tool references 2026-01-19 23:03:54 +08:00
Harry bf34c871bb feat: implement file upload 2026-01-13 18:01:54 +08:00
Harry 6b68394641 fix: enhance error reporting for non-200 API responses
- Improved error handling in the callDifyAPI function by reading the response body for non-200 status codes.
- This change ensures that error messages include the actual response content, providing better context for debugging.

This update enhances the clarity of error reporting during API interactions.
2026-01-12 20:20:44 +08:00
Harry b7c22eea22 fix: improve error handling for API responses in callDifyAPI
- Added a check for the API response status code in the callDifyAPI function to handle non-200 responses more effectively.
- Enhanced error reporting by including the status code and response body in the error message.

This update improves the robustness of API interactions by ensuring that errors are clearly communicated to the user.
2026-01-12 20:11:57 +08:00
Harry 69cb144fe0 feat: update CLI configuration and API request handling
- Updated the .dify_cli.json configuration to include cli_api_url, cli_api_session_id, and cli_api_secret for improved API interaction.
- Refactored the callDifyAPI and fetchProviders functions to utilize the new CLI API structure, including HMAC signature generation for enhanced security.
- Modified EnvConfig to reflect the new CLI API parameters, ensuring required fields are validated.

This update enhances the security and functionality of the CLI by transitioning to a new API structure and improving request handling.
2026-01-12 19:55:38 +08:00
Harry de24e0b2a9 refactor: update tool parameter handling and types
- Replaced references to plugin_entities and requests with the new types package for tool parameters and descriptions.
- Enhanced the structure of tool parameters and descriptions to include LLM descriptions and improved type definitions.
- Updated the .dify_cli.json configuration to reflect changes in session ID format for enhanced security.

This refactor improves code organization and type safety, streamlining the handling of tool parameters in the CLI.
2026-01-04 19:36:55 +08:00
Harry 10d34daa29 refactor: update configuration to use inner_api_session_id
- Replaced inner_api_key and user_id with inner_api_session_id in the .dify_cli.json configuration.
- Updated EnvConfig and related functions to reflect the new session-based authentication.
- Removed obsolete tenant_id and user_id fields from the configuration and API request handling.

This update enhances security by transitioning to session-based authentication and streamlining the configuration structure.
2026-01-04 16:23:40 +08:00
Harry 2bb1b2f521 feat: add pull command to fetch and save tools from Dify
- Introduced a new `pull` command that retrieves all available tools from the Dify platform and saves them to the `.dify_cli.json` configuration file.
- Implemented error handling for API requests and configuration saving to enhance reliability.
- Updated the command initialization to include the new `pull` command in the CLI structure.
- Enhanced the `EnvConfig` struct to include a `FilesURL` field for better tool management.

This update improves the CLI's functionality by allowing users to easily pull and manage tools from the Dify platform.
2026-01-02 15:42:10 +08:00
Harry 944defac2a feat: enhance argument handling in InvokeTool function
- Updated the argument check in the InvokeTool function to display help information when the first argument is either empty or a help flag ("--help" or "-h").
- This improvement ensures users receive guidance on tool usage when invoking without specific commands.

This update enhances user experience by providing immediate help options for the CLI tools.
2025-12-30 18:05:01 +08:00
Harry 4522bfc094 feat: improve tool help display in execute command
- Added a check for empty arguments in the InvokeTool function to display tool help when no arguments are provided.
- Refactored the printToolHelp function to PrintToolHelp for consistency in naming conventions.

This update enhances user experience by providing immediate help information when invoking tools without arguments.
2025-12-30 18:03:47 +08:00
Harry 7ca7940ea7 feat: streamline API response output in execute.go
- Replaced individual data type handling with a unified JSON output for API responses.
- Added error handling for JSON marshaling to ensure robust output.
- Enhanced logging to provide clearer context during tool execution.

This update improves the clarity and consistency of API interaction outputs in the CLI tool.
2025-12-30 17:18:47 +08:00
Harry 644aa5cc72 feat: enhance API call handling in execute.go
- Added error handling for API responses, including checks for nil data and specific error messages.
- Implemented a timeout for the HTTP client to improve reliability during long-running requests.
- Refactored response processing to handle various data types (text, JSON, file, blob, link) more effectively.

This update improves the robustness and clarity of API interactions within the CLI tool.
2025-12-30 17:10:10 +08:00
Harry 6e04ebb9da feat: add .dify_cli.json configuration file and enhance command initialization
- Introduced a new .dify_cli.json file to define environment variables and tool configurations.
- Updated command initialization to create symlinks for tools defined in the new configuration file.
- Improved error handling and output messages during symlink creation.
- Removed obsolete environment file and related loading functions to streamline configuration management.

This update enhances the CLI's flexibility and usability by allowing dynamic tool management through JSON configuration.
2025-12-30 16:49:57 +08:00
Harry 6527ddb0f2 refactor: introduce new json schema structure 2025-12-30 16:04:08 +08:00
Harry 8379d2673b refactor: separate tool schemas from env config
- Change schema format to flat {"tools": [...]} structure
- Add Provider field to EnvConfig for API calls
- Remove provider nesting, use simple ToolSchemas type
- Update FindTool to return only tool (no provider)
- Update all commands to use new structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:33:53 +08:00
Harry 066e5864e6 refactor: reuse daemon's http_requests and dify_invocation for API calls
- Add TenantID and UserID to EnvConfig
- Update config loading to parse TENANT_ID and USER_ID from env file
- Rewrite callDifyAPI to use daemon's http_requests.PostAndParseStream
- Use dify_invocation.InvokeToolRequest and tool_entities.ToolResponseChunk
- Update tests to verify new config fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:21:29 +08:00
Harry b0eaddfe60 fix: use positional arg for tool name in execute command
Change from `dify execute --tool name` to `dify execute name` to avoid
flag name conflicts with tool parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:13:16 +08:00
Harry f90cd8aa9a feat: add dify_cli BusyBox-style CLI tool
Add a new CLI tool that allows invoking Dify platform tools like bash commands.

Features:
- BusyBox-style symlink invocation (e.g., google_search --query "hello")
- Cobra-based command structure for dify init/execute/list
- Flag-style parameters (--param value) instead of JSON
- Supports tool schema from Dify plugin entities

Usage:
  dify init --env <file> --schemas <file>   # Initialize config and create symlinks
  dify execute --tool <name> [--args...]    # Execute tool directly
  dify list                                 # List available tools
  google_search --query "hello"             # Via symlink

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:09:02 +08:00