PerryLink/dsh-os--packages-contract ↗★ 1

@perrylink/dsh-os-contract

Canonical service names, capabilities, error codes, refs, result/error/audit protocol helpers and thin validators shared by dsh-os modules.

包名
@perrylink/dsh-os-contract
兼容性
待验证
版本
0.2.0
许可证
MIT
最近更新
2026年11月21日

安装

此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗

Usage

import {
  CAPABILITIES,
  ERROR_CODES,
  SERVICES,
  assertManifest,
  defineTool,
  isOsObject,
  makeRef,
  parseRef,
} from '@perrylink/dsh-os-contract'

SERVICES.trigger // 'triggers' → the module provides ctx.triggers
CAPABILITIES[0] // 'fs.read'
ERROR_CODES.E_NOT_FOUND // 'E_NOT_FOUND'

makeRef('memory', 'm-1') // 'dsh://memory/m-1'
parseRef('dsh://memory/m-1') // { kind: 'memory', id: 'm-1' }

isOsObject({ id: 'm-1', createdAt: Date.now() }) // true

assertManifest(pkg) // returns pkg, or throws E_INVALID_ARGUMENT

const tool = defineTool({
  name: 'snip_search',
  description: 'Search snippets.',
  parameters: { type: 'object', additionalProperties: false, properties: {} },
  output: {
    schema: { type: 'object', additionalProperties: true },
    render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }],
  },
  async execute(args) {
    return { items: [] }
  },
})