Skip to content

Commit 0e6aa72

Browse files
committed
fix: static prompts, move agents out of tasks
1 parent 701387f commit 0e6aa72

File tree

11 files changed

+31
-30
lines changed

11 files changed

+31
-30
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"timeout": 900000,
4343
"nodeVersion": 22,
4444
"static": [
45-
"src/tasks/agents/brand-profile/prompts",
45+
"src/agents/brand-profile/prompts/system.prompt",
46+
"src/agents/brand-profile/prompts/user.prompt",
4647
"static/cls1.md",
4748
"static/cls2.md",
4849
"static/inp1.md",
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/tasks/agent-executor/handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { ok, badRequest } from '@adobe/spacecat-shared-http-utils';
1313
import { hasText, isNonEmptyObject } from '@adobe/spacecat-shared-utils';
1414

15-
import { getAgent } from '../agents/registry.js';
15+
import { getAgent } from '../../agents/registry.js';
1616

1717
/**
1818
* Message shape:

test/tasks/agents/base.test.js renamed to test/agents/base.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import path from 'path';
1818
import os from 'os';
1919
import fs from 'fs';
2020

21-
import { readPromptFile, renderTemplate } from '../../../src/tasks/agents/base.js';
21+
import { readPromptFile, renderTemplate } from '../../src/agents/base.js';
2222

2323
describe('agents/base utilities', () => {
2424
describe('renderTemplate', () => {

test/tasks/agents/brand-profile/brand-profile.test.js renamed to test/agents/brand-profile/brand-profile.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ describe('agents/brand-profile', () => {
4949
});
5050
const createFrom = sandbox.stub().returns({ fetchChatCompletion });
5151

52-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
52+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
5353
'@adobe/spacecat-shared-gpt-client': {
5454
AzureOpenAIClient: { createFrom },
5555
},
56-
'../../../../src/tasks/agents/base.js': {
56+
'../../../src/agents/base.js': {
5757
readPromptFile: sandbox.stub()
5858
.onFirstCall()
5959
.returns('SYS_PROMPT')
@@ -78,8 +78,8 @@ describe('agents/brand-profile', () => {
7878
});
7979

8080
it('run() throws on invalid baseURL', async () => {
81-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
82-
'../../../../src/tasks/agents/base.js': {
81+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
82+
'../../../src/agents/base.js': {
8383
readPromptFile: sandbox.stub(),
8484
renderTemplate: sandbox.stub(),
8585
},
@@ -94,11 +94,11 @@ describe('agents/brand-profile', () => {
9494
});
9595
const createFrom = sandbox.stub().returns({ fetchChatCompletion });
9696

97-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
97+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
9898
'@adobe/spacecat-shared-gpt-client': {
9999
AzureOpenAIClient: { createFrom },
100100
},
101-
'../../../../src/tasks/agents/base.js': {
101+
'../../../src/agents/base.js': {
102102
readPromptFile: sandbox.stub()
103103
.onFirstCall()
104104
.returns('SYS_PROMPT')
@@ -119,11 +119,11 @@ describe('agents/brand-profile', () => {
119119
});
120120
const createFrom = sandbox.stub().returns({ fetchChatCompletion });
121121

122-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
122+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
123123
'@adobe/spacecat-shared-gpt-client': {
124124
AzureOpenAIClient: { createFrom },
125125
},
126-
'../../../../src/tasks/agents/base.js': {
126+
'../../../src/agents/base.js': {
127127
readPromptFile: sandbox.stub()
128128
.onFirstCall()
129129
.returns('SYS_PROMPT')
@@ -142,7 +142,7 @@ describe('agents/brand-profile', () => {
142142
});
143143

144144
it('persist() returns early for invalid siteId', async () => {
145-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {});
145+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {});
146146

147147
await mod.default.persist(
148148
{ context: { siteId: 'invalid' } },
@@ -153,7 +153,7 @@ describe('agents/brand-profile', () => {
153153
});
154154

155155
it('persist() returns early for empty result', async () => {
156-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {});
156+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {});
157157
await mod.default.persist(
158158
{ context: { siteId: '123e4567-e89b-12d3-a456-426614174000' } },
159159
context,
@@ -166,7 +166,7 @@ describe('agents/brand-profile', () => {
166166
const findById = sandbox.stub().resolves(null);
167167
context.dataAccess.Site = { findById };
168168

169-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {});
169+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {});
170170
await mod.default.persist(
171171
{ context: { siteId: '123e4567-e89b-12d3-a456-426614174000' } },
172172
context,
@@ -195,7 +195,7 @@ describe('agents/brand-profile', () => {
195195
context.dataAccess.Site = { findById };
196196

197197
const toDynamoItem = sandbox.stub().callsFake((c) => c);
198-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
198+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
199199
'@adobe/spacecat-shared-data-access/src/models/site/config.js': {
200200
Config: { toDynamoItem },
201201
},
@@ -230,7 +230,7 @@ describe('agents/brand-profile', () => {
230230
context.dataAccess.Site = { findById };
231231

232232
const toDynamoItem = sandbox.stub().callsFake((c) => c);
233-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
233+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
234234
'@adobe/spacecat-shared-data-access/src/models/site/config.js': {
235235
Config: { toDynamoItem },
236236
},
@@ -267,7 +267,7 @@ describe('agents/brand-profile', () => {
267267
context.dataAccess.Site = { findById };
268268

269269
const toDynamoItem = sandbox.stub().callsFake((c) => c);
270-
const mod = await esmock('../../../../src/tasks/agents/brand-profile/index.js', {
270+
const mod = await esmock('../../../src/agents/brand-profile/index.js', {
271271
'@adobe/spacecat-shared-data-access/src/models/site/config.js': {
272272
Config: { toDynamoItem },
273273
},

test/tasks/agents/registry.test.js renamed to test/agents/registry.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ describe('agents/registry', () => {
3737
persist: sandbox.stub().resolves(),
3838
};
3939

40-
const registryModule = await esmock('../../../src/tasks/agents/registry.js', {
41-
'../../../src/tasks/agents/brand-profile/index.js': {
40+
const registryModule = await esmock('../../src/agents/registry.js', {
41+
'../../src/agents/brand-profile/index.js': {
4242
default: mockAgent,
4343
},
4444
});
@@ -50,8 +50,8 @@ describe('agents/registry', () => {
5050
});
5151

5252
it('returns null for unknown agent id', async () => {
53-
const registryModule = await esmock('../../../src/tasks/agents/registry.js', {
54-
'../../../src/tasks/agents/brand-profile/index.js': {
53+
const registryModule = await esmock('../../src/agents/registry.js', {
54+
'../../src/agents/brand-profile/index.js': {
5555
default: {},
5656
},
5757
});

0 commit comments

Comments
 (0)