{"version":3,"file":"telemetry-VMPKEj8y.cjs","names":["createDoomTelemetry","Type","VOICE_TOOL_MAX_IDENTIFIER_LENGTH","requireDoomConfigContext"],"sources":["../src/services/logSinkTelemetry/index.ts","../src/schemas/majorModeVoiceTools.ts","../src/services/pendingSelection/index.ts","../src/services/statusLine/index.ts","../src/types/majorMode.ts","../src/types/telemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nimport type { MajorModeTelemetry } from '../../types/telemetry';\n\nconst SERVICE_NAME = 'doom-pi-major-mode';\nconst PACKAGE_NAME = '@agimon-ai/doompi-major-mode';\n\nexport interface MajorModeTelemetryOptions {\n  cwd?: string;\n  workspaceRoot?: string;\n  env?: NodeJS.ProcessEnv;\n  telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n  warn?: (message: string) => void;\n}\n\nexport function createMajorModeTelemetry(options: MajorModeTelemetryOptions = {}): MajorModeTelemetry {\n  const telemetry: DoomTelemetry = createDoomTelemetry({\n    serviceName: SERVICE_NAME,\n    packageName: PACKAGE_NAME,\n    cwd: options.cwd,\n    workspaceRoot: options.workspaceRoot,\n    env: options.env,\n    telemetryFactory: options.telemetryFactory,\n    warn: options.warn,\n    enableLogs: true,\n    enableTraces: true,\n  });\n  return {\n    recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n    recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n  };\n}\n","import { VOICE_TOOL_MAX_IDENTIFIER_LENGTH } from '@agimon-ai/doompi-core/voiceTools';\nimport { type Static, Type } from 'typebox';\n\nexport const MAJOR_MODE_VOICE_TOOL_NAME = 'major_mode';\n\nconst MAJOR_MODE_INPUT_NAME_SCHEMA = Type.String({\n  minLength: 1,\n  maxLength: VOICE_TOOL_MAX_IDENTIFIER_LENGTH,\n});\nconst CONFIGURED_NAME_SCHEMA = Type.String({ minLength: 1 });\nconst MAJOR_MODE_LAYERS_SCHEMA = Type.Array(CONFIGURED_NAME_SCHEMA);\n\nexport const MAJOR_MODE_VOICE_INPUT_SCHEMA = Type.Union([\n  Type.Object({ action: Type.Literal('list') }, { additionalProperties: false }),\n  Type.Object(\n    {\n      action: Type.Literal('switch'),\n      majorMode: MAJOR_MODE_INPUT_NAME_SCHEMA,\n    },\n    { additionalProperties: false },\n  ),\n]);\n\nexport const MAJOR_MODE_VOICE_RESULT_SCHEMA = Type.Union([\n  Type.Object(\n    {\n      status: Type.Literal('listed'),\n      current: CONFIGURED_NAME_SCHEMA,\n      modes: Type.Array(\n        Type.Object(\n          {\n            name: CONFIGURED_NAME_SCHEMA,\n            description: Type.String({ minLength: 1 }),\n            layers: MAJOR_MODE_LAYERS_SCHEMA,\n          },\n          { additionalProperties: false },\n        ),\n      ),\n    },\n    { additionalProperties: false },\n  ),\n  Type.Object(\n    {\n      status: Type.Literal('unchanged'),\n      majorMode: CONFIGURED_NAME_SCHEMA,\n    },\n    { additionalProperties: false },\n  ),\n  Type.Object(\n    {\n      status: Type.Literal('queued'),\n      majorMode: CONFIGURED_NAME_SCHEMA,\n      stopBatch: Type.Literal('session-reload'),\n    },\n    { additionalProperties: false },\n  ),\n]);\n\nexport type MajorModeVoiceInput = Static<typeof MAJOR_MODE_VOICE_INPUT_SCHEMA>;\nexport type MajorModeVoiceResult = Static<typeof MAJOR_MODE_VOICE_RESULT_SCHEMA>;\n","import {\n  replaceDoomConfigContext,\n  requireDoomConfigContext,\n  supersedeDoomConfigTransition,\n} from '@agimon-ai/doompi-config/piContext';\nimport type { DoomConfigContext, DoomConfigPendingSelection } from '@agimon-ai/doompi-config/types';\nimport type { TransitionSelectionSnapshot } from '@agimon-ai/doompi-core/transition';\nimport type { Context } from '@deepseek-ai/cordis';\n\ntype ConfigTransitionWriter = Parameters<typeof supersedeDoomConfigTransition>[0];\n\n/** The journal shape a transition records for the session that resumes after it. */\nexport function selectionFromSnapshot(snapshot: TransitionSelectionSnapshot) {\n  return {\n    version: 1 as const,\n    majorMode: snapshot.majorMode,\n    domains: [...snapshot.domains],\n    profile: snapshot.profile,\n    compositionFingerprint: snapshot.compositionFingerprint,\n  };\n}\n\nexport function clearPendingSelection(pi: ConfigTransitionWriter, cordis: Context): void {\n  const context = requireDoomConfigContext(cordis);\n  const pendingSelection = context.pendingSelection;\n  if (!pendingSelection) return;\n  supersedeDoomConfigTransition(pi, pendingSelection);\n  replaceDoomConfigContext(cordis, Object.freeze({ ...context, pendingSelection: undefined }));\n}\n\nexport function bindPendingSelection(\n  context: DoomConfigContext,\n  pendingSelection: DoomConfigPendingSelection,\n): DoomConfigContext {\n  const freezeSelection = (selection: DoomConfigPendingSelection['active']) =>\n    Object.freeze({ ...selection, domains: Object.freeze([...selection.domains]) });\n  return Object.freeze({\n    ...context,\n    pendingSelection: Object.freeze({\n      ...pendingSelection,\n      active: freezeSelection(pendingSelection.active),\n      target: freezeSelection(pendingSelection.target),\n    }),\n  });\n}\n","import type { Theme } from '@earendil-works/pi-coding-agent';\n\nexport const STATUS_KEY = 'doom-major-mode';\n\n/** Compact footer text for the selected major mode, domains, and profile. */\nexport function statusText(majorMode: string, domains: readonly string[], profile?: string): string {\n  return [profile ? `*${profile}*` : undefined, `[${majorMode}]`, domains.join(',')]\n    .filter((part) => Boolean(part))\n    .join(':');\n}\n\n/**\n * The same footer, coloured.\n *\n * A pure function of the theme it is handed rather than of an ambient one, so it\n * stays testable with a plain object and lives beside statusText rather than in\n * the TUI layer the command may not reach.\n */\nexport function colorStatus(\n  theme: Theme,\n  majorMode: string,\n  domains: readonly string[],\n  profile: string | undefined,\n  pending: boolean,\n): string {\n  const parts = [\n    profile ? theme.fg('success', theme.bold(`*${profile}*`)) : undefined,\n    theme.fg(pending ? 'warning' : 'accent', `[${majorMode}]`),\n    domains.length > 0 ? theme.fg('muted', domains.join(',')) : undefined,\n  ].filter((part): part is string => Boolean(part));\n  return parts.join(theme.fg('dim', ':'));\n}\n","import type { MajorModesConfig } from '@agimon-ai/doompi-config/majorModes';\n\n/** The npm name this package registers its voice tool and contributions under. */\nexport const MAJOR_MODE_SOURCE = '@agimon-ai/doompi-major-mode';\n/** Discriminates this package's reload handoffs from every other axis's. */\nexport const MAJOR_MODE_SWITCH_HANDOFF_KIND = 'major-mode-switch';\n\n/** The selection as both the command and the voice tool need to see it. */\nexport interface MajorModeView {\n  config: MajorModesConfig;\n  majorMode: string;\n  domains: readonly string[];\n  profile?: string;\n}\n","/** Telemetry events this package reports, and the port that records them. */\nexport const MAJOR_MODE_EVENT = {\n  majorModeSwitched: 'doom_pi_major_mode.switched',\n  majorModeUnavailable: 'doom_pi_major_mode.unavailable',\n} as const;\n\nexport type MajorModeEventName = (typeof MAJOR_MODE_EVENT)[keyof typeof MAJOR_MODE_EVENT];\nexport type MajorModeEventAttributes = Record<string, string | number | boolean>;\n\nexport interface MajorModeTelemetry {\n  recordError(event: MajorModeEventName, error: unknown, attributes?: MajorModeEventAttributes): Promise<void>;\n  recordEvent(event: MajorModeEventName, attributes?: MajorModeEventAttributes): Promise<void>;\n}\n"],"mappings":";;;;;AAIA,MAAM,eAAe;AACrB,MAAM,eAAe;AAUrB,SAAgB,yBAAyB,UAAqC,CAAC,GAAuB;CACpG,MAAM,aAAA,GAA2BA,4BAAAA,oBAAAA,CAAoB;EACnD,aAAa;EACb,aAAa;EACb,KAAK,QAAQ;EACb,eAAe,QAAQ;EACvB,KAAK,QAAQ;EACb,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;EACL,cAAc,OAAO,OAAO,eAAe,UAAU,YAAY,OAAO,OAAO,UAAU;EACzF,cAAc,OAAO,eAAe,UAAU,YAAY,OAAO,UAAU;CAC7E;AACF;;;AC5BA,MAAa,6BAA6B;AAE1C,MAAM,+BAA+BC,QAAAA,KAAK,OAAO;CAC/C,WAAW;CACX,WAAWC,kCAAAA;AACb,CAAC;AACD,MAAM,yBAAyBD,QAAAA,KAAK,OAAO,EAAE,WAAW,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