@sparkleideas/claims 3.5.2-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +261 -0
- package/package.json +84 -0
- package/src/api/cli-commands.ts +1459 -0
- package/src/api/cli-types.ts +154 -0
- package/src/api/index.ts +24 -0
- package/src/api/mcp-tools.ts +1977 -0
- package/src/application/claim-service.ts +753 -0
- package/src/application/index.ts +46 -0
- package/src/application/load-balancer.ts +840 -0
- package/src/application/work-stealing-service.ts +807 -0
- package/src/domain/events.ts +779 -0
- package/src/domain/index.ts +214 -0
- package/src/domain/repositories.ts +239 -0
- package/src/domain/rules.ts +526 -0
- package/src/domain/types.ts +826 -0
- package/src/index.ts +79 -0
- package/src/infrastructure/claim-repository.ts +358 -0
- package/src/infrastructure/event-store.ts +297 -0
- package/src/infrastructure/index.ts +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# @claude-flow/claims
|
|
2
|
+
|
|
3
|
+
**Issue claiming and work coordination for human-agent collaboration.**
|
|
4
|
+
|
|
5
|
+
## What is this?
|
|
6
|
+
|
|
7
|
+
This package provides a complete system for coordinating work between humans and AI agents:
|
|
8
|
+
|
|
9
|
+
- **Issue Claiming** - Claim issues to work on, preventing conflicts
|
|
10
|
+
- **Handoffs** - Transfer work between humans and agents seamlessly
|
|
11
|
+
- **Work Stealing** - Automatically reassign stalled work
|
|
12
|
+
- **Load Balancing** - Distribute work evenly across agents
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @claude-flow/claims
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install via Claude Flow CLI:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx claude-flow plugins install @claude-flow/claims
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Claim an Issue
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { ClaimsService } from '@claude-flow/claims';
|
|
34
|
+
|
|
35
|
+
const claims = new ClaimsService();
|
|
36
|
+
|
|
37
|
+
// Human claims an issue
|
|
38
|
+
await claims.claim({
|
|
39
|
+
issueId: 'ISSUE-123',
|
|
40
|
+
claimant: 'human:alice',
|
|
41
|
+
context: 'Working on the authentication fix'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Agent claims an issue
|
|
45
|
+
await claims.claim({
|
|
46
|
+
issueId: 'ISSUE-456',
|
|
47
|
+
claimant: 'agent:coder-1:coder',
|
|
48
|
+
context: 'Implementing new feature'
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Release a Claim
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
await claims.release({
|
|
56
|
+
issueId: 'ISSUE-123',
|
|
57
|
+
claimant: 'human:alice',
|
|
58
|
+
reason: 'Completed the work'
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Handoff Between Human and Agent
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// Human hands off to agent
|
|
66
|
+
await claims.handoff({
|
|
67
|
+
issueId: 'ISSUE-123',
|
|
68
|
+
from: 'human:alice',
|
|
69
|
+
to: 'agent:coder-1:coder',
|
|
70
|
+
reason: 'Need AI to continue implementation',
|
|
71
|
+
progress: 40
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Agent accepts handoff
|
|
75
|
+
await claims.acceptHandoff({
|
|
76
|
+
issueId: 'ISSUE-123',
|
|
77
|
+
claimant: 'agent:coder-1:coder'
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Update Claim Status
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
await claims.updateStatus({
|
|
85
|
+
issueId: 'ISSUE-123',
|
|
86
|
+
status: 'review-requested',
|
|
87
|
+
progress: 80,
|
|
88
|
+
note: 'Ready for code review'
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## MCP Tools (17 Tools)
|
|
95
|
+
|
|
96
|
+
### Core Claiming (7 tools)
|
|
97
|
+
|
|
98
|
+
| Tool | Description |
|
|
99
|
+
|------|-------------|
|
|
100
|
+
| `claims_claim` | Claim an issue for work |
|
|
101
|
+
| `claims_release` | Release a claimed issue |
|
|
102
|
+
| `claims_handoff` | Request handoff to another claimant |
|
|
103
|
+
| `claims_accept-handoff` | Accept a pending handoff |
|
|
104
|
+
| `claims_status` | Update claim status |
|
|
105
|
+
| `claims_list` | List claims by criteria |
|
|
106
|
+
| `claims_board` | Visual board view of all claims |
|
|
107
|
+
|
|
108
|
+
### Work Stealing (4 tools)
|
|
109
|
+
|
|
110
|
+
| Tool | Description |
|
|
111
|
+
|------|-------------|
|
|
112
|
+
| `claims_mark-stealable` | Mark issue as available for stealing |
|
|
113
|
+
| `claims_steal` | Steal a stealable issue |
|
|
114
|
+
| `claims_stealable` | List all stealable issues |
|
|
115
|
+
| `claims_contest-steal` | Contest a steal attempt |
|
|
116
|
+
|
|
117
|
+
### Load Balancing (3 tools)
|
|
118
|
+
|
|
119
|
+
| Tool | Description |
|
|
120
|
+
|------|-------------|
|
|
121
|
+
| `claims_load` | Get agent load information |
|
|
122
|
+
| `claims_rebalance` | Suggest or apply load rebalancing |
|
|
123
|
+
| `claims_swarm-overview` | Overview of swarm workload |
|
|
124
|
+
|
|
125
|
+
### Additional (3 tools)
|
|
126
|
+
|
|
127
|
+
| Tool | Description |
|
|
128
|
+
|------|-------------|
|
|
129
|
+
| `claims_history` | Get claim history for an issue |
|
|
130
|
+
| `claims_metrics` | Get claiming metrics |
|
|
131
|
+
| `claims_config` | Get/set claims configuration |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Claim Statuses
|
|
136
|
+
|
|
137
|
+
| Status | Description |
|
|
138
|
+
|--------|-------------|
|
|
139
|
+
| `active` | Currently being worked on |
|
|
140
|
+
| `paused` | Temporarily paused |
|
|
141
|
+
| `blocked` | Blocked by external dependency |
|
|
142
|
+
| `review-requested` | Ready for review |
|
|
143
|
+
| `handoff-pending` | Handoff requested, awaiting acceptance |
|
|
144
|
+
| `stealable` | Available for other agents to take |
|
|
145
|
+
| `completed` | Work finished |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Work Stealing
|
|
150
|
+
|
|
151
|
+
When work stalls, issues can be marked as stealable:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// Mark issue as stealable
|
|
155
|
+
await claims.markStealable({
|
|
156
|
+
issueId: 'ISSUE-123',
|
|
157
|
+
reason: 'overloaded',
|
|
158
|
+
preferredTypes: ['coder', 'reviewer'],
|
|
159
|
+
context: 'Need someone to continue the implementation'
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Another agent steals the issue
|
|
163
|
+
await claims.steal({
|
|
164
|
+
issueId: 'ISSUE-123',
|
|
165
|
+
stealer: 'agent:coder-2:coder'
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Steal Reasons
|
|
170
|
+
|
|
171
|
+
- `timeout` - Work has been idle too long
|
|
172
|
+
- `overloaded` - Current owner has too much work
|
|
173
|
+
- `blocked` - Work is blocked and owner can't proceed
|
|
174
|
+
- `voluntary` - Owner voluntarily releasing
|
|
175
|
+
- `rebalancing` - System rebalancing workload
|
|
176
|
+
- `abandoned` - Owner is no longer available
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Load Balancing
|
|
181
|
+
|
|
182
|
+
Automatically distribute work across agents:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// Get current agent loads
|
|
186
|
+
const loads = await claims.getAgentLoads();
|
|
187
|
+
|
|
188
|
+
// Preview rebalancing suggestions
|
|
189
|
+
const suggestions = await claims.rebalance({ dryRun: true });
|
|
190
|
+
|
|
191
|
+
// Apply rebalancing
|
|
192
|
+
await claims.rebalance({
|
|
193
|
+
dryRun: false,
|
|
194
|
+
targetUtilization: 0.7
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Event Sourcing
|
|
201
|
+
|
|
202
|
+
All claim operations are event-sourced (ADR-007):
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// Events emitted
|
|
206
|
+
- ClaimCreated
|
|
207
|
+
- ClaimReleased
|
|
208
|
+
- ClaimStatusUpdated
|
|
209
|
+
- HandoffRequested
|
|
210
|
+
- HandoffAccepted
|
|
211
|
+
- HandoffRejected
|
|
212
|
+
- ClaimMarkedStealable
|
|
213
|
+
- ClaimStolen
|
|
214
|
+
- ClaimContested
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## CLI Commands
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Claim an issue
|
|
223
|
+
npx claude-flow claims claim --issue ISSUE-123 --claimant "human:alice"
|
|
224
|
+
|
|
225
|
+
# Release a claim
|
|
226
|
+
npx claude-flow claims release --issue ISSUE-123
|
|
227
|
+
|
|
228
|
+
# View claims board
|
|
229
|
+
npx claude-flow claims board
|
|
230
|
+
|
|
231
|
+
# List stealable issues
|
|
232
|
+
npx claude-flow claims stealable
|
|
233
|
+
|
|
234
|
+
# Rebalance workload
|
|
235
|
+
npx claude-flow claims rebalance --dry-run
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Configuration
|
|
241
|
+
|
|
242
|
+
```yaml
|
|
243
|
+
# claude-flow.config.yaml
|
|
244
|
+
claims:
|
|
245
|
+
autoExpiration:
|
|
246
|
+
enabled: true
|
|
247
|
+
idleTimeout: 3600000 # 1 hour
|
|
248
|
+
checkInterval: 300000 # 5 minutes
|
|
249
|
+
workStealing:
|
|
250
|
+
enabled: true
|
|
251
|
+
contestWindow: 30000 # 30 seconds
|
|
252
|
+
loadBalancing:
|
|
253
|
+
targetUtilization: 0.7
|
|
254
|
+
maxIssuesPerAgent: 5
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sparkleideas/claims",
|
|
3
|
+
"version": "3.5.2-patch.1",
|
|
4
|
+
"description": "Issue claiming and work coordination module for Claude Flow V3",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./api": {
|
|
15
|
+
"import": "./dist/api/index.js",
|
|
16
|
+
"require": "./dist/api/index.js",
|
|
17
|
+
"types": "./dist/api/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./api/mcp-tools": {
|
|
20
|
+
"import": "./dist/api/mcp-tools.js",
|
|
21
|
+
"require": "./dist/api/mcp-tools.js",
|
|
22
|
+
"types": "./dist/api/mcp-tools.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"src"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"dev": "tsc --watch",
|
|
32
|
+
"clean": "rimraf dist",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:coverage": "vitest run --coverage",
|
|
36
|
+
"lint": "eslint src --ext .ts",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"claude-flow",
|
|
41
|
+
"claims",
|
|
42
|
+
"issue-tracking",
|
|
43
|
+
"work-coordination",
|
|
44
|
+
"multi-agent",
|
|
45
|
+
"swarm",
|
|
46
|
+
"mcp"
|
|
47
|
+
],
|
|
48
|
+
"author": "Claude Flow Team",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/ruvnet/claude-flow.git",
|
|
53
|
+
"directory": "v3/@claude-flow/claims"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/ruvnet/claude-flow/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/ruvnet/claude-flow#readme",
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"zod": "^3.22.4"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^20.10.0",
|
|
64
|
+
"rimraf": "^5.0.5",
|
|
65
|
+
"tsup": "^8.0.1",
|
|
66
|
+
"typescript": "^5.3.0",
|
|
67
|
+
"vitest": "^4.0.16"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@sparkleideas/shared": "^3.0.0-alpha.1"
|
|
71
|
+
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"@claude-flow/shared": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=18.0.0"
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public",
|
|
82
|
+
"tag": "v3alpha"
|
|
83
|
+
}
|
|
84
|
+
}
|