Add AgentOS daemon control plane and maintenance tooling
This commit is contained in:
22
packages/primitives/package.json
Normal file
22
packages/primitives/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@code/primitives",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./agent-os": "./src/agent-os.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"check-types": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rivet-dev/agentos": "^0.2.7",
|
||||
"effect": "4.0.0-beta.99"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@code/config": "workspace:*",
|
||||
"@types/node": "^22.13.14",
|
||||
"typescript": "^6"
|
||||
}
|
||||
}
|
||||
64
packages/primitives/src/agent-os.ts
Normal file
64
packages/primitives/src/agent-os.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import {
|
||||
agentOS as createAgentOsActor,
|
||||
type AgentOSConfigInput,
|
||||
} from "@rivet-dev/agentos";
|
||||
import { Context, Effect, Layer, Schema } from "effect";
|
||||
|
||||
export class AgentOsError extends Schema.TaggedErrorClass<AgentOsError>()(
|
||||
"AgentOsError",
|
||||
{
|
||||
cause: Schema.Defect(),
|
||||
}
|
||||
) {}
|
||||
|
||||
export interface AgentOsOptions {
|
||||
readonly config?: AgentOSConfigInput<undefined>;
|
||||
}
|
||||
|
||||
export class AgentOs extends Context.Service<
|
||||
AgentOs,
|
||||
{
|
||||
readonly createActor: (
|
||||
config?: AgentOSConfigInput<undefined>
|
||||
) => Effect.Effect<
|
||||
ReturnType<typeof createAgentOsActor<undefined>>,
|
||||
AgentOsError
|
||||
>;
|
||||
}
|
||||
>()("@code/primitives/agent-os/AgentOs") {
|
||||
static readonly layer = Layer.succeed(
|
||||
AgentOs,
|
||||
AgentOs.of({
|
||||
createActor: Effect.fn("AgentOs.createActor")(function* (
|
||||
config: AgentOSConfigInput<undefined> = {}
|
||||
) {
|
||||
return yield* Effect.try({
|
||||
try: () => createAgentOsActor<undefined>(config),
|
||||
catch: (cause) => new AgentOsError({ cause }),
|
||||
});
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export const makeAgentOsLayer = (options: AgentOsOptions = {}) =>
|
||||
Layer.succeed(
|
||||
AgentOs,
|
||||
AgentOs.of({
|
||||
createActor: Effect.fn("AgentOs.createActor")(function* (
|
||||
config: AgentOSConfigInput<undefined> = options.config ?? {}
|
||||
) {
|
||||
return yield* Effect.try({
|
||||
try: () => createAgentOsActor<undefined>(config),
|
||||
catch: (cause) => new AgentOsError({ cause }),
|
||||
});
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
export const createAgentOsActorEffect = Effect.fn("createAgentOsActorEffect")(
|
||||
function* (config?: AgentOSConfigInput<undefined>) {
|
||||
const agentOs = yield* AgentOs;
|
||||
return yield* agentOs.createActor(config);
|
||||
}
|
||||
);
|
||||
1
packages/primitives/src/index.ts
Normal file
1
packages/primitives/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./agent-os";
|
||||
5
packages/primitives/tsconfig.json
Normal file
5
packages/primitives/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "@code/config/tsconfig.base.json",
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["dist"]
|
||||
}
|
||||
Reference in New Issue
Block a user