pilotswarm-sdk 0.2.0 → 0.2.2

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 (173) hide show
  1. package/dist/agent-loader.d.ts +9 -0
  2. package/dist/agent-loader.d.ts.map +1 -1
  3. package/dist/agent-loader.js +3 -0
  4. package/dist/agent-loader.js.map +1 -1
  5. package/dist/child-notifications.d.ts +10 -0
  6. package/dist/child-notifications.d.ts.map +1 -1
  7. package/dist/child-notifications.js +15 -1
  8. package/dist/child-notifications.js.map +1 -1
  9. package/dist/client.d.ts +2 -2
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +14 -20
  12. package/dist/client.js.map +1 -1
  13. package/dist/cms-migrations.d.ts.map +1 -1
  14. package/dist/cms-migrations.js +321 -0
  15. package/dist/cms-migrations.js.map +1 -1
  16. package/dist/cms.d.ts +132 -8
  17. package/dist/cms.d.ts.map +1 -1
  18. package/dist/cms.js +142 -6
  19. package/dist/cms.js.map +1 -1
  20. package/dist/duroxide-schema-migration.d.ts +19 -0
  21. package/dist/duroxide-schema-migration.d.ts.map +1 -0
  22. package/dist/duroxide-schema-migration.js +122 -0
  23. package/dist/duroxide-schema-migration.js.map +1 -0
  24. package/dist/facts-migrations.d.ts.map +1 -1
  25. package/dist/facts-migrations.js +923 -0
  26. package/dist/facts-migrations.js.map +1 -1
  27. package/dist/facts-store.d.ts +278 -28
  28. package/dist/facts-store.d.ts.map +1 -1
  29. package/dist/facts-store.js +262 -32
  30. package/dist/facts-store.js.map +1 -1
  31. package/dist/facts-tools.d.ts +8 -1
  32. package/dist/facts-tools.d.ts.map +1 -1
  33. package/dist/facts-tools.js +458 -25
  34. package/dist/facts-tools.js.map +1 -1
  35. package/dist/graph-store.d.ts +243 -0
  36. package/dist/graph-store.d.ts.map +1 -0
  37. package/dist/graph-store.js +63 -0
  38. package/dist/graph-store.js.map +1 -0
  39. package/dist/graph-tools.d.ts +47 -0
  40. package/dist/graph-tools.d.ts.map +1 -0
  41. package/dist/graph-tools.js +554 -0
  42. package/dist/graph-tools.js.map +1 -0
  43. package/dist/horizon-env.d.ts +61 -0
  44. package/dist/horizon-env.d.ts.map +1 -0
  45. package/dist/horizon-env.js +120 -0
  46. package/dist/horizon-env.js.map +1 -0
  47. package/dist/index.d.ts +15 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +10 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/inspect-tools.d.ts +2 -2
  52. package/dist/inspect-tools.d.ts.map +1 -1
  53. package/dist/inspect-tools.js +303 -6
  54. package/dist/inspect-tools.js.map +1 -1
  55. package/dist/knowledge-index.d.ts +33 -2
  56. package/dist/knowledge-index.d.ts.map +1 -1
  57. package/dist/knowledge-index.js +90 -19
  58. package/dist/knowledge-index.js.map +1 -1
  59. package/dist/managed-session.d.ts.map +1 -1
  60. package/dist/managed-session.js +61 -2
  61. package/dist/managed-session.js.map +1 -1
  62. package/dist/management-client.d.ts +81 -3
  63. package/dist/management-client.d.ts.map +1 -1
  64. package/dist/management-client.js +97 -20
  65. package/dist/management-client.js.map +1 -1
  66. package/dist/orchestration/agents.d.ts +4 -1
  67. package/dist/orchestration/agents.d.ts.map +1 -1
  68. package/dist/orchestration/agents.js +27 -4
  69. package/dist/orchestration/agents.js.map +1 -1
  70. package/dist/orchestration/index.d.ts +2 -2
  71. package/dist/orchestration/index.js +1 -1
  72. package/dist/orchestration/lifecycle.d.ts +3 -0
  73. package/dist/orchestration/lifecycle.d.ts.map +1 -1
  74. package/dist/orchestration/lifecycle.js +6 -1
  75. package/dist/orchestration/lifecycle.js.map +1 -1
  76. package/dist/orchestration/queue.d.ts.map +1 -1
  77. package/dist/orchestration/queue.js +10 -1
  78. package/dist/orchestration/queue.js.map +1 -1
  79. package/dist/orchestration/runtime.d.ts +1 -1
  80. package/dist/orchestration/state.d.ts +1 -0
  81. package/dist/orchestration/state.d.ts.map +1 -1
  82. package/dist/orchestration/state.js +1 -0
  83. package/dist/orchestration/state.js.map +1 -1
  84. package/dist/orchestration/turn.d.ts +2 -2
  85. package/dist/orchestration/turn.d.ts.map +1 -1
  86. package/dist/orchestration/turn.js +42 -12
  87. package/dist/orchestration/turn.js.map +1 -1
  88. package/dist/orchestration-registry.d.ts.map +1 -1
  89. package/dist/orchestration-registry.js +4 -2
  90. package/dist/orchestration-registry.js.map +1 -1
  91. package/dist/orchestration-version.d.ts +1 -1
  92. package/dist/orchestration-version.js +1 -1
  93. package/dist/orchestration.d.ts +2 -2
  94. package/dist/orchestration.js +1 -1
  95. package/dist/orchestration_1_0_46.d.ts +1 -1
  96. package/dist/orchestration_1_0_47.d.ts +1 -1
  97. package/dist/orchestration_1_0_48.d.ts +1 -1
  98. package/dist/orchestration_1_0_49.d.ts +1 -1
  99. package/dist/orchestration_1_0_50.d.ts +1 -1
  100. package/dist/orchestration_1_0_52/agents.d.ts +38 -0
  101. package/dist/orchestration_1_0_52/agents.d.ts.map +1 -0
  102. package/dist/orchestration_1_0_52/agents.js +735 -0
  103. package/dist/orchestration_1_0_52/agents.js.map +1 -0
  104. package/dist/orchestration_1_0_52/index.d.ts +24 -0
  105. package/dist/orchestration_1_0_52/index.d.ts.map +1 -0
  106. package/dist/orchestration_1_0_52/index.js +13 -0
  107. package/dist/orchestration_1_0_52/index.js.map +1 -0
  108. package/dist/orchestration_1_0_52/lifecycle.d.ts +38 -0
  109. package/dist/orchestration_1_0_52/lifecycle.d.ts.map +1 -0
  110. package/dist/orchestration_1_0_52/lifecycle.js +504 -0
  111. package/dist/orchestration_1_0_52/lifecycle.js.map +1 -0
  112. package/dist/orchestration_1_0_52/queue.d.ts +7 -0
  113. package/dist/orchestration_1_0_52/queue.d.ts.map +1 -0
  114. package/dist/orchestration_1_0_52/queue.js +635 -0
  115. package/dist/orchestration_1_0_52/queue.js.map +1 -0
  116. package/dist/orchestration_1_0_52/runtime.d.ts +29 -0
  117. package/dist/orchestration_1_0_52/runtime.d.ts.map +1 -0
  118. package/dist/orchestration_1_0_52/runtime.js +190 -0
  119. package/dist/orchestration_1_0_52/runtime.js.map +1 -0
  120. package/dist/orchestration_1_0_52/state.d.ts +124 -0
  121. package/dist/orchestration_1_0_52/state.d.ts.map +1 -0
  122. package/dist/orchestration_1_0_52/state.js +104 -0
  123. package/dist/orchestration_1_0_52/state.js.map +1 -0
  124. package/dist/orchestration_1_0_52/turn.d.ts +6 -0
  125. package/dist/orchestration_1_0_52/turn.d.ts.map +1 -0
  126. package/dist/orchestration_1_0_52/turn.js +834 -0
  127. package/dist/orchestration_1_0_52/turn.js.map +1 -0
  128. package/dist/orchestration_1_0_52/utils.d.ts +22 -0
  129. package/dist/orchestration_1_0_52/utils.d.ts.map +1 -0
  130. package/dist/orchestration_1_0_52/utils.js +226 -0
  131. package/dist/orchestration_1_0_52/utils.js.map +1 -0
  132. package/dist/resourcemgr-tools.d.ts +2 -2
  133. package/dist/resourcemgr-tools.d.ts.map +1 -1
  134. package/dist/resourcemgr-tools.js +1 -1
  135. package/dist/resourcemgr-tools.js.map +1 -1
  136. package/dist/session-dumper.d.ts +2 -2
  137. package/dist/session-dumper.d.ts.map +1 -1
  138. package/dist/session-dumper.js.map +1 -1
  139. package/dist/session-manager.d.ts +8 -2
  140. package/dist/session-manager.d.ts.map +1 -1
  141. package/dist/session-manager.js +86 -4
  142. package/dist/session-manager.js.map +1 -1
  143. package/dist/session-messages.d.ts +2 -2
  144. package/dist/session-messages.d.ts.map +1 -1
  145. package/dist/session-messages.js +0 -6
  146. package/dist/session-messages.js.map +1 -1
  147. package/dist/session-proxy.d.ts +47 -2
  148. package/dist/session-proxy.d.ts.map +1 -1
  149. package/dist/session-proxy.js +79 -59
  150. package/dist/session-proxy.js.map +1 -1
  151. package/dist/storage-config.d.ts +62 -0
  152. package/dist/storage-config.d.ts.map +1 -0
  153. package/dist/storage-config.js +138 -0
  154. package/dist/storage-config.js.map +1 -0
  155. package/dist/storage-providers.d.ts +25 -0
  156. package/dist/storage-providers.d.ts.map +1 -0
  157. package/dist/storage-providers.js +150 -0
  158. package/dist/storage-providers.js.map +1 -0
  159. package/dist/sweeper-tools.d.ts +2 -2
  160. package/dist/sweeper-tools.d.ts.map +1 -1
  161. package/dist/system-agents.d.ts +2 -2
  162. package/dist/system-agents.d.ts.map +1 -1
  163. package/dist/types.d.ts +103 -2
  164. package/dist/types.d.ts.map +1 -1
  165. package/dist/types.js.map +1 -1
  166. package/dist/worker.d.ts +5 -4
  167. package/dist/worker.d.ts.map +1 -1
  168. package/dist/worker.js +108 -33
  169. package/dist/worker.js.map +1 -1
  170. package/package.json +3 -1
  171. package/plugins/mgmt/agents/agent-tuner.agent.md +56 -4
  172. package/plugins/mgmt/agents/facts-manager.agent.md +81 -3
  173. package/plugins/mgmt/skills/graph-debug/SKILL.md +133 -0
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Graph Store — the OPTIONAL open knowledge graph contract (enhancedfactstore
3
+ * 07 D2).
4
+ *
5
+ * The graph is a SEPARATE, independently injected interface — NOT part of
6
+ * `EnhancedFactStore` and NOT a capability on the fact store. The SDK owns this
7
+ * contract; a concrete provider (e.g. pilotswarm-horizon-store's
8
+ * `HorizonDBGraphStore`, AGE-backed) implements it. The runtime registers graph
9
+ * tools iff a `graphStore` was injected (`!!graphStore`) — there is no
10
+ * fact-store sniff.
11
+ *
12
+ * The graph stores ids + structure only (never fact values or ACLs). Evidence
13
+ * scope_keys are opaque pointers; resolving them back to fact values is the
14
+ * caller's tool-layer composition:
15
+ * graphStore.searchGraphNodes(...) -> scopeKeys -> factStore.readFacts({ scopeKeys })
16
+ *
17
+ * @module
18
+ */
19
+ import type { AccessContext } from "./facts-store.js";
20
+ /**
21
+ * Reserved namespace token for the unscoped graph partition. Graph records with
22
+ * no namespace property (NULL) are the `default` partition: writes of `default`
23
+ * (or empty) store no namespace, and reads of `default` match `namespace IS
24
+ * NULL`. `default` is always present in the registry and cannot be archived or
25
+ * deleted (graph-fact-search enhancements).
26
+ */
27
+ export declare const DEFAULT_GRAPH_NAMESPACE = "default";
28
+ export interface GraphNodeInput {
29
+ kind: string;
30
+ name: string;
31
+ /** Optional corpus/domain namespace. Prefix semantics match facts_search:
32
+ * "corpus/acme" includes "corpus/acme" and "corpus/acme/...". */
33
+ namespace?: string;
34
+ aliases?: string[];
35
+ evidence?: string[];
36
+ agentId: string;
37
+ }
38
+ export interface GraphEdgeInput {
39
+ fromKey: string;
40
+ toKey: string;
41
+ predicate: string;
42
+ /** Optional corpus/domain namespace for this assertion/edge. */
43
+ namespace?: string;
44
+ confidence?: number;
45
+ evidence?: string[];
46
+ agentId: string;
47
+ model?: string;
48
+ }
49
+ export interface GraphNodeQuery {
50
+ kind?: string;
51
+ nameLike?: string;
52
+ /** Optional corpus/domain namespace filter. Matches exact namespace OR any
53
+ * descendant (`namespace` + "/..."). */
54
+ namespace?: string;
55
+ /** Fact scopeKeys OR node keys anchoring the query. Fact seeds pivot via
56
+ * EVIDENCED_BY (inaccessible fact seeds are IGNORED — treated unknown);
57
+ * node seeds expand directly. */
58
+ seeds?: string[];
59
+ depth?: number;
60
+ minConfidence?: number;
61
+ limit?: number;
62
+ }
63
+ export interface GraphEdgeQuery {
64
+ predicate?: string;
65
+ predicateKey?: string;
66
+ fromKey?: string;
67
+ toKey?: string;
68
+ /** Optional corpus/domain namespace filter. An edge matches when the edge
69
+ * itself OR either endpoint is in the namespace subtree. */
70
+ namespace?: string;
71
+ minConfidence?: number;
72
+ limit?: number;
73
+ }
74
+ export interface GraphNamespaceQuery {
75
+ namespace?: string;
76
+ }
77
+ export interface GraphNodeRef {
78
+ nodeKey: string;
79
+ kind: string;
80
+ name: string;
81
+ namespace?: string;
82
+ aliases: string[];
83
+ created: boolean;
84
+ }
85
+ export interface GraphNodeHit {
86
+ nodeKey: string;
87
+ kind: string;
88
+ name: string;
89
+ namespace?: string;
90
+ aliases: string[];
91
+ /** EVIDENCED_BY fact scopeKeys, FILTERED to caller-accessible keys. */
92
+ evidence: string[];
93
+ score?: number;
94
+ }
95
+ export interface GraphEdgeRef {
96
+ fromKey: string;
97
+ toKey: string;
98
+ predicate: string;
99
+ predicateKey: string;
100
+ namespace?: string;
101
+ confidence: number;
102
+ observations: number;
103
+ reinforced: boolean;
104
+ }
105
+ export interface GraphEvidenceRemovalResult {
106
+ scopeKey: string;
107
+ nodeEvidenceRemoved: number;
108
+ edgeEvidenceRemoved: number;
109
+ nodesDeleted: number;
110
+ edgesDeleted: number;
111
+ }
112
+ export interface GraphEdgeHit {
113
+ fromKey: string;
114
+ toKey: string;
115
+ predicate: string;
116
+ predicateKey: string;
117
+ namespace?: string;
118
+ confidence: number;
119
+ observations: number;
120
+ /** ACL-filtered, as on GraphNodeHit. */
121
+ evidence: string[];
122
+ }
123
+ export interface SubGraph {
124
+ nodes: {
125
+ nodeKey: string;
126
+ kind: string;
127
+ name: string;
128
+ namespace?: string;
129
+ }[];
130
+ edges: {
131
+ fromKey: string;
132
+ toKey: string;
133
+ predicate: string;
134
+ namespace?: string;
135
+ confidence: number;
136
+ }[];
137
+ }
138
+ /**
139
+ * Minimal, skill-file-style discovery frontmatter for a graph namespace. Kept
140
+ * deliberately small: a short name and a `description` that lets an LLM decide
141
+ * whether the corpus is relevant before loading details or searching the graph.
142
+ */
143
+ export interface GraphNamespaceFrontmatter {
144
+ /** Short label. Defaults to the namespace when omitted. */
145
+ name?: string;
146
+ /** When to use this corpus — the discovery hint a reader agent reads. */
147
+ description: string;
148
+ }
149
+ /** A registered graph namespace (corpus) descriptor. */
150
+ export interface GraphNamespaceInfo {
151
+ namespace: string;
152
+ archived: boolean;
153
+ frontmatter: GraphNamespaceFrontmatter;
154
+ source?: string;
155
+ nodeSchema?: unknown;
156
+ edgeSchema?: unknown;
157
+ harvestConfig?: unknown;
158
+ createdAt?: string;
159
+ updatedAt?: string;
160
+ }
161
+ /** Upsert input for a namespace registry row (graph-owned, relational). */
162
+ export interface GraphNamespaceInput {
163
+ namespace: string;
164
+ frontmatter: GraphNamespaceFrontmatter;
165
+ source?: string;
166
+ nodeSchema?: unknown;
167
+ edgeSchema?: unknown;
168
+ harvestConfig?: unknown;
169
+ /** Upsert may clear `archived` back to false; defaults to false on create. */
170
+ archived?: boolean;
171
+ }
172
+ export interface GraphNamespaceListQuery {
173
+ /** String-prefix filter over registry namespace keys (not an AGE subtree). */
174
+ prefix?: string;
175
+ /** Include archived rows. Default false. */
176
+ includeArchived?: boolean;
177
+ /** Include detail fields (source/schemas/harvestConfig). Default false. */
178
+ includeDetails?: boolean;
179
+ }
180
+ /** Result of a destructive namespace delete. */
181
+ export interface GraphNamespaceDeleteResult {
182
+ deleted: boolean;
183
+ nodesDeleted: number;
184
+ edgesDeleted: number;
185
+ }
186
+ export interface GraphStore {
187
+ initialize(): Promise<void>;
188
+ close(): Promise<void>;
189
+ searchGraphNodes(q: GraphNodeQuery, access?: AccessContext): Promise<GraphNodeHit[]>;
190
+ searchGraphEdges(q: GraphEdgeQuery, access?: AccessContext): Promise<GraphEdgeHit[]>;
191
+ graphNeighbourhood(nodeKey: string, depth: number, access?: AccessContext, opts?: GraphNamespaceQuery): Promise<SubGraph>;
192
+ /** Optional provider-owned predicate normalizer for metrics/tooling. */
193
+ normalizePredicateKey?(predicate: string): string;
194
+ upsertGraphNode(n: GraphNodeInput): Promise<GraphNodeRef>;
195
+ upsertGraphEdge(e: GraphEdgeInput): Promise<GraphEdgeRef>;
196
+ mergeGraphNodes(fromKey: string, intoKey: string, reason: string, opts?: GraphNamespaceQuery): Promise<void>;
197
+ deleteGraphNode(nodeKey: string, opts?: GraphNamespaceQuery): Promise<boolean>;
198
+ deleteGraphEdge(fromKey: string, toKey: string, predicateKey: string, opts?: GraphNamespaceQuery): Promise<boolean>;
199
+ /** Remove a deleted fact's scopeKey from graph evidence, deleting graph
200
+ * edges and nodes that become evidence-less as a result. */
201
+ removeGraphEvidence(scopeKey: string, opts?: GraphNamespaceQuery): Promise<GraphEvidenceRemovalResult>;
202
+ /**
203
+ * OPTIONAL cheap aggregate for `graph_stats` (enhancedfactstore 07 P4):
204
+ * total node + edge counts via a single store-side query (e.g. an AGE
205
+ * `MATCH (n) RETURN count(n)` / `MATCH ()-[r]->() RETURN count(r)`), NOT a
206
+ * client-side fan-out traversal. When a provider does not implement this,
207
+ * the graph_stats tool falls back to a bounded node sample and omits the
208
+ * exact edge count. `uncrawledFacts` is optional here — the tool reads the
209
+ * crawl backlog from the base FactStore when the provider omits it.
210
+ */
211
+ graphStats?(opts?: GraphNamespaceQuery): Promise<{
212
+ nodeCount: number;
213
+ edgeCount: number;
214
+ uncrawledFacts?: number;
215
+ }>;
216
+ /** List registered namespaces. Compact by default (namespace, archived,
217
+ * frontmatter); detail fields only with `includeDetails`. Excludes archived
218
+ * rows unless `includeArchived`. No pagination — the set is small. */
219
+ listGraphNamespaces?(q?: GraphNamespaceListQuery): Promise<GraphNamespaceInfo[]>;
220
+ /** Full descriptor for one namespace (regardless of archived), or null. */
221
+ getGraphNamespace?(namespace: string): Promise<GraphNamespaceInfo | null>;
222
+ /** Upsert a namespace registry row (ON CONFLICT (namespace) DO UPDATE). */
223
+ upsertGraphNamespace?(input: GraphNamespaceInput): Promise<GraphNamespaceInfo>;
224
+ /** Non-destructive: set archived = true. `default` cannot be archived. */
225
+ archiveGraphNamespace?(namespace: string): Promise<boolean>;
226
+ /** Destructive: drop graph data for the exact namespace, then the registry
227
+ * row. Re-runnable. Never deletes source facts. `default` cannot be deleted. */
228
+ deleteGraphNamespace?(namespace: string): Promise<GraphNamespaceDeleteResult>;
229
+ }
230
+ /**
231
+ * Structural guard for the construction-time bundled-provider reuse decision
232
+ * only (a single provider object that backs both facts and graph). Graph TOOL
233
+ * gating is `!!graphStore` — a separate injection — never this sniff.
234
+ */
235
+ export declare function isGraphStore(s: unknown): s is GraphStore;
236
+ /**
237
+ * Whether a fact scope_key is readable under the given access context, decided
238
+ * purely from the key's shape: `shared:` always passes; `session:<id>:` passes
239
+ * iff `<id>` is the reader's or a granted session; unrestricted passes all.
240
+ * Used to filter graph `evidence` arrays and to ignore inaccessible seeds.
241
+ */
242
+ export declare function scopeKeyAccessible(scopeKey: string, access?: AccessContext): boolean;
243
+ //# sourceMappingURL=graph-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-store.d.ts","sourceRoot":"","sources":["../src/graph-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAIjD,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;qEACiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,MAAM,WAAW,cAAc;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;4CACwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;qCAEiC;IACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc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AA0E;IAC1E,qBAAqB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D;oFACgF;IAChF,oBAAoB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACjF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAIxD;AAID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAapF"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Graph Store — the OPTIONAL open knowledge graph contract (enhancedfactstore
3
+ * 07 D2).
4
+ *
5
+ * The graph is a SEPARATE, independently injected interface — NOT part of
6
+ * `EnhancedFactStore` and NOT a capability on the fact store. The SDK owns this
7
+ * contract; a concrete provider (e.g. pilotswarm-horizon-store's
8
+ * `HorizonDBGraphStore`, AGE-backed) implements it. The runtime registers graph
9
+ * tools iff a `graphStore` was injected (`!!graphStore`) — there is no
10
+ * fact-store sniff.
11
+ *
12
+ * The graph stores ids + structure only (never fact values or ACLs). Evidence
13
+ * scope_keys are opaque pointers; resolving them back to fact values is the
14
+ * caller's tool-layer composition:
15
+ * graphStore.searchGraphNodes(...) -> scopeKeys -> factStore.readFacts({ scopeKeys })
16
+ *
17
+ * @module
18
+ */
19
+ /**
20
+ * Reserved namespace token for the unscoped graph partition. Graph records with
21
+ * no namespace property (NULL) are the `default` partition: writes of `default`
22
+ * (or empty) store no namespace, and reads of `default` match `namespace IS
23
+ * NULL`. `default` is always present in the registry and cannot be archived or
24
+ * deleted (graph-fact-search enhancements).
25
+ */
26
+ export const DEFAULT_GRAPH_NAMESPACE = "default";
27
+ /**
28
+ * Structural guard for the construction-time bundled-provider reuse decision
29
+ * only (a single provider object that backs both facts and graph). Graph TOOL
30
+ * gating is `!!graphStore` — a separate injection — never this sniff.
31
+ */
32
+ export function isGraphStore(s) {
33
+ return typeof s?.searchGraphNodes === "function"
34
+ && typeof s?.upsertGraphNode === "function"
35
+ && typeof s?.removeGraphEvidence === "function";
36
+ }
37
+ // ─── ACL helper (syntactic scope_key check) ──────────────────────────────────
38
+ /**
39
+ * Whether a fact scope_key is readable under the given access context, decided
40
+ * purely from the key's shape: `shared:` always passes; `session:<id>:` passes
41
+ * iff `<id>` is the reader's or a granted session; unrestricted passes all.
42
+ * Used to filter graph `evidence` arrays and to ignore inaccessible seeds.
43
+ */
44
+ export function scopeKeyAccessible(scopeKey, access) {
45
+ if (access?.unrestricted)
46
+ return true;
47
+ if (scopeKey.startsWith("shared:"))
48
+ return true;
49
+ if (scopeKey.startsWith("session:")) {
50
+ const rest = scopeKey.slice("session:".length);
51
+ // Require a real `<id>:<key>` shape; malformed keys fail closed.
52
+ const sep = rest.indexOf(":");
53
+ if (sep <= 0)
54
+ return false;
55
+ const sessionId = rest.slice(0, sep);
56
+ if (access?.readerSessionId && sessionId === access.readerSessionId)
57
+ return true;
58
+ if (access?.grantedSessionIds?.includes(sessionId))
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+ //# sourceMappingURL=graph-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-store.js","sourceRoot":"","sources":["../src/graph-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AAuOjD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAU;IACnC,OAAO,OAAQ,CAAS,EAAE,gBAAgB,KAAK,UAAU;WACtD,OAAQ,CAAS,EAAE,eAAe,KAAK,UAAU;WACjD,OAAQ,CAAS,EAAE,mBAAmB,KAAK,UAAU,CAAC;AAC7D,CAAC;AAED,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,MAAsB;IACvE,IAAI,MAAM,EAAE,YAAY;QAAE,OAAO,IAAI,CAAC;IACtC,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC/C,iEAAiE;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,GAAG,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACrC,IAAI,MAAM,EAAE,eAAe,IAAI,SAAS,KAAK,MAAM,CAAC,eAAe;YAAE,OAAO,IAAI,CAAC;QACjF,IAAI,MAAM,EAAE,iBAAiB,EAAE,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { Tool } from "@github/copilot-sdk";
2
+ import type { AccessContext, FactStore } from "./facts-store.js";
3
+ import type { GraphStore } from "./graph-store.js";
4
+ export interface CreateGraphToolsOptions {
5
+ graphStore: GraphStore;
6
+ /** Base fact store — graph_stats reads crawl-queue counts from it. */
7
+ factStore: FactStore;
8
+ /** The session's agent identity, used for role gating. */
9
+ agentIdentity?: string;
10
+ /**
11
+ * Whether this session holds the app-assigned HARVESTER role. This now gates
12
+ * ONLY the crawl work queue (`facts_read_uncrawled` / `facts_mark_crawled`);
13
+ * the facts-manager additionally receives the queue (dormant), and
14
+ * agent-tuner never does. Graph write/delete is NOT gated by this flag — it
15
+ * is available to every non-tuner session (see `canWriteGraph`).
16
+ */
17
+ isHarvester?: boolean;
18
+ /**
19
+ * Resolve the caller's ACL context for graph reads (evidence filtering +
20
+ * seed gating). REQUIRED for correct isolation: without it, a reader would
21
+ * see every session's evidence. Mirrors the read_facts lineage model —
22
+ * returns { readerSessionId, grantedSessionIds } (or { unrestricted: true }
23
+ * for the tuner). If omitted, graph reads FAIL CLOSED to the caller's own
24
+ * session only (never unrestricted).
25
+ */
26
+ resolveAccess?: (sessionId: string | undefined) => Promise<AccessContext>;
27
+ /** Agent id recorded on graph writes. */
28
+ agentId?: string;
29
+ /**
30
+ * Fire-and-forget hook recording a `graph.searched` event (query + result
31
+ * digest) for tuner forensics (07 P4 observability). Errors swallowed.
32
+ */
33
+ recordEvent?: (sessionId: string, eventType: string, data: unknown) => Promise<void>;
34
+ }
35
+ /**
36
+ * Build the graph + crawl-queue tools (enhancedfactstore 07 P4). Registered
37
+ * ONLY when a `graphStore` is present. Reader tools (search/neighbourhood) go to
38
+ * every session; graph write/delete (`graph_upsert_*` / `graph_merge_nodes` /
39
+ * `graph_delete_*`) go to EVERY session EXCEPT the read-only agent-tuner, so any
40
+ * agent can incorporate into the SHARED graph; the crawl work queue
41
+ * (`facts_read_uncrawled` / `facts_mark_crawled`) stays harvester-role +
42
+ * facts-manager only (it reads facts across ALL scopes, bypassing per-session
43
+ * ACL); `graph_stats` (read-only) goes to facts-manager + agent-tuner.
44
+ * agent-tuner never gets a mutating tool.
45
+ */
46
+ export declare function createGraphTools(opts: CreateGraphToolsOptions): Tool<any>[];
47
+ //# sourceMappingURL=graph-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-tools.d.ts","sourceRoot":"","sources":["../src/graph-tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAwCnD,MAAM,WAAW,uBAAuB;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,sEAAsE;IACtE,SAAS,EAAE,SAAS,CAAC;IACrB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1E,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAqiB3E"}