mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 13:42:21 +00:00
- Updated `cleanupTool` description to include detailed usage and arguments. - Added optional `noRemote` flag to `cleanupTool` for local‑only tag deletion. - Adjusted remote handling logic to respect the new `noRemote` flag. - Expanded `closeTool` description with clear argument documentation. - Expanded `openTool` description with detailed argument documentation.
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { tool } from "@opencode-ai/plugin";
|
|
import { openMultiModel } from "../core/open";
|
|
import { getBinaryName } from "../core/utils";
|
|
|
|
/**
|
|
* OpenCode tool definition for launching multiple AI models in tmux sessions.
|
|
*
|
|
* Creates a tmux session with one window per model, each in its own git worktree.
|
|
* Returns instructions for attaching to and cleaning up the session.
|
|
*/
|
|
export const openTool = tool({
|
|
description: `Launch multiple OpenCode models in tmux.
|
|
|
|
Arguments:
|
|
- \`sessionName\` (string, required): tmux session name to create.
|
|
- \`models\` (array of strings, required): one or more OpenCode model IDs to launch.`,
|
|
args: {
|
|
sessionName: tool.schema
|
|
.string()
|
|
.min(1)
|
|
.describe("tmux session name to create"),
|
|
models: tool.schema
|
|
.array(tool.schema.string().min(1))
|
|
.min(1)
|
|
.describe("one or more OpenCode model ids to launch"),
|
|
},
|
|
async execute(args, context) {
|
|
const binaryName = getBinaryName();
|
|
|
|
const result = await openMultiModel({
|
|
sessionName: args.sessionName,
|
|
models: args.models,
|
|
binaryName,
|
|
mode: "tool",
|
|
});
|
|
|
|
context.metadata({
|
|
title: `multi-model ${args.sessionName}`,
|
|
metadata: {
|
|
safeSessionName: result.sessionName,
|
|
modelCount: args.models.length,
|
|
},
|
|
});
|
|
|
|
if (!result.success) {
|
|
return result.error!;
|
|
}
|
|
|
|
return (
|
|
result.instructions ||
|
|
`Created session "${result.sessionName}" with ${result.windows?.length || 0} windows`
|
|
);
|
|
},
|
|
});
|