nolo-cli 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -32
- package/agentRuntimeCommands.ts +3 -3
- package/commandRegistry.ts +2 -2
- package/machineCommands.ts +31 -6
- package/package.json +6 -8
- package/ai/agent/_executeModel.ts +0 -118
- package/ai/agent/agentSlice.ts +0 -525
- package/ai/agent/appWorkingMemory.ts +0 -126
- package/ai/agent/avatarUtils.ts +0 -24
- package/ai/agent/buildEditingContext.ts +0 -373
- package/ai/agent/buildSystemPrompt.ts +0 -532
- package/ai/agent/cleanAgentMessages.ts +0 -140
- package/ai/agent/cliChatClient.ts +0 -119
- package/ai/agent/cliExecutor.ts +0 -733
- package/ai/agent/cliPrompt.ts +0 -10
- package/ai/agent/contextCompiler.ts +0 -107
- package/ai/agent/contextLayerContract.ts +0 -44
- package/ai/agent/createAgentSchema.ts +0 -234
- package/ai/agent/executeToolCall.ts +0 -58
- package/ai/agent/fetchAgentContexts.ts +0 -42
- package/ai/agent/generatePrompt.ts +0 -3
- package/ai/agent/getFullChatContextKeys.ts +0 -168
- package/ai/agent/hooks/fetchPublicAgents.ts +0 -133
- package/ai/agent/hooks/useAgentConfig.ts +0 -61
- package/ai/agent/hooks/useAgentDialog.ts +0 -35
- package/ai/agent/hooks/useAgentFormValidation.ts +0 -202
- package/ai/agent/hooks/usePublicAgents.ts +0 -473
- package/ai/agent/machineRunPermissions.ts +0 -95
- package/ai/agent/persistMessageWithFixedId.ts +0 -37
- package/ai/agent/planSlice.ts +0 -259
- package/ai/agent/referenceUtils.ts +0 -229
- package/ai/agent/runAgentBackground.ts +0 -238
- package/ai/agent/runAgentClientLoop.ts +0 -138
- package/ai/agent/runtimeGuidance.ts +0 -97
- package/ai/agent/runtimeServerBase.ts +0 -37
- package/ai/agent/server/fetchPublicAgents.ts +0 -128
- package/ai/agent/startParallelAgentStreams.ts +0 -424
- package/ai/agent/startupProtocol.ts +0 -53
- package/ai/agent/streamAgentChatTurn.ts +0 -1278
- package/ai/agent/streamAgentChatTurnUtils.ts +0 -738
- package/ai/agent/types.ts +0 -71
- package/ai/agent/utils/imageOutput.ts +0 -33
- package/ai/agent/utils/sortUtils.ts +0 -250
- package/ai/agent/web/referencePickerUtils.ts +0 -146
- package/ai/ai.locale.ts +0 -1075
- package/ai/chat/accumulateToolCallChunks.ts +0 -95
- package/ai/chat/fetchUtils.native.ts +0 -276
- package/ai/chat/fetchUtils.ts +0 -153
- package/ai/chat/parseApiError.ts +0 -64
- package/ai/chat/parseMultilineSSE.ts +0 -95
- package/ai/chat/sendOpenAICompletionsRequest.native.ts +0 -682
- package/ai/chat/sendOpenAICompletionsRequest.ts +0 -703
- package/ai/chat/sendOpenAIResponseRequest.ts +0 -491
- package/ai/chat/shouldUseServerProxy.ts +0 -18
- package/ai/chat/sseClient.native.ts +0 -91
- package/ai/chat/sseClient.ts +0 -67
- package/ai/chat/streamReader.native.ts +0 -31
- package/ai/chat/streamReader.ts +0 -62
- package/ai/chat/updateTotalUsage.ts +0 -72
- package/ai/context/buildReferenceContext.ts +0 -437
- package/ai/context/calculateContextUsage.ts +0 -133
- package/ai/context/retention.ts +0 -165
- package/ai/context/tokenUtils.ts +0 -78
- package/ai/index.ts +0 -1
- package/ai/llm/calculateGeminiImageTokens.ts +0 -57
- package/ai/llm/deepinfra.ts +0 -28
- package/ai/llm/fireworks.ts +0 -50
- package/ai/llm/generateRequestBody.ts +0 -165
- package/ai/llm/getModelContextWindow.ts +0 -84
- package/ai/llm/getNoloKey.ts +0 -31
- package/ai/llm/getPricing.ts +0 -199
- package/ai/llm/hooks/useModelPricing.ts +0 -75
- package/ai/llm/imagePricing.ts +0 -40
- package/ai/llm/isResponseAPIModel.ts +0 -13
- package/ai/llm/mimo.ts +0 -71
- package/ai/llm/mistral.ts +0 -22
- package/ai/llm/modelAvatar.ts +0 -427
- package/ai/llm/models.ts +0 -45
- package/ai/llm/openrouterModels.ts +0 -269
- package/ai/llm/providers.ts +0 -306
- package/ai/llm/reasoningModels.ts +0 -28
- package/ai/llm/types.ts +0 -59
- package/ai/llm/usageRequestOptions.ts +0 -59
- package/ai/memory/capture.ts +0 -148
- package/ai/memory/consolidate.ts +0 -104
- package/ai/memory/delete.ts +0 -147
- package/ai/memory/overlay.ts +0 -84
- package/ai/memory/query.ts +0 -38
- package/ai/memory/queryShared.ts +0 -160
- package/ai/memory/rank.ts +0 -105
- package/ai/memory/recentRelationshipRecap.ts +0 -249
- package/ai/memory/remember.ts +0 -167
- package/ai/memory/runtime.ts +0 -76
- package/ai/memory/store.ts +0 -20
- package/ai/memory/storeShared.ts +0 -76
- package/ai/memory/types.ts +0 -46
- package/ai/memory/understanding.ts +0 -349
- package/ai/memory/understandingGreeting.ts +0 -264
- package/ai/messages/type.ts +0 -20
- package/ai/policy/personalizationDialog.ts +0 -333
- package/ai/policy/runtimePolicy.ts +0 -440
- package/ai/policy/selfUpdateFields.ts +0 -48
- package/ai/policy/types.ts +0 -64
- package/ai/skills/referenceRuntime.ts +0 -274
- package/ai/skills/skillDiagnostics.ts +0 -251
- package/ai/skills/skillDocBuilder.ts +0 -139
- package/ai/skills/skillDocProtocol.ts +0 -434
- package/ai/skills/skillReferenceSummary.ts +0 -63
- package/ai/skills/skillSummaryMarker.ts +0 -26
- package/ai/token/calculatePrice.ts +0 -544
- package/ai/token/db.ts +0 -98
- package/ai/token/externalToolCost.ts +0 -330
- package/ai/token/hooks/useRecords.ts +0 -65
- package/ai/token/missingUsageEstimate.ts +0 -42
- package/ai/token/modelUsageQuery.ts +0 -252
- package/ai/token/normalizeUsage.ts +0 -84
- package/ai/token/openaiImageGenerationUsage.ts +0 -56
- package/ai/token/prepareTokenUsageData.ts +0 -88
- package/ai/token/query.ts +0 -88
- package/ai/token/queryUserTokens.ts +0 -59
- package/ai/token/resolveBillingTarget.ts +0 -52
- package/ai/token/saveTokenRecord.ts +0 -53
- package/ai/token/serverDialogProjection.ts +0 -78
- package/ai/token/serverTokenWriter.ts +0 -143
- package/ai/token/stats.ts +0 -21
- package/ai/token/tokenThunks.ts +0 -24
- package/ai/token/types.ts +0 -93
- package/ai/tools/agent/agentTools.ts +0 -176
- package/ai/tools/agent/agentUpdateShared.ts +0 -311
- package/ai/tools/agent/callAgentTool.ts +0 -139
- package/ai/tools/agent/createAgentTool.ts +0 -512
- package/ai/tools/agent/createDialogTool.ts +0 -69
- package/ai/tools/agent/createSkillAgentTool.ts +0 -62
- package/ai/tools/agent/parallelBudget.ts +0 -221
- package/ai/tools/agent/presets/appBuilderPreset.ts +0 -145
- package/ai/tools/agent/runLlmTool.ts +0 -96
- package/ai/tools/agent/runStreamingAgentTool.ts +0 -73
- package/ai/tools/agent/skillAgentArgs.ts +0 -106
- package/ai/tools/agent/skillAgentPreset.ts +0 -89
- package/ai/tools/agent/streamParallelAgentsTool.ts +0 -122
- package/ai/tools/agent/updateAgentTool.ts +0 -96
- package/ai/tools/agent/updateSelfTool.ts +0 -113
- package/ai/tools/amazonProductScraperTool.ts +0 -86
- package/ai/tools/apifyActorClient.ts +0 -45
- package/ai/tools/appEditGuard.ts +0 -372
- package/ai/tools/appReadSnapshot.ts +0 -153
- package/ai/tools/appTools.ts +0 -1549
- package/ai/tools/applyEditTool.ts +0 -256
- package/ai/tools/applyLineEditsTool.ts +0 -312
- package/ai/tools/browserTools/click.ts +0 -33
- package/ai/tools/browserTools/closeSession.ts +0 -29
- package/ai/tools/browserTools/common.ts +0 -27
- package/ai/tools/browserTools/openSession.ts +0 -48
- package/ai/tools/browserTools/readContent.ts +0 -38
- package/ai/tools/browserTools/selectOption.ts +0 -46
- package/ai/tools/browserTools/typeText.ts +0 -42
- package/ai/tools/category/createCategoryTool.ts +0 -66
- package/ai/tools/category/queryContentsByCategoryTool.ts +0 -69
- package/ai/tools/category/updateContentCategoryTool.ts +0 -75
- package/ai/tools/cfBrowserTools.ts +0 -319
- package/ai/tools/cfSpeechToTextTool.ts +0 -49
- package/ai/tools/checkEnvTool.ts +0 -65
- package/ai/tools/cloudflareCrawlTool.ts +0 -289
- package/ai/tools/codeSearchTool.ts +0 -111
- package/ai/tools/codeTools.ts +0 -101
- package/ai/tools/createDocTool.ts +0 -132
- package/ai/tools/createPlanTool.ts +0 -999
- package/ai/tools/createSkillDocTool.ts +0 -155
- package/ai/tools/createWorkflowTool.ts +0 -154
- package/ai/tools/deepseekOcrTool.ts +0 -34
- package/ai/tools/delayTool.ts +0 -31
- package/ai/tools/deleteSpacesTool.ts +0 -325
- package/ai/tools/deleteSpacesToolModel.ts +0 -159
- package/ai/tools/devReloadUtils.ts +0 -29
- package/ai/tools/dialogMessageSearch.ts +0 -137
- package/ai/tools/doctorSkillTool.ts +0 -72
- package/ai/tools/ecommerceScraperTool.ts +0 -86
- package/ai/tools/emailTools.ts +0 -549
- package/ai/tools/evalSkillTool.ts +0 -92
- package/ai/tools/exaSearchTool.ts +0 -64
- package/ai/tools/execBashTool.ts +0 -379
- package/ai/tools/executeSqlTool.ts +0 -192
- package/ai/tools/fetchWebpageSupport.ts +0 -309
- package/ai/tools/fetchWebpageTool.ts +0 -84
- package/ai/tools/geminiImagePreviewTool.ts +0 -361
- package/ai/tools/generateDocxTool.ts +0 -215
- package/ai/tools/googleSearchScraperTool.ts +0 -106
- package/ai/tools/importDataTool.ts +0 -133
- package/ai/tools/importSkillTool.ts +0 -162
- package/ai/tools/index.ts +0 -1858
- package/ai/tools/listFilesTool.ts +0 -82
- package/ai/tools/listUserSpacesTool.ts +0 -113
- package/ai/tools/modelUsageTools.ts +0 -142
- package/ai/tools/olmOcrTool.ts +0 -34
- package/ai/tools/openaiImageTool.ts +0 -218
- package/ai/tools/paddleOcrTool.ts +0 -34
- package/ai/tools/prepareTools.ts +0 -23
- package/ai/tools/readDocTool.ts +0 -84
- package/ai/tools/readFileTool.ts +0 -211
- package/ai/tools/readTool.ts +0 -163
- package/ai/tools/readXPostTool.ts +0 -233
- package/ai/tools/rememberMemoryTool.ts +0 -84
- package/ai/tools/remotionVideoTool.ts +0 -151
- package/ai/tools/searchDialogMessagesTool.ts +0 -222
- package/ai/tools/searchRepoTool.ts +0 -115
- package/ai/tools/searchWorkspaceTool.ts +0 -259
- package/ai/tools/skillFollowup.ts +0 -86
- package/ai/tools/surfWeatherTool.ts +0 -169
- package/ai/tools/table/addTableRowTool.ts +0 -217
- package/ai/tools/table/createTableTool.ts +0 -315
- package/ai/tools/table/rowTools.ts +0 -366
- package/ai/tools/table/schemaTools.ts +0 -244
- package/ai/tools/table/shareTableTool.ts +0 -148
- package/ai/tools/table/toolShared.ts +0 -129
- package/ai/tools/toolApiClient.ts +0 -198
- package/ai/tools/toolNameAliases.ts +0 -57
- package/ai/tools/toolResultError.ts +0 -42
- package/ai/tools/toolRunSlice.ts +0 -303
- package/ai/tools/toolSchemaCompatibility.ts +0 -53
- package/ai/tools/toolVisibility.ts +0 -4
- package/ai/tools/types.ts +0 -20
- package/ai/tools/uiAskChoiceTool.ts +0 -104
- package/ai/tools/updateContentTitleTool.ts +0 -84
- package/ai/tools/updateDocTool.ts +0 -105
- package/ai/tools/updateUserPreferenceProfileTool.ts +0 -145
- package/ai/tools/whisperTool.ts +0 -77
- package/ai/tools/writeFileTool.ts +0 -210
- package/ai/tools/youtubeScraperTool.ts +0 -116
- package/ai/tools/ziweiChartTool.ts +0 -678
- package/ai/types.ts +0 -55
- package/ai/workflow/workflowExecutor.ts +0 -323
- package/ai/workflow/workflowSlice.ts +0 -73
- package/ai/workflow/workflowTypes.ts +0 -106
- package/client/compactDialog.ts +0 -222
- package/connector-experimental/capabilities.ts +0 -73
- package/connector-experimental/codexBinary.ts +0 -41
- package/connector-experimental/heartbeatLoop.ts +0 -22
- package/connector-experimental/index.ts +0 -5
- package/connector-experimental/machineInfo.ts +0 -46
- package/connector-experimental/protocol.ts +0 -54
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
import { dump as dumpYaml, load as loadYaml } from "js-yaml";
|
|
2
|
-
|
|
3
|
-
const SKILL_DOC_ENUMS = {
|
|
4
|
-
triggerMode: ["explicit", "required", "recommended"],
|
|
5
|
-
budgetTier: ["low", "medium", "high"],
|
|
6
|
-
modality: ["text", "image", "video", "audio", "3d"],
|
|
7
|
-
docKind: ["knowledge", "instruction", "skill"],
|
|
8
|
-
} as const;
|
|
9
|
-
|
|
10
|
-
type SkillDocEnumKey = keyof typeof SKILL_DOC_ENUMS;
|
|
11
|
-
|
|
12
|
-
export type SkillTriggerMode = (typeof SKILL_DOC_ENUMS.triggerMode)[number];
|
|
13
|
-
export type SkillBudgetTier = (typeof SKILL_DOC_ENUMS.budgetTier)[number];
|
|
14
|
-
export type SkillModality = (typeof SKILL_DOC_ENUMS.modality)[number];
|
|
15
|
-
export type SkillDocKind = (typeof SKILL_DOC_ENUMS.docKind)[number];
|
|
16
|
-
|
|
17
|
-
export interface SkillDocConfig {
|
|
18
|
-
version: "0.1";
|
|
19
|
-
kind: "skill";
|
|
20
|
-
id?: string;
|
|
21
|
-
name: string;
|
|
22
|
-
description: string;
|
|
23
|
-
triggerMode?: SkillTriggerMode;
|
|
24
|
-
toolNames?: string[];
|
|
25
|
-
preferredAgents?: string[];
|
|
26
|
-
budgetTier?: SkillBudgetTier;
|
|
27
|
-
dispatchPreferred?: boolean;
|
|
28
|
-
modalities?: SkillModality[];
|
|
29
|
-
requiredSkills?: string[];
|
|
30
|
-
recommendedSkills?: string[];
|
|
31
|
-
promptPatch?: string;
|
|
32
|
-
discover?: {
|
|
33
|
-
keywords?: string[];
|
|
34
|
-
examples?: string[];
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface SkillEvalCase {
|
|
39
|
-
input: string;
|
|
40
|
-
expectedTools?: string[];
|
|
41
|
-
expectedSignals?: string[];
|
|
42
|
-
forbiddenSignals?: string[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface SkillEvalConfig {
|
|
46
|
-
version: "0.1";
|
|
47
|
-
cases: SkillEvalCase[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface PageSkillMetadata {
|
|
51
|
-
kind?: SkillDocKind;
|
|
52
|
-
requiredSkills?: string[];
|
|
53
|
-
recommendedSkills?: string[];
|
|
54
|
-
skillConfig?: SkillDocConfig;
|
|
55
|
-
evalConfig?: SkillEvalConfig;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface ParsedSkillDocProtocol {
|
|
59
|
-
content: string;
|
|
60
|
-
meta?: PageSkillMetadata;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface ParsedExternalSkillMarkdown {
|
|
64
|
-
name?: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
compatibility?: string;
|
|
67
|
-
allowedTools: string[];
|
|
68
|
-
metadata?: Record<string, string>;
|
|
69
|
-
body: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const SKILL_CONFIG_BLOCK = "skill-config";
|
|
73
|
-
const EVAL_CONFIG_BLOCK = "eval-config";
|
|
74
|
-
|
|
75
|
-
const normalizeStringArray = (value: unknown): string[] | undefined => {
|
|
76
|
-
if (!Array.isArray(value)) return undefined;
|
|
77
|
-
const items = value
|
|
78
|
-
.filter((item): item is string => typeof item === "string")
|
|
79
|
-
.map((item) => item.trim())
|
|
80
|
-
.filter(Boolean);
|
|
81
|
-
return items.length > 0 ? Array.from(new Set(items)) : undefined;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const normalizeBoolean = (value: unknown): boolean | undefined =>
|
|
85
|
-
typeof value === "boolean" ? value : undefined;
|
|
86
|
-
|
|
87
|
-
const normalizeSkillEnumValue = <K extends SkillDocEnumKey>(
|
|
88
|
-
key: K,
|
|
89
|
-
value: unknown
|
|
90
|
-
): (typeof SKILL_DOC_ENUMS)[K][number] | undefined =>
|
|
91
|
-
typeof value === "string" &&
|
|
92
|
-
(SKILL_DOC_ENUMS[key] as readonly string[]).includes(value)
|
|
93
|
-
? (value as (typeof SKILL_DOC_ENUMS)[K][number])
|
|
94
|
-
: undefined;
|
|
95
|
-
|
|
96
|
-
const normalizeSkillModalities = (
|
|
97
|
-
value: unknown
|
|
98
|
-
): SkillModality[] | undefined => {
|
|
99
|
-
const raw = normalizeStringArray(value);
|
|
100
|
-
if (!raw) return undefined;
|
|
101
|
-
|
|
102
|
-
const filtered = raw.flatMap((item) => {
|
|
103
|
-
const modality = normalizeSkillEnumValue("modality", item);
|
|
104
|
-
return modality ? [modality] : [];
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return filtered.length > 0 ? Array.from(new Set(filtered)) : undefined;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const normalizeSkillConfig = (
|
|
111
|
-
value: unknown,
|
|
112
|
-
fallbackTools?: string[]
|
|
113
|
-
): SkillDocConfig | undefined => {
|
|
114
|
-
if (!value || typeof value !== "object") return undefined;
|
|
115
|
-
const record = value as Record<string, unknown>;
|
|
116
|
-
const name =
|
|
117
|
-
typeof record.name === "string" && record.name.trim()
|
|
118
|
-
? record.name.trim()
|
|
119
|
-
: "";
|
|
120
|
-
const description =
|
|
121
|
-
typeof record.description === "string" && record.description.trim()
|
|
122
|
-
? record.description.trim()
|
|
123
|
-
: "";
|
|
124
|
-
|
|
125
|
-
if (!name || !description) return undefined;
|
|
126
|
-
|
|
127
|
-
const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
|
|
128
|
-
const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
|
|
129
|
-
const modalities = normalizeSkillModalities(record.modalities);
|
|
130
|
-
|
|
131
|
-
const toolNames =
|
|
132
|
-
normalizeStringArray(record.toolNames) ??
|
|
133
|
-
normalizeStringArray(fallbackTools) ??
|
|
134
|
-
undefined;
|
|
135
|
-
|
|
136
|
-
const discover =
|
|
137
|
-
record.discover && typeof record.discover === "object"
|
|
138
|
-
? {
|
|
139
|
-
keywords: normalizeStringArray(
|
|
140
|
-
(record.discover as Record<string, unknown>).keywords
|
|
141
|
-
),
|
|
142
|
-
examples: normalizeStringArray(
|
|
143
|
-
(record.discover as Record<string, unknown>).examples
|
|
144
|
-
),
|
|
145
|
-
}
|
|
146
|
-
: undefined;
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
version: "0.1",
|
|
150
|
-
kind: "skill",
|
|
151
|
-
id:
|
|
152
|
-
typeof record.id === "string" && record.id.trim()
|
|
153
|
-
? record.id.trim()
|
|
154
|
-
: undefined,
|
|
155
|
-
name,
|
|
156
|
-
description,
|
|
157
|
-
triggerMode,
|
|
158
|
-
toolNames,
|
|
159
|
-
preferredAgents: normalizeStringArray(record.preferredAgents),
|
|
160
|
-
budgetTier,
|
|
161
|
-
dispatchPreferred: normalizeBoolean(record.dispatchPreferred),
|
|
162
|
-
modalities,
|
|
163
|
-
requiredSkills: normalizeStringArray(record.requiredSkills),
|
|
164
|
-
recommendedSkills: normalizeStringArray(record.recommendedSkills),
|
|
165
|
-
promptPatch:
|
|
166
|
-
typeof record.promptPatch === "string" && record.promptPatch.trim()
|
|
167
|
-
? record.promptPatch.trim()
|
|
168
|
-
: undefined,
|
|
169
|
-
discover:
|
|
170
|
-
discover?.keywords || discover?.examples ? discover : undefined,
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const normalizeEvalConfig = (value: unknown): SkillEvalConfig | undefined => {
|
|
175
|
-
if (!value || typeof value !== "object") return undefined;
|
|
176
|
-
const record = value as Record<string, unknown>;
|
|
177
|
-
if (!Array.isArray(record.cases)) return undefined;
|
|
178
|
-
const cases: SkillEvalCase[] = [];
|
|
179
|
-
for (const item of record.cases) {
|
|
180
|
-
if (!item || typeof item !== "object") continue;
|
|
181
|
-
const testCase = item as Record<string, unknown>;
|
|
182
|
-
const input =
|
|
183
|
-
typeof testCase.input === "string" && testCase.input.trim()
|
|
184
|
-
? testCase.input.trim()
|
|
185
|
-
: "";
|
|
186
|
-
if (!input) continue;
|
|
187
|
-
cases.push({
|
|
188
|
-
input,
|
|
189
|
-
expectedTools: normalizeStringArray(testCase.expectedTools),
|
|
190
|
-
expectedSignals: normalizeStringArray(testCase.expectedSignals),
|
|
191
|
-
forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals),
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return cases.length > 0
|
|
196
|
-
? {
|
|
197
|
-
version: "0.1",
|
|
198
|
-
cases,
|
|
199
|
-
}
|
|
200
|
-
: undefined;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const normalizePageSkillMetadata = (
|
|
204
|
-
value: unknown,
|
|
205
|
-
fallbackTools?: string[]
|
|
206
|
-
): PageSkillMetadata | undefined => {
|
|
207
|
-
if (!value || typeof value !== "object") return undefined;
|
|
208
|
-
const record = value as Record<string, unknown>;
|
|
209
|
-
const kind = normalizeSkillEnumValue("docKind", record.kind);
|
|
210
|
-
|
|
211
|
-
const meta: PageSkillMetadata = {
|
|
212
|
-
kind,
|
|
213
|
-
requiredSkills: normalizeStringArray(record.requiredSkills),
|
|
214
|
-
recommendedSkills: normalizeStringArray(record.recommendedSkills),
|
|
215
|
-
skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
|
|
216
|
-
evalConfig: normalizeEvalConfig(record.evalConfig),
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
if (meta.skillConfig && !meta.kind) {
|
|
220
|
-
meta.kind = "skill";
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return meta.kind ||
|
|
224
|
-
meta.requiredSkills ||
|
|
225
|
-
meta.recommendedSkills ||
|
|
226
|
-
meta.skillConfig ||
|
|
227
|
-
meta.evalConfig
|
|
228
|
-
? meta
|
|
229
|
-
: undefined;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const extractCommentBlock = (
|
|
233
|
-
markdown: string,
|
|
234
|
-
blockName: string
|
|
235
|
-
): string | undefined => {
|
|
236
|
-
if (!markdown) return undefined;
|
|
237
|
-
const matcher = new RegExp(
|
|
238
|
-
`<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
|
|
239
|
-
"i"
|
|
240
|
-
);
|
|
241
|
-
const match = markdown.match(matcher);
|
|
242
|
-
return typeof match?.[1] === "string" ? match[1].trim() : undefined;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const removeCommentBlock = (markdown: string, blockName: string): string =>
|
|
246
|
-
markdown.replace(
|
|
247
|
-
new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
|
|
248
|
-
"\n\n"
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const parseYamlObject = (raw: string | undefined): Record<string, unknown> | undefined => {
|
|
252
|
-
if (!raw) return undefined;
|
|
253
|
-
try {
|
|
254
|
-
const parsed = loadYaml(raw);
|
|
255
|
-
return parsed && typeof parsed === "object"
|
|
256
|
-
? (parsed as Record<string, unknown>)
|
|
257
|
-
: undefined;
|
|
258
|
-
} catch {
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
export const parseSkillDocProtocol = (
|
|
264
|
-
markdown: string | undefined,
|
|
265
|
-
existingMeta?: PageSkillMetadata,
|
|
266
|
-
fallbackTools?: string[]
|
|
267
|
-
): ParsedSkillDocProtocol => {
|
|
268
|
-
const source = typeof markdown === "string" ? markdown : "";
|
|
269
|
-
const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
|
|
270
|
-
const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
|
|
271
|
-
const cleanedContent = removeCommentBlock(
|
|
272
|
-
removeCommentBlock(source, SKILL_CONFIG_BLOCK),
|
|
273
|
-
EVAL_CONFIG_BLOCK
|
|
274
|
-
)
|
|
275
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
276
|
-
.trim();
|
|
277
|
-
|
|
278
|
-
const parsedMeta = normalizePageSkillMetadata(
|
|
279
|
-
{
|
|
280
|
-
...(existingMeta ?? {}),
|
|
281
|
-
...(skillBlock
|
|
282
|
-
? {
|
|
283
|
-
kind:
|
|
284
|
-
existingMeta?.kind === "skill" || skillBlock.kind === "skill"
|
|
285
|
-
? "skill"
|
|
286
|
-
: existingMeta?.kind,
|
|
287
|
-
requiredSkills:
|
|
288
|
-
skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
|
|
289
|
-
recommendedSkills:
|
|
290
|
-
skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
|
|
291
|
-
skillConfig: skillBlock,
|
|
292
|
-
}
|
|
293
|
-
: {}),
|
|
294
|
-
...(evalBlock ? { evalConfig: evalBlock } : {}),
|
|
295
|
-
},
|
|
296
|
-
fallbackTools
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
return {
|
|
300
|
-
content: cleanedContent,
|
|
301
|
-
meta: parsedMeta,
|
|
302
|
-
};
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
export const resolvePageSkillMetadata = (
|
|
306
|
-
page: {
|
|
307
|
-
content?: string | null;
|
|
308
|
-
meta?: unknown;
|
|
309
|
-
tools?: string[];
|
|
310
|
-
} | null | undefined
|
|
311
|
-
): PageSkillMetadata | undefined => {
|
|
312
|
-
if (!page) return undefined;
|
|
313
|
-
const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
|
|
314
|
-
return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const yamlBlock = (value: Record<string, unknown>): string =>
|
|
318
|
-
dumpYaml(value, { lineWidth: 120, noRefs: true }).trim();
|
|
319
|
-
|
|
320
|
-
export const buildSkillConfigComment = (config: SkillDocConfig): string => {
|
|
321
|
-
const payload: Record<string, unknown> = {
|
|
322
|
-
version: config.version,
|
|
323
|
-
kind: config.kind,
|
|
324
|
-
...(config.id ? { id: config.id } : {}),
|
|
325
|
-
name: config.name,
|
|
326
|
-
description: config.description,
|
|
327
|
-
...(config.triggerMode ? { triggerMode: config.triggerMode } : {}),
|
|
328
|
-
...(config.requiredSkills?.length
|
|
329
|
-
? { requiredSkills: config.requiredSkills }
|
|
330
|
-
: {}),
|
|
331
|
-
...(config.recommendedSkills?.length
|
|
332
|
-
? { recommendedSkills: config.recommendedSkills }
|
|
333
|
-
: {}),
|
|
334
|
-
...(config.toolNames?.length ? { toolNames: config.toolNames } : {}),
|
|
335
|
-
...(config.preferredAgents?.length
|
|
336
|
-
? { preferredAgents: config.preferredAgents }
|
|
337
|
-
: {}),
|
|
338
|
-
...(config.budgetTier ? { budgetTier: config.budgetTier } : {}),
|
|
339
|
-
...(typeof config.dispatchPreferred === "boolean"
|
|
340
|
-
? { dispatchPreferred: config.dispatchPreferred }
|
|
341
|
-
: {}),
|
|
342
|
-
...(config.modalities?.length ? { modalities: config.modalities } : {}),
|
|
343
|
-
...(config.discover?.keywords?.length ||
|
|
344
|
-
config.discover?.examples?.length
|
|
345
|
-
? {
|
|
346
|
-
discover: {
|
|
347
|
-
...(config.discover?.keywords?.length
|
|
348
|
-
? { keywords: config.discover.keywords }
|
|
349
|
-
: {}),
|
|
350
|
-
...(config.discover?.examples?.length
|
|
351
|
-
? { examples: config.discover.examples }
|
|
352
|
-
: {}),
|
|
353
|
-
},
|
|
354
|
-
}
|
|
355
|
-
: {}),
|
|
356
|
-
...(config.promptPatch ? { promptPatch: config.promptPatch } : {}),
|
|
357
|
-
};
|
|
358
|
-
return `<!-- ${SKILL_CONFIG_BLOCK}\n${yamlBlock(payload)}\n-->`;
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
export const buildEvalConfigComment = (config: SkillEvalConfig): string =>
|
|
362
|
-
`<!-- ${EVAL_CONFIG_BLOCK}\n${yamlBlock({
|
|
363
|
-
version: config.version,
|
|
364
|
-
cases: config.cases,
|
|
365
|
-
})}\n-->`;
|
|
366
|
-
|
|
367
|
-
export const buildSkillDocMarkdown = (options: {
|
|
368
|
-
body?: string;
|
|
369
|
-
skillConfig: SkillDocConfig;
|
|
370
|
-
evalConfig?: SkillEvalConfig;
|
|
371
|
-
}): string => {
|
|
372
|
-
const sections = [
|
|
373
|
-
options.body?.trim() || "",
|
|
374
|
-
buildSkillConfigComment(options.skillConfig),
|
|
375
|
-
options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
|
|
376
|
-
].filter(Boolean);
|
|
377
|
-
return sections.join("\n\n").trim();
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
const extractFrontmatter = (markdown: string): {
|
|
381
|
-
frontmatter?: Record<string, unknown>;
|
|
382
|
-
body: string;
|
|
383
|
-
} => {
|
|
384
|
-
const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
|
|
385
|
-
if (!match) return { body: markdown.trim() };
|
|
386
|
-
const frontmatter = parseYamlObject(match[1]);
|
|
387
|
-
const body = markdown.slice(match[0].length).trim();
|
|
388
|
-
return { frontmatter, body };
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
const normalizeAllowedTools = (value: unknown): string[] => {
|
|
392
|
-
if (Array.isArray(value)) {
|
|
393
|
-
return normalizeStringArray(value) ?? [];
|
|
394
|
-
}
|
|
395
|
-
if (typeof value === "string") {
|
|
396
|
-
return value
|
|
397
|
-
.split(/\s+/)
|
|
398
|
-
.map((item) => item.trim())
|
|
399
|
-
.filter(Boolean);
|
|
400
|
-
}
|
|
401
|
-
return [];
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
export const parseExternalSkillMarkdown = (
|
|
405
|
-
markdown: string
|
|
406
|
-
): ParsedExternalSkillMarkdown => {
|
|
407
|
-
const { frontmatter, body } = extractFrontmatter(markdown);
|
|
408
|
-
return {
|
|
409
|
-
name:
|
|
410
|
-
typeof frontmatter?.name === "string" && frontmatter.name.trim()
|
|
411
|
-
? frontmatter.name.trim()
|
|
412
|
-
: undefined,
|
|
413
|
-
description:
|
|
414
|
-
typeof frontmatter?.description === "string" &&
|
|
415
|
-
frontmatter.description.trim()
|
|
416
|
-
? frontmatter.description.trim()
|
|
417
|
-
: undefined,
|
|
418
|
-
compatibility:
|
|
419
|
-
typeof frontmatter?.compatibility === "string" &&
|
|
420
|
-
frontmatter.compatibility.trim()
|
|
421
|
-
? frontmatter.compatibility.trim()
|
|
422
|
-
: undefined,
|
|
423
|
-
allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
|
|
424
|
-
metadata:
|
|
425
|
-
frontmatter?.metadata && typeof frontmatter.metadata === "object"
|
|
426
|
-
? Object.fromEntries(
|
|
427
|
-
Object.entries(frontmatter.metadata as Record<string, unknown>)
|
|
428
|
-
.filter(([, value]) => typeof value === "string")
|
|
429
|
-
.map(([key, value]) => [key, String(value)])
|
|
430
|
-
)
|
|
431
|
-
: undefined,
|
|
432
|
-
body,
|
|
433
|
-
};
|
|
434
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { ReferenceItem } from "app/types";
|
|
2
|
-
|
|
3
|
-
import { resolvePageSkillMetadata } from "./skillDocProtocol";
|
|
4
|
-
import { joinUniqueStrings, type SkillRuntimePageLike } from "./referenceRuntime";
|
|
5
|
-
|
|
6
|
-
export type SkillReferenceSummary = {
|
|
7
|
-
dbKey: string;
|
|
8
|
-
title: string;
|
|
9
|
-
referenceType: ReferenceItem["type"];
|
|
10
|
-
skillId?: string;
|
|
11
|
-
skillName: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
toolNames: string[];
|
|
14
|
-
requiredSkills: string[];
|
|
15
|
-
recommendedSkills: string[];
|
|
16
|
-
promptPatch?: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const summarizeSkillReferences = (
|
|
20
|
-
references: ReferenceItem[] | undefined,
|
|
21
|
-
contentByKey: Map<string, SkillRuntimePageLike>
|
|
22
|
-
): SkillReferenceSummary[] => {
|
|
23
|
-
if (!Array.isArray(references) || references.length === 0) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return references.flatMap((reference) => {
|
|
28
|
-
const content = contentByKey.get(reference.dbKey);
|
|
29
|
-
const meta = resolvePageSkillMetadata(content);
|
|
30
|
-
const skillConfig = meta?.skillConfig;
|
|
31
|
-
|
|
32
|
-
if (meta?.kind !== "skill" && !skillConfig) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const skillName =
|
|
37
|
-
skillConfig?.name?.trim() ||
|
|
38
|
-
reference.title?.trim() ||
|
|
39
|
-
content?.title?.trim() ||
|
|
40
|
-
reference.dbKey;
|
|
41
|
-
|
|
42
|
-
return [
|
|
43
|
-
{
|
|
44
|
-
dbKey: reference.dbKey,
|
|
45
|
-
title: reference.title?.trim() || content?.title?.trim() || reference.dbKey,
|
|
46
|
-
referenceType: reference.type,
|
|
47
|
-
skillId: skillConfig?.id?.trim() || undefined,
|
|
48
|
-
skillName,
|
|
49
|
-
description: skillConfig?.description?.trim() || undefined,
|
|
50
|
-
toolNames: skillConfig?.toolNames ?? [],
|
|
51
|
-
requiredSkills: joinUniqueStrings(
|
|
52
|
-
meta?.requiredSkills,
|
|
53
|
-
skillConfig?.requiredSkills
|
|
54
|
-
),
|
|
55
|
-
recommendedSkills: joinUniqueStrings(
|
|
56
|
-
meta?.recommendedSkills,
|
|
57
|
-
skillConfig?.recommendedSkills
|
|
58
|
-
),
|
|
59
|
-
promptPatch: skillConfig?.promptPatch?.trim() || undefined,
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
});
|
|
63
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { PageSkillMetadata } from "./skillDocProtocol";
|
|
2
|
-
import type { SpaceContent } from "app/types";
|
|
3
|
-
|
|
4
|
-
export type SkillSummaryMarker = NonNullable<SpaceContent["skillSummary"]>;
|
|
5
|
-
|
|
6
|
-
export const buildSkillSummaryMarker = (
|
|
7
|
-
meta?: PageSkillMetadata | null
|
|
8
|
-
): SkillSummaryMarker | null => {
|
|
9
|
-
const skillConfig = meta?.skillConfig;
|
|
10
|
-
if (meta?.kind !== "skill" && !skillConfig) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
isSkill: true,
|
|
16
|
-
...(skillConfig?.id ? { skillId: skillConfig.id } : {}),
|
|
17
|
-
...(skillConfig?.name ? { name: skillConfig.name } : {}),
|
|
18
|
-
...(skillConfig?.description ? { description: skillConfig.description } : {}),
|
|
19
|
-
...(skillConfig?.toolNames?.length ? { toolNames: skillConfig.toolNames } : {}),
|
|
20
|
-
...(skillConfig?.triggerMode ? { triggerMode: skillConfig.triggerMode } : {}),
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const isSkillSummaryMarker = (
|
|
25
|
-
value: SpaceContent["skillSummary"] | undefined | null
|
|
26
|
-
): value is SkillSummaryMarker => Boolean(value?.isSkill);
|