@apify/actors-mcp-server 0.9.20-beta.0 → 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 +68 -4
- package/dist/tools/structured_output_schemas.d.ts.map +1 -1
- package/dist/tools/structured_output_schemas.js +28 -4
- package/dist/tools/structured_output_schemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +9 -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 +20 -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,12 +1,9 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { FAILURE_CATEGORY, HelperTools, TOOL_STATUS } from '../const.js';
|
|
3
1
|
import { connectMCPClient } from '../mcp/client.js';
|
|
4
2
|
import { filterSchemaProperties, shortenProperties } from '../tools/utils.js';
|
|
5
3
|
import { getActorMcpUrlCached } from './actor.js';
|
|
6
4
|
import { formatActorForWidget, formatActorToActorCard, formatActorToStructuredCard } from './actor_card.js';
|
|
7
5
|
import { searchActorsByKeywords } from './actor_search.js';
|
|
8
6
|
import { logHttpError } from './logging.js';
|
|
9
|
-
import { buildMCPResponse } from './mcp.js';
|
|
10
7
|
const ACTOR_DETAILS_PICTURE_SEARCH_LIMIT = 5;
|
|
11
8
|
/**
|
|
12
9
|
* Convert a type object to TypeScript-like string representation.
|
|
@@ -15,41 +12,22 @@ const ACTOR_DETAILS_PICTURE_SEARCH_LIMIT = 5;
|
|
|
15
12
|
* Example:
|
|
16
13
|
* Input: { first_number: "number", tags: ["string"], user: { name: "string" } }
|
|
17
14
|
* Output: "{ first_number: number, tags: string[], user: { name: string } }"
|
|
15
|
+
*
|
|
16
|
+
* Values that are not string / object / array are skipped (not rendered) at every nesting level.
|
|
18
17
|
*/
|
|
19
|
-
function typeObjectToString(obj) {
|
|
20
|
-
const pairs =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Array type
|
|
24
|
-
const itemType = typeValueToString(value[0]);
|
|
25
|
-
pairs.push(`${key}: ${itemType}[]`);
|
|
26
|
-
}
|
|
27
|
-
else if (typeof value === 'object' && value !== null) {
|
|
28
|
-
// Nested object type
|
|
29
|
-
const nestedStr = typeObjectToString(value);
|
|
30
|
-
pairs.push(`${key}: ${nestedStr}`);
|
|
31
|
-
}
|
|
32
|
-
else if (typeof value === 'string') {
|
|
33
|
-
// Primitive type
|
|
34
|
-
pairs.push(`${key}: ${value}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
18
|
+
export function typeObjectToString(obj) {
|
|
19
|
+
const pairs = Object.entries(obj)
|
|
20
|
+
.filter(([, v]) => Array.isArray(v) || (v !== null && typeof v === 'object') || typeof v === 'string')
|
|
21
|
+
.map(([k, v]) => `${k}: ${typeValueToString(v)}`);
|
|
37
22
|
return `{ ${pairs.join(', ')} }`;
|
|
38
23
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Convert a single type value to string.
|
|
41
|
-
*/
|
|
42
24
|
function typeValueToString(value) {
|
|
43
|
-
if (Array.isArray(value))
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
if (typeof value === 'object' && value !== null) {
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return `${typeValueToString(value[0])}[]`;
|
|
27
|
+
if (value !== null && typeof value === 'object')
|
|
48
28
|
return typeObjectToString(value);
|
|
49
|
-
|
|
50
|
-
if (typeof value === 'string') {
|
|
29
|
+
if (typeof value === 'string')
|
|
51
30
|
return value;
|
|
52
|
-
}
|
|
53
31
|
return 'unknown';
|
|
54
32
|
}
|
|
55
33
|
/**
|
|
@@ -65,13 +43,14 @@ export function resolveReadmeContent(details) {
|
|
|
65
43
|
}
|
|
66
44
|
export async function fetchActorDetails(apifyClient, actorName, cardOptions) {
|
|
67
45
|
try {
|
|
46
|
+
// Use only the actor name part (after '/') for better keyword search relevance —
|
|
47
|
+
// "apify/instagram-scraper" returns unrelated results, while "instagram-scraper" finds the correct actor.
|
|
48
|
+
const actorSlug = actorName.split('/').pop() || actorName;
|
|
49
|
+
const actor = apifyClient.actor(actorName);
|
|
68
50
|
const [actorInfo, buildInfo, storeActors] = await Promise.all([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Use only the actor name part (after '/') for better keyword search relevance —
|
|
73
|
-
// searching "apify/instagram-scraper" returns unrelated results, while "instagram-scraper" finds the correct actor.
|
|
74
|
-
searchActorsByKeywords(actorName.split('/').pop() || actorName, apifyClient.token || '', ACTOR_DETAILS_PICTURE_SEARCH_LIMIT).catch(() => []),
|
|
51
|
+
actor.get(),
|
|
52
|
+
actor.defaultBuild().then(async (build) => build.get()),
|
|
53
|
+
searchActorsByKeywords(actorSlug, apifyClient.token || '', ACTOR_DETAILS_PICTURE_SEARCH_LIMIT).catch(() => []),
|
|
75
54
|
]);
|
|
76
55
|
if (!actorInfo || !buildInfo || !buildInfo.actorDefinition)
|
|
77
56
|
return null;
|
|
@@ -102,92 +81,21 @@ export async function fetchActorDetails(apifyClient, actorName, cardOptions) {
|
|
|
102
81
|
}
|
|
103
82
|
}
|
|
104
83
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @param details - Raw actor details from fetchActorDetails
|
|
108
|
-
* @returns Processed actor details with formatted content
|
|
84
|
+
* Build the widget actor-details payload for the openai variant.
|
|
85
|
+
* Returns the Actor URL and the structured `actorDetails` object.
|
|
109
86
|
*/
|
|
110
|
-
export function
|
|
87
|
+
export function buildActorDetailsForWidget(details, userTier) {
|
|
111
88
|
const actorUrl = `https://apify.com/${details.actorInfo.username}/${details.actorInfo.name}`;
|
|
112
|
-
// Add link to README title
|
|
113
89
|
const formattedReadme = details.readme.replace(/^# /, `# [README](${actorUrl}/readme): `);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
formattedReadme,
|
|
117
|
-
];
|
|
118
|
-
// Include input schema if it has properties
|
|
119
|
-
const hasInputSchema = details.inputSchema.properties && Object.keys(details.inputSchema.properties).length !== 0;
|
|
120
|
-
if (hasInputSchema) {
|
|
121
|
-
texts.push(`# [Input schema](${actorUrl}/input)\n\`\`\`json\n${JSON.stringify(details.inputSchema)}\n\`\`\``);
|
|
122
|
-
}
|
|
123
|
-
const structuredContent = {
|
|
90
|
+
return {
|
|
91
|
+
actorUrl,
|
|
124
92
|
actorDetails: {
|
|
125
|
-
actorInfo: formatActorForWidget(details.actorInfo),
|
|
93
|
+
actorInfo: formatActorForWidget(details.actorInfo, userTier),
|
|
126
94
|
actorCard: details.actorCard,
|
|
127
95
|
readme: formattedReadme,
|
|
128
96
|
inputSchema: details.inputSchema,
|
|
129
97
|
},
|
|
130
98
|
};
|
|
131
|
-
return {
|
|
132
|
-
actorUrl,
|
|
133
|
-
texts,
|
|
134
|
-
structuredContent,
|
|
135
|
-
formattedReadme,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Shared schema for actor details output options.
|
|
140
|
-
* Used by both public and internal fetch-actor-details tools.
|
|
141
|
-
*
|
|
142
|
-
* Behavior:
|
|
143
|
-
* - If output is undefined or empty object: use defaults (all true except mcpTools and outputSchema)
|
|
144
|
-
* - If any property is explicitly set: only include sections with explicit true values
|
|
145
|
-
*/
|
|
146
|
-
export const actorDetailsOutputOptionsSchema = z.object({
|
|
147
|
-
description: z.boolean().optional().describe('Include Actor description text only.'),
|
|
148
|
-
stats: z.boolean().optional().describe('Include usage statistics (users, runs, success rate).'),
|
|
149
|
-
pricing: z.boolean().optional().describe('Include pricing model and costs.'),
|
|
150
|
-
rating: z.boolean().optional().describe('Include user rating (out of 5 stars).'),
|
|
151
|
-
metadata: z.boolean().optional().describe('Include developer, categories, last modified date, and deprecation status.'),
|
|
152
|
-
inputSchema: z.boolean().optional().describe('Include required input parameters schema.'),
|
|
153
|
-
readme: z.boolean().optional().describe('Include Actor README documentation (summary when available, full otherwise).'),
|
|
154
|
-
outputSchema: z.boolean().optional().describe('Include inferred output schema from recent successful runs (TypeScript type).'),
|
|
155
|
-
mcpTools: z.boolean().optional().describe('List available tools (only for MCP server Actors).'),
|
|
156
|
-
});
|
|
157
|
-
export const actorDetailsOutputDefaults = {
|
|
158
|
-
description: true,
|
|
159
|
-
stats: true,
|
|
160
|
-
pricing: true,
|
|
161
|
-
rating: true,
|
|
162
|
-
metadata: true,
|
|
163
|
-
inputSchema: true,
|
|
164
|
-
readme: true,
|
|
165
|
-
outputSchema: false,
|
|
166
|
-
mcpTools: false,
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Resolve output options with smart defaults.
|
|
170
|
-
* If output is undefined/empty, returns defaults.
|
|
171
|
-
* If any property is explicitly set, undefined properties are treated as false.
|
|
172
|
-
*/
|
|
173
|
-
export function resolveOutputOptions(output) {
|
|
174
|
-
// Check if output has any explicit true/false values
|
|
175
|
-
const hasExplicitOptions = output && Object.values(output).some((v) => v !== undefined);
|
|
176
|
-
if (!hasExplicitOptions) {
|
|
177
|
-
return actorDetailsOutputDefaults;
|
|
178
|
-
}
|
|
179
|
-
// Return output with undefined treated as false (explicit true required)
|
|
180
|
-
return {
|
|
181
|
-
description: (output === null || output === void 0 ? void 0 : output.description) === true,
|
|
182
|
-
stats: (output === null || output === void 0 ? void 0 : output.stats) === true,
|
|
183
|
-
pricing: (output === null || output === void 0 ? void 0 : output.pricing) === true,
|
|
184
|
-
rating: (output === null || output === void 0 ? void 0 : output.rating) === true,
|
|
185
|
-
metadata: (output === null || output === void 0 ? void 0 : output.metadata) === true,
|
|
186
|
-
inputSchema: (output === null || output === void 0 ? void 0 : output.inputSchema) === true,
|
|
187
|
-
readme: (output === null || output === void 0 ? void 0 : output.readme) === true,
|
|
188
|
-
outputSchema: (output === null || output === void 0 ? void 0 : output.outputSchema) === true,
|
|
189
|
-
mcpTools: (output === null || output === void 0 ? void 0 : output.mcpTools) === true,
|
|
190
|
-
};
|
|
191
99
|
}
|
|
192
100
|
/**
|
|
193
101
|
* Gets MCP tools information for an Actor.
|
|
@@ -211,9 +119,22 @@ export async function getMcpToolsMessage(actorName, apifyClient, apifyToken, pay
|
|
|
211
119
|
try {
|
|
212
120
|
const toolsResponse = await client.listTools();
|
|
213
121
|
const mcpToolsInfo = toolsResponse.tools
|
|
214
|
-
.map((tool) =>
|
|
122
|
+
.map((tool) => [
|
|
123
|
+
`**${tool.name}**`,
|
|
124
|
+
tool.description || 'No description',
|
|
125
|
+
'Input schema:',
|
|
126
|
+
'```json',
|
|
127
|
+
JSON.stringify(tool.inputSchema),
|
|
128
|
+
'```',
|
|
129
|
+
].join('\n'))
|
|
215
130
|
.join('\n\n');
|
|
216
|
-
return
|
|
131
|
+
return [
|
|
132
|
+
'# Available MCP Tools',
|
|
133
|
+
`This Actor is an MCP server with ${toolsResponse.tools.length} tools.`,
|
|
134
|
+
`To call a tool, use: "${actorName}:{toolName}"`,
|
|
135
|
+
'',
|
|
136
|
+
mcpToolsInfo,
|
|
137
|
+
].join('\n');
|
|
217
138
|
}
|
|
218
139
|
catch (error) {
|
|
219
140
|
logHttpError(error, `Failed to list MCP tools for Actor '${actorName}'`, { actorName });
|
|
@@ -226,6 +147,7 @@ export async function getMcpToolsMessage(actorName, apifyClient, apifyToken, pay
|
|
|
226
147
|
/**
|
|
227
148
|
* Build card options from resolved output flags.
|
|
228
149
|
* Maps boolean output flags to card rendering options (explicit true required).
|
|
150
|
+
* Caller adds `userTier` if needed — this helper stays focused on flags.
|
|
229
151
|
*/
|
|
230
152
|
export function buildCardOptions(output) {
|
|
231
153
|
return {
|
|
@@ -236,67 +158,4 @@ export function buildCardOptions(output) {
|
|
|
236
158
|
includeMetadata: output.metadata,
|
|
237
159
|
};
|
|
238
160
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Build error response for when actor is not found.
|
|
241
|
-
*/
|
|
242
|
-
export function buildActorNotFoundResponse(actorName) {
|
|
243
|
-
return buildMCPResponse({
|
|
244
|
-
texts: [`Actor information for '${actorName}' was not found.
|
|
245
|
-
Please verify Actor ID or name format and ensure that the Actor exists.
|
|
246
|
-
You can search for available Actors using the tool: ${HelperTools.STORE_SEARCH}.`],
|
|
247
|
-
isError: true,
|
|
248
|
-
telemetry: { toolStatus: TOOL_STATUS.SOFT_FAIL, failureCategory: FAILURE_CATEGORY.INVALID_INPUT },
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Build text and structured response for actor details.
|
|
253
|
-
* Handles all resolved output options: description, stats, readme, inputSchema, outputSchema, mcpTools.
|
|
254
|
-
* All output properties should be boolean (resolved via resolveOutputOptions).
|
|
255
|
-
*/
|
|
256
|
-
export async function buildActorDetailsTextResponse(options) {
|
|
257
|
-
const { actorName, details, output, cardOptions, apifyClient, apifyToken, actorOutputSchema, paymentProvider, mcpSessionId } = options;
|
|
258
|
-
const actorUrl = `https://apify.com/${details.actorInfo.username}/${details.actorInfo.name}`;
|
|
259
|
-
const texts = [];
|
|
260
|
-
// Build actor card only if any card section is requested
|
|
261
|
-
const needsCard = cardOptions.includeDescription
|
|
262
|
-
|| cardOptions.includeStats
|
|
263
|
-
|| cardOptions.includePricing
|
|
264
|
-
|| cardOptions.includeRating
|
|
265
|
-
|| cardOptions.includeMetadata;
|
|
266
|
-
if (needsCard) {
|
|
267
|
-
texts.push(`# Actor information\n${details.actorCard}`);
|
|
268
|
-
}
|
|
269
|
-
// Add README content if requested (prefer readmeSummary, fall back to full readme)
|
|
270
|
-
const resolvedReadme = output.readme ? resolveReadmeContent(details) : undefined;
|
|
271
|
-
if (resolvedReadme) {
|
|
272
|
-
texts.push(`${resolvedReadme.heading}\n${resolvedReadme.content}`);
|
|
273
|
-
}
|
|
274
|
-
// Add input schema if requested
|
|
275
|
-
if (output.inputSchema) {
|
|
276
|
-
texts.push(`# [Input schema](${actorUrl}/input)\n\`\`\`json\n${JSON.stringify(details.inputSchema)}\n\`\`\``);
|
|
277
|
-
}
|
|
278
|
-
// Add output schema if requested
|
|
279
|
-
if (output.outputSchema) {
|
|
280
|
-
if (actorOutputSchema && Object.keys(actorOutputSchema).length > 0) {
|
|
281
|
-
const typeString = typeObjectToString(actorOutputSchema);
|
|
282
|
-
texts.push(`# Output Schema (TypeScript)\nInferred from recent successful runs:\n\`\`\`typescript\ntype ActorOutput = ${typeString}\n\`\`\``);
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
texts.push(`# Output Schema\nNo output schema available. The Actor may not have recent successful runs, or the output structure could not be determined.`);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// Handle MCP tools
|
|
289
|
-
if (output.mcpTools) {
|
|
290
|
-
const message = await getMcpToolsMessage(actorName, apifyClient, apifyToken, paymentProvider, mcpSessionId);
|
|
291
|
-
texts.push(message);
|
|
292
|
-
}
|
|
293
|
-
// Build structured content
|
|
294
|
-
const structuredContent = {
|
|
295
|
-
actorInfo: needsCard ? details.actorCardStructured : undefined,
|
|
296
|
-
readme: resolvedReadme === null || resolvedReadme === void 0 ? void 0 : resolvedReadme.content,
|
|
297
|
-
inputSchema: output.inputSchema ? details.inputSchema : undefined,
|
|
298
|
-
outputSchema: output.outputSchema ? (actorOutputSchema !== null && actorOutputSchema !== void 0 ? actorOutputSchema : {}) : undefined,
|
|
299
|
-
};
|
|
300
|
-
return { texts, structuredContent };
|
|
301
|
-
}
|
|
302
161
|
//# sourceMappingURL=actor_details.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor_details.js","sourceRoot":"","sources":["../../src/utils/actor_details.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actor_details.js","sourceRoot":"","sources":["../../src/utils/actor_details.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,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O,KAAK,EAAE,CAAC;QACb,YAAY,CAAC,KAAK,EAAE,uCAAuC,SAAS,GAAG,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QACxF,OAAO,2CAA2C,SAAS,mDAAmD,CAAC;IACnH,CAAC;YAAS,CAAC;QACP,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAMhC;IACG,OAAO;QACH,kBAAkB,EAAE,MAAM,CAAC,WAAW;QACtC,YAAY,EAAE,MAAM,CAAC,KAAK;QAC1B,cAAc,EAAE,MAAM,CAAC,OAAO;QAC9B,aAAa,EAAE,MAAM,CAAC,MAAM;QAC5B,eAAe,EAAE,MAAM,CAAC,QAAQ;KACnC,CAAC;AACN,CAAC"}
|
|
@@ -1,8 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pricing output contract for Actor cards.
|
|
3
|
+
*
|
|
4
|
+
* Text callers:
|
|
5
|
+
* - `pricingInfoToString`: complete mode for `fetch-actor-details`
|
|
6
|
+
* - `pricingInfoToSimplifiedString`: simplified mode for `search-actors`
|
|
7
|
+
*
|
|
8
|
+
* Structured callers:
|
|
9
|
+
* - `pricingInfoToStructured`: complete mode
|
|
10
|
+
* - `pricingInfoToSimplifiedStructured`: simplified mode
|
|
11
|
+
*
|
|
12
|
+
* Structured output shape is mostly the same in both modes:
|
|
13
|
+
* {
|
|
14
|
+
* model: string,
|
|
15
|
+
* userTier?: PricingTier,
|
|
16
|
+
* pricePerUnit?: number,
|
|
17
|
+
* unitName?: string,
|
|
18
|
+
* trialMinutes?: number,
|
|
19
|
+
* tieredPricing?: [{ tier: string, pricePerUnit: number }],
|
|
20
|
+
* events?: [{
|
|
21
|
+
* title: string,
|
|
22
|
+
* description?: string,
|
|
23
|
+
* priceUsd?: number,
|
|
24
|
+
* tieredPricing?: [{ tier: string, priceUsd: number }],
|
|
25
|
+
* }],
|
|
26
|
+
* pricingNote?: string,
|
|
27
|
+
* eventDescriptionsOmitted?: boolean,
|
|
28
|
+
* eventDescriptionsNote?: string,
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* Complete mode keeps full tier matrices and never sets `pricingNote`.
|
|
32
|
+
*
|
|
33
|
+
* Simplified mode picks a single tier from each tiered map
|
|
34
|
+
* (requested tier -> FREE -> first entry) and emits `pricingNote` only when
|
|
35
|
+
* the Actor actually has multiple tiers *and* they resolve consistently. The
|
|
36
|
+
* note is omitted for single-tier Actors (the note's "higher tiers may offer
|
|
37
|
+
* lower prices" promise is vacuous) and when PAY_PER_EVENT events resolve
|
|
38
|
+
* to different tiers (no truthful single label).
|
|
39
|
+
*
|
|
40
|
+
* Simplified `PAY_PER_EVENT` also trims long event lists:
|
|
41
|
+
* - `events.length <= 5`: keep event descriptions
|
|
42
|
+
* - `events.length > 5`: omit event descriptions and set
|
|
43
|
+
* `eventDescriptionsOmitted` / `eventDescriptionsNote`
|
|
44
|
+
*
|
|
45
|
+
* Single-tier buckets stay as 1-element `tieredPricing` arrays in both modes.
|
|
46
|
+
* `FREE` or `null` input returns the free text / structured shape.
|
|
47
|
+
*
|
|
48
|
+
* Full examples and contract details are documented inline in this module.
|
|
49
|
+
*/
|
|
1
50
|
import type { ActorRunPricingInfo, PricePerEventActorPricingInfo as PricePerEventActorPricingInfoOutdated } from 'apify-client';
|
|
2
51
|
export type TieredEventPrice = {
|
|
3
52
|
tieredEventPriceUsd: number;
|
|
4
53
|
};
|
|
5
|
-
export
|
|
54
|
+
export declare const PRICING_TIERS: readonly ["FREE", "BRONZE", "SILVER", "GOLD", "PLATINUM", "DIAMOND"];
|
|
55
|
+
export type PricingTier = typeof PRICING_TIERS[number];
|
|
6
56
|
export type ActorChargeEvent = {
|
|
7
57
|
eventTitle: string;
|
|
8
58
|
eventDescription?: string;
|
|
@@ -19,16 +69,20 @@ type PricePerEventActorPricingInfo = PricePerEventActorPricingInfoOutdated & {
|
|
|
19
69
|
actorChargeEvents: Record<string, ActorChargeEvent>;
|
|
20
70
|
};
|
|
21
71
|
};
|
|
22
|
-
export type PricingInfo = ActorRunPricingInfo & {
|
|
72
|
+
export type PricingInfo = (ActorRunPricingInfo & {
|
|
23
73
|
tieredPricing?: TieredPricing;
|
|
24
|
-
} | PricePerEventActorPricingInfo;
|
|
74
|
+
}) | PricePerEventActorPricingInfo;
|
|
25
75
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
76
|
+
* Public structured pricing contract returned by actor cards.
|
|
77
|
+
*
|
|
78
|
+
* `tieredPricing` and event-level `tieredPricing` always use arrays.
|
|
79
|
+
* The difference between modes is array length:
|
|
80
|
+
* - complete mode: full tier matrix
|
|
81
|
+
* - simplified mode: 1 resolved tier
|
|
28
82
|
*/
|
|
29
83
|
export type StructuredPricingInfo = {
|
|
30
84
|
model: string;
|
|
31
|
-
|
|
85
|
+
userTier?: PricingTier;
|
|
32
86
|
pricePerUnit?: number;
|
|
33
87
|
unitName?: string;
|
|
34
88
|
trialMinutes?: number;
|
|
@@ -38,28 +92,25 @@ export type StructuredPricingInfo = {
|
|
|
38
92
|
}[];
|
|
39
93
|
events?: {
|
|
40
94
|
title: string;
|
|
41
|
-
description
|
|
95
|
+
description?: string;
|
|
42
96
|
priceUsd?: number;
|
|
43
97
|
tieredPricing?: {
|
|
44
98
|
tier: string;
|
|
45
99
|
priceUsd: number;
|
|
46
100
|
}[];
|
|
47
101
|
}[];
|
|
102
|
+
pricingNote?: string;
|
|
103
|
+
eventDescriptionsOmitted?: boolean;
|
|
104
|
+
eventDescriptionsNote?: string;
|
|
48
105
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Returns the most recent valid pricing information from a list of pricing infos,
|
|
51
|
-
* based on the provided current date.
|
|
52
|
-
*
|
|
53
|
-
* Filters out pricing infos that have a `startedAt` date in the future or missing,
|
|
54
|
-
* then sorts the remaining infos by `startedAt` in descending order (most recent first).
|
|
55
|
-
* Returns the most recent valid pricing info, or `null` if none are valid.
|
|
56
|
-
*/
|
|
57
106
|
export declare function getCurrentPricingInfo(pricingInfos: PricingInfo[], now: Date): PricingInfo | null;
|
|
107
|
+
/** Complete text contract used by `fetch-actor-details`. */
|
|
58
108
|
export declare function pricingInfoToString(pricingInfo: PricingInfo | null): string;
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
109
|
+
/** Complete structured contract used by `fetch-actor-details`. */
|
|
110
|
+
export declare function pricingInfoToStructured(pricingInfo: PricingInfo | null, userTier: PricingTier): StructuredPricingInfo;
|
|
111
|
+
/** Simplified text contract used by `search-actors`. */
|
|
112
|
+
export declare function pricingInfoToSimplifiedString(pricingInfo: PricingInfo | null, userTier: PricingTier): string;
|
|
113
|
+
/** Simplified structured contract used by `search-actors`. */
|
|
114
|
+
export declare function pricingInfoToSimplifiedStructured(pricingInfo: PricingInfo | null, userTier: PricingTier): StructuredPricingInfo;
|
|
64
115
|
export {};
|
|
65
116
|
//# sourceMappingURL=pricing_info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing_info.d.ts","sourceRoot":"","sources":["../../src/utils/pricing_info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,mBAAmB,EACnB,6BAA6B,IAAI,qCAAqC,EACzE,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,gBAAgB,GAAG;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"pricing_info.d.ts","sourceRoot":"","sources":["../../src/utils/pricing_info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,KAAK,EACR,mBAAmB,EACnB,6BAA6B,IAAI,qCAAqC,EACzE,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,gBAAgB,GAAG;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC/B,CAAC;A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