@almanac-ai/agentlogs-next
v0.1.0
Published
Structured local logs your coding agent can read — Next/React browser SDK. One trace from the click to the backend.
Maintainers
Readme
@almanac-ai/agentlogs-next
Browser and Next.js helpers for agentlogs: browser logging, trace-propagating
fetch, and a server ingest route that writes to the local JSONL file.
npm install @almanac-ai/agentlogs-nextApp Router Setup
Mount the server route once:
// app/api/agentlogs/route.ts
export { POST } from "@almanac-ai/agentlogs-next/server";Configure the browser SDK near your app root:
"use client";
import { LoggingProvider } from "@almanac-ai/agentlogs-next";
export function Providers({ children }: { children: React.ReactNode }) {
return <LoggingProvider service="frontend">{children}</LoggingProvider>;
}Log A User Action
Prefer an explicit action scope when a workflow has multiple async steps:
import { action, logger, loggedFetch } from "@almanac-ai/agentlogs-next";
const log = logger("page-editor");
await action("publish-page", async () => {
log.info("publish.started", { pageId });
const res = await loggedFetch("/api/pages/publish", { method: "POST" });
log.info("publish.succeeded", { pageId, status: res.status });
});loggedFetch ensures a trace exists, sends it in traceparent, and records
fetch.started, fetch.completed, or fetch.failed.
Server Route
@almanac-ai/agentlogs-next/server validates incoming log envelopes and appends them
through the shared Node file sink from @almanac-ai/agentlogs-core. It honors
AGENTLOGS=0 and AGENTLOGS_FILE using the same path rules as the CLI and
Node SDK.
Develop
From the repo root:
npm install
npm run test:next
npm run build