@apify/actors-mcp-server 0.17.5-beta.0 → 0.17.5-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.
Files changed (137) hide show
  1. package/README.md +7 -2
  2. package/dist/apify_client.d.ts +10 -0
  3. package/dist/apify_client.d.ts.map +1 -1
  4. package/dist/apify_client.js +12 -0
  5. package/dist/apify_client.js.map +1 -1
  6. package/dist/const.d.ts +18 -8
  7. package/dist/const.d.ts.map +1 -1
  8. package/dist/const.js +23 -9
  9. package/dist/const.js.map +1 -1
  10. package/dist/index_internals.d.ts +4 -0
  11. package/dist/index_internals.d.ts.map +1 -1
  12. package/dist/mcp/legacy_server.d.ts.map +1 -1
  13. package/dist/mcp/legacy_server.js +1 -5
  14. package/dist/mcp/legacy_server.js.map +1 -1
  15. package/dist/mcp/stateless_server.js +1 -1
  16. package/dist/mcp/stateless_server.js.map +1 -1
  17. package/dist/mcp/tool_dispatch.d.ts.map +1 -1
  18. package/dist/mcp/tool_dispatch.js +2 -1
  19. package/dist/mcp/tool_dispatch.js.map +1 -1
  20. package/dist/payments/helpers.d.ts +1 -1
  21. package/dist/payments/helpers.d.ts.map +1 -1
  22. package/dist/payments/helpers.js +5 -3
  23. package/dist/payments/helpers.js.map +1 -1
  24. package/dist/resources/api_resources.d.ts +16 -11
  25. package/dist/resources/api_resources.d.ts.map +1 -1
  26. package/dist/resources/api_resources.js +35 -25
  27. package/dist/resources/api_resources.js.map +1 -1
  28. package/dist/state.d.ts +3 -0
  29. package/dist/state.d.ts.map +1 -1
  30. package/dist/state.js +3 -0
  31. package/dist/state.js.map +1 -1
  32. package/dist/test_kit/cases/schedules.cases.d.ts +3 -0
  33. package/dist/test_kit/cases/schedules.cases.d.ts.map +1 -0
  34. package/dist/test_kit/cases/schedules.cases.js +156 -0
  35. package/dist/test_kit/cases/schedules.cases.js.map +1 -0
  36. package/dist/test_kit/cases/storage.cases.d.ts.map +1 -1
  37. package/dist/test_kit/cases/storage.cases.js +39 -0
  38. package/dist/test_kit/cases/storage.cases.js.map +1 -1
  39. package/dist/test_kit/index.d.ts +1 -0
  40. package/dist/test_kit/index.d.ts.map +1 -1
  41. package/dist/test_kit/index.js +3 -0
  42. package/dist/test_kit/index.js.map +1 -1
  43. package/dist/test_kit/tsconfig.tsbuildinfo +1 -1
  44. package/dist/tools/actor_tool_naming.d.ts +4 -0
  45. package/dist/tools/actor_tool_naming.d.ts.map +1 -1
  46. package/dist/tools/actor_tool_naming.js +6 -0
  47. package/dist/tools/actor_tool_naming.js.map +1 -1
  48. package/dist/tools/actors/actor_definition.d.ts.map +1 -1
  49. package/dist/tools/actors/actor_definition.js +3 -5
  50. package/dist/tools/actors/actor_definition.js.map +1 -1
  51. package/dist/tools/actors/actor_executor.d.ts.map +1 -1
  52. package/dist/tools/actors/actor_executor.js +2 -1
  53. package/dist/tools/actors/actor_executor.js.map +1 -1
  54. package/dist/tools/actors/actor_run_response.d.ts +1 -0
  55. package/dist/tools/actors/actor_run_response.d.ts.map +1 -1
  56. package/dist/tools/actors/actor_tools_factory.d.ts.map +1 -1
  57. package/dist/tools/actors/actor_tools_factory.js +30 -3
  58. package/dist/tools/actors/actor_tools_factory.js.map +1 -1
  59. package/dist/tools/actors/search_actors.d.ts +4 -1
  60. package/dist/tools/actors/search_actors.d.ts.map +1 -1
  61. package/dist/tools/actors/search_actors.js +20 -34
  62. package/dist/tools/actors/search_actors.js.map +1 -1
  63. package/dist/tools/api/apify_api_blocklist.d.ts +35 -0
  64. package/dist/tools/api/apify_api_blocklist.d.ts.map +1 -0
  65. package/dist/tools/api/apify_api_blocklist.js +91 -0
  66. package/dist/tools/api/apify_api_blocklist.js.map +1 -0
  67. package/dist/tools/api/apify_api_details.d.ts +6 -0
  68. package/dist/tools/api/apify_api_details.d.ts.map +1 -0
  69. package/dist/tools/api/apify_api_details.js +91 -0
  70. package/dist/tools/api/apify_api_details.js.map +1 -0
  71. package/dist/tools/api/apify_api_path.d.ts +9 -0
  72. package/dist/tools/api/apify_api_path.d.ts.map +1 -0
  73. package/dist/tools/api/apify_api_path.js +11 -0
  74. package/dist/tools/api/apify_api_path.js.map +1 -0
  75. package/dist/tools/api/apify_api_read.d.ts +6 -0
  76. package/dist/tools/api/apify_api_read.d.ts.map +1 -0
  77. package/dist/tools/api/apify_api_read.js +67 -0
  78. package/dist/tools/api/apify_api_read.js.map +1 -0
  79. package/dist/tools/api/apify_api_request.d.ts +59 -0
  80. package/dist/tools/api/apify_api_request.d.ts.map +1 -0
  81. package/dist/tools/api/apify_api_request.js +316 -0
  82. package/dist/tools/api/apify_api_request.js.map +1 -0
  83. package/dist/tools/api/apify_api_search.d.ts +6 -0
  84. package/dist/tools/api/apify_api_search.d.ts.map +1 -0
  85. package/dist/tools/api/apify_api_search.js +84 -0
  86. package/dist/tools/api/apify_api_search.js.map +1 -0
  87. package/dist/tools/api/apify_api_spec.d.ts +51 -0
  88. package/dist/tools/api/apify_api_spec.d.ts.map +1 -0
  89. package/dist/tools/api/apify_api_spec.js +298 -0
  90. package/dist/tools/api/apify_api_spec.js.map +1 -0
  91. package/dist/tools/api/apify_api_write.d.ts +6 -0
  92. package/dist/tools/api/apify_api_write.d.ts.map +1 -0
  93. package/dist/tools/api/apify_api_write.js +129 -0
  94. package/dist/tools/api/apify_api_write.js.map +1 -0
  95. package/dist/tools/index.d.ts.map +1 -1
  96. package/dist/tools/index.js +3 -0
  97. package/dist/tools/index.js.map +1 -1
  98. package/dist/tools/registry.d.ts +3 -0
  99. package/dist/tools/registry.d.ts.map +1 -1
  100. package/dist/tools/registry.js +8 -1
  101. package/dist/tools/registry.js.map +1 -1
  102. package/dist/tools/runs/get_actor_run.d.ts +2 -0
  103. package/dist/tools/runs/get_actor_run.d.ts.map +1 -1
  104. package/dist/tools/runs/get_actor_run.js +11 -3
  105. package/dist/tools/runs/get_actor_run.js.map +1 -1
  106. package/dist/tools/storage/get_dataset.d.ts.map +1 -1
  107. package/dist/tools/storage/get_dataset.js +2 -1
  108. package/dist/tools/storage/get_dataset.js.map +1 -1
  109. package/dist/tools/storage/get_key_value_store.d.ts.map +1 -1
  110. package/dist/tools/storage/get_key_value_store.js +3 -1
  111. package/dist/tools/storage/get_key_value_store.js.map +1 -1
  112. package/dist/tools/structured_output_schemas.d.ts +149 -0
  113. package/dist/tools/structured_output_schemas.d.ts.map +1 -1
  114. package/dist/tools/structured_output_schemas.js +93 -1
  115. package/dist/tools/structured_output_schemas.js.map +1 -1
  116. package/dist/tools/widgets/fetch_actor_details_widget.d.ts.map +1 -1
  117. package/dist/tools/widgets/fetch_actor_details_widget.js +0 -1
  118. package/dist/tools/widgets/fetch_actor_details_widget.js.map +1 -1
  119. package/dist/tools/widgets/search_actors_widget.d.ts.map +1 -1
  120. package/dist/tools/widgets/search_actors_widget.js +0 -1
  121. package/dist/tools/widgets/search_actors_widget.js.map +1 -1
  122. package/dist/tsconfig.tsbuildinfo +1 -1
  123. package/dist/types.d.ts +11 -0
  124. package/dist/types.d.ts.map +1 -1
  125. package/dist/types.js.map +1 -1
  126. package/dist/utils/logging.d.ts +6 -0
  127. package/dist/utils/logging.d.ts.map +1 -1
  128. package/dist/utils/logging.js +22 -6
  129. package/dist/utils/logging.js.map +1 -1
  130. package/dist/utils/server-instructions/index.d.ts.map +1 -1
  131. package/dist/utils/server-instructions/index.js +4 -1
  132. package/dist/utils/server-instructions/index.js.map +1 -1
  133. package/dist/utils/tools.d.ts +0 -3
  134. package/dist/utils/tools.d.ts.map +1 -1
  135. package/dist/utils/tools.js +7 -16
  136. package/dist/utils/tools.js.map +1 -1
  137. package/package.json +2 -6
@@ -0,0 +1,91 @@
1
+ import dedent from 'dedent';
2
+ import { z } from 'zod';
3
+ import { HELPER_TOOLS } from '../../const.js';
4
+ import { ALL_TOOLS_PRESENT, TOOL_TYPE } from '../../types.js';
5
+ import { compileSchema } from '../../utils/ajv.js';
6
+ import { respondOk, respondUserError } from '../../utils/mcp.js';
7
+ import { apifyApiDetailsOutputSchema } from '../structured_output_schemas.js';
8
+ import { normalizeApiPath } from './apify_api_path.js';
9
+ import { findPathOperations, formatApiPath, formatList, redactApiCallArgs } from './apify_api_request.js';
10
+ import { API_METHODS, fetchApiOperationIndex } from './apify_api_spec.js';
11
+ const apifyApiDetailsArgs = z.object({
12
+ path: z
13
+ .string()
14
+ .min(1)
15
+ .describe('The API path, as a template such as /v2/datasets/{datasetId} or with its values in it, ' +
16
+ 'such as /v2/datasets/abc. datasets/abc, v2/datasets/abc, and /v2/datasets/abc are the same.'),
17
+ method: z
18
+ .enum(API_METHODS)
19
+ .optional()
20
+ .describe('HTTP method of the operation. Omit it to get every operation on the path.'),
21
+ });
22
+ function buildDescription({ hasTool }) {
23
+ const findPath = hasTool(HELPER_TOOLS.API_SEARCH) ? ` Find the path with ${HELPER_TOOLS.API_SEARCH}.` : '';
24
+ return dedent `
25
+ Get the Apify API operations on a path: for each method, its description, path and query
26
+ parameters, and the JSON schema of its request body.${findPath}
27
+ Give a method to get only that operation, for example {"path": "/v2/datasets/abc", "method": "PUT"}.
28
+
29
+ USAGE:
30
+ - Use before calling an operation, to pass the right parameters and body.
31
+
32
+ USAGE EXAMPLES:
33
+ - user_input: What parameters does the dataset items operation take?
34
+ - user_input: How do I update a webhook through the API?
35
+ `;
36
+ }
37
+ /**
38
+ * Returns the operations on one path of the published Apify API spec, https://docs.apify.com/api/v2.
39
+ */
40
+ export const apifyApiDetails = Object.freeze({
41
+ type: TOOL_TYPE.INTERNAL,
42
+ name: HELPER_TOOLS.API_DETAILS,
43
+ title: 'Get Apify API operation details',
44
+ description: buildDescription(ALL_TOOLS_PRESENT),
45
+ buildDescription,
46
+ inputSchema: z.toJSONSchema(apifyApiDetailsArgs),
47
+ outputSchema: apifyApiDetailsOutputSchema,
48
+ ajvValidate: compileSchema(z.toJSONSchema(apifyApiDetailsArgs)),
49
+ annotations: {
50
+ title: 'Get Apify API operation details',
51
+ readOnlyHint: true,
52
+ destructiveHint: false,
53
+ idempotentHint: true,
54
+ openWorldHint: false,
55
+ },
56
+ // A pasted path can hold a query such as ?token=.
57
+ redactArgs: redactApiCallArgs,
58
+ call: async (toolArgs) => {
59
+ const parsed = apifyApiDetailsArgs.parse(toolArgs.args);
60
+ const index = await fetchApiOperationIndex();
61
+ const normalizedPath = normalizeApiPath(parsed.path);
62
+ const path = formatApiPath(normalizedPath);
63
+ const matched = findPathOperations(index, normalizedPath);
64
+ if (matched.length === 0) {
65
+ const next = toolArgs.loadedToolNames.includes(HELPER_TOOLS.API_SEARCH)
66
+ ? ` Find the path with ${HELPER_TOOLS.API_SEARCH}.`
67
+ : '';
68
+ return respondUserError(`The path ${path} is not in the API spec. A name is written username~name, or ~name for one ` +
69
+ `you own, as in /v2/actors/~my-actor.${next}`);
70
+ }
71
+ const operations = parsed.method ? matched.filter((operation) => operation.method === parsed.method) : matched;
72
+ if (operations.length === 0) {
73
+ const noun = matched.length === 1 ? 'method' : 'methods';
74
+ const methods = formatList(matched.map((operation) => operation.method), 'and');
75
+ return respondUserError(`The path ${path} has no ${parsed.method} operation; it matches ${noun} ${methods}.`);
76
+ }
77
+ const result = {
78
+ operations: operations.map((operation) => ({
79
+ method: operation.method,
80
+ path: operation.path,
81
+ summary: operation.summary,
82
+ description: operation.description,
83
+ parameters: operation.parameters,
84
+ ...(operation.requestBody && { requestBody: operation.requestBody }),
85
+ })),
86
+ };
87
+ const summary = `${operations[0].path}: ${operations.map((operation) => operation.method).join(', ')}.`;
88
+ return respondOk([JSON.stringify(result), summary], { structuredContent: result });
89
+ },
90
+ });
91
+ //# sourceMappingURL=apify_api_details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_details.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api_details.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,iBA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2/actors` becomes `actors`. */
2
+ export declare function normalizeApiPath(path: string): string;
3
+ /**
4
+ * Legacy names of top-level API resources, mapped to the name the spec lists. The API serves `acts`, which
5
+ * apify-client and the CLI still send, as `actors`. A `Map`, so a name such as `constructor` never matches an
6
+ * inherited object property.
7
+ */
8
+ export declare const API_RESOURCE_ALIASES: ReadonlyMap<string, string>;
9
+ //# sourceMappingURL=apify_api_path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_path.d.ts","sourceRoot":"","sources":["../../../src/tools/api/apify_api_path.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAiC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** A path without its leading slash and `v2/` prefix, as `apify api` takes it: `/v2/actors` becomes `actors`. */
2
+ export function normalizeApiPath(path) {
3
+ return path.replace(/^\//, '').replace(/^v2\//i, '');
4
+ }
5
+ /**
6
+ * Legacy names of top-level API resources, mapped to the name the spec lists. The API serves `acts`, which
7
+ * apify-client and the CLI still send, as `actors`. A `Map`, so a name such as `constructor` never matches an
8
+ * inherited object property.
9
+ */
10
+ export const API_RESOURCE_ALIASES = new Map([['acts', 'actors']]);
11
+ //# sourceMappingURL=apify_api_path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_path.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api_path.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgC,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ToolEntry } from '../../types.js';
2
+ /**
3
+ * Sends a GET to a path of the Apify API, https://docs.apify.com/api/v2, as a proxy.
4
+ */
5
+ export declare const apifyApiRead: ToolEntry;
6
+ //# sourceMappingURL=apify_api_read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_read.d.ts","sourceRoot":"","sources":["../../../src/tools/api/apify_api_read.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4C,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAgC3G;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,SA+BhB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import dedent from 'dedent';
2
+ import { z } from 'zod';
3
+ import { HELPER_TOOLS, MAX_INLINE_BYTES } from '../../const.js';
4
+ import { ALL_TOOLS_PRESENT, TOOL_TYPE } from '../../types.js';
5
+ import { compileSchema } from '../../utils/ajv.js';
6
+ import { apifyApiCallOutputSchema } from '../structured_output_schemas.js';
7
+ import { API_CALL_DESCRIPTION, apiCallArgsShape, callApi, redactApiCallArgs } from './apify_api_request.js';
8
+ const apifyApiReadArgs = z.object(apiCallArgsShape);
9
+ function buildDescription({ hasTool }) {
10
+ const findPath = hasTool(HELPER_TOOLS.API_SEARCH) ? `\nFind the path with ${HELPER_TOOLS.API_SEARCH}.` : '';
11
+ const getParameters = hasTool(HELPER_TOOLS.API_DETAILS)
12
+ ? `\nGet the operation's query parameters first with ${HELPER_TOOLS.API_DETAILS} and method GET.`
13
+ : '';
14
+ const runActor = hasTool(HELPER_TOOLS.ACTOR_CALL) ? ` Run an Actor with ${HELPER_TOOLS.ACTOR_CALL}.` : '';
15
+ return dedent `
16
+ Send a GET request to the Apify API at a path, such as /v2/actor-runs/abc.
17
+ A GET can start a paid Actor run, as the synchronous run endpoints do.${runActor}
18
+ ${API_CALL_DESCRIPTION}${findPath}${getParameters}
19
+ Returns the parsed response body, JSON with its data wrapper included: integers above 2^53 can
20
+ lose precision. A body over ${MAX_INLINE_BYTES} bytes is not returned.
21
+
22
+ Example call: {"path": "/v2/webhook-dispatches", "query": {"limit": 10, "desc": true}}
23
+
24
+ USAGE:
25
+ - Use for data no dedicated tool returns, such as webhooks, usage, and limits.
26
+
27
+ USAGE EXAMPLES:
28
+ - user_input: List the webhooks on my account
29
+ - user_input: How much of my monthly usage have I spent?
30
+ `;
31
+ }
32
+ /**
33
+ * Sends a GET to a path of the Apify API, https://docs.apify.com/api/v2, as a proxy.
34
+ */
35
+ export const apifyApiRead = Object.freeze({
36
+ type: TOOL_TYPE.INTERNAL,
37
+ name: HELPER_TOOLS.API_READ,
38
+ title: 'Read Apify API',
39
+ description: buildDescription(ALL_TOOLS_PRESENT),
40
+ buildDescription,
41
+ inputSchema: z.toJSONSchema(apifyApiReadArgs),
42
+ outputSchema: apifyApiCallOutputSchema,
43
+ ajvValidate: compileSchema(z.toJSONSchema(apifyApiReadArgs)),
44
+ annotations: {
45
+ title: 'Read Apify API',
46
+ // A GET can start a run, such as a synchronous run of an Actor or task.
47
+ readOnlyHint: false,
48
+ destructiveHint: false,
49
+ idempotentHint: false,
50
+ openWorldHint: true,
51
+ },
52
+ // A storage signature, or the webhooks of a synchronous run, would otherwise be logged.
53
+ redactArgs: redactApiCallArgs,
54
+ call: async (toolArgs) => {
55
+ const parsed = apifyApiReadArgs.parse(toolArgs.args);
56
+ return callApi({
57
+ client: toolArgs.apifyClient,
58
+ token: toolArgs.apifyToken,
59
+ method: 'GET',
60
+ path: parsed.path,
61
+ query: parsed.query,
62
+ signal: toolArgs.signal,
63
+ loadedToolNames: toolArgs.loadedToolNames,
64
+ });
65
+ },
66
+ });
67
+ //# sourceMappingURL=apify_api_read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_read.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api_read.ts"],"names":[],"mappings":"AAAA,OAAO,M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IAC3B,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;IAChD,gBAAgB;IAChB,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAoB;IAChE,YAAY,EAAE,wBAAwB;IACtC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC5D,WAAW,EAAE;QACT,KAAK,EAAE,gBAAgB;QACvB,wEAAwE;QACxE,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,IAAI;KACtB;IACD,wFAAwF;IACxF,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,KAAK,EAAE,QAA0B,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,OAAO,CAAC;YACX,MAAM,EAAE,QAAQ,CAAC,WAAW;YAC5B,KAAK,EAAE,QAAQ,CAAC,UAAU;YAC1B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,eAAe,EAAE,QAAQ,CAAC,eAAe;SAC5C,CAAC,CAAC;IACP,CAAC;CACK,CAAC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import type { ApifyClient } from '../../apify_client.js';
3
+ import type { ToolResponse } from '../../utils/mcp.js';
4
+ import type { ApiMethod, ApiOperation } from './apify_api_spec.js';
5
+ /** Input fields the read and write tools share. */
6
+ export declare const apiCallArgsShape: {
7
+ path: z.ZodString;
8
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
9
+ };
10
+ /** The shared description lines of the read and write tools. */
11
+ export declare const API_CALL_DESCRIPTION = "A proxy to the Apify API, like apify api in the Apify CLI; the server adds the host and the API token.\nWrite the path as actors, v2/actors, or /v2/actors, with its values in it.\nA name is written username~name, or ~name for one you own, as in /v2/actors/~my-actor.\nSynchronous runs, and waitForFinish above 45 seconds, outlast the usual 60-second tool-call timeout,\nso prefer asynchronous runs.";
12
+ /**
13
+ * The logged copy of an API tool call's arguments (`redactArgs`), built as an allowlist. Secret query
14
+ * values, a query written into the path, the body, and a path or query of the wrong type are logged
15
+ * only as a marker. The body can carry environment variable values, webhook headers, or stored records.
16
+ */
17
+ export declare function redactApiCallArgs({ path, method, query, body }: Record<string, unknown>): {
18
+ body?: string | undefined;
19
+ path: unknown;
20
+ method: unknown;
21
+ query: unknown;
22
+ };
23
+ /** A normalized path as the tools report it, with the `/v2/` prefix. */
24
+ export declare function formatApiPath(normalizedPath: string): string;
25
+ /**
26
+ * The operations on the one path template a normalized path, with values or as a template, matches. When
27
+ * several match, the one with more literal segments wins, so `request-queues/x/requests/batch` is the
28
+ * batch operation, not a request with the ID `batch`.
29
+ */
30
+ export declare function findPathOperations(index: Map<string, ApiOperation>, normalizedPath: string): ApiOperation[];
31
+ /**
32
+ * Up to five path templates closest to a normalized path, best first, scored as the Apify CLI's
33
+ * `findClosestEndpoints`.
34
+ */
35
+ export declare function findClosestApiPaths(index: Map<string, ApiOperation>, normalizedPath: string): string[];
36
+ /** Words in a sentence, with an Oxford comma: `GET, PUT, and DELETE`. */
37
+ export declare function formatList(words: readonly string[], conjunction: 'and' | 'or'): string;
38
+ /**
39
+ * Sends one request to an API path and returns the response body, like `apify api` in the Apify CLI.
40
+ * The URL is the client's base URL and the normalized path, not encoded again, with `query` added.
41
+ * It sends, with a write's JSON body, through `sendApifyApiRequest` (one attempt, response body capped at
42
+ * `MAX_INLINE_BYTES`) and throws a non-2xx response as apify-client's `ApifyApiError`, so it gets the
43
+ * usual tool error text and telemetry.
44
+ */
45
+ export declare function callApi(params: {
46
+ client: ApifyClient;
47
+ /** The session's token, masked in the response. */
48
+ token?: string;
49
+ method: ApiMethod;
50
+ path: string;
51
+ query?: Record<string, string | number | boolean>;
52
+ /** JSON request body; only the write tool sends one. */
53
+ body?: unknown;
54
+ /** Aborts the request when the client cancels the tool call. */
55
+ signal?: AbortSignal;
56
+ /** The session's tools, so a refusal or a too-large log names only tools the session has. */
57
+ loadedToolNames: readonly string[];
58
+ }): Promise<ToolResponse>;
59
+ //# sourceMappingURL=apify_api_request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_request.d.ts","sourceRoot":"","sources":["../../../src/tools/api/apify_api_request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnE,mDAAmD;AACnD,eAAO,MAAM,gBAAgB;;;CAa5B,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,mZAIJ,CAAC;AAK9B;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;EAkBvF;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE5D;AA+BD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,MAAM,GAAG,YAAY,EAAE,CAe3G;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBtG;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM,CAGtF;AAqFD;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gEAAgE;IAChE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,6FAA6F;IAC7F,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,GAAG,OAAO,CAAC,YAAY,CAAC,CAsFxB"}
@@ -0,0 +1,316 @@
1
+ import { setTimeout as sleep } from 'node:timers/promises';
2
+ import { ApifyApiError } from 'apify-client';
3
+ import { isAxiosError } from 'axios';
4
+ import { z } from 'zod';
5
+ import { sendApifyApiRequest } from '../../apify_client.js';
6
+ import { APIFY_ERROR_TYPE_PAGE_NOT_FOUND, HELPER_TOOLS, MAX_INLINE_BYTES } from '../../const.js';
7
+ import { isApifyApiUri, isMaxContentLengthAbort, maskSessionToken, REDACTED, redactUrlSigningSecretKey, } from '../../resources/api_resources.js';
8
+ import { toPlainError } from '../../utils/logging.js';
9
+ import { getHttpErrorHint, respondAborted, respondOk, respondUserError } from '../../utils/mcp.js';
10
+ import { WAIT_SECS_MAX } from '../actors/actor_run_response.js';
11
+ import { validateApiBlocklist } from './apify_api_blocklist.js';
12
+ import { API_RESOURCE_ALIASES, normalizeApiPath } from './apify_api_path.js';
13
+ import { fetchApiOperationIndex, isRecord } from './apify_api_spec.js';
14
+ /** Input fields the read and write tools share. */
15
+ export const apiCallArgsShape = {
16
+ path: z
17
+ .string()
18
+ .min(1)
19
+ .describe('The API path with its values in it: actors, v2/actors, and /v2/actors are the same. A name is ' +
20
+ 'written username~name, or ~name for one you own, as in /v2/actors/~my-actor. ' +
21
+ 'A query string written into the path is sent too.'),
22
+ query: z
23
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
24
+ .optional()
25
+ .describe('Query parameters, by name, for example {"limit": 10}. Added to a query string in the path.'),
26
+ };
27
+ /** The shared description lines of the read and write tools. */
28
+ export const API_CALL_DESCRIPTION = `A proxy to the Apify API, like apify api in the Apify CLI; the server adds the host and the API token.
29
+ Write the path as actors, v2/actors, or /v2/actors, with its values in it.
30
+ A name is written username~name, or ~name for one you own, as in /v2/actors/~my-actor.
31
+ Synchronous runs, and waitForFinish above ${WAIT_SECS_MAX} seconds, outlast the usual 60-second tool-call timeout,
32
+ so prefer asynchronous runs.`;
33
+ /** Query parameters whose values grant access or carry secrets; `webhooks` can hold webhook headers. */
34
+ const SECRET_QUERY_PARAMS = ['token', 'signature', 'webhooks'];
35
+ /**
36
+ * The logged copy of an API tool call's arguments (`redactArgs`), built as an allowlist. Secret query
37
+ * values, a query written into the path, the body, and a path or query of the wrong type are logged
38
+ * only as a marker. The body can carry environment variable values, webhook headers, or stored records.
39
+ */
40
+ export function redactApiCallArgs({ path, method, query, body }) {
41
+ let loggedQuery;
42
+ if (isRecord(query)) {
43
+ loggedQuery = Object.fromEntries(Object.entries(query).map(([name, value]) => [name, SECRET_QUERY_PARAMS.includes(name) ? REDACTED : value]));
44
+ }
45
+ else if (query !== undefined) {
46
+ loggedQuery = REDACTED;
47
+ }
48
+ let loggedPath;
49
+ if (typeof path === 'string')
50
+ loggedPath = path.replace(/[?#][\s\S]*$/, `?${REDACTED}`);
51
+ else if (path !== undefined)
52
+ loggedPath = REDACTED;
53
+ return {
54
+ path: loggedPath,
55
+ method,
56
+ query: loggedQuery,
57
+ ...(body !== undefined && { body: REDACTED }),
58
+ };
59
+ }
60
+ /** A normalized path as the tools report it, with the `/v2/` prefix. */
61
+ export function formatApiPath(normalizedPath) {
62
+ return `/v2/${normalizedPath}`;
63
+ }
64
+ /** A path without the query string or fragment written into it. */
65
+ function stripQuery(path) {
66
+ return path.replace(/[?#][\s\S]*$/, '');
67
+ }
68
+ /** A normalized path as the spec lists it: without its query, and with a legacy resource name replaced. */
69
+ function toSpecPath(normalizedPath) {
70
+ var _a;
71
+ const [resource, ...rest] = stripQuery(normalizedPath).split('/');
72
+ return [(_a = API_RESOURCE_ALIASES.get(resource)) !== null && _a !== void 0 ? _a : resource, ...rest].join('/');
73
+ }
74
+ const PATH_PARAMETER_SEGMENT_REGEX = /^\{[^{}]+\}$/;
75
+ /** How many literal segments of the template match the path segments, or `undefined` when it does not match. */
76
+ function countMatchingLiterals(template, segments) {
77
+ const templateSegments = normalizeApiPath(template).split('/');
78
+ if (templateSegments.length !== segments.length)
79
+ return undefined;
80
+ let literalCount = 0;
81
+ for (const [position, templateSegment] of templateSegments.entries()) {
82
+ if (PATH_PARAMETER_SEGMENT_REGEX.test(templateSegment)) {
83
+ if (!segments[position])
84
+ return undefined;
85
+ continue;
86
+ }
87
+ if (templateSegment !== segments[position])
88
+ return undefined;
89
+ literalCount += 1;
90
+ }
91
+ return literalCount;
92
+ }
93
+ /**
94
+ * The operations on the one path template a normalized path, with values or as a template, matches. When
95
+ * several match, the one with more literal segments wins, so `request-queues/x/requests/batch` is the
96
+ * batch operation, not a request with the ID `batch`.
97
+ */
98
+ export function findPathOperations(index, normalizedPath) {
99
+ const segments = toSpecPath(normalizedPath).split('/');
100
+ let bestLiteralCount = -1;
101
+ let operations = [];
102
+ for (const operation of index.values()) {
103
+ const literalCount = countMatchingLiterals(operation.path, segments);
104
+ if (literalCount === undefined || literalCount < bestLiteralCount)
105
+ continue;
106
+ if (literalCount > bestLiteralCount) {
107
+ bestLiteralCount = literalCount;
108
+ operations = [operation];
109
+ }
110
+ else if (operation.path === operations[0].path) {
111
+ operations.push(operation);
112
+ }
113
+ }
114
+ return operations;
115
+ }
116
+ /**
117
+ * Up to five path templates closest to a normalized path, best first, scored as the Apify CLI's
118
+ * `findClosestEndpoints`.
119
+ */
120
+ export function findClosestApiPaths(index, normalizedPath) {
121
+ const input = toSpecPath(normalizedPath).toLowerCase();
122
+ const inputSegments = input.split('/').filter(Boolean);
123
+ const scores = new Map();
124
+ for (const template of new Set([...index.values()].map((operation) => operation.path))) {
125
+ const candidate = normalizeApiPath(template).toLowerCase();
126
+ let score = candidate.includes(input) || input.includes(candidate) ? 10 : 0;
127
+ const segments = candidate.split('/').filter(Boolean);
128
+ for (let position = 0; position < Math.min(inputSegments.length, segments.length); position++) {
129
+ if (segments[position] === inputSegments[position])
130
+ score += 2;
131
+ else if (segments[position].startsWith('{'))
132
+ score += 1;
133
+ }
134
+ if (segments.length === inputSegments.length)
135
+ score += 1;
136
+ if (score > 0)
137
+ scores.set(template, score);
138
+ }
139
+ return [...scores]
140
+ .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
141
+ .slice(0, 5)
142
+ .map(([template]) => template);
143
+ }
144
+ /** Words in a sentence, with an Oxford comma: `GET, PUT, and DELETE`. */
145
+ export function formatList(words, conjunction) {
146
+ if (words.length <= 2)
147
+ return words.join(` ${conjunction} `);
148
+ return `${words.slice(0, -1).join(', ')}, ${conjunction} ${words.at(-1)}`;
149
+ }
150
+ /** How long a hint waits for the spec, so a stalled download does not hold back the API's answer. */
151
+ const HINT_SPEC_TIMEOUT_MS = 5000;
152
+ /**
153
+ * The index, or `undefined` when the spec cannot be loaded within a few seconds or the call is
154
+ * cancelled; for the hints that only help.
155
+ */
156
+ async function fetchApiOperationIndexIfAvailable(signal) {
157
+ return Promise.race([
158
+ fetchApiOperationIndex(),
159
+ sleep(HINT_SPEC_TIMEOUT_MS, undefined, { signal, ref: false }),
160
+ ]).catch(() => undefined);
161
+ }
162
+ /** Query parameters that make a response smaller. */
163
+ const NARROWING_QUERY_PARAMS = ['limit', 'offset', 'fields', 'omit'];
164
+ /** The dedicated tool that returns the end of a log too large for the API tools, when the session has it. */
165
+ function findLogToolName(path, loadedToolNames) {
166
+ if (!/\/log$|^\/v2\/logs\//.test(path))
167
+ return undefined;
168
+ const toolName = path.startsWith('/v2/actor-builds/') ? HELPER_TOOLS.ACTOR_BUILD_LOG : HELPER_TOOLS.ACTOR_RUNS_LOG;
169
+ return loadedToolNames.includes(toolName) ? toolName : undefined;
170
+ }
171
+ /**
172
+ * The message of a response over the inline limit. It names the parameters that narrow the response
173
+ * when the path matches an operation of the spec that declares them.
174
+ */
175
+ async function formatOversizeMessage({ method, normalizedPath, loadedToolNames, signal, }) {
176
+ var _a;
177
+ const path = formatApiPath(normalizedPath);
178
+ const message = `The response of ${method} ${path} is larger than ${MAX_INLINE_BYTES} bytes, so it is not returned.`;
179
+ if (method !== 'GET')
180
+ return `${message} The request itself was sent; check its effect with a GET.`;
181
+ const index = await fetchApiOperationIndexIfAvailable(signal);
182
+ const operation = index && findPathOperations(index, normalizedPath).find((match) => match.method === method);
183
+ const narrowingNames = ((_a = operation === null || operation === void 0 ? void 0 : operation.parameters) !== null && _a !== void 0 ? _a : [])
184
+ .filter((parameter) => parameter.in === 'query' && NARROWING_QUERY_PARAMS.includes(parameter.name))
185
+ .map((parameter) => parameter.name);
186
+ if (narrowingNames.length > 0) {
187
+ return `${message} Narrow the request with the ${formatList(narrowingNames, 'or')} query parameter.`;
188
+ }
189
+ const logToolName = findLogToolName(stripQuery(path), loadedToolNames);
190
+ return logToolName ? `${message} Get the end of the log with ${logToolName} instead.` : message;
191
+ }
192
+ /** The status of a response axios aborted mid-body; Node's request object keeps the response it got. */
193
+ function readAbortedResponseStatus(error) {
194
+ const request = isAxiosError(error) ? error.request : undefined;
195
+ const statusCode = isRecord(request) && isRecord(request.res) ? request.res.statusCode : undefined;
196
+ return typeof statusCode === 'number' ? statusCode : undefined;
197
+ }
198
+ /** Adds the spec's closest paths to the message of a page-not-found error, when the spec is available. */
199
+ async function addClosestPaths(error, normalizedPath, signal) {
200
+ const index = await fetchApiOperationIndexIfAvailable(signal);
201
+ const paths = index ? findClosestApiPaths(index, normalizedPath) : [];
202
+ if (paths.length === 0)
203
+ return;
204
+ error.message = `${error.message.replace(/([^.!?])$/, '$1.')} The closest paths in the API spec: ${paths.join(', ')}`;
205
+ }
206
+ /**
207
+ * A copy of a response body with the session's token replaced, since a response can echo it, as
208
+ * `GET /v2/browser-info` echoes the request headers. A binary body is masked too: apify-client copies a
209
+ * Buffer error body into the message.
210
+ */
211
+ function maskToken(data, token) {
212
+ if (!token || data === undefined)
213
+ return data;
214
+ if (Buffer.isBuffer(data))
215
+ return maskSessionToken(data, token);
216
+ const text = JSON.stringify(data);
217
+ // The token as it appears inside a JSON string.
218
+ const escapedToken = JSON.stringify(token).slice(1, -1);
219
+ return text.includes(escapedToken) ? JSON.parse(text.replaceAll(escapedToken, REDACTED)) : data;
220
+ }
221
+ /**
222
+ * Sends one request to an API path and returns the response body, like `apify api` in the Apify CLI.
223
+ * The URL is the client's base URL and the normalized path, not encoded again, with `query` added.
224
+ * It sends, with a write's JSON body, through `sendApifyApiRequest` (one attempt, response body capped at
225
+ * `MAX_INLINE_BYTES`) and throws a non-2xx response as apify-client's `ApifyApiError`, so it gets the
226
+ * usual tool error text and telemetry.
227
+ */
228
+ export async function callApi(params) {
229
+ var _a;
230
+ const { client, method } = params;
231
+ const normalizedPath = normalizeApiPath(params.path);
232
+ const refusal = validateApiBlocklist({
233
+ method,
234
+ normalizedPath,
235
+ query: params.query,
236
+ loadedToolNames: params.loadedToolNames,
237
+ });
238
+ if (refusal)
239
+ return respondUserError(refusal);
240
+ const path = formatApiPath(normalizedPath);
241
+ // `client.baseUrl` already ends with /v2.
242
+ const url = `${client.baseUrl}/${normalizedPath}`;
243
+ // An assertion: nothing after the base URL can change the host that gets the token.
244
+ if (!isApifyApiUri(url))
245
+ throw new Error(`The URL ${url} is not on the API host.`);
246
+ let response;
247
+ try {
248
+ response = await sendApifyApiRequest(client, {
249
+ url,
250
+ method,
251
+ params: params.query,
252
+ // Serialized here: axios would send a string as a form and refuse a number. With only the JSON
253
+ // header, a JSON-looking string would reach the API as the object it holds.
254
+ ...(params.body !== undefined && {
255
+ data: JSON.stringify(params.body),
256
+ headers: { 'Content-Type': 'application/json' },
257
+ }),
258
+ signal: params.signal,
259
+ });
260
+ }
261
+ catch (error) {
262
+ // A cancelled call is not a tool error.
263
+ if ((_a = params.signal) === null || _a === void 0 ? void 0 : _a.aborted)
264
+ return respondAborted();
265
+ if (!isMaxContentLengthAbort(error))
266
+ throw toPlainError(error);
267
+ const statusCode = method === 'GET' ? undefined : readAbortedResponseStatus(error);
268
+ if (statusCode === undefined) {
269
+ return respondUserError(await formatOversizeMessage({
270
+ method,
271
+ normalizedPath,
272
+ loadedToolNames: params.loadedToolNames,
273
+ signal: params.signal,
274
+ }));
275
+ }
276
+ // A write has applied by the time its response arrives, so a large response is not a failure.
277
+ if (statusCode < 300) {
278
+ const structuredContent = { method, path, statusCode, data: null };
279
+ const summary = `${method} ${path} returned HTTP ${statusCode}. The response is larger than ` +
280
+ `${MAX_INLINE_BYTES} bytes, so it is not returned; check the result with a GET.`;
281
+ return respondOk([JSON.stringify(structuredContent), summary], { structuredContent });
282
+ }
283
+ // The status says the write failed; the generic message would say it may have applied.
284
+ const hint = getHttpErrorHint(statusCode);
285
+ return respondUserError(`${method} ${path} failed with HTTP ${statusCode}. Its error body is larger than ` +
286
+ `${MAX_INLINE_BYTES} bytes, so it is not returned.${hint ? ` ${hint}` : ''}`);
287
+ }
288
+ const data = maskToken(response.data, params.token);
289
+ if (response.status >= 300) {
290
+ // Without the query in the path: apify-client puts the URL into the error, and a 5xx error is logged.
291
+ const error = new ApifyApiError({ ...response, data, config: { ...response.config, url: stripQuery(url) } }, 1);
292
+ if (error.type === APIFY_ERROR_TYPE_PAGE_NOT_FOUND)
293
+ await addClosestPaths(error, normalizedPath, params.signal);
294
+ throw error;
295
+ }
296
+ const contentTypeHeader = response.headers['content-type'];
297
+ const contentType = typeof contentTypeHeader === 'string' ? contentTypeHeader : undefined;
298
+ // apify-client parses JSON and text bodies; a binary body stays a Buffer and is not returned.
299
+ const isBinary = Buffer.isBuffer(data);
300
+ const structuredContent = {
301
+ method,
302
+ path,
303
+ statusCode: response.status,
304
+ ...(contentType && { contentType }),
305
+ data: isBinary || data === undefined ? null : data,
306
+ };
307
+ const summary = isBinary
308
+ ? `${method} ${path} returned HTTP ${response.status} with a binary body ` +
309
+ `(${contentType !== null && contentType !== void 0 ? contentType : 'no Content-Type'}, ${data.length} bytes), which is not shown.`
310
+ : `${method} ${path} returned HTTP ${response.status}.`;
311
+ // A text body is an escaped JSON string here, so it never matches.
312
+ const json = JSON.stringify(structuredContent);
313
+ const text = redactUrlSigningSecretKey(json);
314
+ return respondOk([text, summary], { structuredContent: text === json ? structuredContent : JSON.parse(text) });
315
+ }
316
+ //# sourceMappingURL=apify_api_request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_request.js","sourceRoot":"","sources":["../../../src/tools/api/apify_api_request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACH,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,QAAQ,EACR,yBAAyB,GAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,gBAA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AAC"}
@@ -0,0 +1,6 @@
1
+ import type { ToolEntry } from '../../types.js';
2
+ /**
3
+ * Searches the operations of the published Apify API spec, https://docs.apify.com/api/v2.
4
+ */
5
+ export declare const apifyApiSearch: ToolEntry;
6
+ //# sourceMappingURL=apify_api_search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apify_api_search.d.ts","sourceRoot":"","sources":["../../../src/tools/api/apify_api_search.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4C,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAiD3G;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,SAgClB,CAAC"}