@pellux/goodvibes-sdk 0.27.12 → 0.28.0
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 +7534 -5938
- 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 +7534 -5938
- 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 +52 -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 +58 -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 +78 -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 +56 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.js +62 -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 +46 -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.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/gap-repair.js +46 -9
- package/dist/_internal/platform/knowledge/semantic/self-improvement.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/self-improvement.js +125 -5
- 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 +51 -54
- package/dist/_internal/platform/knowledge/semantic/types.d.ts +12 -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 +17 -1
- package/dist/_internal/platform/knowledge/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/service.js +52 -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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { KnowledgeStore } from '../store.js';
|
|
2
|
+
import type { KnowledgeEdgeRecord, KnowledgeIssueRecord, KnowledgeNodeRecord, KnowledgeSourceRecord } from '../types.js';
|
|
3
|
+
import type { HomeGraphSpaceInput } from './types.js';
|
|
4
|
+
export declare function listHomeGraphSources(input: HomeGraphSpaceInput & {
|
|
5
|
+
readonly store: KnowledgeStore;
|
|
6
|
+
readonly limit?: number;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
readonly spaceId: string;
|
|
10
|
+
readonly sources: readonly KnowledgeSourceRecord[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare function browseHomeGraph(input: HomeGraphSpaceInput & {
|
|
13
|
+
readonly store: KnowledgeStore;
|
|
14
|
+
readonly limit?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
readonly spaceId: string;
|
|
18
|
+
readonly nodes: readonly KnowledgeNodeRecord[];
|
|
19
|
+
readonly edges: readonly KnowledgeEdgeRecord[];
|
|
20
|
+
readonly sources: readonly KnowledgeSourceRecord[];
|
|
21
|
+
readonly issues: readonly KnowledgeIssueRecord[];
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/inventory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG;IACtE,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAA;CAAE,CAAC,CAI/G;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG;IACjE,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAClD,CAAC,CAaD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { resolveReadableHomeGraphSpace } from './space-selection.js';
|
|
2
|
+
import { readHomeGraphState } from './state.js';
|
|
3
|
+
export async function listHomeGraphSources(input) {
|
|
4
|
+
await input.store.init();
|
|
5
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
6
|
+
return { ok: true, spaceId, sources: readHomeGraphState(input.store, spaceId).sources.slice(0, Math.max(1, input.limit ?? 100)) };
|
|
7
|
+
}
|
|
8
|
+
export async function browseHomeGraph(input) {
|
|
9
|
+
await input.store.init();
|
|
10
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
11
|
+
const limit = Math.max(1, input.limit ?? 250);
|
|
12
|
+
const state = readHomeGraphState(input.store, spaceId);
|
|
13
|
+
return {
|
|
14
|
+
ok: true,
|
|
15
|
+
spaceId,
|
|
16
|
+
nodes: state.nodes.slice(0, limit),
|
|
17
|
+
edges: state.edges.slice(0, limit),
|
|
18
|
+
sources: state.sources.slice(0, limit),
|
|
19
|
+
issues: state.issues.slice(0, limit),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { KnowledgeStore } from '../store.js';
|
|
2
|
+
import type { HomeGraphMapInput, HomeGraphMapResult } from './types.js';
|
|
3
|
+
export declare function mapHomeGraph(input: HomeGraphMapInput & {
|
|
4
|
+
readonly store: KnowledgeStore;
|
|
5
|
+
}): Promise<HomeGraphMapResult>;
|
|
6
|
+
//# sourceMappingURL=map-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-view.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/map-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExE,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG;IAC5D,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { renderHomeGraphMap } from './rendering.js';
|
|
2
|
+
import { resolveReadableHomeGraphSpace } from './space-selection.js';
|
|
3
|
+
import { renderHomeGraphState } from './state.js';
|
|
4
|
+
export async function mapHomeGraph(input) {
|
|
5
|
+
await input.store.init();
|
|
6
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
7
|
+
return renderHomeGraphMap(renderHomeGraphState(input.store, spaceId, 'Home Graph Map'), {
|
|
8
|
+
...input,
|
|
9
|
+
knowledgeSpaceId: spaceId,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { KnowledgeSemanticService } from '../semantic/index.js';
|
|
2
|
+
import type { KnowledgeStore } from '../store.js';
|
|
3
|
+
import type { KnowledgeRefinementTaskRecord } from '../types.js';
|
|
4
|
+
import type { HomeGraphSpaceInput } from './types.js';
|
|
5
|
+
export declare function listHomeGraphRefinementTasks(input: HomeGraphSpaceInput & {
|
|
6
|
+
readonly store: KnowledgeStore;
|
|
7
|
+
readonly limit?: number;
|
|
8
|
+
readonly state?: string;
|
|
9
|
+
readonly subjectId?: string;
|
|
10
|
+
readonly gapId?: string;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly spaceId: string;
|
|
14
|
+
readonly tasks: readonly KnowledgeRefinementTaskRecord[];
|
|
15
|
+
}>;
|
|
16
|
+
export declare function getHomeGraphRefinementTask(input: HomeGraphSpaceInput & {
|
|
17
|
+
readonly store: KnowledgeStore;
|
|
18
|
+
readonly taskId: string;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
readonly ok: true;
|
|
21
|
+
readonly spaceId: string;
|
|
22
|
+
readonly task: KnowledgeRefinementTaskRecord | null;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function runHomeGraphRefinement(input: HomeGraphSpaceInput & {
|
|
25
|
+
readonly store: KnowledgeStore;
|
|
26
|
+
readonly semanticService?: KnowledgeSemanticService;
|
|
27
|
+
readonly gapIds?: readonly string[];
|
|
28
|
+
readonly sourceIds?: readonly string[];
|
|
29
|
+
readonly limit?: number;
|
|
30
|
+
readonly force?: boolean;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
ok: boolean;
|
|
33
|
+
spaceId: string;
|
|
34
|
+
error: string;
|
|
35
|
+
result?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
ok: boolean;
|
|
38
|
+
spaceId: string;
|
|
39
|
+
result: import("../semantic/types.js").KnowledgeSemanticSelfImproveResult;
|
|
40
|
+
error?: undefined;
|
|
41
|
+
}>;
|
|
42
|
+
export declare function cancelHomeGraphRefinementTask(input: HomeGraphSpaceInput & {
|
|
43
|
+
readonly store: KnowledgeStore;
|
|
44
|
+
readonly taskId: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
ok: boolean;
|
|
47
|
+
spaceId: string;
|
|
48
|
+
error: string;
|
|
49
|
+
task?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
spaceId: string;
|
|
53
|
+
task: KnowledgeRefinementTaskRecord;
|
|
54
|
+
error?: undefined;
|
|
55
|
+
}>;
|
|
56
|
+
//# sourceMappingURL=refinement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refinement.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/refinement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,mBAAmB,GAAG;IAC9E,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EA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+
export async function listHomeGraphRefinementTasks(input) {
|
|
3
|
+
await input.store.init();
|
|
4
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
5
|
+
return {
|
|
6
|
+
ok: true,
|
|
7
|
+
spaceId,
|
|
8
|
+
tasks: input.store.listRefinementTasks(input.limit ?? 100, {
|
|
9
|
+
spaceId,
|
|
10
|
+
state: input.state,
|
|
11
|
+
subjectKind: input.subjectId ? 'node' : undefined,
|
|
12
|
+
subjectId: input.subjectId,
|
|
13
|
+
gapId: input.gapId,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export async function getHomeGraphRefinementTask(input) {
|
|
18
|
+
await input.store.init();
|
|
19
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
20
|
+
const task = input.store.getRefinementTask(input.taskId);
|
|
21
|
+
return { ok: true, spaceId, task: task?.spaceId === spaceId ? task : null };
|
|
22
|
+
}
|
|
23
|
+
export async function runHomeGraphRefinement(input) {
|
|
24
|
+
await input.store.init();
|
|
25
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
26
|
+
if (!input.semanticService)
|
|
27
|
+
return { ok: false, spaceId, error: 'Semantic refinement is not configured.' };
|
|
28
|
+
const result = await input.semanticService.selfImprove({
|
|
29
|
+
knowledgeSpaceId: spaceId,
|
|
30
|
+
gapIds: input.gapIds,
|
|
31
|
+
sourceIds: input.sourceIds,
|
|
32
|
+
limit: input.limit,
|
|
33
|
+
force: input.force,
|
|
34
|
+
reason: 'manual',
|
|
35
|
+
});
|
|
36
|
+
return { ok: true, spaceId, result };
|
|
37
|
+
}
|
|
38
|
+
export async function cancelHomeGraphRefinementTask(input) {
|
|
39
|
+
await input.store.init();
|
|
40
|
+
const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
|
|
41
|
+
const task = input.store.getRefinementTask(input.taskId);
|
|
42
|
+
if (!task || task.spaceId !== spaceId)
|
|
43
|
+
return { ok: false, spaceId, error: 'Unknown Home Graph refinement task.' };
|
|
44
|
+
const cancelled = await input.store.upsertRefinementTask({
|
|
45
|
+
id: task.id,
|
|
46
|
+
spaceId: task.spaceId,
|
|
47
|
+
subjectKind: task.subjectKind,
|
|
48
|
+
subjectId: task.subjectId,
|
|
49
|
+
subjectTitle: task.subjectTitle,
|
|
50
|
+
subjectType: task.subjectType,
|
|
51
|
+
gapId: task.gapId,
|
|
52
|
+
issueId: task.issueId,
|
|
53
|
+
state: 'cancelled',
|
|
54
|
+
priority: task.priority,
|
|
55
|
+
trigger: task.trigger,
|
|
56
|
+
budget: task.budget,
|
|
57
|
+
attemptCount: task.attemptCount,
|
|
58
|
+
appendTrace: [{ at: Date.now(), state: 'cancelled', message: 'Home Graph refinement task was cancelled by request.' }],
|
|
59
|
+
metadata: task.metadata,
|
|
60
|
+
});
|
|
61
|
+
return { ok: true, spaceId, task: cancelled };
|
|
62
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KnowledgeEdgeRecord,
|
|
1
|
+
import type { KnowledgeEdgeRecord, KnowledgeIssueRecord, KnowledgeNodeRecord, KnowledgeSourceRecord } from '../types.js';
|
|
2
2
|
import type { HomeGraphMapInput, HomeGraphMapResult } from './types.js';
|
|
3
3
|
export interface HomeGraphRenderState {
|
|
4
4
|
readonly spaceId: string;
|
|
@@ -7,7 +7,6 @@ export interface HomeGraphRenderState {
|
|
|
7
7
|
readonly nodes: readonly KnowledgeNodeRecord[];
|
|
8
8
|
readonly edges: readonly KnowledgeEdgeRecord[];
|
|
9
9
|
readonly issues: readonly KnowledgeIssueRecord[];
|
|
10
|
-
readonly extractions?: readonly KnowledgeExtractionRecord[];
|
|
11
10
|
}
|
|
12
11
|
export declare function renderRoomPage(state: HomeGraphRenderState, areaId?: string): string;
|
|
13
12
|
export declare function renderDevicePassportPage(input: {
|
|
@@ -15,10 +14,10 @@ export declare function renderDevicePassportPage(input: {
|
|
|
15
14
|
readonly device: KnowledgeNodeRecord;
|
|
16
15
|
readonly entities: readonly KnowledgeNodeRecord[];
|
|
17
16
|
readonly sources: readonly KnowledgeSourceRecord[];
|
|
18
|
-
readonly extractions?: readonly KnowledgeExtractionRecord[];
|
|
19
17
|
readonly issues: readonly KnowledgeIssueRecord[];
|
|
20
18
|
readonly missingFields: readonly string[];
|
|
21
19
|
readonly semanticFacts?: readonly KnowledgeNodeRecord[];
|
|
20
|
+
readonly sourceBackedNotes?: readonly string[];
|
|
22
21
|
}): string;
|
|
23
22
|
export declare function renderPacketPage(state: HomeGraphRenderState, options?: {
|
|
24
23
|
readonly packetKind?: string;
|
|
@@ -27,4 +26,5 @@ export declare function renderPacketPage(state: HomeGraphRenderState, options?:
|
|
|
27
26
|
readonly excludeFields?: readonly string[];
|
|
28
27
|
}): string;
|
|
29
28
|
export declare function renderHomeGraphMap(state: HomeGraphRenderState, options?: HomeGraphMapInput): HomeGraphMapResult;
|
|
29
|
+
export declare function issuesForScope(issues: readonly KnowledgeIssueRecord[], edges: readonly KnowledgeEdgeRecord[], nodeIds: ReadonlySet<string>, sources: readonly KnowledgeSourceRecord[]): KnowledgeIssueRecord[];
|
|
30
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,
|
|
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,EAEpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAA6B,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGnG,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,M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kBAAkB,CAAC,KAAK,EAAE,oBAAoB,EAAE,OAAO,GAAE,iBAAsB,GAAG,kBAAkB,CAcnH;AAsRD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,oBAAoB,EAAE,EACvC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,oBAAoB,EAAE,CAUxB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { renderKnowledgeMap } from '../map.js';
|
|
2
2
|
import { countFacet, normalizeStringArray, readString } from '../map-filters.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { isLowValueFeatureOrSpecText, isUsefulHomeGraphPageFact } from '../semantic/fact-quality.js';
|
|
3
|
+
import { edgeIsActive, isGeneratedPageSource, uniqueStrings } from './helpers.js';
|
|
4
|
+
import { isUsefulHomeGraphPageFact } from '../semantic/fact-quality.js';
|
|
6
5
|
export function renderRoomPage(state, areaId) {
|
|
7
6
|
const area = areaId
|
|
8
7
|
? findNodeByHaId(state.nodes, 'ha_area', areaId) ?? findNodeByHaId(state.nodes, 'ha_room', areaId)
|
|
@@ -26,6 +25,7 @@ export function renderRoomPage(state, areaId) {
|
|
|
26
25
|
]);
|
|
27
26
|
const sources = relatedSources(state.sources, state.edges, relatedNodeIds);
|
|
28
27
|
const semanticFacts = semanticFactsLinkedToSources(sources, state.nodes, state.edges);
|
|
28
|
+
const issues = issuesForScope(state.issues, state.edges, relatedNodeIds, sources);
|
|
29
29
|
return [
|
|
30
30
|
`# ${title}`,
|
|
31
31
|
'',
|
|
@@ -37,22 +37,12 @@ export function renderRoomPage(state, areaId) {
|
|
|
37
37
|
renderNodeList('Automations', automations),
|
|
38
38
|
renderNodeList('Scenes', scenes),
|
|
39
39
|
renderNodeList('Scripts', scripts),
|
|
40
|
-
renderSourceEvidence('Source-Backed Knowledge', sources, state.extractions ?? [], {
|
|
41
|
-
tokens: uniqueStrings([
|
|
42
|
-
title,
|
|
43
|
-
...devices.map((node) => node.title),
|
|
44
|
-
...entities.map((node) => node.title),
|
|
45
|
-
].flatMap(tokenizeEvidence)),
|
|
46
|
-
maxSources: 12,
|
|
47
|
-
maxSnippetsPerSource: 2,
|
|
48
|
-
}),
|
|
49
40
|
renderSemanticFacts('Extracted Facts', semanticFacts),
|
|
50
41
|
renderSourceList('Linked Sources', sources),
|
|
51
|
-
renderIssueList('Open Issues',
|
|
42
|
+
renderIssueList('Open Issues', issues),
|
|
52
43
|
].filter(Boolean).join('\n');
|
|
53
44
|
}
|
|
54
45
|
export function renderDevicePassportPage(input) {
|
|
55
|
-
const deviceTokens = deviceEvidenceTokens(input.device, input.entities);
|
|
56
46
|
return [
|
|
57
47
|
`# ${input.device.title}`,
|
|
58
48
|
'',
|
|
@@ -70,14 +60,10 @@ export function renderDevicePassportPage(input) {
|
|
|
70
60
|
renderMetadataField('Device id', readHa(input.device, 'deviceId')),
|
|
71
61
|
'',
|
|
72
62
|
renderNodeList('Entities Exposed To Home Assistant', input.entities),
|
|
73
|
-
renderSemanticFacts('
|
|
74
|
-
|
|
75
|
-
tokens: deviceTokens,
|
|
76
|
-
maxSources: 8,
|
|
77
|
-
maxSnippetsPerSource: 4,
|
|
78
|
-
}),
|
|
63
|
+
renderSemanticFacts('Verified Device Facts', input.semanticFacts ?? []),
|
|
64
|
+
renderTextList('Source-Backed Features And Notes', input.sourceBackedNotes ?? []),
|
|
79
65
|
renderSourceList('Sources', input.sources),
|
|
80
|
-
renderIssueList('Issues', input.issues),
|
|
66
|
+
renderIssueList('Open Issues', input.issues.filter((issue) => issue.status === 'open')),
|
|
81
67
|
input.missingFields.length > 0
|
|
82
68
|
? ['## Open Questions', '', ...input.missingFields.map((field) => `- ${field}`), ''].join('\n')
|
|
83
69
|
: '',
|
|
@@ -257,121 +243,6 @@ function renderDeviceOverview(device, entities, sources) {
|
|
|
257
243
|
const details = identity.length > 0 ? ` ${identity.join(' - ')}.` : '.';
|
|
258
244
|
return `${device.title}${details} The Home Graph links this device to ${entities.length} Home Assistant entity record(s) and ${sources.length} source(s).`;
|
|
259
245
|
}
|
|
260
|
-
function renderSourceEvidence(title, sources, extractions, options) {
|
|
261
|
-
const extractionBySourceId = new Map(extractions.map((extraction) => [extraction.sourceId, extraction]));
|
|
262
|
-
const entries = sources
|
|
263
|
-
.map((source) => ({
|
|
264
|
-
source,
|
|
265
|
-
snippets: sourceEvidenceSnippets(source, extractionBySourceId.get(source.id), options.tokens, options.maxSnippetsPerSource),
|
|
266
|
-
}))
|
|
267
|
-
.filter((entry) => entry.snippets.length > 0)
|
|
268
|
-
.slice(0, options.maxSources);
|
|
269
|
-
if (entries.length === 0) {
|
|
270
|
-
return [
|
|
271
|
-
`## ${title}`,
|
|
272
|
-
'',
|
|
273
|
-
'No linked source-backed details have been extracted yet.',
|
|
274
|
-
'',
|
|
275
|
-
].join('\n');
|
|
276
|
-
}
|
|
277
|
-
return [
|
|
278
|
-
`## ${title}`,
|
|
279
|
-
'',
|
|
280
|
-
...entries.flatMap((entry) => [
|
|
281
|
-
`### ${entry.source.title ?? entry.source.sourceUri ?? entry.source.id}`,
|
|
282
|
-
'',
|
|
283
|
-
...entry.snippets.map((snippet) => `- ${snippet}`),
|
|
284
|
-
'',
|
|
285
|
-
]),
|
|
286
|
-
].join('\n');
|
|
287
|
-
}
|
|
288
|
-
function sourceEvidenceSnippets(source, extraction, tokens, limit) {
|
|
289
|
-
const structure = readRecord(extraction?.structure);
|
|
290
|
-
const searchText = typeof structure.searchText === 'string' ? structure.searchText : undefined;
|
|
291
|
-
const candidates = uniqueStrings([
|
|
292
|
-
extraction?.summary,
|
|
293
|
-
extraction?.excerpt,
|
|
294
|
-
...(extraction?.sections ?? []),
|
|
295
|
-
...evidenceWindows(searchText, tokens),
|
|
296
|
-
...featureSentences(searchText),
|
|
297
|
-
source.summary,
|
|
298
|
-
source.description,
|
|
299
|
-
]).filter((entry) => !isUnusableHomeGraphExtractionText(entry) && !isLowValueFeatureOrSpecText(entry)).slice(0, 80);
|
|
300
|
-
const scored = candidates
|
|
301
|
-
.map((text) => ({ text: clampEvidence(text), score: evidenceScore(text, tokens) }))
|
|
302
|
-
.filter((entry) => entry.text.length > 0)
|
|
303
|
-
.sort((left, right) => right.score - left.score || left.text.length - right.text.length);
|
|
304
|
-
return uniqueStrings(scored.map((entry) => entry.text)).slice(0, limit);
|
|
305
|
-
}
|
|
306
|
-
function evidenceWindows(value, tokens) {
|
|
307
|
-
const text = normalizeWhitespace(value ?? '');
|
|
308
|
-
if (!text)
|
|
309
|
-
return [];
|
|
310
|
-
const lower = text.toLowerCase();
|
|
311
|
-
const windows = [];
|
|
312
|
-
for (const token of tokens) {
|
|
313
|
-
if (token.length < 3)
|
|
314
|
-
continue;
|
|
315
|
-
const index = lower.indexOf(token.toLowerCase());
|
|
316
|
-
if (index < 0)
|
|
317
|
-
continue;
|
|
318
|
-
const start = Math.max(0, index - 180);
|
|
319
|
-
const end = Math.min(text.length, index + 420);
|
|
320
|
-
windows.push(`${start > 0 ? '...' : ''}${text.slice(start, end).trim()}${end < text.length ? '...' : ''}`);
|
|
321
|
-
}
|
|
322
|
-
return windows;
|
|
323
|
-
}
|
|
324
|
-
function featureSentences(value) {
|
|
325
|
-
const text = normalizeWhitespace(value ?? '');
|
|
326
|
-
if (!text)
|
|
327
|
-
return [];
|
|
328
|
-
const keywords = /\b(feature|features|support|supports|capability|capabilities|specification|specifications|mode|modes|hdmi|hdr|dolby|battery|reset|warranty|firmware|voice|remote)\b/i;
|
|
329
|
-
return (text.match(/[^.!?\n]+[.!?]?/g) ?? [])
|
|
330
|
-
.map((entry) => entry.trim())
|
|
331
|
-
.filter((entry) => keywords.test(entry) && !isLowValueFeatureOrSpecText(entry))
|
|
332
|
-
.slice(0, 24);
|
|
333
|
-
}
|
|
334
|
-
function evidenceScore(value, tokens) {
|
|
335
|
-
const lower = value.toLowerCase();
|
|
336
|
-
let score = 0;
|
|
337
|
-
for (const token of tokens) {
|
|
338
|
-
if (token.length >= 3 && lower.includes(token.toLowerCase()))
|
|
339
|
-
score += 10;
|
|
340
|
-
}
|
|
341
|
-
if (/\b(feature|features|support|supports|mode|hdmi|hdr|dolby|voice|remote)\b/i.test(value))
|
|
342
|
-
score += 25;
|
|
343
|
-
return score;
|
|
344
|
-
}
|
|
345
|
-
function deviceEvidenceTokens(device, entities) {
|
|
346
|
-
return uniqueStrings([
|
|
347
|
-
device.title,
|
|
348
|
-
...device.aliases,
|
|
349
|
-
readMetadataString(device, 'manufacturer'),
|
|
350
|
-
readMetadataString(device, 'model'),
|
|
351
|
-
readHa(device, 'deviceId'),
|
|
352
|
-
...entities.flatMap((entity) => [
|
|
353
|
-
entity.title,
|
|
354
|
-
readHa(entity, 'entityId'),
|
|
355
|
-
readMetadataString(entity, 'domain'),
|
|
356
|
-
readMetadataString(entity, 'platform'),
|
|
357
|
-
]),
|
|
358
|
-
].flatMap(tokenizeEvidence));
|
|
359
|
-
}
|
|
360
|
-
function tokenizeEvidence(value) {
|
|
361
|
-
if (!value)
|
|
362
|
-
return [];
|
|
363
|
-
return value.toLowerCase()
|
|
364
|
-
.split(/[^a-z0-9_.:-]+/)
|
|
365
|
-
.map((entry) => entry.trim())
|
|
366
|
-
.filter((entry) => entry.length >= 2 && !['the', 'and', 'home', 'assistant', 'device'].includes(entry));
|
|
367
|
-
}
|
|
368
|
-
function clampEvidence(value) {
|
|
369
|
-
const normalized = normalizeWhitespace(value);
|
|
370
|
-
return normalized.length <= 420 ? normalized : `${normalized.slice(0, 419).trim()}...`;
|
|
371
|
-
}
|
|
372
|
-
function normalizeWhitespace(value) {
|
|
373
|
-
return value.replace(/\s+/g, ' ').trim();
|
|
374
|
-
}
|
|
375
246
|
function readMetadataString(node, key) {
|
|
376
247
|
const value = node.metadata[key];
|
|
377
248
|
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
@@ -417,6 +288,17 @@ function renderSemanticFacts(title, facts) {
|
|
|
417
288
|
]),
|
|
418
289
|
].join('\n');
|
|
419
290
|
}
|
|
291
|
+
function renderTextList(title, items) {
|
|
292
|
+
const entries = uniqueStrings(items).slice(0, 80);
|
|
293
|
+
if (entries.length === 0)
|
|
294
|
+
return '';
|
|
295
|
+
return [
|
|
296
|
+
`## ${title}`,
|
|
297
|
+
'',
|
|
298
|
+
...entries.map((item) => `- ${item}`),
|
|
299
|
+
'',
|
|
300
|
+
].join('\n');
|
|
301
|
+
}
|
|
420
302
|
function semanticFactsLinkedToSources(sources, nodes, edges) {
|
|
421
303
|
const sourceIds = new Set(sources.map((source) => source.id));
|
|
422
304
|
const factIds = new Set(edges.filter((edge) => (edgeIsActive(edge)
|
|
@@ -450,6 +332,40 @@ function renderIssueList(title, issues) {
|
|
|
450
332
|
'',
|
|
451
333
|
].join('\n');
|
|
452
334
|
}
|
|
335
|
+
export function issuesForScope(issues, edges, nodeIds, sources) {
|
|
336
|
+
const sourceIds = new Set(sources.map((source) => source.id));
|
|
337
|
+
const scopedNodeIds = expandScopedIssueNodeIds(edges, nodeIds, sourceIds);
|
|
338
|
+
return issues.filter((issue) => (issue.status === 'open'
|
|
339
|
+
&& ((issue.nodeId !== undefined && scopedNodeIds.has(issue.nodeId))
|
|
340
|
+
|| (issue.sourceId !== undefined && sourceIds.has(issue.sourceId)))));
|
|
341
|
+
}
|
|
342
|
+
function expandScopedIssueNodeIds(edges, nodeIds, sourceIds) {
|
|
343
|
+
const scoped = new Set(nodeIds);
|
|
344
|
+
let changed = true;
|
|
345
|
+
while (changed) {
|
|
346
|
+
changed = false;
|
|
347
|
+
for (const edge of edges) {
|
|
348
|
+
if (!edgeIsActive(edge))
|
|
349
|
+
continue;
|
|
350
|
+
if (edge.toKind !== 'node')
|
|
351
|
+
continue;
|
|
352
|
+
const fromScopedNode = edge.fromKind === 'node' && scoped.has(edge.fromId);
|
|
353
|
+
const fromScopedSource = edge.fromKind === 'source' && sourceIds.has(edge.fromId);
|
|
354
|
+
if ((fromScopedNode || fromScopedSource) && isIssueRelation(edge.relation) && !scoped.has(edge.toId)) {
|
|
355
|
+
scoped.add(edge.toId);
|
|
356
|
+
changed = true;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return scoped;
|
|
361
|
+
}
|
|
362
|
+
function isIssueRelation(relation) {
|
|
363
|
+
return relation === 'has_gap'
|
|
364
|
+
|| relation === 'has_issue'
|
|
365
|
+
|| relation === 'source_for'
|
|
366
|
+
|| relation === 'supports_fact'
|
|
367
|
+
|| relation === 'mentions';
|
|
368
|
+
}
|
|
453
369
|
function renderMetadataField(label, value) {
|
|
454
370
|
return typeof value === 'string' && value.trim().length > 0 ? `- ${label}: ${value.trim()}` : '';
|
|
455
371
|
}
|
|
@@ -49,6 +49,52 @@ export declare class HomeGraphService {
|
|
|
49
49
|
readonly limit?: number;
|
|
50
50
|
readonly includeMarkdown?: boolean;
|
|
51
51
|
}): Promise<HomeGraphPageListResult>;
|
|
52
|
+
listRefinementTasks(input?: HomeGraphSpaceInput & {
|
|
53
|
+
readonly limit?: number;
|
|
54
|
+
readonly state?: string;
|
|
55
|
+
readonly subjectId?: string;
|
|
56
|
+
readonly gapId?: string;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
readonly ok: true;
|
|
59
|
+
readonly spaceId: string;
|
|
60
|
+
readonly tasks: readonly import("../types.js").KnowledgeRefinementTaskRecord[];
|
|
61
|
+
}>;
|
|
62
|
+
getRefinementTask(input: HomeGraphSpaceInput & {
|
|
63
|
+
readonly taskId: string;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
readonly ok: true;
|
|
66
|
+
readonly spaceId: string;
|
|
67
|
+
readonly task: import("../types.js").KnowledgeRefinementTaskRecord | null;
|
|
68
|
+
}>;
|
|
69
|
+
runRefinement(input?: HomeGraphSpaceInput & {
|
|
70
|
+
readonly gapIds?: readonly string[];
|
|
71
|
+
readonly sourceIds?: readonly string[];
|
|
72
|
+
readonly limit?: number;
|
|
73
|
+
readonly force?: boolean;
|
|
74
|
+
}): Promise<{
|
|
75
|
+
ok: boolean;
|
|
76
|
+
spaceId: string;
|
|
77
|
+
error: string;
|
|
78
|
+
result?: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
ok: boolean;
|
|
81
|
+
spaceId: string;
|
|
82
|
+
result: import("../semantic/types.js").KnowledgeSemanticSelfImproveResult;
|
|
83
|
+
error?: undefined;
|
|
84
|
+
}>;
|
|
85
|
+
cancelRefinementTask(input: HomeGraphSpaceInput & {
|
|
86
|
+
readonly taskId: string;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
ok: boolean;
|
|
89
|
+
spaceId: string;
|
|
90
|
+
error: string;
|
|
91
|
+
task?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
ok: boolean;
|
|
94
|
+
spaceId: string;
|
|
95
|
+
task: import("../types.js").KnowledgeRefinementTaskRecord;
|
|
96
|
+
error?: undefined;
|
|
97
|
+
}>;
|
|
52
98
|
browse(input?: HomeGraphSpaceInput & {
|
|
53
99
|
readonly limit?: number;
|
|
54
100
|
}): Promise<{
|
|
@@ -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;AAmBrB,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
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,K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
|
3
3
|
import { upsertIntegrationDocumentationCandidates } from './documentation.js';
|
|
4
4
|
import { refreshHomeGraphQualityIssues } from './quality.js';
|
|
5
5
|
import { reviewHomeGraphFact } from './review.js';
|
|
6
|
-
import { inferHomeGraphSourceType, readHomeGraphState,
|
|
6
|
+
import { inferHomeGraphSourceType, readHomeGraphState, safeHomeGraphFilename, } from './state.js';
|
|
7
7
|
import { answerHomeGraphQuery } from './ask.js';
|
|
8
|
-
import { renderHomeGraphMap } from './rendering.js';
|
|
9
8
|
import { autoLinkHomeGraphSource, autoLinkHomeGraphSources, } from './auto-link.js';
|
|
10
9
|
import { generateAutomaticHomeGraphPages, generateHomeGraphPacket, generateHomeGraphRoomPage, refreshAutomaticHomeGraphPages, refreshHomeGraphDevicePassport, } from './generated-pages.js';
|
|
11
10
|
import { reindexHomeGraphSources } from './reindex.js';
|
|
12
11
|
import { listHomeGraphPages } from './pages.js';
|
|
12
|
+
import { browseHomeGraph, listHomeGraphSources } from './inventory.js';
|
|
13
|
+
import { mapHomeGraph } from './map-view.js';
|
|
14
|
+
import { getHomeGraphStatus } from './status.js';
|
|
15
|
+
import { cancelHomeGraphRefinementTask, getHomeGraphRefinementTask, listHomeGraphRefinementTasks, runHomeGraphRefinement, } from './refinement.js';
|
|
13
16
|
import { isUnusableHomeGraphExtractionText } from './extraction-quality.js';
|
|
14
17
|
import { readHomeGraphSearchState, scoreHomeGraphResults, selectHomeGraphExtractionRepairCandidates, } from './search.js';
|
|
15
18
|
import { resolveReadableHomeGraphSpace } from './space-selection.js';
|
|
16
|
-
import { HOME_GRAPH_CAPABILITIES } from './types.js';
|
|
17
19
|
export class HomeGraphService {
|
|
18
20
|
store;
|
|
19
21
|
artifactStore;
|
|
@@ -24,24 +26,7 @@ export class HomeGraphService {
|
|
|
24
26
|
this.options = options;
|
|
25
27
|
}
|
|
26
28
|
async status(input = {}) {
|
|
27
|
-
|
|
28
|
-
const { spaceId, installationId } = resolveReadableHomeGraphSpace(this.store, input);
|
|
29
|
-
const state = readHomeGraphState(this.store, spaceId);
|
|
30
|
-
const snapshotSources = state.sources
|
|
31
|
-
.filter((source) => source.metadata.homeGraphSourceKind === 'snapshot')
|
|
32
|
-
.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
33
|
-
return {
|
|
34
|
-
ok: true,
|
|
35
|
-
spaceId,
|
|
36
|
-
installationId,
|
|
37
|
-
sourceCount: state.sources.length,
|
|
38
|
-
nodeCount: state.nodes.length,
|
|
39
|
-
edgeCount: state.edges.length,
|
|
40
|
-
issueCount: state.issues.length,
|
|
41
|
-
extractionCount: state.extractions.length,
|
|
42
|
-
...(snapshotSources[0]?.updatedAt ? { lastSnapshotAt: snapshotSources[0].updatedAt } : {}),
|
|
43
|
-
capabilities: HOME_GRAPH_CAPABILITIES,
|
|
44
|
-
};
|
|
29
|
+
return getHomeGraphStatus(this.store, input);
|
|
45
30
|
}
|
|
46
31
|
async syncSnapshot(input) {
|
|
47
32
|
await this.store.init();
|
|
@@ -326,9 +311,7 @@ export class HomeGraphService {
|
|
|
326
311
|
return reviewHomeGraphFact(this.store, spaceId, installationId, input);
|
|
327
312
|
}
|
|
328
313
|
async listSources(input = {}) {
|
|
329
|
-
|
|
330
|
-
const { spaceId } = resolveReadableHomeGraphSpace(this.store, input);
|
|
331
|
-
return { ok: true, spaceId, sources: readHomeGraphState(this.store, spaceId).sources.slice(0, Math.max(1, input.limit ?? 100)) };
|
|
314
|
+
return listHomeGraphSources({ ...input, store: this.store });
|
|
332
315
|
}
|
|
333
316
|
async listPages(input = {}) {
|
|
334
317
|
await this.store.init();
|
|
@@ -342,27 +325,23 @@ export class HomeGraphService {
|
|
|
342
325
|
includeMarkdown: input.includeMarkdown !== false,
|
|
343
326
|
});
|
|
344
327
|
}
|
|
328
|
+
async listRefinementTasks(input = {}) {
|
|
329
|
+
return listHomeGraphRefinementTasks({ ...input, store: this.store });
|
|
330
|
+
}
|
|
331
|
+
async getRefinementTask(input) {
|
|
332
|
+
return getHomeGraphRefinementTask({ ...input, store: this.store });
|
|
333
|
+
}
|
|
334
|
+
async runRefinement(input = {}) {
|
|
335
|
+
return runHomeGraphRefinement({ ...input, store: this.store, semanticService: this.options.semanticService });
|
|
336
|
+
}
|
|
337
|
+
async cancelRefinementTask(input) {
|
|
338
|
+
return cancelHomeGraphRefinementTask({ ...input, store: this.store });
|
|
339
|
+
}
|
|
345
340
|
async browse(input = {}) {
|
|
346
|
-
|
|
347
|
-
const { spaceId } = resolveReadableHomeGraphSpace(this.store, input);
|
|
348
|
-
const limit = Math.max(1, input.limit ?? 250);
|
|
349
|
-
const state = readHomeGraphState(this.store, spaceId);
|
|
350
|
-
return {
|
|
351
|
-
ok: true,
|
|
352
|
-
spaceId,
|
|
353
|
-
nodes: state.nodes.slice(0, limit),
|
|
354
|
-
edges: state.edges.slice(0, limit),
|
|
355
|
-
sources: state.sources.slice(0, limit),
|
|
356
|
-
issues: state.issues.slice(0, limit),
|
|
357
|
-
};
|
|
341
|
+
return browseHomeGraph({ ...input, store: this.store });
|
|
358
342
|
}
|
|
359
343
|
async map(input = {}) {
|
|
360
|
-
|
|
361
|
-
const { spaceId } = resolveReadableHomeGraphSpace(this.store, input);
|
|
362
|
-
return renderHomeGraphMap(renderHomeGraphState(this.store, spaceId, 'Home Graph Map'), {
|
|
363
|
-
...input,
|
|
364
|
-
knowledgeSpaceId: spaceId,
|
|
365
|
-
});
|
|
344
|
+
return mapHomeGraph({ ...input, store: this.store });
|
|
366
345
|
}
|
|
367
346
|
async exportSpace(input = {}) {
|
|
368
347
|
await this.store.init();
|