Skip to content

Commit bfc820d

Browse files
committed
refactor: simplify tool types using discriminated unions
- Convert ToolEntry to discriminated union with explicit type variants - HelperToolEntry: type: 'internal' - ActorToolEntry: type: 'actor' - ActorMcpToolEntry: type: 'actor-mcp' - Remove actorFullName from all internal tools (11 tools across 9 files) - Remove unused ToolType export - Improves type safety and enables automatic type narrowing in TypeScript
1 parent 4e3cf9d commit bfc820d

File tree

11 files changed

+36
-25
lines changed

11 files changed

+36
-25
lines changed

src/tools/actor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ export const callActor: ToolEntry = {
329329
type: 'internal',
330330
tool: {
331331
name: HelperTools.ACTOR_CALL,
332-
actorFullName: HelperTools.ACTOR_CALL,
333332
description: `Call any Actor from the Apify Store using a mandatory two-step workflow.
334333
This ensures you first get the Actor’s input schema and details before executing it safely.
335334

src/tools/build.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ export const actorDefinitionTool: ToolEntry = {
110110
type: 'internal',
111111
tool: {
112112
name: HelperTools.ACTOR_GET_DETAILS,
113-
// TODO: remove actorFullName from internal tools
114-
actorFullName: HelperTools.ACTOR_GET_DETAILS,
115113
description: 'Get documentation, readme, input schema and other details about an Actor. '
116114
+ 'For example, when user says, I need to know more about web crawler Actor.'
117115
+ 'Get details for an Actor with with Actor ID or Actor full name, i.e. username/name.'

src/tools/dataset.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export const getDataset: ToolEntry = {
4545
type: 'internal',
4646
tool: {
4747
name: HelperTools.DATASET_GET,
48-
actorFullName: HelperTools.DATASET_GET,
4948
description: `Get metadata for a dataset (collection of structured data created by an Actor run).
5049
The results will include dataset details such as itemCount, schema, fields, and stats.
5150
Use fields to understand structure for filtering with ${HelperTools.DATASET_GET_ITEMS}.
@@ -79,7 +78,6 @@ export const getDatasetItems: ToolEntry = {
7978
type: 'internal',
8079
tool: {
8180
name: HelperTools.DATASET_GET_ITEMS,
82-
actorFullName: HelperTools.DATASET_GET_ITEMS,
8381
description: `Retrieve dataset items with pagination, sorting, and field selection.
8482
Use clean=true to skip empty items and hidden fields. Include or omit fields using comma-separated lists.
8583
For nested objects, first flatten them (e.g., flatten="metadata"), then reference nested fields via dot notation (e.g., fields="metadata.url").
@@ -143,7 +141,6 @@ export const getDatasetSchema: ToolEntry = {
143141
type: 'internal',
144142
tool: {
145143
name: HelperTools.DATASET_SCHEMA_GET,
146-
actorFullName: HelperTools.DATASET_SCHEMA_GET,
147144
description: `Generate a JSON schema from a sample of dataset items.
148145
The schema describes the structure of the data and can be used for validation, documentation, or processing.
149146
Use this to understand the dataset before fetching many items.

src/tools/dataset_collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const getUserDatasetsList: ToolEntry = {
2929
type: 'internal',
3030
tool: {
3131
name: HelperTools.DATASET_LIST_GET,
32-
actorFullName: HelperTools.DATASET_LIST_GET,
3332
description: `List datasets (collections of Actor run data) for the authenticated user.
3433
Actor runs automatically produce unnamed datasets (set unnamed=true to include them). Users can also create named datasets.
3534

src/tools/get-actor-output.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const getActorOutput: ToolEntry = {
6767
type: 'internal',
6868
tool: {
6969
name: HelperTools.ACTOR_OUTPUT_GET,
70-
actorFullName: HelperTools.ACTOR_OUTPUT_GET,
7170
description: `Retrieve the output dataset items of a specific Actor run using its datasetId.
7271
You can select specific fields to return (supports dot notation like "crawl.statusCode") and paginate results with offset and limit.
7372
This tool is a simplified version of the get-dataset-items tool, focused on Actor run outputs.

src/tools/get-html-skeleton.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const getHtmlSkeleton: ToolEntry = {
4040
type: 'internal',
4141
tool: {
4242
name: HelperTools.GET_HTML_SKELETON,
43-
actorFullName: HelperTools.GET_HTML_SKELETON,
4443
description: `Retrieve the HTML skeleton (clean structure) of a webpage by stripping scripts, styles, and non-essential attributes.
4544
This keeps the core HTML structure, links, images, and data attributes for analysis. Supports optional JavaScript rendering for dynamic pages.
4645

src/tools/key_value_store.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const getKeyValueStore: ToolEntry = {
1919
type: 'internal',
2020
tool: {
2121
name: HelperTools.KEY_VALUE_STORE_GET,
22-
actorFullName: HelperTools.KEY_VALUE_STORE_GET,
2322
description: `Get details about a key-value store by ID or username~store-name.
2423
The results will include store metadata (ID, name, owner, access settings) and usage statistics.
2524
@@ -61,7 +60,6 @@ export const getKeyValueStoreKeys: ToolEntry = {
6160
type: 'internal',
6261
tool: {
6362
name: HelperTools.KEY_VALUE_STORE_KEYS_GET,
64-
actorFullName: HelperTools.KEY_VALUE_STORE_KEYS_GET,
6563
description: `List keys in a key-value store with optional pagination.
6664
The results will include keys and basic info about stored values (e.g., size).
6765
Use exclusiveStartKey and limit to paginate.
@@ -103,7 +101,6 @@ export const getKeyValueStoreRecord: ToolEntry = {
103101
type: 'internal',
104102
tool: {
105103
name: HelperTools.KEY_VALUE_STORE_RECORD_GET,
106-
actorFullName: HelperTools.KEY_VALUE_STORE_RECORD_GET,
107104
description: `Get a value stored in a key-value store under a specific key.
108105
The response preserves the original Content-Encoding; most clients handle decompression automatically.
109106

src/tools/key_value_store_collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const getUserKeyValueStoresList: ToolEntry = {
2929
type: 'internal',
3030
tool: {
3131
name: HelperTools.KEY_VALUE_STORE_LIST_GET,
32-
actorFullName: HelperTools.KEY_VALUE_STORE_LIST_GET,
3332
description: `List key-value stores owned by the authenticated user.
3433
Actor runs automatically produce unnamed stores (set unnamed=true to include them). Users can also create named stores.
3534

src/tools/run.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const getActorRun: ToolEntry = {
2626
type: 'internal',
2727
tool: {
2828
name: HelperTools.ACTOR_RUNS_GET,
29-
actorFullName: HelperTools.ACTOR_RUNS_GET,
3029
description: `Get detailed information about a specific Actor run by runId.
3130
The results will include run metadata (status, timestamps), performance stats, and resource IDs (datasetId, keyValueStoreId, requestQueueId).
3231
@@ -67,7 +66,6 @@ export const getActorRunLog: ToolEntry = {
6766
type: 'internal',
6867
tool: {
6968
name: HelperTools.ACTOR_RUNS_LOG,
70-
actorFullName: HelperTools.ACTOR_RUNS_LOG,
7169
description: `Retrieve recent log lines for a specific Actor run.
7270
The results will include the last N lines of the run’s log output (plain text).
7371
@@ -98,7 +96,6 @@ export const abortActorRun: ToolEntry = {
9896
type: 'internal',
9997
tool: {
10098
name: HelperTools.ACTOR_RUNS_ABORT,
101-
actorFullName: HelperTools.ACTOR_RUNS_ABORT,
10299
description: `Abort an Actor run that is currently starting or running.
103100
For runs with status FINISHED, FAILED, ABORTING, or TIMED-OUT, this call has no effect.
104101
The results will include the updated run details after the abort request.

src/tools/run_collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const getUserRunsList: ToolEntry = {
2929
type: 'internal',
3030
tool: {
3131
name: HelperTools.ACTOR_RUN_LIST_GET,
32-
actorFullName: HelperTools.ACTOR_RUN_LIST_GET,
3332
description: `List Actor runs for the authenticated user with optional filtering and sorting.
3433
The results will include run details (including datasetId and keyValueStoreId) and can be filtered by status.
3534
Valid statuses: READY (not allocated), RUNNING (executing), SUCCEEDED (finished), FAILED (failed), TIMING-OUT, TIMED-OUT, ABORTING, ABORTED.

0 commit comments

Comments
 (0)