AgentSkillsCN

libtype

libtype——共享的 Protocol Buffers 类型。这些类型由 proto/ 定义生成。命名空间包括 common、agent、memory、graph、vector、tool、trace、llm、resource。可通过 Type.fromObject() 进行创建。identifier() 方法可生成资源 ID。适用于类型化消息的创建、Protocol Buffers 数据结构的构建,以及跨服务类型的共享。

SKILL.md
--- frontmatter
name: libtype
description: >
  libtype - Shared Protocol Buffer types. Generated from proto/ definitions.
  Namespaces include common, agent, memory, graph, vector, tool, trace, llm,
  resource. Use Type.fromObject() for creation. identifier() method generates
  resource IDs. Use for typed message creation, protobuf data structures, and
  cross-service type sharing.

libtype Skill

When to Use

  • Creating typed protobuf messages
  • Sharing types across services
  • Working with gRPC request/response objects
  • Generating resource identifiers

Key Concepts

Namespaces: Types organized by domain (common, agent, memory, graph, etc.).

fromObject(): Preferred method to create type instances from plain objects.

identifier(): Method on common types to generate resource identifiers.

Usage Patterns

Pattern 1: Create typed message

javascript
import { agent, common } from "@copilot-ld/libtype";

const request = agent.Request.fromObject({
  resourceId: common.ResourceId.fromObject({
    type: "conversation",
    id: "abc123",
  }),
  content: "Hello, assistant!",
});

Pattern 2: Generate identifier

javascript
import { common } from "@copilot-ld/libtype";

const resourceId = common.ResourceId.fromObject({ type: "message" });
const id = resourceId.identifier(); // "message:uuid"

Integration

Generated by libcodegen from proto/ files. Used by all services and librpc.