Skip to content

Commit d3d8eb5

Browse files
committed
refactor: remove adapter files, use direct tool variants in categories
Remove the runtime-dispatching adapter layer now that buildCategories(uiMode) resolves the correct tool variants at build time: - Delete src/tools/actor.ts (call-actor adapter) - Delete src/tools/store_collection.ts (search-actors adapter) - Delete src/tools/fetch-actor-details.ts (fetch-actor-details adapter) - Remove get-actor-run adapter from common/run.ts (keep mode-independent tools) - Update categories.ts to use default variants directly in static toolCategories - Update tools/index.ts to import from core modules instead of adapter
1 parent db34d71 commit d3d8eb5

6 files changed

Lines changed: 11 additions & 135 deletions

File tree

‎src/tools/actor.ts‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎src/tools/categories.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* which also auto-injects get-actor-run and get-actor-output right after call-actor.
1010
*/
1111
import type { ToolEntry, UiMode } from '../types.js';
12-
import { callActor } from './actor.js';
1312
import { getDataset, getDatasetItems, getDatasetSchema } from './common/dataset.js';
1413
import { getUserDatasetsList } from './common/dataset_collection.js';
1514
import { fetchApifyDocsTool } from './common/fetch-apify-docs.js';
@@ -18,21 +17,19 @@ import { getHtmlSkeleton } from './common/get-html-skeleton.js';
1817
import { addTool } from './common/helpers.js';
1918
import { getKeyValueStore, getKeyValueStoreKeys, getKeyValueStoreRecord } from './common/key_value_store.js';
2019
import { getUserKeyValueStoresList } from './common/key_value_store_collection.js';
21-
import { abortActorRun, getActorRun, getActorRunLog } from './common/run.js';
20+
import { abortActorRun, getActorRunLog } from './common/run.js';
2221
import { getUserRunsList } from './common/run_collection.js';
2322
import { searchApifyDocsTool } from './common/search-apify-docs.js';
2423
import { defaultCallActor } from './default/call-actor.js';
2524
import { defaultFetchActorDetails } from './default/fetch-actor-details.js';
2625
import { defaultGetActorRun } from './default/get-actor-run.js';
2726
import { defaultSearchActors } from './default/search-actors.js';
28-
import { fetchActorDetailsTool } from './fetch-actor-details.js';
2927
import { openaiCallActor } from './openai/call-actor.js';
3028
import { openaiFetchActorDetails } from './openai/fetch-actor-details.js';
3129
import { fetchActorDetailsInternalTool } from './openai/fetch-actor-details-internal.js';
3230
import { openaiGetActorRun } from './openai/get-actor-run.js';
3331
import { openaiSearchActors } from './openai/search-actors.js';
3432
import { searchActorsInternalTool } from './openai/search-actors-internal.js';
35-
import { searchActors } from './store_collection.js';
3633

3734
/**
3835
* Static tool categories using adapter tools that dispatch at runtime based on uiMode.
@@ -46,9 +43,9 @@ export const toolCategories = {
4643
addTool,
4744
],
4845
actors: [
49-
searchActors,
50-
fetchActorDetailsTool,
51-
callActor,
46+
defaultSearchActors,
47+
defaultFetchActorDetails,
48+
defaultCallActor,
5249
],
5350
ui: [
5451
searchActorsInternalTool,
@@ -59,7 +56,7 @@ export const toolCategories = {
5956
fetchApifyDocsTool,
6057
],
6158
runs: [
62-
getActorRun,
59+
defaultGetActorRun,
6360
getUserRunsList,
6461
getActorRunLog,
6562
abortActorRun,

‎src/tools/common/run.ts‎

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,17 @@
11
/**
2-
* Actor run tools — get-actor-run (adapter), get-actor-run-log, and abort-actor-run.
2+
* Mode-independent Actor run tools: get-actor-run-log and abort-actor-run.
33
*
4-
* The get-actor-run tool has been split into mode-specific variants:
4+
* The get-actor-run tool has mode-specific variants in:
55
* - `default/get-actor-run.ts` — full JSON dump without widget metadata
66
* - `openai/get-actor-run.ts` — abbreviated text with widget metadata
7-
* - `core/get-actor-run-common.ts` — shared schema, metadata, and data-fetching logic
8-
*
9-
* The getActorRunLog and abortActorRun tools are mode-independent and remain here.
10-
* PR #4 will wire variants directly into the category registry, making the adapter unnecessary.
7+
* These are resolved via buildCategories(uiMode) in tools-loader.ts.
118
*/
129
import { z } from 'zod';
1310

1411
import { createApifyClientWithSkyfireSupport } from '../../apify-client.js';
1512
import { HelperTools } from '../../const.js';
16-
import type { HelperTool, InternalToolArgs, ToolEntry, ToolInputSchema } from '../../types.js';
13+
import type { InternalToolArgs, ToolEntry, ToolInputSchema } from '../../types.js';
1714
import { compileSchema } from '../../utils/ajv.js';
18-
import { defaultGetActorRun } from '../default/get-actor-run.js';
19-
import { openaiGetActorRun } from '../openai/get-actor-run.js';
20-
21-
const defaultVariant = defaultGetActorRun as HelperTool;
22-
23-
/**
24-
* Adapter get-actor-run tool that dispatches to the correct mode-specific variant at runtime.
25-
*/
26-
export const getActorRun: ToolEntry = Object.freeze({
27-
...defaultVariant,
28-
call: async (toolArgs: InternalToolArgs) => {
29-
const variant = (toolArgs.apifyMcpServer.options.uiMode === 'openai'
30-
? openaiGetActorRun
31-
: defaultGetActorRun) as HelperTool;
32-
return variant.call(toolArgs);
33-
},
34-
});
35-
36-
// --- Mode-independent tools below ---
3715

3816
const GetRunLogArgs = z.object({
3917
runId: z.string().describe('The ID of the Actor run.'),

‎src/tools/fetch-actor-details.ts‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎src/tools/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { HelperTools } from '../const.js';
22
import type { ToolCategory } from '../types.js';
33
import { getExpectedToolsByCategories } from '../utils/tool-categories-helpers.js';
4-
import { callActorGetDataset, getActorsAsTools } from './actor.js';
54
import { buildCategories, CATEGORY_NAMES, toolCategories, toolCategoriesEnabledByDefault } from './categories.js';
5+
import { callActorGetDataset } from './core/actor-execution.js';
6+
import { getActorsAsTools } from './core/actor-tools-factory.js';
67

78
// Use string constants instead of importing tool objects to avoid circular dependency
89
export const unauthEnabledTools: string[] = [

‎src/tools/store_collection.ts‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)