@gtkx/mcp 1.0.0-rc.4 → 1.0.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.
package/README.md CHANGED
@@ -108,7 +108,7 @@ React Native and similar frameworks hide the native toolkit so one API can run e
108
108
 
109
109
  ### Why Node.js, and why generated bindings
110
110
 
111
- GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
111
+ GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers what running on Node.js means day to day.
112
112
 
113
113
  GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
114
114
 
@@ -121,10 +121,10 @@ GTKX is Linux-only and needs Node.js 24 or later. See [Requirements](#requiremen
121
121
  Scaffold a new app with the `create-gtkx` initializer:
122
122
 
123
123
  ```sh
124
- npm create gtkx@rc
124
+ npm create gtkx
125
125
  ```
126
126
 
127
- The same command works with other package managers: `pnpm create gtkx@rc` or `yarn create gtkx@rc`.
127
+ The same command works with other package managers: `pnpm create gtkx` or `yarn create gtkx`.
128
128
 
129
129
  Then run your new app:
130
130
 
@@ -145,7 +145,7 @@ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tu
145
145
 
146
146
  GTKX is Linux-only. You need:
147
147
 
148
- - Linux with the GTK4 (4.20 or later), Adwaita (1.8 or later), and GLib development libraries
148
+ - Linux with the GTK4 (4.20 or later) and GLib development libraries, plus Adwaita (1.8 or later) once your project binds `Adw-1`
149
149
  - Node.js 24 or later
150
150
 
151
151
  The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
@@ -161,7 +161,7 @@ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
161
161
 
162
162
  ## Status
163
163
 
164
- GTKX 1.0 is at the release candidate stage.
164
+ GTKX 1.0 is released.
165
165
 
166
166
  ## Contributing
167
167
 
@@ -1,4 +1,4 @@
1
- export { ErrorCode, invalidRequestError, methodNotFoundError, ProtocolError, widgetNotFoundError, } from "./protocol/errors.js";
2
- export { DEFAULT_SOCKET_PATH, type ParamsSchema, type Request, type SerializedWidget, type ServerInitiatedMethod, type ServerRequestParams, ServerRequestParamsSchemas, } from "./protocol/schemas.js";
1
+ export { ErrorCode, invalidRequestError, methodNotFoundError, ProtocolError, propertyNotFoundError, widgetNotFoundError, } from "./protocol/errors.js";
2
+ export { DEFAULT_SOCKET_PATH, DEFAULT_SUBTREE_DEPTH, MAX_SUBTREE_WIDGETS, type ParamsSchema, type Request, type SerializedProperty, type SerializedWidget, type ServerInitiatedMethod, type ServerRequestParams, ServerRequestParamsSchemas, } from "./protocol/schemas.js";
3
3
  export { ProtocolConnection } from "./transport.js";
4
4
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,0BAA0B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,0BAA0B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/internal.js CHANGED
@@ -1,4 +1,4 @@
1
- export { ErrorCode, invalidRequestError, methodNotFoundError, ProtocolError, widgetNotFoundError, } from "./protocol/errors.js";
2
- export { DEFAULT_SOCKET_PATH, ServerRequestParamsSchemas, } from "./protocol/schemas.js";
1
+ export { ErrorCode, invalidRequestError, methodNotFoundError, ProtocolError, propertyNotFoundError, widgetNotFoundError, } from "./protocol/errors.js";
2
+ export { DEFAULT_SOCKET_PATH, DEFAULT_SUBTREE_DEPTH, MAX_SUBTREE_WIDGETS, ServerRequestParamsSchemas, } from "./protocol/schemas.js";
3
3
  export { ProtocolConnection } from "./transport.js";
4
4
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,mBAAmB,EAMnB,0BAA0B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export {\n ErrorCode,\n invalidRequestError,\n methodNotFoundError,\n ProtocolError,\n widgetNotFoundError,\n} from \"./protocol/errors.js\";\nexport {\n DEFAULT_SOCKET_PATH,\n type ParamsSchema,\n type Request,\n type SerializedWidget,\n type ServerInitiatedMethod,\n type ServerRequestParams,\n ServerRequestParamsSchemas,\n} from \"./protocol/schemas.js\";\nexport { ProtocolConnection } from \"./transport.js\";\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EAOnB,0BAA0B,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export {\n ErrorCode,\n invalidRequestError,\n methodNotFoundError,\n ProtocolError,\n propertyNotFoundError,\n widgetNotFoundError,\n} from \"./protocol/errors.js\";\nexport {\n DEFAULT_SOCKET_PATH,\n DEFAULT_SUBTREE_DEPTH,\n MAX_SUBTREE_WIDGETS,\n type ParamsSchema,\n type Request,\n type SerializedProperty,\n type SerializedWidget,\n type ServerInitiatedMethod,\n type ServerRequestParams,\n ServerRequestParamsSchemas,\n} from \"./protocol/schemas.js\";\nexport { ProtocolConnection } from \"./transport.js\";\n"]}
@@ -8,12 +8,14 @@ declare const ErrorCode: {
8
8
  readonly REQUEST_TIMEOUT: 1005;
9
9
  readonly INVALID_REQUEST: 1006;
10
10
  readonly METHOD_NOT_FOUND: 1007;
11
+ readonly PROPERTY_NOT_FOUND: 1008;
11
12
  };
12
13
  declare function isErrorCode(code: number): code is ErrorCode;
13
14
  declare function noAppConnectedError(): ProtocolError;
14
15
  declare function appNotFoundError(applicationId: string): ProtocolError;
15
16
  declare function connectionWriteFailedError(applicationId: string): ProtocolError;
16
17
  declare function widgetNotFoundError(widgetId: string): ProtocolError;
18
+ declare function propertyNotFoundError(widgetType: string, property: string, readableProperties: string[]): ProtocolError;
17
19
  declare function requestTimeoutError(timeout: number): ProtocolError;
18
20
  declare function invalidRequestError(reason: string): ProtocolError;
19
21
  declare function methodNotFoundError(method: string): ProtocolError;
@@ -27,5 +29,5 @@ declare class ProtocolError extends Error {
27
29
  data?: unknown;
28
30
  };
29
31
  }
30
- export { ErrorCode, isErrorCode, noAppConnectedError, appNotFoundError, connectionWriteFailedError, widgetNotFoundError, requestTimeoutError, invalidRequestError, methodNotFoundError, ProtocolError, };
32
+ export { ErrorCode, isErrorCode, noAppConnectedError, appNotFoundError, connectionWriteFailedError, widgetNotFoundError, propertyNotFoundError, requestTimeoutError, invalidRequestError, methodNotFoundError, ProtocolError, };
31
33
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAE5D,QAAA,MAAM,SAAS;;;;;;;;;CASL,CAAC;AAEX,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAEpD;AAED,iBAAS,mBAAmB,IAAI,aAAa,CAM5C;AAED,iBAAS,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAE9D;AAED,iBAAS,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAMxE;AAED,iBAAS,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAE5D;AAED,iBAAS,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAE3D;AAED,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE1D;AAED,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,C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;AAED,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE1D;AAED,cAAM,aAAc,SAAQ,KAAK;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEH,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;IAO5D,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAOrE;AAED,OAAO,EACH,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GAChB,CAAC"}
@@ -7,6 +7,7 @@ const ErrorCode = {
7
7
  REQUEST_TIMEOUT: 1005,
8
8
  INVALID_REQUEST: 1006,
9
9
  METHOD_NOT_FOUND: 1007,
10
+ PROPERTY_NOT_FOUND: 1008,
10
11
  };
11
12
  function isErrorCode(code) {
12
13
  return Object.values(ErrorCode).includes(code);
@@ -23,6 +24,13 @@ function connectionWriteFailedError(applicationId) {
23
24
  function widgetNotFoundError(widgetId) {
24
25
  return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });
25
26
  }
27
+ function propertyNotFoundError(widgetType, property, readableProperties) {
28
+ return new ProtocolError(ErrorCode.PROPERTY_NOT_FOUND, `${widgetType} has no readable property '${property}'`, {
29
+ widgetType,
30
+ property,
31
+ hint: `Readable properties of ${widgetType}: ${readableProperties.join(", ")}`,
32
+ });
33
+ }
26
34
  function requestTimeoutError(timeout) {
27
35
  return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${String(timeout)}ms`, { timeout });
28
36
  }
@@ -49,5 +57,5 @@ class ProtocolError extends Error {
49
57
  };
50
58
  }
51
59
  }
52
- export { ErrorCode, isErrorCode, noAppConnectedError, appNotFoundError, connectionWriteFailedError, widgetNotFoundError, requestTimeoutError, invalidRequestError, methodNotFoundError, ProtocolError, };
60
+ export { ErrorCode, isErrorCode, noAppConnectedError, appNotFoundError, connectionWriteFailedError, widgetNotFoundError, propertyNotFoundError, requestTimeoutError, invalidRequestError, methodNotFoundError, ProtocolError, };
53
61
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG;IACd,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,IAAI;IACtB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,IAAI;IAC7B,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,IAAI;CAChB,CAAC;AAEX,SAAS,WAAW,CAAC,IAAY;IAC7B,OAAQ,MAAM,CAAC,MAAM,CAAC,SAAS,CAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,mBAAmB;IACxB,OAAO,IAAI,aAAa,CACpB,SAAS,CAAC,gBAAgB,EAC1B,wEAAwE,EACxE,EAAE,IAAI,EAAE,0CAA0C,EAAE,CACvD,CAAC;AACN,CAAC;AAED,SAAS,gBAAgB,CAAC,aAAqB;IAC3C,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,aAAa,aAAa,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;AACrH,CAAC;AAED,SAAS,0BAA0B,CAAC,aAAqB;IACrD,OAAO,IAAI,aAAa,CACpB,SAAS,CAAC,uBAAuB,EACjC,8BAA8B,aAAa,yBAAyB,EACpE,EAAE,aAAa,EAAE,CACpB,CAAC;AACN,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IACzC,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AAmB,EACnB,aAAa,GAChB,CAAC","sourcesContent":["type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst ErrorCode = {\n INTERNAL_ERROR: 1000,\n NO_APP_CONNECTED: 1001,\n APP_NOT_FOUND: 1002,\n WIDGET_NOT_FOUND: 1003,\n CONNECTION_WRITE_FAILED: 1004,\n REQUEST_TIMEOUT: 1005,\n INVALID_REQUEST: 1006,\n METHOD_NOT_FOUND: 1007,\n} as const;\n\nfunction isErrorCode(code: number): code is ErrorCode {\n return (Object.values(ErrorCode) as number[]).includes(code);\n}\n\nfunction noAppConnectedError(): ProtocolError {\n return new ProtocolError(\n ErrorCode.NO_APP_CONNECTED,\n \"No GTKX application connected: start an app with 'gtkx dev' to connect\",\n { hint: \"Run 'gtkx dev' in your project directory\" },\n );\n}\n\nfunction appNotFoundError(applicationId: string): ProtocolError {\n return new ProtocolError(ErrorCode.APP_NOT_FOUND, `Application '${applicationId}' not found`, { applicationId });\n}\n\nfunction connectionWriteFailedError(applicationId: string): ProtocolError {\n return new ProtocolError(\n ErrorCode.CONNECTION_WRITE_FAILED,\n `Connection to application '${applicationId}' is no longer writable`,\n { applicationId },\n );\n}\n\nfunction widgetNotFoundError(widgetId: string): ProtocolError {\n return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });\n}\n\nfunction requestTimeoutError(timeout: number): ProtocolError {\n return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${String(timeout)}ms`, { timeout });\n}\n\nfunction invalidRequestError(reason: string): ProtocolError {\n return new ProtocolError(ErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });\n}\n\nfunction methodNotFoundError(method: string): ProtocolError {\n return new ProtocolError(ErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });\n}\n\nclass ProtocolError extends Error {\n code: ErrorCode;\n data?: unknown;\n\n constructor(code: ErrorCode, message: string, data?: unknown) {\n super(message);\n this.code = code;\n this.data = data;\n this.name = \"ProtocolError\";\n }\n\n toErrorObject(): { code: number; message: string; data?: unknown } {\n return {\n code: this.code,\n message: this.message,\n ...(this.data !== undefined && { data: this.data }),\n };\n }\n}\n\nexport {\n ErrorCode,\n isErrorCode,\n noAppConnectedError,\n appNotFoundError,\n connectionWriteFailedError,\n widgetNotFoundError,\n requestTimeoutError,\n invalidRequestError,\n methodNotFoundError,\n ProtocolError,\n};\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG;IACd,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,IAAI;IACtB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,IAAI;IAC7B,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;CAClB,CAAC;AAEX,SAAS,WAAW,CAAC,IAAY;IAC7B,OAAQ,MAAM,CAAC,MAAM,CAAC,SAAS,CAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,mBAAmB;IACxB,OAAO,IAAI,aAAa,CACpB,SAAS,CAAC,gBAAgB,EAC1B,wEAAwE,EACxE,EAAE,IAAI,EAAE,0CAA0C,EAAE,CACvD,CAAC;AACN,CAAC;AAED,SAAS,gBAAgB,CAAC,aAAqB;IAC3C,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,aAAa,aAAa,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;AACrH,CAAC;AAED,SAAS,0BAA0B,CAAC,aAAqB;IACrD,OAAO,IAAI,aAAa,CACpB,SAAS,CAAC,uBAAuB,EACjC,8BAA8B,aAAa,yBAAyB,EACpE,EAAE,aAAa,EAAE,CACpB,CAAC;AACN,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC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I;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;SACtD,CAAC;IACN,CAAC;CACJ;AAED,OAAO,EACH,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GAChB,CAAC","sourcesContent":["type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst ErrorCode = {\n INTERNAL_ERROR: 1000,\n NO_APP_CONNECTED: 1001,\n APP_NOT_FOUND: 1002,\n WIDGET_NOT_FOUND: 1003,\n CONNECTION_WRITE_FAILED: 1004,\n REQUEST_TIMEOUT: 1005,\n INVALID_REQUEST: 1006,\n METHOD_NOT_FOUND: 1007,\n PROPERTY_NOT_FOUND: 1008,\n} as const;\n\nfunction isErrorCode(code: number): code is ErrorCode {\n return (Object.values(ErrorCode) as number[]).includes(code);\n}\n\nfunction noAppConnectedError(): ProtocolError {\n return new ProtocolError(\n ErrorCode.NO_APP_CONNECTED,\n \"No GTKX application connected: start an app with 'gtkx dev' to connect\",\n { hint: \"Run 'gtkx dev' in your project directory\" },\n );\n}\n\nfunction appNotFoundError(applicationId: string): ProtocolError {\n return new ProtocolError(ErrorCode.APP_NOT_FOUND, `Application '${applicationId}' not found`, { applicationId });\n}\n\nfunction connectionWriteFailedError(applicationId: string): ProtocolError {\n return new ProtocolError(\n ErrorCode.CONNECTION_WRITE_FAILED,\n `Connection to application '${applicationId}' is no longer writable`,\n { applicationId },\n );\n}\n\nfunction widgetNotFoundError(widgetId: string): ProtocolError {\n return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });\n}\n\nfunction propertyNotFoundError(widgetType: string, property: string, readableProperties: string[]): ProtocolError {\n return new ProtocolError(\n ErrorCode.PROPERTY_NOT_FOUND,\n `${widgetType} has no readable property '${property}'`,\n {\n widgetType,\n property,\n hint: `Readable properties of ${widgetType}: ${readableProperties.join(\", \")}`,\n },\n );\n}\n\nfunction requestTimeoutError(timeout: number): ProtocolError {\n return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${String(timeout)}ms`, { timeout });\n}\n\nfunction invalidRequestError(reason: string): ProtocolError {\n return new ProtocolError(ErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });\n}\n\nfunction methodNotFoundError(method: string): ProtocolError {\n return new ProtocolError(ErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });\n}\n\nclass ProtocolError extends Error {\n code: ErrorCode;\n data?: unknown;\n\n constructor(code: ErrorCode, message: string, data?: unknown) {\n super(message);\n this.code = code;\n this.data = data;\n this.name = \"ProtocolError\";\n }\n\n toErrorObject(): { code: number; message: string; data?: unknown } {\n return {\n code: this.code,\n message: this.message,\n ...(this.data !== undefined && { data: this.data }),\n };\n }\n}\n\nexport {\n ErrorCode,\n isErrorCode,\n noAppConnectedError,\n appNotFoundError,\n connectionWriteFailedError,\n widgetNotFoundError,\n propertyNotFoundError,\n requestTimeoutError,\n invalidRequestError,\n methodNotFoundError,\n ProtocolError,\n};\n"]}
@@ -11,6 +11,13 @@ type SerializedWidget = {
11
11
  isVisible: boolean;
12
12
  cssClasses: string[];
13
13
  children: SerializedWidget[];
14
+ hiddenChildren?: number;
15
+ };
16
+ type SerializedProperty = {
17
+ type: string;
18
+ value: string | number | boolean | string[] | null;
19
+ widgetId?: string;
20
+ note?: string;
14
21
  };
15
22
  type AppInfo = {
16
23
  applicationId: string;
@@ -45,6 +52,13 @@ declare const emptyParams: z.ZodObject<Record<string, never>>;
45
52
  declare const widgetIdParams: z.ZodObject<{
46
53
  widgetId: z.ZodString;
47
54
  }>;
55
+ declare const DEFAULT_SUBTREE_DEPTH = 8;
56
+ declare const MAX_SUBTREE_WIDGETS = 30;
57
+ declare const widgetPropsParams: z.ZodObject<{
58
+ widgetId: z.ZodString;
59
+ properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ maxDepth: z.ZodOptional<z.ZodNumber>;
61
+ }>;
48
62
  declare const treeParams: z.ZodObject<{
49
63
  rootId: z.ZodOptional<z.ZodString>;
50
64
  maxDepth: z.ZodOptional<z.ZodNumber>;
@@ -82,12 +96,12 @@ declare const ServerRequestParamsSchemas: {
82
96
  "app.getWindows": typeof emptyParams;
83
97
  "widget.getTree": typeof treeParams;
84
98
  "widget.query": typeof queryParams;
85
- "widget.getProps": typeof widgetIdParams;
99
+ "widget.getProps": typeof widgetPropsParams;
86
100
  "widget.click": typeof widgetIdParams;
87
101
  "widget.type": typeof typeParams;
88
102
  "widget.fireEvent": typeof fireEventParams;
89
103
  "widget.screenshot": typeof screenshotParams;
90
104
  };
91
105
  declare const DEFAULT_SOCKET_PATH: string;
92
- export { RequestSchema, ResponseSchema, RegisterParamsSchema, widgetIdParams, treeParams, queryOptionsSchema, queryParams, typeParams, fireEventParams, screenshotParams, ServerRequestParamsSchemas, DEFAULT_SOCKET_PATH, type Request, type Response, type SerializedWidget, type AppInfo, type ServerRequestParams, type ParamsSchema, type ServerInitiatedMethod, type Message, };
106
+ export { DEFAULT_SUBTREE_DEPTH, MAX_SUBTREE_WIDGETS, RequestSchema, ResponseSchema, RegisterParamsSchema, widgetIdParams, widgetPropsParams, treeParams, queryParams, typeParams, fireEventParams, screenshotParams, ServerRequestParamsSchemas, DEFAULT_SOCKET_PATH, type Request, type Response, type SerializedWidget, type SerializedProperty, type AppInfo, type ServerRequestParams, type ParamsSchema, type ServerInitiatedMethod, type Message, };
93
107
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,OA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
  widgetId: z.string(),
27
27
  });
28
+ const DEFAULT_SUBTREE_DEPTH = 8;
29
+ const MAX_SUBTREE_WIDGETS = 30;
30
+ const widgetPropsParams = z.object({
31
+ widgetId: z.string(),
32
+ properties: z.array(z.string()).optional(),
33
+ maxDepth: z.number().int().nonnegative().optional(),
34
+ });
28
35
  const treeParams = z.object({
29
36
  rootId: z.string().optional(),
30
- maxDepth: z.number().int().positive().optional(),
37
+ maxDepth: z.number().int().nonnegative().optional(),
31
38
  });
32
39
  const queryOptionsSchema = z.object({
33
40
  name: z.string().optional(),
@@ -49,7 +56,7 @@ const ServerRequestParamsSchemas = {
49
56
  "app.getWindows": emptyParams,
50
57
  "widget.getTree": treeParams,
51
58
  "widget.query": queryParams,
52
- "widget.getProps": widgetIdParams,
59
+ "widget.getProps": widgetPropsParams,
53
60
  "widget.click": widgetIdParams,
54
61
  "widget.type": typeParams,
55
62
  "widget.fireEvent": fireEventParams,
@@ -59,5 +66,5 @@ const DEFAULT_SOCKET_PATH = join(getRuntimeDir(), "gtkx-mcp.sock");
59
66
  function getRuntimeDir() {
60
67
  return process.env.XDG_RUNTIME_DIR ?? tmpdir();
61
68
  }
62
- export { RequestSchema, ResponseSchema, RegisterParamsSchema, widgetIdParams, treeParams, queryOptionsSchema, queryParams, typeParams, fireEventParams, screenshotParams, ServerRequestParamsSchemas, DEFAULT_SOCKET_PATH, };
69
+ export { DEFAULT_SUBTREE_DEPTH, MAX_SUBTREE_WIDGETS, RequestSchema, ResponseSchema, RegisterParamsSchema, widgetIdParams, widgetPropsParams, treeParams, queryParams, typeParams, fireEventParams, screenshotParams, ServerRequestParamsSchemas, DEFAULT_SOCKET_PATH, };
63
70
  //# sourceMappingURL=schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAA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,EAAE;IAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAS5B;IACA,gBAAgB,EAAE,WAAW;IAC7B,gBAAgB,EAAE,UAAU;IAC5B,cAAc,EAAE,WAAW;IAC3B,iBAAiB,EAAE,cAAc;IACjC,cAAc,EAAE,cAAc;IAC9B,aAAa,EAAE,UAAU;IACzB,kBAAkB,EAAE,eAAe;IACnC,mBAAmB,EAAE,gBAAgB;CACxC,CAAC;AAEF,MAAM,mBAAmB,GAAW,IAAI,CAAC,aAAa,EAAE,EAAE,eAAe,CAAC,CAAC;AAE3E,SAAS,aAAa;IAClB,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,MAAM,EAAE,CAAC;AACnD,CAAC;AAED,OAAO,EACH,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,GAStB,CAAC","sourcesContent":["import { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\n\ntype Request = z.infer<typeof RequestSchema>;\ntype Response = z.infer<typeof ResponseSchema>;\n\ntype SerializedWidget = {\n id: string;\n type: string;\n role: string;\n name: string | null;\n text: string | null;\n isSensitive: boolean;\n isVisible: boolean;\n cssClasses: string[];\n children: SerializedWidget[];\n};\n\ntype AppInfo = {\n applicationId: string;\n pid: number;\n projectRoot?: string;\n};\n\ntype ServerRequestParams<Method extends keyof typeof ServerRequestParamsSchemas> = z.infer<\n (typeof ServerRequestParamsSchemas)[Method]\n>;\n\ntype ParamsSchema<Output> = z.ZodType<Output>;\ntype ServerInitiatedMethod = keyof typeof ServerRequestParamsSchemas;\ntype Message = Request | Response;\n\nconst RequestSchema: z.ZodObject<\n {\n id: z.ZodString;\n method: z.ZodString;\n params: z.ZodOptional<z.ZodUnknown>;\n }\n> = z.object({\n id: z.string(),\n method: z.string(),\n params: z.unknown().optional(),\n});\n\nconst ErrorSchema: z.ZodObject<\n { code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional<z.ZodUnknown> }\n> = z.object({\n code: z.number(),\n message: z.string(),\n data: z.unknown().optional(),\n});\n\nconst ResponseSchema: z.ZodObject<\n {\n id: z.ZodString;\n result: z.ZodOptional<z.ZodUnknown>;\n error: z.ZodOptional<typeof ErrorSchema>;\n }\n> = z.object({\n id: z.string(),\n result: z.unknown().optional(),\n error: ErrorSchema.optional(),\n});\n\nconst RegisterParamsSchema: z.ZodObject<\n {\n applicationId: z.ZodString;\n pid: z.ZodNumber;\n projectRoot: z.ZodOptional<z.ZodString>;\n }\n> = z.object({\n applicationId: z.string(),\n pid: z.number(),\n projectRoot: z.string().optional(),\n});\n\nconst emptyParams: z.ZodObject<Record<string, never>> = z.object({});\n\nconst widgetIdParams: z.ZodObject<{ widgetId: z.ZodString }> = z.object({\n widgetId: z.string(),\n});\n\nconst treeParams: z.ZodObject<\n { rootId: z.ZodOptional<z.ZodString>; maxDepth: z.ZodOptional<z.ZodNumber> }\n> = z.object({\n rootId: z.string().optional(),\n maxDepth: z.number().int().positive().optional(),\n});\n\nconst queryOptionsSchema: z.ZodObject<\n { name: z.ZodOptional<z.ZodString>; exact: z.ZodOptional<z.ZodBoolean>; timeout: z.ZodOptional<z.ZodNumber> }\n> = z.object({\n name: z.string().optional(),\n exact: z.boolean().optional(),\n timeout: z.number().optional(),\n});\n\nconst queryParams: z.ZodObject<\n {\n by: z.ZodEnum<{ role: \"role\"; text: \"text\"; name: \"name\"; labelText: \"labelText\" }>;\n value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;\n options: z.ZodOptional<typeof queryOptionsSchema>;\n }\n> = z.object({\n by: z.enum([\"role\", \"text\", \"name\", \"labelText\"]),\n value: z.union([z.string(), z.number()]),\n options: queryOptionsSchema.optional(),\n});\n\nconst typeParams: z.ZodObject<\n { widgetId: z.ZodString; text: z.ZodString; clear: z.ZodOptional<z.ZodBoolean> }\n> = z.object({ widgetId: z.string(), text: z.string(), clear: z.boolean().optional() });\n\nconst fireEventParams: z.ZodObject<\n { widgetId: z.ZodString; signal: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodUnknown>> }\n> = z.object({ widgetId: z.string(), signal: z.string(), args: z.array(z.unknown()).optional() });\n\nconst screenshotParams: z.ZodObject<\n { windowId: z.ZodOptional<z.ZodString>; path: z.ZodOptional<z.ZodString> }\n> = z.object({\n windowId: z.string().optional(),\n path: z.string().optional(),\n});\n\nconst ServerRequestParamsSchemas: {\n \"app.getWindows\": typeof emptyParams;\n \"widget.getTree\": typeof treeParams;\n \"widget.query\": typeof queryParams;\n \"widget.getProps\": typeof widgetIdParams;\n \"widget.click\": typeof widgetIdParams;\n \"widget.type\": typeof typeParams;\n \"widget.fireEvent\": typeof fireEventParams;\n \"widget.screenshot\": typeof screenshotParams;\n} = {\n \"app.getWindows\": emptyParams,\n \"widget.getTree\": treeParams,\n \"widget.query\": queryParams,\n \"widget.getProps\": widgetIdParams,\n \"widget.click\": widgetIdParams,\n \"widget.type\": typeParams,\n \"widget.fireEvent\": fireEventParams,\n \"widget.screenshot\": screenshotParams,\n};\n\nconst DEFAULT_SOCKET_PATH: string = join(getRuntimeDir(), \"gtkx-mcp.sock\");\n\nfunction getRuntimeDir(): string {\n return process.env.XDG_RUNTIME_DIR ?? tmpdir();\n}\n\nexport {\n RequestSchema,\n ResponseSchema,\n RegisterParamsSchema,\n widgetIdParams,\n treeParams,\n queryOptionsSchema,\n queryParams,\n typeParams,\n fireEventParams,\n screenshotParams,\n ServerRequestParamsSchemas,\n DEFAULT_SOCKET_PATH,\n type Request,\n type Response,\n type SerializedWidget,\n type AppInfo,\n type ServerRequestParams,\n type ParamsSchema,\n type ServerInitiatedMethod,\n type Message,\n};\n"]}
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],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nimport { z } from \"zod\";\n\ntype Request = z.infer<typeof RequestSchema>;\ntype Response = z.infer<typeof ResponseSchema>;\n\ntype SerializedWidget = {\n id: string;\n type: string;\n role: string;\n name: string | null;\n text: string | null;\n isSensitive: boolean;\n isVisible: boolean;\n cssClasses: string[];\n children: SerializedWidget[];\n hiddenChildren?: number;\n};\n\ntype SerializedProperty = {\n type: string;\n value: string | number | boolean | string[] | null;\n widgetId?: string;\n note?: string;\n};\n\ntype AppInfo = {\n applicationId: string;\n pid: number;\n projectRoot?: string;\n};\n\ntype ServerRequestParams<Method extends keyof typeof ServerRequestParamsSchemas> = z.infer<\n (typeof ServerRequestParamsSchemas)[Method]\n>;\n\ntype ParamsSchema<Output> = z.ZodType<Output>;\ntype ServerInitiatedMethod = keyof typeof ServerRequestParamsSchemas;\ntype Message = Request | Response;\n\nconst RequestSchema: z.ZodObject<\n {\n id: z.ZodString;\n method: z.ZodString;\n params: z.ZodOptional<z.ZodUnknown>;\n }\n> = z.object({\n id: z.string(),\n method: z.string(),\n params: z.unknown().optional(),\n});\n\nconst ErrorSchema: z.ZodObject<\n { code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional<z.ZodUnknown> }\n> = z.object({\n code: z.number(),\n message: z.string(),\n data: z.unknown().optional(),\n});\n\nconst ResponseSchema: z.ZodObject<\n {\n id: z.ZodString;\n result: z.ZodOptional<z.ZodUnknown>;\n error: z.ZodOptional<typeof ErrorSchema>;\n }\n> = z.object({\n id: z.string(),\n result: z.unknown().optional(),\n error: ErrorSchema.optional(),\n});\n\nconst RegisterParamsSchema: z.ZodObject<\n {\n applicationId: z.ZodString;\n pid: z.ZodNumber;\n projectRoot: z.ZodOptional<z.ZodString>;\n }\n> = z.object({\n applicationId: z.string(),\n pid: z.number(),\n projectRoot: z.string().optional(),\n});\n\nconst emptyParams: z.ZodObject<Record<string, never>> = z.object({});\n\nconst widgetIdParams: z.ZodObject<{ widgetId: z.ZodString }> = z.object({\n widgetId: z.string(),\n});\n\nconst DEFAULT_SUBTREE_DEPTH = 8;\nconst MAX_SUBTREE_WIDGETS = 30;\n\nconst widgetPropsParams: z.ZodObject<\n {\n widgetId: z.ZodString;\n properties: z.ZodOptional<z.ZodArray<z.ZodString>>;\n maxDepth: z.ZodOptional<z.ZodNumber>;\n }\n> = z.object({\n widgetId: z.string(),\n properties: z.array(z.string()).optional(),\n maxDepth: z.number().int().nonnegative().optional(),\n});\n\nconst treeParams: z.ZodObject<\n { rootId: z.ZodOptional<z.ZodString>; maxDepth: z.ZodOptional<z.ZodNumber> }\n> = z.object({\n rootId: z.string().optional(),\n maxDepth: z.number().int().nonnegative().optional(),\n});\n\nconst queryOptionsSchema: z.ZodObject<\n { name: z.ZodOptional<z.ZodString>; exact: z.ZodOptional<z.ZodBoolean>; timeout: z.ZodOptional<z.ZodNumber> }\n> = z.object({\n name: z.string().optional(),\n exact: z.boolean().optional(),\n timeout: z.number().optional(),\n});\n\nconst queryParams: z.ZodObject<\n {\n by: z.ZodEnum<{ role: \"role\"; text: \"text\"; name: \"name\"; labelText: \"labelText\" }>;\n value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;\n options: z.ZodOptional<typeof queryOptionsSchema>;\n }\n> = z.object({\n by: z.enum([\"role\", \"text\", \"name\", \"labelText\"]),\n value: z.union([z.string(), z.number()]),\n options: queryOptionsSchema.optional(),\n});\n\nconst typeParams: z.ZodObject<\n { widgetId: z.ZodString; text: z.ZodString; clear: z.ZodOptional<z.ZodBoolean> }\n> = z.object({ widgetId: z.string(), text: z.string(), clear: z.boolean().optional() });\n\nconst fireEventParams: z.ZodObject<\n { widgetId: z.ZodString; signal: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodUnknown>> }\n> = z.object({ widgetId: z.string(), signal: z.string(), args: z.array(z.unknown()).optional() });\n\nconst screenshotParams: z.ZodObject<\n { windowId: z.ZodOptional<z.ZodString>; path: z.ZodOptional<z.ZodString> }\n> = z.object({\n windowId: z.string().optional(),\n path: z.string().optional(),\n});\n\nconst ServerRequestParamsSchemas: {\n \"app.getWindows\": typeof emptyParams;\n \"widget.getTree\": typeof treeParams;\n \"widget.query\": typeof queryParams;\n \"widget.getProps\": typeof widgetPropsParams;\n \"widget.click\": typeof widgetIdParams;\n \"widget.type\": typeof typeParams;\n \"widget.fireEvent\": typeof fireEventParams;\n \"widget.screenshot\": typeof screenshotParams;\n} = {\n \"app.getWindows\": emptyParams,\n \"widget.getTree\": treeParams,\n \"widget.query\": queryParams,\n \"widget.getProps\": widgetPropsParams,\n \"widget.click\": widgetIdParams,\n \"widget.type\": typeParams,\n \"widget.fireEvent\": fireEventParams,\n \"widget.screenshot\": screenshotParams,\n};\n\nconst DEFAULT_SOCKET_PATH: string = join(getRuntimeDir(), \"gtkx-mcp.sock\");\n\nfunction getRuntimeDir(): string {\n return process.env.XDG_RUNTIME_DIR ?? tmpdir();\n}\n\nexport {\n DEFAULT_SUBTREE_DEPTH,\n MAX_SUBTREE_WIDGETS,\n RequestSchema,\n ResponseSchema,\n RegisterParamsSchema,\n widgetIdParams,\n widgetPropsParams,\n treeParams,\n queryParams,\n typeParams,\n fireEventParams,\n screenshotParams,\n ServerRequestParamsSchemas,\n DEFAULT_SOCKET_PATH,\n type Request,\n type Response,\n type SerializedWidget,\n type SerializedProperty,\n type AppInfo,\n type ServerRequestParams,\n type ParamsSchema,\n type ServerInitiatedMethod,\n type Message,\n};\n"]}
@@ -2,12 +2,26 @@ import { type ApiReference } from "@gtkx/codegen";
2
2
  import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { type Tool } from "./tool.js";
4
4
  type ReferenceApi = Pick<ApiReference, "lookup" | "namespaceOverview" | "namespaces" | "overview" | "search" | "symbolNames">;
5
+ type ProjectSource = "argument" | "workingDirectory" | "app";
6
+ type ResolvedProject = {
7
+ root: string;
8
+ source: ProjectSource;
9
+ };
10
+ type ScopedReference = ResolvedProject & {
11
+ reference: ReferenceApi;
12
+ };
13
+ type ReferenceProviderOptions = {
14
+ getAppRoot: () => string | undefined;
15
+ getWorkingDirectory?: () => string;
16
+ };
5
17
  type ReferenceProvider = {
6
- get(): Promise<ReferenceApi>;
18
+ get(projectRoot?: string): Promise<ScopedReference>;
19
+ load(project: ResolvedProject): Promise<ScopedReference>;
20
+ resolve(projectRoot?: string): ResolvedProject;
7
21
  };
8
22
  type ResourceServer = Pick<McpServer, "registerResource">;
9
- declare const createReferenceProvider: (resolveRoot: () => string) => ReferenceProvider;
23
+ declare const createReferenceProvider: (options: ReferenceProviderOptions) => ReferenceProvider;
10
24
  declare const buildReferenceTools: (provider: ReferenceProvider) => Tool[];
11
25
  declare const registerReferenceResources: (server: ResourceServer, provider: ReferenceProvider) => void;
12
- export { createReferenceProvider, buildReferenceTools, registerReferenceResources, type ReferenceApi, type ReferenceProvider, };
26
+ export { createReferenceProvider, buildReferenceTools, registerReferenceResources, type ReferenceApi, type ReferenceProvider, type ResolvedProject, };
13
27
  //# sourceMappingURL=reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAsE,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAK3F,OAAO,EAAsC,KAAK,IAAI,EAAiB,MAAM,WAAW,CAAC;AAEzF,KAAK,YAAY,GAAG,IAAI,CACpB,YAAY,EACZ,QAAQ,GAAG,mBAAmB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CACxF,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACrB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC,CAAC;AAqBF,KAAK,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAsI1D,QAAA,MAAM,uBAAuB,GAAI,aAAa,MAAM,MAAM,KAAG,iBAM5D,CAAC;AAwGF,QAAA,MAAM,mBAA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