veryfront 0.1.1122 → 0.1.1123
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/esm/deno.js +1 -1
- package/esm/extensions/ext-llm-openai/src/openai-responses-request-builder.d.ts.map +1 -1
- package/esm/extensions/ext-llm-openai/src/openai-responses-request-builder.js +5 -0
- package/esm/src/agent/hosted/child-lifecycle.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-lifecycle.js +1 -12
- package/esm/src/agent/hosted/cloud-agent-chat-execution.d.ts +38 -0
- package/esm/src/agent/hosted/cloud-agent-chat-execution.d.ts.map +1 -0
- package/esm/src/agent/hosted/cloud-agent-chat-execution.js +349 -0
- package/esm/src/agent/hosted/cloud-agent-child-tools.d.ts +80 -0
- package/esm/src/agent/hosted/cloud-agent-child-tools.d.ts.map +1 -0
- package/esm/src/agent/hosted/cloud-agent-child-tools.js +280 -0
- package/esm/src/agent/hosted/cloud-agent-config.d.ts +69 -0
- package/esm/src/agent/hosted/cloud-agent-config.d.ts.map +1 -0
- package/esm/src/agent/hosted/cloud-agent-config.js +129 -0
- package/esm/src/agent/hosted/cloud-agent-paths.d.ts +42 -0
- package/esm/src/agent/hosted/cloud-agent-paths.d.ts.map +1 -0
- package/esm/src/agent/hosted/cloud-agent-paths.js +117 -0
- package/esm/src/agent/hosted/cloud-agent-provider-bootstrap.d.ts +49 -0
- package/esm/src/agent/hosted/cloud-agent-provider-bootstrap.d.ts.map +1 -0
- package/esm/src/agent/hosted/cloud-agent-provider-bootstrap.js +96 -0
- package/esm/src/agent/hosted/durable-child-fork-execution.d.ts.map +1 -1
- package/esm/src/agent/hosted/durable-child-fork-execution.js +1 -12
- package/esm/src/agent/hosted/runtime-request-config.js +2 -2
- package/esm/src/agent/hosted/stream-finalization.d.ts.map +1 -1
- package/esm/src/agent/hosted/stream-finalization.js +2 -26
- package/esm/src/agent/hosted/veryfront-cloud-agent-service.d.ts +11 -93
- package/esm/src/agent/hosted/veryfront-cloud-agent-service.d.ts.map +1 -1
- package/esm/src/agent/hosted/veryfront-cloud-agent-service.js +8 -901
- package/esm/src/agent/project/agent-runtime.d.ts.map +1 -1
- package/esm/src/agent/project/agent-runtime.js +3 -0
- package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.js +1 -28
- package/esm/src/agent/streaming/stream-outcome.d.ts +30 -0
- package/esm/src/agent/streaming/stream-outcome.d.ts.map +1 -0
- package/esm/src/agent/streaming/stream-outcome.js +62 -0
- package/esm/src/agent/types.d.ts +3 -0
- package/esm/src/agent/types.d.ts.map +1 -1
- package/esm/src/eval/studio.d.ts +1 -1
- package/esm/src/html/styles-builder/plugin-loader.d.ts.map +1 -1
- package/esm/src/html/styles-builder/plugin-loader.js +4 -2
- package/esm/src/modules/server/classify.d.ts +54 -0
- package/esm/src/modules/server/classify.d.ts.map +1 -0
- package/esm/src/modules/server/classify.js +50 -0
- package/esm/src/modules/server/fs-probe.d.ts +14 -0
- package/esm/src/modules/server/fs-probe.d.ts.map +1 -0
- package/esm/src/modules/server/fs-probe.js +17 -0
- package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
- package/esm/src/modules/server/module-batch-handler.js +31 -45
- package/esm/src/modules/server/module-server.d.ts.map +1 -1
- package/esm/src/modules/server/module-server.js +77 -93
- package/esm/src/modules/server/module-transform.d.ts +73 -0
- package/esm/src/modules/server/module-transform.d.ts.map +1 -0
- package/esm/src/modules/server/module-transform.js +64 -0
- package/esm/src/modules/server/ssr-import-rewriter.d.ts +1 -1
- package/esm/src/modules/server/ssr-import-rewriter.d.ts.map +1 -1
- package/esm/src/observability/error-collector.d.ts.map +1 -1
- package/esm/src/observability/error-collector.js +4 -11
- package/esm/src/observability/log-buffer.d.ts.map +1 -1
- package/esm/src/observability/log-buffer.js +4 -11
- package/esm/src/observability/request-profiler.d.ts +4 -0
- package/esm/src/observability/request-profiler.d.ts.map +1 -1
- package/esm/src/observability/request-profiler.js +9 -4
- package/esm/src/proxy/server-timing.d.ts.map +1 -1
- package/esm/src/proxy/server-timing.js +2 -14
- package/esm/src/react/components/chat/agent-card.d.ts +2 -3
- package/esm/src/react/components/chat/agent-card.d.ts.map +1 -1
- package/esm/src/react/components/chat/agent-card.js +3 -12
- package/esm/src/react/components/chat/agent-picker-context.d.ts +2 -3
- package/esm/src/react/components/chat/agent-picker-context.d.ts.map +1 -1
- package/esm/src/react/components/chat/agent-picker-context.js +3 -13
- package/esm/src/react/components/chat/chat/components/attachment-pill.d.ts +2 -6
- package/esm/src/react/components/chat/chat/components/attachment-pill.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/attachment-pill.js +3 -15
- package/esm/src/react/components/chat/chat/components/attachments-panel.d.ts +2 -12
- package/esm/src/react/components/chat/chat/components/attachments-panel.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/attachments-panel.js +3 -21
- package/esm/src/react/components/chat/chat/components/branch-picker.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/branch-picker.js +2 -11
- package/esm/src/react/components/chat/chat/components/inline-citation.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/inline-citation.js +2 -11
- package/esm/src/react/components/chat/chat/components/message-actions.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/message-actions.js +2 -11
- package/esm/src/react/components/chat/chat/components/message-feedback.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/message-feedback.js +2 -11
- package/esm/src/react/components/chat/chat/components/reasoning.d.ts +2 -3
- package/esm/src/react/components/chat/chat/components/reasoning.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/reasoning.js +3 -12
- package/esm/src/react/components/chat/chat/components/sidebar.d.ts +2 -3
- package/esm/src/react/components/chat/chat/components/sidebar.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/sidebar.js +4 -22
- package/esm/src/react/components/chat/chat/components/sources.d.ts +2 -3
- package/esm/src/react/components/chat/chat/components/sources.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/sources.js +3 -12
- package/esm/src/react/components/chat/chat/components/step-indicator.d.ts +2 -6
- package/esm/src/react/components/chat/chat/components/step-indicator.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/step-indicator.js +3 -15
- package/esm/src/react/components/chat/chat/components/tool-ui.d.ts +2 -3
- package/esm/src/react/components/chat/chat/components/tool-ui.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/components/tool-ui.js +3 -12
- package/esm/src/react/components/chat/chat/composition/chat-message-list.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/composition/chat-message-list.js +2 -11
- package/esm/src/react/components/chat/chat/contexts/chat-context.d.ts +2 -2
- package/esm/src/react/components/chat/chat/contexts/chat-context.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/contexts/chat-context.js +3 -12
- package/esm/src/react/components/chat/chat/contexts/composer-context.d.ts +2 -2
- package/esm/src/react/components/chat/chat/contexts/composer-context.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/contexts/composer-context.js +3 -12
- package/esm/src/react/components/chat/chat/contexts/conversations-context.d.ts +2 -2
- package/esm/src/react/components/chat/chat/contexts/conversations-context.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/contexts/conversations-context.js +3 -12
- package/esm/src/react/components/chat/chat/contexts/message-context.d.ts +2 -2
- package/esm/src/react/components/chat/chat/contexts/message-context.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/contexts/message-context.js +3 -12
- package/esm/src/react/components/chat/chat-actions.d.ts +2 -6
- package/esm/src/react/components/chat/chat-actions.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat-actions.js +3 -15
- package/esm/src/react/components/chat/model-selector.d.ts +2 -6
- package/esm/src/react/components/chat/model-selector.d.ts.map +1 -1
- package/esm/src/react/components/chat/model-selector.js +3 -15
- package/esm/src/react/components/create-strict-context.d.ts +44 -0
- package/esm/src/react/components/create-strict-context.d.ts.map +1 -0
- package/esm/src/react/components/create-strict-context.js +56 -0
- package/esm/src/react/components/ui/app-shell.d.ts +2 -2
- package/esm/src/react/components/ui/app-shell.d.ts.map +1 -1
- package/esm/src/react/components/ui/app-shell.js +3 -7
- package/esm/src/react/components/ui/color-mode.d.ts +2 -2
- package/esm/src/react/components/ui/color-mode.d.ts.map +1 -1
- package/esm/src/react/components/ui/color-mode.js +3 -11
- package/esm/src/react/components/ui/command.d.ts.map +1 -1
- package/esm/src/react/components/ui/command.js +2 -7
- package/esm/src/react/components/ui/select.d.ts.map +1 -1
- package/esm/src/react/components/ui/select.js +2 -7
- package/esm/src/react/components/ui/tabs.d.ts.map +1 -1
- package/esm/src/react/components/ui/tabs.js +3 -4
- package/esm/src/runs/schemas.d.ts +9 -9
- package/esm/src/server/handlers/dev/framework-candidates.generated.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/framework-candidates.generated.js +79 -106
- package/esm/src/server/reload-notifier.d.ts +0 -1
- package/esm/src/server/reload-notifier.d.ts.map +1 -1
- package/esm/src/server/reload-notifier.js +7 -25
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.d.ts.map +1 -1
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/utils/base64url.d.ts +9 -1
- package/esm/src/utils/base64url.d.ts.map +1 -1
- package/esm/src/utils/base64url.js +25 -11
- package/esm/src/utils/index.d.ts +2 -1
- package/esm/src/utils/index.d.ts.map +1 -1
- package/esm/src/utils/index.js +2 -1
- package/esm/src/utils/subscriber-set.d.ts +19 -0
- package/esm/src/utils/subscriber-set.d.ts.map +1 -0
- package/esm/src/utils/subscriber-set.js +38 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/workflow/claude-code/websocket-publisher.d.ts.map +1 -1
- package/esm/src/workflow/claude-code/websocket-publisher.js +8 -15
- package/esm/src/workflow/schemas/workflow.schema.d.ts +4 -4
- package/package.json +5 -5
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted child tool assembly — MCP server resolution, delegation binding,
|
|
3
|
+
* invoke-agent tool, and project steering/skill accessors for the cloud agent service.
|
|
4
|
+
*/
|
|
5
|
+
import { createAgentServiceSandboxTools } from "../../sandbox/index.js";
|
|
6
|
+
import { createRemoteMCPToolSource, createToolsFromRemoteDefinitions, isToolVisibleTo, toolRegistry, } from "../../tool/index.js";
|
|
7
|
+
import { SKILL_TOOL_IDS } from "../../skill/types.js";
|
|
8
|
+
import { parseProviderError } from "../../chat/provider-errors.js";
|
|
9
|
+
import { getVeryfrontCloudProviderFromModelId, resolveVeryfrontCloudModelId, resolveVeryfrontCloudModelThinking, resolveVeryfrontCloudReasoningOption, resolveVeryfrontCloudThinkingProviderOptions, } from "../../provider/veryfront-cloud/model-catalog.js";
|
|
10
|
+
import { filterAgentTraceAttributes } from "./trace-attributes.js";
|
|
11
|
+
import { defaultAgentServiceMcpServers, } from "../service/mcp-server-config.js";
|
|
12
|
+
import { resolveRuntimeSkillsForAgent, } from "../runtime/skill-metadata.js";
|
|
13
|
+
import { buildAgentDelegateTools } from "../runtime/agent-delegation.js";
|
|
14
|
+
import { buildVeryfrontCloudRuntimeInstructions } from "./cloud-runtime-system-messages.js";
|
|
15
|
+
import { flattenSystemInstructions } from "../runtime/tool-inventory.js";
|
|
16
|
+
import { createDefaultHostedInvokeAgentTool } from "./default-invoke-agent-tool.js";
|
|
17
|
+
import { fetchDefaultHostedProjectSteering } from "./default-project-steering-refresh.js";
|
|
18
|
+
import { createLiveStudioMcpTools } from "../project/live-studio-mcp-tools.js";
|
|
19
|
+
import { getProjectAgentRuntime, getProjectSteering, resolveAgentConfig, } from "./cloud-agent-config.js";
|
|
20
|
+
const HOSTED_CHILD_LOCAL_SKILL_TOOL_NAMES = new Set([
|
|
21
|
+
"execute_skill_script",
|
|
22
|
+
"load_skill_reference",
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the effective MCP server list by intersecting service-level options
|
|
26
|
+
* with optional per-agent overrides.
|
|
27
|
+
*/
|
|
28
|
+
export function resolveMcpServers(options, agentConfig) {
|
|
29
|
+
if (options.mcpServers !== undefined) {
|
|
30
|
+
if (agentConfig?.mcpServers === undefined) {
|
|
31
|
+
return options.mcpServers;
|
|
32
|
+
}
|
|
33
|
+
return agentConfig.mcpServers.flatMap((agentServer) => {
|
|
34
|
+
const hostServer = options.mcpServers?.find((server) => server.kind === agentServer.kind && server.id === agentServer.id);
|
|
35
|
+
if (!hostServer) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const toolPolicy = mergeMcpToolPolicies(hostServer.toolPolicy, agentServer.toolPolicy);
|
|
39
|
+
return [{
|
|
40
|
+
...hostServer,
|
|
41
|
+
...(toolPolicy === undefined ? {} : { toolPolicy }),
|
|
42
|
+
}];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (agentConfig?.mcpServers !== undefined) {
|
|
46
|
+
return agentConfig.mcpServers;
|
|
47
|
+
}
|
|
48
|
+
return defaultAgentServiceMcpServers();
|
|
49
|
+
}
|
|
50
|
+
function mergeMcpToolPolicies(hostPolicy, agentPolicy) {
|
|
51
|
+
if (hostPolicy === undefined) {
|
|
52
|
+
return agentPolicy;
|
|
53
|
+
}
|
|
54
|
+
if (agentPolicy === undefined) {
|
|
55
|
+
return hostPolicy;
|
|
56
|
+
}
|
|
57
|
+
const allow = hostPolicy.allow === undefined
|
|
58
|
+
? agentPolicy.allow
|
|
59
|
+
: agentPolicy.allow === undefined
|
|
60
|
+
? hostPolicy.allow
|
|
61
|
+
: hostPolicy.allow.filter((toolName) => agentPolicy.allow?.includes(toolName));
|
|
62
|
+
const deny = [
|
|
63
|
+
...new Set([
|
|
64
|
+
...(hostPolicy.deny ?? []),
|
|
65
|
+
...(agentPolicy.deny ?? []),
|
|
66
|
+
]),
|
|
67
|
+
];
|
|
68
|
+
const approval = hostPolicy.approval ?? agentPolicy.approval;
|
|
69
|
+
return {
|
|
70
|
+
...(allow === undefined ? {} : { allow }),
|
|
71
|
+
...(deny.length === 0 ? {} : { deny }),
|
|
72
|
+
...(approval === undefined ? {} : { approval }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the set of host tools visible to the given agent scope, excluding
|
|
77
|
+
* shared skill infrastructure tools (load_skill_reference, execute_skill_script).
|
|
78
|
+
*/
|
|
79
|
+
export function getDiscoveredHostTools(scope) {
|
|
80
|
+
// Without an agent identity, this remains the project-level host tool spread
|
|
81
|
+
// and matches MCP tools/list: project-level callers see only unowned tools.
|
|
82
|
+
// Hosted per-agent runs pass their task context identity so owned colocated
|
|
83
|
+
// tools are available to their owner and hidden from other agents.
|
|
84
|
+
// Shared skill tools use local registry and filesystem state. Hosted runs
|
|
85
|
+
// instead add the request-scoped load_skill tool below; its optional file
|
|
86
|
+
// input reads references with project, branch, auth, and owner context.
|
|
87
|
+
// Hosted runs do not execute skill scripts directly.
|
|
88
|
+
return Object.fromEntries([...toolRegistry.getAll()]
|
|
89
|
+
.filter(([toolId, registryTool]) => !SKILL_TOOL_IDS.has(toolId) && isToolVisibleTo(registryTool, scope))
|
|
90
|
+
.sort(([left], [right]) => left.localeCompare(right)));
|
|
91
|
+
}
|
|
92
|
+
/** Fetches the project instructions for the given agent id and lookup context. */
|
|
93
|
+
export function getProjectInstructions(context, lookup, agentId) {
|
|
94
|
+
return context.trace("chat.getProjectInstructions", async () => {
|
|
95
|
+
return await getProjectSteering(context, agentId).getProjectInstructions(lookup);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** Fetches the resolved skill definitions for the given agent id and lookup context. */
|
|
99
|
+
export function getSkillsConfig(context, lookup, agentId) {
|
|
100
|
+
return context.trace("chat.getSkillsConfig", async () => {
|
|
101
|
+
return await getProjectSteering(context, agentId).getSkillsConfig(lookup);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** Creates the load_skill tool scoped to the given tool context. */
|
|
105
|
+
export function createLoadSkillTool(context, toolContext) {
|
|
106
|
+
return getProjectSteering(context, toolContext.agentId).createLoadSkillTool(toolContext);
|
|
107
|
+
}
|
|
108
|
+
/** Refreshes the project skill ids for the given skill context. */
|
|
109
|
+
export async function refreshProjectSkillIds(context, skillContext) {
|
|
110
|
+
await getProjectSteering(context, skillContext.agentId).refreshProjectSkillIds(skillContext);
|
|
111
|
+
}
|
|
112
|
+
/** Sets filtered trace attributes on the active span. */
|
|
113
|
+
export function setFilteredTraceAttributes(context, attributes) {
|
|
114
|
+
context.infrastructure.setActiveSpanAttributes(filterAgentTraceAttributes(attributes));
|
|
115
|
+
}
|
|
116
|
+
function getInvokeAgentConfig(context) {
|
|
117
|
+
const config = context.infrastructure.getConfig();
|
|
118
|
+
return {
|
|
119
|
+
apiUrl: config.VERYFRONT_API_URL,
|
|
120
|
+
apiMcpUrl: config.VERYFRONT_MCP_URL,
|
|
121
|
+
studioMcpUrl: config.VERYFRONT_STUDIO_MCP_URL,
|
|
122
|
+
mcpServers: resolveMcpServers(context.options),
|
|
123
|
+
enableDurableInvokeAgent: config.VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function shouldRethrowInvokeAgentError(error) {
|
|
127
|
+
return parseProviderError(error).code === "INSUFFICIENT_CREDITS";
|
|
128
|
+
}
|
|
129
|
+
/** Resolves the effective tool name allowlist for a hosted child agent run. */
|
|
130
|
+
export function resolveHostedChildToolNames(agentConfig) {
|
|
131
|
+
if (agentConfig.tools === true) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
return [
|
|
135
|
+
...new Set([
|
|
136
|
+
...(agentConfig.tools ?? []).filter((toolName) => !HOSTED_CHILD_LOCAL_SKILL_TOOL_NAMES.has(toolName)),
|
|
137
|
+
...(agentConfig.providerTools ?? []),
|
|
138
|
+
...(agentConfig.delegates ?? []).map((id) => `agent_${id}`),
|
|
139
|
+
"load_skill",
|
|
140
|
+
]),
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
/** Builds the child run context for a nested hosted agent invocation. */
|
|
144
|
+
export function buildHostedChildToolContext(globalToolContext, childAgentId, childConfig, durableChildRun) {
|
|
145
|
+
return {
|
|
146
|
+
...globalToolContext,
|
|
147
|
+
agentId: childAgentId,
|
|
148
|
+
...(childConfig?.availableSkillIds ? { availableSkillIds: childConfig.availableSkillIds } : {}),
|
|
149
|
+
...(childConfig?.skillSourcePaths ? { skillSourcePaths: childConfig.skillSourcePaths } : {}),
|
|
150
|
+
...(childConfig?.toolNames ? { availableToolNames: childConfig.toolNames } : {}),
|
|
151
|
+
loadedSkillResponses: {},
|
|
152
|
+
loadedSkillReferenceResponses: {},
|
|
153
|
+
...(durableChildRun
|
|
154
|
+
? {
|
|
155
|
+
conversationId: durableChildRun.childConversationId,
|
|
156
|
+
parentRunId: durableChildRun.childRunId,
|
|
157
|
+
parentMessageId: durableChildRun.childMessageId,
|
|
158
|
+
}
|
|
159
|
+
: {}),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/** Fetches project steering for a given project / auth / branch combination. */
|
|
163
|
+
export function fetchProjectSteering(context, input, agentId) {
|
|
164
|
+
return fetchDefaultHostedProjectSteering({
|
|
165
|
+
...input,
|
|
166
|
+
fetchProjectInstructions: (lookup) => getProjectInstructions(context, lookup, agentId),
|
|
167
|
+
fetchSkills: (lookup) => getSkillsConfig(context, lookup, agentId),
|
|
168
|
+
trace: context.trace,
|
|
169
|
+
traceOperationName: "chat.fetchSteering",
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** Resolves the execution config for a hosted child agent invocation. */
|
|
173
|
+
export async function resolveHostedChildAgentExecutionConfig(context, taskContext, childAgentId, projectId) {
|
|
174
|
+
if (!getProjectAgentRuntime(context).agents.has(childAgentId)) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const agentConfig = await resolveAgentConfig(context, childAgentId);
|
|
178
|
+
const branchId = projectId === taskContext.projectId ? taskContext.branchId : null;
|
|
179
|
+
const steering = await fetchProjectSteering(context, {
|
|
180
|
+
projectId: projectId || null,
|
|
181
|
+
authToken: taskContext.authToken,
|
|
182
|
+
branchId,
|
|
183
|
+
}, childAgentId);
|
|
184
|
+
const advertisedSkills = resolveRuntimeSkillsForAgent({
|
|
185
|
+
skills: steering.skills,
|
|
186
|
+
agentId: childAgentId,
|
|
187
|
+
selector: agentConfig.skills,
|
|
188
|
+
});
|
|
189
|
+
const loadableSkills = resolveRuntimeSkillsForAgent({
|
|
190
|
+
skills: steering.skills,
|
|
191
|
+
agentId: childAgentId,
|
|
192
|
+
selector: true,
|
|
193
|
+
});
|
|
194
|
+
const skillSourcePaths = Object.fromEntries(loadableSkills
|
|
195
|
+
.filter((skill) => skill.sourcePath)
|
|
196
|
+
.map((skill) => [skill.id, skill.sourcePath]));
|
|
197
|
+
const toolNames = resolveHostedChildToolNames(agentConfig);
|
|
198
|
+
const thinking = agentConfig.thinking?.enabled === false ? 0 : agentConfig.thinking?.budgetTokens;
|
|
199
|
+
return {
|
|
200
|
+
system: flattenSystemInstructions(buildVeryfrontCloudRuntimeInstructions({
|
|
201
|
+
agentConfig,
|
|
202
|
+
projectId: projectId || null,
|
|
203
|
+
branchId,
|
|
204
|
+
instructions: steering.instructions,
|
|
205
|
+
skills: advertisedSkills,
|
|
206
|
+
availableToolNames: toolNames,
|
|
207
|
+
})),
|
|
208
|
+
...(agentConfig.model ? { model: agentConfig.model } : {}),
|
|
209
|
+
...(agentConfig.temperature === undefined ? {} : { temperature: agentConfig.temperature }),
|
|
210
|
+
...(agentConfig.maxSteps === undefined ? {} : { maxSteps: agentConfig.maxSteps }),
|
|
211
|
+
...(thinking === undefined ? {} : { thinking }),
|
|
212
|
+
...(toolNames === undefined ? {} : { toolNames }),
|
|
213
|
+
mcpServers: resolveMcpServers(context.options, agentConfig),
|
|
214
|
+
availableSkillIds: loadableSkills.map((skill) => skill.id),
|
|
215
|
+
...(Object.keys(skillSourcePaths).length > 0 ? { skillSourcePaths } : {}),
|
|
216
|
+
...(agentConfig.delegates === undefined ? {} : { delegateIds: agentConfig.delegates }),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** Creates the invoke_agent tool for the given child context. */
|
|
220
|
+
export function createInvokeAgentTool(context, childContext, options) {
|
|
221
|
+
return createDefaultHostedInvokeAgentTool({
|
|
222
|
+
context: childContext,
|
|
223
|
+
getConfig: () => getInvokeAgentConfig(context),
|
|
224
|
+
logger: context.infrastructure.logger,
|
|
225
|
+
trace: context.trace,
|
|
226
|
+
setTraceAttributes: context.infrastructure.setActiveSpanAttributes,
|
|
227
|
+
createBashTool: context.options.createBashTool,
|
|
228
|
+
resolveModelId: resolveVeryfrontCloudModelId,
|
|
229
|
+
resolveProvider: getVeryfrontCloudProviderFromModelId,
|
|
230
|
+
resolveModelThinking: resolveVeryfrontCloudModelThinking,
|
|
231
|
+
resolveProviderOptions: resolveVeryfrontCloudThinkingProviderOptions,
|
|
232
|
+
resolveReasoning: resolveVeryfrontCloudReasoningOption,
|
|
233
|
+
shouldRethrowError: shouldRethrowInvokeAgentError,
|
|
234
|
+
buildGlobalTools: (globalToolContext, childAgentId, childConfig, durableChildRun) => {
|
|
235
|
+
const childToolContext = buildHostedChildToolContext(globalToolContext, childAgentId, childConfig, durableChildRun);
|
|
236
|
+
return {
|
|
237
|
+
...(childConfig ? getDiscoveredHostTools({ agentId: childAgentId }) : {}),
|
|
238
|
+
load_skill: createLoadSkillTool(context, childToolContext),
|
|
239
|
+
...(childConfig?.delegateIds?.length
|
|
240
|
+
? buildHostedDelegateTools(context, {
|
|
241
|
+
delegates: childConfig.delegateIds,
|
|
242
|
+
selfId: childAgentId,
|
|
243
|
+
taskContext: childToolContext,
|
|
244
|
+
})
|
|
245
|
+
: {}),
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
resolveChildAgentExecutionConfig: (childAgentId, projectId) => resolveHostedChildAgentExecutionConfig(context, childContext, childAgentId, projectId),
|
|
249
|
+
refreshProjectSkillIds: (projectSkillContext) => refreshProjectSkillIds(context, projectSkillContext),
|
|
250
|
+
createAgentServiceSandboxTools,
|
|
251
|
+
createLiveStudioTools: createLiveStudioMcpTools,
|
|
252
|
+
createRemoteToolSource: createRemoteMCPToolSource,
|
|
253
|
+
createToolsFromRemoteDefinitions,
|
|
254
|
+
requireDurableInvokeAgent: options?.requireDurable,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/** Builds the set of delegate agent tools for the given delegate ids. */
|
|
258
|
+
export function buildHostedDelegateTools(context, input) {
|
|
259
|
+
const invokeAgent = createInvokeAgentTool(context, input.taskContext, { requireDurable: true });
|
|
260
|
+
return buildAgentDelegateTools({
|
|
261
|
+
delegates: input.delegates,
|
|
262
|
+
selfId: input.selfId,
|
|
263
|
+
resolveAgent: (delegateId) => getProjectAgentRuntime(context).agents.get(delegateId),
|
|
264
|
+
executeDelegate: ({ delegateId, toolInput, context: executionContext }) => invokeAgent.execute({
|
|
265
|
+
agent_id: delegateId,
|
|
266
|
+
description: `Run ${delegateId} specialist task`,
|
|
267
|
+
prompt: toolInput.input,
|
|
268
|
+
}, executionContext),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Resolves the delegation binding from an agent config. Agents with an explicit
|
|
273
|
+
* `delegates` list use scoped delegation; all others fall back to legacy invoke_agent.
|
|
274
|
+
*/
|
|
275
|
+
export function resolveHostedDelegationBinding(agentConfig) {
|
|
276
|
+
if (agentConfig?.delegates !== undefined) {
|
|
277
|
+
return { kind: "scoped", delegateIds: agentConfig.delegates };
|
|
278
|
+
}
|
|
279
|
+
return { kind: "legacy" };
|
|
280
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { AgUiResumeValue } from "../ag-ui/tool-shared.js";
|
|
2
|
+
import { type HostedAgentProjectSteering } from "./agent-project-steering.js";
|
|
3
|
+
import { type ProjectAgentRuntimeDiscovery } from "../project/agent-runtime.js";
|
|
4
|
+
import type { RuntimeAgentMarkdownDefinition } from "../runtime/agent-definition.js";
|
|
5
|
+
import type { ResolvedNodeVeryfrontCloudAgentServiceOptions } from "./cloud-agent-provider-bootstrap.js";
|
|
6
|
+
/**
|
|
7
|
+
* Full runtime context for a running cloud agent service instance.
|
|
8
|
+
* Typed as the return of its creator so accessors can use the inferred shape.
|
|
9
|
+
*/
|
|
10
|
+
export type NodeVeryfrontCloudAgentServiceContext = ReturnType<typeof createNodeVeryfrontCloudAgentServiceContext>;
|
|
11
|
+
/** Creates the shared runtime context for a cloud agent service instance. */
|
|
12
|
+
export declare function createNodeVeryfrontCloudAgentServiceContext(options: ResolvedNodeVeryfrontCloudAgentServiceOptions): {
|
|
13
|
+
options: ResolvedNodeVeryfrontCloudAgentServiceOptions;
|
|
14
|
+
processTarget: NodeJS.Process | (import("../../extensions/observability/node-telemetry-provider.js").NodeTelemetryProcessTarget & import("../index.js").AbortRejectionProcessTarget & {
|
|
15
|
+
env?: import("../index.js").CreateNodeAgentServiceRuntimeInfrastructureOptions["env"];
|
|
16
|
+
exit?: (code: number) => never | void;
|
|
17
|
+
}) | undefined;
|
|
18
|
+
projectDir: string;
|
|
19
|
+
infrastructure: import("../index.js").NodeAgentServiceRuntimeInfrastructure;
|
|
20
|
+
trace: {
|
|
21
|
+
<TResult>(operationName: string, operation: () => Promise<TResult>): Promise<TResult>;
|
|
22
|
+
<TResult>(operationName: string, operation: () => TResult): TResult;
|
|
23
|
+
};
|
|
24
|
+
defaultAgentId: string | null;
|
|
25
|
+
projectSteeringByAgentId: Map<string, HostedAgentProjectSteering>;
|
|
26
|
+
tracker: import("../index.js").DetachedRunTracker<AgUiResumeValue>;
|
|
27
|
+
discoveryResult: ProjectAgentRuntimeDiscovery | null;
|
|
28
|
+
agentConfig: RuntimeAgentMarkdownDefinition | null;
|
|
29
|
+
agentConfigs: Map<string, import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
30
|
+
id: import("../../internal-agents/schema.js").Schema<string>;
|
|
31
|
+
name: import("../../internal-agents/schema.js").Schema<string>;
|
|
32
|
+
description: import("../../internal-agents/schema.js").Schema<string>;
|
|
33
|
+
avatarUrl: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
34
|
+
instructions: import("../../internal-agents/schema.js").Schema<string>;
|
|
35
|
+
thinking: import("../../internal-agents/schema.js").Schema<import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
36
|
+
enabled: import("../../internal-agents/schema.js").Schema<boolean>;
|
|
37
|
+
budgetTokens: import("../../internal-agents/schema.js").Schema<number | undefined>;
|
|
38
|
+
}> | undefined>;
|
|
39
|
+
model: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
40
|
+
temperature: import("../../internal-agents/schema.js").Schema<number | undefined>;
|
|
41
|
+
maxSteps: import("../../internal-agents/schema.js").Schema<number | undefined>;
|
|
42
|
+
providerTools: import("../../internal-agents/schema.js").Schema<string[] | undefined>;
|
|
43
|
+
skills: import("../../internal-agents/schema.js").Schema<boolean | string[] | undefined>;
|
|
44
|
+
tools: import("../../internal-agents/schema.js").Schema<true | string[] | undefined>;
|
|
45
|
+
delegates: import("../../internal-agents/schema.js").Schema<string[] | undefined>;
|
|
46
|
+
mcpServers: import("../../internal-agents/schema.js").Schema<import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
47
|
+
kind: import("../../internal-agents/schema.js").Schema<"veryfront-api" | "veryfront-studio">;
|
|
48
|
+
id: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
49
|
+
toolPolicy: import("../../internal-agents/schema.js").Schema<import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
50
|
+
allow: import("../../internal-agents/schema.js").Schema<string[] | undefined>;
|
|
51
|
+
deny: import("../../internal-agents/schema.js").Schema<string[] | undefined>;
|
|
52
|
+
approval: import("../../internal-agents/schema.js").Schema<"never" | undefined>;
|
|
53
|
+
}> | undefined>;
|
|
54
|
+
}>[] | undefined>;
|
|
55
|
+
}>>;
|
|
56
|
+
};
|
|
57
|
+
/** Resolves and caches the agent config for the given agent id. */
|
|
58
|
+
export declare function resolveAgentConfig(context: NodeVeryfrontCloudAgentServiceContext, agentId: string): Promise<RuntimeAgentMarkdownDefinition>;
|
|
59
|
+
/** Returns the resolved agent config, throwing if the context has not been initialized. */
|
|
60
|
+
export declare function getResolvedAgentConfig(context: NodeVeryfrontCloudAgentServiceContext): RuntimeAgentMarkdownDefinition;
|
|
61
|
+
/** Returns the discovered project agent runtime, throwing if not yet initialized. */
|
|
62
|
+
export declare function getProjectAgentRuntime(context: NodeVeryfrontCloudAgentServiceContext): ProjectAgentRuntimeDiscovery;
|
|
63
|
+
/** Discovers project primitives and resolves the default agent id and config. */
|
|
64
|
+
export declare function initializeNodeVeryfrontCloudAgentServiceContext(context: NodeVeryfrontCloudAgentServiceContext): Promise<void>;
|
|
65
|
+
/** Returns the default agent id, throwing if the context has not been initialized. */
|
|
66
|
+
export declare function getDefaultAgentId(context: NodeVeryfrontCloudAgentServiceContext): string;
|
|
67
|
+
/** Returns (and caches) the project steering object for the given agent id. */
|
|
68
|
+
export declare function getProjectSteering(context: NodeVeryfrontCloudAgentServiceContext, agentId?: string): HostedAgentProjectSteering;
|
|
69
|
+
//# sourceMappingURL=cloud-agent-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-agent-config.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/cloud-agent-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAML,KAAK,4BAA4B,EAElC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,qCAAqC,CAAC;AAQzG;;;GAGG;AACH,MAAM,MAAM,qCAAqC,GAAG,UAAU,CAC5D,OAAO,2CAA2C,CACnD,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,6CAA6C;;;;;;;;;SAQvC,OAAO,iBACL,MAAM,aACV,MAAM,OAAO,CAAC,OAAO,CAAC,GAChC,OAAO,CAAC,OAAO,CAAC;SACJ,OAAO,iBAAiB,MAAM,aAAa,MAAM,OAAO,GAAG,OAAO;;oBAcvD,MAAM,GAAG,IAAI;;;qBAGZ,4BAA4B,GAAG,IAAI;iBACvC,8BAA8B,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG7D;AAgBD,mEAAmE;AACnE,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,qCAAqC,EAC9C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,8BAA8B,CAAC,CAsBzC;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,qCAAqC,GAC7C,8BAA8B,CAOhC;AAED,qFAAqF;AACrF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,qCAAqC,GAC7C,4BAA4B,CAK9B;AAgCD,iFAAiF;AACjF,wBAAsB,+CAA+C,CACnE,OAAO,EAAE,qCAAqC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qCAAqC,GAAG,MAAM,CAQxF;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,qCAAqC,EAC9C,OAAO,GAAE,MAAmC,GAC3C,0BAA0B,CAgB5B"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** Agent-config resolution, context creation, and project-steering accessor for the cloud agent service. */
|
|
2
|
+
import { AGENT_NOT_FOUND, CONFIG_INVALID, INITIALIZATION_ERROR } from "../../errors/index.js";
|
|
3
|
+
import { createNodeAgentServiceRuntimeInfrastructure } from "../service/node-runtime-infrastructure.js";
|
|
4
|
+
import { createDetachedRunTracker } from "../service/detached-run-tracker.js";
|
|
5
|
+
import { createHostedAgentProjectSteering, } from "./agent-project-steering.js";
|
|
6
|
+
import { createRuntimeAgentDefinitionFromAgent, describeProjectAgentRuntimeAgentIdCandidates, discoverProjectAgentRuntime, doesProjectAgentRuntimeAgentMatchSource, getProjectAgentRuntimeAgentIdCandidates, resolveSingleProjectAgentRuntimeAgentId, } from "../project/agent-runtime.js";
|
|
7
|
+
import { nodeAdapter } from "../../platform/adapters/node.js";
|
|
8
|
+
import { resolveBaseDir, resolveDefaultProcessTarget, resolveEnvironment, resolveProjectDir, } from "./cloud-agent-paths.js";
|
|
9
|
+
/** Creates the shared runtime context for a cloud agent service instance. */
|
|
10
|
+
export function createNodeVeryfrontCloudAgentServiceContext(options) {
|
|
11
|
+
const processTarget = options.processTarget ?? resolveDefaultProcessTarget();
|
|
12
|
+
const infrastructure = createNodeAgentServiceRuntimeInfrastructure({
|
|
13
|
+
serviceName: options.serviceName,
|
|
14
|
+
env: resolveEnvironment({ env: options.env, processTarget }),
|
|
15
|
+
processTarget,
|
|
16
|
+
});
|
|
17
|
+
function trace(operationName, operation) {
|
|
18
|
+
return infrastructure.tracer.trace(operationName, operation);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
options,
|
|
22
|
+
processTarget,
|
|
23
|
+
projectDir: resolveProjectDir(options),
|
|
24
|
+
infrastructure,
|
|
25
|
+
trace,
|
|
26
|
+
defaultAgentId: null,
|
|
27
|
+
projectSteeringByAgentId: new Map(),
|
|
28
|
+
tracker: createDetachedRunTracker(),
|
|
29
|
+
discoveryResult: null,
|
|
30
|
+
agentConfig: null,
|
|
31
|
+
agentConfigs: new Map(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function getMarkdownAgentConfig(context, agentId) {
|
|
35
|
+
return getProjectSteering(context, agentId).getAgentConfig();
|
|
36
|
+
}
|
|
37
|
+
function loadMarkdownAgentConfig(context, agentId) {
|
|
38
|
+
return getMarkdownAgentConfig(context, agentId);
|
|
39
|
+
}
|
|
40
|
+
/** Resolves and caches the agent config for the given agent id. */
|
|
41
|
+
export async function resolveAgentConfig(context, agentId) {
|
|
42
|
+
const cachedAgentConfig = context.agentConfigs.get(agentId);
|
|
43
|
+
if (cachedAgentConfig) {
|
|
44
|
+
return cachedAgentConfig;
|
|
45
|
+
}
|
|
46
|
+
const source = context.options.agentSource ?? "auto";
|
|
47
|
+
const codeAgent = getProjectAgentRuntime(context).agents.get(agentId);
|
|
48
|
+
if (codeAgent && doesProjectAgentRuntimeAgentMatchSource(codeAgent, source)) {
|
|
49
|
+
const agentConfig = await createRuntimeAgentDefinitionFromAgent(codeAgent);
|
|
50
|
+
context.agentConfigs.set(agentConfig.id, agentConfig);
|
|
51
|
+
return agentConfig;
|
|
52
|
+
}
|
|
53
|
+
if (source === "code") {
|
|
54
|
+
throw AGENT_NOT_FOUND.create({ detail: `Code agent "${agentId}" was not discovered.` });
|
|
55
|
+
}
|
|
56
|
+
const agentConfig = loadMarkdownAgentConfig(context, agentId);
|
|
57
|
+
context.agentConfigs.set(agentConfig.id, agentConfig);
|
|
58
|
+
return agentConfig;
|
|
59
|
+
}
|
|
60
|
+
/** Returns the resolved agent config, throwing if the context has not been initialized. */
|
|
61
|
+
export function getResolvedAgentConfig(context) {
|
|
62
|
+
if (!context.agentConfig) {
|
|
63
|
+
throw INITIALIZATION_ERROR.create({
|
|
64
|
+
detail: "Agent service context has not been initialized.",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return context.agentConfig;
|
|
68
|
+
}
|
|
69
|
+
/** Returns the discovered project agent runtime, throwing if not yet initialized. */
|
|
70
|
+
export function getProjectAgentRuntime(context) {
|
|
71
|
+
if (!context.discoveryResult) {
|
|
72
|
+
throw new Error("Agent service context has not been initialized.");
|
|
73
|
+
}
|
|
74
|
+
return context.discoveryResult;
|
|
75
|
+
}
|
|
76
|
+
async function discoverProjectPrimitives(context) {
|
|
77
|
+
context.discoveryResult = await discoverProjectAgentRuntime({
|
|
78
|
+
projectDir: context.projectDir,
|
|
79
|
+
adapter: nodeAdapter,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function resolveDefaultAgentId(context) {
|
|
83
|
+
if (context.options.agentId) {
|
|
84
|
+
return context.options.agentId;
|
|
85
|
+
}
|
|
86
|
+
const source = context.options.agentSource ?? "auto";
|
|
87
|
+
const candidates = getProjectAgentRuntimeAgentIdCandidates(context.discoveryResult);
|
|
88
|
+
const agentId = resolveSingleProjectAgentRuntimeAgentId({ candidates, source });
|
|
89
|
+
if (agentId) {
|
|
90
|
+
return agentId;
|
|
91
|
+
}
|
|
92
|
+
throw CONFIG_INVALID.create({
|
|
93
|
+
detail: [
|
|
94
|
+
"agentId is required when agent discovery does not resolve to exactly one agent.",
|
|
95
|
+
`Discovered agents: ${describeProjectAgentRuntimeAgentIdCandidates(candidates)}.`,
|
|
96
|
+
].join(" "),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** Discovers project primitives and resolves the default agent id and config. */
|
|
100
|
+
export async function initializeNodeVeryfrontCloudAgentServiceContext(context) {
|
|
101
|
+
await discoverProjectPrimitives(context);
|
|
102
|
+
context.defaultAgentId = resolveDefaultAgentId(context);
|
|
103
|
+
context.agentConfig = await resolveAgentConfig(context, context.defaultAgentId);
|
|
104
|
+
}
|
|
105
|
+
/** Returns the default agent id, throwing if the context has not been initialized. */
|
|
106
|
+
export function getDefaultAgentId(context) {
|
|
107
|
+
if (!context.defaultAgentId) {
|
|
108
|
+
throw INITIALIZATION_ERROR.create({
|
|
109
|
+
detail: "Agent service context has not been initialized.",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return context.defaultAgentId;
|
|
113
|
+
}
|
|
114
|
+
/** Returns (and caches) the project steering object for the given agent id. */
|
|
115
|
+
export function getProjectSteering(context, agentId = getDefaultAgentId(context)) {
|
|
116
|
+
const cachedProjectSteering = context.projectSteeringByAgentId.get(agentId);
|
|
117
|
+
if (cachedProjectSteering) {
|
|
118
|
+
return cachedProjectSteering;
|
|
119
|
+
}
|
|
120
|
+
const projectSteering = createHostedAgentProjectSteering({
|
|
121
|
+
baseDir: resolveBaseDir(context.options),
|
|
122
|
+
agentId,
|
|
123
|
+
getApiUrl: () => context.infrastructure.getConfig().VERYFRONT_API_URL,
|
|
124
|
+
logger: context.infrastructure.logger,
|
|
125
|
+
trace: context.trace,
|
|
126
|
+
});
|
|
127
|
+
context.projectSteeringByAgentId.set(agentId, projectSteering);
|
|
128
|
+
return projectSteering;
|
|
129
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CreateNodeAgentServiceRuntimeInfrastructureOptions } from "../service/node-runtime-infrastructure.js";
|
|
2
|
+
/** A path option that is either a string path or a URL. */
|
|
3
|
+
export type AgentServicePathOption = string | URL;
|
|
4
|
+
export declare const DEFAULT_AGENT_SERVICE_NAME = "veryfront-agent-service";
|
|
5
|
+
/** Converts a path option (string or URL) to a string path. */
|
|
6
|
+
export declare function pathOptionToPath(pathOption: AgentServicePathOption): string;
|
|
7
|
+
/** Resolves the base directory from baseDir or entrypointUrl options. */
|
|
8
|
+
export declare function resolveBaseDir(options: {
|
|
9
|
+
baseDir?: AgentServicePathOption;
|
|
10
|
+
entrypointUrl?: AgentServicePathOption;
|
|
11
|
+
}): string;
|
|
12
|
+
/** Resolves the project directory from options, walking up for a discovery root. */
|
|
13
|
+
export declare function resolveProjectDir(options: {
|
|
14
|
+
baseDir?: AgentServicePathOption;
|
|
15
|
+
entrypointUrl?: AgentServicePathOption;
|
|
16
|
+
projectDir?: string;
|
|
17
|
+
}): string;
|
|
18
|
+
/** Reads the `name` field from the nearest package.json or deno.json, or null. */
|
|
19
|
+
export declare function readProjectManifestName(projectDir: string): string | null;
|
|
20
|
+
type ServiceNameOptions = {
|
|
21
|
+
serviceName?: string;
|
|
22
|
+
baseDir?: AgentServicePathOption;
|
|
23
|
+
entrypointUrl?: AgentServicePathOption;
|
|
24
|
+
projectDir?: string;
|
|
25
|
+
env?: CreateNodeAgentServiceRuntimeInfrastructureOptions["env"];
|
|
26
|
+
processTarget?: {
|
|
27
|
+
env?: CreateNodeAgentServiceRuntimeInfrastructureOptions["env"];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/** Resolves the service name from options, env, or project manifest. */
|
|
31
|
+
export declare function resolveServiceName(options: ServiceNameOptions): string;
|
|
32
|
+
/** Returns the default process target if `process` is available in the runtime. */
|
|
33
|
+
export declare function resolveDefaultProcessTarget(): NodeJS.Process | undefined;
|
|
34
|
+
/** Resolves the environment record from explicit env, processTarget.env, or the process env. */
|
|
35
|
+
export declare function resolveEnvironment(options: {
|
|
36
|
+
env?: CreateNodeAgentServiceRuntimeInfrastructureOptions["env"];
|
|
37
|
+
processTarget?: {
|
|
38
|
+
env?: CreateNodeAgentServiceRuntimeInfrastructureOptions["env"];
|
|
39
|
+
};
|
|
40
|
+
}): CreateNodeAgentServiceRuntimeInfrastructureOptions["env"];
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=cloud-agent-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-agent-paths.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/cloud-agent-paths.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kDAAkD,EAAE,MAAM,2CAA2C,CAAC;AAEpH,2DAA2D;AAC3D,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,GAAG,CAAC;AAElD,eAAO,MAAM,0BAA0B,4BAA4B,CAAC;AAQpE,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,sBAAsB,GAAG,MAAM,CAE3E;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAC5B,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,sBAAsB,CAAC;IAAC,aAAa,CAAC,EAAE,sBAAsB,CAAA;CAAE,GACpF,MAAM,CAQR;AAqBD,oFAAoF;AACpF,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,MAAM,CAQR;AAgBD,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsBzE;AAED,KAAK,kBAAkB,GAAG;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,kDAAkD,CAAC,KAAK,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,kDAAkD,CAAC,KAAK,CAAC,CAAA;KAAE,CAAC;CACrF,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAYtE;AAED,mFAAmF;AACnF,wBAAgB,2BAA2B,+BAK1C;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,CAChC,OAAO,EAAE;IACP,GAAG,CAAC,EAAE,kDAAkD,CAAC,KAAK,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,kDAAkD,CAAC,KAAK,CAAC,CAAA;KAAE,CAAC;CACrF,GACA,kDAAkD,CAAC,KAAK,CAAC,CAQ3D"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** Path and directory resolution utilities for the Veryfront Cloud agent service. */
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, resolve } from "../../platform/compat/path/index.js";
|
|
5
|
+
import { cwd, env } from "../../platform/compat/process.js";
|
|
6
|
+
import { defineSchema } from "../../schemas/index.js";
|
|
7
|
+
import { DEFAULT_PROJECT_DISCOVERY_DIRS } from "../../discovery/index.js";
|
|
8
|
+
export const DEFAULT_AGENT_SERVICE_NAME = "veryfront-agent-service";
|
|
9
|
+
const PROJECT_CONFIG_FILES = [
|
|
10
|
+
"veryfront.config.js",
|
|
11
|
+
"veryfront.config.ts",
|
|
12
|
+
"veryfront.config.mjs",
|
|
13
|
+
];
|
|
14
|
+
/** Converts a path option (string or URL) to a string path. */
|
|
15
|
+
export function pathOptionToPath(pathOption) {
|
|
16
|
+
return pathOption instanceof URL ? fileURLToPath(pathOption) : pathOption;
|
|
17
|
+
}
|
|
18
|
+
/** Resolves the base directory from baseDir or entrypointUrl options. */
|
|
19
|
+
export function resolveBaseDir(options) {
|
|
20
|
+
if (options.baseDir !== undefined) {
|
|
21
|
+
return pathOptionToPath(options.baseDir);
|
|
22
|
+
}
|
|
23
|
+
if (options.entrypointUrl !== undefined) {
|
|
24
|
+
return dirname(pathOptionToPath(options.entrypointUrl));
|
|
25
|
+
}
|
|
26
|
+
return cwd();
|
|
27
|
+
}
|
|
28
|
+
function hasDiscoveryRoot(baseDir) {
|
|
29
|
+
const discoveryDirs = [
|
|
30
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.agentDirs,
|
|
31
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.toolDirs,
|
|
32
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.skillDirs,
|
|
33
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.resourceDirs,
|
|
34
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.promptDirs,
|
|
35
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.workflowDirs,
|
|
36
|
+
...DEFAULT_PROJECT_DISCOVERY_DIRS.taskDirs,
|
|
37
|
+
];
|
|
38
|
+
return discoveryDirs.some((dir) => existsSync(resolve(baseDir, dir))) ||
|
|
39
|
+
PROJECT_CONFIG_FILES.some((file) => existsSync(resolve(baseDir, file)));
|
|
40
|
+
}
|
|
41
|
+
function uniquePaths(paths) {
|
|
42
|
+
return [...new Set(paths.map((path) => resolve(path)))];
|
|
43
|
+
}
|
|
44
|
+
/** Resolves the project directory from options, walking up for a discovery root. */
|
|
45
|
+
export function resolveProjectDir(options) {
|
|
46
|
+
if (options.projectDir) {
|
|
47
|
+
return options.projectDir;
|
|
48
|
+
}
|
|
49
|
+
const baseDir = resolveBaseDir(options);
|
|
50
|
+
const candidates = uniquePaths([baseDir, dirname(baseDir), dirname(dirname(baseDir))]);
|
|
51
|
+
return candidates.find(hasDiscoveryRoot) ?? baseDir;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Schema for the subset of a project manifest (package.json / deno.json) we
|
|
55
|
+
* read. Only `name` is consumed; extra fields are tolerated via passthrough so
|
|
56
|
+
* arbitrary manifests validate. Defined lazily via `defineSchema` so the zod
|
|
57
|
+
* extension is resolved at call time — the cloud-agent options resolver calls
|
|
58
|
+
* `ensureDefaultSchemaValidator()` before reaching service-name resolution, so
|
|
59
|
+
* a validator is registered by the time this runs.
|
|
60
|
+
*/
|
|
61
|
+
const getProjectManifestSchema = defineSchema((v) => v.object({
|
|
62
|
+
name: v.string().optional(),
|
|
63
|
+
}).passthrough());
|
|
64
|
+
/** Reads the `name` field from the nearest package.json or deno.json, or null. */
|
|
65
|
+
export function readProjectManifestName(projectDir) {
|
|
66
|
+
const manifestSchema = getProjectManifestSchema();
|
|
67
|
+
for (const fileName of ["package.json", "deno.json"]) {
|
|
68
|
+
const filePath = resolve(projectDir, fileName);
|
|
69
|
+
if (!existsSync(filePath)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const result = manifestSchema.safeParse(JSON.parse(readFileSync(filePath, "utf8")));
|
|
74
|
+
if (!result.success)
|
|
75
|
+
continue;
|
|
76
|
+
const name = result.data.name;
|
|
77
|
+
if (typeof name !== "string")
|
|
78
|
+
continue;
|
|
79
|
+
const trimmedName = name.trim();
|
|
80
|
+
if (trimmedName)
|
|
81
|
+
return trimmedName;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/** Resolves the service name from options, env, or project manifest. */
|
|
90
|
+
export function resolveServiceName(options) {
|
|
91
|
+
if (options.serviceName?.trim()) {
|
|
92
|
+
return options.serviceName.trim();
|
|
93
|
+
}
|
|
94
|
+
const resolved = resolveEnvironment(options);
|
|
95
|
+
const envServiceName = resolved?.VERYFRONT_AGENT_SERVICE_NAME?.trim();
|
|
96
|
+
if (envServiceName) {
|
|
97
|
+
return envServiceName;
|
|
98
|
+
}
|
|
99
|
+
return readProjectManifestName(resolveProjectDir(options)) ?? DEFAULT_AGENT_SERVICE_NAME;
|
|
100
|
+
}
|
|
101
|
+
/** Returns the default process target if `process` is available in the runtime. */
|
|
102
|
+
export function resolveDefaultProcessTarget() {
|
|
103
|
+
if (typeof process === "undefined") {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return process;
|
|
107
|
+
}
|
|
108
|
+
/** Resolves the environment record from explicit env, processTarget.env, or the process env. */
|
|
109
|
+
export function resolveEnvironment(options) {
|
|
110
|
+
if (options.env) {
|
|
111
|
+
return options.env;
|
|
112
|
+
}
|
|
113
|
+
if (options.processTarget?.env) {
|
|
114
|
+
return options.processTarget.env;
|
|
115
|
+
}
|
|
116
|
+
return env();
|
|
117
|
+
}
|