@journal.one/gateway-client 0.1.0 → 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.
Files changed (2) hide show
  1. package/README.md +66 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @journal.one/gateway-client
2
+
3
+ TypeScript client library for the Journal Gateway protocol. Runs a WebSocket server that gateways connect to, authenticates them, auto-pulls their tools and skills, and lets you call tools.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @journal.one/gateway-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { GatewayServer } from "@journal.one/gateway-client";
15
+
16
+ const server = new GatewayServer({
17
+ port: 8080,
18
+ validateToken: async (token) => {
19
+ // Return { organizationId } on success, null on failure
20
+ if (token === "gw_valid") return { organizationId: "org_123" };
21
+ return null;
22
+ },
23
+ });
24
+
25
+ server.onGatewayConnected = (gateway) => {
26
+ console.log("Gateway connected:", gateway.id);
27
+ console.log("Tools:", gateway.integrations);
28
+ };
29
+
30
+ server.onGatewayUpdated = (gateway) => {
31
+ console.log("Gateway tools/skills changed:", gateway.id);
32
+ };
33
+
34
+ server.onGatewayDisconnected = (gateway) => {
35
+ console.log("Gateway disconnected:", gateway.id);
36
+ };
37
+
38
+ await server.start();
39
+
40
+ // Call a tool on a connected gateway
41
+ const result = await server.callTool("postgresql", "query", {
42
+ sql: "SELECT 1",
43
+ });
44
+ ```
45
+
46
+ ## Key APIs
47
+
48
+ - **`start()` / `stop()`** — lifecycle
49
+ - **`callTool(integrationId, toolName, args)`** — execute a tool call on any gateway that provides the integration
50
+ - **`callToolForOrg(orgId, integrationId, toolName, args)`** — same, scoped to an organization with automatic load balancing
51
+ - **`getToolsForOrg(orgId)`** — list deduplicated tools across all gateways for an org
52
+ - **`connectedGateways`** — all currently connected gateways
53
+
54
+ ## Callbacks
55
+
56
+ - **`onGatewayConnected`** — fired after a gateway authenticates and its initial tools/skills are pulled
57
+ - **`onGatewayUpdated`** — fired when a gateway's tools or skills change at runtime
58
+ - **`onGatewayDisconnected`** — fired when a gateway disconnects
59
+
60
+ ## Full documentation
61
+
62
+ See the [root README](https://github.com/journal-ai/journal-edge#readme) for protocol details, gateway configuration, and architecture.
63
+
64
+ ## License
65
+
66
+ MIT
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@journal.one/gateway-client",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "main": "./dist/server.js",
6
7
  "types": "./dist/server.d.ts",
@@ -19,7 +20,7 @@
19
20
  "dependencies": {
20
21
  "ws": "^8",
21
22
  "zod": "^3.24",
22
- "@journal.one/gateway-protocol": "0.1.0"
23
+ "@journal.one/gateway-protocol": "0.2.0"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@types/node": "^22",