update: SystemItem1本化
This commit is contained in:
+23
-70
@@ -214,20 +214,23 @@ pub enum Event {
|
||||
UserMessage {
|
||||
segments: Vec<Segment>,
|
||||
},
|
||||
/// Echo of `Method::Notify` received by this Pod. Broadcast on
|
||||
/// receipt so subscribers can render the external input as a log
|
||||
/// element. The same `message` is independently pushed into the
|
||||
/// notification buffer for LLM injection (with prompt-pack
|
||||
/// wrapping); this echo carries the raw payload and does not
|
||||
/// imply any turn-boundary semantics.
|
||||
Notify {
|
||||
message: String,
|
||||
/// One agent-injected system item committed to history.
|
||||
///
|
||||
/// Carries the JSON form of `session_store::SystemItem`. Covers
|
||||
/// `Method::Notify` echoes, child-Pod lifecycle events from
|
||||
/// `Method::PodEvent`, `@<path>` / `#<slug>` / `/<slug>`
|
||||
/// resolution payloads, and any future agent-side injection kind.
|
||||
/// Clients dispatch on the `kind` tag for typed rendering instead
|
||||
/// of parsing free-text prefixes like `[Notification] …` or
|
||||
/// `[File: …]`.
|
||||
///
|
||||
/// Fired per-item, even when the underlying
|
||||
/// `LogEntry::SystemItems` entry batched several together — the
|
||||
/// IPC layer fans the batch out at broadcast time so subscribers
|
||||
/// observe one event per item.
|
||||
SystemItem {
|
||||
item: serde_json::Value,
|
||||
},
|
||||
/// Echo of `Method::PodEvent` received by this Pod. Same rationale
|
||||
/// as `Notify`: subscribers render the event as a log element,
|
||||
/// while a rendered summary is independently injected into the LLM
|
||||
/// context via the notification buffer.
|
||||
PodEvent(PodEvent),
|
||||
TurnStart {
|
||||
turn: usize,
|
||||
},
|
||||
@@ -335,17 +338,6 @@ pub enum Event {
|
||||
SessionRotated {
|
||||
entry: serde_json::Value,
|
||||
},
|
||||
/// A non-LLM-driven history append landed in the worker history.
|
||||
///
|
||||
/// Carries the JSON form of `session_store::LogEntry::HookInjectedItems`.
|
||||
/// This is the live counterpart of items that the streaming lane
|
||||
/// never broadcasts — `Method::Notify` echoes, `@<path>` attachment
|
||||
/// resolutions, `<system-reminder>` injections — so a connected
|
||||
/// client can render them in time order without waiting for the
|
||||
/// next reconnect's `Snapshot`.
|
||||
HookInjectedItems {
|
||||
entry: serde_json::Value,
|
||||
},
|
||||
/// Current Pod controller status. Broadcast on every controller-level
|
||||
/// transition and included in `History` snapshots for late attach.
|
||||
Status {
|
||||
@@ -791,20 +783,18 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_hook_injected_items_roundtrip() {
|
||||
let event = Event::HookInjectedItems {
|
||||
entry: serde_json::json!({"kind": "hook_injected_items", "ts": 42, "items": []}),
|
||||
fn event_system_item_roundtrip() {
|
||||
let event = Event::SystemItem {
|
||||
item: serde_json::json!({"kind": "notification", "message": "hello"}),
|
||||
};
|
||||
let json = serde_json::to_string(&event).unwrap();
|
||||
let parsed: serde_json::Value = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(parsed["event"], "hook_injected_items");
|
||||
assert_eq!(parsed["data"]["entry"]["kind"], "hook_injected_items");
|
||||
assert_eq!(parsed["event"], "system_item");
|
||||
assert_eq!(parsed["data"]["item"]["kind"], "notification");
|
||||
let decoded: Event = serde_json::from_str(&json).unwrap();
|
||||
match decoded {
|
||||
Event::HookInjectedItems { entry } => {
|
||||
assert_eq!(entry["kind"], "hook_injected_items")
|
||||
}
|
||||
other => panic!("expected HookInjectedItems, got {other:?}"),
|
||||
Event::SystemItem { item } => assert_eq!(item["kind"], "notification"),
|
||||
other => panic!("expected SystemItem, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1066,43 +1056,6 @@ mod tests {
|
||||
assert_eq!(parsed["data"]["code"], "already_running");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_notify_roundtrip() {
|
||||
let event = Event::Notify {
|
||||
message: "child-pod finished".into(),
|
||||
};
|
||||
let json = serde_json::to_string(&event).unwrap();
|
||||
let parsed: serde_json::Value = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(parsed["event"], "notify");
|
||||
assert_eq!(parsed["data"]["message"], "child-pod finished");
|
||||
|
||||
let decoded: Event = serde_json::from_str(&json).unwrap();
|
||||
match decoded {
|
||||
Event::Notify { message } => assert_eq!(message, "child-pod finished"),
|
||||
other => panic!("expected Notify, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_pod_event_roundtrip() {
|
||||
let event = Event::PodEvent(PodEvent::TurnEnded {
|
||||
pod_name: "child".into(),
|
||||
});
|
||||
let json = serde_json::to_string(&event).unwrap();
|
||||
let parsed: serde_json::Value = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(parsed["event"], "pod_event");
|
||||
assert_eq!(parsed["data"]["kind"], "turn_ended");
|
||||
assert_eq!(parsed["data"]["pod_name"], "child");
|
||||
|
||||
let decoded: Event = serde_json::from_str(&json).unwrap();
|
||||
match decoded {
|
||||
Event::PodEvent(PodEvent::TurnEnded { pod_name }) => {
|
||||
assert_eq!(pod_name, "child");
|
||||
}
|
||||
other => panic!("expected PodEvent::TurnEnded, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_user_message_roundtrip() {
|
||||
let event = Event::UserMessage {
|
||||
|
||||
Reference in New Issue
Block a user