Compare commits
7 Commits
v0.1.3
...
cdd829199f
| Author | SHA1 | Date | |
|---|---|---|---|
|
cdd829199f
|
|||
|
e3c644b8ca
|
|||
|
5cb8070da1
|
|||
|
66801b5d07
|
|||
|
f2de196e22
|
|||
|
2eba530895
|
|||
| 3baa3102a3 |
+2
-1
@@ -48,7 +48,8 @@ cz commit
|
||||
1. Clone this repo
|
||||
2. Run `cargo test` to set up hooks
|
||||
3. Make changes
|
||||
4. Run the application using `make run` or `cargo run`
|
||||
4. Run the application using `just run` or `just run`
|
||||
- Install `just` (`cargo install just`) if you haven't already to use the [justfile](./justfile) in this project.
|
||||
5. Commit changes. This will trigger pre-commit hooks that will run format, test and lint. If there are errors or
|
||||
warnings from Clippy, please fix them.
|
||||
6. Push your code to a new branch named after the feature/bug/etc. you're adding. This will trigger pre-push hooks that
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
# Credits
|
||||
|
||||
## AIChat
|
||||
Loki originally started as a fork of the fantastic
|
||||
[AIChat CLI](https://github.com/sigoden/aichat). The initial goal was simply
|
||||
to fix a bug in how MCP servers worked with AIChat, allowing different MCP
|
||||
servers to be specified per agent. Since then, Loki has evolved far beyond
|
||||
its original scope and grown into a passion project with a life of its own.
|
||||
|
||||
Today, Loki includes first-class MCP server support (for both local and remote
|
||||
servers), a built-in vault for interpolating secrets in configuration files,
|
||||
built-in agents and macros, dynamic tab completions, integrated custom
|
||||
functions (no external `argc` dependency), improved documentation, and much
|
||||
more with many more ideas planned for the future.
|
||||
|
||||
Loki is now developed and maintained as an independent project. Full credit
|
||||
for the original foundation goes to the developers of the wonderful
|
||||
AIChat project.
|
||||
|
||||
This project is not affiliated with or endorsed by the AIChat maintainers.
|
||||
|
||||
## AIChat
|
||||
|
||||
Loki originally began as a fork of [AIChat CLI](https://github.com/sigoden/aichat),
|
||||
created and maintained by the AIChat contributors.
|
||||
|
||||
While Loki has since diverged significantly and is now developed as an
|
||||
independent project, its early foundation and inspiration came from the
|
||||
AIChat project.
|
||||
|
||||
AIChat is licensed under the MIT License.
|
||||
@@ -245,15 +245,10 @@ The appearance of Loki can be modified using the following settings:
|
||||
---
|
||||
|
||||
## History
|
||||
Loki originally started as a fork of the fantastic [AIChat CLI](https://github.com/sigoden/aichat). The purpose was to
|
||||
simply fix a bug in how MCP servers worked with AIChat so that I could specify different ones for agents. However, it
|
||||
has since evolved far beyond that and become a passion project with a life of its own!
|
||||
|
||||
Loki now has first class MCP server support (with support for local and remote servers alike), a built-in vault for
|
||||
interpolating secrets in configuration files, built-in agents, built-in macros, dynamic tab completions, integrated
|
||||
custom functions (no `argc` dependency), improved documentation, and much more with many more plans for the future!
|
||||
Loki began as a fork of [AIChat CLI](https://github.com/sigoden/aichat) and has since evolved into an independent project.
|
||||
|
||||
The original kudos goes out to all the developers of the wonderful AIChat project!
|
||||
See [CREDITS.md](./CREDITS.md) for full attribution and background.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -507,12 +507,14 @@ open_link() {
|
||||
|
||||
guard_operation() {
|
||||
if [[ -t 1 ]]; then
|
||||
ans="$(confirm "${1:-Are you sure you want to continue?}")"
|
||||
if [[ -z "$AUTO_CONFIRM" ]]; then
|
||||
ans="$(confirm "${1:-Are you sure you want to continue?}")"
|
||||
|
||||
if [[ "$ans" == 0 ]]; then
|
||||
error "Operation aborted!" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$ans" == 0 ]]; then
|
||||
error "Operation aborted!" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -657,13 +659,13 @@ guard_path() {
|
||||
path="$(_to_real_path "$1")"
|
||||
confirmation_prompt="$2"
|
||||
|
||||
if [[ ! "$path" == "$(pwd)"* ]]; then
|
||||
ans="$(confirm "$confirmation_prompt")"
|
||||
if [[ ! "$path" == "$(pwd)"* && -z "$AUTO_CONFIRM" ]]; then
|
||||
ans="$(confirm "$confirmation_prompt")"
|
||||
|
||||
if [[ "$ans" == 0 ]]; then
|
||||
error "Operation aborted!" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$ans" == 0 ]]; then
|
||||
error "Operation aborted!" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ loki --info | grep 'config_dir' | awk '{print $2}'
|
||||
- [Files and Directory Related Variables](#files-and-directory-related-variables)
|
||||
- [Agent Related Variables](#agent-related-variables)
|
||||
- [Logging Related Variables](#logging-related-variables)
|
||||
- [Miscellaneous Variables](#miscellaneous-variables)
|
||||
<!--toc:end-->
|
||||
|
||||
---
|
||||
@@ -104,3 +105,8 @@ The following variables can be used to change the log level of Loki or the locat
|
||||
|
||||
**Pro-Tip:** You can always tail the Loki logs using the `--tail-logs` flag. If you need to disable color output, you
|
||||
can also pass the `--disable-log-colors` flag as well.
|
||||
|
||||
## Miscellaneous Variables
|
||||
| Environment Variable | Description | Default Value |
|
||||
|----------------------|--------------------------------------------------------------------------------------------------|---------------|
|
||||
| `AUTO_CONFIRM` | Bypass all `guard_*` checks in the bash prompt helpers; useful for agent composition and routing | |
|
||||
@@ -207,7 +207,9 @@ open_link https://www.google.com
|
||||
```
|
||||
|
||||
### guard_operation
|
||||
Prompt for permission to run an operation
|
||||
Prompt for permission to run an operation.
|
||||
|
||||
Can be disabled by setting the environment variable `AUTO_CONFIRM`.
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
@@ -216,7 +218,9 @@ _run_sql
|
||||
```
|
||||
|
||||
### guard_path
|
||||
Prompt for permission to perform path operations
|
||||
Prompt for permission to perform path operations.
|
||||
|
||||
Can be disabled by setting the environment variable `AUTO_CONFIRM`.
|
||||
|
||||
**Example:***
|
||||
```bash
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# List all recipes
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Run all tests
|
||||
[group: 'test']
|
||||
test:
|
||||
cargo test --all
|
||||
|
||||
# See what linter errors and warnings are unaddressed
|
||||
[group: 'style']
|
||||
lint:
|
||||
cargo clippy --all
|
||||
|
||||
# Run Rustfmt against all source files
|
||||
[group: 'style']
|
||||
fmt:
|
||||
cargo fmt --all
|
||||
|
||||
# Build the project for the current system architecture
|
||||
# (Gets stored at ./target/[debug|release]/loki)
|
||||
[group: 'build']
|
||||
[arg('build_type', pattern="debug|release")]
|
||||
build build_type='debug':
|
||||
@cargo build {{ if build_type == "release" { "--release" } else { "" } }}
|
||||
+26
@@ -290,6 +290,32 @@
|
||||
thinking:
|
||||
type: enabled
|
||||
budget_tokens: 16000
|
||||
- name: claude-opus-4-5-20251101
|
||||
type: chat
|
||||
max_input_tokens: 200000
|
||||
input_price: 15.0
|
||||
output_price: 75.0
|
||||
max_output_tokens: 8192
|
||||
require_max_tokens: true
|
||||
supports_vision: true
|
||||
supports_function_calling: true
|
||||
- name: claude-opus-4-5-20251101:thinking
|
||||
type: chat
|
||||
real_name: claude-opus-4-5-20251101
|
||||
max_input_tokens: 200000
|
||||
input_price: 15.0
|
||||
output_price: 75.0
|
||||
patch:
|
||||
body:
|
||||
temperature: null
|
||||
top_p: null
|
||||
thinking:
|
||||
type: enabled
|
||||
budget_tokens: 16000
|
||||
max_output_tokens: 24000
|
||||
require_max_tokens: true
|
||||
supports_vision: true
|
||||
supports_function_calling: true
|
||||
- name: claude-opus-4-1-20250805
|
||||
max_input_tokens: 200000
|
||||
max_output_tokens: 8192
|
||||
|
||||
@@ -228,7 +228,7 @@ macro_rules! config_get_fn {
|
||||
std::env::var(&env_name)
|
||||
.ok()
|
||||
.or_else(|| self.config.$field_name.clone())
|
||||
.ok_or_else(|| anyhow::anyhow!("Miss '{}'", stringify!($field_name)))
|
||||
.ok_or_else(|| anyhow::anyhow!("Missing '{}'", stringify!($field_name)))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+22
-4
@@ -219,7 +219,14 @@ pub async fn gemini_chat_completions_streaming(
|
||||
part["functionCall"]["name"].as_str(),
|
||||
part["functionCall"]["args"].as_object(),
|
||||
) {
|
||||
handler.tool_call(ToolCall::new(name.to_string(), json!(args), None))?;
|
||||
let thought_signature = part["thoughtSignature"]
|
||||
.as_str()
|
||||
.or_else(|| part["thought_signature"].as_str())
|
||||
.map(|s| s.to_string());
|
||||
handler.tool_call(
|
||||
ToolCall::new(name.to_string(), json!(args), None)
|
||||
.with_thought_signature(thought_signature),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
} else if let Some("SAFETY") = data["promptFeedback"]["blockReason"]
|
||||
@@ -280,7 +287,14 @@ fn gemini_extract_chat_completions_text(data: &Value) -> Result<ChatCompletionsO
|
||||
part["functionCall"]["name"].as_str(),
|
||||
part["functionCall"]["args"].as_object(),
|
||||
) {
|
||||
tool_calls.push(ToolCall::new(name.to_string(), json!(args), None));
|
||||
let thought_signature = part["thoughtSignature"]
|
||||
.as_str()
|
||||
.or_else(|| part["thought_signature"].as_str())
|
||||
.map(|s| s.to_string());
|
||||
tool_calls.push(
|
||||
ToolCall::new(name.to_string(), json!(args), None)
|
||||
.with_thought_signature(thought_signature),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,12 +361,16 @@ pub fn gemini_build_chat_completions_body(
|
||||
},
|
||||
MessageContent::ToolCalls(MessageContentToolCalls { tool_results, .. }) => {
|
||||
let model_parts: Vec<Value> = tool_results.iter().map(|tool_result| {
|
||||
json!({
|
||||
let mut part = json!({
|
||||
"functionCall": {
|
||||
"name": tool_result.call.name,
|
||||
"args": tool_result.call.arguments,
|
||||
}
|
||||
})
|
||||
});
|
||||
if let Some(sig) = &tool_result.call.thought_signature {
|
||||
part["thoughtSignature"] = json!(sig);
|
||||
}
|
||||
part
|
||||
}).collect();
|
||||
let function_parts: Vec<Value> = tool_results.into_iter().map(|tool_result| {
|
||||
json!({
|
||||
|
||||
@@ -204,6 +204,7 @@ impl Agent {
|
||||
|
||||
pub fn init_agent_variables(
|
||||
agent_variables: &[AgentVariable],
|
||||
pre_set_variables: Option<&AgentVariables>,
|
||||
no_interaction: bool,
|
||||
) -> Result<AgentVariables> {
|
||||
let mut output = IndexMap::new();
|
||||
@@ -214,6 +215,10 @@ impl Agent {
|
||||
let mut unset_variables = vec![];
|
||||
for agent_variable in agent_variables {
|
||||
let key = agent_variable.name.clone();
|
||||
if let Some(value) = pre_set_variables.and_then(|v| v.get(&key)) {
|
||||
output.insert(key, value.clone());
|
||||
continue;
|
||||
}
|
||||
if let Some(value) = agent_variable.default.clone() {
|
||||
output.insert(key, value);
|
||||
continue;
|
||||
|
||||
+10
-4
@@ -2607,8 +2607,11 @@ impl Config {
|
||||
None => return Ok(()),
|
||||
};
|
||||
if !agent.defined_variables().is_empty() && agent.shared_variables().is_empty() {
|
||||
let new_variables =
|
||||
Agent::init_agent_variables(agent.defined_variables(), self.info_flag)?;
|
||||
let new_variables = Agent::init_agent_variables(
|
||||
agent.defined_variables(),
|
||||
self.agent_variables.as_ref(),
|
||||
self.info_flag,
|
||||
)?;
|
||||
agent.set_shared_variables(new_variables);
|
||||
}
|
||||
if !self.info_flag {
|
||||
@@ -2626,8 +2629,11 @@ impl Config {
|
||||
let shared_variables = agent.shared_variables().clone();
|
||||
let session_variables =
|
||||
if !agent.defined_variables().is_empty() && shared_variables.is_empty() {
|
||||
let new_variables =
|
||||
Agent::init_agent_variables(agent.defined_variables(), self.info_flag)?;
|
||||
let new_variables = Agent::init_agent_variables(
|
||||
agent.defined_variables(),
|
||||
self.agent_variables.as_ref(),
|
||||
self.info_flag,
|
||||
)?;
|
||||
agent.set_shared_variables(new_variables.clone());
|
||||
new_variables
|
||||
} else {
|
||||
|
||||
@@ -756,6 +756,10 @@ pub struct ToolCall {
|
||||
pub name: String,
|
||||
pub arguments: Value,
|
||||
pub id: Option<String>,
|
||||
/// Gemini 3's thought signature for stateful reasoning in function calling.
|
||||
/// Must be preserved and sent back when submitting function responses.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub thought_signature: Option<String>,
|
||||
}
|
||||
|
||||
type CallConfig = (String, String, Vec<String>, HashMap<String, String>);
|
||||
@@ -785,9 +789,15 @@ impl ToolCall {
|
||||
name,
|
||||
arguments,
|
||||
id,
|
||||
thought_signature: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_thought_signature(mut self, thought_signature: Option<String>) -> Self {
|
||||
self.thought_signature = thought_signature;
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn eval(&self, config: &GlobalConfig) -> Result<Value> {
|
||||
let (call_name, cmd_name, mut cmd_args, envs) = match &config.read().agent {
|
||||
Some(agent) => self.extract_call_config_from_agent(config, agent)?,
|
||||
|
||||
Reference in New Issue
Block a user