From 0f482cc33b0a3fb58976ccdede0ca37179c3b7be Mon Sep 17 00:00:00 2001 From: synw Date: Wed, 6 Mar 2024 19:37:57 +0100 Subject: [PATCH] Various fixes in packages --- packages/jobs/package.json | 5 +---- packages/jobs/src/job.ts | 5 +++-- packages/jobs/src/jobsinterfaces.ts | 5 +++-- packages/jobs/src/main.ts | 21 ++++++++++++++++++++ packages/tmem-jobs/package.json | 7 +++++-- packages/tmem-jobs/src/main.ts | 13 ++++++++++++ packages/tmem-jobs/src/tmem_jobs.ts | 5 +++-- packages/tmem-jobs/src/tmemjobsinterfaces.ts | 3 ++- packages/tmem/package.json | 2 +- packages/tmem/rollup.config.js | 1 - packages/tmem/src/tmem.ts | 4 ++-- packages/tmem/src/tmeminterfaces.ts | 1 + 12 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 packages/jobs/src/main.ts diff --git a/packages/jobs/package.json b/packages/jobs/package.json index a31fef0..a5cffd7 100644 --- a/packages/jobs/package.json +++ b/packages/jobs/package.json @@ -9,11 +9,8 @@ "test": "jest --coverage", "docs": "typedoc --entryPointStrategy expand" }, - "dependencies": { - "nanostores": "^0.10.0" - }, "devDependencies": { - "@locallm/types": "^0.0.14", + "@agent-smith/tmem-jobs": "^0.0.2", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", diff --git a/packages/jobs/src/job.ts b/packages/jobs/src/job.ts index 0287680..1fd5e95 100644 --- a/packages/jobs/src/job.ts +++ b/packages/jobs/src/job.ts @@ -1,6 +1,7 @@ import { map } from 'nanostores'; +import { TaskMem, TmemJobs } from "@agent-smith/tmem-jobs"; +//import { TaskMem, TmemJobs } from '../../tmem-jobs/src/tmemjobsinterfaces.js'; import { AgentJob, AgentJobSpec, AgentJobState, AgentTask } from "./jobsinterfaces.js"; -import { TaskMem } from '../../tmem/src/tmeminterfaces.js'; import { useAgentTask } from './task.js'; const useAgentJob = (initParams: AgentJobSpec): AgentJob => { @@ -11,7 +12,7 @@ const useAgentJob = (initParams: AgentJobSpec): AgentJob => { _tasks[_t.id] = _t }); const _title = initParams.title; - const tmem = initParams.tmem; + const tmem = initParams.tmem ?? {} as TmemJobs; //console.log("INIT JOB", _tasks.map((t) => t.name)); const state = map({ isRunning: false, diff --git a/packages/jobs/src/jobsinterfaces.ts b/packages/jobs/src/jobsinterfaces.ts index 33ba120..82038da 100644 --- a/packages/jobs/src/jobsinterfaces.ts +++ b/packages/jobs/src/jobsinterfaces.ts @@ -1,5 +1,6 @@ import { MapStore } from "nanostores"; -import { TmemJobs } from "../../tmem/src/tmeminterfaces"; +import { TmemJobs } from "@agent-smith/tmem-jobs"; +//import { TmemJobs } from "../../tmem-jobs/src/tmemjobsinterfaces.js"; interface AgentTaskSpec { id: string; @@ -45,7 +46,7 @@ interface AgentJob { title: string; state: MapStore; tasks: Record; - tmem?: TmemJobs; + tmem: TmemJobs; runTask: (name: string, params?: any) => Promise>; continueTask: (params?: any) => Promise>; startTask: (name: string, params?: any) => Promise; diff --git a/packages/jobs/src/main.ts b/packages/jobs/src/main.ts new file mode 100644 index 0000000..483b135 --- /dev/null +++ b/packages/jobs/src/main.ts @@ -0,0 +1,21 @@ +import { + AgentJob, + AgentJobSpec, + AgentTask, + AgentTaskSpec, + AgentTaskState, + AgentJobState, +} from "./jobsinterfaces.js" +import { useAgentTask } from "./task.js"; +import { useAgentJob } from "./job.js"; + +export { + useAgentJob, + useAgentTask, + AgentJob, + AgentJobSpec, + AgentTask, + AgentTaskSpec, + AgentTaskState, + AgentJobState, +} \ No newline at end of file diff --git a/packages/tmem-jobs/package.json b/packages/tmem-jobs/package.json index 4b9b8a8..e8293b2 100644 --- a/packages/tmem-jobs/package.json +++ b/packages/tmem-jobs/package.json @@ -1,6 +1,6 @@ { "name": "@agent-smith/tmem-jobs", - "version": "0.0.1", + "version": "0.0.2", "description": "An api to ceate human friendly agents: the transient memory for jobs", "repository": "https://github.com/synw/agent-smith", "scripts": { @@ -9,7 +9,10 @@ "test": "jest --coverage", "docs": "typedoc --entryPointStrategy expand" }, - "dependencies": {}, + "dependencies": { + "@agent-smith/tmem": "^0.0.2", + "localforage": "^1.10.0" + }, "devDependencies": { "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-terser": "^0.4.4", diff --git a/packages/tmem-jobs/src/main.ts b/packages/tmem-jobs/src/main.ts index e69de29..8efe822 100644 --- a/packages/tmem-jobs/src/main.ts +++ b/packages/tmem-jobs/src/main.ts @@ -0,0 +1,13 @@ +import { + JobMem, + TaskMem, + TmemJobs +} from "./tmemjobsinterfaces.js"; +import { useTmemJobs } from "./tmem_jobs"; + +export { + useTmemJobs, + JobMem, + TaskMem, + TmemJobs +} \ No newline at end of file diff --git a/packages/tmem-jobs/src/tmem_jobs.ts b/packages/tmem-jobs/src/tmem_jobs.ts index 0823c6d..9be5a6f 100644 --- a/packages/tmem-jobs/src/tmem_jobs.ts +++ b/packages/tmem-jobs/src/tmem_jobs.ts @@ -1,5 +1,6 @@ -import { useTmem } from "../../tmem/src/tmem"; -import { JobMem, TaskMem, TmemJobs } from "./tmemjobsinterfaces"; +import { useTmem } from "@agent-smith/tmem"; +//import { useTmem } from "../../tmem/src/tmem"; +import { JobMem, TaskMem, TmemJobs } from "./tmemjobsinterfaces.js"; const useTmemJobs = (isVerbose = false): TmemJobs => { const jMem = useTmem("job", { diff --git a/packages/tmem-jobs/src/tmemjobsinterfaces.ts b/packages/tmem-jobs/src/tmemjobsinterfaces.ts index f9ecbe9..1b3acc7 100644 --- a/packages/tmem-jobs/src/tmemjobsinterfaces.ts +++ b/packages/tmem-jobs/src/tmemjobsinterfaces.ts @@ -1,4 +1,5 @@ -import { Tmem } from "../../tmem/src/tmeminterfaces"; +import { Tmem } from "@agent-smith/tmem"; +//import { Tmem } from "../../tmem/src/tmeminterfaces" interface JobMem { isRunning: boolean; diff --git a/packages/tmem/package.json b/packages/tmem/package.json index 88dc5b2..ab1a5e2 100644 --- a/packages/tmem/package.json +++ b/packages/tmem/package.json @@ -1,6 +1,6 @@ { "name": "@agent-smith/tmem", - "version": "0.0.1", + "version": "0.0.2", "description": "An api to ceate human friendly agents: the transient memory module", "repository": "https://github.com/synw/agent-smith", "scripts": { diff --git a/packages/tmem/rollup.config.js b/packages/tmem/rollup.config.js index 1fd4883..96077b8 100644 --- a/packages/tmem/rollup.config.js +++ b/packages/tmem/rollup.config.js @@ -24,6 +24,5 @@ export default { main: true, browser: true, }), - //isProduction && terser({ format: { comments: false } }), ], }; \ No newline at end of file diff --git a/packages/tmem/src/tmem.ts b/packages/tmem/src/tmem.ts index 4bc4d07..844da3f 100644 --- a/packages/tmem/src/tmem.ts +++ b/packages/tmem/src/tmem.ts @@ -1,5 +1,5 @@ -import localForage from "localforage"; -import { Tmem } from "./tmeminterfaces"; +import * as localForage from "localforage"; +import { Tmem } from "./tmeminterfaces.js"; const useTmem = = Record>(name: string, initial: S, verbose = false) => { const db = localForage.createInstance({ diff --git a/packages/tmem/src/tmeminterfaces.ts b/packages/tmem/src/tmeminterfaces.ts index 7a55794..c0a0f62 100644 --- a/packages/tmem/src/tmeminterfaces.ts +++ b/packages/tmem/src/tmeminterfaces.ts @@ -1,3 +1,4 @@ +import 'localforage'; interface Tmem> { db: LocalForage; init: () => Promise;