Skip to content

Commit 11f7299

Browse files
authored
refactor: remove adapter files, wire direct tool variants (Phase B3) (#479)
* 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 * refactor: split server-instructions into common/default/openai (Phase C) (#480) * refactor: split server-instructions into common/default/openai modules Split the monolithic server-instructions.ts into mode-specific modules: - common.ts: shared instruction text (Actor overview, storage, disambiguation) - default.ts: default mode instructions (references fetch-actor-details) - openai.ts: UI mode instructions (workflow rules, internal tool disambiguation) - index.ts: getServerInstructions(uiMode) selector This eliminates if/else branching in the instructions builder. Adding a new mode requires only a new file (e.g., anthropic.ts) and a case in index.ts. * test: add mode-contract tests for tool separation (PR #9) (#481) * test: add mode-contract tests for tool separation verification * refactor: extract Skyfire augmentation and add unit tests (PR #10) (#482) * refactor: extract Skyfire augmentation into pure function and add unit tests - Extract applySkyfireAugmentation() from upsertTools() inline logic into src/utils/tools.ts - Simplify upsertTools() to a 4-line loop delegating to the pure function - Remove unused SKYFIRE_* imports from server.ts - Add 35 unit tests covering eligibility, idempotency, frozen originals, and function preservation * refactor: rename all files from kebab-case to snake_case (#489) * refactor: rename all files from kebab-case to snake_case Use git mv to rename all source files (src/, tests/, evals/, res/, scripts/) from kebab-case to snake_case naming convention. Import paths are not yet updated and will be fixed in the next commit. * refactor: update all imports and references to use snake_case filenames Fix all import paths, package.json exports/scripts, and documentation references to match the renamed snake_case files. Add explicit NEVER use kebab-case rule to AGENTS.md naming conventions. * refactor: enforce one-file-per-tool in common/ directory (#491) * refactor: split common/ multi-tool files into one file per tool - dataset.ts → get_dataset.ts, get_dataset_items.ts, get_dataset_schema.ts - key_value_store.ts → get_key_value_store.ts, get_key_value_store_keys.ts, get_key_value_store_record.ts - run.ts → get_actor_run_log.ts, abort_actor_run.ts - helpers.ts → add_actor.ts (renamed to match tool name) * refactor: replace duplicated tool categories with unified mode-aware resolver (#494) Replace buildCategories() + static toolCategories duplication with a single unified category definition using mode-aware entries (ModeMap) and a generic getCategoryTools(mode) resolver. Key changes: - Add ServerMode type ('default' | 'openai') as string union, normalize once at server construction via options.uiMode ?? 'default' - Replace ternary mode dispatch with Record<ServerMode, ...> map lookups (actorExecutorsByMode, instructionsByMode) - Add parseUiMode() boundary validator for untrusted input (URL params, env vars) - Make mode required in all tool-resolving functions to prevent wrong-mode bugs - Keep mode out of invariant functions (getExpectedToolNamesByCategories, getUnauthEnabledToolCategories, isApiTokenRequired) that never branch on mode - Add contract test enforcing tool name invariance across modes
1 parent db34d71 commit 11f7299

File tree

127 files changed

+1677
-1089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1677
-1089
lines changed

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The codebase is organized into logical modules:
4545

4646
- Entry points:
4747
- `src/index.ts` - Main library export (`ActorsMcpServer` class)
48-
- `src/index-internals.ts` - Internal exports for testing and advanced usage
48+
- `src/index_internals.ts` - Internal exports for testing and advanced usage
4949
- `src/stdio.ts` - Standard input/output entry point (CLI, used for Docker)
5050
- `src/main.ts` - Actor entry point (for Apify platform)
5151
- `src/input.ts` - Input processing and validation
@@ -195,7 +195,7 @@ We use **4 spaces** for indentation (configured in `.editorconfig`).
195195
- **Constants**: Use uppercase `SNAKE_CASE` for global, immutable constants (e.g., `ACTOR_MAX_MEMORY_MBYTES`, `SERVER_NAME`)
196196
- **Functions & Variables**: Use `camelCase` format (e.g., `fetchActorDetails`, `actorClient`)
197197
- **Classes, Types, Interfaces**: Use `PascalCase` format (e.g., `ActorsMcpServer`, `ActorDetailsResult`)
198-
- **Files & Folders**: Use lowercase `snake_case` format (e.g., `actor_details.ts`, `key_value_store.ts`)
198+
- **Files & Folders**: Use lowercase `snake_case` format (e.g., `actor_details.ts`, `key_value_store.ts`). **NEVER use kebab-case** (`kebab-case.ts`) for file or folder names — always use underscores, not hyphens.
199199
- **Booleans**: Prefix with `is`, `has`, or `should` (e.g., `isValid`, `hasFinished`, `shouldRetry`)
200200
- **Units**: Suffix with the unit of measure (e.g., `intervalMillis`, `maxMemoryBytes`)
201201
- **Date/Time**: Suffix with `At` (e.g., `createdAt`, `updatedAt`)
@@ -283,10 +283,10 @@ We use **4 spaces** for indentation (configured in `.editorconfig`).
283283
### Common patterns
284284

285285
- **Tool implementation**: Tools are defined in `src/tools/` using Zod schemas for validation
286-
- **Actor interaction**: Use `src/utils/apify-client.ts` for Apify API calls, never call Apify API directly
286+
- **Actor interaction**: Use `src/utils/apify_client.ts` for Apify API calls, never call Apify API directly
287287
- **Error responses**: Return user-friendly error messages with suggestions
288288
- **Input validation**: Always validate tool inputs with Zod before processing
289-
- **Caching**: Use TTL-based caching for Actor schemas and details (see `src/utils/ttl-lru.ts`)
289+
- **Caching**: Use TTL-based caching for Actor schemas and details (see `src/utils/ttl_lru.ts`)
290290
- **Constants and Tool Names**: Always use constants and never magic or hardcoded values. When referring to tools, ALWAYS use the `HelperTools` enum.
291291
- **Exception**: Integration tests (`tests/integration/`) must use hardcoded strings for tool names. This ensures tests fail if a tool is renamed, helping to prevent accidental breaking changes.
292292

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tests/
2929
Key entry points:
3030

3131
- `src/index.ts` - Main library export (`ActorsMcpServer` class)
32-
- `src/index-internals.ts` - Internal exports for testing / advanced usage
32+
- `src/index_internals.ts` - Internal exports for testing / advanced usage
3333
- `src/stdio.ts` - Standard input/output (CLI) entry point
3434
- `src/main.ts` - Actor entry point (standby server / debugging)
3535
- `src/input.ts` - Input processing and validation
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { hideBin } from 'yargs/helpers';
1515
import log from '@apify/log';
1616

1717
import { sanitizeHeaderValue, validatePhoenixEnvVars } from './config.js';
18-
import { loadTestCases, filterByCategory, filterById, type TestCase } from './evaluation-utils.js';
18+
import { loadTestCases, filterByCategory, filterById, type TestCase } from './evaluation_utils.js';
1919

2020
// Set log level to debug
2121
log.setLevel(log.LEVELS.INFO);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
createToolSelectionLLMEvaluator,
99
loadTestCases, filterById,
1010
type TestCase
11-
} from './evaluation-utils.js';
11+
} from './evaluation_utils.js';
1212
import { PASS_THRESHOLD, sanitizeHeaderValue } from './config.js';
1313

1414
dotenv.config({ path: '.env' });
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { createClassifierFn } from '@arizeai/phoenix-evals';
99

1010
import log from '@apify/log';
1111

12-
import { ApifyClient } from '../src/apify-client.js';
13-
import { getToolPublicFieldOnly, processParamsGetTools } from '../src/index-internals.js';
12+
import { ApifyClient } from '../src/apify_client.js';
13+
import { getToolPublicFieldOnly, processParamsGetTools } from '../src/index_internals.js';
1414
import type { ToolBase, ToolEntry } from '../src/types.js';
1515
import {
1616
SYSTEM_PROMPT,
@@ -20,16 +20,16 @@ import {
2020
TEMPERATURE,
2121
sanitizeHeaderValue
2222
} from './config.js';
23-
import { loadTestCases as loadTestCasesShared, filterByCategory, filterById } from './shared/test-case-loader.js';
24-
import { transformToolsToOpenAIFormat } from './shared/openai-tools.js';
23+
import { loadTestCases as loadTestCasesShared, filterByCategory, filterById } from './shared/test_case_loader.js';
24+
import { transformToolsToOpenAIFormat } from './shared/openai_tools.js';
2525
import type { ToolSelectionTestCase, TestData } from './shared/types.js';
2626

2727
// Re-export types for backwards compatibility
2828
export type TestCase = ToolSelectionTestCase;
2929
export type { TestData } from './shared/types.js';
3030

3131
// Re-export shared functions for backwards compatibility
32-
export { filterByCategory, filterById } from './shared/test-case-loader.js';
32+
export { filterByCategory, filterById } from './shared/test_case_loader.js';
3333

3434
type ExampleInputOnly = { input: Record<string, unknown>, metadata?: Record<string, unknown>, output?: never };
3535

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
loadTools,
2121
createOpenRouterTask,
2222
createToolSelectionLLMEvaluator
23-
} from './evaluation-utils.js';
23+
} from './evaluation_utils.js';
2424
import {
2525
DATASET_NAME,
2626
MODELS_TO_EVALUATE,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Filter test cases by line ranges
33
*/
44

5-
import type { LineRange } from './line-range-parser.js';
5+
import type { LineRange } from './line_range_parser.js';
66

77
/**
88
* Type for test cases with line number metadata

0 commit comments

Comments
 (0)