Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

feat: enhance agent skill call functionality with domain support

Muhammad Hamza Khan13e68ec4bec8
diff --git a/packages/app/src/backend/routes/api/page/builder.ts b/packages/app/src/backend/routes/api/page/builder.ts
index a8b7ca3c..9a3db106 100644
--- a/packages/app/src/backend/routes/api/page/builder.ts
+++ b/packages/app/src/backend/routes/api/page/builder.ts
@@ -17,7 +17,6 @@ import { getIntegrations } from '../../router.utils/templates.utils';
import axios, { AxiosError, AxiosResponse } from 'axios';
import rateLimit from 'express-rate-limit';
import { jsonrepair } from 'jsonrepair';
-import jwt from 'jsonwebtoken';
import multer from 'multer';
import { RedisStore } from 'rate-limit-redis';
import {
@@ -524,7 +523,7 @@ router.post('/data/generate-form-data', generateFormDataRateLim, async (req, res
});
router.post('/ai-agent/:agentId/skill-call', async (req, res) => {
- const { componentId, payload, version } = req.body;
+ const { componentId, payload, version, domain } = req.body;
const agentId = req.params.agentId;
if (!agentId || !componentId || !payload) {
return res.status(400).send({ success: false, error: 'Missing required fields' });
@@ -564,6 +563,7 @@ router.post('/ai-agent/:agentId/skill-call', async (req, res) => {
agentId,
teamId: agentData?.teamId,
headers,
+ domain: domain || '',
});
return res.status(200).send({ success: true, response: result });
@@ -576,6 +576,7 @@ async function fetchAgentSkill({
agentId,
teamId,
headers,
+ domain,
}: {
values: any;
endpoint: string;
@@ -583,10 +584,11 @@ async function fetchAgentSkill({
agentId: string;
teamId: string;
headers?: { [key: string]: string | string[] };
+ domain: string;
}) {
const _method = method.toUpperCase();
- const RUNTIME_AGENT_URL = config.env.API_SERVER;
+ const RUNTIME_AGENT_URL = domain || config.env.API_SERVER;
const request: {
body: string | null;
@@ -595,16 +597,6 @@ async function fetchAgentSkill({
request.body = JSON.stringify(values);
- const token = jwt.sign(
- {
- agentId: agentId,
- teamId: teamId,
- exp: Math.floor(Date.now() / 1000) + 60, // 60 min expiry
- },
- config.env.INTERNAL_TRUSTED_SECRET, // Shared secret between services
- { algorithm: 'HS256' },
- );
-
request.headers = {
...(headers || {}),
...(_method === 'POST' && { 'Content-Type': 'application/json' }),
@@ -613,7 +605,6 @@ async function fetchAgentSkill({
'X-AGENT-ID': agentId,
'x-smyth-debug': 'true',
'X-DEBUG-read': '',
- 'X-AUTH-TOKEN': 'Bearer ' + token,
};
try {
diff --git a/packages/app/src/react/features/builder/contexts/endpoint-form-preview-sidebar.context.tsx b/packages/app/src/react/features/builder/contexts/endpoint-form-preview-sidebar.context.tsx
index 90ac72b2..72068311 100644
--- a/packages/app/src/react/features/builder/contexts/endpoint-form-preview-sidebar.context.tsx
+++ b/packages/app/src/react/features/builder/contexts/endpoint-form-preview-sidebar.context.tsx
@@ -1,5 +1,6 @@
import EventEmitter from '@src/react/features/builder/utils';
import { Input } from '@src/react/shared/types/agent-data.types';
+import { builderStore } from '@src/shared/state_stores/builder/store';
import { useMutation, UseMutationResult } from '@tanstack/react-query';
import {
createContext,
@@ -10,6 +11,7 @@ import {
SetStateAction,
useContext,
useEffect,
+ useMemo,
useRef,
useState,
} from 'react';
@@ -169,6 +171,12 @@ export const EndpointFormPreviewProvider: FC<EndpointFormPreviewProviderProps> =
);
};
+ const { dev: devDomain, scheme } = builderStore.getState().agentDomains;
+ const agentDomain = useMemo(
+ () => (devDomain && scheme ? `${scheme}://${devDomain}` : ''),
+ [devDomain, scheme],
+ );
+
const callSkillMutation = useMutation({
mutationFn: async (values: any) => {
abortController.current?.abort();
@@ -179,6 +187,7 @@ export const EndpointFormPreviewProvider: FC<EndpointFormPreviewProviderProps> =
payload: values,
componentId: selectedSkill?.skillId,
version: 'dev',
+ domain: agentDomain,
}),
signal: abortController.current?.signal,
headers: {