Skip to content
Color theme

API: @loopstack/code-agent

Classes

CodeAgentModule

NestJS module that provides the codebase-exploration tool ExploreTask (explore_task), which launches an AgentWorkflow sub-agent that searches and reads a remote workspace with the glob/grep/read tools and returns a synthesized answer.

Registration:

  • CodeAgentModule — bare import registers ExploreTask and re-exports AgentModule; use this when the agent’s default LLM configuration is fine.
  • CodeAgentModule.forFeature(config?: { llm?: LlmModuleConfig }) — use to override the LLM provider/model for the code agent; it imports AgentModule.forFeature(config).

Requires, configured in your app:

  • LlmProviderModule with a registered LLM provider — needed by the imported AgentModule.
  • RemoteClientModule (bare or forRoot) — supplies the glob/grep/read tools the explore_task sub-agent uses. Without it the app fails at boot with an error naming RemoteClientModule.
import { CodeAgentModule } from '@loopstack/code-agent';
export class CodeAgentModule {
static forFeature(config?: { llm?: LlmModuleConfig }): DynamicModule;
}

ExploreTask

Tool that launches an AgentWorkflow sub-agent to explore and analyze a codebase with the glob/grep/read tools and return a synthesized summary.

Those tools come from RemoteClientModule. Constructing ExploreTask without them throws, so an app that has not wired the remote client fails at boot instead of on the first explore_task call.

import { ExploreTask } from '@loopstack/code-agent';

Provided by: CodeAgentModule

export class ExploreTask extends BaseTool<ExploreTaskInput, object, ExploreTaskResult> {
constructor(agentWorkflow: AgentWorkflow, globTool?: GlobTool, grepTool?: GrepTool, readTool?: ReadTool);
protected handle(
args: ExploreTaskInput,
ctx: RunContext,
options?: ToolCallOptions,
): Promise<ToolEnvelope<ExploreTaskResult>>;
complete(result: Record<string, unknown>): Promise<ToolEnvelope<ExploreTaskResult>>;
}

Type Aliases

ExploreTaskInput

Args for ExploreTask.

import { ExploreTaskInput } from '@loopstack/code-agent';
export type ExploreTaskInput = z.infer<typeof ExploreTaskInputSchema>;

ExploreTaskResult

Result for ExploreTask (explore_task) — the synthesized exploration summary or its pending workflow reference.

import { ExploreTaskResult } from '@loopstack/code-agent';
export type ExploreTaskResult =
| {
workflowId: string;
}
| string
| Record<string, unknown>;

Variables

ExploreTaskInputSchema

Zod schema for ExploreTask args.

import { ExploreTaskInputSchema } from '@loopstack/code-agent';
ExploreTaskInputSchema: z.ZodObject<
{
instructions: z.ZodString;
},
z.core.$strict
>;

ExploreTaskResultSchema

Zod schema for ExploreTaskResult — the synthesized summary string or, when the sub-workflow returned no response text, its raw result record.

import { ExploreTaskResultSchema } from '@loopstack/code-agent';
ExploreTaskResultSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;