Agent CommonsDocs

TypeScript SDK

@agent-commons/sdk — one typed client for the whole platform.

View sourceEdit
npm install @agent-commons/sdk

Zero runtime dependencies, ESM and CJS builds, full type declarations. Node 18+ or any runtime with fetch.

The client

import { CommonsClient } from '@agent-commons/sdk';
 
const commons = new CommonsClient({
  apiKey: process.env.COMMONS_API_KEY,
});
OptionDefaultPurpose
apiKeyBearer credential for platform calls
baseUrlhttps://api.agentcommons.ioPlatform origin
identityTokenCommons session token, for developer-project calls
identityUrlhttps://auth.agentcommons.ioIdentity origin
initiatorSent as x-initiator to act for a user
fetchglobal fetchInject your own implementation

Every call resolves to { data } unless noted, and throws CommonsError — carrying status and the parsed body — on a non-2xx response.

import { CommonsError } from '@agent-commons/sdk';
 
try {
  await commons.agents.get('agent_missing');
} catch (error) {
  if (error instanceof CommonsError && error.status === 404) {
    // …
  }
}

For a route the SDK does not yet wrap, drop to commons.request():

const result = await commons.request<{ data: unknown }>(
  'POST',
  '/v1/some/new/route',
  { hello: 'world' },
);

Agents

const { data: agent } = await commons.agents.create({
  name: 'Research Bot',
  instructions: 'You research topics and answer with sources.',
  modelProvider: 'anthropic',
  modelId: 'claude-sonnet-4-6',
  temperature: 0.3,
});
 
const { data: agents } = await commons.agents.list();
await commons.agents.update(agent.agentId, { temperature: 0.1 });
MethodPurpose
create · list · get · updateAgent CRUD
generateImageProduce durable image assets without a tool-selection turn
listTools · addTool · updateTool · removeToolManage the toolbelt
getKnowledgebase · updateKnowledgebaseAlways-on context
getPreferredConnections · addPreferredConnection · removePreferredConnectionPin peer agents this agent prefers to delegate to
getAutonomy · setAutonomy · triggerHeartbeat · triggerHeartbeat control
getRuntime · configureRuntime · deployRuntime · sleepRuntime · restartRuntime · manageRuntimeChannelManaged runtimes
listVoicesText-to-speech voices
createLiaisonSpawn a liaison agent

Running

Blocking

const result = await commons.run.once({
  agentId,
  messages: [{ role: 'user', content: 'Summarise this quarter.' }],
  sessionId,
});

Streaming

agents.stream is an async generator over StreamEvent.

for await (const event of commons.agents.stream({
  agentId,
  messages: [{ role: 'user', content: 'Research the EU AI Act.' }],
  provenance: { mode: 'metadata' },
})) {
  switch (event.type) {
    case 'token':
      process.stdout.write(event.content ?? '');
      break;
    case 'toolStart':
      console.log(`\n→ ${event.toolName}`);
      break;
    case 'final':
      console.log(`\nsession ${event.sessionId}`);
      break;
    case 'error':
      throw new Error(event.message);
  }
}

Events carry runId and a monotonic seq. Full list: stream events.

Caller-owned tools

Hand the agent functions that run on your side — the platform emits cli_tool_request and waits for you to post the result. This is exactly how agc chat exposes your local filesystem.

for await (const event of commons.agents.stream({
  agentId,
  messages,
  cliTools: [
    {
      name: 'readFile',
      description: 'Read a file from the local working directory',
      parameters: {
        type: 'object',
        properties: { path: { type: 'string' } },
        required: ['path'],
      },
    },
  ],
})) {
  if (event.type === 'cli_tool_request') {
    const output = await runLocally(event.toolName!, event.args);
    await commons.agents.submitCliToolResult(event.requestId!, output);
  }
}

Sessions

const { data: session } = await commons.sessions.create({ agentId, title: 'Q3 research' });
const { data: full } = await commons.sessions.getFull(session.sessionId);
await commons.sessions.rename(session.sessionId, 'Q3 research — final');

list · listByAgent · listByUser · create · get · getFull · getChat · rename · delete.

Tasks

const { data: task } = await commons.tasks.create({
  agentId,
  sessionId,
  title: 'Daily briefing',
  description: 'Summarise overnight news.',
  executionMode: 'single',
  cronExpression: '0 8 * * 1-5',
  isRecurring: true,
  createdBy: userId,
  createdByType: 'user',
});
 
for await (const event of commons.tasks.stream(task.taskId)) {
  console.log(event.type, event.status);
}

create · list · get · execute · cancel · update · reschedule · delete · stream.

Workflows

const { data: workflow } = await commons.workflows.create({
  name: 'Summarise a URL',
  definition: {
    nodes: [
      { id: 'in', type: 'input' },
      { id: 'fetch', type: 'tool', toolName: 'webSearch' },
      { id: 'write', type: 'agent_processor', agentId },
      { id: 'out', type: 'output' },
    ],
    edges: [
      { id: 'e1', source: 'in', target: 'fetch' },
      { id: 'e2', source: 'fetch', target: 'write' },
      { id: 'e3', source: 'write', target: 'out' },
    ],
  },
});
 
const { data: execution } = await commons.workflows.execute(workflow.workflowId, {
  inputData: { url: 'https://example.com' },
});
 
for await (const event of commons.workflows.stream(workflow.workflowId, execution.executionId)) {
  console.log(event.type, event.stage);
}

create · list · discoverPublic · get · update · delete · fork · execute · getExecution · listExecutions · cancelExecution · approveExecution · rejectExecution · stream · getWebhook · rotateWebhookToken · disableWebhook · executeWebhook.

Built-in templates come from a separate export:

import { listWorkflowTemplates, buildWorkflowTemplate } from '@agent-commons/sdk';

Tools

const { data: tool } = await commons.tools.create({
  name: 'weather_lookup',
  description: 'Get the current weather for a city',
  schema: {
    type: 'object',
    properties: { city: { type: 'string' } },
    required: ['city'],
  },
  apiSpec: {
    baseUrl: 'https://api.example.com',
    path: '/weather',
    method: 'GET',
    queryParams: { q: '{{city}}' },
    authType: 'api-key',
    authKeyName: 'X-API-Key',
  },
});
 
await commons.agents.addTool(agentId, { toolId: tool.toolId });
NamespaceMethods
toolslist · get · create · update · delete · listStatic
toolKeyslist · create · get · updateMetadata · updateValue · test · mapToTool · removeMapping · delete
toolPermissionsgrant · batchGrant · revoke · check · checkAgentAccess · list · listForTool · listForSubject · accessibleTools · transferOwnership

MCP

const server = await commons.mcp.createServer({
  name: 'Filesystem',
  connectionType: 'stdio',
  connectionConfig: {
    command: 'npx',
    args: ['@modelcontextprotocol/server-filesystem', '/Users/me/projects'],
  },
  ownerId: userId,
  ownerType: 'user',
});
 
await commons.mcp.connect(server.mcpServerId);
await commons.mcp.sync(server.mcpServerId);
const { data: tools } = await commons.mcp.listTools(server.mcpServerId);

listServers · createServer · getServer · updateServer · deleteServer · getMarketplace · getServerStatus · connect · disconnect · sync · listTools · listToolsByOwner · listResources · readResource · listPrompts · getPrompt.

Skills

const { data: skill } = await commons.skills.create({
  slug: 'weekly-report',
  name: 'Weekly report',
  description: 'Produce the standard weekly status report',
  instructions: '1. Pull last week…',
  tools: ['webSearch', 'createDocumentFile'],
  triggers: ['weekly report', 'status update'],
});
 
await commons.skills.setAgentAvailability(skill.skillId, agentId, true);

list · get · getIndex · listForAgent · setAgentAvailability · create · update · delete · import.

Memory

await commons.memory.create({
  agentId,
  content: 'The user prefers concise bullet-point answers.',
  memoryType: 'semantic',
});
 
const { data: hits } = await commons.memory.retrieve(
  agentId,
  'formatting preferences',
  5,
);

list · stats · retrieve · get · create · update · delete · createSharedScope · listSharedScopes.

Knowledge and files

const { data: space } = await commons.knowledge.createSpace({ name: 'Handbook' });
 
await commons.knowledge.createDocument(space.spaceId, {
  path: 'onboarding/day-one.md',
  title: 'Day one',
  content: '# Day one\n…',
});
 
const { data: results } = await commons.knowledge.search({ query: 'expense policy' });
const { data: uploaded } = await commons.files.upload(
  [{ name: 'report.pdf', data: fileBlob }],
  { agentId, sessionId },
);
 
const { data: text } = await commons.files.content(uploaded[0].fileId, { maxChars: 20_000 });
NamespaceMethods
knowledgeproviders · listSpaces · createSpace · getSpace · updateSpace · deleteSpace · grant · revokeGrant · listFolders · createFolder · moveFolder · deleteFolder · listDocuments · getDocument · createDocument · updateDocument · deleteDocument · importMarkdown · graph · search
filesupload · get · content
librarylist · get · download · preview · update · delete · grant · revokeGrant · createShareLink · revokeShareLink · resolveShare · storagePreference · setStoragePreference

Computers

await commons.agents.wakeComputer(agentId);
 
const { data: run } = await commons.agents.execComputer(agentId, {
  command: 'python analyse.py',
  cwd: '/workspace',
  timeoutSeconds: 300,
});
 
await commons.agents.sleepComputer(agentId);

getComputer · getComputerConfig · updateComputerConfig · wakeComputer · sleepComputer · restartComputer · resizeComputer · execComputer · readComputerFile · writeComputerFile · openComputerBrowser · testComputerBrowser · listComputerEvents.

Common Arcade

const { data: release } = await commons.arcade.publish(agentId, projectId);

status · list · create · get · write · test · publish. See Common Arcade.

Connections

const { data: providers } = await commons.oauth.listProviders();
 
const flow = await commons.oauth.connect({
  providerKey: 'google',
  scopes: ['https://www.googleapis.com/auth/gmail.send'],
});
// send the user to flow.authorizationUrl
 
const { data: connections } = await commons.oauth.listConnections();

listProviders · getProvider · connect · listConnections · getConnection · updateConnection · refresh · test · revoke.

A2A

const card = await commons.a2a.getAgentCard(agentId);
 
const task = await commons.a2a.sendTask(agentId, {
  message: { role: 'user', parts: [{ type: 'text', text: 'Research quantum computing' }] },
});
 
for await (const event of commons.a2a.stream(agentId, task.id)) {
  console.log(event.type);
}

getAgentCard · sendTask · getTask · cancelTask · listTasks · stream.

Wallets

const { data: wallet } = await commons.wallets.primary(agentId);
const { data: balance } = await commons.wallets.balance(wallet.walletId);
 
const paid = await commons.wallets.x402Fetch(agentId, {
  url: 'https://paid.example.com/dataset',
  method: 'GET',
});

list · primary · get · create · balance · transfer · x402Fetch · deactivate.

Provenance

const { data: report } = await commons.provenance.session(sessionId);
const { data: bundle } = await commons.provenance.bundle(traceId);

session · scope · bundle · anchor.

Accounts and observability

NamespaceMethods
authme
developerscopes · listProjects · createProject · listApiKeys · createApiKey · revokeApiKey
apiKeyscreate · list · revoke — legacy sk-ac- keys
usagegetAgentUsage · getSessionUsage
logslist · observability
activitylist
creditsbalance · ledger · summary · campaigns · claimCampaign · transfers · gift · grant · debit
billingcatalog · subscription · entitlements · invoices · paymentMethods · subscribe · topup · portal
flagsall · evaluate
modelslist
providerslist · configure · remove
uiPluginslist · getBySlug · create · setStatus · delete
spaceslist · create · get · getFull · update · delete · issueRtcTicket · listMembers · addMember · updateMember · removeMember · listMessages · sendMessage · updateMessage · deleteMessage
projectslist · create · get · writeFiles · publish · verify · exportToComputer · exportToGitHub
goalscreate · get · updateProgress
audiotranscribe
copilotget · updateSettings · listChanges · acceptChange · rejectChange · revertChange
liaisonscreate · interact

Types

Everything is exported from the package root — Agent, Session, StreamEvent, Workflow, WorkflowNode, Task, Tool, Skill, AgentMemory, KnowledgeSpace, LibraryItem, AgentComputer, OAuthConnection, AgentWallet, CreditBalance, PlanEntitlements, AgentCard, and the rest.

import type { Agent, StreamEvent, WorkflowNodeType } from '@agent-commons/sdk';

On this page