@memberjunction/ng-agent-client 5.43.0 → 5.45.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/package.json +3 -3
- package/dist/__tests__/agent-client-service.test.d.ts +0 -2
- package/dist/__tests__/agent-client-service.test.d.ts.map +0 -1
- package/dist/__tests__/agent-client-service.test.js +0 -148
- package/dist/__tests__/agent-client-service.test.js.map +0 -1
- package/dist/__tests__/index.test.d.ts +0 -2
- package/dist/__tests__/index.test.d.ts.map +0 -1
- package/dist/__tests__/index.test.js +0 -7
- package/dist/__tests__/index.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-agent-client",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.45.0",
|
|
4
4
|
"description": "MemberJunction: Angular adapter for the Agent Client SDK - injectable service, navigation tools, RxJS bridges",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@angular/router": "21.1.3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@memberjunction/ai-agent-client": "5.
|
|
30
|
-
"@memberjunction/global": "5.
|
|
29
|
+
"@memberjunction/ai-agent-client": "5.45.0",
|
|
30
|
+
"@memberjunction/global": "5.45.0",
|
|
31
31
|
"rxjs": "^7.8.2",
|
|
32
32
|
"tslib": "^2.8.1"
|
|
33
33
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-client-service.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/agent-client-service.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
/**
|
|
3
|
-
* Tests for AgentClientService — verifies pass-through delegation to AgentClientSession.
|
|
4
|
-
*/
|
|
5
|
-
vi.mock('@angular/core', () => ({
|
|
6
|
-
Injectable: () => (target) => target,
|
|
7
|
-
OnDestroy: class {
|
|
8
|
-
},
|
|
9
|
-
}));
|
|
10
|
-
// Track the mock session created by the constructor
|
|
11
|
-
let createdSession;
|
|
12
|
-
vi.mock('@memberjunction/ai-agent-client', () => {
|
|
13
|
-
// Factory runs at module load — must define mock inside
|
|
14
|
-
function MockAgentClientSession() {
|
|
15
|
-
const session = {
|
|
16
|
-
ToolRequested$: { subscribe: () => { } },
|
|
17
|
-
ToolExecuted$: { subscribe: () => { } },
|
|
18
|
-
AgentProgress$: { subscribe: () => { } },
|
|
19
|
-
SessionActive$: { subscribe: () => { } },
|
|
20
|
-
Error$: { subscribe: () => { } },
|
|
21
|
-
SessionId: null,
|
|
22
|
-
IsActive: false,
|
|
23
|
-
RegisterTool: vi.fn(),
|
|
24
|
-
UnregisterTool: vi.fn(),
|
|
25
|
-
GetRegisteredTools: vi.fn().mockReturnValue([]),
|
|
26
|
-
RegisterToolDecorator: vi.fn(),
|
|
27
|
-
SetDecoratorContext: vi.fn(),
|
|
28
|
-
DecorateAndSendTools: vi.fn().mockResolvedValue(undefined),
|
|
29
|
-
StartSession: vi.fn(),
|
|
30
|
-
StopSession: vi.fn(),
|
|
31
|
-
RunAgent: vi.fn().mockResolvedValue({ Success: true }),
|
|
32
|
-
RunAgentFromConversationDetail: vi.fn().mockResolvedValue({ Success: true }),
|
|
33
|
-
Dispose: vi.fn(),
|
|
34
|
-
};
|
|
35
|
-
createdSession = session;
|
|
36
|
-
return session;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
AgentClientSession: MockAgentClientSession,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
import { AgentClientService } from '../lib/agent-client.service';
|
|
43
|
-
describe('AgentClientService', () => {
|
|
44
|
-
let service;
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
vi.clearAllMocks();
|
|
47
|
-
service = new AgentClientService();
|
|
48
|
-
});
|
|
49
|
-
describe('Observable pass-throughs', () => {
|
|
50
|
-
it('should expose ToolRequested$ from the session', () => {
|
|
51
|
-
expect(service.ToolRequested$).toBe(createdSession.ToolRequested$);
|
|
52
|
-
});
|
|
53
|
-
it('should expose ToolExecuted$ from the session', () => {
|
|
54
|
-
expect(service.ToolExecuted$).toBe(createdSession.ToolExecuted$);
|
|
55
|
-
});
|
|
56
|
-
it('should expose AgentProgress$ from the session', () => {
|
|
57
|
-
expect(service.AgentProgress$).toBe(createdSession.AgentProgress$);
|
|
58
|
-
});
|
|
59
|
-
it('should expose SessionActive$ from the session', () => {
|
|
60
|
-
expect(service.SessionActive$).toBe(createdSession.SessionActive$);
|
|
61
|
-
});
|
|
62
|
-
it('should expose Error$ from the session', () => {
|
|
63
|
-
expect(service.Error$).toBe(createdSession.Error$);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
describe('Session state', () => {
|
|
67
|
-
it('should return SessionId from the session', () => {
|
|
68
|
-
createdSession.SessionId = 'test-session-123';
|
|
69
|
-
expect(service.SessionId).toBe('test-session-123');
|
|
70
|
-
});
|
|
71
|
-
it('should return null SessionId when no session is active', () => {
|
|
72
|
-
createdSession.SessionId = null;
|
|
73
|
-
expect(service.SessionId).toBeNull();
|
|
74
|
-
});
|
|
75
|
-
it('should return IsActive from the session', () => {
|
|
76
|
-
createdSession.IsActive = true;
|
|
77
|
-
expect(service.IsActive).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
it('should return false when session is not active', () => {
|
|
80
|
-
createdSession.IsActive = false;
|
|
81
|
-
expect(service.IsActive).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('Tool registration', () => {
|
|
85
|
-
it('should delegate RegisterTool to the session', () => {
|
|
86
|
-
const tool = { Name: 'TestTool', Handler: vi.fn() };
|
|
87
|
-
service.RegisterTool(tool);
|
|
88
|
-
expect(createdSession.RegisterTool).toHaveBeenCalledWith(tool);
|
|
89
|
-
});
|
|
90
|
-
it('should delegate UnregisterTool to the session', () => {
|
|
91
|
-
service.UnregisterTool('TestTool');
|
|
92
|
-
expect(createdSession.UnregisterTool).toHaveBeenCalledWith('TestTool');
|
|
93
|
-
});
|
|
94
|
-
it('should delegate GetRegisteredTools to the session', () => {
|
|
95
|
-
const tools = [{ Name: 'Tool1' }, { Name: 'Tool2' }];
|
|
96
|
-
createdSession.GetRegisteredTools.mockReturnValue(tools);
|
|
97
|
-
expect(service.GetRegisteredTools()).toBe(tools);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe('Tool decoration', () => {
|
|
101
|
-
it('should delegate RegisterToolDecorator to the session', () => {
|
|
102
|
-
const decorator = vi.fn();
|
|
103
|
-
service.RegisterToolDecorator('MyTool', decorator);
|
|
104
|
-
expect(createdSession.RegisterToolDecorator).toHaveBeenCalledWith('MyTool', decorator);
|
|
105
|
-
});
|
|
106
|
-
it('should delegate SetDecoratorContext to the session', () => {
|
|
107
|
-
const context = { activeConversationId: 'conv-123' };
|
|
108
|
-
service.SetDecoratorContext(context);
|
|
109
|
-
expect(createdSession.SetDecoratorContext).toHaveBeenCalledWith(context);
|
|
110
|
-
});
|
|
111
|
-
it('should delegate DecorateAndSendTools to the session', async () => {
|
|
112
|
-
const baseTools = [{ Name: 'BaseTool' }];
|
|
113
|
-
await service.DecorateAndSendTools(baseTools);
|
|
114
|
-
expect(createdSession.DecorateAndSendTools).toHaveBeenCalledWith(baseTools);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
describe('Session lifecycle', () => {
|
|
118
|
-
it('should delegate StartSession to the session', () => {
|
|
119
|
-
service.StartSession('session-abc');
|
|
120
|
-
expect(createdSession.StartSession).toHaveBeenCalledWith('session-abc');
|
|
121
|
-
});
|
|
122
|
-
it('should delegate StopSession to the session', () => {
|
|
123
|
-
service.StopSession();
|
|
124
|
-
expect(createdSession.StopSession).toHaveBeenCalled();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
describe('Agent execution', () => {
|
|
128
|
-
it('should delegate RunAgent to the session', async () => {
|
|
129
|
-
const params = { AgentId: 'agent-1', Message: 'Hello' };
|
|
130
|
-
const result = await service.RunAgent(params);
|
|
131
|
-
expect(createdSession.RunAgent).toHaveBeenCalledWith(params);
|
|
132
|
-
expect(result).toEqual({ Success: true });
|
|
133
|
-
});
|
|
134
|
-
it('should delegate RunAgentFromConversationDetail to the session', async () => {
|
|
135
|
-
const params = { ConversationDetailId: 'detail-1' };
|
|
136
|
-
const result = await service.RunAgentFromConversationDetail(params);
|
|
137
|
-
expect(createdSession.RunAgentFromConversationDetail).toHaveBeenCalledWith(params);
|
|
138
|
-
expect(result).toEqual({ Success: true });
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe('Angular lifecycle', () => {
|
|
142
|
-
it('should call Dispose on the session when destroyed', () => {
|
|
143
|
-
service.ngOnDestroy();
|
|
144
|
-
expect(createdSession.Dispose).toHaveBeenCalled();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
//# sourceMappingURL=agent-client-service.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-client-service.test.js","sourceRoot":"","sources":["../../src/__tests__/agent-client-service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D;;GAEG;AAEH,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM;IAC9C,SAAS,EAAE;KAAQ;CACtB,CAAC,CAAC,CAAC;AAEJ,oDAAoD;AACpD,IAAI,cAAuC,CAAC;AAE5C,EAAE,CAAC,IAAI,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC5C,wDAAwD;IACxD,SAAS,sB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AM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC/B,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;YACzD,OAAO,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect, vi, beforeEach } from 'vitest';\n\n/**\n * Tests for AgentClientService — verifies pass-through delegation to AgentClientSession.\n */\n\nvi.mock('@angular/core', () => ({\n Injectable: () => (target: Function) => target,\n OnDestroy: class {},\n}));\n\n// Track the mock session created by the constructor\nlet createdSession: Record<string, unknown>;\n\nvi.mock('@memberjunction/ai-agent-client', () => {\n // Factory runs at module load — must define mock inside\n function MockAgentClientSession() {\n const session: Record<string, unknown> = {\n ToolRequested$: { subscribe: () => {} },\n ToolExecuted$: { subscribe: () => {} },\n AgentProgress$: { subscribe: () => {} },\n SessionActive$: { subscribe: () => {} },\n Error$: { subscribe: () => {} },\n SessionId: null,\n IsActive: false,\n RegisterTool: vi.fn(),\n UnregisterTool: vi.fn(),\n GetRegisteredTools: vi.fn().mockReturnValue([]),\n RegisterToolDecorator: vi.fn(),\n SetDecoratorContext: vi.fn(),\n DecorateAndSendTools: vi.fn().mockResolvedValue(undefined),\n StartSession: vi.fn(),\n StopSession: vi.fn(),\n RunAgent: vi.fn().mockResolvedValue({ Success: true }),\n RunAgentFromConversationDetail: vi.fn().mockResolvedValue({ Success: true }),\n Dispose: vi.fn(),\n };\n createdSession = session;\n return session;\n }\n return {\n AgentClientSession: MockAgentClientSession,\n };\n});\n\nimport { AgentClientService } from '../lib/agent-client.service';\n\ndescribe('AgentClientService', () => {\n let service: AgentClientService;\n\n beforeEach(() => {\n vi.clearAllMocks();\n service = new AgentClientService();\n });\n\n describe('Observable pass-throughs', () => {\n it('should expose ToolRequested$ from the session', () => {\n expect(service.ToolRequested$).toBe(createdSession.ToolRequested$);\n });\n\n it('should expose ToolExecuted$ from the session', () => {\n expect(service.ToolExecuted$).toBe(createdSession.ToolExecuted$);\n });\n\n it('should expose AgentProgress$ from the session', () => {\n expect(service.AgentProgress$).toBe(createdSession.AgentProgress$);\n });\n\n it('should expose SessionActive$ from the session', () => {\n expect(service.SessionActive$).toBe(createdSession.SessionActive$);\n });\n\n it('should expose Error$ from the session', () => {\n expect(service.Error$).toBe(createdSession.Error$);\n });\n });\n\n describe('Session state', () => {\n it('should return SessionId from the session', () => {\n createdSession.SessionId = 'test-session-123';\n expect(service.SessionId).toBe('test-session-123');\n });\n\n it('should return null SessionId when no session is active', () => {\n createdSession.SessionId = null;\n expect(service.SessionId).toBeNull();\n });\n\n it('should return IsActive from the session', () => {\n createdSession.IsActive = true;\n expect(service.IsActive).toBe(true);\n });\n\n it('should return false when session is not active', () => {\n createdSession.IsActive = false;\n expect(service.IsActive).toBe(false);\n });\n });\n\n describe('Tool registration', () => {\n it('should delegate RegisterTool to the session', () => {\n const tool = { Name: 'TestTool', Handler: vi.fn() };\n service.RegisterTool(tool as never);\n expect(createdSession.RegisterTool).toHaveBeenCalledWith(tool);\n });\n\n it('should delegate UnregisterTool to the session', () => {\n service.UnregisterTool('TestTool');\n expect(createdSession.UnregisterTool).toHaveBeenCalledWith('TestTool');\n });\n\n it('should delegate GetRegisteredTools to the session', () => {\n const tools = [{ Name: 'Tool1' }, { Name: 'Tool2' }];\n (createdSession.GetRegisteredTools as ReturnType<typeof vi.fn>).mockReturnValue(tools);\n expect(service.GetRegisteredTools()).toBe(tools);\n });\n });\n\n describe('Tool decoration', () => {\n it('should delegate RegisterToolDecorator to the session', () => {\n const decorator = vi.fn();\n service.RegisterToolDecorator('MyTool', decorator as never);\n expect(createdSession.RegisterToolDecorator).toHaveBeenCalledWith('MyTool', decorator);\n });\n\n it('should delegate SetDecoratorContext to the session', () => {\n const context = { activeConversationId: 'conv-123' };\n service.SetDecoratorContext(context as never);\n expect(createdSession.SetDecoratorContext).toHaveBeenCalledWith(context);\n });\n\n it('should delegate DecorateAndSendTools to the session', async () => {\n const baseTools = [{ Name: 'BaseTool' }];\n await service.DecorateAndSendTools(baseTools as never);\n expect(createdSession.DecorateAndSendTools).toHaveBeenCalledWith(baseTools);\n });\n });\n\n describe('Session lifecycle', () => {\n it('should delegate StartSession to the session', () => {\n service.StartSession('session-abc');\n expect(createdSession.StartSession).toHaveBeenCalledWith('session-abc');\n });\n\n it('should delegate StopSession to the session', () => {\n service.StopSession();\n expect(createdSession.StopSession).toHaveBeenCalled();\n });\n });\n\n describe('Agent execution', () => {\n it('should delegate RunAgent to the session', async () => {\n const params = { AgentId: 'agent-1', Message: 'Hello' };\n const result = await service.RunAgent(params as never);\n expect(createdSession.RunAgent).toHaveBeenCalledWith(params);\n expect(result).toEqual({ Success: true });\n });\n\n it('should delegate RunAgentFromConversationDetail to the session', async () => {\n const params = { ConversationDetailId: 'detail-1' };\n const result = await service.RunAgentFromConversationDetail(params as never);\n expect(createdSession.RunAgentFromConversationDetail).toHaveBeenCalledWith(params);\n expect(result).toEqual({ Success: true });\n });\n });\n\n describe('Angular lifecycle', () => {\n it('should call Dispose on the session when destroyed', () => {\n service.ngOnDestroy();\n expect(createdSession.Dispose).toHaveBeenCalled();\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect } from 'vitest';\n\ndescribe('@memberjunction/ng-agent-client', () => {\n it('should have a passing test', () => {\n expect(true).toBe(true);\n });\n});\n"]}
|