Skip to content

Commit

Permalink
feat: fixed auth problem on jobs and removed logs (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
shide1989 authored Jan 31, 2025
1 parent e4b9975 commit 336379c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
27 changes: 10 additions & 17 deletions src/commands/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

import { queryCommand } from './query';

import { listAgentsFromWorkspace, readConfig } from '../utils/conf';
import { listAgentsFromWorkspace } from '../utils/conf';
import { unixSourceCommand } from '../utils/shellCommands';
import Logger from '../utils/logger';

Expand Down Expand Up @@ -72,7 +72,6 @@ export async function jobSubscriptionCommand(options: {
if (options.listen) {
try {
const workspace = options.workspace || process.cwd();
const config = readConfig();

const [agent] = listAgentsFromWorkspace(workspace);

Expand All @@ -83,8 +82,7 @@ export async function jobSubscriptionCommand(options: {
logger.start(`Listening for new jobs on ${workspace}`);

const response = await axios.get(
`${API_HOST}${API_VERSION}/agents/${agent.id}/jobs?status=todo`,
{ headers: { Authorization: `Bearer ${config?.api_key}` } }
`${API_HOST}${API_VERSION}/agents/${agent.id}/jobs?status=todo`
);

const jobs = response.data;
Expand All @@ -98,21 +96,16 @@ export async function jobSubscriptionCommand(options: {

logger.stop(`Found ${jobs.length} jobs to execute`);
for (const idx in jobs) {
await axios.put(
`${API_HOST}${API_VERSION}/jobs/${jobs[idx].id}`,
{
status: 'in_progress',
host: `${shell_user.trim()}@${localIP.trim()}`,
},
{ headers: { Authorization: `Bearer ${config?.api_key}` } }
);
await axios.put(`${API_HOST}${API_VERSION}/jobs/${jobs[idx].id}`, {
status: 'in_progress',
host: `${shell_user.trim()}@${localIP.trim()}`,
});
await queryCommand(jobs[idx].brief, {
callback: async (response: unknown) => {
await axios.put(
`${API_HOST}${API_VERSION}/jobs/${jobs[idx].id}`,
{ status: 'completed', result: response },
{ headers: { Authorization: `Bearer ${config?.api_key}` } }
);
await axios.put(`${API_HOST}${API_VERSION}/jobs/${jobs[idx].id}`, {
status: 'completed',
result: response,
});
},
});
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ program
'Unsubscribe to the API for new jobs on the current workspace'
)
.option('--listen', 'Listen for new jobs from the API and execute them')
.hook('preAction', authMiddleware)
.action(jobSubscriptionCommand);

program
Expand Down
1 change: 0 additions & 1 deletion src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export function getDirectoryMd5Hash({
maxDepth = DEFAULT_MAX_DEPTH,
maxDirSize = DEFAULT_MAX_DIR_SIZE, // 10MB
}: DirectoryMd5HashOptions) {
Logger.debug('Computing MD5 hash for directory:', directoryPath);
// Initialize ignore manager at root level
const ignoreManager = IgnoreManager.getInstance();

Expand Down
1 change: 0 additions & 1 deletion src/utils/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export class IgnoreManager {
}
}
});
Logger.debug('Unique ignore patterns:', uniquePatterns);
}

/**
Expand Down

0 comments on commit 336379c

Please sign in to comment.