Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
171 lines (149 loc) · 4.86 KB
/
Copy pathtypes.ts
File metadata and controls
171 lines (149 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import type { SkillHubTarget } from './agents'
import type { SkillSourceKind, SkillResolverKind, SkillTrustLevel } from '../shared/skill-render'
export type { SkillSourceKind, SkillResolverKind, SkillTrustLevel }
export type SkillHubGenerationMode = 'prepare' | 'manual'
export const DEFAULT_SKILL_HUB_GENERATION_MODE: SkillHubGenerationMode = 'prepare'
export const DEFAULT_REMOTE_TIMEOUT_MS = 1500
export const DEFAULT_REMOTE_CACHE_TTL_MS = 1000 * 60 * 60 * 24
export const DEFAULT_REMOTE_CONCURRENCY = 8
export const DEFAULT_WELL_KNOWN_MAX_FILES = 40
export const DEFAULT_WELL_KNOWN_MAX_BYTES = 512 * 1024
export const DEFAULT_WELL_KNOWN_MAX_FILE_BYTES = 128 * 1024
export function normalizeGenerationMode(value: string | undefined | null): SkillHubGenerationMode {
return value === 'manual' ? 'manual' : DEFAULT_SKILL_HUB_GENERATION_MODE
}
export interface SkillHubRemoteOptions {
enabled?: boolean
timeoutMs?: number
concurrency?: number
refresh?: boolean
cacheTtlMs?: number
githubHeuristics?: boolean
timings?: boolean
maxFiles?: number
maxBytes?: number
maxFileBytes?: number
}
export interface NormalizedSkillHubRemoteOptions {
enabled: boolean
timeoutMs: number
concurrency: number
refresh: boolean
cacheTtlMs: number
githubHeuristics: boolean
timings: boolean
maxFiles: number
maxBytes: number
maxFileBytes: number
}
function positiveNumber(value: unknown, fallback: number): number {
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback
}
function nonNegativeNumber(value: unknown, fallback: number): number {
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : fallback
}
function positiveInteger(value: unknown, fallback: number): number {
return typeof value === 'number' && Number.isFinite(value) && value > 0
? Math.floor(value)
: fallback
}
export function normalizeRemoteOptions(value: boolean | SkillHubRemoteOptions | undefined): NormalizedSkillHubRemoteOptions {
const options = typeof value === 'object' && value ? value : {}
const enabled = typeof value === 'boolean' ? value : options.enabled !== false
return {
enabled,
timeoutMs: positiveNumber(options.timeoutMs, DEFAULT_REMOTE_TIMEOUT_MS),
concurrency: positiveInteger(options.concurrency, DEFAULT_REMOTE_CONCURRENCY),
refresh: options.refresh === true,
cacheTtlMs: nonNegativeNumber(options.cacheTtlMs, DEFAULT_REMOTE_CACHE_TTL_MS),
githubHeuristics: options.githubHeuristics === true,
timings: options.timings === true,
maxFiles: positiveNumber(options.maxFiles, DEFAULT_WELL_KNOWN_MAX_FILES),
maxBytes: positiveNumber(options.maxBytes, DEFAULT_WELL_KNOWN_MAX_BYTES),
maxFileBytes: positiveNumber(options.maxFileBytes, DEFAULT_WELL_KNOWN_MAX_FILE_BYTES),
}
}
export interface SkillHubResolveStartContext {
skillName: string
packageCount: number
concurrency: number
remoteEnabled: boolean
githubHeuristics: boolean
}
export interface SkillHubResolvePackageContext {
skillName: string
packageName: string
packageIndex: number
packageCount: number
durationMs: number
resolver?: SkillResolverKind
sourceKind?: SkillSourceKind
contributionCount: number
skippedCount: number
}
export interface SkillHubResolveDoneContext extends SkillHubResolveStartContext {
durationMs: number
contributionCount: number
skippedCount: number
issueCount: number
resolverCounts: Partial<Record<SkillResolverKind, number>>
}
export interface ModuleOptions {
skillName?: string
targets?: SkillHubTarget[]
moduleAuthoring?: boolean
generationMode?: SkillHubGenerationMode
remote?: boolean | SkillHubRemoteOptions
}
export interface AgentSkillDeclaration {
name: string
path: string
}
export interface SkillHubContribution {
packageName: string
version?: string
sourceDir: string
skillName?: string
description?: string
sourceKind?: SkillSourceKind
sourceRepo?: string
sourceRef?: string
sourcePath?: string
repoUrl?: string
docsUrl?: string
official?: boolean
resolver?: SkillResolverKind
forceIncludeScripts?: boolean
}
export interface SkillHubContributionContext {
add: (contribution: SkillHubContribution) => void
}
export interface ResolvedContribution extends SkillHubContribution {
skillName: string
sourceRoot: string
sourceKind: SkillSourceKind
description?: string
repoUrl?: string
docsUrl?: string
official: boolean
resolver: SkillResolverKind
forceIncludeScripts: boolean
}
export type ValidationSeverity = 'warning'
export interface ValidationIssue {
severity: ValidationSeverity
packageName: string
skillName: string
reason: string
sourceKind?: SkillSourceKind
}
export interface ValidatedContribution {
contribution: ResolvedContribution
issues: ValidationIssue[]
}
export interface SkillManifestSkipped {
packageName: string
skillName: string
reason: string
sourceKind?: SkillSourceKind
}