Skip to content

Commit 1680950

Browse files
Copilothotlong
andauthored
feat: add @objectstack/service-ai — unified AI capability service plugin
- Expand IAIService contract with streamChat, tool calling, conversation management - Create packages/services/service-ai with LLM adapter layer, ToolRegistry, InMemoryConversationService, REST/SSE routes, kernel plugin - Add 52 comprehensive tests covering all components - Update changeset config, CHANGELOG.md, ROADMAP.md Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/c48a190a-19bb-45fd-8caa-0b6b9e1f7c49 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 56dc9bf commit 1680950

21 files changed

Lines changed: 1558 additions & 9 deletions

File tree

.changeset/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@objectstack/service-job",
3838
"@objectstack/service-queue",
3939
"@objectstack/service-realtime",
40+
"@objectstack/service-ai",
4041
"@objectstack/service-storage",
4142
"@objectstack/docs",
4243
"create-objectstack",

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- **`@objectstack/service-ai` — Unified AI capability service plugin** — New kernel plugin
12+
providing standardized AI service integration:
13+
- Registers as kernel `'ai'` service conforming to `IAIService` contract
14+
- LLM adapter layer with provider abstraction (`LLMAdapter` interface) and built-in
15+
`MemoryLLMAdapter` for testing/development
16+
- `ToolRegistry` for metadata/business tool registration and execution
17+
- `InMemoryConversationService` implementing `IAIConversationService` for multi-turn
18+
conversation management with message persistence
19+
- REST/SSE route self-registration (`/api/v1/ai/chat`, `/api/v1/ai/chat/stream`,
20+
`/api/v1/ai/complete`, `/api/v1/ai/models`, `/api/v1/ai/conversations`)
21+
- Plugin lifecycle hooks (`ai:ready`, `ai:routes`) for extensibility
22+
- **Expanded `IAIService` contract** — Added streaming (`streamChat`), tool calling protocol
23+
(`AIToolDefinition`, `AIToolCall`, `AIToolResult`, `AIMessageWithTools`,
24+
`AIRequestOptionsWithTools`, `AIStreamEvent`), and conversation management
25+
(`IAIConversationService`, `AIConversation`) to `packages/spec/src/contracts/ai-service.ts`
26+
1027
### Documentation
1128
- **Unified API query syntax documentation with Spec canonical format** — Rewrote
1229
`content/docs/protocol/objectql/query-syntax.mdx` and

ROADMAP.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,13 @@ Objects now declare `namespace: 'sys'` and a short `name` (e.g., `name: 'user'`)
534534
| `IAutomationService` | **P2** | `@objectstack/service-automation` | ✅ Plugin-based DAG flow engine + HTTP API + Client SDK (67 tests) |
535535
| `IWorkflowService` | **P2** | `@objectstack/service-workflow` | State machine + approval processes |
536536
| `IGraphQLService` | **P2** | `@objectstack/service-graphql` | Auto-generated GraphQL from objects |
537-
| `IAIService` | **P2** | `@objectstack/service-ai` | LLM integration (OpenAI/Anthropic/local) |
537+
| `IAIService` | **P2** | `@objectstack/service-ai` | LLM adapter layer, ToolRegistry, conversation management, REST/SSE routes, streaming (52 tests) |
538538
| `IAnalyticsService` | **P3** | `@objectstack/service-analytics` | ✅ Multi-driver analytics with strategy pattern (NativeSQL/ObjectQL/InMemory), CubeRegistry, generateSql (34 tests) |
539539

540540
- [x] `service-automation` — Implement `IAutomationService` with plugin-based DAG flow engine (CRUD/Logic/HTTP nodes, fault edges, parallel branches, cycle detection, safe eval, timeout, versioning), HTTP API CRUD (9 routes), Client SDK (10 methods), execution history with step-level logging
541541
- [ ] `service-workflow` — Implement `IWorkflowService` with state machine runtime
542542
- [ ] `service-graphql` — Implement `IGraphQLService` with auto-schema generation
543-
- [ ] `service-ai` — Implement `IAIService` with multi-provider LLM routing
543+
- [x] `service-ai` — Implement `IAIService` with LLM adapter layer, ToolRegistry, InMemoryConversationService, REST/SSE routes (/api/v1/ai/*), streaming support (streamChat), kernel plugin (52 tests)
544544
- [x] `service-analytics` — Implement full `IAnalyticsService` with multi-driver strategy pattern (NativeSQLStrategy P1, ObjectQLStrategy P2, InMemoryStrategy P3), CubeRegistry with auto-inference from object schemas, generateSql dry-run, kernel plugin lifecycle
545545

546546
---
@@ -583,7 +583,7 @@ Objects now declare `namespace: 'sys'` and a short `name` (e.g., `name: 'user'`)
583583
- [x] **Phase A+: Dual Transport** (v3.2) — Remote-only mode via `@libsql/client` (libsql://, https://), auto-detection of transport mode, pre-configured client injection, full CRUD/schema/bulk/transaction support in remote mode
584584
- [ ] **Phase B: Edge & Sync** (v3.2) — Embedded replica sync, WASM build for Cloudflare/Deno, offline write queue
585585
- [x] **Phase C: Multi-Tenancy** (v3.3) — Database-per-tenant router with TTL cache, concurrency dedup, lifecycle callbacks
586-
- [ ] **Phase D: Advanced** (v4.0) — Vector search + `IAIService`, FTS5 + `ISearchService`, ~~better-auth adapter~~ (✅ done in plugin-auth)
586+
- [ ] **Phase D: Advanced** (v4.0) — Vector search + `IAIService` (✅ `service-ai` base implemented), FTS5 + `ISearchService`, ~~better-auth adapter~~ (✅ done in plugin-auth)
587587
- [ ] Driver benchmark suite comparing performance across all drivers
588588

589589
### 6.2 Multi-Tenancy
@@ -643,15 +643,15 @@ Objects now declare `namespace: 'sys'` and a short `name` (e.g., `name: 'user'`)
643643
644644
### 7.1 Core AI Services
645645

646-
- [ ] `service-ai` — Multi-provider LLM service (OpenAI, Anthropic, Gemini, local models)
646+
- [x] `service-ai` — Multi-provider LLM service with adapter pattern, streaming, tool registry, conversation management, REST/SSE routes
647647
- [ ] NLQ (Natural Language Query) runtime — translate natural language to ObjectQL
648648
- [ ] Embedding service for vector search and RAG
649649

650650
### 7.2 Agent Framework
651651

652652
- [ ] Agent runtime — execute AI agents defined in spec schemas
653-
- [ ] Tool registry — connect agents to ObjectQL operations, APIs, and workflows
654-
- [ ] Conversation management — persistent chat with context windows
653+
- [x] Tool registry — connect agents to ObjectQL operations, APIs, and workflows (initial implementation in `service-ai`)
654+
- [x] Conversation management — persistent chat with context windows (initial implementation in `service-ai`)
655655

656656
### 7.3 RAG Pipeline
657657

@@ -869,7 +869,7 @@ Final polish and advanced features.
869869
| 15 | Feed Service | `IFeedService` || `@objectstack/service-feed` | In-memory feed/chatter (comments, reactions, subscriptions) |
870870
| 16 | Search Service | `ISearchService` || `@objectstack/service-search` (planned) | Spec only |
871871
| 17 | Notification Service | `INotificationService` || `@objectstack/service-notification` (planned) | Spec only |
872-
| 18 | AI Service | `IAIService` | | `@objectstack/service-ai` (planned) | Spec only |
872+
| 18 | AI Service | `IAIService` | | `@objectstack/service-ai` | LLM adapter layer, ToolRegistry, conversation management, REST/SSE routes (52 tests) |
873873
| 19 | Automation Service | `IAutomationService` || `@objectstack/service-automation` | DAG engine + HTTP API CRUD + Client SDK + typed returns (67 tests) |
874874
| 20 | Workflow Service | `IWorkflowService` || `@objectstack/service-workflow` (planned) | Spec only |
875875
| 21 | GraphQL Service | `IGraphQLService` || `@objectstack/service-graphql` (planned) | Spec only |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# @objectstack/service-ai
2+
3+
## 3.3.1
4+
5+
### Patch Changes
6+
7+
- Initial release of AI Service plugin
8+
- LLM adapter layer with provider abstraction (memory adapter included)
9+
- Conversation management service with in-memory persistence
10+
- Tool registry for metadata/business tool registration
11+
- REST/SSE route self-registration (`/api/v1/ai/*`)
12+
- Kernel plugin registering as `'ai'` service conforming to `IAIService` contract
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@objectstack/service-ai",
3+
"version": "3.3.1",
4+
"license": "Apache-2.0",
5+
"description": "AI Service for ObjectStack — implements IAIService with LLM adapter layer, conversation management, tool registry, and REST/SSE routes",
6+
"type": "module",
7+
"main": "dist/index.js",
8+
"types": "dist/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/index.d.ts",
12+
"import": "./dist/index.js",
13+
"require": "./dist/index.cjs"
14+
}
15+
},
16+
"scripts": {
17+
"build": "tsup --config ../../../tsup.config.ts",
18+
"test": "vitest run"
19+
},
20+
"dependencies": {
21+
"@objectstack/core": "workspace:*",
22+
"@objectstack/spec": "workspace:*"
23+
},
24+
"devDependencies": {
25+
"@types/node": "^25.5.0",
26+
"typescript": "^6.0.2",
27+
"vitest": "^4.1.2"
28+
}
29+
}

0 commit comments

Comments
 (0)