blob: b12fe36b31efd6d22393962f63dacfa783fcac2e [file]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
pub use maka_agent_facts::memory::*;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryRead {
pub scope: MemoryScope,
pub id: MemoryId,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoriesRead {
pub scope: MemoryScope,
pub after: Option<MemoryId>,
pub limit: u32,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryPage {
pub records: Vec<MemoryRecord>,
pub next: Option<MemoryId>,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryChange {
pub scope: MemoryScope,
pub edit: MemoryEdit,
pub resolution: Option<MemoryResolution>,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryHistoryRead {
pub scope: MemoryScope,
pub id: MemoryId,
pub after: Option<MemoryRevision>,
pub limit: u32,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryHistoryPage {
pub versions: Vec<MemoryVersion>,
pub next: Option<MemoryRevision>,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryEvidenceRead {
pub scope: MemoryScope,
pub id: MemoryId,
pub assertion: MemoryRevision,
pub after: Option<u64>,
pub limit: u32,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryEvidencePage {
pub evidence: Vec<MemoryEvidence>,
pub next: Option<u64>,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryResolution {
pub session_id: String,
pub model: crate::contract::ModelSelection,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ReconcileMemories {
pub scope: MemoryScope,
pub writes: Vec<MemoryWrite>,
pub resolution: Option<MemoryResolution>,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct LoadedMemoriesRead {
pub session_id: String,
pub run_id: maka_agent_facts::durable::RunId,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ExtractMemories {
pub session_id: String,
pub model: crate::contract::ModelSelection,
pub scope: MemoryScope,
pub range: MemoryExtractionRange,
pub intent: MemoryExtractionIntent,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct MemoryExtractionRange {
/// Exclusive lower bound of the authorized history range.
pub after_sequence: u64,
/// Inclusive upper bound identifying an exact committed history boundary.
pub through_sequence: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
pub enum MemoryExtractionIntent {
Remember { instruction: String },
Organize,
}
/// The Host derives the instruction, model and source range from the calling Run.
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct RememberConversation {
#[serde(default)]
pub scope: ConversationMemoryScope,
#[serde(default)]
pub mode: ConversationMemoryMode,
}
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ConversationMemoryScope {
#[default]
Project,
Personal,
}
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ConversationMemoryMode {
#[default]
Remember,
Organize,
}