@nextsparkjs/plugin-ai 0.1.0-beta.82 → 0.1.0-beta.83
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.
|
@@ -81,6 +81,7 @@ import { AIHistoryService } from '@/contents/plugins/ai/lib/ai-history-service'
|
|
|
81
81
|
```typescript
|
|
82
82
|
const historyId = await AIHistoryService.startOperation({
|
|
83
83
|
userId: 'user-id',
|
|
84
|
+
teamId: 'team-id',
|
|
84
85
|
operation: 'generate',
|
|
85
86
|
model: 'gpt-4o-mini',
|
|
86
87
|
provider: 'openai',
|
|
@@ -133,6 +134,7 @@ await AIHistoryService.failOperation({
|
|
|
133
134
|
```typescript
|
|
134
135
|
{
|
|
135
136
|
userId: string // Required
|
|
137
|
+
teamId: string // Required - team context for the operation
|
|
136
138
|
operation: AIOperation // 'generate' | 'refine' | 'analyze' | 'chat' | 'completion' | 'other'
|
|
137
139
|
model: string // Model name (e.g., 'gpt-4o-mini')
|
|
138
140
|
provider?: AIProvider // 'openai' | 'anthropic' | 'ollama'
|
|
@@ -147,6 +149,7 @@ await AIHistoryService.failOperation({
|
|
|
147
149
|
```typescript
|
|
148
150
|
const historyId = await AIHistoryService.startOperation({
|
|
149
151
|
userId: session.user.id,
|
|
152
|
+
teamId: session.user.activeTeamId,
|
|
150
153
|
operation: 'generate',
|
|
151
154
|
model: 'llama3.2:3b',
|
|
152
155
|
provider: 'ollama'
|
|
@@ -225,6 +228,7 @@ try {
|
|
|
225
228
|
```typescript
|
|
226
229
|
const historyId = await AIHistoryService.startOperation({
|
|
227
230
|
userId: 'user-id',
|
|
231
|
+
teamId: 'team-id',
|
|
228
232
|
operation: 'analyze',
|
|
229
233
|
model: 'claude-3-5-haiku-20241022',
|
|
230
234
|
relatedEntityType: 'clients',
|
|
@@ -249,6 +253,7 @@ PATCH /api/v1/plugin/ai/ai-history/:id
|
|
|
249
253
|
// Generate product description
|
|
250
254
|
const historyId = await AIHistoryService.startOperation({
|
|
251
255
|
userId: session.user.id,
|
|
256
|
+
teamId: session.user.activeTeamId,
|
|
252
257
|
operation: 'generate',
|
|
253
258
|
model: 'gpt-4o-mini',
|
|
254
259
|
relatedEntityType: 'products',
|
|
@@ -265,6 +270,7 @@ const historyId = await AIHistoryService.startOperation({
|
|
|
265
270
|
// Analyze client data
|
|
266
271
|
const historyId = await AIHistoryService.startOperation({
|
|
267
272
|
userId: session.user.id,
|
|
273
|
+
teamId: session.user.activeTeamId,
|
|
268
274
|
operation: 'analyze',
|
|
269
275
|
model: 'claude-3-5-sonnet-20241022',
|
|
270
276
|
relatedEntityType: 'clients',
|
|
@@ -279,6 +285,7 @@ const historyId = await AIHistoryService.startOperation({
|
|
|
279
285
|
// Audit article content
|
|
280
286
|
const historyId = await AIHistoryService.startOperation({
|
|
281
287
|
userId: session.user.id,
|
|
288
|
+
teamId: session.user.activeTeamId,
|
|
282
289
|
operation: 'analyze',
|
|
283
290
|
model: 'gpt-4o',
|
|
284
291
|
relatedEntityType: 'articles',
|
|
@@ -384,6 +391,7 @@ export async function generateProductDescription(productId: string) {
|
|
|
384
391
|
// 1. Start operation tracking
|
|
385
392
|
const historyId = await AIHistoryService.startOperation({
|
|
386
393
|
userId: session.user.id,
|
|
394
|
+
teamId: session.user.activeTeamId,
|
|
387
395
|
operation: 'generate',
|
|
388
396
|
model: 'gpt-4o-mini',
|
|
389
397
|
provider: 'openai',
|
|
@@ -336,6 +336,7 @@ export async function generateAndSaveDescription(productId: string) {
|
|
|
336
336
|
// Start operation tracking
|
|
337
337
|
const historyId = await AIHistoryService.startOperation({
|
|
338
338
|
userId: session.user.id,
|
|
339
|
+
teamId: session.user.activeTeamId,
|
|
339
340
|
operation: 'generate',
|
|
340
341
|
model: 'gpt-4o-mini',
|
|
341
342
|
provider: 'openai',
|
|
@@ -20,6 +20,7 @@ export type AIStatus = 'pending' | 'processing' | 'completed' | 'failed'
|
|
|
20
20
|
|
|
21
21
|
export interface StartOperationParams {
|
|
22
22
|
userId: string
|
|
23
|
+
teamId: string // Required - team context for the operation
|
|
23
24
|
operation: AIOperation
|
|
24
25
|
model: string
|
|
25
26
|
provider?: AIProvider
|
|
@@ -75,6 +76,7 @@ export class AIHistoryService {
|
|
|
75
76
|
static async startOperation(params: StartOperationParams): Promise<string> {
|
|
76
77
|
const {
|
|
77
78
|
userId,
|
|
79
|
+
teamId,
|
|
78
80
|
operation,
|
|
79
81
|
model,
|
|
80
82
|
provider = 'anthropic',
|
|
@@ -86,6 +88,7 @@ export class AIHistoryService {
|
|
|
86
88
|
const result = await queryOne<{ id: string }>(
|
|
87
89
|
`INSERT INTO "ai_history" (
|
|
88
90
|
"userId",
|
|
91
|
+
"teamId",
|
|
89
92
|
operation,
|
|
90
93
|
model,
|
|
91
94
|
provider,
|
|
@@ -93,9 +96,9 @@ export class AIHistoryService {
|
|
|
93
96
|
"relatedEntityId",
|
|
94
97
|
status,
|
|
95
98
|
"createdAt"
|
|
96
|
-
) VALUES ($1, $2, $3, $4, $5, $6, $7, now())
|
|
99
|
+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, now())
|
|
97
100
|
RETURNING id`,
|
|
98
|
-
[userId, operation, model, provider, relatedEntityType || null, relatedEntityId || null, 'pending']
|
|
101
|
+
[userId, teamId, operation, model, provider, relatedEntityType || null, relatedEntityId || null, 'pending']
|
|
99
102
|
)
|
|
100
103
|
|
|
101
104
|
if (!result) {
|
package/package.json
CHANGED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 NextSpark
|
|
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.
|