import type { InstalledSkill } from "@agentxm/workspace-features/lifecycle"; import type * as Cause from "effect/Cause"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; import * as Ref from "effect/Ref"; import type * as Scope from "effect/Scope"; import * as ServiceMap from "effect/Context"; import { type OperationLifecycleService } from "@agentxm/workspace-kernel/operations"; import { type AppErrorCode } from "../app-error/index.js"; import { TelemetryClient, type TelemetryFailurePhase, type TelemetryProperties } from "../telemetry/index.js"; export interface CliCommandTelemetryOptions { readonly command: string; readonly event?: string; readonly properties?: TelemetryProperties; } export declare const trackCliCommand: ({ command, event, properties, }: CliCommandTelemetryOptions) => Effect.Effect; export type ProductActivityKind = "configure" | "install" | "publish" | "restore" | "update"; export interface ProductActivityIntent { readonly activity: ProductActivityKind; /** Whether a successful usable completion can activate a consumer cohort. */ readonly activationEligible: boolean; } interface ProductActivityAttempt extends ProductActivityIntent { readonly activityId: string; } declare const ProductActivity_base: ServiceMap.ServiceClass>; }>; export declare class ProductActivity extends ProductActivity_base { } export declare const ProductActivityLive: Layer.Layer; /** * Register and publish the first eligible product activity in this invocation. * Nested command adapters are intentionally idempotent and retain the outer * activity identity. */ export declare const startProductActivity: (intent: ProductActivityIntent) => Effect.Effect; export interface CliCommandCompletedOptions { readonly command: string; readonly result: "success" | "error" | "cancelled" | "defect"; readonly durationMs: number; readonly errorCode?: string; readonly errorCategory?: string; readonly semanticProperties?: TelemetryProperties; } export declare const trackCliCommandCompleted: (options: CliCommandCompletedOptions) => Effect.Effect; export declare const readGlobalFlagProperties: Effect.Effect<{ "cli.global.non_interactive": string; "cli.global.json": string; "cli.global.verbose": string; "cli.global.debug": string; "cli.global.quiet": string; }, never, "effect/cli/GlobalFlag/axm-non-interactive" | "effect/cli/GlobalFlag/axm-json" | "effect/cli/GlobalFlag/axm-quiet" | "effect/cli/GlobalFlag/axm-verbose" | "effect/cli/GlobalFlag/axm-debug">; /** The failure a command settled with, as telemetry reports it. */ export interface CommandSettlementFailure { readonly code: AppErrorCode; /** Where in the invocation the command settled with the failure. */ readonly phase: Exclude; /** Allowlisted diagnostic identity; see `failure-identity.ts`. */ readonly kind: string; /** True when the command handled the failure; false for a defect. */ readonly handled: boolean; } export interface CommandSettlement { /** Canonical command identity; absent when the envelope was given none. */ readonly command?: string; readonly result: CliCommandCompletedOptions["result"]; readonly durationMs: number; /** Absent for a success or a cancellation. */ readonly failure?: CommandSettlementFailure; readonly semanticProperties?: TelemetryProperties; } /** * Report one settled command outcome: the error report, when the command * settled with a failure, and then the completion event, from the same * settlement. Every termination path — an operation resolution, a handled * error, a defect, a cancellation — settles through this one reporter, so a * failure is reported the same way whichever path it took. Error details can * quote arbitrary package content or resolved input; telemetry reports the * failure's allowlisted identity and local output owns the detail. */ export declare const recordCommandSettlement: (settlement: CommandSettlement) => Effect.Effect; /** * Report the failure that ended the invocation after escaping every command * envelope — a startup rejection, a parse error, a configuration failure * before the command ran, or an output failure after it — once, before the * process renders it. A cancellation, or help that exits successfully, * reports nothing. */ export declare const reportProcessFailure: (cause: Cause.Cause) => Effect.Effect; /** * Report the failure of a command that runs without the runtime envelope — * help, which renders before any command runtime exists — in the command * phase under the command's canonical identity. The failure then continues * unchanged to the process, which renders it; the invocation has already * reported its one failure, so the process reports nothing more. */ export declare const withCommandFailureReport: (command: string) => (program: Effect.Effect) => Effect.Effect; /** * Give a whole invocation one process-owned telemetry reporter. A failure * that escapes every command envelope is reported once and then fails the * invocation unchanged, so the process renders and exits exactly as it would * without telemetry; the reporter releases, within its shutdown budget, * before that rendering. */ export declare const withProcessTelemetry: (reporter: Layer.Layer) => (program: Effect.Effect) => Effect.Effect>; declare const CommandSemanticProperties_base: ServiceMap.ServiceClass; }>; export declare class CommandSemanticProperties extends CommandSemanticProperties_base { } /** * Set semantic telemetry properties from within a command handler. * These properties are read by the runtime envelope and merged into * the `command_completed` event. Safe to call when the service is * absent (e.g., in tests that bypass the runtime envelope). */ export declare const setCommandSemanticProperties: (properties: TelemetryProperties) => Effect.Effect; export declare const getCommandSemanticProperties: Effect.Effect; /** * Create a Layer that provides CommandSemanticProperties backed by a fresh Ref. */ export declare const CommandSemanticPropertiesLive: Layer.Layer; /** * Fold an operation's lifecycle into `cli.lifecycle.*` semantic properties at * settlement. Telemetry is an independent, lossy observer: it buffers with a * sliding window so it can never hold the frame or the machine writer back, * and it does not register as lossless. */ export declare const observeLifecycleForTelemetry: (lifecycle: OperationLifecycleService) => Effect.Effect; /** Observe settled installs before output rendering can fail. */ export declare const recordSkillInstalls: (skills: ReadonlyArray) => Effect.Effect; export {}; //# sourceMappingURL=telemetry.d.ts.map