@opencode-cockpit/protocol 0.1.4 → 0.2.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.
@@ -0,0 +1,12 @@
1
+ export interface CockpitPaths {
2
+ home: string;
3
+ socket: string;
4
+ pidFile: string;
5
+ lockFile: string;
6
+ logFile: string;
7
+ }
8
+ /**
9
+ * Filesystem layout shared by daemon and clients. Pure: creates nothing.
10
+ * Kept short because unix socket paths are limited to 104 bytes on macOS.
11
+ */
12
+ export declare function resolvePaths(env?: Record<string, string | undefined>): CockpitPaths;
package/types/rpc.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ /** Wire envelope: JSON-RPC 2.0, one JSON object per line (ADR 0002). */
2
+ /** Bump MAJOR on breaking changes to methods, events or framing. */
3
+ export declare const PROTOCOL_VERSION: {
4
+ readonly major: 1;
5
+ readonly minor: 2;
6
+ };
7
+ export type RequestId = number | string;
8
+ export interface RpcRequest {
9
+ jsonrpc: "2.0";
10
+ id: RequestId;
11
+ method: string;
12
+ params?: unknown;
13
+ }
14
+ export interface RpcNotification {
15
+ jsonrpc: "2.0";
16
+ method: string;
17
+ params?: unknown;
18
+ }
19
+ export interface RpcSuccess {
20
+ jsonrpc: "2.0";
21
+ id: RequestId;
22
+ result: unknown;
23
+ }
24
+ export interface RpcFailure {
25
+ jsonrpc: "2.0";
26
+ id: RequestId | null;
27
+ error: RpcErrorShape;
28
+ }
29
+ export type RpcMessage = RpcRequest | RpcNotification | RpcSuccess | RpcFailure;
30
+ export interface RpcErrorShape {
31
+ code: number;
32
+ message: string;
33
+ data?: unknown;
34
+ }
35
+ export declare const ErrorCode: {
36
+ readonly ParseError: -32700;
37
+ readonly InvalidRequest: -32600;
38
+ readonly MethodNotFound: -32601;
39
+ readonly InvalidParams: -32602;
40
+ readonly InternalError: -32603;
41
+ readonly NotFound: -32001;
42
+ readonly InvalidState: -32002;
43
+ readonly ProtocolMismatch: -32003;
44
+ readonly SpawnFailed: -32004;
45
+ readonly ShuttingDown: -32005;
46
+ };
47
+ export type ErrorCodeValue = (typeof ErrorCode)[keyof typeof ErrorCode];
48
+ export declare class RpcError extends Error {
49
+ readonly code: number;
50
+ readonly data?: unknown;
51
+ constructor(code: number, message: string, data?: unknown);
52
+ toShape(): RpcErrorShape;
53
+ static from(shape: RpcErrorShape): RpcError;
54
+ }
55
+ /** Method name for daemon → client notifications. */
56
+ export declare const EVENT_METHOD = "event";
57
+ export interface EventEnvelope<T extends string = string, D = unknown> {
58
+ topic: T;
59
+ data: D;
60
+ }
61
+ export declare function isRequest(msg: RpcMessage): msg is RpcRequest;
62
+ export declare function isNotification(msg: RpcMessage): msg is RpcNotification;
63
+ export declare function isResponse(msg: RpcMessage): msg is RpcSuccess | RpcFailure;
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ /** Identity and ownership, shared by every shell message. */
3
+ export declare const ShellId: z.ZodString;
4
+ export declare const Owner: z.ZodObject<{
5
+ project: z.ZodString;
6
+ session: z.ZodOptional<z.ZodString>;
7
+ instance: z.ZodOptional<z.ZodString>;
8
+ }, z.core.$strip>;
9
+ export declare const ShellStatus: z.ZodEnum<{
10
+ exited: "exited";
11
+ failed: "failed";
12
+ killed: "killed";
13
+ running: "running";
14
+ }>;
15
+ export type Owner = z.output<typeof Owner>;
16
+ export type ShellStatus = z.output<typeof ShellStatus>;