veryfront 0.1.435 → 0.1.436

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.
Files changed (29) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/src/agent/index.d.ts +2 -1
  3. package/esm/src/agent/index.d.ts.map +1 -1
  4. package/esm/src/agent/index.js +2 -1
  5. package/esm/src/agent/runtime/index.d.ts +1 -0
  6. package/esm/src/agent/runtime/index.d.ts.map +1 -1
  7. package/esm/src/agent/runtime/index.js +1 -0
  8. package/esm/src/agent/runtime/model-tool-converter.d.ts.map +1 -1
  9. package/esm/src/agent/runtime/model-tool-converter.js +6 -2
  10. package/esm/src/agent/runtime/provider-tool-compat.d.ts +17 -0
  11. package/esm/src/agent/runtime/provider-tool-compat.d.ts.map +1 -0
  12. package/esm/src/agent/runtime/provider-tool-compat.js +177 -0
  13. package/esm/src/agent/runtime-project-skill-catalog.d.ts +26 -0
  14. package/esm/src/agent/runtime-project-skill-catalog.d.ts.map +1 -0
  15. package/esm/src/agent/runtime-project-skill-catalog.js +148 -0
  16. package/esm/src/utils/version-constant.d.ts +1 -1
  17. package/esm/src/utils/version-constant.js +1 -1
  18. package/package.json +1 -1
  19. package/src/deno.js +1 -1
  20. package/src/deps/esm.sh/@types/react-dom@19.2.3/client.d.ts +1 -1
  21. package/src/deps/esm.sh/@types/{react@19.2.3 → react@19.2.14}/global.d.ts +1 -0
  22. package/src/deps/esm.sh/@types/{react@19.2.3 → react@19.2.14}/index.d.ts +93 -24
  23. package/src/deps/esm.sh/react-dom@19.2.4/client.d.ts +1 -1
  24. package/src/src/agent/index.ts +15 -0
  25. package/src/src/agent/runtime/index.ts +9 -0
  26. package/src/src/agent/runtime/model-tool-converter.ts +11 -2
  27. package/src/src/agent/runtime/provider-tool-compat.ts +239 -0
  28. package/src/src/agent/runtime-project-skill-catalog.ts +238 -0
  29. package/src/src/utils/version-constant.ts +1 -1
@@ -0,0 +1,238 @@
1
+ import { basename } from "node:path";
2
+ import {
3
+ DEFAULT_PROJECT_STEERING_PATHS,
4
+ type ProjectSteeringPaths,
5
+ } from "./project-steering-mutation.js";
6
+ import type {
7
+ RuntimeGetProjectFileOptions,
8
+ RuntimeProjectFile,
9
+ RuntimeProjectFileListItem,
10
+ RuntimeProjectFilesApiOptions,
11
+ } from "./runtime-project-files-client.js";
12
+ import {
13
+ listRuntimeBuiltinSkillReferences,
14
+ readRuntimeBuiltinDirectorySkill,
15
+ readRuntimeBuiltinFlatSkill,
16
+ readRuntimeBuiltinSkillEntries,
17
+ } from "./runtime-builtin-skill-files.js";
18
+ import {
19
+ buildRuntimeSkillDefinition,
20
+ type RuntimeSkillDefinition,
21
+ type RuntimeSkillMetadataLogger,
22
+ } from "./runtime-skill-metadata.js";
23
+
24
+ export type RuntimeProjectSteeringLookup = {
25
+ projectId: string;
26
+ authToken: string;
27
+ branchId?: string | null;
28
+ };
29
+
30
+ export type RuntimeProjectSkillCatalogOptions = {
31
+ getProjectFile: (options: RuntimeGetProjectFileOptions) => Promise<RuntimeProjectFile | null>;
32
+ getProjectFiles: (
33
+ options: RuntimeProjectFilesApiOptions,
34
+ ) => Promise<readonly RuntimeProjectFileListItem[] | null>;
35
+ builtinSkills: readonly RuntimeSkillDefinition[];
36
+ steeringPaths?: Pick<ProjectSteeringPaths, "skills">;
37
+ logger?: RuntimeSkillMetadataLogger;
38
+ };
39
+
40
+ export type RuntimeProjectInstructionsOptions = {
41
+ getProjectFile: (options: RuntimeGetProjectFileOptions) => Promise<RuntimeProjectFile | null>;
42
+ steeringPaths?: Pick<ProjectSteeringPaths, "instructions">;
43
+ };
44
+
45
+ function sortSkillsById(skills: Iterable<RuntimeSkillDefinition>): RuntimeSkillDefinition[] {
46
+ return [...skills].sort((a, b) => a.id.localeCompare(b.id));
47
+ }
48
+
49
+ function getSkillPaths(options: Pick<RuntimeProjectSkillCatalogOptions, "steeringPaths">) {
50
+ return options.steeringPaths?.skills ?? DEFAULT_PROJECT_STEERING_PATHS.skills;
51
+ }
52
+
53
+ function getInstructionPaths(options: RuntimeProjectInstructionsOptions) {
54
+ return options.steeringPaths?.instructions ?? DEFAULT_PROJECT_STEERING_PATHS.instructions;
55
+ }
56
+
57
+ export function loadRuntimeBuiltinSkillCatalog(input: {
58
+ skillsDir: string;
59
+ logger?: RuntimeSkillMetadataLogger;
60
+ }): RuntimeSkillDefinition[] {
61
+ const entriesResult = readRuntimeBuiltinSkillEntries(input.skillsDir);
62
+ if (!entriesResult.ok) {
63
+ input.logger?.error?.("Failed to load built-in skills", {
64
+ error: entriesResult.errorMessage,
65
+ skillsDir: input.skillsDir,
66
+ });
67
+ return [];
68
+ }
69
+
70
+ return sortSkillsById(
71
+ entriesResult.entries.flatMap((entry) => {
72
+ if (entry.isFile() && entry.name.endsWith(".md")) {
73
+ const id = basename(entry.name, ".md");
74
+ const content = readRuntimeBuiltinFlatSkill(input.skillsDir, id);
75
+ if (content === null) {
76
+ return [];
77
+ }
78
+
79
+ const definition = buildRuntimeSkillDefinition({
80
+ id,
81
+ content,
82
+ logger: input.logger,
83
+ });
84
+
85
+ return definition ? [definition] : [];
86
+ }
87
+
88
+ if (entry.isDirectory()) {
89
+ const content = readRuntimeBuiltinDirectorySkill(input.skillsDir, entry.name);
90
+ if (content === null) {
91
+ return [];
92
+ }
93
+
94
+ const definition = buildRuntimeSkillDefinition({
95
+ id: entry.name,
96
+ content,
97
+ references: listRuntimeBuiltinSkillReferences(input.skillsDir, entry.name),
98
+ logger: input.logger,
99
+ });
100
+
101
+ return definition ? [definition] : [];
102
+ }
103
+
104
+ return [];
105
+ }),
106
+ );
107
+ }
108
+
109
+ export async function getRuntimeProjectInstructions(
110
+ input: RuntimeProjectSteeringLookup & RuntimeProjectInstructionsOptions,
111
+ ): Promise<string> {
112
+ for (const filePath of getInstructionPaths(input)) {
113
+ const file = await input.getProjectFile({
114
+ projectId: input.projectId,
115
+ authToken: input.authToken,
116
+ branchId: input.branchId,
117
+ path: filePath,
118
+ });
119
+
120
+ if (file?.content) {
121
+ return file.content;
122
+ }
123
+ }
124
+
125
+ return "";
126
+ }
127
+
128
+ export async function getRuntimeProjectSkillCatalog(
129
+ input: RuntimeProjectSteeringLookup & RuntimeProjectSkillCatalogOptions,
130
+ ): Promise<RuntimeSkillDefinition[]> {
131
+ const allFiles = await input.getProjectFiles({
132
+ projectId: input.projectId,
133
+ authToken: input.authToken,
134
+ branchId: input.branchId,
135
+ });
136
+ if (!allFiles || allFiles.length === 0) {
137
+ return [...input.builtinSkills];
138
+ }
139
+
140
+ const projectSkillsById = new Map<string, RuntimeSkillDefinition>();
141
+
142
+ for (const prefix of getSkillPaths(input)) {
143
+ const prefixWithSlash = `${prefix}/`;
144
+
145
+ const flatPaths = allFiles
146
+ .filter((file) => {
147
+ if (!file.path.startsWith(prefixWithSlash) || !file.path.endsWith(".md")) {
148
+ return false;
149
+ }
150
+
151
+ const relative = file.path.slice(prefixWithSlash.length);
152
+ return !relative.includes("/");
153
+ })
154
+ .map((file) => file.path);
155
+
156
+ const dirPaths = allFiles
157
+ .filter((file) => file.path.startsWith(prefixWithSlash) && file.path.endsWith("/SKILL.md"))
158
+ .map((file) => file.path);
159
+
160
+ const skillPaths = [...dirPaths.sort(), ...flatPaths.sort()];
161
+ if (skillPaths.length === 0) {
162
+ continue;
163
+ }
164
+
165
+ const skillFiles = await Promise.all(
166
+ skillPaths.map((path) =>
167
+ input.getProjectFile({
168
+ projectId: input.projectId,
169
+ authToken: input.authToken,
170
+ branchId: input.branchId,
171
+ path,
172
+ })
173
+ ),
174
+ );
175
+
176
+ for (const file of skillFiles) {
177
+ if (!file?.content) {
178
+ continue;
179
+ }
180
+
181
+ const isFlat = file.path.endsWith(".md") && !file.path.endsWith("/SKILL.md");
182
+ const id = getProjectSkillId(file.path, isFlat);
183
+ if (!id) {
184
+ continue;
185
+ }
186
+
187
+ const definition = buildRuntimeSkillDefinition({
188
+ id,
189
+ content: file.content,
190
+ references: getProjectSkillReferences({ allFiles, file, isFlat }),
191
+ logger: input.logger,
192
+ });
193
+
194
+ if (definition && !projectSkillsById.has(definition.id)) {
195
+ projectSkillsById.set(definition.id, definition);
196
+ }
197
+ }
198
+ }
199
+
200
+ if (projectSkillsById.size === 0) {
201
+ return [...input.builtinSkills];
202
+ }
203
+
204
+ const mergedSkillsById = new Map(input.builtinSkills.map((skill) => [skill.id, skill]));
205
+ for (const skill of projectSkillsById.values()) {
206
+ mergedSkillsById.set(skill.id, skill);
207
+ }
208
+
209
+ return sortSkillsById(mergedSkillsById.values());
210
+ }
211
+
212
+ function getProjectSkillId(path: string, isFlat: boolean): string | null {
213
+ const pathParts = path.split("/");
214
+ const fileName = pathParts.at(-1);
215
+ if (isFlat) {
216
+ return fileName ? basename(fileName, ".md") : null;
217
+ }
218
+
219
+ return pathParts.at(-2) ?? null;
220
+ }
221
+
222
+ function getProjectSkillReferences(input: {
223
+ allFiles: readonly RuntimeProjectFileListItem[];
224
+ file: RuntimeProjectFile;
225
+ isFlat: boolean;
226
+ }): string[] {
227
+ if (input.isFlat) {
228
+ return [];
229
+ }
230
+
231
+ const skillRootPrefix = input.file.path.replace(/SKILL\.md$/, "");
232
+ const refsPrefix = `${skillRootPrefix}references/`;
233
+
234
+ return input.allFiles
235
+ .filter((file) => file.path.startsWith(refsPrefix))
236
+ .map((file) => file.path.slice(skillRootPrefix.length))
237
+ .sort();
238
+ }
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.435";
3
+ export const VERSION = "0.1.436";