@pellux/goodvibes-sdk 0.26.9 → 0.26.11
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 +1563 -118
- 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 +1563 -118
- 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 +3 -0
- package/dist/_internal/daemon/context.d.ts +1 -0
- package/dist/_internal/daemon/context.d.ts.map +1 -1
- package/dist/_internal/daemon/knowledge-route-types.d.ts +2 -1
- 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 +19 -3
- 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 +2 -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 +22 -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 +16 -1
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.d.ts +3 -0
- 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 +57 -2
- 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 +2 -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 +24 -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 +1 -0
- package/dist/_internal/platform/knowledge/extractors.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/extractors.js +73 -1
- package/dist/_internal/platform/knowledge/generated-projections.d.ts +38 -0
- package/dist/_internal/platform/knowledge/generated-projections.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/generated-projections.js +106 -0
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.d.ts +29 -0
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.js +296 -0
- package/dist/_internal/platform/knowledge/home-graph/helpers.d.ts +2 -1
- package/dist/_internal/platform/knowledge/home-graph/helpers.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/helpers.js +4 -0
- package/dist/_internal/platform/knowledge/home-graph/index.d.ts +1 -1
- package/dist/_internal/platform/knowledge/home-graph/index.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/reindex.d.ts +12 -0
- package/dist/_internal/platform/knowledge/home-graph/reindex.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/reindex.js +35 -0
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts +5 -0
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/rendering.js +32 -11
- package/dist/_internal/platform/knowledge/home-graph/search.d.ts +2 -0
- package/dist/_internal/platform/knowledge/home-graph/search.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/search.js +135 -7
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts +4 -2
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/service.js +79 -91
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts +46 -2
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/types.js +2 -0
- package/dist/_internal/platform/knowledge/index.d.ts +6 -2
- package/dist/_internal/platform/knowledge/index.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/index.js +2 -0
- package/dist/_internal/platform/knowledge/ingest-compile.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/ingest-compile.js +26 -1
- package/dist/_internal/platform/knowledge/knowledge-api.d.ts +2 -0
- package/dist/_internal/platform/knowledge/knowledge-api.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/knowledge-api.js +1 -0
- package/dist/_internal/platform/knowledge/map.d.ts +18 -0
- package/dist/_internal/platform/knowledge/map.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/map.js +235 -0
- package/dist/_internal/platform/knowledge/projection-utils.d.ts +16 -0
- package/dist/_internal/platform/knowledge/projection-utils.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/projection-utils.js +48 -0
- package/dist/_internal/platform/knowledge/projections.d.ts +1 -0
- package/dist/_internal/platform/knowledge/projections.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/projections.js +52 -58
- package/dist/_internal/platform/knowledge/service.d.ts +7 -1
- package/dist/_internal/platform/knowledge/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/service.js +11 -0
- package/dist/_internal/platform/knowledge/types.d.ts +35 -0
- package/dist/_internal/platform/knowledge/types.d.ts.map +1 -1
- package/dist/_internal/platform/version.js +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EAEjB,sBAAsB,EACtB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B,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAQA;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAChE,yBAAyB,CAa3B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,MAAM,CAE7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,MAAM,EAAE,CAUnF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,mBAAmB,GAAG,iBAAiB,EAC7C,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpD,oBAAoB,CAyDtB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { isGeneratedKnowledgeSource, } from '../generated-projections.js';
|
|
2
3
|
import { getKnowledgeSpaceId, homeAssistantKnowledgeSpaceId, knowledgeSpaceMetadata, normalizeHomeAssistantInstallationId, normalizeKnowledgeSpaceId, normalizeSpaceComponent, } from '../spaces.js';
|
|
3
4
|
export const HOME_GRAPH_CONNECTOR_ID = 'homeassistant';
|
|
4
5
|
const NODE_KIND_BY_OBJECT = {
|
|
@@ -119,6 +120,9 @@ function homeGraphObjectId(kind, object) {
|
|
|
119
120
|
export function edgeIsActive(edge) {
|
|
120
121
|
return edge.metadata.linkStatus !== 'unlinked';
|
|
121
122
|
}
|
|
123
|
+
export function isGeneratedPageSource(source) {
|
|
124
|
+
return isGeneratedKnowledgeSource(source);
|
|
125
|
+
}
|
|
122
126
|
export function belongsToSpace(record, spaceId) {
|
|
123
127
|
return record ? getKnowledgeSpaceId(record) === normalizeKnowledgeSpaceId(spaceId) : false;
|
|
124
128
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { HomeGraphService } from './service.js';
|
|
2
2
|
export { HOME_GRAPH_NODE_KINDS, HOME_GRAPH_RELATIONS, } from './types.js';
|
|
3
|
-
export type { HomeGraphAskInput, HomeGraphAskResult, HomeGraphDevicePassportResult, HomeGraphExport, HomeGraphIngestArtifactInput, HomeGraphIngestNoteInput, HomeGraphIngestResult, HomeGraphIngestUrlInput, HomeGraphKnowledgeTarget, HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphNodeKind, HomeGraphObjectInput, HomeGraphObjectKind, HomeGraphProjectionInput, HomeGraphProjectionResult, HomeGraphRelation, HomeGraphReviewInput, HomeGraphSnapshotInput, HomeGraphStatus, HomeGraphSyncResult, } from './types.js';
|
|
3
|
+
export type { HomeGraphAskInput, HomeGraphAskResult, HomeGraphDevicePassportResult, HomeGraphExport, HomeGraphGeneratedPagesSummary, HomeGraphIngestArtifactInput, HomeGraphIngestNoteInput, HomeGraphIngestResult, HomeGraphIngestUrlInput, HomeGraphKnowledgeTarget, HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphMapEdge, HomeGraphMapInput, HomeGraphMapNode, HomeGraphMapResult, HomeGraphNodeKind, HomeGraphObjectInput, HomeGraphObjectKind, HomeGraphPageAutomationOptions, HomeGraphProjectionInput, HomeGraphProjectionResult, HomeGraphReindexResult, HomeGraphRelation, HomeGraphReviewInput, HomeGraphSnapshotInput, HomeGraphStatus, HomeGraphSyncResult, } from './types.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,EAC7B,eAAe,EACf,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,EAC7B,eAAe,EACf,8BAA8B,EAC9B,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ArtifactStore } from '../../artifacts/index.js';
|
|
2
|
+
import type { ArtifactDescriptor } from '../../artifacts/types.js';
|
|
3
|
+
import type { KnowledgeExtractionRecord, KnowledgeSourceRecord } from '../types.js';
|
|
4
|
+
import type { HomeGraphReindexResult } from './types.js';
|
|
5
|
+
export declare function reindexHomeGraphSources(input: {
|
|
6
|
+
readonly spaceId: string;
|
|
7
|
+
readonly sources: readonly KnowledgeSourceRecord[];
|
|
8
|
+
readonly extractionBySourceId: ReadonlyMap<string, KnowledgeExtractionRecord>;
|
|
9
|
+
readonly artifactStore: ArtifactStore;
|
|
10
|
+
readonly extract: (source: KnowledgeSourceRecord, artifact: ArtifactDescriptor) => Promise<KnowledgeExtractionRecord | undefined>;
|
|
11
|
+
}): Promise<HomeGraphReindexResult>;
|
|
12
|
+
//# sourceMappingURL=reindex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reindex.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/reindex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACnD,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAC9E,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAAC;CACnI,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAgClC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { homeGraphExtractionNeedsRepair } from './search.js';
|
|
2
|
+
export async function reindexHomeGraphSources(input) {
|
|
3
|
+
const sources = [];
|
|
4
|
+
const failures = [];
|
|
5
|
+
let scanned = 0;
|
|
6
|
+
let reparsed = 0;
|
|
7
|
+
let skipped = 0;
|
|
8
|
+
let failed = 0;
|
|
9
|
+
for (const source of input.sources) {
|
|
10
|
+
const artifactId = typeof source.artifactId === 'string' ? source.artifactId : undefined;
|
|
11
|
+
if (!artifactId)
|
|
12
|
+
continue;
|
|
13
|
+
scanned += 1;
|
|
14
|
+
const current = input.extractionBySourceId.get(source.id);
|
|
15
|
+
if (!homeGraphExtractionNeedsRepair(current)) {
|
|
16
|
+
skipped += 1;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const artifact = input.artifactStore.get(artifactId);
|
|
20
|
+
if (!artifact) {
|
|
21
|
+
failed += 1;
|
|
22
|
+
failures.push({ sourceId: source.id, error: `Unknown artifact: ${artifactId}` });
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const extraction = await input.extract(source, artifact);
|
|
26
|
+
if (!extraction) {
|
|
27
|
+
failed += 1;
|
|
28
|
+
failures.push({ sourceId: source.id, error: 'Artifact extraction failed.' });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
reparsed += 1;
|
|
32
|
+
sources.push(source);
|
|
33
|
+
}
|
|
34
|
+
return { ok: true, spaceId: input.spaceId, scanned, reparsed, skipped, failed, sources, failures };
|
|
35
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { KnowledgeEdgeRecord, KnowledgeIssueRecord, KnowledgeNodeRecord, KnowledgeSourceRecord } from '../types.js';
|
|
2
|
+
import type { HomeGraphMapResult } from './types.js';
|
|
2
3
|
export interface HomeGraphRenderState {
|
|
3
4
|
readonly spaceId: string;
|
|
4
5
|
readonly title: string;
|
|
@@ -22,4 +23,8 @@ export declare function renderPacketPage(state: HomeGraphRenderState, options?:
|
|
|
22
23
|
readonly includeFields?: readonly string[];
|
|
23
24
|
readonly excludeFields?: readonly string[];
|
|
24
25
|
}): string;
|
|
26
|
+
export declare function renderHomeGraphMap(state: HomeGraphRenderState, options?: {
|
|
27
|
+
readonly limit?: number;
|
|
28
|
+
readonly includeSources?: boolean;
|
|
29
|
+
}): HomeGraphMapResult;
|
|
25
30
|
//# sourceMappingURL=rendering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAClD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"rendering.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/rendering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EA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B,EAAE,OAAO,GAAE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC9B,GAAG,kBAAkB,CAM1B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderKnowledgeMap } from '../map.js';
|
|
2
|
+
import { edgeIsActive, isGeneratedPageSource } from './helpers.js';
|
|
2
3
|
export function renderRoomPage(state, areaId) {
|
|
3
4
|
const area = areaId
|
|
4
5
|
? findNodeByHaId(state.nodes, 'ha_area', areaId) ?? findNodeByHaId(state.nodes, 'ha_room', areaId)
|
|
@@ -9,10 +10,18 @@ export function renderRoomPage(state, areaId) {
|
|
|
9
10
|
&& (!areaNodeId || hasActiveEdge(state.edges, node.id, 'located_in', areaNodeId))));
|
|
10
11
|
const devices = state.nodes.filter((node) => (node.kind === 'ha_device'
|
|
11
12
|
&& (!areaNodeId || hasActiveEdge(state.edges, node.id, 'located_in', areaNodeId))));
|
|
12
|
-
const automations = state.nodes
|
|
13
|
-
const scenes = state.nodes
|
|
14
|
-
const scripts = state.nodes
|
|
15
|
-
const
|
|
13
|
+
const automations = filterNodesForArea(state.nodes, state.edges, 'ha_automation', areaNodeId);
|
|
14
|
+
const scenes = filterNodesForArea(state.nodes, state.edges, 'ha_scene', areaNodeId);
|
|
15
|
+
const scripts = filterNodesForArea(state.nodes, state.edges, 'ha_script', areaNodeId);
|
|
16
|
+
const relatedNodeIds = new Set([
|
|
17
|
+
...(areaNodeId ? [areaNodeId] : []),
|
|
18
|
+
...devices.map((node) => node.id),
|
|
19
|
+
...entities.map((node) => node.id),
|
|
20
|
+
...automations.map((node) => node.id),
|
|
21
|
+
...scenes.map((node) => node.id),
|
|
22
|
+
...scripts.map((node) => node.id),
|
|
23
|
+
]);
|
|
24
|
+
const sources = relatedSources(state.sources, state.edges, relatedNodeIds);
|
|
16
25
|
return [
|
|
17
26
|
`# ${title}`,
|
|
18
27
|
'',
|
|
@@ -63,10 +72,17 @@ export function renderPacketPage(state, options = {}) {
|
|
|
63
72
|
excluded.has('maintenance') ? '' : renderNodeList('Maintenance', state.nodes.filter((node) => node.kind === 'ha_maintenance_item')),
|
|
64
73
|
excluded.has('troubleshooting') ? '' : renderNodeList('Troubleshooting', state.nodes.filter((node) => node.kind === 'ha_troubleshooting_case')),
|
|
65
74
|
excluded.has('network') ? '' : renderNodeList('Network', state.nodes.filter((node) => node.kind === 'ha_network_node')),
|
|
66
|
-
excluded.has('sources') ? '' : renderSourceList('Sources', state.sources),
|
|
75
|
+
excluded.has('sources') ? '' : renderSourceList('Sources', state.sources.filter((source) => !isGeneratedPageSource(source))),
|
|
67
76
|
excluded.has('issues') ? '' : renderIssueList('Open Issues', state.issues.filter((issue) => issue.status === 'open')),
|
|
68
77
|
].filter(Boolean).join('\n');
|
|
69
78
|
}
|
|
79
|
+
export function renderHomeGraphMap(state, options = {}) {
|
|
80
|
+
return renderKnowledgeMap(state, {
|
|
81
|
+
...options,
|
|
82
|
+
title: state.title,
|
|
83
|
+
spaceId: state.spaceId,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
70
86
|
function renderNodeList(title, nodes) {
|
|
71
87
|
if (nodes.length === 0)
|
|
72
88
|
return '';
|
|
@@ -103,14 +119,19 @@ function renderIssueList(title, issues) {
|
|
|
103
119
|
function renderMetadataField(label, value) {
|
|
104
120
|
return typeof value === 'string' && value.trim().length > 0 ? `- ${label}: ${value.trim()}` : '';
|
|
105
121
|
}
|
|
106
|
-
function relatedSources(sources, edges,
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
function relatedSources(sources, edges, nodeIds) {
|
|
123
|
+
const visibleSources = sources.filter((source) => !isGeneratedPageSource(source));
|
|
124
|
+
if (nodeIds.size === 0)
|
|
125
|
+
return visibleSources;
|
|
109
126
|
const sourceIds = new Set(edges.filter((edge) => (edgeIsActive(edge)
|
|
110
127
|
&& edge.fromKind === 'source'
|
|
111
128
|
&& edge.toKind === 'node'
|
|
112
|
-
&& edge.toId
|
|
113
|
-
return
|
|
129
|
+
&& nodeIds.has(edge.toId))).map((edge) => edge.fromId));
|
|
130
|
+
return visibleSources.filter((source) => sourceIds.has(source.id));
|
|
131
|
+
}
|
|
132
|
+
function filterNodesForArea(nodes, edges, kind, areaNodeId) {
|
|
133
|
+
return nodes.filter((node) => (node.kind === kind
|
|
134
|
+
&& (!areaNodeId || hasActiveEdge(edges, node.id, 'located_in', areaNodeId))));
|
|
114
135
|
}
|
|
115
136
|
function hasActiveEdge(edges, fromId, relation, toId) {
|
|
116
137
|
return edges.some((edge) => (edgeIsActive(edge)
|
|
@@ -10,4 +10,6 @@ export interface HomeGraphSearchState {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function readHomeGraphSearchState(store: KnowledgeStore, spaceId: string): HomeGraphSearchState;
|
|
12
12
|
export declare function scoreHomeGraphResults(query: string, sources: readonly KnowledgeSourceRecord[], nodes: readonly KnowledgeNodeRecord[], edges: readonly KnowledgeEdgeRecord[], extractionBySourceId: (sourceId: string) => KnowledgeExtractionRecord | null | undefined, limit: number): HomeGraphSearchResult[];
|
|
13
|
+
export declare function selectHomeGraphExtractionRepairCandidates(query: string, sources: readonly KnowledgeSourceRecord[], nodes: readonly KnowledgeNodeRecord[], edges: readonly KnowledgeEdgeRecord[], extractionBySourceId: (sourceId: string) => KnowledgeExtractionRecord | null | undefined, limit: number): KnowledgeSourceRecord[];
|
|
14
|
+
export declare function homeGraphExtractionNeedsRepair(extraction: KnowledgeExtractionRecord | null | undefined): boolean;
|
|
13
15
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAgFxD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;CAC/E;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAuBrG;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,yBAAyB,GAAG,IAAI,GAAG,SAAS,EACxF,KAAK,EAAE,MAAM,GACZ,qBAAqB,EAAE,CAwEzB;AAED,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,yBAAyB,GAAG,IAAI,GAAG,SAAS,EACxF,KAAK,EAAE,MAAM,GACZ,qBAAqB,EAAE,CA6BzB;AA0ID,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,yBAAyB,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAWhH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { belongsToSpace, edgeIsActive, readRecord } from './helpers.js';
|
|
1
|
+
import { belongsToSpace, edgeIsActive, isGeneratedPageSource, readRecord } from './helpers.js';
|
|
2
2
|
const MAX_FIELD_CHARS = 4_096;
|
|
3
3
|
const MAX_SECTION_COUNT = 32;
|
|
4
4
|
const MAX_SEARCH_TEXT_CHARS = 64 * 1024;
|
|
@@ -54,8 +54,25 @@ const QUERY_EXPANSIONS = {
|
|
|
54
54
|
television: ['tv', 'media_player'],
|
|
55
55
|
tv: ['television', 'media_player'],
|
|
56
56
|
};
|
|
57
|
+
const SOURCE_EVIDENCE_TOKENS = new Set([
|
|
58
|
+
'battery',
|
|
59
|
+
'capabilities',
|
|
60
|
+
'capability',
|
|
61
|
+
'feature',
|
|
62
|
+
'features',
|
|
63
|
+
'manual',
|
|
64
|
+
'model',
|
|
65
|
+
'reset',
|
|
66
|
+
'serial',
|
|
67
|
+
'spec',
|
|
68
|
+
'specs',
|
|
69
|
+
'support',
|
|
70
|
+
'supports',
|
|
71
|
+
'warranty',
|
|
72
|
+
]);
|
|
73
|
+
const INTEGRATION_QUERY_TOKENS = new Set(['automation', 'automations', 'homeassistant', 'integration', 'integrations', 'webostv']);
|
|
57
74
|
export function readHomeGraphSearchState(store, spaceId) {
|
|
58
|
-
const sources = store.listSources(10_000).filter((source) => belongsToSpace(source, spaceId));
|
|
75
|
+
const sources = store.listSources(10_000).filter((source) => (belongsToSpace(source, spaceId) && !isGeneratedPageSource(source)));
|
|
59
76
|
const nodes = store.listNodes(10_000).filter((node) => belongsToSpace(node, spaceId));
|
|
60
77
|
const sourceIds = new Set(sources.map((source) => source.id));
|
|
61
78
|
const nodeIds = new Set(nodes.map((node) => node.id));
|
|
@@ -84,11 +101,16 @@ export function scoreHomeGraphResults(query, sources, nodes, edges, extractionBy
|
|
|
84
101
|
const anchorIds = new Set(anchors.map((anchor) => anchor.node.id));
|
|
85
102
|
const sourceLinks = buildSourceLinkIndex(edges);
|
|
86
103
|
const useAnchorScope = anchors.length > 0 && anchors.length <= ANCHOR_SCOPE_LIMIT;
|
|
104
|
+
const sourceEvidenceQuery = queryNeedsSourceEvidence(expandedTokens);
|
|
105
|
+
const integrationQuery = queryMentionsIntegration(tokens);
|
|
87
106
|
const sourceResults = sources.map((source) => {
|
|
88
107
|
const extraction = extractionBySourceId(source.id);
|
|
89
108
|
if (isPendingDocumentationCandidate(source, extraction)) {
|
|
90
109
|
return sourceResult(source, extraction, 0);
|
|
91
110
|
}
|
|
111
|
+
if (sourceEvidenceQuery && !integrationQuery && isHomeAssistantIntegrationSource(source)) {
|
|
112
|
+
return sourceResult(source, extraction, 0);
|
|
113
|
+
}
|
|
92
114
|
const linkedNodeIds = sourceLinks.get(source.id) ?? new Set();
|
|
93
115
|
const linkedToAnchor = useAnchorScope && intersects(linkedNodeIds, anchorIds);
|
|
94
116
|
const identityScore = scoreFields(tokens, [
|
|
@@ -108,10 +130,11 @@ export function scoreHomeGraphResults(query, sources, nodes, edges, extractionBy
|
|
|
108
130
|
]);
|
|
109
131
|
const baseScore = identityScore + contentScore;
|
|
110
132
|
const linkBoost = linkedToAnchor ? 120 + relationBoost(source.id, anchorIds, edges) : 0;
|
|
133
|
+
const manualBoost = isManualLikeSource(source) ? 24 : 0;
|
|
111
134
|
const indexedBoost = source.status === 'indexed' ? 18 : source.status === 'stale' ? 6 : 0;
|
|
112
135
|
const extractionBoost = extraction ? 20 : 0;
|
|
113
136
|
const score = baseScore > 0 || linkBoost > 0
|
|
114
|
-
? baseScore + linkBoost + indexedBoost + extractionBoost
|
|
137
|
+
? baseScore + linkBoost + manualBoost + indexedBoost + extractionBoost
|
|
115
138
|
: 0;
|
|
116
139
|
return sourceResult(source, extraction, score, selectRelevantExcerpt(expandedTokens, source, extraction));
|
|
117
140
|
});
|
|
@@ -137,16 +160,51 @@ export function scoreHomeGraphResults(query, sources, nodes, edges, extractionBy
|
|
|
137
160
|
if (anchoredSourceResults.length > 0) {
|
|
138
161
|
results = anchoredSourceResults.sort(compareHomeGraphResults);
|
|
139
162
|
}
|
|
163
|
+
if (sourceEvidenceQuery) {
|
|
164
|
+
results = pruneWeakSourceEvidence(results, tokens, sourceLinks, anchorIds);
|
|
165
|
+
}
|
|
140
166
|
const strongResults = pruneWeakTokenCoverage(results, tokens);
|
|
141
167
|
return strongResults.slice(0, Math.max(1, limit));
|
|
142
168
|
}
|
|
169
|
+
export function selectHomeGraphExtractionRepairCandidates(query, sources, nodes, edges, extractionBySourceId, limit) {
|
|
170
|
+
const tokens = tokenizeQuery(query);
|
|
171
|
+
if (tokens.length === 0)
|
|
172
|
+
return [];
|
|
173
|
+
const anchors = selectAnchorNodes(tokens, nodes);
|
|
174
|
+
const anchorIds = new Set(anchors.map((anchor) => anchor.node.id));
|
|
175
|
+
const sourceLinks = buildSourceLinkIndex(edges);
|
|
176
|
+
return sources
|
|
177
|
+
.map((source) => {
|
|
178
|
+
if (!source.artifactId || !homeGraphExtractionNeedsRepair(extractionBySourceId(source.id)))
|
|
179
|
+
return { source, score: 0 };
|
|
180
|
+
const linkedNodeIds = sourceLinks.get(source.id) ?? new Set();
|
|
181
|
+
const linkedToAnchor = anchors.length > 0 && intersects(linkedNodeIds, anchorIds);
|
|
182
|
+
const identityScore = scoreFields(tokens, [
|
|
183
|
+
source.title,
|
|
184
|
+
source.summary,
|
|
185
|
+
source.description,
|
|
186
|
+
source.sourceUri,
|
|
187
|
+
source.canonicalUri,
|
|
188
|
+
source.tags.join(' '),
|
|
189
|
+
]);
|
|
190
|
+
const sourceKindBoost = isManualLikeSource(source) ? 30 : 0;
|
|
191
|
+
const score = linkedToAnchor
|
|
192
|
+
? 140 + relationBoost(source.id, anchorIds, edges) + sourceKindBoost + identityScore
|
|
193
|
+
: identityScore > 0 ? identityScore + sourceKindBoost : 0;
|
|
194
|
+
return { source, score };
|
|
195
|
+
})
|
|
196
|
+
.filter((entry) => entry.score > 0)
|
|
197
|
+
.sort((left, right) => right.score - left.score || left.source.id.localeCompare(right.source.id))
|
|
198
|
+
.slice(0, Math.max(1, limit))
|
|
199
|
+
.map((entry) => entry.source);
|
|
200
|
+
}
|
|
143
201
|
function sourceResult(source, extraction, score, excerpt) {
|
|
144
202
|
return {
|
|
145
203
|
kind: 'source',
|
|
146
204
|
id: source.id,
|
|
147
205
|
score,
|
|
148
206
|
title: source.title ?? source.sourceUri ?? source.id,
|
|
149
|
-
summary: extraction
|
|
207
|
+
summary: usefulExtractionSummary(extraction) ?? source.summary,
|
|
150
208
|
...(excerpt ? { excerpt } : {}),
|
|
151
209
|
source,
|
|
152
210
|
};
|
|
@@ -264,20 +322,79 @@ function isPendingDocumentationCandidate(source, extraction) {
|
|
|
264
322
|
&& source.status !== 'indexed'
|
|
265
323
|
&& source.metadata.homeGraphSourceKind === 'documentation-candidate';
|
|
266
324
|
}
|
|
325
|
+
export function homeGraphExtractionNeedsRepair(extraction) {
|
|
326
|
+
if (!extraction)
|
|
327
|
+
return true;
|
|
328
|
+
if (extraction.format === 'pdf' && extraction.extractorId !== 'pdfjs')
|
|
329
|
+
return true;
|
|
330
|
+
const searchText = readSearchText(extraction);
|
|
331
|
+
if (searchText && searchText.trim().length > 0)
|
|
332
|
+
return false;
|
|
333
|
+
if ((extraction.excerpt?.trim() && !isLowInformationExtractionText(extraction.excerpt))
|
|
334
|
+
|| (extraction.summary?.trim() && !isLowInformationExtractionText(extraction.summary))
|
|
335
|
+
|| extraction.sections.some((section) => section.trim() && !isLowInformationExtractionText(section))) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
function queryNeedsSourceEvidence(tokens) {
|
|
341
|
+
return tokens.some((token) => SOURCE_EVIDENCE_TOKENS.has(token));
|
|
342
|
+
}
|
|
343
|
+
function queryMentionsIntegration(tokens) {
|
|
344
|
+
return tokens.some((token) => INTEGRATION_QUERY_TOKENS.has(token));
|
|
345
|
+
}
|
|
346
|
+
function isManualLikeSource(source) {
|
|
347
|
+
const tags = source.tags.map((tag) => tag.toLowerCase());
|
|
348
|
+
return source.sourceType === 'manual'
|
|
349
|
+
|| source.sourceType === 'document'
|
|
350
|
+
|| source.sourceType === 'url'
|
|
351
|
+
|| tags.includes('manual')
|
|
352
|
+
|| tags.includes('artifact')
|
|
353
|
+
|| tags.includes('document');
|
|
354
|
+
}
|
|
355
|
+
function isHomeAssistantIntegrationSource(source) {
|
|
356
|
+
const tags = source.tags.map((tag) => tag.toLowerCase());
|
|
357
|
+
const sourceKind = typeof source.metadata.homeGraphSourceKind === 'string'
|
|
358
|
+
? source.metadata.homeGraphSourceKind.toLowerCase()
|
|
359
|
+
: '';
|
|
360
|
+
return tags.includes('integration')
|
|
361
|
+
|| tags.includes('documentation')
|
|
362
|
+
|| sourceKind === 'documentation-candidate';
|
|
363
|
+
}
|
|
364
|
+
function pruneWeakSourceEvidence(results, tokens, sourceLinks, anchorIds) {
|
|
365
|
+
const sourceResults = results.filter((result) => result.source);
|
|
366
|
+
if (sourceResults.length === 0)
|
|
367
|
+
return [...results];
|
|
368
|
+
const strongSourceResults = sourceResults.filter((result) => {
|
|
369
|
+
const source = result.source;
|
|
370
|
+
if (!source)
|
|
371
|
+
return false;
|
|
372
|
+
if (!hasUsefulSourceAnswerText(result))
|
|
373
|
+
return false;
|
|
374
|
+
const linkedToAnchor = intersects(sourceLinks.get(source.id) ?? new Set(), anchorIds);
|
|
375
|
+
return linkedToAnchor || tokenCoverage(tokens, resultText(result)) >= Math.min(2, tokens.length);
|
|
376
|
+
});
|
|
377
|
+
return strongSourceResults;
|
|
378
|
+
}
|
|
379
|
+
function hasUsefulSourceAnswerText(result) {
|
|
380
|
+
const detail = result.excerpt ?? result.summary ?? result.source?.description;
|
|
381
|
+
return typeof detail === 'string' && detail.trim().length > 0 && !isLowInformationExtractionText(detail);
|
|
382
|
+
}
|
|
267
383
|
function selectRelevantExcerpt(tokens, source, extraction) {
|
|
268
384
|
const chunks = candidateExcerptChunks(source, extraction);
|
|
269
385
|
let best;
|
|
270
386
|
for (const chunk of chunks) {
|
|
271
387
|
const text = cleanWhitespace(chunk);
|
|
272
|
-
if (!text)
|
|
388
|
+
if (!text || isLowInformationExtractionText(text))
|
|
273
389
|
continue;
|
|
274
390
|
const score = scoreFields(tokens, [text]);
|
|
275
391
|
if (!best || score > best.score || (score === best.score && text.length < best.text.length)) {
|
|
276
392
|
best = { score, text };
|
|
277
393
|
}
|
|
278
394
|
}
|
|
279
|
-
if (!best || best.score <= 0)
|
|
280
|
-
return firstBoundedText(chunks, MAX_ANSWER_EXCERPT_CHARS);
|
|
395
|
+
if (!best || best.score <= 0) {
|
|
396
|
+
return firstBoundedText(chunks.filter((chunk) => !isLowInformationExtractionText(chunk)), MAX_ANSWER_EXCERPT_CHARS);
|
|
397
|
+
}
|
|
281
398
|
return clampAroundBestToken(best.text, tokens, MAX_ANSWER_EXCERPT_CHARS);
|
|
282
399
|
}
|
|
283
400
|
function candidateExcerptChunks(source, extraction) {
|
|
@@ -291,6 +408,17 @@ function candidateExcerptChunks(source, extraction) {
|
|
|
291
408
|
source.summary,
|
|
292
409
|
].filter((value) => typeof value === 'string' && value.trim().length > 0);
|
|
293
410
|
}
|
|
411
|
+
function usefulExtractionSummary(extraction) {
|
|
412
|
+
const summary = extraction?.summary?.trim();
|
|
413
|
+
return summary && !isLowInformationExtractionText(summary) ? summary : undefined;
|
|
414
|
+
}
|
|
415
|
+
function isLowInformationExtractionText(value) {
|
|
416
|
+
const normalized = value.toLowerCase();
|
|
417
|
+
return normalized.includes('pdf extraction produced limited text')
|
|
418
|
+
|| normalized.includes('no readable text streams')
|
|
419
|
+
|| normalized.includes('no specialized extractor matched')
|
|
420
|
+
|| normalized.includes('has no specialized in-core extractor');
|
|
421
|
+
}
|
|
294
422
|
function sentenceChunks(value) {
|
|
295
423
|
const text = cleanWhitespace(value ?? '');
|
|
296
424
|
if (!text)
|
|
@@ -2,7 +2,7 @@ import type { ArtifactStore } from '../../artifacts/index.js';
|
|
|
2
2
|
import type { KnowledgeStore } from '../store.js';
|
|
3
3
|
import type { KnowledgeEdgeRecord, KnowledgeIssueRecord, KnowledgeNodeRecord, KnowledgeSourceRecord } from '../types.js';
|
|
4
4
|
import { type HomeGraphReviewResult } from './review.js';
|
|
5
|
-
import type { HomeGraphAskInput, HomeGraphAskResult, HomeGraphDevicePassportResult, HomeGraphExport, HomeGraphIngestArtifactInput, HomeGraphIngestNoteInput, HomeGraphIngestResult, HomeGraphIngestUrlInput, HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphProjectionInput, HomeGraphProjectionResult, HomeGraphReviewInput, HomeGraphSpaceInput, HomeGraphSnapshotInput, HomeGraphStatus, HomeGraphSyncResult } from './types.js';
|
|
5
|
+
import type { HomeGraphAskInput, HomeGraphAskResult, HomeGraphDevicePassportResult, HomeGraphExport, HomeGraphIngestArtifactInput, HomeGraphIngestNoteInput, HomeGraphIngestResult, HomeGraphIngestUrlInput, HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphMapInput, HomeGraphMapResult, HomeGraphProjectionInput, HomeGraphProjectionResult, HomeGraphReindexResult, HomeGraphReviewInput, HomeGraphSpaceInput, HomeGraphSnapshotInput, HomeGraphStatus, HomeGraphSyncResult } from './types.js';
|
|
6
6
|
export declare class HomeGraphService {
|
|
7
7
|
private readonly store;
|
|
8
8
|
private readonly artifactStore;
|
|
@@ -18,6 +18,8 @@ export declare class HomeGraphService {
|
|
|
18
18
|
linkKnowledge(input: HomeGraphLinkInput): Promise<HomeGraphLinkResult>;
|
|
19
19
|
unlinkKnowledge(input: HomeGraphLinkInput): Promise<HomeGraphLinkResult>;
|
|
20
20
|
ask(input: HomeGraphAskInput): Promise<HomeGraphAskResult>;
|
|
21
|
+
reindex(input?: HomeGraphSpaceInput): Promise<HomeGraphReindexResult>;
|
|
22
|
+
private repairWeakExtractionsForAsk;
|
|
21
23
|
refreshDevicePassport(input: HomeGraphProjectionInput): Promise<HomeGraphDevicePassportResult>;
|
|
22
24
|
generateRoomPage(input: HomeGraphProjectionInput): Promise<HomeGraphProjectionResult>;
|
|
23
25
|
generatePacket(input: HomeGraphProjectionInput): Promise<HomeGraphProjectionResult>;
|
|
@@ -49,6 +51,7 @@ export declare class HomeGraphService {
|
|
|
49
51
|
readonly sources: readonly KnowledgeSourceRecord[];
|
|
50
52
|
readonly issues: readonly KnowledgeIssueRecord[];
|
|
51
53
|
}>;
|
|
54
|
+
map(input?: HomeGraphMapInput): Promise<HomeGraphMapResult>;
|
|
52
55
|
exportSpace(input?: HomeGraphSpaceInput): Promise<HomeGraphExport>;
|
|
53
56
|
importSpace(input: HomeGraphSpaceInput & {
|
|
54
57
|
readonly data: HomeGraphExport;
|
|
@@ -72,6 +75,5 @@ export declare class HomeGraphService {
|
|
|
72
75
|
private refreshQualityIssues;
|
|
73
76
|
private resolveLinkSource;
|
|
74
77
|
private ensureTarget;
|
|
75
|
-
private materializeMarkdown;
|
|
76
78
|
}
|
|
77
79
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EAEnB,oBAAoB,EACpB,mBAAmB,EAEnB,qBAAqB,EAEtB,MAAM,aAAa,CAAC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