adachsoft/ssh-tool 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adachsoft/ssh-tool

最新稳定版本:v0.1.1

Composer 安装命令:

composer require adachsoft/ssh-tool

包简介

SSH integration for AdachSoft AiToolCall — login, remote command execution and session management for pluggable AI tool actions.

README 文档

README

PHP Version License

SSH Tool is a bridge between AdachSoft AiToolCall and SSH operations. It implements the ToolInterface and uses the Strategy pattern to provide clean, testable SSH actions (login, logout, command execution, account management, etc.).

Features

  • Full SSH session management (login/logout)
  • Remote command execution with stdout/stderr/exit code handling
  • Account listing and details retrieval
  • Strategy/Command pattern for easy extension
  • Strict type safety and comprehensive error handling
  • PHPUnit tests (unit + functional)

Installation

composer require adachsoft/ssh-tool

Usage

1. Configuration

use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\SshTool\Config\SshToolConfigKeyEnum;

$config = new ConfigMap([
    SshToolConfigKeyEnum::JSON_REPOSITORY_FILE_PATH->value => '/path/to/accounts.json',
    SshToolConfigKeyEnum::SSH_API_BASE_URL->value => 'https://your-ssh-api.example.com',
]);

2. Registering the Tool

use AdachSoft\AiToolCall\PublicApi\Builder\AiToolCallFacadeBuilder;
use AdachSoft\SshTool\Factory\SshToolFactory;

$facade = AiToolCallFacadeBuilder::new()
    ->withSpiFactories([new SshToolFactory()])
    ->withToolConfigs(['ssh' => $config])
    ->build();

3. Available Actions

The tool supports the following actions via the action parameter:

  • login – Authenticates and returns a session token
  • logout – Ends an active SSH session
  • executeCommand – Runs a command on a remote host
  • getAccount – Retrieves details of a specific account
  • listAccounts – Lists all configured accounts (without passwords)
  • listSessions – Lists active sessions

Example call:

$result = $facade->callTool(new ToolCallRequestDto(
    'ssh',
    new KeyValueMap([
        'action' => 'executeCommand',
        'sessionToken' => 'abc123',
        'command' => 'ls -la',
    ])
));

echo $result->result->get('stdout');

Development

Running Tests

# Unit + Functional tests
vendor/bin/phpunit

# Production/end-to-end tests (if available)
vendor/bin/phpunit --group production

Code Quality

vendor/bin/rector process --config=rector.php
vendor/bin/php-cs-fixer fix
vendor/bin/phpstan analyse src tests

Architecture

  • SshTool – thin router/delegator
  • SshActionInterface + concrete *Action classes – each action is a separate, testable strategy
  • SshToolFactory – creates facade and injects actions
  • All public documentation is in English per project rules.

License

MIT License – see the LICENSE file for details.

Part of the AdachSoft ecosystem. For more information see adachsoft.com.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固