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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@yuzumican/jules-api

v0.1.3-alpha

Published

Official Node.js client for the Jules API

Readme

Jules API JavaScript 客户端

npm version License: MIT

道歉:我们在早期版本中误将其呈现为官方库。我们对此表示歉意。这是非官方库。

Jules API 的非官方 Node.js/TypeScript 客户端库。

安装

npm install @yuzumican/jules-api

使用

import { JulesClient } from '@yuzumican/jules-api';

// 使用 API 密钥初始化客户端
const client = new JulesClient({
  apiKey: 'YOUR_API_KEY_HERE'
});

// 列出可用源码
const sources = await client.listSources();
console.log('可用源码:', sources.sources);

// 创建新会话
const session = await client.createSession({
  prompt: '创建一个 boba 应用!',
  sourceContext: {
    source: 'sources/github/yourusername/yourrepo',
    githubRepoContext: {
      startingBranch: 'main'
    }
  },
  title: 'Boba 应用会话'
});
console.log('会话创建:', session);

// 向代理发送消息
await client.sendMessage(session.id, {
  prompt: '可以让它更像柯基犬吗?'
});

// 列出会话中的活动
const activities = await client.listActivities(session.id, 30);
console.log('会话活动:', activities.activities);

API 参考

JulesClient

构造函数

const client = new JulesClient(options: JulesClientOptions)

选项:

  • apiKey: Jules API 密钥(必需)
  • baseUrl: API 基础 URL(可选,默认 'https://jules.googleapis.com/v1alpha')

方法

listSources(nextPageToken?: string): Promise<ListSourcesResponse>

列出连接到您的 Jules 账户的所有可用源码。

参数:

  • nextPageToken: 分页令牌(可选)

返回: 包含源数组和可选 nextPageToken 的对象

createSession(request: CreateSessionRequest): Promise<Session>

创建新会话。

参数:

  • request: 会话创建参数

CreateSessionRequest:

  • prompt: 会话的初始提示(必需)
  • sourceContext: 包含源码名称和 GitHub 仓库详细信息的源码上下文(必需)
  • title: 会话标题(必需)
  • requirePlanApproval: 是否需要明确计划批准(可选,默认为 false)

返回: 创建的会话对象

listSessions(pageSize?: number, nextPageToken?: string): Promise<ListSessionsResponse>

列出您的会话。

参数:

  • pageSize: 要返回的最大会话数(可选)
  • nextPageToken: 分页令牌(可选)

返回: 包含会话数组和可选 nextPageToken 的对象

approvePlan(sessionId: string): Promise<void>

批准会话的最新计划(当 requirePlanApproval 为 true 时使用)。

参数:

  • sessionId: 会话 ID(必需)
listActivities(sessionId: string, pageSize?: number, nextPageToken?: string): Promise<ListActivitiesResponse>

列出会话活动。

参数:

  • sessionId: 会话 ID(必需)
  • pageSize: 要返回的最大活动数(可选)
  • nextPageToken: 分页令牌(可选)

返回: 包含活动数组和可选 nextPageToken 的对象

sendMessage(sessionId: string, request: SendMessageRequest): Promise<void>

向会话中的代理发送消息。

参数:

  • sessionId: 会话 ID(必需)
  • request: 消息参数

SendMessageRequest:

  • prompt: 要发送的消息(必需)
getSession(sessionId: string): Promise<Session>

获取特定会话的详细信息。

参数:

  • sessionId: 会话 ID(必需)

返回: 会话对象

getSource(sourceId: string): Promise<Source>

获取特定源码的详细信息。

参数:

  • sourceId: 源 ID(必需)

返回: 源码对象

身份验证

所有 API 请求都需要使用从 Jules Web 应用 Settings 页面获取的 Jules API 密钥进行身份验证。客户端自动在所有请求的 X-Goog-Api-Key 头中包含密钥。

重要: 请安全保管您的 API 密钥。切勿将其提交到版本控制或在客户端代码中公开。

错误处理

客户端为 HTTP 错误抛出异常。请始终将 API 调用包装在 try-catch 块中:

try {
  const session = await client.createSession(request);
  console.log('成功:', session);
} catch (error) {
  console.error('错误:', error.message);
}

TypeScript 支持

此库使用 TypeScript 编写并包含完整的类型定义。您将获得出色的 IntelliSense 支持和编译时类型检查。

贡献

欢迎贡献!请阅读我们的贡献准则了解详情。

许可证

本项目根据 MIT 许可证获得许可 - 详情请参阅LICENSE 文件。