cccc-sdk 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.
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # @cccc/sdk
2
+
3
+ CCCC Client SDK for Node.js - IPC client for CCCC daemon.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @cccc/sdk
9
+ ```
10
+
11
+ ## Requirements
12
+
13
+ - Node.js >= 18.0.0
14
+ - CCCC daemon running locally
15
+
16
+ ## Quick Start
17
+
18
+ ```typescript
19
+ import { CCCCClient } from '@cccc/sdk';
20
+
21
+ const client = new CCCCClient();
22
+
23
+ // Check daemon is running
24
+ const isRunning = await client.ping();
25
+ console.log('Daemon running:', isRunning);
26
+
27
+ // List all groups
28
+ const groups = await client.groups.list();
29
+ console.log('Groups:', groups);
30
+ ```
31
+
32
+ ## API Overview
33
+
34
+ ### Groups
35
+
36
+ ```typescript
37
+ // List groups
38
+ const groups = await client.groups.list();
39
+
40
+ // Get group info
41
+ const group = await client.groups.get('g_abc123');
42
+
43
+ // Create group
44
+ const newGroup = await client.groups.create({
45
+ title: 'My Project',
46
+ topic: 'Building something awesome',
47
+ url: '/path/to/project',
48
+ });
49
+
50
+ // Start/Stop group
51
+ await client.groups.start('g_abc123');
52
+ await client.groups.stop('g_abc123');
53
+
54
+ // Set group state
55
+ await client.groups.setState('g_abc123', 'active', 'user');
56
+ ```
57
+
58
+ ### Actors
59
+
60
+ ```typescript
61
+ // List actors
62
+ const actors = await client.actors.list('g_abc123');
63
+
64
+ // Add actor
65
+ const actor = await client.actors.add('g_abc123', 'user', {
66
+ actor_id: 'agent-1',
67
+ runtime: 'claude',
68
+ runner: 'pty',
69
+ title: 'Claude Agent',
70
+ });
71
+
72
+ // Start/Stop/Restart actor
73
+ await client.actors.start('g_abc123', 'agent-1', 'user');
74
+ await client.actors.stop('g_abc123', 'agent-1', 'user');
75
+ await client.actors.restart('g_abc123', 'agent-1', 'user');
76
+
77
+ // Remove actor
78
+ await client.actors.remove('g_abc123', 'agent-1', 'user');
79
+ ```
80
+
81
+ ### Messages
82
+
83
+ ```typescript
84
+ // Send message
85
+ const event = await client.messages.send('g_abc123', 'user', {
86
+ text: 'Hello agents!',
87
+ to: ['agent-1', 'agent-2'],
88
+ });
89
+
90
+ // Reply to message
91
+ await client.messages.reply('g_abc123', 'user', {
92
+ event_id: 'abc123',
93
+ text: 'Got it!',
94
+ });
95
+ ```
96
+
97
+ ### Inbox
98
+
99
+ ```typescript
100
+ // List inbox messages
101
+ const messages = await client.inbox.list('g_abc123', 'agent-1', {
102
+ kind_filter: 'chat',
103
+ limit: 50,
104
+ });
105
+
106
+ // Mark as read
107
+ await client.inbox.markRead('g_abc123', 'agent-1', 'event_id');
108
+
109
+ // Mark all as read
110
+ await client.inbox.markAllRead('g_abc123', 'agent-1');
111
+ ```
112
+
113
+ ### Context
114
+
115
+ ```typescript
116
+ // Get context
117
+ const ctx = await client.context.get('g_abc123');
118
+ console.log('Vision:', ctx.vision);
119
+ console.log('Milestones:', ctx.milestones);
120
+
121
+ // Update vision
122
+ await client.vision.update('g_abc123', 'Build the best product');
123
+
124
+ // Update sketch
125
+ await client.sketch.update('g_abc123', '## Architecture\n...');
126
+ ```
127
+
128
+ ### Tasks
129
+
130
+ ```typescript
131
+ // List tasks
132
+ const tasks = await client.tasks.list('g_abc123');
133
+
134
+ // Create task
135
+ const task = await client.tasks.create('g_abc123', {
136
+ name: 'Implement feature X',
137
+ goal: 'Feature X works correctly',
138
+ steps: [
139
+ { name: 'Design API', acceptance: 'API spec documented' },
140
+ { name: 'Implement', acceptance: 'Code written and tested' },
141
+ { name: 'Review', acceptance: 'PR approved' },
142
+ ],
143
+ });
144
+
145
+ // Update task status
146
+ await client.tasks.update('g_abc123', {
147
+ task_id: task.id,
148
+ status: 'active',
149
+ });
150
+ ```
151
+
152
+ ### Milestones
153
+
154
+ ```typescript
155
+ // Create milestone
156
+ const milestone = await client.milestones.create('g_abc123', {
157
+ name: 'MVP',
158
+ description: 'Minimum viable product',
159
+ });
160
+
161
+ // Complete milestone
162
+ await client.milestones.complete('g_abc123', milestone.id, 'Shipped!');
163
+ ```
164
+
165
+ ## Error Handling
166
+
167
+ ```typescript
168
+ import { CCCCClient, CCCCError } from '@cccc/sdk';
169
+
170
+ const client = new CCCCClient();
171
+
172
+ try {
173
+ await client.groups.get('invalid-id');
174
+ } catch (error) {
175
+ if (error instanceof CCCCError) {
176
+ console.error('CCCC Error:', error.code, error.message);
177
+ // Handle specific errors
178
+ switch (error.code) {
179
+ case 'DAEMON_NOT_RUNNING':
180
+ console.error('Please start CCCC daemon first');
181
+ break;
182
+ case 'GROUP_NOT_FOUND':
183
+ console.error('Group does not exist');
184
+ break;
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ ## Configuration
191
+
192
+ ```typescript
193
+ const client = new CCCCClient({
194
+ // Custom CCCC home directory (default: ~/.cccc)
195
+ ccccHome: '/custom/path/.cccc',
196
+ // Request timeout in ms (default: 60000)
197
+ timeoutMs: 30000,
198
+ });
199
+ ```
200
+
201
+ ## Low-level API
202
+
203
+ For operations not covered by the high-level API:
204
+
205
+ ```typescript
206
+ // Direct daemon call
207
+ const response = await client.call('custom_op', {
208
+ arg1: 'value1',
209
+ arg2: 'value2',
210
+ });
211
+
212
+ if (response.ok) {
213
+ console.log('Result:', response.result);
214
+ } else {
215
+ console.error('Error:', response.error);
216
+ }
217
+ ```
218
+
219
+ ## License
220
+
221
+ MIT
@@ -0,0 +1,262 @@
1
+ /**
2
+ * CCCC Client SDK
3
+ *
4
+ * High-level API for interacting with CCCC daemon
5
+ */
6
+ import { type TransportOptions } from './transport.js';
7
+ import { type DaemonResponse } from './types/ipc.js';
8
+ import type { Actor, ActorAddOptions, GroupState, HeadlessState } from './types/actor.js';
9
+ import type { GroupInfo, GroupCreateOptions, GroupUpdatePatch } from './types/group.js';
10
+ import type { SendMessageOptions, ReplyMessageOptions, InboxMessage, InboxListOptions } from './types/message.js';
11
+ import type { Event } from './types/event.js';
12
+ import type { Context, ContextSyncOp, Task, TaskCreateOptions, TaskUpdateOptions, Milestone, MilestoneCreateOptions } from './types/context.js';
13
+ export interface CCCCClientOptions extends TransportOptions {
14
+ }
15
+ /**
16
+ * Groups API
17
+ */
18
+ declare class GroupsAPI {
19
+ private client;
20
+ constructor(client: CCCCClient);
21
+ /**
22
+ * List all groups
23
+ */
24
+ list(): Promise<GroupInfo[]>;
25
+ /**
26
+ * Get group info
27
+ */
28
+ get(groupId: string): Promise<GroupInfo>;
29
+ /**
30
+ * Create a new group
31
+ */
32
+ create(options: GroupCreateOptions): Promise<GroupInfo>;
33
+ /**
34
+ * Set group state
35
+ */
36
+ setState(groupId: string, state: GroupState, by: string): Promise<void>;
37
+ /**
38
+ * Start group (activate all enabled actors)
39
+ */
40
+ start(groupId: string): Promise<void>;
41
+ /**
42
+ * Stop group (stop all actors)
43
+ */
44
+ stop(groupId: string): Promise<void>;
45
+ /**
46
+ * Update group
47
+ */
48
+ update(groupId: string, patch: GroupUpdatePatch): Promise<void>;
49
+ /**
50
+ * Delete group
51
+ */
52
+ delete(groupId: string): Promise<void>;
53
+ }
54
+ /**
55
+ * Actors API
56
+ */
57
+ declare class ActorsAPI {
58
+ private client;
59
+ constructor(client: CCCCClient);
60
+ /**
61
+ * List actors in a group
62
+ */
63
+ list(groupId: string): Promise<Actor[]>;
64
+ /**
65
+ * Add an actor to a group
66
+ */
67
+ add(groupId: string, by: string, options: ActorAddOptions): Promise<Actor>;
68
+ /**
69
+ * Start an actor
70
+ */
71
+ start(groupId: string, actorId: string, by: string): Promise<void>;
72
+ /**
73
+ * Stop an actor
74
+ */
75
+ stop(groupId: string, actorId: string, by: string): Promise<void>;
76
+ /**
77
+ * Restart an actor
78
+ */
79
+ restart(groupId: string, actorId: string, by: string): Promise<void>;
80
+ /**
81
+ * Remove an actor
82
+ */
83
+ remove(groupId: string, actorId: string, by: string): Promise<void>;
84
+ }
85
+ /**
86
+ * Messages API
87
+ */
88
+ declare class MessagesAPI {
89
+ private client;
90
+ constructor(client: CCCCClient);
91
+ /**
92
+ * Send a message
93
+ */
94
+ send(groupId: string, by: string, options: SendMessageOptions): Promise<Event>;
95
+ /**
96
+ * Reply to a message
97
+ */
98
+ reply(groupId: string, by: string, options: ReplyMessageOptions): Promise<Event>;
99
+ }
100
+ /**
101
+ * Inbox API
102
+ */
103
+ declare class InboxAPI {
104
+ private client;
105
+ constructor(client: CCCCClient);
106
+ /**
107
+ * List inbox messages
108
+ */
109
+ list(groupId: string, actorId: string, options?: InboxListOptions): Promise<InboxMessage[]>;
110
+ /**
111
+ * Mark messages as read up to event_id
112
+ */
113
+ markRead(groupId: string, actorId: string, eventId: string): Promise<void>;
114
+ /**
115
+ * Mark all messages as read
116
+ */
117
+ markAllRead(groupId: string, actorId: string): Promise<void>;
118
+ }
119
+ /**
120
+ * Context API
121
+ */
122
+ declare class ContextAPI {
123
+ private client;
124
+ constructor(client: CCCCClient);
125
+ /**
126
+ * Get project context
127
+ */
128
+ get(groupId: string): Promise<Context>;
129
+ /**
130
+ * Sync context with batch operations
131
+ */
132
+ sync(groupId: string, ops: ContextSyncOp[], dryRun?: boolean): Promise<Record<string, unknown>>;
133
+ }
134
+ /**
135
+ * Tasks API
136
+ */
137
+ declare class TasksAPI {
138
+ private client;
139
+ constructor(client: CCCCClient);
140
+ /**
141
+ * List tasks
142
+ */
143
+ list(groupId: string, includeArchived?: boolean): Promise<Task[]>;
144
+ /**
145
+ * Create a task
146
+ */
147
+ create(groupId: string, options: TaskCreateOptions): Promise<Task>;
148
+ /**
149
+ * Update a task
150
+ */
151
+ update(groupId: string, options: TaskUpdateOptions): Promise<Task>;
152
+ }
153
+ /**
154
+ * Milestones API
155
+ */
156
+ declare class MilestonesAPI {
157
+ private client;
158
+ constructor(client: CCCCClient);
159
+ /**
160
+ * Create a milestone
161
+ */
162
+ create(groupId: string, options: MilestoneCreateOptions): Promise<Milestone>;
163
+ /**
164
+ * Complete a milestone
165
+ */
166
+ complete(groupId: string, milestoneId: string, outcomes: string): Promise<void>;
167
+ }
168
+ /**
169
+ * Vision API
170
+ */
171
+ declare class VisionAPI {
172
+ private client;
173
+ constructor(client: CCCCClient);
174
+ /**
175
+ * Update project vision
176
+ */
177
+ update(groupId: string, vision: string): Promise<void>;
178
+ }
179
+ /**
180
+ * Sketch API
181
+ */
182
+ declare class SketchAPI {
183
+ private client;
184
+ constructor(client: CCCCClient);
185
+ /**
186
+ * Update execution sketch
187
+ */
188
+ update(groupId: string, sketch: string): Promise<void>;
189
+ }
190
+ /**
191
+ * Headless API for MCP-driven actors
192
+ */
193
+ declare class HeadlessAPI {
194
+ private client;
195
+ constructor(client: CCCCClient);
196
+ /**
197
+ * Get headless session status
198
+ */
199
+ status(groupId: string, actorId: string): Promise<HeadlessState>;
200
+ /**
201
+ * Set headless session status
202
+ */
203
+ setStatus(groupId: string, actorId: string, status: 'idle' | 'working' | 'waiting' | 'stopped', taskId?: string): Promise<void>;
204
+ /**
205
+ * Acknowledge processed message
206
+ */
207
+ ackMessage(groupId: string, actorId: string, messageId: string): Promise<void>;
208
+ }
209
+ /**
210
+ * CCCC Client
211
+ *
212
+ * Main entry point for SDK
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const client = new CCCCClient();
217
+ *
218
+ * // List all groups
219
+ * const groups = await client.groups.list();
220
+ *
221
+ * // Add an actor
222
+ * await client.actors.add(groupId, 'user', {
223
+ * actor_id: 'agent-1',
224
+ * runtime: 'claude',
225
+ * runner: 'pty'
226
+ * });
227
+ *
228
+ * // Send a message
229
+ * await client.messages.send(groupId, 'user', {
230
+ * text: 'Hello agents!',
231
+ * to: ['agent-1']
232
+ * });
233
+ * ```
234
+ */
235
+ export declare class CCCCClient {
236
+ private options;
237
+ readonly groups: GroupsAPI;
238
+ readonly actors: ActorsAPI;
239
+ readonly messages: MessagesAPI;
240
+ readonly inbox: InboxAPI;
241
+ readonly context: ContextAPI;
242
+ readonly tasks: TasksAPI;
243
+ readonly milestones: MilestonesAPI;
244
+ readonly vision: VisionAPI;
245
+ readonly sketch: SketchAPI;
246
+ readonly headless: HeadlessAPI;
247
+ constructor(options?: CCCCClientOptions);
248
+ /**
249
+ * Ping daemon to check if it's running
250
+ */
251
+ ping(): Promise<boolean>;
252
+ /**
253
+ * Low-level daemon call
254
+ */
255
+ call(op: string, args: Record<string, unknown>): Promise<DaemonResponse>;
256
+ /**
257
+ * Shutdown the daemon
258
+ */
259
+ shutdown(): Promise<void>;
260
+ }
261
+ export {};
262
+ //# sourceMappingURL=client.d.ts.map