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

@daydreamsai/cli

v0.3.22

Published

Command-line interface context and utilities for Daydreams agents, enabling interactive terminal-based conversations.

Readme

@daydreamsai/cli

Command-line interface context and utilities for Daydreams agents, enabling interactive terminal-based conversations.

Installation

npm install @daydreamsai/cli

Quick Start

import { createDreams } from '@daydreamsai/core';
import { cliExtension } from '@daydreamsai/cli';
import { openai } from '@ai-sdk/openai';

// Create an agent with CLI support
const agent = createDreams({
  model: openai('gpt-4'),
  extensions: [cliExtension()]
});

await agent.start();

// The CLI will automatically start an interactive session
// Type messages and get responses in the terminal
// Type "exit" to quit

Features

  • 🖥️ Interactive Terminal Interface: Built-in readline interface for conversations
  • 📥 CLI Input Handler: Automatic message handling from terminal input
  • 📤 CLI Output Handler: Formatted responses to terminal
  • 🔄 Session Management: Persistent CLI sessions with context
  • 🛠️ Service Integration: Readline service for input management

Components

CLI Context

The CLI context provides a terminal-based conversation interface:

import { cli } from '@daydreamsai/cli';

// Use directly with an agent
const agent = createDreams({
  contexts: [cli],
  // ... other config
});

CLI Extension

Bundles everything needed for CLI interactions:

import { cliExtension } from '@daydreamsai/cli';

const extension = cliExtension();
// Includes: CLI context, readline service, input/output handlers

Readline Service

Manages terminal I/O operations:

import { readlineService } from '@daydreamsai/cli';

// Registered automatically with cliExtension
// Provides readline interface to other components

Usage Examples

Basic CLI Agent

import { createDreams, action } from '@daydreamsai/core';
import { cliExtension } from '@daydreamsai/cli';
import { openai } from '@ai-sdk/openai';
import * as z from 'zod';

// Define actions for the CLI agent
const calculateAction = action({
  name: 'calculate',
  description: 'Perform calculations',
  schema: z.object({
    expression: z.string()
  }),
  handler: async ({ call }) => {
    // Simple eval for demo (use math library in production)
    const result = eval(call.data.expression);
    return { result };
  }
});

const agent = createDreams({
  model: openai('gpt-4'),
  extensions: [cliExtension()],
  actions: [calculateAction]
});

await agent.start();
console.log('CLI Agent started. Type "exit" to quit.');

Custom CLI Context

import { context, input, output } from '@daydreamsai/core';
import * as z from 'zod';

const customCli = context({
  type: 'custom-cli',
  schema: z.object({
    username: z.string(),
    sessionId: z.string()
  }),
  inputs: {
    'terminal:input': input({
      async subscribe(send, { args }) {
        // Custom input handling
        const rl = readline.createInterface({
          input: process.stdin,
          output: process.stdout,
          prompt: `${args.username}> `
        });
        
        // ... handle input
      }
    })
  },
  outputs: {
    'terminal:output': output({
      schema: z.object({
        message: z.string(),
        formatting: z.enum(['plain', 'markdown', 'code'])
      }),
      handler({ data }) {
        // Custom output formatting
        switch(data.formatting) {
          case 'code':
            console.log('```\n' + data.message + '\n```');
            break;
          default:
            console.log(data.message);
        }
      }
    })
  }
});

API Reference

cli

Pre-configured CLI context with:

  • Type: 'cli'
  • Schema: { user: z.string() }
  • Max Steps: 100
  • Inputs: cli:message - Handles terminal input
  • Outputs: cli:message - Sends responses to terminal

cliExtension()

Creates a CLI extension bundle containing:

  • CLI context
  • Readline service
  • Input/output handlers

readlineService

Service that provides readline interface for terminal I/O.

Integration with Other Packages

Works seamlessly with other Daydreams packages:

import { createDreams } from '@daydreamsai/core';
import { cliExtension } from '@daydreamsai/cli';
import { browserExtension } from '@daydreamsai/browser';

const agent = createDreams({
  extensions: [
    cliExtension(),     // Terminal interface
    browserExtension()  // Web automation
  ]
});

// Agent can now interact via CLI and control browser

Examples

Best Practices

  1. Exit Handling: Always provide a way to exit (default: type "exit")
  2. Error Display: Format errors clearly in terminal output
  3. Input Validation: Validate user input before processing
  4. Session State: Use context args to maintain session info
  5. Output Formatting: Use appropriate formatting for readability

Contributing

See CONTRIBUTING.md for development guidelines.

License

MIT