@memberjunction/server 5.21.0 → 5.22.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/README.md +9 -0
- package/dist/agents/skip-sdk.d.ts.map +1 -1
- package/dist/agents/skip-sdk.js +32 -2
- package/dist/agents/skip-sdk.js.map +1 -1
- package/dist/generated/generated.d.ts +24 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +113 -0
- package/dist/generated/generated.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/resolvers/PipelineProgressResolver.d.ts +33 -0
- package/dist/resolvers/PipelineProgressResolver.d.ts.map +1 -0
- package/dist/resolvers/PipelineProgressResolver.js +138 -0
- package/dist/resolvers/PipelineProgressResolver.js.map +1 -0
- package/dist/resolvers/RunAIAgentResolver.js +4 -4
- package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
- package/dist/resolvers/SearchKnowledgeResolver.d.ts +85 -0
- package/dist/resolvers/SearchKnowledgeResolver.d.ts.map +1 -0
- package/dist/resolvers/SearchKnowledgeResolver.js +587 -0
- package/dist/resolvers/SearchKnowledgeResolver.js.map +1 -0
- package/dist/resolvers/VectorizeEntityResolver.d.ts +21 -0
- package/dist/resolvers/VectorizeEntityResolver.d.ts.map +1 -0
- package/dist/resolvers/VectorizeEntityResolver.js +134 -0
- package/dist/resolvers/VectorizeEntityResolver.js.map +1 -0
- package/package.json +63 -62
- package/src/agents/skip-sdk.ts +31 -2
- package/src/generated/generated.ts +83 -0
- package/src/index.ts +3 -0
- package/src/resolvers/PipelineProgressResolver.ts +107 -0
- package/src/resolvers/RunAIAgentResolver.ts +4 -4
- package/src/resolvers/SearchKnowledgeResolver.ts +614 -0
- package/src/resolvers/VectorizeEntityResolver.ts +123 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Resolver, Subscription, Root, ObjectType, Field, Float, Mutation, Arg, Ctx, PubSub, PubSubEngine } from 'type-graphql';
|
|
2
|
+
import { AppContext } from '../types.js';
|
|
3
|
+
import { LogStatus, LogError } from '@memberjunction/core';
|
|
4
|
+
import { ResolverBase } from '../generic/ResolverBase.js';
|
|
5
|
+
|
|
6
|
+
const PIPELINE_PROGRESS_TOPIC = 'PIPELINE_PROGRESS';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Stage of the knowledge pipeline.
|
|
10
|
+
*/
|
|
11
|
+
export type PipelineStageType = 'extract' | 'autotag' | 'vectorize' | 'complete' | 'error';
|
|
12
|
+
|
|
13
|
+
@ObjectType()
|
|
14
|
+
export class PipelineProgressNotification {
|
|
15
|
+
@Field()
|
|
16
|
+
PipelineRunID: string;
|
|
17
|
+
|
|
18
|
+
@Field()
|
|
19
|
+
Stage: string;
|
|
20
|
+
|
|
21
|
+
@Field()
|
|
22
|
+
TotalItems: number;
|
|
23
|
+
|
|
24
|
+
@Field()
|
|
25
|
+
ProcessedItems: number;
|
|
26
|
+
|
|
27
|
+
@Field({ nullable: true })
|
|
28
|
+
CurrentItem?: string;
|
|
29
|
+
|
|
30
|
+
@Field(() => Float)
|
|
31
|
+
ElapsedMs: number;
|
|
32
|
+
|
|
33
|
+
@Field(() => Float, { nullable: true })
|
|
34
|
+
EstimatedRemainingMs?: number;
|
|
35
|
+
|
|
36
|
+
@Field(() => Float)
|
|
37
|
+
PercentComplete: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@ObjectType()
|
|
41
|
+
export class PipelineStartResult {
|
|
42
|
+
@Field()
|
|
43
|
+
Success: boolean;
|
|
44
|
+
|
|
45
|
+
@Field()
|
|
46
|
+
PipelineRunID: string;
|
|
47
|
+
|
|
48
|
+
@Field({ nullable: true })
|
|
49
|
+
ErrorMessage?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Resolver()
|
|
53
|
+
export class PipelineProgressResolver extends ResolverBase {
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to pipeline progress notifications for a specific pipeline run.
|
|
56
|
+
*/
|
|
57
|
+
@Subscription(() => PipelineProgressNotification, {
|
|
58
|
+
topics: PIPELINE_PROGRESS_TOPIC,
|
|
59
|
+
filter: ({ payload, args }: { payload: PipelineProgressNotification; args: { pipelineRunID: string } }) => {
|
|
60
|
+
return payload.PipelineRunID === args.pipelineRunID;
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
PipelineProgress(
|
|
64
|
+
@Root() notification: PipelineProgressNotification,
|
|
65
|
+
@Arg('pipelineRunID') _pipelineRunID: string
|
|
66
|
+
): PipelineProgressNotification {
|
|
67
|
+
return notification;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Publish a pipeline progress update. Called internally by the pipeline engine.
|
|
72
|
+
*/
|
|
73
|
+
@Mutation(() => Boolean)
|
|
74
|
+
async PublishPipelineProgress(
|
|
75
|
+
@Arg('pipelineRunID') pipelineRunID: string,
|
|
76
|
+
@Arg('stage') stage: string,
|
|
77
|
+
@Arg('totalItems') totalItems: number,
|
|
78
|
+
@Arg('processedItems') processedItems: number,
|
|
79
|
+
@Arg('currentItem', { nullable: true }) currentItem: string | undefined,
|
|
80
|
+
@Arg('elapsedMs', () => Float) elapsedMs: number,
|
|
81
|
+
@Arg('estimatedRemainingMs', () => Float, { nullable: true }) estimatedRemainingMs: number | undefined,
|
|
82
|
+
@PubSub() pubSub: PubSubEngine,
|
|
83
|
+
@Ctx() { userPayload }: AppContext = {} as AppContext
|
|
84
|
+
): Promise<boolean> {
|
|
85
|
+
try {
|
|
86
|
+
const percentComplete = totalItems > 0 ? Math.round((processedItems / totalItems) * 100) : 0;
|
|
87
|
+
|
|
88
|
+
const notification: PipelineProgressNotification = {
|
|
89
|
+
PipelineRunID: pipelineRunID,
|
|
90
|
+
Stage: stage,
|
|
91
|
+
TotalItems: totalItems,
|
|
92
|
+
ProcessedItems: processedItems,
|
|
93
|
+
CurrentItem: currentItem,
|
|
94
|
+
ElapsedMs: elapsedMs,
|
|
95
|
+
EstimatedRemainingMs: estimatedRemainingMs,
|
|
96
|
+
PercentComplete: percentComplete,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
await pubSub.publish(PIPELINE_PROGRESS_TOPIC, notification);
|
|
100
|
+
LogStatus(`PipelineProgress: ${stage} ${processedItems}/${totalItems} (${percentComplete}%)`);
|
|
101
|
+
return true;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
LogError(`PipelineProgressResolver.PublishPipelineProgress failed: ${error}`);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -390,10 +390,10 @@ export class RunAIAgentResolver extends ResolverBase {
|
|
|
390
390
|
// Validate agent
|
|
391
391
|
const agentEntity = await this.validateAgent(agentId, currentUser);
|
|
392
392
|
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
//
|
|
396
|
-
const agentRunner = new AgentRunner();
|
|
393
|
+
// Create AI agent runner with the per-request isolated provider so all agent DB operations
|
|
394
|
+
// (AIAgentRun, AIAgentRunSteps, AIAgentRequests, AIPromptRuns) never share the global
|
|
395
|
+
// singleton's transaction state with concurrent requests (e.g. conversation deletes).
|
|
396
|
+
const agentRunner = new AgentRunner(p);
|
|
397
397
|
|
|
398
398
|
// Track agent run for streaming (use ref to update later)
|
|
399
399
|
const agentRunRef = { current: null as any };
|