cccc-sdk 0.1.0 → 0.1.2

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 (50) hide show
  1. package/README.md +68 -186
  2. package/dist/client.d.ts +136 -186
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +419 -414
  5. package/dist/client.js.map +1 -0
  6. package/dist/errors.d.ts +32 -10
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/errors.js +46 -16
  9. package/dist/errors.js.map +1 -0
  10. package/dist/index.d.ts +7 -7
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +11 -10
  13. package/dist/index.js.map +1 -0
  14. package/dist/transport.d.ts +44 -24
  15. package/dist/transport.d.ts.map +1 -0
  16. package/dist/transport.js +248 -92
  17. package/dist/transport.js.map +1 -0
  18. package/dist/types.d.ts +273 -0
  19. package/dist/types.d.ts.map +1 -0
  20. package/dist/types.js +5 -0
  21. package/dist/types.js.map +1 -0
  22. package/package.json +27 -26
  23. package/dist/types/actor.d.ts +0 -42
  24. package/dist/types/actor.d.ts.map +0 -1
  25. package/dist/types/actor.js +0 -5
  26. package/dist/types/actor.js.map +0 -1
  27. package/dist/types/context.d.ts +0 -89
  28. package/dist/types/context.d.ts.map +0 -1
  29. package/dist/types/context.js +0 -5
  30. package/dist/types/context.js.map +0 -1
  31. package/dist/types/event.d.ts +0 -15
  32. package/dist/types/event.d.ts.map +0 -1
  33. package/dist/types/event.js +0 -5
  34. package/dist/types/event.js.map +0 -1
  35. package/dist/types/group.d.ts +0 -33
  36. package/dist/types/group.d.ts.map +0 -1
  37. package/dist/types/group.js +0 -5
  38. package/dist/types/group.js.map +0 -1
  39. package/dist/types/index.d.ts +0 -10
  40. package/dist/types/index.d.ts.map +0 -1
  41. package/dist/types/index.js +0 -10
  42. package/dist/types/index.js.map +0 -1
  43. package/dist/types/ipc.d.ts +0 -24
  44. package/dist/types/ipc.d.ts.map +0 -1
  45. package/dist/types/ipc.js +0 -10
  46. package/dist/types/ipc.js.map +0 -1
  47. package/dist/types/message.d.ts +0 -53
  48. package/dist/types/message.d.ts.map +0 -1
  49. package/dist/types/message.js +0 -5
  50. package/dist/types/message.js.map +0 -1
package/README.md CHANGED
@@ -1,221 +1,103 @@
1
- # @cccc/sdk
1
+ # CCCC TypeScript SDK
2
2
 
3
- CCCC Client SDK for Node.js - IPC client for CCCC daemon.
3
+ TypeScript/Node.js client for the CCCC daemon (IPC v1).
4
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
5
+ ## Relationship to CCCC core
33
6
 
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
- ```
7
+ - CCCC core repository: https://github.com/ChesterRa/cccc
8
+ - `cccc` core provides daemon/web/CLI and owns runtime state.
9
+ - `cccc-sdk` provides Node.js client APIs that call the daemon over IPC.
80
10
 
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
- });
11
+ ## Installation
89
12
 
90
- // Reply to message
91
- await client.messages.reply('g_abc123', 'user', {
92
- event_id: 'abc123',
93
- text: 'Got it!',
94
- });
13
+ ```bash
14
+ npm install cccc-sdk
95
15
  ```
96
16
 
97
- ### Inbox
17
+ ## Quick start
98
18
 
99
19
  ```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');
20
+ import { CCCCClient } from 'cccc-sdk';
21
+
22
+ async function main() {
23
+ const client = await CCCCClient.create();
24
+
25
+ await client.assertCompatible({
26
+ requireIpcV: 1,
27
+ requireCapabilities: { events_stream: true },
28
+ requireOps: ['groups', 'send', 'reply', 'group_automation_manage'],
29
+ });
30
+
31
+ const group = await client.groupCreate({ title: 'TS demo' });
32
+ const groupId = String(group.group_id || '');
33
+
34
+ await client.send({
35
+ groupId,
36
+ text: 'Please check this and reply.',
37
+ priority: 'attention',
38
+ replyRequired: true,
39
+ });
40
+ }
108
41
 
109
- // Mark all as read
110
- await client.inbox.markAllRead('g_abc123', 'agent-1');
42
+ main().catch(console.error);
111
43
  ```
112
44
 
113
- ### Context
45
+ ## Message semantics
114
46
 
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);
47
+ - `priority`: `'normal' | 'attention'`
48
+ - `replyRequired`: `boolean` (maps to daemon `reply_required`)
120
49
 
121
- // Update vision
122
- await client.vision.update('g_abc123', 'Build the best product');
50
+ Supported in:
51
+ - `send(options)`
52
+ - `reply(options)`
53
+ - `sendCrossGroup(options)`
123
54
 
124
- // Update sketch
125
- await client.sketch.update('g_abc123', '## Architecture\n...');
126
- ```
55
+ ## Automation semantics
127
56
 
128
- ### Tasks
57
+ `groupAutomationManage` is action-list based (canonical daemon shape):
129
58
 
130
59
  ```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' },
60
+ await client.groupAutomationManage({
61
+ groupId,
62
+ actions: [
63
+ {
64
+ type: 'create_rule',
65
+ rule: {
66
+ id: 'standup',
67
+ enabled: true,
68
+ scope: 'group',
69
+ to: ['@foreman'],
70
+ trigger: { kind: 'interval', every_seconds: 900 },
71
+ action: { kind: 'notify', snippet_ref: 'standup' },
72
+ },
73
+ },
142
74
  ],
143
75
  });
144
-
145
- // Update task status
146
- await client.tasks.update('g_abc123', {
147
- task_id: task.id,
148
- status: 'active',
149
- });
150
76
  ```
151
77
 
152
- ### Milestones
78
+ ## Events stream
153
79
 
154
80
  ```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
- }
81
+ for await (const item of client.eventsStream({ groupId })) {
82
+ if (item.t === 'event') {
83
+ console.log(item.event.kind, item.event.id);
186
84
  }
187
85
  }
188
86
  ```
189
87
 
190
- ## Configuration
88
+ ## Build and checks
191
89
 
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
- });
90
+ ```bash
91
+ npm ci
92
+ npm run typecheck
93
+ npm run build
199
94
  ```
200
95
 
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
- });
96
+ ## Requirements
211
97
 
212
- if (response.ok) {
213
- console.log('Result:', response.result);
214
- } else {
215
- console.error('Error:', response.error);
216
- }
217
- ```
98
+ - Node.js 16+
99
+ - Running CCCC daemon
218
100
 
219
101
  ## License
220
102
 
221
- MIT
103
+ Apache-2.0