mod build;
mod cards;
mod cohort;
mod pin;
mod place;
mod tree;
use crate::budgets::BudgetSpend;
use crate::git_tree::{AgentState, Framing, StepCommit};
use crate::rail::ChildInput;
use crate::steps_view::{Orphan, StepSummary, StepsView, Wound};
use crate::transcript::{Block, Entry, EntryKind, Transcript, Usage};
pub(super) fn commit(oid: &str, at: i64) -> StepCommit {
StepCommit {
oid: oid.to_owned(),
short_oid: oid.chars().take(8).collect(),
timestamp_unix: at,
subject: "step".to_owned(),
}
}
pub(super) fn step(seq: &str, oid: Option<&str>, tokens: u64) -> StepSummary {
StepSummary {
seq: seq.to_owned(),
framing: Framing::Complete,
attempts: 1,
tokens: BudgetSpend {
input_tokens: tokens,
..BudgetSpend::default()
},
commit: oid.map(str::to_owned),
started_at: None,
ended_at: None,
wound: Wound::None,
}
}
pub(super) fn steps(rows: Vec<StepSummary>) -> StepsView {
StepsView {
steps: rows,
orphan: Orphan::default(),
}
}
pub(super) fn chat(turns: usize) -> Transcript {
let entry = |name: String, kind: EntryKind| Entry {
name,
raw: b"x".to_vec(),
kind,
};
let mut entries = Vec::new();
for turn in 0..turns {
entries.push(entry(
format!("{:03}-user.md", turn * 2 + 1),
EntryKind::Delivered {
sender: "user".to_owned(),
epitaph: None,
body: "hi".to_owned(),
},
));
entries.push(entry(
format!("{:03}-opus.json", turn * 2 + 2),
EntryKind::Model {
model_id: "opus".to_owned(),
blocks: vec![Block::Text("ok".to_owned())],
usage: Usage::new(),
},
));
}
Transcript { entries }
}
pub(super) fn seat(turn: usize) -> String {
format!("tx/{:03}-user.md#0", turn * 2 + 1)
}
pub(super) fn child(name: &str, commits: Vec<StepCommit>) -> ChildInput {
ChildInput {
agent_id: format!("root-{name}"),
name: name.to_owned(),
state: AgentState::Quiescent,
streaming_text: None,
commits,
tokens: 0,
config_label: None,
}
}