@spencerbeggs/claude-coordinator-core 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 (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/index.d.ts +242 -0
  4. package/index.js +88 -0
  5. package/package.json +43 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 C. Spencer Beggs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @spencerbeggs/claude-coordinator-core
2
+
3
+ Core schemas and TypeScript types for the Claude Coordinator system, providing
4
+ Zod-based validation and type-safe communication primitives.
5
+
6
+ ## Features
7
+
8
+ - **Type-safe schemas** - Zod schemas with full TypeScript inference
9
+ - **Runtime validation** - Validate all data at runtime with helpful error
10
+ messages
11
+ - **Zero runtime deps** - Only Zod required at runtime
12
+ - **Schema-first design** - Define once, use everywhere
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @spencerbeggs/claude-coordinator-core
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import {
24
+ AgentSchema,
25
+ JoinInputSchema,
26
+ QuestionSchema,
27
+ type Agent,
28
+ type JoinInput,
29
+ } from "@spencerbeggs/claude-coordinator-core";
30
+
31
+ // Validate input data
32
+ const input = JoinInputSchema.parse({
33
+ name: "my-agent",
34
+ role: "source",
35
+ repoPath: "/path/to/repo",
36
+ });
37
+
38
+ // Type inference works automatically
39
+ const agent: Agent = {
40
+ id: "550e8400-e29b-41d4-a716-446655440000",
41
+ role: "source",
42
+ name: "my-agent",
43
+ repoPath: "/path/to/repo",
44
+ connectedAt: new Date(),
45
+ };
46
+
47
+ // Validate the agent
48
+ AgentSchema.parse(agent);
49
+ ```
50
+
51
+ ## API Overview
52
+
53
+ ### Schemas
54
+
55
+ | Schema | Description |
56
+ | ------ | ----------- |
57
+ | `AgentSchema` | Connected agent identity |
58
+ | `JoinInputSchema` | Input for joining a session |
59
+ | `JoinResultSchema` | Result from joining (agent + sessionId) |
60
+ | `ContextEntrySchema` | Shared context key-value entry |
61
+ | `ShareContextInputSchema` | Input for sharing context |
62
+ | `QuestionSchema` | Question with optional answer |
63
+ | `AskInputSchema` | Input for asking a question |
64
+ | `AnswerInputSchema` | Input for answering a question |
65
+ | `DecisionSchema` | Logged decision with rationale |
66
+ | `LogDecisionInputSchema` | Input for logging a decision |
67
+
68
+ ### Types
69
+
70
+ All types are inferred from schemas:
71
+
72
+ ```typescript
73
+ import type {
74
+ Agent,
75
+ JoinInput,
76
+ JoinResult,
77
+ ContextEntry,
78
+ Question,
79
+ Decision,
80
+ } from "@spencerbeggs/claude-coordinator-core";
81
+ ```
82
+
83
+ ### Constants
84
+
85
+ ```typescript
86
+ import {
87
+ DEFAULT_PORT, // 3030
88
+ DEFAULT_HOST, // "localhost"
89
+ DEFAULT_URL, // "ws://localhost:3030"
90
+ } from "@spencerbeggs/claude-coordinator-core";
91
+ ```
92
+
93
+ ## Documentation
94
+
95
+ - [Architecture Design Doc](../../.claude/design/claude-coordinator-core/architecture.md)
96
+ - [Server Package](../claude-coordinator-server/README.md)
97
+ - [MCP Bridge Package](../claude-coordinator-mcp/README.md)
98
+
99
+ ## License
100
+
101
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,242 @@
1
+ /**
2
+ * \@spencerbeggs/claude-coordinator-core
3
+ *
4
+ * Core schemas and types for the Claude Coordinator system.
5
+ * Provides Zod schemas for validation and TypeScript types for
6
+ * communication between Claude Code instances.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+
11
+ import { z } from 'zod';
12
+
13
+ export declare type Agent = z.infer<typeof AgentSchema>;
14
+
15
+ export declare type AgentRole = z.infer<typeof AgentRoleSchema>;
16
+
17
+ /**
18
+ * Role of an agent in the coordination session
19
+ */
20
+ export declare const AgentRoleSchema: z.ZodEnum<{
21
+ source: "source";
22
+ target: "target";
23
+ }>;
24
+
25
+ /**
26
+ * Schema for a connected agent in the coordination session
27
+ */
28
+ export declare const AgentSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ role: z.ZodEnum<{
31
+ source: "source";
32
+ target: "target";
33
+ }>;
34
+ name: z.ZodString;
35
+ repoPath: z.ZodString;
36
+ connectedAt: z.ZodCoercedDate<unknown>;
37
+ }, z.core.$strip>;
38
+
39
+ export declare type AnswerEvent = z.infer<typeof AnswerEventSchema>;
40
+
41
+ /**
42
+ * Event emitted when a question is answered
43
+ */
44
+ export declare const AnswerEventSchema: z.ZodObject<{
45
+ type: z.ZodLiteral<"answer">;
46
+ question: z.ZodObject<{
47
+ id: z.ZodString;
48
+ question: z.ZodString;
49
+ from: z.ZodString;
50
+ to: z.ZodOptional<z.ZodString>;
51
+ answer: z.ZodOptional<z.ZodString>;
52
+ answeredBy: z.ZodOptional<z.ZodString>;
53
+ status: z.ZodEnum<{
54
+ answered: "answered";
55
+ pending: "pending";
56
+ }>;
57
+ createdAt: z.ZodCoercedDate<unknown>;
58
+ answeredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
59
+ }, z.core.$strip>;
60
+ }, z.core.$strip>;
61
+
62
+ export declare type AnswerInput = z.infer<typeof AnswerInputSchema>;
63
+
64
+ /**
65
+ * Input schema for answering a question
66
+ */
67
+ export declare const AnswerInputSchema: z.ZodObject<{
68
+ questionId: z.ZodString;
69
+ answer: z.ZodString;
70
+ }, z.core.$strip>;
71
+
72
+ export declare type AskInput = z.infer<typeof AskInputSchema>;
73
+
74
+ /**
75
+ * Input schema for asking a question
76
+ */
77
+ export declare const AskInputSchema: z.ZodObject<{
78
+ question: z.ZodString;
79
+ to: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>;
81
+
82
+ export declare type ContextEntry = z.infer<typeof ContextEntrySchema>;
83
+
84
+ /**
85
+ * Schema for a shared context entry
86
+ */
87
+ export declare const ContextEntrySchema: z.ZodObject<{
88
+ id: z.ZodString;
89
+ key: z.ZodString;
90
+ value: z.ZodString;
91
+ tags: z.ZodArray<z.ZodString>;
92
+ createdBy: z.ZodString;
93
+ createdAt: z.ZodCoercedDate<unknown>;
94
+ updatedAt: z.ZodCoercedDate<unknown>;
95
+ }, z.core.$strip>;
96
+
97
+ export declare type Decision = z.infer<typeof DecisionSchema>;
98
+
99
+ /**
100
+ * Schema for a logged decision
101
+ */
102
+ export declare const DecisionSchema: z.ZodObject<{
103
+ id: z.ZodString;
104
+ decision: z.ZodString;
105
+ rationale: z.ZodOptional<z.ZodString>;
106
+ by: z.ZodString;
107
+ createdAt: z.ZodCoercedDate<unknown>;
108
+ }, z.core.$strip>;
109
+
110
+ export declare const DEFAULT_HOST: string;
111
+
112
+ export declare const DEFAULT_PORT: number;
113
+
114
+ export declare const DEFAULT_URL: string;
115
+
116
+ export declare type GetContextInput = z.infer<typeof GetContextInputSchema>;
117
+
118
+ /**
119
+ * Input schema for retrieving a context entry by key
120
+ */
121
+ export declare const GetContextInputSchema: z.ZodObject<{
122
+ key: z.ZodString;
123
+ }, z.core.$strip>;
124
+
125
+ export declare type JoinInput = z.infer<typeof JoinInputSchema>;
126
+
127
+ /**
128
+ * Input schema for joining a coordination session
129
+ */
130
+ export declare const JoinInputSchema: z.ZodObject<{
131
+ name: z.ZodString;
132
+ role: z.ZodEnum<{
133
+ source: "source";
134
+ target: "target";
135
+ }>;
136
+ repoPath: z.ZodString;
137
+ }, z.core.$strip>;
138
+
139
+ export declare type JoinResult = z.infer<typeof JoinResultSchema>;
140
+
141
+ /**
142
+ * Result of joining a coordination session
143
+ */
144
+ export declare const JoinResultSchema: z.ZodObject<{
145
+ agent: z.ZodObject<{
146
+ id: z.ZodString;
147
+ role: z.ZodEnum<{
148
+ source: "source";
149
+ target: "target";
150
+ }>;
151
+ name: z.ZodString;
152
+ repoPath: z.ZodString;
153
+ connectedAt: z.ZodCoercedDate<unknown>;
154
+ }, z.core.$strip>;
155
+ sessionId: z.ZodString;
156
+ }, z.core.$strip>;
157
+
158
+ export declare type ListContextInput = z.infer<typeof ListContextInputSchema>;
159
+
160
+ /**
161
+ * Input schema for listing context entries with optional filters
162
+ */
163
+ export declare const ListContextInputSchema: z.ZodObject<{
164
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
165
+ createdBy: z.ZodOptional<z.ZodString>;
166
+ }, z.core.$strip>;
167
+
168
+ export declare type LogDecisionInput = z.infer<typeof LogDecisionInputSchema>;
169
+
170
+ /**
171
+ * Input schema for logging a decision
172
+ */
173
+ export declare const LogDecisionInputSchema: z.ZodObject<{
174
+ decision: z.ZodString;
175
+ rationale: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$strip>;
177
+
178
+ export declare type Question = z.infer<typeof QuestionSchema>;
179
+
180
+ export declare type QuestionEvent = z.infer<typeof QuestionEventSchema>;
181
+
182
+ /**
183
+ * Event emitted when a question is asked
184
+ */
185
+ export declare const QuestionEventSchema: z.ZodObject<{
186
+ type: z.ZodLiteral<"question">;
187
+ question: z.ZodObject<{
188
+ id: z.ZodString;
189
+ question: z.ZodString;
190
+ from: z.ZodString;
191
+ to: z.ZodOptional<z.ZodString>;
192
+ answer: z.ZodOptional<z.ZodString>;
193
+ answeredBy: z.ZodOptional<z.ZodString>;
194
+ status: z.ZodEnum<{
195
+ answered: "answered";
196
+ pending: "pending";
197
+ }>;
198
+ createdAt: z.ZodCoercedDate<unknown>;
199
+ answeredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
200
+ }, z.core.$strip>;
201
+ }, z.core.$strip>;
202
+
203
+ /**
204
+ * Schema for a question between agents
205
+ */
206
+ export declare const QuestionSchema: z.ZodObject<{
207
+ id: z.ZodString;
208
+ question: z.ZodString;
209
+ from: z.ZodString;
210
+ to: z.ZodOptional<z.ZodString>;
211
+ answer: z.ZodOptional<z.ZodString>;
212
+ answeredBy: z.ZodOptional<z.ZodString>;
213
+ status: z.ZodEnum<{
214
+ answered: "answered";
215
+ pending: "pending";
216
+ }>;
217
+ createdAt: z.ZodCoercedDate<unknown>;
218
+ answeredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
219
+ }, z.core.$strip>;
220
+
221
+ export declare type QuestionStatus = z.infer<typeof QuestionStatusSchema>;
222
+
223
+ /**
224
+ * Status of a question
225
+ */
226
+ export declare const QuestionStatusSchema: z.ZodEnum<{
227
+ answered: "answered";
228
+ pending: "pending";
229
+ }>;
230
+
231
+ export declare type ShareContextInput = z.infer<typeof ShareContextInputSchema>;
232
+
233
+ /**
234
+ * Input schema for sharing a context entry
235
+ */
236
+ export declare const ShareContextInputSchema: z.ZodObject<{
237
+ key: z.ZodString;
238
+ value: z.ZodString;
239
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
240
+ }, z.core.$strip>;
241
+
242
+ export { }
package/index.js ADDED
@@ -0,0 +1,88 @@
1
+ import { z } from "zod";
2
+ const AgentRoleSchema = z["enum"]([
3
+ "source",
4
+ "target"
5
+ ]).describe("The role of the agent: 'source' provides knowledge, 'target' receives knowledge");
6
+ const AgentSchema = z.object({
7
+ id: z.string().uuid().describe("Unique identifier for the agent"),
8
+ role: AgentRoleSchema,
9
+ name: z.string().min(1).describe("Human-readable name for the agent"),
10
+ repoPath: z.string().min(1).describe("Path to the repository this agent is working in"),
11
+ connectedAt: z.coerce.date().describe("Timestamp when the agent connected")
12
+ }).describe("A connected agent in the coordination session");
13
+ const JoinInputSchema = z.object({
14
+ name: z.string().min(1).describe("Human-readable name for the agent"),
15
+ role: AgentRoleSchema,
16
+ repoPath: z.string().min(1).describe("Path to the repository this agent is working in")
17
+ }).describe("Input for joining a coordination session");
18
+ const JoinResultSchema = z.object({
19
+ agent: AgentSchema,
20
+ sessionId: z.string().uuid().describe("Unique identifier for the session")
21
+ }).describe("Result of joining a coordination session");
22
+ const ContextEntrySchema = z.object({
23
+ id: z.string().uuid().describe("Unique identifier for this context entry"),
24
+ key: z.string().min(1).describe("Key to identify this context entry"),
25
+ value: z.string().describe("The context value/content"),
26
+ tags: z.array(z.string()).describe("Tags for categorizing context"),
27
+ createdBy: z.string().uuid().describe("ID of the agent that created this entry"),
28
+ createdAt: z.coerce.date().describe("Timestamp when the entry was created"),
29
+ updatedAt: z.coerce.date().describe("Timestamp when the entry was last updated")
30
+ }).describe("A shared context entry");
31
+ const ShareContextInputSchema = z.object({
32
+ key: z.string().min(1).describe("Key to identify this context entry"),
33
+ value: z.string().describe("The context value/content to share"),
34
+ tags: z.array(z.string()).optional().describe("Optional tags for categorizing context")
35
+ }).describe("Input for sharing a context entry");
36
+ const GetContextInputSchema = z.object({
37
+ key: z.string().min(1).describe("Key of the context entry to retrieve")
38
+ }).describe("Input for retrieving a context entry by key");
39
+ const ListContextInputSchema = z.object({
40
+ tags: z.array(z.string()).optional().describe("Filter by tags (entries must have all specified tags)"),
41
+ createdBy: z.string().uuid().optional().describe("Filter by creator agent ID")
42
+ }).describe("Input for listing context entries with optional filters");
43
+ const DecisionSchema = z.object({
44
+ id: z.string().uuid().describe("Unique identifier for this decision"),
45
+ decision: z.string().min(1).describe("The decision that was made"),
46
+ rationale: z.string().optional().describe("Explanation for why this decision was made"),
47
+ by: z.string().uuid().describe("ID of the agent that made this decision"),
48
+ createdAt: z.coerce.date().describe("Timestamp when the decision was logged")
49
+ }).describe("A logged decision");
50
+ const LogDecisionInputSchema = z.object({
51
+ decision: z.string().min(1).describe("The decision that was made"),
52
+ rationale: z.string().optional().describe("Explanation for why this decision was made")
53
+ }).describe("Input for logging a decision");
54
+ const QuestionStatusSchema = z["enum"]([
55
+ "pending",
56
+ "answered"
57
+ ]).describe("Status of the question");
58
+ const QuestionSchema = z.object({
59
+ id: z.string().uuid().describe("Unique identifier for this question"),
60
+ question: z.string().min(1).describe("The question being asked"),
61
+ from: z.string().uuid().describe("ID of the agent asking the question"),
62
+ to: z.string().uuid().optional().describe("ID of a specific agent to answer (optional)"),
63
+ answer: z.string().optional().describe("The answer to the question"),
64
+ answeredBy: z.string().uuid().optional().describe("ID of the agent that answered"),
65
+ status: QuestionStatusSchema,
66
+ createdAt: z.coerce.date().describe("Timestamp when the question was asked"),
67
+ answeredAt: z.coerce.date().optional().describe("Timestamp when the question was answered")
68
+ }).describe("A question between agents");
69
+ const AskInputSchema = z.object({
70
+ question: z.string().min(1).describe("The question to ask"),
71
+ to: z.string().uuid().optional().describe("ID of a specific agent to answer (optional)")
72
+ }).describe("Input for asking a question");
73
+ const AnswerInputSchema = z.object({
74
+ questionId: z.string().uuid().describe("ID of the question to answer"),
75
+ answer: z.string().min(1).describe("The answer to the question")
76
+ }).describe("Input for answering a question");
77
+ const QuestionEventSchema = z.object({
78
+ type: z.literal("question"),
79
+ question: QuestionSchema
80
+ }).describe("Event emitted when a question is asked");
81
+ const AnswerEventSchema = z.object({
82
+ type: z.literal("answer"),
83
+ question: QuestionSchema
84
+ }).describe("Event emitted when a question is answered");
85
+ const DEFAULT_PORT = 3030;
86
+ const DEFAULT_HOST = "localhost";
87
+ const DEFAULT_URL = `ws://${DEFAULT_HOST}:${DEFAULT_PORT}`;
88
+ export { AgentRoleSchema, AgentSchema, AnswerEventSchema, AnswerInputSchema, AskInputSchema, ContextEntrySchema, DEFAULT_HOST, DEFAULT_PORT, DEFAULT_URL, DecisionSchema, GetContextInputSchema, JoinInputSchema, JoinResultSchema, ListContextInputSchema, LogDecisionInputSchema, QuestionEventSchema, QuestionSchema, QuestionStatusSchema, ShareContextInputSchema };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@spencerbeggs/claude-coordinator-core",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Core schemas and types for Claude Coordinator",
6
+ "keywords": [
7
+ "claude",
8
+ "coordinator",
9
+ "trpc",
10
+ "schemas"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/spencerbeggs/claude-design-coordinator.git",
15
+ "directory": "pkgs/claude-coordinator-core"
16
+ },
17
+ "license": "MIT",
18
+ "author": {
19
+ "name": "C. Spencer Beggs",
20
+ "email": "spencer@beggs.codes",
21
+ "url": "https://spencerbeg.gs"
22
+ },
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./index.d.ts",
27
+ "import": "./index.js"
28
+ }
29
+ },
30
+ "dependencies": {
31
+ "zod": "^4.3.5"
32
+ },
33
+ "engines": {
34
+ "node": ">=20.0.0"
35
+ },
36
+ "files": [
37
+ "LICENSE",
38
+ "README.md",
39
+ "index.d.ts",
40
+ "index.js",
41
+ "package.json"
42
+ ]
43
+ }