@pellux/goodvibes-sdk 0.28.16 → 0.28.17
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 +70 -1
- package/dist/_internal/contracts/generated/foundation-metadata.d.ts +1 -1
- package/dist/_internal/contracts/generated/foundation-metadata.js +1 -1
- package/dist/_internal/contracts/generated/operator-contract.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-contract.js +70 -1
- package/dist/_internal/platform/artifacts/store.d.ts +2 -0
- package/dist/_internal/platform/artifacts/store.d.ts.map +1 -1
- package/dist/_internal/platform/artifacts/store.js +20 -0
- package/dist/_internal/platform/control-plane/method-catalog-homegraph.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-homegraph.js +9 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.js +15 -1
- package/dist/_internal/platform/knowledge/home-graph/ask-page-refresh.d.ts +11 -0
- package/dist/_internal/platform/knowledge/home-graph/ask-page-refresh.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/ask-page-refresh.js +31 -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 +89 -20
- package/dist/_internal/platform/knowledge/home-graph/map-view.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/map-view.js +11 -0
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts +0 -1
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/rendering.js +0 -12
- package/dist/_internal/platform/knowledge/home-graph/reset.d.ts +2 -1
- package/dist/_internal/platform/knowledge/home-graph/reset.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/reset.js +35 -2
- package/dist/_internal/platform/knowledge/home-graph/search.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/search.js +2 -18
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts +1 -1
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/service.js +15 -5
- package/dist/_internal/platform/knowledge/home-graph/source-links.d.ts +3 -0
- package/dist/_internal/platform/knowledge/home-graph/source-links.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/source-links.js +30 -0
- package/dist/_internal/platform/knowledge/home-graph/state.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/state.js +43 -1
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts +14 -1
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/ingest-compile.js +1 -1
- package/dist/_internal/platform/knowledge/pdf-extractor.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/pdf-extractor.js +8 -3
- package/dist/_internal/platform/knowledge/semantic/answer-fallback.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/answer-fallback.js +11 -16
- package/dist/_internal/platform/knowledge/semantic/answer-source-ranking.d.ts +7 -0
- package/dist/_internal/platform/knowledge/semantic/answer-source-ranking.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/semantic/answer-source-ranking.js +55 -0
- package/dist/_internal/platform/knowledge/semantic/answer.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/answer.js +62 -7
- package/dist/_internal/platform/knowledge/semantic/fact-quality.d.ts +0 -1
- package/dist/_internal/platform/knowledge/semantic/fact-quality.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/fact-quality.js +6 -18
- package/dist/_internal/platform/knowledge/semantic/homeassistant-scope.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/homeassistant-scope.js +63 -5
- package/dist/_internal/platform/knowledge/semantic/repair-profile.d.ts +16 -0
- package/dist/_internal/platform/knowledge/semantic/repair-profile.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/semantic/repair-profile.js +152 -0
- package/dist/_internal/platform/knowledge/semantic/self-improvement-promotion.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/self-improvement-promotion.js +87 -52
- package/dist/_internal/platform/knowledge/semantic/self-improvement.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/self-improvement.js +4 -3
- package/dist/_internal/platform/knowledge/semantic/service.js +1 -1
- package/dist/_internal/platform/version.js +1 -1
- package/package.json +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { yieldEvery, yieldToEventLoop } from '../cooperative.js';
|
|
2
2
|
import { getKnowledgeSpaceId } from '../spaces.js';
|
|
3
3
|
import { hasConcreteFeatureSignal, isLowValueFeatureOrSpecText } from './fact-quality.js';
|
|
4
|
+
import { deriveRepairProfileFacts } from './repair-profile.js';
|
|
4
5
|
import { updateRefinementTask } from './self-improvement-tasks.js';
|
|
5
6
|
import { withTimeout } from './timeouts.js';
|
|
6
7
|
import { clampText, normalizeWhitespace, readRecord, readString, semanticHash, semanticMetadata, semanticSlug, sourceSemanticText, splitSentences, uniqueStrings, } from './utils.js';
|
|
@@ -37,70 +38,104 @@ async function promoteRepairEvidenceFacts(store, spaceId, gap, sourceIds) {
|
|
|
37
38
|
continue;
|
|
38
39
|
const extraction = store.getExtractionBySourceId(source.id);
|
|
39
40
|
const authority = sourceAuthority(source);
|
|
41
|
+
const text = sourceSemanticText(source, extraction);
|
|
42
|
+
const profileFacts = deriveRepairProfileFacts({
|
|
43
|
+
query: gap.title,
|
|
44
|
+
source,
|
|
45
|
+
text,
|
|
46
|
+
});
|
|
47
|
+
for (const profileFact of profileFacts) {
|
|
48
|
+
promoted += await upsertPromotedRepairFact({
|
|
49
|
+
store,
|
|
50
|
+
spaceId,
|
|
51
|
+
gap,
|
|
52
|
+
source,
|
|
53
|
+
subjects,
|
|
54
|
+
authority,
|
|
55
|
+
title: profileFact.title,
|
|
56
|
+
summary: profileFact.summary,
|
|
57
|
+
classification: profileFact,
|
|
58
|
+
evidence: profileFact.evidence,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
40
61
|
const sentences = selectRepairFactSentences({
|
|
41
62
|
query: gap.title,
|
|
42
63
|
source,
|
|
43
|
-
text
|
|
64
|
+
text,
|
|
44
65
|
});
|
|
45
|
-
for (const
|
|
66
|
+
for (const sentence of sentences) {
|
|
46
67
|
const classification = classifyRepairFact(sentence);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
promoted += await upsertPromotedRepairFact({
|
|
69
|
+
store,
|
|
70
|
+
spaceId,
|
|
71
|
+
gap,
|
|
72
|
+
source,
|
|
73
|
+
subjects,
|
|
74
|
+
authority,
|
|
51
75
|
title: classification.title,
|
|
52
76
|
summary: sentence,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
confidence: authority === 'official-vendor' ? 88 : 76,
|
|
56
|
-
sourceId: source.id,
|
|
57
|
-
metadata: semanticMetadata(spaceId, {
|
|
58
|
-
semanticKind: 'fact',
|
|
59
|
-
factKind: classification.kind,
|
|
60
|
-
value: classification.value,
|
|
61
|
-
evidence: sentence,
|
|
62
|
-
labels: classification.labels,
|
|
63
|
-
sourceId: source.id,
|
|
64
|
-
gapId: gap.id,
|
|
65
|
-
linkedObjectIds: subjects.map((subject) => subject.id),
|
|
66
|
-
extractor: 'repair-promotion',
|
|
67
|
-
sourceAuthority: authority,
|
|
68
|
-
sourceDiscovery: readRecord(source.metadata.sourceDiscovery),
|
|
69
|
-
}),
|
|
70
|
-
});
|
|
71
|
-
await store.upsertEdge({
|
|
72
|
-
fromKind: 'source',
|
|
73
|
-
fromId: source.id,
|
|
74
|
-
toKind: 'node',
|
|
75
|
-
toId: fact.id,
|
|
76
|
-
relation: 'supports_fact',
|
|
77
|
-
weight: authority === 'official-vendor' ? 0.95 : 0.84,
|
|
78
|
-
metadata: semanticMetadata(spaceId, {
|
|
79
|
-
linkedBy: 'semantic-gap-repair',
|
|
80
|
-
gapId: gap.id,
|
|
81
|
-
}),
|
|
77
|
+
classification,
|
|
78
|
+
evidence: sentence,
|
|
82
79
|
});
|
|
83
|
-
for (const subject of subjects) {
|
|
84
|
-
await store.upsertEdge({
|
|
85
|
-
fromKind: 'node',
|
|
86
|
-
fromId: fact.id,
|
|
87
|
-
toKind: 'node',
|
|
88
|
-
toId: subject.id,
|
|
89
|
-
relation: 'describes',
|
|
90
|
-
weight: authority === 'official-vendor' ? 0.94 : 0.82,
|
|
91
|
-
metadata: semanticMetadata(spaceId, {
|
|
92
|
-
linkedBy: 'semantic-gap-repair',
|
|
93
|
-
repairedAt: Date.now(),
|
|
94
|
-
sourceId: source.id,
|
|
95
|
-
gapId: gap.id,
|
|
96
|
-
}),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
promoted += 1;
|
|
100
80
|
}
|
|
101
81
|
}
|
|
102
82
|
return promoted;
|
|
103
83
|
}
|
|
84
|
+
async function upsertPromotedRepairFact(input) {
|
|
85
|
+
const fact = await input.store.upsertNode({
|
|
86
|
+
id: `sem-fact-${semanticHash(input.spaceId, input.source.id, input.gap.id, input.title, input.summary)}`,
|
|
87
|
+
kind: 'fact',
|
|
88
|
+
slug: semanticSlug(`${input.spaceId}-${input.title}-${input.source.id}`),
|
|
89
|
+
title: input.title,
|
|
90
|
+
summary: input.summary,
|
|
91
|
+
aliases: input.classification.aliases,
|
|
92
|
+
status: 'active',
|
|
93
|
+
confidence: input.authority === 'official-vendor' ? 90 : input.authority === 'vendor' ? 82 : 76,
|
|
94
|
+
sourceId: input.source.id,
|
|
95
|
+
metadata: semanticMetadata(input.spaceId, {
|
|
96
|
+
semanticKind: 'fact',
|
|
97
|
+
factKind: input.classification.kind,
|
|
98
|
+
value: input.classification.value,
|
|
99
|
+
evidence: input.evidence,
|
|
100
|
+
labels: input.classification.labels,
|
|
101
|
+
sourceId: input.source.id,
|
|
102
|
+
gapId: input.gap.id,
|
|
103
|
+
linkedObjectIds: input.subjects.map((subject) => subject.id),
|
|
104
|
+
extractor: 'repair-promotion',
|
|
105
|
+
sourceAuthority: input.authority,
|
|
106
|
+
sourceDiscovery: readRecord(input.source.metadata.sourceDiscovery),
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
await input.store.upsertEdge({
|
|
110
|
+
fromKind: 'source',
|
|
111
|
+
fromId: input.source.id,
|
|
112
|
+
toKind: 'node',
|
|
113
|
+
toId: fact.id,
|
|
114
|
+
relation: 'supports_fact',
|
|
115
|
+
weight: input.authority === 'official-vendor' ? 0.96 : 0.84,
|
|
116
|
+
metadata: semanticMetadata(input.spaceId, {
|
|
117
|
+
linkedBy: 'semantic-gap-repair',
|
|
118
|
+
gapId: input.gap.id,
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
for (const subject of input.subjects) {
|
|
122
|
+
await input.store.upsertEdge({
|
|
123
|
+
fromKind: 'node',
|
|
124
|
+
fromId: fact.id,
|
|
125
|
+
toKind: 'node',
|
|
126
|
+
toId: subject.id,
|
|
127
|
+
relation: 'describes',
|
|
128
|
+
weight: input.authority === 'official-vendor' ? 0.95 : 0.82,
|
|
129
|
+
metadata: semanticMetadata(input.spaceId, {
|
|
130
|
+
linkedBy: 'semantic-gap-repair',
|
|
131
|
+
repairedAt: Date.now(),
|
|
132
|
+
sourceId: input.source.id,
|
|
133
|
+
gapId: input.gap.id,
|
|
134
|
+
}),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
104
139
|
async function linkPromotedFactsToRepairSubjects(store, spaceId, gap, sourceIds) {
|
|
105
140
|
const linkedObjectIds = readStringArray(gap.metadata.linkedObjectIds).filter((nodeId) => Boolean(store.getNode(nodeId)));
|
|
106
141
|
if (linkedObjectIds.length === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"self-improvement.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/semantic/self-improvement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD,OAAO,KAAK,EACV,4BAA4B,EAC5B,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,YAAY,CAAC;AAapB,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3I;AAUD,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,kBAAkB,EAC3B,KAAK,GAAE,iCAAsC,GAC5C,OAAO,CAAC,kCAAkC,CAAC,
|
|
1
|
+
{"version":3,"file":"self-improvement.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/semantic/self-improvement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD,OAAO,KAAK,EACV,4BAA4B,EAC5B,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,YAAY,CAAC;AAapB,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3I;AAUD,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,kBAAkB,EAC3B,KAAK,GAAE,iCAAsC,GAC5C,OAAO,CAAC,kCAAkC,CAAC,CA+N7C"}
|
|
@@ -23,11 +23,12 @@ export async function runKnowledgeSemanticSelfImprovement(context, input = {}) {
|
|
|
23
23
|
const createdGaps = await discoverIntrinsicGaps(context.store, spaceId, sourceIdFilter);
|
|
24
24
|
const candidates = collectCandidateGaps(context.store, spaceId, sourceIdFilter, gapIdFilter);
|
|
25
25
|
const requestedLimit = Math.max(1, input.limit ?? DEFAULT_REFINEMENT_LIMIT);
|
|
26
|
-
const
|
|
26
|
+
const cappedLimit = Math.min(requestedLimit, MAX_REFINEMENT_LIMIT);
|
|
27
27
|
const maxRunMs = Math.min(MAX_REFINEMENT_RUN_MS, Math.max(5_000, input.maxRunMs ?? DEFAULT_REFINEMENT_RUN_MS));
|
|
28
28
|
const startedAt = Date.now();
|
|
29
|
-
const gaps = candidates.slice(0,
|
|
30
|
-
|
|
29
|
+
const gaps = candidates.slice(0, cappedLimit);
|
|
30
|
+
const effectiveLimit = gaps.length;
|
|
31
|
+
let truncated = candidates.length > gaps.length || requestedLimit > cappedLimit;
|
|
31
32
|
let budgetExhausted = false;
|
|
32
33
|
let processedGaps = 0;
|
|
33
34
|
let repairableGaps = 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
let version = '0.28.
|
|
3
|
+
let version = '0.28.17';
|
|
4
4
|
try {
|
|
5
5
|
const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', '..', 'package.json'), 'utf-8'));
|
|
6
6
|
version = pkg.version ?? version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pellux/goodvibes-sdk",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.17",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/mgd34msu/goodvibes-sdk.git"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@ast-grep/napi": "^0.42.0",
|
|
14
14
|
"@aws/bedrock-token-generator": "^1.1.0",
|
|
15
15
|
"@mozilla/readability": "^0.6.0",
|
|
16
|
+
"@smithy/util-retry": "4.3.6",
|
|
16
17
|
"bash-language-server": "file:vendor/bash-language-server",
|
|
17
18
|
"bplist-parser": "^0.3.2",
|
|
18
19
|
"cloudflare": "5.2.0",
|