@pellux/goodvibes-sdk 0.27.12 → 0.28.1
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/_internal/contracts/artifacts/operator-contract.json +5302 -3628
- package/dist/_internal/contracts/generated/foundation-metadata.d.ts +2 -2
- package/dist/_internal/contracts/generated/foundation-metadata.js +2 -2
- package/dist/_internal/contracts/generated/operator-contract.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-contract.js +5302 -3628
- package/dist/_internal/contracts/generated/operator-method-ids.d.ts +1 -1
- package/dist/_internal/contracts/generated/operator-method-ids.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-method-ids.js +8 -0
- package/dist/_internal/daemon/context.d.ts +4 -0
- package/dist/_internal/daemon/context.d.ts.map +1 -1
- package/dist/_internal/daemon/index.d.ts +1 -0
- package/dist/_internal/daemon/index.d.ts.map +1 -1
- package/dist/_internal/daemon/index.js +1 -0
- package/dist/_internal/daemon/knowledge-refinement-routes.d.ts +4 -0
- package/dist/_internal/daemon/knowledge-refinement-routes.d.ts.map +1 -0
- package/dist/_internal/daemon/knowledge-refinement-routes.js +57 -0
- package/dist/_internal/daemon/knowledge-route-types.d.ts +4 -0
- package/dist/_internal/daemon/knowledge-route-types.d.ts.map +1 -1
- package/dist/_internal/daemon/knowledge-routes.d.ts +1 -1
- package/dist/_internal/daemon/knowledge-routes.d.ts.map +1 -1
- package/dist/_internal/daemon/knowledge-routes.js +2 -0
- package/dist/_internal/daemon/operator.d.ts +1 -1
- package/dist/_internal/daemon/operator.d.ts.map +1 -1
- package/dist/_internal/daemon/operator.js +10 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts +4 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema-domain-runtime.js +17 -0
- package/dist/_internal/platform/config/schema-types.d.ts +6 -2
- package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-homegraph.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-homegraph.js +53 -2
- package/dist/_internal/platform/control-plane/method-catalog-knowledge.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-knowledge.js +59 -1
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.d.ts +20 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.d.ts.map +1 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.js +140 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.d.ts +11 -16
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.js +90 -127
- package/dist/_internal/platform/control-plane/routes/operator.d.ts +1 -1
- package/dist/_internal/platform/control-plane/routes/operator.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/routes/operator.js +10 -0
- package/dist/_internal/platform/daemon/http/home-graph-routes.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/home-graph-routes.js +32 -0
- package/dist/_internal/platform/daemon/http/openai-compatible-routes.d.ts +10 -0
- package/dist/_internal/platform/daemon/http/openai-compatible-routes.d.ts.map +1 -0
- package/dist/_internal/platform/daemon/http/openai-compatible-routes.js +445 -0
- package/dist/_internal/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router-route-contexts.js +4 -0
- package/dist/_internal/platform/daemon/http/router.d.ts +1 -0
- package/dist/_internal/platform/daemon/http/router.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router.js +16 -0
- package/dist/_internal/platform/knowledge/home-graph/ask.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/ask.js +1 -0
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.js +24 -5
- package/dist/_internal/platform/knowledge/home-graph/inventory.d.ts +23 -0
- package/dist/_internal/platform/knowledge/home-graph/inventory.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/inventory.js +21 -0
- package/dist/_internal/platform/knowledge/home-graph/map-view.d.ts +6 -0
- package/dist/_internal/platform/knowledge/home-graph/map-view.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/map-view.js +11 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.d.ts +57 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.js +63 -0
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts +3 -3
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/rendering.js +52 -136
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts +47 -0
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/service.js +21 -42
- package/dist/_internal/platform/knowledge/home-graph/status.d.ts +4 -0
- package/dist/_internal/platform/knowledge/home-graph/status.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/status.js +43 -0
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts +7 -0
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/index.d.ts +1 -1
- package/dist/_internal/platform/knowledge/index.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/scheduling.js +1 -1
- package/dist/_internal/platform/knowledge/semantic/answer.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/answer.js +69 -9
- package/dist/_internal/platform/knowledge/semantic/gap-repair.d.ts +2 -0
- package/dist/_internal/platform/knowledge/semantic/gap-repair.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/gap-repair.js +68 -14
- package/dist/_internal/platform/knowledge/semantic/self-improvement.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/self-improvement.js +172 -7
- package/dist/_internal/platform/knowledge/semantic/service.d.ts +1 -2
- package/dist/_internal/platform/knowledge/semantic/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/service.js +63 -54
- package/dist/_internal/platform/knowledge/semantic/types.d.ts +19 -0
- package/dist/_internal/platform/knowledge/semantic/types.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/service-jobs.d.ts +34 -0
- package/dist/_internal/platform/knowledge/service-jobs.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/service-jobs.js +64 -0
- package/dist/_internal/platform/knowledge/service.d.ts +18 -1
- package/dist/_internal/platform/knowledge/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/service.js +53 -69
- package/dist/_internal/platform/knowledge/store-config.d.ts +8 -0
- package/dist/_internal/platform/knowledge/store-config.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/store-config.js +10 -0
- package/dist/_internal/platform/knowledge/store-load.d.ts +2 -1
- package/dist/_internal/platform/knowledge/store-load.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store-load.js +2 -1
- package/dist/_internal/platform/knowledge/store-read.d.ts +10 -1
- package/dist/_internal/platform/knowledge/store-read.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store-read.js +14 -0
- package/dist/_internal/platform/knowledge/store-refinement.d.ts +4 -0
- package/dist/_internal/platform/knowledge/store-refinement.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/store-refinement.js +69 -0
- package/dist/_internal/platform/knowledge/store-schema.d.ts +2 -1
- package/dist/_internal/platform/knowledge/store-schema.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store-schema.js +48 -0
- package/dist/_internal/platform/knowledge/store.d.ts +6 -7
- package/dist/_internal/platform/knowledge/store.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store.js +18 -13
- package/dist/_internal/platform/knowledge/types.d.ts +56 -0
- package/dist/_internal/platform/knowledge/types.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/emitters/turn.d.ts +6 -2
- package/dist/_internal/platform/runtime/emitters/turn.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/emitters/turn.js +4 -4
- package/dist/_internal/platform/runtime/events/turn.d.ts +12 -2
- package/dist/_internal/platform/runtime/events/turn.d.ts.map +1 -1
- package/dist/_internal/platform/version.js +1 -1
- package/package.json +1 -1
|
@@ -2,55 +2,105 @@ import { isGeneratedKnowledgeSource } from '../generated-projections.js';
|
|
|
2
2
|
import { getKnowledgeSpaceId, normalizeKnowledgeSpaceId } from '../spaces.js';
|
|
3
3
|
import { readRecord, readString, semanticHash, semanticMetadata, semanticSlug, sourceKnowledgeSpace, uniqueStrings, } from './utils.js';
|
|
4
4
|
const RETRY_DELAY_MS = 6 * 60 * 60 * 1000;
|
|
5
|
+
const DEFAULT_REFINEMENT_LIMIT = 24;
|
|
6
|
+
const MAX_REFINEMENT_LIMIT = 50;
|
|
7
|
+
const DEFAULT_REFINEMENT_RUN_MS = 90_000;
|
|
8
|
+
const MAX_REFINEMENT_RUN_MS = 120_000;
|
|
9
|
+
const STALE_ACTIVE_TASK_MS = 10 * 60 * 1000;
|
|
10
|
+
const ACTIVE_REFINEMENT_STATES = new Set([
|
|
11
|
+
'queued',
|
|
12
|
+
'searching',
|
|
13
|
+
'evaluating',
|
|
14
|
+
'extracting',
|
|
15
|
+
'applying',
|
|
16
|
+
]);
|
|
5
17
|
export async function runKnowledgeSemanticSelfImprovement(context, input = {}) {
|
|
6
18
|
await context.store.init();
|
|
7
19
|
const sourceIdFilter = input.sourceIds?.length ? new Set(input.sourceIds) : null;
|
|
8
20
|
const gapIdFilter = input.gapIds?.length ? new Set(input.gapIds) : null;
|
|
9
21
|
const spaceId = resolveSelfImproveSpace(context.store, input);
|
|
22
|
+
await recoverStaleActiveTasks(context.store, spaceId);
|
|
10
23
|
const createdGaps = await discoverIntrinsicGaps(context.store, spaceId, sourceIdFilter);
|
|
11
|
-
const
|
|
12
|
-
|
|
24
|
+
const candidates = collectCandidateGaps(context.store, spaceId, sourceIdFilter, gapIdFilter);
|
|
25
|
+
const requestedLimit = Math.max(1, input.limit ?? DEFAULT_REFINEMENT_LIMIT);
|
|
26
|
+
const effectiveLimit = Math.min(requestedLimit, MAX_REFINEMENT_LIMIT);
|
|
27
|
+
const maxRunMs = Math.min(MAX_REFINEMENT_RUN_MS, Math.max(5_000, input.maxRunMs ?? DEFAULT_REFINEMENT_RUN_MS));
|
|
28
|
+
const startedAt = Date.now();
|
|
29
|
+
const gaps = candidates.slice(0, effectiveLimit);
|
|
30
|
+
let truncated = candidates.length > gaps.length || requestedLimit > effectiveLimit;
|
|
31
|
+
let budgetExhausted = false;
|
|
32
|
+
let processedGaps = 0;
|
|
13
33
|
let repairableGaps = 0;
|
|
14
34
|
let suppressedGaps = 0;
|
|
15
35
|
let skippedGaps = 0;
|
|
36
|
+
let blockedGaps = 0;
|
|
37
|
+
let closedGaps = 0;
|
|
38
|
+
let queuedTasks = 0;
|
|
16
39
|
let searched = 0;
|
|
17
40
|
let ingestedSources = 0;
|
|
18
41
|
let linkedRepairs = 0;
|
|
42
|
+
const taskIds = [];
|
|
43
|
+
const ingestedSourceIds = [];
|
|
19
44
|
const errors = [];
|
|
45
|
+
const trigger = input.reason ?? 'manual';
|
|
20
46
|
for (const gap of gaps) {
|
|
47
|
+
if (Date.now() - startedAt >= maxRunMs) {
|
|
48
|
+
truncated = true;
|
|
49
|
+
budgetExhausted = true;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
processedGaps += 1;
|
|
21
53
|
const gapContext = buildGapContext(context.store, spaceId, gap);
|
|
54
|
+
let task = await upsertRefinementTaskForGap(context.store, spaceId, gapContext, trigger, 'detected', 'Gap was detected for semantic refinement.');
|
|
55
|
+
taskIds.push(task.id);
|
|
22
56
|
const classification = classifyGap(gapContext, input.force === true);
|
|
23
57
|
if (classification.action === 'suppress') {
|
|
24
58
|
await suppressGap(context.store, gap, classification.reason, spaceId);
|
|
59
|
+
await updateRefinementTask(context.store, task, 'suppressed', classification.reason ?? 'Gap was classified as not applicable.');
|
|
25
60
|
suppressedGaps += 1;
|
|
26
61
|
continue;
|
|
27
62
|
}
|
|
28
63
|
if (classification.action === 'skip') {
|
|
29
|
-
|
|
64
|
+
if (classification.status === 'repaired' || classification.status === 'already_repaired') {
|
|
65
|
+
closedGaps += 1;
|
|
66
|
+
await updateRefinementTask(context.store, task, 'closed', classification.reason ?? 'Gap is already repaired.');
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (classification.status === 'active') {
|
|
70
|
+
skippedGaps += 1;
|
|
71
|
+
await updateRefinementTask(context.store, task, 'queued', classification.reason ?? 'Gap repair is already active.');
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
blockedGaps += 1;
|
|
30
75
|
if (classification.markAttempt) {
|
|
31
76
|
await markGapRepairAttempt(context.store, gap, spaceId, {
|
|
32
77
|
status: classification.status ?? 'skipped',
|
|
33
78
|
reason: classification.reason,
|
|
34
79
|
});
|
|
35
80
|
}
|
|
81
|
+
await updateRefinementTask(context.store, task, 'blocked', classification.reason ?? 'Gap is not currently repairable.');
|
|
36
82
|
continue;
|
|
37
83
|
}
|
|
38
84
|
if (!context.gapRepairer) {
|
|
39
|
-
|
|
85
|
+
blockedGaps += 1;
|
|
40
86
|
await markGapRepairAttempt(context.store, gap, spaceId, {
|
|
41
87
|
status: 'no_repairer',
|
|
42
88
|
reason: 'No semantic gap repairer is configured.',
|
|
43
89
|
});
|
|
90
|
+
await updateRefinementTask(context.store, task, 'blocked', 'No semantic gap repairer is configured.');
|
|
44
91
|
continue;
|
|
45
92
|
}
|
|
46
93
|
const repairKey = `${spaceId}:${gap.id}`;
|
|
47
94
|
if (context.activeGapRepairs.has(repairKey)) {
|
|
48
95
|
skippedGaps += 1;
|
|
96
|
+
await updateRefinementTask(context.store, task, 'queued', 'Gap repair is already active.');
|
|
49
97
|
continue;
|
|
50
98
|
}
|
|
51
99
|
repairableGaps += 1;
|
|
100
|
+
queuedTasks += 1;
|
|
52
101
|
context.activeGapRepairs.add(repairKey);
|
|
53
102
|
try {
|
|
103
|
+
task = await updateRefinementTask(context.store, task, 'searching', 'Searching for source-backed repair evidence.', { query: gap.title });
|
|
54
104
|
const result = await context.gapRepairer({
|
|
55
105
|
spaceId,
|
|
56
106
|
query: gap.title,
|
|
@@ -62,12 +112,31 @@ export async function runKnowledgeSemanticSelfImprovement(context, input = {}) {
|
|
|
62
112
|
if (result?.searched)
|
|
63
113
|
searched += 1;
|
|
64
114
|
ingestedSources += result?.ingestedSourceIds.length ?? 0;
|
|
115
|
+
ingestedSourceIds.push(...(result?.ingestedSourceIds ?? []));
|
|
116
|
+
task = await updateRefinementTask(context.store, task, 'evaluating', result?.reason ?? 'Source discovery completed.', {
|
|
117
|
+
query: result?.query ?? gap.title,
|
|
118
|
+
sourceAssessments: result?.sourceAssessments ?? [],
|
|
119
|
+
ingestedSourceIds: result?.ingestedSourceIds ?? [],
|
|
120
|
+
skippedUrls: result?.skippedUrls ?? [],
|
|
121
|
+
});
|
|
122
|
+
if (result?.ingestedSourceIds.length) {
|
|
123
|
+
task = await updateRefinementTask(context.store, task, 'applying', 'Linking accepted repair sources into the graph.');
|
|
124
|
+
}
|
|
65
125
|
linkedRepairs += await linkRepairSources(context.store, spaceId, gap, result?.ingestedSourceIds ?? [], result?.query ?? gap.title);
|
|
66
126
|
await markGapRepairAttempt(context.store, gap, spaceId, {
|
|
67
127
|
status: result?.ingestedSourceIds.length ? 'repaired' : 'searched_no_sources',
|
|
68
128
|
reason: result?.reason,
|
|
69
129
|
query: result?.query,
|
|
70
130
|
});
|
|
131
|
+
if (result?.ingestedSourceIds.length) {
|
|
132
|
+
await updateRefinementTask(context.store, task, 'closed', 'Repair sources were accepted and linked to the gap.', {
|
|
133
|
+
ingestedSourceIds: result.ingestedSourceIds,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
blockedGaps += 1;
|
|
138
|
+
await updateRefinementTask(context.store, task, 'blocked', result?.reason ?? 'No acceptable repair sources were found.');
|
|
139
|
+
}
|
|
71
140
|
}
|
|
72
141
|
catch (error) {
|
|
73
142
|
errors.push({ gapId: gap.id, error: error instanceof Error ? error.message : String(error) });
|
|
@@ -75,13 +144,17 @@ export async function runKnowledgeSemanticSelfImprovement(context, input = {}) {
|
|
|
75
144
|
status: 'failed',
|
|
76
145
|
reason: error instanceof Error ? error.message : String(error),
|
|
77
146
|
});
|
|
147
|
+
await updateRefinementTask(context.store, task, 'failed', error instanceof Error ? error.message : String(error));
|
|
78
148
|
}
|
|
79
149
|
finally {
|
|
80
150
|
context.activeGapRepairs.delete(repairKey);
|
|
81
151
|
}
|
|
152
|
+
await yieldToEventLoop();
|
|
82
153
|
}
|
|
83
154
|
return {
|
|
84
155
|
scannedGaps: gaps.length,
|
|
156
|
+
candidateGaps: candidates.length,
|
|
157
|
+
processedGaps,
|
|
85
158
|
createdGaps,
|
|
86
159
|
repairableGaps,
|
|
87
160
|
suppressedGaps,
|
|
@@ -89,9 +162,30 @@ export async function runKnowledgeSemanticSelfImprovement(context, input = {}) {
|
|
|
89
162
|
searched,
|
|
90
163
|
ingestedSources,
|
|
91
164
|
linkedRepairs,
|
|
165
|
+
blockedGaps,
|
|
166
|
+
closedGaps,
|
|
167
|
+
queuedTasks,
|
|
168
|
+
requestedLimit,
|
|
169
|
+
effectiveLimit,
|
|
170
|
+
truncated,
|
|
171
|
+
budgetExhausted,
|
|
172
|
+
taskIds: uniqueStrings(taskIds),
|
|
173
|
+
ingestedSourceIds: uniqueStrings(ingestedSourceIds),
|
|
92
174
|
errors,
|
|
93
175
|
};
|
|
94
176
|
}
|
|
177
|
+
async function recoverStaleActiveTasks(store, spaceId) {
|
|
178
|
+
const now = Date.now();
|
|
179
|
+
const staleTasks = store.listRefinementTasks(10_000, { spaceId })
|
|
180
|
+
.filter((task) => ACTIVE_REFINEMENT_STATES.has(task.state))
|
|
181
|
+
.filter((task) => now - task.updatedAt >= STALE_ACTIVE_TASK_MS);
|
|
182
|
+
for (const task of staleTasks) {
|
|
183
|
+
await updateRefinementTask(store, task, 'blocked', 'Refinement task was interrupted or exceeded the active window; it can be retried.');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async function yieldToEventLoop() {
|
|
187
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
188
|
+
}
|
|
95
189
|
function resolveSelfImproveSpace(store, input) {
|
|
96
190
|
if (input.knowledgeSpaceId)
|
|
97
191
|
return normalizeKnowledgeSpaceId(input.knowledgeSpaceId);
|
|
@@ -264,11 +358,11 @@ function classifyGap(context, force) {
|
|
|
264
358
|
const status = readString(context.gap.metadata.repairStatus);
|
|
265
359
|
const nextAttemptAt = readNumber(context.gap.metadata.nextRepairAttemptAt);
|
|
266
360
|
if (!force && status === 'repaired')
|
|
267
|
-
return { action: 'skip', reason: 'Gap already has linked repair sources.' };
|
|
361
|
+
return { action: 'skip', reason: 'Gap already has linked repair sources.', status: 'repaired' };
|
|
268
362
|
if (!force && nextAttemptAt && nextAttemptAt > Date.now())
|
|
269
|
-
return { action: 'skip', reason: 'Gap repair retry window has not elapsed.' };
|
|
363
|
+
return { action: 'skip', reason: 'Gap repair retry window has not elapsed.', status: 'retry_wait', markAttempt: true };
|
|
270
364
|
if (hasRepairEdge(context))
|
|
271
|
-
return { action: 'skip', reason: 'Gap already has a repair source.' };
|
|
365
|
+
return { action: 'skip', reason: 'Gap already has a repair source.', status: 'already_repaired' };
|
|
272
366
|
if (isNotApplicableGap(context))
|
|
273
367
|
return { action: 'suppress', reason: 'The gap is not applicable to the linked subject.' };
|
|
274
368
|
if (!hasConcreteSubject(context)) {
|
|
@@ -279,6 +373,77 @@ function classifyGap(context, force) {
|
|
|
279
373
|
}
|
|
280
374
|
return { action: 'repair' };
|
|
281
375
|
}
|
|
376
|
+
async function upsertRefinementTaskForGap(store, spaceId, context, trigger, state, message, data = {}) {
|
|
377
|
+
const subject = context.linkedObjects[0];
|
|
378
|
+
const id = `kref-${semanticHash(spaceId, context.gap.id, subject?.id ?? 'unscoped')}`;
|
|
379
|
+
const existing = store.getRefinementTask(id);
|
|
380
|
+
const attemptCount = existing?.attemptCount ?? 0;
|
|
381
|
+
return store.upsertRefinementTask({
|
|
382
|
+
id,
|
|
383
|
+
spaceId,
|
|
384
|
+
...(subject ? {
|
|
385
|
+
subjectKind: 'node',
|
|
386
|
+
subjectId: subject.id,
|
|
387
|
+
subjectTitle: subjectTitle(subject),
|
|
388
|
+
subjectType: subject.kind,
|
|
389
|
+
} : {}),
|
|
390
|
+
gapId: context.gap.id,
|
|
391
|
+
state,
|
|
392
|
+
trigger,
|
|
393
|
+
priority: refinementPriority(context.gap),
|
|
394
|
+
budget: {
|
|
395
|
+
maxSearches: 1,
|
|
396
|
+
maxSources: 3,
|
|
397
|
+
maxLlmCalls: 1,
|
|
398
|
+
},
|
|
399
|
+
attemptCount,
|
|
400
|
+
appendTrace: [trace(state, message, data)],
|
|
401
|
+
metadata: semanticMetadata(spaceId, {
|
|
402
|
+
gapTitle: context.gap.title,
|
|
403
|
+
gapKind: readString(context.gap.metadata.gapKind) ?? 'unknown',
|
|
404
|
+
sourceIds: context.sources.map((source) => source.id),
|
|
405
|
+
linkedObjectIds: context.linkedObjects.map((node) => node.id),
|
|
406
|
+
policyVersion: 'knowledge-refinement-v1',
|
|
407
|
+
}),
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
async function updateRefinementTask(store, task, state, message, data = {}) {
|
|
411
|
+
return store.upsertRefinementTask({
|
|
412
|
+
id: task.id,
|
|
413
|
+
spaceId: task.spaceId,
|
|
414
|
+
subjectKind: task.subjectKind,
|
|
415
|
+
subjectId: task.subjectId,
|
|
416
|
+
subjectTitle: task.subjectTitle,
|
|
417
|
+
subjectType: task.subjectType,
|
|
418
|
+
gapId: task.gapId,
|
|
419
|
+
issueId: task.issueId,
|
|
420
|
+
state,
|
|
421
|
+
priority: task.priority,
|
|
422
|
+
trigger: task.trigger,
|
|
423
|
+
budget: task.budget,
|
|
424
|
+
attemptCount: state === 'searching' ? task.attemptCount + 1 : task.attemptCount,
|
|
425
|
+
...(state === 'blocked' || state === 'failed' ? { blockedReason: message } : {}),
|
|
426
|
+
appendTrace: [trace(state, message, data)],
|
|
427
|
+
metadata: task.metadata,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
function trace(state, message, data = {}) {
|
|
431
|
+
return {
|
|
432
|
+
at: Date.now(),
|
|
433
|
+
state,
|
|
434
|
+
message,
|
|
435
|
+
...(Object.keys(data).length > 0 ? { data } : {}),
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function refinementPriority(gap) {
|
|
439
|
+
const severity = readString(gap.metadata.severity);
|
|
440
|
+
const kind = readString(gap.metadata.gapKind);
|
|
441
|
+
if (severity === 'error')
|
|
442
|
+
return 'urgent';
|
|
443
|
+
if (severity === 'warning' || kind === 'intrinsic_features')
|
|
444
|
+
return 'high';
|
|
445
|
+
return 'normal';
|
|
446
|
+
}
|
|
282
447
|
function hasRepairEdge(context) {
|
|
283
448
|
return context.repairSourceIds.length > 0;
|
|
284
449
|
}
|
|
@@ -39,7 +39,6 @@ export declare class KnowledgeSemanticService {
|
|
|
39
39
|
}>;
|
|
40
40
|
answer(input: KnowledgeSemanticAnswerInput): Promise<KnowledgeSemanticAnswerResult>;
|
|
41
41
|
selfImprove(input?: KnowledgeSemanticSelfImproveInput): Promise<KnowledgeSemanticSelfImproveResult>;
|
|
42
|
-
private
|
|
43
|
-
private hasGapRepairSource;
|
|
42
|
+
private taskIdsForGaps;
|
|
44
43
|
}
|
|
45
44
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/semantic/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,q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C,eAAe,EAAE,kCAAkC,CAAC;KAC9D,CAAC;IAqCI,MAAM,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAsCnF,WAAW,CAAC,KAAK,GAAE,iCAAsC,GAAG,OAAO,CAAC,kCAAkC,CAAC;IAyB7G,OAAO,CAAC,cAAc;CAOvB"}
|
|
@@ -39,6 +39,7 @@ export class KnowledgeSemanticService {
|
|
|
39
39
|
const allowed = input.sourceIds?.length ? new Set(input.sourceIds) : null;
|
|
40
40
|
const sources = this.store.listSources(10_000)
|
|
41
41
|
.filter((source) => !allowed || allowed.has(source.id))
|
|
42
|
+
.filter((source) => !input.knowledgeSpaceId || getKnowledgeSpaceId(source) === input.knowledgeSpaceId)
|
|
42
43
|
.slice(0, Math.max(1, input.limit ?? 10_000));
|
|
43
44
|
const maxLlmSources = Math.max(0, this.options.maxLlmSourcesPerReindex ?? 3);
|
|
44
45
|
let llmAttempts = 0;
|
|
@@ -75,8 +76,39 @@ export class KnowledgeSemanticService {
|
|
|
75
76
|
}
|
|
76
77
|
async answer(input) {
|
|
77
78
|
await this.store.init();
|
|
78
|
-
|
|
79
|
-
this.
|
|
79
|
+
let answer = await answerKnowledgeQuery({ store: this.store, llm: this.options.llm }, input);
|
|
80
|
+
if (this.options.gapRepairer && answer.answer.gaps.length > 0) {
|
|
81
|
+
const refinement = await this.selfImprove({
|
|
82
|
+
knowledgeSpaceId: answer.spaceId,
|
|
83
|
+
gapIds: answer.answer.gaps.map((gap) => gap.id),
|
|
84
|
+
reason: 'answer',
|
|
85
|
+
limit: Math.max(1, answer.answer.gaps.length),
|
|
86
|
+
});
|
|
87
|
+
if (refinement.ingestedSourceIds.length > 0) {
|
|
88
|
+
const sources = refinement.ingestedSourceIds
|
|
89
|
+
.map((sourceId) => this.store.getSource(sourceId))
|
|
90
|
+
.filter((source) => Boolean(source));
|
|
91
|
+
await this.enrichSources(sources, {
|
|
92
|
+
knowledgeSpaceId: answer.spaceId,
|
|
93
|
+
force: true,
|
|
94
|
+
limit: sources.length,
|
|
95
|
+
});
|
|
96
|
+
answer = await answerKnowledgeQuery({ store: this.store, llm: this.options.llm }, input);
|
|
97
|
+
}
|
|
98
|
+
const taskIds = uniqueStrings([
|
|
99
|
+
...refinement.taskIds,
|
|
100
|
+
...this.taskIdsForGaps(answer.spaceId, answer.answer.gaps.map((gap) => gap.id)),
|
|
101
|
+
]);
|
|
102
|
+
if (taskIds.length > 0) {
|
|
103
|
+
return {
|
|
104
|
+
...answer,
|
|
105
|
+
answer: {
|
|
106
|
+
...answer.answer,
|
|
107
|
+
refinementTaskIds: taskIds,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
80
112
|
return answer;
|
|
81
113
|
}
|
|
82
114
|
async selfImprove(input = {}) {
|
|
@@ -103,58 +135,13 @@ export class KnowledgeSemanticService {
|
|
|
103
135
|
activeGapRepairs: this.activeGapRepairs,
|
|
104
136
|
}, input);
|
|
105
137
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (this.activeGapRepairs.has(repairKey))
|
|
114
|
-
return;
|
|
115
|
-
this.activeGapRepairs.add(repairKey);
|
|
116
|
-
const repairer = this.options.gapRepairer;
|
|
117
|
-
void repairer({
|
|
118
|
-
spaceId: answer.spaceId,
|
|
119
|
-
query: answer.query,
|
|
120
|
-
gaps,
|
|
121
|
-
sources: answer.answer.sources,
|
|
122
|
-
linkedObjects: answer.answer.linkedObjects,
|
|
123
|
-
facts: answer.answer.facts,
|
|
124
|
-
})
|
|
125
|
-
.then(async (result) => {
|
|
126
|
-
if (!result?.ingestedSourceIds.length)
|
|
127
|
-
return;
|
|
128
|
-
for (const sourceId of result.ingestedSourceIds) {
|
|
129
|
-
for (const gap of gaps) {
|
|
130
|
-
await this.store.upsertEdge({
|
|
131
|
-
fromKind: 'source',
|
|
132
|
-
fromId: sourceId,
|
|
133
|
-
toKind: 'node',
|
|
134
|
-
toId: gap.id,
|
|
135
|
-
relation: 'repairs_gap',
|
|
136
|
-
weight: 0.8,
|
|
137
|
-
metadata: {
|
|
138
|
-
semantic: true,
|
|
139
|
-
knowledgeSpaceId: answer.spaceId,
|
|
140
|
-
query: result.query ?? answer.query,
|
|
141
|
-
repairedAt: Date.now(),
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
})
|
|
147
|
-
.catch(() => { })
|
|
148
|
-
.finally(() => {
|
|
149
|
-
this.activeGapRepairs.delete(repairKey);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
hasGapRepairSource(spaceId, gapId) {
|
|
153
|
-
return this.store.listEdges().some((edge) => (edge.relation === 'repairs_gap'
|
|
154
|
-
&& edge.toKind === 'node'
|
|
155
|
-
&& edge.toId === gapId
|
|
156
|
-
&& edge.fromKind === 'source'
|
|
157
|
-
&& readString(edge.metadata.knowledgeSpaceId) === spaceId));
|
|
138
|
+
taskIdsForGaps(spaceId, gapIds) {
|
|
139
|
+
const wanted = new Set(gapIds);
|
|
140
|
+
if (wanted.size === 0)
|
|
141
|
+
return [];
|
|
142
|
+
return this.store.listRefinementTasks(100, { spaceId })
|
|
143
|
+
.filter((task) => task.gapId && wanted.has(task.gapId))
|
|
144
|
+
.map((task) => task.id);
|
|
158
145
|
}
|
|
159
146
|
}
|
|
160
147
|
function sourceCanUseLlmUpgrade(store, source) {
|
|
@@ -169,6 +156,8 @@ function sourceCanUseLlmUpgrade(store, source) {
|
|
|
169
156
|
function emptySelfImproveResult() {
|
|
170
157
|
return {
|
|
171
158
|
scannedGaps: 0,
|
|
159
|
+
candidateGaps: 0,
|
|
160
|
+
processedGaps: 0,
|
|
172
161
|
createdGaps: 0,
|
|
173
162
|
repairableGaps: 0,
|
|
174
163
|
suppressedGaps: 0,
|
|
@@ -176,12 +165,23 @@ function emptySelfImproveResult() {
|
|
|
176
165
|
searched: 0,
|
|
177
166
|
ingestedSources: 0,
|
|
178
167
|
linkedRepairs: 0,
|
|
168
|
+
blockedGaps: 0,
|
|
169
|
+
closedGaps: 0,
|
|
170
|
+
queuedTasks: 0,
|
|
171
|
+
requestedLimit: 0,
|
|
172
|
+
effectiveLimit: 0,
|
|
173
|
+
truncated: false,
|
|
174
|
+
budgetExhausted: false,
|
|
175
|
+
taskIds: [],
|
|
176
|
+
ingestedSourceIds: [],
|
|
179
177
|
errors: [],
|
|
180
178
|
};
|
|
181
179
|
}
|
|
182
180
|
function mergeSelfImproveResults(left, right) {
|
|
183
181
|
return {
|
|
184
182
|
scannedGaps: left.scannedGaps + right.scannedGaps,
|
|
183
|
+
candidateGaps: (left.candidateGaps ?? 0) + (right.candidateGaps ?? 0),
|
|
184
|
+
processedGaps: (left.processedGaps ?? 0) + (right.processedGaps ?? 0),
|
|
185
185
|
createdGaps: left.createdGaps + right.createdGaps,
|
|
186
186
|
repairableGaps: left.repairableGaps + right.repairableGaps,
|
|
187
187
|
suppressedGaps: left.suppressedGaps + right.suppressedGaps,
|
|
@@ -189,6 +189,15 @@ function mergeSelfImproveResults(left, right) {
|
|
|
189
189
|
searched: left.searched + right.searched,
|
|
190
190
|
ingestedSources: left.ingestedSources + right.ingestedSources,
|
|
191
191
|
linkedRepairs: left.linkedRepairs + right.linkedRepairs,
|
|
192
|
+
blockedGaps: left.blockedGaps + right.blockedGaps,
|
|
193
|
+
closedGaps: left.closedGaps + right.closedGaps,
|
|
194
|
+
queuedTasks: left.queuedTasks + right.queuedTasks,
|
|
195
|
+
requestedLimit: (left.requestedLimit ?? 0) + (right.requestedLimit ?? 0),
|
|
196
|
+
effectiveLimit: (left.effectiveLimit ?? 0) + (right.effectiveLimit ?? 0),
|
|
197
|
+
truncated: Boolean(left.truncated || right.truncated),
|
|
198
|
+
budgetExhausted: Boolean(left.budgetExhausted || right.budgetExhausted),
|
|
199
|
+
taskIds: uniqueStrings([...left.taskIds, ...right.taskIds]),
|
|
200
|
+
ingestedSourceIds: uniqueStrings([...left.ingestedSourceIds, ...right.ingestedSourceIds]),
|
|
192
201
|
errors: [...left.errors, ...right.errors],
|
|
193
202
|
};
|
|
194
203
|
}
|
|
@@ -93,6 +93,7 @@ export interface KnowledgeSemanticAnswer {
|
|
|
93
93
|
readonly linkedObjects: readonly KnowledgeNodeRecord[];
|
|
94
94
|
readonly facts: readonly KnowledgeNodeRecord[];
|
|
95
95
|
readonly gaps: readonly KnowledgeNodeRecord[];
|
|
96
|
+
readonly refinementTaskIds?: readonly string[];
|
|
96
97
|
readonly synthesized: boolean;
|
|
97
98
|
}
|
|
98
99
|
export interface KnowledgeSemanticAnswerResult {
|
|
@@ -124,8 +125,14 @@ export interface KnowledgeSemanticGapRepairResult {
|
|
|
124
125
|
readonly skippedUrls: readonly string[];
|
|
125
126
|
readonly sourceAssessments?: readonly {
|
|
126
127
|
readonly url: string;
|
|
128
|
+
readonly title?: string;
|
|
129
|
+
readonly domain?: string;
|
|
130
|
+
readonly rank?: number;
|
|
131
|
+
readonly accepted?: boolean;
|
|
127
132
|
readonly confidence: number;
|
|
128
133
|
readonly reasons: readonly string[];
|
|
134
|
+
readonly trustReason?: string;
|
|
135
|
+
readonly rejectionReason?: string;
|
|
129
136
|
}[];
|
|
130
137
|
readonly reason?: string;
|
|
131
138
|
}
|
|
@@ -135,11 +142,14 @@ export interface KnowledgeSemanticSelfImproveInput {
|
|
|
135
142
|
readonly sourceIds?: readonly string[];
|
|
136
143
|
readonly gapIds?: readonly string[];
|
|
137
144
|
readonly limit?: number;
|
|
145
|
+
readonly maxRunMs?: number;
|
|
138
146
|
readonly force?: boolean;
|
|
139
147
|
readonly reason?: 'ingest' | 'homegraph-sync' | 'reindex' | 'scheduled' | 'answer' | 'manual';
|
|
140
148
|
}
|
|
141
149
|
export interface KnowledgeSemanticSelfImproveResult {
|
|
142
150
|
readonly scannedGaps: number;
|
|
151
|
+
readonly candidateGaps?: number;
|
|
152
|
+
readonly processedGaps?: number;
|
|
143
153
|
readonly createdGaps: number;
|
|
144
154
|
readonly repairableGaps: number;
|
|
145
155
|
readonly suppressedGaps: number;
|
|
@@ -147,6 +157,15 @@ export interface KnowledgeSemanticSelfImproveResult {
|
|
|
147
157
|
readonly searched: number;
|
|
148
158
|
readonly ingestedSources: number;
|
|
149
159
|
readonly linkedRepairs: number;
|
|
160
|
+
readonly blockedGaps: number;
|
|
161
|
+
readonly closedGaps: number;
|
|
162
|
+
readonly queuedTasks: number;
|
|
163
|
+
readonly requestedLimit?: number;
|
|
164
|
+
readonly effectiveLimit?: number;
|
|
165
|
+
readonly truncated?: boolean;
|
|
166
|
+
readonly budgetExhausted?: boolean;
|
|
167
|
+
readonly taskIds: readonly string[];
|
|
168
|
+
readonly ingestedSourceIds: readonly string[];
|
|
150
169
|
readonly errors: readonly {
|
|
151
170
|
readonly gapId: string;
|
|
152
171
|
readonly error: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/semantic/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,yBAAyB,GACjC,SAAS,GACT,YAAY,GACZ,eAAe,GACf,UAAU,GACV,WAAW,GACX,SAAS,GACT,aAAa,GACb,eAAe,GACf,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,MAAM,CAAC;AAEX,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAA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a,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { KnowledgeBatchIngestResult, KnowledgeIssueRecord, KnowledgeJobMode, KnowledgeJobRecord, KnowledgeMaterializedProjection, KnowledgeStatus } from './types.js';
|
|
2
|
+
import type { BrowserKnowledgeProfile } from './browser-history/index.js';
|
|
3
|
+
import type { KnowledgeSemanticService } from './semantic/index.js';
|
|
4
|
+
export interface KnowledgeServiceJobRunnerContext {
|
|
5
|
+
readonly lint: () => Promise<readonly KnowledgeIssueRecord[]>;
|
|
6
|
+
readonly reindex: () => Promise<{
|
|
7
|
+
readonly status: KnowledgeStatus;
|
|
8
|
+
readonly issues: readonly KnowledgeIssueRecord[];
|
|
9
|
+
}>;
|
|
10
|
+
readonly refreshSources: (kind: 'stale' | 'bookmark', sourceIds?: readonly string[], limit?: number) => Promise<number>;
|
|
11
|
+
readonly syncBrowserHistory: (input: {
|
|
12
|
+
readonly limit?: number;
|
|
13
|
+
}) => Promise<KnowledgeBatchIngestResult & {
|
|
14
|
+
readonly profiles: readonly BrowserKnowledgeProfile[];
|
|
15
|
+
}>;
|
|
16
|
+
readonly materializeProjection: (input: {
|
|
17
|
+
readonly kind: 'overview' | 'bundle';
|
|
18
|
+
readonly limit: number;
|
|
19
|
+
}) => Promise<KnowledgeMaterializedProjection>;
|
|
20
|
+
readonly semanticService: KnowledgeSemanticService;
|
|
21
|
+
readonly runConsolidation: (kind: 'light-consolidation' | 'deep-consolidation', input: {
|
|
22
|
+
readonly limit?: number;
|
|
23
|
+
readonly autoPromote: boolean;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly metrics: Record<string, number>;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export declare function runKnowledgeServiceJobByKind(kind: KnowledgeJobRecord['kind'], input: {
|
|
30
|
+
readonly mode?: KnowledgeJobMode;
|
|
31
|
+
readonly sourceIds?: readonly string[];
|
|
32
|
+
readonly limit?: number;
|
|
33
|
+
}, context: KnowledgeServiceJobRunnerContext): Promise<Record<string, unknown>>;
|
|
34
|
+
//# sourceMappingURL=service-jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-jobs.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/knowledge/service-jobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAo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AAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;KAAE,KAC9D,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;CACjF;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAChC,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5G,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+DlC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export async function runKnowledgeServiceJobByKind(kind, input, context) {
|
|
2
|
+
switch (kind) {
|
|
3
|
+
case 'lint': {
|
|
4
|
+
const issues = await context.lint();
|
|
5
|
+
return { issueCount: issues.length };
|
|
6
|
+
}
|
|
7
|
+
case 'reindex': {
|
|
8
|
+
const result = await context.reindex();
|
|
9
|
+
return { sourceCount: result.status.sourceCount, issueCount: result.issues.length };
|
|
10
|
+
}
|
|
11
|
+
case 'refresh-stale':
|
|
12
|
+
return { refreshed: await context.refreshSources('stale', input.sourceIds, input.limit) };
|
|
13
|
+
case 'refresh-bookmarks':
|
|
14
|
+
return { refreshed: await context.refreshSources('bookmark', input.sourceIds, input.limit) };
|
|
15
|
+
case 'sync-browser-history': {
|
|
16
|
+
const result = await context.syncBrowserHistory({ limit: input.limit });
|
|
17
|
+
return {
|
|
18
|
+
imported: result.imported,
|
|
19
|
+
failed: result.failed,
|
|
20
|
+
profileCount: result.profiles.length,
|
|
21
|
+
errorCount: result.errors.length,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
case 'rebuild-projections': {
|
|
25
|
+
const overview = await context.materializeProjection({ kind: 'overview', limit: Math.max(8, input.limit ?? 12) });
|
|
26
|
+
const bundle = await context.materializeProjection({ kind: 'bundle', limit: Math.max(12, input.limit ?? 18) });
|
|
27
|
+
return {
|
|
28
|
+
projections: [
|
|
29
|
+
{ targetId: overview.bundle.target.targetId, artifactId: overview.artifact.id },
|
|
30
|
+
{ targetId: bundle.bundle.target.targetId, artifactId: bundle.artifact.id },
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
case 'semantic-enrichment':
|
|
35
|
+
return context.semanticService.reindex({
|
|
36
|
+
sourceIds: input.sourceIds,
|
|
37
|
+
limit: input.limit,
|
|
38
|
+
});
|
|
39
|
+
case 'semantic-self-improvement': {
|
|
40
|
+
const result = await context.semanticService.selfImprove({
|
|
41
|
+
sourceIds: input.sourceIds,
|
|
42
|
+
limit: input.limit,
|
|
43
|
+
reason: 'scheduled',
|
|
44
|
+
});
|
|
45
|
+
return { ...result };
|
|
46
|
+
}
|
|
47
|
+
case 'light-consolidation': {
|
|
48
|
+
const report = await context.runConsolidation('light-consolidation', {
|
|
49
|
+
limit: input.limit,
|
|
50
|
+
autoPromote: false,
|
|
51
|
+
});
|
|
52
|
+
return { reportId: report.id, metrics: report.metrics };
|
|
53
|
+
}
|
|
54
|
+
case 'deep-consolidation': {
|
|
55
|
+
const report = await context.runConsolidation('deep-consolidation', {
|
|
56
|
+
limit: input.limit,
|
|
57
|
+
autoPromote: true,
|
|
58
|
+
});
|
|
59
|
+
return { reportId: report.id, metrics: report.metrics };
|
|
60
|
+
}
|
|
61
|
+
default:
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
}
|