@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,36 +1,29 @@
|
|
|
1
|
+
import dedent from 'dedent';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
import { ApifyClient } from '../../apify_client.js';
|
|
3
3
|
import { HelperTools } from '../../const.js';
|
|
4
|
-
import { actorDetailsOutputOptionsSchema, buildActorDetailsTextResponse, buildActorNotFoundResponse, buildCardOptions, fetchActorDetails, resolveOutputOptions, } from '../../utils/actor_details.js';
|
|
5
4
|
import { compileSchema } from '../../utils/ajv.js';
|
|
6
|
-
import {
|
|
7
|
-
import { fixActorNameInputAndLog } from '../core/actor_tools_factory.js';
|
|
5
|
+
import { buildFetchActorDetailsResult, fetchActorDetailsToolArgsSchema, } from '../core/fetch_actor_details_common.js';
|
|
8
6
|
import { actorDetailsOutputSchema } from '../structured_output_schemas.js';
|
|
9
|
-
const fetchActorDetailsInternalArgsSchema = z.object({
|
|
10
|
-
actor: z.string()
|
|
11
|
-
.min(1)
|
|
12
|
-
.describe(`Actor ID or full name in the format "username/name", e.g., "apify/rag-web-browser".`),
|
|
13
|
-
output: actorDetailsOutputOptionsSchema.optional()
|
|
14
|
-
.describe('Specify which information to include in the response to save tokens.'),
|
|
15
|
-
});
|
|
16
7
|
export const fetchActorDetailsInternalTool = Object.freeze({
|
|
17
8
|
type: 'internal',
|
|
18
9
|
name: HelperTools.ACTOR_GET_DETAILS_INTERNAL,
|
|
19
|
-
description: `
|
|
10
|
+
description: dedent `
|
|
11
|
+
Fetch Actor details with flexible output options (UI mode internal tool).
|
|
20
12
|
|
|
21
|
-
This tool is available because the LLM is operating in UI mode. Use it for internal lookups
|
|
22
|
-
where data presentation to the user is NOT needed - this tool does NOT render a widget.
|
|
13
|
+
This tool is available because the LLM is operating in UI mode. Use it for internal lookups
|
|
14
|
+
where data presentation to the user is NOT needed - this tool does NOT render a widget.
|
|
23
15
|
|
|
24
|
-
Use 'output' parameter with boolean flags to control returned information:
|
|
25
|
-
- Default: Fields: description, stats, pricing, rating, metadata, inputSchema, readme - except mcpTools
|
|
26
|
-
- Selective: Set desired fields to true to save tokens (e.g., output: { inputSchema: true, readme: false })
|
|
27
|
-
- Common patterns: inputSchema only for execution prep, readme + inputSchema for documentation, etc.
|
|
16
|
+
Use 'output' parameter with boolean flags to control returned information:
|
|
17
|
+
- Default: Fields: description, stats, pricing, rating, metadata, inputSchema, readme - except mcpTools
|
|
18
|
+
- Selective: Set desired fields to true to save tokens (e.g., output: { inputSchema: true, readme: false })
|
|
19
|
+
- Common patterns: inputSchema only for execution prep, readme + inputSchema for documentation, etc.
|
|
28
20
|
|
|
29
|
-
Use this instead of fetch-actor-details when you need Actor information to prepare execution
|
|
30
|
-
but the user did NOT explicitly ask for Actor details presentation
|
|
31
|
-
|
|
21
|
+
Use this instead of fetch-actor-details when you need Actor information to prepare execution
|
|
22
|
+
but the user did NOT explicitly ask for Actor details presentation.
|
|
23
|
+
`,
|
|
24
|
+
inputSchema: z.toJSONSchema(fetchActorDetailsToolArgsSchema),
|
|
32
25
|
outputSchema: actorDetailsOutputSchema,
|
|
33
|
-
ajvValidate: compileSchema(z.toJSONSchema(
|
|
26
|
+
ajvValidate: compileSchema(z.toJSONSchema(fetchActorDetailsToolArgsSchema)),
|
|
34
27
|
annotations: {
|
|
35
28
|
title: 'Fetch Actor details internal',
|
|
36
29
|
readOnlyHint: true,
|
|
@@ -38,34 +31,6 @@ but the user did NOT explicitly ask for Actor details presentation.`,
|
|
|
38
31
|
idempotentHint: true,
|
|
39
32
|
openWorldHint: false,
|
|
40
33
|
},
|
|
41
|
-
call: async (toolArgs) =>
|
|
42
|
-
var _a;
|
|
43
|
-
const { args, apifyToken, apifyMcpServer, mcpSessionId } = toolArgs;
|
|
44
|
-
const parsed = fetchActorDetailsInternalArgsSchema.parse(args);
|
|
45
|
-
const actorName = fixActorNameInputAndLog(parsed.actor, { mcpSessionId, route: 'fetch-actor-details-internal' });
|
|
46
|
-
const apifyClient = new ApifyClient({ token: apifyToken });
|
|
47
|
-
const resolvedOutput = resolveOutputOptions(parsed.output);
|
|
48
|
-
const cardOptions = buildCardOptions(resolvedOutput);
|
|
49
|
-
const details = await fetchActorDetails(apifyClient, actorName, cardOptions);
|
|
50
|
-
if (!details) {
|
|
51
|
-
return buildActorNotFoundResponse(actorName);
|
|
52
|
-
}
|
|
53
|
-
// Fetch output schema from ActorStore if available and requested
|
|
54
|
-
const actorOutputSchema = resolvedOutput.outputSchema
|
|
55
|
-
? await ((_a = apifyMcpServer.actorStore) === null || _a === void 0 ? void 0 : _a.getActorOutputSchemaAsTypeObject(actorName).catch(() => null))
|
|
56
|
-
: undefined;
|
|
57
|
-
const { texts, structuredContent } = await buildActorDetailsTextResponse({
|
|
58
|
-
actorName,
|
|
59
|
-
details,
|
|
60
|
-
output: resolvedOutput,
|
|
61
|
-
cardOptions,
|
|
62
|
-
apifyClient,
|
|
63
|
-
apifyToken,
|
|
64
|
-
actorOutputSchema,
|
|
65
|
-
paymentProvider: apifyMcpServer === null || apifyMcpServer === void 0 ? void 0 : apifyMcpServer.options.paymentProvider,
|
|
66
|
-
mcpSessionId,
|
|
67
|
-
});
|
|
68
|
-
return buildMCPResponse({ texts, structuredContent });
|
|
69
|
-
},
|
|
34
|
+
call: async (toolArgs) => buildFetchActorDetailsResult(toolArgs, HelperTools.ACTOR_GET_DETAILS_INTERNAL),
|
|
70
35
|
});
|
|
71
36
|
//# sourceMappingURL=fetch_actor_details_internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details_internal.js","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details_internal.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"fetch_actor_details_internal.js","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details_internal.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;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACH,4BAA4B,EAC5B,+BAA+B,GAClC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,CAAC,MAAM,6BAA6B,GAAc,MAAM,CAAC,MAAM,CAAC;IAClE,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,WAAW,CAAC,0BAA0B;IAC5C,WAAW,EAAE,MAAM,CAAA;;;;;;;;;;;;;KAalB;IACD,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,+BAA+B,CAAoB;IAC/E,YAAY,EAAE,wBAAwB;IACtC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,+BAA+B,CAAC,CAAC;IAC3E,WAAW,EAAE;QACT,KAAK,EAAE,8BAA8B;QACrC,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB;IACD,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,4BAA4B,CAAC,QAAQ,EAAE,WAAW,CAAC,0BAA0B,CAAC;CAClG,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_actor_run.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/get_actor_run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_actor_run.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/get_actor_run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUlE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAuBrB,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { TOOL_STATUS } from '../../const.js';
|
|
2
|
-
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
3
1
|
import { logHttpError } from '../../utils/logging.js';
|
|
4
|
-
import {
|
|
5
|
-
import { fetchActorRunData, getActorRunArgs, getActorRunMetadata, } from '../core/get_actor_run_common.js';
|
|
2
|
+
import { buildGetActorRunError, buildGetActorRunSuccessResponse, fetchActorRunData, getActorRunArgs, getActorRunMetadata, } from '../core/get_actor_run_common.js';
|
|
6
3
|
/**
|
|
7
4
|
* OpenAI mode get-actor-run tool.
|
|
8
5
|
* Returns abbreviated text with widget metadata for interactive progress display.
|
|
@@ -21,30 +18,11 @@ export const openaiGetActorRun = Object.freeze({
|
|
|
21
18
|
if ('error' in fetchResult) {
|
|
22
19
|
return fetchResult.error;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
const statusText = run.status === 'SUCCEEDED' && structuredContent.dataset
|
|
26
|
-
? `Actor run ${parsed.runId} completed successfully with ${structuredContent.dataset.totalItemCount} items. A widget has been rendered with the details.`
|
|
27
|
-
: `Actor run ${parsed.runId} status: ${run.status}. A progress widget has been rendered.`;
|
|
28
|
-
const widgetConfig = getWidgetConfig(WIDGET_URIS.ACTOR_RUN);
|
|
29
|
-
const usageMeta = buildUsageMeta(run);
|
|
30
|
-
return buildMCPResponse({
|
|
31
|
-
texts: [statusText],
|
|
32
|
-
structuredContent,
|
|
33
|
-
// Response-level meta; only returned in openai mode (this handler is openai-only)
|
|
34
|
-
_meta: {
|
|
35
|
-
...widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.meta,
|
|
36
|
-
...usageMeta,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
21
|
+
return buildGetActorRunSuccessResponse({ ...fetchResult.result, widget: true });
|
|
39
22
|
}
|
|
40
23
|
catch (error) {
|
|
41
24
|
logHttpError(error, 'Failed to get Actor run', { runId: parsed.runId });
|
|
42
|
-
return
|
|
43
|
-
texts: [`Failed to get Actor run '${parsed.runId}': ${error instanceof Error ? error.message : String(error)}.
|
|
44
|
-
Please verify the run ID and ensure that the run exists.`],
|
|
45
|
-
isError: true,
|
|
46
|
-
telemetry: { toolStatus: TOOL_STATUS.SOFT_FAIL },
|
|
47
|
-
});
|
|
25
|
+
return buildGetActorRunError(parsed.runId, error);
|
|
48
26
|
}
|
|
49
27
|
},
|
|
50
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_actor_run.js","sourceRoot":"","sources":["../../../src/tools/openai/get_actor_run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_actor_run.js","sourceRoot":"","sources":["../../../src/tools/openai/get_actor_run.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACH,qBAAqB,EACrB,+BAA+B,EAC/B,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACtB,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAc,MAAM,CAAC,MAAM,CAAC;IACtD,GAAG,mBAAmB;IACtB,IAAI,EAAE,KAAK,EAAE,QAA0B,EAAE,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;QAC7D,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE3C,IAAI,CAAC;YACD,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC;gBACxC,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,MAAM;gBACN,YAAY;aACf,CAAC,CAAC;YAEH,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;gBACzB,OAAO,WAAW,CAAC,KAAK,CAAC;YAC7B,CAAC;YAED,OAAO,+BAA+B,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,YAAY,CAAC,KAAK,EAAE,yBAAyB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACxE,OAAO,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;CACK,CAAC,CAAC"}
|