cc-peer 1.1.0 → 1.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/dist/bin/cc-peer.cjs +54 -23
- package/dist/bin/cc-peer.mjs +54 -23
- package/dist/cc-peer.d.cts +3 -3
- package/dist/cc-peer.d.mts +3 -3
- package/package.json +1 -1
package/dist/bin/cc-peer.cjs
CHANGED
|
@@ -51,26 +51,58 @@ const IdleSubscriptionRequestSchema = require_cc_peer.defineSchema(zod.z.object(
|
|
|
51
51
|
id: "IdleSubscriptionRequest",
|
|
52
52
|
title: "Idle subscription request"
|
|
53
53
|
}));
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
const SendAcceptedSchema = require_cc_peer.defineSchema(zod.z.object({ msgId: zod.z.string() }).meta({
|
|
55
|
+
id: "SendAccepted",
|
|
56
|
+
title: "Send accepted"
|
|
57
|
+
}));
|
|
58
|
+
const RosterResponseSchema = require_cc_peer.defineSchema(zod.z.object({ sessions: zod.z.array(require_cc_peer.RegistryEntrySchema) }).meta({
|
|
59
|
+
id: "RosterResponse",
|
|
60
|
+
title: "Roster response"
|
|
61
|
+
}));
|
|
62
|
+
const ErrorResponseSchema = require_cc_peer.defineSchema(zod.z.object({ error: zod.z.string() }).meta({
|
|
63
|
+
id: "ErrorResponse",
|
|
64
|
+
title: "Error response"
|
|
65
|
+
}));
|
|
66
|
+
const API_REGISTRY = zod.z.registry();
|
|
67
|
+
API_REGISTRY.add(PeerTargetSchema, {
|
|
68
|
+
id: "PeerTarget",
|
|
69
|
+
title: "Peer target"
|
|
70
|
+
});
|
|
71
|
+
API_REGISTRY.add(SendMessageRequestSchema, {
|
|
72
|
+
id: "SendMessageRequest",
|
|
73
|
+
title: "Send message request"
|
|
74
|
+
});
|
|
75
|
+
API_REGISTRY.add(IdleSubscriptionRequestSchema, {
|
|
76
|
+
id: "IdleSubscriptionRequest",
|
|
77
|
+
title: "Idle subscription request"
|
|
78
|
+
});
|
|
79
|
+
API_REGISTRY.add(SendAcceptedSchema, {
|
|
80
|
+
id: "SendAccepted",
|
|
81
|
+
title: "Send accepted"
|
|
82
|
+
});
|
|
83
|
+
API_REGISTRY.add(RosterResponseSchema, {
|
|
84
|
+
id: "RosterResponse",
|
|
85
|
+
title: "Roster response"
|
|
86
|
+
});
|
|
87
|
+
API_REGISTRY.add(ErrorResponseSchema, {
|
|
88
|
+
id: "ErrorResponse",
|
|
89
|
+
title: "Error response"
|
|
90
|
+
});
|
|
91
|
+
/** Convert the registry into OpenAPI 3.1 component schemas, refs as pointers. */
|
|
92
|
+
function isJsonObject(value) {
|
|
93
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
94
|
+
}
|
|
95
|
+
function apiComponentSchemas() {
|
|
96
|
+
const converted = zod.z.toJSONSchema(API_REGISTRY, { uri: (id) => `#/components/schemas/${id}` });
|
|
97
|
+
const schemas = isJsonObject(converted) && isJsonObject(converted.schemas) ? converted.schemas : {};
|
|
98
|
+
const stripped = {};
|
|
99
|
+
for (const [name, schema] of Object.entries(schemas)) if (isJsonObject(schema) && "$schema" in schema) {
|
|
100
|
+
const rest = { ...schema };
|
|
101
|
+
delete rest.$schema;
|
|
102
|
+
stripped[name] = rest;
|
|
103
|
+
} else stripped[name] = schema;
|
|
104
|
+
return stripped;
|
|
105
|
+
}
|
|
74
106
|
//#endregion
|
|
75
107
|
//#region src/api/server.ts
|
|
76
108
|
/** Loopback only; this bridges onto a same-user IPC trust boundary. */
|
|
@@ -175,7 +207,7 @@ function toPeerRef(to) {
|
|
|
175
207
|
throw new Error("target must specify pid, name, or address");
|
|
176
208
|
}
|
|
177
209
|
function errorBody(message) {
|
|
178
|
-
return JSON.stringify(
|
|
210
|
+
return JSON.stringify({ error: message });
|
|
179
211
|
}
|
|
180
212
|
function streamEvents(peer, req, res) {
|
|
181
213
|
res.writeHead(HTTP_OK, {
|
|
@@ -223,8 +255,7 @@ function ref(name) {
|
|
|
223
255
|
* OpenAPI 3.1 document: hand-authored paths/operations (which Zod cannot express) with every component schema converted losslessly from the same Zod definitions the server parses request bodies with — 3.1 components are JSON Schema 2020-12, so z.toJSONSchema output embeds directly.
|
|
224
256
|
*/
|
|
225
257
|
function openApiDocument() {
|
|
226
|
-
const components =
|
|
227
|
-
for (const [name, schema] of Object.entries(API_COMPONENT_SCHEMAS)) components[name] = zod.z.toJSONSchema(schema, { target: "draft-2020-12" });
|
|
258
|
+
const components = apiComponentSchemas();
|
|
228
259
|
const jsonBody = (name) => ({
|
|
229
260
|
required: true,
|
|
230
261
|
content: { "application/json": { schema: ref(name) } }
|
package/dist/bin/cc-peer.mjs
CHANGED
|
@@ -28,26 +28,58 @@ const IdleSubscriptionRequestSchema = defineSchema(z.object({ to: PeerTargetSche
|
|
|
28
28
|
id: "IdleSubscriptionRequest",
|
|
29
29
|
title: "Idle subscription request"
|
|
30
30
|
}));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
const SendAcceptedSchema = defineSchema(z.object({ msgId: z.string() }).meta({
|
|
32
|
+
id: "SendAccepted",
|
|
33
|
+
title: "Send accepted"
|
|
34
|
+
}));
|
|
35
|
+
const RosterResponseSchema = defineSchema(z.object({ sessions: z.array(RegistryEntrySchema) }).meta({
|
|
36
|
+
id: "RosterResponse",
|
|
37
|
+
title: "Roster response"
|
|
38
|
+
}));
|
|
39
|
+
const ErrorResponseSchema = defineSchema(z.object({ error: z.string() }).meta({
|
|
40
|
+
id: "ErrorResponse",
|
|
41
|
+
title: "Error response"
|
|
42
|
+
}));
|
|
43
|
+
const API_REGISTRY = z.registry();
|
|
44
|
+
API_REGISTRY.add(PeerTargetSchema, {
|
|
45
|
+
id: "PeerTarget",
|
|
46
|
+
title: "Peer target"
|
|
47
|
+
});
|
|
48
|
+
API_REGISTRY.add(SendMessageRequestSchema, {
|
|
49
|
+
id: "SendMessageRequest",
|
|
50
|
+
title: "Send message request"
|
|
51
|
+
});
|
|
52
|
+
API_REGISTRY.add(IdleSubscriptionRequestSchema, {
|
|
53
|
+
id: "IdleSubscriptionRequest",
|
|
54
|
+
title: "Idle subscription request"
|
|
55
|
+
});
|
|
56
|
+
API_REGISTRY.add(SendAcceptedSchema, {
|
|
57
|
+
id: "SendAccepted",
|
|
58
|
+
title: "Send accepted"
|
|
59
|
+
});
|
|
60
|
+
API_REGISTRY.add(RosterResponseSchema, {
|
|
61
|
+
id: "RosterResponse",
|
|
62
|
+
title: "Roster response"
|
|
63
|
+
});
|
|
64
|
+
API_REGISTRY.add(ErrorResponseSchema, {
|
|
65
|
+
id: "ErrorResponse",
|
|
66
|
+
title: "Error response"
|
|
67
|
+
});
|
|
68
|
+
/** Convert the registry into OpenAPI 3.1 component schemas, refs as pointers. */
|
|
69
|
+
function isJsonObject(value) {
|
|
70
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
71
|
+
}
|
|
72
|
+
function apiComponentSchemas() {
|
|
73
|
+
const converted = z.toJSONSchema(API_REGISTRY, { uri: (id) => `#/components/schemas/${id}` });
|
|
74
|
+
const schemas = isJsonObject(converted) && isJsonObject(converted.schemas) ? converted.schemas : {};
|
|
75
|
+
const stripped = {};
|
|
76
|
+
for (const [name, schema] of Object.entries(schemas)) if (isJsonObject(schema) && "$schema" in schema) {
|
|
77
|
+
const rest = { ...schema };
|
|
78
|
+
delete rest.$schema;
|
|
79
|
+
stripped[name] = rest;
|
|
80
|
+
} else stripped[name] = schema;
|
|
81
|
+
return stripped;
|
|
82
|
+
}
|
|
51
83
|
//#endregion
|
|
52
84
|
//#region src/api/server.ts
|
|
53
85
|
/** Loopback only; this bridges onto a same-user IPC trust boundary. */
|
|
@@ -152,7 +184,7 @@ function toPeerRef(to) {
|
|
|
152
184
|
throw new Error("target must specify pid, name, or address");
|
|
153
185
|
}
|
|
154
186
|
function errorBody(message) {
|
|
155
|
-
return JSON.stringify(
|
|
187
|
+
return JSON.stringify({ error: message });
|
|
156
188
|
}
|
|
157
189
|
function streamEvents(peer, req, res) {
|
|
158
190
|
res.writeHead(HTTP_OK, {
|
|
@@ -200,8 +232,7 @@ function ref(name) {
|
|
|
200
232
|
* OpenAPI 3.1 document: hand-authored paths/operations (which Zod cannot express) with every component schema converted losslessly from the same Zod definitions the server parses request bodies with — 3.1 components are JSON Schema 2020-12, so z.toJSONSchema output embeds directly.
|
|
201
233
|
*/
|
|
202
234
|
function openApiDocument() {
|
|
203
|
-
const components =
|
|
204
|
-
for (const [name, schema] of Object.entries(API_COMPONENT_SCHEMAS)) components[name] = z.toJSONSchema(schema, { target: "draft-2020-12" });
|
|
235
|
+
const components = apiComponentSchemas();
|
|
205
236
|
const jsonBody = (name) => ({
|
|
206
237
|
required: true,
|
|
207
238
|
content: { "application/json": { schema: ref(name) } }
|
package/dist/cc-peer.d.cts
CHANGED
|
@@ -70,12 +70,12 @@ declare const RegistryEntrySchema: z.ZodObject<{
|
|
|
70
70
|
nameSince: z.ZodOptional<z.ZodNumber>;
|
|
71
71
|
updatedAt: z.ZodNumber;
|
|
72
72
|
status: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
idle: "idle";
|
|
73
74
|
busy: "busy";
|
|
74
75
|
shell: "shell";
|
|
75
|
-
idle: "idle";
|
|
76
76
|
waiting: "waiting";
|
|
77
77
|
}> & {
|
|
78
|
-
is(value: unknown): value is "
|
|
78
|
+
is(value: unknown): value is "idle" | "busy" | "shell" | "waiting";
|
|
79
79
|
}>;
|
|
80
80
|
statusUpdatedAt: z.ZodOptional<z.ZodNumber>;
|
|
81
81
|
bridgeSessionId: z.ZodOptional<z.ZodString>;
|
|
@@ -97,7 +97,7 @@ declare const RegistryEntrySchema: z.ZodObject<{
|
|
|
97
97
|
name?: string | undefined;
|
|
98
98
|
nameSource?: "user" | "peer" | "derived" | "collision" | "auto" | "hook" | undefined;
|
|
99
99
|
nameSince?: number | undefined;
|
|
100
|
-
status?: "
|
|
100
|
+
status?: "idle" | "busy" | "shell" | "waiting" | undefined;
|
|
101
101
|
statusUpdatedAt?: number | undefined;
|
|
102
102
|
bridgeSessionId?: string | undefined;
|
|
103
103
|
};
|
package/dist/cc-peer.d.mts
CHANGED
|
@@ -70,12 +70,12 @@ declare const RegistryEntrySchema: z.ZodObject<{
|
|
|
70
70
|
nameSince: z.ZodOptional<z.ZodNumber>;
|
|
71
71
|
updatedAt: z.ZodNumber;
|
|
72
72
|
status: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
idle: "idle";
|
|
73
74
|
busy: "busy";
|
|
74
75
|
shell: "shell";
|
|
75
|
-
idle: "idle";
|
|
76
76
|
waiting: "waiting";
|
|
77
77
|
}> & {
|
|
78
|
-
is(value: unknown): value is "
|
|
78
|
+
is(value: unknown): value is "idle" | "busy" | "shell" | "waiting";
|
|
79
79
|
}>;
|
|
80
80
|
statusUpdatedAt: z.ZodOptional<z.ZodNumber>;
|
|
81
81
|
bridgeSessionId: z.ZodOptional<z.ZodString>;
|
|
@@ -97,7 +97,7 @@ declare const RegistryEntrySchema: z.ZodObject<{
|
|
|
97
97
|
name?: string | undefined;
|
|
98
98
|
nameSource?: "user" | "peer" | "derived" | "collision" | "auto" | "hook" | undefined;
|
|
99
99
|
nameSince?: number | undefined;
|
|
100
|
-
status?: "
|
|
100
|
+
status?: "idle" | "busy" | "shell" | "waiting" | undefined;
|
|
101
101
|
statusUpdatedAt?: number | undefined;
|
|
102
102
|
bridgeSessionId?: string | undefined;
|
|
103
103
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-peer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Communicate with local Claude Code instances over their native cross-session peer messaging: send and receive messages, register as a named discoverable peer, receipts, idle subscriptions, and a REST facade via `npx cc-peer`.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|