返回 Skill 列表
extension
分类: 开发与工程无需 API Key

libresource

libresource - 带有访问控制的类型化资源管理。ResourceIndex 通过基于策略的授权存储和检索资源。toInstance 将对象转换为类型化的实例。toResourceId 解析 URI 字符串。createResourceIndex 工厂。用于持久化结构化数据、管理实体和执行访问控制。

person作者: jakexiaohubgithub

libresource Skill

When to Use

  • Storing and retrieving typed resources
  • Managing entities with access control
  • Converting between resource formats
  • Building resource-based APIs

Key Concepts

ResourceIndex: Storage-backed index with policy enforcement for resource access.

Resource identifiers: URIs that identify resource type and instance (e.g., conversation:abc123).

toInstance: Converts plain objects to properly typed resource instances.

Usage Patterns

Pattern 1: Get resource

import { createResourceIndex } from "@copilot-ld/libresource";

const index = await createResourceIndex(storage, policyIndex);
const resource = await index.get("conversation:abc123", actor);

Pattern 2: Parse resource ID

import { toResourceId } from "@copilot-ld/libresource";

const id = toResourceId("conversation:abc123");
// { type: "conversation", id: "abc123" }

Integration

Used by Memory and Agent services. Works with libpolicy for access control.