Skip to content

Commit

Permalink
Various fixes in packages
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Mar 6, 2024
1 parent fbeb4cd commit 0f482cc
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 17 deletions.
5 changes: 1 addition & 4 deletions packages/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions packages/jobs/src/job.ts
Original file line number Diff line number Diff line change
@@ -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 => {
Expand All @@ -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<AgentJobState>({
isRunning: false,
Expand Down
5 changes: 3 additions & 2 deletions packages/jobs/src/jobsinterfaces.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -45,7 +46,7 @@ interface AgentJob {
title: string;
state: MapStore<AgentJobState>;
tasks: Record<string, AgentTask>;
tmem?: TmemJobs;
tmem: TmemJobs;
runTask: (name: string, params?: any) => Promise<Record<string, any>>;
continueTask: (params?: any) => Promise<Record<string, any>>;
startTask: (name: string, params?: any) => Promise<void>;
Expand Down
21 changes: 21 additions & 0 deletions packages/jobs/src/main.ts
Original file line number Diff line number Diff line change
@@ -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,
}
7 changes: 5 additions & 2 deletions packages/tmem-jobs/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions packages/tmem-jobs/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
JobMem,
TaskMem,
TmemJobs
} from "./tmemjobsinterfaces.js";
import { useTmemJobs } from "./tmem_jobs";

export {
useTmemJobs,
JobMem,
TaskMem,
TmemJobs
}
5 changes: 3 additions & 2 deletions packages/tmem-jobs/src/tmem_jobs.ts
Original file line number Diff line number Diff line change
@@ -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<JobMem>("job", {
Expand Down
3 changes: 2 additions & 1 deletion packages/tmem-jobs/src/tmemjobsinterfaces.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/tmem/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 0 additions & 1 deletion packages/tmem/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ export default {
main: true,
browser: true,
}),
//isProduction && terser({ format: { comments: false } }),
],
};
4 changes: 2 additions & 2 deletions packages/tmem/src/tmem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import localForage from "localforage";
import { Tmem } from "./tmeminterfaces";
import * as localForage from "localforage";
import { Tmem } from "./tmeminterfaces.js";

const useTmem = <S extends Record<string, any> = Record<string, any>>(name: string, initial: S, verbose = false) => {
const db = localForage.createInstance({
Expand Down
1 change: 1 addition & 0 deletions packages/tmem/src/tmeminterfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'localforage';
interface Tmem<S extends Record<string, any>> {
db: LocalForage;
init: () => Promise<void>;
Expand Down

0 comments on commit 0f482cc

Please sign in to comment.