@eddacraft/anvil-runtime 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/LICENSE +14 -0
  2. package/dist/cache/cache-key.d.ts +45 -0
  3. package/dist/cache/cache-key.d.ts.map +1 -0
  4. package/dist/cache/cache-key.js +135 -0
  5. package/dist/cache/index.d.ts +27 -0
  6. package/dist/cache/index.d.ts.map +1 -0
  7. package/dist/cache/index.js +38 -0
  8. package/dist/cache/providers/file-cache.d.ts +63 -0
  9. package/dist/cache/providers/file-cache.d.ts.map +1 -0
  10. package/dist/cache/providers/file-cache.js +369 -0
  11. package/dist/cache/providers/memory-cache.d.ts +52 -0
  12. package/dist/cache/providers/memory-cache.d.ts.map +1 -0
  13. package/dist/cache/providers/memory-cache.js +197 -0
  14. package/dist/cache/providers/null-cache.d.ts +26 -0
  15. package/dist/cache/providers/null-cache.d.ts.map +1 -0
  16. package/dist/cache/providers/null-cache.js +50 -0
  17. package/dist/cache/types.d.ts +114 -0
  18. package/dist/cache/types.d.ts.map +1 -0
  19. package/dist/cache/types.js +4 -0
  20. package/dist/concurrency/agent.d.ts +137 -0
  21. package/dist/concurrency/agent.d.ts.map +1 -0
  22. package/dist/concurrency/agent.js +440 -0
  23. package/dist/concurrency/atomic.d.ts +93 -0
  24. package/dist/concurrency/atomic.d.ts.map +1 -0
  25. package/dist/concurrency/atomic.js +281 -0
  26. package/dist/concurrency/git-agent.d.ts +114 -0
  27. package/dist/concurrency/git-agent.d.ts.map +1 -0
  28. package/dist/concurrency/git-agent.js +313 -0
  29. package/dist/concurrency/index.d.ts +95 -0
  30. package/dist/concurrency/index.d.ts.map +1 -0
  31. package/dist/concurrency/index.js +127 -0
  32. package/dist/concurrency/lock-manager.d.ts +170 -0
  33. package/dist/concurrency/lock-manager.d.ts.map +1 -0
  34. package/dist/concurrency/lock-manager.js +525 -0
  35. package/dist/concurrency/queue-manager.d.ts +166 -0
  36. package/dist/concurrency/queue-manager.d.ts.map +1 -0
  37. package/dist/concurrency/queue-manager.js +442 -0
  38. package/dist/concurrency/types.d.ts +382 -0
  39. package/dist/concurrency/types.d.ts.map +1 -0
  40. package/dist/concurrency/types.js +204 -0
  41. package/dist/export/constraint-collector.d.ts +175 -0
  42. package/dist/export/constraint-collector.d.ts.map +1 -0
  43. package/dist/export/constraint-collector.js +203 -0
  44. package/dist/export/formatters/llms-txt-formatter.d.ts +89 -0
  45. package/dist/export/formatters/llms-txt-formatter.d.ts.map +1 -0
  46. package/dist/export/formatters/llms-txt-formatter.js +249 -0
  47. package/dist/export/formatters/mcp-resource-formatter.d.ts +186 -0
  48. package/dist/export/formatters/mcp-resource-formatter.d.ts.map +1 -0
  49. package/dist/export/formatters/mcp-resource-formatter.js +139 -0
  50. package/dist/export/formatters/prompt-formatter.d.ts +83 -0
  51. package/dist/export/formatters/prompt-formatter.d.ts.map +1 -0
  52. package/dist/export/formatters/prompt-formatter.js +256 -0
  53. package/dist/export/index.d.ts +10 -0
  54. package/dist/export/index.d.ts.map +1 -0
  55. package/dist/export/index.js +9 -0
  56. package/dist/gate/check.interface.d.ts +15 -0
  57. package/dist/gate/check.interface.d.ts.map +1 -0
  58. package/dist/gate/check.interface.js +18 -0
  59. package/dist/gate/checks/antipattern.check.d.ts +27 -0
  60. package/dist/gate/checks/antipattern.check.d.ts.map +1 -0
  61. package/dist/gate/checks/antipattern.check.js +140 -0
  62. package/dist/gate/checks/architecture/circular-detector.d.ts +33 -0
  63. package/dist/gate/checks/architecture/circular-detector.d.ts.map +1 -0
  64. package/dist/gate/checks/architecture/circular-detector.js +71 -0
  65. package/dist/gate/checks/architecture/dependency-analyzer.d.ts +81 -0
  66. package/dist/gate/checks/architecture/dependency-analyzer.d.ts.map +1 -0
  67. package/dist/gate/checks/architecture/dependency-analyzer.js +136 -0
  68. package/dist/gate/checks/architecture/layer-validator.d.ts +75 -0
  69. package/dist/gate/checks/architecture/layer-validator.d.ts.map +1 -0
  70. package/dist/gate/checks/architecture/layer-validator.js +193 -0
  71. package/dist/gate/checks/architecture.check.d.ts +56 -0
  72. package/dist/gate/checks/architecture.check.d.ts.map +1 -0
  73. package/dist/gate/checks/architecture.check.js +394 -0
  74. package/dist/gate/checks/command-safety.check.d.ts +12 -0
  75. package/dist/gate/checks/command-safety.check.d.ts.map +1 -0
  76. package/dist/gate/checks/command-safety.check.js +230 -0
  77. package/dist/gate/checks/coverage.check.d.ts +9 -0
  78. package/dist/gate/checks/coverage.check.d.ts.map +1 -0
  79. package/dist/gate/checks/coverage.check.js +81 -0
  80. package/dist/gate/checks/dependency.check.d.ts +17 -0
  81. package/dist/gate/checks/dependency.check.d.ts.map +1 -0
  82. package/dist/gate/checks/dependency.check.js +342 -0
  83. package/dist/gate/checks/eslint.check.d.ts +14 -0
  84. package/dist/gate/checks/eslint.check.d.ts.map +1 -0
  85. package/dist/gate/checks/eslint.check.js +79 -0
  86. package/dist/gate/checks/policy.check.d.ts +78 -0
  87. package/dist/gate/checks/policy.check.d.ts.map +1 -0
  88. package/dist/gate/checks/policy.check.js +457 -0
  89. package/dist/gate/checks/secret/entropy-detector.d.ts +44 -0
  90. package/dist/gate/checks/secret/entropy-detector.d.ts.map +1 -0
  91. package/dist/gate/checks/secret/entropy-detector.js +76 -0
  92. package/dist/gate/checks/secret/git-scanner.d.ts +36 -0
  93. package/dist/gate/checks/secret/git-scanner.d.ts.map +1 -0
  94. package/dist/gate/checks/secret/git-scanner.js +90 -0
  95. package/dist/gate/checks/secret/secret-patterns.d.ts +42 -0
  96. package/dist/gate/checks/secret/secret-patterns.d.ts.map +1 -0
  97. package/dist/gate/checks/secret/secret-patterns.js +137 -0
  98. package/dist/gate/checks/secret.check.d.ts +56 -0
  99. package/dist/gate/checks/secret.check.d.ts.map +1 -0
  100. package/dist/gate/checks/secret.check.js +245 -0
  101. package/dist/gate/config/command-safety-config.d.ts +5 -0
  102. package/dist/gate/config/command-safety-config.d.ts.map +1 -0
  103. package/dist/gate/config/command-safety-config.js +69 -0
  104. package/dist/gate/config/index.d.ts +2 -0
  105. package/dist/gate/config/index.d.ts.map +1 -0
  106. package/dist/gate/config/index.js +1 -0
  107. package/dist/gate/formatters/command-safety-formatter.d.ts +10 -0
  108. package/dist/gate/formatters/command-safety-formatter.d.ts.map +1 -0
  109. package/dist/gate/formatters/command-safety-formatter.js +64 -0
  110. package/dist/gate/formatters/index.d.ts +2 -0
  111. package/dist/gate/formatters/index.d.ts.map +1 -0
  112. package/dist/gate/formatters/index.js +1 -0
  113. package/dist/gate/gate-config.d.ts +44 -0
  114. package/dist/gate/gate-config.d.ts.map +1 -0
  115. package/dist/gate/gate-config.js +334 -0
  116. package/dist/gate/gate-runner.d.ts +160 -0
  117. package/dist/gate/gate-runner.d.ts.map +1 -0
  118. package/dist/gate/gate-runner.js +531 -0
  119. package/dist/gate/index.d.ts +20 -0
  120. package/dist/gate/index.d.ts.map +1 -0
  121. package/dist/gate/index.js +14 -0
  122. package/dist/gate/parsers/command-parser.d.ts +18 -0
  123. package/dist/gate/parsers/command-parser.d.ts.map +1 -0
  124. package/dist/gate/parsers/command-parser.js +363 -0
  125. package/dist/gate/parsers/index.d.ts +2 -0
  126. package/dist/gate/parsers/index.d.ts.map +1 -0
  127. package/dist/gate/parsers/index.js +1 -0
  128. package/dist/gate/policy/index.d.ts +12 -0
  129. package/dist/gate/policy/index.d.ts.map +1 -0
  130. package/dist/gate/policy/index.js +10 -0
  131. package/dist/gate/rules/default-filesystem-rules.d.ts +3 -0
  132. package/dist/gate/rules/default-filesystem-rules.d.ts.map +1 -0
  133. package/dist/gate/rules/default-filesystem-rules.js +201 -0
  134. package/dist/gate/rules/default-git-rules.d.ts +3 -0
  135. package/dist/gate/rules/default-git-rules.d.ts.map +1 -0
  136. package/dist/gate/rules/default-git-rules.js +192 -0
  137. package/dist/gate/rules/index.d.ts +5 -0
  138. package/dist/gate/rules/index.d.ts.map +1 -0
  139. package/dist/gate/rules/index.js +3 -0
  140. package/dist/gate/rules/rule-matcher.d.ts +27 -0
  141. package/dist/gate/rules/rule-matcher.d.ts.map +1 -0
  142. package/dist/gate/rules/rule-matcher.js +228 -0
  143. package/dist/gate/rules/types.d.ts +250 -0
  144. package/dist/gate/rules/types.d.ts.map +1 -0
  145. package/dist/gate/rules/types.js +1 -0
  146. package/dist/index.d.ts +19 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +35 -0
  149. package/dist/types/gate.types.d.ts +42 -0
  150. package/dist/types/gate.types.d.ts.map +1 -0
  151. package/dist/types/gate.types.js +94 -0
  152. package/dist/watch/debouncer.d.ts +90 -0
  153. package/dist/watch/debouncer.d.ts.map +1 -0
  154. package/dist/watch/debouncer.js +135 -0
  155. package/dist/watch/file-watcher.d.ts +73 -0
  156. package/dist/watch/file-watcher.d.ts.map +1 -0
  157. package/dist/watch/file-watcher.js +121 -0
  158. package/dist/watch/git-status.d.ts +98 -0
  159. package/dist/watch/git-status.d.ts.map +1 -0
  160. package/dist/watch/git-status.js +266 -0
  161. package/dist/watch/index.d.ts +16 -0
  162. package/dist/watch/index.d.ts.map +1 -0
  163. package/dist/watch/index.js +15 -0
  164. package/dist/watch/orchestrator.d.ts +113 -0
  165. package/dist/watch/orchestrator.d.ts.map +1 -0
  166. package/dist/watch/orchestrator.js +409 -0
  167. package/dist/watch/types.d.ts +190 -0
  168. package/dist/watch/types.d.ts.map +1 -0
  169. package/dist/watch/types.js +76 -0
  170. package/package.json +60 -0
@@ -0,0 +1,382 @@
1
+ /**
2
+ * Multi-Agent Concurrency Types
3
+ *
4
+ * Type definitions for agent registration, locking, and queuing systems
5
+ * to handle concurrent AI agent operations across multiple processes.
6
+ */
7
+ import { z } from 'zod';
8
+ /**
9
+ * Agent type enumeration
10
+ */
11
+ export declare const AgentTypeSchema: z.ZodEnum<{
12
+ unknown: "unknown";
13
+ ci: "ci";
14
+ cursor: "cursor";
15
+ copilot: "copilot";
16
+ claude: "claude";
17
+ aider: "aider";
18
+ continue: "continue";
19
+ codeium: "codeium";
20
+ human: "human";
21
+ }>;
22
+ export type AgentType = z.infer<typeof AgentTypeSchema>;
23
+ /**
24
+ * Agent information schema
25
+ */
26
+ export declare const AgentInfoSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ type: z.ZodDefault<z.ZodEnum<{
29
+ unknown: "unknown";
30
+ ci: "ci";
31
+ cursor: "cursor";
32
+ copilot: "copilot";
33
+ claude: "claude";
34
+ aider: "aider";
35
+ continue: "continue";
36
+ codeium: "codeium";
37
+ human: "human";
38
+ }>>;
39
+ pid: z.ZodOptional<z.ZodNumber>;
40
+ name: z.ZodOptional<z.ZodString>;
41
+ sessionId: z.ZodOptional<z.ZodString>;
42
+ parentAgentId: z.ZodOptional<z.ZodString>;
43
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
44
+ }, z.core.$strip>;
45
+ export type AgentInfo = z.infer<typeof AgentInfoSchema>;
46
+ /**
47
+ * Registered agent record in the registry
48
+ */
49
+ export declare const AgentRegistrationSchema: z.ZodObject<{
50
+ agent: z.ZodObject<{
51
+ id: z.ZodString;
52
+ type: z.ZodDefault<z.ZodEnum<{
53
+ unknown: "unknown";
54
+ ci: "ci";
55
+ cursor: "cursor";
56
+ copilot: "copilot";
57
+ claude: "claude";
58
+ aider: "aider";
59
+ continue: "continue";
60
+ codeium: "codeium";
61
+ human: "human";
62
+ }>>;
63
+ pid: z.ZodOptional<z.ZodNumber>;
64
+ name: z.ZodOptional<z.ZodString>;
65
+ sessionId: z.ZodOptional<z.ZodString>;
66
+ parentAgentId: z.ZodOptional<z.ZodString>;
67
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
68
+ }, z.core.$strip>;
69
+ registeredAt: z.ZodString;
70
+ lastHeartbeat: z.ZodString;
71
+ heartbeatCount: z.ZodDefault<z.ZodNumber>;
72
+ state: z.ZodDefault<z.ZodEnum<{
73
+ active: "active";
74
+ idle: "idle";
75
+ stale: "stale";
76
+ terminated: "terminated";
77
+ }>>;
78
+ currentOperation: z.ZodOptional<z.ZodString>;
79
+ workspaceRoot: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>;
81
+ export type AgentRegistration = z.infer<typeof AgentRegistrationSchema>;
82
+ /**
83
+ * Agent registry file schema (.anvil/agents/registry.json)
84
+ */
85
+ export declare const AgentRegistrySchema: z.ZodObject<{
86
+ version: z.ZodDefault<z.ZodString>;
87
+ updatedAt: z.ZodString;
88
+ agents: z.ZodRecord<z.ZodString, z.ZodObject<{
89
+ agent: z.ZodObject<{
90
+ id: z.ZodString;
91
+ type: z.ZodDefault<z.ZodEnum<{
92
+ unknown: "unknown";
93
+ ci: "ci";
94
+ cursor: "cursor";
95
+ copilot: "copilot";
96
+ claude: "claude";
97
+ aider: "aider";
98
+ continue: "continue";
99
+ codeium: "codeium";
100
+ human: "human";
101
+ }>>;
102
+ pid: z.ZodOptional<z.ZodNumber>;
103
+ name: z.ZodOptional<z.ZodString>;
104
+ sessionId: z.ZodOptional<z.ZodString>;
105
+ parentAgentId: z.ZodOptional<z.ZodString>;
106
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
107
+ }, z.core.$strip>;
108
+ registeredAt: z.ZodString;
109
+ lastHeartbeat: z.ZodString;
110
+ heartbeatCount: z.ZodDefault<z.ZodNumber>;
111
+ state: z.ZodDefault<z.ZodEnum<{
112
+ active: "active";
113
+ idle: "idle";
114
+ stale: "stale";
115
+ terminated: "terminated";
116
+ }>>;
117
+ currentOperation: z.ZodOptional<z.ZodString>;
118
+ workspaceRoot: z.ZodOptional<z.ZodString>;
119
+ }, z.core.$strip>>;
120
+ }, z.core.$strip>;
121
+ export type AgentRegistry = z.infer<typeof AgentRegistrySchema>;
122
+ /**
123
+ * Lock type enumeration
124
+ */
125
+ export declare const LockTypeSchema: z.ZodEnum<{
126
+ cache: "cache";
127
+ watch: "watch";
128
+ action: "action";
129
+ state: "state";
130
+ task: "task";
131
+ }>;
132
+ export type LockType = z.infer<typeof LockTypeSchema>;
133
+ /**
134
+ * Lock record schema
135
+ */
136
+ export declare const LockRecordSchema: z.ZodObject<{
137
+ type: z.ZodEnum<{
138
+ cache: "cache";
139
+ watch: "watch";
140
+ action: "action";
141
+ state: "state";
142
+ task: "task";
143
+ }>;
144
+ resource: z.ZodString;
145
+ agentId: z.ZodString;
146
+ agentType: z.ZodOptional<z.ZodEnum<{
147
+ unknown: "unknown";
148
+ ci: "ci";
149
+ cursor: "cursor";
150
+ copilot: "copilot";
151
+ claude: "claude";
152
+ aider: "aider";
153
+ continue: "continue";
154
+ codeium: "codeium";
155
+ human: "human";
156
+ }>>;
157
+ pid: z.ZodOptional<z.ZodNumber>;
158
+ acquiredAt: z.ZodString;
159
+ expiresAt: z.ZodString;
160
+ reason: z.ZodOptional<z.ZodString>;
161
+ renewCount: z.ZodDefault<z.ZodNumber>;
162
+ }, z.core.$strip>;
163
+ export type LockRecord = z.infer<typeof LockRecordSchema>;
164
+ /**
165
+ * Lock file schema (.anvil/locks/{type}-{resource-hash}.lock)
166
+ */
167
+ export declare const LockFileSchema: z.ZodObject<{
168
+ version: z.ZodDefault<z.ZodString>;
169
+ lock: z.ZodObject<{
170
+ type: z.ZodEnum<{
171
+ cache: "cache";
172
+ watch: "watch";
173
+ action: "action";
174
+ state: "state";
175
+ task: "task";
176
+ }>;
177
+ resource: z.ZodString;
178
+ agentId: z.ZodString;
179
+ agentType: z.ZodOptional<z.ZodEnum<{
180
+ unknown: "unknown";
181
+ ci: "ci";
182
+ cursor: "cursor";
183
+ copilot: "copilot";
184
+ claude: "claude";
185
+ aider: "aider";
186
+ continue: "continue";
187
+ codeium: "codeium";
188
+ human: "human";
189
+ }>>;
190
+ pid: z.ZodOptional<z.ZodNumber>;
191
+ acquiredAt: z.ZodString;
192
+ expiresAt: z.ZodString;
193
+ reason: z.ZodOptional<z.ZodString>;
194
+ renewCount: z.ZodDefault<z.ZodNumber>;
195
+ }, z.core.$strip>;
196
+ history: z.ZodDefault<z.ZodArray<z.ZodObject<{
197
+ agentId: z.ZodString;
198
+ acquiredAt: z.ZodString;
199
+ releasedAt: z.ZodOptional<z.ZodString>;
200
+ reason: z.ZodOptional<z.ZodString>;
201
+ }, z.core.$strip>>>;
202
+ }, z.core.$strip>;
203
+ export type LockFile = z.infer<typeof LockFileSchema>;
204
+ /**
205
+ * Lock acquisition result
206
+ */
207
+ export interface LockAcquisitionResult {
208
+ /** Whether lock was acquired */
209
+ acquired: boolean;
210
+ /** Lock record if acquired */
211
+ lock?: LockRecord;
212
+ /** Error message if not acquired */
213
+ error?: string;
214
+ /** Existing lock holder info (if lock is held by another) */
215
+ heldBy?: {
216
+ agentId: string;
217
+ agentType?: AgentType;
218
+ acquiredAt: string;
219
+ expiresAt: string;
220
+ pid?: number;
221
+ };
222
+ /** Position in queue (if queued) */
223
+ queuePosition?: number;
224
+ }
225
+ /**
226
+ * Lock release result
227
+ */
228
+ export interface LockReleaseResult {
229
+ /** Whether lock was released */
230
+ released: boolean;
231
+ /** Error message if not released */
232
+ error?: string;
233
+ /** Whether lock was held by a different agent */
234
+ wasHeldByOther?: boolean;
235
+ }
236
+ /**
237
+ * Queue entry schema
238
+ */
239
+ export declare const QueueEntrySchema: z.ZodObject<{
240
+ id: z.ZodString;
241
+ agentId: z.ZodString;
242
+ agentType: z.ZodOptional<z.ZodEnum<{
243
+ unknown: "unknown";
244
+ ci: "ci";
245
+ cursor: "cursor";
246
+ copilot: "copilot";
247
+ claude: "claude";
248
+ aider: "aider";
249
+ continue: "continue";
250
+ codeium: "codeium";
251
+ human: "human";
252
+ }>>;
253
+ lockType: z.ZodEnum<{
254
+ cache: "cache";
255
+ watch: "watch";
256
+ action: "action";
257
+ state: "state";
258
+ task: "task";
259
+ }>;
260
+ resource: z.ZodString;
261
+ queuedAt: z.ZodString;
262
+ priority: z.ZodDefault<z.ZodNumber>;
263
+ timeoutAt: z.ZodString;
264
+ reason: z.ZodOptional<z.ZodString>;
265
+ callbackPath: z.ZodOptional<z.ZodString>;
266
+ }, z.core.$strip>;
267
+ export type QueueEntry = z.infer<typeof QueueEntrySchema>;
268
+ /**
269
+ * Queue file schema (.anvil/queue/{resource-hash}.json)
270
+ */
271
+ export declare const QueueFileSchema: z.ZodObject<{
272
+ version: z.ZodDefault<z.ZodString>;
273
+ resource: z.ZodString;
274
+ lockType: z.ZodEnum<{
275
+ cache: "cache";
276
+ watch: "watch";
277
+ action: "action";
278
+ state: "state";
279
+ task: "task";
280
+ }>;
281
+ updatedAt: z.ZodString;
282
+ entries: z.ZodArray<z.ZodObject<{
283
+ id: z.ZodString;
284
+ agentId: z.ZodString;
285
+ agentType: z.ZodOptional<z.ZodEnum<{
286
+ unknown: "unknown";
287
+ ci: "ci";
288
+ cursor: "cursor";
289
+ copilot: "copilot";
290
+ claude: "claude";
291
+ aider: "aider";
292
+ continue: "continue";
293
+ codeium: "codeium";
294
+ human: "human";
295
+ }>>;
296
+ lockType: z.ZodEnum<{
297
+ cache: "cache";
298
+ watch: "watch";
299
+ action: "action";
300
+ state: "state";
301
+ task: "task";
302
+ }>;
303
+ resource: z.ZodString;
304
+ queuedAt: z.ZodString;
305
+ priority: z.ZodDefault<z.ZodNumber>;
306
+ timeoutAt: z.ZodString;
307
+ reason: z.ZodOptional<z.ZodString>;
308
+ callbackPath: z.ZodOptional<z.ZodString>;
309
+ }, z.core.$strip>>;
310
+ }, z.core.$strip>;
311
+ export type QueueFile = z.infer<typeof QueueFileSchema>;
312
+ /**
313
+ * Queue join result
314
+ */
315
+ export interface QueueJoinResult {
316
+ /** Entry ID */
317
+ entryId: string;
318
+ /** Position in queue (1-based) */
319
+ position: number;
320
+ /** Estimated wait time in ms (if calculable) */
321
+ estimatedWaitMs?: number;
322
+ /** Whether already in queue (entry updated) */
323
+ alreadyQueued: boolean;
324
+ }
325
+ /**
326
+ * Queue status result
327
+ */
328
+ export interface QueueStatusResult {
329
+ /** Total entries in queue */
330
+ totalEntries: number;
331
+ /** Your position (if in queue, 1-based) */
332
+ yourPosition?: number;
333
+ /** Your entry (if in queue) */
334
+ yourEntry?: QueueEntry;
335
+ /** Current lock holder */
336
+ currentHolder?: {
337
+ agentId: string;
338
+ agentType?: AgentType;
339
+ acquiredAt: string;
340
+ expiresAt: string;
341
+ };
342
+ }
343
+ /**
344
+ * Coordination event types
345
+ */
346
+ export type CoordinationEventType = 'agent:registered' | 'agent:heartbeat' | 'agent:terminated' | 'agent:stale' | 'lock:acquired' | 'lock:released' | 'lock:expired' | 'lock:denied' | 'queue:joined' | 'queue:advanced' | 'queue:timeout' | 'queue:removed';
347
+ /**
348
+ * Coordination event
349
+ */
350
+ export interface CoordinationEvent {
351
+ /** Event type */
352
+ type: CoordinationEventType;
353
+ /** Timestamp */
354
+ timestamp: string;
355
+ /** Agent involved */
356
+ agentId: string;
357
+ /** Resource involved (if applicable) */
358
+ resource?: string;
359
+ /** Additional details */
360
+ details?: Record<string, unknown>;
361
+ }
362
+ /**
363
+ * Concurrency configuration schema
364
+ */
365
+ export declare const ConcurrencyConfigSchema: z.ZodObject<{
366
+ enabled: z.ZodDefault<z.ZodBoolean>;
367
+ lockTimeoutMs: z.ZodDefault<z.ZodNumber>;
368
+ heartbeatIntervalMs: z.ZodDefault<z.ZodNumber>;
369
+ staleThresholdMs: z.ZodDefault<z.ZodNumber>;
370
+ queueTimeoutMs: z.ZodDefault<z.ZodNumber>;
371
+ maxQueueSize: z.ZodDefault<z.ZodNumber>;
372
+ autoAcquireFromStale: z.ZodDefault<z.ZodBoolean>;
373
+ lockDir: z.ZodDefault<z.ZodString>;
374
+ queueDir: z.ZodDefault<z.ZodString>;
375
+ registryPath: z.ZodDefault<z.ZodString>;
376
+ }, z.core.$strip>;
377
+ export type ConcurrencyConfig = z.infer<typeof ConcurrencyConfigSchema>;
378
+ /**
379
+ * Get default concurrency config
380
+ */
381
+ export declare function getDefaultConcurrencyConfig(): ConcurrencyConfig;
382
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.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AAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IAErB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB,0BAA0B;IAC1B,aAAa,CAAC,EAAE;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAMD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,aAAa,GACb,eAAe,GACf,eAAe,GACf,cAAc,GACd,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iBAAiB;IACjB,IAAI,EAAE,qBAAqB,CAAC;IAE5B,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAElB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAMD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;iBA8BlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,iBAAiB,CAE/D"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Multi-Agent Concurrency Types
3
+ *
4
+ * Type definitions for agent registration, locking, and queuing systems
5
+ * to handle concurrent AI agent operations across multiple processes.
6
+ */
7
+ import { z } from 'zod';
8
+ // ============================================================================
9
+ // Agent Identification
10
+ // ============================================================================
11
+ /**
12
+ * Agent type enumeration
13
+ */
14
+ export const AgentTypeSchema = z.enum([
15
+ 'claude', // Claude Code / Anthropic Claude
16
+ 'cursor', // Cursor AI
17
+ 'copilot', // GitHub Copilot
18
+ 'aider', // Aider
19
+ 'continue', // Continue.dev
20
+ 'codeium', // Codeium
21
+ 'human', // Human developer
22
+ 'ci', // CI/CD system
23
+ 'unknown', // Unknown/unidentified
24
+ ]);
25
+ /**
26
+ * Agent information schema
27
+ */
28
+ export const AgentInfoSchema = z.object({
29
+ /** Unique agent ID (UUID or custom identifier) */
30
+ id: z.string().min(1),
31
+ /** Type of agent */
32
+ type: AgentTypeSchema.default('unknown'),
33
+ /** Process ID (if available) */
34
+ pid: z.number().optional(),
35
+ /** Human-readable name/label */
36
+ name: z.string().optional(),
37
+ /** Session ID (for tracking related operations) */
38
+ sessionId: z.string().optional(),
39
+ /** Parent agent ID (for hierarchical agent setups) */
40
+ parentAgentId: z.string().optional(),
41
+ /** Custom metadata */
42
+ metadata: z.record(z.string(), z.unknown()).optional(),
43
+ });
44
+ /**
45
+ * Registered agent record in the registry
46
+ */
47
+ export const AgentRegistrationSchema = z.object({
48
+ /** Agent info */
49
+ agent: AgentInfoSchema,
50
+ /** ISO timestamp when registered */
51
+ registeredAt: z.string(),
52
+ /** ISO timestamp of last heartbeat */
53
+ lastHeartbeat: z.string(),
54
+ /** Number of heartbeats received */
55
+ heartbeatCount: z.number().default(0),
56
+ /** Current state */
57
+ state: z.enum(['active', 'idle', 'stale', 'terminated']).default('active'),
58
+ /** Current operation (if any) */
59
+ currentOperation: z.string().optional(),
60
+ /** Workspace being operated on */
61
+ workspaceRoot: z.string().optional(),
62
+ });
63
+ /**
64
+ * Agent registry file schema (.anvil/agents/registry.json)
65
+ */
66
+ export const AgentRegistrySchema = z.object({
67
+ /** Schema version */
68
+ version: z.string().default('1.0.0'),
69
+ /** Last updated timestamp */
70
+ updatedAt: z.string(),
71
+ /** Registered agents by ID */
72
+ agents: z.record(z.string(), AgentRegistrationSchema),
73
+ });
74
+ // ============================================================================
75
+ // Lock Management
76
+ // ============================================================================
77
+ /**
78
+ * Lock type enumeration
79
+ */
80
+ export const LockTypeSchema = z.enum([
81
+ 'watch', // Watch mode lock (only one watcher per workspace)
82
+ 'action', // Action execution lock (gate, validate, check)
83
+ 'cache', // Cache write lock
84
+ 'state', // State file lock
85
+ 'task', // Task execution lock (specific task)
86
+ ]);
87
+ /**
88
+ * Lock record schema
89
+ */
90
+ export const LockRecordSchema = z.object({
91
+ /** Lock type */
92
+ type: LockTypeSchema,
93
+ /** Resource being locked (e.g., file path, task ID) */
94
+ resource: z.string(),
95
+ /** Agent holding the lock */
96
+ agentId: z.string(),
97
+ /** Agent type (for display) */
98
+ agentType: AgentTypeSchema.optional(),
99
+ /** Process ID holding the lock */
100
+ pid: z.number().optional(),
101
+ /** ISO timestamp when lock was acquired */
102
+ acquiredAt: z.string(),
103
+ /** ISO timestamp when lock expires (for auto-release) */
104
+ expiresAt: z.string(),
105
+ /** Lock reason/description */
106
+ reason: z.string().optional(),
107
+ /** Number of times lock was renewed */
108
+ renewCount: z.number().default(0),
109
+ });
110
+ /**
111
+ * Lock file schema (.anvil/locks/{type}-{resource-hash}.lock)
112
+ */
113
+ export const LockFileSchema = z.object({
114
+ /** Schema version */
115
+ version: z.string().default('1.0.0'),
116
+ /** Lock record */
117
+ lock: LockRecordSchema,
118
+ /** Lock acquisition history (for debugging) */
119
+ history: z
120
+ .array(z.object({
121
+ agentId: z.string(),
122
+ acquiredAt: z.string(),
123
+ releasedAt: z.string().optional(),
124
+ reason: z.string().optional(),
125
+ }))
126
+ .default([]),
127
+ });
128
+ // ============================================================================
129
+ // Queue Management
130
+ // ============================================================================
131
+ /**
132
+ * Queue entry schema
133
+ */
134
+ export const QueueEntrySchema = z.object({
135
+ /** Unique entry ID */
136
+ id: z.string(),
137
+ /** Agent requesting the resource */
138
+ agentId: z.string(),
139
+ /** Agent type */
140
+ agentType: AgentTypeSchema.optional(),
141
+ /** Lock type being requested */
142
+ lockType: LockTypeSchema,
143
+ /** Resource being requested */
144
+ resource: z.string(),
145
+ /** ISO timestamp when queued */
146
+ queuedAt: z.string(),
147
+ /** Priority (lower = higher priority, default: 100) */
148
+ priority: z.number().default(100),
149
+ /** Timeout for queue entry (auto-remove after this) */
150
+ timeoutAt: z.string(),
151
+ /** Reason for request */
152
+ reason: z.string().optional(),
153
+ /** Callback URL/path for notification (optional) */
154
+ callbackPath: z.string().optional(),
155
+ });
156
+ /**
157
+ * Queue file schema (.anvil/queue/{resource-hash}.json)
158
+ */
159
+ export const QueueFileSchema = z.object({
160
+ /** Schema version */
161
+ version: z.string().default('1.0.0'),
162
+ /** Resource identifier */
163
+ resource: z.string(),
164
+ /** Lock type */
165
+ lockType: LockTypeSchema,
166
+ /** Last updated timestamp */
167
+ updatedAt: z.string(),
168
+ /** Queued entries (ordered by priority then queuedAt) */
169
+ entries: z.array(QueueEntrySchema),
170
+ });
171
+ // ============================================================================
172
+ // Configuration
173
+ // ============================================================================
174
+ /**
175
+ * Concurrency configuration schema
176
+ */
177
+ export const ConcurrencyConfigSchema = z.object({
178
+ /** Enable multi-agent mode */
179
+ enabled: z.boolean().default(true),
180
+ /** Lock timeout in ms (default: 5 minutes) */
181
+ lockTimeoutMs: z.number().min(1000).max(3600000).default(300000),
182
+ /** Heartbeat interval in ms (default: 10 seconds) */
183
+ heartbeatIntervalMs: z.number().min(1000).max(60000).default(10000),
184
+ /** Stale agent threshold in ms (3x heartbeat) */
185
+ staleThresholdMs: z.number().min(3000).max(180000).default(30000),
186
+ /** Queue timeout in ms (default: 10 minutes) */
187
+ queueTimeoutMs: z.number().min(5000).max(3600000).default(600000),
188
+ /** Maximum queue size per resource */
189
+ maxQueueSize: z.number().min(1).max(100).default(20),
190
+ /** Whether to auto-acquire lock from stale agents */
191
+ autoAcquireFromStale: z.boolean().default(true),
192
+ /** Lock directory path (relative to workspace) */
193
+ lockDir: z.string().default('.anvil/locks'),
194
+ /** Queue directory path (relative to workspace) */
195
+ queueDir: z.string().default('.anvil/queue'),
196
+ /** Agent registry path (relative to workspace) */
197
+ registryPath: z.string().default('.anvil/agents/registry.json'),
198
+ });
199
+ /**
200
+ * Get default concurrency config
201
+ */
202
+ export function getDefaultConcurrencyConfig() {
203
+ return ConcurrencyConfigSchema.parse({});
204
+ }