From c3640b6f42e5a31b9066b8f866a94fa68d75338a Mon Sep 17 00:00:00 2001 From: synw Date: Wed, 16 Oct 2024 15:17:33 +0200 Subject: [PATCH] Fix in job execution - Updated `cmds.ts` to pass options to `executeJobCmd` and `executeActionCmd`. - Modified `execute_job.ts` to accept options for `job.runTask` calls. - Added option handling to `execute_task.ts`. - Bumped version number in `package.json`. --- packages/cli/bin/cmd/clicmds/cmds.ts | 6 ++-- packages/cli/bin/cmd/lib/execute_action.ts | 2 +- packages/cli/bin/cmd/lib/execute_job.ts | 34 +++++++++++++++------- packages/cli/bin/cmd/lib/execute_task.ts | 2 ++ packages/cli/package.json | 2 +- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/packages/cli/bin/cmd/clicmds/cmds.ts b/packages/cli/bin/cmd/clicmds/cmds.ts index 4c41fe8..829a7b1 100644 --- a/packages/cli/bin/cmd/clicmds/cmds.ts +++ b/packages/cli/bin/cmd/clicmds/cmds.ts @@ -76,14 +76,14 @@ function initAliases(): Record { _cmds[alias.name] = { cmd: (args: Array = [], options: any = {}, quiet = false) => executeActionCmd([alias.name, ...args], options, quiet), description: "action: " + alias.name, - args: "arguments: \n-args: other arguments if any for the action" + //args: "arguments: \n-args: other arguments if any for the action" } break; case "job": _cmds[alias.name] = { cmd: (args: Array = [], options: any) => _executeJobCmd([alias.name, ...args], options), description: "job: " + alias.name, - args: "arguments: \n-args: other arguments if any for the job" + //args: "arguments: \n-args: other arguments if any for the job" } } }); @@ -162,7 +162,7 @@ async function _executeJobCmd(args: Array = [], options: any): Promise = [], options: any = {}, qui throw new Error(`Action ext ${ext} not implemented`) break; } - const res = await act.run(args); + const res = await act.run(args, options); if (!quiet) { console.log(res.data); } diff --git a/packages/cli/bin/cmd/lib/execute_job.ts b/packages/cli/bin/cmd/lib/execute_job.ts index e719f7f..3b7fb5c 100644 --- a/packages/cli/bin/cmd/lib/execute_job.ts +++ b/packages/cli/bin/cmd/lib/execute_job.ts @@ -8,7 +8,7 @@ import { FeatureType } from '../../interfaces.js'; import { formatMode } from '../../state/state.js'; import { initTaskVars, readTask } from './utils.js'; -async function executeJobCmd(name: string, args: Array = []): Promise> { +async function executeJobCmd(name: string, args: Array = [], options: any = {}): Promise> { const { job, found } = await _dispatchReadJob(name); //console.log("F", found); if (!found) { @@ -22,19 +22,24 @@ async function executeJobCmd(name: string, args: Array = []): Promise = {}; let vars: Record = {}; - if (i == 0) { + const tv = initTaskVars(args); + //console.log("TV", tv); + conf = tv.conf; + vars = i == 0 ? tv.vars : params; + /*if (i == 0) { const tv = initTaskVars(args); + console.log("TV", tv); conf = tv.conf; vars = tv.vars; } else { conf = {}; vars = params; - } + }*/ const { found, path } = getFeatureSpec(name, "task" as FeatureType); if (!found) { return { ok: false, data: {}, error: `Task ${name} not found` }; @@ -46,10 +51,19 @@ async function executeJobCmd(name: string, args: Array = []): Promise { @@ -57,7 +71,7 @@ async function executeJobCmd(name: string, args: Array = []): Promise = []): Promise = [], options: any = {}): Prom const taskSpec = taskBuilder.readFromYaml(res.ymlTask); const task = taskBuilder.fromYaml(res.ymlTask); const { conf, vars } = initTaskVars(args); + //console.log("Conf", conf) + //console.log("Vars", vars) let m = taskSpec.model.name; let t = taskSpec.template.name; if (conf?.model) { diff --git a/packages/cli/package.json b/packages/cli/package.json index c7cacee..b292c59 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -2,7 +2,7 @@ "name": "@agent-smith/cli", "description": "Agent Smith: terminal client for language model agents", "repository": "https://github.com/synw/agent-smith", - "version": "0.0.15", + "version": "0.0.17", "scripts": { "buildrl": "rm -rf dist/* && rollup -c", "build": "rm -rf dist/* && tsc",