Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def call_tracedecay_tool(name: str, args: dict, **kwargs) -> str:
user_scoped = (
tool_args.get("memory_scope") == "user"
or tool_args.get("storage_scope") == "user"
or tool_args.get("user_scope") is True
)
if user_scoped:
project_root = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2420,13 +2420,16 @@ def sync_turn(self, user_content, assistant_content, *, session_id="", messages=
# so one turn can be searched from every repository it actually touched
# without binding the long-lived host session to any one project.
for project_root in [None, *project_roots]:
args = _lcm_store_args({
# The internal hook tool is not format-capable, so the JSON
# result this reads back is requested explicitly.
args = {
"action": "ingest_transcript",
"provider": STANDARD_HERMES_LCM_PROVIDER,
"session_id": sid,
"messages": turn_messages,
"user_scope": project_root is None,
}, project_root)
"format": "json",
}
try:
result = call_tracedecay_json(
"tracedecay_hook_runtime",
Expand Down
3 changes: 2 additions & 1 deletion crates/tracedecay-agent-hosts/src/hooks/analytics/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use std::time::Duration;
use tracedecay_contracts::retrieval::HookRuntimeSurfaceRequestV1;
use tracedecay_runtime_core::config::ProfileRoot;

fn enroll_project(project_root: &Path, profile_root: &Path, project_id: &str) -> PathBuf {
Expand Down Expand Up @@ -244,7 +245,7 @@ fn daemon_hook_action_records_completed_rtt_and_wire_length() {
let result = crate::hooks::daemon_hook_action(
&crate::ports::hook_runtime::crate_test_runtime(profile.clone()),
Some(&project_root),
serde_json::json!({ "action": "reset_counter" }),
HookRuntimeSurfaceRequestV1::ResetCounter {},
Some(&span),
)
.await;
Expand Down
11 changes: 7 additions & 4 deletions crates/tracedecay-agent-hosts/src/hooks/claude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use std::path::PathBuf;
use std::time::Instant;

use serde_json::Value;
use tracedecay_contracts::retrieval::HookRuntimeSurfaceRequestV1;

use crate::ports::hook_runtime::HookRuntimeV1;

use super::post_tool_use::is_post_tool_use_failure_event;
use super::tool_hints::{ToolHintInput, decide_hint};
use super::{
additional_context_json, compact_daemon_args, event_project_root_with_identity,
event_session_id, prompt_like_text, read_hook_event, record_hook_invoked_parsed,
research_block_reason,
additional_context_json, event_project_root_with_identity, event_session_id, prompt_like_text,
read_hook_event, record_hook_invoked_parsed, research_block_reason,
};
use tracedecay_domain::HostIntegrationIdV1;

Expand Down Expand Up @@ -110,7 +110,10 @@ pub async fn hook_claude_post_compact(runtime: &HookRuntimeV1) -> i32 {
&event,
&parsed,
);
let args = compact_daemon_args("claude_compact", "claude", root.is_none(), &event, None);
let args = HookRuntimeSurfaceRequestV1::ClaudeCompact {
event_json: event.clone(),
user_scope: root.is_none(),
};
if let Err(error) =
super::daemon_hook_action(runtime, root.as_deref(), args, Some(&hook_telemetry)).await
{
Expand Down
21 changes: 8 additions & 13 deletions crates/tracedecay-agent-hosts/src/hooks/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::time::Instant;
use tracedecay_contracts::retrieval::HookRuntimeSurfaceRequestV1;

use serde_json::Value;

Expand All @@ -15,11 +16,10 @@ use super::claude::is_code_research_prompt;
use super::steering::{HookWorkspaceStatus, index_status_line};
use super::tool_hints::{HintCategory, ToolHint, ToolHintInput, decide_hint};
use super::{
additional_context_json, append_tool_hint, compact_daemon_args, deduped_project_hint_with_id,
event_cwd_from_parsed, event_project_root, event_project_root_from_json,
event_project_root_with_identity, event_session_id, format_tool_hint,
is_project_like_workspace, mint_hint_id, prompt_like_text, read_hook_event,
record_hint_analytics, record_hook_analytics, record_hook_invoked_parsed,
additional_context_json, append_tool_hint, deduped_project_hint_with_id, event_cwd_from_parsed,
event_project_root, event_project_root_from_json, event_project_root_with_identity,
event_session_id, format_tool_hint, is_project_like_workspace, mint_hint_id, prompt_like_text,
read_hook_event, record_hint_analytics, record_hook_analytics, record_hook_invoked_parsed,
record_workspace_status_analytics, rel_under_root, text_field,
};
use tracedecay_domain::HostIntegrationIdV1;
Expand Down Expand Up @@ -545,14 +545,9 @@ async fn codex_post_compact(
let Some(root) = event_project_root_with_identity(runtime, &parsed).await else {
return;
};
let session_id = event_session_id(&parsed);
let args = compact_daemon_args(
"codex_compact",
"codex",
false,
event_json,
session_id.as_deref(),
);
let args = HookRuntimeSurfaceRequestV1::CodexCompact {
event_json: event_json.to_owned(),
};
if let Err(error) = super::daemon_hook_action(runtime, Some(&root), args, telemetry).await {
tracing::warn!(%error, "Codex PostCompact daemon call failed");
}
Expand Down
18 changes: 14 additions & 4 deletions crates/tracedecay-agent-hosts/src/hooks/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ mod tests {
use tracedecay_runtime_core::config::ProfileRoot;

#[tokio::test]
async fn transcript_ingest_forwards_its_budget_to_the_daemon() {
async fn transcript_ingest_forwards_its_byte_budget_to_the_daemon() {
let daemon = crate::hooks::TestDaemonHookActionGuard::install([
serde_json::json!({ "user_scope": true, "messages_upserted": 2 }),
]);
Expand Down Expand Up @@ -453,9 +453,19 @@ mod tests {
assert_eq!(calls[0].0, None);
assert_eq!(calls[0].1["action"], "ingest_transcript");
assert_eq!(calls[0].1["provider"], "cursor");
assert_eq!(calls[0].1["max_new_bytes"], 4_096);
assert_eq!(calls[0].1["timeout_budget_ms"], 250);
assert_eq!(calls[0].1["format"], "json");
assert_eq!(
calls[0].1,
serde_json::json!({
"action": "ingest_transcript",
"provider": "cursor",
"user_scope": true,
"session_id": null,
"event_json": event,
"messages": null,
"max_new_bytes": 4_096,
"format": "json",
})
);
}

#[tokio::test]
Expand Down
8 changes: 4 additions & 4 deletions crates/tracedecay-agent-hosts/src/hooks/cursor_compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use std::time::Duration;

use tracedecay_contracts::retrieval::HookRuntimeSurfaceRequestV1;
use tracedecay_lcm::LcmRelationProjectionStatus;

use crate::ports::hook_runtime::HookRuntimeV1;
Expand Down Expand Up @@ -100,10 +101,9 @@ async fn cursor_pre_compact_via_daemon_inner(
let result = match super::daemon_hook_action(
runtime,
Some(&root),
serde_json::json!({
"action": "cursor_compact",
"event_json": event_json,
}),
HookRuntimeSurfaceRequestV1::CursorCompact {
event_json: event_json.to_owned(),
},
telemetry,
)
.await
Expand Down
Loading
Loading