// The ports the agent module's use cases are written against, and the tokens the composition // roots bind. The runtime itself (durable run record, step log, engine) is @conusai-kit/agent; // this module is its template integration: procedures, job and pages. import { type TenantScope, token } from "@conusai-kit/core" import type { DataSource } from "@conusai-kit/data" export type AgentScope = TenantScope & { workspaceId: string; projectId: string } export interface AgentDeps { readonly data: DataSource } /** * The project a run's job executes in, with a system actor. The worker binds it per job from the * enqueueing scope (the same arrangement as `DOCUMENTS_SCOPE`, decision AT-F6): a payload never * names a tenant. */ export const AGENT_SCOPE = token("agent.scope") /** The scope the tools adapter needs to review persisted proposals in the console. */ export interface AgentActionScope { readonly orgSlug: string readonly workspaceSlug: string readonly projectSlug: string } /** Resolves the slug scope the registry's tool-actions API is addressed by, from ids. */ export async function actionScopeOf( data: import("@conusai-kit/data").DataSource, scope: AgentScope, ): Promise { const { organizations, workspaces, projects } = await import("@conusai-kit/tenancy") const org = await data.global(organizations).get(scope.orgId) const workspace = await data.forScope(scope).of(workspaces).get(scope.workspaceId) const project = await data.forScope(scope).of(projects).get(scope.projectId) if (!org || !workspace || !project) throw new Error("the run's organization, workspace or project is gone") return { orgSlug: org.slug, workspaceSlug: workspace.slug, projectSlug: project.slug } }