Files
template-app/modules/agent/module.ts
T
2026-11-14 09:56:45 +00:00

29 lines
1.5 KiB
TypeScript

// The agent module's manifest (spec §4.1): the one place it registers anything. The module's own
// outbox subscriber enqueues the run job (singleton on the run id), so a request writes the run
// row and answers; the worker executes and resumes it.
import { agentRunRetentionDaysOf } from "@app/config"
import { assistantModule, assistantSchedules } from "@conusai-kit/agent/turn"
import { defineModule } from "@conusai-kit/core"
import { AGENT_JOBS, AGENT_SUBSCRIPTIONS } from "./adapters/procedures.js"
import { AGENT_EVENTS } from "./contract/index.js"
import { AGENT_MODULE_BASE } from "./module.shared.js"
import { agentSchedules } from "./schedules.js"
export const agentModule = defineModule({
...AGENT_MODULE_BASE,
jobs: AGENT_JOBS,
// `agent.runs.expire`, hourly for every project: deletes the finished runs past the retention the environment
// sets (AGENT_RUN_RETENTION_DAYS), with their step logs and conversations.
schedules: (env) => agentSchedules(agentRunRetentionDaysOf(env)),
events: { publishes: [...AGENT_EVENTS], subscribes: AGENT_SUBSCRIPTIONS },
})
/**
* The conversation behind the Agent in the frame's right panel (`@conusai-kit/agent/turn`). The kit's module
* declares no migrations: its tables are this module's `0005_assistant_workspace.sql`, the kit's file
* after the drop of what `0004_assistant.sql` made. Its sweep
* deletes a conversation nobody wrote to for 90 days, with its turns, logs and receipts.
*/
export const assistantAppModule = defineModule({ ...assistantModule, schedules: () => assistantSchedules() })