@apify/actors-mcp-server 0.9.20-beta.0 → 0.9.20-beta.10
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/const.d.ts +1 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +3 -0
- package/dist/const.js.map +1 -1
- package/dist/mcp/server.js +3 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/tools/core/call_actor_common.d.ts +45 -0
- package/dist/tools/core/call_actor_common.d.ts.map +1 -1
- package/dist/tools/core/call_actor_common.js +148 -13
- package/dist/tools/core/call_actor_common.js.map +1 -1
- 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 +168 -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/core/search_actors_common.d.ts +12 -2
- package/dist/tools/core/search_actors_common.d.ts.map +1 -1
- package/dist/tools/core/search_actors_common.js +26 -16
- package/dist/tools/core/search_actors_common.js.map +1 -1
- package/dist/tools/default/call_actor.d.ts.map +1 -1
- package/dist/tools/default/call_actor.js +19 -50
- package/dist/tools/default/call_actor.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/default/search_actors.d.ts.map +1 -1
- package/dist/tools/default/search_actors.js +16 -10
- package/dist/tools/default/search_actors.js.map +1 -1
- package/dist/tools/openai/actor_executor.d.ts.map +1 -1
- package/dist/tools/openai/actor_executor.js +6 -26
- package/dist/tools/openai/actor_executor.js.map +1 -1
- package/dist/tools/openai/call_actor.d.ts.map +1 -1
- package/dist/tools/openai/call_actor.js +18 -62
- package/dist/tools/openai/call_actor.js.map +1 -1
- package/dist/tools/openai/fetch_actor_details.d.ts.map +1 -1
- package/dist/tools/openai/fetch_actor_details.js +19 -13
- 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/tools/openai/search_actors.d.ts.map +1 -1
- package/dist/tools/openai/search_actors.js +18 -12
- package/dist/tools/openai/search_actors.js.map +1 -1
- package/dist/tools/openai/search_actors_internal.d.ts.map +1 -1
- package/dist/tools/openai/search_actors_internal.js +5 -19
- package/dist/tools/openai/search_actors_internal.js.map +1 -1
- package/dist/tools/structured_output_schemas.d.ts +68 -4
- package/dist/tools/structured_output_schemas.d.ts.map +1 -1
- package/dist/tools/structured_output_schemas.js +28 -4
- package/dist/tools/structured_output_schemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/actor_card.d.ts +7 -2
- package/dist/utils/actor_card.d.ts.map +1 -1
- package/dist/utils/actor_card.js +20 -8
- package/dist/utils/actor_card.js.map +1 -1
- package/dist/utils/actor_details.d.ts +21 -95
- package/dist/utils/actor_details.d.ts.map +1 -1
- package/dist/utils/actor_details.js +39 -180
- package/dist/utils/actor_details.js.map +1 -1
- package/dist/utils/pricing_info.d.ts +71 -20
- package/dist/utils/pricing_info.d.ts.map +1 -1
- package/dist/utils/pricing_info.js +362 -129
- package/dist/utils/pricing_info.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +5 -4
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/userid_cache.d.ts +12 -4
- package/dist/utils/userid_cache.d.ts.map +1 -1
- package/dist/utils/userid_cache.js +41 -14
- package/dist/utils/userid_cache.js.map +1 -1
- package/dist/web/dist/actor-detail-widget.js +2 -2
- package/dist/web/dist/search-actors-widget.js +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
2
|
+
import { HelperTools } from '../../const.js';
|
|
3
|
+
import type { HelperTool, InternalToolArgs } from '../../types.js';
|
|
4
|
+
import { type ActorDetailsResult } from '../../utils/actor_details.js';
|
|
5
|
+
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
6
|
+
/**
|
|
7
|
+
* Shared schema for actor details output options.
|
|
8
|
+
*
|
|
9
|
+
* Behavior:
|
|
10
|
+
* - If output is undefined or empty object: use defaults (all true except mcpTools and outputSchema)
|
|
11
|
+
* - If any property is explicitly set: only include sections with explicit true values
|
|
12
|
+
*/
|
|
13
|
+
export declare const actorDetailsOutputOptionsSchema: z.ZodObject<{
|
|
14
|
+
description: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
stats: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
pricing: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
rating: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
metadata: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
inputSchema: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
readme: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
outputSchema: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
mcpTools: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const actorDetailsOutputDefaults: {
|
|
25
|
+
description: boolean;
|
|
26
|
+
stats: boolean;
|
|
27
|
+
pricing: boolean;
|
|
28
|
+
rating: boolean;
|
|
29
|
+
metadata: boolean;
|
|
30
|
+
inputSchema: boolean;
|
|
31
|
+
readme: boolean;
|
|
32
|
+
outputSchema: boolean;
|
|
33
|
+
mcpTools: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type ResolvedOutputOptions = typeof actorDetailsOutputDefaults;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve output options with smart defaults.
|
|
38
|
+
* If output is undefined/empty, returns defaults.
|
|
39
|
+
* If any property is explicitly set, undefined properties are treated as false.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveOutputOptions(output?: z.infer<typeof actorDetailsOutputOptionsSchema>): ResolvedOutputOptions;
|
|
3
42
|
/**
|
|
4
43
|
* Zod schema for fetch-actor-details arguments — shared between default and openai variants.
|
|
5
44
|
*/
|
|
@@ -22,4 +61,26 @@ export declare const fetchActorDetailsToolArgsSchema: z.ZodObject<{
|
|
|
22
61
|
* Used by both default and openai variants.
|
|
23
62
|
*/
|
|
24
63
|
export declare const fetchActorDetailsMetadata: Omit<HelperTool, 'call'>;
|
|
64
|
+
/**
|
|
65
|
+
* Build error response for when actor is not found.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildActorNotFoundResponse(actorName: string): ReturnType<typeof buildMCPResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Build text and structured response for actor details.
|
|
70
|
+
* Pure/sync: the caller pre-resolves `mcpToolsMessage` when `output.mcpTools` is true.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildActorDetailsTextResponse(options: {
|
|
73
|
+
details: ActorDetailsResult;
|
|
74
|
+
output: ResolvedOutputOptions;
|
|
75
|
+
actorOutputSchema?: Record<string, unknown> | null;
|
|
76
|
+
mcpToolsMessage?: string;
|
|
77
|
+
}): {
|
|
78
|
+
texts: string[];
|
|
79
|
+
structuredContent: Record<string, unknown>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Shared handler for default and internal fetch-actor-details variants.
|
|
83
|
+
* Both return the same text + structured response; only the telemetry route differs.
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildFetchActorDetailsResult(toolArgs: InternalToolArgs, route: HelperTools.ACTOR_GET_DETAILS | HelperTools.ACTOR_GET_DETAILS_INTERNAL): Promise<ReturnType<typeof buildMCPResponse>>;
|
|
25
86
|
//# sourceMappingURL=fetch_actor_details_common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details_common.d.ts","sourceRoot":"","sources":["../../../src/tools/core/fetch_actor_details_common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch_actor_details_common.d.ts","sourceRoot":"","sources":["../../../src/tools/core/fetch_actor_details_common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAoB,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAE5E,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AACpF,OAAO,EACH,KAAK,kBAAkB,EAM1B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;iBAU1C,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;CAUtC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,OAAO,0BAA0B,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,GAAG,qBAAqB,CAkBpH;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;iBAM1C,CAAC;AAiBH;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAkB9D,CAAC;AAEF;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAUjG;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE;IACnD,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,qBAAqB,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG;IACA,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C,CA6DA;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAC9C,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,WAAW,CAAC,iBAAiB,GAAG,WAAW,CAAC,0BAA0B,GAC9E,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAuC9C"}
|
|
@@ -1,10 +1,65 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import dedent from 'dedent';
|
|
2
3
|
import { z } from 'zod';
|
|
3
|
-
import { HelperTools } from '../../const.js';
|
|
4
|
+
import { FAILURE_CATEGORY, HelperTools, TOOL_STATUS } from '../../const.js';
|
|
4
5
|
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
5
|
-
import {
|
|
6
|
+
import { buildCardOptions, fetchActorDetails, getMcpToolsMessage, resolveReadmeContent, typeObjectToString, } from '../../utils/actor_details.js';
|
|
6
7
|
import { compileSchema } from '../../utils/ajv.js';
|
|
8
|
+
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
9
|
+
import { getUserInfoCached } from '../../utils/userid_cache.js';
|
|
7
10
|
import { actorDetailsOutputSchema } from '../structured_output_schemas.js';
|
|
11
|
+
import { fixActorNameInputAndLog } from './actor_tools_factory.js';
|
|
12
|
+
/**
|
|
13
|
+
* Shared schema for actor details output options.
|
|
14
|
+
*
|
|
15
|
+
* Behavior:
|
|
16
|
+
* - If output is undefined or empty object: use defaults (all true except mcpTools and outputSchema)
|
|
17
|
+
* - If any property is explicitly set: only include sections with explicit true values
|
|
18
|
+
*/
|
|
19
|
+
export const actorDetailsOutputOptionsSchema = z.object({
|
|
20
|
+
description: z.boolean().optional().describe('Include Actor description text only.'),
|
|
21
|
+
stats: z.boolean().optional().describe('Include usage statistics (users, runs, success rate).'),
|
|
22
|
+
pricing: z.boolean().optional().describe('Include pricing model and costs.'),
|
|
23
|
+
rating: z.boolean().optional().describe('Include user rating (out of 5 stars).'),
|
|
24
|
+
metadata: z.boolean().optional().describe('Include developer, categories, last modified date, and deprecation status.'),
|
|
25
|
+
inputSchema: z.boolean().optional().describe('Include required input parameters schema.'),
|
|
26
|
+
readme: z.boolean().optional().describe('Include Actor README documentation (summary when available, full otherwise).'),
|
|
27
|
+
outputSchema: z.boolean().optional().describe('Include inferred output schema from recent successful runs (TypeScript type).'),
|
|
28
|
+
mcpTools: z.boolean().optional().describe('List available tools (only for MCP server Actors).'),
|
|
29
|
+
});
|
|
30
|
+
export const actorDetailsOutputDefaults = {
|
|
31
|
+
description: true,
|
|
32
|
+
stats: true,
|
|
33
|
+
pricing: true,
|
|
34
|
+
rating: true,
|
|
35
|
+
metadata: true,
|
|
36
|
+
inputSchema: true,
|
|
37
|
+
readme: true,
|
|
38
|
+
outputSchema: false,
|
|
39
|
+
mcpTools: false,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Resolve output options with smart defaults.
|
|
43
|
+
* If output is undefined/empty, returns defaults.
|
|
44
|
+
* If any property is explicitly set, undefined properties are treated as false.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveOutputOptions(output) {
|
|
47
|
+
const hasExplicitOptions = output && Object.values(output).some((v) => v !== undefined);
|
|
48
|
+
if (!hasExplicitOptions) {
|
|
49
|
+
return actorDetailsOutputDefaults;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
description: (output === null || output === void 0 ? void 0 : output.description) === true,
|
|
53
|
+
stats: (output === null || output === void 0 ? void 0 : output.stats) === true,
|
|
54
|
+
pricing: (output === null || output === void 0 ? void 0 : output.pricing) === true,
|
|
55
|
+
rating: (output === null || output === void 0 ? void 0 : output.rating) === true,
|
|
56
|
+
metadata: (output === null || output === void 0 ? void 0 : output.metadata) === true,
|
|
57
|
+
inputSchema: (output === null || output === void 0 ? void 0 : output.inputSchema) === true,
|
|
58
|
+
readme: (output === null || output === void 0 ? void 0 : output.readme) === true,
|
|
59
|
+
outputSchema: (output === null || output === void 0 ? void 0 : output.outputSchema) === true,
|
|
60
|
+
mcpTools: (output === null || output === void 0 ? void 0 : output.mcpTools) === true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
8
63
|
/**
|
|
9
64
|
* Zod schema for fetch-actor-details arguments — shared between default and openai variants.
|
|
10
65
|
*/
|
|
@@ -52,4 +107,115 @@ export const fetchActorDetailsMetadata = {
|
|
|
52
107
|
openWorldHint: false,
|
|
53
108
|
},
|
|
54
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Build error response for when actor is not found.
|
|
112
|
+
*/
|
|
113
|
+
export function buildActorNotFoundResponse(actorName) {
|
|
114
|
+
return buildMCPResponse({
|
|
115
|
+
texts: [dedent `
|
|
116
|
+
Actor information for '${actorName}' was not found.
|
|
117
|
+
Please verify Actor ID or name format and ensure that the Actor exists.
|
|
118
|
+
You can search for available Actors using the tool: ${HelperTools.STORE_SEARCH}.
|
|
119
|
+
`],
|
|
120
|
+
isError: true,
|
|
121
|
+
telemetry: { toolStatus: TOOL_STATUS.SOFT_FAIL, failureCategory: FAILURE_CATEGORY.INVALID_INPUT },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Build text and structured response for actor details.
|
|
126
|
+
* Pure/sync: the caller pre-resolves `mcpToolsMessage` when `output.mcpTools` is true.
|
|
127
|
+
*/
|
|
128
|
+
export function buildActorDetailsTextResponse(options) {
|
|
129
|
+
const { details, output, actorOutputSchema, mcpToolsMessage } = options;
|
|
130
|
+
const actorUrl = `https://apify.com/${details.actorInfo.username}/${details.actorInfo.name}`;
|
|
131
|
+
const texts = [];
|
|
132
|
+
const needsCard = output.description
|
|
133
|
+
|| output.stats
|
|
134
|
+
|| output.pricing
|
|
135
|
+
|| output.rating
|
|
136
|
+
|| output.metadata;
|
|
137
|
+
if (needsCard) {
|
|
138
|
+
texts.push(`# Actor information\n${details.actorCard}`);
|
|
139
|
+
}
|
|
140
|
+
const resolvedReadme = output.readme ? resolveReadmeContent(details) : undefined;
|
|
141
|
+
if (resolvedReadme) {
|
|
142
|
+
texts.push(`${resolvedReadme.heading}\n${resolvedReadme.content}`);
|
|
143
|
+
}
|
|
144
|
+
if (output.inputSchema) {
|
|
145
|
+
texts.push([
|
|
146
|
+
`# [Input schema](${actorUrl}/input)`,
|
|
147
|
+
'```json',
|
|
148
|
+
JSON.stringify(details.inputSchema),
|
|
149
|
+
'```',
|
|
150
|
+
].join('\n'));
|
|
151
|
+
}
|
|
152
|
+
if (output.outputSchema) {
|
|
153
|
+
if (actorOutputSchema && Object.keys(actorOutputSchema).length > 0) {
|
|
154
|
+
const typeString = typeObjectToString(actorOutputSchema);
|
|
155
|
+
texts.push(dedent `
|
|
156
|
+
# Output Schema (TypeScript)
|
|
157
|
+
Inferred from recent successful runs:
|
|
158
|
+
\`\`\`typescript
|
|
159
|
+
type ActorOutput = ${typeString}
|
|
160
|
+
\`\`\`
|
|
161
|
+
`);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
texts.push(dedent `
|
|
165
|
+
# Output Schema
|
|
166
|
+
No output schema available. The Actor may not have recent successful runs, or the output structure could not be determined.
|
|
167
|
+
`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (mcpToolsMessage) {
|
|
171
|
+
texts.push(mcpToolsMessage);
|
|
172
|
+
}
|
|
173
|
+
const structuredContent = {
|
|
174
|
+
actorInfo: needsCard ? details.actorCardStructured : undefined,
|
|
175
|
+
readme: resolvedReadme === null || resolvedReadme === void 0 ? void 0 : resolvedReadme.content,
|
|
176
|
+
inputSchema: output.inputSchema ? details.inputSchema : undefined,
|
|
177
|
+
outputSchema: output.outputSchema ? (actorOutputSchema !== null && actorOutputSchema !== void 0 ? actorOutputSchema : {}) : undefined,
|
|
178
|
+
};
|
|
179
|
+
return { texts, structuredContent };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Shared handler for default and internal fetch-actor-details variants.
|
|
183
|
+
* Both return the same text + structured response; only the telemetry route differs.
|
|
184
|
+
*/
|
|
185
|
+
export async function buildFetchActorDetailsResult(toolArgs, route) {
|
|
186
|
+
const { args, apifyToken, apifyClient, apifyMcpServer, mcpSessionId } = toolArgs;
|
|
187
|
+
const parsed = fetchActorDetailsToolArgsSchema.parse(args);
|
|
188
|
+
const actorName = fixActorNameInputAndLog(parsed.actor, { mcpSessionId, route });
|
|
189
|
+
const resolvedOutput = resolveOutputOptions(parsed.output);
|
|
190
|
+
// Skip the /users/me round-trip when pricing isn't rendered (e.g. inputSchema-only
|
|
191
|
+
// or mcpTools-only requests). In that case `userTier` is only used to fill the
|
|
192
|
+
// placeholder `{ model: 'FREE', userTier }` in the structured card, where it's never
|
|
193
|
+
// read, so defaulting to 'FREE' is safe and saves a request.
|
|
194
|
+
const userPlanTier = resolvedOutput.pricing
|
|
195
|
+
? (await getUserInfoCached(apifyToken, apifyClient)).userPlanTier
|
|
196
|
+
: 'FREE';
|
|
197
|
+
const cardOptions = { ...buildCardOptions(resolvedOutput), userTier: userPlanTier };
|
|
198
|
+
const details = await fetchActorDetails(apifyClient, actorName, cardOptions);
|
|
199
|
+
if (!details) {
|
|
200
|
+
return buildActorNotFoundResponse(actorName);
|
|
201
|
+
}
|
|
202
|
+
let actorOutputSchema;
|
|
203
|
+
if (resolvedOutput.outputSchema) {
|
|
204
|
+
actorOutputSchema = apifyMcpServer.actorStore
|
|
205
|
+
? await apifyMcpServer.actorStore.getActorOutputSchemaAsTypeObject(actorName).catch(() => null)
|
|
206
|
+
: null;
|
|
207
|
+
}
|
|
208
|
+
const mcpToolsMessage = resolvedOutput.mcpTools
|
|
209
|
+
? await getMcpToolsMessage(actorName, apifyClient, apifyToken, apifyMcpServer === null || apifyMcpServer === void 0 ? void 0 : apifyMcpServer.options.paymentProvider, mcpSessionId)
|
|
210
|
+
: undefined;
|
|
211
|
+
// NOTE: Data duplication between texts and structuredContent is intentional and required.
|
|
212
|
+
// Some MCP clients only read text content, while others only read structured content.
|
|
213
|
+
const { texts, structuredContent } = buildActorDetailsTextResponse({
|
|
214
|
+
details,
|
|
215
|
+
output: resolvedOutput,
|
|
216
|
+
actorOutputSchema,
|
|
217
|
+
mcpToolsMessage,
|
|
218
|
+
});
|
|
219
|
+
return buildMCPResponse({ texts, structuredContent });
|
|
220
|
+
}
|
|
55
221
|
//# sourceMappingURL=fetch_actor_details_common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details_common.js","sourceRoot":"","sources":["../../../src/tools/core/fetch_actor_details_common.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch_actor_details_common.js","sourceRoot":"","sources":["../../../src/tools/core/fetch_actor_details_common.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAEH,gBAAgB,EAChB,iBAAiB,EACjB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;KAClB,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ApifyClient } from '../../apify_client.js';
|
|
3
3
|
import type { HelperTool } from '../../types.js';
|
|
4
|
+
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
4
5
|
/**
|
|
5
6
|
* Zod schema for get-actor-run arguments — shared between default and openai variants.
|
|
6
7
|
*/
|
|
@@ -37,6 +38,16 @@ export type FetchActorRunResult = {
|
|
|
37
38
|
run: Record<string, unknown>;
|
|
38
39
|
structuredContent: ActorRunStructuredContent;
|
|
39
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Builds the standard tool error response for get-actor-run.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildGetActorRunError(runId: string, error: unknown): ReturnType<typeof buildMCPResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Builds the tool success response for get-actor-run in default or widget mode.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildGetActorRunSuccessResponse(params: FetchActorRunResult & {
|
|
49
|
+
widget: boolean;
|
|
50
|
+
}): ReturnType<typeof buildMCPResponse>;
|
|
40
51
|
/**
|
|
41
52
|
* Fetches actor run data, resolves actor name, and fetches dataset results if completed.
|
|
42
53
|
* Shared data-fetching logic used by both default and openai variants.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_actor_run_common.d.ts","sourceRoot":"","sources":["../../../src/tools/core/get_actor_run_common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_actor_run_common.d.ts","sourceRoot":"","sources":["../../../src/tools/core/get_actor_run_common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK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IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC,CA0D/D"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import dedent from 'dedent';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import log from '@apify/log';
|
|
4
5
|
import { FAILURE_CATEGORY, HelperTools, TOOL_STATUS } from '../../const.js';
|
|
5
6
|
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
6
7
|
import { compileSchema } from '../../utils/ajv.js';
|
|
7
|
-
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
8
|
+
import { buildMCPResponse, buildUsageMeta } from '../../utils/mcp.js';
|
|
8
9
|
import { generateSchemaFromItems } from '../../utils/schema_generation.js';
|
|
9
10
|
import { getActorRunOutputSchema } from '../structured_output_schemas.js';
|
|
10
11
|
/**
|
|
@@ -52,6 +53,44 @@ export const getActorRunMetadata = {
|
|
|
52
53
|
openWorldHint: false,
|
|
53
54
|
},
|
|
54
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Builds the standard tool error response for get-actor-run.
|
|
58
|
+
*/
|
|
59
|
+
export function buildGetActorRunError(runId, error) {
|
|
60
|
+
return buildMCPResponse({
|
|
61
|
+
texts: [dedent `
|
|
62
|
+
Failed to get Actor run '${runId}': ${error instanceof Error ? error.message : String(error)}.
|
|
63
|
+
Please verify the run ID and ensure that the run exists.
|
|
64
|
+
`],
|
|
65
|
+
isError: true,
|
|
66
|
+
telemetry: { toolStatus: TOOL_STATUS.SOFT_FAIL },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Builds the tool success response for get-actor-run in default or widget mode.
|
|
71
|
+
*/
|
|
72
|
+
export function buildGetActorRunSuccessResponse(params) {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
const { run, structuredContent, widget } = params;
|
|
75
|
+
if (!widget) {
|
|
76
|
+
return buildMCPResponse({
|
|
77
|
+
texts: [`# Actor Run Information\n\`\`\`json\n${JSON.stringify(run)}\n\`\`\``],
|
|
78
|
+
structuredContent,
|
|
79
|
+
_meta: buildUsageMeta(run),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const statusText = structuredContent.status === 'SUCCEEDED' && structuredContent.dataset
|
|
83
|
+
? `Actor run ${structuredContent.runId} completed successfully with ${structuredContent.dataset.totalItemCount} items. A widget has been rendered with the details.`
|
|
84
|
+
: `Actor run ${structuredContent.runId} status: ${structuredContent.status}. A progress widget has been rendered.`;
|
|
85
|
+
return buildMCPResponse({
|
|
86
|
+
texts: [statusText],
|
|
87
|
+
structuredContent,
|
|
88
|
+
_meta: {
|
|
89
|
+
...((_b = (_a = getWidgetConfig(WIDGET_URIS.ACTOR_RUN)) === null || _a === void 0 ? void 0 : _a.meta) !== null && _b !== void 0 ? _b : {}),
|
|
90
|
+
...((_c = buildUsageMeta(run)) !== null && _c !== void 0 ? _c : {}),
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
55
94
|
/**
|
|
56
95
|
* Fetches actor run data, resolves actor name, and fetches dataset results if completed.
|
|
57
96
|
* Shared data-fetching logic used by both default and openai variants.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_actor_run_common.js","sourceRoot":"","sources":["../../../src/tools/core/get_actor_run_common.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,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AE,CAAC;AAC7F,CAAC"}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ActorStoreList, HelperTool, StructuredActorCard } from '../../types.js';
|
|
3
3
|
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
4
|
+
import type { PricingTier } from '../../utils/pricing_info.js';
|
|
5
|
+
/**
|
|
6
|
+
* Shared base schema for search-actors arguments. Used directly by the internal
|
|
7
|
+
* variant; extended by `searchActorsArgsSchema` with a longer `keywords` description.
|
|
8
|
+
*/
|
|
9
|
+
export declare const searchActorsBaseArgsSchema: z.ZodObject<{
|
|
10
|
+
keywords: z.ZodDefault<z.ZodString>;
|
|
11
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>;
|
|
4
14
|
/**
|
|
5
15
|
* Zod schema for search-actors arguments — shared between default and openai variants.
|
|
6
16
|
*/
|
|
7
17
|
export declare const searchActorsArgsSchema: z.ZodObject<{
|
|
8
|
-
keywords: z.ZodDefault<z.ZodString>;
|
|
9
18
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
10
19
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
keywords: z.ZodDefault<z.ZodString>;
|
|
11
21
|
}, z.core.$strip>;
|
|
12
22
|
/**
|
|
13
23
|
* Shared tool metadata for search-actors — everything except the `call` handler.
|
|
@@ -18,6 +28,6 @@ export type SearchActorsResult = {
|
|
|
18
28
|
actorCardText: string;
|
|
19
29
|
actorCardStructured: StructuredActorCard[];
|
|
20
30
|
};
|
|
21
|
-
export declare function buildSearchActorsResult(actors: ActorStoreList[]): SearchActorsResult;
|
|
31
|
+
export declare function buildSearchActorsResult(actors: ActorStoreList[], userTier: PricingTier): SearchActorsResult;
|
|
22
32
|
export declare function buildSearchActorsEmptyResponse(query: string): ReturnType<typeof buildMCPResponse>;
|
|
23
33
|
//# sourceMappingURL=search_actors_common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search_actors_common.d.ts","sourceRoot":"","sources":["../../../src/tools/core/search_actors_common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,mBAAmB,EAAmB,MAAM,gBAAgB,CAAC;AAGvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"search_actors_common.d.ts","sourceRoot":"","sources":["../../../src/tools/core/search_actors_common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,mBAAmB,EAAmB,MAAM,gBAAgB,CAAC;AAGvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;iBAerC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;iBAoBjC,CAAC;AAwCH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAgBzD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,mBAAmB,EAAE,CAAC;CAC9C,CAAC;AAEF,wBAAgB,uBAAuB,CACnC,MAAM,EAAE,cAAc,EAAE,EACxB,QAAQ,EAAE,WAAW,GACtB,kBAAkB,CAMpB;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAQjG"}
|
|
@@ -3,14 +3,34 @@ import dedent from 'dedent';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { HelperTools } from '../../const.js';
|
|
5
5
|
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
6
|
-
import { formatActorToActorCard, formatActorToStructuredCard } from '../../utils/actor_card.js';
|
|
6
|
+
import { DEFAULT_CARD_OPTIONS, formatActorToActorCard, formatActorToStructuredCard } from '../../utils/actor_card.js';
|
|
7
7
|
import { compileSchema } from '../../utils/ajv.js';
|
|
8
8
|
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
9
9
|
import { actorSearchOutputSchema } from '../structured_output_schemas.js';
|
|
10
|
+
/**
|
|
11
|
+
* Shared base schema for search-actors arguments. Used directly by the internal
|
|
12
|
+
* variant; extended by `searchActorsArgsSchema` with a longer `keywords` description.
|
|
13
|
+
*/
|
|
14
|
+
export const searchActorsBaseArgsSchema = z.object({
|
|
15
|
+
keywords: z.string()
|
|
16
|
+
.default('')
|
|
17
|
+
.describe('Keywords used to search for Actors in the Apify Store.'),
|
|
18
|
+
limit: z.number()
|
|
19
|
+
.int()
|
|
20
|
+
.min(1)
|
|
21
|
+
.max(100)
|
|
22
|
+
.default(5)
|
|
23
|
+
.describe('The maximum number of Actors to return (default = 5)'),
|
|
24
|
+
offset: z.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(0)
|
|
27
|
+
.default(0)
|
|
28
|
+
.describe('The number of elements to skip from the start (default = 0)'),
|
|
29
|
+
});
|
|
10
30
|
/**
|
|
11
31
|
* Zod schema for search-actors arguments — shared between default and openai variants.
|
|
12
32
|
*/
|
|
13
|
-
export const searchActorsArgsSchema =
|
|
33
|
+
export const searchActorsArgsSchema = searchActorsBaseArgsSchema.extend({
|
|
14
34
|
keywords: z.string()
|
|
15
35
|
.default('')
|
|
16
36
|
.describe(dedent `
|
|
@@ -30,17 +50,6 @@ export const searchActorsArgsSchema = z.object({
|
|
|
30
50
|
❌ Bad: "Instagram posts profiles comments hashtags reels stories followers..." (too long, too many terms)
|
|
31
51
|
❌ Bad: "data extraction scraping tools" (too generic)
|
|
32
52
|
`),
|
|
33
|
-
limit: z.number()
|
|
34
|
-
.int()
|
|
35
|
-
.min(1)
|
|
36
|
-
.max(100)
|
|
37
|
-
.default(5)
|
|
38
|
-
.describe('The maximum number of Actors to return (default = 5)'),
|
|
39
|
-
offset: z.number()
|
|
40
|
-
.int()
|
|
41
|
-
.min(0)
|
|
42
|
-
.default(0)
|
|
43
|
-
.describe('The number of elements to skip from the start (default = 0)'),
|
|
44
53
|
});
|
|
45
54
|
const SEARCH_ACTORS_DESCRIPTION = `
|
|
46
55
|
Search the Apify Store to FIND and DISCOVER what scraping tools/Actors exist for specific platforms or use cases.
|
|
@@ -100,10 +109,11 @@ export const searchActorsMetadata = {
|
|
|
100
109
|
openWorldHint: false,
|
|
101
110
|
},
|
|
102
111
|
};
|
|
103
|
-
export function buildSearchActorsResult(actors) {
|
|
112
|
+
export function buildSearchActorsResult(actors, userTier) {
|
|
113
|
+
const options = { ...DEFAULT_CARD_OPTIONS, userTier, simplifyPricingForUserTier: true };
|
|
104
114
|
return {
|
|
105
|
-
actorCardText: actors.map((actor) => formatActorToActorCard(actor)).join('\n\n'),
|
|
106
|
-
actorCardStructured: actors.map((actor) => formatActorToStructuredCard(actor)),
|
|
115
|
+
actorCardText: actors.map((actor) => formatActorToActorCard(actor, options)).join('\n\n'),
|
|
116
|
+
actorCardStructured: actors.map((actor) => formatActorToStructuredCard(actor, options)),
|
|
107
117
|
};
|
|
108
118
|
}
|
|
109
119
|
export function buildSearchActorsEmptyResponse(query) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search_actors_common.js","sourceRoot":"","sources":["../../../src/tools/core/search_actors_common.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MA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B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC1F,CAAC;AACN,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,KAAa;IACxD,MAAM,YAAY,GAAG,MAAM,CAAA;qDACsB,KAAK;;;KAGrD,CAAC;IAEF,OAAO,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;AACzH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call_actor.d.ts","sourceRoot":"","sources":["../../../src/tools/default/call_actor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"call_actor.d.ts","sourceRoot":"","sources":["../../../src/tools/default/call_actor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAuBlE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAsGpB,CAAC"}
|
|
@@ -2,32 +2,18 @@ var _a;
|
|
|
2
2
|
import log from '@apify/log';
|
|
3
3
|
import { HelperTools } from '../../const.js';
|
|
4
4
|
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
5
|
-
import {
|
|
6
|
-
import { buildMCPResponse, buildUsageMeta } from '../../utils/mcp.js';
|
|
7
|
-
import { classifyFailureCategory, getToolStatusFromError } from '../../utils/tool_status.js';
|
|
5
|
+
import { buildUsageMeta } from '../../utils/mcp.js';
|
|
8
6
|
import { extractActorId } from '../../utils/tools.js';
|
|
9
7
|
import { callActorGetDataset } from '../core/actor_execution.js';
|
|
10
8
|
import { buildActorResponseContent } from '../core/actor_response.js';
|
|
11
|
-
import {
|
|
9
|
+
import { buildCallActorDescription, buildCallActorErrorResponse, buildStartAsyncResponse, callActorAjvValidate, callActorInputSchema, callActorPreExecute, resolveAndValidateActor, } from '../core/call_actor_common.js';
|
|
12
10
|
import { callActorOutputSchema } from '../structured_output_schemas.js';
|
|
13
|
-
const CALL_ACTOR_DEFAULT_DESCRIPTION =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
If the actor name is not in "username/name" format, use ${HelperTools.STORE_SEARCH} to resolve the correct Actor first.`,
|
|
20
|
-
CALL_ACTOR_MCP_SERVER_SECTION,
|
|
21
|
-
`IMPORTANT:
|
|
22
|
-
- Typically returns a datasetId and preview of output items
|
|
23
|
-
- Use ${HelperTools.ACTOR_OUTPUT_GET} tool with the datasetId to fetch full results
|
|
24
|
-
- Use dedicated Actor tools when available for better experience`,
|
|
25
|
-
CALL_ACTOR_USAGE_SECTION,
|
|
26
|
-
`- This tool supports async execution via the \`async\` parameter:
|
|
27
|
-
- **When \`async: false\` or not provided** (default): Waits for completion and returns results immediately with dataset preview. Use this whenever the user asks for data or results.
|
|
28
|
-
- **When \`async: true\`**: Starts the run and returns immediately with runId. Only use this when the user explicitly asks to run the Actor in the background or does not need immediate results.`,
|
|
29
|
-
CALL_ACTOR_EXAMPLES_SECTION,
|
|
30
|
-
].join('\n\n');
|
|
11
|
+
const CALL_ACTOR_DEFAULT_DESCRIPTION = buildCallActorDescription({
|
|
12
|
+
actorGetDetailsTool: HelperTools.ACTOR_GET_DETAILS,
|
|
13
|
+
storeSearchTool: HelperTools.STORE_SEARCH,
|
|
14
|
+
useInternalSearchWarning: false,
|
|
15
|
+
alwaysAsync: false,
|
|
16
|
+
});
|
|
31
17
|
/**
|
|
32
18
|
* Default mode call-actor tool.
|
|
33
19
|
* Supports both sync (default) and async execution.
|
|
@@ -57,7 +43,6 @@ export const defaultCallActor = Object.freeze({
|
|
|
57
43
|
taskSupport: 'optional',
|
|
58
44
|
},
|
|
59
45
|
call: async (toolArgs) => {
|
|
60
|
-
var _a;
|
|
61
46
|
const preResult = await callActorPreExecute(toolArgs);
|
|
62
47
|
if ('earlyResponse' in preResult) {
|
|
63
48
|
return preResult.earlyResponse;
|
|
@@ -81,19 +66,14 @@ export const defaultCallActor = Object.freeze({
|
|
|
81
66
|
const actorClient = apifyClient.actor(baseActorName);
|
|
82
67
|
const actorRun = await actorClient.start(input, callOptions);
|
|
83
68
|
log.debug('Started Actor run (async)', { actorName: baseActorName, runId: actorRun.id, mcpSessionId: toolArgs.mcpSessionId });
|
|
84
|
-
const
|
|
85
|
-
runId: actorRun.id,
|
|
69
|
+
const response = buildStartAsyncResponse({
|
|
86
70
|
actorName: baseActorName,
|
|
87
|
-
|
|
88
|
-
startedAt: ((_a = actorRun.startedAt) === null || _a === void 0 ? void 0 : _a.toISOString()) || '',
|
|
71
|
+
actorRun,
|
|
89
72
|
input,
|
|
90
|
-
|
|
73
|
+
widget: false,
|
|
74
|
+
});
|
|
91
75
|
return {
|
|
92
|
-
|
|
93
|
-
type: 'text',
|
|
94
|
-
text: `Started Actor "${baseActorName}" (Run ID: ${actorRun.id}).`,
|
|
95
|
-
}],
|
|
96
|
-
structuredContent,
|
|
76
|
+
...response,
|
|
97
77
|
toolTelemetry: { actorId: resolvedActorId },
|
|
98
78
|
};
|
|
99
79
|
}
|
|
@@ -123,25 +103,14 @@ export const defaultCallActor = Object.freeze({
|
|
|
123
103
|
};
|
|
124
104
|
}
|
|
125
105
|
catch (error) {
|
|
126
|
-
|
|
127
|
-
logHttpError(error, 'Failed to call Actor', {
|
|
106
|
+
return buildCallActorErrorResponse({
|
|
128
107
|
actorName: baseActorName,
|
|
129
|
-
|
|
108
|
+
error,
|
|
109
|
+
actorId: resolvedActorId,
|
|
110
|
+
isAsync,
|
|
130
111
|
mcpSessionId: toolArgs.mcpSessionId,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return buildMCPResponse({
|
|
134
|
-
texts: [`Failed to call Actor '${baseActorName}': ${errMsg}.
|
|
135
|
-
Please verify the Actor name, input parameters, and ensure the Actor exists.
|
|
136
|
-
You can search for available Actors using the tool: ${HelperTools.STORE_SEARCH}, or get Actor details using: ${HelperTools.ACTOR_GET_DETAILS}.`],
|
|
137
|
-
isError: true,
|
|
138
|
-
telemetry: {
|
|
139
|
-
toolStatus: getToolStatusFromError(error, false),
|
|
140
|
-
failureCategory: classifyFailureCategory(error),
|
|
141
|
-
failureHttpStatus: getHttpStatusCode(error),
|
|
142
|
-
failureDetail: errMsg.slice(0, 200),
|
|
143
|
-
actorId: resolvedActorId,
|
|
144
|
-
},
|
|
112
|
+
actorGetDetailsTool: HelperTools.ACTOR_GET_DETAILS,
|
|
113
|
+
storeSearchTool: HelperTools.STORE_SEARCH,
|
|
145
114
|
});
|
|
146
115
|
}
|
|
147
116
|
},
|