
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6d0a4c28-efd5-5acc-9aad-63d8a9ad444e")}catch(e){}}();
import { z } from 'zod';
import { HelperTools } from '../../const.js';
import { compileSchema } from '../../utils/ajv.js';
const GetRunLogArgs = z.object({
    runId: z.string().describe('The ID of the Actor run.'),
    lines: z.number()
        .max(50)
        .describe('Output the last NUM lines, instead of the last 10')
        .default(10),
});
/**
 * https://docs.apify.com/api/v2/actor-run-get
 *  /v2/actor-runs/{runId}/log{?token}
 */
export const getActorRunLog = Object.freeze({
    type: 'internal',
    name: HelperTools.ACTOR_RUNS_LOG,
    description: `Retrieve recent log lines for a specific Actor run.
The results will include the last N lines of the run's log output (plain text).

USAGE:
- Use when you need to inspect recent logs to debug or monitor a run.

USAGE EXAMPLES:
- user_input: Show last 20 lines of logs for run y2h7sK3Wc
- user_input: Get logs for run y2h7sK3Wc`,
    inputSchema: z.toJSONSchema(GetRunLogArgs),
    // It does not make sense to add structured output here since the log API just returns plain text
    ajvValidate: compileSchema(z.toJSONSchema(GetRunLogArgs)),
    paymentRequired: true,
    annotations: {
        title: 'Get Actor run log',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false,
    },
    call: async (toolArgs) => {
        var _a;
        const { args, apifyClient: client } = toolArgs;
        const parsed = GetRunLogArgs.parse(args);
        const v = (_a = await client.run(parsed.runId).log().get()) !== null && _a !== void 0 ? _a : '';
        const lines = v.split('\n');
        const text = lines.slice(lines.length - parsed.lines - 1, lines.length).join('\n');
        return { content: [{ type: 'text', text }] };
    },
});
//# sourceMappingURL=get_actor_run_log.js.map
//# debugId=6d0a4c28-efd5-5acc-9aad-63d8a9ad444e
