cyclops-clientdevbridge-cli 0.1.1

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 (112) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/README.md +218 -0
  4. package/dist/artifacts.d.ts +56 -0
  5. package/dist/artifacts.d.ts.map +1 -0
  6. package/dist/artifacts.js +58 -0
  7. package/dist/artifacts.js.map +1 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +348 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/commands/compare.d.ts +27 -0
  13. package/dist/commands/compare.d.ts.map +1 -0
  14. package/dist/commands/compare.js +209 -0
  15. package/dist/commands/compare.js.map +1 -0
  16. package/dist/commands/context.d.ts +25 -0
  17. package/dist/commands/context.d.ts.map +1 -0
  18. package/dist/commands/context.js +36 -0
  19. package/dist/commands/context.js.map +1 -0
  20. package/dist/commands/doctor.d.ts +31 -0
  21. package/dist/commands/doctor.d.ts.map +1 -0
  22. package/dist/commands/doctor.js +234 -0
  23. package/dist/commands/doctor.js.map +1 -0
  24. package/dist/commands/hotswap.d.ts +7 -0
  25. package/dist/commands/hotswap.d.ts.map +1 -0
  26. package/dist/commands/hotswap.js +76 -0
  27. package/dist/commands/hotswap.js.map +1 -0
  28. package/dist/commands/input.d.ts +53 -0
  29. package/dist/commands/input.d.ts.map +1 -0
  30. package/dist/commands/input.js +204 -0
  31. package/dist/commands/input.js.map +1 -0
  32. package/dist/commands/inspect.d.ts +19 -0
  33. package/dist/commands/inspect.d.ts.map +1 -0
  34. package/dist/commands/inspect.js +90 -0
  35. package/dist/commands/inspect.js.map +1 -0
  36. package/dist/commands/lifecycle.d.ts +29 -0
  37. package/dist/commands/lifecycle.d.ts.map +1 -0
  38. package/dist/commands/lifecycle.js +201 -0
  39. package/dist/commands/lifecycle.js.map +1 -0
  40. package/dist/commands/snapshot.d.ts +37 -0
  41. package/dist/commands/snapshot.d.ts.map +1 -0
  42. package/dist/commands/snapshot.js +133 -0
  43. package/dist/commands/snapshot.js.map +1 -0
  44. package/dist/commands/world.d.ts +27 -0
  45. package/dist/commands/world.d.ts.map +1 -0
  46. package/dist/commands/world.js +203 -0
  47. package/dist/commands/world.js.map +1 -0
  48. package/dist/detect.d.ts +58 -0
  49. package/dist/detect.d.ts.map +1 -0
  50. package/dist/detect.js +185 -0
  51. package/dist/detect.js.map +1 -0
  52. package/dist/errors.d.ts +24 -0
  53. package/dist/errors.d.ts.map +1 -0
  54. package/dist/errors.js +37 -0
  55. package/dist/errors.js.map +1 -0
  56. package/dist/hotswap.d.ts +58 -0
  57. package/dist/hotswap.d.ts.map +1 -0
  58. package/dist/hotswap.js +284 -0
  59. package/dist/hotswap.js.map +1 -0
  60. package/dist/index.d.ts +11 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +11 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/initscript.d.ts +49 -0
  65. package/dist/initscript.d.ts.map +1 -0
  66. package/dist/initscript.js +202 -0
  67. package/dist/initscript.js.map +1 -0
  68. package/dist/java.d.ts +47 -0
  69. package/dist/java.d.ts.map +1 -0
  70. package/dist/java.js +114 -0
  71. package/dist/java.js.map +1 -0
  72. package/dist/launcher.d.ts +104 -0
  73. package/dist/launcher.d.ts.map +1 -0
  74. package/dist/launcher.js +609 -0
  75. package/dist/launcher.js.map +1 -0
  76. package/dist/loopback.d.ts +17 -0
  77. package/dist/loopback.d.ts.map +1 -0
  78. package/dist/loopback.js +19 -0
  79. package/dist/loopback.js.map +1 -0
  80. package/dist/output.d.ts +21 -0
  81. package/dist/output.d.ts.map +1 -0
  82. package/dist/output.js +41 -0
  83. package/dist/output.js.map +1 -0
  84. package/dist/paths.d.ts +23 -0
  85. package/dist/paths.d.ts.map +1 -0
  86. package/dist/paths.js +47 -0
  87. package/dist/paths.js.map +1 -0
  88. package/dist/protocol/client.d.ts +35 -0
  89. package/dist/protocol/client.d.ts.map +1 -0
  90. package/dist/protocol/client.js +170 -0
  91. package/dist/protocol/client.js.map +1 -0
  92. package/dist/protocol/types.d.ts +114 -0
  93. package/dist/protocol/types.d.ts.map +1 -0
  94. package/dist/protocol/types.js +38 -0
  95. package/dist/protocol/types.js.map +1 -0
  96. package/dist/session.d.ts +77 -0
  97. package/dist/session.d.ts.map +1 -0
  98. package/dist/session.js +79 -0
  99. package/dist/session.js.map +1 -0
  100. package/dist/snapshot/model.d.ts +327 -0
  101. package/dist/snapshot/model.d.ts.map +1 -0
  102. package/dist/snapshot/model.js +91 -0
  103. package/dist/snapshot/model.js.map +1 -0
  104. package/dist/snapshot/outline.d.ts +35 -0
  105. package/dist/snapshot/outline.d.ts.map +1 -0
  106. package/dist/snapshot/outline.js +135 -0
  107. package/dist/snapshot/outline.js.map +1 -0
  108. package/dist/xvfb.d.ts +30 -0
  109. package/dist/xvfb.d.ts.map +1 -0
  110. package/dist/xvfb.js +66 -0
  111. package/dist/xvfb.js.map +1 -0
  112. package/package.json +66 -0
@@ -0,0 +1,79 @@
1
+ import * as fs from 'node:fs';
2
+ import { z } from 'zod';
3
+ import { SessionError } from './errors.js';
4
+ import { resolvePaths } from './paths.js';
5
+ export const sessionSchema = z.object({
6
+ version: z.literal(1),
7
+ port: z.number().int().positive(),
8
+ pid: z.number().int().positive(),
9
+ pgid: z.number().int(),
10
+ loader: z.enum(['fabric', 'neoforge']),
11
+ mcVersion: z.string(),
12
+ bridgeVersion: z.string(),
13
+ projectDir: z.string(),
14
+ gradleTask: z.string(),
15
+ startedAt: z.string(),
16
+ world: z.string().nullable(),
17
+ headed: z.boolean(),
18
+ display: z.string().nullable(),
19
+ jdwpPort: z.number().int().positive().nullable(),
20
+ /**
21
+ * Xvfb servers this launch started. `stop` kills them explicitly: killing the process group
22
+ * does not reliably take them with it, and a leaked one is not harmless -- a stale server on a
23
+ * display a later run reuses makes the next client die with an X GLX BadAccess before it
24
+ * renders anything. Optional so a session file written by an older CLI still parses.
25
+ */
26
+ xvfbPids: z.array(z.number().int().positive()).optional(),
27
+ });
28
+ export function readSession(projectDir) {
29
+ const paths = resolvePaths(projectDir);
30
+ if (!fs.existsSync(paths.sessionFile)) {
31
+ return { paths, session: null, stale: false };
32
+ }
33
+ let parsed;
34
+ try {
35
+ parsed = sessionSchema.parse(JSON.parse(fs.readFileSync(paths.sessionFile, 'utf8')));
36
+ }
37
+ catch {
38
+ // A truncated or older session file is treated exactly like a dead one, so that a cold VM
39
+ // never leaves the CLI stuck on a file it cannot read.
40
+ return { paths, session: null, stale: true };
41
+ }
42
+ return { paths, session: parsed, stale: !isProcessAlive(parsed.pid) };
43
+ }
44
+ export function writeSession(paths, session) {
45
+ fs.writeFileSync(paths.sessionFile, `${JSON.stringify(session, null, 2)}\n`, 'utf8');
46
+ }
47
+ export function clearSession(paths) {
48
+ if (fs.existsSync(paths.sessionFile)) {
49
+ fs.rmSync(paths.sessionFile);
50
+ }
51
+ }
52
+ /**
53
+ * Returns the session for commands that need a running client, with a message that says what to do
54
+ * rather than just what went wrong.
55
+ */
56
+ export function requireRunningSession(projectDir) {
57
+ const status = readSession(projectDir);
58
+ if (status.session === null) {
59
+ if (status.stale) {
60
+ throw new SessionError(`The session file at ${status.paths.sessionFile} is unreadable, so no client is being tracked.`, "Run 'clientdevbridge start' to launch a fresh client.");
61
+ }
62
+ throw new SessionError(`No ClientDevBridge session in ${status.paths.projectDir}.`, "Run 'clientdevbridge start' first (add --project <dir> if the mod project is elsewhere).");
63
+ }
64
+ if (status.stale) {
65
+ throw new SessionError(`The recorded client (pid ${status.session.pid}) is no longer running.`, "Run 'clientdevbridge start' to launch a new one; 'clientdevbridge logs --gradle' shows why the old one exited.");
66
+ }
67
+ return { session: status.session, paths: status.paths };
68
+ }
69
+ export function isProcessAlive(pid) {
70
+ try {
71
+ // Signal 0 performs the permission and existence checks without delivering a signal.
72
+ process.kill(pid, 0);
73
+ return true;
74
+ }
75
+ catch (error) {
76
+ return error.code === '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AAK,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,IAAI,YAAY,CACpB,uBAAuB,MAAM,CAAC,KAAK,CAAC,WAAW,gDAAgD,EAC/F,uDAAuD,CACxD,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,YAAY,CACpB,iCAAiC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,EAC3D,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,YAAY,CACpB,4BAA4B,MAAM,CAAC,OAAO,CAAC,GAAG,yBAAyB,EACvE,gHAAgH,CACjH,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,CAAC;QACH,qFAAqF;QACrF,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAQ,KAA+B,CAAC,IAAI,KAAK,OAAO,CAAC;IAC3D,CAAC;AACH,CAAC"}
@@ -0,0 +1,327 @@
1
+ import { z } from 'zod';
2
+ export declare const boundsSchema: z.ZodObject<{
3
+ x: z.ZodNumber;
4
+ y: z.ZodNumber;
5
+ w: z.ZodNumber;
6
+ h: z.ZodNumber;
7
+ }, "strip", z.ZodTypeAny, {
8
+ x: number;
9
+ y: number;
10
+ w: number;
11
+ h: number;
12
+ }, {
13
+ x: number;
14
+ y: number;
15
+ w: number;
16
+ h: number;
17
+ }>;
18
+ export type Bounds = z.infer<typeof boundsSchema>;
19
+ export interface SnapshotNode {
20
+ path: string;
21
+ type: string;
22
+ bounds: Bounds | null;
23
+ message: string | null;
24
+ narration: string | null;
25
+ visible: boolean;
26
+ active: boolean;
27
+ focused: boolean;
28
+ hovered: boolean;
29
+ value?: unknown;
30
+ extra: Record<string, unknown>;
31
+ children: SnapshotNode[];
32
+ }
33
+ export declare const snapshotNodeSchema: z.ZodType<SnapshotNode, z.ZodTypeDef, unknown>;
34
+ export declare const slotSchema: z.ZodObject<{
35
+ index: z.ZodNumber;
36
+ item: z.ZodNullable<z.ZodString>;
37
+ count: z.ZodNumber;
38
+ name: z.ZodOptional<z.ZodString>;
39
+ x: z.ZodNumber;
40
+ y: z.ZodNumber;
41
+ hovered: z.ZodBoolean;
42
+ }, "strip", z.ZodTypeAny, {
43
+ x: number;
44
+ y: number;
45
+ hovered: boolean;
46
+ index: number;
47
+ item: string | null;
48
+ count: number;
49
+ name?: string | undefined;
50
+ }, {
51
+ x: number;
52
+ y: number;
53
+ hovered: boolean;
54
+ index: number;
55
+ item: string | null;
56
+ count: number;
57
+ name?: string | undefined;
58
+ }>;
59
+ export declare const containerSchema: z.ZodObject<{
60
+ menuClass: z.ZodString;
61
+ leftPos: z.ZodNumber;
62
+ topPos: z.ZodNumber;
63
+ imageWidth: z.ZodNumber;
64
+ imageHeight: z.ZodNumber;
65
+ carried: z.ZodObject<{
66
+ item: z.ZodNullable<z.ZodString>;
67
+ count: z.ZodNumber;
68
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
69
+ item: z.ZodNullable<z.ZodString>;
70
+ count: z.ZodNumber;
71
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
72
+ item: z.ZodNullable<z.ZodString>;
73
+ count: z.ZodNumber;
74
+ }, z.ZodTypeAny, "passthrough">>;
75
+ slots: z.ZodArray<z.ZodObject<{
76
+ index: z.ZodNumber;
77
+ item: z.ZodNullable<z.ZodString>;
78
+ count: z.ZodNumber;
79
+ name: z.ZodOptional<z.ZodString>;
80
+ x: z.ZodNumber;
81
+ y: z.ZodNumber;
82
+ hovered: z.ZodBoolean;
83
+ }, "strip", z.ZodTypeAny, {
84
+ x: number;
85
+ y: number;
86
+ hovered: boolean;
87
+ index: number;
88
+ item: string | null;
89
+ count: number;
90
+ name?: string | undefined;
91
+ }, {
92
+ x: number;
93
+ y: number;
94
+ hovered: boolean;
95
+ index: number;
96
+ item: string | null;
97
+ count: number;
98
+ name?: string | undefined;
99
+ }>, "many">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ menuClass: string;
102
+ leftPos: number;
103
+ topPos: number;
104
+ imageWidth: number;
105
+ imageHeight: number;
106
+ carried: {
107
+ item: string | null;
108
+ count: number;
109
+ } & {
110
+ [k: string]: unknown;
111
+ };
112
+ slots: {
113
+ x: number;
114
+ y: number;
115
+ hovered: boolean;
116
+ index: number;
117
+ item: string | null;
118
+ count: number;
119
+ name?: string | undefined;
120
+ }[];
121
+ }, {
122
+ menuClass: string;
123
+ leftPos: number;
124
+ topPos: number;
125
+ imageWidth: number;
126
+ imageHeight: number;
127
+ carried: {
128
+ item: string | null;
129
+ count: number;
130
+ } & {
131
+ [k: string]: unknown;
132
+ };
133
+ slots: {
134
+ x: number;
135
+ y: number;
136
+ hovered: boolean;
137
+ index: number;
138
+ item: string | null;
139
+ count: number;
140
+ name?: string | undefined;
141
+ }[];
142
+ }>;
143
+ export declare const snapshotSchema: z.ZodObject<{
144
+ screenClass: z.ZodNullable<z.ZodString>;
145
+ title: z.ZodNullable<z.ZodString>;
146
+ guiScale: z.ZodNumber;
147
+ guiWidth: z.ZodNumber;
148
+ guiHeight: z.ZodNumber;
149
+ pixelWidth: z.ZodNumber;
150
+ pixelHeight: z.ZodNumber;
151
+ mouse: z.ZodArray<z.ZodNumber, "many">;
152
+ focused: z.ZodOptional<z.ZodNullable<z.ZodString>>;
153
+ hovered: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
+ truncated: z.ZodDefault<z.ZodBoolean>;
155
+ container: z.ZodNullable<z.ZodObject<{
156
+ menuClass: z.ZodString;
157
+ leftPos: z.ZodNumber;
158
+ topPos: z.ZodNumber;
159
+ imageWidth: z.ZodNumber;
160
+ imageHeight: z.ZodNumber;
161
+ carried: z.ZodObject<{
162
+ item: z.ZodNullable<z.ZodString>;
163
+ count: z.ZodNumber;
164
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
165
+ item: z.ZodNullable<z.ZodString>;
166
+ count: z.ZodNumber;
167
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
168
+ item: z.ZodNullable<z.ZodString>;
169
+ count: z.ZodNumber;
170
+ }, z.ZodTypeAny, "passthrough">>;
171
+ slots: z.ZodArray<z.ZodObject<{
172
+ index: z.ZodNumber;
173
+ item: z.ZodNullable<z.ZodString>;
174
+ count: z.ZodNumber;
175
+ name: z.ZodOptional<z.ZodString>;
176
+ x: z.ZodNumber;
177
+ y: z.ZodNumber;
178
+ hovered: z.ZodBoolean;
179
+ }, "strip", z.ZodTypeAny, {
180
+ x: number;
181
+ y: number;
182
+ hovered: boolean;
183
+ index: number;
184
+ item: string | null;
185
+ count: number;
186
+ name?: string | undefined;
187
+ }, {
188
+ x: number;
189
+ y: number;
190
+ hovered: boolean;
191
+ index: number;
192
+ item: string | null;
193
+ count: number;
194
+ name?: string | undefined;
195
+ }>, "many">;
196
+ }, "strip", z.ZodTypeAny, {
197
+ menuClass: string;
198
+ leftPos: number;
199
+ topPos: number;
200
+ imageWidth: number;
201
+ imageHeight: number;
202
+ carried: {
203
+ item: string | null;
204
+ count: number;
205
+ } & {
206
+ [k: string]: unknown;
207
+ };
208
+ slots: {
209
+ x: number;
210
+ y: number;
211
+ hovered: boolean;
212
+ index: number;
213
+ item: string | null;
214
+ count: number;
215
+ name?: string | undefined;
216
+ }[];
217
+ }, {
218
+ menuClass: string;
219
+ leftPos: number;
220
+ topPos: number;
221
+ imageWidth: number;
222
+ imageHeight: number;
223
+ carried: {
224
+ item: string | null;
225
+ count: number;
226
+ } & {
227
+ [k: string]: unknown;
228
+ };
229
+ slots: {
230
+ x: number;
231
+ y: number;
232
+ hovered: boolean;
233
+ index: number;
234
+ item: string | null;
235
+ count: number;
236
+ name?: string | undefined;
237
+ }[];
238
+ }>>;
239
+ root: z.ZodNullable<z.ZodType<SnapshotNode, z.ZodTypeDef, unknown>>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ guiScale: number;
242
+ guiWidth: number;
243
+ guiHeight: number;
244
+ pixelWidth: number;
245
+ pixelHeight: number;
246
+ screenClass: string | null;
247
+ title: string | null;
248
+ mouse: number[];
249
+ truncated: boolean;
250
+ container: {
251
+ menuClass: string;
252
+ leftPos: number;
253
+ topPos: number;
254
+ imageWidth: number;
255
+ imageHeight: number;
256
+ carried: {
257
+ item: string | null;
258
+ count: number;
259
+ } & {
260
+ [k: string]: unknown;
261
+ };
262
+ slots: {
263
+ x: number;
264
+ y: number;
265
+ hovered: boolean;
266
+ index: number;
267
+ item: string | null;
268
+ count: number;
269
+ name?: string | undefined;
270
+ }[];
271
+ } | null;
272
+ root: SnapshotNode | null;
273
+ focused?: string | null | undefined;
274
+ hovered?: string | null | undefined;
275
+ }, {
276
+ guiScale: number;
277
+ guiWidth: number;
278
+ guiHeight: number;
279
+ pixelWidth: number;
280
+ pixelHeight: number;
281
+ screenClass: string | null;
282
+ title: string | null;
283
+ mouse: number[];
284
+ container: {
285
+ menuClass: string;
286
+ leftPos: number;
287
+ topPos: number;
288
+ imageWidth: number;
289
+ imageHeight: number;
290
+ carried: {
291
+ item: string | null;
292
+ count: number;
293
+ } & {
294
+ [k: string]: unknown;
295
+ };
296
+ slots: {
297
+ x: number;
298
+ y: number;
299
+ hovered: boolean;
300
+ index: number;
301
+ item: string | null;
302
+ count: number;
303
+ name?: string | undefined;
304
+ }[];
305
+ } | null;
306
+ focused?: string | null | undefined;
307
+ hovered?: string | null | undefined;
308
+ truncated?: boolean | undefined;
309
+ root?: unknown;
310
+ }>;
311
+ export type Snapshot = z.infer<typeof snapshotSchema>;
312
+ export type Slot = z.infer<typeof slotSchema>;
313
+ /** Depth-first walk, parents before children. */
314
+ export declare function walk(node: SnapshotNode, visit: (node: SnapshotNode, depth: number) => void, depth?: number): void;
315
+ export declare function flatten(root: SnapshotNode | null): {
316
+ node: SnapshotNode;
317
+ depth: number;
318
+ }[];
319
+ /** The point a click should target for a node. */
320
+ export declare function centre(node: SnapshotNode): {
321
+ x: number;
322
+ y: number;
323
+ } | null;
324
+ /** A short, human-meaningful label for a node: its message, else its narration, else nothing. */
325
+ export declare function label(node: SnapshotNode): string;
326
+ export declare function simpleType(node: SnapshotNode): string;
327
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/snapshot/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;EAA2E,CAAC;AACrG,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,EAAE,YAAY,EAAE,CAAC;C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AAY,GAAG,MAAM,CAQhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAGrD"}
@@ -0,0 +1,91 @@
1
+ import { z } from 'zod';
2
+ export const boundsSchema = z.object({ x: z.number(), y: z.number(), w: z.number(), h: z.number() });
3
+ // The input type differs from the output type because of the `.default()`s, so the third
4
+ // type argument is `unknown` rather than SnapshotNode.
5
+ export const snapshotNodeSchema = z.lazy(() => z.object({
6
+ path: z.string(),
7
+ type: z.string(),
8
+ bounds: boundsSchema.nullable(),
9
+ message: z.string().nullable(),
10
+ narration: z.string().nullable(),
11
+ visible: z.boolean(),
12
+ active: z.boolean(),
13
+ focused: z.boolean(),
14
+ hovered: z.boolean(),
15
+ value: z.unknown(),
16
+ extra: z.record(z.unknown()).default({}),
17
+ children: z.array(snapshotNodeSchema).default([]),
18
+ }));
19
+ export const slotSchema = z.object({
20
+ index: z.number(),
21
+ item: z.string().nullable(),
22
+ count: z.number(),
23
+ name: z.string().optional(),
24
+ x: z.number(),
25
+ y: z.number(),
26
+ hovered: z.boolean(),
27
+ });
28
+ export const containerSchema = z.object({
29
+ menuClass: z.string(),
30
+ leftPos: z.number(),
31
+ topPos: z.number(),
32
+ imageWidth: z.number(),
33
+ imageHeight: z.number(),
34
+ carried: z.object({ item: z.string().nullable(), count: z.number() }).passthrough(),
35
+ slots: z.array(slotSchema),
36
+ });
37
+ export const snapshotSchema = z.object({
38
+ screenClass: z.string().nullable(),
39
+ title: z.string().nullable(),
40
+ guiScale: z.number(),
41
+ guiWidth: z.number(),
42
+ guiHeight: z.number(),
43
+ pixelWidth: z.number(),
44
+ pixelHeight: z.number(),
45
+ mouse: z.array(z.number()),
46
+ focused: z.string().nullable().optional(),
47
+ hovered: z.string().nullable().optional(),
48
+ truncated: z.boolean().default(false),
49
+ container: containerSchema.nullable(),
50
+ root: snapshotNodeSchema.nullable(),
51
+ });
52
+ /** Depth-first walk, parents before children. */
53
+ export function walk(node, visit, depth = 0) {
54
+ visit(node, depth);
55
+ for (const child of node.children) {
56
+ walk(child, visit, depth + 1);
57
+ }
58
+ }
59
+ export function flatten(root) {
60
+ if (root === null) {
61
+ return [];
62
+ }
63
+ const all = [];
64
+ walk(root, (node, depth) => all.push({ node, depth }));
65
+ return all;
66
+ }
67
+ /** The point a click should target for a node. */
68
+ export function centre(node) {
69
+ if (node.bounds === null) {
70
+ return null;
71
+ }
72
+ return {
73
+ x: node.bounds.x + Math.floor(node.bounds.w / 2),
74
+ y: node.bounds.y + Math.floor(node.bounds.h / 2),
75
+ };
76
+ }
77
+ /** A short, human-meaningful label for a node: its message, else its narration, else nothing. */
78
+ export function label(node) {
79
+ if (node.message !== null && node.message.length > 0) {
80
+ return node.message;
81
+ }
82
+ if (node.narration !== null && node.narration.length > 0) {
83
+ return node.narration;
84
+ }
85
+ return '';
86
+ }
87
+ export function simpleType(node) {
88
+ const parts = node.type.split('.');
89
+ return parts[parts.length - 1] ?? node.type;
90
+ }
91
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/snapshot/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAkBrG,yFAAyF;AACzF,uDAAuD;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAmD,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC5F,CAAC,CAAC,MAAM,CAAC;IACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,M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,CAAC,SAAS,CAAC;IACxB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAkB;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { type Slot, type Snapshot, type SnapshotNode } from './model.js';
2
+ /**
3
+ * Renders a snapshot as one line per widget, indented by depth.
4
+ *
5
+ * This is the format an agent actually reads, so it is optimised for scanning: the type and label
6
+ * first, then the geometry it would need to click, then only the flags that are *not* the default.
7
+ * A line looks like:
8
+ *
9
+ * ```
10
+ * Button "Apply" @(312,208 60x20) disabled /root/children[3]
11
+ * ```
12
+ *
13
+ * The trailing path is what `click --widget` consumes, so an outline line can be copied verbatim.
14
+ */
15
+ export declare function formatOutline(snapshot: Snapshot, options?: {
16
+ includeHidden?: boolean;
17
+ }): string;
18
+ export declare function formatSlot(slot: Slot): string;
19
+ export declare function formatNode(node: SnapshotNode): string;
20
+ export interface Match {
21
+ readonly node: SnapshotNode;
22
+ readonly centre: {
23
+ x: number;
24
+ y: number;
25
+ } | null;
26
+ }
27
+ /**
28
+ * Finds nodes by label, by path, or by type.
29
+ *
30
+ * An exact path match wins outright, then an exact label match, then a case-insensitive
31
+ * substring match — so `click --widget Apply` picks the "Apply" button even on a screen that
32
+ * also has an "Apply to all" one.
33
+ */
34
+ export declare function findNodes(snapshot: Snapshot, query: string, typeFilter?: string): Match[];
35
+ //# sourceMappingURL=outline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/snapshot/outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAc,MAAM,YAAY,CAAC;AAE7G;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAmDnG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAI7C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAuCrD;AAYD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAClD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAwBzF"}