@pellux/goodvibes-sdk 1.1.0 → 1.3.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.
Files changed (139) hide show
  1. package/dist/contracts/artifacts/operator-contract.json +1416 -88
  2. package/dist/platform/companion/companion-chat-manager.d.ts +6 -12
  3. package/dist/platform/companion/companion-chat-manager.d.ts.map +1 -1
  4. package/dist/platform/companion/companion-chat-manager.js +8 -2
  5. package/dist/platform/config/index.d.ts +2 -1
  6. package/dist/platform/config/index.d.ts.map +1 -1
  7. package/dist/platform/config/index.js +1 -0
  8. package/dist/platform/config/manager.d.ts +35 -0
  9. package/dist/platform/config/manager.d.ts.map +1 -1
  10. package/dist/platform/config/manager.js +98 -2
  11. package/dist/platform/config/shared-config-tier.d.ts +51 -0
  12. package/dist/platform/config/shared-config-tier.d.ts.map +1 -0
  13. package/dist/platform/config/shared-config-tier.js +127 -0
  14. package/dist/platform/control-plane/method-catalog-runtime.d.ts.map +1 -1
  15. package/dist/platform/control-plane/method-catalog-runtime.js +95 -1
  16. package/dist/platform/control-plane/operator-contract-schemas-knowledge.d.ts.map +1 -1
  17. package/dist/platform/control-plane/operator-contract-schemas-knowledge.js +6 -1
  18. package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts +7 -0
  19. package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts.map +1 -1
  20. package/dist/platform/control-plane/operator-contract-schemas-runtime.js +40 -1
  21. package/dist/platform/daemon/facade-composition.d.ts.map +1 -1
  22. package/dist/platform/daemon/facade-composition.js +1 -0
  23. package/dist/platform/daemon/homeassistant-chat.d.ts +4 -1
  24. package/dist/platform/daemon/homeassistant-chat.d.ts.map +1 -1
  25. package/dist/platform/daemon/homeassistant-chat.js +1 -1
  26. package/dist/platform/daemon/http/homeassistant-routes.d.ts.map +1 -1
  27. package/dist/platform/daemon/http/homeassistant-routes.js +28 -2
  28. package/dist/platform/integrations/webhooks.d.ts +15 -0
  29. package/dist/platform/integrations/webhooks.d.ts.map +1 -1
  30. package/dist/platform/integrations/webhooks.js +18 -0
  31. package/dist/platform/knowledge/extraction-policy.d.ts +12 -1
  32. package/dist/platform/knowledge/extraction-policy.d.ts.map +1 -1
  33. package/dist/platform/knowledge/extraction-policy.js +19 -1
  34. package/dist/platform/knowledge/graphql-schema.d.ts +1 -1
  35. package/dist/platform/knowledge/graphql-schema.d.ts.map +1 -1
  36. package/dist/platform/knowledge/graphql-schema.js +5 -0
  37. package/dist/platform/knowledge/home-graph/index.d.ts.map +1 -1
  38. package/dist/platform/knowledge/home-graph/index.js +4 -0
  39. package/dist/platform/knowledge/home-graph/link.d.ts +2 -2
  40. package/dist/platform/knowledge/home-graph/link.d.ts.map +1 -1
  41. package/dist/platform/knowledge/home-graph/link.js +60 -9
  42. package/dist/platform/knowledge/home-graph/refinement.d.ts +14 -9
  43. package/dist/platform/knowledge/home-graph/refinement.d.ts.map +1 -1
  44. package/dist/platform/knowledge/home-graph/refinement.js +18 -3
  45. package/dist/platform/knowledge/home-graph/reset.js +21 -4
  46. package/dist/platform/knowledge/home-graph/service.d.ts +10 -11
  47. package/dist/platform/knowledge/home-graph/service.d.ts.map +1 -1
  48. package/dist/platform/knowledge/home-graph/triage.d.ts +103 -0
  49. package/dist/platform/knowledge/home-graph/triage.d.ts.map +1 -0
  50. package/dist/platform/knowledge/home-graph/triage.js +362 -0
  51. package/dist/platform/knowledge/home-graph/types.d.ts +15 -0
  52. package/dist/platform/knowledge/home-graph/types.d.ts.map +1 -1
  53. package/dist/platform/knowledge/knowledge-api.d.ts +6 -0
  54. package/dist/platform/knowledge/knowledge-api.d.ts.map +1 -1
  55. package/dist/platform/knowledge/knowledge-api.js +5 -0
  56. package/dist/platform/knowledge/knowledge-history-types.d.ts +56 -0
  57. package/dist/platform/knowledge/knowledge-history-types.d.ts.map +1 -0
  58. package/dist/platform/knowledge/knowledge-history-types.js +1 -0
  59. package/dist/platform/knowledge/packet.d.ts.map +1 -1
  60. package/dist/platform/knowledge/packet.js +27 -3
  61. package/dist/platform/knowledge/scope-records.js +4 -2
  62. package/dist/platform/knowledge/semantic/answer-gaps.d.ts +8 -0
  63. package/dist/platform/knowledge/semantic/answer-gaps.d.ts.map +1 -1
  64. package/dist/platform/knowledge/semantic/answer-gaps.js +26 -6
  65. package/dist/platform/knowledge/semantic/enrichment.d.ts.map +1 -1
  66. package/dist/platform/knowledge/semantic/enrichment.js +15 -13
  67. package/dist/platform/knowledge/semantic/graph-index.d.ts.map +1 -1
  68. package/dist/platform/knowledge/semantic/graph-index.js +3 -1
  69. package/dist/platform/knowledge/semantic/service.d.ts +7 -0
  70. package/dist/platform/knowledge/semantic/service.d.ts.map +1 -1
  71. package/dist/platform/knowledge/semantic/service.js +10 -1
  72. package/dist/platform/knowledge/service-node-admin.d.ts +46 -0
  73. package/dist/platform/knowledge/service-node-admin.d.ts.map +1 -0
  74. package/dist/platform/knowledge/service-node-admin.js +72 -0
  75. package/dist/platform/knowledge/service.d.ts +24 -20
  76. package/dist/platform/knowledge/service.d.ts.map +1 -1
  77. package/dist/platform/knowledge/service.js +23 -47
  78. package/dist/platform/knowledge/store-config.d.ts +34 -0
  79. package/dist/platform/knowledge/store-config.d.ts.map +1 -1
  80. package/dist/platform/knowledge/store-config.js +23 -0
  81. package/dist/platform/knowledge/store-load.d.ts +3 -1
  82. package/dist/platform/knowledge/store-load.d.ts.map +1 -1
  83. package/dist/platform/knowledge/store-load.js +3 -1
  84. package/dist/platform/knowledge/store-node-history.d.ts +49 -0
  85. package/dist/platform/knowledge/store-node-history.d.ts.map +1 -0
  86. package/dist/platform/knowledge/store-node-history.js +331 -0
  87. package/dist/platform/knowledge/store-record-delete.d.ts +25 -0
  88. package/dist/platform/knowledge/store-record-delete.d.ts.map +1 -0
  89. package/dist/platform/knowledge/store-record-delete.js +84 -0
  90. package/dist/platform/knowledge/store-schema.d.ts +3 -1
  91. package/dist/platform/knowledge/store-schema.d.ts.map +1 -1
  92. package/dist/platform/knowledge/store-schema.js +66 -0
  93. package/dist/platform/knowledge/store.d.ts +19 -1
  94. package/dist/platform/knowledge/store.d.ts.map +1 -1
  95. package/dist/platform/knowledge/store.js +69 -108
  96. package/dist/platform/knowledge/types.d.ts +18 -0
  97. package/dist/platform/knowledge/types.d.ts.map +1 -1
  98. package/dist/platform/providers/registry.d.ts +18 -0
  99. package/dist/platform/providers/registry.d.ts.map +1 -1
  100. package/dist/platform/providers/registry.js +49 -3
  101. package/dist/platform/providers/runtime-snapshot.d.ts.map +1 -1
  102. package/dist/platform/providers/runtime-snapshot.js +14 -2
  103. package/dist/platform/runtime/memory-spine/client.d.ts +137 -12
  104. package/dist/platform/runtime/memory-spine/client.d.ts.map +1 -1
  105. package/dist/platform/runtime/memory-spine/client.js +119 -1
  106. package/dist/platform/runtime/memory-spine/index.d.ts +8 -1
  107. package/dist/platform/runtime/memory-spine/index.d.ts.map +1 -1
  108. package/dist/platform/runtime/memory-spine/index.js +7 -0
  109. package/dist/platform/runtime/memory-spine/recall-snapshot.d.ts +74 -0
  110. package/dist/platform/runtime/memory-spine/recall-snapshot.d.ts.map +1 -0
  111. package/dist/platform/runtime/memory-spine/recall-snapshot.js +87 -0
  112. package/dist/platform/runtime/memory-spine/wire-verb-availability.d.ts +59 -0
  113. package/dist/platform/runtime/memory-spine/wire-verb-availability.d.ts.map +1 -0
  114. package/dist/platform/runtime/memory-spine/wire-verb-availability.js +114 -0
  115. package/dist/platform/runtime/services.d.ts.map +1 -1
  116. package/dist/platform/runtime/services.js +3 -12
  117. package/dist/platform/state/memory-recall-contract.d.ts +7 -0
  118. package/dist/platform/state/memory-recall-contract.d.ts.map +1 -1
  119. package/dist/platform/state/memory-recall-contract.js +2 -0
  120. package/dist/platform/utils/notify.d.ts +25 -1
  121. package/dist/platform/utils/notify.d.ts.map +1 -1
  122. package/dist/platform/utils/notify.js +29 -1
  123. package/dist/platform/version.js +1 -1
  124. package/dist/platform/voice/index.d.ts +2 -0
  125. package/dist/platform/voice/index.d.ts.map +1 -1
  126. package/dist/platform/voice/index.js +3 -0
  127. package/dist/platform/voice/spoken-turn/audio-sink.d.ts +111 -0
  128. package/dist/platform/voice/spoken-turn/audio-sink.d.ts.map +1 -0
  129. package/dist/platform/voice/spoken-turn/audio-sink.js +1 -0
  130. package/dist/platform/voice/spoken-turn/controller.d.ts +117 -0
  131. package/dist/platform/voice/spoken-turn/controller.d.ts.map +1 -0
  132. package/dist/platform/voice/spoken-turn/controller.js +448 -0
  133. package/dist/platform/voice/spoken-turn/index.d.ts +16 -0
  134. package/dist/platform/voice/spoken-turn/index.d.ts.map +1 -0
  135. package/dist/platform/voice/spoken-turn/index.js +12 -0
  136. package/dist/platform/voice/spoken-turn/text-chunker.d.ts +33 -0
  137. package/dist/platform/voice/spoken-turn/text-chunker.d.ts.map +1 -0
  138. package/dist/platform/voice/spoken-turn/text-chunker.js +97 -0
  139. package/package.json +9 -9
@@ -1,5 +1,5 @@
1
1
  import type { KnowledgeStore } from '../store.js';
2
- import type { HomeGraphLinkInput, HomeGraphLinkResult } from './types.js';
2
+ import type { HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphUnlinkResult } from './types.js';
3
3
  export declare function linkHomeGraphKnowledge(store: KnowledgeStore, input: HomeGraphLinkInput & {
4
4
  readonly spaceId: string;
5
5
  readonly installationId: string;
@@ -7,5 +7,5 @@ export declare function linkHomeGraphKnowledge(store: KnowledgeStore, input: Hom
7
7
  export declare function unlinkHomeGraphKnowledge(store: KnowledgeStore, input: HomeGraphLinkInput & {
8
8
  readonly spaceId: string;
9
9
  readonly installationId: string;
10
- }): Promise<HomeGraphLinkResult>;
10
+ }): Promise<HomeGraphUnlinkResult>;
11
11
  //# sourceMappingURL=link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/platform/knowledge/home-graph/link.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,OAAO,KAAK,EAA4B,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEpG,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,kBAAkB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACxF,OAAO,CAAC,mBAAmB,CAAC,CAgB9B;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,kBAAkB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACxF,OAAO,CAAC,mBAAmB,CAAC,CAU9B"}
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/platform/knowledge/home-graph/link.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASlD,OAAO,KAAK,EAA4B,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAQ3H,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,kBAAkB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACxF,OAAO,CAAC,mBAAmB,CAAC,CAgB9B;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,kBAAkB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACxF,OAAO,CAAC,qBAAqB,CAAC,CA+BhC"}
@@ -1,4 +1,5 @@
1
1
  import { GoodVibesSdkError } from '@pellux/goodvibes-errors';
2
+ import { isActiveKnowledgeEdge } from '../projection-utils.js';
2
3
  import { belongsToSpace, buildHomeGraphMetadata, homeGraphNodeId, nodeKindForHomeGraphObject, targetToReference, } from './helpers.js';
3
4
  export async function linkHomeGraphKnowledge(store, input) {
4
5
  const from = resolveLinkSource(store, input.spaceId, input);
@@ -18,15 +19,62 @@ export async function linkHomeGraphKnowledge(store, input) {
18
19
  return { ok: true, spaceId: input.spaceId, edge, target: target.record };
19
20
  }
20
21
  export async function unlinkHomeGraphKnowledge(store, input) {
21
- const linked = await linkHomeGraphKnowledge(store, {
22
- ...input,
23
- metadata: {
24
- ...(input.metadata ?? {}),
25
- linkStatus: 'unlinked',
26
- unlinkedAt: Date.now(),
27
- },
28
- });
29
- return { ...linked, edge: linked.edge };
22
+ const from = resolveLinkSource(store, input.spaceId, input);
23
+ const target = resolveExistingHomeGraphTarget(store, input.spaceId, input.target);
24
+ const relation = input.relation ?? input.target.relation ?? 'source_for';
25
+ // Never-linked target: nothing to reverse, and we materialize no phantom records.
26
+ if (!target) {
27
+ return { ok: true, spaceId: input.spaceId, reversed: false, target: null };
28
+ }
29
+ const edge = findHomeGraphLinkEdge(store, from, target, relation);
30
+ if (!edge) {
31
+ return { ok: true, spaceId: input.spaceId, reversed: false, target: target.record };
32
+ }
33
+ await store.deleteEdge(edge.id);
34
+ let removedNodeId;
35
+ if (target.kind === 'node'
36
+ && target.record
37
+ && wasLinkCreatedNode(target.record)
38
+ && !hasOtherActiveEdges(store, target.id, edge.id)) {
39
+ await store.deleteNode(target.id);
40
+ removedNodeId = target.id;
41
+ }
42
+ return {
43
+ ok: true,
44
+ spaceId: input.spaceId,
45
+ reversed: true,
46
+ removedEdgeId: edge.id,
47
+ ...(removedNodeId ? { removedNodeId } : {}),
48
+ target: target.record,
49
+ };
50
+ }
51
+ function resolveExistingHomeGraphTarget(store, spaceId, target) {
52
+ const ref = targetToReference(target);
53
+ if (ref.kind === 'source') {
54
+ const source = store.getSource(ref.id);
55
+ return source && belongsToSpace(source, spaceId) ? { kind: 'source', id: source.id, record: source } : null;
56
+ }
57
+ const existing = store.getNode(ref.id);
58
+ if (existing && belongsToSpace(existing, spaceId))
59
+ return { kind: 'node', id: existing.id, record: existing };
60
+ const kind = ref.nodeKind ?? nodeKindForHomeGraphObject(target.kind);
61
+ const deterministic = store.getNode(homeGraphNodeId(spaceId, kind, ref.id));
62
+ return deterministic && belongsToSpace(deterministic, spaceId)
63
+ ? { kind: 'node', id: deterministic.id, record: deterministic }
64
+ : null;
65
+ }
66
+ function findHomeGraphLinkEdge(store, from, target, relation) {
67
+ return store.edgesFor(from.kind, from.id).find((edge) => (edge.fromKind === from.kind
68
+ && edge.fromId === from.id
69
+ && edge.toKind === target.kind
70
+ && edge.toId === target.id
71
+ && edge.relation === relation));
72
+ }
73
+ function wasLinkCreatedNode(node) {
74
+ return node.metadata.linkCreated === true;
75
+ }
76
+ function hasOtherActiveEdges(store, nodeId, excludeEdgeId) {
77
+ return store.edgesFor('node', nodeId).some((edge) => edge.id !== excludeEdgeId && isActiveKnowledgeEdge(edge));
30
78
  }
31
79
  function resolveLinkSource(store, spaceId, input) {
32
80
  if (input.sourceId) {
@@ -88,6 +136,9 @@ async function ensureHomeGraphLinkTarget(store, spaceId, installationId, target)
88
136
  confidence: 60,
89
137
  metadata: buildHomeGraphMetadata(spaceId, installationId, {
90
138
  homeAssistant: { installationId, objectKind: kind, objectId: target.id },
139
+ // Marks a node the link itself materialized, so unlink can cleanly remove it
140
+ // (and only it) on reversal.
141
+ linkCreated: true,
91
142
  }),
92
143
  };
93
144
  const node = await store.upsertNode(nodeInput);
@@ -1,6 +1,7 @@
1
1
  import type { KnowledgeSemanticService } from '../semantic/index.js';
2
2
  import type { KnowledgeStore } from '../store.js';
3
3
  import type { KnowledgeRefinementTaskRecord } from '../types.js';
4
+ import { type HomeGraphTriageOptions, type HomeGraphTriageResult } from './triage.js';
4
5
  import type { HomeGraphSpaceInput } from './types.js';
5
6
  export declare function listHomeGraphRefinementTasks(input: HomeGraphSpaceInput & {
6
7
  readonly store: KnowledgeStore;
@@ -29,16 +30,20 @@ export declare function runHomeGraphRefinement(input: HomeGraphSpaceInput & {
29
30
  readonly limit?: number | undefined;
30
31
  readonly maxRunMs?: number | undefined;
31
32
  readonly force?: boolean | undefined;
33
+ /**
34
+ * Run the LLM issue-triage pass over open device-quality issues. `true` uses
35
+ * defaults; an object customizes thresholds/limits/rules. Omitted → unchanged
36
+ * gap-refinement behavior for existing callers.
37
+ */
38
+ readonly triage?: HomeGraphTriageOptions | boolean | undefined;
39
+ /** Skip the gap self-improvement pass (e.g. a triage-only run). */
40
+ readonly skipGapRefinement?: boolean | undefined;
32
41
  }): Promise<{
33
- ok: boolean;
34
- spaceId: string;
35
- error: string;
36
- result?: never;
37
- } | {
38
- ok: boolean;
39
- spaceId: string;
40
- result: import("../semantic/types.js").KnowledgeSemanticSelfImproveResult;
41
- error?: never;
42
+ readonly ok: boolean;
43
+ readonly spaceId: string;
44
+ readonly error?: string | undefined;
45
+ readonly result?: Awaited<ReturnType<KnowledgeSemanticService['selfImprove']>> | undefined;
46
+ readonly triage?: HomeGraphTriageResult | undefined;
42
47
  }>;
43
48
  export declare function cancelHomeGraphRefinementTask(input: HomeGraphSpaceInput & {
44
49
  readonly store: KnowledgeStore;
@@ -1 +1 @@
1
- {"version":3,"file":"refinement.d.ts","sourceRoot":"","sources":["../../../../src/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,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AC,CAgCD;AAED,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,mBAAmB,GAAG;IAC/E,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;;;;;;;;;;GAuBA"}
@@ -1,4 +1,5 @@
1
1
  import { resolveReadableHomeGraphSpace } from './space-selection.js';
2
+ import { runHomeGraphIssueTriage, } from './triage.js';
2
3
  export async function listHomeGraphRefinementTasks(input) {
3
4
  await input.store.init();
4
5
  const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
@@ -23,8 +24,22 @@ export async function getHomeGraphRefinementTask(input) {
23
24
  export async function runHomeGraphRefinement(input) {
24
25
  await input.store.init();
25
26
  const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
26
- if (!input.semanticService)
27
- return { ok: false, spaceId, error: 'Semantic refinement is not configured.' };
27
+ const triageRequested = input.triage !== undefined && input.triage !== false;
28
+ const triage = triageRequested
29
+ ? await runHomeGraphIssueTriage({
30
+ store: input.store,
31
+ ...(input.semanticService ? { semanticService: input.semanticService } : {}),
32
+ ...(input.installationId ? { installationId: input.installationId } : {}),
33
+ ...(input.knowledgeSpaceId ? { knowledgeSpaceId: input.knowledgeSpaceId } : {}),
34
+ options: typeof input.triage === 'object' ? input.triage : {},
35
+ })
36
+ : undefined;
37
+ if (input.skipGapRefinement === true) {
38
+ return { ok: true, spaceId, ...(triage ? { triage } : {}) };
39
+ }
40
+ if (!input.semanticService) {
41
+ return { ok: false, spaceId, error: 'Semantic refinement is not configured.', ...(triage ? { triage } : {}) };
42
+ }
28
43
  const result = await input.semanticService.selfImprove({
29
44
  knowledgeSpaceId: spaceId,
30
45
  gapIds: input.gapIds,
@@ -34,7 +49,7 @@ export async function runHomeGraphRefinement(input) {
34
49
  force: input.force,
35
50
  reason: 'manual',
36
51
  });
37
- return { ok: true, spaceId, result };
52
+ return { ok: true, spaceId, result, ...(triage ? { triage } : {}) };
38
53
  }
39
54
  export async function cancelHomeGraphRefinementTask(input) {
40
55
  await input.store.init();
@@ -1,4 +1,4 @@
1
- import { getKnowledgeSpaceId, normalizeKnowledgeSpaceId } from '../spaces.js';
1
+ import { getExplicitKnowledgeSpaceId, getKnowledgeSpaceId, normalizeKnowledgeSpaceId } from '../spaces.js';
2
2
  import { resolveReadableHomeGraphSpace } from './space-selection.js';
3
3
  export async function resetHomeGraphSpace(store, artifactStore, input) {
4
4
  await store.init();
@@ -26,12 +26,29 @@ export async function resetHomeGraphSpace(store, artifactStore, input) {
26
26
  function collectKnowledgeSpaceArtifactIds(store, artifactStore, spaceId) {
27
27
  const normalized = normalizeKnowledgeSpaceId(spaceId);
28
28
  const ids = new Set();
29
+ // Scope-checked deletion (HAZARD H1): the ArtifactStore is shared across the
30
+ // wiki / home-graph / agent families. A blob that a *different* family owns —
31
+ // identifiable by its own explicit knowledge-space stamp — must never be deleted
32
+ // by a home-graph reset, even if a home-graph source references it, because that
33
+ // would orphan the other family's reference. We err toward preserving: an
34
+ // artifact is a delete candidate only when it is not explicitly owned by another
35
+ // space.
36
+ const ownedByOtherSpace = (artifactId) => {
37
+ const descriptor = artifactStore.get(artifactId);
38
+ if (!descriptor)
39
+ return false;
40
+ const artifactSpace = getExplicitKnowledgeSpaceId({ metadata: descriptor.metadata });
41
+ return artifactSpace !== undefined && artifactSpace !== normalized;
42
+ };
29
43
  for (const source of store.listSources(100_000)) {
30
44
  if (getKnowledgeSpaceId(source) !== normalized)
31
45
  continue;
32
- if (typeof source.artifactId === 'string' && source.artifactId.trim().length > 0) {
33
- ids.add(source.artifactId.trim());
34
- }
46
+ const artifactId = typeof source.artifactId === 'string' ? source.artifactId.trim() : '';
47
+ if (artifactId.length === 0)
48
+ continue;
49
+ if (ownedByOtherSpace(artifactId))
50
+ continue;
51
+ ids.add(artifactId);
35
52
  }
36
53
  for (const artifact of artifactStore.list(100_000)) {
37
54
  if (getKnowledgeSpaceId({ metadata: artifact.metadata }) === normalized)
@@ -3,7 +3,8 @@ 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
5
  import type { KnowledgeSemanticService } from '../semantic/index.js';
6
- import type { HomeGraphAskInput, HomeGraphAskResult, HomeGraphDevicePassportResult, HomeGraphExport, HomeGraphIngestArtifactInput, HomeGraphIngestNoteInput, HomeGraphIngestResult, HomeGraphIngestUrlInput, HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphMapInput, HomeGraphMapResult, HomeGraphProjectionInput, HomeGraphProjectionResult, HomeGraphPageListResult, HomeGraphReindexInput, HomeGraphReindexResult, HomeGraphResetInput, HomeGraphResetResult, HomeGraphReviewInput, HomeGraphSpaceInput, HomeGraphSnapshotInput, HomeGraphStatus, HomeGraphSyncResult } from './types.js';
6
+ import type { HomeGraphTriageOptions } from './triage.js';
7
+ import type { HomeGraphAskInput, HomeGraphAskResult, HomeGraphDevicePassportResult, HomeGraphExport, HomeGraphIngestArtifactInput, HomeGraphIngestNoteInput, HomeGraphIngestResult, HomeGraphIngestUrlInput, HomeGraphLinkInput, HomeGraphLinkResult, HomeGraphUnlinkResult, HomeGraphMapInput, HomeGraphMapResult, HomeGraphProjectionInput, HomeGraphProjectionResult, HomeGraphPageListResult, HomeGraphReindexInput, HomeGraphReindexResult, HomeGraphResetInput, HomeGraphResetResult, HomeGraphReviewInput, HomeGraphSpaceInput, HomeGraphSnapshotInput, HomeGraphStatus, HomeGraphSyncResult } from './types.js';
7
8
  export declare class HomeGraphService {
8
9
  private readonly store;
9
10
  private readonly artifactStore;
@@ -24,7 +25,7 @@ export declare class HomeGraphService {
24
25
  ingestNote(input: HomeGraphIngestNoteInput): Promise<HomeGraphIngestResult>;
25
26
  ingestArtifact(input: HomeGraphIngestArtifactInput): Promise<HomeGraphIngestResult>;
26
27
  linkKnowledge(input: HomeGraphLinkInput): Promise<HomeGraphLinkResult>;
27
- unlinkKnowledge(input: HomeGraphLinkInput): Promise<HomeGraphLinkResult>;
28
+ unlinkKnowledge(input: HomeGraphLinkInput): Promise<HomeGraphUnlinkResult>;
28
29
  ask(input: HomeGraphAskInput): Promise<HomeGraphAskResult>;
29
30
  reindex(input?: HomeGraphReindexInput): Promise<HomeGraphReindexResult>;
30
31
  private repairStaleExtractionsForAsk;
@@ -76,16 +77,14 @@ export declare class HomeGraphService {
76
77
  readonly limit?: number | undefined;
77
78
  readonly maxRunMs?: number | undefined;
78
79
  readonly force?: boolean | undefined;
80
+ readonly triage?: HomeGraphTriageOptions | boolean | undefined;
81
+ readonly skipGapRefinement?: boolean | undefined;
79
82
  }): Promise<{
80
- ok: boolean;
81
- spaceId: string;
82
- error: string;
83
- result?: never;
84
- } | {
85
- ok: boolean;
86
- spaceId: string;
87
- result: import("../semantic/types.js").KnowledgeSemanticSelfImproveResult;
88
- error?: never;
83
+ readonly ok: boolean;
84
+ readonly spaceId: string;
85
+ readonly error?: string | undefined;
86
+ readonly result?: Awaited<ReturnType<KnowledgeSemanticService["selfImprove"]>> | undefined;
87
+ readonly triage?: import("./triage.js").HomeGraphTriageResult | undefined;
89
88
  }>;
90
89
  cancelRefinementTask(input: HomeGraphSpaceInput & {
91
90
  readonly taskId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/platform/knowledge/home-graph/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EAEnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EAEtB,MAAM,aAAa,CAAC;AAWrB,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAO9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAwCrE,O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E,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI/D,WAAW,CAAC,KAAK,GAAE,mBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IAMtE,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC;QAC1F,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;QAClB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,EAAE;YAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KACxJ,CAAC;IAMI,UAAU,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAS7D,qBAAqB;YAyDrB,eAAe;YAaf,uBAAuB;YAQvB,oBAAoB;IAIlC;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAkBnC,uFAAuF;IACvF,OAAO,CAAC,yBAAyB;IAWjC;;;OAGG;YACW,0BAA0B;YAK1B,kBAAkB;YAKlB,sBAAsB;IAKpC,OAAO,CAAC,6BAA6B;IAgBrC,OAAO,CAAC,qBAAqB;CAS9B"}
@@ -0,0 +1,103 @@
1
+ import type { KnowledgeStore } from '../store.js';
2
+ import type { KnowledgeSemanticService } from '../semantic/index.js';
3
+ import type { HomeGraphSpaceInput } from './types.js';
4
+ /**
5
+ * Default auto-apply threshold for LLM triage decisions, expressed on the SDK's
6
+ * 0-100 confidence scale. This mirrors the Home Assistant Python triage engine's
7
+ * `0.85` gate and reuses the same "trust above a threshold" idiom as the semantic
8
+ * gap-repair `minConfidence` precedent (`knowledge/semantic/gap-repair.ts`).
9
+ */
10
+ export declare const HOME_GRAPH_TRIAGE_DEFAULT_MIN_CONFIDENCE = 85;
11
+ /** Issues sent to the model per completion call. */
12
+ export declare const HOME_GRAPH_TRIAGE_DEFAULT_CHUNK_SIZE = 25;
13
+ /** Untriaged open issues examined in a single run by default. */
14
+ export declare const HOME_GRAPH_TRIAGE_DEFAULT_LIMIT = 25;
15
+ /**
16
+ * One entry in the extensible issue-code → applicability-rule framework. Adding a
17
+ * rule for a new `homegraph.*` issue code makes that code eligible for LLM triage
18
+ * without touching the loop itself. This replaces the two hardcoded codes the
19
+ * heuristic layer knows about.
20
+ */
21
+ export interface HomeGraphTriageRule {
22
+ /** The issue code this rule governs, e.g. `homegraph.device.unknown_battery`. */
23
+ readonly code: string;
24
+ /** Extra model guidance appended to the triage instruction for this code. */
25
+ readonly promptGuidance?: string | undefined;
26
+ /** Review category recorded when the model omits one for a reject. */
27
+ readonly defaultCategory?: string | undefined;
28
+ }
29
+ /**
30
+ * The built-in rules. These reproduce the applicability judgment the Python triage
31
+ * prompt asked for, for exactly the two codes `quality.ts` raises today. The
32
+ * `deriveIssueFacts` mapping in `review.ts` supplies the code-specific facts when a
33
+ * reject is applied, so rules only carry the prompt guidance and default category.
34
+ */
35
+ export declare const DEFAULT_HOME_GRAPH_TRIAGE_RULES: readonly HomeGraphTriageRule[];
36
+ export interface HomeGraphTriageOptions {
37
+ /** Auto-apply threshold on the 0-100 scale. Default 85. */
38
+ readonly minConfidence?: number | undefined;
39
+ /** Max untriaged open issues to examine this run. Default 25. */
40
+ readonly limit?: number | undefined;
41
+ /** Issues per model completion. Default 25. */
42
+ readonly chunkSize?: number | undefined;
43
+ /** Re-triage even issues whose cached fingerprint is unchanged. */
44
+ readonly force?: boolean | undefined;
45
+ /** Issue ids to leave untouched this run. */
46
+ readonly skipIssueIds?: readonly string[] | undefined;
47
+ /** Restrict triage to this subset of issue codes (must still have a rule). */
48
+ readonly issueCodes?: readonly string[] | undefined;
49
+ /** Extra rules merged over the built-ins (by code) — the extensibility hook. */
50
+ readonly additionalRules?: readonly HomeGraphTriageRule[] | undefined;
51
+ /** Per-completion model timeout in ms. */
52
+ readonly timeoutMs?: number | undefined;
53
+ /** Reviewer label recorded on applied decisions. */
54
+ readonly reviewer?: string | undefined;
55
+ }
56
+ export interface HomeGraphTriageDecision {
57
+ readonly issueId: string;
58
+ readonly code: string;
59
+ readonly action: 'reject' | 'review';
60
+ readonly category?: string | undefined;
61
+ readonly confidence: number;
62
+ readonly reason?: string | undefined;
63
+ /** True when the decision cleared the threshold and was auto-applied. */
64
+ readonly applied: boolean;
65
+ /** Facts written to the device node when applied. */
66
+ readonly appliedFacts?: Record<string, unknown> | undefined;
67
+ /** Provenance tag — always `homegraph-triage`. */
68
+ readonly source: string;
69
+ }
70
+ export interface HomeGraphTriageResult {
71
+ readonly ok: true;
72
+ readonly spaceId: string;
73
+ /** False when no semantic LLM is configured — the loop is a no-op. */
74
+ readonly configured: boolean;
75
+ readonly processed: number;
76
+ /** Open triageable issues skipped because their cached fingerprint was unchanged. */
77
+ readonly skipped: number;
78
+ readonly applied: number;
79
+ readonly reviewed: number;
80
+ readonly decisions: readonly HomeGraphTriageDecision[];
81
+ /** Open triageable issues still unresolved after this run. */
82
+ readonly remaining: number;
83
+ readonly minConfidence: number;
84
+ readonly reason?: string | undefined;
85
+ }
86
+ /**
87
+ * LLM-driven triage over open Home Graph device-quality issues. Operates strictly
88
+ * on the resolved Home Assistant knowledge space: it reads that space's issues and
89
+ * nodes, prompts the configured semantic LLM to classify each open issue as
90
+ * `reject` (safe to auto-dismiss) or `review` (needs a human), auto-applies rejects
91
+ * at or above the confidence threshold via {@link reviewHomeGraphFact}, and caches
92
+ * every decision on the issue so an unchanged issue is never re-sent to the model.
93
+ *
94
+ * This never reads or writes any other knowledge space — Home Graph shares this
95
+ * code with the wiki/agent knowledge functions but never their data.
96
+ */
97
+ export declare function runHomeGraphIssueTriage(input: HomeGraphSpaceInput & {
98
+ readonly store: KnowledgeStore;
99
+ readonly semanticService?: KnowledgeSemanticService | undefined;
100
+ readonly options?: HomeGraphTriageOptions | undefined;
101
+ readonly signal?: AbortSignal | undefined;
102
+ }): Promise<HomeGraphTriageResult>;
103
+ //# sourceMappingURL=triage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triage.d.ts","sourceRoot":"","sources":["../../../../src/platform/knowledge/home-graph/triage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,wCAAwC,KAAK,CAAC;AAC3D,oDAAoD;AACpD,eAAO,MAAM,oCAAoC,KAAK,CAAC;AACvD,iEAAiE;AACjE,eAAO,MAAM,+BAA+B,KAAK,CAAC;AASlD;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,sEAAsE;IACtE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C;AAED;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,EAAE,SAAS,mBAAmB,EAsBzE,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,iEAAiE;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,mEAAmE;IACnE,QAAQ,CAAC,KAAK,CAAC,E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