-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b6acfc
commit 6c96c71
Showing
14 changed files
with
177 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Context } from 'main/ipc/dimensions/context'; | ||
import type { Action } from 'main/ipc/types'; | ||
import { getEnv } from '../envScheduler'; | ||
|
||
interface Data { | ||
env: string; | ||
agents: string[]; | ||
} | ||
|
||
type Result = { | ||
episodeId: string; | ||
env: string; | ||
metaData: $TSFIXME; | ||
name: string; | ||
}; | ||
|
||
export const createEpisode: Action<Data, Result, Context> = | ||
(ctx) => async (_event, data) => { | ||
const env = await getEnv(data.env, ctx); | ||
const { episodes } = ctx.data; | ||
const episode = await ctx.dim.createEpisode(env, data.agents); | ||
await episode.initialize(); | ||
episodes.set(episode.id, episode); | ||
return { | ||
episodeId: episode.id, | ||
env: data.env, | ||
metaData: env.metaData, | ||
name: env.configs.name ?? '', | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { EpisodeResult } from 'dimensions-ai-temp/lib/main/Episode'; | ||
import { Context } from 'main/ipc/dimensions/context'; | ||
import type { Action } from 'main/ipc/types'; | ||
|
||
interface Data { | ||
episodeId: string; | ||
} | ||
|
||
type Result = { results: EpisodeResult; done: boolean }; | ||
|
||
export const envStep: Action<Data, Result, Context> = | ||
(ctx) => async (_event, data) => { | ||
const { episodes } = ctx.data; | ||
const episode = episodes.get(data.episodeId); | ||
console.log('HERE'); | ||
if (episode) { | ||
console.log('HERE2'); | ||
const done = await episode.stepParallel(); | ||
return { results: episode.results, done }; | ||
} | ||
throw Error(`Episode with id ${data.episodeId} not found!`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Context } from 'main/ipc/dimensions/context'; | ||
|
||
/** | ||
* Finds an available environment process to use. If none available, a new one is created | ||
* @param envstr | ||
* @param ctx | ||
* @returns | ||
*/ | ||
export const getEnv = async (envstr: string, ctx: Context) => { | ||
let env = ctx.data.envs.get(envstr); | ||
if (env) { | ||
console.log('FREE ENV EXISTS ALREADY, REUSUING', env.id); | ||
} else { | ||
console.log('CREATING ENV', envstr); | ||
env = await ctx.dim.makeEnv(envstr); | ||
ctx.data.envs.set(envstr, env); | ||
} | ||
return env; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters