UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

49 lines (48 loc) • 2.15 kB
import { n as SkillResourceDeliverySchema } from "./skill-resources-MoEs_LGM.mjs"; import { Value } from "typebox/value"; import { Type } from "typebox"; //#region src/infra/node-claude-skill-protocol.ts const NODE_CLAUDE_SKILLS_CAPABILITY = "claude-cli-skills-v1"; const NODE_CLAUDE_SKILLS_MESSAGE_BYTES = 67108864; const NODE_CLAUDE_WORKSHOP_CALL_BYTES = NODE_CLAUDE_SKILLS_MESSAGE_BYTES; const NODE_CLAUDE_WORKSHOP_RESULT_BYTES = 131072; const closed = { additionalProperties: false }; const callId = Type.String({ minLength: 1, maxLength: 128 }); const NodeClaudeSkillInitSchema = Type.Object({ type: Type.Literal("init"), resources: Type.Optional(SkillResourceDeliverySchema), workshop: Type.Optional(Type.Object({ description: Type.String({ maxLength: 4096 }), inputSchema: Type.Record(Type.String(), Type.Unknown()) }, closed)) }, closed); const NodeClaudeSkillUpstreamSchema = Type.Union([Type.Object({ type: Type.Literal("stdout"), text: Type.String({ maxLength: 1048576 }) }, closed), Type.Object({ type: Type.Literal("workshop"), id: callId, arguments: Type.Unknown() }, closed)]); const NodeClaudeSkillResultSchema = Type.Object({ type: Type.Literal("result"), id: callId, result: Type.Unknown() }, closed); function encodeNodeClaudeSkillMessage(e, t) { const n = Buffer.from(JSON.stringify(e)); if (n.length > t) throw new Error("Claude node skill message exceeds its bounded transport limit."); return n; } function decodeNodeClaudeSkillInit(e) { if (e.byteLength > 67108864) throw new Error("Claude node skill initialization exceeds its transport limit."); const t = JSON.parse(Buffer.from(e).toString("utf8")); if (!Value.Check(NodeClaudeSkillInitSchema, t)) throw new Error("Invalid Claude node skill initialization."); if (t.workshop) encodeNodeClaudeSkillMessage(t.workshop, 16384); return t; } //#endregion export { NodeClaudeSkillResultSchema as a, encodeNodeClaudeSkillMessage as c, NODE_CLAUDE_WORKSHOP_RESULT_BYTES as i, NODE_CLAUDE_SKILLS_MESSAGE_BYTES as n, NodeClaudeSkillUpstreamSchema as o, NODE_CLAUDE_WORKSHOP_CALL_BYTES as r, decodeNodeClaudeSkillInit as s, NODE_CLAUDE_SKILLS_CAPABILITY as t };