Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 104x 24x 16x | /** A version's action — mirrors svc-core's HistoryEnum.Action. */
export type HistoryAction = "created" | "updated" | "deleted";
/** Which generative flow was invoked — mirrors svc-core's GenerationEnum.Flow. */
export type GenerationFlow =
| "agent_setup"
| "skillset_setup"
| "toolkit_setup"
| "dashboard_setup"
| "knowledge_setup"
| "rule_setup"
| "skill_setup"
| "source_discovery";
/** How far a generative invocation got. `running` is a flow still working
* in the background (knowledge setup's search and design). */
export type GenerationStatus = "running" | "proposed" | "applied" | "failed";
/**
* The invocation behind a version, inlined into history lists — enough to
* label the row without a second request. The arguments live on
* {@link GenerationRun}, fetched on demand.
*/
export interface GenerationRef {
id: string;
flow: GenerationFlow;
status: GenerationStatus;
provider?: string | null;
model_name?: string | null;
created_at?: string | null;
}
/** One resource a generative invocation created. */
export interface ProducedResource {
resource_type: string;
resource_id: string;
name?: string | null;
}
/**
* One invocation of a generative flow: what was asked for, which model
* answered, and what came of it. Fetched from `/app/generations/{id}` when a
* history entry's provenance is expanded.
*/
export interface GenerationRun {
id: string;
flow: GenerationFlow;
status: GenerationStatus;
arguments: Record<string, unknown>;
ai_model_id?: string | null;
provider?: string | null;
model_name?: string | null;
target_resource_type?: string | null;
target_resource_id?: string | null;
warnings?: string[] | null;
error?: string | null;
actor_user_id?: string | null;
actor_name?: string | null;
created_at?: string | null;
applied_at?: string | null;
produced?: ProducedResource[];
}
/**
* Who made a version, as a kind: a named `user`; the `platform` — every
* version of a built-in resource is a CHAIN-R release, written with no
* actor; or `unknown` — no actor on a user's resource (the user has since
* been deleted).
*/
export type VersionActorKind = "user" | "platform" | "unknown";
/** One entry in a resource's edit history (a "commit"). */
export interface VersionSummary {
id: string;
version_number: number;
action: HistoryAction;
actor_user_id?: string | null;
actor_name?: string | null;
actor_email?: string | null;
actor_kind?: VersionActorKind;
changed_fields: string[];
is_ai_generated?: boolean | null;
/** The invocation responsible for this edit, when there was one. */
generation_id?: string | null;
generation?: GenerationRef | null;
created_at?: string | null;
}
export interface VersionList {
versions: VersionSummary[];
total: number;
}
export type DiffChangeType = "added" | "removed" | "changed" | "unchanged";
export interface TextDiffLine {
op: "equal" | "insert" | "delete";
line: string;
}
export interface FieldDiff {
field: string;
change_type: DiffChangeType;
old_value: unknown;
new_value: unknown;
text_diff?: TextDiffLine[] | null;
}
export interface ChildrenDiffEntry {
added: string[];
removed: string[];
}
export interface DiffResponse {
from_version: number | null;
to_version: number;
fields: FieldDiff[];
children_diff: Record<string, ChildrenDiffEntry>;
}
/**
* The two reads every resource with an edit history exposes.
*
* Implemented by ``HistoricalAPIRouter`` — and by the scoped accessors it
* hands out for routers carrying more than one resource type (evaluations
* serves both experiments and test suites). ``ResourceHistorySection`` takes
* one of these, so a call site never wires the two fetches by hand.
*/
export interface ResourceHistorySource {
history(id: string): Promise<VersionList | null>;
historyDiff(
id: string,
toVersion: number,
fromVersion?: number | null,
): Promise<DiffResponse | null>;
}
/** Flow labels for display — the raw enum values read as code. */
export const GENERATION_FLOW_LABELS: Record<GenerationFlow, string> = {
agent_setup: "Agent setup",
skillset_setup: "Skillset setup",
toolkit_setup: "Toolkit setup",
dashboard_setup: "Dashboard setup",
knowledge_setup: "Knowledge setup",
rule_setup: "Rule setup",
skill_setup: "Skill setup",
source_discovery: "Finding sources",
};
/** Who made a version, as the history shows it: the user's name, "CHAIN-R"
* for a built-in resource's releases, or "Unknown user". */
export function versionActor(
version: Pick<VersionSummary, "actor_kind" | "actor_name" | "actor_email">,
): string {
if (version.actor_kind === "platform") return "CHAIN-R";
return version.actor_name || version.actor_email || "Unknown user";
}
|