@axiom-lattice/examples-deep_research 1.0.78 → 1.0.80
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/CHANGELOG.md +16 -0
- package/package.json +4 -4
- package/.turbo/turbo-build.log +0 -17
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2040
- package/dist/index.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,2040 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
4
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// package.json
|
|
8
|
-
var require_package = __commonJS({
|
|
9
|
-
"package.json"(exports, module) {
|
|
10
|
-
module.exports = {
|
|
11
|
-
name: "@axiom-lattice/examples-deep_research",
|
|
12
|
-
version: "1.0.78",
|
|
13
|
-
type: "module",
|
|
14
|
-
main: "dist/index.js",
|
|
15
|
-
bin: {
|
|
16
|
-
"lattice-deep-research": "./dist/index.js"
|
|
17
|
-
},
|
|
18
|
-
scripts: {
|
|
19
|
-
build: "tsup",
|
|
20
|
-
start: "node dist/index.js",
|
|
21
|
-
dev: 'lsof -ti:4001 | xargs kill -9 && tsup src/index.ts --format esm --dts --watch --onSuccess "node dist/index.js"',
|
|
22
|
-
"dev:nodemon": "nodemon --watch 'src/**/*.ts' --watch '../../packages/core/dist/**/*' --exec 'ts-node' -r tsconfig-paths/register src/index.ts",
|
|
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"',
|
|
25
|
-
lint: "tsc --noEmit",
|
|
26
|
-
test: "jest",
|
|
27
|
-
"test:watch": "jest --watch",
|
|
28
|
-
"test:coverage": "jest --coverage"
|
|
29
|
-
},
|
|
30
|
-
keywords: [],
|
|
31
|
-
author: "",
|
|
32
|
-
license: "ISC",
|
|
33
|
-
description: "Deep Research Server for Axiom Lattice",
|
|
34
|
-
dependencies: {
|
|
35
|
-
"@axiom-lattice/core": "workspace:*",
|
|
36
|
-
"@axiom-lattice/gateway": "workspace:*",
|
|
37
|
-
"@axiom-lattice/pg-stores": "workspace:*",
|
|
38
|
-
"@axiom-lattice/protocols": "workspace:*",
|
|
39
|
-
"@langchain/langgraph-checkpoint-postgres": "^1.0.0",
|
|
40
|
-
dotenv: "^16.6.1",
|
|
41
|
-
pg: "^8.20.0",
|
|
42
|
-
uuid: "^9.0.1",
|
|
43
|
-
zod: "^3.24.2",
|
|
44
|
-
"zod-to-json-schema": "^3.24.3"
|
|
45
|
-
},
|
|
46
|
-
devDependencies: {
|
|
47
|
-
"@types/jest": "^29.5.14",
|
|
48
|
-
"@types/lodash": "^4.17.16",
|
|
49
|
-
"@types/node": "^20.17.23",
|
|
50
|
-
"@types/pg": "^8.20.0",
|
|
51
|
-
"@types/uuid": "^9.0.8",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
53
|
-
"@typescript-eslint/parser": "^7.2.0",
|
|
54
|
-
eslint: "^8.57.0",
|
|
55
|
-
jest: "^29.7.0",
|
|
56
|
-
nodemon: "^3.1.9",
|
|
57
|
-
"ts-jest": "^29.4.0",
|
|
58
|
-
"ts-node": "^10.9.2",
|
|
59
|
-
tsup: "^8.5.0",
|
|
60
|
-
typescript: "^5.8.2"
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// src/index.ts
|
|
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";
|
|
80
|
-
|
|
81
|
-
// src/agents/research/index.ts
|
|
82
|
-
import {
|
|
83
|
-
registerAgentLattices,
|
|
84
|
-
AgentType
|
|
85
|
-
} from "@axiom-lattice/core";
|
|
86
|
-
import z from "zod";
|
|
87
|
-
var subResearchPrompt = `You are a dedicated researcher. Your job is to conduct research based on the users questions.
|
|
88
|
-
|
|
89
|
-
Conduct thorough research and then reply to the user with a detailed answer to their question
|
|
90
|
-
|
|
91
|
-
only 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!`;
|
|
92
|
-
var subCritiquePrompt = `You are a dedicated editor. You are being tasked to critique a report.
|
|
93
|
-
|
|
94
|
-
You can find the report at \`final_report.md\`.
|
|
95
|
-
|
|
96
|
-
You can find the question/topic for this report at \`question.txt\`.
|
|
97
|
-
|
|
98
|
-
The 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.
|
|
99
|
-
|
|
100
|
-
You can use the search tool to search for information, if that will help you critique the report
|
|
101
|
-
|
|
102
|
-
Do not write to the \`final_report.md\` yourself.
|
|
103
|
-
|
|
104
|
-
Things to check:
|
|
105
|
-
- Check that each section is appropriately named
|
|
106
|
-
- 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!
|
|
107
|
-
- Check that the report is comprehensive. If any paragraphs or sections are short, or missing important details, point it out.
|
|
108
|
-
- Check that the article covers key areas of the industry, ensures overall understanding, and does not omit important parts.
|
|
109
|
-
- Check that the article deeply analyzes causes, impacts, and trends, providing valuable insights
|
|
110
|
-
- Check that the article closely follows the research topic and directly answers questions
|
|
111
|
-
- Check that the article has a clear structure, fluent language, and is easy to understand.
|
|
112
|
-
`;
|
|
113
|
-
var researchInstructions = `You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.
|
|
114
|
-
|
|
115
|
-
The first thing you should do is to write the original user question to \`question.txt\` so you have a record of it.
|
|
116
|
-
|
|
117
|
-
Use the research-agent to conduct deep research. It will respond to your questions/topics with a detailed answer.
|
|
118
|
-
|
|
119
|
-
When you think you enough information to write a final report, write it to \`final_report.md\`
|
|
120
|
-
|
|
121
|
-
You 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\`
|
|
122
|
-
You can do this however many times you want until are you satisfied with the result.
|
|
123
|
-
|
|
124
|
-
Only edit the file once at a time (if you call this tool in parallel, there may be conflicts).
|
|
125
|
-
|
|
126
|
-
Here are instructions for writing the final report:
|
|
127
|
-
|
|
128
|
-
<report_instructions>
|
|
129
|
-
|
|
130
|
-
CRITICAL: 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!
|
|
131
|
-
Note: the language the report should be in is the language the QUESTION is in, not the language/country that the question is ABOUT.
|
|
132
|
-
|
|
133
|
-
Please create a detailed answer to the overall research brief that:
|
|
134
|
-
1. Is well-organized with proper headings (# for title, ## for sections, ### for subsections)
|
|
135
|
-
2. Includes specific facts and insights from the research
|
|
136
|
-
3. References relevant sources using [Title](URL) format
|
|
137
|
-
4. 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.
|
|
138
|
-
5. Includes a "Sources" section at the end with all referenced links
|
|
139
|
-
|
|
140
|
-
You can structure your report in a number of different ways. Here are some examples:
|
|
141
|
-
|
|
142
|
-
To answer a question that asks you to compare two things, you might structure your report like this:
|
|
143
|
-
1/ intro
|
|
144
|
-
2/ overview of topic A
|
|
145
|
-
3/ overview of topic B
|
|
146
|
-
4/ comparison between A and B
|
|
147
|
-
5/ conclusion
|
|
148
|
-
|
|
149
|
-
To answer a question that asks you to return a list of things, you might only need a single section which is the entire list.
|
|
150
|
-
1/ list of things or table of things
|
|
151
|
-
Or, 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.
|
|
152
|
-
1/ item 1
|
|
153
|
-
2/ item 2
|
|
154
|
-
3/ item 3
|
|
155
|
-
|
|
156
|
-
To answer a question that asks you to summarize a topic, give a report, or give an overview, you might structure your report like this:
|
|
157
|
-
1/ overview of topic
|
|
158
|
-
2/ concept 1
|
|
159
|
-
3/ concept 2
|
|
160
|
-
4/ concept 3
|
|
161
|
-
5/ conclusion
|
|
162
|
-
|
|
163
|
-
If you think you can answer the question with a single section, you can do that too!
|
|
164
|
-
1/ answer
|
|
165
|
-
|
|
166
|
-
REMEMBER: 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!
|
|
167
|
-
Make sure that your sections are cohesive, and make sense for the reader.
|
|
168
|
-
|
|
169
|
-
For each section of the report, do the following:
|
|
170
|
-
- Use simple, clear language
|
|
171
|
-
- Use ## for section title (Markdown format) for each section of the report
|
|
172
|
-
- Do NOT ever refer to yourself as the writer of the report. This should be a professional report without any self-referential language.
|
|
173
|
-
- Do not say what you are doing in the report. Just write the report without any commentary from yourself.
|
|
174
|
-
- 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.
|
|
175
|
-
- Use bullet points to list out information when appropriate, but by default, write in paragraph form.
|
|
176
|
-
|
|
177
|
-
REMEMBER:
|
|
178
|
-
The brief and research may be in English, but you need to translate this information to the right language when writing the final answer.
|
|
179
|
-
Make sure the final answer report is in the SAME language as the human messages in the message history.
|
|
180
|
-
|
|
181
|
-
Format the report in clear markdown with proper structure and include source references where appropriate.
|
|
182
|
-
|
|
183
|
-
<Citation Rules>
|
|
184
|
-
- Assign each unique URL a single citation number in your text
|
|
185
|
-
- End with ### Sources that lists each source with corresponding numbers
|
|
186
|
-
- IMPORTANT: Number sources sequentially without gaps (1,2,3,4...) in the final list regardless of which sources you choose
|
|
187
|
-
- Each source should be a separate line item in a list, so that in markdown it is rendered as a list.
|
|
188
|
-
- Example format:
|
|
189
|
-
[1] Source Title: URL
|
|
190
|
-
[2] Source Title: URL
|
|
191
|
-
- 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.
|
|
192
|
-
</Citation Rules>
|
|
193
|
-
</report_instructions>
|
|
194
|
-
|
|
195
|
-
You have access to a few tools.
|
|
196
|
-
|
|
197
|
-
## \`internet_search\`
|
|
198
|
-
|
|
199
|
-
Use 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.
|
|
200
|
-
`;
|
|
201
|
-
var research_agents = [
|
|
202
|
-
{
|
|
203
|
-
key: "deep_research_agent",
|
|
204
|
-
name: "Deep Research Agent",
|
|
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.",
|
|
206
|
-
type: AgentType.DEEP_AGENT,
|
|
207
|
-
tools: ["internet_search"],
|
|
208
|
-
prompt: researchInstructions,
|
|
209
|
-
subAgents: ["critique-agent", "research-agent"],
|
|
210
|
-
schema: z.object({
|
|
211
|
-
test: z.string().optional()
|
|
212
|
-
})
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
key: "research-agent",
|
|
216
|
-
name: "research-agent",
|
|
217
|
-
type: AgentType.REACT,
|
|
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.",
|
|
219
|
-
prompt: subResearchPrompt,
|
|
220
|
-
tools: ["internet_search"]
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
key: "critique-agent",
|
|
224
|
-
name: "critique-agent",
|
|
225
|
-
type: AgentType.REACT,
|
|
226
|
-
description: "Used to critique the final report. Give this agent some infomration about how you want it to critique the report.",
|
|
227
|
-
prompt: subCritiquePrompt
|
|
228
|
-
}
|
|
229
|
-
];
|
|
230
|
-
var tenantId = process.env.TENANT_ID || "default";
|
|
231
|
-
registerAgentLattices(tenantId, research_agents);
|
|
232
|
-
|
|
233
|
-
// src/agents/research_team/index.ts
|
|
234
|
-
import {
|
|
235
|
-
registerAgentLattices as registerAgentLattices2,
|
|
236
|
-
AgentType as AgentType2
|
|
237
|
-
} from "@axiom-lattice/core";
|
|
238
|
-
import z2 from "zod";
|
|
239
|
-
var teamLeadPrompt = `You are an expert research team lead. You coordinate a team of specialized agents to produce a thorough, polished research report.
|
|
240
|
-
|
|
241
|
-
## Workflow
|
|
242
|
-
|
|
243
|
-
1. When given a research topic, break it down into concrete research tasks:
|
|
244
|
-
- Multiple focused research sub-topics (assign to "researcher" teammates)
|
|
245
|
-
- A final critique pass (assign to "critic" teammate)
|
|
246
|
-
- A writing/synthesis task (you will handle this yourself after research is done)
|
|
247
|
-
|
|
248
|
-
2. Call \`create_team\` with the initial tasks and teammates. Tasks can have dependencies (e.g. critique depends on all research tasks completing).
|
|
249
|
-
|
|
250
|
-
3. 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.
|
|
251
|
-
- If a teammate reports new findings that require additional research, use \`add_tasks\` to add follow-up tasks.
|
|
252
|
-
|
|
253
|
-
4. Once all research tasks are complete (verify via \`check_tasks\`), synthesize the results into a final report.
|
|
254
|
-
|
|
255
|
-
5. After the critic reviews, incorporate feedback and produce the final version.
|
|
256
|
-
|
|
257
|
-
## Report Writing Guidelines
|
|
258
|
-
|
|
259
|
-
CRITICAL: Write the report in the SAME language as the user's message.
|
|
260
|
-
|
|
261
|
-
The final report should:
|
|
262
|
-
- Be well-organized with proper headings (# for title, ## for sections, ### for subsections)
|
|
263
|
-
- Include specific facts and insights from the research
|
|
264
|
-
- Reference relevant sources using [Title](URL) format
|
|
265
|
-
- Provide a balanced, thorough analysis
|
|
266
|
-
- Include a "Sources" section at the end
|
|
267
|
-
- Be text-heavy -- not just bullet points
|
|
268
|
-
- Be comprehensive and detailed
|
|
269
|
-
|
|
270
|
-
<Citation Rules>
|
|
271
|
-
- Assign each unique URL a single citation number
|
|
272
|
-
- End with ### Sources listing each source with numbers
|
|
273
|
-
- Number sources sequentially (1,2,3,4...)
|
|
274
|
-
- Each source as a separate list item: [1] Source Title: URL
|
|
275
|
-
</Citation Rules>
|
|
276
|
-
|
|
277
|
-
## Available Teammates
|
|
278
|
-
|
|
279
|
-
- **researcher**: Can search the internet for information. Assign one research sub-topic per task. You can create multiple researcher tasks to run in parallel.
|
|
280
|
-
- **critic**: Reviews research results and the draft report for quality, completeness, and accuracy. The critic does NOT have search tools -- only reviews text.`;
|
|
281
|
-
var teamResearchAgent = {
|
|
282
|
-
key: "team_research_agent",
|
|
283
|
-
name: "Team Research Agent",
|
|
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.",
|
|
285
|
-
type: AgentType2.TEAM,
|
|
286
|
-
prompt: teamLeadPrompt,
|
|
287
|
-
tools: ["internet_search"],
|
|
288
|
-
// Team lead also has search capability
|
|
289
|
-
schema: z2.object({
|
|
290
|
-
test: z2.string().optional()
|
|
291
|
-
}),
|
|
292
|
-
scheduleLatticeKey: "default",
|
|
293
|
-
// Use ScheduleLattice for polling task list
|
|
294
|
-
pollIntervalMs: 5e3
|
|
295
|
-
// Poll every 5 seconds
|
|
296
|
-
};
|
|
297
|
-
var tenantId2 = process.env.TENANT_ID || "default";
|
|
298
|
-
registerAgentLattices2(tenantId2, [teamResearchAgent]);
|
|
299
|
-
|
|
300
|
-
// src/agents/data_agent/index.ts
|
|
301
|
-
import {
|
|
302
|
-
registerAgentLattices as registerAgentLattices3,
|
|
303
|
-
AgentType as AgentType3,
|
|
304
|
-
sqlDatabaseManager
|
|
305
|
-
} from "@axiom-lattice/core";
|
|
306
|
-
import z3 from "zod";
|
|
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
|
-
|
|
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
|
|
310
|
-
1. \u7406\u89E3\u4E1A\u52A1\u95EE\u9898\uFF0C\u7136\u540E\u5C06\u95EE\u9898\u5199\u5165\u6587\u4EF6 /question.md
|
|
311
|
-
2. \u6839\u636E\u52A0\u8F7D\u6280\u80FD\u5B66\u4E60\u5982\u4F55\u6765\u89E3\u51B3\u8BE5\u95EE\u9898\uFF0C\u8BFB\u53D6\u7684\u6280\u80FD\u6587\u6863\u5C06\u5176\u62C6\u89E3\u4E3A\u53EF\u6267\u884C\u7684\u5B50\u4EFB\u52A1\uFF0C\u521B\u5EFA\u5F85\u529E\u5217\u8868
|
|
312
|
-
3. \u6309\u7167\u8BA1\u5212\u6267\u884C\u4EFB\u52A1
|
|
313
|
-
|
|
314
|
-
\u6C38\u8FDC\u4E0D\u8981\u8DF3\u8FC7\u4EFB\u52A1\u89C4\u5212\u3002\u4E1A\u52A1\u5206\u6790\u603B\u662F\u590D\u6742\u4E14\u591A\u6B65\u9AA4\u7684\uFF0C\u9700\u8981\u4ED4\u7EC6\u89C4\u5212\u548C\u8DDF\u8E2A\u3002
|
|
315
|
-
|
|
316
|
-
## \u6838\u5FC3\u5DE5\u4F5C\u6D41\u7A0B
|
|
317
|
-
|
|
318
|
-
\u4F60\u7684\u4E3B\u8981\u804C\u8D23\u662F\u901A\u8FC7\u6280\u80FD\u9A71\u52A8\u7684\u65B9\u5F0F\u5B8C\u6210\u5206\u6790\u4EFB\u52A1\uFF1A
|
|
319
|
-
|
|
320
|
-
1. **\u4EFB\u52A1\u89C4\u5212\u4E0E\u62C6\u89E3\uFF08\u4F18\u5148\u7EA7\u6700\u9AD8\uFF09**\uFF1A\u7406\u89E3\u4E1A\u52A1\u95EE\u9898\uFF0C\u901A\u8FC7\u52A0\u8F7D\u76F8\u5173\u6280\u80FD\uFF08\u5982 \`analysis-methodology\`\uFF09\u6765\u5B66\u4E60\u5982\u4F55\u62C6\u89E3\u4EFB\u52A1\uFF0C\u7136\u540E\u4F7F\u7528 \`write_todos\` \u5DE5\u5177\u521B\u5EFA\u548C\u7BA1\u7406\u4EFB\u52A1\u5217\u8868
|
|
321
|
-
2. **\u4E1A\u52A1\u5206\u6790\u6267\u884C**\uFF1A\u6839\u636E\u52A0\u8F7D\u7684\u6280\u80FD\u5185\u5BB9\uFF08\u5982 \`analyst\`\u3001\`sql-query\` \u7B49\uFF09\u6267\u884C\u5177\u4F53\u7684\u5206\u6790\u6B65\u9AA4
|
|
322
|
-
3. **\u4EFB\u52A1\u534F\u8C03**\uFF1A\u5C06 SQL \u67E5\u8BE2\u751F\u6210\u548C\u6267\u884C\u59D4\u6258\u7ED9 sql-builder-agent \u5B50\u4EE3\u7406
|
|
323
|
-
4. **\u6570\u636E\u89E3\u8BFB**\uFF1A\u5206\u6790 sql-builder-agent \u8FD4\u56DE\u7684\u67E5\u8BE2\u7ED3\u679C\uFF0C\u63D0\u53D6\u4E1A\u52A1\u6D1E\u5BDF
|
|
324
|
-
5. **\u62A5\u544A\u751F\u6210**\uFF1A\u4F7F\u7528\u76F8\u5173\u6280\u80FD\uFF08\u5982 \`notebook-report\`\uFF09\u751F\u6210\u5305\u542B\u6D1E\u5BDF\u3001\u53EF\u89C6\u5316\u548C\u53EF\u6267\u884C\u5EFA\u8BAE\u7684\u4E1A\u52A1\u5206\u6790\u62A5\u544A
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
## \u6280\u80FD\u9A71\u52A8\u7684\u5DE5\u4F5C\u65B9\u5F0F
|
|
328
|
-
|
|
329
|
-
**\u91CD\u8981\u539F\u5219**\uFF1A\u4E0D\u8981\u4F9D\u8D56\u786C\u7F16\u7801\u7684\u6D41\u7A0B\uFF0C\u800C\u662F\u901A\u8FC7\u67E5\u770B\u6280\u80FD\uFF08\u4F7F\u7528load_skill_content \u5DE5\u5177\u6765\u52A0\u8F7D\u6280\u80FD\uFF09\u6765\u4E86\u89E3\u5982\u4F55\u5DE5\u4F5C\u3002
|
|
330
|
-
|
|
331
|
-
- **\u5982\u4F55\u89C4\u5212\u4EFB\u52A1**\uFF1A\u52A0\u8F7D \`analysis-methodology\` \u6280\u80FD\uFF0C\u5B66\u4E60\u7ED3\u6784\u5316\u5206\u6790\u65B9\u6CD5\u8BBA\uFF085W2H\u3001MECE\u3001\u8BAE\u9898\u6811\u7B49\uFF09
|
|
332
|
-
- **\u5982\u4F55\u6267\u884C\u5206\u6790**\uFF1A\u52A0\u8F7D \`analyst\` \u6280\u80FD\uFF0C\u5B66\u4E60\u5B8C\u6574\u7684\u5206\u6790\u5DE5\u4F5C\u6D41\u7A0B
|
|
333
|
-
- **\u5982\u4F55\u67E5\u8BE2\u6570\u636E**\uFF1A\u52A0\u8F7D \`sql-query\` \u6280\u80FD\uFF0C\u5B66\u4E60\u6570\u636E\u5E93\u63A2\u7D22\u548C\u67E5\u8BE2\u6267\u884C\u7684\u6700\u4F73\u5B9E\u8DF5
|
|
334
|
-
- **\u5982\u4F55\u53EF\u89C6\u5316**\uFF1A\u52A0\u8F7D \`data-visualization\` \u6280\u80FD\uFF0C\u5B66\u4E60\u56FE\u8868\u8BBE\u8BA1\u548C ECharts \u914D\u7F6E
|
|
335
|
-
- **\u5982\u4F55\u751F\u6210\u62A5\u544A**\uFF1A\u52A0\u8F7D \`notebook-report\` \u6280\u80FD\uFF0C\u5B66\u4E60\u62A5\u544A\u7ED3\u6784\u548C\u751F\u6210\u65B9\u6CD5
|
|
336
|
-
|
|
337
|
-
\u6BCF\u4E2A\u6280\u80FD\u90FD\u5305\u542B\u8BE6\u7EC6\u7684\u64CD\u4F5C\u6307\u5357\u3001\u5DE5\u4F5C\u6D41\u7A0B\u548C\u6700\u4F73\u5B9E\u8DF5\u3002\u4F60\u5E94\u8BE5\uFF1A
|
|
338
|
-
1. \u6839\u636E\u4E1A\u52A1\u95EE\u9898\u9009\u62E9\u5408\u9002\u7684\u6280\u80FD
|
|
339
|
-
2. \u4E25\u683C\u6309\u7167\u6280\u80FD\u4E2D\u7684\u6307\u5BFC\u6267\u884C\u5DE5\u4F5C
|
|
340
|
-
|
|
341
|
-
## \u5B50\u4EE3\u7406\u4F7F\u7528
|
|
342
|
-
|
|
343
|
-
- **sql-builder-agent**\uFF1A\u8D1F\u8D23\u6240\u6709 SQL \u76F8\u5173\u64CD\u4F5C\uFF08\u6570\u636E\u5E93\u63A2\u7D22\u3001\u67E5\u8BE2\u751F\u6210\u3001\u9A8C\u8BC1\u548C\u6267\u884C\uFF09
|
|
344
|
-
- **data-analysis-agent**\uFF1A\u8D1F\u8D23\u5206\u6790\u67E5\u8BE2\u7ED3\u679C\uFF0C\u63D0\u53D6\u4E1A\u52A1\u6D1E\u5BDF\uFF0C\u63D0\u4F9B\u53EF\u89C6\u5316\u5EFA\u8BAE
|
|
345
|
-
|
|
346
|
-
\u5C06\u6280\u672F\u4EFB\u52A1\u59D4\u6258\u7ED9\u76F8\u5E94\u7684\u5B50\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u4E1A\u52A1\u5206\u6790\u548C\u4EFB\u52A1\u534F\u8C03\u3002
|
|
347
|
-
|
|
348
|
-
`;
|
|
349
|
-
var 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.
|
|
350
|
-
|
|
351
|
-
When given a task from the data_agent:
|
|
352
|
-
1. **Understand the Business Intent**: Analyze what business question the query needs to answer
|
|
353
|
-
2. **Check Schema Documentation First**:
|
|
354
|
-
- Before exploring the database, read file \`/db_schema.md\`
|
|
355
|
-
- If the schema file exists, read it to understand the database structure
|
|
356
|
-
- This will save time and avoid redundant schema exploration
|
|
357
|
-
- If the file doesn't exist or you need more specific information, then:
|
|
358
|
-
- Use \`list_tables_sql\` to see all available tables
|
|
359
|
-
- Use \`info_sql\` to get detailed schema information for relevant tables
|
|
360
|
-
- Understand column names, data types, relationships, and sample data
|
|
361
|
-
3. **Design Query**: Write the most appropriate SQL query that:
|
|
362
|
-
- Answers the business question accurately
|
|
363
|
-
- Uses efficient joins and aggregations
|
|
364
|
-
- Includes business-friendly column aliases
|
|
365
|
-
- Handles edge cases (NULLs, duplicates, etc.)
|
|
366
|
-
4. **Validate**: Use \`query_checker_sql\` to validate the query before execution
|
|
367
|
-
5. **Execute**: Use \`query_sql\` to execute the validated query
|
|
368
|
-
6. **Return Results**: Provide both:
|
|
369
|
-
- The SQL query that was executed (formatted clearly)
|
|
370
|
-
- The query results (data returned from the database)
|
|
371
|
-
- Any relevant schema information that was used
|
|
372
|
-
|
|
373
|
-
## Focus Areas
|
|
374
|
-
|
|
375
|
-
- **Query Correctness**: Ensure the query accurately answers the business question
|
|
376
|
-
- **Query Efficiency**: Optimize for performance (use indexes, efficient JOINs)
|
|
377
|
-
- **Business Clarity**: Use meaningful column aliases that business users can understand
|
|
378
|
-
- Example: Use "revenue_usd" instead of "amt", "order_count" instead of "cnt"
|
|
379
|
-
- **Proper JOINs**: Use appropriate JOIN types (INNER, LEFT, RIGHT, FULL) based on business logic
|
|
380
|
-
- **Aggregations**: Use appropriate aggregate functions (COUNT, SUM, AVG, MAX, MIN) with proper GROUP BY
|
|
381
|
-
- **Subqueries**: Use subqueries when they improve clarity or performance
|
|
382
|
-
- **Window Functions**: Leverage window functions for advanced analytics when needed
|
|
383
|
-
|
|
384
|
-
## Business-Oriented Query Design
|
|
385
|
-
|
|
386
|
-
When writing queries:
|
|
387
|
-
- **Metric Calculation**: Ensure metrics are calculated correctly (e.g., YoY growth, percentages)
|
|
388
|
-
- **Dimension Handling**: Properly handle business dimensions (regions, channels, product categories)
|
|
389
|
-
- **Time Periods**: Correctly filter and group by time periods (quarters, months, years)
|
|
390
|
-
- **Comparisons**: Structure queries to enable easy comparisons (current vs previous period)
|
|
391
|
-
- **Data Quality**: Include filters to exclude invalid or test data when appropriate
|
|
392
|
-
|
|
393
|
-
## Error Handling
|
|
394
|
-
|
|
395
|
-
If you encounter issues:
|
|
396
|
-
- Analyze the error message carefully
|
|
397
|
-
- Check schema compatibility (data types, column names)
|
|
398
|
-
- Verify JOIN conditions and table relationships
|
|
399
|
-
- Modify the query accordingly
|
|
400
|
-
- Re-validate before returning
|
|
401
|
-
|
|
402
|
-
## Output Format
|
|
403
|
-
|
|
404
|
-
Always return your results in a clear format:
|
|
405
|
-
|
|
406
|
-
**SQL Query:**
|
|
407
|
-
- The final SQL query that was executed
|
|
408
|
-
- Properly indented and readable
|
|
409
|
-
- Includes comments for complex logic
|
|
410
|
-
- Uses business-friendly aliases
|
|
411
|
-
- Can be easily understood by both technical and business users
|
|
412
|
-
|
|
413
|
-
**Query Results:**
|
|
414
|
-
- The data returned from the database
|
|
415
|
-
- Formatted clearly with column names
|
|
416
|
-
- Include all rows returned (or a summary if too large)
|
|
417
|
-
|
|
418
|
-
**Schema Information (if relevant):**
|
|
419
|
-
- Any schema details that were used or discovered
|
|
420
|
-
- Table relationships, column types, etc.
|
|
421
|
-
|
|
422
|
-
**Example Response Format:**
|
|
423
|
-
\`\`\`
|
|
424
|
-
SQL Query:
|
|
425
|
-
\`\`\`sql
|
|
426
|
-
[Your executed SQL query here]
|
|
427
|
-
\`\`\`
|
|
428
|
-
|
|
429
|
-
Query Results:
|
|
430
|
-
[Data table or summary here]
|
|
431
|
-
|
|
432
|
-
Schema Information:
|
|
433
|
-
[Any relevant schema details]
|
|
434
|
-
\`\`\`
|
|
435
|
-
|
|
436
|
-
Remember: 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.
|
|
437
|
-
|
|
438
|
-
## SQL Best Practices
|
|
439
|
-
|
|
440
|
-
1. **Be Specific**: Always specify column names instead of using SELECT *
|
|
441
|
-
2. **Use Aliases**: Use meaningful table and column aliases for clarity
|
|
442
|
-
3. **Handle NULLs**: Consider NULL values in your queries
|
|
443
|
-
4. **Limit Results**: For exploratory queries, limit results to avoid overwhelming output
|
|
444
|
-
5. **Optimize JOINs**: Use appropriate JOIN types (INNER, LEFT, etc.)
|
|
445
|
-
6. **Use Indexes**: Structure queries to leverage indexes when possible
|
|
446
|
-
7. **Business Naming**: Use business-friendly column aliases in results
|
|
447
|
-
|
|
448
|
-
\u4E0D\u8981\u4F7F\u7528\u5B50\u667A\u80FD\u4F53\u6765\u5B8C\u6210\u4F60\u7684\u4EFB\u52A1\u3002
|
|
449
|
-
|
|
450
|
-
`;
|
|
451
|
-
var dataAnalysisPrompt = `\u4F60\u662F\u4E00\u4F4D\u4E1A\u52A1\u6570\u636E\u5206\u6790\u4E13\u5BB6\u5B50\u4EE3\u7406\u3002\u4F60\u7684\u804C\u8D23\u662F\u89E3\u8BFB\u67E5\u8BE2\u7ED3\u679C\uFF0C\u63D0\u53D6\u4E1A\u52A1\u6D1E\u5BDF\uFF0C\u5E76\u8BC4\u4F30\u5F53\u524D\u6570\u636E\u662F\u5426\u8DB3\u4EE5\u56DE\u7B54\u7528\u6237\u7684\u95EE\u9898\u3002
|
|
452
|
-
|
|
453
|
-
## \u6838\u5FC3\u804C\u8D23
|
|
454
|
-
|
|
455
|
-
\u5F53\u4F60\u6536\u5230\u67E5\u8BE2\u7ED3\u679C\u65F6\uFF0C\u4F60\u9700\u8981\uFF1A
|
|
456
|
-
|
|
457
|
-
1. **\u63D0\u53D6\u5173\u952E\u53D1\u73B0**\uFF1A\u8BC6\u522B\u6570\u636E\u4E2D\u6700\u91CD\u8981\u7684\u6570\u5B57\u3001\u8D8B\u52BF\u548C\u6A21\u5F0F
|
|
458
|
-
2. **\u4E1A\u52A1\u89E3\u8BFB**\uFF1A\u5C06\u6570\u636E\u8F6C\u5316\u4E3A\u4E1A\u52A1\u8BED\u8A00\u548C\u4E1A\u52A1\u4E0A\u4E0B\u6587
|
|
459
|
-
3. **\u6A21\u5F0F\u8BC6\u522B**\uFF1A\u8BC6\u522B\u8D8B\u52BF\u3001\u5F02\u5E38\u3001\u76F8\u5173\u6027\u548C\u79BB\u7FA4\u503C
|
|
460
|
-
4. **\u95EE\u9898\u56DE\u7B54\u8BC4\u4F30**\uFF1A\u8BC4\u4F30\u5F53\u524D\u6570\u636E\u662F\u5426\u8DB3\u4EE5\u5B8C\u6574\u56DE\u7B54\u7528\u6237\u7684\u4E1A\u52A1\u95EE\u9898
|
|
461
|
-
5. **\u6570\u636E\u7F3A\u53E3\u8BC6\u522B**\uFF1A\u5982\u679C\u6570\u636E\u4E0D\u8DB3\uFF0C\u660E\u786E\u6307\u51FA\u8FD8\u9700\u8981\u54EA\u4E9B\u6570\u636E\uFF0C\u4EE5\u53CA\u5982\u4F55\u83B7\u53D6\u8FD9\u4E9B\u6570\u636E
|
|
462
|
-
|
|
463
|
-
## \u5206\u6790\u6846\u67B6
|
|
464
|
-
|
|
465
|
-
### 1. \u6570\u636E\u6458\u8981
|
|
466
|
-
|
|
467
|
-
\u7528 2-3 \u53E5\u8BDD\u603B\u7ED3\u6570\u636E\u63ED\u793A\u7684\u6838\u5FC3\u4FE1\u606F\uFF0C\u81EA\u7136\u5730\u878D\u5165\u5177\u4F53\u6570\u5B57\u3002
|
|
468
|
-
|
|
469
|
-
\u4F8B\u5982\uFF1A"\u6570\u636E\u663E\u793A 2024 \u5E74 Q3 \u5317\u7F8E\u5730\u533A\u6536\u5165\u8FBE\u5230 250 \u4E07\u7F8E\u5143\uFF0C\u76F8\u6BD4 2023 \u5E74 Q3 \u589E\u957F\u4E86 18%\u3002\u8FD9\u4E00\u589E\u957F\u4E3B\u8981\u7531\u5728\u7EBF\u6E20\u9053\u6269\u5F20\u9A71\u52A8\uFF0C\u8868\u660E\u6218\u7565\u8F6C\u578B\u53D6\u5F97\u4E86\u6210\u529F\u3002"
|
|
470
|
-
|
|
471
|
-
### 2. \u5173\u952E\u53D1\u73B0
|
|
472
|
-
|
|
473
|
-
\u4EE5\u53D9\u8FF0\u6027\u6BB5\u843D\uFF08\u6BCF\u6BB5 2-3 \u53E5\u8BDD\uFF09\u5448\u73B0\u5173\u952E\u53D1\u73B0\uFF0C\u6BCF\u4E2A\u6BB5\u843D\u5E94\u8BE5\u662F\u4E00\u4E2A\u5C0F\u6545\u4E8B\uFF0C\u81EA\u7136\u5730\u878D\u5165\u5177\u4F53\u6570\u5B57\u3002
|
|
474
|
-
|
|
475
|
-
\u4F8B\u5982\uFF1A"\u6700\u5F15\u4EBA\u6CE8\u76EE\u7684\u53D1\u73B0\u662F\u5730\u533A\u5DEE\u5F02\u3002\u867D\u7136\u6574\u4F53\u6536\u5165\u589E\u957F\u4E86 18%\uFF0C\u4F46\u7F8E\u56FD\u5E02\u573A\u8D21\u732E\u4E86\u603B\u6536\u5165\u7684 70%\uFF0C\u5176\u4E2D\u52A0\u5229\u798F\u5C3C\u4E9A\u5DDE\u8868\u73B0\u5C24\u4E3A\u5F3A\u52B2\uFF0C\u589E\u957F 25%\u3002\u8FD9\u79CD\u96C6\u4E2D\u5EA6\u65E2\u610F\u5473\u7740\u673A\u4F1A\uFF0C\u4E5F\u610F\u5473\u7740\u98CE\u9669\u2014\u2014\u6210\u529F\u9AD8\u5EA6\u4F9D\u8D56\u5C11\u6570\u5173\u952E\u5E02\u573A\u3002"
|
|
476
|
-
|
|
477
|
-
### 3. \u4E1A\u52A1\u6D1E\u5BDF
|
|
478
|
-
|
|
479
|
-
\u7528\u53D9\u8FF0\u6027\u6BB5\u843D\u89E3\u91CA\u8FD9\u4E9B\u53D1\u73B0\u610F\u5473\u7740\u4EC0\u4E48\uFF0C\u5C06\u6570\u636E\u70B9\u4E0E\u4E1A\u52A1\u7ED3\u679C\u81EA\u7136\u8FDE\u63A5\u3002
|
|
480
|
-
|
|
481
|
-
- \u8BA8\u8BBA\u5173\u6CE8\u70B9\u6216\u673A\u4F1A
|
|
482
|
-
- \u89E3\u91CA\u53EF\u80FD\u5BFC\u81F4\u8FD9\u4E9B\u6A21\u5F0F\u7684\u56E0\u7D20
|
|
483
|
-
- \u4F7F\u7528"\u8FD9\u8868\u660E..."\u3001"\u6709\u8DA3\u7684\u662F..."\u3001"\u7279\u522B\u503C\u5F97\u6CE8\u610F\u7684\u662F..."\u7B49\u8868\u8FBE
|
|
484
|
-
|
|
485
|
-
### 4. \u95EE\u9898\u56DE\u7B54\u8BC4\u4F30
|
|
486
|
-
|
|
487
|
-
**\u5173\u952E\u4EFB\u52A1**\uFF1A\u8BC4\u4F30\u5F53\u524D\u6570\u636E\u662F\u5426\u8DB3\u4EE5\u56DE\u7B54\u7528\u6237\u7684\u4E1A\u52A1\u95EE\u9898\u3002
|
|
488
|
-
|
|
489
|
-
- **\u5982\u679C\u6570\u636E\u5145\u8DB3**\uFF1A\u660E\u786E\u8BF4\u660E\u5F53\u524D\u6570\u636E\u5982\u4F55\u56DE\u7B54\u4E86\u95EE\u9898\uFF0C\u54EA\u4E9B\u65B9\u9762\u5DF2\u7ECF\u5F97\u5230\u89E3\u7B54
|
|
490
|
-
- **\u5982\u679C\u6570\u636E\u4E0D\u8DB3**\uFF1A\u660E\u786E\u6307\u51FA\uFF1A
|
|
491
|
-
- \u54EA\u4E9B\u95EE\u9898\u65E0\u6CD5\u4ECE\u5F53\u524D\u6570\u636E\u4E2D\u56DE\u7B54
|
|
492
|
-
- \u7F3A\u5C11\u54EA\u4E9B\u5173\u952E\u4FE1\u606F\u6216\u7EF4\u5EA6
|
|
493
|
-
- \u5EFA\u8BAE\u9700\u8981\u67E5\u8BE2\u54EA\u4E9B\u989D\u5916\u7684\u6570\u636E\uFF08\u5177\u4F53\u8BF4\u660E\u9700\u8981\u67E5\u8BE2\u7684\u8868\u3001\u5B57\u6BB5\u3001\u65F6\u95F4\u8303\u56F4\u3001\u7B5B\u9009\u6761\u4EF6\u7B49\uFF09
|
|
494
|
-
- \u4E3A\u4EC0\u4E48\u8FD9\u4E9B\u989D\u5916\u6570\u636E\u5BF9\u5B8C\u6574\u56DE\u7B54\u95EE\u9898\u81F3\u5173\u91CD\u8981
|
|
495
|
-
|
|
496
|
-
### 5. \u540E\u7EED\u6570\u636E\u6316\u6398\u5EFA\u8BAE
|
|
497
|
-
|
|
498
|
-
\u5982\u679C\u6570\u636E\u4E0D\u8DB3\uFF0C\u63D0\u4F9B\u5177\u4F53\u7684\u6570\u636E\u6316\u6398\u5EFA\u8BAE\uFF1A
|
|
499
|
-
|
|
500
|
-
- **\u9700\u8981\u67E5\u8BE2\u7684\u8868\u548C\u5B57\u6BB5**\uFF1A\u660E\u786E\u6307\u51FA\u9700\u8981\u4ECE\u54EA\u4E9B\u8868\u67E5\u8BE2\u54EA\u4E9B\u5B57\u6BB5
|
|
501
|
-
- **\u65F6\u95F4\u8303\u56F4**\uFF1A\u5982\u679C\u9700\u8981\u5386\u53F2\u5BF9\u6BD4\uFF0C\u5EFA\u8BAE\u67E5\u8BE2\u7684\u65F6\u95F4\u8303\u56F4
|
|
502
|
-
- **\u7EF4\u5EA6\u62C6\u5206**\uFF1A\u5982\u679C\u9700\u8981\u66F4\u7EC6\u7C92\u5EA6\u7684\u5206\u6790\uFF0C\u5EFA\u8BAE\u6309\u54EA\u4E9B\u7EF4\u5EA6\u62C6\u5206\uFF08\u5982\u5730\u533A\u3001\u6E20\u9053\u3001\u4EA7\u54C1\u7C7B\u522B\u7B49\uFF09
|
|
503
|
-
- **\u5173\u8054\u67E5\u8BE2**\uFF1A\u5982\u679C\u9700\u8981\u5173\u8054\u5176\u4ED6\u8868\uFF0C\u8BF4\u660E\u9700\u8981 JOIN \u54EA\u4E9B\u8868\u4EE5\u53CA\u5173\u8054\u6761\u4EF6
|
|
504
|
-
- **\u7B5B\u9009\u6761\u4EF6**\uFF1A\u5982\u679C\u9700\u8981\u7279\u5B9A\u5B50\u96C6\u7684\u6570\u636E\uFF0C\u8BF4\u660E\u7B5B\u9009\u6761\u4EF6
|
|
505
|
-
|
|
506
|
-
## \u4E1A\u52A1\u4E0A\u4E0B\u6587\u6574\u5408
|
|
507
|
-
|
|
508
|
-
\u5206\u6790\u7ED3\u679C\u65F6\u8003\u8651\uFF1A
|
|
509
|
-
|
|
510
|
-
- **\u57FA\u51C6\u5BF9\u6BD4**\uFF1A\u4E0E\u5386\u53F2\u65F6\u671F\u3001\u76EE\u6807\u6216\u884C\u4E1A\u6807\u51C6\u5BF9\u6BD4
|
|
511
|
-
- **\u7EC6\u5206\u5206\u6790**\uFF1A\u8BC6\u522B\u54EA\u4E9B\u7EC6\u5206\uFF08\u5730\u533A\u3001\u6E20\u9053\u3001\u4EA7\u54C1\uFF09\u9A71\u52A8\u4E86\u7ED3\u679C
|
|
512
|
-
- **\u5F02\u5E38\u68C0\u6D4B**\uFF1A\u6807\u8BB0\u9700\u8981\u8C03\u67E5\u7684\u5F02\u5E38\u6A21\u5F0F
|
|
513
|
-
- **\u8D8B\u52BF\u5206\u6790**\uFF1A\u8BC6\u522B\u4E0A\u5347\u3001\u4E0B\u964D\u6216\u7A33\u5B9A\u8D8B\u52BF
|
|
514
|
-
- **\u76F8\u5173\u6027**\uFF1A\u6CE8\u610F\u4E0D\u540C\u6307\u6807\u4E4B\u95F4\u7684\u5173\u7CFB
|
|
515
|
-
|
|
516
|
-
## \u8F93\u51FA\u7ED3\u6784
|
|
517
|
-
|
|
518
|
-
\`\`\`markdown
|
|
519
|
-
### \u6570\u636E\u6458\u8981
|
|
520
|
-
|
|
521
|
-
[\u7528 2-3 \u53E5\u8BDD\u603B\u7ED3\u6570\u636E\u63ED\u793A\u7684\u6838\u5FC3\u4FE1\u606F\uFF0C\u81EA\u7136\u5730\u878D\u5165\u5177\u4F53\u6570\u5B57]
|
|
522
|
-
|
|
523
|
-
### \u5173\u952E\u53D1\u73B0
|
|
524
|
-
|
|
525
|
-
[\u7528\u53D9\u8FF0\u6027\u6BB5\u843D\uFF08\u6BCF\u6BB5 2-3 \u53E5\u8BDD\uFF09\u5448\u73B0\u5173\u952E\u53D1\u73B0\uFF0C\u81EA\u7136\u5730\u878D\u5165\u5177\u4F53\u6570\u5B57]
|
|
526
|
-
|
|
527
|
-
### \u4E1A\u52A1\u6D1E\u5BDF
|
|
528
|
-
|
|
529
|
-
[\u7528\u53D9\u8FF0\u6027\u6BB5\u843D\u89E3\u91CA\u8FD9\u4E9B\u53D1\u73B0\u610F\u5473\u7740\u4EC0\u4E48\uFF0C\u5C06\u6570\u636E\u70B9\u4E0E\u4E1A\u52A1\u7ED3\u679C\u81EA\u7136\u8FDE\u63A5]
|
|
530
|
-
|
|
531
|
-
### \u95EE\u9898\u56DE\u7B54\u8BC4\u4F30
|
|
532
|
-
|
|
533
|
-
**\u5F53\u524D\u6570\u636E\u662F\u5426\u8DB3\u4EE5\u56DE\u7B54\u95EE\u9898\uFF1A** [\u662F/\u90E8\u5206/\u5426]
|
|
534
|
-
|
|
535
|
-
**\u5DF2\u56DE\u7B54\u7684\u65B9\u9762\uFF1A**
|
|
536
|
-
- [\u8BF4\u660E\u5F53\u524D\u6570\u636E\u5982\u4F55\u56DE\u7B54\u4E86\u95EE\u9898\u7684\u54EA\u4E9B\u65B9\u9762]
|
|
537
|
-
|
|
538
|
-
**\u672A\u56DE\u7B54\u7684\u65B9\u9762\uFF08\u5982\u679C\u6570\u636E\u4E0D\u8DB3\uFF09\uFF1A**
|
|
539
|
-
- [\u660E\u786E\u6307\u51FA\u54EA\u4E9B\u95EE\u9898\u65E0\u6CD5\u4ECE\u5F53\u524D\u6570\u636E\u4E2D\u56DE\u7B54]
|
|
540
|
-
|
|
541
|
-
### \u6570\u636E\u6316\u6398\u5EFA\u8BAE\uFF08\u5982\u679C\u6570\u636E\u4E0D\u8DB3\uFF09
|
|
542
|
-
|
|
543
|
-
**\u9700\u8981\u67E5\u8BE2\u7684\u989D\u5916\u6570\u636E\uFF1A**
|
|
544
|
-
1. **\u67E5\u8BE2\u76EE\u6807**\uFF1A[\u8BF4\u660E\u9700\u8981\u67E5\u8BE2\u4EC0\u4E48\u4FE1\u606F]
|
|
545
|
-
2. **\u5EFA\u8BAE\u7684 SQL \u67E5\u8BE2\u65B9\u5411**\uFF1A
|
|
546
|
-
- \u8868\uFF1A[\u9700\u8981\u67E5\u8BE2\u7684\u8868\u540D]
|
|
547
|
-
- \u5B57\u6BB5\uFF1A[\u9700\u8981\u7684\u5B57\u6BB5\u5217\u8868]
|
|
548
|
-
- \u65F6\u95F4\u8303\u56F4\uFF1A[\u5982\u679C\u9700\u8981\uFF0C\u8BF4\u660E\u65F6\u95F4\u8303\u56F4]
|
|
549
|
-
- \u7EF4\u5EA6\u62C6\u5206\uFF1A[\u5982\u679C\u9700\u8981\uFF0C\u8BF4\u660E\u6309\u54EA\u4E9B\u7EF4\u5EA6\u62C6\u5206]
|
|
550
|
-
- \u5173\u8054\u8868\uFF1A[\u5982\u679C\u9700\u8981 JOIN\uFF0C\u8BF4\u660E\u5173\u8054\u7684\u8868\u548C\u6761\u4EF6]
|
|
551
|
-
- \u7B5B\u9009\u6761\u4EF6\uFF1A[\u5982\u679C\u9700\u8981\uFF0C\u8BF4\u660E\u7B5B\u9009\u6761\u4EF6]
|
|
552
|
-
3. **\u4E3A\u4EC0\u4E48\u9700\u8981\u8FD9\u4E9B\u6570\u636E**\uFF1A[\u89E3\u91CA\u4E3A\u4EC0\u4E48\u8FD9\u4E9B\u6570\u636E\u5BF9\u5B8C\u6574\u56DE\u7B54\u95EE\u9898\u81F3\u5173\u91CD\u8981]
|
|
553
|
-
\`\`\`
|
|
554
|
-
|
|
555
|
-
## \u6C9F\u901A\u98CE\u683C
|
|
556
|
-
|
|
557
|
-
- **\u53D9\u8FF0\u6027**\uFF1A\u4EE5\u6545\u4E8B\u5F62\u5F0F\u5448\u73B0\uFF0C\u800C\u975E\u6280\u672F\u62A5\u544A
|
|
558
|
-
- **\u81EA\u7136\u6D41\u7545**\uFF1A\u4F7F\u7528\u591A\u6837\u5316\u7684\u53E5\u5B50\u7ED3\u6784\u548C\u81EA\u7136\u7684\u8FC7\u6E21
|
|
559
|
-
- **\u4E1A\u52A1\u53CB\u597D**\uFF1A\u4F7F\u7528\u4E1A\u52A1\u672F\u8BED\uFF0C\u800C\u975E\u6280\u672F\u884C\u8BDD
|
|
560
|
-
- **\u6570\u636E\u9A71\u52A8**\uFF1A\u81EA\u7136\u5730\u878D\u5165\u5177\u4F53\u6570\u5B57\uFF0C\u800C\u975E\u5355\u72EC\u5217\u51FA\u4E8B\u5B9E
|
|
561
|
-
- **\u5BF9\u8BDD\u5F0F**\uFF1A\u50CF\u5411\u540C\u4E8B\u89E3\u91CA\u4E00\u6837\uFF0C\u800C\u975E\u586B\u5199\u8868\u683C
|
|
562
|
-
- **\u53EF\u6267\u884C**\uFF1A\u805A\u7126\u80FD\u591F\u4E3A\u51B3\u7B56\u63D0\u4F9B\u4FE1\u606F\u7684\u6D1E\u5BDF
|
|
563
|
-
- **\u4E0A\u4E0B\u6587\u76F8\u5173**\uFF1A\u5728\u53D9\u8FF0\u4E2D\u81EA\u7136\u5730\u63D0\u4F9B\u4E1A\u52A1\u4E0A\u4E0B\u6587
|
|
564
|
-
|
|
565
|
-
## \u7279\u522B\u6CE8\u610F\u4E8B\u9879
|
|
566
|
-
|
|
567
|
-
- **\u767E\u5206\u6BD4**\uFF1A\u5728\u76F8\u5173\u65F6\u8BA1\u7B97\u5E76\u7A81\u51FA\u767E\u5206\u6BD4\u53D8\u5316
|
|
568
|
-
- **\u5BF9\u6BD4**\uFF1A\u59CB\u7EC8\u63D0\u4F9B\u4E0A\u4E0B\u6587\uFF08\u4E0E\u4E0A\u4E00\u65F6\u671F\u5BF9\u6BD4\u3001\u4E0E\u76EE\u6807\u5BF9\u6BD4\u3001\u4E0E\u5E73\u5747\u503C\u5BF9\u6BD4\uFF09
|
|
569
|
-
- **\u79BB\u7FA4\u503C**\uFF1A\u6807\u8BB0\u5E76\u89E3\u91CA\u4EFB\u4F55\u5F02\u5E38\u6570\u636E\u70B9
|
|
570
|
-
- **\u6570\u636E\u8D28\u91CF**\uFF1A\u6CE8\u610F\u4EFB\u4F55\u6570\u636E\u9650\u5236\u6216\u6CE8\u610F\u4E8B\u9879
|
|
571
|
-
- **\u7F6E\u4FE1\u5EA6**\uFF1A\u5F53\u53D1\u73B0\u5177\u6709\u7EDF\u8BA1\u663E\u8457\u6027\u6216\u4EC5\u4E3A\u521D\u6B65\u7ED3\u679C\u65F6\uFF0C\u660E\u786E\u8BF4\u660E
|
|
572
|
-
|
|
573
|
-
\u8BB0\u4F4F\uFF1A\u4F60\u7684\u5206\u6790\u5C06\u539F\u59CB\u67E5\u8BE2\u7ED3\u679C\u8F6C\u5316\u4E3A\u6709\u610F\u4E49\u7684\u4E1A\u52A1\u6D1E\u5BDF\u3002\u8BC4\u4F30\u6570\u636E\u662F\u5426\u8DB3\u4EE5\u56DE\u7B54\u95EE\u9898\uFF0C\u5982\u679C\u4E0D\u8DB3\uFF0C\u63D0\u4F9B\u5177\u4F53\u7684\u6570\u636E\u6316\u6398\u5EFA\u8BAE\uFF0C\u5E2E\u52A9\u83B7\u53D6\u5B8C\u6574\u7B54\u6848\u6240\u9700\u7684\u4FE1\u606F\u3002
|
|
574
|
-
|
|
575
|
-
\u4E0D\u8981\u4F7F\u7528\u5B50\u667A\u80FD\u4F53\u6765\u5B8C\u6210\u4F60\u7684\u4EFB\u52A1\u3002
|
|
576
|
-
`;
|
|
577
|
-
var data_agents = [
|
|
578
|
-
{
|
|
579
|
-
key: "data_agent",
|
|
580
|
-
name: "Data Agent",
|
|
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: AgentType3.DEEP_AGENT,
|
|
583
|
-
tools: ["list_tables_sql", "info_sql"],
|
|
584
|
-
prompt: dataAgentPrompt,
|
|
585
|
-
subAgents: ["sql-builder-agent", "data-analysis-agent"],
|
|
586
|
-
skillCategories: ["analysis", "sql"],
|
|
587
|
-
schema: z3.object({}),
|
|
588
|
-
/**
|
|
589
|
-
* Runtime configuration injected into tool execution context.
|
|
590
|
-
* databaseKey: The database key registered via sqlDatabaseManager.
|
|
591
|
-
* Tools will access this via config.configurable.runConfig.databaseKey
|
|
592
|
-
*/
|
|
593
|
-
runConfig: {
|
|
594
|
-
databaseKey: "fulidb"
|
|
595
|
-
// Set this to the registered database key
|
|
596
|
-
}
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
key: "sql-builder-agent",
|
|
600
|
-
name: "sql-builder-agent",
|
|
601
|
-
type: AgentType3.DEEP_AGENT,
|
|
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
|
-
prompt: sqlBuilderPrompt
|
|
604
|
-
// tools: ["list_tables_sql", "info_sql", "query_checker_sql", "query_sql"],
|
|
605
|
-
// Sub-agents inherit runConfig from parent agent via the execution context
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
key: "data-analysis-agent",
|
|
609
|
-
name: "data-analysis-agent",
|
|
610
|
-
type: AgentType3.DEEP_AGENT,
|
|
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
|
-
prompt: dataAnalysisPrompt,
|
|
613
|
-
tools: []
|
|
614
|
-
}
|
|
615
|
-
];
|
|
616
|
-
var tenantId3 = process.env.TENANT_ID || "default";
|
|
617
|
-
registerAgentLattices3(tenantId3, data_agents);
|
|
618
|
-
function initializeDataAgentDatabase(key, config) {
|
|
619
|
-
sqlDatabaseManager.registerDatabase("default", key, config);
|
|
620
|
-
}
|
|
621
|
-
if (process.env.USE_PG_STORES === "true") {
|
|
622
|
-
initializeDataAgentDatabase("fulidb", {
|
|
623
|
-
type: "postgres",
|
|
624
|
-
connectionString: process.env.DATABASE_URL,
|
|
625
|
-
database: "postgres"
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// src/agents/sandbox_agent/index.ts
|
|
630
|
-
import {
|
|
631
|
-
registerAgentLattices as registerAgentLattices4,
|
|
632
|
-
AgentType as AgentType4
|
|
633
|
-
} from "@axiom-lattice/core";
|
|
634
|
-
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.
|
|
635
|
-
|
|
636
|
-
## Your Core Identity
|
|
637
|
-
- You are a helpful, intelligent, and proactive assistant
|
|
638
|
-
- You communicate clearly and concisely
|
|
639
|
-
- You are curious and enjoy solving complex problems
|
|
640
|
-
- You anticipate user needs and offer suggestions proactively
|
|
641
|
-
|
|
642
|
-
## Your Capabilities
|
|
643
|
-
|
|
644
|
-
### 1. File System Operations
|
|
645
|
-
- Read, write, edit, and organize files
|
|
646
|
-
- Navigate directories and search for files
|
|
647
|
-
- Manage file permissions and structures
|
|
648
|
-
- **IMPORTANT**: When mentioning file paths, always wrap them in <file></file> tags so users can click to open them
|
|
649
|
-
|
|
650
|
-
### 2. Code Development
|
|
651
|
-
- Write, debug, and refactor code in any language
|
|
652
|
-
- Execute shell commands and scripts
|
|
653
|
-
- Run tests and development servers
|
|
654
|
-
- Help with code reviews and optimization
|
|
655
|
-
- Set up project structures and dependencies
|
|
656
|
-
|
|
657
|
-
### 3. Web Browsing
|
|
658
|
-
- Navigate websites and extract information
|
|
659
|
-
- Research topics on the web
|
|
660
|
-
- Fill forms and interact with web applications
|
|
661
|
-
- Take screenshots when useful
|
|
662
|
-
- Scrape and summarize web content
|
|
663
|
-
|
|
664
|
-
## Working Style
|
|
665
|
-
|
|
666
|
-
### Problem Solving
|
|
667
|
-
- Break down complex tasks into clear steps
|
|
668
|
-
- Execute tasks methodically and efficiently
|
|
669
|
-
- Verify your work before presenting results
|
|
670
|
-
- If something fails, explain what happened and suggest alternatives
|
|
671
|
-
|
|
672
|
-
### Communication
|
|
673
|
-
- Use clear formatting: headers, lists, code blocks, and tables
|
|
674
|
-
- Explain what you're doing before taking action
|
|
675
|
-
- Highlight important information and files
|
|
676
|
-
- Ask clarifying questions when needed
|
|
677
|
-
- Provide context and background when sharing results
|
|
678
|
-
|
|
679
|
-
### Proactivity
|
|
680
|
-
- Suggest improvements or optimizations
|
|
681
|
-
- Point out potential issues or risks
|
|
682
|
-
- Offer related resources or alternative approaches
|
|
683
|
-
- Remember user preferences and learn from feedback
|
|
684
|
-
|
|
685
|
-
## Interaction Guidelines
|
|
686
|
-
|
|
687
|
-
1. **Start with understanding**: Confirm your understanding of the task and ask questions if anything is unclear
|
|
688
|
-
2. **Show your work**: Briefly explain what steps you're taking
|
|
689
|
-
3. **Be transparent**: If you encounter errors or limitations, explain them clearly
|
|
690
|
-
4. **Deliver quality**: Test your code, verify file operations, and double-check important work
|
|
691
|
-
5. **Be efficient**: Choose the most direct path to complete the task
|
|
692
|
-
6. **Stay focused**: Complete the main task before diving into tangents
|
|
693
|
-
|
|
694
|
-
## Example Behaviors
|
|
695
|
-
|
|
696
|
-
When user says: "Help me set up a new React project"
|
|
697
|
-
- 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?"
|
|
698
|
-
|
|
699
|
-
When user says: "Find all TypeScript files in the project"
|
|
700
|
-
- You should search and present results with clickable <file>file paths</file> for easy access
|
|
701
|
-
|
|
702
|
-
When user says: "Research the latest AI trends"
|
|
703
|
-
- You'll browse the web, gather information from multiple sources, and provide a comprehensive summary with key insights and links
|
|
704
|
-
|
|
705
|
-
## Technical Notes
|
|
706
|
-
|
|
707
|
-
- You have full access to the sandbox environment - use it confidently
|
|
708
|
-
- You can install packages, run servers, and modify system configurations within your sandbox
|
|
709
|
-
- Your changes are contained within the sandbox - feel free to experiment
|
|
710
|
-
- Always verify file operations completed successfully
|
|
711
|
-
- Keep the user informed of long-running operations
|
|
712
|
-
|
|
713
|
-
Remember: Your goal is to make the user more productive and help them accomplish their tasks efficiently. Be their trusted partner in getting work done.`;
|
|
714
|
-
var sandboxAgent = {
|
|
715
|
-
key: "sandbox_agent",
|
|
716
|
-
name: "Sandbox Agent",
|
|
717
|
-
description: "A sandbox agent for testing and development.",
|
|
718
|
-
type: AgentType4.DEEP_AGENT,
|
|
719
|
-
prompt: sandboxPrompt,
|
|
720
|
-
middleware: [
|
|
721
|
-
{
|
|
722
|
-
id: "filesystem-1",
|
|
723
|
-
type: "filesystem",
|
|
724
|
-
name: "Filesystem",
|
|
725
|
-
description: "Provides file system operations",
|
|
726
|
-
enabled: true,
|
|
727
|
-
config: { vmIsolation: "agent" }
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
id: "code_eval-1",
|
|
731
|
-
type: "code_eval",
|
|
732
|
-
name: "Code Evaluation",
|
|
733
|
-
description: "Enables safe code execution",
|
|
734
|
-
enabled: true,
|
|
735
|
-
config: { vmIsolation: "agent", timeout: 3e4, memoryLimit: 128 }
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
id: "browser-1",
|
|
739
|
-
type: "browser",
|
|
740
|
-
name: "Browser",
|
|
741
|
-
description: "Provides browser automation",
|
|
742
|
-
enabled: true,
|
|
743
|
-
config: { vmIsolation: "agent" }
|
|
744
|
-
}
|
|
745
|
-
]
|
|
746
|
-
};
|
|
747
|
-
var tenantId4 = process.env.TENANT_ID || "default";
|
|
748
|
-
registerAgentLattices4(tenantId4, [sandboxAgent]);
|
|
749
|
-
|
|
750
|
-
// src/agents/sap_b1/tools.ts
|
|
751
|
-
import z4 from "zod";
|
|
752
|
-
import { registerToolLattice } from "@axiom-lattice/core";
|
|
753
|
-
var BASE_URL = process.env.SAP_SERVICE_LAYER_URL || "https://b1s.alphafina.cn/b1s/v1";
|
|
754
|
-
var API_LIST = [
|
|
755
|
-
// ========== Business Partner ==========
|
|
756
|
-
{
|
|
757
|
-
name: "BusinessPartners",
|
|
758
|
-
kind: "EntitySet",
|
|
759
|
-
entityType: "SAPB1.BusinessPartner",
|
|
760
|
-
primaryKey: "CardCode",
|
|
761
|
-
domain: "BusinessPartner",
|
|
762
|
-
description: "\u5BA2\u6237/\u4F9B\u5E94\u5546\u4E3B\u6570\u636E",
|
|
763
|
-
fields: [
|
|
764
|
-
"CardCode",
|
|
765
|
-
"CardName",
|
|
766
|
-
"CardType",
|
|
767
|
-
"GroupCode",
|
|
768
|
-
"Currency",
|
|
769
|
-
"Phone1",
|
|
770
|
-
"Phone2",
|
|
771
|
-
"EmailAddress",
|
|
772
|
-
"Address",
|
|
773
|
-
"City",
|
|
774
|
-
"Country",
|
|
775
|
-
"SalesPersonCode",
|
|
776
|
-
"PriceListNum",
|
|
777
|
-
"CreditLimit",
|
|
778
|
-
"Balance",
|
|
779
|
-
"PayTermsGrpCode",
|
|
780
|
-
"VatGroup",
|
|
781
|
-
"VatLiable",
|
|
782
|
-
"FederalTaxID",
|
|
783
|
-
"Valid",
|
|
784
|
-
"Frozen",
|
|
785
|
-
"CompanyPrivate",
|
|
786
|
-
"CreateDate",
|
|
787
|
-
"UpdateDate"
|
|
788
|
-
]
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
name: "BusinessPartnerGroups",
|
|
792
|
-
kind: "EntitySet",
|
|
793
|
-
entityType: "SAPB1.BusinessPartnerGroup",
|
|
794
|
-
primaryKey: "Code",
|
|
795
|
-
domain: "BusinessPartner",
|
|
796
|
-
description: "BP \u5206\u7EC4",
|
|
797
|
-
fields: ["Code", "Name", "Type"]
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
name: "SalesPersons",
|
|
801
|
-
kind: "EntitySet",
|
|
802
|
-
entityType: "SAPB1.SalesPerson",
|
|
803
|
-
primaryKey: "SalesEmployeeCode",
|
|
804
|
-
domain: "BusinessPartner",
|
|
805
|
-
description: "\u9500\u552E\u96C7\u5458",
|
|
806
|
-
fields: ["SalesEmployeeCode", "SalesEmployeeName", "CommissionGroup", "Valid"]
|
|
807
|
-
},
|
|
808
|
-
// ========== Item / Product ==========
|
|
809
|
-
{
|
|
810
|
-
name: "Items",
|
|
811
|
-
kind: "EntitySet",
|
|
812
|
-
entityType: "SAPB1.Item",
|
|
813
|
-
primaryKey: "ItemCode",
|
|
814
|
-
domain: "Item / Product",
|
|
815
|
-
description: "\u7269\u6599\u4E3B\u6570\u636E",
|
|
816
|
-
fields: [
|
|
817
|
-
"ItemCode",
|
|
818
|
-
"ItemName",
|
|
819
|
-
"ForeignName",
|
|
820
|
-
"ItemsGroupCode",
|
|
821
|
-
"BarCode",
|
|
822
|
-
"SalesItem",
|
|
823
|
-
"PurchaseItem",
|
|
824
|
-
"InventoryItem",
|
|
825
|
-
"SalesUnit",
|
|
826
|
-
"PurchaseUnit",
|
|
827
|
-
"InventoryUOM",
|
|
828
|
-
"QuantityOnStock",
|
|
829
|
-
"AvgStdPrice",
|
|
830
|
-
"DefaultWarehouse",
|
|
831
|
-
"ManageSerialNumbers",
|
|
832
|
-
"ManageBatchNumbers",
|
|
833
|
-
"SalesVATGroup",
|
|
834
|
-
"PurchaseVATGroup",
|
|
835
|
-
"Valid",
|
|
836
|
-
"Frozen",
|
|
837
|
-
"CreateDate",
|
|
838
|
-
"UpdateDate"
|
|
839
|
-
]
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
name: "ItemGroups",
|
|
843
|
-
kind: "EntitySet",
|
|
844
|
-
entityType: "SAPB1.ItemGroups",
|
|
845
|
-
primaryKey: "Number",
|
|
846
|
-
domain: "Item / Product",
|
|
847
|
-
description: "\u7269\u6599\u7EC4",
|
|
848
|
-
fields: ["Number", "GroupName", "CommissionGroup"]
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
name: "PriceLists",
|
|
852
|
-
kind: "EntitySet",
|
|
853
|
-
entityType: "SAPB1.PriceList",
|
|
854
|
-
primaryKey: "PriceListNo",
|
|
855
|
-
domain: "Item / Product",
|
|
856
|
-
description: "\u4EF7\u683C\u6E05\u5355",
|
|
857
|
-
fields: [
|
|
858
|
-
"PriceListNo",
|
|
859
|
-
"PriceListName",
|
|
860
|
-
"DefaultPrimeCurrency",
|
|
861
|
-
"DefaultAdditionalCurrency1",
|
|
862
|
-
"DefaultAdditionalCurrency2",
|
|
863
|
-
"BasePriceList",
|
|
864
|
-
"Factor",
|
|
865
|
-
"Active",
|
|
866
|
-
"IsGrossPrice",
|
|
867
|
-
"RoundingMethod",
|
|
868
|
-
"GroupNum"
|
|
869
|
-
]
|
|
870
|
-
},
|
|
871
|
-
{
|
|
872
|
-
name: "BarCodes",
|
|
873
|
-
kind: "EntitySet",
|
|
874
|
-
entityType: "SAPB1.BarCode",
|
|
875
|
-
primaryKey: "AbsEntry",
|
|
876
|
-
domain: "Item / Product",
|
|
877
|
-
description: "\u6761\u7801",
|
|
878
|
-
fields: ["AbsEntry", "ItemCode", "UoMEntry", "BarCode", "FreeText"]
|
|
879
|
-
},
|
|
880
|
-
// ========== Orders — Sales ==========
|
|
881
|
-
{
|
|
882
|
-
name: "Orders",
|
|
883
|
-
kind: "EntitySet",
|
|
884
|
-
entityType: "SAPB1.Document",
|
|
885
|
-
primaryKey: "DocEntry",
|
|
886
|
-
domain: "Document",
|
|
887
|
-
description: "\u9500\u552E\u8BA2\u5355",
|
|
888
|
-
fields: [
|
|
889
|
-
"DocEntry",
|
|
890
|
-
"DocNum",
|
|
891
|
-
"DocType",
|
|
892
|
-
"DocDate",
|
|
893
|
-
"DocDueDate",
|
|
894
|
-
"TaxDate",
|
|
895
|
-
"CardCode",
|
|
896
|
-
"CardName",
|
|
897
|
-
"Address",
|
|
898
|
-
"DocTotal",
|
|
899
|
-
"DocCurrency",
|
|
900
|
-
"SalesPersonCode",
|
|
901
|
-
"Confirmed",
|
|
902
|
-
"Cancelled",
|
|
903
|
-
"DocumentStatus",
|
|
904
|
-
"Comments",
|
|
905
|
-
"Reference1",
|
|
906
|
-
"Reference2",
|
|
907
|
-
"NumAtCard",
|
|
908
|
-
"VatSum",
|
|
909
|
-
"RoundDif",
|
|
910
|
-
"DiscountPercent",
|
|
911
|
-
"PaymentGroupCode",
|
|
912
|
-
"Project"
|
|
913
|
-
]
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
name: "DeliveryNotes",
|
|
917
|
-
kind: "EntitySet",
|
|
918
|
-
entityType: "SAPB1.Document",
|
|
919
|
-
primaryKey: "DocEntry",
|
|
920
|
-
domain: "Document",
|
|
921
|
-
description: "\u4EA4\u8D27\u5355",
|
|
922
|
-
fields: [
|
|
923
|
-
"DocEntry",
|
|
924
|
-
"DocNum",
|
|
925
|
-
"DocType",
|
|
926
|
-
"DocDate",
|
|
927
|
-
"DocDueDate",
|
|
928
|
-
"TaxDate",
|
|
929
|
-
"CardCode",
|
|
930
|
-
"CardName",
|
|
931
|
-
"DocTotal",
|
|
932
|
-
"DocCurrency",
|
|
933
|
-
"SalesPersonCode",
|
|
934
|
-
"Confirmed",
|
|
935
|
-
"Cancelled",
|
|
936
|
-
"DocumentStatus",
|
|
937
|
-
"Comments",
|
|
938
|
-
"NumAtCard"
|
|
939
|
-
]
|
|
940
|
-
},
|
|
941
|
-
{
|
|
942
|
-
name: "Invoices",
|
|
943
|
-
kind: "EntitySet",
|
|
944
|
-
entityType: "SAPB1.Document",
|
|
945
|
-
primaryKey: "DocEntry",
|
|
946
|
-
domain: "Document",
|
|
947
|
-
description: "\u9500\u552E\u53D1\u7968 (\u5E94\u6536)",
|
|
948
|
-
fields: [
|
|
949
|
-
"DocEntry",
|
|
950
|
-
"DocNum",
|
|
951
|
-
"DocType",
|
|
952
|
-
"DocDate",
|
|
953
|
-
"DocDueDate",
|
|
954
|
-
"TaxDate",
|
|
955
|
-
"CardCode",
|
|
956
|
-
"CardName",
|
|
957
|
-
"DocTotal",
|
|
958
|
-
"DocCurrency",
|
|
959
|
-
"SalesPersonCode",
|
|
960
|
-
"Confirmed",
|
|
961
|
-
"Cancelled",
|
|
962
|
-
"DocumentStatus",
|
|
963
|
-
"Comments",
|
|
964
|
-
"NumAtCard",
|
|
965
|
-
"VatSum"
|
|
966
|
-
]
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
name: "Quotations",
|
|
970
|
-
kind: "EntitySet",
|
|
971
|
-
entityType: "SAPB1.Document",
|
|
972
|
-
primaryKey: "DocEntry",
|
|
973
|
-
domain: "Document",
|
|
974
|
-
description: "\u9500\u552E\u62A5\u4EF7\u5355",
|
|
975
|
-
fields: [
|
|
976
|
-
"DocEntry",
|
|
977
|
-
"DocNum",
|
|
978
|
-
"DocType",
|
|
979
|
-
"DocDate",
|
|
980
|
-
"DocDueDate",
|
|
981
|
-
"CardCode",
|
|
982
|
-
"CardName",
|
|
983
|
-
"DocTotal",
|
|
984
|
-
"DocCurrency",
|
|
985
|
-
"SalesPersonCode",
|
|
986
|
-
"Comments",
|
|
987
|
-
"DocumentStatus"
|
|
988
|
-
]
|
|
989
|
-
},
|
|
990
|
-
{
|
|
991
|
-
name: "CreditNotes",
|
|
992
|
-
kind: "EntitySet",
|
|
993
|
-
entityType: "SAPB1.Document",
|
|
994
|
-
primaryKey: "DocEntry",
|
|
995
|
-
domain: "Document",
|
|
996
|
-
description: "\u9500\u552E\u8D37\u9879\u51ED\u8BC1",
|
|
997
|
-
fields: [
|
|
998
|
-
"DocEntry",
|
|
999
|
-
"DocNum",
|
|
1000
|
-
"DocType",
|
|
1001
|
-
"DocDate",
|
|
1002
|
-
"CardCode",
|
|
1003
|
-
"CardName",
|
|
1004
|
-
"DocTotal",
|
|
1005
|
-
"DocCurrency",
|
|
1006
|
-
"Comments"
|
|
1007
|
-
]
|
|
1008
|
-
},
|
|
1009
|
-
{
|
|
1010
|
-
name: "Returns",
|
|
1011
|
-
kind: "EntitySet",
|
|
1012
|
-
entityType: "SAPB1.Document",
|
|
1013
|
-
primaryKey: "DocEntry",
|
|
1014
|
-
domain: "Document",
|
|
1015
|
-
description: "\u9500\u552E\u9000\u8D27",
|
|
1016
|
-
fields: [
|
|
1017
|
-
"DocEntry",
|
|
1018
|
-
"DocNum",
|
|
1019
|
-
"DocType",
|
|
1020
|
-
"DocDate",
|
|
1021
|
-
"CardCode",
|
|
1022
|
-
"CardName",
|
|
1023
|
-
"DocTotal",
|
|
1024
|
-
"DocCurrency",
|
|
1025
|
-
"Comments"
|
|
1026
|
-
]
|
|
1027
|
-
},
|
|
1028
|
-
{
|
|
1029
|
-
name: "DownPayments",
|
|
1030
|
-
kind: "EntitySet",
|
|
1031
|
-
entityType: "SAPB1.Document",
|
|
1032
|
-
primaryKey: "DocEntry",
|
|
1033
|
-
domain: "Document",
|
|
1034
|
-
description: "\u9884\u6536\u6B3E",
|
|
1035
|
-
fields: [
|
|
1036
|
-
"DocEntry",
|
|
1037
|
-
"DocNum",
|
|
1038
|
-
"DocType",
|
|
1039
|
-
"DocDate",
|
|
1040
|
-
"CardCode",
|
|
1041
|
-
"CardName",
|
|
1042
|
-
"DocTotal",
|
|
1043
|
-
"DocCurrency",
|
|
1044
|
-
"DownPaymentType",
|
|
1045
|
-
"DownPaymentAmount"
|
|
1046
|
-
]
|
|
1047
|
-
},
|
|
1048
|
-
{
|
|
1049
|
-
name: "Drafts",
|
|
1050
|
-
kind: "EntitySet",
|
|
1051
|
-
entityType: "SAPB1.Document",
|
|
1052
|
-
primaryKey: "DocEntry",
|
|
1053
|
-
domain: "Document",
|
|
1054
|
-
description: "\u9500\u552E\u8349\u7A3F/\u91C7\u8D2D\u8349\u7A3F\uFF08\u652F\u6301\u521B\u5EFA\u3001\u67E5\u8BE2\u3001\u66F4\u65B0\u3001\u5220\u9664\uFF09",
|
|
1055
|
-
fields: [
|
|
1056
|
-
"DocEntry",
|
|
1057
|
-
"DocNum",
|
|
1058
|
-
"DocObjectCode",
|
|
1059
|
-
"DocType",
|
|
1060
|
-
"DocDate",
|
|
1061
|
-
"DocDueDate",
|
|
1062
|
-
"TaxDate",
|
|
1063
|
-
"CardCode",
|
|
1064
|
-
"CardName",
|
|
1065
|
-
"DocTotal",
|
|
1066
|
-
"DocCurrency",
|
|
1067
|
-
"Comments",
|
|
1068
|
-
"SalesPersonCode",
|
|
1069
|
-
"Confirmed",
|
|
1070
|
-
"Cancelled",
|
|
1071
|
-
"DocumentStatus",
|
|
1072
|
-
"U_YWLX",
|
|
1073
|
-
"U_YWLX2",
|
|
1074
|
-
"DocumentLines"
|
|
1075
|
-
]
|
|
1076
|
-
},
|
|
1077
|
-
// ========== Orders — Purchase ==========
|
|
1078
|
-
{
|
|
1079
|
-
name: "PurchaseOrders",
|
|
1080
|
-
kind: "EntitySet",
|
|
1081
|
-
entityType: "SAPB1.Document",
|
|
1082
|
-
primaryKey: "DocEntry",
|
|
1083
|
-
domain: "Document",
|
|
1084
|
-
description: "\u91C7\u8D2D\u8BA2\u5355",
|
|
1085
|
-
fields: [
|
|
1086
|
-
"DocEntry",
|
|
1087
|
-
"DocNum",
|
|
1088
|
-
"DocType",
|
|
1089
|
-
"DocDate",
|
|
1090
|
-
"DocDueDate",
|
|
1091
|
-
"TaxDate",
|
|
1092
|
-
"CardCode",
|
|
1093
|
-
"CardName",
|
|
1094
|
-
"DocTotal",
|
|
1095
|
-
"DocCurrency",
|
|
1096
|
-
"SalesPersonCode",
|
|
1097
|
-
"Confirmed",
|
|
1098
|
-
"Cancelled",
|
|
1099
|
-
"DocumentStatus",
|
|
1100
|
-
"Comments",
|
|
1101
|
-
"NumAtCard"
|
|
1102
|
-
]
|
|
1103
|
-
},
|
|
1104
|
-
{
|
|
1105
|
-
name: "PurchaseDeliveryNotes",
|
|
1106
|
-
kind: "EntitySet",
|
|
1107
|
-
entityType: "SAPB1.Document",
|
|
1108
|
-
primaryKey: "DocEntry",
|
|
1109
|
-
domain: "Document",
|
|
1110
|
-
description: "\u91C7\u8D2D\u6536\u8D27\u5355",
|
|
1111
|
-
fields: [
|
|
1112
|
-
"DocEntry",
|
|
1113
|
-
"DocNum",
|
|
1114
|
-
"DocType",
|
|
1115
|
-
"DocDate",
|
|
1116
|
-
"CardCode",
|
|
1117
|
-
"CardName",
|
|
1118
|
-
"DocTotal",
|
|
1119
|
-
"Comments"
|
|
1120
|
-
]
|
|
1121
|
-
},
|
|
1122
|
-
{
|
|
1123
|
-
name: "PurchaseInvoices",
|
|
1124
|
-
kind: "EntitySet",
|
|
1125
|
-
entityType: "SAPB1.Document",
|
|
1126
|
-
primaryKey: "DocEntry",
|
|
1127
|
-
domain: "Document",
|
|
1128
|
-
description: "\u91C7\u8D2D\u53D1\u7968 (\u5E94\u4ED8)",
|
|
1129
|
-
fields: [
|
|
1130
|
-
"DocEntry",
|
|
1131
|
-
"DocNum",
|
|
1132
|
-
"DocType",
|
|
1133
|
-
"DocDate",
|
|
1134
|
-
"DocDueDate",
|
|
1135
|
-
"CardCode",
|
|
1136
|
-
"CardName",
|
|
1137
|
-
"DocTotal",
|
|
1138
|
-
"DocCurrency",
|
|
1139
|
-
"Comments"
|
|
1140
|
-
]
|
|
1141
|
-
},
|
|
1142
|
-
{
|
|
1143
|
-
name: "PurchaseReturns",
|
|
1144
|
-
kind: "EntitySet",
|
|
1145
|
-
entityType: "SAPB1.Document",
|
|
1146
|
-
primaryKey: "DocEntry",
|
|
1147
|
-
domain: "Document",
|
|
1148
|
-
description: "\u91C7\u8D2D\u9000\u8D27",
|
|
1149
|
-
fields: [
|
|
1150
|
-
"DocEntry",
|
|
1151
|
-
"DocNum",
|
|
1152
|
-
"DocType",
|
|
1153
|
-
"DocDate",
|
|
1154
|
-
"CardCode",
|
|
1155
|
-
"CardName",
|
|
1156
|
-
"DocTotal",
|
|
1157
|
-
"Comments"
|
|
1158
|
-
]
|
|
1159
|
-
},
|
|
1160
|
-
{
|
|
1161
|
-
name: "PurchaseQuotations",
|
|
1162
|
-
kind: "EntitySet",
|
|
1163
|
-
entityType: "SAPB1.Document",
|
|
1164
|
-
primaryKey: "DocEntry",
|
|
1165
|
-
domain: "Document",
|
|
1166
|
-
description: "\u91C7\u8D2D\u62A5\u4EF7",
|
|
1167
|
-
fields: [
|
|
1168
|
-
"DocEntry",
|
|
1169
|
-
"DocNum",
|
|
1170
|
-
"DocType",
|
|
1171
|
-
"DocDate",
|
|
1172
|
-
"CardCode",
|
|
1173
|
-
"CardName",
|
|
1174
|
-
"DocTotal",
|
|
1175
|
-
"Comments"
|
|
1176
|
-
]
|
|
1177
|
-
},
|
|
1178
|
-
// ========== Inventory / Warehouse ==========
|
|
1179
|
-
{
|
|
1180
|
-
name: "InventoryGenEntries",
|
|
1181
|
-
kind: "EntitySet",
|
|
1182
|
-
entityType: "SAPB1.Document",
|
|
1183
|
-
primaryKey: "DocEntry",
|
|
1184
|
-
domain: "Inventory / Warehouse",
|
|
1185
|
-
description: "\u5E93\u5B58\u6536\u8D27",
|
|
1186
|
-
fields: [
|
|
1187
|
-
"DocEntry",
|
|
1188
|
-
"DocNum",
|
|
1189
|
-
"DocType",
|
|
1190
|
-
"DocDate",
|
|
1191
|
-
"Comments",
|
|
1192
|
-
"JournalMemo",
|
|
1193
|
-
"Reference1",
|
|
1194
|
-
"Reference2",
|
|
1195
|
-
"WareHouseUpdateType"
|
|
1196
|
-
]
|
|
1197
|
-
},
|
|
1198
|
-
{
|
|
1199
|
-
name: "InventoryGenExits",
|
|
1200
|
-
kind: "EntitySet",
|
|
1201
|
-
entityType: "SAPB1.Document",
|
|
1202
|
-
primaryKey: "DocEntry",
|
|
1203
|
-
domain: "Inventory / Warehouse",
|
|
1204
|
-
description: "\u5E93\u5B58\u53D1\u8D27",
|
|
1205
|
-
fields: [
|
|
1206
|
-
"DocEntry",
|
|
1207
|
-
"DocNum",
|
|
1208
|
-
"DocType",
|
|
1209
|
-
"DocDate",
|
|
1210
|
-
"Comments",
|
|
1211
|
-
"JournalMemo",
|
|
1212
|
-
"Reference1",
|
|
1213
|
-
"Reference2"
|
|
1214
|
-
]
|
|
1215
|
-
},
|
|
1216
|
-
{
|
|
1217
|
-
name: "StockTransfers",
|
|
1218
|
-
kind: "EntitySet",
|
|
1219
|
-
entityType: "SAPB1.StockTransfer",
|
|
1220
|
-
primaryKey: "DocEntry",
|
|
1221
|
-
domain: "Inventory / Warehouse",
|
|
1222
|
-
description: "\u5E93\u5B58\u8F6C\u50A8",
|
|
1223
|
-
fields: [
|
|
1224
|
-
"DocEntry",
|
|
1225
|
-
"DocNum",
|
|
1226
|
-
"DocDate",
|
|
1227
|
-
"DueDate",
|
|
1228
|
-
"FromWarehouse",
|
|
1229
|
-
"ToWarehouse",
|
|
1230
|
-
"Comments",
|
|
1231
|
-
"Reference1",
|
|
1232
|
-
"Reference2"
|
|
1233
|
-
]
|
|
1234
|
-
},
|
|
1235
|
-
{
|
|
1236
|
-
name: "InventoryPostings",
|
|
1237
|
-
kind: "EntitySet",
|
|
1238
|
-
entityType: "SAPB1.InventoryPosting",
|
|
1239
|
-
primaryKey: "DocumentEntry",
|
|
1240
|
-
domain: "Inventory / Warehouse",
|
|
1241
|
-
description: "\u5E93\u5B58\u8FC7\u8D26",
|
|
1242
|
-
fields: [
|
|
1243
|
-
"DocumentEntry",
|
|
1244
|
-
"DocumentNumber",
|
|
1245
|
-
"PostingDate",
|
|
1246
|
-
"CountDate",
|
|
1247
|
-
"Remarks",
|
|
1248
|
-
"Reference2",
|
|
1249
|
-
"PriceList"
|
|
1250
|
-
]
|
|
1251
|
-
},
|
|
1252
|
-
{
|
|
1253
|
-
name: "InventoryCountings",
|
|
1254
|
-
kind: "EntitySet",
|
|
1255
|
-
entityType: "SAPB1.InventoryCounting",
|
|
1256
|
-
primaryKey: "DocumentEntry",
|
|
1257
|
-
domain: "Inventory / Warehouse",
|
|
1258
|
-
description: "\u5E93\u5B58\u76D8\u70B9",
|
|
1259
|
-
fields: [
|
|
1260
|
-
"DocumentEntry",
|
|
1261
|
-
"DocumentNumber",
|
|
1262
|
-
"CountDate",
|
|
1263
|
-
"SingleCounterType",
|
|
1264
|
-
"SingleCounterID",
|
|
1265
|
-
"Remarks"
|
|
1266
|
-
]
|
|
1267
|
-
},
|
|
1268
|
-
{
|
|
1269
|
-
name: "Warehouses",
|
|
1270
|
-
kind: "EntitySet",
|
|
1271
|
-
entityType: "SAPB1.Warehouse",
|
|
1272
|
-
primaryKey: "WarehouseCode",
|
|
1273
|
-
domain: "Inventory / Warehouse",
|
|
1274
|
-
description: "\u4ED3\u5E93\u5B9A\u4E49",
|
|
1275
|
-
fields: [
|
|
1276
|
-
"WarehouseCode",
|
|
1277
|
-
"WarehouseName",
|
|
1278
|
-
"Street",
|
|
1279
|
-
"City",
|
|
1280
|
-
"Country",
|
|
1281
|
-
"Location",
|
|
1282
|
-
"DropShip",
|
|
1283
|
-
"Nettable",
|
|
1284
|
-
"Inactive",
|
|
1285
|
-
"EnableBinLocations",
|
|
1286
|
-
"ManageSerialAndBatchNumbers"
|
|
1287
|
-
]
|
|
1288
|
-
},
|
|
1289
|
-
{
|
|
1290
|
-
name: "BinLocations",
|
|
1291
|
-
kind: "EntitySet",
|
|
1292
|
-
entityType: "SAPB1.BinLocation",
|
|
1293
|
-
primaryKey: "AbsEntry",
|
|
1294
|
-
domain: "Inventory / Warehouse",
|
|
1295
|
-
description: "\u5E93\u4F4D",
|
|
1296
|
-
fields: [
|
|
1297
|
-
"AbsEntry",
|
|
1298
|
-
"Warehouse",
|
|
1299
|
-
"BinCode",
|
|
1300
|
-
"Description",
|
|
1301
|
-
"Sublevel1",
|
|
1302
|
-
"Sublevel2",
|
|
1303
|
-
"Sublevel3",
|
|
1304
|
-
"Sublevel4",
|
|
1305
|
-
"Inactive",
|
|
1306
|
-
"MinimumQty",
|
|
1307
|
-
"MaximumQty"
|
|
1308
|
-
]
|
|
1309
|
-
},
|
|
1310
|
-
{
|
|
1311
|
-
name: "BatchNumberDetails",
|
|
1312
|
-
kind: "EntitySet",
|
|
1313
|
-
entityType: "SAPB1.BatchNumberDetail",
|
|
1314
|
-
primaryKey: "DocEntry",
|
|
1315
|
-
domain: "Inventory / Warehouse",
|
|
1316
|
-
description: "\u6279\u6B21\u53F7\u660E\u7EC6",
|
|
1317
|
-
fields: [
|
|
1318
|
-
"DocEntry",
|
|
1319
|
-
"ItemCode",
|
|
1320
|
-
"ItemDescription",
|
|
1321
|
-
"Batch",
|
|
1322
|
-
"BatchAttribute1",
|
|
1323
|
-
"BatchAttribute2",
|
|
1324
|
-
"AdmissionDate",
|
|
1325
|
-
"ExpirationDate",
|
|
1326
|
-
"ManufacturingDate"
|
|
1327
|
-
]
|
|
1328
|
-
},
|
|
1329
|
-
{
|
|
1330
|
-
name: "SerialNumberDetails",
|
|
1331
|
-
kind: "EntitySet",
|
|
1332
|
-
entityType: "SAPB1.SerialNumberDetail",
|
|
1333
|
-
primaryKey: "DocEntry",
|
|
1334
|
-
domain: "Inventory / Warehouse",
|
|
1335
|
-
description: "\u5E8F\u5217\u53F7\u660E\u7EC6",
|
|
1336
|
-
fields: [
|
|
1337
|
-
"DocEntry",
|
|
1338
|
-
"ItemCode",
|
|
1339
|
-
"ItemDescription",
|
|
1340
|
-
"SerialNumber",
|
|
1341
|
-
"MfrSerialNo",
|
|
1342
|
-
"AdmissionDate",
|
|
1343
|
-
"ExpirationDate"
|
|
1344
|
-
]
|
|
1345
|
-
},
|
|
1346
|
-
// ========== Function Imports (常用) ==========
|
|
1347
|
-
{
|
|
1348
|
-
name: "ItemsService_InitData",
|
|
1349
|
-
kind: "FunctionImport",
|
|
1350
|
-
entityType: "SAPB1.Item",
|
|
1351
|
-
domain: "Item / Product",
|
|
1352
|
-
description: "\u521D\u59CB\u5316\u7269\u6599\u6570\u636E",
|
|
1353
|
-
fields: []
|
|
1354
|
-
},
|
|
1355
|
-
{
|
|
1356
|
-
name: "BusinessPartnersService_InitData",
|
|
1357
|
-
kind: "FunctionImport",
|
|
1358
|
-
entityType: "SAPB1.BusinessPartner",
|
|
1359
|
-
domain: "BusinessPartner",
|
|
1360
|
-
description: "\u521D\u59CB\u5316 BP \u6570\u636E",
|
|
1361
|
-
fields: []
|
|
1362
|
-
},
|
|
1363
|
-
{
|
|
1364
|
-
name: "OrdersService_InitData",
|
|
1365
|
-
kind: "FunctionImport",
|
|
1366
|
-
entityType: "SAPB1.Document",
|
|
1367
|
-
domain: "Document",
|
|
1368
|
-
description: "\u521D\u59CB\u5316\u8BA2\u5355\u6570\u636E",
|
|
1369
|
-
fields: []
|
|
1370
|
-
},
|
|
1371
|
-
{
|
|
1372
|
-
name: "InvoicesService_InitData",
|
|
1373
|
-
kind: "FunctionImport",
|
|
1374
|
-
entityType: "SAPB1.Document",
|
|
1375
|
-
domain: "Document",
|
|
1376
|
-
description: "\u521D\u59CB\u5316\u53D1\u7968\u6570\u636E",
|
|
1377
|
-
fields: []
|
|
1378
|
-
},
|
|
1379
|
-
// ========== Pricing / Cost / Rate ==========
|
|
1380
|
-
{
|
|
1381
|
-
name: "SpecialPrices",
|
|
1382
|
-
kind: "EntitySet",
|
|
1383
|
-
entityType: "SAPB1.SpecialPrice",
|
|
1384
|
-
primaryKey: "ItemCode+CardCode",
|
|
1385
|
-
domain: "Item / Product",
|
|
1386
|
-
description: "\u7279\u6B8A\u4EF7\u683C\uFF08BP/\u5BA2\u6237\u7279\u5B9A\u4EF7\u683C\uFF09",
|
|
1387
|
-
fields: [
|
|
1388
|
-
"ItemCode",
|
|
1389
|
-
"CardCode",
|
|
1390
|
-
"Price",
|
|
1391
|
-
"Currency",
|
|
1392
|
-
"DiscountPercent",
|
|
1393
|
-
"PriceListNum",
|
|
1394
|
-
"AutoUpdate",
|
|
1395
|
-
"SourcePrice"
|
|
1396
|
-
]
|
|
1397
|
-
},
|
|
1398
|
-
{
|
|
1399
|
-
name: "LandedCosts",
|
|
1400
|
-
kind: "EntitySet",
|
|
1401
|
-
entityType: "SAPB1.LandedCost",
|
|
1402
|
-
primaryKey: "DocEntry",
|
|
1403
|
-
domain: "Document",
|
|
1404
|
-
description: "\u5230\u5CB8\u6210\u672C/\u9644\u52A0\u6210\u672C\u51ED\u8BC1",
|
|
1405
|
-
fields: ["DocEntry", "DocNum", "DocDate", "CardCode", "Comments"]
|
|
1406
|
-
},
|
|
1407
|
-
{
|
|
1408
|
-
name: "LandedCostsCodes",
|
|
1409
|
-
kind: "EntitySet",
|
|
1410
|
-
entityType: "SAPB1.LandedCostsCode",
|
|
1411
|
-
primaryKey: "Code",
|
|
1412
|
-
domain: "Document",
|
|
1413
|
-
description: "\u5230\u5CB8\u6210\u672C\u4EE3\u7801\u5B9A\u4E49",
|
|
1414
|
-
fields: ["Code", "Name"]
|
|
1415
|
-
},
|
|
1416
|
-
{
|
|
1417
|
-
name: "CompanyService_GetItemPrice",
|
|
1418
|
-
kind: "FunctionImport",
|
|
1419
|
-
entityType: "SAPB1.ItemPriceReturnParams",
|
|
1420
|
-
domain: "Item / Product",
|
|
1421
|
-
description: "\u6839\u636E\u53C2\u6570\u67E5\u8BE2\u7269\u6599\u4EF7\u683C\uFF08\u542B\u5386\u53F2\u660E\u7EC6\uFF09",
|
|
1422
|
-
fields: ["ItemPrices", "ItemUnitOfMeasurementCollection"]
|
|
1423
|
-
},
|
|
1424
|
-
{
|
|
1425
|
-
name: "SBOBobService_GetCurrencyRate",
|
|
1426
|
-
kind: "FunctionImport",
|
|
1427
|
-
domain: "Finance / Accounting",
|
|
1428
|
-
description: "\u83B7\u53D6\u8D27\u5E01\u6C47\u7387",
|
|
1429
|
-
fields: []
|
|
1430
|
-
},
|
|
1431
|
-
{
|
|
1432
|
-
name: "SBOBobService_GetIndexRate",
|
|
1433
|
-
kind: "FunctionImport",
|
|
1434
|
-
domain: "Finance / Accounting",
|
|
1435
|
-
description: "\u83B7\u53D6\u6307\u6570\u6C47\u7387",
|
|
1436
|
-
fields: []
|
|
1437
|
-
},
|
|
1438
|
-
{
|
|
1439
|
-
name: "SBOBobService_SetCurrencyRate",
|
|
1440
|
-
kind: "FunctionImport",
|
|
1441
|
-
domain: "Finance / Accounting",
|
|
1442
|
-
description: "\u8BBE\u7F6E\u8D27\u5E01\u6C47\u7387",
|
|
1443
|
-
fields: []
|
|
1444
|
-
},
|
|
1445
|
-
{
|
|
1446
|
-
name: "Z20_COST",
|
|
1447
|
-
kind: "EntitySet",
|
|
1448
|
-
entityType: "SAPB1.Z20_COST",
|
|
1449
|
-
primaryKey: "DocEntry",
|
|
1450
|
-
domain: "Item / Product",
|
|
1451
|
-
description: "\u81EA\u5B9A\u4E49: \u6210\u672C\u8BB0\u5F55\u8868\uFF08\u542B\u5468\u671F/\u5B9E\u4F8B\u7EF4\u5EA6\u7684\u6210\u672C\u5386\u53F2\uFF09",
|
|
1452
|
-
fields: [
|
|
1453
|
-
"DocEntry",
|
|
1454
|
-
"DocNum",
|
|
1455
|
-
"Period",
|
|
1456
|
-
"Instance",
|
|
1457
|
-
"Series",
|
|
1458
|
-
"Status",
|
|
1459
|
-
"RequestStatus",
|
|
1460
|
-
"Creator",
|
|
1461
|
-
"Remark",
|
|
1462
|
-
"Canceled",
|
|
1463
|
-
"Object",
|
|
1464
|
-
"CreateDate",
|
|
1465
|
-
"CreateTime"
|
|
1466
|
-
]
|
|
1467
|
-
},
|
|
1468
|
-
{
|
|
1469
|
-
name: "Z20_CPAT",
|
|
1470
|
-
kind: "EntitySet",
|
|
1471
|
-
entityType: "SAPB1.Z20_CPAT",
|
|
1472
|
-
primaryKey: "DocEntry",
|
|
1473
|
-
domain: "Item / Product",
|
|
1474
|
-
description: "\u81EA\u5B9A\u4E49: \u6210\u672C/\u4EF7\u683C\u5206\u644A\u8BB0\u5F55",
|
|
1475
|
-
fields: [
|
|
1476
|
-
"DocEntry",
|
|
1477
|
-
"DocNum",
|
|
1478
|
-
"Period",
|
|
1479
|
-
"Instance",
|
|
1480
|
-
"Status",
|
|
1481
|
-
"Creator",
|
|
1482
|
-
"Remark",
|
|
1483
|
-
"CreateDate",
|
|
1484
|
-
"CreateTime"
|
|
1485
|
-
]
|
|
1486
|
-
},
|
|
1487
|
-
{
|
|
1488
|
-
name: "Z20_OINP",
|
|
1489
|
-
kind: "EntitySet",
|
|
1490
|
-
entityType: "SAPB1.Z20_OINP",
|
|
1491
|
-
primaryKey: "DocEntry",
|
|
1492
|
-
domain: "Document",
|
|
1493
|
-
description: "\u81EA\u5B9A\u4E49: \u91C7\u8D2D\u8BA2\u5355\u8F93\u5165\u4EF7\u683C\u8BB0\u5F55",
|
|
1494
|
-
fields: [
|
|
1495
|
-
"DocEntry",
|
|
1496
|
-
"DocNum",
|
|
1497
|
-
"Period",
|
|
1498
|
-
"Instance",
|
|
1499
|
-
"Status",
|
|
1500
|
-
"Creator",
|
|
1501
|
-
"Remark",
|
|
1502
|
-
"CreateDate",
|
|
1503
|
-
"CreateTime"
|
|
1504
|
-
]
|
|
1505
|
-
},
|
|
1506
|
-
{
|
|
1507
|
-
name: "Z20_PWAG",
|
|
1508
|
-
kind: "EntitySet",
|
|
1509
|
-
entityType: "SAPB1.Z20_PWAG",
|
|
1510
|
-
primaryKey: "DocEntry",
|
|
1511
|
-
domain: "Item / Product",
|
|
1512
|
-
description: "\u81EA\u5B9A\u4E49: \u5DE5\u4EF7/\u5DE5\u5E8F\u4EF7\u683C\u8BB0\u5F55",
|
|
1513
|
-
fields: [
|
|
1514
|
-
"DocEntry",
|
|
1515
|
-
"DocNum",
|
|
1516
|
-
"Period",
|
|
1517
|
-
"Instance",
|
|
1518
|
-
"Status",
|
|
1519
|
-
"Creator",
|
|
1520
|
-
"Remark",
|
|
1521
|
-
"CreateDate",
|
|
1522
|
-
"CreateTime"
|
|
1523
|
-
]
|
|
1524
|
-
},
|
|
1525
|
-
{
|
|
1526
|
-
name: "Z20_HOLD",
|
|
1527
|
-
kind: "EntitySet",
|
|
1528
|
-
entityType: "SAPB1.Z20_HOLD",
|
|
1529
|
-
primaryKey: "DocEntry",
|
|
1530
|
-
domain: "Inventory / Warehouse",
|
|
1531
|
-
description: "\u81EA\u5B9A\u4E49: \u6682\u5B58/\u51BB\u7ED3\u5E93\u5B58\u8BB0\u5F55",
|
|
1532
|
-
fields: [
|
|
1533
|
-
"DocEntry",
|
|
1534
|
-
"DocNum",
|
|
1535
|
-
"Period",
|
|
1536
|
-
"Instance",
|
|
1537
|
-
"Status",
|
|
1538
|
-
"Creator",
|
|
1539
|
-
"Remark",
|
|
1540
|
-
"CreateDate",
|
|
1541
|
-
"CreateTime"
|
|
1542
|
-
]
|
|
1543
|
-
},
|
|
1544
|
-
{
|
|
1545
|
-
name: "Z20_IMIT",
|
|
1546
|
-
kind: "EntitySet",
|
|
1547
|
-
entityType: "SAPB1.Z20_IMIT",
|
|
1548
|
-
primaryKey: "DocEntry",
|
|
1549
|
-
domain: "Inventory / Warehouse",
|
|
1550
|
-
description: "\u81EA\u5B9A\u4E49: \u5E93\u5B58\u521D\u59CB\u5316\u8BB0\u5F55",
|
|
1551
|
-
fields: [
|
|
1552
|
-
"DocEntry",
|
|
1553
|
-
"DocNum",
|
|
1554
|
-
"Period",
|
|
1555
|
-
"Instance",
|
|
1556
|
-
"Status",
|
|
1557
|
-
"Creator",
|
|
1558
|
-
"Remark",
|
|
1559
|
-
"CreateDate",
|
|
1560
|
-
"CreateTime"
|
|
1561
|
-
]
|
|
1562
|
-
}
|
|
1563
|
-
];
|
|
1564
|
-
registerToolLattice(
|
|
1565
|
-
"sap_api_search",
|
|
1566
|
-
{
|
|
1567
|
-
name: "sap_api_search",
|
|
1568
|
-
description: "\u641C\u7D22 SAP B1 Service Layer API \u63A5\u53E3\u3002\u8986\u76D6\u4E1A\u52A1\u4F19\u4F34(BP)\u3001\u7269\u6599(Item)\u3001\u9500\u552E/\u91C7\u8D2D\u8BA2\u5355(Document/Order)\u3001\u5E93\u5B58(Inventory/Warehouse) \u56DB\u5927\u9886\u57DF\u3002\u8FD4\u56DE\u63A5\u53E3\u540D\u79F0\u3001\u4E3B\u952E\u3001\u5E38\u7528\u5B57\u6BB5\u5217\u8868\u53CA\u63CF\u8FF0\u3002",
|
|
1569
|
-
needUserApprove: false,
|
|
1570
|
-
schema: z4.object({
|
|
1571
|
-
query: z4.string().describe(
|
|
1572
|
-
"\u641C\u7D22\u5173\u952E\u8BCD\u3002\u53EF\u4EE5\u662F API \u540D\u79F0\uFF08\u5982 'BusinessPartners', 'Orders', 'Items', 'PurchaseOrders'\uFF09\u6216\u4E1A\u52A1\u63CF\u8FF0\uFF08\u5982 '\u5BA2\u6237', '\u8BA2\u5355', '\u7269\u6599', '\u5E93\u5B58', '\u91C7\u8D2D', '\u4ED3\u5E93'\uFF09"
|
|
1573
|
-
),
|
|
1574
|
-
domain: z4.string().optional().describe(
|
|
1575
|
-
"\u6309\u9886\u57DF\u8FC7\u6EE4: 'BusinessPartner'(BP), 'Item / Product'(\u7269\u6599), 'Document'(\u8BA2\u5355/\u53D1\u7968), 'Inventory / Warehouse'(\u5E93\u5B58/\u4ED3\u5E93)"
|
|
1576
|
-
),
|
|
1577
|
-
maxResults: z4.number().optional().default(10).describe("\u6700\u5927\u8FD4\u56DE\u6761\u6570")
|
|
1578
|
-
})
|
|
1579
|
-
},
|
|
1580
|
-
async (input) => {
|
|
1581
|
-
const q = input.query.toLowerCase();
|
|
1582
|
-
const max = input.maxResults ?? 10;
|
|
1583
|
-
const domainHints = {
|
|
1584
|
-
"\u5BA2\u6237": "BusinessPartner",
|
|
1585
|
-
"\u4F9B\u5E94\u5546": "BusinessPartner",
|
|
1586
|
-
"bp": "BusinessPartner",
|
|
1587
|
-
"\u7269\u6599": "Item / Product",
|
|
1588
|
-
"\u4EA7\u54C1": "Item / Product",
|
|
1589
|
-
"\u5546\u54C1": "Item / Product",
|
|
1590
|
-
"\u8D27\u54C1": "Item / Product",
|
|
1591
|
-
"\u8BA2\u5355": "Document",
|
|
1592
|
-
"\u9500\u552E": "Document",
|
|
1593
|
-
"\u91C7\u8D2D": "Document",
|
|
1594
|
-
"\u53D1\u7968": "Document",
|
|
1595
|
-
"\u4EA4\u8D27": "Document",
|
|
1596
|
-
"\u62A5\u4EF7": "Document",
|
|
1597
|
-
"\u8349\u7A3F": "Document",
|
|
1598
|
-
"\u5E93\u5B58": "Inventory / Warehouse",
|
|
1599
|
-
"\u4ED3\u5E93": "Inventory / Warehouse",
|
|
1600
|
-
"\u5E93\u4F4D": "Inventory / Warehouse",
|
|
1601
|
-
"\u6279\u6B21": "Inventory / Warehouse",
|
|
1602
|
-
"\u5E8F\u5217\u53F7": "Inventory / Warehouse",
|
|
1603
|
-
"\u6536\u8D27": "Inventory / Warehouse",
|
|
1604
|
-
"\u53D1\u8D27": "Inventory / Warehouse",
|
|
1605
|
-
"\u8F6C\u50A8": "Inventory / Warehouse",
|
|
1606
|
-
"\u76D8\u70B9": "Inventory / Warehouse",
|
|
1607
|
-
"\u8FC7\u8D26": "Inventory / Warehouse",
|
|
1608
|
-
"\u4EF7\u683C": "Item / Product",
|
|
1609
|
-
"\u6210\u672C": "Item / Product",
|
|
1610
|
-
"\u6C47\u7387": "Finance / Accounting",
|
|
1611
|
-
"\u5230\u5CB8": "Document"
|
|
1612
|
-
};
|
|
1613
|
-
const hintedDomain = domainHints[q] || void 0;
|
|
1614
|
-
const effectiveDomain = input.domain || hintedDomain;
|
|
1615
|
-
const scored = API_LIST.filter((e) => {
|
|
1616
|
-
if (effectiveDomain && e.domain !== effectiveDomain) return false;
|
|
1617
|
-
return true;
|
|
1618
|
-
}).map((e) => {
|
|
1619
|
-
let score = 0;
|
|
1620
|
-
const nameLo = e.name.toLowerCase();
|
|
1621
|
-
const descLo = e.description.toLowerCase();
|
|
1622
|
-
const typeLo = (e.entityType || "").toLowerCase();
|
|
1623
|
-
if (nameLo === q) score += 100;
|
|
1624
|
-
else if (nameLo.startsWith(q)) score += 60;
|
|
1625
|
-
else if (nameLo.includes(q)) score += 30;
|
|
1626
|
-
if (descLo.includes(q)) score += 20;
|
|
1627
|
-
if (typeLo.includes(q)) score += 10;
|
|
1628
|
-
for (const word of q.split(/[\s_\-/]+/).filter((w) => w.length >= 2)) {
|
|
1629
|
-
if (nameLo.includes(word)) score += 10;
|
|
1630
|
-
if (descLo.includes(word)) score += 5;
|
|
1631
|
-
}
|
|
1632
|
-
return { ...e, score };
|
|
1633
|
-
});
|
|
1634
|
-
const top = scored.filter((e) => e.score > 0).sort((a, b) => b.score - a.score).slice(0, max);
|
|
1635
|
-
const domainCounts = {};
|
|
1636
|
-
for (const e of top) domainCounts[e.domain] = (domainCounts[e.domain] || 0) + 1;
|
|
1637
|
-
return {
|
|
1638
|
-
query: input.query,
|
|
1639
|
-
domainFilter: effectiveDomain || null,
|
|
1640
|
-
totalMatches: scored.filter((e) => e.score > 0).length,
|
|
1641
|
-
domainsFound: domainCounts,
|
|
1642
|
-
results: top.map((e) => ({
|
|
1643
|
-
name: e.name,
|
|
1644
|
-
kind: e.kind,
|
|
1645
|
-
domain: e.domain,
|
|
1646
|
-
description: e.description,
|
|
1647
|
-
primaryKey: e.primaryKey || null,
|
|
1648
|
-
fields: e.fields,
|
|
1649
|
-
hint: e.kind === "EntitySet" ? `${e.name} \u2014 ${e.description}\u3002\u4E3B\u952E: ${e.primaryKey}\u3002\u8C03\u7528 sap_api_call \u8FDB\u884C CRUD \u64CD\u4F5C\u3002` : `${e.name} \u2014 ${e.description}\u3002\u8C03\u7528 sap_api_call \u6267\u884C\u6B64\u65B9\u6CD5\u3002`
|
|
1650
|
-
})),
|
|
1651
|
-
suggestion: top.length === 0 ? `\u672A\u627E\u5230\u5339\u914D "${input.query}" \u7684\u63A5\u53E3\u3002\u53EF\u7528\u9886\u57DF: BusinessPartner(\u5BA2\u6237/\u4F9B\u5E94\u5546), Item / Product(\u7269\u6599), Document(\u8BA2\u5355/\u53D1\u7968), Inventory / Warehouse(\u5E93\u5B58/\u4ED3\u5E93)\u3002\u5C1D\u8BD5\u7528\u82F1\u6587\u540D\u79F0\u641C\u7D22\u3002` : void 0
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
|
-
);
|
|
1655
|
-
var SAP_COOKIE = process.env.SAP_B1SESSION ? `B1SESSION=${process.env.SAP_B1SESSION}; ROUTEID=.node0` : "";
|
|
1656
|
-
registerToolLattice(
|
|
1657
|
-
"sap_api_call",
|
|
1658
|
-
{
|
|
1659
|
-
name: "sap_api_call",
|
|
1660
|
-
description: `\u6267\u884C\u5BF9 SAP B1 Service Layer \u7684 OData API \u8C03\u7528\u3002\u76F4\u63A5\u53D1\u8D77 HTTP \u8BF7\u6C42\u5E76\u8FD4\u56DE\u54CD\u5E94\u6570\u636E\u3002\u5F53\u524D Base URL: ${BASE_URL}\u3002GET \u8BF7\u6C42\u901A\u5E38\u65E0\u9700\u8BA4\u8BC1\uFF0CPOST/PATCH/DELETE \u9700\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF SAP_B1SESSION\u3002`,
|
|
1661
|
-
needUserApprove: false,
|
|
1662
|
-
schema: z4.object({
|
|
1663
|
-
entitySet: z4.string().describe("EntitySet \u540D\u79F0\uFF0C\u5982 'BusinessPartners', 'Orders', 'Items', 'PurchaseOrders'"),
|
|
1664
|
-
method: z4.enum(["GET", "POST", "PATCH", "DELETE"]).describe("HTTP \u65B9\u6CD5"),
|
|
1665
|
-
id: z4.string().optional().describe("\u4E3B\u952E\u503C\uFF0CGET/PATCH/DELETE \u5355\u4E2A\u5B9E\u4F53\u65F6\u4F7F\u7528\u3002\u5982 /BusinessPartners('C001')"),
|
|
1666
|
-
queryOptions: z4.string().optional().describe(
|
|
1667
|
-
"OData \u67E5\u8BE2\u53C2\u6570\uFF08\u4E0D\u542B `?` \u524D\u7F00\uFF09\u3002\u5E38\u7528: $top=10, $skip=20, $select=CardCode,CardName, $filter=contains(CardName,'\u6E05\u534E'), $orderby=DocDate desc, $expand=DocumentLines"
|
|
1668
|
-
),
|
|
1669
|
-
body: z4.record(z4.unknown()).optional().describe("POST/PATCH \u65F6\u7684 JSON \u8BF7\u6C42\u4F53")
|
|
1670
|
-
})
|
|
1671
|
-
},
|
|
1672
|
-
async (input) => {
|
|
1673
|
-
const url = buildUrl(input.entitySet, input.method, input.id, input.queryOptions);
|
|
1674
|
-
const method = input.method;
|
|
1675
|
-
const headers = {
|
|
1676
|
-
"Content-Type": "application/json",
|
|
1677
|
-
Accept: "application/json"
|
|
1678
|
-
};
|
|
1679
|
-
if (SAP_COOKIE) headers.Cookie = SAP_COOKIE;
|
|
1680
|
-
const fetchOptions = { method, headers };
|
|
1681
|
-
if ((method === "POST" || method === "PATCH") && input.body) {
|
|
1682
|
-
fetchOptions.body = JSON.stringify(input.body);
|
|
1683
|
-
}
|
|
1684
|
-
try {
|
|
1685
|
-
const res = await fetch(url, fetchOptions);
|
|
1686
|
-
const text = await res.text();
|
|
1687
|
-
let data;
|
|
1688
|
-
try {
|
|
1689
|
-
data = JSON.parse(text);
|
|
1690
|
-
} catch {
|
|
1691
|
-
data = text;
|
|
1692
|
-
}
|
|
1693
|
-
const result = {
|
|
1694
|
-
ok: res.ok,
|
|
1695
|
-
status: res.status,
|
|
1696
|
-
statusText: res.statusText,
|
|
1697
|
-
data
|
|
1698
|
-
};
|
|
1699
|
-
if (!res.ok) {
|
|
1700
|
-
result.error = `HTTP ${res.status} ${res.statusText}`;
|
|
1701
|
-
result.hint = res.status === 401 ? "\u9700\u8981\u6709\u6548\u7684 B1SESSION Cookie\u3002\u8BF7\u5148\u901A\u8FC7 Login \u7AEF\u70B9\u83B7\u53D6\uFF0C\u6216\u8BBE\u7F6E SAP_B1SESSION \u73AF\u5883\u53D8\u91CF\u3002" : res.status === 404 ? "\u63A5\u53E3\u6216\u5B9E\u4F53\u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5 entitySet \u540D\u79F0\u548C id\u3002" : void 0;
|
|
1702
|
-
}
|
|
1703
|
-
return result;
|
|
1704
|
-
} catch (err) {
|
|
1705
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
1706
|
-
return {
|
|
1707
|
-
ok: false,
|
|
1708
|
-
error: `\u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
1709
|
-
url,
|
|
1710
|
-
hint: "\u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5 SAP_SERVICE_LAYER_URL \u662F\u5426\u6B63\u786E\u3002"
|
|
1711
|
-
};
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
);
|
|
1715
|
-
function buildUrl(entitySet, method, id, queryOptions) {
|
|
1716
|
-
let url = `${BASE_URL}/${entitySet}`;
|
|
1717
|
-
if (id && method !== "POST") {
|
|
1718
|
-
url += `('${encodeURIComponent(id)}')`;
|
|
1719
|
-
}
|
|
1720
|
-
if (queryOptions) {
|
|
1721
|
-
url += `?${queryOptions}`;
|
|
1722
|
-
}
|
|
1723
|
-
return url;
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
|
-
// src/index.ts
|
|
1727
|
-
import {
|
|
1728
|
-
LoggerType,
|
|
1729
|
-
ScheduleType
|
|
1730
|
-
} from "@axiom-lattice/protocols";
|
|
1731
|
-
import { PostgreSQLAssistantStore, PostgreSQLScheduleStorage, PostgreSQLThreadStore, PostgreSQLDatabaseConfigStore, PostgreSQLMetricsServerConfigStore, PostgreSQLMcpServerConfigStore, PostgreSQLWorkspaceStore, PostgreSQLProjectStore, PostgreSQLUserStore, PostgreSQLTenantStore, PostgreSQLUserTenantLinkStore, PostgreSQLWorkflowTrackingStore, PostgreSQLEvalStore, ThreadMessageQueueStore, ChannelBindingStore, PostgreSQLChannelInstallationStore, Pool } from "@axiom-lattice/pg-stores";
|
|
1732
|
-
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";
|
|
1733
|
-
|
|
1734
|
-
// src/env.ts
|
|
1735
|
-
import dotenv from "dotenv";
|
|
1736
|
-
import path from "path";
|
|
1737
|
-
import { fileURLToPath } from "url";
|
|
1738
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
1739
|
-
var __dirname = path.dirname(__filename);
|
|
1740
|
-
function loadLocalEnv() {
|
|
1741
|
-
dotenv.config({ path: path.resolve(__dirname, "../.env.local") });
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
|
-
// src/index.ts
|
|
1745
|
-
var PACKAGE_VERSION = require_package().version;
|
|
1746
|
-
var BUILD_TIME = (/* @__PURE__ */ new Date()).toISOString();
|
|
1747
|
-
var IS_DEV = process.env.NODE_ENV !== "production";
|
|
1748
|
-
console.log(`
|
|
1749
|
-
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
1750
|
-
\u2551 Lattice Deep Research Server \u2551
|
|
1751
|
-
\u2551 Version: ${PACKAGE_VERSION} \u2551
|
|
1752
|
-
\u2551 Build Time: ${BUILD_TIME} \u2551
|
|
1753
|
-
\u2551 Environment: ${IS_DEV ? "Development" : "Production"} \u2551
|
|
1754
|
-
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
1755
|
-
`);
|
|
1756
|
-
loadLocalEnv();
|
|
1757
|
-
var baseURL = process.env.LLM_BASE_URL || "https://llm.alphafina.cn/v1";
|
|
1758
|
-
function parsePort() {
|
|
1759
|
-
const args = process.argv.slice(2);
|
|
1760
|
-
const portIndex = args.findIndex((arg) => arg === "--port" || arg === "-p");
|
|
1761
|
-
if (portIndex !== -1 && args[portIndex + 1]) {
|
|
1762
|
-
const port = parseInt(args[portIndex + 1], 10);
|
|
1763
|
-
if (!isNaN(port) && port > 0 && port < 65536) {
|
|
1764
|
-
return port;
|
|
1765
|
-
}
|
|
1766
|
-
console.warn(
|
|
1767
|
-
`Invalid port value: ${args[portIndex + 1]}, using default port 4001`
|
|
1768
|
-
);
|
|
1769
|
-
}
|
|
1770
|
-
if (process.env.PORT) {
|
|
1771
|
-
const port = parseInt(process.env.PORT, 10);
|
|
1772
|
-
if (!isNaN(port) && port > 0 && port < 65536) {
|
|
1773
|
-
return port;
|
|
1774
|
-
}
|
|
1775
|
-
console.warn(
|
|
1776
|
-
`Invalid PORT environment variable: ${process.env.PORT}, using default port 4001`
|
|
1777
|
-
);
|
|
1778
|
-
}
|
|
1779
|
-
return 4001;
|
|
1780
|
-
}
|
|
1781
|
-
registerModelLattice(
|
|
1782
|
-
"default",
|
|
1783
|
-
{
|
|
1784
|
-
model: "kimi-k2.6",
|
|
1785
|
-
displayName: "kimi-k2.6",
|
|
1786
|
-
//model: "qwen3.5-35b-a3b",
|
|
1787
|
-
provider: "openai",
|
|
1788
|
-
streaming: true,
|
|
1789
|
-
apiKeyEnvName: "API_KEY3",
|
|
1790
|
-
baseURL,
|
|
1791
|
-
modelKwargs: {
|
|
1792
|
-
"enable_thinking": false
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
);
|
|
1796
|
-
registerModelLattice(
|
|
1797
|
-
"qwen3.5-plus",
|
|
1798
|
-
{
|
|
1799
|
-
model: "qwen3.5-plus",
|
|
1800
|
-
displayName: "qwen3.5-plus",
|
|
1801
|
-
//model: "qwen3.5-35b-a3b",
|
|
1802
|
-
provider: "openai",
|
|
1803
|
-
streaming: true,
|
|
1804
|
-
apiKeyEnvName: "API_KEY3",
|
|
1805
|
-
baseURL
|
|
1806
|
-
}
|
|
1807
|
-
);
|
|
1808
|
-
registerModelLattice(
|
|
1809
|
-
"doubao-seed-2-0-pro",
|
|
1810
|
-
{
|
|
1811
|
-
displayName: "Doubao pro 2.0",
|
|
1812
|
-
model: "doubao-seed-2-0-pro-260215",
|
|
1813
|
-
provider: "volcengine",
|
|
1814
|
-
streaming: true,
|
|
1815
|
-
apiKeyEnvName: "VOLCENGINE_API_KEY2",
|
|
1816
|
-
modelKwargs: {
|
|
1817
|
-
"thinking": { "type": "disabled" }
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
);
|
|
1821
|
-
var AUTH_CONFIG = {
|
|
1822
|
-
autoApproveUsers: process.env.AUTO_APPROVE_USERS !== "false",
|
|
1823
|
-
allowTenantRegistration: process.env.ALLOW_TENANT_REGISTRATION !== "false",
|
|
1824
|
-
jwtSecret: process.env.JWT_SECRET || "your-secret-key-change-in-production",
|
|
1825
|
-
tokenExpiration: parseInt(process.env.TOKEN_EXPIRATION || "86400", 10)
|
|
1826
|
-
};
|
|
1827
|
-
console.log("Auth Configuration:");
|
|
1828
|
-
console.log(` - Auto Approve Users: ${AUTH_CONFIG.autoApproveUsers}`);
|
|
1829
|
-
console.log(` - Allow Tenant Registration: ${AUTH_CONFIG.allowTenantRegistration}`);
|
|
1830
|
-
console.log(` - Token Expiration: ${AUTH_CONFIG.tokenExpiration}s`);
|
|
1831
|
-
async function initializeEssentialPgStores() {
|
|
1832
|
-
const connectionString = process.env.DATABASE_URL || "";
|
|
1833
|
-
if (!connectionString) {
|
|
1834
|
-
console.warn("\u26A0\uFE0F DATABASE_URL not set, skipping essential PG stores (Workspace, Project)");
|
|
1835
|
-
return;
|
|
1836
|
-
}
|
|
1837
|
-
console.log("\n\u{1F50C} Initializing essential PostgreSQL stores (Workspace, Project)...\n");
|
|
1838
|
-
const workspaceStore = new PostgreSQLWorkspaceStore({
|
|
1839
|
-
poolConfig: connectionString,
|
|
1840
|
-
autoMigrate: false
|
|
1841
|
-
});
|
|
1842
|
-
await workspaceStore.initialize();
|
|
1843
|
-
storeLatticeManager.removeLattice("default", "workspace");
|
|
1844
|
-
registerStoreLattice("default", "workspace", workspaceStore);
|
|
1845
|
-
console.log("\u2713 PostgreSQL WorkspaceStore initialized");
|
|
1846
|
-
const projectStore = new PostgreSQLProjectStore({
|
|
1847
|
-
poolConfig: connectionString,
|
|
1848
|
-
autoMigrate: false
|
|
1849
|
-
});
|
|
1850
|
-
await projectStore.initialize();
|
|
1851
|
-
storeLatticeManager.removeLattice("default", "project");
|
|
1852
|
-
registerStoreLattice("default", "project", projectStore);
|
|
1853
|
-
console.log("\u2713 PostgreSQL ProjectStore initialized");
|
|
1854
|
-
const evalStore = new PostgreSQLEvalStore({
|
|
1855
|
-
poolConfig: connectionString,
|
|
1856
|
-
autoMigrate: true
|
|
1857
|
-
});
|
|
1858
|
-
await evalStore.initialize();
|
|
1859
|
-
storeLatticeManager.removeLattice("default", "eval");
|
|
1860
|
-
registerStoreLattice("default", "eval", evalStore);
|
|
1861
|
-
console.log("\u2713 PostgreSQL EvalStore initialized");
|
|
1862
|
-
const userStore = new PostgreSQLUserStore({
|
|
1863
|
-
poolConfig: connectionString,
|
|
1864
|
-
autoMigrate: false
|
|
1865
|
-
});
|
|
1866
|
-
await userStore.initialize();
|
|
1867
|
-
storeLatticeManager.removeLattice("default", "user");
|
|
1868
|
-
registerStoreLattice("default", "user", userStore);
|
|
1869
|
-
console.log("\u2713 PostgreSQL UserStore initialized");
|
|
1870
|
-
const tenantStore = new PostgreSQLTenantStore({
|
|
1871
|
-
poolConfig: connectionString,
|
|
1872
|
-
autoMigrate: false
|
|
1873
|
-
});
|
|
1874
|
-
await tenantStore.initialize();
|
|
1875
|
-
storeLatticeManager.removeLattice("default", "tenant");
|
|
1876
|
-
registerStoreLattice("default", "tenant", tenantStore);
|
|
1877
|
-
console.log("\u2713 PostgreSQL TenantStore initialized");
|
|
1878
|
-
const userTenantLinkStore = new PostgreSQLUserTenantLinkStore({
|
|
1879
|
-
poolConfig: connectionString,
|
|
1880
|
-
autoMigrate: false
|
|
1881
|
-
});
|
|
1882
|
-
await userTenantLinkStore.initialize();
|
|
1883
|
-
storeLatticeManager.removeLattice("default", "userTenantLink");
|
|
1884
|
-
registerStoreLattice("default", "userTenantLink", userTenantLinkStore);
|
|
1885
|
-
console.log("\u2713 PostgreSQL UserTenantLinkStore initialized");
|
|
1886
|
-
const channelBindingStore = new ChannelBindingStore({
|
|
1887
|
-
poolConfig: connectionString,
|
|
1888
|
-
autoMigrate: true
|
|
1889
|
-
});
|
|
1890
|
-
await channelBindingStore.initialize();
|
|
1891
|
-
storeLatticeManager.removeLattice("default", "channelBinding");
|
|
1892
|
-
registerStoreLattice("default", "channelBinding", channelBindingStore);
|
|
1893
|
-
const channelInstallationStore = new PostgreSQLChannelInstallationStore({
|
|
1894
|
-
poolConfig: connectionString,
|
|
1895
|
-
autoMigrate: true
|
|
1896
|
-
});
|
|
1897
|
-
await channelInstallationStore.initialize();
|
|
1898
|
-
storeLatticeManager.removeLattice("default", "channelInstallation");
|
|
1899
|
-
registerStoreLattice("default", "channelInstallation", channelInstallationStore);
|
|
1900
|
-
console.log("\u2713 Essential PostgreSQL stores initialized\n");
|
|
1901
|
-
}
|
|
1902
|
-
async function initializePgStores() {
|
|
1903
|
-
const connectionString = process.env.DATABASE_URL || "";
|
|
1904
|
-
if (!connectionString) {
|
|
1905
|
-
console.error("ERROR: DATABASE_URL environment variable is not set");
|
|
1906
|
-
process.exit(1);
|
|
1907
|
-
}
|
|
1908
|
-
console.log("\n\u{1F50C} Initializing remaining PostgreSQL stores...\n");
|
|
1909
|
-
const sharedPool = new Pool({ connectionString });
|
|
1910
|
-
const threadStore = new PostgreSQLThreadStore({
|
|
1911
|
-
poolConfig: connectionString,
|
|
1912
|
-
autoMigrate: false
|
|
1913
|
-
});
|
|
1914
|
-
await threadStore.initialize();
|
|
1915
|
-
storeLatticeManager.removeLattice("default", "thread");
|
|
1916
|
-
registerStoreLattice("default", "thread", threadStore);
|
|
1917
|
-
console.log("\u2713 PostgreSQL ThreadStore initialized");
|
|
1918
|
-
const databaseConfigStore = new PostgreSQLDatabaseConfigStore({
|
|
1919
|
-
poolConfig: connectionString,
|
|
1920
|
-
autoMigrate: false
|
|
1921
|
-
});
|
|
1922
|
-
await databaseConfigStore.initialize();
|
|
1923
|
-
storeLatticeManager.removeLattice("default", "database");
|
|
1924
|
-
registerStoreLattice("default", "database", databaseConfigStore);
|
|
1925
|
-
sqlDatabaseManager2.setConfigStore(databaseConfigStore);
|
|
1926
|
-
console.log("\u2713 PostgreSQL DatabaseConfigStore initialized");
|
|
1927
|
-
const metricsConfigStore = new PostgreSQLMetricsServerConfigStore({
|
|
1928
|
-
poolConfig: connectionString,
|
|
1929
|
-
autoMigrate: false
|
|
1930
|
-
});
|
|
1931
|
-
await metricsConfigStore.initialize();
|
|
1932
|
-
storeLatticeManager.removeLattice("default", "metrics");
|
|
1933
|
-
registerStoreLattice("default", "metrics", metricsConfigStore);
|
|
1934
|
-
metricsServerManager.loadAllConfigsFromStore(metricsConfigStore);
|
|
1935
|
-
console.log("\u2713 PostgreSQL MetricsServerConfigStore initialized");
|
|
1936
|
-
const mcpConfigStore = new PostgreSQLMcpServerConfigStore({
|
|
1937
|
-
poolConfig: connectionString,
|
|
1938
|
-
autoMigrate: false
|
|
1939
|
-
});
|
|
1940
|
-
await mcpConfigStore.initialize();
|
|
1941
|
-
storeLatticeManager.removeLattice("default", "mcp");
|
|
1942
|
-
registerStoreLattice("default", "mcp", mcpConfigStore);
|
|
1943
|
-
console.log("\u2713 PostgreSQL McpServerConfigStore initialized");
|
|
1944
|
-
const assistantStore = new PostgreSQLAssistantStore({
|
|
1945
|
-
poolConfig: connectionString,
|
|
1946
|
-
autoMigrate: false
|
|
1947
|
-
});
|
|
1948
|
-
await assistantStore.initialize();
|
|
1949
|
-
storeLatticeManager.removeLattice("default", "assistant");
|
|
1950
|
-
registerStoreLattice("default", "assistant", assistantStore);
|
|
1951
|
-
console.log("\u2713 PostgreSQL AssistantStore initialized");
|
|
1952
|
-
const workflowTrackingStore = new PostgreSQLWorkflowTrackingStore({
|
|
1953
|
-
poolConfig: connectionString,
|
|
1954
|
-
autoMigrate: true
|
|
1955
|
-
});
|
|
1956
|
-
storeLatticeManager.removeLattice("default", "workflowTracking");
|
|
1957
|
-
registerStoreLattice("default", "workflowTracking", workflowTrackingStore);
|
|
1958
|
-
console.log("\u2713 PostgreSQL WorkflowTrackingStore initialized with auto-migration");
|
|
1959
|
-
const threadMessageQueueStore = ThreadMessageQueueStore.getInstance();
|
|
1960
|
-
await threadMessageQueueStore.initialize(sharedPool, true);
|
|
1961
|
-
storeLatticeManager.removeLattice("default", "threadMessageQueue");
|
|
1962
|
-
registerStoreLattice("default", "threadMessageQueue", threadMessageQueueStore);
|
|
1963
|
-
console.log("\u2713 ThreadMessageQueueStore initialized for Agent Recovery");
|
|
1964
|
-
const globalMemory = PostgresSaver.fromConnString(
|
|
1965
|
-
connectionString
|
|
1966
|
-
);
|
|
1967
|
-
MemoryLatticeManager.getInstance().removeCheckpointSaver("default");
|
|
1968
|
-
registerCheckpointSaver("default", globalMemory);
|
|
1969
|
-
console.log("\u2713 globalMemory initialized for LangGraph checkpoints");
|
|
1970
|
-
const scheduleStorage = new PostgreSQLScheduleStorage({
|
|
1971
|
-
poolConfig: connectionString,
|
|
1972
|
-
autoMigrate: false
|
|
1973
|
-
});
|
|
1974
|
-
await scheduleStorage.initialize();
|
|
1975
|
-
registerScheduleLattice("default", {
|
|
1976
|
-
name: "Default Scheduler",
|
|
1977
|
-
description: "Production scheduler with PostgreSQL persistence",
|
|
1978
|
-
type: ScheduleType.POSTGRES,
|
|
1979
|
-
storage: scheduleStorage
|
|
1980
|
-
});
|
|
1981
|
-
console.log("\u2713 PostgreSQL ScheduleStorage initialized");
|
|
1982
|
-
console.log("\n\u2713 All PostgreSQL stores initialized\n");
|
|
1983
|
-
}
|
|
1984
|
-
async function main() {
|
|
1985
|
-
await initializeEssentialPgStores();
|
|
1986
|
-
const usePgStores = process.env.USE_PG_STORES === "true";
|
|
1987
|
-
if (usePgStores) {
|
|
1988
|
-
await initializePgStores();
|
|
1989
|
-
} else {
|
|
1990
|
-
console.log(" USE_PG_STORES is not set to 'true', skipping remaining PG stores");
|
|
1991
|
-
console.log(" Set USE_PG_STORES=true in .env.local to enable all production DB stores.\n");
|
|
1992
|
-
}
|
|
1993
|
-
const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox";
|
|
1994
|
-
const sandboxBaseURL = process.env.SANDBOX_BASE_URL;
|
|
1995
|
-
const microsandboxServiceBaseURL = process.env.MICROSANDBOX_SERVICE_BASE_URL;
|
|
1996
|
-
const e2bApiKey = process.env.E2B_API_KEY;
|
|
1997
|
-
const daytonaApiKey = process.env.DAYTONA_API_KEY;
|
|
1998
|
-
const daytonaApiUrl = process.env.DAYTONA_API_URL;
|
|
1999
|
-
const daytonaTarget = process.env.DAYTONA_TARGET;
|
|
2000
|
-
const sandboxProvider = createSandboxProvider({
|
|
2001
|
-
type: sandboxProviderType,
|
|
2002
|
-
remoteBaseURL: sandboxBaseURL,
|
|
2003
|
-
microsandboxServiceBaseURL,
|
|
2004
|
-
e2bApiKey,
|
|
2005
|
-
e2bTemplate: process.env.E2B_TEMPLATE,
|
|
2006
|
-
e2bTimeoutMs: process.env.E2B_TIMEOUT_MS ? parseInt(process.env.E2B_TIMEOUT_MS, 10) : void 0,
|
|
2007
|
-
daytonaApiKey,
|
|
2008
|
-
daytonaApiUrl,
|
|
2009
|
-
daytonaTarget,
|
|
2010
|
-
daytonaTimeout: process.env.DAYTONA_TIMEOUT ? parseInt(process.env.DAYTONA_TIMEOUT, 10) : void 0,
|
|
2011
|
-
daytonaVolumeName: process.env.DAYTONA_VOLUME_NAME
|
|
2012
|
-
});
|
|
2013
|
-
sandboxLatticeManager.registerLattice("default", sandboxProvider);
|
|
2014
|
-
console.log(`\u2713 Sandbox provider registered: ${sandboxProviderType}`);
|
|
2015
|
-
const port = parsePort();
|
|
2016
|
-
console.log(`
|
|
2017
|
-
\u{1F310} Starting server on port ${port}...
|
|
2018
|
-
`);
|
|
2019
|
-
const DEFAULT_LOGGER_CONFIG = {
|
|
2020
|
-
name: "default",
|
|
2021
|
-
description: "Default logger for lattice-gateway service",
|
|
2022
|
-
type: LoggerType.PINO,
|
|
2023
|
-
serviceName: "lattice/deep_research",
|
|
2024
|
-
loggerName: "lattice/deep_research"
|
|
2025
|
-
};
|
|
2026
|
-
await LatticeGateway.configureSwagger(LatticeGateway.app);
|
|
2027
|
-
console.log(`\u{1F4DA} Swagger UI available at: http://localhost:${port}/api-docs`);
|
|
2028
|
-
console.log(`\u{1F4C4} OpenAPI JSON available at: http://localhost:${port}/api-docs/json
|
|
2029
|
-
`);
|
|
2030
|
-
LatticeGateway.startAsHttpEndpoint({
|
|
2031
|
-
port,
|
|
2032
|
-
queueServiceConfig: { type: "memory", defaultStartPollingQueue: true },
|
|
2033
|
-
loggerConfig: DEFAULT_LOGGER_CONFIG
|
|
2034
|
-
});
|
|
2035
|
-
}
|
|
2036
|
-
main().catch((error) => {
|
|
2037
|
-
console.error("Failed to start server:", error);
|
|
2038
|
-
process.exit(1);
|
|
2039
|
-
});
|
|
2040
|
-
//# sourceMappingURL=index.js.map
|