mindgraph 0.2.2 → 0.4.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/README.md CHANGED
@@ -113,6 +113,23 @@ const entity = await graph.findOrCreateEntity("Some Entity");
113
113
  | `governance(req)` | Create policies, set safety budgets, request/resolve approvals |
114
114
  | `execution(req)` | Track execution lifecycle and register agents |
115
115
 
116
+ ### Synthesis (Projects)
117
+
118
+ Scope a corpus to a `Project` (via `commit({ action: "project", ... })` then link documents with `PartOfProject`), then mine cross-document signals and generate synthesis articles.
119
+
120
+ | Method | Description |
121
+ |--------|-------------|
122
+ | `signals(projectUid, opts?)` | Mine cross-document structural signals for a project (entity bridges, claim hubs, theory gaps, concept clusters, analogies, dialectical pairs) |
123
+ | `runSynthesis(projectUid)` | Spawn an async synthesis job that turns top clusters into Article nodes; returns a `job_id` to poll via `getJob()` |
124
+
125
+ ```typescript
126
+ const project = await graph.commit({ action: "project", label: "Q2 China strategy" });
127
+ // ...link documents to the project via PartOfProject edges...
128
+ const signals = await graph.signals(project.uid, { signals: "clustered_claim_hubs,dialectical_pairs" });
129
+ const { job_id } = await graph.runSynthesis(project.uid);
130
+ const job = await graph.getJob(job_id);
131
+ ```
132
+
116
133
  ### CRUD
117
134
 
118
135
  | Method | Description |
package/dist/index.d.mts CHANGED
@@ -409,24 +409,48 @@ interface IngestSessionRequest {
409
409
  }
410
410
  interface RetrieveContextRequest {
411
411
  query: string;
412
- k?: number;
413
- depth?: number;
412
+ /** Max graph nodes to return (default 10). */
413
+ node_limit?: number;
414
+ /** Max wiki articles to return (default 3). Set to 0 to skip. */
415
+ article_limit?: number;
416
+ /** Max raw chunks to return (default 0). Set > 0 to include source text. */
417
+ chunk_limit?: number;
414
418
  node_types?: string[];
415
419
  layer?: string;
416
- include_chunks?: boolean;
417
420
  include_graph?: boolean;
418
421
  min_similarity?: number;
419
422
  }
423
+ interface ArticleResult {
424
+ uid: string;
425
+ label: string;
426
+ content: string;
427
+ article_type: string;
428
+ covers_uid: string | null;
429
+ questions: string[] | null;
430
+ score: number;
431
+ }
432
+ interface ListArticlesResponse {
433
+ articles: GraphNode[];
434
+ total: number;
435
+ has_more: boolean;
436
+ }
420
437
  interface RetrieveContextResponse {
421
- chunks: {
438
+ articles?: ArticleResult[];
439
+ chunks?: {
422
440
  chunk_uid: string;
423
441
  content: string;
424
442
  score: number;
425
443
  document_uid: string | null;
444
+ document_title: string | null;
426
445
  chunk_index: number | null;
427
446
  }[];
428
447
  graph: {
429
- nodes: Record<string, unknown>[];
448
+ nodes: (Record<string, unknown> & {
449
+ source_documents?: {
450
+ uid: string;
451
+ title: string;
452
+ }[];
453
+ })[];
430
454
  edges: Record<string, unknown>[];
431
455
  };
432
456
  }
@@ -474,10 +498,120 @@ interface DecayRequest {
474
498
  interface PurgeRequest {
475
499
  before?: number;
476
500
  }
501
+ interface SignalsQuery {
502
+ /**
503
+ * Comma-separated subset of signal names to compute, e.g.
504
+ * `"documents,entity_bridges,claim_hubs"`. If omitted, all signals run.
505
+ */
506
+ signals?: string;
507
+ /**
508
+ * Comma-separated node types used as filters for `entity_bridges` and
509
+ * `claim_hubs`. Defaults to the server's built-in target set
510
+ * (Person, Organization, Nation, Event, Place, Theory, Hypothesis,
511
+ * Pattern, Mechanism, Model, Analogy).
512
+ */
513
+ target_types?: string;
514
+ }
515
+ interface DocumentRef {
516
+ uid: string;
517
+ label: string;
518
+ }
519
+ interface EntityBridge {
520
+ uid: string;
521
+ label: string;
522
+ node_type: string;
523
+ doc_count: number;
524
+ }
525
+ interface ClaimHub {
526
+ target_uid: string;
527
+ target_label: string;
528
+ target_type: string;
529
+ claim_count: number;
530
+ }
531
+ interface RankedClaimHub {
532
+ target_uid: string;
533
+ target_label: string;
534
+ target_type: string;
535
+ claim_count: number;
536
+ distinct_doc_count: number;
537
+ project_doc_count: number;
538
+ dialectical_count: number;
539
+ score: number;
540
+ breadth_score: number;
541
+ tension_score: number;
542
+ density_score: number;
543
+ }
544
+ interface ClusterClaimSample {
545
+ uid: string;
546
+ label: string;
547
+ source_doc_label: string;
548
+ }
549
+ interface EpistemicCounts {
550
+ evidence: number;
551
+ arguments: number;
552
+ warrants: number;
553
+ theories_hypotheses: number;
554
+ contradicts_edges: number;
555
+ }
556
+ interface ClusteredClaimHub {
557
+ cluster_id: number;
558
+ size: number;
559
+ distinct_doc_count: number;
560
+ project_doc_count: number;
561
+ cohesion_score: number;
562
+ epistemic_density: number;
563
+ score: number;
564
+ breadth_score: number;
565
+ size_score: number;
566
+ dominant_entity_uid: string | null;
567
+ dominant_entity_label: string | null;
568
+ dominant_entity_type: string | null;
569
+ sample_claims: ClusterClaimSample[];
570
+ epistemic_counts: EpistemicCounts;
571
+ }
572
+ interface TheorySupportGap {
573
+ uid: string;
574
+ label: string;
575
+ node_type: string;
576
+ support_count: number;
577
+ }
578
+ interface ConceptCluster {
579
+ uid: string;
580
+ label: string;
581
+ doc_count: number;
582
+ }
583
+ interface AnalogyCandidate {
584
+ uid: string;
585
+ label: string;
586
+ summary: string;
587
+ }
588
+ interface DialecticalPair {
589
+ edge_type: string;
590
+ from_uid: string;
591
+ from_label: string;
592
+ to_uid: string;
593
+ to_label: string;
594
+ }
595
+ interface SignalsResponse {
596
+ project_uid: string;
597
+ documents: DocumentRef[];
598
+ entity_bridges: EntityBridge[];
599
+ claim_hubs: ClaimHub[];
600
+ ranked_claim_hubs: RankedClaimHub[];
601
+ clustered_claim_hubs: ClusteredClaimHub[];
602
+ theory_support_gaps: TheorySupportGap[];
603
+ concept_clusters: ConceptCluster[];
604
+ analogy_candidates: AnalogyCandidate[];
605
+ dialectical_pairs: DialecticalPair[];
606
+ }
607
+ interface SynthesisJobResponse {
608
+ job_id: string;
609
+ }
477
610
  interface MindGraphConfig {
478
611
  baseUrl: string;
479
612
  apiKey?: string;
480
613
  jwt?: string;
614
+ orgId?: string;
481
615
  /** Max retries for 503 (server warming up) responses. Default: 3. Set to 0 to disable. */
482
616
  maxRetries?: number;
483
617
  /** Initial backoff in ms before first retry. Doubles each attempt. Default: 1000. */
@@ -779,6 +913,11 @@ declare class MindGraph {
779
913
  ingestDocument(req: IngestDocumentRequest): Promise<IngestDocumentResponse>;
780
914
  ingestSession(req: IngestSessionRequest): Promise<IngestDocumentResponse>;
781
915
  retrieveContext(req: RetrieveContextRequest): Promise<RetrieveContextResponse>;
916
+ /** Backfill node_source provenance for existing graphs. */
917
+ backfillNodeSources(): Promise<{
918
+ documents_processed: number;
919
+ node_source_pairs_added: number;
920
+ }>;
782
921
  listJobs(): Promise<Job[]>;
783
922
  getJob(id: string): Promise<Job>;
784
923
  cancelJob(id: string): Promise<unknown>;
@@ -796,6 +935,51 @@ declare class MindGraph {
796
935
  cleanupOrphans(): Promise<unknown>;
797
936
  embedAll(): Promise<unknown>;
798
937
  clearGraph(): Promise<ClearResponse>;
938
+ /** List wiki articles with optional filters. */
939
+ listArticles(params?: {
940
+ article_type?: string;
941
+ covers_node_type?: string;
942
+ search?: string;
943
+ limit?: number;
944
+ offset?: number;
945
+ }): Promise<ListArticlesResponse>;
946
+ /** Get a single wiki article by UID. */
947
+ getArticle(uid: string): Promise<GraphNode>;
948
+ /** Find the article that covers or summarizes a given entity/document UID. */
949
+ getArticleBySubject(subjectUid: string): Promise<GraphNode | null>;
950
+ /** Update an article's markdown content (user editing). */
951
+ updateArticle(uid: string, content: string): Promise<GraphNode>;
952
+ /** Trigger wiki compilation for a specific document. */
953
+ compileDocument(docUid: string): Promise<{
954
+ job_id?: string;
955
+ status: string;
956
+ }>;
957
+ /** Trigger wiki compilation for a specific entity. */
958
+ compileEntity(entityUid: string): Promise<{
959
+ job_id: string;
960
+ }>;
961
+ /** Backfill: compile articles for all documents and eligible entities. */
962
+ compileAll(): Promise<{
963
+ job_id: string;
964
+ }>;
965
+ /**
966
+ * Mine structural synthesis signals for a project's document corpus.
967
+ *
968
+ * Returns candidate surface for downstream synthesis — entity bridges
969
+ * across documents, claim hubs, clustered claim hubs, theory support
970
+ * gaps, concept clusters, analogy candidates, and dialectical pairs.
971
+ *
972
+ * Blocking operation. No LLM calls; Datalog + embedding clustering only.
973
+ */
974
+ signals(projectUid: string, opts?: SignalsQuery): Promise<SignalsResponse>;
975
+ /**
976
+ * Spawn a background synthesis job for a project: mines signals,
977
+ * selects top idea clusters, runs LLM synthesis, and persists
978
+ * candidate Article nodes linked via `Covers` edges.
979
+ *
980
+ * Returns a `job_id` immediately; poll `getJob(id)` for progress.
981
+ */
982
+ runSynthesis(projectUid: string): Promise<SynthesisJobResponse>;
799
983
  }
800
984
 
801
- export { type ArgumentRequest, type BatchRequest, type CaptureRequest, type ClearResponse, type CommitmentRequest, type DecayRequest, type DeliberationRequest, type DistillRequest, type EnrichedSearchResponse, type EntityRequest, type EventProps, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type NationProps, type OrganizationProps, type PathStep, type PersonProps, type PlaceProps, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchChunk, type SearchResult, type SessionRequest, type StructureRequest, type TraverseRequest };
985
+ export { type AnalogyCandidate, type ArgumentRequest, type ArticleResult, type BatchRequest, type CaptureRequest, type ClaimHub, type ClearResponse, type ClusterClaimSample, type ClusteredClaimHub, type CommitmentRequest, type ConceptCluster, type DecayRequest, type DeliberationRequest, type DialecticalPair, type DistillRequest, type DocumentRef, type EnrichedSearchResponse, type EntityBridge, type EntityRequest, type EpistemicCounts, type EventProps, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type ListArticlesResponse, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type NationProps, type OrganizationProps, type PathStep, type PersonProps, type PlaceProps, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RankedClaimHub, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchChunk, type SearchResult, type SessionRequest, type SignalsQuery, type SignalsResponse, type StructureRequest, type SynthesisJobResponse, type TheorySupportGap, type TraverseRequest };
package/dist/index.d.ts CHANGED
@@ -409,24 +409,48 @@ interface IngestSessionRequest {
409
409
  }
410
410
  interface RetrieveContextRequest {
411
411
  query: string;
412
- k?: number;
413
- depth?: number;
412
+ /** Max graph nodes to return (default 10). */
413
+ node_limit?: number;
414
+ /** Max wiki articles to return (default 3). Set to 0 to skip. */
415
+ article_limit?: number;
416
+ /** Max raw chunks to return (default 0). Set > 0 to include source text. */
417
+ chunk_limit?: number;
414
418
  node_types?: string[];
415
419
  layer?: string;
416
- include_chunks?: boolean;
417
420
  include_graph?: boolean;
418
421
  min_similarity?: number;
419
422
  }
423
+ interface ArticleResult {
424
+ uid: string;
425
+ label: string;
426
+ content: string;
427
+ article_type: string;
428
+ covers_uid: string | null;
429
+ questions: string[] | null;
430
+ score: number;
431
+ }
432
+ interface ListArticlesResponse {
433
+ articles: GraphNode[];
434
+ total: number;
435
+ has_more: boolean;
436
+ }
420
437
  interface RetrieveContextResponse {
421
- chunks: {
438
+ articles?: ArticleResult[];
439
+ chunks?: {
422
440
  chunk_uid: string;
423
441
  content: string;
424
442
  score: number;
425
443
  document_uid: string | null;
444
+ document_title: string | null;
426
445
  chunk_index: number | null;
427
446
  }[];
428
447
  graph: {
429
- nodes: Record<string, unknown>[];
448
+ nodes: (Record<string, unknown> & {
449
+ source_documents?: {
450
+ uid: string;
451
+ title: string;
452
+ }[];
453
+ })[];
430
454
  edges: Record<string, unknown>[];
431
455
  };
432
456
  }
@@ -474,10 +498,120 @@ interface DecayRequest {
474
498
  interface PurgeRequest {
475
499
  before?: number;
476
500
  }
501
+ interface SignalsQuery {
502
+ /**
503
+ * Comma-separated subset of signal names to compute, e.g.
504
+ * `"documents,entity_bridges,claim_hubs"`. If omitted, all signals run.
505
+ */
506
+ signals?: string;
507
+ /**
508
+ * Comma-separated node types used as filters for `entity_bridges` and
509
+ * `claim_hubs`. Defaults to the server's built-in target set
510
+ * (Person, Organization, Nation, Event, Place, Theory, Hypothesis,
511
+ * Pattern, Mechanism, Model, Analogy).
512
+ */
513
+ target_types?: string;
514
+ }
515
+ interface DocumentRef {
516
+ uid: string;
517
+ label: string;
518
+ }
519
+ interface EntityBridge {
520
+ uid: string;
521
+ label: string;
522
+ node_type: string;
523
+ doc_count: number;
524
+ }
525
+ interface ClaimHub {
526
+ target_uid: string;
527
+ target_label: string;
528
+ target_type: string;
529
+ claim_count: number;
530
+ }
531
+ interface RankedClaimHub {
532
+ target_uid: string;
533
+ target_label: string;
534
+ target_type: string;
535
+ claim_count: number;
536
+ distinct_doc_count: number;
537
+ project_doc_count: number;
538
+ dialectical_count: number;
539
+ score: number;
540
+ breadth_score: number;
541
+ tension_score: number;
542
+ density_score: number;
543
+ }
544
+ interface ClusterClaimSample {
545
+ uid: string;
546
+ label: string;
547
+ source_doc_label: string;
548
+ }
549
+ interface EpistemicCounts {
550
+ evidence: number;
551
+ arguments: number;
552
+ warrants: number;
553
+ theories_hypotheses: number;
554
+ contradicts_edges: number;
555
+ }
556
+ interface ClusteredClaimHub {
557
+ cluster_id: number;
558
+ size: number;
559
+ distinct_doc_count: number;
560
+ project_doc_count: number;
561
+ cohesion_score: number;
562
+ epistemic_density: number;
563
+ score: number;
564
+ breadth_score: number;
565
+ size_score: number;
566
+ dominant_entity_uid: string | null;
567
+ dominant_entity_label: string | null;
568
+ dominant_entity_type: string | null;
569
+ sample_claims: ClusterClaimSample[];
570
+ epistemic_counts: EpistemicCounts;
571
+ }
572
+ interface TheorySupportGap {
573
+ uid: string;
574
+ label: string;
575
+ node_type: string;
576
+ support_count: number;
577
+ }
578
+ interface ConceptCluster {
579
+ uid: string;
580
+ label: string;
581
+ doc_count: number;
582
+ }
583
+ interface AnalogyCandidate {
584
+ uid: string;
585
+ label: string;
586
+ summary: string;
587
+ }
588
+ interface DialecticalPair {
589
+ edge_type: string;
590
+ from_uid: string;
591
+ from_label: string;
592
+ to_uid: string;
593
+ to_label: string;
594
+ }
595
+ interface SignalsResponse {
596
+ project_uid: string;
597
+ documents: DocumentRef[];
598
+ entity_bridges: EntityBridge[];
599
+ claim_hubs: ClaimHub[];
600
+ ranked_claim_hubs: RankedClaimHub[];
601
+ clustered_claim_hubs: ClusteredClaimHub[];
602
+ theory_support_gaps: TheorySupportGap[];
603
+ concept_clusters: ConceptCluster[];
604
+ analogy_candidates: AnalogyCandidate[];
605
+ dialectical_pairs: DialecticalPair[];
606
+ }
607
+ interface SynthesisJobResponse {
608
+ job_id: string;
609
+ }
477
610
  interface MindGraphConfig {
478
611
  baseUrl: string;
479
612
  apiKey?: string;
480
613
  jwt?: string;
614
+ orgId?: string;
481
615
  /** Max retries for 503 (server warming up) responses. Default: 3. Set to 0 to disable. */
482
616
  maxRetries?: number;
483
617
  /** Initial backoff in ms before first retry. Doubles each attempt. Default: 1000. */
@@ -779,6 +913,11 @@ declare class MindGraph {
779
913
  ingestDocument(req: IngestDocumentRequest): Promise<IngestDocumentResponse>;
780
914
  ingestSession(req: IngestSessionRequest): Promise<IngestDocumentResponse>;
781
915
  retrieveContext(req: RetrieveContextRequest): Promise<RetrieveContextResponse>;
916
+ /** Backfill node_source provenance for existing graphs. */
917
+ backfillNodeSources(): Promise<{
918
+ documents_processed: number;
919
+ node_source_pairs_added: number;
920
+ }>;
782
921
  listJobs(): Promise<Job[]>;
783
922
  getJob(id: string): Promise<Job>;
784
923
  cancelJob(id: string): Promise<unknown>;
@@ -796,6 +935,51 @@ declare class MindGraph {
796
935
  cleanupOrphans(): Promise<unknown>;
797
936
  embedAll(): Promise<unknown>;
798
937
  clearGraph(): Promise<ClearResponse>;
938
+ /** List wiki articles with optional filters. */
939
+ listArticles(params?: {
940
+ article_type?: string;
941
+ covers_node_type?: string;
942
+ search?: string;
943
+ limit?: number;
944
+ offset?: number;
945
+ }): Promise<ListArticlesResponse>;
946
+ /** Get a single wiki article by UID. */
947
+ getArticle(uid: string): Promise<GraphNode>;
948
+ /** Find the article that covers or summarizes a given entity/document UID. */
949
+ getArticleBySubject(subjectUid: string): Promise<GraphNode | null>;
950
+ /** Update an article's markdown content (user editing). */
951
+ updateArticle(uid: string, content: string): Promise<GraphNode>;
952
+ /** Trigger wiki compilation for a specific document. */
953
+ compileDocument(docUid: string): Promise<{
954
+ job_id?: string;
955
+ status: string;
956
+ }>;
957
+ /** Trigger wiki compilation for a specific entity. */
958
+ compileEntity(entityUid: string): Promise<{
959
+ job_id: string;
960
+ }>;
961
+ /** Backfill: compile articles for all documents and eligible entities. */
962
+ compileAll(): Promise<{
963
+ job_id: string;
964
+ }>;
965
+ /**
966
+ * Mine structural synthesis signals for a project's document corpus.
967
+ *
968
+ * Returns candidate surface for downstream synthesis — entity bridges
969
+ * across documents, claim hubs, clustered claim hubs, theory support
970
+ * gaps, concept clusters, analogy candidates, and dialectical pairs.
971
+ *
972
+ * Blocking operation. No LLM calls; Datalog + embedding clustering only.
973
+ */
974
+ signals(projectUid: string, opts?: SignalsQuery): Promise<SignalsResponse>;
975
+ /**
976
+ * Spawn a background synthesis job for a project: mines signals,
977
+ * selects top idea clusters, runs LLM synthesis, and persists
978
+ * candidate Article nodes linked via `Covers` edges.
979
+ *
980
+ * Returns a `job_id` immediately; poll `getJob(id)` for progress.
981
+ */
982
+ runSynthesis(projectUid: string): Promise<SynthesisJobResponse>;
799
983
  }
800
984
 
801
- export { type ArgumentRequest, type BatchRequest, type CaptureRequest, type ClearResponse, type CommitmentRequest, type DecayRequest, type DeliberationRequest, type DistillRequest, type EnrichedSearchResponse, type EntityRequest, type EventProps, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type NationProps, type OrganizationProps, type PathStep, type PersonProps, type PlaceProps, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchChunk, type SearchResult, type SessionRequest, type StructureRequest, type TraverseRequest };
985
+ export { type AnalogyCandidate, type ArgumentRequest, type ArticleResult, type BatchRequest, type CaptureRequest, type ClaimHub, type ClearResponse, type ClusterClaimSample, type ClusteredClaimHub, type CommitmentRequest, type ConceptCluster, type DecayRequest, type DeliberationRequest, type DialecticalPair, type DistillRequest, type DocumentRef, type EnrichedSearchResponse, type EntityBridge, type EntityRequest, type EpistemicCounts, type EventProps, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type ListArticlesResponse, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type NationProps, type OrganizationProps, type PathStep, type PersonProps, type PlaceProps, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RankedClaimHub, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchChunk, type SearchResult, type SessionRequest, type SignalsQuery, type SignalsResponse, type StructureRequest, type SynthesisJobResponse, type TheorySupportGap, type TraverseRequest };
package/dist/index.js CHANGED
@@ -43,6 +43,9 @@ var MindGraph = class {
43
43
  } else if (config.jwt) {
44
44
  this.headers["Authorization"] = `Bearer ${config.jwt}`;
45
45
  }
46
+ if (config.orgId) {
47
+ this.headers["X-MindGraph-Org"] = config.orgId;
48
+ }
46
49
  this.maxRetries = config.maxRetries ?? 3;
47
50
  this.retryBackoffMs = config.retryBackoffMs ?? 1e3;
48
51
  }
@@ -540,6 +543,10 @@ var MindGraph = class {
540
543
  async retrieveContext(req) {
541
544
  return this.post("/retrieve/context", req);
542
545
  }
546
+ /** Backfill node_source provenance for existing graphs. */
547
+ async backfillNodeSources() {
548
+ return this.post("/backfill/node-sources", {});
549
+ }
543
550
  async listJobs() {
544
551
  return this.get("/jobs");
545
552
  }
@@ -566,6 +573,72 @@ var MindGraph = class {
566
573
  async clearGraph() {
567
574
  return this.post("/clear", {});
568
575
  }
576
+ // ── Wiki ──────────────────────────────────────────────────────────────
577
+ /** List wiki articles with optional filters. */
578
+ async listArticles(params) {
579
+ const q = new URLSearchParams();
580
+ if (params?.article_type) q.set("article_type", params.article_type);
581
+ if (params?.covers_node_type) q.set("covers_node_type", params.covers_node_type);
582
+ if (params?.search) q.set("search", params.search);
583
+ if (params?.limit) q.set("limit", String(params.limit));
584
+ if (params?.offset) q.set("offset", String(params.offset));
585
+ return this.get(`/wiki/articles?${q}`);
586
+ }
587
+ /** Get a single wiki article by UID. */
588
+ async getArticle(uid) {
589
+ return this.get(`/wiki/article/${uid}`);
590
+ }
591
+ /** Find the article that covers or summarizes a given entity/document UID. */
592
+ async getArticleBySubject(subjectUid) {
593
+ try {
594
+ return await this.get(`/wiki/article/by-subject/${subjectUid}`);
595
+ } catch {
596
+ return null;
597
+ }
598
+ }
599
+ /** Update an article's markdown content (user editing). */
600
+ async updateArticle(uid, content) {
601
+ return this.patch(`/wiki/article/${uid}`, { content });
602
+ }
603
+ /** Trigger wiki compilation for a specific document. */
604
+ async compileDocument(docUid) {
605
+ return this.post(`/wiki/compile/${docUid}`, {});
606
+ }
607
+ /** Trigger wiki compilation for a specific entity. */
608
+ async compileEntity(entityUid) {
609
+ return this.post(`/wiki/compile/entity/${entityUid}`, {});
610
+ }
611
+ /** Backfill: compile articles for all documents and eligible entities. */
612
+ async compileAll() {
613
+ return this.post("/wiki/compile/all", {});
614
+ }
615
+ // ── Synthesis (Projects) ──────────────────────────────────────────────
616
+ /**
617
+ * Mine structural synthesis signals for a project's document corpus.
618
+ *
619
+ * Returns candidate surface for downstream synthesis — entity bridges
620
+ * across documents, claim hubs, clustered claim hubs, theory support
621
+ * gaps, concept clusters, analogy candidates, and dialectical pairs.
622
+ *
623
+ * Blocking operation. No LLM calls; Datalog + embedding clustering only.
624
+ */
625
+ async signals(projectUid, opts) {
626
+ const q = new URLSearchParams();
627
+ if (opts?.signals) q.set("signals", opts.signals);
628
+ if (opts?.target_types) q.set("target_types", opts.target_types);
629
+ const qs = q.toString();
630
+ return this.get(`/synthesis/signals/${projectUid}${qs ? `?${qs}` : ""}`);
631
+ }
632
+ /**
633
+ * Spawn a background synthesis job for a project: mines signals,
634
+ * selects top idea clusters, runs LLM synthesis, and persists
635
+ * candidate Article nodes linked via `Covers` edges.
636
+ *
637
+ * Returns a `job_id` immediately; poll `getJob(id)` for progress.
638
+ */
639
+ async runSynthesis(projectUid) {
640
+ return this.post(`/synthesis/run/${projectUid}`, {});
641
+ }
569
642
  };
570
643
  // Annotate the CommonJS export names for ESM import in node:
571
644
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -16,6 +16,9 @@ var MindGraph = class {
16
16
  } else if (config.jwt) {
17
17
  this.headers["Authorization"] = `Bearer ${config.jwt}`;
18
18
  }
19
+ if (config.orgId) {
20
+ this.headers["X-MindGraph-Org"] = config.orgId;
21
+ }
19
22
  this.maxRetries = config.maxRetries ?? 3;
20
23
  this.retryBackoffMs = config.retryBackoffMs ?? 1e3;
21
24
  }
@@ -513,6 +516,10 @@ var MindGraph = class {
513
516
  async retrieveContext(req) {
514
517
  return this.post("/retrieve/context", req);
515
518
  }
519
+ /** Backfill node_source provenance for existing graphs. */
520
+ async backfillNodeSources() {
521
+ return this.post("/backfill/node-sources", {});
522
+ }
516
523
  async listJobs() {
517
524
  return this.get("/jobs");
518
525
  }
@@ -539,6 +546,72 @@ var MindGraph = class {
539
546
  async clearGraph() {
540
547
  return this.post("/clear", {});
541
548
  }
549
+ // ── Wiki ──────────────────────────────────────────────────────────────
550
+ /** List wiki articles with optional filters. */
551
+ async listArticles(params) {
552
+ const q = new URLSearchParams();
553
+ if (params?.article_type) q.set("article_type", params.article_type);
554
+ if (params?.covers_node_type) q.set("covers_node_type", params.covers_node_type);
555
+ if (params?.search) q.set("search", params.search);
556
+ if (params?.limit) q.set("limit", String(params.limit));
557
+ if (params?.offset) q.set("offset", String(params.offset));
558
+ return this.get(`/wiki/articles?${q}`);
559
+ }
560
+ /** Get a single wiki article by UID. */
561
+ async getArticle(uid) {
562
+ return this.get(`/wiki/article/${uid}`);
563
+ }
564
+ /** Find the article that covers or summarizes a given entity/document UID. */
565
+ async getArticleBySubject(subjectUid) {
566
+ try {
567
+ return await this.get(`/wiki/article/by-subject/${subjectUid}`);
568
+ } catch {
569
+ return null;
570
+ }
571
+ }
572
+ /** Update an article's markdown content (user editing). */
573
+ async updateArticle(uid, content) {
574
+ return this.patch(`/wiki/article/${uid}`, { content });
575
+ }
576
+ /** Trigger wiki compilation for a specific document. */
577
+ async compileDocument(docUid) {
578
+ return this.post(`/wiki/compile/${docUid}`, {});
579
+ }
580
+ /** Trigger wiki compilation for a specific entity. */
581
+ async compileEntity(entityUid) {
582
+ return this.post(`/wiki/compile/entity/${entityUid}`, {});
583
+ }
584
+ /** Backfill: compile articles for all documents and eligible entities. */
585
+ async compileAll() {
586
+ return this.post("/wiki/compile/all", {});
587
+ }
588
+ // ── Synthesis (Projects) ──────────────────────────────────────────────
589
+ /**
590
+ * Mine structural synthesis signals for a project's document corpus.
591
+ *
592
+ * Returns candidate surface for downstream synthesis — entity bridges
593
+ * across documents, claim hubs, clustered claim hubs, theory support
594
+ * gaps, concept clusters, analogy candidates, and dialectical pairs.
595
+ *
596
+ * Blocking operation. No LLM calls; Datalog + embedding clustering only.
597
+ */
598
+ async signals(projectUid, opts) {
599
+ const q = new URLSearchParams();
600
+ if (opts?.signals) q.set("signals", opts.signals);
601
+ if (opts?.target_types) q.set("target_types", opts.target_types);
602
+ const qs = q.toString();
603
+ return this.get(`/synthesis/signals/${projectUid}${qs ? `?${qs}` : ""}`);
604
+ }
605
+ /**
606
+ * Spawn a background synthesis job for a project: mines signals,
607
+ * selects top idea clusters, runs LLM synthesis, and persists
608
+ * candidate Article nodes linked via `Covers` edges.
609
+ *
610
+ * Returns a `job_id` immediately; poll `getJob(id)` for progress.
611
+ */
612
+ async runSynthesis(projectUid) {
613
+ return this.post(`/synthesis/run/${projectUid}`, {});
614
+ }
542
615
  };
543
616
  export {
544
617
  MindGraph,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindgraph",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript client for the MindGraph Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",