@things-factory/ai-assistant 10.1.247 → 10.1.254
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/dist-server/service/help-documents/help-tools.d.ts +4 -4
- package/dist-server/service/help-documents/help-tools.js +10 -8
- package/dist-server/service/help-documents/help-tools.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/server/service/help-documents/help-tools.test.ts +8 -8
- package/server/service/help-documents/help-tools.ts +10 -8
|
@@ -4,7 +4,7 @@ export declare const helpLink: (topic: string, section?: string) => string;
|
|
|
4
4
|
export declare function searchHelpDocuments(args: {
|
|
5
5
|
query?: string;
|
|
6
6
|
limit?: number;
|
|
7
|
-
}, context?: any): {
|
|
7
|
+
}, context?: any): Promise<{
|
|
8
8
|
found: number;
|
|
9
9
|
parts: any[];
|
|
10
10
|
message: string;
|
|
@@ -18,11 +18,11 @@ export declare function searchHelpDocuments(args: {
|
|
|
18
18
|
link: string;
|
|
19
19
|
}[];
|
|
20
20
|
message?: undefined;
|
|
21
|
-
}
|
|
21
|
+
}>;
|
|
22
22
|
export declare function readHelpDocument(args: {
|
|
23
23
|
topic?: string;
|
|
24
24
|
section?: string;
|
|
25
|
-
}, context?: any): {
|
|
25
|
+
}, context?: any): Promise<{
|
|
26
26
|
found: boolean;
|
|
27
27
|
message: string;
|
|
28
28
|
} | {
|
|
@@ -34,5 +34,5 @@ export declare function readHelpDocument(args: {
|
|
|
34
34
|
text: string;
|
|
35
35
|
found: boolean;
|
|
36
36
|
message?: undefined;
|
|
37
|
-
}
|
|
37
|
+
}>;
|
|
38
38
|
export declare const helpCategory: ToolCategory;
|
|
@@ -9,7 +9,8 @@ exports.readHelpDocument = readHelpDocument;
|
|
|
9
9
|
* and reads it, rather than the mode's prompt carrying the manual.
|
|
10
10
|
*
|
|
11
11
|
* The help is no one's secret - every screen's `?` opens it for whoever is there - so the tools reach no door. Whether
|
|
12
|
-
* the person may open the screen a part names is still that screen's own door.
|
|
12
|
+
* the person may open the screen a part names is still that screen's own door. A source's parts - the company's rules
|
|
13
|
+
* (ADR-0187 decision 12) - are found only where the source lets the person read them; they open where the source says.
|
|
13
14
|
*/
|
|
14
15
|
const ai_client_base_1 = require("@things-factory/ai-client-base");
|
|
15
16
|
const help_1 = require("@things-factory/help");
|
|
@@ -18,26 +19,26 @@ const help_keys_js_1 = require("./help-keys.js");
|
|
|
18
19
|
const helpLink = (topic, section = '') => `help?topic=${encodeURIComponent(topic)}${section ? `§ion=${encodeURIComponent(section)}` : ''}`;
|
|
19
20
|
exports.helpLink = helpLink;
|
|
20
21
|
const languageOf = (context) => context?.state?.lng || context?.state?.language || undefined;
|
|
21
|
-
function searchHelpDocuments(args, context) {
|
|
22
|
+
async function searchHelpDocuments(args, context) {
|
|
22
23
|
const query = String(args?.query ?? '').trim();
|
|
23
24
|
if (!query)
|
|
24
25
|
return { found: 0, parts: [], message: 'name what to look for.' };
|
|
25
|
-
const parts = (0, help_1.searchHelp)(query, { lang: languageOf(context), limit: Math.min(Math.max(Number(args?.limit) || 5, 1), 10) }).map(hit => ({
|
|
26
|
+
const parts = (await (0, help_1.searchHelp)(query, { lang: languageOf(context), limit: Math.min(Math.max(Number(args?.limit) || 5, 1), 10), context })).map(hit => ({
|
|
26
27
|
topic: hit.topic,
|
|
27
28
|
section: hit.section,
|
|
28
29
|
title: hit.documentTitle === hit.title ? hit.title : `${hit.documentTitle} › ${hit.title}`,
|
|
29
30
|
summary: hit.summary,
|
|
30
|
-
link: (0, exports.helpLink)(hit.topic, hit.section)
|
|
31
|
+
link: hit.link ?? (0, exports.helpLink)(hit.topic, hit.section)
|
|
31
32
|
}));
|
|
32
33
|
return parts.length ? { found: parts.length, parts } : { found: 0, parts: [], message: 'the help has nothing on this - say so; do not answer from general knowledge as if it were this application.' };
|
|
33
34
|
}
|
|
34
|
-
function readHelpDocument(args, context) {
|
|
35
|
+
async function readHelpDocument(args, context) {
|
|
35
36
|
const topic = String(args?.topic ?? '').trim();
|
|
36
37
|
const section = String(args?.section ?? '').trim();
|
|
37
|
-
const part = topic ? (0, help_1.readHelp)(topic, section, languageOf(context)) : null;
|
|
38
|
+
const part = topic ? await (0, help_1.readHelp)(topic, section, languageOf(context), context) : null;
|
|
38
39
|
if (!part)
|
|
39
40
|
return { found: false, message: `no help part ${topic}${section ? `#${section}` : ''} - search again with searchHelp.` };
|
|
40
|
-
return { found: true, ...part, link: (0, exports.helpLink)(part.topic, part.section) };
|
|
41
|
+
return { found: true, ...part, link: part.link ?? (0, exports.helpLink)(part.topic, part.section) };
|
|
41
42
|
}
|
|
42
43
|
const searchSpec = {
|
|
43
44
|
kind: 'read',
|
|
@@ -77,7 +78,8 @@ exports.helpCategory = {
|
|
|
77
78
|
'- When the person asks how to do something in this application, where a screen or menu is, what the steps are, or what a term on a screen means, call searchHelp, then readHelp on the part that answers it - before you answer.',
|
|
78
79
|
'- Answer from what readHelp returned, in your own short words, and end with the part as a link: [its title](its link). Never invent a menu, a button or a step the help does not name.',
|
|
79
80
|
'- When searchHelp finds nothing, say the help does not cover it; then answer only what your other tools show.',
|
|
80
|
-
'- The help says how the application works; figures and records still come from the other tools.'
|
|
81
|
+
'- The help says how the application works; figures and records still come from the other tools.',
|
|
82
|
+
"- A part of the company's own rules (a topic under regulation/) is the company's: answer with the article and its effective day as a link. Where the guidance on the law and the company's rule read differently, show both and do not judge between them."
|
|
81
83
|
].join('\n'),
|
|
82
84
|
specs: [searchSpec, readSpec]
|
|
83
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-tools.js","sourceRoot":"","sources":["../../../server/service/help-documents/help-tools.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"help-tools.js","sourceRoot":"","sources":["../../../server/service/help-documents/help-tools.ts"],"names":[],"mappings":";;;AAmBA,kDAWC;AAED,4CAMC;AAtCD;;;;;;;;GAQG;AACH,mEAAuG;AACvG,+CAA2D;AAE3D,iDAA8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AC9B,CAAA;AAED,IAAA,qCAAoB,EAAC,oBAAY,CAAC,CAAA","sourcesContent":["/*\n * The application's help documents, for the assistant (ADR-0181) - the same index the screen's `?` asks\n * (@things-factory/help). How to do a piece of work, which screen it is on, what a word means: the model finds the part\n * and reads it, rather than the mode's prompt carrying the manual.\n *\n * The help is no one's secret - every screen's `?` opens it for whoever is there - so the tools reach no door. Whether\n * the person may open the screen a part names is still that screen's own door. A source's parts - the company's rules\n * (ADR-0187 decision 12) - are found only where the source lets the person read them; they open where the source says.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\nimport { readHelp, searchHelp } from '@things-factory/help'\n\nimport { HELP_CATEGORY } from './help-keys.js'\n\n/** Where a part opens in the application - the help page at that part. */\nexport const helpLink = (topic: string, section = '') => `help?topic=${encodeURIComponent(topic)}${section ? `§ion=${encodeURIComponent(section)}` : ''}`\n\nconst languageOf = (context: any): string | undefined => context?.state?.lng || context?.state?.language || undefined\n\nexport async function searchHelpDocuments(args: { query?: string; limit?: number }, context?: any) {\n const query = String(args?.query ?? '').trim()\n if (!query) return { found: 0, parts: [], message: 'name what to look for.' }\n const parts = (await searchHelp(query, { lang: languageOf(context), limit: Math.min(Math.max(Number(args?.limit) || 5, 1), 10), context })).map(hit => ({\n topic: hit.topic,\n section: hit.section,\n title: hit.documentTitle === hit.title ? hit.title : `${hit.documentTitle} › ${hit.title}`,\n summary: hit.summary,\n link: hit.link ?? helpLink(hit.topic, hit.section)\n }))\n return parts.length ? { found: parts.length, parts } : { found: 0, parts: [], message: 'the help has nothing on this - say so; do not answer from general knowledge as if it were this application.' }\n}\n\nexport async function readHelpDocument(args: { topic?: string; section?: string }, context?: any) {\n const topic = String(args?.topic ?? '').trim()\n const section = String(args?.section ?? '').trim()\n const part = topic ? await readHelp(topic, section, languageOf(context), context) : null\n if (!part) return { found: false, message: `no help part ${topic}${section ? `#${section}` : ''} - search again with searchHelp.` }\n return { found: true, ...part, link: part.link ?? helpLink(part.topic, part.section) }\n}\n\nconst searchSpec = {\n kind: 'read',\n name: 'searchHelp',\n doors: [],\n description:\n \"Search this application's help and manuals (how to do a piece of work, which screen and menu it is on, what a term means). \" +\n 'Returns the matching parts with a one-line summary and a link; read one with readHelp.',\n schema: {\n type: 'object',\n properties: {\n query: { type: 'string', description: 'The words to look for, in the language of the help - a screen or menu name, a task, a term (\"지출결의 지급\", \"휴가 신청\").' },\n limit: { type: 'number', description: 'How many parts, 1-10. Default 5.' }\n },\n required: ['query']\n },\n builder: (args: any, context: any) => searchHelpDocuments(args, context)\n} as ToolSpec\n\nconst readSpec = {\n kind: 'read',\n name: 'readHelp',\n doors: [],\n description: 'Read one part of the help (topic and section from searchHelp), or the whole document when section is left out.',\n schema: {\n type: 'object',\n properties: {\n topic: { type: 'string', description: 'The topic from searchHelp (\"office/guide-employee\").' },\n section: { type: 'string', description: 'The section from searchHelp (\"leave\"). Leave out for the whole document.' }\n },\n required: ['topic']\n },\n builder: (args: any, context: any) => readHelpDocument(args, context)\n} as ToolSpec\n\nexport const helpCategory: ToolCategory = {\n name: HELP_CATEGORY,\n description: \"the application's help and manuals\",\n guidance: [\n '- When the person asks how to do something in this application, where a screen or menu is, what the steps are, or what a term on a screen means, call searchHelp, then readHelp on the part that answers it - before you answer.',\n '- Answer from what readHelp returned, in your own short words, and end with the part as a link: [its title](its link). Never invent a menu, a button or a step the help does not name.',\n '- When searchHelp finds nothing, say the help does not cover it; then answer only what your other tools show.',\n '- The help says how the application works; figures and records still come from the other tools.',\n \"- A part of the company's own rules (a topic under regulation/) is the company's: answer with the article and its effective day as a link. Where the guidance on the law and the company's rule read differently, show both and do not judge between them.\"\n ].join('\\n'),\n specs: [searchSpec, readSpec]\n}\n\nregisterToolCategory(helpCategory)\n"]}
|