dsh-data-domain-knowledge 0.1.1-alpha.2 → 0.1.1-alpha.3
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/README.md +23 -16
- package/lib/client.js +596 -841
- package/lib/contract-refs.d.ts +0 -1
- package/lib/doc-page.js +7 -7
- package/lib/pages.js +928 -1145
- package/lib/types/agent-behavior-rules.d.ts.map +1 -1
- package/lib/types/agent-behavior-rules.js +1 -2
- package/lib/types/agent-behavior-rules.js.map +1 -1
- package/lib/types/axis-contract.js +1 -1
- package/lib/types/axis-contract.js.map +1 -1
- package/lib/types/card-organize.d.ts +2 -1
- package/lib/types/card-organize.d.ts.map +1 -1
- package/lib/types/card-organize.js +5 -3
- package/lib/types/card-organize.js.map +1 -1
- package/lib/types/config-schema.d.ts +1 -1
- package/lib/types/config-schema.js +1 -1
- package/lib/types/convert/host.d.ts +2 -3
- package/lib/types/convert/host.d.ts.map +1 -1
- package/lib/types/convert/host.js +5 -2
- package/lib/types/convert/host.js.map +1 -1
- package/lib/types/convert/ingest.d.ts +2 -0
- package/lib/types/convert/ingest.d.ts.map +1 -1
- package/lib/types/convert/ingest.js +1 -0
- package/lib/types/convert/ingest.js.map +1 -1
- package/lib/types/diagnosis/types.d.ts +1 -1
- package/lib/types/diagnosis/types.js +1 -1
- package/lib/types/images.js +1 -1
- package/lib/types/index.d.ts +0 -4
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +30 -41
- package/lib/types/index.js.map +1 -1
- package/lib/types/knowledge-contract.d.ts +6 -0
- package/lib/types/knowledge-contract.d.ts.map +1 -1
- package/lib/types/knowledge-contract.js +6 -2
- package/lib/types/knowledge-contract.js.map +1 -1
- package/lib/types/layout.d.ts +9 -26
- package/lib/types/layout.d.ts.map +1 -1
- package/lib/types/layout.js +10 -28
- package/lib/types/layout.js.map +1 -1
- package/lib/types/materialize-snapshot.d.ts +5 -0
- package/lib/types/materialize-snapshot.d.ts.map +1 -1
- package/lib/types/migrate.d.ts +3 -1
- package/lib/types/migrate.d.ts.map +1 -1
- package/lib/types/migrate.js +3 -1
- package/lib/types/migrate.js.map +1 -1
- package/lib/types/organize-contract.d.ts.map +1 -1
- package/lib/types/organize-contract.js +2 -1
- package/lib/types/organize-contract.js.map +1 -1
- package/lib/types/pipeline/engine.d.ts +1 -0
- package/lib/types/pipeline/engine.d.ts.map +1 -1
- package/lib/types/pipeline/engine.js +9 -3
- package/lib/types/pipeline/engine.js.map +1 -1
- package/lib/types/pipeline/types.d.ts +6 -0
- package/lib/types/pipeline/types.d.ts.map +1 -1
- package/lib/types/pipeline/types.js.map +1 -1
- package/lib/types/present.d.ts +1 -1
- package/lib/types/present.js +1 -1
- package/lib/types/preset-ids.d.ts +0 -1
- package/lib/types/preset-ids.d.ts.map +1 -1
- package/lib/types/preset-ids.js +0 -3
- package/lib/types/preset-ids.js.map +1 -1
- package/lib/types/query-analysis.d.ts +0 -5
- package/lib/types/query-analysis.d.ts.map +1 -1
- package/lib/types/query-analysis.js +0 -16
- package/lib/types/query-analysis.js.map +1 -1
- package/lib/types/recall-delivery.d.ts +36 -0
- package/lib/types/recall-delivery.d.ts.map +1 -0
- package/lib/types/recall-delivery.js +16 -0
- package/lib/types/recall-delivery.js.map +1 -0
- package/lib/types/runtime.d.ts +26 -12
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/runtime.js +231 -106
- package/lib/types/runtime.js.map +1 -1
- package/lib/types/settings-volatile.d.ts +0 -7
- package/lib/types/settings-volatile.d.ts.map +1 -1
- package/lib/types/settings-volatile.js +0 -7
- package/lib/types/settings-volatile.js.map +1 -1
- package/lib/types/source-identity.d.ts +3 -0
- package/lib/types/source-identity.d.ts.map +1 -0
- package/lib/types/source-identity.js +5 -0
- package/lib/types/source-identity.js.map +1 -0
- package/lib/types/store/axis-references.d.ts.map +1 -1
- package/lib/types/store/axis-references.js +5 -3
- package/lib/types/store/axis-references.js.map +1 -1
- package/lib/types/store/knowledge-db.d.ts +1 -1
- package/lib/types/store/knowledge-db.d.ts.map +1 -1
- package/lib/types/store/knowledge-db.js +16 -2
- package/lib/types/store/knowledge-db.js.map +1 -1
- package/lib/types/types.d.ts +5 -4
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js +6 -3
- package/lib/types/types.js.map +1 -1
- package/lib/types/wiki-availability.d.ts +11 -0
- package/lib/types/wiki-availability.d.ts.map +1 -0
- package/lib/types/wiki-availability.js +39 -0
- package/lib/types/wiki-availability.js.map +1 -0
- package/lib/types/wiki-finalize.d.ts +4 -2
- package/lib/types/wiki-finalize.d.ts.map +1 -1
- package/lib/types/wiki-finalize.js +9 -27
- package/lib/types/wiki-finalize.js.map +1 -1
- package/lib/types/wiki-links.d.ts +35 -0
- package/lib/types/wiki-links.d.ts.map +1 -0
- package/lib/types/wiki-links.js +129 -0
- package/lib/types/wiki-links.js.map +1 -0
- package/package.json +16 -16
- package/scripts/doctor.mjs +0 -7
- package/scripts/setup-embedding.sh +0 -0
- package/src/agent-behavior-rules.ts +1 -2
- package/src/axis-contract.ts +1 -1
- package/src/card-organize.ts +5 -3
- package/src/client/AttributionEventGuide.tsx +3 -3
- package/src/client/AxisMatrix.tsx +86 -19
- package/src/client/DirectoryPicker.tsx +0 -2
- package/src/client/GuideArchitectureCanvas.tsx +5 -12
- package/src/client/ImportFilesDialog.tsx +1 -0
- package/src/client/InfoHint.tsx +1 -1
- package/src/client/KnowledgeBaseTab.tsx +113 -39
- package/src/client/KnowledgePanel.tsx +16 -9
- package/src/client/OperationLogTab.tsx +1 -1
- package/src/client/RecallPanel.tsx +5 -16
- package/src/client/TabGuide.tsx +3 -7
- package/src/client/WikiFlowPanel.tsx +10 -11
- package/src/client/arch/NodeLogicPanel.tsx +3 -3
- package/src/client/arch/model.ts +5 -113
- package/src/client/architecture.css +1 -1
- package/src/client/architecture.tsx +13 -27
- package/src/client/attribution/AttributionTab.tsx +141 -10
- package/src/client/pages.css +2 -2
- package/src/client/pages.tsx +4 -11
- package/src/client/styles.css +15 -96
- package/src/config-schema.ts +1 -1
- package/src/convert/host.ts +7 -5
- package/src/convert/ingest.ts +3 -0
- package/src/diagnosis/types.ts +1 -1
- package/src/images.ts +1 -1
- package/src/index.ts +27 -49
- package/src/knowledge-contract.ts +7 -2
- package/src/layout.ts +10 -32
- package/src/materialize-snapshot.ts +1 -0
- package/src/migrate.ts +3 -1
- package/src/organize-contract.ts +2 -1
- package/src/pipeline/engine.ts +9 -3
- package/src/pipeline/types.ts +2 -0
- package/src/present.ts +1 -1
- package/src/preset-ids.ts +0 -4
- package/src/query-analysis.ts +0 -20
- package/src/recall-delivery.ts +19 -0
- package/src/runtime.ts +220 -102
- package/src/settings-volatile.ts +0 -7
- package/src/source-identity.ts +4 -0
- package/src/store/axis-references.ts +5 -3
- package/src/store/knowledge-db.ts +14 -2
- package/src/types.ts +6 -4
- package/src/wiki-availability.ts +37 -0
- package/src/wiki-finalize.ts +9 -25
- package/src/wiki-links.ts +120 -0
- package/lib/types/intent/engine.d.ts +0 -122
- package/lib/types/intent/engine.d.ts.map +0 -1
- package/lib/types/intent/engine.js +0 -488
- package/lib/types/intent/engine.js.map +0 -1
- package/lib/types/intent/host.d.ts +0 -68
- package/lib/types/intent/host.d.ts.map +0 -1
- package/lib/types/intent/host.js +0 -249
- package/lib/types/intent/host.js.map +0 -1
- package/lib/types/intent/scope.d.ts +0 -25
- package/lib/types/intent/scope.d.ts.map +0 -1
- package/lib/types/intent/scope.js +0 -116
- package/lib/types/intent/scope.js.map +0 -1
- package/lib/types/intent/store.d.ts +0 -33
- package/lib/types/intent/store.d.ts.map +0 -1
- package/lib/types/intent/store.js +0 -239
- package/lib/types/intent/store.js.map +0 -1
- package/lib/types/intent/tools.d.ts +0 -62
- package/lib/types/intent/tools.d.ts.map +0 -1
- package/lib/types/intent/tools.js +0 -130
- package/lib/types/intent/tools.js.map +0 -1
- package/lib/types/intent/types.d.ts +0 -170
- package/lib/types/intent/types.d.ts.map +0 -1
- package/lib/types/intent/types.js +0 -56
- package/lib/types/intent/types.js.map +0 -1
- package/src/client/IntentLogic.tsx +0 -192
- package/src/client/IntentTab.tsx +0 -343
- package/src/intent/README.md +0 -42
- package/src/intent/engine.ts +0 -515
- package/src/intent/host.ts +0 -315
- package/src/intent/scope.ts +0 -125
- package/src/intent/store.ts +0 -218
- package/src/intent/tools.ts +0 -154
- package/src/intent/types.ts +0 -229
package/lib/types/index.js
CHANGED
|
@@ -14,21 +14,16 @@ import { KnowledgeEnvironment } from './environment/service.js';
|
|
|
14
14
|
import { DOC_PAGE_CHARS, DOC_PAGE_CHARS_MAX, documentContentPage } from './document-page.js';
|
|
15
15
|
import { runWikiTrial, trialSummary } from './wiki-trial.js';
|
|
16
16
|
import { extractionRunId } from './extraction-runs.js';
|
|
17
|
-
import { agentLayout, defaultAgentRoot, ensureAgentLayout,
|
|
17
|
+
import { agentLayout, defaultAgentRoot, ensureAgentLayout, knowledgeBaseRoot, memoryRoot, resourceRegistry, resourceRoot, } from './layout.js';
|
|
18
18
|
import { PickerError, createDirectory, listDirectory, pickDirectory, pickerKind, pickerOf, } from './directory-picker.js';
|
|
19
19
|
import { KNOWLEDGE_SETTINGS_SCHEMA, SETTINGS_NAMESPACE } from './settings-schema.js';
|
|
20
20
|
import { DEFAULT_KB_ID, KnowledgeBases } from './knowledge-bases.js';
|
|
21
21
|
import { ImagePublishError, publishKnowledgeImage } from './images.js';
|
|
22
22
|
import { applyConvert, CONVERT_SETTINGS_NAMESPACE, CONVERT_SETTINGS_SCHEMA, MOUNT_PATH as CONVERT_MOUNT_PATH, } from './convert/host.js';
|
|
23
|
-
import { applyIntent, INTENT_MOUNT_PATH, INTENT_SERVICE, } from './intent/host.js';
|
|
24
|
-
import { registerIntentTools } from './intent/tools.js';
|
|
25
23
|
export * from './types.js';
|
|
26
24
|
export * from './runtime.js';
|
|
27
25
|
export * from './knowledge-bases.js';
|
|
28
|
-
export * from './intent/types.js';
|
|
29
|
-
export * from './intent/engine.js';
|
|
30
26
|
export { applyConvert as applyConvertHost, CONVERT_SETTINGS_NAMESPACE, CONVERT_MOUNT_PATH };
|
|
31
|
-
export { applyIntent as applyIntentHost, INTENT_MOUNT_PATH, INTENT_SERVICE };
|
|
32
27
|
export const name = 'dsh-data-domain-knowledge';
|
|
33
28
|
/**
|
|
34
29
|
* `settings` 在 0.1.7 之后**不再需要**:设置已经是本 entry 的 config
|
|
@@ -51,6 +46,7 @@ export { CONVERT_SETTINGS_SCHEMA };
|
|
|
51
46
|
*/
|
|
52
47
|
import { Config } from './config-schema.js';
|
|
53
48
|
import { buildModelRequest, callModelWithRetry, collectModelText } from './model-text.js';
|
|
49
|
+
import { agentRecallEnvelope } from './recall-delivery.js';
|
|
54
50
|
import { addSourceCallView, addSourceMetaOf, addSourceResultMarkdown, importCallView, importMetaOf, importResultMarkdown, recallCallView, recallMetaOf, recallResultMarkdown, rebuildCallView, rebuildMetaOf, rebuildResultMarkdown, writeCardsCallView, writeCardsMetaOf, writeCardsResultMarkdown, } from './present.js';
|
|
55
51
|
export { Config };
|
|
56
52
|
/**
|
|
@@ -137,7 +133,7 @@ function lineageOf(args, exec) {
|
|
|
137
133
|
if (sessionId)
|
|
138
134
|
lineage.sessionId = sessionId;
|
|
139
135
|
const fields = [
|
|
140
|
-
['turnId', 'turn_id'], ['
|
|
136
|
+
['turnId', 'turn_id'], ['taskId', 'task_id'],
|
|
141
137
|
['subtaskId', 'subtask_id'], ['parentSubtaskId', 'parent_subtask_id'], ['runId', 'run_id'], ['traceId', 'trace_id'], ['domain', 'domain'],
|
|
142
138
|
];
|
|
143
139
|
for (const [target, source] of fields)
|
|
@@ -149,7 +145,6 @@ function lineageFromUrl(url) {
|
|
|
149
145
|
return lineageOf({
|
|
150
146
|
session_key: url.searchParams.get('session_key') ?? undefined,
|
|
151
147
|
turn_id: url.searchParams.get('turn_id') ?? undefined,
|
|
152
|
-
intent_id: url.searchParams.get('intent_id') ?? undefined,
|
|
153
148
|
task_id: url.searchParams.get('task_id') ?? undefined,
|
|
154
149
|
subtask_id: url.searchParams.get('subtask_id') ?? undefined,
|
|
155
150
|
parent_subtask_id: url.searchParams.get('parent_subtask_id') ?? undefined,
|
|
@@ -335,8 +330,7 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
335
330
|
/**
|
|
336
331
|
* 这两组的把手,`loader/volatile-update` 时调 `reprocess()` 按新值重灌。
|
|
337
332
|
*
|
|
338
|
-
*
|
|
339
|
-
* `applyIntent`)。
|
|
333
|
+
* 先声明后赋值:事件只在运行时触发,转换宿主在下面的 `applyConvert` 中装配。
|
|
340
334
|
*/
|
|
341
335
|
let convertHost;
|
|
342
336
|
/**
|
|
@@ -725,7 +719,7 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
725
719
|
/**
|
|
726
720
|
* 交付物落在**工作项目**下:`<工作区>/output/<日期>/`,不是 Agent 根路径。
|
|
727
721
|
*
|
|
728
|
-
*
|
|
722
|
+
* 根路径下的几段(知识 / 记忆 / 家当)是**这个 Agent 自己的东西**,跨项目
|
|
729
723
|
* 累积;交付物是**某个项目的产物**,换一个项目打开就不该再看见。两者判据不同,
|
|
730
724
|
* 所以落点也不同。
|
|
731
725
|
*
|
|
@@ -745,26 +739,6 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
745
739
|
return target ? { runtime: target, knowledgeRoot: target.rootDir } : undefined;
|
|
746
740
|
},
|
|
747
741
|
});
|
|
748
|
-
// 意图记录模块 (issue 0020). The 意图 view was already one of this plugin's
|
|
749
|
-
// five panel tabs, but its Host lived in a second mount unit; 0020 folds it in
|
|
750
|
-
// so the declared information architecture and the code layout agree again.
|
|
751
|
-
// It keeps the `intent_record` / `intent_store_view` tools and `/intent/**` audit endpoints,
|
|
752
|
-
// and — critically — the `titaDataAgentIntent` Cordis service that `data-table`
|
|
753
|
-
// resolves by name.
|
|
754
|
-
// 意图只保留固定的会话审计契约;可编辑词表不再属于插件配置。
|
|
755
|
-
applyIntent(ctx, {
|
|
756
|
-
intentRoot: () => intentRoot(config.agentRoot),
|
|
757
|
-
});
|
|
758
|
-
// `applyIntent` provides this service from the same plugin fiber. During
|
|
759
|
-
// `apply()`, that fiber is still starting, so Cordis's default strict lookup
|
|
760
|
-
// hides the just-provided service until startup completes. The non-strict
|
|
761
|
-
// lookup is safe here because `applyIntent` ran immediately above.
|
|
762
|
-
const intentService = ctx.get(INTENT_SERVICE, false);
|
|
763
|
-
/**
|
|
764
|
-
* `intent_*` 工具在 Host 层注册,使标准模式可以调用它们;工具执行端只接受
|
|
765
|
-
* standard 会话,其他 preset 不会写入或读取意图记录。
|
|
766
|
-
*/
|
|
767
|
-
ctx.effect(() => registerIntentTools(ctx, intentService), 'tita knowledge: global intent tools');
|
|
768
742
|
/**
|
|
769
743
|
* 规则正文由当前会话 preset 决定;设置里的 volatile 引用在每次组装提示词时解包,
|
|
770
744
|
* 因此开关保存后立即生效,不需要重建 Agent 会话。
|
|
@@ -806,12 +780,16 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
806
780
|
return Promise.resolve({ kind: 'ask', reason: '该操作会写入 Tita Knowledge Store,需要本轮用户审批。' });
|
|
807
781
|
return next();
|
|
808
782
|
});
|
|
809
|
-
ctx.tools.register(tool('recall_knowledge', 'Recall Wiki Fact and Wiki Way through H2 title and body search. Use the current subquestion as query when seeking a Procedure. Return complete Wiki files with conditions and evidence. Use get_knowledge_cases for historical Case evidence; a past root cause does not establish the current root cause.', { query: { type: 'string', required: true }, limit: { type: 'integer' }, top_k: { type: 'integer' }, top_n: { type: 'integer' }, rerank: { type: 'boolean' }, context_max_chars: { type: 'integer', description: '这次召回的上下文字符上限;省略则用设置里的值(默认 20000,0 = 不限)。超出部分落在系统临时目录,响应里的 budget.overflow_path 就是它的绝对路径 —— 需要更多信息时直接读那个文件。' }, include_problems: { type: 'boolean' }, mode: { type: 'string', enum: ['fts', 'vector', 'hybrid'] }, kb: { type: 'string' }, session_key: { type: 'string' }, task_id: { type: 'string' }, subtask_id: { type: 'string' }, parent_subtask_id: { type: 'string' }, run_id: { type: 'string' }, turn_id: { type: 'string' }, trace_id: { type: 'string' }, domain: { type: 'string' } }, async (args, exec) => withRuntime(args.kb, target => target.recall(args.query, args.top_k ?? args.limit, args.include_problems ?? false, args.mode, lineageOf(args, exec), { contextTopN: args.top_n, rerank: args.rerank, ...(typeof args.context_max_chars === 'number' ? { contextMaxChars: args.context_max_chars } : {}) })), {
|
|
783
|
+
ctx.tools.register(tool('recall_knowledge', 'Recall Wiki Fact and Wiki Way through H2 title and body search. Use the current subquestion as query when seeking a Procedure. Return complete Wiki files with conditions and evidence. Follow Wiki links with read_knowledge_wiki; browse Object coordinates with its object_id filter. Use get_knowledge_cases for historical Case evidence; a past root cause does not establish the current root cause.', { query: { type: 'string', required: true }, limit: { type: 'integer' }, top_k: { type: 'integer' }, top_n: { type: 'integer' }, rerank: { type: 'boolean' }, context_max_chars: { type: 'integer', description: '这次召回的上下文字符上限;省略则用设置里的值(默认 20000,0 = 不限)。超出部分落在系统临时目录,响应里的 budget.overflow_path 就是它的绝对路径 —— 需要更多信息时直接读那个文件。' }, include_problems: { type: 'boolean' }, mode: { type: 'string', enum: ['fts', 'vector', 'hybrid'] }, kb: { type: 'string' }, session_key: { type: 'string' }, task_id: { type: 'string' }, subtask_id: { type: 'string' }, parent_subtask_id: { type: 'string' }, run_id: { type: 'string' }, turn_id: { type: 'string' }, trace_id: { type: 'string' }, domain: { type: 'string' } }, async (args, exec) => withRuntime(args.kb, async (target) => agentRecallEnvelope(await target.recall(args.query, args.top_k ?? args.limit, args.include_problems ?? false, args.mode, lineageOf(args, exec), { contextTopN: args.top_n, rerank: args.rerank, ...(typeof args.context_max_chars === 'number' ? { contextMaxChars: args.context_max_chars } : {}) }))), {
|
|
810
784
|
call: recallCallView,
|
|
811
785
|
// 查询词从参数来,命中从结果来 —— 两者拼成一张能看懂的账本。
|
|
812
786
|
meta: (args, value) => recallMetaOf({ ...dataOf(value), query: args?.query }),
|
|
813
787
|
result: resultViewOf(recallResultMarkdown),
|
|
814
788
|
}));
|
|
789
|
+
ctx.tools.register(tool('read_knowledge_wiki', 'Read a complete Wiki through a [[type/entityId|label]] link or stable target. Browse an Object by object_id or unique object name; optional action_id, scene_id and wiki_kind select exact coordinates. Omitted axes mean all; empty axes match empty only. Object browsing returns a paged directory by default. Set include_content to read complete selected files. Follow outgoing links and backlinks as needed; do not fetch every neighbor automatically.', {
|
|
790
|
+
target: { type: 'string' }, object_id: { type: 'string' }, object: { type: 'string' }, action_id: { type: 'string' }, scene_id: { type: 'string' }, wiki_kind: { type: 'string', enum: ['fact', 'way'] },
|
|
791
|
+
include_content: { type: 'boolean' }, limit: { type: 'integer' }, offset: { type: 'integer' }, kb: { type: 'string' },
|
|
792
|
+
}, async (args) => withRuntime(args.kb, target => target.readWiki({ target: args.target, objectId: args.object_id, object: args.object, actionId: args.action_id, sceneId: args.scene_id, wikiKind: args.wiki_kind, includeContent: args.include_content, limit: args.limit, offset: args.offset }))));
|
|
815
793
|
ctx.tools.register(tool('get_knowledge_cases', 'Read historical Case records referenced by Wiki metadata.case_refs. Timelines are evidence from a past instance, not proof of the present diagnosis.', {
|
|
816
794
|
case_ids: { type: 'array', required: true, description: 'Case IDs from Wiki metadata.case_refs; maximum 50 IDs.' },
|
|
817
795
|
version: { type: 'integer', description: 'Optional historical Case version from metadata.case_refs; requires exactly one case ID.' },
|
|
@@ -916,10 +894,10 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
916
894
|
* 两者的差别只在「一次多少份」,落盘路径、分类闸门、编译链路完全共用 ——
|
|
917
895
|
* 这个工具的 `execute` 就是循环调 `importSources`,而后者逐条调 `addSource`。
|
|
918
896
|
*
|
|
919
|
-
* `compile`
|
|
920
|
-
*
|
|
897
|
+
* `compile` 默认关闭:先保存来源,再由调用方决定何时处理。显式 true 才跑全链路;
|
|
898
|
+
* 未触发处理时工具返回 `compile: null`。
|
|
921
899
|
*/
|
|
922
|
-
ctx.tools.register(tool('import_sources', 'Import many SourceRaw documents in one call. By default only stores sources. Explicit compile:true runs extract, normalize, materialize, and index publication for the imported documents. Per-source import failures are reported without aborting the batch. DSH requests one user approval before execution.', { sources: { type: 'array', required: true, description: `来源数组,每项 { title?, content, external_id?, metadata?, allow_duplicate_title? };一次最多 ${MAX_IMPORT_SOURCES} 份,超了请分批。标题与已有来源重复的那一份会被拒(SOURCE_TITLE_DUPLICATED),逐条报出来而不是整批失败` }, compile: { type: 'boolean', description: '默认 false:只保存来源;显式 true 才运行完整抽取、归一与物化' }, kb: { type: 'string' }, session_key: { type: 'string' }, task_id: { type: 'string' }, subtask_id: { type: 'string' }, run_id: { type: 'string' }, turn_id: { type: 'string' }, trace_id: { type: 'string' }, domain: { type: 'string' } }, async (args, exec) => withRuntime(args.kb, target => target.importSources({ sources: (Array.isArray(args.sources) ? args.sources : []).map(item => ({ ...(item?.title ? { title: item.title } : {}), content: item?.content, ...(item?.external_id ? { externalId: item.external_id } : {}), ...(item?.metadata ? { metadata: item.metadata } : {}), ...(item?.allow_duplicate_title === true ? { allowDuplicateTitle: true } : {}) })), compile: args.compile === true, lineage: lineageOf(args, exec) })), { call: importCallView, meta: (_args, value) => importMetaOf(dataOf(value)), result: resultViewOf(importResultMarkdown) }));
|
|
900
|
+
ctx.tools.register(tool('import_sources', 'Import many SourceRaw documents in one call. By default only stores sources. Explicit compile:true runs extract, normalize, materialize, and index publication for the imported documents. Per-source import failures are reported without aborting the batch. DSH requests one user approval before execution.', { sources: { type: 'array', required: true, description: `来源数组,每项 { source_id?, title?, content, external_id?, metadata?, allow_duplicate_title? };文件导入前分配唯一 source_id,重试沿用;更新旧来源必须传其 source_id;一次最多 ${MAX_IMPORT_SOURCES} 份,超了请分批。标题与已有来源重复的那一份会被拒(SOURCE_TITLE_DUPLICATED),逐条报出来而不是整批失败` }, compile: { type: 'boolean', description: '默认 false:只保存来源;显式 true 才运行完整抽取、归一与物化' }, kb: { type: 'string' }, session_key: { type: 'string' }, task_id: { type: 'string' }, subtask_id: { type: 'string' }, run_id: { type: 'string' }, turn_id: { type: 'string' }, trace_id: { type: 'string' }, domain: { type: 'string' } }, async (args, exec) => withRuntime(args.kb, target => target.importSources({ sources: (Array.isArray(args.sources) ? args.sources : []).map(item => ({ ...(item?.source_id ? { sourceId: item.source_id } : {}), ...(item?.title ? { title: item.title } : {}), content: item?.content, ...(item?.external_id ? { externalId: item.external_id } : {}), ...(item?.metadata ? { metadata: item.metadata } : {}), ...(item?.allow_duplicate_title === true ? { allowDuplicateTitle: true } : {}) })), compile: args.compile === true, lineage: lineageOf(args, exec) })), { call: importCallView, meta: (_args, value) => importMetaOf(dataOf(value)), result: resultViewOf(importResultMarkdown) }));
|
|
923
901
|
/**
|
|
924
902
|
* `propose_wiki_cards` —— 把一批卡片**直接写进 `02_wiki`**(工具名不变,语义在 0044 改了)。
|
|
925
903
|
*
|
|
@@ -1063,6 +1041,18 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
1063
1041
|
return sendEnvelope(res, resolved.failure);
|
|
1064
1042
|
return send(res, 200, success(await resolved.runtime.stats()));
|
|
1065
1043
|
} },
|
|
1044
|
+
{ kind: 'exact', path: '/knowledge/wiki', handler: async (req, res) => {
|
|
1045
|
+
if (req.method !== 'GET')
|
|
1046
|
+
return send(res, 405, envelopeError('METHOD_NOT_ALLOWED', 'Wiki 读取只接受 GET'));
|
|
1047
|
+
const url = query(req);
|
|
1048
|
+
const resolved = resolveBase(url.searchParams.get('kb'));
|
|
1049
|
+
if ('failure' in resolved)
|
|
1050
|
+
return sendEnvelope(res, resolved.failure);
|
|
1051
|
+
return sendEnvelope(res, await resolved.runtime.readWiki({ target: url.searchParams.get('target') ?? undefined, objectId: url.searchParams.get('object_id') ?? undefined, object: url.searchParams.get('object') ?? undefined,
|
|
1052
|
+
actionId: url.searchParams.get('action_id') ?? undefined, sceneId: url.searchParams.get('scene_id') ?? undefined, wikiKind: (url.searchParams.get('wiki_kind') ?? undefined),
|
|
1053
|
+
includeContent: url.searchParams.has('include_content') ? url.searchParams.get('include_content') === 'true' : undefined,
|
|
1054
|
+
limit: url.searchParams.has('limit') ? Number(url.searchParams.get('limit')) : undefined, offset: url.searchParams.has('offset') ? Number(url.searchParams.get('offset')) : undefined }));
|
|
1055
|
+
} },
|
|
1066
1056
|
{ kind: 'exact', path: '/knowledge/cases', handler: async (req, res) => {
|
|
1067
1057
|
if (req.method !== 'GET')
|
|
1068
1058
|
return send(res, 405, envelopeError('METHOD_NOT_ALLOWED', 'Case 只接受 GET'));
|
|
@@ -1323,8 +1313,10 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
1323
1313
|
sources: (Array.isArray(body.sources) ? body.sources : []).map((item) => ({
|
|
1324
1314
|
...(item?.title ? { title: String(item.title) } : {}),
|
|
1325
1315
|
content: item?.content,
|
|
1316
|
+
...(item?.source_id ? { sourceId: String(item.source_id) } : {}),
|
|
1326
1317
|
...(item?.external_id ? { externalId: String(item.external_id) } : {}),
|
|
1327
1318
|
...(item?.metadata && typeof item.metadata === 'object' ? { metadata: item.metadata } : {}),
|
|
1319
|
+
...(item?.allow_duplicate_title === true ? { allowDuplicateTitle: true } : {}),
|
|
1328
1320
|
})),
|
|
1329
1321
|
compile: body.compile === true,
|
|
1330
1322
|
lineage: lineageOf(body),
|
|
@@ -1974,7 +1966,6 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
1974
1966
|
* /knowledge/pages/run?kb=<库 id>&run=<轨迹 id> 一次抽取的完整报告
|
|
1975
1967
|
* /knowledge/pages/tasks?kb=<知识库 id> 抽取任务
|
|
1976
1968
|
* /knowledge/pages/help/compile 编译链路
|
|
1977
|
-
* /knowledge/pages/help/intent 意图的逻辑
|
|
1978
1969
|
* /knowledge/pages/help/overview?node=... 五个 Tab 的方案说明
|
|
1979
1970
|
* ```
|
|
1980
1971
|
*
|
|
@@ -2003,11 +1994,9 @@ export function apply(ctx, pluginConfig = {}) {
|
|
|
2003
1994
|
? '抽取轨迹'
|
|
2004
1995
|
: rest[1] === 'tasks'
|
|
2005
1996
|
? '抽取任务'
|
|
2006
|
-
: rest[1] === 'help' && rest[2] === '
|
|
2007
|
-
? '
|
|
2008
|
-
: rest[1] === 'help' && rest[2] === '
|
|
2009
|
-
? '编译链路'
|
|
2010
|
-
: rest[1] === 'help' && rest[2] === 'overview' ? 'Agent 方案说明' : '整页';
|
|
1997
|
+
: rest[1] === 'help' && rest[2] === 'compile'
|
|
1998
|
+
? '编译链路'
|
|
1999
|
+
: rest[1] === 'help' && rest[2] === 'overview' ? 'Agent 方案说明' : '整页';
|
|
2011
2000
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' });
|
|
2012
2001
|
res.end(standalonePageHtml(title));
|
|
2013
2002
|
return;
|