Skip to content

Commit a2bcd19

Browse files
Copilothotlong
andauthored
refactor(service-ai): add auth/permissions metadata, user context, ownership, enhanced tool-call loop
- RouteDefinition: add `auth` and `permissions` fields - RouteRequest: add `user: RouteUserContext` for authenticated user context - Conversation routes: enforce ownership (create binds userId, list scopes to user, add/delete check ownership) - chatWithTools: add `onToolError` callback, error tracking across iterations - Add streamChatWithTools: streaming tool-call loop with SSE events - ChatWithToolsOptions: add `onToolError` callback in contract - 27 new tests: 7 auth metadata, 10 ownership, 6 tool-call error handling, 4 streamChatWithTools - Update CHANGELOG.md Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/05de3b78-8ac6-4821-a0c8-ae863084c76b Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 0ef2e7c commit a2bcd19

8 files changed

Lines changed: 822 additions & 7 deletions

File tree

packages/services/service-ai/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @objectstack/service-ai
22

3+
## 4.1.0
4+
5+
### Minor Changes
6+
7+
- **Route auth/permissions metadata**: Every route definition (`RouteDefinition`) now declares `auth` and `permissions` fields, enabling HTTP server adapters to enforce authentication and authorization automatically.
8+
- **User context on RouteRequest**: `RouteRequest` now carries an optional `user: RouteUserContext` object populated by the auth middleware, providing `userId`, `displayName`, `roles`, and `permissions`.
9+
- **Conversation ownership enforcement**: Conversation routes (create, list, add message, delete) are scoped to the authenticated user — users can only access their own conversations.
10+
- **Enhanced tool-call loop error handling**: `chatWithTools` now tracks tool execution errors across iterations and supports an `onToolError` callback (`'continue'` | `'abort'`) for fine-grained error control.
11+
- **`streamChatWithTools`**: New streaming tool-call loop that yields SSE events while automatically resolving intermediate tool calls.
12+
- **New `RouteUserContext` type**: Exported from the package for use by HTTP adapters and middleware.
13+
314
## 4.0.0
415

516
### Major Changes

0 commit comments

Comments
 (0)