veryfront 0.1.498 → 0.1.499

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 (30) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/src/agent/index.d.ts +1 -0
  3. package/esm/src/agent/index.d.ts.map +1 -1
  4. package/esm/src/agent/index.js +1 -0
  5. package/esm/src/agent/veryfront-cloud-agent-service.d.ts +39 -0
  6. package/esm/src/agent/veryfront-cloud-agent-service.d.ts.map +1 -0
  7. package/esm/src/agent/veryfront-cloud-agent-service.js +482 -0
  8. package/esm/src/config/schemas/config.schema.d.ts +24 -0
  9. package/esm/src/config/schemas/config.schema.d.ts.map +1 -1
  10. package/esm/src/config/schemas/config.schema.js +48 -0
  11. package/esm/src/discovery/index.d.ts +1 -0
  12. package/esm/src/discovery/index.d.ts.map +1 -1
  13. package/esm/src/discovery/index.js +1 -0
  14. package/esm/src/discovery/project-discovery-config.d.ts +30 -0
  15. package/esm/src/discovery/project-discovery-config.d.ts.map +1 -0
  16. package/esm/src/discovery/project-discovery-config.js +33 -0
  17. package/esm/src/server/handlers/request/api/project-discovery.d.ts.map +1 -1
  18. package/esm/src/server/handlers/request/api/project-discovery.js +6 -22
  19. package/esm/src/utils/version-constant.d.ts +1 -1
  20. package/esm/src/utils/version-constant.js +1 -1
  21. package/esm/src/workflow/schemas/workflow.schema.d.ts +1 -1
  22. package/package.json +1 -1
  23. package/src/deno.js +1 -1
  24. package/src/src/agent/index.ts +8 -0
  25. package/src/src/agent/veryfront-cloud-agent-service.ts +761 -0
  26. package/src/src/config/schemas/config.schema.ts +48 -0
  27. package/src/src/discovery/index.ts +4 -0
  28. package/src/src/discovery/project-discovery-config.ts +89 -0
  29. package/src/src/server/handlers/request/api/project-discovery.ts +6 -27
  30. package/src/src/utils/version-constant.ts +1 -1
@@ -0,0 +1,482 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
2
+ import { existsSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { createHostedSandboxTools } from "../sandbox/index.js";
6
+ import { createRemoteMCPToolSource, createToolsFromRemoteDefinitions, sleepTool, toolRegistry, } from "../tool/index.js";
7
+ import { parseProviderError } from "../chat/provider-errors.js";
8
+ import { getConfig } from "../config/index.js";
9
+ import { clearTrackedAgents, clearTranspileCache, createProjectDiscoveryConfig, DEFAULT_PROJECT_DISCOVERY_DIRS, discoverAll, } from "../discovery/index.js";
10
+ import { nodeAdapter } from "../platform/adapters/node.js";
11
+ import { getVeryfrontCloudProviderFromModelId, resolveVeryfrontCloudModelId, resolveVeryfrontCloudThinkingProviderOptions, } from "../provider/index.js";
12
+ import { __registerTraceContextGetter } from "../utils/logger/logger.js";
13
+ import { buildAgentRunTraceAttributes, buildExecuteToolTraceAttributes, filterAgentTraceAttributes, } from "./agent-trace-attributes.js";
14
+ import { runAgentServiceMain, } from "./agent-service-bootstrap.js";
15
+ import { loadAgentServiceEnvFiles } from "./hosted-agent-service-env-files.js";
16
+ import { createHostedFormInputTool } from "./hosted-form-input-tool.js";
17
+ import { createHostedAgentProjectSteering } from "./hosted-agent-project-steering.js";
18
+ import { createLiveStudioMcpTools } from "./live-studio-mcp-tools.js";
19
+ import { createDefaultHostedChatRuntime, } from "./default-hosted-chat-runtime.js";
20
+ import { createDefaultHostedInvokeAgentTool } from "./default-hosted-invoke-agent-tool.js";
21
+ import { createDefaultHostedProjectSteeringRefresh, fetchDefaultHostedProjectSteering, } from "./default-hosted-project-steering-refresh.js";
22
+ import { buildVeryfrontCloudRuntimeInstructions, } from "./veryfront-cloud-runtime-system-messages.js";
23
+ import { createNodeAgentServiceRuntimeInfrastructure, } from "./node-hosted-agent-service-runtime-infrastructure.js";
24
+ import { createAgentServiceRuntime, startNodeAgentService, } from "./hosted-agent-service-runtime.js";
25
+ import { createDetachedRunTracker } from "./detached-run-tracker.js";
26
+ import { runPreparedHostedChatExecutionDetached, streamPreparedHostedChatExecutionToAgUiResponse, } from "./prepared-hosted-chat-execution.js";
27
+ import { createVeryfrontCloudPreparedHostedChatExecutionRuntimeOptions, } from "./veryfront-cloud-prepared-hosted-chat-execution-runtime.js";
28
+ import { prepareVeryfrontCloudHostedChatExecution, } from "./veryfront-cloud-hosted-chat-execution-preparation.js";
29
+ import { applyAgentProjectContextChange } from "./project-context.js";
30
+ import { agentRegistry, getAgent } from "./composition/index.js";
31
+ const DEFAULT_FORWARDED_CONFIG_NAMESPACE = "veryfront";
32
+ const DEFAULT_DRAIN_TIMEOUT_MS = 15_000;
33
+ const DEFAULT_HARD_SHUTDOWN_TIMEOUT_MS = 20_000;
34
+ const DEFAULT_PROJECT_NAVIGATION_TOOL_NAMES = ["studio_open_project"];
35
+ const PROJECT_CONFIG_FILES = [
36
+ "veryfront.config.js",
37
+ "veryfront.config.ts",
38
+ "veryfront.config.mjs",
39
+ ];
40
+ function resolveBaseDir(options) {
41
+ if (options.baseDir) {
42
+ return options.baseDir;
43
+ }
44
+ if (options.entryUrl) {
45
+ return dirname(fileURLToPath(options.entryUrl));
46
+ }
47
+ if (typeof process !== "undefined") {
48
+ return process.cwd();
49
+ }
50
+ return dntShim.Deno.cwd();
51
+ }
52
+ function hasDiscoveryRoot(baseDir) {
53
+ const discoveryDirs = [
54
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.agentDirs,
55
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.toolDirs,
56
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.skillDirs,
57
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.resourceDirs,
58
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.promptDirs,
59
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.workflowDirs,
60
+ ...DEFAULT_PROJECT_DISCOVERY_DIRS.taskDirs,
61
+ ];
62
+ return discoveryDirs.some((dir) => existsSync(resolve(baseDir, dir))) ||
63
+ PROJECT_CONFIG_FILES.some((file) => existsSync(resolve(baseDir, file)));
64
+ }
65
+ function uniquePaths(paths) {
66
+ return [...new Set(paths.map((path) => resolve(path)))];
67
+ }
68
+ function resolveProjectDir(options) {
69
+ if (options.projectDir) {
70
+ return options.projectDir;
71
+ }
72
+ const baseDir = resolveBaseDir(options);
73
+ const candidates = uniquePaths([baseDir, dirname(baseDir), dirname(dirname(baseDir))]);
74
+ return candidates.find(hasDiscoveryRoot) ?? baseDir;
75
+ }
76
+ function resolveDefaultProcessTarget() {
77
+ if (typeof process === "undefined") {
78
+ return undefined;
79
+ }
80
+ return process;
81
+ }
82
+ function resolveEnvironment(options) {
83
+ if (options.env) {
84
+ return options.env;
85
+ }
86
+ if (options.processTarget?.env) {
87
+ return options.processTarget.env;
88
+ }
89
+ if (typeof process !== "undefined") {
90
+ return process.env;
91
+ }
92
+ return {};
93
+ }
94
+ function createNodeVeryfrontCloudAgentServiceContext(options) {
95
+ const processTarget = options.processTarget ?? resolveDefaultProcessTarget();
96
+ const infrastructure = createNodeAgentServiceRuntimeInfrastructure({
97
+ serviceName: options.serviceName,
98
+ env: resolveEnvironment({ env: options.env, processTarget }),
99
+ processTarget,
100
+ });
101
+ function trace(operationName, operation) {
102
+ return infrastructure.tracer.trace(operationName, operation);
103
+ }
104
+ const projectSteering = createHostedAgentProjectSteering({
105
+ baseDir: resolveBaseDir(options),
106
+ agentId: options.agentId,
107
+ getApiUrl: () => infrastructure.getConfig().VERYFRONT_API_URL,
108
+ logger: infrastructure.logger,
109
+ trace,
110
+ });
111
+ return {
112
+ options,
113
+ processTarget,
114
+ projectDir: resolveProjectDir(options),
115
+ infrastructure,
116
+ trace,
117
+ projectSteering,
118
+ tracker: createDetachedRunTracker(),
119
+ discoveryResult: null,
120
+ agentConfig: null,
121
+ };
122
+ }
123
+ function resolveAgentSystem(system) {
124
+ return typeof system === "function" ? system() : system;
125
+ }
126
+ async function createRuntimeAgentDefinitionFromCodeAgent(codeAgent) {
127
+ return {
128
+ id: codeAgent.id,
129
+ name: codeAgent.id,
130
+ description: "",
131
+ instructions: await resolveAgentSystem(codeAgent.config.system),
132
+ model: codeAgent.config.model,
133
+ maxSteps: codeAgent.config.maxSteps,
134
+ };
135
+ }
136
+ function getMarkdownAgentConfig(context) {
137
+ return context.projectSteering.getAgentConfig();
138
+ }
139
+ async function resolveAgentConfig(context) {
140
+ const source = context.options.agentSource ?? "auto";
141
+ const codeAgent = getAgent(context.options.agentId);
142
+ if (source !== "markdown" && codeAgent) {
143
+ return await createRuntimeAgentDefinitionFromCodeAgent(codeAgent);
144
+ }
145
+ if (source === "code") {
146
+ throw new Error(`Code agent "${context.options.agentId}" was not discovered.`);
147
+ }
148
+ return getMarkdownAgentConfig(context);
149
+ }
150
+ function getResolvedAgentConfig(context) {
151
+ if (!context.agentConfig) {
152
+ throw new Error("Agent service context has not been initialized.");
153
+ }
154
+ return context.agentConfig;
155
+ }
156
+ async function discoverProjectPrimitives(context) {
157
+ clearTrackedAgents();
158
+ clearTranspileCache();
159
+ agentRegistry.clear();
160
+ toolRegistry.clear();
161
+ const config = await getConfig(context.projectDir, nodeAdapter);
162
+ const discoveryOptions = createProjectDiscoveryConfig({
163
+ projectDir: context.projectDir,
164
+ config,
165
+ });
166
+ context.discoveryResult = await discoverAll(discoveryOptions);
167
+ }
168
+ async function initializeNodeVeryfrontCloudAgentServiceContext(context) {
169
+ await discoverProjectPrimitives(context);
170
+ context.agentConfig = await resolveAgentConfig(context);
171
+ }
172
+ function getDiscoveredHostTools() {
173
+ return Object.fromEntries([...toolRegistry.getAll()].sort(([left], [right]) => left.localeCompare(right)));
174
+ }
175
+ function getProjectInstructions(context, lookup) {
176
+ return context.trace("chat.getProjectInstructions", async () => {
177
+ return await context.projectSteering.getProjectInstructions(lookup);
178
+ });
179
+ }
180
+ function getSkillsConfig(context, lookup) {
181
+ return context.trace("chat.getSkillsConfig", async () => {
182
+ return await context.projectSteering.getSkillsConfig(lookup);
183
+ });
184
+ }
185
+ function createLoadSkillTool(context, toolContext) {
186
+ return context.projectSteering.createLoadSkillTool(toolContext);
187
+ }
188
+ async function refreshProjectSkillIds(context, skillContext) {
189
+ await context.projectSteering.refreshProjectSkillIds(skillContext);
190
+ }
191
+ function setFilteredTraceAttributes(context, attributes) {
192
+ context.infrastructure.setActiveSpanAttributes(filterAgentTraceAttributes(attributes));
193
+ }
194
+ function getInvokeAgentConfig(context) {
195
+ const config = context.infrastructure.getConfig();
196
+ return {
197
+ apiUrl: config.VERYFRONT_API_URL,
198
+ apiMcpUrl: config.VERYFRONT_MCP_URL,
199
+ studioMcpUrl: config.VERYFRONT_STUDIO_MCP_URL,
200
+ enableDurableInvokeAgent: config.VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT,
201
+ };
202
+ }
203
+ function shouldRethrowInvokeAgentError(error) {
204
+ return parseProviderError(error).code === "INSUFFICIENT_CREDITS";
205
+ }
206
+ function createInvokeAgentTool(context, childContext) {
207
+ return createDefaultHostedInvokeAgentTool({
208
+ context: childContext,
209
+ getConfig: () => getInvokeAgentConfig(context),
210
+ logger: context.infrastructure.logger,
211
+ trace: context.trace,
212
+ setTraceAttributes: context.infrastructure.setActiveSpanAttributes,
213
+ createBashTool: context.options.createBashTool,
214
+ resolveModelId: resolveVeryfrontCloudModelId,
215
+ resolveProvider: getVeryfrontCloudProviderFromModelId,
216
+ resolveProviderOptions: resolveVeryfrontCloudThinkingProviderOptions,
217
+ shouldRethrowError: shouldRethrowInvokeAgentError,
218
+ buildGlobalTools: (globalToolContext) => ({
219
+ load_skill: createLoadSkillTool(context, globalToolContext),
220
+ }),
221
+ refreshProjectSkillIds: (projectSkillContext) => refreshProjectSkillIds(context, projectSkillContext),
222
+ createHostedSandboxTools,
223
+ createLiveStudioTools: createLiveStudioMcpTools,
224
+ createRemoteToolSource: createRemoteMCPToolSource,
225
+ createToolsFromRemoteDefinitions,
226
+ });
227
+ }
228
+ function buildLocalTools(context, options, taskContext) {
229
+ const config = context.infrastructure.getConfig();
230
+ const tools = {
231
+ ...getDiscoveredHostTools(),
232
+ form_input: createHostedFormInputTool(taskContext, config.VERYFRONT_API_URL),
233
+ load_skill: createLoadSkillTool(context, taskContext),
234
+ sleep: sleepTool,
235
+ };
236
+ if (options.allowDelegation !== false) {
237
+ tools.invoke_agent = createInvokeAgentTool(context, taskContext);
238
+ }
239
+ return tools;
240
+ }
241
+ function createProjectSteeringRefresh(context) {
242
+ return createDefaultHostedProjectSteeringRefresh({
243
+ fetchProjectInstructions: (lookup) => getProjectInstructions(context, lookup),
244
+ fetchSkills: (lookup) => getSkillsConfig(context, lookup),
245
+ buildInstructions: buildVeryfrontCloudRuntimeInstructions,
246
+ projectScopedRemoteToolOptions: {
247
+ projectNavigationToolNames: DEFAULT_PROJECT_NAVIGATION_TOOL_NAMES,
248
+ },
249
+ logger: context.infrastructure.logger,
250
+ });
251
+ }
252
+ function createAgentRuntime(context, options) {
253
+ const config = context.infrastructure.getConfig();
254
+ const refreshSystem = createProjectSteeringRefresh(context);
255
+ return createDefaultHostedChatRuntime({
256
+ options,
257
+ config: {
258
+ apiUrl: config.VERYFRONT_API_URL,
259
+ apiMcpUrl: config.VERYFRONT_MCP_URL,
260
+ studioMcpUrl: config.VERYFRONT_STUDIO_MCP_URL,
261
+ },
262
+ buildLocalTools: (taskContext) => buildLocalTools(context, options, taskContext),
263
+ refreshSystem,
264
+ onSteeringMutation: async ({ mutation, taskContext }) => {
265
+ if (mutation.skillsChanged) {
266
+ await refreshProjectSkillIds(context, {
267
+ ...taskContext,
268
+ authToken: taskContext.authToken,
269
+ });
270
+ }
271
+ },
272
+ onStudioProjectSwitch: async ({ projectId, taskContext }) => {
273
+ if (!applyAgentProjectContextChange(taskContext, projectId)) {
274
+ return false;
275
+ }
276
+ await refreshProjectSkillIds(context, {
277
+ ...taskContext,
278
+ authToken: taskContext.authToken,
279
+ });
280
+ return true;
281
+ },
282
+ projectScopedRemoteToolOptions: {
283
+ projectNavigationToolNames: DEFAULT_PROJECT_NAVIGATION_TOOL_NAMES,
284
+ },
285
+ createRemoteToolSource: createRemoteMCPToolSource,
286
+ traceLocalTools: {
287
+ trace: (spanName, operation) => context.infrastructure.tracer.trace(spanName, operation),
288
+ buildAttributes: ({ toolName, toolCallId }) => buildExecuteToolTraceAttributes({
289
+ toolName,
290
+ toolCallId,
291
+ }),
292
+ setAttributes: (attributes) => setFilteredTraceAttributes(context, attributes),
293
+ },
294
+ logger: context.infrastructure.logger,
295
+ });
296
+ }
297
+ function setPrepareChatExecutionStartAttributes(context, input) {
298
+ const span = context.infrastructure.tracer.scope().active();
299
+ span?.setAttributes({
300
+ "chat.projectId": input.projectId ?? "none",
301
+ "chat.userId": input.userId,
302
+ });
303
+ }
304
+ function setPrepareChatExecutionResultAttributes(context, input) {
305
+ const span = context.infrastructure.tracer.scope().active();
306
+ span?.setAttributes(buildAgentRunTraceAttributes({
307
+ operationName: "chat",
308
+ conversationId: input.conversationId,
309
+ projectId: input.projectId,
310
+ userId: input.userId,
311
+ agentId: input.agentId,
312
+ runId: input.runId,
313
+ parentConversationId: input.upstreamParentConversationId,
314
+ parentRunId: input.upstreamParentRunId,
315
+ toolCallId: input.spawnedFromToolCallId,
316
+ }));
317
+ span?.setAttributes({
318
+ "agent.runtime.kind": input.runtimeKind,
319
+ });
320
+ }
321
+ function fetchProjectSteering(context, input) {
322
+ return fetchDefaultHostedProjectSteering({
323
+ ...input,
324
+ fetchProjectInstructions: (lookup) => getProjectInstructions(context, lookup),
325
+ fetchSkills: (lookup) => getSkillsConfig(context, lookup),
326
+ trace: context.trace,
327
+ traceOperationName: "chat.fetchSteering",
328
+ });
329
+ }
330
+ async function prepareChatExecution(context, req) {
331
+ const { userId, authToken, projectId, conversationId, upstreamParentConversationId, upstreamParentRunId, spawnedFromToolCallId, } = req;
332
+ const config = context.infrastructure.getConfig();
333
+ setPrepareChatExecutionStartAttributes(context, { projectId, userId });
334
+ const agentConfig = getResolvedAgentConfig(context);
335
+ const { effectiveMessages, rootRunContext, runtime: { agent, runtimeKind, modelId, cleanup }, finalMessages, } = await prepareVeryfrontCloudHostedChatExecution({
336
+ request: req,
337
+ agentConfig,
338
+ apiUrl: config.VERYFRONT_API_URL,
339
+ abortSignal: new AbortController().signal,
340
+ logger: context.infrastructure.logger,
341
+ rootRun: {
342
+ instrumentation: {
343
+ trace: context.trace,
344
+ setTraceAttributes: context.infrastructure.setActiveSpanAttributes,
345
+ debug: (message, metadata) => context.infrastructure.logger.debug(message, metadata),
346
+ warn: (message, metadata) => context.infrastructure.logger.warn(message, metadata),
347
+ error: (message, metadata) => context.infrastructure.logger.error(message, metadata),
348
+ },
349
+ },
350
+ fetchSteering: (steeringInput) => fetchProjectSteering(context, steeringInput),
351
+ buildInstructions: buildVeryfrontCloudRuntimeInstructions,
352
+ createRuntime: (creationOptions) => context.trace("chat.createRuntime", () => createAgentRuntime(context, {
353
+ ...creationOptions,
354
+ userId: req.userId,
355
+ })),
356
+ });
357
+ setPrepareChatExecutionResultAttributes(context, {
358
+ conversationId,
359
+ projectId,
360
+ userId,
361
+ agentId: agentConfig.id,
362
+ runId: rootRunContext.durableRootRun?.runId,
363
+ upstreamParentConversationId,
364
+ upstreamParentRunId,
365
+ spawnedFromToolCallId,
366
+ runtimeKind,
367
+ });
368
+ return {
369
+ config,
370
+ agent,
371
+ agentId: agentConfig.id,
372
+ runtimeKind,
373
+ modelId,
374
+ cleanup,
375
+ messages: effectiveMessages,
376
+ finalMessages,
377
+ conversationId,
378
+ authToken,
379
+ projectId,
380
+ userId,
381
+ rootRunContext,
382
+ upstreamParentConversationId,
383
+ upstreamParentRunId,
384
+ spawnedFromToolCallId,
385
+ };
386
+ }
387
+ function createPreparedExecutionRuntimeOptions(context, config) {
388
+ return createVeryfrontCloudPreparedHostedChatExecutionRuntimeOptions({
389
+ apiUrl: config.VERYFRONT_API_URL,
390
+ tracer: context.infrastructure.tracer,
391
+ trace: context.trace,
392
+ traceStream: (operation) => context.infrastructure.tracer.trace("chat.stream", operation),
393
+ logger: context.infrastructure.logger,
394
+ setActiveSpanAttributes: context.infrastructure.setActiveSpanAttributes,
395
+ });
396
+ }
397
+ function createNodeVeryfrontCloudAgentServiceRuntimeOptions(context) {
398
+ return {
399
+ serviceName: context.options.serviceName,
400
+ forwardedConfigNamespace: context.options.forwardedConfigNamespace ??
401
+ DEFAULT_FORWARDED_CONFIG_NAMESPACE,
402
+ getConfig: context.infrastructure.getConfig,
403
+ getAgentConfig: () => getResolvedAgentConfig(context),
404
+ tracker: context.tracker,
405
+ prepareExecution: (request) => prepareChatExecution(context, request),
406
+ streamExecutionToAgUiResponse: (execution) => streamPreparedHostedChatExecutionToAgUiResponse({
407
+ execution,
408
+ runtime: createPreparedExecutionRuntimeOptions(context, execution.config),
409
+ }),
410
+ startDetachedExecution: ({ execution, abortSignal }) => runPreparedHostedChatExecutionDetached({
411
+ execution: {
412
+ ...execution,
413
+ abortSignal,
414
+ },
415
+ runtime: createPreparedExecutionRuntimeOptions(context, execution.config),
416
+ }),
417
+ cleanupExecution: async ({ execution, runId, conversationId }) => {
418
+ await execution.cleanup().catch((error) => {
419
+ context.infrastructure.logger.error("Detached durable run cleanup failed after duplicate start", {
420
+ runId,
421
+ conversationId,
422
+ error: error instanceof Error ? error.message : String(error),
423
+ });
424
+ });
425
+ },
426
+ setActiveSpanAttributes: context.infrastructure.setActiveSpanAttributes,
427
+ trace: context.trace,
428
+ logger: context.infrastructure.logger,
429
+ drainTimeoutMs: context.options.drainTimeoutMs ?? DEFAULT_DRAIN_TIMEOUT_MS,
430
+ };
431
+ }
432
+ export async function createNodeVeryfrontCloudAgentServiceRuntime(options) {
433
+ const context = createNodeVeryfrontCloudAgentServiceContext(options);
434
+ await initializeNodeVeryfrontCloudAgentServiceContext(context);
435
+ return createAgentServiceRuntime(createNodeVeryfrontCloudAgentServiceRuntimeOptions(context));
436
+ }
437
+ export async function startNodeVeryfrontCloudAgentService(options) {
438
+ const context = createNodeVeryfrontCloudAgentServiceContext(options);
439
+ await initializeNodeVeryfrontCloudAgentServiceContext(context);
440
+ return await startNodeAgentService({
441
+ ...createNodeVeryfrontCloudAgentServiceRuntimeOptions(context),
442
+ hardShutdownTimeoutMs: options.hardShutdownTimeoutMs ?? DEFAULT_HARD_SHUTDOWN_TIMEOUT_MS,
443
+ });
444
+ }
445
+ export async function runNodeVeryfrontCloudAgentServiceMain(options) {
446
+ const processTarget = options.processTarget ?? resolveDefaultProcessTarget();
447
+ let getRuntimeTraceContext = () => ({});
448
+ await loadAgentServiceEnvFiles();
449
+ const context = createNodeVeryfrontCloudAgentServiceContext({
450
+ ...options,
451
+ processTarget,
452
+ });
453
+ getRuntimeTraceContext = context.infrastructure.getTraceContext;
454
+ await initializeNodeVeryfrontCloudAgentServiceContext(context);
455
+ await runAgentServiceMain({
456
+ loadLogger: () => context.infrastructure.logger,
457
+ initializeTelemetry: async () => {
458
+ return await context.infrastructure.initializeOpenTelemetry().catch((error) => {
459
+ console.error("Failed to initialize OpenTelemetry:", error);
460
+ return false;
461
+ });
462
+ },
463
+ onTelemetryInitialized: () => {
464
+ console.log("OpenTelemetry initialized successfully");
465
+ },
466
+ getTraceContext: () => getRuntimeTraceContext(),
467
+ registerTraceContextGetter: (getter) => {
468
+ __registerTraceContextGetter(getter);
469
+ },
470
+ start: async () => {
471
+ await startNodeAgentService({
472
+ ...createNodeVeryfrontCloudAgentServiceRuntimeOptions(context),
473
+ hardShutdownTimeoutMs: options.hardShutdownTimeoutMs ?? DEFAULT_HARD_SHUTDOWN_TIMEOUT_MS,
474
+ });
475
+ },
476
+ onStartupError: (error) => {
477
+ console.error("Error in server startup:", error);
478
+ },
479
+ exit: processTarget?.exit,
480
+ processTarget,
481
+ });
482
+ }
@@ -297,6 +297,30 @@ export declare const veryfrontConfigSchema: z.ZodObject<{
297
297
  paths: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
298
298
  }, z.core.$strip>>>;
299
299
  }, z.core.$strip>>>;
300
+ resources: z.ZodOptional<z.ZodOptional<z.ZodObject<{
301
+ discovery: z.ZodOptional<z.ZodOptional<z.ZodObject<{
302
+ enabled: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
303
+ paths: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
304
+ }, z.core.$strip>>>;
305
+ }, z.core.$strip>>>;
306
+ prompts: z.ZodOptional<z.ZodOptional<z.ZodObject<{
307
+ discovery: z.ZodOptional<z.ZodOptional<z.ZodObject<{
308
+ enabled: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
309
+ paths: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
310
+ }, z.core.$strip>>>;
311
+ }, z.core.$strip>>>;
312
+ workflows: z.ZodOptional<z.ZodOptional<z.ZodObject<{
313
+ discovery: z.ZodOptional<z.ZodOptional<z.ZodObject<{
314
+ enabled: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
315
+ paths: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
316
+ }, z.core.$strip>>>;
317
+ }, z.core.$strip>>>;
318
+ tasks: z.ZodOptional<z.ZodOptional<z.ZodObject<{
319
+ discovery: z.ZodOptional<z.ZodOptional<z.ZodObject<{
320
+ enabled: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
321
+ paths: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
322
+ }, z.core.$strip>>>;
323
+ }, z.core.$strip>>>;
300
324
  mcp: z.ZodOptional<z.ZodOptional<z.ZodObject<{
301
325
  enabled: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
302
326
  port: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.schema.d.ts","sourceRoot":"","sources":["../../../../src/src/config/schemas/config.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwhBtB,CAAC;AAGb,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGzE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAyBvE;AAQD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAEhF"}
1
+ {"version":3,"file":"config.schema.d.ts","sourceRoot":"","sources":["../../../../src/src/config/schemas/config.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwkBtB,CAAC;AAGb,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGzE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAyBvE;AAQD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAEhF"}
@@ -418,6 +418,54 @@ export const veryfrontConfigSchema = z
418
418
  })
419
419
  .partial()
420
420
  .optional(),
421
+ resources: z
422
+ .object({
423
+ discovery: z
424
+ .object({
425
+ enabled: z.boolean().optional(),
426
+ paths: z.array(z.string()).optional(),
427
+ })
428
+ .partial()
429
+ .optional(),
430
+ })
431
+ .partial()
432
+ .optional(),
433
+ prompts: z
434
+ .object({
435
+ discovery: z
436
+ .object({
437
+ enabled: z.boolean().optional(),
438
+ paths: z.array(z.string()).optional(),
439
+ })
440
+ .partial()
441
+ .optional(),
442
+ })
443
+ .partial()
444
+ .optional(),
445
+ workflows: z
446
+ .object({
447
+ discovery: z
448
+ .object({
449
+ enabled: z.boolean().optional(),
450
+ paths: z.array(z.string()).optional(),
451
+ })
452
+ .partial()
453
+ .optional(),
454
+ })
455
+ .partial()
456
+ .optional(),
457
+ tasks: z
458
+ .object({
459
+ discovery: z
460
+ .object({
461
+ enabled: z.boolean().optional(),
462
+ paths: z.array(z.string()).optional(),
463
+ })
464
+ .partial()
465
+ .optional(),
466
+ })
467
+ .partial()
468
+ .optional(),
421
469
  mcp: z
422
470
  .object({
423
471
  enabled: z.boolean().optional(),
@@ -10,6 +10,7 @@
10
10
  */
11
11
  export type { DiscoveryConfig, DiscoveryHandler, DiscoveryResult, FileDiscoveryContext, } from "./types.js";
12
12
  export { discoverAll } from "./discovery-engine.js";
13
+ export { createProjectDiscoveryConfig, DEFAULT_PROJECT_DISCOVERY_DIRS, } from "./project-discovery-config.js";
13
14
  export { clearTrackedAgents, filenameToId, filePathToPattern } from "./discovery-utils.js";
14
15
  export { clearTranspileCache } from "./transpiler.js";
15
16
  export { validateProviderConfig, type ValidationResult } from "./provider-config-validator.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -10,6 +10,7 @@
10
10
  */
11
11
  // Re-export main discovery function
12
12
  export { discoverAll } from "./discovery-engine.js";
13
+ export { createProjectDiscoveryConfig, DEFAULT_PROJECT_DISCOVERY_DIRS, } from "./project-discovery-config.js";
13
14
  // Re-export utilities
14
15
  export { clearTrackedAgents, filenameToId, filePathToPattern } from "./discovery-utils.js";
15
16
  // Re-export transpiler utilities
@@ -0,0 +1,30 @@
1
+ import type { VeryfrontConfig } from "../config/index.js";
2
+ import type { FileSystemAdapter } from "../platform/adapters/base.js";
3
+ import type { DiscoveryConfig } from "./types.js";
4
+ export declare const DEFAULT_PROJECT_DISCOVERY_DIRS: {
5
+ toolDirs: string[];
6
+ agentDirs: string[];
7
+ skillDirs: string[];
8
+ resourceDirs: string[];
9
+ promptDirs: string[];
10
+ workflowDirs: string[];
11
+ taskDirs: string[];
12
+ };
13
+ type ProjectDiscoveryConfigInput = {
14
+ projectDir: string;
15
+ config?: VeryfrontConfig | null;
16
+ fsAdapter?: FileSystemAdapter;
17
+ verbose?: boolean;
18
+ };
19
+ export type ProjectDiscoveryConfig = DiscoveryConfig & {
20
+ toolDirs: string[];
21
+ agentDirs: string[];
22
+ skillDirs: string[];
23
+ resourceDirs: string[];
24
+ promptDirs: string[];
25
+ workflowDirs: string[];
26
+ taskDirs: string[];
27
+ };
28
+ export declare function createProjectDiscoveryConfig(input: ProjectDiscoveryConfigInput): ProjectDiscoveryConfig;
29
+ export {};
30
+ //# sourceMappingURL=project-discovery-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-discovery-config.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/project-discovery-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,eAAO,MAAM,8BAA8B;;;;;;;;CAQ1C,CAAC;AAOF,KAAK,2BAA2B,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG;IACrD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAgBF,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,2BAA2B,GACjC,sBAAsB,CAoCxB"}
@@ -0,0 +1,33 @@
1
+ export const DEFAULT_PROJECT_DISCOVERY_DIRS = {
2
+ toolDirs: ["tools"],
3
+ agentDirs: ["agents"],
4
+ skillDirs: ["skills"],
5
+ resourceDirs: ["resources"],
6
+ promptDirs: ["prompts"],
7
+ workflowDirs: ["workflows"],
8
+ taskDirs: ["tasks"],
9
+ };
10
+ function isDiscoveryEnabled(discovery) {
11
+ return discovery?.enabled ?? true;
12
+ }
13
+ function resolveDiscoveryPaths(discovery, defaultPaths) {
14
+ if (!isDiscoveryEnabled(discovery)) {
15
+ return [];
16
+ }
17
+ return discovery?.paths ?? defaultPaths;
18
+ }
19
+ export function createProjectDiscoveryConfig(input) {
20
+ const aiConfig = input.config?.ai;
21
+ return {
22
+ baseDir: input.projectDir,
23
+ toolDirs: resolveDiscoveryPaths(aiConfig?.tools?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.toolDirs),
24
+ agentDirs: resolveDiscoveryPaths(aiConfig?.agents?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.agentDirs),
25
+ skillDirs: resolveDiscoveryPaths(aiConfig?.skills?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.skillDirs),
26
+ resourceDirs: resolveDiscoveryPaths(aiConfig?.resources?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.resourceDirs),
27
+ promptDirs: resolveDiscoveryPaths(aiConfig?.prompts?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.promptDirs),
28
+ workflowDirs: resolveDiscoveryPaths(aiConfig?.workflows?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.workflowDirs),
29
+ taskDirs: resolveDiscoveryPaths(aiConfig?.tasks?.discovery, DEFAULT_PROJECT_DISCOVERY_DIRS.taskDirs),
30
+ fsAdapter: input.fsAdapter,
31
+ verbose: input.verbose ?? false,
32
+ };
33
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"project-discovery.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/api/project-discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAuErD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE/E"}
1
+ {"version":3,"file":"project-discovery.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/api/project-discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA8CrD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuE/E"}