Forge
csharp4405de34
1using System.Text.Json.Serialization;
2using CascadeIDE.Models.Intercom;
3
4namespace CascadeIDE.Models.AgentChat;
5
6/// <summary>Снимок сообщения для <see cref="ChatHistoryEventKind.MessageAdded"/> / MessageCompleted.</summary>
7public sealed record ChatHistoryMessagePayload(
8 [property: JsonPropertyName("message_id")] string MessageId,
9 [property: JsonPropertyName("role")] string Role,
10 [property: JsonPropertyName("content")] string Content,
11 [property: JsonPropertyName("thread_id")] string ThreadId,
12 [property: JsonPropertyName("parent_message_id")] string? ParentMessageId = null,
13 [property: JsonPropertyName("slash_command_path")] string? SlashCommandPath = null,
14 [property: JsonPropertyName("slash_command_args")] string? SlashCommandArgs = null,
15 [property: JsonPropertyName("slash_command_status")] string? SlashCommandStatus = null,
16 [property: JsonPropertyName("attachments")] IReadOnlyList<AttachmentAnchor>? Attachments = null,
17 [property: JsonPropertyName("sender_workspace_context")] SenderWorkspaceContext? SenderWorkspaceContext = null,
18 [property: JsonPropertyName("audience")] IntercomMessageAudience? Audience = null,
19 [property: JsonPropertyName("delivery_mode")] string? DeliveryMode = null);
20
21/// <summary>Компенсирующее редактирование (<see cref="ChatHistoryEventKind.MessageEdited"/>).</summary>
22public sealed record ChatHistoryMessageEditedPayload(
23 [property: JsonPropertyName("message_id")] string MessageId,
24 [property: JsonPropertyName("new_content")] string NewContent,
25 [property: JsonPropertyName("reason")] string Reason);
26
27/// <summary>Новая ветка (<see cref="ChatHistoryEventKind.ThreadForked"/>).</summary>
28public sealed record ChatHistoryThreadForkedPayload(
29 [property: JsonPropertyName("new_thread_id")] string NewThreadId,
30 [property: JsonPropertyName("previous_thread_id")] string PreviousThreadId,
31 [property: JsonPropertyName("parent_message_id")] string? ParentMessageId = null);
32
33/// <summary>Ответ на пакет уточнений (<see cref="ChatHistoryEventKind.ClarificationAnswerSubmitted"/>).</summary>
34public sealed record ChatHistoryClarificationAnswerSubmittedPayload(
35 [property: JsonPropertyName("batch_id")] string BatchId,
36 [property: JsonPropertyName("answers")] IReadOnlyDictionary<string, string> Answers);
37
38/// <summary>Явная связь gutter ordinals с кодом (<see cref="ChatHistoryEventKind.MessageRangeRelated"/>, ADR 0137/0138).</summary>
39public sealed record ChatHistoryMessageRangeRelatedPayload(
40 [property: JsonPropertyName("thread_id")] string ThreadId,
41 [property: JsonPropertyName("start_ordinal")] int StartOrdinal,
42 [property: JsonPropertyName("end_ordinal")] int EndOrdinal,
43 [property: JsonPropertyName("code_ref")] AttachmentAnchor CodeRef,
44 [property: JsonPropertyName("source")] string Source,
45 [property: JsonPropertyName("ordinal_segments")] IReadOnlyList<ChatHistoryMessageOrdinalSegment>? OrdinalSegments = null);
46
47/// <summary>Якорь T2 context card (ADR 0174 §3.1).</summary>
48public sealed record SedmContextCardAnchorPayload(
49 [property: JsonPropertyName("path")] string Path,
50 [property: JsonPropertyName("symbol")] string? Symbol = null);
51
52/// <summary>Workline ref в SEDM payload (MLP: thread_id как workline).</summary>
53public sealed record SedmWorklineRefPayload(
54 [property: JsonPropertyName("id")] string Id,
55 [property: JsonPropertyName("label")] string? Label = null,
56 [property: JsonPropertyName("intent_tag")] string? IntentTag = null);
57
58/// <summary>Applies one-liner (0061 / ADR map).</summary>
59public sealed record SedmAppliesEntryPayload(
60 [property: JsonPropertyName("kind")] string Kind,
61 [property: JsonPropertyName("ref")] string Ref,
62 [property: JsonPropertyName("one_liner")] string OneLiner,
63 [property: JsonPropertyName("provenance")] string? Provenance = null);
64
65/// <summary><see cref="ChatHistoryEventKind.ContextCardMaterialized"/> payload v1.</summary>
66public sealed record SedmContextCardMaterializedPayload(
67 [property: JsonPropertyName("schema_version")] int SchemaVersion,
68 [property: JsonPropertyName("workline_id")] string WorklineId,
69 [property: JsonPropertyName("anchor")] SedmContextCardAnchorPayload Anchor,
70 [property: JsonPropertyName("workline")] SedmWorklineRefPayload? Workline = null,
71 [property: JsonPropertyName("applies")] IReadOnlyList<SedmAppliesEntryPayload>? Applies = null,
72 [property: JsonPropertyName("path_hint")] string? PathHint = null,
73 [property: JsonPropertyName("risk_advisory")] string? RiskAdvisory = null,
74 [property: JsonPropertyName("drill_down")] IReadOnlyList<string>? DrillDown = null,
75 [property: JsonPropertyName("trigger_reason")] string? TriggerReason = null);
76
77/// <summary>Тело intent / decision card (ADR 0173 tier A).</summary>
78public sealed record SedmIntentCardBodyPayload(
79 [property: JsonPropertyName("outcome")] string Outcome,
80 [property: JsonPropertyName("trigger")] string? Trigger = null,
81 [property: JsonPropertyName("chosen_approach")] string? ChosenApproach = null,
82 [property: JsonPropertyName("selection_rationale")] string? SelectionRationale = null,
83 [property: JsonPropertyName("constraints")] string? Constraints = null,
84 [property: JsonPropertyName("validation_plan")] string? ValidationPlan = null);
85
86public sealed record SedmIntentConsideredOptionPayload(
87 [property: JsonPropertyName("approach")] string Approach,
88 [property: JsonPropertyName("rejected_because")] string? RejectedBecause = null);
89
90/// <summary><see cref="ChatHistoryEventKind.IntentCardRecorded"/> payload v1.</summary>
91public sealed record SedmIntentCardRecordedPayload(
92 [property: JsonPropertyName("schema_version")] int SchemaVersion,
93 [property: JsonPropertyName("author")] string Author,
94 [property: JsonPropertyName("workline_id")] string WorklineId,
95 [property: JsonPropertyName("card")] SedmIntentCardBodyPayload Card,
96 [property: JsonPropertyName("message_id")] string? MessageId = null,
97 [property: JsonPropertyName("considered")] IReadOnlyList<SedmIntentConsideredOptionPayload>? Considered = null);
98
99public sealed record SedmDecisionFindingPayload(
100 [property: JsonPropertyName("kind")] string Kind,
101 [property: JsonPropertyName("ref")] string Ref,
102 [property: JsonPropertyName("summary")] string Summary);
103
104public sealed record SedmDecisionBasisPayload(
105 [property: JsonPropertyName("revision")] string? Revision = null,
106 [property: JsonPropertyName("touched_paths")] IReadOnlyList<string>? TouchedPaths = null);
107
108/// <summary><see cref="ChatHistoryEventKind.DecisionRecorded"/> payload v1.</summary>
109public sealed record SedmDecisionRecordedPayload(
110 [property: JsonPropertyName("schema_version")] int SchemaVersion,
111 [property: JsonPropertyName("author")] string Author,
112 [property: JsonPropertyName("workline_id")] string WorklineId,
113 [property: JsonPropertyName("card")] SedmIntentCardBodyPayload Card,
114 [property: JsonPropertyName("message_id")] string? MessageId = null,
115 [property: JsonPropertyName("considered")] IReadOnlyList<SedmIntentConsideredOptionPayload>? Considered = null,
116 [property: JsonPropertyName("findings")] IReadOnlyList<SedmDecisionFindingPayload>? Findings = null,
117 [property: JsonPropertyName("basis")] SedmDecisionBasisPayload? Basis = null,
118 [property: JsonPropertyName("status")] string Status = "active");
119
120/// <summary>Lifecycle events for decisions (stale / superseded).</summary>
121public sealed record SedmDecisionLifecyclePayload(
122 [property: JsonPropertyName("schema_version")] int SchemaVersion,
123 [property: JsonPropertyName("workline_id")] string WorklineId,
124 [property: JsonPropertyName("decision_event_id")] string DecisionEventId,
125 [property: JsonPropertyName("reason")] string? Reason = null);
126
View only · write via MCP/CIDE