Line data Source code
1 : import type {
2 : AgentSkill,
3 : AgentSkillPublishRequest
4 : } from '@comfyorg/ingest-types'
5 :
6 : /** The list route returns the user's packs with their full instruction bodies. */
7 : export type SkillPack = AgentSkill
8 :
9 : export type SkillPackPublishRequest = AgentSkillPublishRequest
10 :
11 : /** `maxLength` from the spec, counted in code points as JSON Schema defines it. */
12 2356 : export const MAX_DESCRIPTION_CODE_POINTS = 1024
13 : export const MAX_NAME_LENGTH = 64
14 :
15 : /** All-dot names are excluded because clients normalize `.` and `..` paths. */
16 2356 : export const PACK_NAME_PATTERN = /^[A-Za-z0-9._-]*[A-Za-z0-9_-][A-Za-z0-9._-]*$/
17 :
18 : /** Only always-on built-ins are reserved; on-demand built-ins are shadowable. */
19 2356 : export const RESERVED_PACK_NAMES = [
20 : 'building',
21 : 'comfy-cloud',
22 : 'canvas-tabs'
23 : ] as const
24 :
25 2356 : export const CONTROL_CHARACTERS = /[\p{Cc}\u2028\u2029]/u
26 :
27 0 : export function utf8ByteLength(value: string): number {
28 0 : return new TextEncoder().encode(value).length
29 : }
30 :
31 0 : export function codePointLength(value: string): number {
32 0 : return Array.from(value).length
33 : }
34 :
35 : /** Description + body, the unit the per-user total-bytes budget is counted in. */
36 0 : export function packByteSize(pack: {
37 : description: string
38 : body: string
39 : }): number {
40 0 : return utf8ByteLength(pack.description) + utf8ByteLength(pack.body)
41 : }
|