@adhdev/daemon-core 0.9.82-rc.48 → 0.9.82-rc.49

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.
@@ -0,0 +1,9 @@
1
+ import type { RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostStatus } from '../repo-mesh-types.js';
2
+ export declare function normalizeMeshDaemonRole(value: unknown): RepoMeshDaemonRole | undefined;
3
+ export declare function resolveMeshHostStatus(mesh: unknown): RepoMeshHostStatus;
4
+ export declare function isMeshHostOwner(mesh: unknown): boolean;
5
+ export declare function buildMeshHostRequiredFailure(mesh: unknown, operation: string): Record<string, unknown>;
6
+ export declare function requireMeshHostQueueOwner(opts?: {
7
+ ownerRole?: RepoMeshDaemonRole;
8
+ }): void;
9
+ export declare function createDefaultMeshHostMetadata(): RepoMeshHostMetadata;
@@ -13,7 +13,7 @@
13
13
  * Safety: mode 0o600, atomic append via appendFileSync
14
14
  */
15
15
  import { EventEmitter } from 'events';
16
- export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled';
16
+ export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_joined' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled';
17
17
  export interface MeshLedgerEntry {
18
18
  id: string;
19
19
  meshId: string;
@@ -1,3 +1,4 @@
1
+ import type { RepoMeshDaemonRole } from '../repo-mesh-types.js';
1
2
  export type MeshTaskStatus = 'pending' | 'assigned' | 'completed' | 'failed' | 'cancelled';
2
3
  export type MeshActiveTaskStatus = Extract<MeshTaskStatus, 'pending' | 'assigned'>;
3
4
  export type MeshHistoricalTaskStatus = Extract<MeshTaskStatus, 'completed' | 'failed' | 'cancelled'>;
@@ -37,13 +38,16 @@ export interface MeshWorkQueueEntry {
37
38
  createdAt: string;
38
39
  updatedAt: string;
39
40
  }
41
+ export interface MeshQueueMutationOptions {
42
+ ownerRole?: RepoMeshDaemonRole;
43
+ }
40
44
  /**
41
45
  * Add a new task to the mesh queue.
42
46
  */
43
47
  export declare function enqueueTask(meshId: string, message: string, opts?: {
44
48
  targetNodeId?: string;
45
49
  targetSessionId?: string;
46
- }): MeshWorkQueueEntry;
50
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry;
47
51
  /**
48
52
  * Get all tasks in the queue, optionally filtered by status.
49
53
  */
@@ -58,14 +62,14 @@ export declare function claimNextTask(meshId: string, nodeId: string, sessionId:
58
62
  * Update the status of a specific task.
59
63
  * Used when a session completes, fails, or stalls.
60
64
  */
61
- export declare function updateTaskStatus(meshId: string, taskId: string, status: MeshTaskStatus): MeshWorkQueueEntry | null;
65
+ export declare function updateTaskStatus(meshId: string, taskId: string, status: MeshTaskStatus, opts?: MeshQueueMutationOptions): MeshWorkQueueEntry | null;
62
66
  export declare function recordTaskAutoLaunch(meshId: string, taskId: string, autoLaunch: Omit<NonNullable<MeshWorkQueueEntry['autoLaunch']>, 'updatedAt'>): MeshWorkQueueEntry | null;
63
67
  /**
64
68
  * Mark a queue task as manually cancelled without deleting audit history.
65
69
  */
66
70
  export declare function cancelTask(meshId: string, taskId: string, opts?: {
67
71
  reason?: string;
68
- }): MeshWorkQueueEntry | null;
72
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry | null;
69
73
  /**
70
74
  * Return a queue task to pending for retry. By default, dead session targeting
71
75
  * and assigned ownership are cleared so stale assignments do not strand again.
@@ -76,7 +80,7 @@ export declare function requeueTask(meshId: string, taskId: string, opts?: {
76
80
  targetSessionId?: string;
77
81
  clearTargetNode?: boolean;
78
82
  clearTargetSession?: boolean;
79
- }): MeshWorkQueueEntry | null;
83
+ } & MeshQueueMutationOptions): MeshWorkQueueEntry | null;
80
84
  /**
81
85
  * Update the status of the task currently assigned to a specific session.
82
86
  */
@@ -0,0 +1,119 @@
1
+ export declare const MESH_REFINE_VALIDATION_CATEGORIES: readonly ["typecheck", "test", "lint", "build"];
2
+ export type MeshRefineValidationCategory = typeof MESH_REFINE_VALIDATION_CATEGORIES[number];
3
+ export interface RepoMeshRefineValidationCommandConfig {
4
+ /** Executable name or a whitespace-tokenized command string. Never executed through a shell. */
5
+ command: string;
6
+ /** Optional explicit argv. Prefer this over shell-like command strings. */
7
+ args?: string[];
8
+ category?: MeshRefineValidationCategory;
9
+ cwd?: string;
10
+ timeoutMs?: number;
11
+ env?: Record<string, string>;
12
+ }
13
+ export interface RepoMeshRefineConfig {
14
+ version: 1;
15
+ validation?: {
16
+ required?: boolean;
17
+ commands?: RepoMeshRefineValidationCommandConfig[];
18
+ };
19
+ }
20
+ export interface MeshRefineValidationCommandPlan {
21
+ command: string;
22
+ args: string[];
23
+ displayCommand: string;
24
+ category: MeshRefineValidationCategory | 'custom';
25
+ source: string;
26
+ cwd?: string;
27
+ timeoutMs?: number;
28
+ env?: Record<string, string>;
29
+ }
30
+ export interface MeshRefineConfigLoadResult {
31
+ config?: RepoMeshRefineConfig;
32
+ source: string;
33
+ sourceType: 'mesh_policy' | 'repo_file' | 'unavailable' | 'invalid';
34
+ path?: string;
35
+ error?: string;
36
+ }
37
+ export interface MeshRefineValidationPlan {
38
+ source: string;
39
+ sourceType: MeshRefineConfigLoadResult['sourceType'];
40
+ commands: MeshRefineValidationCommandPlan[];
41
+ rejectedCommands: Array<Record<string, unknown>>;
42
+ suggestions: RepoMeshRefineValidationCommandConfig[];
43
+ suggestedConfig?: RepoMeshRefineConfig;
44
+ unavailableReason?: string;
45
+ }
46
+ export declare const MESH_REFINE_CONFIG_LOCATIONS: string[];
47
+ export declare const MESH_REFINE_CONFIG_SCHEMA: {
48
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
49
+ readonly title: "ADHDev Repo Mesh Refinery Config";
50
+ readonly type: "object";
51
+ readonly additionalProperties: false;
52
+ readonly required: readonly ["version"];
53
+ readonly properties: {
54
+ readonly version: {
55
+ readonly const: 1;
56
+ };
57
+ readonly validation: {
58
+ readonly type: "object";
59
+ readonly additionalProperties: false;
60
+ readonly properties: {
61
+ readonly required: {
62
+ readonly type: "boolean";
63
+ readonly default: true;
64
+ };
65
+ readonly commands: {
66
+ readonly type: "array";
67
+ readonly minItems: 1;
68
+ readonly maxItems: 8;
69
+ readonly items: {
70
+ readonly type: "object";
71
+ readonly additionalProperties: false;
72
+ readonly required: readonly ["command"];
73
+ readonly properties: {
74
+ readonly command: {
75
+ readonly type: "string";
76
+ readonly minLength: 1;
77
+ };
78
+ readonly args: {
79
+ readonly type: "array";
80
+ readonly items: {
81
+ readonly type: "string";
82
+ };
83
+ };
84
+ readonly category: {
85
+ readonly enum: readonly ["typecheck", "test", "lint", "build", "custom"];
86
+ };
87
+ readonly cwd: {
88
+ readonly type: "string";
89
+ };
90
+ readonly timeoutMs: {
91
+ readonly type: "number";
92
+ readonly minimum: 1000;
93
+ readonly maximum: 600000;
94
+ };
95
+ readonly env: {
96
+ readonly type: "object";
97
+ readonly additionalProperties: {
98
+ readonly type: "string";
99
+ };
100
+ };
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ };
107
+ };
108
+ export declare function validateMeshRefineConfig(config: unknown, source?: string): {
109
+ valid: boolean;
110
+ errors: string[];
111
+ commands: MeshRefineValidationCommandPlan[];
112
+ rejectedCommands: Array<Record<string, unknown>>;
113
+ };
114
+ export declare function loadMeshRefineConfig(mesh: any, workspace: string): MeshRefineConfigLoadResult;
115
+ export declare function suggestMeshRefineConfig(mesh: any, workspace: string): {
116
+ suggestions: RepoMeshRefineValidationCommandConfig[];
117
+ suggestedConfig?: RepoMeshRefineConfig;
118
+ };
119
+ export declare function resolveMeshRefineValidationPlan(mesh: any, workspace: string): MeshRefineValidationPlan;
@@ -19,10 +19,37 @@ export interface RepoMesh {
19
19
  defaultBranch?: string;
20
20
  policy: RepoMeshPolicy;
21
21
  coordinator: RepoMeshCoordinatorConfig;
22
+ meshHost?: RepoMeshHostMetadata;
22
23
  projectContext: ProjectContextSnapshot;
23
24
  nodes: RepoMeshNode[];
24
25
  status: 'active' | 'archived' | 'deleted';
25
26
  }
27
+ export type RepoMeshDaemonRole = 'host' | 'member';
28
+ export interface RepoMeshHostPairingMetadata {
29
+ status: 'not_configured' | 'pairing' | 'paired' | 'rejected' | 'revoked';
30
+ tokenId?: string;
31
+ joinedAt?: string;
32
+ lastPairedAt?: string;
33
+ lastRejectedAt?: string;
34
+ expiresAt?: string;
35
+ }
36
+ export interface RepoMeshHostMetadata {
37
+ /** Local daemon role for this mesh. Missing metadata defaults to host for standalone compatibility. */
38
+ role: RepoMeshDaemonRole;
39
+ /** Daemon that owns mesh truth/status/git/queue/session/ledger/coordinator ownership. */
40
+ hostDaemonId?: string;
41
+ /** Mesh node that represents the host daemon, when known. */
42
+ hostNodeId?: string;
43
+ /** Future standalone manual pairing endpoint entered by member daemons. */
44
+ hostAddress?: string;
45
+ /** Redacted pairing state only; raw join tokens must not be persisted here. */
46
+ pairing?: RepoMeshHostPairingMetadata;
47
+ }
48
+ export interface RepoMeshHostStatus extends RepoMeshHostMetadata {
49
+ canOwnCoordinator: boolean;
50
+ canOwnQueue: boolean;
51
+ defaulted: boolean;
52
+ }
26
53
  export interface RepoMeshNode {
27
54
  id: string;
28
55
  daemonId: string;
@@ -37,6 +64,7 @@ export interface RepoMeshNode {
37
64
  effectiveCapabilities: RepoMeshNodeCapabilities;
38
65
  policy: RepoMeshNodePolicy;
39
66
  health: RepoMeshNodeHealth;
67
+ role?: RepoMeshDaemonRole;
40
68
  status: 'enabled' | 'disabled' | 'removed';
41
69
  }
42
70
  export type RepoMeshNodeHealth = 'online' | 'offline' | 'degraded' | 'dirty' | 'wrong_branch' | 'unknown';
@@ -185,6 +213,7 @@ export interface LocalMeshEntry {
185
213
  defaultBranch?: string;
186
214
  policy: RepoMeshPolicy;
187
215
  coordinator: RepoMeshCoordinatorConfig;
216
+ meshHost?: RepoMeshHostMetadata;
188
217
  nodes: LocalMeshNodeEntry[];
189
218
  createdAt: string;
190
219
  updatedAt: string;
@@ -206,6 +235,7 @@ export interface LocalMeshNodeEntry {
206
235
  clonedFromNodeId?: string;
207
236
  /** Optional associated/external repos configured as node metadata. */
208
237
  relatedRepos?: RepoMeshRelatedRepo[];
238
+ role?: RepoMeshDaemonRole;
209
239
  }
210
240
  export interface RepoMeshStatus {
211
241
  meshId: string;
@@ -213,6 +243,7 @@ export interface RepoMeshStatus {
213
243
  repoIdentity: string;
214
244
  defaultBranch?: string;
215
245
  refreshedAt: string;
246
+ meshHost?: RepoMeshHostStatus;
216
247
  nodes: RepoMeshNodeStatus[];
217
248
  queue?: RepoMeshQueueStatus;
218
249
  ledger?: RepoMeshLedgerStatus;
@@ -249,6 +280,7 @@ export interface RepoMeshNodeStatus {
249
280
  repoRoot?: string;
250
281
  daemonId?: string;
251
282
  machineId?: string;
283
+ role?: RepoMeshDaemonRole;
252
284
  machineStatus?: string;
253
285
  isLocalWorktree?: boolean;
254
286
  worktreeBranch?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.48",
3
+ "version": "0.9.82-rc.49",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",