@apify/actors-mcp-server 0.9.20-beta.2 → 0.9.20-beta.4
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/dist/tools/core/fetch_actor_details_common.d.ts +62 -1
- package/dist/tools/core/fetch_actor_details_common.d.ts.map +1 -1
- package/dist/tools/core/fetch_actor_details_common.js +161 -2
- package/dist/tools/core/fetch_actor_details_common.js.map +1 -1
- package/dist/tools/core/get_actor_run_common.d.ts +11 -0
- package/dist/tools/core/get_actor_run_common.d.ts.map +1 -1
- package/dist/tools/core/get_actor_run_common.js +40 -1
- package/dist/tools/core/get_actor_run_common.js.map +1 -1
- package/dist/tools/default/fetch_actor_details.d.ts.map +1 -1
- package/dist/tools/default/fetch_actor_details.js +3 -36
- package/dist/tools/default/fetch_actor_details.js.map +1 -1
- package/dist/tools/default/get_actor_run.d.ts.map +1 -1
- package/dist/tools/default/get_actor_run.js +3 -16
- package/dist/tools/default/get_actor_run.js.map +1 -1
- package/dist/tools/openai/fetch_actor_details.d.ts.map +1 -1
- package/dist/tools/openai/fetch_actor_details.js +12 -12
- package/dist/tools/openai/fetch_actor_details.js.map +1 -1
- package/dist/tools/openai/fetch_actor_details_internal.d.ts.map +1 -1
- package/dist/tools/openai/fetch_actor_details_internal.js +16 -51
- package/dist/tools/openai/fetch_actor_details_internal.js.map +1 -1
- package/dist/tools/openai/get_actor_run.d.ts.map +1 -1
- package/dist/tools/openai/get_actor_run.js +3 -25
- package/dist/tools/openai/get_actor_run.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/actor_details.d.ts +19 -95
- package/dist/utils/actor_details.d.ts.map +1 -1
- package/dist/utils/actor_details.js +37 -179
- package/dist/utils/actor_details.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { Build } from 'apify-client';
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
import type { ApifyClient } from '../apify_client.js';
|
|
4
3
|
import type { PaymentProvider } from '../payments/types.js';
|
|
5
4
|
import type { Actor, ActorCardOptions, ActorInputSchema, StructuredActorCard } from '../types.js';
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Convert a type object to TypeScript-like string representation.
|
|
7
|
+
* Used for human-readable text output.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* Input: { first_number: "number", tags: ["string"], user: { name: "string" } }
|
|
11
|
+
* Output: "{ first_number: number, tags: string[], user: { name: string } }"
|
|
12
|
+
*
|
|
13
|
+
* Values that are not string / object / array are skipped (not rendered) at every nesting level.
|
|
14
|
+
*/
|
|
15
|
+
export declare function typeObjectToString(obj: Record<string, unknown>): string;
|
|
7
16
|
/**
|
|
8
17
|
* Resolve README content with fallback: prefer readmeSummary, fall back to full readme.
|
|
9
18
|
* Returns the content string and appropriate heading for text output.
|
|
@@ -26,69 +35,17 @@ export type ActorDetailsResult = {
|
|
|
26
35
|
};
|
|
27
36
|
export declare function fetchActorDetails(apifyClient: ApifyClient, actorName: string, cardOptions?: ActorCardOptions): Promise<ActorDetailsResult | null>;
|
|
28
37
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @param details - Raw actor details from fetchActorDetails
|
|
32
|
-
* @returns Processed actor details with formatted content
|
|
38
|
+
* Build the widget actor-details payload for the openai variant.
|
|
39
|
+
* Returns the Actor URL and the structured `actorDetails` object.
|
|
33
40
|
*/
|
|
34
|
-
export declare function
|
|
41
|
+
export declare function buildActorDetailsForWidget(details: ActorDetailsResult): {
|
|
35
42
|
actorUrl: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readme: string;
|
|
42
|
-
inputSchema: ActorInputSchema;
|
|
43
|
-
};
|
|
43
|
+
actorDetails: {
|
|
44
|
+
actorInfo: import("./actor_card.js").WidgetActor;
|
|
45
|
+
actorCard: string;
|
|
46
|
+
readme: string;
|
|
47
|
+
inputSchema: ActorInputSchema;
|
|
44
48
|
};
|
|
45
|
-
formattedReadme: string;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Shared schema for actor details output options.
|
|
49
|
-
* Used by both public and internal fetch-actor-details tools.
|
|
50
|
-
*
|
|
51
|
-
* Behavior:
|
|
52
|
-
* - If output is undefined or empty object: use defaults (all true except mcpTools and outputSchema)
|
|
53
|
-
* - If any property is explicitly set: only include sections with explicit true values
|
|
54
|
-
*/
|
|
55
|
-
export declare const actorDetailsOutputOptionsSchema: z.ZodObject<{
|
|
56
|
-
description: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
-
stats: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
-
pricing: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
-
rating: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
-
metadata: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
-
inputSchema: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
-
readme: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
-
outputSchema: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
-
mcpTools: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
-
}, z.core.$strip>;
|
|
66
|
-
export declare const actorDetailsOutputDefaults: {
|
|
67
|
-
description: boolean;
|
|
68
|
-
stats: boolean;
|
|
69
|
-
pricing: boolean;
|
|
70
|
-
rating: boolean;
|
|
71
|
-
metadata: boolean;
|
|
72
|
-
inputSchema: boolean;
|
|
73
|
-
readme: boolean;
|
|
74
|
-
outputSchema: boolean;
|
|
75
|
-
mcpTools: boolean;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Resolve output options with smart defaults.
|
|
79
|
-
* If output is undefined/empty, returns defaults.
|
|
80
|
-
* If any property is explicitly set, undefined properties are treated as false.
|
|
81
|
-
*/
|
|
82
|
-
export declare function resolveOutputOptions(output?: z.infer<typeof actorDetailsOutputOptionsSchema>): {
|
|
83
|
-
description: boolean;
|
|
84
|
-
stats: boolean;
|
|
85
|
-
pricing: boolean;
|
|
86
|
-
rating: boolean;
|
|
87
|
-
metadata: boolean;
|
|
88
|
-
inputSchema: boolean;
|
|
89
|
-
readme: boolean;
|
|
90
|
-
outputSchema: boolean;
|
|
91
|
-
mcpTools: boolean;
|
|
92
49
|
};
|
|
93
50
|
/**
|
|
94
51
|
* Gets MCP tools information for an Actor.
|
|
@@ -106,37 +63,4 @@ export declare function buildCardOptions(output: {
|
|
|
106
63
|
rating: boolean;
|
|
107
64
|
metadata: boolean;
|
|
108
65
|
}): ActorCardOptions;
|
|
109
|
-
/**
|
|
110
|
-
* Build error response for when actor is not found.
|
|
111
|
-
*/
|
|
112
|
-
export declare function buildActorNotFoundResponse(actorName: string): ReturnType<typeof buildMCPResponse>;
|
|
113
|
-
/**
|
|
114
|
-
* Build text and structured response for actor details.
|
|
115
|
-
* Handles all resolved output options: description, stats, readme, inputSchema, outputSchema, mcpTools.
|
|
116
|
-
* All output properties should be boolean (resolved via resolveOutputOptions).
|
|
117
|
-
*/
|
|
118
|
-
export declare function buildActorDetailsTextResponse(options: {
|
|
119
|
-
actorName: string;
|
|
120
|
-
details: ActorDetailsResult;
|
|
121
|
-
output: {
|
|
122
|
-
description: boolean;
|
|
123
|
-
stats: boolean;
|
|
124
|
-
pricing: boolean;
|
|
125
|
-
rating: boolean;
|
|
126
|
-
metadata: boolean;
|
|
127
|
-
readme: boolean;
|
|
128
|
-
inputSchema: boolean;
|
|
129
|
-
outputSchema: boolean;
|
|
130
|
-
mcpTools: boolean;
|
|
131
|
-
};
|
|
132
|
-
cardOptions: ActorCardOptions;
|
|
133
|
-
apifyClient: ApifyClient;
|
|
134
|
-
apifyToken: string;
|
|
135
|
-
actorOutputSchema?: Record<string, unknown> | null;
|
|
136
|
-
paymentProvider?: PaymentProvider;
|
|
137
|
-
mcpSessionId?: string;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
texts: string[];
|
|
140
|
-
structuredContent: Record<string, unknown>;
|
|
141
|
-
}>;
|
|
142
66
|
//# sourceMappingURL=actor_details.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor_details.d.ts","sourceRoot":"","sources":["../../src/utils/actor_details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"actor_details.d.ts","sourceRoot":"","sources":["../../src/utils/actor_details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAkB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQlH;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKvE;AASD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB,CAKA;AAGD,MAAM,MAAM,kBAAkB,GAAG;IAC7B,SAAS,EAAE,KAAK,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAsB,iBAAiB,CACnC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,gBAAgB,GAC/B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAsCpC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,kBAAkB;;;;;;;;EAYrE;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACpC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,eAAe,EACjC,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,CA6CjB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACrB,GAAG,gBAAgB,CAQnB"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { FAILURE_CATEGORY, HelperTools, TOOL_STATUS } from '../const.js';
|
|
3
1
|
import { connectMCPClient } from '../mcp/client.js';
|
|
4
2
|
import { filterSchemaProperties, shortenProperties } from '../tools/utils.js';
|
|
5
3
|
import { getActorMcpUrlCached } from './actor.js';
|
|
6
4
|
import { formatActorForWidget, formatActorToActorCard, formatActorToStructuredCard } from './actor_card.js';
|
|
7
5
|
import { searchActorsByKeywords } from './actor_search.js';
|
|
8
6
|
import { logHttpError } from './logging.js';
|
|
9
|
-
import { buildMCPResponse } from './mcp.js';
|
|
10
7
|
const ACTOR_DETAILS_PICTURE_SEARCH_LIMIT = 5;
|
|
11
8
|
/**
|
|
12
9
|
* Convert a type object to TypeScript-like string representation.
|
|
@@ -15,41 +12,22 @@ const ACTOR_DETAILS_PICTURE_SEARCH_LIMIT = 5;
|
|
|
15
12
|
* Example:
|
|
16
13
|
* Input: { first_number: "number", tags: ["string"], user: { name: "string" } }
|
|
17
14
|
* Output: "{ first_number: number, tags: string[], user: { name: string } }"
|
|
15
|
+
*
|
|
16
|
+
* Values that are not string / object / array are skipped (not rendered) at every nesting level.
|
|
18
17
|
*/
|
|
19
|
-
function typeObjectToString(obj) {
|
|
20
|
-
const pairs =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Array type
|
|
24
|
-
const itemType = typeValueToString(value[0]);
|
|
25
|
-
pairs.push(`${key}: ${itemType}[]`);
|
|
26
|
-
}
|
|
27
|
-
else if (typeof value === 'object' && value !== null) {
|
|
28
|
-
// Nested object type
|
|
29
|
-
const nestedStr = typeObjectToString(value);
|
|
30
|
-
pairs.push(`${key}: ${nestedStr}`);
|
|
31
|
-
}
|
|
32
|
-
else if (typeof value === 'string') {
|
|
33
|
-
// Primitive type
|
|
34
|
-
pairs.push(`${key}: ${value}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
18
|
+
export function typeObjectToString(obj) {
|
|
19
|
+
const pairs = Object.entries(obj)
|
|
20
|
+
.filter(([, v]) => Array.isArray(v) || (v !== null && typeof v === 'object') || typeof v === 'string')
|
|
21
|
+
.map(([k, v]) => `${k}: ${typeValueToString(v)}`);
|
|
37
22
|
return `{ ${pairs.join(', ')} }`;
|
|
38
23
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Convert a single type value to string.
|
|
41
|
-
*/
|
|
42
24
|
function typeValueToString(value) {
|
|
43
|
-
if (Array.isArray(value))
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
if (typeof value === 'object' && value !== null) {
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return `${typeValueToString(value[0])}[]`;
|
|
27
|
+
if (value !== null && typeof value === 'object')
|
|
48
28
|
return typeObjectToString(value);
|
|
49
|
-
|
|
50
|
-
if (typeof value === 'string') {
|
|
29
|
+
if (typeof value === 'string')
|
|
51
30
|
return value;
|
|
52
|
-
}
|
|
53
31
|
return 'unknown';
|
|
54
32
|
}
|
|
55
33
|
/**
|
|
@@ -65,13 +43,14 @@ export function resolveReadmeContent(details) {
|
|
|
65
43
|
}
|
|
66
44
|
export async function fetchActorDetails(apifyClient, actorName, cardOptions) {
|
|
67
45
|
try {
|
|
46
|
+
// Use only the actor name part (after '/') for better keyword search relevance —
|
|
47
|
+
// "apify/instagram-scraper" returns unrelated results, while "instagram-scraper" finds the correct actor.
|
|
48
|
+
const actorSlug = actorName.split('/').pop() || actorName;
|
|
49
|
+
const actor = apifyClient.actor(actorName);
|
|
68
50
|
const [actorInfo, buildInfo, storeActors] = await Promise.all([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Use only the actor name part (after '/') for better keyword search relevance —
|
|
73
|
-
// searching "apify/instagram-scraper" returns unrelated results, while "instagram-scraper" finds the correct actor.
|
|
74
|
-
searchActorsByKeywords(actorName.split('/').pop() || actorName, apifyClient.token || '', ACTOR_DETAILS_PICTURE_SEARCH_LIMIT).catch(() => []),
|
|
51
|
+
actor.get(),
|
|
52
|
+
actor.defaultBuild().then(async (build) => build.get()),
|
|
53
|
+
searchActorsByKeywords(actorSlug, apifyClient.token || '', ACTOR_DETAILS_PICTURE_SEARCH_LIMIT).catch(() => []),
|
|
75
54
|
]);
|
|
76
55
|
if (!actorInfo || !buildInfo || !buildInfo.actorDefinition)
|
|
77
56
|
return null;
|
|
@@ -102,25 +81,14 @@ export async function fetchActorDetails(apifyClient, actorName, cardOptions) {
|
|
|
102
81
|
}
|
|
103
82
|
}
|
|
104
83
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @param details - Raw actor details from fetchActorDetails
|
|
108
|
-
* @returns Processed actor details with formatted content
|
|
84
|
+
* Build the widget actor-details payload for the openai variant.
|
|
85
|
+
* Returns the Actor URL and the structured `actorDetails` object.
|
|
109
86
|
*/
|
|
110
|
-
export function
|
|
87
|
+
export function buildActorDetailsForWidget(details) {
|
|
111
88
|
const actorUrl = `https://apify.com/${details.actorInfo.username}/${details.actorInfo.name}`;
|
|
112
|
-
// Add link to README title
|
|
113
89
|
const formattedReadme = details.readme.replace(/^# /, `# [README](${actorUrl}/readme): `);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
formattedReadme,
|
|
117
|
-
];
|
|
118
|
-
// Include input schema if it has properties
|
|
119
|
-
const hasInputSchema = details.inputSchema.properties && Object.keys(details.inputSchema.properties).length !== 0;
|
|
120
|
-
if (hasInputSchema) {
|
|
121
|
-
texts.push(`# [Input schema](${actorUrl}/input)\n\`\`\`json\n${JSON.stringify(details.inputSchema)}\n\`\`\``);
|
|
122
|
-
}
|
|
123
|
-
const structuredContent = {
|
|
90
|
+
return {
|
|
91
|
+
actorUrl,
|
|
124
92
|
actorDetails: {
|
|
125
93
|
actorInfo: formatActorForWidget(details.actorInfo),
|
|
126
94
|
actorCard: details.actorCard,
|
|
@@ -128,66 +96,6 @@ export function processActorDetailsForResponse(details) {
|
|
|
128
96
|
inputSchema: details.inputSchema,
|
|
129
97
|
},
|
|
130
98
|
};
|
|
131
|
-
return {
|
|
132
|
-
actorUrl,
|
|
133
|
-
texts,
|
|
134
|
-
structuredContent,
|
|
135
|
-
formattedReadme,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Shared schema for actor details output options.
|
|
140
|
-
* Used by both public and internal fetch-actor-details tools.
|
|
141
|
-
*
|
|
142
|
-
* Behavior:
|
|
143
|
-
* - If output is undefined or empty object: use defaults (all true except mcpTools and outputSchema)
|
|
144
|
-
* - If any property is explicitly set: only include sections with explicit true values
|
|
145
|
-
*/
|
|
146
|
-
export const actorDetailsOutputOptionsSchema = z.object({
|
|
147
|
-
description: z.boolean().optional().describe('Include Actor description text only.'),
|
|
148
|
-
stats: z.boolean().optional().describe('Include usage statistics (users, runs, success rate).'),
|
|
149
|
-
pricing: z.boolean().optional().describe('Include pricing model and costs.'),
|
|
150
|
-
rating: z.boolean().optional().describe('Include user rating (out of 5 stars).'),
|
|
151
|
-
metadata: z.boolean().optional().describe('Include developer, categories, last modified date, and deprecation status.'),
|
|
152
|
-
inputSchema: z.boolean().optional().describe('Include required input parameters schema.'),
|
|
153
|
-
readme: z.boolean().optional().describe('Include Actor README documentation (summary when available, full otherwise).'),
|
|
154
|
-
outputSchema: z.boolean().optional().describe('Include inferred output schema from recent successful runs (TypeScript type).'),
|
|
155
|
-
mcpTools: z.boolean().optional().describe('List available tools (only for MCP server Actors).'),
|
|
156
|
-
});
|
|
157
|
-
export const actorDetailsOutputDefaults = {
|
|
158
|
-
description: true,
|
|
159
|
-
stats: true,
|
|
160
|
-
pricing: true,
|
|
161
|
-
rating: true,
|
|
162
|
-
metadata: true,
|
|
163
|
-
inputSchema: true,
|
|
164
|
-
readme: true,
|
|
165
|
-
outputSchema: false,
|
|
166
|
-
mcpTools: false,
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Resolve output options with smart defaults.
|
|
170
|
-
* If output is undefined/empty, returns defaults.
|
|
171
|
-
* If any property is explicitly set, undefined properties are treated as false.
|
|
172
|
-
*/
|
|
173
|
-
export function resolveOutputOptions(output) {
|
|
174
|
-
// Check if output has any explicit true/false values
|
|
175
|
-
const hasExplicitOptions = output && Object.values(output).some((v) => v !== undefined);
|
|
176
|
-
if (!hasExplicitOptions) {
|
|
177
|
-
return actorDetailsOutputDefaults;
|
|
178
|
-
}
|
|
179
|
-
// Return output with undefined treated as false (explicit true required)
|
|
180
|
-
return {
|
|
181
|
-
description: (output === null || output === void 0 ? void 0 : output.description) === true,
|
|
182
|
-
stats: (output === null || output === void 0 ? void 0 : output.stats) === true,
|
|
183
|
-
pricing: (output === null || output === void 0 ? void 0 : output.pricing) === true,
|
|
184
|
-
rating: (output === null || output === void 0 ? void 0 : output.rating) === true,
|
|
185
|
-
metadata: (output === null || output === void 0 ? void 0 : output.metadata) === true,
|
|
186
|
-
inputSchema: (output === null || output === void 0 ? void 0 : output.inputSchema) === true,
|
|
187
|
-
readme: (output === null || output === void 0 ? void 0 : output.readme) === true,
|
|
188
|
-
outputSchema: (output === null || output === void 0 ? void 0 : output.outputSchema) === true,
|
|
189
|
-
mcpTools: (output === null || output === void 0 ? void 0 : output.mcpTools) === true,
|
|
190
|
-
};
|
|
191
99
|
}
|
|
192
100
|
/**
|
|
193
101
|
* Gets MCP tools information for an Actor.
|
|
@@ -211,9 +119,22 @@ export async function getMcpToolsMessage(actorName, apifyClient, apifyToken, pay
|
|
|
211
119
|
try {
|
|
212
120
|
const toolsResponse = await client.listTools();
|
|
213
121
|
const mcpToolsInfo = toolsResponse.tools
|
|
214
|
-
.map((tool) =>
|
|
122
|
+
.map((tool) => [
|
|
123
|
+
`**${tool.name}**`,
|
|
124
|
+
tool.description || 'No description',
|
|
125
|
+
'Input schema:',
|
|
126
|
+
'```json',
|
|
127
|
+
JSON.stringify(tool.inputSchema),
|
|
128
|
+
'```',
|
|
129
|
+
].join('\n'))
|
|
215
130
|
.join('\n\n');
|
|
216
|
-
return
|
|
131
|
+
return [
|
|
132
|
+
'# Available MCP Tools',
|
|
133
|
+
`This Actor is an MCP server with ${toolsResponse.tools.length} tools.`,
|
|
134
|
+
`To call a tool, use: "${actorName}:{toolName}"`,
|
|
135
|
+
'',
|
|
136
|
+
mcpToolsInfo,
|
|
137
|
+
].join('\n');
|
|
217
138
|
}
|
|
218
139
|
catch (error) {
|
|
219
140
|
logHttpError(error, `Failed to list MCP tools for Actor '${actorName}'`, { actorName });
|
|
@@ -236,67 +157,4 @@ export function buildCardOptions(output) {
|
|
|
236
157
|
includeMetadata: output.metadata,
|
|
237
158
|
};
|
|
238
159
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Build error response for when actor is not found.
|
|
241
|
-
*/
|
|
242
|
-
export function buildActorNotFoundResponse(actorName) {
|
|
243
|
-
return buildMCPResponse({
|
|
244
|
-
texts: [`Actor information for '${actorName}' was not found.
|
|
245
|
-
Please verify Actor ID or name format and ensure that the Actor exists.
|
|
246
|
-
You can search for available Actors using the tool: ${HelperTools.STORE_SEARCH}.`],
|
|
247
|
-
isError: true,
|
|
248
|
-
telemetry: { toolStatus: TOOL_STATUS.SOFT_FAIL, failureCategory: FAILURE_CATEGORY.INVALID_INPUT },
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Build text and structured response for actor details.
|
|
253
|
-
* Handles all resolved output options: description, stats, readme, inputSchema, outputSchema, mcpTools.
|
|
254
|
-
* All output properties should be boolean (resolved via resolveOutputOptions).
|
|
255
|
-
*/
|
|
256
|
-
export async function buildActorDetailsTextResponse(options) {
|
|
257
|
-
const { actorName, details, output, cardOptions, apifyClient, apifyToken, actorOutputSchema, paymentProvider, mcpSessionId } = options;
|
|
258
|
-
const actorUrl = `https://apify.com/${details.actorInfo.username}/${details.actorInfo.name}`;
|
|
259
|
-
const texts = [];
|
|
260
|
-
// Build actor card only if any card section is requested
|
|
261
|
-
const needsCard = cardOptions.includeDescription
|
|
262
|
-
|| cardOptions.includeStats
|
|
263
|
-
|| cardOptions.includePricing
|
|
264
|
-
|| cardOptions.includeRating
|
|
265
|
-
|| cardOptions.includeMetadata;
|
|
266
|
-
if (needsCard) {
|
|
267
|
-
texts.push(`# Actor information\n${details.actorCard}`);
|
|
268
|
-
}
|
|
269
|
-
// Add README content if requested (prefer readmeSummary, fall back to full readme)
|
|
270
|
-
const resolvedReadme = output.readme ? resolveReadmeContent(details) : undefined;
|
|
271
|
-
if (resolvedReadme) {
|
|
272
|
-
texts.push(`${resolvedReadme.heading}\n${resolvedReadme.content}`);
|
|
273
|
-
}
|
|
274
|
-
// Add input schema if requested
|
|
275
|
-
if (output.inputSchema) {
|
|
276
|
-
texts.push(`# [Input schema](${actorUrl}/input)\n\`\`\`json\n${JSON.stringify(details.inputSchema)}\n\`\`\``);
|
|
277
|
-
}
|
|
278
|
-
// Add output schema if requested
|
|
279
|
-
if (output.outputSchema) {
|
|
280
|
-
if (actorOutputSchema && Object.keys(actorOutputSchema).length > 0) {
|
|
281
|
-
const typeString = typeObjectToString(actorOutputSchema);
|
|
282
|
-
texts.push(`# Output Schema (TypeScript)\nInferred from recent successful runs:\n\`\`\`typescript\ntype ActorOutput = ${typeString}\n\`\`\``);
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
texts.push(`# Output Schema\nNo output schema available. The Actor may not have recent successful runs, or the output structure could not be determined.`);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// Handle MCP tools
|
|
289
|
-
if (output.mcpTools) {
|
|
290
|
-
const message = await getMcpToolsMessage(actorName, apifyClient, apifyToken, paymentProvider, mcpSessionId);
|
|
291
|
-
texts.push(message);
|
|
292
|
-
}
|
|
293
|
-
// Build structured content
|
|
294
|
-
const structuredContent = {
|
|
295
|
-
actorInfo: needsCard ? details.actorCardStructured : undefined,
|
|
296
|
-
readme: resolvedReadme === null || resolvedReadme === void 0 ? void 0 : resolvedReadme.content,
|
|
297
|
-
inputSchema: output.inputSchema ? details.inputSchema : undefined,
|
|
298
|
-
outputSchema: output.outputSchema ? (actorOutputSchema !== null && actorOutputSchema !== void 0 ? actorOutputSchema : {}) : undefined,
|
|
299
|
-
};
|
|
300
|
-
return { texts, structuredContent };
|
|
301
|
-
}
|
|
302
160
|
//# sourceMappingURL=actor_details.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor_details.js","sourceRoot":"","sources":["../../src/utils/actor_details.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actor_details.js","sourceRoot":"","sources":["../../src/utils/actor_details.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,E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