npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fusilier/calendarai

v0.2.2

Published

Production-grade Calendar AI orchestration for Next.js (App Router) with pluggable calendar providers (Zimbra/CalDAV), OpenAI Responses model calls, strict plan schemas, idempotency, audit/outbox, and RBAC.

Readme

@fusilier/calendarai

Production-grade Calendar AI orchestration for Next.js (App Router): sessions → objective → snapshot → resolution → plan → validate/explain/approve → execute → verify/finalize.

Open-core note: this package is typically used as the “orchestration layer”. In an open-core strategy, you may expose calendarai-core publicly and keep enterprise connectors/agents private.

Key Features

  • Deterministic, confirmation-based workflow (objective approval + plan approval).
  • Strict JSON Schema validation for LLM outputs (server-side validation).
  • Pluggable architecture:
    • Calendar Provider (Mock, Zimbra/CalDAV, etc.)
    • Repository (In-memory, Postgres, custom)
    • Model Calls (OpenAI Responses API adapter, custom)
  • Idempotency for create operations (prevents duplicate event creation).
  • Audit trail + outbox hooks for enterprise workflows.
  • Next.js App Router integration via a single catch-all route handler.

Requirements

  • Node.js: 18+ (recommended 20+)
  • Next.js: App Router (Node runtime required for server-side API handlers)
  • An OpenAI API key (if using the built-in OpenAI adapter)

Installation

npm install @fusilier/calendarai
# or
pnpm add @fusilier/calendarai
# or
yarn add @fusilier/calendarai

Quickstart (Next.js App Router)

Create the catch-all route:

app/api/calendar-ai/[...path]/route.ts

import {
  createCalendarAIRouteHandlers,
  InMemoryCalendarAIRepository,
  MockCalendarProvider,
  OpenAIResponsesModelCalls,
} from "@fusilier/calendarai";

const repo = new InMemoryCalendarAIRepository();
const calendarProvider = new MockCalendarProvider();

const modelCalls = new OpenAIResponsesModelCalls({
  apiKey: process.env.OPENAI_API_KEY!,
  model: process.env.OPENAI_MODEL ?? "gpt-4o-mini",
});

export const { GET, POST } = createCalendarAIRouteHandlers({
  basePath: "/api/calendar-ai",
  repo,
  calendarProvider,
  modelCalls,
  auth: async () => ({
    userId: "demo-user",
    tenantId: "demo-tenant",
    calId: "primary",
    timezone: "Europe/Paris",
    scopes: ["calendar_ai:write"],
  }),
});

// IMPORTANT: Next.js must run this route in Node runtime.
export const runtime = "nodejs";

Set environment variables:

OPENAI_API_KEY=...
OPENAI_MODEL=gpt-4o-mini

API Surface (Default Routes)

Base path: /api/calendar-ai

  • GET /health
  • POST /sessions
  • POST /sessions/:sessionId/objectives:interpret
  • POST /sessions/:sessionId/objectives/:objectiveId:approve
  • POST /sessions/:sessionId/context-snapshots
  • POST /sessions/:sessionId/resolutions
  • POST /sessions/:sessionId/plans
  • POST /sessions/:sessionId/plans/:planId:validate
  • POST /sessions/:sessionId/plans/:planId:explain
  • POST /sessions/:sessionId/plans/:planId:approve
  • POST /sessions/:sessionId/plans/:planId:execute
  • GET /executions/:executionId
  • POST /executions/:executionId:verify
  • POST /executions/:executionId:finalize

Typical Workflow

  1. Create a session
  2. Interpret objective from free text
  3. Approve objective (locks intent)
  4. Create snapshot (pull calendar window)
  5. Create resolution (select relevant events)
  6. Create plan (strict JSON operations)
  7. Validate plan (schema + risk policy)
  8. Explain plan (UI-friendly summaries)
  9. Approve plan
  10. Execute plan (provider calls + idempotency)
  11. Verify + finalize

Configuration

Auth

You must provide an auth(req) resolver returning an AuthContext:

  • userId, tenantId, calId, timezone
  • scopes[] (RBAC)
  • optional providerAuth (opaque credentials/token used by the calendar provider)

RBAC

Non-GET endpoints require calendar_ai:write by default.

Repository

You can swap persistence by implementing the repository interface and passing it into the factory:

  • InMemoryCalendarAIRepository is recommended for development only.
  • For production, use Postgres or your own durable backend.

Calendar Provider

  • MockCalendarProvider is included for development/testing.
  • Production providers should implement optimistic concurrency (ETag / If-Match) and robust error mapping.

Model Calls

  • OpenAIResponsesModelCalls uses the OpenAI Responses API with structured outputs.
  • You may implement your own model adapter to use different models/vendors or stricter internal prompt policies.

Security Considerations

  • Treat all calendar operations as high-impact: always require explicit approvals.
  • Use server-side schema validation and reject malformed LLM outputs.
  • Store secrets only in server environment variables; never expose provider credentials to the browser.
  • Ensure audit logs do not leak sensitive content (PII, private event notes) unless required by business needs.

Development

npm install
npm run build
npm test

Versioning

This project follows Semantic Versioning (SemVer) where possible.

License

Copyright (c) Fusilier International Group (FIG).

  • If this package is part of your commercial/private distribution: use UNLICENSED or SEE LICENSE IN LICENSE.
  • If this package is part of your open-core public distribution: use a standard OSI license (e.g., Apache-2.0) and keep enterprise modules private.

Support

For commercial licensing, enterprise connectors, and integration support: