@versatly/workgraph 0.2.0 → 1.0.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/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export { m as mcpServer } from './mcp-server-fU6U6ht8.js';
2
+ import '@modelcontextprotocol/sdk/server/mcp.js';
3
+
1
4
  /**
2
5
  * Workgraph type definitions.
3
6
  */
@@ -45,7 +48,7 @@ interface Registry {
45
48
  version: number;
46
49
  types: Record<string, PrimitiveTypeDefinition>;
47
50
  }
48
- type LedgerOp = 'create' | 'update' | 'delete' | 'claim' | 'release' | 'block' | 'unblock' | 'done' | 'cancel' | 'define' | 'decompose';
51
+ type LedgerOp = 'create' | 'update' | 'delete' | 'claim' | 'heartbeat' | 'release' | 'block' | 'unblock' | 'done' | 'reopen' | 'cancel' | 'define' | 'decompose' | 'handoff';
49
52
  interface LedgerEntry {
50
53
  ts: string;
51
54
  actor: string;
@@ -149,6 +152,9 @@ interface DispatchRun {
149
152
  adapter: string;
150
153
  objective: string;
151
154
  status: RunStatus;
155
+ leaseExpires?: string;
156
+ leaseDurationMinutes?: number;
157
+ heartbeats?: string[];
152
158
  idempotencyKey?: string;
153
159
  context?: Record<string, unknown>;
154
160
  output?: string;
@@ -291,8 +297,12 @@ declare function create(workspacePath: string, typeName: string, fields: Record<
291
297
  pathOverride?: string;
292
298
  }): PrimitiveInstance;
293
299
  declare function read(workspacePath: string, relPath: string): PrimitiveInstance | null;
294
- declare function list(workspacePath: string, typeName: string): PrimitiveInstance[];
295
- declare function update(workspacePath: string, relPath: string, fieldUpdates: Record<string, unknown>, bodyUpdate: string | undefined, actor: string): PrimitiveInstance;
300
+ declare function list$1(workspacePath: string, typeName: string): PrimitiveInstance[];
301
+ interface PrimitiveUpdateOptions {
302
+ expectedEtag?: string;
303
+ concurrentConflictMode?: 'warn' | 'error';
304
+ }
305
+ declare function update(workspacePath: string, relPath: string, fieldUpdates: Record<string, unknown>, bodyUpdate: string | undefined, actor: string, options?: PrimitiveUpdateOptions): PrimitiveInstance;
296
306
  declare function remove(workspacePath: string, relPath: string, actor: string): void;
297
307
  declare function findByField(workspacePath: string, typeName: string, field: string, value: unknown): PrimitiveInstance[];
298
308
  declare function openThreads(workspacePath: string): PrimitiveInstance[];
@@ -300,18 +310,49 @@ declare function activeThreads(workspacePath: string): PrimitiveInstance[];
300
310
  declare function blockedThreads(workspacePath: string): PrimitiveInstance[];
301
311
  declare function threadsInSpace(workspacePath: string, spaceRef: string): PrimitiveInstance[];
302
312
 
313
+ type store_PrimitiveUpdateOptions = PrimitiveUpdateOptions;
303
314
  declare const store_activeThreads: typeof activeThreads;
304
315
  declare const store_blockedThreads: typeof blockedThreads;
305
316
  declare const store_create: typeof create;
306
317
  declare const store_findByField: typeof findByField;
307
- declare const store_list: typeof list;
308
318
  declare const store_openThreads: typeof openThreads;
309
319
  declare const store_read: typeof read;
310
320
  declare const store_remove: typeof remove;
311
321
  declare const store_threadsInSpace: typeof threadsInSpace;
312
322
  declare const store_update: typeof update;
313
323
  declare namespace store {
314
- export { store_activeThreads as activeThreads, store_blockedThreads as blockedThreads, store_create as create, store_findByField as findByField, store_list as list, store_openThreads as openThreads, store_read as read, store_remove as remove, store_threadsInSpace as threadsInSpace, store_update as update };
324
+ export { type store_PrimitiveUpdateOptions as PrimitiveUpdateOptions, store_activeThreads as activeThreads, store_blockedThreads as blockedThreads, store_create as create, store_findByField as findByField, list$1 as list, store_openThreads as openThreads, store_read as read, store_remove as remove, store_threadsInSpace as threadsInSpace, store_update as update };
325
+ }
326
+
327
+ interface ClaimLeaseRecord {
328
+ target: string;
329
+ owner: string;
330
+ claimedAt: string;
331
+ lastHeartbeatAt: string;
332
+ expiresAt: string;
333
+ ttlMinutes: number;
334
+ }
335
+ interface ClaimLeaseStatus extends ClaimLeaseRecord {
336
+ stale: boolean;
337
+ msUntilExpiry: number;
338
+ }
339
+ declare function listClaimLeases(workspacePath: string, nowMs?: number): ClaimLeaseStatus[];
340
+ declare function setClaimLease(workspacePath: string, target: string, owner: string, options?: {
341
+ ttlMinutes?: number;
342
+ now?: Date;
343
+ claimedAt?: string;
344
+ }): ClaimLeaseRecord;
345
+ declare function removeClaimLease(workspacePath: string, target: string): void;
346
+ declare function claimLeasePath(workspacePath: string): string;
347
+
348
+ type claimLease_ClaimLeaseRecord = ClaimLeaseRecord;
349
+ type claimLease_ClaimLeaseStatus = ClaimLeaseStatus;
350
+ declare const claimLease_claimLeasePath: typeof claimLeasePath;
351
+ declare const claimLease_listClaimLeases: typeof listClaimLeases;
352
+ declare const claimLease_removeClaimLease: typeof removeClaimLease;
353
+ declare const claimLease_setClaimLease: typeof setClaimLease;
354
+ declare namespace claimLease {
355
+ export { type claimLease_ClaimLeaseRecord as ClaimLeaseRecord, type claimLease_ClaimLeaseStatus as ClaimLeaseStatus, claimLease_claimLeasePath as claimLeasePath, claimLease_listClaimLeases as listClaimLeases, claimLease_removeClaimLease as removeClaimLease, claimLease_setClaimLease as setClaimLease };
315
356
  }
316
357
 
317
358
  /**
@@ -333,18 +374,58 @@ declare function pickNextReadyThread(workspacePath: string): PrimitiveInstance |
333
374
  declare function pickNextReadyThreadInSpace(workspacePath: string, spaceRef: string): PrimitiveInstance | null;
334
375
  declare function claimNextReady(workspacePath: string, actor: string): PrimitiveInstance | null;
335
376
  declare function claimNextReadyInSpace(workspacePath: string, actor: string, spaceRef: string): PrimitiveInstance | null;
336
- declare function claim(workspacePath: string, threadPath: string, actor: string): PrimitiveInstance;
377
+ declare function claim(workspacePath: string, threadPath: string, actor: string, options?: {
378
+ leaseTtlMinutes?: number;
379
+ }): PrimitiveInstance;
337
380
  declare function release(workspacePath: string, threadPath: string, actor: string, reason?: string): PrimitiveInstance;
381
+ declare function heartbeat$2(workspacePath: string, threadPath: string, actor: string, leaseMinutes?: number): PrimitiveInstance;
382
+ declare function handoff(workspacePath: string, threadPath: string, fromActor: string, toActor: string, note?: string): PrimitiveInstance;
338
383
  declare function block(workspacePath: string, threadPath: string, actor: string, blockedBy: string, reason?: string): PrimitiveInstance;
339
384
  declare function unblock(workspacePath: string, threadPath: string, actor: string): PrimitiveInstance;
340
385
  declare function done(workspacePath: string, threadPath: string, actor: string, output?: string): PrimitiveInstance;
341
386
  declare function cancel(workspacePath: string, threadPath: string, actor: string, reason?: string): PrimitiveInstance;
387
+ declare function reopen(workspacePath: string, threadPath: string, actor: string, reason?: string): PrimitiveInstance;
388
+ interface ThreadHeartbeatResult {
389
+ actor: string;
390
+ touched: Array<{
391
+ threadPath: string;
392
+ expiresAt: string;
393
+ ttlMinutes: number;
394
+ }>;
395
+ skipped: Array<{
396
+ threadPath: string;
397
+ reason: string;
398
+ }>;
399
+ }
400
+ declare function heartbeatClaim(workspacePath: string, actor: string, threadPath?: string, options?: {
401
+ ttlMinutes?: number;
402
+ }): ThreadHeartbeatResult;
403
+ interface ReapStaleClaimsResult {
404
+ actor: string;
405
+ scanned: number;
406
+ reaped: Array<{
407
+ threadPath: string;
408
+ previousOwner: string;
409
+ expiredAt: string;
410
+ }>;
411
+ skipped: Array<{
412
+ threadPath: string;
413
+ reason: string;
414
+ }>;
415
+ }
416
+ declare function reapStaleClaims(workspacePath: string, actor: string, options?: {
417
+ limit?: number;
418
+ }): ReapStaleClaimsResult;
419
+ declare function listClaimLeaseStatus(workspacePath: string): ClaimLeaseStatus[];
342
420
  declare function decompose(workspacePath: string, parentPath: string, subthreads: Array<{
343
421
  title: string;
344
422
  goal: string;
345
423
  deps?: string[];
346
424
  }>, actor: string): PrimitiveInstance[];
425
+ declare function inferThreadDependenciesFromText(text: string): string[];
347
426
 
427
+ type thread_ReapStaleClaimsResult = ReapStaleClaimsResult;
428
+ type thread_ThreadHeartbeatResult = ThreadHeartbeatResult;
348
429
  declare const thread_block: typeof block;
349
430
  declare const thread_cancel: typeof cancel;
350
431
  declare const thread_claim: typeof claim;
@@ -353,15 +434,21 @@ declare const thread_claimNextReadyInSpace: typeof claimNextReadyInSpace;
353
434
  declare const thread_createThread: typeof createThread;
354
435
  declare const thread_decompose: typeof decompose;
355
436
  declare const thread_done: typeof done;
437
+ declare const thread_handoff: typeof handoff;
438
+ declare const thread_heartbeatClaim: typeof heartbeatClaim;
439
+ declare const thread_inferThreadDependenciesFromText: typeof inferThreadDependenciesFromText;
356
440
  declare const thread_isReadyForClaim: typeof isReadyForClaim;
441
+ declare const thread_listClaimLeaseStatus: typeof listClaimLeaseStatus;
357
442
  declare const thread_listReadyThreads: typeof listReadyThreads;
358
443
  declare const thread_listReadyThreadsInSpace: typeof listReadyThreadsInSpace;
359
444
  declare const thread_pickNextReadyThread: typeof pickNextReadyThread;
360
445
  declare const thread_pickNextReadyThreadInSpace: typeof pickNextReadyThreadInSpace;
446
+ declare const thread_reapStaleClaims: typeof reapStaleClaims;
361
447
  declare const thread_release: typeof release;
448
+ declare const thread_reopen: typeof reopen;
362
449
  declare const thread_unblock: typeof unblock;
363
450
  declare namespace thread {
364
- export { thread_block as block, thread_cancel as cancel, thread_claim as claim, thread_claimNextReady as claimNextReady, thread_claimNextReadyInSpace as claimNextReadyInSpace, thread_createThread as createThread, thread_decompose as decompose, thread_done as done, thread_isReadyForClaim as isReadyForClaim, thread_listReadyThreads as listReadyThreads, thread_listReadyThreadsInSpace as listReadyThreadsInSpace, thread_pickNextReadyThread as pickNextReadyThread, thread_pickNextReadyThreadInSpace as pickNextReadyThreadInSpace, thread_release as release, thread_unblock as unblock };
451
+ export { type thread_ReapStaleClaimsResult as ReapStaleClaimsResult, type thread_ThreadHeartbeatResult as ThreadHeartbeatResult, thread_block as block, thread_cancel as cancel, thread_claim as claim, thread_claimNextReady as claimNextReady, thread_claimNextReadyInSpace as claimNextReadyInSpace, thread_createThread as createThread, thread_decompose as decompose, thread_done as done, thread_handoff as handoff, heartbeat$2 as heartbeat, thread_heartbeatClaim as heartbeatClaim, thread_inferThreadDependenciesFromText as inferThreadDependenciesFromText, thread_isReadyForClaim as isReadyForClaim, thread_listClaimLeaseStatus as listClaimLeaseStatus, thread_listReadyThreads as listReadyThreads, thread_listReadyThreadsInSpace as listReadyThreadsInSpace, thread_pickNextReadyThread as pickNextReadyThread, thread_pickNextReadyThreadInSpace as pickNextReadyThreadInSpace, thread_reapStaleClaims as reapStaleClaims, thread_release as release, thread_reopen as reopen, thread_unblock as unblock };
365
452
  }
366
453
 
367
454
  /**
@@ -569,15 +656,26 @@ declare namespace orientation {
569
656
  }
570
657
 
571
658
  /**
572
- * Wiki-link graph indexing and hygiene reports.
659
+ * Wiki-link graph indexing and graph-intelligence queries.
573
660
  */
661
+ type WikiGraphEdgeType = 'wiki' | 'context_refs' | 'depends_on' | 'blocks' | 'informs' | 'contradicts' | 'supports' | 'supersedes' | 'parent';
574
662
  interface WikiGraphEdge {
575
663
  from: string;
576
664
  to: string;
665
+ type: WikiGraphEdgeType;
666
+ source: 'body' | 'frontmatter';
667
+ field?: string;
668
+ }
669
+ interface WikiGraphNode {
670
+ path: string;
671
+ slug: string;
672
+ type: string;
673
+ title?: string;
577
674
  }
578
675
  interface WikiGraphIndex {
579
676
  generatedAt: string;
580
677
  nodes: string[];
678
+ nodeInfo: Record<string, WikiGraphNode>;
581
679
  edges: WikiGraphEdge[];
582
680
  backlinks: Record<string, string[]>;
583
681
  orphans: string[];
@@ -596,6 +694,66 @@ interface WikiGraphNeighborhood {
596
694
  outgoing: string[];
597
695
  incoming: string[];
598
696
  }
697
+ interface WikiGraphNeighborhoodQueryNode extends WikiGraphNode {
698
+ exists: boolean;
699
+ distance: number;
700
+ }
701
+ interface WikiGraphNeighborhoodQuery {
702
+ center: WikiGraphNeighborhoodQueryNode;
703
+ depth: number;
704
+ connectedNodes: WikiGraphNeighborhoodQueryNode[];
705
+ edges: WikiGraphEdge[];
706
+ }
707
+ interface WikiGraphImpactReference {
708
+ node: WikiGraphNode;
709
+ edgeTypes: WikiGraphEdgeType[];
710
+ referenceCount: number;
711
+ }
712
+ interface WikiGraphImpactGroup {
713
+ type: string;
714
+ references: WikiGraphImpactReference[];
715
+ referenceCount: number;
716
+ }
717
+ interface WikiGraphImpactAnalysis {
718
+ target: WikiGraphNode & {
719
+ exists: boolean;
720
+ };
721
+ totalReferences: number;
722
+ incomingEdges: WikiGraphEdge[];
723
+ groups: WikiGraphImpactGroup[];
724
+ }
725
+ interface WikiGraphContextSection {
726
+ path: string;
727
+ type: string;
728
+ distance: number;
729
+ chars: number;
730
+ tokens: number;
731
+ }
732
+ interface WikiGraphContextAssembly {
733
+ center: WikiGraphNode & {
734
+ exists: boolean;
735
+ };
736
+ budgetTokens: number;
737
+ usedTokens: number;
738
+ sections: WikiGraphContextSection[];
739
+ markdown: string;
740
+ }
741
+ interface WikiGraphTypedEdges {
742
+ node: WikiGraphNode & {
743
+ exists: boolean;
744
+ };
745
+ outgoing: WikiGraphEdge[];
746
+ incoming: WikiGraphEdge[];
747
+ }
748
+ interface WikiGraphExportResult {
749
+ center: WikiGraphNode;
750
+ depth: number;
751
+ format: 'md';
752
+ outputDirectory: string;
753
+ manifestPath: string;
754
+ exportedNodes: string[];
755
+ exportedEdgeCount: number;
756
+ }
599
757
  declare function graphIndexPath(workspacePath: string): string;
600
758
  declare function buildWikiLinkGraph(workspacePath: string): WikiGraphIndex;
601
759
  declare function refreshWikiLinkGraphIndex(workspacePath: string): WikiGraphIndex;
@@ -616,21 +774,60 @@ declare function graphHygieneReport(workspacePath: string): {
616
774
  to: string;
617
775
  }>;
618
776
  };
777
+ /**
778
+ * Backward-compatible one-hop direct neighborhood.
779
+ */
619
780
  declare function graphNeighborhood(workspacePath: string, nodeRef: string, options?: {
620
781
  refresh?: boolean;
621
782
  }): WikiGraphNeighborhood;
783
+ declare function graphNeighborhoodQuery(workspacePath: string, nodeRef: string, options?: {
784
+ depth?: number;
785
+ refresh?: boolean;
786
+ }): WikiGraphNeighborhoodQuery;
787
+ declare function graphImpactAnalysis(workspacePath: string, nodeRef: string, options?: {
788
+ refresh?: boolean;
789
+ }): WikiGraphImpactAnalysis;
790
+ declare function graphContextAssembly(workspacePath: string, nodeRef: string, options?: {
791
+ budgetTokens?: number;
792
+ refresh?: boolean;
793
+ }): WikiGraphContextAssembly;
794
+ declare function graphTypedEdges(workspacePath: string, nodeRef: string, options?: {
795
+ refresh?: boolean;
796
+ }): WikiGraphTypedEdges;
797
+ declare function graphExportSubgraph(workspacePath: string, nodeRef: string, options?: {
798
+ depth?: number;
799
+ format?: 'md';
800
+ outputDir?: string;
801
+ refresh?: boolean;
802
+ }): WikiGraphExportResult;
622
803
 
804
+ type graph_WikiGraphContextAssembly = WikiGraphContextAssembly;
805
+ type graph_WikiGraphContextSection = WikiGraphContextSection;
623
806
  type graph_WikiGraphEdge = WikiGraphEdge;
807
+ type graph_WikiGraphEdgeType = WikiGraphEdgeType;
808
+ type graph_WikiGraphExportResult = WikiGraphExportResult;
809
+ type graph_WikiGraphImpactAnalysis = WikiGraphImpactAnalysis;
810
+ type graph_WikiGraphImpactGroup = WikiGraphImpactGroup;
811
+ type graph_WikiGraphImpactReference = WikiGraphImpactReference;
624
812
  type graph_WikiGraphIndex = WikiGraphIndex;
625
813
  type graph_WikiGraphNeighborhood = WikiGraphNeighborhood;
814
+ type graph_WikiGraphNeighborhoodQuery = WikiGraphNeighborhoodQuery;
815
+ type graph_WikiGraphNeighborhoodQueryNode = WikiGraphNeighborhoodQueryNode;
816
+ type graph_WikiGraphNode = WikiGraphNode;
817
+ type graph_WikiGraphTypedEdges = WikiGraphTypedEdges;
626
818
  declare const graph_buildWikiLinkGraph: typeof buildWikiLinkGraph;
819
+ declare const graph_graphContextAssembly: typeof graphContextAssembly;
820
+ declare const graph_graphExportSubgraph: typeof graphExportSubgraph;
627
821
  declare const graph_graphHygieneReport: typeof graphHygieneReport;
822
+ declare const graph_graphImpactAnalysis: typeof graphImpactAnalysis;
628
823
  declare const graph_graphIndexPath: typeof graphIndexPath;
629
824
  declare const graph_graphNeighborhood: typeof graphNeighborhood;
825
+ declare const graph_graphNeighborhoodQuery: typeof graphNeighborhoodQuery;
826
+ declare const graph_graphTypedEdges: typeof graphTypedEdges;
630
827
  declare const graph_readWikiLinkGraphIndex: typeof readWikiLinkGraphIndex;
631
828
  declare const graph_refreshWikiLinkGraphIndex: typeof refreshWikiLinkGraphIndex;
632
829
  declare namespace graph {
633
- export { type graph_WikiGraphEdge as WikiGraphEdge, type graph_WikiGraphIndex as WikiGraphIndex, type graph_WikiGraphNeighborhood as WikiGraphNeighborhood, graph_buildWikiLinkGraph as buildWikiLinkGraph, graph_graphHygieneReport as graphHygieneReport, graph_graphIndexPath as graphIndexPath, graph_graphNeighborhood as graphNeighborhood, graph_readWikiLinkGraphIndex as readWikiLinkGraphIndex, graph_refreshWikiLinkGraphIndex as refreshWikiLinkGraphIndex };
830
+ export { type graph_WikiGraphContextAssembly as WikiGraphContextAssembly, type graph_WikiGraphContextSection as WikiGraphContextSection, type graph_WikiGraphEdge as WikiGraphEdge, type graph_WikiGraphEdgeType as WikiGraphEdgeType, type graph_WikiGraphExportResult as WikiGraphExportResult, type graph_WikiGraphImpactAnalysis as WikiGraphImpactAnalysis, type graph_WikiGraphImpactGroup as WikiGraphImpactGroup, type graph_WikiGraphImpactReference as WikiGraphImpactReference, type graph_WikiGraphIndex as WikiGraphIndex, type graph_WikiGraphNeighborhood as WikiGraphNeighborhood, type graph_WikiGraphNeighborhoodQuery as WikiGraphNeighborhoodQuery, type graph_WikiGraphNeighborhoodQueryNode as WikiGraphNeighborhoodQueryNode, type graph_WikiGraphNode as WikiGraphNode, type graph_WikiGraphTypedEdges as WikiGraphTypedEdges, graph_buildWikiLinkGraph as buildWikiLinkGraph, graph_graphContextAssembly as graphContextAssembly, graph_graphExportSubgraph as graphExportSubgraph, graph_graphHygieneReport as graphHygieneReport, graph_graphImpactAnalysis as graphImpactAnalysis, graph_graphIndexPath as graphIndexPath, graph_graphNeighborhood as graphNeighborhood, graph_graphNeighborhoodQuery as graphNeighborhoodQuery, graph_graphTypedEdges as graphTypedEdges, graph_readWikiLinkGraphIndex as readWikiLinkGraphIndex, graph_refreshWikiLinkGraphIndex as refreshWikiLinkGraphIndex };
634
831
  }
635
832
 
636
833
  /**
@@ -693,7 +890,40 @@ declare namespace policy {
693
890
  }
694
891
 
695
892
  /**
696
- * Runtime dispatch contract (MVP local adapter).
893
+ * Thread quality gate evaluation.
894
+ */
895
+ interface GateRuleResult {
896
+ rule: 'required-facts' | 'required-approvals' | 'min-age-seconds' | 'gate-status' | 'gate-exists';
897
+ ok: boolean;
898
+ message: string;
899
+ }
900
+ interface GateEvaluation {
901
+ gateRef: string;
902
+ gatePath?: string;
903
+ gateTitle?: string;
904
+ ok: boolean;
905
+ rules: GateRuleResult[];
906
+ }
907
+ interface ThreadGateCheckResult {
908
+ checkedAt: string;
909
+ threadPath: string;
910
+ allowed: boolean;
911
+ gates: GateEvaluation[];
912
+ }
913
+ declare function checkThreadGates(workspacePath: string, threadRef: string, now?: Date): ThreadGateCheckResult;
914
+ declare function summarizeGateFailures(result: ThreadGateCheckResult): string;
915
+
916
+ type gate_GateEvaluation = GateEvaluation;
917
+ type gate_GateRuleResult = GateRuleResult;
918
+ type gate_ThreadGateCheckResult = ThreadGateCheckResult;
919
+ declare const gate_checkThreadGates: typeof checkThreadGates;
920
+ declare const gate_summarizeGateFailures: typeof summarizeGateFailures;
921
+ declare namespace gate {
922
+ export { type gate_GateEvaluation as GateEvaluation, type gate_GateRuleResult as GateRuleResult, type gate_ThreadGateCheckResult as ThreadGateCheckResult, gate_checkThreadGates as checkThreadGates, gate_summarizeGateFailures as summarizeGateFailures };
923
+ }
924
+
925
+ /**
926
+ * Runtime dispatch contract with adapter-backed execution.
697
927
  */
698
928
 
699
929
  interface DispatchCreateInput {
@@ -703,30 +933,103 @@ interface DispatchCreateInput {
703
933
  context?: Record<string, unknown>;
704
934
  idempotencyKey?: string;
705
935
  }
936
+ interface DispatchExecuteInput {
937
+ actor: string;
938
+ agents?: string[];
939
+ maxSteps?: number;
940
+ stepDelayMs?: number;
941
+ space?: string;
942
+ createCheckpoint?: boolean;
943
+ }
944
+ interface DispatchHeartbeatInput {
945
+ actor: string;
946
+ leaseMinutes?: number;
947
+ }
948
+ interface DispatchReconcileResult {
949
+ reconciledAt: string;
950
+ inspectedRuns: number;
951
+ requeuedRuns: DispatchRun[];
952
+ }
953
+ interface DispatchHandoffInput {
954
+ actor: string;
955
+ to: string;
956
+ reason: string;
957
+ adapter?: string;
958
+ }
959
+ interface DispatchHandoffResult {
960
+ sourceRun: DispatchRun;
961
+ handoffRun: DispatchRun;
962
+ }
963
+ interface DispatchClaimResult {
964
+ thread: PrimitiveInstance;
965
+ gateCheck: ThreadGateCheckResult;
966
+ }
706
967
  declare function createRun(workspacePath: string, input: DispatchCreateInput): DispatchRun;
968
+ declare function claimThread(workspacePath: string, threadRef: string, actor: string): DispatchClaimResult;
707
969
  declare function status(workspacePath: string, runId: string): DispatchRun;
708
970
  declare function followup(workspacePath: string, runId: string, actor: string, input: string): DispatchRun;
709
971
  declare function stop(workspacePath: string, runId: string, actor: string): DispatchRun;
710
972
  declare function markRun(workspacePath: string, runId: string, actor: string, nextStatus: Exclude<RunStatus, 'queued'>, options?: {
711
973
  output?: string;
712
974
  error?: string;
975
+ contextPatch?: Record<string, unknown>;
713
976
  }): DispatchRun;
977
+ declare function heartbeat$1(workspacePath: string, runId: string, input: DispatchHeartbeatInput): DispatchRun;
978
+ declare function reconcileExpiredLeases(workspacePath: string, actor: string): DispatchReconcileResult;
979
+ declare function handoffRun(workspacePath: string, runId: string, input: DispatchHandoffInput): DispatchHandoffResult;
714
980
  declare function logs(workspacePath: string, runId: string): DispatchRun['logs'];
715
981
  declare function listRuns(workspacePath: string, options?: {
716
982
  status?: RunStatus;
717
983
  limit?: number;
718
984
  }): DispatchRun[];
985
+ declare function executeRun(workspacePath: string, runId: string, input: DispatchExecuteInput): Promise<DispatchRun>;
986
+ declare function createAndExecuteRun(workspacePath: string, createInput: DispatchCreateInput, executeInput?: Omit<DispatchExecuteInput, 'actor'>): Promise<DispatchRun>;
719
987
 
988
+ type dispatch_DispatchClaimResult = DispatchClaimResult;
720
989
  type dispatch_DispatchCreateInput = DispatchCreateInput;
990
+ type dispatch_DispatchExecuteInput = DispatchExecuteInput;
991
+ type dispatch_DispatchHandoffInput = DispatchHandoffInput;
992
+ type dispatch_DispatchHandoffResult = DispatchHandoffResult;
993
+ type dispatch_DispatchHeartbeatInput = DispatchHeartbeatInput;
994
+ type dispatch_DispatchReconcileResult = DispatchReconcileResult;
995
+ declare const dispatch_claimThread: typeof claimThread;
996
+ declare const dispatch_createAndExecuteRun: typeof createAndExecuteRun;
721
997
  declare const dispatch_createRun: typeof createRun;
998
+ declare const dispatch_executeRun: typeof executeRun;
722
999
  declare const dispatch_followup: typeof followup;
1000
+ declare const dispatch_handoffRun: typeof handoffRun;
723
1001
  declare const dispatch_listRuns: typeof listRuns;
724
1002
  declare const dispatch_logs: typeof logs;
725
1003
  declare const dispatch_markRun: typeof markRun;
1004
+ declare const dispatch_reconcileExpiredLeases: typeof reconcileExpiredLeases;
726
1005
  declare const dispatch_status: typeof status;
727
1006
  declare const dispatch_stop: typeof stop;
728
1007
  declare namespace dispatch {
729
- export { type dispatch_DispatchCreateInput as DispatchCreateInput, dispatch_createRun as createRun, dispatch_followup as followup, dispatch_listRuns as listRuns, dispatch_logs as logs, dispatch_markRun as markRun, dispatch_status as status, dispatch_stop as stop };
1008
+ export { type dispatch_DispatchClaimResult as DispatchClaimResult, type dispatch_DispatchCreateInput as DispatchCreateInput, type dispatch_DispatchExecuteInput as DispatchExecuteInput, type dispatch_DispatchHandoffInput as DispatchHandoffInput, type dispatch_DispatchHandoffResult as DispatchHandoffResult, type dispatch_DispatchHeartbeatInput as DispatchHeartbeatInput, type dispatch_DispatchReconcileResult as DispatchReconcileResult, dispatch_claimThread as claimThread, dispatch_createAndExecuteRun as createAndExecuteRun, dispatch_createRun as createRun, dispatch_executeRun as executeRun, dispatch_followup as followup, dispatch_handoffRun as handoffRun, heartbeat$1 as heartbeat, dispatch_listRuns as listRuns, dispatch_logs as logs, dispatch_markRun as markRun, dispatch_reconcileExpiredLeases as reconcileExpiredLeases, dispatch_status as status, dispatch_stop as stop };
1009
+ }
1010
+
1011
+ /**
1012
+ * Agent presence primitives.
1013
+ */
1014
+
1015
+ type AgentPresenceStatus = 'online' | 'busy' | 'offline';
1016
+ interface AgentHeartbeatOptions {
1017
+ status?: AgentPresenceStatus;
1018
+ currentTask?: string;
1019
+ capabilities?: string[];
1020
+ actor?: string;
1021
+ }
1022
+ declare function heartbeat(workspacePath: string, name: string, options?: AgentHeartbeatOptions): PrimitiveInstance;
1023
+ declare function list(workspacePath: string): PrimitiveInstance[];
1024
+ declare function getPresence(workspacePath: string, name: string): PrimitiveInstance | null;
1025
+
1026
+ type agent_AgentHeartbeatOptions = AgentHeartbeatOptions;
1027
+ type agent_AgentPresenceStatus = AgentPresenceStatus;
1028
+ declare const agent_getPresence: typeof getPresence;
1029
+ declare const agent_heartbeat: typeof heartbeat;
1030
+ declare const agent_list: typeof list;
1031
+ declare namespace agent {
1032
+ export { type agent_AgentHeartbeatOptions as AgentHeartbeatOptions, type agent_AgentPresenceStatus as AgentPresenceStatus, agent_getPresence as getPresence, agent_heartbeat as heartbeat, agent_list as list };
730
1033
  }
731
1034
 
732
1035
  /**
@@ -760,6 +1063,31 @@ declare namespace onboard {
760
1063
  export { type onboard_OnboardOptions as OnboardOptions, type onboard_OnboardResult as OnboardResult, type onboard_OnboardingStatus as OnboardingStatus, onboard_onboardWorkspace as onboardWorkspace, onboard_updateOnboardingStatus as updateOnboardingStatus };
761
1064
  }
762
1065
 
1066
+ type ThreadAuditIssueKind = 'thread_without_ledger_history' | 'active_without_claim' | 'active_owner_mismatch' | 'claim_without_active_status' | 'owner_set_without_active' | 'dependency_reference_not_declared' | 'declared_dependency_missing_target' | 'active_without_lease' | 'stale_lease';
1067
+ interface ThreadAuditIssue {
1068
+ kind: ThreadAuditIssueKind;
1069
+ path: string;
1070
+ message: string;
1071
+ details?: Record<string, unknown>;
1072
+ }
1073
+ interface ThreadAuditReport {
1074
+ ok: boolean;
1075
+ generatedAt: string;
1076
+ totalThreads: number;
1077
+ totalClaims: number;
1078
+ totalLeases: number;
1079
+ issues: ThreadAuditIssue[];
1080
+ }
1081
+ declare function reconcileThreadState(workspacePath: string): ThreadAuditReport;
1082
+
1083
+ type threadAudit_ThreadAuditIssue = ThreadAuditIssue;
1084
+ type threadAudit_ThreadAuditIssueKind = ThreadAuditIssueKind;
1085
+ type threadAudit_ThreadAuditReport = ThreadAuditReport;
1086
+ declare const threadAudit_reconcileThreadState: typeof reconcileThreadState;
1087
+ declare namespace threadAudit {
1088
+ export { type threadAudit_ThreadAuditIssue as ThreadAuditIssue, type threadAudit_ThreadAuditIssueKind as ThreadAuditIssueKind, type threadAudit_ThreadAuditReport as ThreadAuditReport, threadAudit_reconcileThreadState as reconcileThreadState };
1089
+ }
1090
+
763
1091
  /**
764
1092
  * QMD-compatible search adapter.
765
1093
  *
@@ -811,4 +1139,585 @@ declare namespace trigger {
811
1139
  export { type trigger_FireTriggerOptions as FireTriggerOptions, type trigger_FireTriggerResult as FireTriggerResult, trigger_fireTrigger as fireTrigger };
812
1140
  }
813
1141
 
814
- export { type DispatchRun, type FieldDefinition, type LedgerChainState, type LedgerEntry, type LedgerIndex, type LedgerOp, type PolicyParty, type PolicyRegistry, type PrimitiveInstance, type PrimitiveQueryFilters, type PrimitiveTypeDefinition, type Registry, type RunStatus, THREAD_STATUS_TRANSITIONS, type ThreadStatus, type WorkgraphBrief, type WorkgraphStatusSnapshot, type WorkgraphWorkspaceConfig, bases, board, commandCenter, dispatch, graph, ledger, onboard, orientation, policy, query, registry, searchQmdAdapter, skill, store, thread, trigger, workspace };
1142
+ /**
1143
+ * Trigger polling engine, cascade evaluator, and dashboard/status helpers.
1144
+ */
1145
+
1146
+ type TriggerRuntimeStatus = 'ready' | 'cooldown' | 'inactive' | 'error';
1147
+ interface TriggerRuntimeState {
1148
+ fireCount: number;
1149
+ lastEvaluatedAt?: string;
1150
+ lastFiredAt?: string;
1151
+ cooldownUntil?: string;
1152
+ lastError?: string;
1153
+ state?: TriggerRuntimeStatus;
1154
+ lastResult?: Record<string, unknown>;
1155
+ lastEventCursorTs?: string;
1156
+ lastFileScanTs?: string;
1157
+ lastCronBucket?: string;
1158
+ synthesisCursorTs?: string;
1159
+ }
1160
+ interface TriggerStateData {
1161
+ version: number;
1162
+ updatedAt: string;
1163
+ engine: {
1164
+ cycleCount: number;
1165
+ lastCycleAt?: string;
1166
+ intervalSeconds: number;
1167
+ lastError?: string;
1168
+ };
1169
+ triggers: Record<string, TriggerRuntimeState>;
1170
+ }
1171
+ interface TriggerEngineCycleTriggerResult {
1172
+ triggerPath: string;
1173
+ fired: boolean;
1174
+ reason: string;
1175
+ actionType?: string;
1176
+ runtimeState: TriggerRuntimeStatus;
1177
+ error?: string;
1178
+ }
1179
+ interface TriggerEngineCycleResult {
1180
+ cycleAt: string;
1181
+ evaluated: number;
1182
+ fired: number;
1183
+ errors: number;
1184
+ triggers: TriggerEngineCycleTriggerResult[];
1185
+ statePath: string;
1186
+ }
1187
+ interface TriggerEngineCycleOptions {
1188
+ actor?: string;
1189
+ now?: Date;
1190
+ intervalSeconds?: number;
1191
+ }
1192
+ interface StartTriggerEngineOptions {
1193
+ actor?: string;
1194
+ intervalSeconds?: number;
1195
+ maxCycles?: number;
1196
+ logger?: (line: string) => void;
1197
+ }
1198
+ interface TriggerDashboardItem {
1199
+ path: string;
1200
+ title: string;
1201
+ status: string;
1202
+ condition: string;
1203
+ action: string;
1204
+ cooldownSeconds: number;
1205
+ fireCount: number;
1206
+ lastFiredAt?: string;
1207
+ nextFireAt?: string;
1208
+ currentState: TriggerRuntimeStatus;
1209
+ lastError?: string;
1210
+ }
1211
+ interface TriggerDashboard {
1212
+ generatedAt: string;
1213
+ statePath: string;
1214
+ engine: TriggerStateData['engine'];
1215
+ triggers: TriggerDashboardItem[];
1216
+ }
1217
+ interface CascadeEvaluationResult {
1218
+ completedThreadPath: string;
1219
+ evaluated: number;
1220
+ fired: number;
1221
+ errors: number;
1222
+ results: TriggerEngineCycleTriggerResult[];
1223
+ }
1224
+ interface AddSynthesisTriggerOptions {
1225
+ tagPattern: string;
1226
+ threshold: number;
1227
+ actor: string;
1228
+ cooldownSeconds?: number;
1229
+ }
1230
+ interface AddSynthesisTriggerResult {
1231
+ trigger: PrimitiveInstance;
1232
+ }
1233
+ declare function triggerStatePath(workspacePath: string): string;
1234
+ declare function loadTriggerState(workspacePath: string): TriggerStateData;
1235
+ declare function saveTriggerState(workspacePath: string, state: TriggerStateData): void;
1236
+ declare function runTriggerEngineCycle(workspacePath: string, options?: TriggerEngineCycleOptions): TriggerEngineCycleResult;
1237
+ declare function startTriggerEngine(workspacePath: string, options?: StartTriggerEngineOptions): Promise<void>;
1238
+ declare function evaluateThreadCompleteCascadeTriggers(workspacePath: string, completedThreadPath: string, actor?: string, now?: Date): CascadeEvaluationResult;
1239
+ declare function triggerDashboard(workspacePath: string, now?: Date): TriggerDashboard;
1240
+ declare function addSynthesisTrigger(workspacePath: string, options: AddSynthesisTriggerOptions): AddSynthesisTriggerResult;
1241
+
1242
+ type triggerEngine_AddSynthesisTriggerOptions = AddSynthesisTriggerOptions;
1243
+ type triggerEngine_AddSynthesisTriggerResult = AddSynthesisTriggerResult;
1244
+ type triggerEngine_CascadeEvaluationResult = CascadeEvaluationResult;
1245
+ type triggerEngine_StartTriggerEngineOptions = StartTriggerEngineOptions;
1246
+ type triggerEngine_TriggerDashboard = TriggerDashboard;
1247
+ type triggerEngine_TriggerDashboardItem = TriggerDashboardItem;
1248
+ type triggerEngine_TriggerEngineCycleOptions = TriggerEngineCycleOptions;
1249
+ type triggerEngine_TriggerEngineCycleResult = TriggerEngineCycleResult;
1250
+ type triggerEngine_TriggerEngineCycleTriggerResult = TriggerEngineCycleTriggerResult;
1251
+ declare const triggerEngine_addSynthesisTrigger: typeof addSynthesisTrigger;
1252
+ declare const triggerEngine_evaluateThreadCompleteCascadeTriggers: typeof evaluateThreadCompleteCascadeTriggers;
1253
+ declare const triggerEngine_loadTriggerState: typeof loadTriggerState;
1254
+ declare const triggerEngine_runTriggerEngineCycle: typeof runTriggerEngineCycle;
1255
+ declare const triggerEngine_saveTriggerState: typeof saveTriggerState;
1256
+ declare const triggerEngine_startTriggerEngine: typeof startTriggerEngine;
1257
+ declare const triggerEngine_triggerDashboard: typeof triggerDashboard;
1258
+ declare const triggerEngine_triggerStatePath: typeof triggerStatePath;
1259
+ declare namespace triggerEngine {
1260
+ export { type triggerEngine_AddSynthesisTriggerOptions as AddSynthesisTriggerOptions, type triggerEngine_AddSynthesisTriggerResult as AddSynthesisTriggerResult, type triggerEngine_CascadeEvaluationResult as CascadeEvaluationResult, type triggerEngine_StartTriggerEngineOptions as StartTriggerEngineOptions, type triggerEngine_TriggerDashboard as TriggerDashboard, type triggerEngine_TriggerDashboardItem as TriggerDashboardItem, type triggerEngine_TriggerEngineCycleOptions as TriggerEngineCycleOptions, type triggerEngine_TriggerEngineCycleResult as TriggerEngineCycleResult, type triggerEngine_TriggerEngineCycleTriggerResult as TriggerEngineCycleTriggerResult, triggerEngine_addSynthesisTrigger as addSynthesisTrigger, triggerEngine_evaluateThreadCompleteCascadeTriggers as evaluateThreadCompleteCascadeTriggers, triggerEngine_loadTriggerState as loadTriggerState, triggerEngine_runTriggerEngineCycle as runTriggerEngineCycle, triggerEngine_saveTriggerState as saveTriggerState, triggerEngine_startTriggerEngine as startTriggerEngine, triggerEngine_triggerDashboard as triggerDashboard, triggerEngine_triggerStatePath as triggerStatePath };
1261
+ }
1262
+
1263
+ interface AutonomyLoopOptions {
1264
+ actor: string;
1265
+ adapter?: string;
1266
+ agents?: string[];
1267
+ space?: string;
1268
+ pollMs?: number;
1269
+ watch?: boolean;
1270
+ maxCycles?: number;
1271
+ maxIdleCycles?: number;
1272
+ maxSteps?: number;
1273
+ stepDelayMs?: number;
1274
+ staleClaimMinutes?: number;
1275
+ executeTriggers?: boolean;
1276
+ executeReadyThreads?: boolean;
1277
+ heartbeatFile?: string;
1278
+ }
1279
+ interface AutonomyCycleReport {
1280
+ cycle: number;
1281
+ readyThreads: number;
1282
+ triggerActions: number;
1283
+ runId?: string;
1284
+ runStatus?: string;
1285
+ driftOk: boolean;
1286
+ driftIssues: number;
1287
+ }
1288
+ interface AutonomyLoopResult {
1289
+ cycles: AutonomyCycleReport[];
1290
+ finalReadyThreads: number;
1291
+ finalDriftOk: boolean;
1292
+ }
1293
+ declare function runAutonomyLoop(workspacePath: string, options: AutonomyLoopOptions): Promise<AutonomyLoopResult>;
1294
+
1295
+ type autonomy_AutonomyCycleReport = AutonomyCycleReport;
1296
+ type autonomy_AutonomyLoopOptions = AutonomyLoopOptions;
1297
+ type autonomy_AutonomyLoopResult = AutonomyLoopResult;
1298
+ declare const autonomy_runAutonomyLoop: typeof runAutonomyLoop;
1299
+ declare namespace autonomy {
1300
+ export { type autonomy_AutonomyCycleReport as AutonomyCycleReport, type autonomy_AutonomyLoopOptions as AutonomyLoopOptions, type autonomy_AutonomyLoopResult as AutonomyLoopResult, autonomy_runAutonomyLoop as runAutonomyLoop };
1301
+ }
1302
+
1303
+ interface SkillIntegrationProvider {
1304
+ id: string;
1305
+ defaultTitle: string;
1306
+ defaultSourceUrl: string;
1307
+ distribution: string;
1308
+ defaultTags: string[];
1309
+ userAgent?: string;
1310
+ }
1311
+ interface InstallSkillIntegrationOptions {
1312
+ actor: string;
1313
+ owner?: string;
1314
+ title?: string;
1315
+ sourceUrl?: string;
1316
+ force?: boolean;
1317
+ status?: WriteSkillOptions['status'];
1318
+ tags?: string[];
1319
+ fetchSkillMarkdown?: (sourceUrl: string) => Promise<string>;
1320
+ }
1321
+ interface InstallSkillIntegrationResult {
1322
+ provider: string;
1323
+ skill: PrimitiveInstance;
1324
+ sourceUrl: string;
1325
+ importedAt: string;
1326
+ replacedExisting: boolean;
1327
+ }
1328
+ declare function installSkillIntegration(workspacePath: string, provider: SkillIntegrationProvider, options: InstallSkillIntegrationOptions): Promise<InstallSkillIntegrationResult>;
1329
+ declare function fetchSkillMarkdownFromUrl(sourceUrl: string, userAgent?: string): Promise<string>;
1330
+
1331
+ declare const DEFAULT_CLAWDAPUS_SKILL_URL = "https://raw.githubusercontent.com/mostlydev/clawdapus/master/skills/clawdapus/SKILL.md";
1332
+ declare const CLAWDAPUS_INTEGRATION_PROVIDER: SkillIntegrationProvider;
1333
+ type InstallClawdapusSkillOptions = InstallSkillIntegrationOptions;
1334
+ type InstallClawdapusSkillResult = InstallSkillIntegrationResult;
1335
+ declare function installClawdapusSkill(workspacePath: string, options: InstallClawdapusSkillOptions): Promise<InstallClawdapusSkillResult>;
1336
+ declare function fetchClawdapusSkillMarkdown(sourceUrl: string): Promise<string>;
1337
+
1338
+ declare const clawdapus_CLAWDAPUS_INTEGRATION_PROVIDER: typeof CLAWDAPUS_INTEGRATION_PROVIDER;
1339
+ declare const clawdapus_DEFAULT_CLAWDAPUS_SKILL_URL: typeof DEFAULT_CLAWDAPUS_SKILL_URL;
1340
+ type clawdapus_InstallClawdapusSkillOptions = InstallClawdapusSkillOptions;
1341
+ type clawdapus_InstallClawdapusSkillResult = InstallClawdapusSkillResult;
1342
+ declare const clawdapus_fetchClawdapusSkillMarkdown: typeof fetchClawdapusSkillMarkdown;
1343
+ declare const clawdapus_installClawdapusSkill: typeof installClawdapusSkill;
1344
+ declare namespace clawdapus {
1345
+ export { clawdapus_CLAWDAPUS_INTEGRATION_PROVIDER as CLAWDAPUS_INTEGRATION_PROVIDER, clawdapus_DEFAULT_CLAWDAPUS_SKILL_URL as DEFAULT_CLAWDAPUS_SKILL_URL, type clawdapus_InstallClawdapusSkillOptions as InstallClawdapusSkillOptions, type clawdapus_InstallClawdapusSkillResult as InstallClawdapusSkillResult, clawdapus_fetchClawdapusSkillMarkdown as fetchClawdapusSkillMarkdown, clawdapus_installClawdapusSkill as installClawdapusSkill };
1346
+ }
1347
+
1348
+ interface IntegrationDescriptor {
1349
+ id: string;
1350
+ description: string;
1351
+ defaultTitle: string;
1352
+ defaultSourceUrl: string;
1353
+ }
1354
+ declare function listIntegrations(): IntegrationDescriptor[];
1355
+ declare function installIntegration(workspacePath: string, integrationId: string, options: InstallSkillIntegrationOptions): Promise<InstallSkillIntegrationResult>;
1356
+
1357
+ type integration_IntegrationDescriptor = IntegrationDescriptor;
1358
+ declare const integration_installIntegration: typeof installIntegration;
1359
+ declare const integration_listIntegrations: typeof listIntegrations;
1360
+ declare namespace integration {
1361
+ export { type integration_IntegrationDescriptor as IntegrationDescriptor, integration_installIntegration as installIntegration, integration_listIntegrations as listIntegrations };
1362
+ }
1363
+
1364
+ /**
1365
+ * Lightweight 5-field cron parsing and matching utilities.
1366
+ *
1367
+ * Supported field syntax:
1368
+ * - "*" (any value)
1369
+ * - step syntax (for example, star-slash-5 to mean every 5 units)
1370
+ * - "a,b,c" (list)
1371
+ * - "a-b" (range)
1372
+ * - "a-b/n" (range with step)
1373
+ * - "n" (single value)
1374
+ */
1375
+ interface CronField {
1376
+ all: boolean;
1377
+ values: Set<number>;
1378
+ }
1379
+ interface CronSchedule {
1380
+ expression: string;
1381
+ minute: CronField;
1382
+ hour: CronField;
1383
+ dayOfMonth: CronField;
1384
+ month: CronField;
1385
+ dayOfWeek: CronField;
1386
+ }
1387
+ declare function parseCronExpression(expression: string): CronSchedule;
1388
+ declare function matchesCronSchedule(schedule: CronSchedule, date: Date): boolean;
1389
+ declare function nextCronMatch(scheduleOrExpression: CronSchedule | string, after: Date, maxSearchMinutes?: number): Date | null;
1390
+
1391
+ type DoctorSeverity = 'warning' | 'error';
1392
+ interface DoctorIssue {
1393
+ code: string;
1394
+ severity: DoctorSeverity;
1395
+ message: string;
1396
+ path?: string;
1397
+ details?: Record<string, unknown>;
1398
+ }
1399
+ interface DoctorChecks {
1400
+ orphanWikiLinks: number;
1401
+ staleClaims: number;
1402
+ staleRuns: number;
1403
+ missingRequiredFields: number;
1404
+ brokenPrimitiveRegistryReferences: number;
1405
+ emptyPrimitiveDirectories: number;
1406
+ duplicateSlugs: number;
1407
+ }
1408
+ interface DoctorFixSummary {
1409
+ enabled: boolean;
1410
+ orphanLinksRemoved: number;
1411
+ staleClaimsReleased: number;
1412
+ staleRunsCancelled: number;
1413
+ filesUpdated: string[];
1414
+ errors: string[];
1415
+ }
1416
+ interface DoctorReport {
1417
+ generatedAt: string;
1418
+ workspacePath: string;
1419
+ ok: boolean;
1420
+ summary: {
1421
+ errors: number;
1422
+ warnings: number;
1423
+ };
1424
+ checks: DoctorChecks;
1425
+ issues: DoctorIssue[];
1426
+ fixes: DoctorFixSummary;
1427
+ }
1428
+ interface DoctorOptions {
1429
+ fix?: boolean;
1430
+ actor?: string;
1431
+ staleAfterMs?: number;
1432
+ }
1433
+ declare function diagnoseVaultHealth(workspacePath: string, options?: DoctorOptions): DoctorReport;
1434
+
1435
+ type ReplayEventTypeFilter = 'create' | 'update' | 'transition';
1436
+ interface ReplayOptions {
1437
+ type?: ReplayEventTypeFilter;
1438
+ actor?: string;
1439
+ primitive?: string;
1440
+ since?: string;
1441
+ until?: string;
1442
+ color?: boolean;
1443
+ }
1444
+ interface ReplayUpdateDiff {
1445
+ changedFields: string[];
1446
+ statusTransition?: {
1447
+ from: string | null;
1448
+ to: string | null;
1449
+ };
1450
+ }
1451
+ interface ReplayEvent {
1452
+ ts: string;
1453
+ actor: string;
1454
+ op: string;
1455
+ target: string;
1456
+ primitiveType?: string;
1457
+ category: ReplayEventTypeFilter;
1458
+ diff?: ReplayUpdateDiff;
1459
+ }
1460
+ interface ReplayReport {
1461
+ generatedAt: string;
1462
+ workspacePath: string;
1463
+ filters: {
1464
+ type?: ReplayEventTypeFilter;
1465
+ actor?: string;
1466
+ primitive?: string;
1467
+ since?: string;
1468
+ until?: string;
1469
+ };
1470
+ totalEvents: number;
1471
+ events: ReplayEvent[];
1472
+ }
1473
+ declare function replayLedger(workspacePath: string, options?: ReplayOptions): ReplayReport;
1474
+ declare function renderReplayText(report: ReplayReport, options?: {
1475
+ color?: boolean;
1476
+ }): string[];
1477
+
1478
+ interface VizOptions {
1479
+ focus?: string;
1480
+ depth?: number;
1481
+ top?: number;
1482
+ color?: boolean;
1483
+ }
1484
+ interface VizReport {
1485
+ generatedAt: string;
1486
+ workspacePath: string;
1487
+ nodeCount: number;
1488
+ edgeCount: number;
1489
+ hubs: Array<{
1490
+ path: string;
1491
+ degree: number;
1492
+ }>;
1493
+ focus?: string;
1494
+ rendered: string;
1495
+ }
1496
+ declare function visualizeVaultGraph(workspacePath: string, options?: VizOptions): VizReport;
1497
+
1498
+ interface VaultStats {
1499
+ generatedAt: string;
1500
+ workspacePath: string;
1501
+ primitives: {
1502
+ total: number;
1503
+ byType: Record<string, number>;
1504
+ };
1505
+ links: {
1506
+ total: number;
1507
+ wikiLinkDensity: number;
1508
+ graphDensityRatio: number;
1509
+ orphanCount: number;
1510
+ orphanNodeCount: number;
1511
+ mostConnectedNodes: Array<{
1512
+ path: string;
1513
+ degree: number;
1514
+ }>;
1515
+ };
1516
+ frontmatter: {
1517
+ averageCompleteness: number;
1518
+ byType: Record<string, number>;
1519
+ };
1520
+ ledger: {
1521
+ totalEvents: number;
1522
+ eventRatePerDay: {
1523
+ average: number;
1524
+ byDay: Array<{
1525
+ day: string;
1526
+ count: number;
1527
+ }>;
1528
+ };
1529
+ };
1530
+ threads: {
1531
+ completedCount: number;
1532
+ averageOpenToDoneHours: number;
1533
+ };
1534
+ }
1535
+ declare function computeVaultStats(workspacePath: string): VaultStats;
1536
+
1537
+ interface ChangelogOptions {
1538
+ since: string;
1539
+ until?: string;
1540
+ }
1541
+ interface ChangelogItem {
1542
+ ts: string;
1543
+ actor: string;
1544
+ op: string;
1545
+ target: string;
1546
+ summary?: string;
1547
+ }
1548
+ interface ChangelogTypeGroup {
1549
+ primitiveType: string;
1550
+ items: ChangelogItem[];
1551
+ }
1552
+ interface ChangelogDayGroup {
1553
+ day: string;
1554
+ created: ChangelogTypeGroup[];
1555
+ updated: ChangelogTypeGroup[];
1556
+ completed: ChangelogTypeGroup[];
1557
+ }
1558
+ interface ChangelogReport {
1559
+ generatedAt: string;
1560
+ workspacePath: string;
1561
+ since: string;
1562
+ until?: string;
1563
+ totalEvents: number;
1564
+ days: ChangelogDayGroup[];
1565
+ }
1566
+ declare function generateLedgerChangelog(workspacePath: string, options: ChangelogOptions): ChangelogReport;
1567
+ declare function renderChangelogText(report: ChangelogReport): string[];
1568
+
1569
+ declare function renderDoctorReport(report: DoctorReport): string[];
1570
+ declare function renderStatsReport(stats: VaultStats): string[];
1571
+
1572
+ type index_ChangelogDayGroup = ChangelogDayGroup;
1573
+ type index_ChangelogItem = ChangelogItem;
1574
+ type index_ChangelogOptions = ChangelogOptions;
1575
+ type index_ChangelogReport = ChangelogReport;
1576
+ type index_ChangelogTypeGroup = ChangelogTypeGroup;
1577
+ type index_DoctorChecks = DoctorChecks;
1578
+ type index_DoctorFixSummary = DoctorFixSummary;
1579
+ type index_DoctorIssue = DoctorIssue;
1580
+ type index_DoctorOptions = DoctorOptions;
1581
+ type index_DoctorReport = DoctorReport;
1582
+ type index_DoctorSeverity = DoctorSeverity;
1583
+ type index_ReplayEvent = ReplayEvent;
1584
+ type index_ReplayEventTypeFilter = ReplayEventTypeFilter;
1585
+ type index_ReplayOptions = ReplayOptions;
1586
+ type index_ReplayReport = ReplayReport;
1587
+ type index_ReplayUpdateDiff = ReplayUpdateDiff;
1588
+ type index_VaultStats = VaultStats;
1589
+ type index_VizOptions = VizOptions;
1590
+ type index_VizReport = VizReport;
1591
+ declare const index_computeVaultStats: typeof computeVaultStats;
1592
+ declare const index_diagnoseVaultHealth: typeof diagnoseVaultHealth;
1593
+ declare const index_generateLedgerChangelog: typeof generateLedgerChangelog;
1594
+ declare const index_renderChangelogText: typeof renderChangelogText;
1595
+ declare const index_renderDoctorReport: typeof renderDoctorReport;
1596
+ declare const index_renderReplayText: typeof renderReplayText;
1597
+ declare const index_renderStatsReport: typeof renderStatsReport;
1598
+ declare const index_replayLedger: typeof replayLedger;
1599
+ declare const index_visualizeVaultGraph: typeof visualizeVaultGraph;
1600
+ declare namespace index {
1601
+ export { type index_ChangelogDayGroup as ChangelogDayGroup, type index_ChangelogItem as ChangelogItem, type index_ChangelogOptions as ChangelogOptions, type index_ChangelogReport as ChangelogReport, type index_ChangelogTypeGroup as ChangelogTypeGroup, type index_DoctorChecks as DoctorChecks, type index_DoctorFixSummary as DoctorFixSummary, type index_DoctorIssue as DoctorIssue, type index_DoctorOptions as DoctorOptions, type index_DoctorReport as DoctorReport, type index_DoctorSeverity as DoctorSeverity, type index_ReplayEvent as ReplayEvent, type index_ReplayEventTypeFilter as ReplayEventTypeFilter, type index_ReplayOptions as ReplayOptions, type index_ReplayReport as ReplayReport, type index_ReplayUpdateDiff as ReplayUpdateDiff, type index_VaultStats as VaultStats, type index_VizOptions as VizOptions, type index_VizReport as VizReport, index_computeVaultStats as computeVaultStats, index_diagnoseVaultHealth as diagnoseVaultHealth, index_generateLedgerChangelog as generateLedgerChangelog, index_renderChangelogText as renderChangelogText, index_renderDoctorReport as renderDoctorReport, index_renderReplayText as renderReplayText, index_renderStatsReport as renderStatsReport, index_replayLedger as replayLedger, index_visualizeVaultGraph as visualizeVaultGraph };
1602
+ }
1603
+
1604
+ interface AutonomyDaemonStartInput {
1605
+ cliEntrypointPath: string;
1606
+ actor: string;
1607
+ adapter?: string;
1608
+ agents?: string[];
1609
+ pollMs?: number;
1610
+ maxCycles?: number;
1611
+ maxIdleCycles?: number;
1612
+ maxSteps?: number;
1613
+ stepDelayMs?: number;
1614
+ space?: string;
1615
+ staleClaimMinutes?: number;
1616
+ executeTriggers?: boolean;
1617
+ executeReadyThreads?: boolean;
1618
+ logPath?: string;
1619
+ heartbeatPath?: string;
1620
+ }
1621
+ interface AutonomyDaemonStopInput {
1622
+ signal?: NodeJS.Signals;
1623
+ timeoutMs?: number;
1624
+ }
1625
+ interface AutonomyDaemonHeartbeat {
1626
+ ts: string;
1627
+ cycle?: number;
1628
+ readyThreads?: number;
1629
+ triggerActions?: number;
1630
+ runStatus?: string;
1631
+ driftOk?: boolean;
1632
+ driftIssues?: number;
1633
+ finalReadyThreads?: number;
1634
+ finalDriftOk?: boolean;
1635
+ }
1636
+ interface AutonomyDaemonStatus {
1637
+ running: boolean;
1638
+ pid?: number;
1639
+ pidPath: string;
1640
+ logPath: string;
1641
+ heartbeatPath: string;
1642
+ heartbeat?: AutonomyDaemonHeartbeat;
1643
+ }
1644
+ interface AutonomyDaemonStopResult {
1645
+ stopped: boolean;
1646
+ previouslyRunning: boolean;
1647
+ pid?: number;
1648
+ status: AutonomyDaemonStatus;
1649
+ }
1650
+ declare function startAutonomyDaemon(workspacePath: string, input: AutonomyDaemonStartInput): AutonomyDaemonStatus;
1651
+ declare function stopAutonomyDaemon(workspacePath: string, input?: AutonomyDaemonStopInput): Promise<AutonomyDaemonStopResult>;
1652
+ declare function readAutonomyDaemonStatus(workspacePath: string, options?: {
1653
+ cleanupStalePidFile?: boolean;
1654
+ }): AutonomyDaemonStatus;
1655
+
1656
+ type autonomyDaemon_AutonomyDaemonHeartbeat = AutonomyDaemonHeartbeat;
1657
+ type autonomyDaemon_AutonomyDaemonStartInput = AutonomyDaemonStartInput;
1658
+ type autonomyDaemon_AutonomyDaemonStatus = AutonomyDaemonStatus;
1659
+ type autonomyDaemon_AutonomyDaemonStopInput = AutonomyDaemonStopInput;
1660
+ type autonomyDaemon_AutonomyDaemonStopResult = AutonomyDaemonStopResult;
1661
+ declare const autonomyDaemon_readAutonomyDaemonStatus: typeof readAutonomyDaemonStatus;
1662
+ declare const autonomyDaemon_startAutonomyDaemon: typeof startAutonomyDaemon;
1663
+ declare const autonomyDaemon_stopAutonomyDaemon: typeof stopAutonomyDaemon;
1664
+ declare namespace autonomyDaemon {
1665
+ export { type autonomyDaemon_AutonomyDaemonHeartbeat as AutonomyDaemonHeartbeat, type autonomyDaemon_AutonomyDaemonStartInput as AutonomyDaemonStartInput, type autonomyDaemon_AutonomyDaemonStatus as AutonomyDaemonStatus, type autonomyDaemon_AutonomyDaemonStopInput as AutonomyDaemonStopInput, type autonomyDaemon_AutonomyDaemonStopResult as AutonomyDaemonStopResult, autonomyDaemon_readAutonomyDaemonStatus as readAutonomyDaemonStatus, autonomyDaemon_startAutonomyDaemon as startAutonomyDaemon, autonomyDaemon_stopAutonomyDaemon as stopAutonomyDaemon };
1666
+ }
1667
+
1668
+ interface DispatchAdapterCreateInput {
1669
+ actor: string;
1670
+ objective: string;
1671
+ idempotencyKey?: string;
1672
+ context?: Record<string, unknown>;
1673
+ }
1674
+ interface DispatchAdapterRunStatus {
1675
+ runId: string;
1676
+ status: RunStatus;
1677
+ }
1678
+ interface DispatchAdapterLogEntry {
1679
+ ts: string;
1680
+ level: 'info' | 'warn' | 'error';
1681
+ message: string;
1682
+ }
1683
+ interface DispatchAdapterExecutionInput {
1684
+ workspacePath: string;
1685
+ runId: string;
1686
+ actor: string;
1687
+ objective: string;
1688
+ context?: Record<string, unknown>;
1689
+ agents?: string[];
1690
+ maxSteps?: number;
1691
+ stepDelayMs?: number;
1692
+ space?: string;
1693
+ createCheckpoint?: boolean;
1694
+ isCancelled?: () => boolean;
1695
+ }
1696
+ interface DispatchAdapterExecutionResult {
1697
+ status: RunStatus;
1698
+ output?: string;
1699
+ error?: string;
1700
+ logs: DispatchAdapterLogEntry[];
1701
+ metrics?: Record<string, unknown>;
1702
+ }
1703
+ interface DispatchAdapter {
1704
+ name: string;
1705
+ create(input: DispatchAdapterCreateInput): Promise<DispatchAdapterRunStatus>;
1706
+ status(runId: string): Promise<DispatchAdapterRunStatus>;
1707
+ followup(runId: string, actor: string, input: string): Promise<DispatchAdapterRunStatus>;
1708
+ stop(runId: string, actor: string): Promise<DispatchAdapterRunStatus>;
1709
+ logs(runId: string): Promise<DispatchAdapterLogEntry[]>;
1710
+ execute?(input: DispatchAdapterExecutionInput): Promise<DispatchAdapterExecutionResult>;
1711
+ }
1712
+
1713
+ declare class CursorCloudAdapter implements DispatchAdapter {
1714
+ name: string;
1715
+ create(_input: DispatchAdapterCreateInput): Promise<DispatchAdapterRunStatus>;
1716
+ status(runId: string): Promise<DispatchAdapterRunStatus>;
1717
+ followup(runId: string, _actor: string, _input: string): Promise<DispatchAdapterRunStatus>;
1718
+ stop(runId: string, _actor: string): Promise<DispatchAdapterRunStatus>;
1719
+ logs(_runId: string): Promise<DispatchAdapterLogEntry[]>;
1720
+ execute(input: DispatchAdapterExecutionInput): Promise<DispatchAdapterExecutionResult>;
1721
+ }
1722
+
1723
+ export { type CronField, type CronSchedule, CursorCloudAdapter, type DispatchAdapter, type DispatchAdapterCreateInput, type DispatchAdapterExecutionInput, type DispatchAdapterExecutionResult, type DispatchAdapterLogEntry, type DispatchAdapterRunStatus, type DispatchRun, type FieldDefinition, type InstallSkillIntegrationOptions, type InstallSkillIntegrationResult, type LedgerChainState, type LedgerEntry, type LedgerIndex, type LedgerOp, type PolicyParty, type PolicyRegistry, type PrimitiveInstance, type PrimitiveQueryFilters, type PrimitiveTypeDefinition, type Registry, type RunStatus, type SkillIntegrationProvider, THREAD_STATUS_TRANSITIONS, type ThreadStatus, type WorkgraphBrief, type WorkgraphStatusSnapshot, type WorkgraphWorkspaceConfig, agent, autonomy, autonomyDaemon, bases, board, claimLease, clawdapus, commandCenter, index as diagnostics, dispatch, fetchSkillMarkdownFromUrl, gate, graph, installSkillIntegration, integration, ledger, matchesCronSchedule, nextCronMatch, onboard, orientation, parseCronExpression, policy, query, registry, searchQmdAdapter, skill, store, thread, threadAudit, trigger, triggerEngine, workspace };