mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: move the terminal fully into the ssh-terminal plugin (B9)
This commit is contained in:
1 parent
535126fd1b
commit
79d77678c9
309 files changed
+41789
-14958
No files matched your search
@@ -221,3 +221,30 @@ export async function deleteSnippet(
|
||||
): Promise<boolean> {
|
||||
return requireSnippetsAccess(userId).remove(id);
|
||||
}
|
||||
|
||||
/** The terminal's command history, as ctx.services.get("terminal.history") returns it. */
|
||||
interface TerminalHistory {
|
||||
list: (
|
||||
hostId: number,
|
||||
limit?: number,
|
||||
) => Promise<Array<{ command: string; executedAt: string }>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The user's recent commands on one host, or null when the ssh-terminal
|
||||
* plugin is off or the user may not read its history.
|
||||
*/
|
||||
export async function listCommandHistory(
|
||||
userId: string,
|
||||
hostId: number,
|
||||
limit: number,
|
||||
): Promise<Array<{ command: string; executedAt: string }> | null> {
|
||||
if (!current) return null;
|
||||
try {
|
||||
return await current
|
||||
.get<TerminalHistory>("terminal.history", { userId })
|
||||
.list(hostId, limit);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
createCurrentNotificationChannelRepository,
|
||||
createCurrentAutomationRepository,
|
||||
createCurrentCommandHistoryRepository,
|
||||
createCurrentHomepageItemRepository,
|
||||
createCurrentHostRepository,
|
||||
} from "../../../../../src/backend/database/repositories/factory.js";
|
||||
@@ -11,6 +10,7 @@ import {
|
||||
getNetworkTopology,
|
||||
listSnippets,
|
||||
listFleets,
|
||||
listCommandHistory,
|
||||
} from "../services.js";
|
||||
|
||||
/**
|
||||
@@ -244,13 +244,9 @@ export const readTools: AiTool[] = [
|
||||
);
|
||||
if (!host) return { error: "Host not found" };
|
||||
|
||||
const commands =
|
||||
await createCurrentCommandHistoryRepository().listCommandsForHost(
|
||||
context.userId,
|
||||
hostId,
|
||||
limit,
|
||||
);
|
||||
return { commands };
|
||||
const history = await listCommandHistory(context.userId, hostId, limit);
|
||||
if (history === null) return { commands: [], unavailable: true };
|
||||
return { commands: history.map((entry) => entry.command) };
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user