Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
mod ai_peer;
use inbound::credentials as auth;
mod inbound;
mod outbound;
use outbound::{d1, dss_internal, lexical_service, secrets, storage};
mod constants;
mod domain;
use inbound::durable_object;
mod error;
mod generated;
pub mod keepalive;
mod metrics;
mod mutex;
mod socket;
mod state;
mod tags;
mod timeout;
use tracing_subscriber::{
EnvFilter, fmt::time::UtcTime, layer::SubscriberExt, util::SubscriberInitExt,
};
use worker::{Context, Env, Result, event};
pub const GIT_DESCRIBE: &str = env!("GIT_DESCRIBE");
fn inner_start() {
let filter = EnvFilter::new("sync_service=trace,loro=warn");
let fmt_layer = tracing_subscriber::fmt::layer()
.json()
.with_file(true)
.with_target(true)
.with_line_number(true)
.with_level(true)
.with_ansi(false)
.with_timer(UtcTime::rfc_3339());
let layered = tracing_subscriber::registry().with(filter);
#[cfg(target_arch = "wasm32")]
{
use tracing_web::{MakeConsoleWriter, performance_layer};
layered
.with(fmt_layer.with_writer(MakeConsoleWriter))
.with(
performance_layer()
.with_details_from_fields(tracing_subscriber::fmt::format::Pretty::default()),
)
.with(worker_rs_otel::OtelLayer::new("sync-service"))
.init();
}
#[cfg(not(target_arch = "wasm32"))]
{
layered.with(fmt_layer).init();
}
tracing::info!("Starting. GIT_DESCRIBE = [{GIT_DESCRIBE}]");
}
#[event(start)]
fn start() {
inner_start()
}
#[event(fetch)]
async fn fetch(req: worker::Request, env: Env, ctx: Context) -> Result<worker::Response> {
use crate::inbound::worker::router;
use tracing::Instrument;
let traceparent = worker_rs_otel::traceparent_from_request(&req);
let (remote_id, remote_parent) = worker_rs_otel::remote_fields(traceparent.as_ref());
let method = req.method().to_string();
let path = req.path();
let span = tracing::info_span!(
"request",
http.method = %method,
http.path = %path,
trace.remote_id = %remote_id,
trace.remote_parent = %remote_parent,
);
worker_rs_otel::scope(&env, &ctx, router(env.clone(), req).instrument(span)).await
}
#[cfg(feature = "openapi")]
pub mod swagger;