import {
  appendEdge
} from "./chunk-RK2Y4XOM.js";
import "./chunk-2LSZVONP.js";
import "./chunk-WIICJPET.js";
import "./chunk-PZ5AY32C.js";

// src/causal-trajectory-graph.ts
function causalTrajectoryGraphNodeId(trajectoryId, stage) {
  return `causal-trajectory/${trajectoryId}#${stage}`;
}
function buildCausalTrajectoryGraphEdges(record) {
  const edges = [
    {
      from: causalTrajectoryGraphNodeId(record.trajectoryId, "goal"),
      to: causalTrajectoryGraphNodeId(record.trajectoryId, "action"),
      type: "causal",
      weight: 1,
      label: "goal_to_action",
      ts: record.recordedAt
    },
    {
      from: causalTrajectoryGraphNodeId(record.trajectoryId, "action"),
      to: causalTrajectoryGraphNodeId(record.trajectoryId, "observation"),
      type: "causal",
      weight: 1,
      label: "action_to_observation",
      ts: record.recordedAt
    },
    {
      from: causalTrajectoryGraphNodeId(record.trajectoryId, "observation"),
      to: causalTrajectoryGraphNodeId(record.trajectoryId, "outcome"),
      type: "causal",
      weight: 1,
      label: `observation_to_outcome:${record.outcomeKind}`,
      ts: record.recordedAt
    }
  ];
  if (record.followUpSummary) {
    edges.push({
      from: causalTrajectoryGraphNodeId(record.trajectoryId, "outcome"),
      to: causalTrajectoryGraphNodeId(record.trajectoryId, "follow_up"),
      type: "causal",
      weight: 1,
      label: "outcome_to_follow_up",
      ts: record.recordedAt
    });
  }
  return edges;
}
async function appendCausalTrajectoryGraphEdges(options) {
  const edges = buildCausalTrajectoryGraphEdges(options.record);
  for (const edge of edges) {
    await appendEdge(options.memoryDir, edge);
  }
}
export {
  appendCausalTrajectoryGraphEdges,
  buildCausalTrajectoryGraphEdges,
  causalTrajectoryGraphNodeId
};
//# sourceMappingURL=causal-trajectory-graph.js.map