@opencode-cockpit/protocol 0.1.4 → 0.1.5

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/build.js ADDED
@@ -0,0 +1,32 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readdirSync, readFileSync, statSync } from "node:fs";
3
+ import { dirname, join, relative } from "node:path";
4
+ const SOURCE = /\.(ts|tsx|js|mjs|json)$/;
5
+ const SKIP = new Set(["node_modules", "test", "dist"]);
6
+
7
+ /**
8
+ * Identity of the daemon code that `entry` would run: a hash of every source file in the directory
9
+ * the entry lives in. Daemon and client compute it the same way, so a client can tell when a
10
+ * running daemon was started from different code.
11
+ */
12
+ export function daemonBuildId(entry, version) {
13
+ const hash = createHash("sha256").update(version);
14
+ // A checkout runs from `src/`, a published install from `dist/`. Hash that whole directory so
15
+ // any change to the daemon's code yields a new id, and accept either the directory itself or a
16
+ // file inside it, so daemon and client always agree.
17
+ const root = statSync(entry).isDirectory() ? entry : dirname(entry);
18
+ const files = walk(root);
19
+ for (const file of files.sort()) {
20
+ hash.update(relative(root, file)).update("\0").update(readFileSync(file)).update("\0");
21
+ }
22
+ return `${version}+${hash.digest("hex").slice(0, 12)}`;
23
+ }
24
+ function walk(dir) {
25
+ const out = [];
26
+ for (const name of readdirSync(dir)) {
27
+ if (SKIP.has(name)) continue;
28
+ const path = join(dir, name);
29
+ if (statSync(path).isDirectory()) out.push(...walk(path));else if (SOURCE.test(name)) out.push(path);
30
+ }
31
+ return out;
32
+ }
@@ -0,0 +1,6 @@
1
+ export const method = (params, result) => ({
2
+ params,
3
+ result
4
+ });
5
+
6
+ /** Params after schema parsing (defaults applied): what handlers receive. */
package/dist/daemon.js ADDED
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ import { method } from "./contract.js";
3
+ export const ClientInfo = z.object({
4
+ name: z.string().min(1),
5
+ version: z.string().min(1),
6
+ pid: z.number().int().optional()
7
+ });
8
+ export const Version = z.object({
9
+ major: z.number().int(),
10
+ minor: z.number().int()
11
+ });
12
+ export const HelloResult = z.object({
13
+ daemonVersion: z.string(),
14
+ /** Content identity of the running daemon code (see daemonBuildId). */
15
+ build: z.string().optional(),
16
+ protocol: Version,
17
+ modules: z.array(z.string()),
18
+ pid: z.number().int(),
19
+ startedAt: z.number()
20
+ });
21
+ export const StatusResult = z.object({
22
+ pid: z.number().int(),
23
+ uptimeMs: z.number(),
24
+ clients: z.number().int(),
25
+ modules: z.array(z.object({
26
+ name: z.string(),
27
+ busy: z.boolean()
28
+ }))
29
+ });
30
+ export const daemonContract = {
31
+ "daemon.hello": method(z.object({
32
+ client: ClientInfo,
33
+ protocol: Version
34
+ }), HelloResult),
35
+ "daemon.status": method(z.object({}).optional(), StatusResult),
36
+ "daemon.shutdown": method(z.object({
37
+ force: z.boolean().optional()
38
+ }).optional(), z.object({
39
+ accepted: z.boolean()
40
+ })),
41
+ "events.subscribe": method(z.object({
42
+ topics: z.array(z.string().min(1)).min(1)
43
+ }), z.object({
44
+ topics: z.array(z.string())
45
+ })),
46
+ "events.unsubscribe": method(z.object({
47
+ topics: z.array(z.string().min(1)).min(1)
48
+ }), z.object({
49
+ topics: z.array(z.string())
50
+ }))
51
+ };
@@ -0,0 +1,27 @@
1
+ /** NDJSON framing shared by daemon and client. */
2
+
3
+ const encoder = new TextEncoder();
4
+ export function encodeFrame(message) {
5
+ return encoder.encode(`${JSON.stringify(message)}\n`);
6
+ }
7
+
8
+ /** Accumulates chunks and yields complete lines. Bounded to protect against runaway peers. */
9
+ export class LineDecoder {
10
+ decoder = new TextDecoder();
11
+ pending = "";
12
+ constructor(maxLineBytes = 16 * 1024 * 1024) {
13
+ this.maxLineBytes = maxLineBytes;
14
+ }
15
+ push(chunk) {
16
+ this.pending += this.decoder.decode(chunk, {
17
+ stream: true
18
+ });
19
+ const parts = this.pending.split("\n");
20
+ this.pending = parts.pop() ?? "";
21
+ if (this.pending.length > this.maxLineBytes) {
22
+ this.pending = "";
23
+ throw new Error(`frame exceeds ${this.maxLineBytes} bytes`);
24
+ }
25
+ return parts.filter(line => line.length > 0);
26
+ }
27
+ }
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import { daemonContract } from "./daemon.js";
2
+ import { shellContract, shellEvents } from "./shell.js";
3
+ export * from "./build.js";
4
+ export * from "./contract.js";
5
+ export * from "./daemon.js";
6
+ export * from "./framing.js";
7
+ export * from "./paths.js";
8
+ export * from "./rpc.js";
9
+ export * as shell from "./shell.js";
10
+
11
+ /** Every method the daemon serves. Adding a module means spreading its contract here. */
12
+ export const contract = {
13
+ ...daemonContract,
14
+ ...shellContract
15
+ };
16
+ /** Every event topic the daemon emits. */
17
+ export const events = {
18
+ ...shellEvents
19
+ };
package/dist/paths.js ADDED
@@ -0,0 +1,16 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Filesystem layout shared by daemon and clients. Pure: creates nothing.
5
+ * Kept short because unix socket paths are limited to 104 bytes on macOS.
6
+ */
7
+ export function resolvePaths(env = process.env) {
8
+ const home = env.COCKPIT_HOME ?? join(env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "opencode-cockpit");
9
+ return {
10
+ home,
11
+ socket: join(home, "cockpitd.sock"),
12
+ pidFile: join(home, "cockpitd.pid"),
13
+ lockFile: join(home, "spawn.lock"),
14
+ logFile: join(home, "cockpitd.log")
15
+ };
16
+ }
package/dist/rpc.js ADDED
@@ -0,0 +1,53 @@
1
+ /** Wire envelope: JSON-RPC 2.0, one JSON object per line (ADR 0002). */
2
+
3
+ /** Bump MAJOR on breaking changes to methods, events or framing. */
4
+ export const PROTOCOL_VERSION = {
5
+ major: 1,
6
+ minor: 1
7
+ };
8
+ export const ErrorCode = {
9
+ ParseError: -32700,
10
+ InvalidRequest: -32600,
11
+ MethodNotFound: -32601,
12
+ InvalidParams: -32602,
13
+ InternalError: -32603,
14
+ // Application range
15
+ NotFound: -32001,
16
+ InvalidState: -32002,
17
+ ProtocolMismatch: -32003,
18
+ SpawnFailed: -32004,
19
+ ShuttingDown: -32005
20
+ };
21
+ export class RpcError extends Error {
22
+ constructor(code, message, data) {
23
+ super(message);
24
+ this.code = code;
25
+ this.data = data;
26
+ this.name = "RpcError";
27
+ }
28
+ toShape() {
29
+ return this.data === undefined ? {
30
+ code: this.code,
31
+ message: this.message
32
+ } : {
33
+ code: this.code,
34
+ message: this.message,
35
+ data: this.data
36
+ };
37
+ }
38
+ static from(shape) {
39
+ return new RpcError(shape.code, shape.message, shape.data);
40
+ }
41
+ }
42
+
43
+ /** Method name for daemon → client notifications. */
44
+ export const EVENT_METHOD = "event";
45
+ export function isRequest(msg) {
46
+ return "method" in msg && "id" in msg && msg.id !== undefined;
47
+ }
48
+ export function isNotification(msg) {
49
+ return "method" in msg && !("id" in msg);
50
+ }
51
+ export function isResponse(msg) {
52
+ return !("method" in msg) && ("result" in msg || "error" in msg);
53
+ }
@@ -1,19 +1,15 @@
1
- import { z } from "zod"
2
- import { method } from "./contract.ts"
3
-
4
- export const ShellId = z.string().regex(/^sh_[a-z2-7]{8}$/, "expected sh_ followed by 8 base32 chars")
5
-
1
+ import { z } from "zod";
2
+ import { method } from "./contract.js";
3
+ export const ShellId = z.string().regex(/^sh_[a-z2-7]{8}$/, "expected sh_ followed by 8 base32 chars");
6
4
  export const Owner = z.object({
7
5
  /** Absolute project directory the shell belongs to. */
8
6
  project: z.string().min(1),
9
7
  /** OpenCode session that started it, when started by an agent. */
10
8
  session: z.string().min(1).optional(),
11
9
  /** Opaque id of the client instance that started it; used to route notifications to one place. */
12
- instance: z.string().min(1).optional(),
13
- })
14
-
15
- export const ShellStatus = z.enum(["running", "exited", "killed", "failed"])
16
-
10
+ instance: z.string().min(1).optional()
11
+ });
12
+ export const ShellStatus = z.enum(["running", "exited", "killed", "failed"]);
17
13
  export const ShellInfo = z.object({
18
14
  id: ShellId,
19
15
  title: z.string(),
@@ -33,13 +29,14 @@ export const ShellInfo = z.object({
33
29
  endedAt: z.number().optional(),
34
30
  cols: z.number().int(),
35
31
  rows: z.number().int(),
36
- lines: z.object({ first: z.number().int(), last: z.number().int() }),
32
+ lines: z.object({
33
+ first: z.number().int(),
34
+ last: z.number().int()
35
+ }),
37
36
  /** Absolute raw byte offset written so far (for UI attach/replay). */
38
- bytes: z.number().int(),
39
- })
40
-
41
- const Dimension = z.number().int().min(2).max(1000)
42
-
37
+ bytes: z.number().int()
38
+ });
39
+ const Dimension = z.number().int().min(2).max(1000);
43
40
  export const StartParams = z.object({
44
41
  command: z.string().min(1),
45
42
  args: z.array(z.string()).default([]),
@@ -55,28 +52,26 @@ export const StartParams = z.object({
55
52
  * Restart a finished shell with the same command, args, cwd, project and session instead of
56
53
  * creating a new one. Repeated runs then share one id and one log.
57
54
  */
58
- reuse: z.boolean().default(false),
59
- })
60
-
61
- export const ClearParams = z
62
- .object({
63
- owner: Owner.partial().optional(),
64
- /** Only remove shells that finished at least this long ago. */
65
- finishedBeforeMs: z.number().int().min(0).optional(),
66
- })
67
- .default({})
68
-
69
- export const ListParams = z
70
- .object({
71
- owner: Owner.partial().optional(),
72
- includeExited: z.boolean().default(true),
73
- })
74
- .default({ includeExited: true })
75
-
76
- export const IdParams = z.object({ id: ShellId })
77
-
78
- export const LogLine = z.object({ n: z.number().int(), text: z.string() })
79
-
55
+ reuse: z.boolean().default(false)
56
+ });
57
+ export const ClearParams = z.object({
58
+ owner: Owner.partial().optional(),
59
+ /** Only remove shells that finished at least this long ago. */
60
+ finishedBeforeMs: z.number().int().min(0).optional()
61
+ }).default({});
62
+ export const ListParams = z.object({
63
+ owner: Owner.partial().optional(),
64
+ includeExited: z.boolean().default(true)
65
+ }).default({
66
+ includeExited: true
67
+ });
68
+ export const IdParams = z.object({
69
+ id: ShellId
70
+ });
71
+ export const LogLine = z.object({
72
+ n: z.number().int(),
73
+ text: z.string()
74
+ });
80
75
  export const ReadParams = z.object({
81
76
  id: ShellId,
82
77
  /** Cursor: return only lines numbered strictly greater than this. */
@@ -85,9 +80,8 @@ export const ReadParams = z.object({
85
80
  tail: z.number().int().positive().max(10_000).default(100),
86
81
  limit: z.number().int().positive().max(10_000).default(500),
87
82
  grep: z.string().min(1).max(500).optional(),
88
- ignoreCase: z.boolean().default(false),
89
- })
90
-
83
+ ignoreCase: z.boolean().default(false)
84
+ });
91
85
  export const ReadResult = z.object({
92
86
  lines: z.array(LogLine),
93
87
  firstLine: z.number().int(),
@@ -98,90 +92,90 @@ export const ReadResult = z.object({
98
92
  truncated: z.boolean(),
99
93
  /** True when more lines exist beyond `limit`. */
100
94
  hasMore: z.boolean(),
101
- status: ShellStatus,
102
- })
103
-
95
+ status: ShellStatus
96
+ });
104
97
  export const ScreenResult = z.object({
105
98
  text: z.string(),
106
99
  cols: z.number().int(),
107
100
  rows: z.number().int(),
108
- cursor: z.object({ x: z.number().int(), y: z.number().int() }),
109
- })
110
-
111
- export const WriteParams = z.object({ id: ShellId, data: z.string().max(1_000_000) })
112
-
113
- export const ResizeParams = z.object({ id: ShellId, cols: Dimension, rows: Dimension })
114
-
115
- export const WaitUntil = z
116
- .object({
117
- pattern: z.string().min(1).max(500).optional(),
118
- ignoreCase: z.boolean().optional(),
119
- exit: z.boolean().optional(),
120
- idleMs: z.number().int().positive().optional(),
121
- port: z.number().int().min(1).max(65_535).optional(),
122
- host: z.string().optional(),
101
+ cursor: z.object({
102
+ x: z.number().int(),
103
+ y: z.number().int()
123
104
  })
124
- .refine((u) => u.pattern !== undefined || u.exit || u.idleMs !== undefined || u.port !== undefined, {
125
- message: "until needs at least one of pattern, exit, idleMs, port",
126
- })
127
-
105
+ });
106
+ export const WriteParams = z.object({
107
+ id: ShellId,
108
+ data: z.string().max(1_000_000)
109
+ });
110
+ export const ResizeParams = z.object({
111
+ id: ShellId,
112
+ cols: Dimension,
113
+ rows: Dimension
114
+ });
115
+ export const WaitUntil = z.object({
116
+ pattern: z.string().min(1).max(500).optional(),
117
+ ignoreCase: z.boolean().optional(),
118
+ exit: z.boolean().optional(),
119
+ idleMs: z.number().int().positive().optional(),
120
+ port: z.number().int().min(1).max(65_535).optional(),
121
+ host: z.string().optional()
122
+ }).refine(u => u.pattern !== undefined || u.exit || u.idleMs !== undefined || u.port !== undefined, {
123
+ message: "until needs at least one of pattern, exit, idleMs, port"
124
+ });
128
125
  export const WaitParams = z.object({
129
126
  id: ShellId,
130
127
  until: WaitUntil,
131
128
  timeoutMs: z.number().int().positive().max(3_600_000),
132
129
  /** Only consider lines after this cursor for `pattern`. Defaults to the current last line. */
133
- after: z.number().int().min(0).optional(),
134
- })
135
-
136
- export const WaitReason = z.enum(["pattern", "exit", "idle", "port", "timeout"])
137
-
130
+ after: z.number().int().min(0).optional()
131
+ });
132
+ export const WaitReason = z.enum(["pattern", "exit", "idle", "port", "timeout"]);
138
133
  export const WaitResult = z.object({
139
134
  reason: WaitReason,
140
135
  match: LogLine.optional(),
141
- info: ShellInfo,
142
- })
143
-
136
+ info: ShellInfo
137
+ });
144
138
  export const StopParams = z.object({
145
139
  id: ShellId,
146
140
  signal: z.enum(["SIGTERM", "SIGINT", "SIGHUP", "SIGKILL"]).default("SIGTERM"),
147
- graceMs: z.number().int().min(0).max(60_000).default(3000),
148
- })
149
-
150
- export const AttachParams = z.object({ id: ShellId, fromOffset: z.number().int().min(0).optional() })
151
-
141
+ graceMs: z.number().int().min(0).max(60_000).default(3000)
142
+ });
143
+ export const AttachParams = z.object({
144
+ id: ShellId,
145
+ fromOffset: z.number().int().min(0).optional()
146
+ });
152
147
  export const shellContract = {
153
148
  "shell.start": method(StartParams, ShellInfo),
154
149
  "shell.list": method(ListParams, z.array(ShellInfo)),
155
150
  "shell.get": method(IdParams, ShellInfo),
156
151
  "shell.read": method(ReadParams, ReadResult),
157
152
  "shell.screen": method(IdParams, ScreenResult),
158
- "shell.write": method(WriteParams, z.object({ bytes: z.number().int() })),
153
+ "shell.write": method(WriteParams, z.object({
154
+ bytes: z.number().int()
155
+ })),
159
156
  "shell.resize": method(ResizeParams, z.object({})),
160
157
  "shell.wait": method(WaitParams, WaitResult),
161
158
  "shell.stop": method(StopParams, ShellInfo),
162
159
  "shell.restart": method(IdParams, ShellInfo),
163
160
  "shell.remove": method(IdParams, z.object({})),
164
- "shell.clear": method(ClearParams, z.object({ removed: z.array(ShellId) })),
165
- "shell.attach": method(AttachParams, z.object({ offset: z.number().int(), replay: z.string() })),
166
- "shell.detach": method(IdParams, z.object({})),
167
- }
168
-
161
+ "shell.clear": method(ClearParams, z.object({
162
+ removed: z.array(ShellId)
163
+ })),
164
+ "shell.attach": method(AttachParams, z.object({
165
+ offset: z.number().int(),
166
+ replay: z.string()
167
+ })),
168
+ "shell.detach": method(IdParams, z.object({}))
169
+ };
169
170
  export const shellEvents = {
170
171
  "shell.started": ShellInfo,
171
172
  "shell.exited": ShellInfo,
172
- "shell.removed": z.object({ id: ShellId }),
173
- "shell.output": z.object({ id: ShellId, offset: z.number().int(), data: z.string() }),
174
- }
175
-
176
- export type Owner = z.output<typeof Owner>
177
- export type ShellStatus = z.output<typeof ShellStatus>
178
- export type ShellInfo = z.output<typeof ShellInfo>
179
- export type StartParams = z.output<typeof StartParams>
180
- export type ReadParams = z.output<typeof ReadParams>
181
- export type ReadResult = z.output<typeof ReadResult>
182
- export type ScreenResult = z.output<typeof ScreenResult>
183
- export type WaitParams = z.output<typeof WaitParams>
184
- export type WaitResult = z.output<typeof WaitResult>
185
- export type WaitReason = z.output<typeof WaitReason>
186
- export type StopParams = z.output<typeof StopParams>
187
- export type LogLine = z.output<typeof LogLine>
173
+ "shell.removed": z.object({
174
+ id: ShellId
175
+ }),
176
+ "shell.output": z.object({
177
+ id: ShellId,
178
+ offset: z.number().int(),
179
+ data: z.string()
180
+ })
181
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode-cockpit/protocol",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Wire protocol, method and event contracts for cockpitd (opencode-cockpit)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,11 +20,18 @@
20
20
  "protocol"
21
21
  ],
22
22
  "exports": {
23
- ".": "./src/index.ts",
24
- "./shell": "./src/shell.ts"
23
+ ".": {
24
+ "types": "./types/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./shell": {
28
+ "types": "./types/shell.d.ts",
29
+ "default": "./dist/shell.js"
30
+ }
25
31
  },
26
32
  "files": [
27
- "src",
33
+ "dist",
34
+ "types",
28
35
  "README.md",
29
36
  "LICENSE"
30
37
  ],
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Identity of the daemon code that `entry` would run: a hash of every source file in the directory
3
+ * the entry lives in. Daemon and client compute it the same way, so a client can tell when a
4
+ * running daemon was started from different code.
5
+ */
6
+ export declare function daemonBuildId(entry: string, version: string): string;
@@ -1,20 +1,13 @@
1
- import type { z } from "zod"
2
-
1
+ import type { z } from "zod";
3
2
  export interface MethodSpec<P extends z.ZodType = z.ZodType, R extends z.ZodType = z.ZodType> {
4
- params: P
5
- result: R
3
+ params: P;
4
+ result: R;
6
5
  }
7
-
8
- export const method = <P extends z.ZodType, R extends z.ZodType>(params: P, result: R): MethodSpec<P, R> => ({
9
- params,
10
- result,
11
- })
12
-
13
- export type Contract = Record<string, MethodSpec>
14
- export type EventContract = Record<string, z.ZodType>
15
-
16
- export type ParamsOf<C extends Contract, M extends keyof C> = z.input<C[M]["params"]>
17
- export type ResultOf<C extends Contract, M extends keyof C> = z.output<C[M]["result"]>
18
- export type EventOf<E extends EventContract, T extends keyof E> = z.output<E[T]>
6
+ export declare const method: <P extends z.ZodType, R extends z.ZodType>(params: P, result: R) => MethodSpec<P, R>;
7
+ export type Contract = Record<string, MethodSpec>;
8
+ export type EventContract = Record<string, z.ZodType>;
9
+ export type ParamsOf<C extends Contract, M extends keyof C> = z.input<C[M]["params"]>;
10
+ export type ResultOf<C extends Contract, M extends keyof C> = z.output<C[M]["result"]>;
11
+ export type EventOf<E extends EventContract, T extends keyof E> = z.output<E[T]>;
19
12
  /** Params after schema parsing (defaults applied): what handlers receive. */
20
- export type ParsedParamsOf<C extends Contract, M extends keyof C> = z.output<C[M]["params"]>
13
+ export type ParsedParamsOf<C extends Contract, M extends keyof C> = z.output<C[M]["params"]>;
@@ -0,0 +1,80 @@
1
+ import { z } from "zod";
2
+ export declare const ClientInfo: z.ZodObject<{
3
+ name: z.ZodString;
4
+ version: z.ZodString;
5
+ pid: z.ZodOptional<z.ZodNumber>;
6
+ }, z.core.$strip>;
7
+ export declare const Version: z.ZodObject<{
8
+ major: z.ZodNumber;
9
+ minor: z.ZodNumber;
10
+ }, z.core.$strip>;
11
+ export declare const HelloResult: z.ZodObject<{
12
+ daemonVersion: z.ZodString;
13
+ build: z.ZodOptional<z.ZodString>;
14
+ protocol: z.ZodObject<{
15
+ major: z.ZodNumber;
16
+ minor: z.ZodNumber;
17
+ }, z.core.$strip>;
18
+ modules: z.ZodArray<z.ZodString>;
19
+ pid: z.ZodNumber;
20
+ startedAt: z.ZodNumber;
21
+ }, z.core.$strip>;
22
+ export declare const StatusResult: z.ZodObject<{
23
+ pid: z.ZodNumber;
24
+ uptimeMs: z.ZodNumber;
25
+ clients: z.ZodNumber;
26
+ modules: z.ZodArray<z.ZodObject<{
27
+ name: z.ZodString;
28
+ busy: z.ZodBoolean;
29
+ }, z.core.$strip>>;
30
+ }, z.core.$strip>;
31
+ export declare const daemonContract: {
32
+ "daemon.hello": import("./contract.ts").MethodSpec<z.ZodObject<{
33
+ client: z.ZodObject<{
34
+ name: z.ZodString;
35
+ version: z.ZodString;
36
+ pid: z.ZodOptional<z.ZodNumber>;
37
+ }, z.core.$strip>;
38
+ protocol: z.ZodObject<{
39
+ major: z.ZodNumber;
40
+ minor: z.ZodNumber;
41
+ }, z.core.$strip>;
42
+ }, z.core.$strip>, z.ZodObject<{
43
+ daemonVersion: z.ZodString;
44
+ build: z.ZodOptional<z.ZodString>;
45
+ protocol: z.ZodObject<{
46
+ major: z.ZodNumber;
47
+ minor: z.ZodNumber;
48
+ }, z.core.$strip>;
49
+ modules: z.ZodArray<z.ZodString>;
50
+ pid: z.ZodNumber;
51
+ startedAt: z.ZodNumber;
52
+ }, z.core.$strip>>;
53
+ "daemon.status": import("./contract.ts").MethodSpec<z.ZodOptional<z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
54
+ pid: z.ZodNumber;
55
+ uptimeMs: z.ZodNumber;
56
+ clients: z.ZodNumber;
57
+ modules: z.ZodArray<z.ZodObject<{
58
+ name: z.ZodString;
59
+ busy: z.ZodBoolean;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>>;
62
+ "daemon.shutdown": import("./contract.ts").MethodSpec<z.ZodOptional<z.ZodObject<{
63
+ force: z.ZodOptional<z.ZodBoolean>;
64
+ }, z.core.$strip>>, z.ZodObject<{
65
+ accepted: z.ZodBoolean;
66
+ }, z.core.$strip>>;
67
+ "events.subscribe": import("./contract.ts").MethodSpec<z.ZodObject<{
68
+ topics: z.ZodArray<z.ZodString>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ topics: z.ZodArray<z.ZodString>;
71
+ }, z.core.$strip>>;
72
+ "events.unsubscribe": import("./contract.ts").MethodSpec<z.ZodObject<{
73
+ topics: z.ZodArray<z.ZodString>;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ topics: z.ZodArray<z.ZodString>;
76
+ }, z.core.$strip>>;
77
+ };
78
+ export type HelloResult = z.output<typeof HelloResult>;
79
+ export type StatusResult = z.output<typeof StatusResult>;
80
+ export type ClientInfo = z.output<typeof ClientInfo>;
@@ -0,0 +1,10 @@
1
+ /** NDJSON framing shared by daemon and client. */
2
+ export declare function encodeFrame(message: unknown): Uint8Array;
3
+ /** Accumulates chunks and yields complete lines. Bounded to protect against runaway peers. */
4
+ export declare class LineDecoder {
5
+ private readonly maxLineBytes;
6
+ private readonly decoder;
7
+ private pending;
8
+ constructor(maxLineBytes?: number);
9
+ push(chunk: Uint8Array): string[];
10
+ }