TASKCLANQuickstart ↗

REFERENCE

SDK reference

Complete reference for @taskclan/sdk. TypeScript-first, works in Node 18+, edge runtimes, and any server environment.

Installation

npm install @taskclan/sdk

new Taskclan(options)

Creates a client. All requests inherit these defaults.

OptionTypeDefaultDescription
apiKeystring, Secret key (required). Server-side only.
baseUrlstringhttps://api.taskclan.comOverride the API host.
defaultProfileProfile"t1-flow"Profile used when a call omits one.
timeoutnumber60000Request timeout in ms.
maxRetriesnumber2Automatic retries for transient errors.
import { Taskclan } from "@taskclan/sdk";

const taskclan = new Taskclan({
  apiKey: process.env.TASKCLAN_API_KEY,
  defaultProfile: "t1-flow",
});

taskclan.run(params)

Runs a goal to completion and resolves with a RunResult.

ParamTypeDescription
goalstringWhat you want done (required).
profile"t1-core" | "t1-flow" | "t1-max"Intelligence profile. Defaults to the client default.
inputRecord<string, unknown>Structured input the goal can reference.
toolsTool[]Typed tools the run may call. See Agents & tools.
verifybooleanRun the evaluation layer before returning.
maxTokensnumberUpper bound on generated tokens.
signalAbortSignalCancel an in-flight run.

RunResult

FieldTypeDescription
idstringRun identifier.
outputstringFinal text output.
dataunknownStructured output when produced.
stepsStepTrace[]Plan, tool calls and results.
usage{ inputTokens, outputTokens, costUsd }Usage & cost for the run.
modelstringThe model the profile routed to.

taskclan.run.stream(params)

Same params as run(), but returns an async iterable of StreamEvents.

Event typePayloadEmitted when
plan{ steps }The run forms a plan.
text{ delta }A chunk of output text is ready.
tool_call{ name, input }A tool is about to run.
tool_result{ name, output }A tool returned.
done{ result }The run finished; carries the RunResult.
error{ error }The run failed.
const stream = await taskclan.run.stream({ goal: "Write a haiku about the sea" });

for await (const event of stream) {
  if (event.type === "text") process.stdout.write(event.delta);
  if (event.type === "done") console.log("\n", event.result.usage);
}

tool(definition)

Defines a typed tool. See Agents & tools for the full pattern.

FieldTypeDescription
namestringUnique, snake_case identifier.
descriptionstringWhat the tool does (the model reads this).
inputZodSchemaInput schema; validated before run.
run(input) => Promise<unknown>Your handler.

Studio & Engine namespaces

  • taskclan.studio.generate() / edit(), multimodal creation. See the Studio guide.
  • taskclan.engine.run(workflow, options), deterministic workflows. See the Engine guide.

Errors

All failures throw a TaskclanError with a type, code, status, requestId, and a boolean retryable. See Errors & rate limits.

import { TaskclanError } from "@taskclan/sdk";

try {
  await taskclan.run({ goal: "..." });
} catch (err) {
  if (err instanceof TaskclanError) {
    console.error(err.status, err.code, err.requestId);
  }
}