@openserv-labs/sdk 2.1.0 → 2.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.
- package/README.md +10 -6
- package/dist/run.d.ts +2 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +27 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -320,6 +320,7 @@ agent.start()
|
|
|
320
320
|
| `PORT` | Server port | No | 7378 |
|
|
321
321
|
| `OPENSERV_AUTH_TOKEN` | Token for authenticating incoming requests | No | - |
|
|
322
322
|
| `OPENSERV_PROXY_URL` | Custom proxy URL for tunnel connections | No | `https://agents-proxy.openserv.ai` |
|
|
323
|
+
| `DISABLE_TUNNEL` | Skip tunnel and run HTTP server only | No | - |
|
|
323
324
|
|
|
324
325
|
\*Required if using OpenAI integration features
|
|
325
326
|
|
|
@@ -794,12 +795,15 @@ The `run()` function automatically:
|
|
|
794
795
|
|
|
795
796
|
#### Tunnel vs. Deployed Endpoint
|
|
796
797
|
|
|
797
|
-
| Aspect | Tunnel (Local Development) | Deployed Endpoint (Production)
|
|
798
|
-
| ----------------- | -------------------------- |
|
|
799
|
-
| Setup | Just run your code | Deploy to cloud/server
|
|
800
|
-
| URL Configuration | Not needed | Set Agent Endpoint in platform
|
|
801
|
-
| Connection | WebSocket via proxy | Direct HTTP
|
|
802
|
-
|
|
|
798
|
+
| Aspect | Tunnel (Local Development) | Deployed Endpoint (Production) |
|
|
799
|
+
| ----------------- | -------------------------- | ------------------------------------ |
|
|
800
|
+
| Setup | Just run your code | Deploy to cloud/server |
|
|
801
|
+
| URL Configuration | Not needed | Set Agent Endpoint in platform |
|
|
802
|
+
| Connection | WebSocket via proxy | Direct HTTP |
|
|
803
|
+
| Tunnel | Enabled (default) | Disabled (`DISABLE_TUNNEL=true`) |
|
|
804
|
+
| Use case | Development & testing | Production |
|
|
805
|
+
|
|
806
|
+
When deploying to a hosting provider like Cloud Run, set `DISABLE_TUNNEL=true` as an environment variable. This makes `run()` start only the HTTP server without opening a WebSocket tunnel to the proxy — the platform reaches your agent directly at its public URL.
|
|
803
807
|
|
|
804
808
|
#### Configuration Options
|
|
805
809
|
|
package/dist/run.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export interface RunOptions {
|
|
|
15
15
|
export interface RunResult {
|
|
16
16
|
/**
|
|
17
17
|
* The tunnel instance for advanced control.
|
|
18
|
+
* Null when the tunnel is disabled (DISABLE_TUNNEL=true).
|
|
18
19
|
*/
|
|
19
|
-
tunnel: OpenServTunnel;
|
|
20
|
+
tunnel: OpenServTunnel | null;
|
|
20
21
|
/**
|
|
21
22
|
* Stop the agent and tunnel.
|
|
22
23
|
*/
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAMrE,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC,CAAA;IAE7E;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,SAAS;IACxB
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAMrE,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC,CAAA;IAE7E;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;IAE7B;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAsFhF"}
|
package/dist/run.js
CHANGED
|
@@ -40,27 +40,34 @@ const tunnel_1 = require("./tunnel");
|
|
|
40
40
|
*/
|
|
41
41
|
async function run(agent, options) {
|
|
42
42
|
await agent.start();
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
const tunnelDisabled = process.env.DISABLE_TUNNEL === 'true';
|
|
44
|
+
let tunnel = null;
|
|
45
|
+
if (!tunnelDisabled) {
|
|
46
|
+
tunnel = new tunnel_1.OpenServTunnel({
|
|
47
|
+
...options?.tunnel,
|
|
48
|
+
// Always use the agent's API key to ensure tunnel authenticates as the correct agent
|
|
49
|
+
// This prevents issues when running multiple agents with different API keys
|
|
50
|
+
apiKey: agent.apiKey,
|
|
51
|
+
onConnected: isReconnect => {
|
|
52
|
+
if (!isReconnect) {
|
|
53
|
+
logger_1.logger.info('Agent connected to OpenServ proxy');
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
onError: error => {
|
|
57
|
+
logger_1.logger.error(`Tunnel error: ${error.message}`);
|
|
51
58
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
});
|
|
60
|
+
try {
|
|
61
|
+
await tunnel.start(agent.port);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Clean up the agent if tunnel fails to connect
|
|
65
|
+
await agent.stop();
|
|
66
|
+
throw error;
|
|
55
67
|
}
|
|
56
|
-
});
|
|
57
|
-
try {
|
|
58
|
-
await tunnel.start(agent.port);
|
|
59
68
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
await agent.stop();
|
|
63
|
-
throw error;
|
|
69
|
+
else {
|
|
70
|
+
logger_1.logger.info(`Agent running on port ${agent.port} (tunnel disabled)`);
|
|
64
71
|
}
|
|
65
72
|
let shutdownPromise = null;
|
|
66
73
|
let sigtermHandler = null;
|
|
@@ -80,7 +87,8 @@ async function run(agent, options) {
|
|
|
80
87
|
process.removeListener('SIGINT', sigintHandler);
|
|
81
88
|
sigintHandler = null;
|
|
82
89
|
}
|
|
83
|
-
|
|
90
|
+
if (tunnel)
|
|
91
|
+
await tunnel.stop();
|
|
84
92
|
await agent.stop();
|
|
85
93
|
})();
|
|
86
94
|
return shutdownPromise;
|