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.
- package/README.md +68 -186
- package/dist/client.d.ts +136 -186
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +419 -414
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +32 -10
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +46 -16
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -0
- package/dist/transport.d.ts +44 -24
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +248 -92
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +273 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +27 -26
- package/dist/types/actor.d.ts +0 -42
- package/dist/types/actor.d.ts.map +0 -1
- package/dist/types/actor.js +0 -5
- package/dist/types/actor.js.map +0 -1
- package/dist/types/context.d.ts +0 -89
- package/dist/types/context.d.ts.map +0 -1
- package/dist/types/context.js +0 -5
- package/dist/types/context.js.map +0 -1
- package/dist/types/event.d.ts +0 -15
- package/dist/types/event.d.ts.map +0 -1
- package/dist/types/event.js +0 -5
- package/dist/types/event.js.map +0 -1
- package/dist/types/group.d.ts +0 -33
- package/dist/types/group.d.ts.map +0 -1
- package/dist/types/group.js +0 -5
- package/dist/types/group.js.map +0 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -10
- package/dist/types/index.js.map +0 -1
- package/dist/types/ipc.d.ts +0 -24
- package/dist/types/ipc.d.ts.map +0 -1
- package/dist/types/ipc.js +0 -10
- package/dist/types/ipc.js.map +0 -1
- package/dist/types/message.d.ts +0 -53
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/message.js +0 -5
- package/dist/types/message.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,221 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CCCC TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript/Node.js client for the CCCC daemon (IPC v1).
|
|
4
4
|
|
|
5
|
-
##
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
event_id: 'abc123',
|
|
93
|
-
text: 'Got it!',
|
|
94
|
-
});
|
|
13
|
+
```bash
|
|
14
|
+
npm install cccc-sdk
|
|
95
15
|
```
|
|
96
16
|
|
|
97
|
-
|
|
17
|
+
## Quick start
|
|
98
18
|
|
|
99
19
|
```typescript
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
await client.inbox.markAllRead('g_abc123', 'agent-1');
|
|
42
|
+
main().catch(console.error);
|
|
111
43
|
```
|
|
112
44
|
|
|
113
|
-
|
|
45
|
+
## Message semantics
|
|
114
46
|
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
122
|
-
|
|
50
|
+
Supported in:
|
|
51
|
+
- `send(options)`
|
|
52
|
+
- `reply(options)`
|
|
53
|
+
- `sendCrossGroup(options)`
|
|
123
54
|
|
|
124
|
-
|
|
125
|
-
await client.sketch.update('g_abc123', '## Architecture\n...');
|
|
126
|
-
```
|
|
55
|
+
## Automation semantics
|
|
127
56
|
|
|
128
|
-
|
|
57
|
+
`groupAutomationManage` is action-list based (canonical daemon shape):
|
|
129
58
|
|
|
130
59
|
```typescript
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
78
|
+
## Events stream
|
|
153
79
|
|
|
154
80
|
```typescript
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
##
|
|
88
|
+
## Build and checks
|
|
191
89
|
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
213
|
-
|
|
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
|
-
|
|
103
|
+
Apache-2.0
|