Impl: tool-npm-package

This commit is contained in:
2026-03-19 19:12:50 +05:30
parent f1b09bf7de
commit ca753cd1ca
17 changed files with 1914 additions and 499 deletions
+43
View File
@@ -0,0 +1,43 @@
import { tool } from "@opencode-ai/plugin";
import { launchMultiModel } from "../core/launch";
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",
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 launchMultiModel({
sessionName: args.sessionName,
models: args.models,
binaryName,
});
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`;
},
});