@xandreed/sdk-core
v0.5.1
Published
efferent SDK — the pure Effect.ts domain: agent loop, context tree, compaction, multi-provider router contracts, approval. Ports + use cases, no IO. Runtime-agnostic.
Maintainers
Readme
@xandreed/sdk-core
The pure domain of the efferent agent — entities, ports, and use cases. Runtime dependencies are
effectand@effect/ai(provider-agnostic) and nothing else.
This is the inward end of the ports & adapters architecture: cli → sdk-adapters → sdk-core. sdk-core imports nothing from its siblings — it declares what the agent does as Effects over Context.Tag ports; the adapters supply how.
What's inside
entities/— Schema-backed types the loop manipulates:Conversation(theAgentMessageunion,Checkpoint),AgentContext(context-tree nodes),AgentEvent(the wire event union),Model(selections, roles, the generated context-window catalogue),Settings,Scope,Skill,AgentDefinition,AgentHooks,Job(the control-plane submission unit),Memory,Directive. Pure values, no IO.ports/—Context.Tagservices for everything the domain needs from outside:ConversationStore,ContextTreeStore,FileSystem,Shell,Http,WebSearch,AuthStore,SettingsStore,ModelRegistry,LlmInfo,UtilityLlm,Approval,AuthFlow. Each port file pairs its tagged errors with the Tag.usecases/— Effects over the ports: the agent loop (runAgent.ts,agentLoop.ts,promptMapping.ts,agentPhase.ts); the orchestration substrate lifted here from the CLI —agentBus.ts(the Supervisor, exported astype Supervisor = AgentBus; not aContext.Tagport but a per-session stateful value carrying the event sink, threaded viamakeAgentBus),buildScopeRuntime.ts(sub-agent spawning over the context tree),codingToolkit.ts(the coding tools),discoverScopeTree.ts,loadTools.ts,schedule.ts,staleness.ts,parseFrontmatter.ts; the loop primitivesrunContext.ts+tokenBudget.ts; context management (handoff.ts,compaction.ts,compactionContent.ts); approval (autoApproval.ts); and helpers (generateTitle.ts). (Workspace-shaped discovery —loadSkills.ts,loadAgents.ts,loadMemory.ts,teamAgents.ts— lives inefferent.)prompts/— system-prompt strings/functions:handoff.ts,title.ts, plus the shared fleet/scope pieces lifted from the CLI —sections.ts(subAgentsSection/coordinationSection/renderAgentsSection/renderMemorySection) andscopeAgent.ts(renderScopeSystemPrompt). (The root coder promptcoder.tslives inefferent.)
Rules
- Never import from
@xandreed/sdk-adaptersor the CLI. If a use case needs a capability, declare a port — the only SDK allowed here is@effect/ai(provider packages live in adapters). - No
try/catch/throw/.catch()insrc/— error handling is Effect's typed errors (Effect.fail,Effect.catchTag, …), enforced byscripts/banTryCatch.tsinbun run typecheck. - camelCase files export functions; PascalCase files export types /
Context.Tagclasses. Tags carry a fully-qualified id:Context.Tag("@xandreed/sdk-core/FileSystem").
Part of efferent — an agent runtime on Effect.ts + Bun.
