@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Type Stubs for Claims Module
|
|
3
|
+
*
|
|
4
|
+
* Local type definitions to avoid cross-package imports.
|
|
5
|
+
* These mirror the types from @sparkleideas/cli for use in claims commands.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Command Types (mirrors @sparkleideas/cli/src/types.ts)
|
|
10
|
+
// =============================================================================
|
|
11
|
+
|
|
12
|
+
export interface CommandContext {
|
|
13
|
+
args: string[];
|
|
14
|
+
flags: Record<string, string | boolean | number | undefined>;
|
|
15
|
+
cwd: string;
|
|
16
|
+
verbose: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CommandResult {
|
|
20
|
+
success: boolean;
|
|
21
|
+
message?: string;
|
|
22
|
+
data?: unknown;
|
|
23
|
+
error?: Error;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Command {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
aliases?: string[];
|
|
30
|
+
usage?: string;
|
|
31
|
+
examples?: string[];
|
|
32
|
+
options?: CommandOption[];
|
|
33
|
+
subcommands?: Command[];
|
|
34
|
+
execute: (context: CommandContext) => Promise<CommandResult>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CommandOption {
|
|
38
|
+
name: string;
|
|
39
|
+
alias?: string;
|
|
40
|
+
description: string;
|
|
41
|
+
type: 'string' | 'boolean' | 'number';
|
|
42
|
+
required?: boolean;
|
|
43
|
+
default?: string | boolean | number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// Output Utilities (mirrors @sparkleideas/cli/src/output.ts)
|
|
48
|
+
// =============================================================================
|
|
49
|
+
|
|
50
|
+
export const output = {
|
|
51
|
+
log: (message: string): void => {
|
|
52
|
+
console.log(message);
|
|
53
|
+
},
|
|
54
|
+
error: (message: string): void => {
|
|
55
|
+
console.error(`Error: ${message}`);
|
|
56
|
+
},
|
|
57
|
+
warn: (message: string): void => {
|
|
58
|
+
console.warn(`Warning: ${message}`);
|
|
59
|
+
},
|
|
60
|
+
warning: (message: string): string => {
|
|
61
|
+
return `⚠ ${message}`;
|
|
62
|
+
},
|
|
63
|
+
success: (message: string): void => {
|
|
64
|
+
console.log(`✓ ${message}`);
|
|
65
|
+
},
|
|
66
|
+
info: (message: string): void => {
|
|
67
|
+
console.log(`ℹ ${message}`);
|
|
68
|
+
},
|
|
69
|
+
table: (data: Record<string, unknown>[]): void => {
|
|
70
|
+
console.table(data);
|
|
71
|
+
},
|
|
72
|
+
json: (data: unknown): void => {
|
|
73
|
+
console.log(JSON.stringify(data, null, 2));
|
|
74
|
+
},
|
|
75
|
+
// Formatting helpers that return strings for composition
|
|
76
|
+
dim: (message: string): string => message,
|
|
77
|
+
bold: (message: string): string => message,
|
|
78
|
+
italic: (message: string): string => message,
|
|
79
|
+
highlight: (message: string): string => message,
|
|
80
|
+
code: (message: string): string => `\`${message}\``,
|
|
81
|
+
link: (url: string, text?: string): string => text ? `${text} (${url})` : url,
|
|
82
|
+
list: (items: string[]): string => items.map(i => ` • ${i}`).join('\n'),
|
|
83
|
+
header: (message: string): string => `\n${message}\n${'─'.repeat(message.length)}`,
|
|
84
|
+
// Colors
|
|
85
|
+
red: (message: string): string => message,
|
|
86
|
+
green: (message: string): string => message,
|
|
87
|
+
yellow: (message: string): string => message,
|
|
88
|
+
blue: (message: string): string => message,
|
|
89
|
+
cyan: (message: string): string => message,
|
|
90
|
+
magenta: (message: string): string => message,
|
|
91
|
+
gray: (message: string): string => message,
|
|
92
|
+
white: (message: string): string => message,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// =============================================================================
|
|
96
|
+
// Prompt Utilities (mirrors @sparkleideas/cli/src/prompt.ts)
|
|
97
|
+
// =============================================================================
|
|
98
|
+
|
|
99
|
+
export interface SelectOption<T = string> {
|
|
100
|
+
label: string;
|
|
101
|
+
value: T;
|
|
102
|
+
description?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function select<T = string>(
|
|
106
|
+
message: string,
|
|
107
|
+
options: SelectOption<T>[]
|
|
108
|
+
): Promise<T> {
|
|
109
|
+
// In a real implementation, this would use a terminal prompt library
|
|
110
|
+
// For now, return the first option as a stub
|
|
111
|
+
console.log(`[Prompt] ${message}`);
|
|
112
|
+
options.forEach((opt, i) => console.log(` ${i + 1}. ${opt.label}`));
|
|
113
|
+
return options[0]?.value as T;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function confirm(message: string, defaultValue = false): Promise<boolean> {
|
|
117
|
+
console.log(`[Confirm] ${message} (default: ${defaultValue ? 'yes' : 'no'})`);
|
|
118
|
+
return defaultValue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function input(message: string, defaultValue = ''): Promise<string> {
|
|
122
|
+
console.log(`[Input] ${message} (default: ${defaultValue})`);
|
|
123
|
+
return defaultValue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// =============================================================================
|
|
127
|
+
// MCP Client Utilities (mirrors @sparkleideas/cli/src/mcp-client.ts)
|
|
128
|
+
// =============================================================================
|
|
129
|
+
|
|
130
|
+
export class MCPClientError extends Error {
|
|
131
|
+
constructor(
|
|
132
|
+
message: string,
|
|
133
|
+
public readonly code?: string,
|
|
134
|
+
public readonly details?: Record<string, unknown>
|
|
135
|
+
) {
|
|
136
|
+
super(message);
|
|
137
|
+
this.name = 'MCPClientError';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface MCPToolResult {
|
|
142
|
+
success: boolean;
|
|
143
|
+
data?: unknown;
|
|
144
|
+
error?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export async function callMCPTool(
|
|
148
|
+
toolName: string,
|
|
149
|
+
params: Record<string, unknown>
|
|
150
|
+
): Promise<MCPToolResult> {
|
|
151
|
+
// MCP tool call - delegates to active MCP server
|
|
152
|
+
console.log(`[MCP] Calling tool: ${toolName}`, params);
|
|
153
|
+
return { success: true, data: {} };
|
|
154
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claims API Module
|
|
3
|
+
*
|
|
4
|
+
* Exports all MCP tools, CLI commands, and utilities for the claims system.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// MCP Tools
|
|
8
|
+
export * from './mcp-tools.js';
|
|
9
|
+
export { default } from './mcp-tools.js';
|
|
10
|
+
|
|
11
|
+
// CLI Commands
|
|
12
|
+
export {
|
|
13
|
+
issuesCommand,
|
|
14
|
+
createIssuesCommand,
|
|
15
|
+
type ClaimServices,
|
|
16
|
+
type ClaimantType,
|
|
17
|
+
type ClaimStatus,
|
|
18
|
+
type Claim,
|
|
19
|
+
type ClaimFilter,
|
|
20
|
+
type HandoffRequest,
|
|
21
|
+
type ContestResult,
|
|
22
|
+
type AgentLoad,
|
|
23
|
+
type RebalanceResult
|
|
24
|
+
} from './cli-commands.js';
|