move the review classifier, agent login and inference types into swarm-wire
This commit is contained in:
parent
bdeec3f744
commit
6ea13c02e3
44 changed files with 344 additions and 332 deletions
|
|
@ -139,7 +139,7 @@ Swarm-level:
|
||||||
- **`swarm-queue-client/`** — the one authenticated connect to the swarm
|
- **`swarm-queue-client/`** — the one authenticated connect to the swarm
|
||||||
NATS queue.
|
NATS queue.
|
||||||
- **`swarm-wire/`** — serde-only request and reply contracts services
|
- **`swarm-wire/`** — serde-only request and reply contracts services
|
||||||
exchange over the queue (builder, claude login), so naming one links
|
exchange over the queue (builder, claude login, review classifier, agent inference and login), so naming one links
|
||||||
neither the queue client nor the store client.
|
neither the queue client nor the store client.
|
||||||
- **`swarm-nats-auth/`** — NATS auth-callout responder; without it the
|
- **`swarm-nats-auth/`** — NATS auth-callout responder; without it the
|
||||||
queue is fail-closed and admits nobody.
|
queue is fail-closed and admits nobody.
|
||||||
|
|
|
||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
|
|
@ -1692,6 +1692,7 @@ dependencies = [
|
||||||
"swarm-agent-verify",
|
"swarm-agent-verify",
|
||||||
"swarm-queue-client",
|
"swarm-queue-client",
|
||||||
"swarm-secret-client",
|
"swarm-secret-client",
|
||||||
|
"swarm-wire",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
|
|
@ -2060,6 +2061,7 @@ dependencies = [
|
||||||
"swarm-agent-verify",
|
"swarm-agent-verify",
|
||||||
"swarm-queue-client",
|
"swarm-queue-client",
|
||||||
"swarm-secret-client",
|
"swarm-secret-client",
|
||||||
|
"swarm-wire",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
|
@ -5035,10 +5037,10 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"strum",
|
"strum",
|
||||||
"swarm-secret-client",
|
"swarm-secret-client",
|
||||||
|
"swarm-wire",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"utoipa",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -5058,6 +5060,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"swarm-queue-client",
|
"swarm-queue-client",
|
||||||
"swarm-secret-client",
|
"swarm-secret-client",
|
||||||
|
"swarm-wire",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
@ -5089,6 +5092,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"utoipa",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ runtime's key by hand in the secret store
|
||||||
|
|
||||||
The per-agent equivalent is [`inference.md`](inference.md), where the
|
The per-agent equivalent is [`inference.md`](inference.md), where the
|
||||||
controller writes model and effort to a queue KV bucket
|
controller writes model and effort to a queue KV bucket
|
||||||
(`swarm-queue-client/src/agent_inference.rs`) and each agent reads its own
|
(`swarm-wire/src/agent_inference.rs`) and each agent reads its own
|
||||||
key.
|
key.
|
||||||
|
|
||||||
### The service account
|
### The service account
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// today, and the frontend only ever reads a handful of these fields.
|
// today, and the frontend only ever reads a handful of these fields.
|
||||||
// Extend as more of the page gets rebuilt against real data.
|
// Extend as more of the page gets rebuilt against real data.
|
||||||
|
|
||||||
// Mirrors `swarm_queue_client::agent_inference::Source`.
|
// Mirrors `swarm_wire::agent_inference::Source`.
|
||||||
export type InferenceSource = "swarm" | "agent_nix" | "local_file" | "default";
|
export type InferenceSource = "swarm" | "agent_nix" | "local_file" | "default";
|
||||||
|
|
||||||
export interface AgentState {
|
export interface AgentState {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export interface TokenUsage {
|
||||||
cache_creation_input_tokens?: number;
|
cache_creation_input_tokens?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `swarm_queue_client::agent_inference::Source`.
|
// `swarm_wire::agent_inference::Source`.
|
||||||
export type InferenceSource = "swarm" | "agent_nix" | "local_file" | "default";
|
export type InferenceSource = "swarm" | "agent_nix" | "local_file" | "default";
|
||||||
|
|
||||||
// Mirrors `hive_agent::swarm_agent_state::AgentStateMsg` field-for-field
|
// Mirrors `hive_agent::swarm_agent_state::AgentStateMsg` field-for-field
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ swarm-queue-client = { workspace = true, features = [
|
||||||
] }
|
] }
|
||||||
# The spelling of the token the queue connection presents.
|
# The spelling of the token the queue connection presents.
|
||||||
swarm-agent-verify.workspace = true
|
swarm-agent-verify.workspace = true
|
||||||
|
swarm-wire.workspace = true
|
||||||
# This agent's own queue secret, read from the store under its own certificate.
|
# This agent's own queue secret, read from the store under its own certificate.
|
||||||
swarm-secret-client.workspace = true
|
swarm-secret-client.workspace = true
|
||||||
# The directory an AGENTS.md edit is applied in, and the file it is written
|
# The directory an AGENTS.md edit is applied in, and the file it is written
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use chrono::Utc;
|
||||||
use hive_claude::TokenUsage;
|
use hive_claude::TokenUsage;
|
||||||
use rusqlite::{Connection, params};
|
use rusqlite::{Connection, params};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use swarm_queue_client::agent_inference::Source;
|
use swarm_wire::agent_inference::Source;
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
|
|
||||||
use crate::harness_state::{
|
use crate::harness_state::{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use swarm_queue_client::agent_inference::Source;
|
use swarm_wire::agent_inference::Source;
|
||||||
|
|
||||||
/// Path to the `hyperhive-model` file. The harness only reads it, as the
|
/// Path to the `hyperhive-model` file. The harness only reads it, as the
|
||||||
/// fallback in [`local_model`]. Overridable via `HYPERHIVE_MODEL_FILE` for
|
/// fallback in [`local_model`]. Overridable via `HYPERHIVE_MODEL_FILE` for
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ use serde::Serialize;
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
use tokio::time::{Interval, MissedTickBehavior};
|
use tokio::time::{Interval, MissedTickBehavior};
|
||||||
|
|
||||||
use swarm_queue_client::agent_inference::Effective;
|
|
||||||
use swarm_queue_client::agent_login::Login;
|
|
||||||
use swarm_queue_client::wanted::AgentState;
|
use swarm_queue_client::wanted::AgentState;
|
||||||
|
use swarm_wire::agent_inference::Effective;
|
||||||
|
use swarm_wire::agent_login::Login;
|
||||||
|
|
||||||
use crate::events::{Bus, BusEvent, LiveEvent, TurnState};
|
use crate::events::{Bus, BusEvent, LiveEvent, TurnState};
|
||||||
use crate::login::LoginState;
|
use crate::login::LoginState;
|
||||||
|
|
@ -337,8 +337,8 @@ mod tests {
|
||||||
use crate::events::{BusEvent, LiveEvent, TurnState};
|
use crate::events::{BusEvent, LiveEvent, TurnState};
|
||||||
use crate::login::LoginState;
|
use crate::login::LoginState;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use swarm_queue_client::agent_inference::{Effective, Source};
|
|
||||||
use swarm_queue_client::wanted::AgentState;
|
use swarm_queue_client::wanted::AgentState;
|
||||||
|
use swarm_wire::agent_inference::{Effective, Source};
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
use tokio::time::{Duration, Instant};
|
use tokio::time::{Duration, Instant};
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ mod tests {
|
||||||
..msg()
|
..msg()
|
||||||
})
|
})
|
||||||
.expect("serialises");
|
.expect("serialises");
|
||||||
let decoded: swarm_queue_client::agent_login::Login =
|
let decoded: swarm_wire::agent_login::Login =
|
||||||
serde_json::from_slice(&bytes).expect("decodes");
|
serde_json::from_slice(&bytes).expect("decodes");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
decoded.needs_login,
|
decoded.needs_login,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use swarm_queue_client::agent_inference::{AgentInference, Effort, Read, Source, read_own};
|
use swarm_queue_client::agent_inference::{Read, read_own};
|
||||||
|
use swarm_wire::agent_inference::{AgentInference, Effort, Source};
|
||||||
|
|
||||||
use crate::events::Bus;
|
use crate::events::Bus;
|
||||||
use crate::harness_state::{configured_effort, configured_model, local_effort, local_model};
|
use crate::harness_state::{configured_effort, configured_model, local_effort, local_model};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use swarm_queue_client::agent_inference::Source;
|
use swarm_wire::agent_inference::Source;
|
||||||
|
|
||||||
use crate::login::LoginState;
|
use crate::login::LoginState;
|
||||||
use crate::login_session::drop_if_finished;
|
use crate::login_session::drop_if_finished;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ swarm-queue-client = { workspace = true, features = [
|
||||||
] }
|
] }
|
||||||
# The spelling of the token the queue connection presents.
|
# The spelling of the token the queue connection presents.
|
||||||
swarm-agent-verify.workspace = true
|
swarm-agent-verify.workspace = true
|
||||||
|
swarm-wire.workspace = true
|
||||||
# The agent's own queue credential, read under its store identity.
|
# The agent's own queue credential, read under its store identity.
|
||||||
swarm-secret-client.workspace = true
|
swarm-secret-client.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ use hive_runtime::{
|
||||||
AcpCommand, AcpRuntime, PermissionAsk, PermissionPolicy, Runtime as _, RuntimeSpec, TurnStop,
|
AcpCommand, AcpRuntime, PermissionAsk, PermissionPolicy, Runtime as _, RuntimeSpec, TurnStop,
|
||||||
};
|
};
|
||||||
use hive_sh4re::permissions::Permission;
|
use hive_sh4re::permissions::Permission;
|
||||||
use swarm_queue_client::agent_inference::AgentInference;
|
use swarm_wire::agent_inference::AgentInference;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
|
||||||
use crate::swarm_term::Output;
|
use crate::swarm_term::Output;
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,9 @@ use std::sync::{Arc, OnceLock};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use hive_sh4re::permissions::Permission;
|
use hive_sh4re::permissions::Permission;
|
||||||
use swarm_queue_client::agent_inference::{self, AgentInference, read_own};
|
use swarm_queue_client::agent_inference::{self, read_own};
|
||||||
use swarm_queue_client::agent_permissions::{self, HIVE_COPY_PATH, HiveCopy};
|
use swarm_queue_client::agent_permissions::{self, HIVE_COPY_PATH, HiveCopy};
|
||||||
|
use swarm_wire::agent_inference::AgentInference;
|
||||||
|
|
||||||
use crate::swarm_term::{Target, connect};
|
use crate::swarm_term::{Target, connect};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -902,7 +902,7 @@ in
|
||||||
# so it would cover every agent's) and no `$KV` write.
|
# so it would cover every agent's) and no `$KV` write.
|
||||||
"--agent-token-publish-subject ${lib.escapeShellArg "\$\$JS.API.DIRECT.GET.KV_agent-schedules.\$\$KV.agent-schedules.{agent}"}"
|
"--agent-token-publish-subject ${lib.escapeShellArg "\$\$JS.API.DIRECT.GET.KV_agent-schedules.\$\$KV.agent-schedules.{agent}"}"
|
||||||
# Its own key of the `agent-inference` KV bucket
|
# Its own key of the `agent-inference` KV bucket
|
||||||
# (`swarm_queue_client::agent_inference`), on the same terms.
|
# (`swarm_wire::agent_inference`), on the same terms.
|
||||||
"--agent-token-publish-subject ${lib.escapeShellArg "\$\$JS.API.DIRECT.GET.KV_agent-inference.\$\$KV.agent-inference.{agent}"}"
|
"--agent-token-publish-subject ${lib.escapeShellArg "\$\$JS.API.DIRECT.GET.KV_agent-inference.\$\$KV.agent-inference.{agent}"}"
|
||||||
# Its own key of the `agent-permissions` KV bucket
|
# Its own key of the `agent-permissions` KV bucket
|
||||||
# (`swarm_queue_client::agent_permissions`), on the same terms:
|
# (`swarm_queue_client::agent_permissions`), on the same terms:
|
||||||
|
|
|
||||||
|
|
@ -104,22 +104,21 @@ swarm-controller-api = { workspace = true, features = ["schema"] }
|
||||||
# config the crate spells.
|
# config the crate spells.
|
||||||
# `agent-term`: likewise every agent's terminal stream, plus the consumer it
|
# `agent-term`: likewise every agent's terminal stream, plus the consumer it
|
||||||
# replays that stream through.
|
# replays that stream through.
|
||||||
# `schema`: the review classifier try-out API serves the shapes the queue
|
|
||||||
# carries.
|
|
||||||
swarm-queue-client = { workspace = true, features = [
|
swarm-queue-client = { workspace = true, features = [
|
||||||
"kv",
|
"kv",
|
||||||
"agent-permissions",
|
"agent-permissions",
|
||||||
"subagent-term",
|
"subagent-term",
|
||||||
"agent-term",
|
"agent-term",
|
||||||
"schema",
|
|
||||||
] }
|
] }
|
||||||
# `matrix_account.rs` writes the credential this daemon's route accepts. Same
|
# `matrix_account.rs` writes the credential this daemon's route accepts. Same
|
||||||
# crate the hive reads it back with, which is the point: the path, the field
|
# crate the hive reads it back with, which is the point: the path, the field
|
||||||
# name and the object's shape are agreements between the two ends, and a
|
# name and the object's shape are agreements between the two ends, and a
|
||||||
# second spelling here would be a store this hive could not read.
|
# second spelling here would be a store this hive could not read.
|
||||||
swarm-secret-client.workspace = true
|
swarm-secret-client.workspace = true
|
||||||
# The builder and claude login subjects, requests and replies it sends.
|
# The builder, claude login and review classifier subjects, requests and
|
||||||
swarm-wire.workspace = true
|
# replies it sends. `schema`: the review classifier try-out API serves the
|
||||||
|
# same shapes, so they derive `ToSchema`.
|
||||||
|
swarm-wire = { workspace = true, features = ["schema"] }
|
||||||
# The appservice calls `matrix_account::agent_token` mints agents' accounts
|
# The appservice calls `matrix_account::agent_token` mints agents' accounts
|
||||||
# with — shared with `swarm-matrix-ctl`, which pins the same device id.
|
# with — shared with `swarm-matrix-ctl`, which pins the same device id.
|
||||||
swarm-matrix-client.workspace = true
|
swarm-matrix-client.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex, PoisonError};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use futures_util::StreamExt as _;
|
use futures_util::StreamExt as _;
|
||||||
use swarm_queue_client::agent_login::Login;
|
use swarm_wire::agent_login::Login;
|
||||||
|
|
||||||
/// The latest login flag each agent reported, by agent.
|
/// The latest login flag each agent reported, by agent.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ pub(crate) struct ArchetypeView {
|
||||||
/// As `PUT /api/agents/{name}/inference` takes them.
|
/// As `PUT /api/agents/{name}/inference` takes them.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[schema(value_type = Option<Object>)]
|
#[schema(value_type = Option<Object>)]
|
||||||
inference: Option<swarm_queue_client::agent_inference::AgentInference>,
|
inference: Option<swarm_wire::agent_inference::AgentInference>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One archetype a source declared and this daemon refused.
|
/// One archetype a source declared and this daemon refused.
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ use std::sync::{Arc, OnceLock};
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
use crate::webhook::DeliveryKind;
|
use crate::webhook::DeliveryKind;
|
||||||
use swarm_queue_client::review_classifier::Commit;
|
|
||||||
use swarm_secret_client::stored_secret::StoredSecret;
|
use swarm_secret_client::stored_secret::StoredSecret;
|
||||||
|
use swarm_wire::review_classifier::Commit;
|
||||||
|
|
||||||
pub mod agent_token;
|
pub mod agent_token;
|
||||||
mod api;
|
mod api;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
//! running on.
|
//! running on.
|
||||||
//!
|
//!
|
||||||
//! Each agent's settings are one value under its own key of `agent-inference`
|
//! Each agent's settings are one value under its own key of `agent-inference`
|
||||||
//! (`swarm_queue_client::agent_inference`), which this daemon alone writes.
|
//! (`swarm_wire::agent_inference`), which this daemon alone writes.
|
||||||
//! The agent reads its key and applies each set field over its local value;
|
//! The agent reads its key and applies each set field over its local value;
|
||||||
//! an unset field leaves the local value in force.
|
//! an unset field leaves the local value in force.
|
||||||
//!
|
//!
|
||||||
|
|
@ -23,7 +23,8 @@ use axum::http::StatusCode;
|
||||||
use futures_util::StreamExt as _;
|
use futures_util::StreamExt as _;
|
||||||
use problem_details::ProblemDetails;
|
use problem_details::ProblemDetails;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use swarm_queue_client::agent_inference::{self, AgentInference, Effective, Effort, Source};
|
use swarm_queue_client::agent_inference;
|
||||||
|
use swarm_wire::agent_inference::{AgentInference, Effective, Effort, Source};
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
use crate::routes::{AppState, error_problem, wanted_error_status};
|
use crate::routes::{AppState, error_problem, wanted_error_status};
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue