fix play
This commit is contained in:
committed by
Colin McDonnell
parent
c335032c37
commit
89e93d3398
@@ -138360,7 +138360,7 @@ var Timer = class {
|
||||
// main.ts
|
||||
var Inputs = type({
|
||||
prompt: "string",
|
||||
effort: Effort
|
||||
"effort?": Effort
|
||||
});
|
||||
async function main(inputs) {
|
||||
var _stack2 = [];
|
||||
|
||||
@@ -23,7 +23,7 @@ import { Timer } from "./utils/timer.ts";
|
||||
|
||||
export const Inputs = type({
|
||||
prompt: "string",
|
||||
effort: Effort,
|
||||
"effort?": Effort,
|
||||
});
|
||||
|
||||
export type Inputs = typeof Inputs.infer;
|
||||
|
||||
@@ -3,10 +3,8 @@ import { existsSync, readFileSync } from "node:fs";
|
||||
import { extname, join, resolve } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { fromHere } from "@ark/fs";
|
||||
import { flatMorph } from "@ark/util";
|
||||
import arg from "arg";
|
||||
import { config } from "dotenv";
|
||||
import { agents } from "./agents/index.ts";
|
||||
import type { AgentResult } from "./agents/shared.ts";
|
||||
import { type Inputs, main } from "./main.ts";
|
||||
import { log } from "./utils/cli.ts";
|
||||
@@ -25,26 +23,10 @@ export async function run(prompt: string): Promise<AgentResult> {
|
||||
const originalCwd = process.cwd();
|
||||
process.chdir(tempDir);
|
||||
|
||||
// check if prompt is a pullfrog payload and extract agent
|
||||
// note: agent from payload will be used by determineAgent with highest precedence
|
||||
// we don't need to extract it here since main() will parse the payload
|
||||
const inputs = {
|
||||
const inputs: Inputs = {
|
||||
prompt,
|
||||
...flatMorph(agents, (_, agent) => {
|
||||
// for OpenCode, scan all API_KEY environment variables
|
||||
if (agent.name === "opencode") {
|
||||
const opencodeKeys: Array<[string, string | undefined]> = [];
|
||||
for (const [key, value] of Object.entries(process.env)) {
|
||||
if (value && typeof value === "string" && key.includes("API_KEY")) {
|
||||
opencodeKeys.push([key.toLowerCase(), value]);
|
||||
}
|
||||
}
|
||||
return opencodeKeys;
|
||||
}
|
||||
// for other agents, use apiKeyNames
|
||||
return agent.apiKeyNames.map((inputKey) => [inputKey, process.env[inputKey.toUpperCase()]]);
|
||||
}),
|
||||
} as Required<Inputs>;
|
||||
effort: "nothink",
|
||||
};
|
||||
|
||||
const result = await main(inputs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user