// src/telemetry/spans/well-known-attributes.ts
var WellKnownAttributes = {
  conversationId: {
    type: "string",
    description: "The current conversation the execution is part of",
    title: "Conversation ID",
    default: ""
  },
  workflowId: {
    type: "string",
    description: "The current workflow the execution is part of",
    title: "Workflow ID"
  },
  eventId: {
    type: "string",
    description: "The current incoming event the execution is part of",
    title: "Workflow ID"
  },
  userId: {
    type: "string",
    description: "The user attached to the event/message of the execution",
    title: "User ID"
  },
  messageId: {
    type: "string",
    description: "The message attached to the event/message of the execution",
    title: "Message ID"
  },
  botId: {
    type: "string",
    description: "The bot running the execution",
    title: "Bot ID"
  },
  parentWorkflowId: {
    type: "string",
    description: "The parent workflow the execution is part of",
    title: "Parent Workflow ID"
  },
  "event.type": {
    type: "string",
    description: "The type of the event the execution is part of",
    title: "Event Type"
  },
  "message.type": {
    type: "string",
    description: "The type of the message received",
    title: "Message Type"
  },
  integration: {
    type: "string",
    description: "The integration originating the event",
    title: "Integration"
  },
  channel: {
    type: "string",
    description: "The integration channel originating the event",
    title: "Channel"
  },
  "action.name": {
    type: "string",
    description: "The name of the action being called",
    title: "Action Name"
  },
  "event.payload": {
    type: "json",
    description: "The payload of the event received",
    title: "Event Payload"
  },
  "message.payload": {
    type: "json",
    description: "The payload of the message received",
    title: "Message Payload"
  }
};

// src/telemetry/spans/factory.ts
var required = (...keys) => {
  const result = {};
  for (const key of keys) {
    result[key] = { ...WellKnownAttributes[key], required: true };
  }
  return result;
};
var optional = (...keys) => {
  const result = {};
  for (const key of keys) {
    result[key] = { ...WellKnownAttributes[key], required: true };
  }
  return result;
};

// src/telemetry/spans/index.ts
var IncomingRequestSpan = {
  name: "request.incoming",
  importance: "high",
  attributes: {
    "request.operation": {
      type: "enum",
      enum: ["register", "event_received", "ping", "action_triggered"],
      description: "The operation being performed",
      title: "Operation",
      required: true
    },
    "request.type": {
      type: "string",
      description: "The request type (e.g., message_created)",
      title: "Request Type"
    },
    "request.method": {
      type: "enum",
      enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
      description: "The HTTP method",
      title: "HTTP Method",
      required: true
    },
    "request.path": {
      type: "string",
      description: "The request path",
      title: "Request Path",
      required: true
    },
    botId: {
      type: "string",
      description: "The bot ID",
      title: "Bot ID",
      required: true
    },
    webhookId: {
      type: "string",
      description: "The webhook ID if applicable",
      title: "Webhook ID"
    },
    "memory.rss": {
      type: "number",
      description: "The resident set size memory usage in bytes",
      title: "Memory RSS (bytes)"
    },
    "memory.heapTotal": {
      type: "number",
      description: "The total heap size memory usage in bytes",
      title: "Memory Heap Total (bytes)"
    },
    "cpu.count": {
      type: "number",
      description: "The number of CPU cores",
      title: "CPU Count",
      required: true
    },
    "requests.total": {
      type: "number",
      description: "The total number of requests handled by the process",
      title: "Total Requests",
      required: true
    }
  }
};
var CognitiveSpan = {
  name: "cognitive.request",
  importance: "high",
  attributes: {
    "ai.model": {
      type: "string",
      description: "The AI model used for the request",
      title: "AI Model"
    },
    "ai.provider": {
      type: "string",
      description: "The AI provider used for the request",
      title: "AI Provider"
    },
    "ai.temperature": {
      type: "number",
      description: "The temperature setting for the AI model",
      title: "AI Temperature"
    },
    "ai.max_tokens": {
      type: "number",
      description: "The maximum number of tokens to generate",
      title: "AI Max Tokens"
    },
    "ai.top_p": {
      type: "number",
      description: "The top_p (nucleus sampling) parameter",
      title: "AI Top P"
    },
    "ai.system_length": {
      type: "number",
      description: "The length of the system prompt in characters",
      title: "AI System Prompt Length"
    },
    "ai.messages_count": {
      type: "number",
      description: "The number of messages in the conversation",
      title: "AI Messages Count"
    },
    "ai.input_length": {
      type: "number",
      description: "The total length of input messages in characters",
      title: "AI Input Length"
    },
    "ai.input_tokens": {
      type: "number",
      description: "The number of input tokens used for the request",
      title: "AI Input Tokens"
    },
    "ai.output_tokens": {
      type: "number",
      description: "The number of output tokens used for the request",
      title: "AI Output Tokens"
    },
    "ai.cost_input": {
      type: "number",
      description: "The cost of input tokens in USD",
      title: "AI Input Cost (USD)"
    },
    "ai.cost_output": {
      type: "number",
      description: "The cost of output tokens in USD",
      title: "AI Output Cost (USD)"
    },
    "ai.cost": {
      type: "number",
      description: "The total cost of the request in USD",
      title: "AI Cost (USD)"
    },
    "ai.cached": {
      type: "boolean",
      description: "Whether the response was served from cache",
      title: "AI Cached"
    },
    "ai.prompt_category": {
      type: "string",
      description: "The category of the prompt",
      title: "AI Prompt Category"
    },
    "ai.prompt_source": {
      type: "string",
      description: "The source of the prompt",
      title: "AI Prompt Source"
    },
    "ai.instructions": {
      type: "string",
      description: "The system prompt/instructions for the AI model",
      title: "AI Instructions"
    },
    "ai.tools": {
      type: "json",
      description: "The tools available to the AI model",
      title: "AI Tools"
    }
  }
};
var BotpressClientSpan = {
  name: "botpress.client",
  importance: "medium",
  attributes: {
    "botpress.method": {
      type: "enum",
      enum: ["GET", "POST", "PUT", "OPTIONS", "DELETE"],
      required: true
    },
    "botpress.url": { type: "string" },
    "botpress.status_code": { type: "number", default: "" },
    "botpress.duration_ms": { type: "number" },
    "botpress.error": { type: "string" },
    "botpress.via": { type: "string" },
    "botpress.request.body": { type: "string" },
    "botpress.response.body": { type: "string" },
    "trace.traceparent": { type: "string" },
    ...optional("conversationId", "messageId", "workflowId", "userId", "eventId", "action.name")
  }
};
var HttpSpan = {
  name: "http.client",
  importance: "medium",
  attributes: {
    "http.method": {
      type: "enum",
      enum: ["GET", "POST", "PUT", "OPTIONS", "DELETE"],
      required: true
    },
    "http.url": { type: "string", required: true },
    "http.query": { type: "json" },
    "http.request.headers": { type: "json" },
    "http.response.headers": { type: "json" },
    "http.request.body": { type: "string" },
    "http.response.body": { type: "string" },
    "http.status_code": { type: "number" },
    "http.error": { type: "string" },
    "http.via": {
      type: "enum",
      enum: ["http", "undici"],
      required: true
    },
    "trace.traceparent": { type: "string" }
  }
};
var ConversationHandlerSpan = {
  name: "handler.conversation",
  importance: "high",
  attributes: {
    ...required("botId", "conversationId", "eventId", "integration", "channel", "event.type"),
    ...optional("messageId", "userId", "event.payload", "message.payload", "message.type")
  }
};
var TriggerHandlerSpan = {
  name: "handler.trigger",
  importance: "high",
  attributes: {
    ...required("botId", "eventId", "event.type"),
    ...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
  }
};
var EventHandlerSpan = {
  name: "handler.event",
  importance: "high",
  attributes: {
    ...required("botId", "eventId", "event.type"),
    ...optional("conversationId", "messageId", "userId", "integration", "channel", "workflowId", "parentWorkflowId")
  }
};
var WorkflowHandlerSpan = {
  name: "handler.workflow",
  importance: "high",
  attributes: {
    ...required("botId", "workflowId", "eventId", "event.type"),
    ...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
    "workflow.name": { type: "string" },
    "workflow.status.initial": {
      type: "enum",
      enum: ["pending", "in_progress", "listening", "paused", "completed", "failed", "timedout", "cancelled"]
    },
    "workflow.status.final": {
      type: "enum",
      enum: ["continue", "completed", "failed"]
    }
  }
};
var WorkflowStepSpan = {
  name: "handler.workflow.step",
  importance: "high",
  attributes: {
    ...required("workflowId"),
    "workflow.step": { type: "string", required: true },
    "workflow.step.type": { type: "string", required: true },
    "workflow.step.attempt": { type: "number", required: true },
    "workflow.step.output": { type: "json" },
    "workflow.step.max_attempts": { type: "number" },
    "workflow.step.error": { type: "string" }
  }
};
var ActionHandlerSpan = {
  name: "handler.action",
  importance: "high",
  attributes: {
    ...required("botId", "workflowId", "eventId", "event.type"),
    ...optional("messageId", "userId", "integration", "channel", "conversationId", "parentWorkflowId"),
    "action.name": { type: "string", required: true },
    "action.input": { type: "json", required: true }
  }
};
var AutonomousExecutionSpan = {
  name: "autonomous.execution",
  importance: "high",
  attributes: {
    "autonomous.max_loops": {
      type: "number",
      title: "Max Loops",
      description: "The maximum number of loops allowed",
      required: true
    },
    "autonomous.mode": {
      type: "enum",
      title: "Mode",
      description: "The mode LLMz is running in (chat or worker)",
      enum: ["chat", "worker"],
      required: true
    },
    "autonomous.message_types": {
      type: "json",
      title: "Message Types",
      description: "The types of messages LLMz can send"
    },
    "autonomous.iterations": {
      type: "number",
      title: "Iterations",
      description: "The number of iterations performed"
    },
    "autonomous.execution_id": {
      type: "string",
      title: "Execution ID",
      description: "The unique ID for this execution"
    }
  }
};
var AutonomousIterationSpan = {
  name: "autonomous.iteration",
  importance: "high",
  attributes: {
    "autonomous.iteration": {
      type: "number",
      title: "Iteration",
      description: "The current iteration number",
      required: true
    },
    "autonomous.instructions": {
      type: "string",
      title: "Instructions",
      description: "The instructions provided to the agent"
    },
    "autonomous.exits": {
      type: "json",
      title: "Exits",
      description: "The possible exit points for the agent"
    },
    "autonomous.code": {
      type: "string",
      title: "Code",
      description: "The code generated in this iteration"
    },
    "autonomous.tools": {
      type: "json",
      title: "Tools",
      description: "The tools available to the agent"
    },
    "autonomous.thoughts": {
      type: "string",
      title: "Thoughts",
      description: "The thoughts generated in this iteration"
    },
    "autonomous.status": {
      type: "enum",
      enum: [
        "pending",
        "generation_error",
        "execution_error",
        "invalid_code_error",
        "thinking_requested",
        "callback_requested",
        "exit_success",
        "exit_error",
        "aborted"
      ],
      title: "Error Type",
      description: "The type of error encountered, if any"
    },
    "autonomous.error": {
      type: "string",
      title: "Error Message",
      description: "The error message, if any"
    },
    "autonomous.exit.name": {
      type: "string",
      title: "Exit Name",
      description: "The name of the exit point if exiting"
    },
    "autonomous.exit.value": {
      type: "json",
      title: "Exit Value",
      description: "The value returned upon exit"
    },
    "ai.model": {
      type: "string",
      title: "AI Model",
      description: "The AI model used for this iteration"
    },
    "ai.tokens": {
      type: "number",
      title: "Input Tokens",
      description: "Number of input tokens used"
    },
    "ai.cost": {
      type: "number",
      title: "Cost",
      description: "Total cost of this iteration in USD"
    }
  }
};
var AutonomousToolSpan = {
  name: "autonomous.tool",
  importance: "high",
  attributes: {
    "autonomous.tool.object": {
      type: "string",
      title: "Object Name",
      description: "The name of the object being used",
      required: false
    },
    "autonomous.tool.name": {
      type: "string",
      title: "Tool Name",
      description: "The name of the tool being used",
      required: true
    },
    "autonomous.tool.input": {
      type: "json",
      title: "Tool Input",
      description: "The input provided to the tool"
    },
    "autonomous.tool.output": {
      type: "json",
      title: "Tool Output",
      description: "The output returned by the tool"
    },
    "autonomous.tool.status": {
      type: "enum",
      enum: ["think", "success", "error"],
      title: "Tool Status",
      description: "The status of the tool execution"
    },
    "autonomous.tool.error": {
      type: "string",
      title: "Tool Error",
      description: "The error message if the tool failed"
    }
  }
};
var InterruptionCheckSpan = {
  name: "interruption.check",
  importance: "medium",
  attributes: {
    ...required("conversationId"),
    "interruption.detected": {
      type: "boolean",
      title: "Interruption Detected",
      description: "Whether an interruption was detected"
    },
    "interruption.events_count": {
      type: "number",
      title: "New Events Count",
      description: "The number of new events detected"
    },
    "interruption.event_ids": {
      type: "json",
      title: "New Event IDs",
      description: "The IDs of the new events that caused the interruption"
    }
  }
};
var ChatFetchTranscriptSpan = {
  name: "chat.fetchTranscript",
  importance: "medium",
  attributes: {
    ...required("conversationId")
  }
};
var ChatCompactTranscriptSpan = {
  name: "chat.compactTranscript",
  importance: "medium",
  attributes: {
    ...required("conversationId")
  }
};
var ChatSaveTranscriptSpan = {
  name: "chat.saveTranscript",
  importance: "medium",
  attributes: {
    ...required("conversationId")
  }
};
var ChatSendMessageSpan = {
  name: "chat.sendMessage",
  importance: "high",
  attributes: {
    ...required("conversationId"),
    ...optional("messageId", "integration", "channel", "userId", "botId"),
    "message.type": {
      type: "string",
      description: "The type of message being sent",
      title: "Message Type"
    },
    direction: {
      type: "enum",
      enum: ["incoming", "outgoing"],
      description: "The direction of the message",
      title: "Direction"
    }
  }
};
var TrackedStateLoadSpan = {
  name: "state.load",
  importance: "medium",
  attributes: {
    type: {
      type: "enum",
      enum: ["bot", "user", "conversation", "workflow"],
      description: "The type of state being loaded",
      title: "State Type",
      required: true
    },
    name: {
      type: "string",
      description: "The name of the state",
      title: "State Name",
      required: true
    },
    location: {
      type: "enum",
      enum: ["state", "file"],
      description: "Where the state is stored",
      title: "Storage Location"
    },
    has_value: {
      type: "boolean",
      description: "Whether the state has a value",
      title: "Has Value"
    }
  }
};
var TrackedStateSaveSpan = {
  name: "state.save",
  importance: "medium",
  attributes: {
    type: {
      type: "enum",
      enum: ["bot", "user", "conversation", "workflow"],
      description: "The type of state being saved",
      title: "State Type",
      required: true
    },
    name: {
      type: "string",
      description: "The name of the state",
      title: "State Name",
      required: true
    },
    state_size_bytes: {
      type: "number",
      description: "The size of the state in bytes",
      title: "State Size (bytes)"
    },
    swapped_to_file: {
      type: "boolean",
      description: "Whether the state was swapped to a file",
      title: "Swapped to File"
    }
  }
};
var TrackedStateSaveAllDirtySpan = {
  name: "state.saveAllDirty",
  importance: "medium",
  attributes: {
    states_count: {
      type: "number",
      description: "The number of dirty states being saved",
      title: "States Count",
      required: true
    },
    states: {
      type: "json",
      description: "The list of states being saved (type/id/name)",
      title: "States"
    }
  }
};
var TrackedStateLoadAllSpan = {
  name: "state.loadAll",
  importance: "medium",
  attributes: {}
};
var Spans = {
  IncomingRequestSpan,
  CognitiveSpan,
  HttpSpan,
  BotpressClientSpan,
  ConversationHandlerSpan,
  TriggerHandlerSpan,
  WorkflowHandlerSpan,
  WorkflowStepSpan,
  ActionHandlerSpan,
  EventHandlerSpan,
  AutonomousExecutionSpan,
  AutonomousIterationSpan,
  AutonomousToolSpan,
  InterruptionCheckSpan,
  ChatFetchTranscriptSpan,
  ChatCompactTranscriptSpan,
  ChatSaveTranscriptSpan,
  ChatSendMessageSpan,
  TrackedStateLoadSpan,
  TrackedStateSaveSpan,
  TrackedStateSaveAllDirtySpan,
  TrackedStateLoadAllSpan
};
export {
  Spans as SpanDefinitions
};
//# sourceMappingURL=ui.js.map
