@adhd/agent-base-types

中文文档
2.3.13发布于 2026/10/22MITTypeScriptESM + CJS零依赖近 30 天下载 1965

Shared TypeScript types and schemas for the @adhd/agent ecosystem

原始使用文档
文档目录6 节
  1. What it does
  2. Usage
  3. Key files
  4. R10 trace-signal types (additive, all optional)
  5. 2.0.2 changes
  6. Architecture

@adhd/agent-base-types

Shared TypeScript type definitions and schemas for the @adhd/agent-* family. Provides interfaces for agents, tasks, sessions, messages, usage, and validation schemas.

Status: Shared types (shipped v2.0.0)
Package: npm install @adhd/agent-base-types
Consumers: All agent-* packages

What it does

  • Core types — Agent, Task, Session, Message, TaskEvent interfaces
  • Token accounting — TokenUsage interface with provider-neutral fields (2.0.2+)
  • Response model — PostModelResponsePayload.responseModel carries the model id the provider says served a call (absent when not reported)
  • Validation schemas — Zod schemas for agent config, task input, message validation
  • Execution models — Status enums, stop-reason normalization, error types
  • MCP contract — Tool input/output schemas for the 16 MCP tools

Usage

import {
  Agent,
  Task,
  TokenUsage,
  agentCreateSchema,
} from '@adhd/agent-base-types';

const agentConfig = agentCreateSchema.parse({
  name: 'my-agent',
  config: { provider: 'anthropic', model: 'claude-opus-4-1' },
});

Key files

  • src/domain.ts — core interface definitions (Agent, Task, Session, Message, TokenUsage)
  • src/validation/ — Zod schemas for all inputs
  • src/index.ts — public exports

R10 trace-signal types (additive, all optional)

  • Hook events (HookEventMap in src/hooks.ts): task:startup (TaskStartupPayload: per-server MCP connect ms, tools-ready ms, queue wait, session ms, tool count), dispatch:completed (DispatchCompletedPayload: kind, sync/background mode, child task ids, parent blocked ms) and background:delivered (BackgroundDeliveredPayload; type only, no emitter yet). HookEvent is keyof HookEventMap, so these are accepted by HookRegistry with no further registration.
  • Payload fields: PreToolCallPayload gains concurrencyClass, turnIndex, groupIndex, queuedMs; PostToolCallPayload gains errorClass, resultBytes, noteAppended; the post:model_response payload gains thinkingConfig, thinkingBlocks, toolResultBytesIn, turnIndex (it already carried ttfbMs).
  • ToolDefinition.annotations (IToolAnnotations: readOnlyHint, destructiveHint, idempotentHint): engine-internal metadata. It must never be serialized onto a provider wire request or into the canonical tool hash.
  • IAnthropicThinking ({ type: 'adaptive'; display?: 'summarized' | 'omitted' } | { type: 'disabled' }) on the anthropic ProviderConfig and PartialBinding as thinking. Unset by default; validated by the orchestrator's providerConfigSchema.

2.0.2 changes

  • TokenUsage expansion — adds uncachedInputTokens, cacheReadTokens, cacheCreationTokens, reasoningTokens fields (provider-neutral accounting)
  • Added peakContextTokens to task_usage tracking

Architecture

  • Part of the 6-package agent framework family
  • Depends on: zod
  • Depended on by: All other @adhd/agent-* packages

See /entrypoint/agent-mcp/docs/architecture-and-security.md for the full agent runtime architecture.

版本与发布记录

@adhd/agent-base-types 共发布 22 个版本,首次发布于 2026/07/13;过去 12 个月发布了 22 个版本。

版本发布日期距今
2.3.13latest2026/10/2217 天前
2.3.122026/10/1524 天前
2.3.112026/10/1128 天前
2.3.102026/10/1029 天前
2.3.92026/10/1029 天前
2.3.82026/10/1029 天前

关于 @adhd/agent-base-types 的常见问题

@adhd/agent-base-types 是什么?

Shared TypeScript types and schemas for the @adhd/agent ecosystem

如何安装 @adhd/agent-base-types?

在项目目录运行 npm install @adhd/agent-base-types,或使用 pnpm add / yarn add / bun add。

@adhd/agent-base-types 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adhd/agent-base-types 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@adhd/agent-base-types 可以商用吗?

@adhd/agent-base-types 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adhd/agent-base-types 的下载量有多少?

根据 npm 官方下载统计,@adhd/agent-base-types 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,965 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adhd/agent-base-types 还在维护吗?

最新版本 2.3.13 发布于 2026/10/22(17 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/07/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。