Skip to content

Upstream sync#153

Closed
bilawalriaz wants to merge 41 commits into
spacedriveapp:mainfrom
bilawalriaz:upstream-sync
Closed

Upstream sync#153
bilawalriaz wants to merge 41 commits into
spacedriveapp:mainfrom
bilawalriaz:upstream-sync

Conversation

@bilawalriaz

Copy link
Copy Markdown
Contributor

No description provided.

l33t0 and others added 30 commits February 21, 2026 21:42
…and per-agent context

Wire the metrics server startup, fix LLM histogram buckets, and resolve all
known limitations from spacedriveapp#35: agent_id/tier labels are no longer hardcoded to
"unknown", memory_entry_count gauge is instrumented, and six new metrics
cover token usage, estimated USD cost, branch/worker lifecycle, process
errors, and memory audit trail.

- Wire start_metrics_server() call in main.rs
- Extend LLM duration buckets to [0.1 … 120s]
- Add agent_id + process_type context to SpacebotModel, wired at all 7 call sites
- Add spacebot_llm_tokens_total (input/output/cached_input)
- Add spacebot_llm_estimated_cost_dollars with static pricing table (src/llm/pricing.rs)
- Add spacebot_active_branches gauge
- Add spacebot_worker_duration_seconds histogram
- Add spacebot_process_errors_total counter with error classification
- Add spacebot_memory_updates_total counter (save/delete/forget)
- Wire memory_entry_count gauge in MemoryStore save/delete
- Add metrics docs page for docs.spacebot.sh
- Update METRICS.md and docs/metrics.md with full inventory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MiniMax was configured as ApiType::Anthropic, but build_anthropic_request
hardcodes api.anthropic.com. Requests were sent to Anthropic with a
MiniMax key, producing 401 invalid x-api-key.

Switch to ApiType::OpenAiCompletions with base_url api.minimax.io —
their OpenAI-compatible endpoint works correctly.
The debug log for empty assistant_content was invisible at default log
level. Upgrade to warn so we can see stop_reason and raw content when
the API returns an empty content array.
…ell bypass)

- Validate memory IDs as UUID format before LanceDB predicate interpolation (SQL injection)
- Restrict CORS from allow_origin(Any) to mirror_request() with explicit methods/headers
- Add 10 MiB request body size limit to prevent DoS via unlimited uploads
- Clear inherited env vars from MCP subprocesses to prevent secret leakage
- Block identity file writes (SOUL.md, IDENTITY.md, USER.md) through file tool
- Expand shell hardening: unbraced $VAR detection, dump command blocking,
  interpreter one-liner prevention (python -c, perl -e, etc.)
…mlinks

- Replace derived Debug with custom impls on 7 config structs that hold
  secrets (ProviderConfig, LlmConfig, DefaultsConfig, DiscordConfig,
  SlackConfig, TelegramConfig, TwitchConfig) — all secret fields now
  show [REDACTED] in logs and debug output
- Replace unbounded_channel with bounded channel(256) in cortex_chat
  to prevent unlimited memory growth under backpressure
- Reject symlinks within workspace in file tool resolve_path to prevent
  TOCTOU races where a path component is swapped after canonicalization
…d adapters

Convert 11 production .expect() and panic!() calls to Result-based error
handling:
- main.rs: rustls crypto provider, agent config validation, 4 permissions checks
- config.rs: provider API key resolution
- slack.rs: 4 SlackAdapterState downcasts

Startup failures now produce clean error messages instead of panics.
Add vitest test infrastructure and fix tab bar overflow on narrow
viewports.

- Install vitest, jsdom, @testing-library/react and @testing-library/jest-dom
- Add vitest.config.ts with jsdom environment and @ path alias
- Add src/test/setup.ts importing jest-dom matchers
- Add AgentTabs.test.tsx asserting overflow-x-auto and no-scrollbar
  classes are present (tests fail before the fix)
- Add overflow-x-auto and no-scrollbar to the AgentTabs container div
  so tabs are swipeable on mobile with no visible scrollbar chrome

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Upgrade routing defaults: use gemini-2.5-pro for channel/branch
  (quality tasks) and gemini-2.5-flash for worker/compactor/cortex
  (speed tasks)
- Add fallback chain: gemini-2.5-pro → gemini-2.5-flash → gemini-2.5-flash-lite
- Add native Gemini API voice transcription models alongside
  existing OpenRouter paths

Closes spacedriveapp#133
- browser.rs: replace `url::Url` with `reqwest::Url` since the `url`
  crate is not a direct dependency (reqwest re-exports it)
- server.rs: use `State<Arc<ApiState>>` extractor for the auth
  middleware, required by axum 0.8's `from_fn_with_state`
…MODEL env vars

Add environment variable support for custom Anthropic API endpoints
and authentication tokens, enabling use with API proxies (LiteLLM,
Azure AI Gateway, corporate proxies).

New environment variables:
- ANTHROPIC_BASE_URL: override the Anthropic API endpoint
- ANTHROPIC_AUTH_TOKEN: alternative to ANTHROPIC_API_KEY for proxy auth
- SPACEBOT_MODEL: override all process types with a single model

Also fixes a bug where build_anthropic_request() hardcoded the API URL
instead of using the provider's configured base_url, making custom
base URLs via TOML config ineffective.

Closes spacedriveapp#132
The VOLUME keyword is banned on Railway deployments. The /data
directory is still configured via SPACEBOT_DIR env var — volumes
should be mounted via the hosting platform's configuration instead.
Railway requires --mount=type=cache,id=<cache-id> format.
Railway requires cache mount IDs prefixed with a hardcoded service UUID
(--mount=type=cache,id=s/<service-id>-<path>), which is incompatible
with a generic open-source Dockerfile. Remove all cache mounts since
they are a build-speed optimization, not a correctness requirement.
Without shrink-0 and an initial width, framer-motion did not set the
sidebar width inline style before first paint, causing the content area
to consume the full viewport width. Adding initial={{ width }} ensures
the correct width is applied synchronously, shrink-0 prevents flex from
compressing the sidebar, and min-w-0 on the content div allows it to
shrink below its content size.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
iOS Safari zooms the page when focusing any input with font-size < 16px.
Applies font-size: 16px to all inputs and textareas at viewports ≤768px
so desktop styles are entirely unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tailwind utility classes (.text-sm etc.) have class-level specificity
(0,1,0) which wins over bare element selectors (0,0,1). Adding
!important ensures the 16px floor takes effect on mobile regardless of
what font-size utility is applied to the input.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Responsive section navigation: desktop shows w-52 vertical sidebar,
mobile shows horizontal overflow-x-auto tab bar with group dividers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace inline sidebar with shared SettingSectionNav component.
Outer wrapper gains flex-col md:flex-row for responsive stacking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace inline two-group sidebar with shared SettingSectionNav component.
Outer wrapper gains flex-col md:flex-row for responsive stacking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…/spacebot into upstream-sync

# Conflicts:
#	src/api/server.rs
#	src/tools/shell.rs
bilawalriaz and others added 11 commits February 22, 2026 19:28
…/spacebot into upstream-sync

# Conflicts:
#	src/api/server.rs
#	src/tools/browser.rs
…/spacebot into upstream-sync

# Conflicts:
#	src/api/server.rs
#	src/tools/browser.rs
Directed links between agents with relationship semantics (peer/superior/subordinate),
a shared instance-level database, and a send_agent_message tool that routes through
the existing MessagingManager pipeline. Foundation for the 0.2.0 release.

- Instance database (instance.db) with separate migration path for cross-agent data
- AgentLink model with direction (one_way/two_way) and relationship policies
- LinkStore CRUD backed by instance.db
- [[links]] config section with startup sync
- send_agent_message tool: resolves target, validates link, injects InboundMessage
- ROLE.md identity file for operational responsibilities
- Org context prompt fragment (superiors/subordinates/peers hierarchy)
- Link context prompt fragment for agent-to-agent channels
- AgentMessageSent/Received process events with SSE forwarding
- Link CRUD API endpoints + topology snapshot endpoint
Links are defined in [[links]] config sections and stored in a shared
ArcSwap<Vec<AgentLink>> that hot-reloads when config.toml changes.
No separate database needed since config is already runtime-mutable
through the API.

- Remove InstanceDb, migrations_instance/, LinkStore
- Links parsed from config at startup via AgentLink::from_config()
- Shared via Arc<ArcSwap<Vec<AgentLink>>> passed to agents and API
- File watcher reloads links on config.toml changes
- API endpoints simplified to read-only (list, agent links, topology)
- Deterministic link channel IDs from sorted agent ID pairs
- ROLE.md added to file watcher identity change detection
@bilawalriaz

Copy link
Copy Markdown
Contributor Author

I'm sorry for repeatedly PR'ing upstream instead of my own fork, i shall slow down next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants