@apify/actors-mcp-server 0.9.20-beta.1 → 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 +56 -4
- package/dist/tools/structured_output_schemas.d.ts.map +1 -1
- package/dist/tools/structured_output_schemas.js +27 -4
- package/dist/tools/structured_output_schemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +8 -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 +19 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call_actor.js","sourceRoot":"","sources":["../../../src/tools/default/call_actor.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"call_actor.js","sourceRoot":"","sources":["../../../src/tools/default/call_actor.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACH,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,8BAA8B,GAA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EAAE,CAAC;YACd,CAAC;YAED,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,yBAAyB,CAAC,aAAa,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;YAC3G,MAAM,KAAK,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;YACzC,OAAO;gBACH,OAAO;gBACP,iBAAiB;gBACjB,GAAG,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC;gBACvB,aAAa,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE;aAC9C,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,2BAA2B,CAAC;gBAC/B,SAAS,EAAE,aAAa;gBACxB,KAAK;gBACL,OAAO,EAAE,eAAe;gBACxB,OAAO;gBACP,YAAY,EAAE,QAAQ,CAAC,YAAY;gBACnC,mBAAmB,EAAE,WAAW,CAAC,iBAAiB;gBAClD,eAAe,EAAE,WAAW,CAAC,YAAY;aAC5C,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details.d.ts","sourceRoot":"","sources":["../../../src/tools/default/fetch_actor_details.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fetch_actor_details.d.ts","sourceRoot":"","sources":["../../../src/tools/default/fetch_actor_details.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAG5B,CAAC"}
|
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
4
|
-
import { fixActorNameInputAndLog } from '../core/actor_tools_factory.js';
|
|
5
|
-
import { fetchActorDetailsMetadata, fetchActorDetailsToolArgsSchema, } from '../core/fetch_actor_details_common.js';
|
|
1
|
+
import { HelperTools } from '../../const.js';
|
|
2
|
+
import { buildFetchActorDetailsResult, fetchActorDetailsMetadata, } from '../core/fetch_actor_details_common.js';
|
|
6
3
|
/**
|
|
7
4
|
* Default mode fetch-actor-details tool.
|
|
8
5
|
* Returns full text response with output schema fetch.
|
|
9
6
|
*/
|
|
10
7
|
export const defaultFetchActorDetails = Object.freeze({
|
|
11
8
|
...fetchActorDetailsMetadata,
|
|
12
|
-
call: async (toolArgs) =>
|
|
13
|
-
var _a;
|
|
14
|
-
const { args, apifyToken, apifyMcpServer, mcpSessionId } = toolArgs;
|
|
15
|
-
const parsedArgs = fetchActorDetailsToolArgsSchema.parse(args);
|
|
16
|
-
const actorName = fixActorNameInputAndLog(parsedArgs.actor, { mcpSessionId, route: 'fetch-actor-details' });
|
|
17
|
-
const apifyClient = new ApifyClient({ token: apifyToken });
|
|
18
|
-
const resolvedOutput = resolveOutputOptions(parsedArgs.output);
|
|
19
|
-
const cardOptions = buildCardOptions(resolvedOutput);
|
|
20
|
-
const details = await fetchActorDetails(apifyClient, actorName, cardOptions);
|
|
21
|
-
if (!details) {
|
|
22
|
-
return buildActorNotFoundResponse(actorName);
|
|
23
|
-
}
|
|
24
|
-
// Fetch output schema from ActorStore if available and requested
|
|
25
|
-
const actorOutputSchema = resolvedOutput.outputSchema
|
|
26
|
-
? await ((_a = apifyMcpServer.actorStore) === null || _a === void 0 ? void 0 : _a.getActorOutputSchemaAsTypeObject(actorName).catch(() => null))
|
|
27
|
-
: undefined;
|
|
28
|
-
// NOTE: Data duplication between texts and structuredContent is intentional and required.
|
|
29
|
-
// Some MCP clients only read text content, while others only read structured content.
|
|
30
|
-
const { texts, structuredContent: responseStructuredContent } = await buildActorDetailsTextResponse({
|
|
31
|
-
actorName,
|
|
32
|
-
details,
|
|
33
|
-
output: resolvedOutput,
|
|
34
|
-
cardOptions,
|
|
35
|
-
apifyClient,
|
|
36
|
-
apifyToken,
|
|
37
|
-
actorOutputSchema,
|
|
38
|
-
paymentProvider: apifyMcpServer === null || apifyMcpServer === void 0 ? void 0 : apifyMcpServer.options.paymentProvider,
|
|
39
|
-
mcpSessionId,
|
|
40
|
-
});
|
|
41
|
-
return buildMCPResponse({ texts, structuredContent: responseStructuredContent });
|
|
42
|
-
},
|
|
9
|
+
call: async (toolArgs) => buildFetchActorDetailsResult(toolArgs, HelperTools.ACTOR_GET_DETAILS),
|
|
43
10
|
});
|
|
44
11
|
//# sourceMappingURL=fetch_actor_details.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details.js","sourceRoot":"","sources":["../../../src/tools/default/fetch_actor_details.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fetch_actor_details.js","sourceRoot":"","sources":["../../../src/tools/default/fetch_actor_details.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACH,4BAA4B,EAC5B,yBAAyB,GAC5B,MAAM,uCAAuC,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAc,MAAM,CAAC,MAAM,CAAC;IAC7D,GAAG,yBAAyB;IAC5B,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,4BAA4B,CAAC,QAAQ,EAAE,WAAW,CAAC,iBAAiB,CAAC;CACzF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_actor_run.d.ts","sourceRoot":"","sources":["../../../src/tools/default/get_actor_run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_actor_run.d.ts","sourceRoot":"","sources":["../../../src/tools/default/get_actor_run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUlE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAuBtB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { TOOL_STATUS } from '../../const.js';
|
|
2
1
|
import { logHttpError } from '../../utils/logging.js';
|
|
3
|
-
import {
|
|
4
|
-
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';
|
|
5
3
|
/**
|
|
6
4
|
* Default mode get-actor-run tool.
|
|
7
5
|
* Returns full JSON dump of the run without widget metadata.
|
|
@@ -20,22 +18,11 @@ export const defaultGetActorRun = Object.freeze({
|
|
|
20
18
|
if ('error' in fetchResult) {
|
|
21
19
|
return fetchResult.error;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
const texts = [`# Actor Run Information\n\`\`\`json\n${JSON.stringify(run)}\n\`\`\``];
|
|
25
|
-
return buildMCPResponse({
|
|
26
|
-
texts,
|
|
27
|
-
structuredContent,
|
|
28
|
-
_meta: buildUsageMeta(run),
|
|
29
|
-
});
|
|
21
|
+
return buildGetActorRunSuccessResponse({ ...fetchResult.result, widget: false });
|
|
30
22
|
}
|
|
31
23
|
catch (error) {
|
|
32
24
|
logHttpError(error, 'Failed to get Actor run', { runId: parsed.runId });
|
|
33
|
-
return
|
|
34
|
-
texts: [`Failed to get Actor run '${parsed.runId}': ${error instanceof Error ? error.message : String(error)}.
|
|
35
|
-
Please verify the run ID and ensure that the run exists.`],
|
|
36
|
-
isError: true,
|
|
37
|
-
telemetry: { toolStatus: TOOL_STATUS.SOFT_FAIL },
|
|
38
|
-
});
|
|
25
|
+
return buildGetActorRunError(parsed.runId, error);
|
|
39
26
|
}
|
|
40
27
|
},
|
|
41
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_actor_run.js","sourceRoot":"","sources":["../../../src/tools/default/get_actor_run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_actor_run.js","sourceRoot":"","sources":["../../../src/tools/default/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,kBAAkB,GAAc,MAAM,CAAC,MAAM,CAAC;IACvD,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,KAAK,EAAE,CAAC,CAAC;QACrF,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search_actors.d.ts","sourceRoot":"","sources":["../../../src/tools/default/search_actors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"search_actors.d.ts","sourceRoot":"","sources":["../../../src/tools/default/search_actors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAWlE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAwDvB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import dedent from 'dedent';
|
|
|
2
2
|
import { HelperTools } from '../../const.js';
|
|
3
3
|
import { searchAndFilterActors } from '../../utils/actor_search.js';
|
|
4
4
|
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
5
|
+
import { getUserInfoCached } from '../../utils/userid_cache.js';
|
|
5
6
|
import { buildSearchActorsEmptyResponse, buildSearchActorsResult, searchActorsArgsSchema, searchActorsMetadata, } from '../core/search_actors_common.js';
|
|
6
7
|
/**
|
|
7
8
|
* Default mode search-actors tool.
|
|
@@ -10,20 +11,25 @@ import { buildSearchActorsEmptyResponse, buildSearchActorsResult, searchActorsAr
|
|
|
10
11
|
export const defaultSearchActors = Object.freeze({
|
|
11
12
|
...searchActorsMetadata,
|
|
12
13
|
call: async (toolArgs) => {
|
|
13
|
-
const { args, apifyToken, userRentedActorIds, apifyMcpServer } = toolArgs;
|
|
14
|
+
const { args, apifyToken, apifyClient, userRentedActorIds, apifyMcpServer } = toolArgs;
|
|
14
15
|
const parsed = searchActorsArgsSchema.parse(args);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
// Actor search and user-info fetch are independent; run in parallel to avoid a
|
|
17
|
+
// sequential round-trip on cache miss.
|
|
18
|
+
const [actors, { userPlanTier }] = await Promise.all([
|
|
19
|
+
searchAndFilterActors({
|
|
20
|
+
keywords: parsed.keywords,
|
|
21
|
+
apifyToken,
|
|
22
|
+
limit: parsed.limit,
|
|
23
|
+
offset: parsed.offset,
|
|
24
|
+
paymentProvider: apifyMcpServer.options.paymentProvider,
|
|
25
|
+
userRentedActorIds,
|
|
26
|
+
}),
|
|
27
|
+
getUserInfoCached(apifyToken, apifyClient),
|
|
28
|
+
]);
|
|
23
29
|
if (actors.length === 0) {
|
|
24
30
|
return buildSearchActorsEmptyResponse(parsed.keywords);
|
|
25
31
|
}
|
|
26
|
-
const { actorCardText, actorCardStructured } = buildSearchActorsResult(actors);
|
|
32
|
+
const { actorCardText, actorCardStructured } = buildSearchActorsResult(actors, userPlanTier);
|
|
27
33
|
const structuredContent = {
|
|
28
34
|
actors: actorCardStructured,
|
|
29
35
|
query: parsed.keywords,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search_actors.js","sourceRoot":"","sources":["../../../src/tools/default/search_actors.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACH,8BAA8B,EAC9B,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,GACvB,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAc,MAAM,CAAC,MAAM,CAAC;IACxD,GAAG,oBAAoB;IACvB,IAAI,EAAE,KAAK,EAAE,QAA0B,EAAE,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"search_actors.js","sourceRoot":"","sources":["../../../src/tools/default/search_actors.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;A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AM,EAAE,mBAAmB;YAC3B,KAAK,EAAE,MAAM,CAAC,QAAQ;YACtB,KAAK,EAAE,MAAM,CAAC,MAAM;YACpB,YAAY,EAAE,MAAM,CAAA;;uEAEuC,WAAW,CAAC,iBAAiB;;;;;aAKvF;SACJ,CAAC;QAEF,MAAM,YAAY,GAAG,MAAM,CAAA;;kCAED,MAAM,CAAC,QAAQ;4CACL,MAAM,CAAC,MAAM;;;;cAI3C,aAAa;;;sDAG2B,WAAW,CAAC,iBAAiB;;;;;SAK1E,CAAC;QACF,OAAO,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC1E,CAAC;CACK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor_executor.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/actor_executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actor_executor.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/actor_executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA8C,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGhG;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAsBjC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import log from '@apify/log';
|
|
2
|
-
import {
|
|
3
|
-
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
2
|
+
import { buildStartAsyncResponse } from '../core/call_actor_common.js';
|
|
4
3
|
/**
|
|
5
4
|
* OpenAI actor executor for UI mode.
|
|
6
5
|
* Runs actors asynchronously — starts the run and returns immediately with widget metadata.
|
|
@@ -8,7 +7,7 @@ import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
|
8
7
|
*/
|
|
9
8
|
export const openaiActorExecutor = {
|
|
10
9
|
async executeActorTool(params) {
|
|
11
|
-
var _a
|
|
10
|
+
var _a;
|
|
12
11
|
if ((_a = params.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
13
12
|
return null;
|
|
14
13
|
}
|
|
@@ -19,31 +18,12 @@ export const openaiActorExecutor = {
|
|
|
19
18
|
runId: actorRun.id,
|
|
20
19
|
mcpSessionId: params.mcpSessionId,
|
|
21
20
|
});
|
|
22
|
-
|
|
23
|
-
runId: actorRun.id,
|
|
21
|
+
return buildStartAsyncResponse({
|
|
24
22
|
actorName: params.actorFullName,
|
|
25
|
-
|
|
26
|
-
startedAt: ((_b = actorRun.startedAt) === null || _b === void 0 ? void 0 : _b.toISOString()) || '',
|
|
23
|
+
actorRun,
|
|
27
24
|
input: params.input,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
A live progress widget has been rendered that automatically tracks this run and refreshes status every few seconds until completion.
|
|
32
|
-
|
|
33
|
-
The widget will update the context with run status and datasetId when the run completes. Once complete (or if the user requests results), use ${HelperTools.ACTOR_OUTPUT_GET} with the datasetId to retrieve the output.
|
|
34
|
-
|
|
35
|
-
Do NOT proactively poll using ${HelperTools.ACTOR_RUNS_GET}. Wait for the widget state update or user instructions. Ask the user what they would like to do next.`;
|
|
36
|
-
// _meta carries widget rendering config (not usage meta — the run is still in progress)
|
|
37
|
-
const widgetConfig = getWidgetConfig(WIDGET_URIS.ACTOR_RUN);
|
|
38
|
-
return {
|
|
39
|
-
content: [{ type: 'text', text: responseText }],
|
|
40
|
-
structuredContent,
|
|
41
|
-
// Response-level meta; only returned in openai mode (this executor is openai-only)
|
|
42
|
-
_meta: {
|
|
43
|
-
...widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.meta,
|
|
44
|
-
'openai/widgetDescription': `Actor run progress for ${params.actorFullName}`,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
25
|
+
widget: true,
|
|
26
|
+
});
|
|
47
27
|
},
|
|
48
28
|
};
|
|
49
29
|
//# sourceMappingURL=actor_executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor_executor.js","sourceRoot":"","sources":["../../../src/tools/openai/actor_executor.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"actor_executor.js","sourceRoot":"","sources":["../../../src/tools/openai/actor_executor.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkB;IAC9C,KAAK,CAAC,gBAAgB,CAAC,MAA4B;;QAC/C,IAAI,MAAA,MAAM,CAAC,WAAW,0CAAE,OAAO,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACnE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAE3E,GAAG,CAAC,KAAK,CAAC,8CAA8C,EAAE;YACtD,SAAS,EAAE,MAAM,CAAC,aAAa;YAC/B,KAAK,EAAE,QAAQ,CAAC,EAAE;YAClB,YAAY,EAAE,MAAM,CAAC,YAAY;SACpC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;YAC3B,SAAS,EAAE,MAAM,CAAC,aAAa;YAC/B,QAAQ;YACR,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,IAAI;SACf,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call_actor.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/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/openai/call_actor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAoBlE;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,SAoEnB,CAAC"}
|
|
@@ -2,29 +2,15 @@ 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 { getHttpStatusCode, logHttpError } from '../../utils/logging.js';
|
|
6
|
-
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
7
|
-
import { classifyFailureCategory, getToolStatusFromError } from '../../utils/tool_status.js';
|
|
8
5
|
import { extractActorId } from '../../utils/tools.js';
|
|
9
|
-
import {
|
|
6
|
+
import { buildCallActorDescription, buildCallActorErrorResponse, buildStartAsyncResponse, callActorAjvValidate, callActorInputSchema, callActorPreExecute, resolveAndValidateActor, } from '../core/call_actor_common.js';
|
|
10
7
|
import { callActorOutputSchema } from '../structured_output_schemas.js';
|
|
11
|
-
const CALL_ACTOR_OPENAI_DESCRIPTION =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
If the actor name is not in "username/name" format, use ${HelperTools.STORE_SEARCH_INTERNAL} to resolve the correct Actor first.
|
|
18
|
-
Do NOT use ${HelperTools.STORE_SEARCH} for name resolution when the next step is running an Actor.`,
|
|
19
|
-
CALL_ACTOR_MCP_SERVER_SECTION,
|
|
20
|
-
`IMPORTANT:
|
|
21
|
-
- This tool always runs asynchronously — it starts the Actor and returns immediately with a runId. A live widget automatically tracks the run progress.
|
|
22
|
-
- After calling this tool, do NOT poll or call any other tool. Wait for the user to respond — the widget will update them when the run completes.
|
|
23
|
-
- Once the run completes, 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
|
-
CALL_ACTOR_EXAMPLES_SECTION,
|
|
27
|
-
].join('\n\n');
|
|
8
|
+
const CALL_ACTOR_OPENAI_DESCRIPTION = buildCallActorDescription({
|
|
9
|
+
actorGetDetailsTool: HelperTools.ACTOR_GET_DETAILS_INTERNAL,
|
|
10
|
+
storeSearchTool: HelperTools.STORE_SEARCH_INTERNAL,
|
|
11
|
+
useInternalSearchWarning: true,
|
|
12
|
+
alwaysAsync: true,
|
|
13
|
+
});
|
|
28
14
|
/**
|
|
29
15
|
* OpenAI mode call-actor tool.
|
|
30
16
|
* Always runs asynchronously — starts the run and returns immediately with widget metadata.
|
|
@@ -50,7 +36,6 @@ export const openaiCallActor = Object.freeze({
|
|
|
50
36
|
openWorldHint: true,
|
|
51
37
|
},
|
|
52
38
|
call: async (toolArgs) => {
|
|
53
|
-
var _a;
|
|
54
39
|
const preResult = await callActorPreExecute(toolArgs);
|
|
55
40
|
if ('earlyResponse' in preResult) {
|
|
56
41
|
return preResult.earlyResponse;
|
|
@@ -73,55 +58,26 @@ export const openaiCallActor = Object.freeze({
|
|
|
73
58
|
const actorClient = apifyClient.actor(baseActorName);
|
|
74
59
|
const actorRun = await actorClient.start(input, callOptions);
|
|
75
60
|
log.debug('Started Actor run (async)', { actorName: baseActorName, runId: actorRun.id, mcpSessionId: toolArgs.mcpSessionId });
|
|
76
|
-
const
|
|
77
|
-
runId: actorRun.id,
|
|
61
|
+
const response = buildStartAsyncResponse({
|
|
78
62
|
actorName: baseActorName,
|
|
79
|
-
|
|
80
|
-
startedAt: ((_a = actorRun.startedAt) === null || _a === void 0 ? void 0 : _a.toISOString()) || '',
|
|
63
|
+
actorRun,
|
|
81
64
|
input,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
A live progress widget has been rendered that automatically tracks this run and refreshes status every few seconds until completion.
|
|
86
|
-
|
|
87
|
-
The widget will update the context with run status and datasetId when the run completes. Once complete (or if the user requests results), use ${HelperTools.ACTOR_OUTPUT_GET} with the datasetId to retrieve the output.
|
|
88
|
-
|
|
89
|
-
Do NOT proactively poll using ${HelperTools.ACTOR_RUNS_GET}. Wait for the widget state update or user instructions. Ask the user what they would like to do next.`;
|
|
90
|
-
const widgetConfig = getWidgetConfig(WIDGET_URIS.ACTOR_RUN);
|
|
65
|
+
widget: true,
|
|
66
|
+
});
|
|
91
67
|
return {
|
|
92
|
-
|
|
93
|
-
type: 'text',
|
|
94
|
-
text: responseText,
|
|
95
|
-
}],
|
|
96
|
-
structuredContent,
|
|
97
|
-
// Response-level meta; only returned in openai mode (this handler is openai-only)
|
|
98
|
-
_meta: {
|
|
99
|
-
...widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.meta,
|
|
100
|
-
'openai/widgetDescription': `Actor run progress for ${baseActorName}`,
|
|
101
|
-
},
|
|
68
|
+
...response,
|
|
102
69
|
toolTelemetry: { actorId: resolvedActorId },
|
|
103
70
|
};
|
|
104
71
|
}
|
|
105
72
|
catch (error) {
|
|
106
|
-
|
|
107
|
-
logHttpError(error, 'Failed to call Actor', {
|
|
73
|
+
return buildCallActorErrorResponse({
|
|
108
74
|
actorName: baseActorName,
|
|
109
|
-
|
|
75
|
+
error,
|
|
76
|
+
actorId: resolvedActorId,
|
|
77
|
+
isAsync: true,
|
|
110
78
|
mcpSessionId: toolArgs.mcpSessionId,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return buildMCPResponse({
|
|
114
|
-
texts: [`Failed to call Actor '${baseActorName}': ${errMsg}.
|
|
115
|
-
Please verify the Actor name, input parameters, and ensure the Actor exists.
|
|
116
|
-
You can search for available Actors using the tool: ${HelperTools.STORE_SEARCH_INTERNAL}, or get Actor details using: ${HelperTools.ACTOR_GET_DETAILS_INTERNAL}.`],
|
|
117
|
-
isError: true,
|
|
118
|
-
telemetry: {
|
|
119
|
-
toolStatus: getToolStatusFromError(error, false),
|
|
120
|
-
failureCategory: classifyFailureCategory(error),
|
|
121
|
-
failureHttpStatus: getHttpStatusCode(error),
|
|
122
|
-
failureDetail: errMsg.slice(0, 200),
|
|
123
|
-
actorId: resolvedActorId,
|
|
124
|
-
},
|
|
79
|
+
actorGetDetailsTool: HelperTools.ACTOR_GET_DETAILS_INTERNAL,
|
|
80
|
+
storeSearchTool: HelperTools.STORE_SEARCH_INTERNAL,
|
|
125
81
|
});
|
|
126
82
|
}
|
|
127
83
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call_actor.js","sourceRoot":"","sources":["../../../src/tools/openai/call_actor.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"call_actor.js","sourceRoot":"","sources":["../../../src/tools/openai/call_actor.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACH,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,6BAA6B,GAAG,yBAAyB,CAAC;IAC5D,mBAAmB,EAAE,WAAW,CAAC,0BAA0B;IAC3D,eAAe,EAAE,WAAW,CAAC,qBAAqB;IAClD,wBAAwB,EAAE,IAAI;IAC9B,WAAW,EAAE,IAAI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jC,yCAAyC;YACzC,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAC7D,GAAG,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;YAC9H,MAAM,QAAQ,GAAG,uBAAuB,CAAC;gBACrC,SAAS,EAAE,aAAa;gBACxB,QAAQ;gBACR,KAAK;gBACL,MAAM,EAAE,IAAI;aACf,CAAC,CAAC;YACH,OAAO;gBACH,GAAG,QAAQ;gBACX,aAAa,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE;aAC9C,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,2BAA2B,CAAC;gBAC/B,SAAS,EAAE,aAAa;gBACxB,KAAK;gBACL,OAAO,EAAE,eAAe;gBACxB,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,QAAQ,CAAC,YAAY;gBACnC,mBAAmB,EAAE,WAAW,CAAC,0BAA0B;gBAC3D,eAAe,EAAE,WAAW,CAAC,qBAAqB;aACrD,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch_actor_details.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAgBlE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,SA6C3B,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import dedent from 'dedent';
|
|
1
2
|
import { ApifyClient } from '../../apify_client.js';
|
|
2
3
|
import { getWidgetConfig, WIDGET_URIS } from '../../resources/widgets.js';
|
|
3
|
-
import {
|
|
4
|
+
import { buildActorDetailsForWidget, buildCardOptions, fetchActorDetails, } from '../../utils/actor_details.js';
|
|
4
5
|
import { buildMCPResponse } from '../../utils/mcp.js';
|
|
6
|
+
import { getUserInfoCached } from '../../utils/userid_cache.js';
|
|
5
7
|
import { fixActorNameInputAndLog } from '../core/actor_tools_factory.js';
|
|
6
|
-
import { fetchActorDetailsMetadata, fetchActorDetailsToolArgsSchema, } from '../core/fetch_actor_details_common.js';
|
|
8
|
+
import { buildActorNotFoundResponse, fetchActorDetailsMetadata, fetchActorDetailsToolArgsSchema, resolveOutputOptions, } from '../core/fetch_actor_details_common.js';
|
|
7
9
|
/**
|
|
8
10
|
* OpenAI mode fetch-actor-details tool.
|
|
9
11
|
* Returns simplified structured content with interactive widget metadata.
|
|
@@ -15,25 +17,29 @@ export const openaiFetchActorDetails = Object.freeze({
|
|
|
15
17
|
const parsed = fetchActorDetailsToolArgsSchema.parse(args);
|
|
16
18
|
const actorName = fixActorNameInputAndLog(parsed.actor, { mcpSessionId, route: 'fetch-actor-details' });
|
|
17
19
|
const apifyClient = new ApifyClient({ token: apifyToken });
|
|
18
|
-
const
|
|
19
|
-
const cardOptions = buildCardOptions(
|
|
20
|
+
const { userPlanTier } = await getUserInfoCached(apifyToken, apifyClient);
|
|
21
|
+
const cardOptions = { ...buildCardOptions(resolveOutputOptions(parsed.output)), userTier: userPlanTier };
|
|
20
22
|
const details = await fetchActorDetails(apifyClient, actorName, cardOptions);
|
|
21
23
|
if (!details) {
|
|
22
24
|
return buildActorNotFoundResponse(actorName);
|
|
23
25
|
}
|
|
24
|
-
const {
|
|
26
|
+
const { actorUrl, actorDetails } = buildActorDetailsForWidget(details, userPlanTier);
|
|
27
|
+
// Pricing is already carried by `actorDetails.actorInfo.currentPricingInfo` (widget-facing,
|
|
28
|
+
// tier-aware simplified). Omit the complete-mode `pricing` field from the top-level
|
|
29
|
+
// `actorInfo` to avoid two conflicting pricing shapes in the same response.
|
|
30
|
+
const { pricing: _pricing, ...actorInfoWithoutPricing } = details.actorCardStructured;
|
|
25
31
|
const structuredContent = {
|
|
26
|
-
actorInfo:
|
|
32
|
+
actorInfo: actorInfoWithoutPricing,
|
|
27
33
|
inputSchema: details.inputSchema,
|
|
28
|
-
actorDetails
|
|
34
|
+
actorDetails,
|
|
29
35
|
};
|
|
30
|
-
const texts = [`
|
|
31
|
-
# Actor information:
|
|
32
|
-
- **Actor:** ${actorName}
|
|
33
|
-
- **URL:** ${actorUrl}
|
|
36
|
+
const texts = [dedent `
|
|
37
|
+
# Actor information:
|
|
38
|
+
- **Actor:** ${actorName}
|
|
39
|
+
- **URL:** ${actorUrl}
|
|
34
40
|
|
|
35
|
-
An interactive widget has been rendered with detailed Actor information.
|
|
36
|
-
`];
|
|
41
|
+
An interactive widget has been rendered with detailed Actor information.
|
|
42
|
+
`];
|
|
37
43
|
const widgetConfig = getWidgetConfig(WIDGET_URIS.SEARCH_ACTORS);
|
|
38
44
|
return buildMCPResponse({
|
|
39
45
|
texts,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details.js","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EACH,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"fetch_actor_details.js","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,u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CAAC,OAAO,EAAE,CAAC;YACX,OAAO,0BAA0B,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,0BAA0B,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrF,4FAA4F;QAC5F,oFAAoF;QACpF,4EAA4E;QAC5E,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,uBAAuB,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;QACtF,MAAM,iBAAiB,GAAG;YACtB,SAAS,EAAE,uBAAuB;YAClC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY;SACf,CAAC;QAEF,MAAM,KAAK,GAAG,CAAC,MAAM,CAAA;;2BAEF,SAAS;yBACX,QAAQ;;;SAGxB,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAChE,OAAO,gBAAgB,CAAC;YACpB,KAAK;YACL,iBAAiB;YACjB,kFAAkF;YAClF,KAAK,EAAE;gBACH,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI;gBACrB,0BAA0B,EAAE,qBAAqB,SAAS,mBAAmB;aAChF;SACJ,CAAC,CAAC;IACP,CAAC;CACK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_actor_details_internal.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details_internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fetch_actor_details_internal.d.ts","sourceRoot":"","sources":["../../../src/tools/openai/fetch_actor_details_internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAQjE,eAAO,MAAM,6BAA6B,EAAE,SA4BjC,CAAC"}
|
|
@@ -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"}
|