@equationalapplications/core-llm-tools

中文文档
8.4.0发布于 2026/11/13MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4602

Zero-dependency Gemini function-calling schemas and capability-scoped tool injection for edge AI agents. Works in Node.js, browser, and React Native (Hermes).

原始使用文档
文档目录11 节
  1. Overview
  2. Features
  3. Installation
  4. Quick Start
  5. 1. Defining a Tool Manifest
  6. 2. Injecting Authorized Tools
  7. 3. Built-In Tools (Grounding)
  8. Memory manifests
  9. Removed in 8.0.0: the wiki_* tool names
  10. Helpful Resources & Links
  11. Monorepo Ecosystem

@equationalapplications/core-llm-tools

Zero-dependency Gemini function-calling schemas and capability-scoped tool injection for edge AI agents. Works in Node.js, browser, and React Native (Hermes).

npm version npm downloads TypeScript License: MIT

📖 Docs · GitHub · ScopeLab · WikiDemo · Changelog · Issues

A universal registry bridging the gap between Edge AI (Expo/React Native) and Cloud Agents (Cloud Run).

Overview

core-llm-tools provides a shared, strictly-typed repository of JSON Function Declarations (Tools) for Gemini models. By decoupling the Tool Interface (the schema) from the Tool Implementation (the executing code), this package allows client-side triage agents and heavy backend cloud agents to share the exact same capabilities without importing Node.js server dependencies into the browser or mobile environments.

It also introduces a robust Capability-Based Scope Model (similar to OAuth 2.0), ensuring that Large Language Models are only injected with tools the user has explicitly authorized.

Features

  • Platform-Agnostic — Zero runtime dependencies. Pure TypeScript. Compiles safely for Node.js, the browser, and the React Native Hermes engine.
  • Capability-Based Security — Tools are locked behind specific scopes (e.g., calendar:read, messages:send). The injector ensures models cannot hallucinate calls to unauthorized tools.
  • Strict Typings — Provides rigid interfaces (AgentToolSchema, AgentToolManifest) to prevent malformed Gemini API requests.
  • Harmonized Edge/Cloud Routing — Enables lightweight edge models (like Gemini Nano) to triage intents using the exact same schemas the heavy Cloud Run backend uses to execute them.
  • GraphRAG tool schemas — graphTraverseManifest and ontologyGetManifest are pre-built Gemini tool schemas for the GraphRAG retrieval API; see GraphRAG guide.

Installation

npm install @equationalapplications/core-llm-tools
# or
pnpm add @equationalapplications/core-llm-tools

Quick Start

1. Defining a Tool Manifest

Tools are defined by wrapping a standard Gemini JSON schema with a required security scope.

import type { AgentToolManifest } from '@equationalapplications/core-llm-tools';

export const getCalendarEventsManifest: AgentToolManifest = {
  name: 'get_calendar_events',
  scope: 'calendar:read', // Security scope required to use this tool
  schema: {
    name: 'get_calendar_events',
    description: 'Fetch the user\'s schedule for a given date.',
    parameters: {
      type: 'object',
      properties: {
        date: { type: 'string' }
      }
    }
  }
};

2. Injecting Authorized Tools

At runtime, use buildAuthorizedToolsArray to filter your tool library against the user's granted permissions. It returns the full Gemini tools[] array: at most one functionDeclarations group containing every authorized function tool's schema, plus one entry per authorized built-in tool (e.g. Google Search grounding).

import { buildAuthorizedToolsArray, escalateToCloudManifest } from '@equationalapplications/core-llm-tools';

// 1. Gather all manifests known to your app
const allAppTools = [escalateToCloudManifest, getCalendarEventsManifest];

// 2. Fetch the user's authorized scopes from your DB (e.g., SQLite/Postgres)
const userGrantedScopes = ['calendar:read'];

// 3. The injector automatically includes 'core' tools and authorized scoped tools,
//    collapsing all authorized function tools into a single functionDeclarations group
const tools = buildAuthorizedToolsArray(allAppTools, userGrantedScopes);
// => [{ functionDeclarations: [get_calendar_events, escalate_to_cloud] }]

// 4. Pass safely to Gemini
const response = await ai.models.generateContent({
  model: 'gemini-flash-latest',
  contents: userInput,
  config: { tools }, // @google/genai reads tools only from config
});

3. Built-In Tools (Grounding)

"Grounding" here means Gemini's server-side Google Search tool. It is unrelated to core-llm-wiki's evidence grounding check (WikiConfig.grounding), which verifies that facts quote their source.

Some Gemini capabilities, like Google Search grounding, are built-in tools executed server-side by Google rather than function declarations your code implements. These are declared with kind: 'built_in' and flow through the same capability-scope model as function tools, via buildAuthorizedToolsArray. Use AnyAgentToolManifest when mixing function and built-in manifests; AgentToolManifest remains the function-only type for existing callers:

import type { AnyAgentToolManifest } from '@equationalapplications/core-llm-tools';
import { buildAuthorizedToolsArray, googleSearchManifest, escalateToCloudManifest } from '@equationalapplications/core-llm-tools';

const allAppTools: AnyAgentToolManifest[] = [escalateToCloudManifest, googleSearchManifest];
const userGrantedScopes: string[] = [];

// Returns the full Gemini tools[] array: a functionDeclarations group (if any
// function tools are authorized) plus one entry per authorized built-in tool.
const tools = buildAuthorizedToolsArray(allAppTools, userGrantedScopes);
// => [{ functionDeclarations: [...] }, { googleSearch: {} }]
// The manifest is named `google_search`; the wire key is `googleSearch`,
// the only spelling @google/genai reads. The REST API accepts it too.
// The GeminiToolEntry type accepts both spellings, so call sites written
// against the pre-rename `google_search` shape keep compiling.

const response = await ai.models.generateContent({
  model: 'gemini-flash-latest',
  contents: userInput,
  config: { tools }, // @google/genai reads tools only from config
});

Note: When the model uses google_search, Gemini returns a groundingMetadata object (search queries, source citations, etc.) on the response. Parsing that metadata is the caller's responsibility — this package only handles the request-side tool declaration.

Memory manifests

ontology_get (ontologyGetManifest), graph_traverse (graphTraverseManifest), and instructions_get (instructionsGetManifest) are schema-only memory:read tools. Dispatch them to WikiMemory.getOntologyManifest, traverseGraph, and getInstructions. instructions_get returns your WikiConfig.prompts overrides verbatim, so keep secrets out of them. The names follow SynapseTree's <resource>_<verb> convention, which the @equationalapplications/mcp-server tools also use.

Removed in 8.0.0: the wiki_* tool names

Removed export (tool name)Use instead
wikiTraverseGraphManifest (wiki_traverse_graph)graphTraverseManifest (graph_traverse)
wikiGetOntologyManifest (wiki_get_ontology)ontologyGetManifest (ontology_get)
wikiGetInstructionsManifest (wiki_get_instructions)instructionsGetManifest (instructions_get)

LEGACY_TOOL_NAMES and canonicalToolName are removed too. Declare the new manifests and dispatch on the new names. A stored prompt that still tells a model to call an old name has to be updated, because the model no longer has a tool by that name.

Monorepo Ecosystem

PackagePurpose
@equationalapplications/core-llm-wikiPersistent episodic memory
@equationalapplications/expo-llm-wikiPersistent episodic memory for Expo/React Native
@equationalapplications/react-llm-wikiPersistent episodic memory for Web
@equationalapplications/prisma-outboxSync SQLite outbox events to Prisma
@equationalapplications/core-llm-toolsGemini tool schemas and capability injector
@equationalapplications/core-okfZero-dependency Open Knowledge Format (OKF) v0.1 + v0.2 primitives — parse and produce interoperable knowledge bundles.
@equationalapplications/schema-org-llm-wikiCurated schema.org warm-agent ontology manifest
@equationalapplications/schema-software-orgSoftware-organization executive ontology manifest — 17 node types, 40 edges, warm-agent superset, data-only
@equationalapplications/mcp-serverMCP server exposing SynapseTree memory tools to coding agents

Made with ❤️ by Equational Applications LLC. https://equationalapplications.com/

版本与发布记录

@equationalapplications/core-llm-tools 共发布 94 个版本,首次发布于 2026/05/28;过去 12 个月发布了 94 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.4.0latest2026/11/131 天前
8.3.02026/11/131 天前
8.2.02026/11/122 天前
8.1.02026/11/122 天前
8.0.52026/11/112 天前
8.0.42026/11/112 天前

关于 @equationalapplications/core-llm-tools 的常见问题

@equationalapplications/core-llm-tools 是什么?

Zero-dependency Gemini function-calling schemas and capability-scoped tool injection for edge AI agents. Works in Node.js, browser, and React Native (Hermes).

如何安装 @equationalapplications/core-llm-tools?

在项目目录运行 npm install @equationalapplications/core-llm-tools,或使用 pnpm add / yarn add / bun add。

@equationalapplications/core-llm-tools 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@equationalapplications/core-llm-tools 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@equationalapplications/core-llm-tools 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@equationalapplications/core-llm-tools 可以商用吗?

@equationalapplications/core-llm-tools 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@equationalapplications/core-llm-tools 的下载量有多少?

根据 npm 官方下载统计,@equationalapplications/core-llm-tools 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,602 次,日均约 153 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@equationalapplications/core-llm-tools 还在维护吗?

最新版本 8.4.0 发布于 2026/11/13(1 天前);至今共发布 94 个版本,其中过去 12 个月发布了 94 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。