@equationalapplications/core-llm-tools 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Equational Applications LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @equationalapplications/core-llm-tools
2
+
3
+ Platform-agnostic Gemini tool schemas and a capability-based scope injector.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40equationalapplications%2Fcore-llm-tools?label=core-llm-tools)](https://www.npmjs.com/package/@equationalapplications/core-llm-tools)
6
+ [![npm downloads](https://img.shields.io/npm/dm/%40equationalapplications%2Fcore-llm-tools?label=downloads)](https://www.npmjs.com/package/@equationalapplications/core-llm-tools)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
9
+
10
+ > A universal registry bridging the gap between Edge AI (Expo/React Native) and Cloud Agents (Cloud Run).
11
+
12
+ ## Overview
13
+
14
+ `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.
15
+
16
+ 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.
17
+
18
+ ## Features
19
+
20
+ - **Platform-Agnostic** — Zero runtime dependencies. Pure TypeScript. Compiles safely for Node.js, the browser, and the React Native Hermes engine.
21
+ - **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.
22
+ - **Strict Typings** — Provides rigid interfaces (`AgentToolSchema`, `AgentToolManifest`) to prevent malformed Gemini API requests.
23
+ - **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.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @equationalapplications/core-llm-tools
29
+ # or
30
+ pnpm add @equationalapplications/core-llm-tools
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ### 1. Defining a Tool Manifest
36
+
37
+ Tools are defined by wrapping a standard Gemini JSON schema with a required security scope.
38
+
39
+ ```typescript
40
+ import type { AgentToolManifest } from '@equationalapplications/core-llm-tools';
41
+
42
+ export const getCalendarEventsManifest: AgentToolManifest = {
43
+ name: 'get_calendar_events',
44
+ scope: 'calendar:read', // Security scope required to use this tool
45
+ schema: {
46
+ name: 'get_calendar_events',
47
+ description: 'Fetch the user\'s schedule for a given date.',
48
+ parameters: {
49
+ type: 'object',
50
+ properties: {
51
+ date: { type: 'string' }
52
+ }
53
+ }
54
+ }
55
+ };
56
+ ```
57
+
58
+ ### 2. Injecting Authorized Tools
59
+
60
+ At runtime, use `buildAuthorizedSchemaArray` to filter your tool library against the user's granted permissions before passing them to the LLM.
61
+
62
+ ```typescript
63
+ import { buildAuthorizedSchemaArray, escalateToCloudManifest } from '@equationalapplications/core-llm-tools';
64
+
65
+ // 1. Gather all manifests known to your app
66
+ const allAppTools = [escalateToCloudManifest, getCalendarEventsManifest];
67
+
68
+ // 2. Fetch the user's authorized scopes from your DB (e.g., SQLite/Postgres)
69
+ const userGrantedScopes = ['calendar:read'];
70
+
71
+ // 3. The injector automatically includes 'core' tools and authorized scoped tools
72
+ const schemasForLlm = buildAuthorizedSchemaArray(allAppTools, userGrantedScopes);
73
+
74
+ // 4. Pass safely to Gemini
75
+ const response = await ai.models.generateContent({
76
+ model: 'gemini-2.5-flash',
77
+ contents: userInput,
78
+ tools: [{ functionDeclarations: schemasForLlm }],
79
+ });
80
+ ```
81
+
82
+ ## Helpful Resources & Links
83
+
84
+ - [Google Gen AI: Function Calling Tutorial](https://ai.google.dev/gemini-api/docs/function-calling) — Official docs on how the JSON schemas in this package interact with Gemini models.
85
+ - [JSON Schema Specification](https://json-schema.org/understanding-json-schema/) — Structural foundation for `AgentToolSchema.parameters`.
86
+ - [OAuth 2.0 Scope Concepts](https://oauth.net/2/scope/) — Inspiration behind the capability-based `AgentScope` permission hierarchy.
87
+ - [@google/adk (Agent Development Kit)](https://github.com/google/adk-python) — Server-side framework used by Cloud Run backends to wrap and execute the schemas defined in this package.
@@ -0,0 +1,22 @@
1
+ type AgentScope = 'core' | 'location:read' | 'calendar:read' | 'calendar:write' | 'messages:send' | 'memory:read' | 'memory:write';
2
+ interface AgentToolSchema {
3
+ name: string;
4
+ description: string;
5
+ parameters?: {
6
+ type: 'object' | 'string' | 'number' | 'boolean' | 'array';
7
+ properties: Record<string, unknown>;
8
+ required?: string[];
9
+ };
10
+ }
11
+ interface AgentToolManifest {
12
+ name: string;
13
+ scope: AgentScope;
14
+ schema: AgentToolSchema;
15
+ }
16
+
17
+ declare function buildAuthorizedSchemaArray(availableManifests: AgentToolManifest[], userGrantedScopes: string[]): AgentToolSchema[];
18
+
19
+ declare const getCurrentTimeManifest: AgentToolManifest;
20
+ declare const escalateToCloudManifest: AgentToolManifest;
21
+
22
+ export { type AgentScope, type AgentToolManifest, type AgentToolSchema, buildAuthorizedSchemaArray, escalateToCloudManifest, getCurrentTimeManifest };
@@ -0,0 +1,22 @@
1
+ type AgentScope = 'core' | 'location:read' | 'calendar:read' | 'calendar:write' | 'messages:send' | 'memory:read' | 'memory:write';
2
+ interface AgentToolSchema {
3
+ name: string;
4
+ description: string;
5
+ parameters?: {
6
+ type: 'object' | 'string' | 'number' | 'boolean' | 'array';
7
+ properties: Record<string, unknown>;
8
+ required?: string[];
9
+ };
10
+ }
11
+ interface AgentToolManifest {
12
+ name: string;
13
+ scope: AgentScope;
14
+ schema: AgentToolSchema;
15
+ }
16
+
17
+ declare function buildAuthorizedSchemaArray(availableManifests: AgentToolManifest[], userGrantedScopes: string[]): AgentToolSchema[];
18
+
19
+ declare const getCurrentTimeManifest: AgentToolManifest;
20
+ declare const escalateToCloudManifest: AgentToolManifest;
21
+
22
+ export { type AgentScope, type AgentToolManifest, type AgentToolSchema, buildAuthorizedSchemaArray, escalateToCloudManifest, getCurrentTimeManifest };
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ // src/injector.ts
4
+ function buildAuthorizedSchemaArray(availableManifests, userGrantedScopes) {
5
+ return availableManifests.filter(
6
+ (manifest) => manifest.scope === "core" || userGrantedScopes.includes(manifest.scope)
7
+ ).map((manifest) => manifest.schema);
8
+ }
9
+
10
+ // src/manifests/core.ts
11
+ var getCurrentTimeManifest = {
12
+ name: "get_current_time",
13
+ scope: "core",
14
+ schema: {
15
+ name: "get_current_time",
16
+ description: 'Get the exact current date and time. Always call this tool first if resolving relative temporal words like "today" or "tomorrow".',
17
+ parameters: { type: "object", properties: {} }
18
+ }
19
+ };
20
+ var escalateToCloudManifest = {
21
+ name: "escalate_to_cloud_agent",
22
+ scope: "core",
23
+ schema: {
24
+ name: "escalate_to_cloud_agent",
25
+ description: "Use this tool when the user asks to schedule a reminder, perform deep memory searches, or execute a complex workflow that requires cloud resources.",
26
+ parameters: { type: "object", properties: {} }
27
+ }
28
+ };
29
+
30
+ exports.buildAuthorizedSchemaArray = buildAuthorizedSchemaArray;
31
+ exports.escalateToCloudManifest = escalateToCloudManifest;
32
+ exports.getCurrentTimeManifest = getCurrentTimeManifest;
33
+ //# sourceMappingURL=index.js.map
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/injector.ts","../src/manifests/core.ts"],"names":[],"mappings":";;;AAEO,SAAS,0BAAA,CACd,oBACA,iBAAA,EACmB;AACnB,EAAA,OAAO,kBAAA,CACJ,MAAA;AAAA,IACC,CAAC,aACC,QAAA,CAAS,KAAA,KAAU,UAAU,iBAAA,CAAkB,QAAA,CAAS,SAAS,KAAK;AAAA,GAC1E,CACC,GAAA,CAAI,CAAC,QAAA,KAAa,SAAS,MAAM,CAAA;AACtC;;;ACVO,IAAM,sBAAA,GAA4C;AAAA,EACvD,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO,MAAA;AAAA,EACP,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,kBAAA;AAAA,IACN,WAAA,EACE,mIAAA;AAAA,IACF,YAAY,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,EAAC;AAAE;AAEjD;AAEO,IAAM,uBAAA,GAA6C;AAAA,EACxD,IAAA,EAAM,yBAAA;AAAA,EACN,KAAA,EAAO,MAAA;AAAA,EACP,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,yBAAA;AAAA,IACN,WAAA,EACE,qJAAA;AAAA,IACF,YAAY,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,EAAC;AAAE;AAEjD","file":"index.js","sourcesContent":["import type { AgentToolManifest, AgentToolSchema } from './types';\n\nexport function buildAuthorizedSchemaArray(\n availableManifests: AgentToolManifest[],\n userGrantedScopes: string[]\n): AgentToolSchema[] {\n return availableManifests\n .filter(\n (manifest) =>\n manifest.scope === 'core' || userGrantedScopes.includes(manifest.scope)\n )\n .map((manifest) => manifest.schema);\n}\n","import type { AgentToolManifest } from '../types';\n\nexport const getCurrentTimeManifest: AgentToolManifest = {\n name: 'get_current_time',\n scope: 'core',\n schema: {\n name: 'get_current_time',\n description:\n 'Get the exact current date and time. Always call this tool first if resolving relative temporal words like \"today\" or \"tomorrow\".',\n parameters: { type: 'object', properties: {} },\n },\n};\n\nexport const escalateToCloudManifest: AgentToolManifest = {\n name: 'escalate_to_cloud_agent',\n scope: 'core',\n schema: {\n name: 'escalate_to_cloud_agent',\n description:\n 'Use this tool when the user asks to schedule a reminder, perform deep memory searches, or execute a complex workflow that requires cloud resources.',\n parameters: { type: 'object', properties: {} },\n },\n};\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ // src/injector.ts
2
+ function buildAuthorizedSchemaArray(availableManifests, userGrantedScopes) {
3
+ return availableManifests.filter(
4
+ (manifest) => manifest.scope === "core" || userGrantedScopes.includes(manifest.scope)
5
+ ).map((manifest) => manifest.schema);
6
+ }
7
+
8
+ // src/manifests/core.ts
9
+ var getCurrentTimeManifest = {
10
+ name: "get_current_time",
11
+ scope: "core",
12
+ schema: {
13
+ name: "get_current_time",
14
+ description: 'Get the exact current date and time. Always call this tool first if resolving relative temporal words like "today" or "tomorrow".',
15
+ parameters: { type: "object", properties: {} }
16
+ }
17
+ };
18
+ var escalateToCloudManifest = {
19
+ name: "escalate_to_cloud_agent",
20
+ scope: "core",
21
+ schema: {
22
+ name: "escalate_to_cloud_agent",
23
+ description: "Use this tool when the user asks to schedule a reminder, perform deep memory searches, or execute a complex workflow that requires cloud resources.",
24
+ parameters: { type: "object", properties: {} }
25
+ }
26
+ };
27
+
28
+ export { buildAuthorizedSchemaArray, escalateToCloudManifest, getCurrentTimeManifest };
29
+ //# sourceMappingURL=index.mjs.map
30
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/injector.ts","../src/manifests/core.ts"],"names":[],"mappings":";AAEO,SAAS,0BAAA,CACd,oBACA,iBAAA,EACmB;AACnB,EAAA,OAAO,kBAAA,CACJ,MAAA;AAAA,IACC,CAAC,aACC,QAAA,CAAS,KAAA,KAAU,UAAU,iBAAA,CAAkB,QAAA,CAAS,SAAS,KAAK;AAAA,GAC1E,CACC,GAAA,CAAI,CAAC,QAAA,KAAa,SAAS,MAAM,CAAA;AACtC;;;ACVO,IAAM,sBAAA,GAA4C;AAAA,EACvD,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO,MAAA;AAAA,EACP,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,kBAAA;AAAA,IACN,WAAA,EACE,mIAAA;AAAA,IACF,YAAY,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,EAAC;AAAE;AAEjD;AAEO,IAAM,uBAAA,GAA6C;AAAA,EACxD,IAAA,EAAM,yBAAA;AAAA,EACN,KAAA,EAAO,MAAA;AAAA,EACP,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,yBAAA;AAAA,IACN,WAAA,EACE,qJAAA;AAAA,IACF,YAAY,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,EAAC;AAAE;AAEjD","file":"index.mjs","sourcesContent":["import type { AgentToolManifest, AgentToolSchema } from './types';\n\nexport function buildAuthorizedSchemaArray(\n availableManifests: AgentToolManifest[],\n userGrantedScopes: string[]\n): AgentToolSchema[] {\n return availableManifests\n .filter(\n (manifest) =>\n manifest.scope === 'core' || userGrantedScopes.includes(manifest.scope)\n )\n .map((manifest) => manifest.schema);\n}\n","import type { AgentToolManifest } from '../types';\n\nexport const getCurrentTimeManifest: AgentToolManifest = {\n name: 'get_current_time',\n scope: 'core',\n schema: {\n name: 'get_current_time',\n description:\n 'Get the exact current date and time. Always call this tool first if resolving relative temporal words like \"today\" or \"tomorrow\".',\n parameters: { type: 'object', properties: {} },\n },\n};\n\nexport const escalateToCloudManifest: AgentToolManifest = {\n name: 'escalate_to_cloud_agent',\n scope: 'core',\n schema: {\n name: 'escalate_to_cloud_agent',\n description:\n 'Use this tool when the user asks to schedule a reminder, perform deep memory searches, or execute a complex workflow that requires cloud resources.',\n parameters: { type: 'object', properties: {} },\n },\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@equationalapplications/core-llm-tools",
3
+ "version": "0.1.0",
4
+ "description": "Platform-agnostic Gemini tool schemas and capability-based scope injector.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup",
17
+ "dev": "tsup --watch",
18
+ "typecheck": "tsc --noEmit",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "LICENSE",
25
+ "README.md"
26
+ ],
27
+ "license": "MIT",
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "registry": "https://registry.npmjs.org"
31
+ },
32
+ "engines": {
33
+ "node": ">=20"
34
+ },
35
+ "devDependencies": {
36
+ "tsup": "^8.0.0",
37
+ "typescript": "^5.4.0",
38
+ "vitest": "4.1.5"
39
+ }
40
+ }