Skip to content

Commit 43b51c0

Browse files
committed
changes from review
1 parent 882db63 commit 43b51c0

File tree

12 files changed

+36
-49
lines changed

12 files changed

+36
-49
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Sophia Agent is an autonomous workflow agent that monitors, logs, and notifies a
44

55
## Features
66

7-
- **Watches** for new wiki creations or edits by Sophia on iq.wiki
7+
- **Checks** for new wiki creations or edits by Sophia on iq.wiki
88
- **Logs** activities to the $SOPHIA agent on IQAI ATP
99
- **Notifies** a Telegram channel about new activities
1010
- **Scheduled** to run at configurable intervals (via cron)
@@ -67,9 +67,8 @@ pnpm run start
6767

6868
## Project Structure
6969

70-
- `src/agents/` — Agent definitions (Watcher, Logger, Notifier, SophiaAgent)
71-
- `src/utils/` — Utility functions (MCP config, etc.)
72-
- `src/runner.ts` — Toolset lifecycle, scheduling, and shutdown logic
70+
- `src/agents/` — Agent definitions (Wikis Checker, Logger, Notifier, SophiaAgent)
71+
- `src/cron.ts` — scheduling, and shutdown logic
7372
- `src/index.ts` — Entry point
7473

7574
## License

src/agents/sophia/agent.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
import {
2-
AgentBuilder,
3-
type BaseTool,
4-
type BuiltAgent,
5-
InMemorySessionService,
6-
} from "@iqai/adk";
7-
import type { LanguageModelV1 } from "@openrouter/ai-sdk-provider";
1+
import { AgentBuilder, type BuiltAgent } from "@iqai/adk";
82
import { atpLoggerAgent } from "./sub-agents/logger/agent";
93
import { notifierAgent } from "./sub-agents/notifier/agent";
10-
import { watcherAgent } from "./sub-agents/watcher/agent";
4+
import { wikisCheckerAgent } from "./sub-agents/wikis-checker/agent";
115

126
export async function sophiaAgent(): Promise<BuiltAgent> {
13-
const watcher = await watcherAgent();
7+
const wikisChecker = await wikisCheckerAgent();
148
const atpLogger = await atpLoggerAgent();
159
const notifier = await notifierAgent();
16-
const sessionService = new InMemorySessionService();
1710
return await AgentBuilder.create("sophia")
1811
.withDescription(
1912
"Sophia agent watches for new wiki creations or edits of sophia on iq.wiki platform and logs the activities to the ATP and sends a notification to the Telegram",
2013
)
2114
.asLangGraph(
2215
[
2316
{
24-
name: "watcher",
25-
agent: watcher,
17+
name: "wikis_checker",
18+
agent: wikisChecker,
2619
targets: ["atp_logger"],
2720
},
2821
{
@@ -44,8 +37,7 @@ export async function sophiaAgent(): Promise<BuiltAgent> {
4437
targets: [],
4538
},
4639
],
47-
"watcher",
40+
"wikis_checker",
4841
)
49-
.withSessionService(sessionService)
5042
.build();
5143
}

src/agents/sophia/sub-agents/logger/agent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { env, model } from "@/env";
12
import { LlmAgent } from "@iqai/adk";
2-
import { env, model } from "../../../../env";
33
import { getAtpTools } from "./tools";
44

55
export async function atpLoggerAgent(): Promise<LlmAgent> {
@@ -11,8 +11,8 @@ export async function atpLoggerAgent(): Promise<LlmAgent> {
1111
instruction: `
1212
YOU ARE THE ATP LOGGER AGENT ON THE SOPHIA AGENT'S WORKFLOW.
1313
YOUR ONLY TASK IS TO LOG THE ACTIVITIES OF SOPHIA ON IQ.WIKI PLATFORM TO THE $SOPHIA AGENT ON IQAI ATP.
14-
THE SOPHIA WIKIS ACTIVITIES ARE ALREADY LOGGED IN THE CONTEXT BY THE watcher AGENT:
15-
{watcher}
14+
THE SOPHIA WIKIS ACTIVITIES ARE ALREADY LOGGED IN THE CONTEXT BY THE wikis_checker AGENT:
15+
{wikis_checker}
1616
1717
SOPHIA'S TOKEN ADDRESS ON ATP: ${env.SOPHIA_TOKEN_ADDRESS}
1818

src/agents/sophia/sub-agents/logger/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { env } from "@/env";
12
import { McpAtp } from "@iqai/adk";
2-
import { env } from "../../../../env";
33

44
export const getAtpTools = async () => {
55
const toolset = McpAtp({

src/agents/sophia/sub-agents/notifier/agent.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { getTelegramTools } from "@/agents/telegram-agent/tools";
2+
import { env, model } from "@/env";
13
import { LlmAgent } from "@iqai/adk";
2-
import { env, model } from "../../../../env";
3-
import { getTelegramTools } from "../../../telegram-agent/tools";
44

55
export async function notifierAgent() {
66
const tools = await getTelegramTools();
@@ -13,29 +13,29 @@ export async function notifierAgent() {
1313
YOUR ONLY TASK IS TO SEND A NOTIFICATION TO TELEGRAM ABOUT THE LATEST WIKI ACTIVITY AND THE RESULT OF THE ATP LOGGING.
1414
1515
You will find in the context:
16-
- The detailed wiki activity response from the watcher agent: {watcher}
16+
- The detailed wiki activity response from the wikis_checker agent: {wikis_checker}
1717
- The ATP logging status from the atp_logger agent: {atp_logger}
1818
1919
Your only work is to do the below:
2020
- use this as chat id: ${env.TELEGRAM_CHAT_ID}
2121
- call the send_message tool to send a message with the following format:
2222
2323
If ATP logging was successful (if atp_logger response contains ATP_LOG_COMPLETE):
24-
Send the EXACT wiki activities from the watcher agent output, followed by:
24+
Send the EXACT wiki activities from the wikis_checker agent output, followed by:
2525
2626
✅ ATP Logging: Successfully logged all activities to $SOPHIA agent on IQAI ATP
2727
2828
If ATP logging failed (if atp_logger response contains ATP_LOG_FAILED):
29-
Send the EXACT wiki activities from the watcher agent output, followed by:
29+
Send the EXACT wiki activities from the wikis_checker agent output, followed by:
3030
3131
❌ ATP Logging: Failed to log some activities to $SOPHIA agent on IQAI ATP
3232
[Include details about the failure from atp_logger response]
3333
3434
IMPORTANT:
35-
- You MUST use the watcher agent output ({watcher}) for the wiki activity details (titles, summaries, edit times, changes, source links, transaction links)
35+
- You MUST use the wikis_checker agent output ({wikis_checker}) for the wiki activity details (titles, summaries, edit times, changes, source links, transaction links)
3636
- You MUST use the atp_logger agent output ({atp_logger}) only to determine success/failure status
3737
- Do NOT send generic messages or hallucinated data
38-
- The message should contain the actual wiki activity information from the watcher agent
38+
- The message should contain the actual wiki activity information from the wikis_checker agent
3939
- After you complete the above step, you must end your response with the token NOTIFICATION_COMPLETE.
4040
4141
IMPORTANT: You MUST end your response with the exact token NOTIFICATION_COMPLETE.

src/agents/sophia/sub-agents/watcher/agent.ts renamed to src/agents/sophia/sub-agents/wikis-checker/agent.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import { LlmAgent } from "@iqai/adk";
22
import { env, model } from "../../../../env";
33
import { getIqWikiTools } from "./tools";
44

5-
export async function watcherAgent(): Promise<LlmAgent> {
5+
export async function wikisCheckerAgent(): Promise<LlmAgent> {
66
const tools = await getIqWikiTools();
77
return new LlmAgent({
8-
name: "watcher",
9-
description:
10-
"Watches for new wiki creations or edits of sophia on iq.wiki platform.",
8+
name: "wikis_checker",
9+
description: "Checks for new wikis created by sophia on iq.wiki platform.",
1110
instruction: `
12-
YOU ARE THE WATCHER AGENT ON THE SOPHIA AGENT'S WORKFLOW.
13-
YOUR ONLY TASK IS TO WATCH FOR NEW WIKI CREATIONS OR EDITS OF SOPHIA ON IQ.WIKI PLATFORM.
11+
YOU ARE THE WIKIS CHECKER AGENT ON THE SOPHIA AGENT'S WORKFLOW.
12+
YOUR ONLY TASK IS TO CHECK FOR NEW WIKIS CREATED BY SOPHIA ON IQ.WIKI PLATFORM.
1413
1514
SOPHIA'S IQ.WIKI PROFILE ADDRESS: ${env.SOPHIA_ADDRESS}
1615
1716
Your only work is to do the below:
18-
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 14 hours (pass it as seconds)
17+
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 18 hours (pass it as seconds)
1918
- after you call the tool, if any new activities are seen, order them according to the time, older ones first. No extra formatting is needed.
2019
2120
After you complete the above steps, you might face two possible outcomes:
@@ -36,6 +35,6 @@ export async function watcherAgent(): Promise<LlmAgent> {
3635
`,
3736
model,
3837
tools,
39-
outputKey: "watcher",
38+
outputKey: "wikis_checker",
4039
});
4140
}
File renamed without changes.

src/agents/telegram-agent/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { model } from "@/env";
12
import { AgentBuilder, type SamplingHandler } from "@iqai/adk";
2-
import { model } from "../../env";
33
import { getTelegramTools } from "./tools";
44

55
export const createTelegramAgent = async (samplingHandler: SamplingHandler) => {

src/agents/telegram-agent/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { env } from "@/env";
12
import { McpTelegram, type SamplingHandler } from "@iqai/adk";
2-
import { env } from "../../env";
33

44
export const getTelegramTools = async (samplingHandler?: SamplingHandler) => {
55
const toolset = McpTelegram({

src/runner.ts renamed to src/cron.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
type BuiltAgent,
3-
McpAtp,
4-
McpError,
5-
McpIqWiki,
6-
McpTelegram,
7-
type McpToolset,
8-
} from "@iqai/adk";
1+
import { type BuiltAgent, McpError } from "@iqai/adk";
92
import * as cron from "node-cron";
103
import { env } from "./env";
114

0 commit comments

Comments
 (0)