Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@anthropic-ai/claude-code": "=1.0.24",
"@anthropic-ai/sdk": "~0.54.0",
"@anthropic-ai/bedrock-sdk": "~0.22.2",
"@automa/bot": "~0.3.0",
"@automa/bot": "file:../sdk-typescript/packages/bot",
"@fastify/autoload": "~6.3.1",
"@fastify/helmet": "~13.0.2",
"@fastify/sensible": "~6.0.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { env } from './env';

import AnthropicBedrock from '@anthropic-ai/bedrock-sdk';
import Anthropic from '@anthropic-ai/sdk';
import Automa from '@automa/bot';

export const automa = new Automa();

export const anthropic = env.ANTHROPIC.API_KEY
? new Anthropic({
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const version = pkg.version;
const schema = z.object({
ANTHROPIC: z.object({
API_KEY: z.string().optional(),
MODEL: z.string().default('claude-sonnet-4-0'),
MODEL: z.string().default('claude-sonnet-4-5'),
}),
AUTOMA: z.object({
WEBHOOK_SECRET: z.string().default('atma_whsec_claude-code'),
Expand Down
26 changes: 12 additions & 14 deletions src/routes/hooks/automa.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FastifyInstance } from 'fastify';
import { Tool } from '@anthropic-ai/sdk/resources/messages';
import {
Automa,
verifyWebhook,
WebhookEventData,
WebhookEventType,
Expand All @@ -11,7 +12,7 @@ import { z } from 'zod/v4';

import { env } from '../../env';

import { anthropic, automa } from '../../clients';
import { anthropic } from '../../clients';
import { update } from '../../update';

const PullRequest = z.object({
Expand Down Expand Up @@ -102,28 +103,25 @@ export const runUpdate = async (
baseURL: string,
data: WebhookEventData<WebhookEventType.TaskCreated>,
) => {
const automa = new Automa({ baseURL });

// Download code
const folder = await automa.code.download(data, { baseURL });
const folder = await automa.code.download(data);

try {
// Modify code
const { message } = await update(app, folder, data);
const { message } = await update(app, folder, data, automa);

const prFields = await generatePrFields(message);

// Propose code
await automa.code.propose(
{
...data,
proposal: {
title: prFields?.title,
body: prFields?.body,
},
await automa.code.propose({
...data,
proposal: {
title: prFields?.title,
body: prFields?.body,
},
{
baseURL,
},
);
});
} finally {
// Clean up
automa.code.cleanup(data);
Expand Down
12 changes: 11 additions & 1 deletion src/update/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { FastifyInstance } from 'fastify';
import { query } from '@anthropic-ai/claude-code';
import { CodeFolder, WebhookEventData, WebhookEventType } from '@automa/bot';
import Automa, {
CodeFolder,
WebhookEventData,
WebhookEventType,
} from '@automa/bot';

export const update = async (
app: FastifyInstance,
folder: CodeFolder,
data: WebhookEventData<WebhookEventType.TaskCreated>,
automa: Automa,
) => {
const descriptions = data.task.items
.filter(({ type }) => type === 'message')
Expand Down Expand Up @@ -36,6 +41,11 @@ export const update = async (
let completedMsg;

for await (const message of run) {
automa.task.log({
task: { id: data.task.id, token: data.task.token },
event: message,
});

if (message.type === 'result') {
completedMsg = message;
}
Expand Down
Loading