@axiom-lattice/examples-deep_research 1.0.10 → 1.0.11
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/.env +5 -5
- package/.turbo/turbo-build.log +7 -6
- package/CHANGELOG.md +7 -0
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/src/agents/research/index.ts +4 -0
- package/src/index.ts +47 -5
- package/tsup.config.ts +12 -0
- package/src/agents/todo/index.ts +0 -21
- package/src/agents/todo/tools/create_todo_item.ts +0 -37
- package/src/agents/todo/tools/read_todo_list.ts +0 -22
package/.env
CHANGED
|
@@ -25,7 +25,7 @@ SILICONCLOUD_API_KEY=sk-omhkuwebiotihbmgthgrcrzzneundgkeqmfrxnkzeldohpfi
|
|
|
25
25
|
|
|
26
26
|
VOLCENGINE_API_KEY=3c11b06b-3d48-4cce-a1c7-d9e0f5fab80c
|
|
27
27
|
VOLCENGINE_API_KEY2=a0533576-d6ed-4ca4-a308-473cbf7ebd10
|
|
28
|
-
|
|
28
|
+
KIMI_API_KEY=sk-9FlkLQyuBD5ULCEGFMFgnqHA5TtV0gYPTYkfBOWAarsaWzaq
|
|
29
29
|
|
|
30
30
|
TAVILY_API_KEY=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
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ QUEUE_NAME=simon_tasks
|
|
|
34
34
|
REDIS_URL=redis://localhost:6379
|
|
35
35
|
REDIS_PASSWORD=fina
|
|
36
36
|
|
|
37
|
-
LANGSMITH_TRACING=true
|
|
38
|
-
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
|
|
39
|
-
LANGSMITH_API_KEY="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"
|
|
40
|
-
LANGSMITH_PROJECT="fina"
|
|
37
|
+
# LANGSMITH_TRACING=true
|
|
38
|
+
# LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
|
|
39
|
+
# LANGSMITH_API_KEY="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"
|
|
40
|
+
# LANGSMITH_PROJECT="fina"
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/examples-deep_research@1.0.
|
|
3
|
-
> tsup
|
|
2
|
+
> @axiom-lattice/examples-deep_research@1.0.11 build /home/runner/work/agentic/agentic/examples/deep_research
|
|
3
|
+
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/agentic/agentic/examples/deep_research/tsup.config.ts
|
|
8
9
|
[34mCLI[39m Target: es2020
|
|
9
10
|
[34mCLI[39m Cleaning output folder
|
|
10
11
|
[34mCJS[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
+
[32mCJS[39m [1mdist/index.js [22m[32m11.45 KB[39m
|
|
13
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m13.13 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 35ms
|
|
14
15
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4590ms
|
|
16
17
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m13.00 B[39m
|
package/CHANGELOG.md
ADDED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -29,6 +30,7 @@ var import_core2 = require("@axiom-lattice/core");
|
|
|
29
30
|
|
|
30
31
|
// src/agents/research/index.ts
|
|
31
32
|
var import_core = require("@axiom-lattice/core");
|
|
33
|
+
var import_zod = __toESM(require("zod"));
|
|
32
34
|
var subResearchPrompt = `You are a dedicated researcher. Your job is to conduct research based on the users questions.
|
|
33
35
|
|
|
34
36
|
Conduct thorough research and then reply to the user with a detailed answer to their question
|
|
@@ -166,7 +168,10 @@ var research_agents = [
|
|
|
166
168
|
type: import_core.AgentType.DEEP_AGENT,
|
|
167
169
|
tools: ["internet_search"],
|
|
168
170
|
prompt: researchInstructions,
|
|
169
|
-
subAgents: ["critique-agent", "research-agent"]
|
|
171
|
+
subAgents: ["critique-agent", "research-agent"],
|
|
172
|
+
schema: import_zod.default.object({
|
|
173
|
+
test: import_zod.default.string().optional()
|
|
174
|
+
})
|
|
170
175
|
}
|
|
171
176
|
];
|
|
172
177
|
(0, import_core.registerAgentLattices)(research_agents);
|
|
@@ -174,6 +179,29 @@ var research_agents = [
|
|
|
174
179
|
// src/index.ts
|
|
175
180
|
var import_path = __toESM(require("path"));
|
|
176
181
|
import_dotenv.default.config({ path: import_path.default.resolve(__dirname, "../.env") });
|
|
182
|
+
function parsePort() {
|
|
183
|
+
const args = process.argv.slice(2);
|
|
184
|
+
const portIndex = args.findIndex((arg) => arg === "--port" || arg === "-p");
|
|
185
|
+
if (portIndex !== -1 && args[portIndex + 1]) {
|
|
186
|
+
const port2 = parseInt(args[portIndex + 1], 10);
|
|
187
|
+
if (!isNaN(port2) && port2 > 0 && port2 < 65536) {
|
|
188
|
+
return port2;
|
|
189
|
+
}
|
|
190
|
+
console.warn(
|
|
191
|
+
`Invalid port value: ${args[portIndex + 1]}, using default port 4001`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (process.env.PORT) {
|
|
195
|
+
const port2 = parseInt(process.env.PORT, 10);
|
|
196
|
+
if (!isNaN(port2) && port2 > 0 && port2 < 65536) {
|
|
197
|
+
return port2;
|
|
198
|
+
}
|
|
199
|
+
console.warn(
|
|
200
|
+
`Invalid PORT environment variable: ${process.env.PORT}, using default port 4001`
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return 4001;
|
|
204
|
+
}
|
|
177
205
|
(0, import_core2.registerModelLattice)(
|
|
178
206
|
"default",
|
|
179
207
|
// {
|
|
@@ -193,12 +221,19 @@ import_dotenv.default.config({ path: import_path.default.resolve(__dirname, "../
|
|
|
193
221
|
// streaming: false,
|
|
194
222
|
// },
|
|
195
223
|
{
|
|
196
|
-
model: "kimi-k2-
|
|
224
|
+
model: "kimi-k2-250905",
|
|
197
225
|
provider: "volcengine",
|
|
198
226
|
streaming: true,
|
|
199
227
|
apiKeyEnvName: "VOLCENGINE_API_KEY2"
|
|
200
228
|
}
|
|
201
229
|
// {
|
|
230
|
+
// model: "kimi-k2-0711-preview",
|
|
231
|
+
// provider: "openai",
|
|
232
|
+
// streaming: true,
|
|
233
|
+
// apiKeyEnvName: "KIMI_API_KEY",
|
|
234
|
+
// baseURL: "https://api.moonshot.cn/v1",
|
|
235
|
+
// }
|
|
236
|
+
// {
|
|
202
237
|
// model: "qwen-plus",
|
|
203
238
|
// provider: "openai",
|
|
204
239
|
// streaming: false,
|
|
@@ -207,5 +242,10 @@ import_dotenv.default.config({ path: import_path.default.resolve(__dirname, "../
|
|
|
207
242
|
// }
|
|
208
243
|
);
|
|
209
244
|
import_gateway.LatticeGateway.registerLatticeRoutes(import_gateway.LatticeGateway.app);
|
|
210
|
-
|
|
245
|
+
var port = parsePort();
|
|
246
|
+
console.log(`Starting server on port ${port}`);
|
|
247
|
+
import_gateway.LatticeGateway.startAsHttpEndpoint({
|
|
248
|
+
port,
|
|
249
|
+
queueServiceConfig: { type: "memory", defaultStartPollingQueue: true }
|
|
250
|
+
});
|
|
211
251
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/agents/research/index.ts"],"sourcesContent":["import dotenv from \"dotenv\";\n\nimport { LatticeGateway } from \"@axiom-lattice/gateway\";\nimport {\n registerCheckpointSaver,\n registerModelLattice,\n} from \"@axiom-lattice/core\";\nimport \"./agents\";\nimport path from \"path\";\n\n// 加载环境变量\ndotenv.config({ path: path.resolve(__dirname, \"../.env\") });\n\n// 注册默认模型Lattice\nregisterModelLattice(\n \"default\",\n // {\n // model: \"deepseek-chat\",\n // provider: \"deepseek\",\n // streaming: false,\n // }\n // {\n // model: \"deepseek-chat\",\n // provider: \"deepseek\",\n // streaming: false,\n // apiKeyEnvName: \"DEEPSEEK_API_KEY2\",\n // },\n // {\n // model: \"deepseek-v3-250324\",\n // provider: \"volcengine\",\n // streaming: false,\n // },\n {\n model: \"kimi-k2-250711\",\n provider: \"volcengine\",\n streaming: true,\n apiKeyEnvName: \"VOLCENGINE_API_KEY2\",\n }\n // {\n // model: \"qwen-plus\",\n // provider: \"openai\",\n // streaming: false,\n // apiKeyEnvName: \"DASHSCOPE_API_KEY\",\n // baseURL: \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n // }\n);\n\nLatticeGateway.registerLatticeRoutes(LatticeGateway.app);\n\nLatticeGateway.startAsHttpEndpoint({ port: 4001 });\n","/* eslint-disable no-console */\n\nimport {\n registerAgentLattices,\n AgentType,\n AgentConfig,\n} from \"@axiom-lattice/core\";\n\nconst subResearchPrompt = `You are a dedicated researcher. Your job is to conduct research based on the users questions.\n\nConduct thorough research and then reply to the user with a detailed answer to their question\n\nonly your FINAL answer will be passed on to the user. They will have NO knowledge of anything except your final message, so your final report should be your final message!`;\n\nconst subCritiquePrompt = `You are a dedicated editor. You are being tasked to critique a report.\n\nYou can find the report at \\`final_report.md\\`.\n\nYou can find the question/topic for this report at \\`question.txt\\`.\n\nThe user may ask for specific areas to critique the report in. Respond to the user with a detailed critique of the report. Things that could be improved.\n\nYou can use the search tool to search for information, if that will help you critique the report\n\nDo not write to the \\`final_report.md\\` yourself.\n\nThings to check:\n- Check that each section is appropriately named\n- Check that the report is written as you would find in an essay or a textbook - it should be text heavy, do not let it just be a list of bullet points!\n- Check that the report is comprehensive. If any paragraphs or sections are short, or missing important details, point it out.\n- Check that the article covers key areas of the industry, ensures overall understanding, and does not omit important parts.\n- Check that the article deeply analyzes causes, impacts, and trends, providing valuable insights\n- Check that the article closely follows the research topic and directly answers questions\n- Check that the article has a clear structure, fluent language, and is easy to understand.\n`;\n\n// Prompt prefix to steer the agent to be an expert researcher\nconst researchInstructions = `You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.\n\nThe first thing you should do is to write the original user question to \\`question.txt\\` so you have a record of it.\n\nUse the research-agent to conduct deep research. It will respond to your questions/topics with a detailed answer.\n\nWhen you think you enough information to write a final report, write it to \\`final_report.md\\`\n\nYou can call the critique-agent to get a critique of the final report. After that (if needed) you can do more research and edit the \\`final_report.md\\`\nYou can do this however many times you want until are you satisfied with the result.\n\nOnly edit the file once at a time (if you call this tool in parallel, there may be conflicts).\n\nHere are instructions for writing the final report:\n\n<report_instructions>\n\nCRITICAL: Make sure the answer is written in the same language as the human messages! If you make a todo plan - you should note in the plan what language the report should be in so you dont forget!\nNote: the language the report should be in is the language the QUESTION is in, not the language/country that the question is ABOUT.\n\nPlease create a detailed answer to the overall research brief that:\n1. Is well-organized with proper headings (# for title, ## for sections, ### for subsections)\n2. Includes specific facts and insights from the research\n3. References relevant sources using [Title](URL) format\n4. Provides a balanced, thorough analysis. Be as comprehensive as possible, and include all information that is relevant to the overall research question. People are using you for deep research and will expect detailed, comprehensive answers.\n5. Includes a \"Sources\" section at the end with all referenced links\n\nYou can structure your report in a number of different ways. Here are some examples:\n\nTo answer a question that asks you to compare two things, you might structure your report like this:\n1/ intro\n2/ overview of topic A\n3/ overview of topic B\n4/ comparison between A and B\n5/ conclusion\n\nTo answer a question that asks you to return a list of things, you might only need a single section which is the entire list.\n1/ list of things or table of things\nOr, you could choose to make each item in the list a separate section in the report. When asked for lists, you don't need an introduction or conclusion.\n1/ item 1\n2/ item 2\n3/ item 3\n\nTo answer a question that asks you to summarize a topic, give a report, or give an overview, you might structure your report like this:\n1/ overview of topic\n2/ concept 1\n3/ concept 2\n4/ concept 3\n5/ conclusion\n\nIf you think you can answer the question with a single section, you can do that too!\n1/ answer\n\nREMEMBER: Section is a VERY fluid and loose concept. You can structure your report however you think is best, including in ways that are not listed above!\nMake sure that your sections are cohesive, and make sense for the reader.\n\nFor each section of the report, do the following:\n- Use simple, clear language\n- Use ## for section title (Markdown format) for each section of the report\n- Do NOT ever refer to yourself as the writer of the report. This should be a professional report without any self-referential language.\n- Do not say what you are doing in the report. Just write the report without any commentary from yourself.\n- Each section should be as long as necessary to deeply answer the question with the information you have gathered. It is expected that sections will be fairly long and verbose. You are writing a deep research report, and users will expect a thorough answer.\n- Use bullet points to list out information when appropriate, but by default, write in paragraph form.\n\nREMEMBER:\nThe brief and research may be in English, but you need to translate this information to the right language when writing the final answer.\nMake sure the final answer report is in the SAME language as the human messages in the message history.\n\nFormat the report in clear markdown with proper structure and include source references where appropriate.\n\n<Citation Rules>\n- Assign each unique URL a single citation number in your text\n- End with ### Sources that lists each source with corresponding numbers\n- IMPORTANT: Number sources sequentially without gaps (1,2,3,4...) in the final list regardless of which sources you choose\n- Each source should be a separate line item in a list, so that in markdown it is rendered as a list.\n- Example format:\n [1] Source Title: URL\n [2] Source Title: URL\n- Citations are extremely important. Make sure to include these, and pay a lot of attention to getting these right. Users will often use these citations to look into more information.\n</Citation Rules>\n</report_instructions>\n\nYou have access to a few tools.\n\n## \\`internet_search\\`\n\nUse this to run an internet search for a given query. You can specify the number of results, the topic, and whether raw content should be included.\n`;\n\nconst research_agents: AgentConfig[] = [\n {\n key: \"research-agent\",\n name: \"research-agent\",\n type: AgentType.REACT,\n description:\n \"Used to research more in depth questions. Only give this researcher one topic at a time. Do not pass multiple sub questions to this researcher. Instead, you should break down a large topic into the necessary components, and then call multiple research agents in parallel, one for each sub question.\",\n prompt: subResearchPrompt,\n tools: [\"internet_search\"],\n },\n {\n key: \"critique-agent\",\n name: \"critique-agent\",\n type: AgentType.REACT,\n description:\n \"Used to critique the final report. Give this agent some infomration about how you want it to critique the report.\",\n prompt: subCritiquePrompt,\n },\n {\n key: \"main\",\n name: \"deep_research_agent\",\n description:\n \"Used to research more in depth questions. Only give this researcher one topic at a time. Do not pass multiple sub questions to this researcher. Instead, you should break down a large topic into the necessary components, and then call multiple research agents in parallel, one for each sub question.\",\n type: AgentType.DEEP_AGENT,\n tools: [\"internet_search\"],\n prompt: researchInstructions,\n subAgents: [\"critique-agent\", \"research-agent\"],\n },\n];\n\nregisterAgentLattices(research_agents);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAmB;AAEnB,qBAA+B;AAC/B,IAAAA,eAGO;;;ACJP,kBAIO;AAEP,IAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAM1B,IAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuB1B,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyF7B,IAAM,kBAAiC;AAAA,EACrC;AAAA,IACE,KAAK;AAAA,IACL,MAAM;AAAA,IACN,MAAM,sBAAU;AAAA,IAChB,aACE;AAAA,IACF,QAAQ;AAAA,IACR,OAAO,CAAC,iBAAiB;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,MAAM;AAAA,IACN,MAAM,sBAAU;AAAA,IAChB,aACE;AAAA,IACF,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,MAAM;AAAA,IACN,aACE;AAAA,IACF,MAAM,sBAAU;AAAA,IAChB,OAAO,CAAC,iBAAiB;AAAA,IACzB,QAAQ;AAAA,IACR,WAAW,CAAC,kBAAkB,gBAAgB;AAAA,EAChD;AACF;AAAA,IAEA,mCAAsB,eAAe;;;ADpJrC,kBAAiB;AAGjB,cAAAC,QAAO,OAAO,EAAE,MAAM,YAAAC,QAAK,QAAQ,WAAW,SAAS,EAAE,CAAC;AAAA,IAG1D;AAAA,EACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA;AAAA,IACE,OAAO;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,eAAe;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQF;AAEA,8BAAe,sBAAsB,8BAAe,GAAG;AAEvD,8BAAe,oBAAoB,EAAE,MAAM,KAAK,CAAC;","names":["import_core","dotenv","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/agents/research/index.ts"],"sourcesContent":["import dotenv from \"dotenv\";\n\nimport { LatticeGateway } from \"@axiom-lattice/gateway\";\nimport {\n registerCheckpointSaver,\n registerModelLattice,\n} from \"@axiom-lattice/core\";\nimport \"./agents\";\nimport path from \"path\";\n\n// Load environment variables\ndotenv.config({ path: path.resolve(__dirname, \"../.env\") });\n\n// Parse command line arguments for port configuration\nfunction parsePort(): number {\n const args = process.argv.slice(2);\n const portIndex = args.findIndex((arg) => arg === \"--port\" || arg === \"-p\");\n\n if (portIndex !== -1 && args[portIndex + 1]) {\n const port = parseInt(args[portIndex + 1], 10);\n if (!isNaN(port) && port > 0 && port < 65536) {\n return port;\n }\n console.warn(\n `Invalid port value: ${args[portIndex + 1]}, using default port 4001`\n );\n }\n\n // Check environment variable\n if (process.env.PORT) {\n const port = parseInt(process.env.PORT, 10);\n if (!isNaN(port) && port > 0 && port < 65536) {\n return port;\n }\n console.warn(\n `Invalid PORT environment variable: ${process.env.PORT}, using default port 4001`\n );\n }\n\n // Default port\n return 4001;\n}\n\n// Register default model Lattice\nregisterModelLattice(\n \"default\",\n // {\n // model: \"deepseek-chat\",\n // provider: \"deepseek\",\n // streaming: false,\n // }\n // {\n // model: \"deepseek-chat\",\n // provider: \"deepseek\",\n // streaming: false,\n // apiKeyEnvName: \"DEEPSEEK_API_KEY2\",\n // },\n // {\n // model: \"deepseek-v3-250324\",\n // provider: \"volcengine\",\n // streaming: false,\n // },\n {\n model: \"kimi-k2-250905\",\n provider: \"volcengine\",\n streaming: true,\n apiKeyEnvName: \"VOLCENGINE_API_KEY2\",\n }\n // {\n // model: \"kimi-k2-0711-preview\",\n // provider: \"openai\",\n // streaming: true,\n // apiKeyEnvName: \"KIMI_API_KEY\",\n // baseURL: \"https://api.moonshot.cn/v1\",\n // }\n // {\n // model: \"qwen-plus\",\n // provider: \"openai\",\n // streaming: false,\n // apiKeyEnvName: \"DASHSCOPE_API_KEY\",\n // baseURL: \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n // }\n);\nLatticeGateway.registerLatticeRoutes(LatticeGateway.app);\n\nconst port = parsePort();\nconsole.log(`Starting server on port ${port}`);\n\nLatticeGateway.startAsHttpEndpoint({\n port,\n queueServiceConfig: { type: \"memory\", defaultStartPollingQueue: true },\n});\n","/* eslint-disable no-console */\n\nimport {\n registerAgentLattices,\n AgentType,\n AgentConfig,\n} from \"@axiom-lattice/core\";\nimport z from \"zod\";\n\nconst subResearchPrompt = `You are a dedicated researcher. Your job is to conduct research based on the users questions.\n\nConduct thorough research and then reply to the user with a detailed answer to their question\n\nonly your FINAL answer will be passed on to the user. They will have NO knowledge of anything except your final message, so your final report should be your final message!`;\n\nconst subCritiquePrompt = `You are a dedicated editor. You are being tasked to critique a report.\n\nYou can find the report at \\`final_report.md\\`.\n\nYou can find the question/topic for this report at \\`question.txt\\`.\n\nThe user may ask for specific areas to critique the report in. Respond to the user with a detailed critique of the report. Things that could be improved.\n\nYou can use the search tool to search for information, if that will help you critique the report\n\nDo not write to the \\`final_report.md\\` yourself.\n\nThings to check:\n- Check that each section is appropriately named\n- Check that the report is written as you would find in an essay or a textbook - it should be text heavy, do not let it just be a list of bullet points!\n- Check that the report is comprehensive. If any paragraphs or sections are short, or missing important details, point it out.\n- Check that the article covers key areas of the industry, ensures overall understanding, and does not omit important parts.\n- Check that the article deeply analyzes causes, impacts, and trends, providing valuable insights\n- Check that the article closely follows the research topic and directly answers questions\n- Check that the article has a clear structure, fluent language, and is easy to understand.\n`;\n\n// Prompt prefix to steer the agent to be an expert researcher\nconst researchInstructions = `You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.\n\nThe first thing you should do is to write the original user question to \\`question.txt\\` so you have a record of it.\n\nUse the research-agent to conduct deep research. It will respond to your questions/topics with a detailed answer.\n\nWhen you think you enough information to write a final report, write it to \\`final_report.md\\`\n\nYou can call the critique-agent to get a critique of the final report. After that (if needed) you can do more research and edit the \\`final_report.md\\`\nYou can do this however many times you want until are you satisfied with the result.\n\nOnly edit the file once at a time (if you call this tool in parallel, there may be conflicts).\n\nHere are instructions for writing the final report:\n\n<report_instructions>\n\nCRITICAL: Make sure the answer is written in the same language as the human messages! If you make a todo plan - you should note in the plan what language the report should be in so you dont forget!\nNote: the language the report should be in is the language the QUESTION is in, not the language/country that the question is ABOUT.\n\nPlease create a detailed answer to the overall research brief that:\n1. Is well-organized with proper headings (# for title, ## for sections, ### for subsections)\n2. Includes specific facts and insights from the research\n3. References relevant sources using [Title](URL) format\n4. Provides a balanced, thorough analysis. Be as comprehensive as possible, and include all information that is relevant to the overall research question. People are using you for deep research and will expect detailed, comprehensive answers.\n5. Includes a \"Sources\" section at the end with all referenced links\n\nYou can structure your report in a number of different ways. Here are some examples:\n\nTo answer a question that asks you to compare two things, you might structure your report like this:\n1/ intro\n2/ overview of topic A\n3/ overview of topic B\n4/ comparison between A and B\n5/ conclusion\n\nTo answer a question that asks you to return a list of things, you might only need a single section which is the entire list.\n1/ list of things or table of things\nOr, you could choose to make each item in the list a separate section in the report. When asked for lists, you don't need an introduction or conclusion.\n1/ item 1\n2/ item 2\n3/ item 3\n\nTo answer a question that asks you to summarize a topic, give a report, or give an overview, you might structure your report like this:\n1/ overview of topic\n2/ concept 1\n3/ concept 2\n4/ concept 3\n5/ conclusion\n\nIf you think you can answer the question with a single section, you can do that too!\n1/ answer\n\nREMEMBER: Section is a VERY fluid and loose concept. You can structure your report however you think is best, including in ways that are not listed above!\nMake sure that your sections are cohesive, and make sense for the reader.\n\nFor each section of the report, do the following:\n- Use simple, clear language\n- Use ## for section title (Markdown format) for each section of the report\n- Do NOT ever refer to yourself as the writer of the report. This should be a professional report without any self-referential language.\n- Do not say what you are doing in the report. Just write the report without any commentary from yourself.\n- Each section should be as long as necessary to deeply answer the question with the information you have gathered. It is expected that sections will be fairly long and verbose. You are writing a deep research report, and users will expect a thorough answer.\n- Use bullet points to list out information when appropriate, but by default, write in paragraph form.\n\nREMEMBER:\nThe brief and research may be in English, but you need to translate this information to the right language when writing the final answer.\nMake sure the final answer report is in the SAME language as the human messages in the message history.\n\nFormat the report in clear markdown with proper structure and include source references where appropriate.\n\n<Citation Rules>\n- Assign each unique URL a single citation number in your text\n- End with ### Sources that lists each source with corresponding numbers\n- IMPORTANT: Number sources sequentially without gaps (1,2,3,4...) in the final list regardless of which sources you choose\n- Each source should be a separate line item in a list, so that in markdown it is rendered as a list.\n- Example format:\n [1] Source Title: URL\n [2] Source Title: URL\n- Citations are extremely important. Make sure to include these, and pay a lot of attention to getting these right. Users will often use these citations to look into more information.\n</Citation Rules>\n</report_instructions>\n\nYou have access to a few tools.\n\n## \\`internet_search\\`\n\nUse this to run an internet search for a given query. You can specify the number of results, the topic, and whether raw content should be included.\n`;\n\nconst research_agents: AgentConfig[] = [\n {\n key: \"research-agent\",\n name: \"research-agent\",\n type: AgentType.REACT,\n description:\n \"Used to research more in depth questions. Only give this researcher one topic at a time. Do not pass multiple sub questions to this researcher. Instead, you should break down a large topic into the necessary components, and then call multiple research agents in parallel, one for each sub question.\",\n prompt: subResearchPrompt,\n tools: [\"internet_search\"],\n },\n {\n key: \"critique-agent\",\n name: \"critique-agent\",\n type: AgentType.REACT,\n description:\n \"Used to critique the final report. Give this agent some infomration about how you want it to critique the report.\",\n prompt: subCritiquePrompt,\n },\n {\n key: \"main\",\n name: \"deep_research_agent\",\n description:\n \"Used to research more in depth questions. Only give this researcher one topic at a time. Do not pass multiple sub questions to this researcher. Instead, you should break down a large topic into the necessary components, and then call multiple research agents in parallel, one for each sub question.\",\n type: AgentType.DEEP_AGENT,\n tools: [\"internet_search\"],\n prompt: researchInstructions,\n subAgents: [\"critique-agent\", \"research-agent\"],\n schema: z.object({\n test: z.string().optional(),\n }),\n },\n];\n\nregisterAgentLattices(research_agents);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAmB;AAEnB,qBAA+B;AAC/B,IAAAA,eAGO;;;ACJP,kBAIO;AACP,iBAAc;AAEd,IAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAM1B,IAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuB1B,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
+
"bin": {
|
|
6
|
+
"lattice-deep-research": "./dist/index.js"
|
|
7
|
+
},
|
|
5
8
|
"keywords": [],
|
|
6
9
|
"author": "",
|
|
7
10
|
"license": "ISC",
|
|
@@ -11,8 +14,8 @@
|
|
|
11
14
|
"uuid": "^9.0.1",
|
|
12
15
|
"zod": "^3.24.2",
|
|
13
16
|
"zod-to-json-schema": "^3.24.3",
|
|
14
|
-
"@axiom-lattice/core": "2.
|
|
15
|
-
"@axiom-lattice/gateway": "2.
|
|
17
|
+
"@axiom-lattice/core": "2.1.12",
|
|
18
|
+
"@axiom-lattice/gateway": "2.1.17"
|
|
16
19
|
},
|
|
17
20
|
"devDependencies": {
|
|
18
21
|
"@types/jest": "^29.5.14",
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
"typescript": "^5.8.2"
|
|
31
34
|
},
|
|
32
35
|
"scripts": {
|
|
33
|
-
"build": "tsup
|
|
36
|
+
"build": "tsup",
|
|
34
37
|
"start": "node dist/index.js",
|
|
35
38
|
"dev": "tsup src/index.ts --format cjs --dts --watch --onSuccess \"node dist/index.js\"",
|
|
36
39
|
"dev:nodemon": "nodemon --watch 'src/**/*.ts' --watch '../../packages/core/dist/**/*' --exec 'ts-node' -r tsconfig-paths/register src/index.ts",
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
AgentType,
|
|
6
6
|
AgentConfig,
|
|
7
7
|
} from "@axiom-lattice/core";
|
|
8
|
+
import z from "zod";
|
|
8
9
|
|
|
9
10
|
const subResearchPrompt = `You are a dedicated researcher. Your job is to conduct research based on the users questions.
|
|
10
11
|
|
|
@@ -151,6 +152,9 @@ const research_agents: AgentConfig[] = [
|
|
|
151
152
|
tools: ["internet_search"],
|
|
152
153
|
prompt: researchInstructions,
|
|
153
154
|
subAgents: ["critique-agent", "research-agent"],
|
|
155
|
+
schema: z.object({
|
|
156
|
+
test: z.string().optional(),
|
|
157
|
+
}),
|
|
154
158
|
},
|
|
155
159
|
];
|
|
156
160
|
|
package/src/index.ts
CHANGED
|
@@ -8,10 +8,40 @@ import {
|
|
|
8
8
|
import "./agents";
|
|
9
9
|
import path from "path";
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// Load environment variables
|
|
12
12
|
dotenv.config({ path: path.resolve(__dirname, "../.env") });
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// Parse command line arguments for port configuration
|
|
15
|
+
function parsePort(): number {
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
const portIndex = args.findIndex((arg) => arg === "--port" || arg === "-p");
|
|
18
|
+
|
|
19
|
+
if (portIndex !== -1 && args[portIndex + 1]) {
|
|
20
|
+
const port = parseInt(args[portIndex + 1], 10);
|
|
21
|
+
if (!isNaN(port) && port > 0 && port < 65536) {
|
|
22
|
+
return port;
|
|
23
|
+
}
|
|
24
|
+
console.warn(
|
|
25
|
+
`Invalid port value: ${args[portIndex + 1]}, using default port 4001`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check environment variable
|
|
30
|
+
if (process.env.PORT) {
|
|
31
|
+
const port = parseInt(process.env.PORT, 10);
|
|
32
|
+
if (!isNaN(port) && port > 0 && port < 65536) {
|
|
33
|
+
return port;
|
|
34
|
+
}
|
|
35
|
+
console.warn(
|
|
36
|
+
`Invalid PORT environment variable: ${process.env.PORT}, using default port 4001`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Default port
|
|
41
|
+
return 4001;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Register default model Lattice
|
|
15
45
|
registerModelLattice(
|
|
16
46
|
"default",
|
|
17
47
|
// {
|
|
@@ -31,12 +61,19 @@ registerModelLattice(
|
|
|
31
61
|
// streaming: false,
|
|
32
62
|
// },
|
|
33
63
|
{
|
|
34
|
-
model: "kimi-k2-
|
|
64
|
+
model: "kimi-k2-250905",
|
|
35
65
|
provider: "volcengine",
|
|
36
66
|
streaming: true,
|
|
37
67
|
apiKeyEnvName: "VOLCENGINE_API_KEY2",
|
|
38
68
|
}
|
|
39
69
|
// {
|
|
70
|
+
// model: "kimi-k2-0711-preview",
|
|
71
|
+
// provider: "openai",
|
|
72
|
+
// streaming: true,
|
|
73
|
+
// apiKeyEnvName: "KIMI_API_KEY",
|
|
74
|
+
// baseURL: "https://api.moonshot.cn/v1",
|
|
75
|
+
// }
|
|
76
|
+
// {
|
|
40
77
|
// model: "qwen-plus",
|
|
41
78
|
// provider: "openai",
|
|
42
79
|
// streaming: false,
|
|
@@ -44,7 +81,12 @@ registerModelLattice(
|
|
|
44
81
|
// baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
45
82
|
// }
|
|
46
83
|
);
|
|
47
|
-
|
|
48
84
|
LatticeGateway.registerLatticeRoutes(LatticeGateway.app);
|
|
49
85
|
|
|
50
|
-
|
|
86
|
+
const port = parsePort();
|
|
87
|
+
console.log(`Starting server on port ${port}`);
|
|
88
|
+
|
|
89
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
90
|
+
port,
|
|
91
|
+
queueServiceConfig: { type: "memory", defaultStartPollingQueue: true },
|
|
92
|
+
});
|
package/tsup.config.ts
ADDED
package/src/agents/todo/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AgentConfig,
|
|
3
|
-
AgentType,
|
|
4
|
-
registerAgentLattice,
|
|
5
|
-
} from "@axiom-lattice/core";
|
|
6
|
-
import "./tools/read_todo_list";
|
|
7
|
-
import "./tools/create_todo_item";
|
|
8
|
-
|
|
9
|
-
export const TODO_AGENT_NAME = "maintodo";
|
|
10
|
-
|
|
11
|
-
const todo_agent_definition: AgentConfig = {
|
|
12
|
-
key: "todo",
|
|
13
|
-
type: AgentType.PLAN_EXECUTE,
|
|
14
|
-
name: TODO_AGENT_NAME,
|
|
15
|
-
description: "todo_agent可以分析用户的输入,整理并生成待办事项",
|
|
16
|
-
prompt:
|
|
17
|
-
"你是一个todo助手,请根据用户输入生成待办事项,每次生成待办时都需要用户进行确认,而且需要先查询下待办列表,再根据待办列表生成待办事项",
|
|
18
|
-
tools: ["读取待办列表", "创建待办事项", "获取当前日期时间"],
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
registerAgentLattice(todo_agent_definition);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { registerToolLattice } from "@axiom-lattice/core";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
registerToolLattice(
|
|
5
|
-
"create_todo_item",
|
|
6
|
-
{
|
|
7
|
-
name: "创建待办事项",
|
|
8
|
-
description: "创建待办事项",
|
|
9
|
-
needUserApprove: true,
|
|
10
|
-
schema: z.object({
|
|
11
|
-
title: z.string(),
|
|
12
|
-
description: z.string().nullable(),
|
|
13
|
-
due_date: z.string().nullable(),
|
|
14
|
-
priority: z.string().nullable(),
|
|
15
|
-
status: z.string().nullable(),
|
|
16
|
-
tags: z.array(z.string()).nullable(),
|
|
17
|
-
category: z.string().nullable(),
|
|
18
|
-
}),
|
|
19
|
-
},
|
|
20
|
-
async (
|
|
21
|
-
input: {
|
|
22
|
-
title: string;
|
|
23
|
-
description: string;
|
|
24
|
-
due_date: string;
|
|
25
|
-
priority: string;
|
|
26
|
-
status: string;
|
|
27
|
-
tags: string[];
|
|
28
|
-
},
|
|
29
|
-
config: any
|
|
30
|
-
) => {
|
|
31
|
-
(globalThis as any)["todo_list"].push(input);
|
|
32
|
-
|
|
33
|
-
return genUIMarkdown("todo_item_view", input);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
(globalThis as any)["todo_list"] = [];
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { registerToolLattice } from "@core/tool_lattice/ToolLatticeManager";
|
|
2
|
-
import { genUIMarkdown } from "@core/util/genUIMarkdown";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
registerToolLattice(
|
|
6
|
-
"read_todo_list",
|
|
7
|
-
{
|
|
8
|
-
name: "读取待办列表",
|
|
9
|
-
description: "读取待办事项列表",
|
|
10
|
-
schema: z.object({
|
|
11
|
-
search_text: z.string().optional().nullable(),
|
|
12
|
-
}),
|
|
13
|
-
},
|
|
14
|
-
async (input: { search_text: string }) => {
|
|
15
|
-
const md = genUIMarkdown("generic_data_table", {
|
|
16
|
-
dataSource: (globalThis as any)["todo_list"],
|
|
17
|
-
message: "待办事项列表",
|
|
18
|
-
});
|
|
19
|
-
console.log(md);
|
|
20
|
-
return md;
|
|
21
|
-
}
|
|
22
|
-
);
|