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

@yassinehamouten/glm-agent-sdk

v1.0.0

Published

GLM Agent SDK - Build AI agents with GLM API (Zhipu AI / BigModel)

Readme

GLM Agent SDK

npm

A TypeScript SDK for building AI agents with GLM API (Zhipu AI / BigModel). Create autonomous agents that can understand codebases, edit files, run commands, and execute complex workflows.

Why GLM Agent SDK?

  • Cost-effective: GLM models offer competitive pricing
  • Flexible models: Support for glm-4-plus, glm-4, glm-4.7, glm-4-air, glm-4-flash, and more
  • Tool calling: Built-in support for Bash, file operations, and custom tools
  • TypeScript: Fully typed for great developer experience

Get started

Install the GLM Agent SDK:

npm install @yassinehamouten/glm-agent-sdk

Usage

import { query } from '@yassinehamouten/glm-agent-sdk';

async function runAgent() {
  const generator = query({
    prompt: 'Analyze this codebase and suggest improvements',
    options: {
      model: 'glm-4.7',
      maxTurns: 10,
    }
  });

  for await (const message of generator) {
    switch (message.type) {
      case 'system':
        console.log('System:', message.message);
        break;
      case 'user':
        console.log('Agent:', message.content);
        break;
      case 'result':
        if (message.subtype === 'success') {
          console.log('✅ Success in', message.duration_ms, 'ms');
        } else {
          console.log('❌ Error:', message.errors);
        }
        break;
    }
  }
}

Configuration

Set your GLM API key as an environment variable:

export GLM_API_KEY="your-api-key-here"
export GLM_MODEL="glm-4.7"  # Optional, defaults to glm-4-plus

You can also use ANTHROPIC_API_KEY and ANTHROPIC_MODEL if you have those set up.

Available Models

  • glm-4-plus - Most capable model (default)
  • glm-4 - High-performance model
  • glm-4.7 - Latest version (recommended)
  • glm-4-air - Faster, more cost-effective
  • glm-4-flash - Fastest for simple tasks
  • glm-4-long - Extended context window

See Zhipu AI documentation for the full list of models.

Tools

The SDK includes built-in tools that the agent can use:

| Tool | Description | |------|-------------| | Bash | Execute shell commands | | read_file | Read file contents | | write_file | Write content to files |

You can control which tools are available:

const generator = query({
  prompt: 'List all files in the current directory',
  options: {
    allowedTools: ['Bash'],  // Only allow Bash
    // or
    disallowedTools: ['write_file'],  // Disable write_file
  }
});

Features

This SDK provides a complete agent building experience:

| Feature | Status | |---------|--------| | query() async generator | ✅ | | SDK message format | ✅ | | Tool calling | ✅ | | Multi-turn conversations | ✅ | | System prompts | ✅ | | Error handling | ✅ | | Cost tracking | ✅ |

Advanced Usage

Custom System Prompt

const generator = query({
  prompt: 'Write a function to sort an array',
  options: {
    systemPrompt: 'You are an expert TypeScript developer. Always include type annotations.',
  }
});

Limit Conversation Turns

const generator = query({
  prompt: 'Refactor this code',
  options: {
    maxTurns: 5,  // Maximum 5 tool calls
  }
});

API Endpoint

This SDK uses the GLM Anthropic-compatible API at https://api.z.ai/api/anthropic, which provides an Anthropic-compatible interface for GLM models. This allows drop-in compatibility with tools designed for Anthropic's API.

License

MIT © Yassine Hamouten

Links

Support