@axiom-lattice/examples-deep_research 1.0.55 → 1.0.57
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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +20 -0
- package/dist/index.js +119 -111
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/env.ts +4 -0
- package/src/index.ts +0 -2
- package/tsup.config.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/examples-deep_research@1.0.
|
|
2
|
+
> @axiom-lattice/examples-deep_research@1.0.57 build /home/runner/work/agentic/agentic/examples/deep_research
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
[34mCLI[39m Using tsup config: /home/runner/work/agentic/agentic/examples/deep_research/tsup.config.ts
|
|
9
9
|
[34mCLI[39m Target: es2020
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m50.78 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m57.40 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 58ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 5610ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m13.00 B[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @axiom-lattice/examples-deep_research
|
|
2
2
|
|
|
3
|
+
## 1.0.57
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [505d7c1]
|
|
8
|
+
- @axiom-lattice/core@2.1.53
|
|
9
|
+
- @axiom-lattice/gateway@2.1.59
|
|
10
|
+
- @axiom-lattice/pg-stores@1.0.43
|
|
11
|
+
|
|
12
|
+
## 1.0.56
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 64a0971: fix path resolve
|
|
17
|
+
- Updated dependencies [64a0971]
|
|
18
|
+
- @axiom-lattice/core@2.1.52
|
|
19
|
+
- @axiom-lattice/gateway@2.1.58
|
|
20
|
+
- @axiom-lattice/pg-stores@1.0.42
|
|
21
|
+
- @axiom-lattice/protocols@2.1.29
|
|
22
|
+
|
|
3
23
|
## 1.0.55
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
3
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
4
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
5
|
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
6
|
|
|
29
7
|
// package.json
|
|
30
8
|
var require_package = __commonJS({
|
|
31
|
-
"package.json"(
|
|
32
|
-
|
|
9
|
+
"package.json"(exports, module) {
|
|
10
|
+
module.exports = {
|
|
33
11
|
name: "@axiom-lattice/examples-deep_research",
|
|
34
|
-
version: "1.0.
|
|
12
|
+
version: "1.0.57",
|
|
13
|
+
type: "module",
|
|
35
14
|
main: "dist/index.js",
|
|
36
15
|
bin: {
|
|
37
16
|
"lattice-deep-research": "./dist/index.js"
|
|
@@ -39,10 +18,10 @@ var require_package = __commonJS({
|
|
|
39
18
|
scripts: {
|
|
40
19
|
build: "tsup",
|
|
41
20
|
start: "node dist/index.js",
|
|
42
|
-
dev: 'lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format
|
|
21
|
+
dev: 'lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format esm --dts --watch --onSuccess "node dist/index.js"',
|
|
43
22
|
"dev:nodemon": "nodemon --watch 'src/**/*.ts' --watch '../../packages/core/dist/**/*' --exec 'ts-node' -r tsconfig-paths/register src/index.ts",
|
|
44
|
-
"dev:serve": "tsup src/index.ts --format
|
|
45
|
-
"dev:inspect": 'tsup src/index.ts --format
|
|
23
|
+
"dev:serve": "tsup src/index.ts --format esm --dts --watch --serve dist/index.js",
|
|
24
|
+
"dev:inspect": 'tsup src/index.ts --format esm --dts --watch --onSuccess "node --inspect dist/index.js"',
|
|
46
25
|
lint: "tsc --noEmit",
|
|
47
26
|
test: "jest",
|
|
48
27
|
"test:watch": "jest --watch",
|
|
@@ -85,12 +64,26 @@ var require_package = __commonJS({
|
|
|
85
64
|
});
|
|
86
65
|
|
|
87
66
|
// src/index.ts
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
68
|
+
import {
|
|
69
|
+
registerCheckpointSaver,
|
|
70
|
+
registerModelLattice,
|
|
71
|
+
registerScheduleLattice,
|
|
72
|
+
storeLatticeManager,
|
|
73
|
+
registerStoreLattice,
|
|
74
|
+
sandboxLatticeManager,
|
|
75
|
+
createSandboxProvider,
|
|
76
|
+
sqlDatabaseManager as sqlDatabaseManager2,
|
|
77
|
+
metricsServerManager,
|
|
78
|
+
MemoryLatticeManager
|
|
79
|
+
} from "@axiom-lattice/core";
|
|
90
80
|
|
|
91
81
|
// src/agents/research/index.ts
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
import {
|
|
83
|
+
registerAgentLattices,
|
|
84
|
+
AgentType
|
|
85
|
+
} from "@axiom-lattice/core";
|
|
86
|
+
import z from "zod";
|
|
94
87
|
var subResearchPrompt = `You are a dedicated researcher. Your job is to conduct research based on the users questions.
|
|
95
88
|
|
|
96
89
|
Conduct thorough research and then reply to the user with a detailed answer to their question
|
|
@@ -210,18 +203,18 @@ var research_agents = [
|
|
|
210
203
|
key: "deep_research_agent",
|
|
211
204
|
name: "Deep Research Agent",
|
|
212
205
|
description: "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.",
|
|
213
|
-
type:
|
|
206
|
+
type: AgentType.DEEP_AGENT,
|
|
214
207
|
tools: ["internet_search"],
|
|
215
208
|
prompt: researchInstructions,
|
|
216
209
|
subAgents: ["critique-agent", "research-agent"],
|
|
217
|
-
schema:
|
|
218
|
-
test:
|
|
210
|
+
schema: z.object({
|
|
211
|
+
test: z.string().optional()
|
|
219
212
|
})
|
|
220
213
|
},
|
|
221
214
|
{
|
|
222
215
|
key: "research-agent",
|
|
223
216
|
name: "research-agent",
|
|
224
|
-
type:
|
|
217
|
+
type: AgentType.REACT,
|
|
225
218
|
description: "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.",
|
|
226
219
|
prompt: subResearchPrompt,
|
|
227
220
|
tools: ["internet_search"]
|
|
@@ -229,17 +222,20 @@ var research_agents = [
|
|
|
229
222
|
{
|
|
230
223
|
key: "critique-agent",
|
|
231
224
|
name: "critique-agent",
|
|
232
|
-
type:
|
|
225
|
+
type: AgentType.REACT,
|
|
233
226
|
description: "Used to critique the final report. Give this agent some infomration about how you want it to critique the report.",
|
|
234
227
|
prompt: subCritiquePrompt
|
|
235
228
|
}
|
|
236
229
|
];
|
|
237
230
|
var tenantId = process.env.TENANT_ID || "default";
|
|
238
|
-
|
|
231
|
+
registerAgentLattices(tenantId, research_agents);
|
|
239
232
|
|
|
240
233
|
// src/agents/research_team/index.ts
|
|
241
|
-
|
|
242
|
-
|
|
234
|
+
import {
|
|
235
|
+
registerAgentLattices as registerAgentLattices2,
|
|
236
|
+
AgentType as AgentType2
|
|
237
|
+
} from "@axiom-lattice/core";
|
|
238
|
+
import z2 from "zod";
|
|
243
239
|
var teamLeadPrompt = `You are an expert research team lead. You coordinate a team of specialized agents to produce a thorough, polished research report.
|
|
244
240
|
|
|
245
241
|
## Workflow
|
|
@@ -286,12 +282,12 @@ var teamResearchAgent = {
|
|
|
286
282
|
key: "team_research_agent",
|
|
287
283
|
name: "Team Research Agent",
|
|
288
284
|
description: "Team-based deep research agent. Uses a team of persistent researcher and critic agents that work in parallel via a shared task list and mailbox. Compare with deep_research_agent (DEEP_AGENT version) for architectural differences.",
|
|
289
|
-
type:
|
|
285
|
+
type: AgentType2.TEAM,
|
|
290
286
|
prompt: teamLeadPrompt,
|
|
291
287
|
tools: ["internet_search"],
|
|
292
288
|
// Team lead also has search capability
|
|
293
|
-
schema:
|
|
294
|
-
test:
|
|
289
|
+
schema: z2.object({
|
|
290
|
+
test: z2.string().optional()
|
|
295
291
|
}),
|
|
296
292
|
scheduleLatticeKey: "default",
|
|
297
293
|
// Use ScheduleLattice for polling task list
|
|
@@ -299,11 +295,15 @@ var teamResearchAgent = {
|
|
|
299
295
|
// Poll every 5 seconds
|
|
300
296
|
};
|
|
301
297
|
var tenantId2 = process.env.TENANT_ID || "default";
|
|
302
|
-
(
|
|
298
|
+
registerAgentLattices2(tenantId2, [teamResearchAgent]);
|
|
303
299
|
|
|
304
300
|
// src/agents/data_agent/index.ts
|
|
305
|
-
|
|
306
|
-
|
|
301
|
+
import {
|
|
302
|
+
registerAgentLattices as registerAgentLattices3,
|
|
303
|
+
AgentType as AgentType3,
|
|
304
|
+
sqlDatabaseManager
|
|
305
|
+
} from "@axiom-lattice/core";
|
|
306
|
+
import z3 from "zod";
|
|
307
307
|
var dataAgentPrompt = `\u4F60\u662F\u4E00\u4F4D\u4E13\u4E1A\u7684\u4E1A\u52A1\u6570\u636E\u5206\u6790AI\u52A9\u624B\uFF0C\u64C5\u957F\u89C4\u5212\u4E1A\u52A1\u5206\u6790\u4EFB\u52A1\u3001\u534F\u8C03\u6570\u636E\u68C0\u7D22\uFF0C\u5E76\u751F\u6210\u5168\u9762\u7684\u4E1A\u52A1\u5206\u6790\u62A5\u544A\u3002
|
|
308
308
|
|
|
309
309
|
**\u5173\u952E\uFF1A\u4F60\u7684\u7B2C\u4E00\u9879\u4E5F\u662F\u6700\u91CD\u8981\u7684\u4EFB\u52A1\u662F\u4F7F\u7528 \`write_todos\` \u5DE5\u5177\u521B\u5EFA\u5F85\u529E\u5217\u8868\u3002** \u5728\u5F00\u59CB\u4EFB\u4F55\u5DE5\u4F5C\u4E4B\u524D\uFF0C\u4F60\u5FC5\u987B\uFF1A
|
|
@@ -579,12 +579,12 @@ var data_agents = [
|
|
|
579
579
|
key: "data_agent",
|
|
580
580
|
name: "Data Agent",
|
|
581
581
|
description: "An intelligent Business Data Analyst agent that converts natural language questions into SQL queries, performs multi-step business analysis, and generates comprehensive business reports. Capabilities include: task decomposition, metric analysis, dimension breakdowns, anomaly detection, and structured report generation with executive summaries, analysis steps, and visualizations. Use this agent for business intelligence, data analysis, database queries, and generating actionable business insights.",
|
|
582
|
-
type:
|
|
582
|
+
type: AgentType3.DEEP_AGENT,
|
|
583
583
|
tools: ["list_tables_sql", "info_sql"],
|
|
584
584
|
prompt: dataAgentPrompt,
|
|
585
585
|
subAgents: ["sql-builder-agent", "data-analysis-agent"],
|
|
586
586
|
skillCategories: ["analysis", "sql"],
|
|
587
|
-
schema:
|
|
587
|
+
schema: z3.object({}),
|
|
588
588
|
/**
|
|
589
589
|
* Runtime configuration injected into tool execution context.
|
|
590
590
|
* databaseKey: The database key registered via sqlDatabaseManager.
|
|
@@ -598,7 +598,7 @@ var data_agents = [
|
|
|
598
598
|
{
|
|
599
599
|
key: "sql-builder-agent",
|
|
600
600
|
name: "sql-builder-agent",
|
|
601
|
-
type:
|
|
601
|
+
type: AgentType3.DEEP_AGENT,
|
|
602
602
|
description: "A specialized sub-agent for database exploration, SQL query generation, validation, and execution. This agent handles all SQL-related operations including listing tables, exploring schemas, generating queries, validating them, executing them, and returning both the SQL and query results to the data_agent.",
|
|
603
603
|
prompt: sqlBuilderPrompt
|
|
604
604
|
// tools: ["list_tables_sql", "info_sql", "query_checker_sql", "query_sql"],
|
|
@@ -607,16 +607,16 @@ var data_agents = [
|
|
|
607
607
|
{
|
|
608
608
|
key: "data-analysis-agent",
|
|
609
609
|
name: "data-analysis-agent",
|
|
610
|
-
type:
|
|
610
|
+
type: AgentType3.DEEP_AGENT,
|
|
611
611
|
description: "A specialized sub-agent for analyzing query results and extracting business insights. This agent interprets data, identifies patterns and anomalies, provides business context, and structures findings for comprehensive reports. Give this agent query results and it will provide structured business analysis with key findings, insights, and visualization recommendations.",
|
|
612
612
|
prompt: dataAnalysisPrompt,
|
|
613
613
|
tools: []
|
|
614
614
|
}
|
|
615
615
|
];
|
|
616
616
|
var tenantId3 = process.env.TENANT_ID || "default";
|
|
617
|
-
(
|
|
617
|
+
registerAgentLattices3(tenantId3, data_agents);
|
|
618
618
|
function initializeDataAgentDatabase(key, config) {
|
|
619
|
-
|
|
619
|
+
sqlDatabaseManager.registerDatabase("default", key, config);
|
|
620
620
|
}
|
|
621
621
|
initializeDataAgentDatabase("fulidb", {
|
|
622
622
|
type: "postgres",
|
|
@@ -625,7 +625,10 @@ initializeDataAgentDatabase("fulidb", {
|
|
|
625
625
|
});
|
|
626
626
|
|
|
627
627
|
// src/agents/sandbox_agent/index.ts
|
|
628
|
-
|
|
628
|
+
import {
|
|
629
|
+
registerAgentLattices as registerAgentLattices4,
|
|
630
|
+
AgentType as AgentType4
|
|
631
|
+
} from "@axiom-lattice/core";
|
|
629
632
|
var sandboxPrompt = `You are a Personal AI Assistant with access to a powerful sandboxed computer environment. You can help users with research, coding, file management, and web browsing tasks.
|
|
630
633
|
|
|
631
634
|
## Your Core Identity
|
|
@@ -710,7 +713,7 @@ var sandboxAgent = {
|
|
|
710
713
|
key: "sandbox_agent",
|
|
711
714
|
name: "Sandbox Agent",
|
|
712
715
|
description: "A sandbox agent for testing and development.",
|
|
713
|
-
type:
|
|
716
|
+
type: AgentType4.DEEP_AGENT,
|
|
714
717
|
prompt: sandboxPrompt,
|
|
715
718
|
middleware: [
|
|
716
719
|
{
|
|
@@ -740,22 +743,27 @@ var sandboxAgent = {
|
|
|
740
743
|
]
|
|
741
744
|
};
|
|
742
745
|
var tenantId4 = process.env.TENANT_ID || "default";
|
|
743
|
-
(
|
|
746
|
+
registerAgentLattices4(tenantId4, [sandboxAgent]);
|
|
744
747
|
|
|
745
748
|
// src/index.ts
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
+
import {
|
|
750
|
+
LoggerType,
|
|
751
|
+
ScheduleType
|
|
752
|
+
} from "@axiom-lattice/protocols";
|
|
753
|
+
import { PostgreSQLAssistantStore, PostgreSQLScheduleStorage, PostgreSQLThreadStore, PostgreSQLDatabaseConfigStore, PostgreSQLMetricsServerConfigStore, PostgreSQLMcpServerConfigStore, PostgreSQLWorkspaceStore, PostgreSQLProjectStore, PostgreSQLUserStore, PostgreSQLTenantStore, PostgreSQLUserTenantLinkStore, ThreadMessageQueueStore, Pool } from "@axiom-lattice/pg-stores";
|
|
754
|
+
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
|
|
749
755
|
|
|
750
756
|
// src/env.ts
|
|
751
|
-
|
|
752
|
-
|
|
757
|
+
import dotenv from "dotenv";
|
|
758
|
+
import path from "path";
|
|
759
|
+
import { fileURLToPath } from "url";
|
|
760
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
761
|
+
var __dirname = path.dirname(__filename);
|
|
753
762
|
function loadLocalEnv() {
|
|
754
|
-
|
|
763
|
+
dotenv.config({ path: path.resolve(__dirname, "../.env.local") });
|
|
755
764
|
}
|
|
756
765
|
|
|
757
766
|
// src/index.ts
|
|
758
|
-
var fs = require("fs");
|
|
759
767
|
var PACKAGE_VERSION = require_package().version;
|
|
760
768
|
var BUILD_TIME = (/* @__PURE__ */ new Date()).toISOString();
|
|
761
769
|
var IS_DEV = process.env.NODE_ENV !== "production";
|
|
@@ -791,7 +799,7 @@ function parsePort() {
|
|
|
791
799
|
}
|
|
792
800
|
return 4001;
|
|
793
801
|
}
|
|
794
|
-
|
|
802
|
+
registerModelLattice(
|
|
795
803
|
"default",
|
|
796
804
|
{
|
|
797
805
|
model: "kimi-k2.6",
|
|
@@ -806,7 +814,7 @@ function parsePort() {
|
|
|
806
814
|
}
|
|
807
815
|
}
|
|
808
816
|
);
|
|
809
|
-
|
|
817
|
+
registerModelLattice(
|
|
810
818
|
"qwen3.5-plus",
|
|
811
819
|
{
|
|
812
820
|
model: "qwen3.5-plus",
|
|
@@ -818,7 +826,7 @@ function parsePort() {
|
|
|
818
826
|
baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
|
819
827
|
}
|
|
820
828
|
);
|
|
821
|
-
|
|
829
|
+
registerModelLattice(
|
|
822
830
|
"doubao-seed-2-0-pro",
|
|
823
831
|
{
|
|
824
832
|
displayName: "Doubao pro 2.0",
|
|
@@ -847,100 +855,100 @@ async function main() {
|
|
|
847
855
|
console.error("ERROR: DATABASE_URL environment variable is not set");
|
|
848
856
|
process.exit(1);
|
|
849
857
|
}
|
|
850
|
-
const sharedPool = new
|
|
851
|
-
const threadStore = new
|
|
858
|
+
const sharedPool = new Pool({ connectionString });
|
|
859
|
+
const threadStore = new PostgreSQLThreadStore({
|
|
852
860
|
poolConfig: connectionString,
|
|
853
861
|
autoMigrate: false
|
|
854
862
|
// Will manually initialize
|
|
855
863
|
});
|
|
856
864
|
await threadStore.initialize();
|
|
857
|
-
|
|
858
|
-
|
|
865
|
+
storeLatticeManager.removeLattice("default", "thread");
|
|
866
|
+
registerStoreLattice("default", "thread", threadStore);
|
|
859
867
|
console.log("\u2713 PostgreSQL ThreadStore initialized");
|
|
860
|
-
const databaseConfigStore = new
|
|
868
|
+
const databaseConfigStore = new PostgreSQLDatabaseConfigStore({
|
|
861
869
|
poolConfig: connectionString,
|
|
862
870
|
autoMigrate: false
|
|
863
871
|
});
|
|
864
872
|
await databaseConfigStore.initialize();
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
873
|
+
storeLatticeManager.removeLattice("default", "database");
|
|
874
|
+
registerStoreLattice("default", "database", databaseConfigStore);
|
|
875
|
+
sqlDatabaseManager2.setConfigStore(databaseConfigStore);
|
|
868
876
|
console.log("\u2713 PostgreSQL DatabaseConfigStore initialized");
|
|
869
|
-
const metricsConfigStore = new
|
|
877
|
+
const metricsConfigStore = new PostgreSQLMetricsServerConfigStore({
|
|
870
878
|
poolConfig: connectionString,
|
|
871
879
|
autoMigrate: false
|
|
872
880
|
});
|
|
873
881
|
await metricsConfigStore.initialize();
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
882
|
+
storeLatticeManager.removeLattice("default", "metrics");
|
|
883
|
+
registerStoreLattice("default", "metrics", metricsConfigStore);
|
|
884
|
+
metricsServerManager.loadAllConfigsFromStore(metricsConfigStore);
|
|
877
885
|
console.log("\u2713 PostgreSQL MetricsServerConfigStore initialized");
|
|
878
|
-
const mcpConfigStore = new
|
|
886
|
+
const mcpConfigStore = new PostgreSQLMcpServerConfigStore({
|
|
879
887
|
poolConfig: connectionString,
|
|
880
888
|
autoMigrate: false
|
|
881
889
|
});
|
|
882
890
|
await mcpConfigStore.initialize();
|
|
883
|
-
|
|
884
|
-
|
|
891
|
+
storeLatticeManager.removeLattice("default", "mcp");
|
|
892
|
+
registerStoreLattice("default", "mcp", mcpConfigStore);
|
|
885
893
|
console.log("\u2713 PostgreSQL McpServerConfigStore initialized");
|
|
886
|
-
const workspaceStore = new
|
|
894
|
+
const workspaceStore = new PostgreSQLWorkspaceStore({
|
|
887
895
|
poolConfig: connectionString,
|
|
888
896
|
autoMigrate: false
|
|
889
897
|
});
|
|
890
898
|
await workspaceStore.initialize();
|
|
891
|
-
|
|
892
|
-
|
|
899
|
+
storeLatticeManager.removeLattice("default", "workspace");
|
|
900
|
+
registerStoreLattice("default", "workspace", workspaceStore);
|
|
893
901
|
console.log("\u2713 PostgreSQL WorkspaceStore initialized");
|
|
894
|
-
const projectStore = new
|
|
902
|
+
const projectStore = new PostgreSQLProjectStore({
|
|
895
903
|
poolConfig: connectionString,
|
|
896
904
|
autoMigrate: false
|
|
897
905
|
});
|
|
898
906
|
await projectStore.initialize();
|
|
899
|
-
|
|
900
|
-
|
|
907
|
+
storeLatticeManager.removeLattice("default", "project");
|
|
908
|
+
registerStoreLattice("default", "project", projectStore);
|
|
901
909
|
console.log("\u2713 PostgreSQL ProjectStore initialized");
|
|
902
|
-
const userStore = new
|
|
910
|
+
const userStore = new PostgreSQLUserStore({
|
|
903
911
|
poolConfig: connectionString,
|
|
904
912
|
autoMigrate: false
|
|
905
913
|
});
|
|
906
914
|
await userStore.initialize();
|
|
907
|
-
|
|
908
|
-
|
|
915
|
+
storeLatticeManager.removeLattice("default", "user");
|
|
916
|
+
registerStoreLattice("default", "user", userStore);
|
|
909
917
|
console.log("\u2713 PostgreSQL UserStore initialized");
|
|
910
|
-
const tenantStore = new
|
|
918
|
+
const tenantStore = new PostgreSQLTenantStore({
|
|
911
919
|
poolConfig: connectionString,
|
|
912
920
|
autoMigrate: false
|
|
913
921
|
});
|
|
914
922
|
await tenantStore.initialize();
|
|
915
|
-
|
|
916
|
-
|
|
923
|
+
storeLatticeManager.removeLattice("default", "tenant");
|
|
924
|
+
registerStoreLattice("default", "tenant", tenantStore);
|
|
917
925
|
console.log("\u2713 PostgreSQL TenantStore initialized");
|
|
918
|
-
const userTenantLinkStore = new
|
|
926
|
+
const userTenantLinkStore = new PostgreSQLUserTenantLinkStore({
|
|
919
927
|
poolConfig: connectionString,
|
|
920
928
|
autoMigrate: false
|
|
921
929
|
});
|
|
922
930
|
await userTenantLinkStore.initialize();
|
|
923
|
-
|
|
924
|
-
|
|
931
|
+
storeLatticeManager.removeLattice("default", "userTenantLink");
|
|
932
|
+
registerStoreLattice("default", "userTenantLink", userTenantLinkStore);
|
|
925
933
|
console.log("\u2713 PostgreSQL UserTenantLinkStore initialized");
|
|
926
|
-
const assistantStore = new
|
|
934
|
+
const assistantStore = new PostgreSQLAssistantStore({
|
|
927
935
|
poolConfig: connectionString,
|
|
928
936
|
autoMigrate: false
|
|
929
937
|
});
|
|
930
938
|
await assistantStore.initialize();
|
|
931
|
-
|
|
932
|
-
|
|
939
|
+
storeLatticeManager.removeLattice("default", "assistant");
|
|
940
|
+
registerStoreLattice("default", "assistant", assistantStore);
|
|
933
941
|
console.log("\u2713 PostgreSQL AssistantStore initialized");
|
|
934
|
-
const threadMessageQueueStore =
|
|
942
|
+
const threadMessageQueueStore = ThreadMessageQueueStore.getInstance();
|
|
935
943
|
await threadMessageQueueStore.initialize(sharedPool, true);
|
|
936
|
-
|
|
937
|
-
|
|
944
|
+
storeLatticeManager.removeLattice("default", "threadMessageQueue");
|
|
945
|
+
registerStoreLattice("default", "threadMessageQueue", threadMessageQueueStore);
|
|
938
946
|
console.log("\u2713 ThreadMessageQueueStore initialized for Agent Recovery");
|
|
939
|
-
const globalMemory =
|
|
947
|
+
const globalMemory = PostgresSaver.fromConnString(
|
|
940
948
|
connectionString
|
|
941
949
|
);
|
|
942
|
-
|
|
943
|
-
|
|
950
|
+
MemoryLatticeManager.getInstance().removeCheckpointSaver("default");
|
|
951
|
+
registerCheckpointSaver("default", globalMemory);
|
|
944
952
|
console.log("\u2713 globalMemory initialized for LangGraph checkpoints");
|
|
945
953
|
const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox";
|
|
946
954
|
const sandboxBaseURL = process.env.SANDBOX_BASE_URL;
|
|
@@ -949,7 +957,7 @@ async function main() {
|
|
|
949
957
|
const daytonaApiKey = process.env.DAYTONA_API_KEY;
|
|
950
958
|
const daytonaApiUrl = process.env.DAYTONA_API_URL;
|
|
951
959
|
const daytonaTarget = process.env.DAYTONA_TARGET;
|
|
952
|
-
const sandboxProvider =
|
|
960
|
+
const sandboxProvider = createSandboxProvider({
|
|
953
961
|
type: sandboxProviderType,
|
|
954
962
|
remoteBaseURL: sandboxBaseURL,
|
|
955
963
|
microsandboxServiceBaseURL,
|
|
@@ -962,17 +970,17 @@ async function main() {
|
|
|
962
970
|
daytonaTimeout: process.env.DAYTONA_TIMEOUT ? parseInt(process.env.DAYTONA_TIMEOUT, 10) : void 0,
|
|
963
971
|
daytonaVolumeName: process.env.DAYTONA_VOLUME_NAME
|
|
964
972
|
});
|
|
965
|
-
|
|
973
|
+
sandboxLatticeManager.registerLattice("default", sandboxProvider);
|
|
966
974
|
console.log(`\u2713 Sandbox provider registered: ${sandboxProviderType}`);
|
|
967
|
-
const scheduleStorage = new
|
|
975
|
+
const scheduleStorage = new PostgreSQLScheduleStorage({
|
|
968
976
|
poolConfig: connectionString,
|
|
969
977
|
autoMigrate: false
|
|
970
978
|
});
|
|
971
979
|
await scheduleStorage.initialize();
|
|
972
|
-
|
|
980
|
+
registerScheduleLattice("default", {
|
|
973
981
|
name: "Default Scheduler",
|
|
974
982
|
description: "Production scheduler with PostgreSQL persistence",
|
|
975
|
-
type:
|
|
983
|
+
type: ScheduleType.POSTGRES,
|
|
976
984
|
storage: scheduleStorage
|
|
977
985
|
});
|
|
978
986
|
console.log("\u2713 PostgreSQL ScheduleStorage initialized");
|
|
@@ -983,11 +991,11 @@ async function main() {
|
|
|
983
991
|
const DEFAULT_LOGGER_CONFIG = {
|
|
984
992
|
name: "default",
|
|
985
993
|
description: "Default logger for lattice-gateway service",
|
|
986
|
-
type:
|
|
994
|
+
type: LoggerType.PINO,
|
|
987
995
|
serviceName: "lattice/deep_research",
|
|
988
996
|
loggerName: "lattice/deep_research"
|
|
989
997
|
};
|
|
990
|
-
|
|
998
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
991
999
|
port,
|
|
992
1000
|
queueServiceConfig: { type: "memory", defaultStartPollingQueue: true },
|
|
993
1001
|
loggerConfig: DEFAULT_LOGGER_CONFIG
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/index.ts","../src/agents/research/index.ts","../src/agents/research_team/index.ts","../src/agents/data_agent/index.ts","../src/agents/sandbox_agent/index.ts","../src/env.ts"],"sourcesContent":["{\n \"name\": \"@axiom-lattice/examples-deep_research\",\n \"version\": \"1.0.55\",\n \"main\": \"dist/index.js\",\n \"bin\": {\n \"lattice-deep-research\": \"./dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"start\": \"node dist/index.js\",\n \"dev\": \"lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format cjs --dts --watch --onSuccess \\\"node dist/index.js\\\"\",\n \"dev:nodemon\": \"nodemon --watch 'src/**/*.ts' --watch '../../packages/core/dist/**/*' --exec 'ts-node' -r tsconfig-paths/register src/index.ts\",\n \"dev:serve\": \"tsup src/index.ts --format cjs --dts --watch --serve dist/index.js\",\n \"dev:inspect\": \"tsup src/index.ts --format cjs --dts --watch --onSuccess \\\"node --inspect dist/index.js\\\"\",\n \"lint\": \"tsc --noEmit\",\n \"test\": \"jest\",\n \"test:watch\": \"jest --watch\",\n \"test:coverage\": \"jest --coverage\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"description\": \"Deep Research Server for Axiom Lattice\",\n \"dependencies\": {\n \"@axiom-lattice/core\": \"workspace:*\",\n \"@axiom-lattice/gateway\": \"workspace:*\",\n \"@axiom-lattice/pg-stores\": \"workspace:*\",\n \"@axiom-lattice/protocols\": \"workspace:*\",\n \"@langchain/langgraph-checkpoint-postgres\": \"^1.0.0\",\n \"dotenv\": \"^16.6.1\",\n \"pg\": \"^8.20.0\",\n \"uuid\": \"^9.0.1\",\n \"zod\": \"^3.24.2\",\n \"zod-to-json-schema\": \"^3.24.3\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.14\",\n \"@types/lodash\": \"^4.17.16\",\n \"@types/node\": \"^20.17.23\",\n \"@types/pg\": \"^8.20.0\",\n \"@types/uuid\": \"^9.0.8\",\n \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n \"@typescript-eslint/parser\": \"^7.2.0\",\n \"eslint\": \"^8.57.0\",\n \"jest\": \"^29.7.0\",\n \"nodemon\": \"^3.1.9\",\n \"ts-jest\": \"^29.4.0\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.2\"\n }\n}\n","import dotenv from \"dotenv\";\n\nimport { LatticeGateway } from \"@axiom-lattice/gateway\";\nimport {\n getScheduleLattice,\n registerCheckpointSaver,\n registerModelLattice,\n registerScheduleLattice,\n\n storeLatticeManager,\n mcpManager,\n toolLatticeManager,\n registerStoreLattice,\n sandboxLatticeManager,\n getSandBoxManager,\n createSandboxProvider,\n sqlDatabaseManager,\n metricsServerManager,\n MemoryLatticeManager,\n} from \"@axiom-lattice/core\";\nimport { McpServerConfig } from \"@axiom-lattice/protocols\";\nimport \"./agents\";\n\nimport path from \"path\";\nimport {\n LoggerConfig,\n LoggerType,\n ScheduleType,\n} from \"@axiom-lattice/protocols\";\nimport { PostgreSQLAssistantStore, PostgreSQLScheduleStorage, PostgreSQLThreadStore, PostgreSQLDatabaseConfigStore, PostgreSQLMetricsServerConfigStore, PostgreSQLMcpServerConfigStore, PostgreSQLWorkspaceStore, PostgreSQLProjectStore, PostgreSQLUserStore, PostgreSQLTenantStore, PostgreSQLUserTenantLinkStore, ThreadMessageQueueStore, Pool } from \"@axiom-lattice/pg-stores\";\nimport { PostgresSaver } from \"@langchain/langgraph-checkpoint-postgres\";\nimport pg from \"pg\";\nimport { loadLocalEnv } from \"./env\";\n\n// 在文件开头添加\nconst fs = require(\"fs\");\nconst PACKAGE_VERSION = require(\"../package.json\").version;\nconst BUILD_TIME = new Date().toISOString();\nconst IS_DEV = process.env.NODE_ENV !== \"production\";\n\n// 在启动时输出\nconsole.log(`\n╔═══════════════════════════════════════╗\n║ Lattice Deep Research Server ║\n║ Version: ${PACKAGE_VERSION} ║\n║ Build Time: ${BUILD_TIME} ║\n║ Environment: ${IS_DEV ? \"Development\" : \"Production\"} ║\n╚═══════════════════════════════════════╝\n`);\n\n// Load environment variables\nloadLocalEnv();\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 {\n model: \"kimi-k2.6\",\n displayName: \"kimi-k2.6\",\n //model: \"qwen3.5-35b-a3b\",\n provider: \"openai\",\n streaming: true,\n apiKeyEnvName: \"API_KEY3\",\n baseURL: \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n modelKwargs: {\n \"enable_thinking\": false\n }\n }\n);\nregisterModelLattice(\n \"qwen3.5-plus\",\n {\n model: \"qwen3.5-plus\",\n displayName: \"qwen3.5-plus\",\n //model: \"qwen3.5-35b-a3b\",\n provider: \"openai\",\n streaming: true,\n apiKeyEnvName: \"API_KEY3\",\n baseURL: \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n }\n);\nregisterModelLattice(\n \"doubao-seed-2-0-pro\",\n\n {\n displayName: \"Doubao pro 2.0\",\n model: \"doubao-seed-2-0-pro-260215\",\n provider: \"volcengine\",\n streaming: true,\n apiKeyEnvName: \"VOLCENGINE_API_KEY2\",\n modelKwargs: {\n \"thinking\": { \"type\": \"disabled\" }\n },\n }\n);\n// registerModelLattice(\n// \"K2.5-Coding\",\n// {\n// displayName: \"K2.5 Coding\",\n// model: \"k2p5\",\n// provider: \"openai\",\n// streaming: true,\n// apiKeyEnvName: \"API_KEY4\",\n// baseURL: \"https://api.kimi.com/coding/v1\",\n// modelKwargs: {\n// \"enable_thinking\": { \"type\": \"disabled\" },\n// headers: {\n// \"User-Agent\": \"claude-code/0.1.0\"\n// }\n// },\n// }\n// );\n// Auth configuration\nconst AUTH_CONFIG = {\n autoApproveUsers: process.env.AUTO_APPROVE_USERS !== \"false\",\n allowTenantRegistration: process.env.ALLOW_TENANT_REGISTRATION !== \"false\",\n jwtSecret: process.env.JWT_SECRET || \"your-secret-key-change-in-production\",\n tokenExpiration: parseInt(process.env.TOKEN_EXPIRATION || \"86400\", 10),\n};\n\nconsole.log(\"Auth Configuration:\");\nconsole.log(` - Auto Approve Users: ${AUTH_CONFIG.autoApproveUsers}`);\nconsole.log(` - Allow Tenant Registration: ${AUTH_CONFIG.allowTenantRegistration}`);\nconsole.log(` - Token Expiration: ${AUTH_CONFIG.tokenExpiration}s`);\n\n// Main async initialization function\nasync function main() {\n const connectionString = process.env.DATABASE_URL || \"\";\n\n if (!connectionString) {\n console.error(\"ERROR: DATABASE_URL environment variable is not set\");\n process.exit(1);\n }\n\n // Create shared pool for all stores\n const sharedPool = new Pool({ connectionString });\n\n // Initialize and register PostgreSQL ThreadStore\n const threadStore = new PostgreSQLThreadStore({\n poolConfig: connectionString,\n autoMigrate: false, // Will manually initialize\n });\n await threadStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"thread\");\n registerStoreLattice(\"default\", \"thread\", threadStore);\n console.log(\"✓ PostgreSQL ThreadStore initialized\");\n\n // Initialize and register PostgreSQL DatabaseConfigStore\n const databaseConfigStore = new PostgreSQLDatabaseConfigStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await databaseConfigStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"database\");\n registerStoreLattice(\"default\", \"database\", databaseConfigStore);\n sqlDatabaseManager.setConfigStore(databaseConfigStore);\n console.log(\"✓ PostgreSQL DatabaseConfigStore initialized\");\n\n // Initialize and register PostgreSQL MetricsServerConfigStore\n const metricsConfigStore = new PostgreSQLMetricsServerConfigStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await metricsConfigStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"metrics\");\n registerStoreLattice(\"default\", \"metrics\", metricsConfigStore);\n metricsServerManager.loadAllConfigsFromStore(metricsConfigStore);\n console.log(\"✓ PostgreSQL MetricsServerConfigStore initialized\");\n\n // Initialize and register PostgreSQL McpServerConfigStore\n const mcpConfigStore = new PostgreSQLMcpServerConfigStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await mcpConfigStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"mcp\");\n registerStoreLattice(\"default\", \"mcp\", mcpConfigStore);\n console.log(\"✓ PostgreSQL McpServerConfigStore initialized\");\n\n // Initialize and register PostgreSQL WorkspaceStore\n const workspaceStore = new PostgreSQLWorkspaceStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await workspaceStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"workspace\");\n registerStoreLattice(\"default\", \"workspace\", workspaceStore);\n console.log(\"✓ PostgreSQL WorkspaceStore initialized\");\n\n // Initialize and register PostgreSQL ProjectStore\n const projectStore = new PostgreSQLProjectStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await projectStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"project\");\n registerStoreLattice(\"default\", \"project\", projectStore);\n console.log(\"✓ PostgreSQL ProjectStore initialized\");\n\n // Initialize and register PostgreSQL UserStore\n const userStore = new PostgreSQLUserStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await userStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"user\");\n registerStoreLattice(\"default\", \"user\", userStore);\n console.log(\"✓ PostgreSQL UserStore initialized\");\n\n // Initialize and register PostgreSQL TenantStore\n const tenantStore = new PostgreSQLTenantStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await tenantStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"tenant\");\n registerStoreLattice(\"default\", \"tenant\", tenantStore);\n console.log(\"✓ PostgreSQL TenantStore initialized\");\n\n // Initialize and register PostgreSQL UserTenantLinkStore\n const userTenantLinkStore = new PostgreSQLUserTenantLinkStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await userTenantLinkStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"userTenantLink\");\n registerStoreLattice(\"default\", \"userTenantLink\", userTenantLinkStore);\n console.log(\"✓ PostgreSQL UserTenantLinkStore initialized\");\n\n // Initialize and register PostgreSQL AssistantStore\n const assistantStore = new PostgreSQLAssistantStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await assistantStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"assistant\");\n registerStoreLattice(\"default\", \"assistant\", assistantStore);\n console.log(\"✓ PostgreSQL AssistantStore initialized\");\n\n // Initialize and register ThreadMessageQueueStore for Agent Recovery\n // This MUST be initialized before starting the gateway\n const threadMessageQueueStore = ThreadMessageQueueStore.getInstance();\n await threadMessageQueueStore.initialize(sharedPool, true);\n storeLatticeManager.removeLattice(\"default\", \"threadMessageQueue\");\n registerStoreLattice(\"default\", \"threadMessageQueue\", threadMessageQueueStore);\n console.log(\"✓ ThreadMessageQueueStore initialized for Agent Recovery\");\n\n // Initialize and register PostgresSaver for LangGraph checkpoint persistence\n // This enables thread state recovery after server restart\n // Create a new Pool using the same connection string to avoid type conflicts\n const globalMemory = PostgresSaver.fromConnString(\n connectionString\n );\n //await globalMemory.setup();\n MemoryLatticeManager.getInstance().removeCheckpointSaver(\"default\");\n\n registerCheckpointSaver(\"default\", globalMemory);\n console.log(\"✓ globalMemory initialized for LangGraph checkpoints\");\n\n // Register Sandbox Manager Lattice\n const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || \"microsandbox\";\n const sandboxBaseURL = process.env.SANDBOX_BASE_URL;\n const microsandboxServiceBaseURL = process.env.MICROSANDBOX_SERVICE_BASE_URL;\n const e2bApiKey = process.env.E2B_API_KEY;\n const daytonaApiKey = process.env.DAYTONA_API_KEY;\n const daytonaApiUrl = process.env.DAYTONA_API_URL;\n const daytonaTarget = process.env.DAYTONA_TARGET;\n\n const sandboxProvider = createSandboxProvider({\n type: sandboxProviderType as any,\n remoteBaseURL: sandboxBaseURL,\n microsandboxServiceBaseURL,\n e2bApiKey,\n e2bTemplate: process.env.E2B_TEMPLATE,\n e2bTimeoutMs: process.env.E2B_TIMEOUT_MS\n ? parseInt(process.env.E2B_TIMEOUT_MS, 10)\n : undefined,\n daytonaApiKey,\n daytonaApiUrl,\n daytonaTarget,\n daytonaTimeout: process.env.DAYTONA_TIMEOUT\n ? parseInt(process.env.DAYTONA_TIMEOUT, 10)\n : undefined,\n daytonaVolumeName: process.env.DAYTONA_VOLUME_NAME,\n });\n\n sandboxLatticeManager.registerLattice(\"default\", sandboxProvider);\n\n console.log(`✓ Sandbox provider registered: ${sandboxProviderType}`);\n\n // Initialize and register PostgreSQL ScheduleStorage for scheduled tasks\n const scheduleStorage = new PostgreSQLScheduleStorage({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await scheduleStorage.initialize();\n registerScheduleLattice(\"default\", {\n name: \"Default Scheduler\",\n description: \"Production scheduler with PostgreSQL persistence\",\n type: ScheduleType.POSTGRES,\n storage: scheduleStorage,\n });\n console.log(\"✓ PostgreSQL ScheduleStorage initialized\");\n\n const port = parsePort();\n console.log(`\\n🌐 Starting server on port ${port}...\\n`);\n\n // Default logger configuration\n const DEFAULT_LOGGER_CONFIG: LoggerConfig = {\n name: \"default\",\n description: \"Default logger for lattice-gateway service\",\n type: LoggerType.PINO,\n serviceName: \"lattice/deep_research\",\n loggerName: \"lattice/deep_research\",\n };\n\n // Start the gateway\n LatticeGateway.startAsHttpEndpoint({\n port,\n queueServiceConfig: { type: \"memory\", defaultStartPollingQueue: true },\n loggerConfig: DEFAULT_LOGGER_CONFIG,\n });\n}\n\n// Run main function\nmain().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\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: \"deep_research_agent\",\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 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\n// Register with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, research_agents);\n","/**\n * Team-based Deep Research Agent\n *\n * This is the TEAM version of the deep_research_agent, designed to be\n * compared side-by-side with the original DEEP_AGENT version.\n *\n * Architecture difference:\n * - DEEP_AGENT version: Leader calls sub-agents sequentially/parallel,\n * each sub-agent completes a single invocation and returns.\n * - TEAM version: Leader creates a team with a shared task list and mailbox.\n * Teammates are persistent workers that claim tasks from the list,\n * report back via messages, and keep working until all tasks are done.\n * The leader can dynamically add/modify tasks based on user feedback\n * or teammate discoveries.\n */\n\nimport {\n registerAgentLattices,\n AgentType,\n} from \"@axiom-lattice/core\";\nimport type { AgentConfig, TeamAgentConfig } from \"@axiom-lattice/protocols\";\nimport z from \"zod\";\n\n// ---------------------------------------------------------------------------\n// Team Lead prompt -- the orchestrator\n// ---------------------------------------------------------------------------\n\nconst teamLeadPrompt = `You are an expert research team lead. You coordinate a team of specialized agents to produce a thorough, polished research report.\n\n## Workflow\n\n1. When given a research topic, break it down into concrete research tasks:\n - Multiple focused research sub-topics (assign to \"researcher\" teammates)\n - A final critique pass (assign to \"critic\" teammate)\n - A writing/synthesis task (you will handle this yourself after research is done)\n\n2. Call \\`create_team\\` with the initial tasks and teammates. Tasks can have dependencies (e.g. critique depends on all research tasks completing).\n\n3. While tasks are NOT all completed: You MUST periodically call \\`check_tasks\\` and \\`read_messages\\` to monitor progress. Do not assume tasks are done without checking. Keep polling until all research tasks show completed or failed.\n - If a teammate reports new findings that require additional research, use \\`add_tasks\\` to add follow-up tasks.\n\n4. Once all research tasks are complete (verify via \\`check_tasks\\`), synthesize the results into a final report.\n\n5. After the critic reviews, incorporate feedback and produce the final version.\n\n## Report Writing Guidelines\n\nCRITICAL: Write the report in the SAME language as the user's message.\n\nThe final report should:\n- Be well-organized with proper headings (# for title, ## for sections, ### for subsections)\n- Include specific facts and insights from the research\n- Reference relevant sources using [Title](URL) format\n- Provide a balanced, thorough analysis\n- Include a \"Sources\" section at the end\n- Be text-heavy -- not just bullet points\n- Be comprehensive and detailed\n\n<Citation Rules>\n- Assign each unique URL a single citation number\n- End with ### Sources listing each source with numbers\n- Number sources sequentially (1,2,3,4...)\n- Each source as a separate list item: [1] Source Title: URL\n</Citation Rules>\n\n## Available Teammates\n\n- **researcher**: Can search the internet for information. Assign one research sub-topic per task. You can create multiple researcher tasks to run in parallel.\n- **critic**: Reviews research results and the draft report for quality, completeness, and accuracy. The critic does NOT have search tools -- only reviews text.`;\n\n// ---------------------------------------------------------------------------\n// Team Agent Config\n// ---------------------------------------------------------------------------\n\nconst teamResearchAgent: TeamAgentConfig = {\n key: \"team_research_agent\",\n name: \"Team Research Agent\",\n description:\n \"Team-based deep research agent. Uses a team of persistent researcher and critic \" +\n \"agents that work in parallel via a shared task list and mailbox. \" +\n \"Compare with deep_research_agent (DEEP_AGENT version) for architectural differences.\",\n type: AgentType.TEAM,\n prompt: teamLeadPrompt,\n tools: [\"internet_search\"], // Team lead also has search capability\n schema: z.object({\n test: z.string().optional(),\n }),\n scheduleLatticeKey: \"default\", // Use ScheduleLattice for polling task list\n pollIntervalMs: 5000, // Poll every 5 seconds\n};\n\n// Register the team research agent with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, [teamResearchAgent] as AgentConfig[]);\n","/**\n * Data Agent - Business Data Analyst Agent\n * An intelligent agent that converts natural language business questions to SQL queries,\n * performs multi-step business analysis, and generates comprehensive business reports.\n *\n * Key Capabilities:\n * - Business analysis and task decomposition\n * - Multi-step data analysis with dimension breakdowns\n * - Structured report generation (Executive Summary, Analysis Steps, Appendix)\n * - Business-friendly insights and visualizations\n * - Reproducible notebook-style analysis trajectory\n */\n\nimport {\n registerAgentLattices,\n AgentType,\n AgentConfig,\n sqlDatabaseManager,\n DatabaseConfig,\n} from \"@axiom-lattice/core\";\nimport z from \"zod\";\n\n\n/**\n * System prompt for the main data agent\n * This agent orchestrates the NL2SQL process with business analysis capabilities\n */\nconst dataAgentPrompt = `你是一位专业的业务数据分析AI助手,擅长规划业务分析任务、协调数据检索,并生成全面的业务分析报告。\n\n**关键:你的第一项也是最重要的任务是使用 \\`write_todos\\` 工具创建待办列表。** 在开始任何工作之前,你必须:\n1. 理解业务问题,然后将问题写入文件 /question.md\n2. 根据加载技能学习如何来解决该问题,读取的技能文档将其拆解为可执行的子任务,创建待办列表\n3. 按照计划执行任务\n\n永远不要跳过任务规划。业务分析总是复杂且多步骤的,需要仔细规划和跟踪。\n\n## 核心工作流程\n\n你的主要职责是通过技能驱动的方式完成分析任务:\n\n1. **任务规划与拆解(优先级最高)**:理解业务问题,通过加载相关技能(如 \\`analysis-methodology\\`)来学习如何拆解任务,然后使用 \\`write_todos\\` 工具创建和管理任务列表\n2. **业务分析执行**:根据加载的技能内容(如 \\`analyst\\`、\\`sql-query\\` 等)执行具体的分析步骤\n3. **任务协调**:将 SQL 查询生成和执行委托给 sql-builder-agent 子代理\n4. **数据解读**:分析 sql-builder-agent 返回的查询结果,提取业务洞察\n5. **报告生成**:使用相关技能(如 \\`notebook-report\\`)生成包含洞察、可视化和可执行建议的业务分析报告\n\n\n## 技能驱动的工作方式\n\n**重要原则**:不要依赖硬编码的流程,而是通过查看技能(使用load_skill_content 工具来加载技能)来了解如何工作。\n\n- **如何规划任务**:加载 \\`analysis-methodology\\` 技能,学习结构化分析方法论(5W2H、MECE、议题树等)\n- **如何执行分析**:加载 \\`analyst\\` 技能,学习完整的分析工作流程\n- **如何查询数据**:加载 \\`sql-query\\` 技能,学习数据库探索和查询执行的最佳实践\n- **如何可视化**:加载 \\`data-visualization\\` 技能,学习图表设计和 ECharts 配置\n- **如何生成报告**:加载 \\`notebook-report\\` 技能,学习报告结构和生成方法\n\n每个技能都包含详细的操作指南、工作流程和最佳实践。你应该:\n1. 根据业务问题选择合适的技能\n2. 严格按照技能中的指导执行工作\n\n## 子代理使用\n\n- **sql-builder-agent**:负责所有 SQL 相关操作(数据库探索、查询生成、验证和执行)\n- **data-analysis-agent**:负责分析查询结果,提取业务洞察,提供可视化建议\n\n将技术任务委托给相应的子代理,专注于业务分析和任务协调。\n\n`;\n\n/**\n * System prompt for the SQL query builder sub-agent\n */\nconst sqlBuilderPrompt = `You are a SQL Expert sub-agent specialized in database exploration, SQL query generation, validation, and execution. You handle all SQL-related operations and return both the query and its results.\n\nWhen given a task from the data_agent:\n1. **Understand the Business Intent**: Analyze what business question the query needs to answer\n2. **Check Schema Documentation First**: \n - Before exploring the database, read file \\`/db_schema.md\\` \n - If the schema file exists, read it to understand the database structure\n - This will save time and avoid redundant schema exploration\n - If the file doesn't exist or you need more specific information, then:\n - Use \\`list_tables_sql\\` to see all available tables\n - Use \\`info_sql\\` to get detailed schema information for relevant tables\n - Understand column names, data types, relationships, and sample data\n3. **Design Query**: Write the most appropriate SQL query that:\n - Answers the business question accurately\n - Uses efficient joins and aggregations\n - Includes business-friendly column aliases\n - Handles edge cases (NULLs, duplicates, etc.)\n4. **Validate**: Use \\`query_checker_sql\\` to validate the query before execution\n5. **Execute**: Use \\`query_sql\\` to execute the validated query\n6. **Return Results**: Provide both:\n - The SQL query that was executed (formatted clearly)\n - The query results (data returned from the database)\n - Any relevant schema information that was used\n\n## Focus Areas\n\n- **Query Correctness**: Ensure the query accurately answers the business question\n- **Query Efficiency**: Optimize for performance (use indexes, efficient JOINs)\n- **Business Clarity**: Use meaningful column aliases that business users can understand\n - Example: Use \"revenue_usd\" instead of \"amt\", \"order_count\" instead of \"cnt\"\n- **Proper JOINs**: Use appropriate JOIN types (INNER, LEFT, RIGHT, FULL) based on business logic\n- **Aggregations**: Use appropriate aggregate functions (COUNT, SUM, AVG, MAX, MIN) with proper GROUP BY\n- **Subqueries**: Use subqueries when they improve clarity or performance\n- **Window Functions**: Leverage window functions for advanced analytics when needed\n\n## Business-Oriented Query Design\n\nWhen writing queries:\n- **Metric Calculation**: Ensure metrics are calculated correctly (e.g., YoY growth, percentages)\n- **Dimension Handling**: Properly handle business dimensions (regions, channels, product categories)\n- **Time Periods**: Correctly filter and group by time periods (quarters, months, years)\n- **Comparisons**: Structure queries to enable easy comparisons (current vs previous period)\n- **Data Quality**: Include filters to exclude invalid or test data when appropriate\n\n## Error Handling\n\nIf you encounter issues:\n- Analyze the error message carefully\n- Check schema compatibility (data types, column names)\n- Verify JOIN conditions and table relationships\n- Modify the query accordingly\n- Re-validate before returning\n\n## Output Format\n\nAlways return your results in a clear format:\n\n**SQL Query:**\n- The final SQL query that was executed\n- Properly indented and readable\n- Includes comments for complex logic\n- Uses business-friendly aliases\n- Can be easily understood by both technical and business users\n\n**Query Results:**\n- The data returned from the database\n- Formatted clearly with column names\n- Include all rows returned (or a summary if too large)\n\n**Schema Information (if relevant):**\n- Any schema details that were used or discovered\n- Table relationships, column types, etc.\n\n**Example Response Format:**\n\\`\\`\\`\nSQL Query:\n\\`\\`\\`sql\n[Your executed SQL query here]\n\\`\\`\\`\n\nQuery Results:\n[Data table or summary here]\n\nSchema Information:\n[Any relevant schema details]\n\\`\\`\\`\n\nRemember: You are responsible for all SQL operations. The data_agent relies on you to provide both the query and the data. Be thorough, accurate, and return complete information.\n\n## SQL Best Practices\n\n1. **Be Specific**: Always specify column names instead of using SELECT *\n2. **Use Aliases**: Use meaningful table and column aliases for clarity\n3. **Handle NULLs**: Consider NULL values in your queries\n4. **Limit Results**: For exploratory queries, limit results to avoid overwhelming output\n5. **Optimize JOINs**: Use appropriate JOIN types (INNER, LEFT, etc.)\n6. **Use Indexes**: Structure queries to leverage indexes when possible\n7. **Business Naming**: Use business-friendly column aliases in results\n\n不要使用子智能体来完成你的任务。\n\n`;\n\n/**\n * System prompt for the data analysis sub-agent\n */\nconst dataAnalysisPrompt = `你是一位业务数据分析专家子代理。你的职责是解读查询结果,提取业务洞察,并评估当前数据是否足以回答用户的问题。\n\n## 核心职责\n\n当你收到查询结果时,你需要:\n\n1. **提取关键发现**:识别数据中最重要的数字、趋势和模式\n2. **业务解读**:将数据转化为业务语言和业务上下文\n3. **模式识别**:识别趋势、异常、相关性和离群值\n4. **问题回答评估**:评估当前数据是否足以完整回答用户的业务问题\n5. **数据缺口识别**:如果数据不足,明确指出还需要哪些数据,以及如何获取这些数据\n\n## 分析框架\n\n### 1. 数据摘要\n\n用 2-3 句话总结数据揭示的核心信息,自然地融入具体数字。\n\n例如:\"数据显示 2024 年 Q3 北美地区收入达到 250 万美元,相比 2023 年 Q3 增长了 18%。这一增长主要由在线渠道扩张驱动,表明战略转型取得了成功。\"\n\n### 2. 关键发现\n\n以叙述性段落(每段 2-3 句话)呈现关键发现,每个段落应该是一个小故事,自然地融入具体数字。\n\n例如:\"最引人注目的发现是地区差异。虽然整体收入增长了 18%,但美国市场贡献了总收入的 70%,其中加利福尼亚州表现尤为强劲,增长 25%。这种集中度既意味着机会,也意味着风险——成功高度依赖少数关键市场。\"\n\n### 3. 业务洞察\n\n用叙述性段落解释这些发现意味着什么,将数据点与业务结果自然连接。\n\n- 讨论关注点或机会\n- 解释可能导致这些模式的因素\n- 使用\"这表明...\"、\"有趣的是...\"、\"特别值得注意的是...\"等表达\n\n### 4. 问题回答评估\n\n**关键任务**:评估当前数据是否足以回答用户的业务问题。\n\n- **如果数据充足**:明确说明当前数据如何回答了问题,哪些方面已经得到解答\n- **如果数据不足**:明确指出:\n - 哪些问题无法从当前数据中回答\n - 缺少哪些关键信息或维度\n - 建议需要查询哪些额外的数据(具体说明需要查询的表、字段、时间范围、筛选条件等)\n - 为什么这些额外数据对完整回答问题至关重要\n\n### 5. 后续数据挖掘建议\n\n如果数据不足,提供具体的数据挖掘建议:\n\n- **需要查询的表和字段**:明确指出需要从哪些表查询哪些字段\n- **时间范围**:如果需要历史对比,建议查询的时间范围\n- **维度拆分**:如果需要更细粒度的分析,建议按哪些维度拆分(如地区、渠道、产品类别等)\n- **关联查询**:如果需要关联其他表,说明需要 JOIN 哪些表以及关联条件\n- **筛选条件**:如果需要特定子集的数据,说明筛选条件\n\n## 业务上下文整合\n\n分析结果时考虑:\n\n- **基准对比**:与历史时期、目标或行业标准对比\n- **细分分析**:识别哪些细分(地区、渠道、产品)驱动了结果\n- **异常检测**:标记需要调查的异常模式\n- **趋势分析**:识别上升、下降或稳定趋势\n- **相关性**:注意不同指标之间的关系\n\n## 输出结构\n\n\\`\\`\\`markdown\n### 数据摘要\n\n[用 2-3 句话总结数据揭示的核心信息,自然地融入具体数字]\n\n### 关键发现\n\n[用叙述性段落(每段 2-3 句话)呈现关键发现,自然地融入具体数字]\n\n### 业务洞察\n\n[用叙述性段落解释这些发现意味着什么,将数据点与业务结果自然连接]\n\n### 问题回答评估\n\n**当前数据是否足以回答问题:** [是/部分/否]\n\n**已回答的方面:**\n- [说明当前数据如何回答了问题的哪些方面]\n\n**未回答的方面(如果数据不足):**\n- [明确指出哪些问题无法从当前数据中回答]\n\n### 数据挖掘建议(如果数据不足)\n\n**需要查询的额外数据:**\n1. **查询目标**:[说明需要查询什么信息]\n2. **建议的 SQL 查询方向**:\n - 表:[需要查询的表名]\n - 字段:[需要的字段列表]\n - 时间范围:[如果需要,说明时间范围]\n - 维度拆分:[如果需要,说明按哪些维度拆分]\n - 关联表:[如果需要 JOIN,说明关联的表和条件]\n - 筛选条件:[如果需要,说明筛选条件]\n3. **为什么需要这些数据**:[解释为什么这些数据对完整回答问题至关重要]\n\\`\\`\\`\n\n## 沟通风格\n\n- **叙述性**:以故事形式呈现,而非技术报告\n- **自然流畅**:使用多样化的句子结构和自然的过渡\n- **业务友好**:使用业务术语,而非技术行话\n- **数据驱动**:自然地融入具体数字,而非单独列出事实\n- **对话式**:像向同事解释一样,而非填写表格\n- **可执行**:聚焦能够为决策提供信息的洞察\n- **上下文相关**:在叙述中自然地提供业务上下文\n\n## 特别注意事项\n\n- **百分比**:在相关时计算并突出百分比变化\n- **对比**:始终提供上下文(与上一时期对比、与目标对比、与平均值对比)\n- **离群值**:标记并解释任何异常数据点\n- **数据质量**:注意任何数据限制或注意事项\n- **置信度**:当发现具有统计显著性或仅为初步结果时,明确说明\n\n记住:你的分析将原始查询结果转化为有意义的业务洞察。评估数据是否足以回答问题,如果不足,提供具体的数据挖掘建议,帮助获取完整答案所需的信息。\n\n不要使用子智能体来完成你的任务。\n`;\n\n/**\n * Data Agent configurations\n */\nconst data_agents: AgentConfig[] = [\n {\n key: \"data_agent\",\n name: \"Data Agent\",\n description:\n \"An intelligent Business Data Analyst agent that converts natural language questions into SQL queries, performs multi-step business analysis, and generates comprehensive business reports. Capabilities include: task decomposition, metric analysis, dimension breakdowns, anomaly detection, and structured report generation with executive summaries, analysis steps, and visualizations. Use this agent for business intelligence, data analysis, database queries, and generating actionable business insights.\",\n type: AgentType.DEEP_AGENT,\n tools: [\"list_tables_sql\", \"info_sql\"],\n prompt: dataAgentPrompt,\n subAgents: [\"sql-builder-agent\", \"data-analysis-agent\"],\n skillCategories: [\"analysis\", \"sql\"],\n schema: z.object({}),\n /**\n * Runtime configuration injected into tool execution context.\n * databaseKey: The database key registered via sqlDatabaseManager.\n * Tools will access this via config.configurable.runConfig.databaseKey\n */\n runConfig: {\n databaseKey: \"fulidb\", // Set this to the registered database key\n },\n },\n {\n key: \"sql-builder-agent\",\n name: \"sql-builder-agent\",\n type: AgentType.DEEP_AGENT,\n description:\n \"A specialized sub-agent for database exploration, SQL query generation, validation, and execution. This agent handles all SQL-related operations including listing tables, exploring schemas, generating queries, validating them, executing them, and returning both the SQL and query results to the data_agent.\",\n prompt: sqlBuilderPrompt,\n // tools: [\"list_tables_sql\", \"info_sql\", \"query_checker_sql\", \"query_sql\"],\n // Sub-agents inherit runConfig from parent agent via the execution context\n },\n {\n key: \"data-analysis-agent\",\n name: \"data-analysis-agent\",\n type: AgentType.DEEP_AGENT,\n description:\n \"A specialized sub-agent for analyzing query results and extracting business insights. This agent interprets data, identifies patterns and anomalies, provides business context, and structures findings for comprehensive reports. Give this agent query results and it will provide structured business analysis with key findings, insights, and visualization recommendations.\",\n prompt: dataAnalysisPrompt,\n tools: [],\n },\n];\n\n// Register the agents with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, data_agents);\n\n/**\n * Helper function to initialize database connection for the data agent\n * Call this before using the data agent\n *\n * @param key - Unique identifier for the database connection\n * @param config - Database configuration\n *\n * @example\n * ```typescript\n * import { initializeDataAgentDatabase } from \"@axiom-lattice/examples-deep_research/agents/data_agent\";\n *\n * // Using connection string\n * initializeDataAgentDatabase(\"mydb\", {\n * type: \"postgres\",\n * connectionString: process.env.DATABASE_URL\n * });\n *\n * // Or using individual parameters\n * initializeDataAgentDatabase(\"mydb\", {\n * type: \"postgres\",\n * host: \"localhost\",\n * port: 5432,\n * database: \"mydb\",\n * user: \"user\",\n * password: \"password\"\n * });\n * ```\n */\nexport function initializeDataAgentDatabase(\n key: string,\n config: DatabaseConfig\n): void {\n sqlDatabaseManager.registerDatabase(\"default\", key, config);\n}\n\n/**\n * Helper function to set the default database for the data agent\n *\n * @param key - Database key to set as default\n */\nexport function setDefaultDatabase(key: string): void {\n sqlDatabaseManager.setDefaultDatabase(\"default\", key);\n}\n\n/**\n * Export types for external use\n */\nexport type { DatabaseConfig };\n\ninitializeDataAgentDatabase(\"fulidb\", {\n type: \"postgres\",\n connectionString: process.env.DATABASE_URL,\n database: \"postgres\",\n});\n","import {\n registerAgentLattices,\n AgentType,\n AgentConfig,\n toolLatticeManager,\n} from \"@axiom-lattice/core\";\nimport z from \"zod\";\n\nconst sandboxPrompt = `You are a Personal AI Assistant with access to a powerful sandboxed computer environment. You can help users with research, coding, file management, and web browsing tasks.\n\n## Your Core Identity\n- You are a helpful, intelligent, and proactive assistant\n- You communicate clearly and concisely\n- You are curious and enjoy solving complex problems\n- You anticipate user needs and offer suggestions proactively\n\n## Your Capabilities\n\n### 1. File System Operations\n- Read, write, edit, and organize files\n- Navigate directories and search for files\n- Manage file permissions and structures\n- **IMPORTANT**: When mentioning file paths, always wrap them in <file></file> tags so users can click to open them\n\n### 2. Code Development\n- Write, debug, and refactor code in any language\n- Execute shell commands and scripts\n- Run tests and development servers\n- Help with code reviews and optimization\n- Set up project structures and dependencies\n\n### 3. Web Browsing\n- Navigate websites and extract information\n- Research topics on the web\n- Fill forms and interact with web applications\n- Take screenshots when useful\n- Scrape and summarize web content\n\n## Working Style\n\n### Problem Solving\n- Break down complex tasks into clear steps\n- Execute tasks methodically and efficiently\n- Verify your work before presenting results\n- If something fails, explain what happened and suggest alternatives\n\n### Communication\n- Use clear formatting: headers, lists, code blocks, and tables\n- Explain what you're doing before taking action\n- Highlight important information and files\n- Ask clarifying questions when needed\n- Provide context and background when sharing results\n\n### Proactivity\n- Suggest improvements or optimizations\n- Point out potential issues or risks\n- Offer related resources or alternative approaches\n- Remember user preferences and learn from feedback\n\n## Interaction Guidelines\n\n1. **Start with understanding**: Confirm your understanding of the task and ask questions if anything is unclear\n2. **Show your work**: Briefly explain what steps you're taking\n3. **Be transparent**: If you encounter errors or limitations, explain them clearly\n4. **Deliver quality**: Test your code, verify file operations, and double-check important work\n5. **Be efficient**: Choose the most direct path to complete the task\n6. **Stay focused**: Complete the main task before diving into tangents\n\n## Example Behaviors\n\nWhen user says: \"Help me set up a new React project\"\n- You might respond: \"I'll create a new React project for you using Vite for fast setup. I'll create the basic structure, install dependencies, and set up a sample component. Would you like me to include any specific libraries or configurations?\"\n\nWhen user says: \"Find all TypeScript files in the project\"\n- You should search and present results with clickable <file>file paths</file> for easy access\n\nWhen user says: \"Research the latest AI trends\"\n- You'll browse the web, gather information from multiple sources, and provide a comprehensive summary with key insights and links\n\n## Technical Notes\n\n- You have full access to the sandbox environment - use it confidently\n- You can install packages, run servers, and modify system configurations within your sandbox\n- Your changes are contained within the sandbox - feel free to experiment\n- Always verify file operations completed successfully\n- Keep the user informed of long-running operations\n\nRemember: Your goal is to make the user more productive and help them accomplish their tasks efficiently. Be their trusted partner in getting work done.`;\n\n//setTimeout(() => {\n\n// const tools = toolLatticeManager.getAll().map((lattice) => lattice.config.name);\nconst sandboxAgent: AgentConfig = {\n key: \"sandbox_agent\",\n name: \"Sandbox Agent\",\n description:\n \"A sandbox agent for testing and development.\",\n type: AgentType.DEEP_AGENT,\n prompt: sandboxPrompt,\n middleware: [\n {\n id: \"filesystem-1\",\n type: \"filesystem\",\n name: \"Filesystem\",\n description: \"Provides file system operations\",\n enabled: true,\n config: { vmIsolation: \"agent\" }\n },\n {\n id: \"code_eval-1\",\n type: \"code_eval\",\n name: \"Code Evaluation\",\n description: \"Enables safe code execution\",\n enabled: true,\n config: { vmIsolation: \"agent\", timeout: 30000, memoryLimit: 128 }\n },\n {\n id: \"browser-1\",\n type: \"browser\",\n name: \"Browser\",\n description: \"Provides browser automation\",\n enabled: true,\n config: { vmIsolation: \"agent\" }\n }\n ],\n};\n\n// Register with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, [sandboxAgent]);\n\n//}, 10000);\n","import dotenv from \"dotenv\";\nimport path from \"path\";\n\nexport function loadLocalEnv(): void {\n dotenv.config({ path: path.resolve(__dirname, \"../.env.local\") });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,M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I,2CAA0B;AAAA,IACpD,YAAY;AAAA,IACZ,aAAa;AAAA,EACf,CAAC;AACD,QAAM,gBAAgB,WAAW;AACjC,4CAAwB,WAAW;AAAA,IACjC,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,8BAAa;AAAA,IACnB,SAAS;AAAA,EACX,CAAC;AACD,UAAQ,IAAI,+CAA0C;AAEtD,QAAM,OAAO,UAAU;AACvB,UAAQ,IAAI;AAAA,oCAAgC,IAAI;AAAA,CAAO;AAGvD,QAAM,wBAAsC;AAAA,IAC1C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,4BAAW;AAAA,IACjB,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAGA,gCAAe,oBAAoB;AAAA,IACjC;AAAA,IACA,oBAAoB,EAAE,MAAM,UAAU,0BAA0B,KAAK;AAAA,IACrE,cAAc;AAAA,EAChB,CAAC;AACH;AAGA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,2BAA2B,KAAK;AAC9C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["exports","module","import_core","z","import_core","import_zod","z","tenantId","import_core","import_zod","z","tenantId","import_core","tenantId","dotenv","path"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/index.ts","../src/agents/research/index.ts","../src/agents/research_team/index.ts","../src/agents/data_agent/index.ts","../src/agents/sandbox_agent/index.ts","../src/env.ts"],"sourcesContent":["{\n \"name\": \"@axiom-lattice/examples-deep_research\",\n \"version\": \"1.0.57\",\n \"type\": \"module\",\n \"main\": \"dist/index.js\",\n \"bin\": {\n \"lattice-deep-research\": \"./dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"start\": \"node dist/index.js\",\n \"dev\": \"lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format esm --dts --watch --onSuccess \\\"node dist/index.js\\\"\",\n \"dev:nodemon\": \"nodemon --watch 'src/**/*.ts' --watch '../../packages/core/dist/**/*' --exec 'ts-node' -r tsconfig-paths/register src/index.ts\",\n \"dev:serve\": \"tsup src/index.ts --format esm --dts --watch --serve dist/index.js\",\n \"dev:inspect\": \"tsup src/index.ts --format esm --dts --watch --onSuccess \\\"node --inspect dist/index.js\\\"\",\n \"lint\": \"tsc --noEmit\",\n \"test\": \"jest\",\n \"test:watch\": \"jest --watch\",\n \"test:coverage\": \"jest --coverage\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"description\": \"Deep Research Server for Axiom Lattice\",\n \"dependencies\": {\n \"@axiom-lattice/core\": \"workspace:*\",\n \"@axiom-lattice/gateway\": \"workspace:*\",\n \"@axiom-lattice/pg-stores\": \"workspace:*\",\n \"@axiom-lattice/protocols\": \"workspace:*\",\n \"@langchain/langgraph-checkpoint-postgres\": \"^1.0.0\",\n \"dotenv\": \"^16.6.1\",\n \"pg\": \"^8.20.0\",\n \"uuid\": \"^9.0.1\",\n \"zod\": \"^3.24.2\",\n \"zod-to-json-schema\": \"^3.24.3\"\n },\n \"devDependencies\": {\n \"@types/jest\": \"^29.5.14\",\n \"@types/lodash\": \"^4.17.16\",\n \"@types/node\": \"^20.17.23\",\n \"@types/pg\": \"^8.20.0\",\n \"@types/uuid\": \"^9.0.8\",\n \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n \"@typescript-eslint/parser\": \"^7.2.0\",\n \"eslint\": \"^8.57.0\",\n \"jest\": \"^29.7.0\",\n \"nodemon\": \"^3.1.9\",\n \"ts-jest\": \"^29.4.0\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.2\"\n }\n}\n","import dotenv from \"dotenv\";\n\nimport { LatticeGateway } from \"@axiom-lattice/gateway\";\nimport {\n getScheduleLattice,\n registerCheckpointSaver,\n registerModelLattice,\n registerScheduleLattice,\n\n storeLatticeManager,\n mcpManager,\n toolLatticeManager,\n registerStoreLattice,\n sandboxLatticeManager,\n getSandBoxManager,\n createSandboxProvider,\n sqlDatabaseManager,\n metricsServerManager,\n MemoryLatticeManager,\n} from \"@axiom-lattice/core\";\nimport { McpServerConfig } from \"@axiom-lattice/protocols\";\nimport \"./agents\";\n\nimport path from \"path\";\nimport {\n LoggerConfig,\n LoggerType,\n ScheduleType,\n} from \"@axiom-lattice/protocols\";\nimport { PostgreSQLAssistantStore, PostgreSQLScheduleStorage, PostgreSQLThreadStore, PostgreSQLDatabaseConfigStore, PostgreSQLMetricsServerConfigStore, PostgreSQLMcpServerConfigStore, PostgreSQLWorkspaceStore, PostgreSQLProjectStore, PostgreSQLUserStore, PostgreSQLTenantStore, PostgreSQLUserTenantLinkStore, ThreadMessageQueueStore, Pool } from \"@axiom-lattice/pg-stores\";\nimport { PostgresSaver } from \"@langchain/langgraph-checkpoint-postgres\";\nimport pg from \"pg\";\nimport { loadLocalEnv } from \"./env\";\n\nconst PACKAGE_VERSION = require(\"../package.json\").version;\nconst BUILD_TIME = new Date().toISOString();\nconst IS_DEV = process.env.NODE_ENV !== \"production\";\n\n// 在启动时输出\nconsole.log(`\n╔═══════════════════════════════════════╗\n║ Lattice Deep Research Server ║\n║ Version: ${PACKAGE_VERSION} ║\n║ Build Time: ${BUILD_TIME} ║\n║ Environment: ${IS_DEV ? \"Development\" : \"Production\"} ║\n╚═══════════════════════════════════════╝\n`);\n\n// Load environment variables\nloadLocalEnv();\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 {\n model: \"kimi-k2.6\",\n displayName: \"kimi-k2.6\",\n //model: \"qwen3.5-35b-a3b\",\n provider: \"openai\",\n streaming: true,\n apiKeyEnvName: \"API_KEY3\",\n baseURL: \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n modelKwargs: {\n \"enable_thinking\": false\n }\n }\n);\nregisterModelLattice(\n \"qwen3.5-plus\",\n {\n model: \"qwen3.5-plus\",\n displayName: \"qwen3.5-plus\",\n //model: \"qwen3.5-35b-a3b\",\n provider: \"openai\",\n streaming: true,\n apiKeyEnvName: \"API_KEY3\",\n baseURL: \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n }\n);\nregisterModelLattice(\n \"doubao-seed-2-0-pro\",\n\n {\n displayName: \"Doubao pro 2.0\",\n model: \"doubao-seed-2-0-pro-260215\",\n provider: \"volcengine\",\n streaming: true,\n apiKeyEnvName: \"VOLCENGINE_API_KEY2\",\n modelKwargs: {\n \"thinking\": { \"type\": \"disabled\" }\n },\n }\n);\n// registerModelLattice(\n// \"K2.5-Coding\",\n// {\n// displayName: \"K2.5 Coding\",\n// model: \"k2p5\",\n// provider: \"openai\",\n// streaming: true,\n// apiKeyEnvName: \"API_KEY4\",\n// baseURL: \"https://api.kimi.com/coding/v1\",\n// modelKwargs: {\n// \"enable_thinking\": { \"type\": \"disabled\" },\n// headers: {\n// \"User-Agent\": \"claude-code/0.1.0\"\n// }\n// },\n// }\n// );\n// Auth configuration\nconst AUTH_CONFIG = {\n autoApproveUsers: process.env.AUTO_APPROVE_USERS !== \"false\",\n allowTenantRegistration: process.env.ALLOW_TENANT_REGISTRATION !== \"false\",\n jwtSecret: process.env.JWT_SECRET || \"your-secret-key-change-in-production\",\n tokenExpiration: parseInt(process.env.TOKEN_EXPIRATION || \"86400\", 10),\n};\n\nconsole.log(\"Auth Configuration:\");\nconsole.log(` - Auto Approve Users: ${AUTH_CONFIG.autoApproveUsers}`);\nconsole.log(` - Allow Tenant Registration: ${AUTH_CONFIG.allowTenantRegistration}`);\nconsole.log(` - Token Expiration: ${AUTH_CONFIG.tokenExpiration}s`);\n\n// Main async initialization function\nasync function main() {\n const connectionString = process.env.DATABASE_URL || \"\";\n\n if (!connectionString) {\n console.error(\"ERROR: DATABASE_URL environment variable is not set\");\n process.exit(1);\n }\n\n // Create shared pool for all stores\n const sharedPool = new Pool({ connectionString });\n\n // Initialize and register PostgreSQL ThreadStore\n const threadStore = new PostgreSQLThreadStore({\n poolConfig: connectionString,\n autoMigrate: false, // Will manually initialize\n });\n await threadStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"thread\");\n registerStoreLattice(\"default\", \"thread\", threadStore);\n console.log(\"✓ PostgreSQL ThreadStore initialized\");\n\n // Initialize and register PostgreSQL DatabaseConfigStore\n const databaseConfigStore = new PostgreSQLDatabaseConfigStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await databaseConfigStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"database\");\n registerStoreLattice(\"default\", \"database\", databaseConfigStore);\n sqlDatabaseManager.setConfigStore(databaseConfigStore);\n console.log(\"✓ PostgreSQL DatabaseConfigStore initialized\");\n\n // Initialize and register PostgreSQL MetricsServerConfigStore\n const metricsConfigStore = new PostgreSQLMetricsServerConfigStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await metricsConfigStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"metrics\");\n registerStoreLattice(\"default\", \"metrics\", metricsConfigStore);\n metricsServerManager.loadAllConfigsFromStore(metricsConfigStore);\n console.log(\"✓ PostgreSQL MetricsServerConfigStore initialized\");\n\n // Initialize and register PostgreSQL McpServerConfigStore\n const mcpConfigStore = new PostgreSQLMcpServerConfigStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await mcpConfigStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"mcp\");\n registerStoreLattice(\"default\", \"mcp\", mcpConfigStore);\n console.log(\"✓ PostgreSQL McpServerConfigStore initialized\");\n\n // Initialize and register PostgreSQL WorkspaceStore\n const workspaceStore = new PostgreSQLWorkspaceStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await workspaceStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"workspace\");\n registerStoreLattice(\"default\", \"workspace\", workspaceStore);\n console.log(\"✓ PostgreSQL WorkspaceStore initialized\");\n\n // Initialize and register PostgreSQL ProjectStore\n const projectStore = new PostgreSQLProjectStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await projectStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"project\");\n registerStoreLattice(\"default\", \"project\", projectStore);\n console.log(\"✓ PostgreSQL ProjectStore initialized\");\n\n // Initialize and register PostgreSQL UserStore\n const userStore = new PostgreSQLUserStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await userStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"user\");\n registerStoreLattice(\"default\", \"user\", userStore);\n console.log(\"✓ PostgreSQL UserStore initialized\");\n\n // Initialize and register PostgreSQL TenantStore\n const tenantStore = new PostgreSQLTenantStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await tenantStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"tenant\");\n registerStoreLattice(\"default\", \"tenant\", tenantStore);\n console.log(\"✓ PostgreSQL TenantStore initialized\");\n\n // Initialize and register PostgreSQL UserTenantLinkStore\n const userTenantLinkStore = new PostgreSQLUserTenantLinkStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await userTenantLinkStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"userTenantLink\");\n registerStoreLattice(\"default\", \"userTenantLink\", userTenantLinkStore);\n console.log(\"✓ PostgreSQL UserTenantLinkStore initialized\");\n\n // Initialize and register PostgreSQL AssistantStore\n const assistantStore = new PostgreSQLAssistantStore({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await assistantStore.initialize();\n storeLatticeManager.removeLattice(\"default\", \"assistant\");\n registerStoreLattice(\"default\", \"assistant\", assistantStore);\n console.log(\"✓ PostgreSQL AssistantStore initialized\");\n\n // Initialize and register ThreadMessageQueueStore for Agent Recovery\n // This MUST be initialized before starting the gateway\n const threadMessageQueueStore = ThreadMessageQueueStore.getInstance();\n await threadMessageQueueStore.initialize(sharedPool, true);\n storeLatticeManager.removeLattice(\"default\", \"threadMessageQueue\");\n registerStoreLattice(\"default\", \"threadMessageQueue\", threadMessageQueueStore);\n console.log(\"✓ ThreadMessageQueueStore initialized for Agent Recovery\");\n\n // Initialize and register PostgresSaver for LangGraph checkpoint persistence\n // This enables thread state recovery after server restart\n // Create a new Pool using the same connection string to avoid type conflicts\n const globalMemory = PostgresSaver.fromConnString(\n connectionString\n );\n //await globalMemory.setup();\n MemoryLatticeManager.getInstance().removeCheckpointSaver(\"default\");\n\n registerCheckpointSaver(\"default\", globalMemory);\n console.log(\"✓ globalMemory initialized for LangGraph checkpoints\");\n\n // Register Sandbox Manager Lattice\n const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || \"microsandbox\";\n const sandboxBaseURL = process.env.SANDBOX_BASE_URL;\n const microsandboxServiceBaseURL = process.env.MICROSANDBOX_SERVICE_BASE_URL;\n const e2bApiKey = process.env.E2B_API_KEY;\n const daytonaApiKey = process.env.DAYTONA_API_KEY;\n const daytonaApiUrl = process.env.DAYTONA_API_URL;\n const daytonaTarget = process.env.DAYTONA_TARGET;\n\n const sandboxProvider = createSandboxProvider({\n type: sandboxProviderType as any,\n remoteBaseURL: sandboxBaseURL,\n microsandboxServiceBaseURL,\n e2bApiKey,\n e2bTemplate: process.env.E2B_TEMPLATE,\n e2bTimeoutMs: process.env.E2B_TIMEOUT_MS\n ? parseInt(process.env.E2B_TIMEOUT_MS, 10)\n : undefined,\n daytonaApiKey,\n daytonaApiUrl,\n daytonaTarget,\n daytonaTimeout: process.env.DAYTONA_TIMEOUT\n ? parseInt(process.env.DAYTONA_TIMEOUT, 10)\n : undefined,\n daytonaVolumeName: process.env.DAYTONA_VOLUME_NAME,\n });\n\n sandboxLatticeManager.registerLattice(\"default\", sandboxProvider);\n\n console.log(`✓ Sandbox provider registered: ${sandboxProviderType}`);\n\n // Initialize and register PostgreSQL ScheduleStorage for scheduled tasks\n const scheduleStorage = new PostgreSQLScheduleStorage({\n poolConfig: connectionString,\n autoMigrate: false,\n });\n await scheduleStorage.initialize();\n registerScheduleLattice(\"default\", {\n name: \"Default Scheduler\",\n description: \"Production scheduler with PostgreSQL persistence\",\n type: ScheduleType.POSTGRES,\n storage: scheduleStorage,\n });\n console.log(\"✓ PostgreSQL ScheduleStorage initialized\");\n\n const port = parsePort();\n console.log(`\\n🌐 Starting server on port ${port}...\\n`);\n\n // Default logger configuration\n const DEFAULT_LOGGER_CONFIG: LoggerConfig = {\n name: \"default\",\n description: \"Default logger for lattice-gateway service\",\n type: LoggerType.PINO,\n serviceName: \"lattice/deep_research\",\n loggerName: \"lattice/deep_research\",\n };\n\n // Start the gateway\n LatticeGateway.startAsHttpEndpoint({\n port,\n queueServiceConfig: { type: \"memory\", defaultStartPollingQueue: true },\n loggerConfig: DEFAULT_LOGGER_CONFIG,\n });\n}\n\n// Run main function\nmain().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\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: \"deep_research_agent\",\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 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\n// Register with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, research_agents);\n","/**\n * Team-based Deep Research Agent\n *\n * This is the TEAM version of the deep_research_agent, designed to be\n * compared side-by-side with the original DEEP_AGENT version.\n *\n * Architecture difference:\n * - DEEP_AGENT version: Leader calls sub-agents sequentially/parallel,\n * each sub-agent completes a single invocation and returns.\n * - TEAM version: Leader creates a team with a shared task list and mailbox.\n * Teammates are persistent workers that claim tasks from the list,\n * report back via messages, and keep working until all tasks are done.\n * The leader can dynamically add/modify tasks based on user feedback\n * or teammate discoveries.\n */\n\nimport {\n registerAgentLattices,\n AgentType,\n} from \"@axiom-lattice/core\";\nimport type { AgentConfig, TeamAgentConfig } from \"@axiom-lattice/protocols\";\nimport z from \"zod\";\n\n// ---------------------------------------------------------------------------\n// Team Lead prompt -- the orchestrator\n// ---------------------------------------------------------------------------\n\nconst teamLeadPrompt = `You are an expert research team lead. You coordinate a team of specialized agents to produce a thorough, polished research report.\n\n## Workflow\n\n1. When given a research topic, break it down into concrete research tasks:\n - Multiple focused research sub-topics (assign to \"researcher\" teammates)\n - A final critique pass (assign to \"critic\" teammate)\n - A writing/synthesis task (you will handle this yourself after research is done)\n\n2. Call \\`create_team\\` with the initial tasks and teammates. Tasks can have dependencies (e.g. critique depends on all research tasks completing).\n\n3. While tasks are NOT all completed: You MUST periodically call \\`check_tasks\\` and \\`read_messages\\` to monitor progress. Do not assume tasks are done without checking. Keep polling until all research tasks show completed or failed.\n - If a teammate reports new findings that require additional research, use \\`add_tasks\\` to add follow-up tasks.\n\n4. Once all research tasks are complete (verify via \\`check_tasks\\`), synthesize the results into a final report.\n\n5. After the critic reviews, incorporate feedback and produce the final version.\n\n## Report Writing Guidelines\n\nCRITICAL: Write the report in the SAME language as the user's message.\n\nThe final report should:\n- Be well-organized with proper headings (# for title, ## for sections, ### for subsections)\n- Include specific facts and insights from the research\n- Reference relevant sources using [Title](URL) format\n- Provide a balanced, thorough analysis\n- Include a \"Sources\" section at the end\n- Be text-heavy -- not just bullet points\n- Be comprehensive and detailed\n\n<Citation Rules>\n- Assign each unique URL a single citation number\n- End with ### Sources listing each source with numbers\n- Number sources sequentially (1,2,3,4...)\n- Each source as a separate list item: [1] Source Title: URL\n</Citation Rules>\n\n## Available Teammates\n\n- **researcher**: Can search the internet for information. Assign one research sub-topic per task. You can create multiple researcher tasks to run in parallel.\n- **critic**: Reviews research results and the draft report for quality, completeness, and accuracy. The critic does NOT have search tools -- only reviews text.`;\n\n// ---------------------------------------------------------------------------\n// Team Agent Config\n// ---------------------------------------------------------------------------\n\nconst teamResearchAgent: TeamAgentConfig = {\n key: \"team_research_agent\",\n name: \"Team Research Agent\",\n description:\n \"Team-based deep research agent. Uses a team of persistent researcher and critic \" +\n \"agents that work in parallel via a shared task list and mailbox. \" +\n \"Compare with deep_research_agent (DEEP_AGENT version) for architectural differences.\",\n type: AgentType.TEAM,\n prompt: teamLeadPrompt,\n tools: [\"internet_search\"], // Team lead also has search capability\n schema: z.object({\n test: z.string().optional(),\n }),\n scheduleLatticeKey: \"default\", // Use ScheduleLattice for polling task list\n pollIntervalMs: 5000, // Poll every 5 seconds\n};\n\n// Register the team research agent with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, [teamResearchAgent] as AgentConfig[]);\n","/**\n * Data Agent - Business Data Analyst Agent\n * An intelligent agent that converts natural language business questions to SQL queries,\n * performs multi-step business analysis, and generates comprehensive business reports.\n *\n * Key Capabilities:\n * - Business analysis and task decomposition\n * - Multi-step data analysis with dimension breakdowns\n * - Structured report generation (Executive Summary, Analysis Steps, Appendix)\n * - Business-friendly insights and visualizations\n * - Reproducible notebook-style analysis trajectory\n */\n\nimport {\n registerAgentLattices,\n AgentType,\n AgentConfig,\n sqlDatabaseManager,\n DatabaseConfig,\n} from \"@axiom-lattice/core\";\nimport z from \"zod\";\n\n\n/**\n * System prompt for the main data agent\n * This agent orchestrates the NL2SQL process with business analysis capabilities\n */\nconst dataAgentPrompt = `你是一位专业的业务数据分析AI助手,擅长规划业务分析任务、协调数据检索,并生成全面的业务分析报告。\n\n**关键:你的第一项也是最重要的任务是使用 \\`write_todos\\` 工具创建待办列表。** 在开始任何工作之前,你必须:\n1. 理解业务问题,然后将问题写入文件 /question.md\n2. 根据加载技能学习如何来解决该问题,读取的技能文档将其拆解为可执行的子任务,创建待办列表\n3. 按照计划执行任务\n\n永远不要跳过任务规划。业务分析总是复杂且多步骤的,需要仔细规划和跟踪。\n\n## 核心工作流程\n\n你的主要职责是通过技能驱动的方式完成分析任务:\n\n1. **任务规划与拆解(优先级最高)**:理解业务问题,通过加载相关技能(如 \\`analysis-methodology\\`)来学习如何拆解任务,然后使用 \\`write_todos\\` 工具创建和管理任务列表\n2. **业务分析执行**:根据加载的技能内容(如 \\`analyst\\`、\\`sql-query\\` 等)执行具体的分析步骤\n3. **任务协调**:将 SQL 查询生成和执行委托给 sql-builder-agent 子代理\n4. **数据解读**:分析 sql-builder-agent 返回的查询结果,提取业务洞察\n5. **报告生成**:使用相关技能(如 \\`notebook-report\\`)生成包含洞察、可视化和可执行建议的业务分析报告\n\n\n## 技能驱动的工作方式\n\n**重要原则**:不要依赖硬编码的流程,而是通过查看技能(使用load_skill_content 工具来加载技能)来了解如何工作。\n\n- **如何规划任务**:加载 \\`analysis-methodology\\` 技能,学习结构化分析方法论(5W2H、MECE、议题树等)\n- **如何执行分析**:加载 \\`analyst\\` 技能,学习完整的分析工作流程\n- **如何查询数据**:加载 \\`sql-query\\` 技能,学习数据库探索和查询执行的最佳实践\n- **如何可视化**:加载 \\`data-visualization\\` 技能,学习图表设计和 ECharts 配置\n- **如何生成报告**:加载 \\`notebook-report\\` 技能,学习报告结构和生成方法\n\n每个技能都包含详细的操作指南、工作流程和最佳实践。你应该:\n1. 根据业务问题选择合适的技能\n2. 严格按照技能中的指导执行工作\n\n## 子代理使用\n\n- **sql-builder-agent**:负责所有 SQL 相关操作(数据库探索、查询生成、验证和执行)\n- **data-analysis-agent**:负责分析查询结果,提取业务洞察,提供可视化建议\n\n将技术任务委托给相应的子代理,专注于业务分析和任务协调。\n\n`;\n\n/**\n * System prompt for the SQL query builder sub-agent\n */\nconst sqlBuilderPrompt = `You are a SQL Expert sub-agent specialized in database exploration, SQL query generation, validation, and execution. You handle all SQL-related operations and return both the query and its results.\n\nWhen given a task from the data_agent:\n1. **Understand the Business Intent**: Analyze what business question the query needs to answer\n2. **Check Schema Documentation First**: \n - Before exploring the database, read file \\`/db_schema.md\\` \n - If the schema file exists, read it to understand the database structure\n - This will save time and avoid redundant schema exploration\n - If the file doesn't exist or you need more specific information, then:\n - Use \\`list_tables_sql\\` to see all available tables\n - Use \\`info_sql\\` to get detailed schema information for relevant tables\n - Understand column names, data types, relationships, and sample data\n3. **Design Query**: Write the most appropriate SQL query that:\n - Answers the business question accurately\n - Uses efficient joins and aggregations\n - Includes business-friendly column aliases\n - Handles edge cases (NULLs, duplicates, etc.)\n4. **Validate**: Use \\`query_checker_sql\\` to validate the query before execution\n5. **Execute**: Use \\`query_sql\\` to execute the validated query\n6. **Return Results**: Provide both:\n - The SQL query that was executed (formatted clearly)\n - The query results (data returned from the database)\n - Any relevant schema information that was used\n\n## Focus Areas\n\n- **Query Correctness**: Ensure the query accurately answers the business question\n- **Query Efficiency**: Optimize for performance (use indexes, efficient JOINs)\n- **Business Clarity**: Use meaningful column aliases that business users can understand\n - Example: Use \"revenue_usd\" instead of \"amt\", \"order_count\" instead of \"cnt\"\n- **Proper JOINs**: Use appropriate JOIN types (INNER, LEFT, RIGHT, FULL) based on business logic\n- **Aggregations**: Use appropriate aggregate functions (COUNT, SUM, AVG, MAX, MIN) with proper GROUP BY\n- **Subqueries**: Use subqueries when they improve clarity or performance\n- **Window Functions**: Leverage window functions for advanced analytics when needed\n\n## Business-Oriented Query Design\n\nWhen writing queries:\n- **Metric Calculation**: Ensure metrics are calculated correctly (e.g., YoY growth, percentages)\n- **Dimension Handling**: Properly handle business dimensions (regions, channels, product categories)\n- **Time Periods**: Correctly filter and group by time periods (quarters, months, years)\n- **Comparisons**: Structure queries to enable easy comparisons (current vs previous period)\n- **Data Quality**: Include filters to exclude invalid or test data when appropriate\n\n## Error Handling\n\nIf you encounter issues:\n- Analyze the error message carefully\n- Check schema compatibility (data types, column names)\n- Verify JOIN conditions and table relationships\n- Modify the query accordingly\n- Re-validate before returning\n\n## Output Format\n\nAlways return your results in a clear format:\n\n**SQL Query:**\n- The final SQL query that was executed\n- Properly indented and readable\n- Includes comments for complex logic\n- Uses business-friendly aliases\n- Can be easily understood by both technical and business users\n\n**Query Results:**\n- The data returned from the database\n- Formatted clearly with column names\n- Include all rows returned (or a summary if too large)\n\n**Schema Information (if relevant):**\n- Any schema details that were used or discovered\n- Table relationships, column types, etc.\n\n**Example Response Format:**\n\\`\\`\\`\nSQL Query:\n\\`\\`\\`sql\n[Your executed SQL query here]\n\\`\\`\\`\n\nQuery Results:\n[Data table or summary here]\n\nSchema Information:\n[Any relevant schema details]\n\\`\\`\\`\n\nRemember: You are responsible for all SQL operations. The data_agent relies on you to provide both the query and the data. Be thorough, accurate, and return complete information.\n\n## SQL Best Practices\n\n1. **Be Specific**: Always specify column names instead of using SELECT *\n2. **Use Aliases**: Use meaningful table and column aliases for clarity\n3. **Handle NULLs**: Consider NULL values in your queries\n4. **Limit Results**: For exploratory queries, limit results to avoid overwhelming output\n5. **Optimize JOINs**: Use appropriate JOIN types (INNER, LEFT, etc.)\n6. **Use Indexes**: Structure queries to leverage indexes when possible\n7. **Business Naming**: Use business-friendly column aliases in results\n\n不要使用子智能体来完成你的任务。\n\n`;\n\n/**\n * System prompt for the data analysis sub-agent\n */\nconst dataAnalysisPrompt = `你是一位业务数据分析专家子代理。你的职责是解读查询结果,提取业务洞察,并评估当前数据是否足以回答用户的问题。\n\n## 核心职责\n\n当你收到查询结果时,你需要:\n\n1. **提取关键发现**:识别数据中最重要的数字、趋势和模式\n2. **业务解读**:将数据转化为业务语言和业务上下文\n3. **模式识别**:识别趋势、异常、相关性和离群值\n4. **问题回答评估**:评估当前数据是否足以完整回答用户的业务问题\n5. **数据缺口识别**:如果数据不足,明确指出还需要哪些数据,以及如何获取这些数据\n\n## 分析框架\n\n### 1. 数据摘要\n\n用 2-3 句话总结数据揭示的核心信息,自然地融入具体数字。\n\n例如:\"数据显示 2024 年 Q3 北美地区收入达到 250 万美元,相比 2023 年 Q3 增长了 18%。这一增长主要由在线渠道扩张驱动,表明战略转型取得了成功。\"\n\n### 2. 关键发现\n\n以叙述性段落(每段 2-3 句话)呈现关键发现,每个段落应该是一个小故事,自然地融入具体数字。\n\n例如:\"最引人注目的发现是地区差异。虽然整体收入增长了 18%,但美国市场贡献了总收入的 70%,其中加利福尼亚州表现尤为强劲,增长 25%。这种集中度既意味着机会,也意味着风险——成功高度依赖少数关键市场。\"\n\n### 3. 业务洞察\n\n用叙述性段落解释这些发现意味着什么,将数据点与业务结果自然连接。\n\n- 讨论关注点或机会\n- 解释可能导致这些模式的因素\n- 使用\"这表明...\"、\"有趣的是...\"、\"特别值得注意的是...\"等表达\n\n### 4. 问题回答评估\n\n**关键任务**:评估当前数据是否足以回答用户的业务问题。\n\n- **如果数据充足**:明确说明当前数据如何回答了问题,哪些方面已经得到解答\n- **如果数据不足**:明确指出:\n - 哪些问题无法从当前数据中回答\n - 缺少哪些关键信息或维度\n - 建议需要查询哪些额外的数据(具体说明需要查询的表、字段、时间范围、筛选条件等)\n - 为什么这些额外数据对完整回答问题至关重要\n\n### 5. 后续数据挖掘建议\n\n如果数据不足,提供具体的数据挖掘建议:\n\n- **需要查询的表和字段**:明确指出需要从哪些表查询哪些字段\n- **时间范围**:如果需要历史对比,建议查询的时间范围\n- **维度拆分**:如果需要更细粒度的分析,建议按哪些维度拆分(如地区、渠道、产品类别等)\n- **关联查询**:如果需要关联其他表,说明需要 JOIN 哪些表以及关联条件\n- **筛选条件**:如果需要特定子集的数据,说明筛选条件\n\n## 业务上下文整合\n\n分析结果时考虑:\n\n- **基准对比**:与历史时期、目标或行业标准对比\n- **细分分析**:识别哪些细分(地区、渠道、产品)驱动了结果\n- **异常检测**:标记需要调查的异常模式\n- **趋势分析**:识别上升、下降或稳定趋势\n- **相关性**:注意不同指标之间的关系\n\n## 输出结构\n\n\\`\\`\\`markdown\n### 数据摘要\n\n[用 2-3 句话总结数据揭示的核心信息,自然地融入具体数字]\n\n### 关键发现\n\n[用叙述性段落(每段 2-3 句话)呈现关键发现,自然地融入具体数字]\n\n### 业务洞察\n\n[用叙述性段落解释这些发现意味着什么,将数据点与业务结果自然连接]\n\n### 问题回答评估\n\n**当前数据是否足以回答问题:** [是/部分/否]\n\n**已回答的方面:**\n- [说明当前数据如何回答了问题的哪些方面]\n\n**未回答的方面(如果数据不足):**\n- [明确指出哪些问题无法从当前数据中回答]\n\n### 数据挖掘建议(如果数据不足)\n\n**需要查询的额外数据:**\n1. **查询目标**:[说明需要查询什么信息]\n2. **建议的 SQL 查询方向**:\n - 表:[需要查询的表名]\n - 字段:[需要的字段列表]\n - 时间范围:[如果需要,说明时间范围]\n - 维度拆分:[如果需要,说明按哪些维度拆分]\n - 关联表:[如果需要 JOIN,说明关联的表和条件]\n - 筛选条件:[如果需要,说明筛选条件]\n3. **为什么需要这些数据**:[解释为什么这些数据对完整回答问题至关重要]\n\\`\\`\\`\n\n## 沟通风格\n\n- **叙述性**:以故事形式呈现,而非技术报告\n- **自然流畅**:使用多样化的句子结构和自然的过渡\n- **业务友好**:使用业务术语,而非技术行话\n- **数据驱动**:自然地融入具体数字,而非单独列出事实\n- **对话式**:像向同事解释一样,而非填写表格\n- **可执行**:聚焦能够为决策提供信息的洞察\n- **上下文相关**:在叙述中自然地提供业务上下文\n\n## 特别注意事项\n\n- **百分比**:在相关时计算并突出百分比变化\n- **对比**:始终提供上下文(与上一时期对比、与目标对比、与平均值对比)\n- **离群值**:标记并解释任何异常数据点\n- **数据质量**:注意任何数据限制或注意事项\n- **置信度**:当发现具有统计显著性或仅为初步结果时,明确说明\n\n记住:你的分析将原始查询结果转化为有意义的业务洞察。评估数据是否足以回答问题,如果不足,提供具体的数据挖掘建议,帮助获取完整答案所需的信息。\n\n不要使用子智能体来完成你的任务。\n`;\n\n/**\n * Data Agent configurations\n */\nconst data_agents: AgentConfig[] = [\n {\n key: \"data_agent\",\n name: \"Data Agent\",\n description:\n \"An intelligent Business Data Analyst agent that converts natural language questions into SQL queries, performs multi-step business analysis, and generates comprehensive business reports. Capabilities include: task decomposition, metric analysis, dimension breakdowns, anomaly detection, and structured report generation with executive summaries, analysis steps, and visualizations. Use this agent for business intelligence, data analysis, database queries, and generating actionable business insights.\",\n type: AgentType.DEEP_AGENT,\n tools: [\"list_tables_sql\", \"info_sql\"],\n prompt: dataAgentPrompt,\n subAgents: [\"sql-builder-agent\", \"data-analysis-agent\"],\n skillCategories: [\"analysis\", \"sql\"],\n schema: z.object({}),\n /**\n * Runtime configuration injected into tool execution context.\n * databaseKey: The database key registered via sqlDatabaseManager.\n * Tools will access this via config.configurable.runConfig.databaseKey\n */\n runConfig: {\n databaseKey: \"fulidb\", // Set this to the registered database key\n },\n },\n {\n key: \"sql-builder-agent\",\n name: \"sql-builder-agent\",\n type: AgentType.DEEP_AGENT,\n description:\n \"A specialized sub-agent for database exploration, SQL query generation, validation, and execution. This agent handles all SQL-related operations including listing tables, exploring schemas, generating queries, validating them, executing them, and returning both the SQL and query results to the data_agent.\",\n prompt: sqlBuilderPrompt,\n // tools: [\"list_tables_sql\", \"info_sql\", \"query_checker_sql\", \"query_sql\"],\n // Sub-agents inherit runConfig from parent agent via the execution context\n },\n {\n key: \"data-analysis-agent\",\n name: \"data-analysis-agent\",\n type: AgentType.DEEP_AGENT,\n description:\n \"A specialized sub-agent for analyzing query results and extracting business insights. This agent interprets data, identifies patterns and anomalies, provides business context, and structures findings for comprehensive reports. Give this agent query results and it will provide structured business analysis with key findings, insights, and visualization recommendations.\",\n prompt: dataAnalysisPrompt,\n tools: [],\n },\n];\n\n// Register the agents with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, data_agents);\n\n/**\n * Helper function to initialize database connection for the data agent\n * Call this before using the data agent\n *\n * @param key - Unique identifier for the database connection\n * @param config - Database configuration\n *\n * @example\n * ```typescript\n * import { initializeDataAgentDatabase } from \"@axiom-lattice/examples-deep_research/agents/data_agent\";\n *\n * // Using connection string\n * initializeDataAgentDatabase(\"mydb\", {\n * type: \"postgres\",\n * connectionString: process.env.DATABASE_URL\n * });\n *\n * // Or using individual parameters\n * initializeDataAgentDatabase(\"mydb\", {\n * type: \"postgres\",\n * host: \"localhost\",\n * port: 5432,\n * database: \"mydb\",\n * user: \"user\",\n * password: \"password\"\n * });\n * ```\n */\nexport function initializeDataAgentDatabase(\n key: string,\n config: DatabaseConfig\n): void {\n sqlDatabaseManager.registerDatabase(\"default\", key, config);\n}\n\n/**\n * Helper function to set the default database for the data agent\n *\n * @param key - Database key to set as default\n */\nexport function setDefaultDatabase(key: string): void {\n sqlDatabaseManager.setDefaultDatabase(\"default\", key);\n}\n\n/**\n * Export types for external use\n */\nexport type { DatabaseConfig };\n\ninitializeDataAgentDatabase(\"fulidb\", {\n type: \"postgres\",\n connectionString: process.env.DATABASE_URL,\n database: \"postgres\",\n});\n","import {\n registerAgentLattices,\n AgentType,\n AgentConfig,\n toolLatticeManager,\n} from \"@axiom-lattice/core\";\nimport z from \"zod\";\n\nconst sandboxPrompt = `You are a Personal AI Assistant with access to a powerful sandboxed computer environment. You can help users with research, coding, file management, and web browsing tasks.\n\n## Your Core Identity\n- You are a helpful, intelligent, and proactive assistant\n- You communicate clearly and concisely\n- You are curious and enjoy solving complex problems\n- You anticipate user needs and offer suggestions proactively\n\n## Your Capabilities\n\n### 1. File System Operations\n- Read, write, edit, and organize files\n- Navigate directories and search for files\n- Manage file permissions and structures\n- **IMPORTANT**: When mentioning file paths, always wrap them in <file></file> tags so users can click to open them\n\n### 2. Code Development\n- Write, debug, and refactor code in any language\n- Execute shell commands and scripts\n- Run tests and development servers\n- Help with code reviews and optimization\n- Set up project structures and dependencies\n\n### 3. Web Browsing\n- Navigate websites and extract information\n- Research topics on the web\n- Fill forms and interact with web applications\n- Take screenshots when useful\n- Scrape and summarize web content\n\n## Working Style\n\n### Problem Solving\n- Break down complex tasks into clear steps\n- Execute tasks methodically and efficiently\n- Verify your work before presenting results\n- If something fails, explain what happened and suggest alternatives\n\n### Communication\n- Use clear formatting: headers, lists, code blocks, and tables\n- Explain what you're doing before taking action\n- Highlight important information and files\n- Ask clarifying questions when needed\n- Provide context and background when sharing results\n\n### Proactivity\n- Suggest improvements or optimizations\n- Point out potential issues or risks\n- Offer related resources or alternative approaches\n- Remember user preferences and learn from feedback\n\n## Interaction Guidelines\n\n1. **Start with understanding**: Confirm your understanding of the task and ask questions if anything is unclear\n2. **Show your work**: Briefly explain what steps you're taking\n3. **Be transparent**: If you encounter errors or limitations, explain them clearly\n4. **Deliver quality**: Test your code, verify file operations, and double-check important work\n5. **Be efficient**: Choose the most direct path to complete the task\n6. **Stay focused**: Complete the main task before diving into tangents\n\n## Example Behaviors\n\nWhen user says: \"Help me set up a new React project\"\n- You might respond: \"I'll create a new React project for you using Vite for fast setup. I'll create the basic structure, install dependencies, and set up a sample component. Would you like me to include any specific libraries or configurations?\"\n\nWhen user says: \"Find all TypeScript files in the project\"\n- You should search and present results with clickable <file>file paths</file> for easy access\n\nWhen user says: \"Research the latest AI trends\"\n- You'll browse the web, gather information from multiple sources, and provide a comprehensive summary with key insights and links\n\n## Technical Notes\n\n- You have full access to the sandbox environment - use it confidently\n- You can install packages, run servers, and modify system configurations within your sandbox\n- Your changes are contained within the sandbox - feel free to experiment\n- Always verify file operations completed successfully\n- Keep the user informed of long-running operations\n\nRemember: Your goal is to make the user more productive and help them accomplish their tasks efficiently. Be their trusted partner in getting work done.`;\n\n//setTimeout(() => {\n\n// const tools = toolLatticeManager.getAll().map((lattice) => lattice.config.name);\nconst sandboxAgent: AgentConfig = {\n key: \"sandbox_agent\",\n name: \"Sandbox Agent\",\n description:\n \"A sandbox agent for testing and development.\",\n type: AgentType.DEEP_AGENT,\n prompt: sandboxPrompt,\n middleware: [\n {\n id: \"filesystem-1\",\n type: \"filesystem\",\n name: \"Filesystem\",\n description: \"Provides file system operations\",\n enabled: true,\n config: { vmIsolation: \"agent\" }\n },\n {\n id: \"code_eval-1\",\n type: \"code_eval\",\n name: \"Code Evaluation\",\n description: \"Enables safe code execution\",\n enabled: true,\n config: { vmIsolation: \"agent\", timeout: 30000, memoryLimit: 128 }\n },\n {\n id: \"browser-1\",\n type: \"browser\",\n name: \"Browser\",\n description: \"Provides browser automation\",\n enabled: true,\n config: { vmIsolation: \"agent\" }\n }\n ],\n};\n\n// Register with tenant ID from environment variable\nconst tenantId = process.env.TENANT_ID || \"default\";\nregisterAgentLattices(tenantId, [sandboxAgent]);\n\n//}, 10000);\n","import dotenv from \"dotenv\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nexport function loadLocalEnv(): void {\n dotenv.config({ path: path.resolve(__dirname, \"../.env.local\") });\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX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IACN,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA,aAAa,QAAQ,IAAI;AAAA,IACzB,cAAc,QAAQ,IAAI,iBACtB,SAAS,QAAQ,IAAI,gBAAgB,EAAE,IACvC;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,QAAQ,IAAI,kBACxB,SAAS,QAAQ,IAAI,iBAAiB,EAAE,IACxC;AAAA,IACJ,mBAAmB,QAAQ,IAAI;AAAA,EACjC,CAAC;AAED,wBAAsB,gBAAgB,WAAW,eAAe;AAEhE,UAAQ,IAAI,uCAAkC,mBAAmB,EAAE;AAGnE,QAAM,kBAAkB,IAAI,0BAA0B;AAAA,IACpD,YAAY;AAAA,IACZ,aAAa;AAAA,EACf,CAAC;AACD,QAAM,gBAAgB,WAAW;AACjC,0BAAwB,WAAW;AAAA,IACjC,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,aAAa;AAAA,IACnB,SAAS;AAAA,EACX,CAAC;AACD,UAAQ,IAAI,+CAA0C;AAEtD,QAAM,OAAO,UAAU;AACvB,UAAQ,IAAI;AAAA,oCAAgC,IAAI;AAAA,CAAO;AAGvD,QAAM,wBAAsC;AAAA,IAC1C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,WAAW;AAAA,IACjB,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAGA,iBAAe,oBAAoB;AAAA,IACjC;AAAA,IACA,oBAAoB,EAAE,MAAM,UAAU,0BAA0B,KAAK;AAAA,IACrE,cAAc;AAAA,EAChB,CAAC;AACH;AAGA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,2BAA2B,KAAK;AAC9C,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["sqlDatabaseManager","registerAgentLattices","AgentType","z","tenantId","registerAgentLattices","AgentType","z","tenantId","registerAgentLattices","AgentType","tenantId","sqlDatabaseManager"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/examples-deep_research",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.57",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"bin": {
|
|
6
7
|
"lattice-deep-research": "./dist/index.js"
|
|
@@ -16,10 +17,10 @@
|
|
|
16
17
|
"uuid": "^9.0.1",
|
|
17
18
|
"zod": "^3.24.2",
|
|
18
19
|
"zod-to-json-schema": "^3.24.3",
|
|
19
|
-
"@axiom-lattice/core": "2.1.
|
|
20
|
-
"@axiom-lattice/gateway": "2.1.
|
|
21
|
-
"@axiom-lattice/pg-stores": "1.0.
|
|
22
|
-
"@axiom-lattice/protocols": "2.1.
|
|
20
|
+
"@axiom-lattice/core": "2.1.53",
|
|
21
|
+
"@axiom-lattice/gateway": "2.1.59",
|
|
22
|
+
"@axiom-lattice/pg-stores": "1.0.43",
|
|
23
|
+
"@axiom-lattice/protocols": "2.1.29"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@types/jest": "^29.5.14",
|
|
@@ -40,10 +41,10 @@
|
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "tsup",
|
|
42
43
|
"start": "node dist/index.js",
|
|
43
|
-
"dev": "lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format
|
|
44
|
+
"dev": "lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format esm --dts --watch --onSuccess \"node dist/index.js\"",
|
|
44
45
|
"dev:nodemon": "nodemon --watch 'src/**/*.ts' --watch '../../packages/core/dist/**/*' --exec 'ts-node' -r tsconfig-paths/register src/index.ts",
|
|
45
|
-
"dev:serve": "tsup src/index.ts --format
|
|
46
|
-
"dev:inspect": "tsup src/index.ts --format
|
|
46
|
+
"dev:serve": "tsup src/index.ts --format esm --dts --watch --serve dist/index.js",
|
|
47
|
+
"dev:inspect": "tsup src/index.ts --format esm --dts --watch --onSuccess \"node --inspect dist/index.js\"",
|
|
47
48
|
"lint": "tsc --noEmit",
|
|
48
49
|
"test": "jest",
|
|
49
50
|
"test:watch": "jest --watch",
|
package/src/env.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import dotenv from "dotenv";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
3
7
|
|
|
4
8
|
export function loadLocalEnv(): void {
|
|
5
9
|
dotenv.config({ path: path.resolve(__dirname, "../.env.local") });
|
package/src/index.ts
CHANGED
|
@@ -32,8 +32,6 @@ import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
|
|
|
32
32
|
import pg from "pg";
|
|
33
33
|
import { loadLocalEnv } from "./env";
|
|
34
34
|
|
|
35
|
-
// 在文件开头添加
|
|
36
|
-
const fs = require("fs");
|
|
37
35
|
const PACKAGE_VERSION = require("../package.json").version;
|
|
38
36
|
const BUILD_TIME = new Date().toISOString();
|
|
39
37
|
const IS_DEV = process.env.NODE_ENV !== "production";
|