@terreno/ai 56.0.0-beta.0 → 56.0.0-beta.2

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 Flourish Health, Inc.
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 CHANGED
@@ -1,5 +1,47 @@
1
1
  # @terreno/ai
2
2
 
3
- AI service layer for Terreno apps providing GPT chat, request logging, and admin tools. Provider-agnostic via the Vercel AI SDK.
3
+ AI service layer for Terreno backends — provider-agnostic chat, request logging, GPT history, projects, file uploads, MCP tools, and optional Langfuse integration.
4
4
 
5
- See the [full documentation](../.claude/rules/ai/00-ai.md) for usage, architecture, and integration details.
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @terreno/ai @terreno/api mongoose
9
+ ```
10
+
11
+ Also install a Vercel AI SDK provider in your app (e.g. `bun add @ai-sdk/google`).
12
+
13
+ ## Quick start
14
+
15
+ ```typescript
16
+ import {TerrenoApp} from "@terreno/api";
17
+ import {AiApp, AIService} from "@terreno/ai";
18
+ import {google} from "@ai-sdk/google";
19
+ import {User} from "./models/user";
20
+
21
+ const aiService = new AIService({model: google("gemini-2.5-flash")});
22
+
23
+ new TerrenoApp({userModel: User})
24
+ .register(new AiApp({aiService}))
25
+ .start();
26
+ ```
27
+
28
+ This mounts GPT chat (`POST /gpt/prompt`), history CRUD (`/gpt/histories`), projects, and the admin AI request explorer. Add `LangfuseApp`, `FileStorageService`, and `MCPService` when you need those features.
29
+
30
+ ## What's included
31
+
32
+ - `AIService` — text, streaming, structured JSON, remix, summary, and translation helpers
33
+ - `AiApp` — TerrenoPlugin that registers all AI routes in one call
34
+ - Mongoose models: `AIRequest`, `GptHistory`, `Project`, `FileAttachment`
35
+ - Route registrars: `addGptRoutes`, `addGptHistoryRoutes`, `addProjectRoutes`, `addFileRoutes`, `addMcpRoutes`, `addAiRequestsExplorerRoutes`
36
+ - `LangfuseApp` — optional Langfuse tracing and admin UI routes
37
+ - `FileStorageService` — GCS uploads with signed URLs
38
+ - `MCPService` — SSE MCP client for tool calling
39
+ - Gemini and Vertex helpers: `listGeminiApiModels`, `createVertexProvider`
40
+
41
+ ## Documentation
42
+
43
+ Full API reference: [docs/reference/ai.md](https://github.com/flourishhealth/terreno/blob/master/docs/reference/ai.md)
44
+
45
+ ## License and Contributing
46
+
47
+ Licensed under the [MIT License](https://github.com/flourishhealth/terreno/blob/master/LICENSE). See [CONTRIBUTING.md](https://github.com/flourishhealth/terreno/blob/master/CONTRIBUTING.md) for contribution guidelines.
@@ -1,5 +1,5 @@
1
1
  import type { FindExactlyOnePlugin, FindOneOrNonePlugin } from "@terreno/api";
2
- import type { LanguageModel } from "ai";
2
+ import type { LanguageModel, StopCondition, ToolSet } from "ai";
3
3
  import type mongoose from "mongoose";
4
4
  export declare const DEFAULT_AI_REQUEST_TYPES: readonly ["general", "json_array", "json_object", "json_value", "remix", "summarization", "translation"];
5
5
  export type DefaultAIRequestType = (typeof DEFAULT_AI_REQUEST_TYPES)[number];
@@ -115,7 +115,7 @@ export interface AIServiceOptions {
115
115
  export interface GenerateTextOptions {
116
116
  maxOutputTokens?: number;
117
117
  prompt: string;
118
- stopWhen?: import("ai").StopCondition<any>;
118
+ stopWhen?: StopCondition<ToolSet>;
119
119
  systemPrompt?: string;
120
120
  temperature?: number;
121
121
  toolChoice?: "auto" | "none" | "required";
@@ -134,7 +134,7 @@ export interface GenerateChatStreamOptions {
134
134
  content: string;
135
135
  role: "user" | "assistant" | "system";
136
136
  }>;
137
- stopWhen?: import("ai").StopCondition<any>;
137
+ stopWhen?: StopCondition<ToolSet>;
138
138
  systemPrompt?: string;
139
139
  toolChoice?: "auto" | "none" | "required";
140
140
  tools?: Record<string, import("ai").Tool>;
package/package.json CHANGED
@@ -18,15 +18,14 @@
18
18
  "description": "AI service layer for Terreno apps - GPT chat, request logging, and admin tools.",
19
19
  "devDependencies": {
20
20
  "@biomejs/biome": "^2.3.6",
21
- "@terreno/api": "56.0.0-beta.0",
22
- "@terreno/test": "56.0.0-beta.0",
21
+ "@terreno/api": "56.0.0-beta.2",
22
+ "@terreno/test": "56.0.0-beta.2",
23
23
  "@types/bun": "^1.3.8",
24
24
  "@types/express": "^5.0.6",
25
25
  "@types/luxon": "^3.7.1",
26
26
  "@types/multer": "^1.4.12",
27
- "@types/passport-local-mongoose": "^6.1.5",
28
27
  "@types/supertest": "^7.2.0",
29
- "mongoose": "8.23.0",
28
+ "mongoose": "9.7.4",
30
29
  "passport-local-mongoose": "^9.0.1",
31
30
  "supertest": "^7.2.2",
32
31
  "typescript": "~6.0.3",
@@ -65,15 +64,15 @@
65
64
  "mongoose",
66
65
  "express"
67
66
  ],
68
- "license": "Apache-2.0",
67
+ "license": "MIT",
69
68
  "main": "dist/index.js",
70
69
  "name": "@terreno/ai",
71
70
  "publishConfig": {
72
71
  "access": "public"
73
72
  },
74
73
  "peerDependencies": {
75
- "@terreno/api": "56.0.0-beta.0",
76
- "mongoose": "^8.0.0"
74
+ "@terreno/api": "56.0.0-beta.2",
75
+ "mongoose": "^8.0.0 || ^9.0.0"
77
76
  },
78
77
  "repository": {
79
78
  "type": "git",
@@ -91,5 +90,5 @@
91
90
  "test:coverage": "bun run ../scripts/check-coverage.ts"
92
91
  },
93
92
  "types": "dist/index.d.ts",
94
- "version": "56.0.0-beta.0"
93
+ "version": "56.0.0-beta.2"
95
94
  }
@@ -1,5 +1,5 @@
1
1
  import type {FindExactlyOnePlugin, FindOneOrNonePlugin} from "@terreno/api";
2
- import type {LanguageModel} from "ai";
2
+ import type {LanguageModel, StopCondition, ToolSet} from "ai";
3
3
  import type mongoose from "mongoose";
4
4
 
5
5
  // ============================================================
@@ -164,9 +164,7 @@ export interface AIServiceOptions {
164
164
  export interface GenerateTextOptions {
165
165
  maxOutputTokens?: number;
166
166
  prompt: string;
167
- // noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
168
- // biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
169
- stopWhen?: import("ai").StopCondition<any>;
167
+ stopWhen?: StopCondition<ToolSet>;
170
168
  systemPrompt?: string;
171
169
  temperature?: number;
172
170
  toolChoice?: "auto" | "none" | "required";
@@ -184,9 +182,7 @@ export interface GenerateStreamOptions {
184
182
 
185
183
  export interface GenerateChatStreamOptions {
186
184
  messages: Array<{content: string; role: "user" | "assistant" | "system"}>;
187
- // noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
188
- // biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
189
- stopWhen?: import("ai").StopCondition<any>;
185
+ stopWhen?: StopCondition<ToolSet>;
190
186
  systemPrompt?: string;
191
187
  toolChoice?: "auto" | "none" | "required";
192
188
  tools?: Record<string, import("ai").Tool>;