@grackle-ai/server 0.74.1 → 0.75.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.
@@ -1,27 +1,24 @@
1
1
  import { WebSocketServer, WebSocket } from "ws";
2
2
  import type { Server as HttpServer } from "node:http";
3
3
  import { taskStore } from "@grackle-ai/database";
4
- /** Options for {@link createWsBridge}. */
5
- export interface WsBridgeOptions {
6
- /** Verify a Bearer-token API key. */
7
- verifyApiKey: (token: string) => boolean;
8
- /** Verify a session cookie. */
9
- validateCookie?: (cookieHeader: string) => boolean;
10
- /** The port the web/WS server is listening on (used for origin validation). */
11
- webPort: number;
12
- /** Whether the server is bound to a wildcard address (`--allow-network`). */
13
- allowNetwork: boolean;
14
- }
15
4
  /**
16
- * Check whether a WebSocket connection's Origin header is acceptable.
5
+ * Check whether a WebSocket Origin header is allowed.
17
6
  *
18
- * - If no Origin is present (CLI/SDK clients), the connection is allowed.
19
- * - If Origin is present, it must target the expected web port.
20
- * - In local mode the Origin hostname must be a loopback address.
21
- * - In network mode (`--allow-network`) any hostname on the correct port is accepted.
7
+ * Rules:
8
+ * - Missing origin (non-browser clients, extensions) always allowed
9
+ * - Origin port must match the web server port
10
+ * - In local mode (`allowNetwork === false`), hostname must be loopback
11
+ * - In network mode (`allowNetwork === true`), any hostname on the right port is allowed
22
12
  */
23
13
  export declare function isAllowedOrigin(origin: string | undefined, webPort: number, allowNetwork: boolean): boolean;
24
- /** Create a WebSocket server on top of an HTTP server that bridges JSON messages to gRPC operations. */
14
+ /** Options for creating the WebSocket bridge. */
15
+ interface WsBridgeOptions {
16
+ verifyApiKey: (token: string) => boolean;
17
+ validateCookie?: (cookieHeader: string) => boolean;
18
+ webPort?: number;
19
+ allowNetwork?: boolean;
20
+ }
21
+ /** Create a WebSocket server on top of an HTTP server for real-time event streaming. */
25
22
  export declare function createWsBridge(httpServer: HttpServer, options: WsBridgeOptions): WebSocketServer;
26
23
  /** Start a new agent session for a task. Returns an error message string on failure, undefined on success. */
27
24
  export declare function startTaskSession(ws: WebSocket | undefined, task: taskStore.TaskRow, options?: {
@@ -29,4 +26,5 @@ export declare function startTaskSession(ws: WebSocket | undefined, task: taskSt
29
26
  environmentId?: string;
30
27
  notes?: string;
31
28
  }): Promise<string | undefined>;
29
+ export {};
32
30
  //# sourceMappingURL=ws-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ws-bridge.d.ts","sourceRoot":"","sources":["../src/ws-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAItD,OAAO,EAA8E,SAAS,EAA4G,MAAM,sBAAsB,CAAC;AAuEvO,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,+BAA+B;IAC/B,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;IACnD,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,GACpB,OAAO,CAyBT;AAED,wGAAwG;AACxG,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,eAAe,GACvB,eAAe,CAiDjB;AA6HD,8GAA8G;AAC9G,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,SAAS,GAAG,SAAS,EACzB,IAAI,EAAE,SAAS,CAAC,OAAO,EACvB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAA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