diff --git a/packages/cli-v3/src/entryPoints/managed/controller.ts b/packages/cli-v3/src/entryPoints/managed/controller.ts index a459ccc7b..3c7ab6c5e 100644 --- a/packages/cli-v3/src/entryPoints/managed/controller.ts +++ b/packages/cli-v3/src/entryPoints/managed/controller.ts @@ -8,7 +8,7 @@ import { } from "@trigger.dev/core/v3/workers"; import { io, type Socket } from "socket.io-client"; import { RunnerEnv } from "./env.js"; -import { RunLogger, SendDebugLogOptions } from "./logger.js"; +import { ManagedRunLogger, RunLogger, SendDebugLogOptions } from "./logger.js"; import { EnvObject } from "std-env"; import { RunExecution } from "./execution.js"; import { tryCatch } from "@trigger.dev/core/utils"; @@ -47,7 +47,7 @@ export class ManagedRunController { projectRef: env.TRIGGER_PROJECT_REF, }); - this.logger = new RunLogger({ + this.logger = new ManagedRunLogger({ httpClient: this.httpClient, env, }); diff --git a/packages/cli-v3/src/entryPoints/managed/logger.ts b/packages/cli-v3/src/entryPoints/managed/logger.ts index 56fcaba43..150d74009 100644 --- a/packages/cli-v3/src/entryPoints/managed/logger.ts +++ b/packages/cli-v3/src/entryPoints/managed/logger.ts @@ -14,16 +14,20 @@ export type SendDebugLogOptions = { print?: boolean; }; +export interface RunLogger { + sendDebugLog(options: SendDebugLogOptions): void; +} + export type RunLoggerOptions = { httpClient: WorkloadHttpClient; env: RunnerEnv; }; -export class RunLogger { +export class ManagedRunLogger implements RunLogger { private readonly httpClient: WorkloadHttpClient; private readonly env: RunnerEnv; - constructor(private readonly opts: RunLoggerOptions) { + constructor(opts: RunLoggerOptions) { this.httpClient = opts.httpClient; this.env = opts.env; } @@ -59,3 +63,17 @@ export class RunLogger { }); } } + +export class ConsoleRunLogger implements RunLogger { + private readonly print: boolean; + + constructor(opts: { print?: boolean } = {}) { + this.print = opts.print ?? true; + } + + sendDebugLog({ message, properties }: SendDebugLogOptions): void { + if (this.print) { + console.log("[ConsoleLogger]", message, properties); + } + } +} diff --git a/packages/cli-v3/src/entryPoints/managed/snapshot.ts b/packages/cli-v3/src/entryPoints/managed/snapshot.ts index 9d4ca9da5..f23590b82 100644 --- a/packages/cli-v3/src/entryPoints/managed/snapshot.ts +++ b/packages/cli-v3/src/entryPoints/managed/snapshot.ts @@ -75,6 +75,12 @@ export class SnapshotManager { return this.enqueueSnapshotChange({ type: "suspendable", value: suspendable }); } + /** + * Update the snapshot ID and status without invoking any handlers + * + * @param snapshotId - The ID of the snapshot to update to + * @param status - The status to update to + */ public updateSnapshot(snapshotId: string, status: TaskRunExecutionStatus) { // Check if this is an old snapshot if (snapshotId < this.state.id) {