oh-pi 0.1.38 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -110,6 +110,9 @@ For simple single-file tasks, work directly without the colony.`,
|
|
|
110
110
|
goal: Type.String({ description: "What the colony should accomplish" }),
|
|
111
111
|
maxAnts: Type.Optional(Type.Number({ description: "Max concurrent ants (default: auto-adapt)", minimum: 1, maximum: 8 })),
|
|
112
112
|
maxCost: Type.Optional(Type.Number({ description: "Max cost budget in USD (default: unlimited)", minimum: 0.01 })),
|
|
113
|
+
scoutModel: Type.Optional(Type.String({ description: "Model for scout ants (default: current session model)" })),
|
|
114
|
+
workerModel: Type.Optional(Type.String({ description: "Model for worker ants (default: current session model)" })),
|
|
115
|
+
soldierModel: Type.Optional(Type.String({ description: "Model for soldier ants (default: current session model)" })),
|
|
113
116
|
}),
|
|
114
117
|
|
|
115
118
|
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
@@ -169,12 +172,18 @@ For simple single-file tasks, work directly without the colony.`,
|
|
|
169
172
|
appendFileSync(gitignorePath, `${content.length && !content.endsWith("\n") ? "\n" : ""}.ant-colony/\n`);
|
|
170
173
|
}
|
|
171
174
|
|
|
175
|
+
const modelOverrides: Record<string, string> = {};
|
|
176
|
+
if (params.scoutModel) modelOverrides.scout = params.scoutModel;
|
|
177
|
+
if (params.workerModel) modelOverrides.worker = params.workerModel;
|
|
178
|
+
if (params.soldierModel) modelOverrides.soldier = params.soldierModel;
|
|
179
|
+
|
|
172
180
|
const state = await runColony({
|
|
173
181
|
cwd: ctx.cwd,
|
|
174
182
|
goal: params.goal,
|
|
175
183
|
maxAnts: params.maxAnts,
|
|
176
184
|
maxCost: params.maxCost,
|
|
177
185
|
currentModel,
|
|
186
|
+
modelOverrides,
|
|
178
187
|
signal: signal ?? undefined,
|
|
179
188
|
callbacks,
|
|
180
189
|
});
|
|
@@ -282,11 +291,13 @@ For simple single-file tasks, work directly without the colony.`,
|
|
|
282
291
|
const taskTitle = task?.title?.slice(0, 55) || "...";
|
|
283
292
|
const dur = a.finishedAt ? formatDuration(a.finishedAt - a.startedAt) : formatDuration(Date.now() - a.startedAt);
|
|
284
293
|
const turns = a.usage.turns > 0 ? `${a.usage.turns}t` : "";
|
|
294
|
+
const model = a.model ? a.model.split("/").pop()! : "";
|
|
285
295
|
|
|
286
296
|
container.addChild(new Text(
|
|
287
297
|
theme.fg("muted", ` ${branch} `) + statusDot + " " +
|
|
288
298
|
theme.fg("accent", `@${a.id.slice(0, 20)} `) +
|
|
289
|
-
theme.fg("dim", `(${a.caste}) ${dur}${turns ? " │ " + turns : ""}`)
|
|
299
|
+
theme.fg("dim", `(${a.caste}) ${dur}${turns ? " │ " + turns : ""}`) +
|
|
300
|
+
(model ? " " + theme.fg("muted", model) : ""),
|
|
290
301
|
0, 0,
|
|
291
302
|
));
|
|
292
303
|
container.addChild(new Text(
|
|
@@ -37,6 +37,7 @@ export interface QueenOptions {
|
|
|
37
37
|
maxAnts?: number;
|
|
38
38
|
maxCost?: number;
|
|
39
39
|
currentModel: string;
|
|
40
|
+
modelOverrides?: ModelOverrides;
|
|
40
41
|
signal?: AbortSignal;
|
|
41
42
|
callbacks: QueenCallbacks;
|
|
42
43
|
}
|
|
@@ -138,6 +139,7 @@ interface WaveOptions {
|
|
|
138
139
|
cwd: string;
|
|
139
140
|
caste: AntCaste;
|
|
140
141
|
currentModel: string;
|
|
142
|
+
modelOverrides?: ModelOverrides;
|
|
141
143
|
signal?: AbortSignal;
|
|
142
144
|
callbacks: QueenCallbacks;
|
|
143
145
|
}
|
|
@@ -147,7 +149,8 @@ interface WaveOptions {
|
|
|
147
149
|
*/
|
|
148
150
|
async function runAntWave(opts: WaveOptions): Promise<"ok"> {
|
|
149
151
|
const { nest, cwd, caste, signal, callbacks, currentModel } = opts;
|
|
150
|
-
const
|
|
152
|
+
const casteModel = opts.modelOverrides?.[caste] || currentModel;
|
|
153
|
+
const config = { ...DEFAULT_ANT_CONFIGS[caste], model: casteModel };
|
|
151
154
|
|
|
152
155
|
let backoffMs = 0; // 429 退避时间
|
|
153
156
|
let consecutiveRateLimits = 0; // 连续限流计数
|
|
@@ -160,7 +163,8 @@ async function runAntWave(opts: WaveOptions): Promise<"ok"> {
|
|
|
160
163
|
|
|
161
164
|
const ant: Ant = {
|
|
162
165
|
id: "", caste, status: "idle", taskId: task.id,
|
|
163
|
-
pid: null,
|
|
166
|
+
pid: null, model: casteModel,
|
|
167
|
+
usage: { input: 0, output: 0, cost: 0, turns: 0 },
|
|
164
168
|
startedAt: Date.now(), finishedAt: null,
|
|
165
169
|
};
|
|
166
170
|
callbacks.onAntSpawn(ant, task);
|
|
@@ -311,6 +315,7 @@ export async function runColony(opts: QueenOptions): Promise<ColonyState> {
|
|
|
311
315
|
const waveBase: Omit<WaveOptions, "caste"> = {
|
|
312
316
|
nest, cwd: opts.cwd, signal, callbacks,
|
|
313
317
|
currentModel: opts.currentModel,
|
|
318
|
+
modelOverrides: opts.modelOverrides,
|
|
314
319
|
};
|
|
315
320
|
|
|
316
321
|
const cleanup = () => {
|